@danderson00/react-forms 0.0.48 → 0.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,203 +1,203 @@
1
- # @danderson00/react-forms
2
-
3
- Ultra simple, stateless, validated forms for use in React function components.
4
-
5
- ## Installation
6
-
7
- ```shell
8
- yarn add @danderson00/react-forms
9
- ```
10
-
11
- ## Usage
12
-
13
- ```jsx
14
- import React from 'react'
15
- import { Form, Input, Textarea, Select, Submit } from '@danderson00/react-forms'
16
-
17
- export default ({ onSubmit, onCancel, initialValues }) => (
18
- <Form onSubmit={onSubmit} values={initialValues}>
19
- <label>Name</label>
20
- <Input name="name" required minLength="5" maxLength="50" />
21
-
22
- <label>Description</label>
23
- <Textarea name="description" maxLength="100" />
24
-
25
- <label>Type</label>
26
- <Select name="type" options={['', 'Widget', 'Component']} required />
27
-
28
- <label>Rating</label>
29
- <div>
30
- <Input name="rating" type="radio" numeric value="1" checked />
31
- <Input name="rating" type="radio" numeric value="2" />
32
- <Input name="rating" type="radio" numeric value="3" />
33
- </div>
34
-
35
- <label>Urgent</label>
36
- <Input name="urgent" type="checkbox" />
37
-
38
- <div>
39
- <Submit>Submit</Submit>
40
- <button onClick={onCancel}>Cancel</button>
41
- </div>
42
- </Form>
43
- )
44
- ```
45
-
46
- All `props` passed to components are passed to underlying HTML elements. Standard HTML `option` elements can also be
47
- used for specifying options for the `Select` component. Using `type="number"` or adding a `numeric` prop will coerce
48
- the provided value to a `Number` type. Specifying a `value` prop for checkboxes causes the output value to toggle
49
- between the provided value and `undefined`.
50
-
51
- Form `onSubmit` handlers are passed an object containing form values:
52
-
53
- ```json
54
- {
55
- "name": "",
56
- "description": "",
57
- "type": "",
58
- "rating": 1,
59
- "urgent": false
60
- }
61
- ```
62
-
63
- The `onSubmit` handler passed to the `Form` component is only called if validation passes. Form submission is also
64
- triggered when the `Enter` key (or `Go` button on mobile) is pressed while form elements are active.
65
-
66
- ### Deep Object Structures
67
-
68
- Simple dotted notation can be used to create deep object structures:
69
-
70
- ```jsx
71
- <Form>
72
- <Input name="name" />
73
- <Input name="inventory.stockLevel" type="number" />
74
- <Input name="inventory.quantityOnOrder" type="number" />
75
- <Submit onSubmit={values => console.log(values)} />
76
- </Form>
77
- ```
78
-
79
- ```json
80
- {
81
- "name": "",
82
- "inventory": {
83
- "stockLevel": 0,
84
- "quantityOnOrder": 0
85
- }
86
- }
87
- ```
88
-
89
- ### Styling
90
-
91
- No styling is provided out of the box. Default corresponding HTML elements are used and can be directly styled using
92
- CSS or style attributes.
93
-
94
- Additionally, a `validated` class is applied to individual elements as they change, and to the form when it is
95
- submitted. This allows you to make use of the `:invalid` CSS pseudo-class, but only display validation styles after
96
- validation has occurred.
97
-
98
- Styling to work with the example code above might look something like:
99
-
100
- ```css
101
- form > * {
102
- display: block;
103
- }
104
-
105
- form label {
106
- font-size: 0.8em;
107
- }
108
-
109
- form label:not(:first-child) {
110
- margin-top: 5px;
111
- }
112
-
113
- form .validated:invalid {
114
- outline: 1px solid red;
115
- }
116
- ```
117
-
118
- ## Custom Components
119
-
120
- `react-functional-forms` exposes functions that can be used to wrap components so that they can be included in output
121
- form value objects.
122
-
123
- ```jsx
124
- import React from 'react'
125
- import { wrapInput, wrapSubmit, Form } from '@danderson00/react-forms'
126
-
127
- const InputField = wrapInput(({ label, className, ...inputProps }) =>
128
- <div className={className}>
129
- <label>{label}</label>
130
- <input {...inputProps} />
131
- </div>
132
- )
133
-
134
- const AnchorSubmit = wrapSubmit(props => <a {...props} />)
135
-
136
- export const SampleForm = ({ onSubmit }) => (
137
- <Form onSubmit={onSubmit}>
138
- <InputField label="Name" name="name" required />
139
- <InputField label="Description" name="description" maxLength="100" />
140
- <InputField label="Urgent" name="urgent" type="checkbox" />
141
- <AnchorSubmit>Submit</AnchorSubmit>
142
- </Form>
143
- )
144
- ```
145
-
146
- The `wrapInput` function manages the `value` and `onChange` props and in most cases, these are the only props you
147
- need to pass to your input component. In the example above, all other props are also passed on to enable validation.
148
-
149
- If your custom component is rendered with a `type` prop of `radio` or `checkbox`, this will cause the `checked` prop
150
- to become managed instead of `value`, and should be passed to your input component. You can also force the component
151
- to be treated as a radio button or checkbox by specifying options to the `wrapInput` function. More on this below.
152
-
153
- The `wrapSubmit` function manages the `onClick` and `disabled` props of your submit component. All other props can be
154
- safely ignored or passed on.
155
-
156
- ### Integration With Third Party Libraries
157
-
158
- The functions described above can also be used to easily wrap components from third party libraries.
159
-
160
- ```jsx
161
- import { wrapInput } from 'react-functional-forms'
162
- import * as material from '@material-ui/core'
163
-
164
- export const Input = wrapInput(material.Input)
165
- export const Checkbox = wrapInput(material.Checkbox, { type: 'checkbox' })
166
- export const Radio = wrapInput(material.Radio, { type: 'radio' })
167
- export const Select = wrapInput(material.Select, { type: 'select' })
168
- export const Switch = wrapInput(material.Switch, { type: 'checkbox' })
169
- ```
170
-
171
- ## API
172
-
173
- ### wrapInput(component, options)
174
-
175
- Options are as follows:
176
-
177
- Option|Type|Default|Description
178
- ---|---|---|---
179
- type|string|'text'|One of `text`, `radio`, `checkbox` or `select`.
180
- passErrorProp|boolean|false|Passes a boolean prop named `error` when field validation fails.
181
- valueFromEvent|function||Override the default mechanism for retrieving a new field value from an onChange event. All function arguments are passed on.
182
- defaultValue|any||Specify the default value for the field. Can be a value or a function that returns a value.
183
-
184
- ### wrapSubmit(component)
185
-
186
- ## License
187
-
188
- **The MIT License (MIT)**
189
-
190
- Copyright © 2022 Dale Anderson
191
-
192
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
193
- documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
194
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
195
- persons to whom the Software is furnished to do so, subject to the following conditions:
196
-
197
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
198
- Software.
199
-
200
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
201
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
202
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
203
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # @danderson00/react-forms
2
+
3
+ Ultra simple, stateless, validated forms for use in React function components.
4
+
5
+ ## Installation
6
+
7
+ ```shell
8
+ yarn add @danderson00/react-forms
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```jsx
14
+ import React from 'react'
15
+ import { Form, Input, Textarea, Select, Submit } from '@danderson00/react-forms'
16
+
17
+ export default ({ onSubmit, onCancel, initialValues }) => (
18
+ <Form onSubmit={onSubmit} values={initialValues}>
19
+ <label>Name</label>
20
+ <Input name="name" required minLength="5" maxLength="50" />
21
+
22
+ <label>Description</label>
23
+ <Textarea name="description" maxLength="100" />
24
+
25
+ <label>Type</label>
26
+ <Select name="type" options={['', 'Widget', 'Component']} required />
27
+
28
+ <label>Rating</label>
29
+ <div>
30
+ <Input name="rating" type="radio" numeric value="1" checked />
31
+ <Input name="rating" type="radio" numeric value="2" />
32
+ <Input name="rating" type="radio" numeric value="3" />
33
+ </div>
34
+
35
+ <label>Urgent</label>
36
+ <Input name="urgent" type="checkbox" />
37
+
38
+ <div>
39
+ <Submit>Submit</Submit>
40
+ <button onClick={onCancel}>Cancel</button>
41
+ </div>
42
+ </Form>
43
+ )
44
+ ```
45
+
46
+ All `props` passed to components are passed to underlying HTML elements. Standard HTML `option` elements can also be
47
+ used for specifying options for the `Select` component. Using `type="number"` or adding a `numeric` prop will coerce
48
+ the provided value to a `Number` type. Specifying a `value` prop for checkboxes causes the output value to toggle
49
+ between the provided value and `undefined`.
50
+
51
+ Form `onSubmit` handlers are passed an object containing form values:
52
+
53
+ ```json
54
+ {
55
+ "name": "",
56
+ "description": "",
57
+ "type": "",
58
+ "rating": 1,
59
+ "urgent": false
60
+ }
61
+ ```
62
+
63
+ The `onSubmit` handler passed to the `Form` component is only called if validation passes. Form submission is also
64
+ triggered when the `Enter` key (or `Go` button on mobile) is pressed while form elements are active.
65
+
66
+ ### Deep Object Structures
67
+
68
+ Simple dotted notation can be used to create deep object structures:
69
+
70
+ ```jsx
71
+ <Form>
72
+ <Input name="name" />
73
+ <Input name="inventory.stockLevel" type="number" />
74
+ <Input name="inventory.quantityOnOrder" type="number" />
75
+ <Submit onSubmit={values => console.log(values)} />
76
+ </Form>
77
+ ```
78
+
79
+ ```json
80
+ {
81
+ "name": "",
82
+ "inventory": {
83
+ "stockLevel": 0,
84
+ "quantityOnOrder": 0
85
+ }
86
+ }
87
+ ```
88
+
89
+ ### Styling
90
+
91
+ No styling is provided out of the box. Default corresponding HTML elements are used and can be directly styled using
92
+ CSS or style attributes.
93
+
94
+ Additionally, a `validated` class is applied to individual elements as they change, and to the form when it is
95
+ submitted. This allows you to make use of the `:invalid` CSS pseudo-class, but only display validation styles after
96
+ validation has occurred.
97
+
98
+ Styling to work with the example code above might look something like:
99
+
100
+ ```css
101
+ form > * {
102
+ display: block;
103
+ }
104
+
105
+ form label {
106
+ font-size: 0.8em;
107
+ }
108
+
109
+ form label:not(:first-child) {
110
+ margin-top: 5px;
111
+ }
112
+
113
+ form .validated:invalid {
114
+ outline: 1px solid red;
115
+ }
116
+ ```
117
+
118
+ ## Custom Components
119
+
120
+ `react-functional-forms` exposes functions that can be used to wrap components so that they can be included in output
121
+ form value objects.
122
+
123
+ ```jsx
124
+ import React from 'react'
125
+ import { wrapInput, wrapSubmit, Form } from '@danderson00/react-forms'
126
+
127
+ const InputField = wrapInput(({ label, className, ...inputProps }) =>
128
+ <div className={className}>
129
+ <label>{label}</label>
130
+ <input {...inputProps} />
131
+ </div>
132
+ )
133
+
134
+ const AnchorSubmit = wrapSubmit(props => <a {...props} />)
135
+
136
+ export const SampleForm = ({ onSubmit }) => (
137
+ <Form onSubmit={onSubmit}>
138
+ <InputField label="Name" name="name" required />
139
+ <InputField label="Description" name="description" maxLength="100" />
140
+ <InputField label="Urgent" name="urgent" type="checkbox" />
141
+ <AnchorSubmit>Submit</AnchorSubmit>
142
+ </Form>
143
+ )
144
+ ```
145
+
146
+ The `wrapInput` function manages the `value` and `onChange` props and in most cases, these are the only props you
147
+ need to pass to your input component. In the example above, all other props are also passed on to enable validation.
148
+
149
+ If your custom component is rendered with a `type` prop of `radio` or `checkbox`, this will cause the `checked` prop
150
+ to become managed instead of `value`, and should be passed to your input component. You can also force the component
151
+ to be treated as a radio button or checkbox by specifying options to the `wrapInput` function. More on this below.
152
+
153
+ The `wrapSubmit` function manages the `onClick` and `disabled` props of your submit component. All other props can be
154
+ safely ignored or passed on.
155
+
156
+ ### Integration With Third Party Libraries
157
+
158
+ The functions described above can also be used to easily wrap components from third party libraries.
159
+
160
+ ```jsx
161
+ import { wrapInput } from 'react-functional-forms'
162
+ import * as material from '@material-ui/core'
163
+
164
+ export const Input = wrapInput(material.Input)
165
+ export const Checkbox = wrapInput(material.Checkbox, { type: 'checkbox' })
166
+ export const Radio = wrapInput(material.Radio, { type: 'radio' })
167
+ export const Select = wrapInput(material.Select, { type: 'select' })
168
+ export const Switch = wrapInput(material.Switch, { type: 'checkbox' })
169
+ ```
170
+
171
+ ## API
172
+
173
+ ### wrapInput(component, options)
174
+
175
+ Options are as follows:
176
+
177
+ Option|Type|Default|Description
178
+ ---|---|---|---
179
+ type|string|'text'|One of `text`, `radio`, `checkbox` or `select`.
180
+ passErrorProp|boolean|false|Passes a boolean prop named `error` when field validation fails.
181
+ valueFromEvent|function||Override the default mechanism for retrieving a new field value from an onChange event. All function arguments are passed on.
182
+ defaultValue|any||Specify the default value for the field. Can be a value or a function that returns a value.
183
+
184
+ ### wrapSubmit(component)
185
+
186
+ ## License
187
+
188
+ **The MIT License (MIT)**
189
+
190
+ Copyright © 2022 Dale Anderson
191
+
192
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
193
+ documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
194
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
195
+ persons to whom the Software is furnished to do so, subject to the following conditions:
196
+
197
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
198
+ Software.
199
+
200
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
201
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
202
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
203
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/TODO.md CHANGED
@@ -1,3 +1,3 @@
1
- - Make opinionated fields default implementation
2
- - Update readme
1
+ - Make opinionated fields default implementation
2
+ - Update readme
3
3
  -
@@ -5,16 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.extractErrorMessage = exports["default"] = void 0;
7
7
  var _react = require("react");
8
- var extractErrorMessage = function extractErrorMessage(error) {
8
+ var extractErrorMessage = exports.extractErrorMessage = function extractErrorMessage(error) {
9
9
  return error ? error.hasOwnProperty('stack') || error.hasOwnProperty('message') ? error.message || 'An error occurred' : error : 'An error occurred';
10
10
  };
11
- exports.extractErrorMessage = extractErrorMessage;
12
- var _default = function _default(_ref) {
11
+ var _default = exports["default"] = function _default(_ref) {
13
12
  var error = _ref.error;
14
13
  return /*#__PURE__*/(0, _react.createElement)('div', {
15
14
  className: 'react-forms-error',
16
15
  children: extractErrorMessage(error)
17
16
  });
18
17
  };
19
- exports["default"] = _default;
20
18
  //# sourceMappingURL=ErrorMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorMessage.js","names":["_react","require","extractErrorMessage","error","hasOwnProperty","message","exports","_default","_ref","createElement","className","children"],"sources":["../src/ErrorMessage.js"],"sourcesContent":["import { createElement } from 'react'\r\n\r\nexport const extractErrorMessage = error => error\r\n ? (error.hasOwnProperty('stack') || error.hasOwnProperty('message'))\r\n ? error.message || 'An error occurred'\r\n : error\r\n : 'An error occurred'\r\n\r\nexport default ({ error }) => createElement('div', {\r\n className: 'react-forms-error',\r\n children: extractErrorMessage(error)\r\n})"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAGC,KAAK;EAAA,OAAIA,KAAK,GAC5CA,KAAK,CAACC,cAAc,CAAC,OAAO,CAAC,IAAID,KAAK,CAACC,cAAc,CAAC,SAAS,CAAC,GAC/DD,KAAK,CAACE,OAAO,IAAI,mBAAmB,GACpCF,KAAK,GACP,mBAAmB;AAAA;AAAAG,OAAA,CAAAJ,mBAAA,GAAAA,mBAAA;AAAA,IAAAK,QAAA,GAER,SAAAA,SAAAC,IAAA;EAAA,IAAGL,KAAK,GAAAK,IAAA,CAALL,KAAK;EAAA,oBAAO,IAAAM,oBAAa,EAAC,KAAK,EAAE;IACjDC,SAAS,EAAE,mBAAmB;IAC9BC,QAAQ,EAAET,mBAAmB,CAACC,KAAK;EACrC,CAAC,CAAC;AAAA;AAAAG,OAAA,cAAAC,QAAA"}
1
+ {"version":3,"file":"ErrorMessage.js","names":["_react","require","extractErrorMessage","exports","error","hasOwnProperty","message","_default","_ref","createElement","className","children"],"sources":["../src/ErrorMessage.js"],"sourcesContent":["import { createElement } from 'react'\n\nexport const extractErrorMessage = error => error\n ? (error.hasOwnProperty('stack') || error.hasOwnProperty('message'))\n ? error.message || 'An error occurred'\n : error\n : 'An error occurred'\n\nexport default ({ error }) => createElement('div', {\n className: 'react-forms-error',\n children: extractErrorMessage(error)\n})"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,IAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,SAAtBA,mBAAmBA,CAAGE,KAAK;EAAA,OAAIA,KAAK,GAC5CA,KAAK,CAACC,cAAc,CAAC,OAAO,CAAC,IAAID,KAAK,CAACC,cAAc,CAAC,SAAS,CAAC,GAC/DD,KAAK,CAACE,OAAO,IAAI,mBAAmB,GACpCF,KAAK,GACP,mBAAmB;AAAA;AAAA,IAAAG,QAAA,GAAAJ,OAAA,cAER,SAAAI,SAAAC,IAAA;EAAA,IAAGJ,KAAK,GAAAI,IAAA,CAALJ,KAAK;EAAA,oBAAO,IAAAK,oBAAa,EAAC,KAAK,EAAE;IACjDC,SAAS,EAAE,mBAAmB;IAC9BC,QAAQ,EAAET,mBAAmB,CAACE,KAAK;EACrC,CAAC,CAAC;AAAA"}
package/dist/Form.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
@@ -8,8 +8,8 @@ exports["default"] = void 0;
8
8
  var _react = require("react");
9
9
  var _objectPathImmutable = require("object-path-immutable");
10
10
  var _excluded = ["resetOnSubmit", "row", "gap", "values"];
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
14
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
15
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
@@ -21,7 +21,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
21
21
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
22
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
23
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
24
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
24
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
25
25
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
26
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
27
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -165,6 +165,5 @@ var Form = function Form(ContextProvider) {
165
165
  }));
166
166
  };
167
167
  };
168
- var _default = Form;
169
- exports["default"] = _default;
168
+ var _default = exports["default"] = Form;
170
169
  //# sourceMappingURL=Form.js.map
package/dist/Form.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","names":["_react","require","_objectPathImmutable","_excluded","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","_typeof","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","_toConsumableArray","arr","_arrayWithoutHoles","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","iter","iterator","Array","from","isArray","_arrayLikeToArray","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_nonIterableRest","o","minLen","n","prototype","toString","slice","constructor","name","test","len","arr2","_i","_s","_e","_x","_r","_arr","_n","_d","next","done","err","_objectWithoutProperties","excluded","_objectWithoutPropertiesLoose","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","Form","ContextProvider","additionalContext","ErrorMessage","_ref","resetOnSubmit","row","gap","values","props","_useState","useState","_useState2","fieldValues","setFieldValues","_useReducer","useReducer","validators","validator","concat","_useReducer2","fieldValidators","registerFieldValidator","_useState3","_useState4","error","setError","_useState5","_useState6","valid","setValid","form","createRef","useEffect","current","checkValidity","getFieldValue","useCallback","path","get","getFieldValues","mapFieldValues","reduce","set","setFieldValue","previousValues","onSubmit","e","_ref2","additionalValues","validate","setFieldValidated","interactiveElements","querySelectorAll","setFormDisabled","disabled","x","reset","checkResultForError","result","success","message","then","preventDefault","stopPropagation","classNames","className","mergedAdditionalContext","property","createElement","join","noValidate","ref","style","children","type","visibility","position","_default","exports"],"sources":["../src/Form.js"],"sourcesContent":["import { createElement, createRef, useCallback, useEffect, useReducer, useState } from 'react'\r\nimport { get, set } from 'object-path-immutable'\r\n\r\nconst Form = (ContextProvider, additionalContext = {}, ErrorMessage) => (\r\n ({ resetOnSubmit, row, gap, values, ...props }) => {\r\n const [fieldValues, setFieldValues] = useState(values || {})\r\n const [fieldValidators, registerFieldValidator] = useReducer((validators, validator) => [...validators, validator], [])\r\n const [error, setError] = useState()\r\n const [valid, setValid] = useState()\r\n const form = createRef()\r\n\r\n useEffect(() => {\r\n if(form.current) {\r\n setValid(form.current.checkValidity())\r\n }\r\n }, [form.current])\r\n\r\n const getFieldValue = useCallback(path => get(fieldValues, path), [fieldValues])\r\n const getFieldValues = useCallback(() => fieldValues, [fieldValues])\r\n const mapFieldValues = target => Object.keys(target).reduce(\r\n (values, name) => set(values, name, target[name]),\r\n {}\r\n )\r\n\r\n const setFieldValue = (path, value) => {\r\n setFieldValues(previousValues => set(previousValues, path, value))\r\n if(form.current) {\r\n setValid(form.current.checkValidity())\r\n }\r\n }\r\n\r\n const onSubmit = useCallback((e, { additionalValues, validate } = {}) => {\r\n if(validate !== false) {\r\n fieldValidators.forEach(setFieldValidated => setFieldValidated(undefined, fieldValues))\r\n }\r\n\r\n if((validate === false || form.current.checkValidity()) && props.onSubmit) {\r\n setError(undefined)\r\n\r\n const interactiveElements = form.current.querySelectorAll('input,button,textarea,select')\r\n const setFormDisabled = disabled => interactiveElements.forEach(x => x.disabled = disabled)\r\n\r\n const reset = () => {\r\n if(resetOnSubmit) {\r\n setFieldValues(values || {})\r\n }\r\n }\r\n\r\n try {\r\n const checkResultForError = result => {\r\n if(result && (result.success === false || result.error)) {\r\n setError(result.error || result.message || 'Form submission failed')\r\n } else {\r\n reset()\r\n }\r\n return result\r\n }\r\n\r\n const result = props.onSubmit(mapFieldValues({ ...fieldValues, ...additionalValues }))\r\n if(result && typeof result.then === 'function') {\r\n setFormDisabled(true)\r\n result\r\n .then(checkResultForError)\r\n .catch(setError)\r\n .finally(() => setFormDisabled(false))\r\n } else {\r\n reset()\r\n }\r\n } catch(error) {\r\n setError(error)\r\n }\r\n }\r\n\r\n e && e.preventDefault && e.preventDefault()\r\n e && e.stopPropagation && e.stopPropagation()\r\n }, [props, fieldValues])\r\n\r\n const classNames = ['react-forms', props.className]\r\n if(row) {\r\n classNames.push('react-forms-row')\r\n }\r\n\r\n const mergedAdditionalContext = Object.keys(additionalContext).reduce(\r\n (result, property) => ({ ...result, [property]: props[property] || additionalContext[property] }),\r\n {}\r\n )\r\n\r\n return (\r\n createElement('form', {\r\n ...props,\r\n className: classNames.join(' '),\r\n noValidate: true,\r\n onSubmit: onSubmit,\r\n ref: form,\r\n ...(gap && { style: { gap } }),\r\n children: [\r\n createElement(ContextProvider, {\r\n ...props,\r\n key: 'context',\r\n value: {\r\n registerFieldValidator,\r\n setFieldValue,\r\n getFieldValue,\r\n getFieldValues,\r\n onSubmit,\r\n valid,\r\n ...mergedAdditionalContext\r\n }\r\n }),\r\n error && createElement(ErrorMessage, { key: 'error', error }),\r\n createElement('input', {\r\n key: 'submit',\r\n type: 'submit',\r\n style: {\r\n visibility: 'hidden',\r\n position: 'absolute'\r\n }\r\n }),\r\n ]\r\n })\r\n )\r\n }\r\n)\r\nexport default Form"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,O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IAED,oBACE,IAAAC,oBAAa,EAAC,MAAM,EAAAjJ,aAAA,CAAAA,aAAA,CAAAA,aAAA,KACfqF,KAAK;MACRyD,SAAS,EAAED,UAAU,CAACK,IAAI,CAAC,GAAG,CAAC;MAC/BC,UAAU,EAAE,IAAI;MAChBzB,QAAQ,EAAEA,QAAQ;MAClB0B,GAAG,EAAEzC;IAAI,GACLxB,GAAG,IAAI;MAAEkE,KAAK,EAAE;QAAElE,GAAG,EAAHA;MAAI;IAAE,CAAC;MAC7BmE,QAAQ,EAAE,cACR,IAAAL,oBAAa,EAACpE,eAAe,EAAA7E,aAAA,CAAAA,aAAA,KACxBqF,KAAK;QACR9E,GAAG,EAAE,SAAS;QACdM,KAAK,EAAAb,aAAA;UACHkG,sBAAsB,EAAtBA,sBAAsB;UACtBsB,aAAa,EAAbA,aAAa;UACbR,aAAa,EAAbA,aAAa;UACbI,cAAc,EAAdA,cAAc;UACdM,QAAQ,EAARA,QAAQ;UACRjB,KAAK,EAALA;QAAK,GACFsC,uBAAuB;MAC3B,EACF,CAAC,EACF1C,KAAK,iBAAI,IAAA4C,oBAAa,EAAClE,YAAY,EAAE;QAAExE,GAAG,EAAE,OAAO;QAAE8F,KAAK,EAALA;MAAM,CAAC,CAAC,eAC7D,IAAA4C,oBAAa,EAAC,OAAO,EAAE;QACrB1I,GAAG,EAAE,QAAQ;QACbgJ,IAAI,EAAE,QAAQ;QACdF,KAAK,EAAE;UACLG,UAAU,EAAE,QAAQ;UACpBC,QAAQ,EAAE;QACZ;MACF,CAAC,CAAC;IACH,EACF,CAAC;EAEN,CAAC;AAAA,CACF;AAAA,IAAAC,QAAA,GACc9E,IAAI;AAAA+E,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"Form.js","names":["_react","require","_objectPathImmutable","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","key","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","_typeof","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","_toConsumableArray","arr","_arrayWithoutHoles","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","iter","iterator","Array","from","isArray","_arrayLikeToArray","_slicedToArray","i","_arrayWithHoles","_iterableToArrayLimit","_nonIterableRest","minLen","n","prototype","toString","slice","constructor","name","test","len","arr2","l","u","a","f","next","done","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","Form","ContextProvider","additionalContext","ErrorMessage","_ref","resetOnSubmit","row","gap","values","props","_useState","useState","_useState2","fieldValues","setFieldValues","_useReducer","useReducer","validators","validator","concat","_useReducer2","fieldValidators","registerFieldValidator","_useState3","_useState4","error","setError","_useState5","_useState6","valid","setValid","form","createRef","useEffect","current","checkValidity","getFieldValue","useCallback","path","get","getFieldValues","mapFieldValues","reduce","set","setFieldValue","previousValues","onSubmit","_ref2","additionalValues","validate","setFieldValidated","interactiveElements","querySelectorAll","setFormDisabled","disabled","x","reset","checkResultForError","result","success","message","then","preventDefault","stopPropagation","classNames","className","mergedAdditionalContext","property","createElement","join","noValidate","ref","style","children","type","visibility","position","_default","exports"],"sources":["../src/Form.js"],"sourcesContent":["import { createElement, createRef, useCallback, useEffect, useReducer, useState } from 'react'\nimport { get, set } from 'object-path-immutable'\n\nconst Form = (ContextProvider, additionalContext = {}, ErrorMessage) => (\n ({ resetOnSubmit, row, gap, values, ...props }) => {\n const [fieldValues, setFieldValues] = useState(values || {})\n const [fieldValidators, registerFieldValidator] = useReducer((validators, validator) => [...validators, validator], [])\n const [error, setError] = useState()\n const [valid, setValid] = useState()\n const form = createRef()\n\n useEffect(() => {\n if(form.current) {\n setValid(form.current.checkValidity())\n }\n }, [form.current])\n\n const getFieldValue = useCallback(path => get(fieldValues, path), [fieldValues])\n const getFieldValues = useCallback(() => fieldValues, [fieldValues])\n const mapFieldValues = target => Object.keys(target).reduce(\n (values, name) => set(values, name, target[name]),\n {}\n )\n\n const setFieldValue = (path, value) => {\n setFieldValues(previousValues => set(previousValues, path, value))\n if(form.current) {\n setValid(form.current.checkValidity())\n }\n }\n\n const onSubmit = useCallback((e, { additionalValues, validate } = {}) => {\n if(validate !== false) {\n fieldValidators.forEach(setFieldValidated => setFieldValidated(undefined, fieldValues))\n }\n\n if((validate === false || form.current.checkValidity()) && props.onSubmit) {\n setError(undefined)\n\n const interactiveElements = form.current.querySelectorAll('input,button,textarea,select')\n const setFormDisabled = disabled => interactiveElements.forEach(x => x.disabled = disabled)\n\n const reset = () => {\n if(resetOnSubmit) {\n setFieldValues(values || {})\n }\n }\n\n try {\n const checkResultForError = result => {\n if(result && (result.success === false || result.error)) {\n setError(result.error || result.message || 'Form submission failed')\n } else {\n reset()\n }\n return result\n }\n\n const result = props.onSubmit(mapFieldValues({ ...fieldValues, ...additionalValues }))\n if(result && typeof result.then === 'function') {\n setFormDisabled(true)\n result\n .then(checkResultForError)\n .catch(setError)\n .finally(() => setFormDisabled(false))\n } else {\n reset()\n }\n } catch(error) {\n setError(error)\n }\n }\n\n e && e.preventDefault && e.preventDefault()\n e && e.stopPropagation && e.stopPropagation()\n }, [props, fieldValues])\n\n const classNames = ['react-forms', props.className]\n if(row) {\n classNames.push('react-forms-row')\n }\n\n const mergedAdditionalContext = Object.keys(additionalContext).reduce(\n (result, property) => ({ ...result, [property]: props[property] || additionalContext[property] }),\n {}\n )\n\n return (\n createElement('form', {\n ...props,\n className: classNames.join(' '),\n noValidate: true,\n onSubmit: onSubmit,\n ref: form,\n ...(gap && { style: { gap } }),\n children: [\n createElement(ContextProvider, {\n ...props,\n key: 'context',\n value: {\n registerFieldValidator,\n setFieldValue,\n getFieldValue,\n getFieldValues,\n onSubmit,\n valid,\n ...mergedAdditionalContext\n }\n }),\n error && createElement(ErrorMessage, { key: 'error', error }),\n createElement('input', {\n key: 'submit',\n type: 'submit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
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
@@ -8,8 +8,8 @@ exports["default"] = void 0;
8
8
  var _react = require("react");
9
9
  var _excluded = ["name"],
10
10
  _excluded2 = ["groups"];
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
14
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
15
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
@@ -31,6 +31,5 @@ var Group = function Group(formContext) {
31
31
  }));
32
32
  };
33
33
  };
34
- var _default = Group;
35
- exports["default"] = _default;
34
+ var _default = exports["default"] = Group;
36
35
  //# sourceMappingURL=Group.js.map