@sheinx/hooks 3.1.9 → 3.1.11
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts +1 -1
- package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-flow/use-form-datum.js +13 -1
- package/cjs/components/use-form/use-form.js +2 -1
- package/esm/components/use-form/use-form-flow/use-form-datum.d.ts +1 -1
- package/esm/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
- package/esm/components/use-form/use-form-flow/use-form-datum.js +13 -1
- package/esm/components/use-form/use-form.js +2 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
@@ -5,12 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
var _useLatestObj = _interopRequireDefault(require("../../../common/use-latest-obj"));
|
8
|
+
var _usePersistFn = require("../../../common/use-persist-fn");
|
8
9
|
var _formFuncContext = require("../form-func-context");
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
+
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; }
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
14
|
+
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); }
|
10
15
|
var useFormDatum = function useFormDatum() {
|
11
16
|
var formFunc = (0, _formFuncContext.useFormFunc)();
|
17
|
+
var set = (0, _usePersistFn.usePersistFn)(function (vals, value) {
|
18
|
+
if (_typeof(vals) === 'object') {
|
19
|
+
formFunc === null || formFunc === void 0 || formFunc.setValue(vals);
|
20
|
+
} else {
|
21
|
+
formFunc === null || formFunc === void 0 || formFunc.setValue(_defineProperty({}, vals, value));
|
22
|
+
}
|
23
|
+
});
|
12
24
|
var func = (0, _useLatestObj.default)({
|
13
|
-
set:
|
25
|
+
set: set,
|
14
26
|
get: formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue
|
15
27
|
});
|
16
28
|
var datum = formFunc ? func : undefined;
|
@@ -26,6 +26,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
26
26
|
var globalKey = '__global__&&@@';
|
27
27
|
var emptyObj = {};
|
28
28
|
var useForm = function useForm(props) {
|
29
|
+
var _props$value;
|
29
30
|
var _props$defaultValue = props.defaultValue,
|
30
31
|
defaultValue = _props$defaultValue === void 0 ? {} : _props$defaultValue,
|
31
32
|
labelWidth = props.labelWidth,
|
@@ -57,7 +58,7 @@ var useForm = function useForm(props) {
|
|
57
58
|
removeArr: new Set(),
|
58
59
|
names: new Set(),
|
59
60
|
submitLock: false,
|
60
|
-
value: props.value || emptyObj,
|
61
|
+
value: ((_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : (0, _utils.deepClone)(props.value)) || emptyObj,
|
61
62
|
errors: {},
|
62
63
|
serverErrors: {},
|
63
64
|
lastValue: props.value || emptyObj,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
@@ -1,9 +1,21 @@
|
|
1
|
+
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; }
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
3
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
|
+
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); }
|
1
5
|
import useLatestObj from "../../../common/use-latest-obj";
|
6
|
+
import { usePersistFn } from "../../../common/use-persist-fn";
|
2
7
|
import { useFormFunc } from "../form-func-context";
|
3
8
|
var useFormDatum = function useFormDatum() {
|
4
9
|
var formFunc = useFormFunc();
|
10
|
+
var set = usePersistFn(function (vals, value) {
|
11
|
+
if (_typeof(vals) === 'object') {
|
12
|
+
formFunc === null || formFunc === void 0 || formFunc.setValue(vals);
|
13
|
+
} else {
|
14
|
+
formFunc === null || formFunc === void 0 || formFunc.setValue(_defineProperty({}, vals, value));
|
15
|
+
}
|
16
|
+
});
|
5
17
|
var func = useLatestObj({
|
6
|
-
set:
|
18
|
+
set: set,
|
7
19
|
get: formFunc === null || formFunc === void 0 ? void 0 : formFunc.getValue
|
8
20
|
});
|
9
21
|
var datum = formFunc ? func : undefined;
|
@@ -17,6 +17,7 @@ import { current, produce } from "../../utils/immer";
|
|
17
17
|
import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone } from "../../utils";
|
18
18
|
var emptyObj = {};
|
19
19
|
var useForm = function useForm(props) {
|
20
|
+
var _props$value;
|
20
21
|
var _props$defaultValue = props.defaultValue,
|
21
22
|
defaultValue = _props$defaultValue === void 0 ? {} : _props$defaultValue,
|
22
23
|
labelWidth = props.labelWidth,
|
@@ -48,7 +49,7 @@ var useForm = function useForm(props) {
|
|
48
49
|
removeArr: new Set(),
|
49
50
|
names: new Set(),
|
50
51
|
submitLock: false,
|
51
|
-
value: props.value || emptyObj,
|
52
|
+
value: ((_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : deepClone(props.value)) || emptyObj,
|
52
53
|
errors: {},
|
53
54
|
serverErrors: {},
|
54
55
|
lastValue: props.value || emptyObj,
|