{"name":"rc-form","version":"2.2.7","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":"8.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.8.5","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":"2de701b818a104208bd70b351ff24d2e064c54c9","_id":"rc-form@2.2.7","_npmVersion":"6.4.1","_nodeVersion":"10.12.0","_npmUser":{"name":"afc163","email":"afc163@gmail.com"},"dist":{"integrity":"sha512-50zIXXa+QzssgZZQx5OwGFbELr99d0sCZYVo1SIXS216ioWnFefzbFs+iofTCir+YbTCQHh/cxqXDdC6r6HvYg==","shasum":"8880851b9cd4a9c911f5272c91db73978a72377d","tarball":"http://registry-npm.ywwl.com/rc-form/download/rc-form-2.2.7.tgz","fileCount":25,"unpackedSize":808396,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcBjs9CRA9TVsSAnZWagAA2p0P/1+QxcT+1tYXrZibYBU7\nNwjAWrr/XePn/vmLGBNp1Q7WHsylbs0upDi14pJYtfeE3hw134KqnaA2iSSa\nrm7PUAVaYauNxlDFngNbVRXosPPq460+Zw426kq44fuErloqIlWk3QBKaFPF\nG0EiU21QpOvEWKW6M10+h3VEhaA7zqnE0oDWGMlA1YpwGRDjpgCF6oK32hoT\nlcWT8xz4IgqZuqyqAKn1zPHBHT3flzApkb7SmzI0JmTGpJ9B1AQoDST3iFl1\nNBm+97kP93Am5mWbvYPgwKfug+vyt8xw0Pjx24xWdWKMKPMPNw3KvDyvsqZs\nMP3CLtFhCkDhor31nodY4COVdHc7fYzVW/kVVWgWaN26tj2QSmD7UFIKJcrv\nGCO7weakuh8NtWUmnEDc3EP6ZeD6ep+rBubN/HZMEv/NsF4l+HIHCxHY7DdX\najUgtK3S8QldmNteo9c1lX3xo5IYt+0GAyCsqWyEimXOcgQqxMyHFE50HwhI\noOHrK3RvJ7buClv0/wBPmSM35DCv3iH2bDm9/O5/aa+cAaJGXTSZGleqOANv\nrivlwk/b3np7YcXiyUy32lT5LzELKXtOr3hBEn72qFiIlqfbCk1sHfYHOTaw\nYL+XPbJtsP8winUj4pn8uWRK2cpzvWVmj6vdO1aJd0ZUohvFHe2fZbhfoX+x\nACN6\r\n=orrJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBkEE623nHUfQTY25HT5oG4n5n7cwJpF4D5D0+YObSplAiEA4eMquywNxcre7T4Pf58SEZ0LuCxmnZ8iSlYuQYjIfLQ="}],"size":188175,"noattachment":false,"key":"/rc-form/-/rc-form-2.2.7.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.7_1543912252682_0.4325140860123218"},"_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":1543912252873,"_cnpm_publish_time":1543912252873,"dist-tags":{"beta":"2.4.12-alpha.0","latest":"2.4.12"}}