@danderson00/react-forms 0.0.41 → 0.0.42
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/dist/ErrorMessage.js +0 -5
- package/dist/ErrorMessage.js.map +1 -1
- package/dist/Form.js +19 -62
- package/dist/Form.js.map +1 -1
- package/dist/Group.js +5 -17
- package/dist/Group.js.map +1 -1
- package/dist/fields.js +70 -0
- package/dist/index.js +3 -28
- package/dist/index.js.map +1 -1
- package/dist/injectCss.js +0 -2
- package/dist/injectCss.js.map +1 -1
- package/dist/input.js +69 -112
- package/dist/input.js.map +1 -1
- package/dist/inputTypes.js +7 -17
- package/dist/inputTypes.js.map +1 -1
- package/dist/styles.js +0 -2
- package/dist/styles.js.map +1 -1
- package/dist/submit.js +14 -37
- package/dist/submit.js.map +1 -1
- package/dist/throttle.js +0 -3
- package/dist/throttle.js.map +1 -1
- package/dist/useForm.js +2 -6
- package/dist/useForm.js.map +1 -1
- package/dist/useFormValues.js +0 -3
- package/dist/useFormValues.js.map +1 -1
- package/dist/usePrevious.js +0 -2
- package/dist/usePrevious.js.map +1 -1
- package/dist/useUpdate.js +0 -2
- package/dist/useUpdate.js.map +1 -1
- package/package.json +1 -1
- package/src/input.js +3 -3
package/dist/submit.js
CHANGED
|
@@ -1,69 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
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); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _excluded = ["onSubmit", "registerFieldValidator", "setFieldValue", "getFieldValue", "getFieldValues", "valid", "validate", "disableInvalid", "values"];
|
|
13
|
-
|
|
14
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
|
|
16
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
18
12
|
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; }
|
|
19
|
-
|
|
20
13
|
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; }
|
|
21
|
-
|
|
22
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
15
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
25
|
-
|
|
26
16
|
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."); }
|
|
27
|
-
|
|
28
17
|
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); }
|
|
29
|
-
|
|
30
18
|
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; }
|
|
31
|
-
|
|
32
19
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
33
|
-
|
|
34
20
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
35
|
-
|
|
36
21
|
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; }
|
|
37
|
-
|
|
38
22
|
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; }
|
|
39
|
-
|
|
40
23
|
var _default = function _default(render) {
|
|
41
24
|
return function Submit(props) {
|
|
42
25
|
if (!props.onSubmit) throw new Error('Button components must be contained within a Form component');
|
|
43
|
-
|
|
44
26
|
var onSubmit = props.onSubmit,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
27
|
+
registerFieldValidator = props.registerFieldValidator,
|
|
28
|
+
setFieldValue = props.setFieldValue,
|
|
29
|
+
getFieldValue = props.getFieldValue,
|
|
30
|
+
getFieldValues = props.getFieldValues,
|
|
31
|
+
valid = props.valid,
|
|
32
|
+
validate = props.validate,
|
|
33
|
+
disableInvalid = props.disableInvalid,
|
|
34
|
+
values = props.values,
|
|
35
|
+
propsToPass = _objectWithoutProperties(props, _excluded);
|
|
36
|
+
|
|
37
|
+
// TODO: set executing when form is triggered by enter key
|
|
56
38
|
var _useState = (0, _react.useState)(false),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
+
executing = _useState2[0],
|
|
41
|
+
setExecuting = _useState2[1];
|
|
61
42
|
var onClick = function onClick(e) {
|
|
62
43
|
var result = onSubmit(e, {
|
|
63
44
|
validate: validate,
|
|
64
45
|
additionalValues: values
|
|
65
46
|
});
|
|
66
|
-
|
|
67
47
|
if (result && result["finally"] && typeof result["finally"] === 'function') {
|
|
68
48
|
setExecuting(true);
|
|
69
49
|
result["finally"](function () {
|
|
@@ -71,15 +51,12 @@ var _default = function _default(render) {
|
|
|
71
51
|
});
|
|
72
52
|
}
|
|
73
53
|
};
|
|
74
|
-
|
|
75
54
|
var finalProps = _objectSpread(_objectSpread({}, propsToPass), {}, {
|
|
76
55
|
onClick: onClick,
|
|
77
56
|
disabled: props.disabled || executing || disableInvalid && !valid
|
|
78
57
|
});
|
|
79
|
-
|
|
80
58
|
return render(finalProps);
|
|
81
59
|
};
|
|
82
60
|
};
|
|
83
|
-
|
|
84
61
|
exports["default"] = _default;
|
|
85
62
|
//# sourceMappingURL=submit.js.map
|
package/dist/submit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submit.js","names":["render","Submit","props","onSubmit","Error","registerFieldValidator","setFieldValue","getFieldValue","getFieldValues","valid","validate","disableInvalid","values","propsToPass","useState","executing","setExecuting","onClick","e","result","additionalValues","finalProps","disabled"],"sources":["../src/submit.js"],"sourcesContent":["import React, { useState } from 'react'\n\nexport default render => function Submit(props) {\n if(!props.onSubmit) throw new Error('Button components must be contained within a Form component')\n\n const {\n onSubmit, registerFieldValidator, setFieldValue, getFieldValue, getFieldValues,\n valid, validate, disableInvalid, values, ...propsToPass\n } = props\n\n // TODO: set executing when form is triggered by enter key\n const [executing, setExecuting] = useState(false)\n\n const onClick = e => {\n const result = onSubmit(e, { validate, additionalValues: values })\n if(result && result.finally && typeof result.finally === 'function') {\n setExecuting(true)\n result.finally(() => setExecuting(false))\n }\n }\n\n const finalProps = {\n ...propsToPass,\n onClick,\n disabled: props.disabled || executing || (disableInvalid && !valid)\n }\n\n return render(finalProps)\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"submit.js","names":["render","Submit","props","onSubmit","Error","registerFieldValidator","setFieldValue","getFieldValue","getFieldValues","valid","validate","disableInvalid","values","propsToPass","useState","executing","setExecuting","onClick","e","result","additionalValues","finalProps","disabled"],"sources":["../src/submit.js"],"sourcesContent":["import React, { useState } from 'react'\n\nexport default render => function Submit(props) {\n if(!props.onSubmit) throw new Error('Button components must be contained within a Form component')\n\n const {\n onSubmit, registerFieldValidator, setFieldValue, getFieldValue, getFieldValues,\n valid, validate, disableInvalid, values, ...propsToPass\n } = props\n\n // TODO: set executing when form is triggered by enter key\n const [executing, setExecuting] = useState(false)\n\n const onClick = e => {\n const result = onSubmit(e, { validate, additionalValues: values })\n if(result && result.finally && typeof result.finally === 'function') {\n setExecuting(true)\n result.finally(() => setExecuting(false))\n }\n }\n\n const finalProps = {\n ...propsToPass,\n onClick,\n disabled: props.disabled || executing || (disableInvalid && !valid)\n }\n\n return render(finalProps)\n}\n"],"mappings":";;;;;;;AAAA;AAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAExB,kBAAAA,MAAM;EAAA,OAAI,SAASC,MAAM,CAACC,KAAK,EAAE;IAC9C,IAAG,CAACA,KAAK,CAACC,QAAQ,EAAE,MAAM,IAAIC,KAAK,CAAC,6DAA6D,CAAC;IAElG,IACED,QAAQ,GAEND,KAAK,CAFPC,QAAQ;MAAEE,sBAAsB,GAE9BH,KAAK,CAFGG,sBAAsB;MAAEC,aAAa,GAE7CJ,KAAK,CAF2BI,aAAa;MAAEC,aAAa,GAE5DL,KAAK,CAF0CK,aAAa;MAAEC,cAAc,GAE5EN,KAAK,CAFyDM,cAAc;MAC9EC,KAAK,GACHP,KAAK,CADPO,KAAK;MAAEC,QAAQ,GACbR,KAAK,CADAQ,QAAQ;MAAEC,cAAc,GAC7BT,KAAK,CADUS,cAAc;MAAEC,MAAM,GACrCV,KAAK,CAD0BU,MAAM;MAAKC,WAAW,4BACrDX,KAAK;;IAET;IACA,gBAAkC,IAAAY,eAAQ,EAAC,KAAK,CAAC;MAAA;MAA1CC,SAAS;MAAEC,YAAY;IAE9B,IAAMC,OAAO,GAAG,SAAVA,OAAO,CAAGC,CAAC,EAAI;MACnB,IAAMC,MAAM,GAAGhB,QAAQ,CAACe,CAAC,EAAE;QAAER,QAAQ,EAARA,QAAQ;QAAEU,gBAAgB,EAAER;MAAO,CAAC,CAAC;MAClE,IAAGO,MAAM,IAAIA,MAAM,WAAQ,IAAI,OAAOA,MAAM,WAAQ,KAAK,UAAU,EAAE;QACnEH,YAAY,CAAC,IAAI,CAAC;QAClBG,MAAM,WAAQ,CAAC;UAAA,OAAMH,YAAY,CAAC,KAAK,CAAC;QAAA,EAAC;MAC3C;IACF,CAAC;IAED,IAAMK,UAAU,mCACXR,WAAW;MACdI,OAAO,EAAPA,OAAO;MACPK,QAAQ,EAAEpB,KAAK,CAACoB,QAAQ,IAAIP,SAAS,IAAKJ,cAAc,IAAI,CAACF;IAAM,EACpE;IAED,OAAOT,MAAM,CAACqB,UAAU,CAAC;EAC3B,CAAC;AAAA;AAAA"}
|
package/dist/throttle.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _default = function _default(target) {
|
|
9
8
|
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
|
|
10
9
|
var timeout;
|
|
@@ -12,13 +11,11 @@ var _default = function _default(target) {
|
|
|
12
11
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
12
|
args[_key] = arguments[_key];
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
clearTimeout(timeout);
|
|
17
15
|
timeout = setTimeout(function () {
|
|
18
16
|
return target.apply(void 0, args);
|
|
19
17
|
}, delay);
|
|
20
18
|
};
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
exports["default"] = _default;
|
|
24
21
|
//# sourceMappingURL=throttle.js.map
|
package/dist/throttle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.js","names":["target","delay","timeout","args","clearTimeout","setTimeout"],"sources":["../src/throttle.js"],"sourcesContent":["export default (target, delay = 200) => {\n let timeout\n\n return (...args) => {\n clearTimeout(timeout)\n timeout = setTimeout(\n () => target(...args),\n delay\n )\n }\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"throttle.js","names":["target","delay","timeout","args","clearTimeout","setTimeout"],"sources":["../src/throttle.js"],"sourcesContent":["export default (target, delay = 200) => {\n let timeout\n\n return (...args) => {\n clearTimeout(timeout)\n timeout = setTimeout(\n () => target(...args),\n delay\n )\n }\n}"],"mappings":";;;;;;eAAe,kBAACA,MAAM,EAAkB;EAAA,IAAhBC,KAAK,uEAAG,GAAG;EACjC,IAAIC,OAAO;EAEX,OAAO,YAAa;IAAA,kCAATC,IAAI;MAAJA,IAAI;IAAA;IACbC,YAAY,CAACF,OAAO,CAAC;IACrBA,OAAO,GAAGG,UAAU,CAClB;MAAA,OAAML,MAAM,eAAIG,IAAI,CAAC;IAAA,GACrBF,KAAK,CACN;EACH,CAAC;AACH,CAAC;AAAA"}
|
package/dist/useForm.js
CHANGED
|
@@ -4,15 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _default = function _default(context) {
|
|
11
9
|
return function useForm() {
|
|
12
10
|
var _useContext = (0, _react.useContext)(context),
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
onSubmit = _useContext.onSubmit,
|
|
12
|
+
getFieldValues = _useContext.getFieldValues;
|
|
16
13
|
return {
|
|
17
14
|
submit: function submit(options) {
|
|
18
15
|
return onSubmit(undefined, options);
|
|
@@ -23,6 +20,5 @@ var _default = function _default(context) {
|
|
|
23
20
|
};
|
|
24
21
|
};
|
|
25
22
|
};
|
|
26
|
-
|
|
27
23
|
exports["default"] = _default;
|
|
28
24
|
//# sourceMappingURL=useForm.js.map
|
package/dist/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","names":["context","useForm","useContext","onSubmit","getFieldValues","submit","options","undefined","values"],"sources":["../src/useForm.js"],"sourcesContent":["import { useContext } from 'react'\n\nexport default context => function useForm() {\n const { onSubmit, getFieldValues } = useContext(context)\n\n return {\n submit: options => onSubmit(undefined, options),\n values: () => getFieldValues()\n }\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useForm.js","names":["context","useForm","useContext","onSubmit","getFieldValues","submit","options","undefined","values"],"sources":["../src/useForm.js"],"sourcesContent":["import { useContext } from 'react'\n\nexport default context => function useForm() {\n const { onSubmit, getFieldValues } = useContext(context)\n\n return {\n submit: options => onSubmit(undefined, options),\n values: () => getFieldValues()\n }\n}"],"mappings":";;;;;;AAAA;AAAkC,eAEnB,kBAAAA,OAAO;EAAA,OAAI,SAASC,OAAO,GAAG;IAC3C,kBAAqC,IAAAC,iBAAU,EAACF,OAAO,CAAC;MAAhDG,QAAQ,eAARA,QAAQ;MAAEC,cAAc,eAAdA,cAAc;IAEhC,OAAO;MACLC,MAAM,EAAE,gBAAAC,OAAO;QAAA,OAAIH,QAAQ,CAACI,SAAS,EAAED,OAAO,CAAC;MAAA;MAC/CE,MAAM,EAAE;QAAA,OAAMJ,cAAc,EAAE;MAAA;IAChC,CAAC;EACH,CAAC;AAAA;AAAA"}
|
package/dist/useFormValues.js
CHANGED
|
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _default = function _default(context) {
|
|
11
9
|
return function useFormValues() {
|
|
12
10
|
return (0, _react.useContext)(context).getFieldValues();
|
|
13
11
|
};
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
exports["default"] = _default;
|
|
17
14
|
//# sourceMappingURL=useFormValues.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormValues.js","names":["context","useFormValues","useContext","getFieldValues"],"sources":["../src/useFormValues.js"],"sourcesContent":["import { useContext } from 'react'\n\nexport default context => function useFormValues() {\n return useContext(context).getFieldValues()\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFormValues.js","names":["context","useFormValues","useContext","getFieldValues"],"sources":["../src/useFormValues.js"],"sourcesContent":["import { useContext } from 'react'\n\nexport default context => function useFormValues() {\n return useContext(context).getFieldValues()\n}"],"mappings":";;;;;;AAAA;AAAkC,eAEnB,kBAAAA,OAAO;EAAA,OAAI,SAASC,aAAa,GAAG;IACjD,OAAO,IAAAC,iBAAU,EAACF,OAAO,CAAC,CAACG,cAAc,EAAE;EAC7C,CAAC;AAAA;AAAA"}
|
package/dist/usePrevious.js
CHANGED
package/dist/usePrevious.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrevious.js","names":["usePrevious","value","ref","useRef","useEffect","current"],"sources":["../src/usePrevious.js"],"sourcesContent":["import { useRef, useEffect } from 'react'\n\nexport default function usePrevious(value) {\n const ref = useRef()\n useEffect(() => {\n ref.current = value\n })\n return ref.current\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePrevious.js","names":["usePrevious","value","ref","useRef","useEffect","current"],"sources":["../src/usePrevious.js"],"sourcesContent":["import { useRef, useEffect } from 'react'\n\nexport default function usePrevious(value) {\n const ref = useRef()\n useEffect(() => {\n ref.current = value\n })\n return ref.current\n}"],"mappings":";;;;;;AAAA;AAEe,SAASA,WAAW,CAACC,KAAK,EAAE;EACzC,IAAMC,GAAG,GAAG,IAAAC,aAAM,GAAE;EACpB,IAAAC,gBAAS,EAAC,YAAM;IACdF,GAAG,CAACG,OAAO,GAAGJ,KAAK;EACrB,CAAC,CAAC;EACF,OAAOC,GAAG,CAACG,OAAO;AACpB"}
|
package/dist/useUpdate.js
CHANGED
package/dist/useUpdate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUpdate.js","names":["useUpdate","hook","inputs","didMountRef","useRef","useEffect","current"],"sources":["../src/useUpdate.js"],"sourcesContent":["import { useRef, useEffect } from 'react'\n\nexport default function useUpdate(hook, inputs) {\n const didMountRef = useRef(false)\n\n useEffect(() => {\n if (didMountRef.current)\n hook()\n else\n didMountRef.current = true\n }, inputs)\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUpdate.js","names":["useUpdate","hook","inputs","didMountRef","useRef","useEffect","current"],"sources":["../src/useUpdate.js"],"sourcesContent":["import { useRef, useEffect } from 'react'\n\nexport default function useUpdate(hook, inputs) {\n const didMountRef = useRef(false)\n\n useEffect(() => {\n if (didMountRef.current)\n hook()\n else\n didMountRef.current = true\n }, inputs)\n}"],"mappings":";;;;;;AAAA;AAEe,SAASA,SAAS,CAACC,IAAI,EAAEC,MAAM,EAAE;EAC9C,IAAMC,WAAW,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EAEjC,IAAAC,gBAAS,EAAC,YAAM;IACd,IAAIF,WAAW,CAACG,OAAO,EACrBL,IAAI,EAAE,MAENE,WAAW,CAACG,OAAO,GAAG,IAAI;EAC9B,CAAC,EAAEJ,MAAM,CAAC;AACZ"}
|
package/package.json
CHANGED
package/src/input.js
CHANGED
|
@@ -43,14 +43,14 @@ export default (render, options = {}) => function Input(props) {
|
|
|
43
43
|
|
|
44
44
|
// ensure form values are updated to reflect passed `value` prop
|
|
45
45
|
// this probably introduces some redundancy with the onChange handler below
|
|
46
|
+
const { type, checked, value, defaultValue, setFieldValue } = props
|
|
46
47
|
useUpdate(() => {
|
|
47
|
-
const { value, setFieldValue }
|
|
48
|
-
const { applyValueTransforms } = types(props, options)
|
|
48
|
+
const { applyValueTransforms } = types({ type, checked, value, defaultValue, setFieldValue }, options)
|
|
49
49
|
|
|
50
50
|
if(value !== previousValueProp) {
|
|
51
51
|
setFieldValue(name, applyValueTransforms(value))
|
|
52
52
|
}
|
|
53
|
-
}, [
|
|
53
|
+
}, [type, checked, value, defaultValue, setFieldValue])
|
|
54
54
|
|
|
55
55
|
// TODO: refactor bubbling to prop pattern
|
|
56
56
|
const onChange = (...args) => {
|