{"name":"rc-form","version":"2.2.4","description":"React High Order Form Component","keywords":["react","react-component","react-form","form"],"homepage":"https://github.com/react-component/form","author":{"name":"yiminghe@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/react-component/form.git"},"bugs":{"url":"https://github.com/react-component/form/issues"},"license":"MIT","main":"./lib/index","module":"./es/index","config":{"port":8000,"entry":{"rc-form":["./scripts/index.js"]}},"scripts":{"build":"rc-tools run build","compile":"rc-tools run compile --babel-runtime","gh-pages":"rc-tools run gh-pages","start":"rc-tools run server","pub":"rc-tools run pub --babel-runtime","lint":"rc-tools run lint","lint:fix":"rc-tools run lint --fix","test":"jest","prepublish":"rc-tools run guard","coverage":"jest --coverage"},"jest":{"setupFiles":["./tests/setup.js"],"collectCoverageFrom":["src/**/*"],"snapshotSerializers":["enzyme-to-json/serializer"],"transform":{"\\.jsx?$":"./node_modules/rc-tools/scripts/jestPreprocessor.js"}},"devDependencies":{"antd":"2.x","async":"^1.5.2","enzyme":"^3.1.0","enzyme-adapter-react-16":"^1.0.2","enzyme-to-json":"^3.1.4","jest":"^21.2.1","pre-commit":"1.x","rc-tools":"6.x","react":"^16.1.1","react-dom":"^16.1.1","react-test-renderer":"^16.1.1","history":"^1.16.0","prop-types":"^15.5.10","react-redux":"^4.0.0","react-router":"^3.0.0","redux":"^3.0.4"},"pre-commit":["lint"],"dependencies":{"async-validator":"1.x","babel-runtime":"6.x","create-react-class":"^15.5.3","dom-scroll-into-view":"1.x","hoist-non-react-statics":"^2.3.1","lodash":"^4.17.4","warning":"^3.0.0"},"peerDependencies":{"prop-types":"^15.0"},"gitHead":"da34cd3992e53baad12c42b0393f98b280e5dc4a","_id":"rc-form@2.2.4","_npmVersion":"6.4.1","_nodeVersion":"8.11.3","_npmUser":{"name":"zombiej","email":"smith3816@gmail.com"},"dist":{"integrity":"sha512-CxAZ12v5UR8hRu63+yPcf3/N3cXmXuo6cv/92iHj2RD82b0hTIZyMfY1duU/oNBSfpQQ0RTlv3WuGnujtU9Bww==","shasum":"d27106c2b8dfa30d89cc0cf580ef8bb41cf2aa1a","tarball":"http://registry-npm.ywwl.com/rc-form/download/rc-form-2.2.4.tgz","fileCount":25,"unpackedSize":802478,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbvLfNCRA9TVsSAnZWagAAv4EP/iUdCryp5xSic3HyXrfV\nup0D7E4X0ZUN38H9bMwLDWpzsDid/+rO8aHPVgCYpUHwfOwLYS+rjzfCFwAA\niHLR1v2iTk4Vw+MiEUL3YvPyTAhDlpH7DxuPRlxHVzdgXCoTrHt1BppFiPA1\nKvf2imK4HP60a0wuJSMdsG3nU+he+KSHzFXmiWosIAzYFW2VRYqH4oEaFXyj\nuPABy2odRcHEu2gGkfXHamNNt/SsPScbX2/iHXtqPgu/r0NKDhQ6AwjHzMOF\nk7tUsiCZCh+5BGejClNHDM+OeIaWTL7g8Q94aGtopONbI5UQxHrO/R1+HNXm\nQTUnONnPyNF/OQ3ml/SF//12IN/1JOEG/On7otPgSWFNF+aoHzv0Eh4iUXlO\njUClhKcWW/8ps6kScnHeCrCkBFC6/oGVqGNVdgcsqs694euQuLtM8fmMcW04\ns6lqLyGdLiNowWOs77VLbqoTyb2S/MlmPpkOAdx+EIsmvA7G8HFS91cVHIDu\npL+mwHAHVjUNxI5sVV4gFJVAXgjJr9UcJAvJ3x/3bPMyzHXHY0cGZYWZlOMW\nmX/mLPr8/osXG17164OE/WpLqWA8Z8SZyc6ejWmPtTwoItXzob5m+NQM3VI/\njxvs1pxeSMWb3I22z6WywoUNV2UnSk6g3FsqyjAu2g++BjB9MwbsGTsL+OyA\nHmUo\r\n=3fcC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHxzvSfXtFYHWv3GzZXzSJvq8heFGVh+pBz0qi87EE0cAiEA36bsHVzAAxU622IYU0QLiXYcAc0LMqPp70vuW63IboU="}],"size":186072,"noattachment":false,"key":"/rc-form/-/rc-form-2.2.4.tgz"},"maintainers":[{"email":"afc163@gmail.com","name":"afc163"},{"email":"benjytrys@gmail.com","name":"benjycui"},{"email":"418150596@qq.com","name":"ddcat1115"},{"email":"644506165@qq.com","name":"nikogu"},{"email":"yesmeck@gmail.com","name":"yesmeck"},{"email":"yiminghe@gmail.com","name":"yiminghe"},{"email":"smith3816@gmail.com","name":"zombiej"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rc-form_2.2.4_1539094476733_0.16685919166533458"},"_hasShrinkwrap":false,"readme":"# rc-form\n\nReact High Order Form Component.\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![gemnasium deps][gemnasium-image]][gemnasium-url]\n[![node version][node-image]][node-url]\n[![npm download][download-image]][download-url]\n[![Code Quality: Javascript][lgtm-badge]][lgtm-badge-url]\n[![Total alerts][lgtm-alerts]][lgtm-alerts-url]\n\n[npm-image]: http://img.shields.io/npm/v/rc-form.svg?style=flat-square\n[npm-url]: http://npmjs.org/package/rc-form\n[travis-image]: https://img.shields.io/travis/react-component/form.svg?style=flat-square\n[travis-url]: https://travis-ci.org/react-component/form\n[coveralls-image]: https://img.shields.io/coveralls/react-component/form.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/react-component/form?branch=master\n[gemnasium-image]: http://img.shields.io/gemnasium/react-component/form.svg?style=flat-square\n[gemnasium-url]: https://gemnasium.com/react-component/form\n[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square\n[node-url]: http://nodejs.org/download/\n[download-image]: https://img.shields.io/npm/dm/rc-form.svg?style=flat-square\n[download-url]: https://npmjs.org/package/rc-form\n[lgtm-badge]: https://img.shields.io/lgtm/grade/javascript/g/react-component/form.svg?logo=lgtm&logoWidth=18\n[lgtm-badge-url]: https://lgtm.com/projects/g/react-component/form/context:javascript\n[lgtm-alerts]: https://img.shields.io/lgtm/alerts/g/react-component/form.svg?logo=lgtm&logoWidth=18\n[lgtm-alerts-url]: https://lgtm.com/projects/g/react-component/form/alerts\n\n## Development\n\n```\nnpm install\nnpm start\nopen http://localhost:8000/examples/\n```\n\n## Feature\n\n* Support react.js and even react-native\n* Validate fields with [async-validator](https://github.com/yiminghe/async-validator/)\n\n## Install\n\n[![rc-form](https://nodei.co/npm/rc-form.png)](https://npmjs.org/package/rc-form)\n\n## Usage\n\n```js\nimport { createForm, formShape } from 'rc-form';\n\nclass Form extends React.Component {\n  static propTypes = {\n    form: formShape,\n  };\n\n  submit = () => {\n    this.props.form.validateFields((error, value) => {\n      console.log(error, value);\n    });\n  }\n\n  render() {\n    let errors;\n    const { getFieldProps, getFieldError } = this.props.form;\n    return (\n      <div>\n        <input {...getFieldProps('normal')}/>\n        <input {...getFieldProps('required', {\n          onChange(){}, // have to write original onChange here if you need\n          rules: [{required: true}],\n        })}/>\n        {(errors = getFieldError('required')) ? errors.join(',') : null}\n        <button onClick={this.submit}>submit</button>\n      </div>\n    );\n  }\n}\n\nexport createForm()(Form);\n```\n\n### Use with React Native\n\nExpo preview   \n\n![avatar](./examples/react-native/expo.jpg)\n\n[View the source code](./examples/react-native/App.js)\n\nOr a quicker version:\n\n```js\nimport { createForm } from 'rc-form';\n\nclass Form extends React.Component {\n  componentWillMount() {\n    this.requiredDecorator = this.props.form.getFieldDecorator('required', {\n      rules: [{required: true}],\n    });\n  }\n\n  submit = () => {\n    this.props.form.validateFields((error, value) => {\n      console.log(error, value);\n    });\n  }\n\n  render() {\n    let errors;\n    const { getFieldError } = this.props.form;\n    return (\n      <div>\n        {this.requiredDecorator(\n          <input\n            onChange={\n              // can still write your own onChange\n            }\n          />\n        )}\n        {(errors = getFieldError('required')) ? errors.join(',') : null}\n        <button onClick={this.submit}>submit</button>\n      </div>\n    );\n  }\n}\n\nexport createForm()(Form);\n```\n\n## createForm(option: Object) => (WrappedComponent: React.Component) => React.Component\n\n| Option    | Description                              | Type       | Default |\n|-----------|------------------------------------------|------------|---------|\n| option.validateMessages | Preseted messages of [async-validator](https://github.com/yiminghe/async-validator) | Object | {} |\n| option.onFieldsChange | Called when field changed, you can dispatch fields to redux store. | (props, changed, all): void | NOOP |\n| option.onValuesChange | Called when value changed. | (props, changed, all): void | NOOP |\n| option.mapProps | Get new props transferred to WrappedComponent. | (props): Object | props => props |\n| option.mapPropsToFields | Convert value from props to fields. Used for read fields from redux store. | (props): Object | NOOP |\n| option.fieldNameProp | Where to store the `name` argument of `getFieldProps`. | String | - |\n| option.fieldMetaProp | Where to store the meta data of `getFieldProps`. | String | - |\n| option.fieldDataProp | Where to store the field data | String | - |\n| option.withRef(deprecated) | Maintain an ref for wrapped component instance, use `refs.wrappedComponent` to access. | boolean | false |\n\n### Note: use wrappedComponentRef instead of withRef after rc-form@1.4.0\n\n```jsx\nclass Form extends React.Component { ... }\n\n// deprecated\nconst EnhancedForm = createForm({ withRef: true })(Form);\n<EnhancedForm ref=\"form\" />\nthis.refs.form.refs.wrappedComponent // => The instance of Form\n\n// Recommended\nconst EnhancedForm = createForm()(Form);\n<EnhancedForm wrappedComponentRef={(inst) => this.formRef = inst} />\nthis.formRef // => The instance of Form\n```\n\n## (WrappedComponent: React.Component) => React.Component\n\nThe returned function of createForm(). It will pass an object as prop `form` with the following members to WrappedComponent:\n\n### getFieldProps(name, option): Object { [valuePropName], [trigger], [validateTrigger] }\n\nWill create props which can be set on a input/InputComponent which support value and onChange interface.\n\nAfter set, this will create a binding with this input.\n\n```jsx\n<form>\n  <input {...getFieldProps('name', { ...options })} />\n</form>\n```\n\n#### name: String\n\nThis input's unique name.\n\n#### option: Object\n\n| Option    | Description                              | Type       | Default |\n|-----------|------------------------------------------|------------|---------|\n| option.valuePropName | Prop name of component's value field, eg: checkbox should be set to `checked` ... | String | 'value' |\n| option.getValueProps | Get the component props according to field value. | (value): Object | (value) => ({ value }) |\n| option.getValueFromEvent | Specify how to get value from event. | (e): any | See below |\n| option.initialValue | Initial value of current component. | any | - |\n| option.normalize | Return normalized value. | (value, prev, all): Object | - |\n| option.trigger | Event which is listened to collect form data. | String | 'onChange' |\n| option.validateTrigger | Event which is listened to validate. Set to falsy to only validate when call props.validateFields. | String|String[] | 'onChange' |\n| option.rules | Validator rules. see: [async-validator](https://github.com/yiminghe/async-validator) | Object[] | - |\n| option.validateFirst | Whether stop validate on first rule of error for this field. | boolean | false |\n| option.validate | | Object[] | - |\n| option.validate[n].trigger | Event which is listened to validate. Set to falsy to only validate when call props.validateFields. | String|String[] | 'onChange' |\n| option.validate[n].rules | Validator rules. see: [async-validator](https://github.com/yiminghe/async-validator) | Object[] | - |\n| option.hidden | Ignore current field while validating or gettting fields | boolean | false |\n| option.preserve | Whether to preserve the value. That will remain the value when the field be unmounted and be mounted again | boolean | false |\n\n##### Default value of `getValueFromEvent`\n\n```js\nfunction defaultGetValueFromEvent(e) {\n  if (!e || !e.target) {\n    return e;\n  }\n  const { target } = e;\n  return target.type === 'checkbox' ? target.checked : target.value;\n}\n```\n\n##### Tips\n\n```js\n{\n  validateTrigger: 'onBlur',\n  rules: [{required: true}],\n}\n// is the shorthand of\n{\n  validate: [{\n    trigger: 'onBlur',\n    rules: [{required: true}],\n  }],\n}\n```\n\n### getFieldDecorator(name:String, option: Object) => (React.Node) => React.Node\n\nSimilar to `getFieldProps`, but add some helper warnings and you can write onXX directly inside React.Node props:\n\n```jsx\n<form>\n  {getFieldDecorator('name', otherOptions)(<input />)}\n</form>\n```\n\n### getFieldsValue([fieldNames: String[]])\n\nGet fields value by fieldNames.\n\n### getFieldValue(fieldName: String)\n\nGet field value by fieldName.\n\n### getFieldInstance(fieldName: String)\n\nGet field react public instance by fieldName.\n\n### setFieldsValue(obj: Object)\n\nSet fields value by kv object.\n\n### setFieldsInitialValue(obj: Object)\n\nSet fields initialValue by kv object. use for reset and initial display/value.\n\n### setFields(obj: Object)\n\nSet fields by kv object. each field can contain errors and value member.\n\n### validateFields([fieldNames: String[]], [options: Object], callback: (errors, values) => void)\n\nValidate and get fields value by fieldNames.\n\noptions is the same as validate method of [async-validator](https://github.com/yiminghe/async-validator).\nAnd add `force`.\n\n#### options.force: Boolean\n\nDefaults to false. Whether to validate fields which have been validated(caused by validateTrigger).\n\n### getFieldsError(names): Object{ [name]: String[] }\n\nGet inputs' validate errors.\n\n### getFieldError(name): String[]\n\nGet input's validate errors.\n\n### isFieldValidating(name: String): Bool\n\nWhether this input is validating.\n\n### isFieldsValidating(names: String[]): Bool\n\nWhether one of the inputs is validating.\n\n### isFieldTouched(name: String): Bool\n\nWhether this input's value had been changed by user.\n\n### isFieldsTouched(names: String[]): Bool\n\nWhether one of the inputs' values had been changed by user.\n\n### resetFields([names: String[]])\n\nReset specified inputs. Defaults to all.\n\n### isSubmitting(): Bool (Deprecated)\n\nWhether the form is submitting.\n\n### submit(callback: Function) (Deprecated)\n\nCause isSubmitting to return true, after callback called, isSubmitting return false.\n\n\n## rc-form/lib/createDOMForm(option): Function\n\ncreateDOMForm enhancement, support props.form.validateFieldsAndScroll\n\n### validateFieldsAndScroll([fieldNames: String[]], [options: Object], callback: (errors, values) => void)\n\nprops.form.validateFields enhancement, support scroll to the first invalid form field,  `scroll` is the same as [dom-scroll-into-view's function parameter `config`](https://github.com/yiminghe/dom-scroll-into-view#function-parameter).\n\n#### options.container: HTMLElement\n\nDefaults to first scrollable container of form field(until document).\n\n\n## Notes\n\n- Do not use stateless function component inside Form component: https://github.com/facebook/react/pull/6534\n\n- you can not set same prop name as the value of validateTrigger/trigger for getFieldProps\n\n```js\n<input {...getFieldProps('change',{\n  onChange: this.iWantToKnow // you must set onChange here or use getFieldDecorator to write inside <input>\n})}>\n```\n\n- you can not use ref prop for getFieldProps\n\n```js\n<input {...getFieldProps('ref')} />\n\nthis.props.form.getFieldInstance('ref') // use this to get ref\n```\n\nor\n\n```js\n<input {...getFieldProps('ref',{\n  ref: this.saveRef // use function here or use getFieldDecorator to write inside <input> (only allow function)\n})} />\n```\n\n## Test Case\n\n```\nnpm test\nnpm run chrome-test\n```\n\n## Coverage\n\n```\nnpm run coverage\n```\n\nopen coverage/ dir\n\n## License\n\nrc-form is released under the MIT license.\n","publish_time":1539094476887,"_cnpm_publish_time":1539094476887,"dist-tags":{"beta":"2.4.12-alpha.0","latest":"2.4.12"}}