@sheinx/hooks 3.4.3-beta.9 → 3.4.4-beta.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAyKC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BAVd,MAAM;oCAgED,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAhFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCA4I5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBAjDjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BAVd,MAAM;gCAgED,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCAhFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCA4I5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA+P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AA0BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAyKC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BAVd,MAAM;oCAkED,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAlFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCA8I5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBAnDjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BAVd,MAAM;gCAkED,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCAlFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;iCA8I5D,MAAM;4BAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA+P9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -205,11 +205,13 @@ var useForm = function useForm(props) {
205
205
  }
206
206
  });
207
207
  });
208
- var keys = Object.keys(vals);
209
- keys.forEach(function (key) {
208
+
209
+ // 获取vals的所有key,包括嵌套对象的key
210
+ var fullKeyPaths = (0, _utils.getAllKeyPaths)(vals);
211
+ fullKeyPaths.forEach(function (key) {
210
212
  delete context.serverErrors[key];
211
213
  });
212
- update(keys);
214
+ update(fullKeyPaths);
213
215
  });
214
216
  var getErrors = (0, _usePersistFn.default)(function () {
215
217
  return context.errors;
@@ -13,7 +13,7 @@ declare const useTableLayout: (props: UseTableLayoutProps) => {
13
13
  floatLeft: boolean;
14
14
  floatRight: boolean;
15
15
  scrollBarWidth: number;
16
- colgroup: (number | undefined)[];
16
+ colgroup: (string | number | undefined)[];
17
17
  func: {
18
18
  scrollCheck: () => void;
19
19
  resetColGroup: () => void;
@@ -21,7 +21,7 @@ declare const useTableLayout: (props: UseTableLayoutProps) => {
21
21
  dragCol: (index: number, deltaX: number) => void;
22
22
  checkFloat: () => void;
23
23
  };
24
- width: number | undefined;
24
+ width: string | number | undefined;
25
25
  shouldLastColAuto: boolean | undefined;
26
26
  scrollWidth: number;
27
27
  maxScrollLeft: number;
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA+CX,MAAM,UAAU,MAAM;;;;;;;;CAmO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAerE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA+CX,MAAM,UAAU,MAAM;;;;;;;;CAmO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -11,6 +11,7 @@ var _usePersistFn = _interopRequireDefault(require("../../common/use-persist-fn"
11
11
  var _usePrevious = _interopRequireDefault(require("../../common/use-previous"));
12
12
  var _element = require("../../utils/dom/element");
13
13
  var _is = require("../../utils/is");
14
+ var _number = require("../../utils/number");
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
16
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -161,7 +162,7 @@ var useTableLayout = function useTableLayout(props) {
161
162
  var resizeCol = (0, _usePersistFn.default)(function (index) {
162
163
  if (!props.columnResizable) return;
163
164
  if (!colgroup) return;
164
- var deltaX = context.dragWidth - colgroup[index];
165
+ var deltaX = context.dragWidth - (0, _number.toNum)(colgroup[index]);
165
166
  var newColgroup = _toConsumableArray(colgroup);
166
167
  newColgroup[index] = context.dragWidth;
167
168
  if ((0, _is.isFunc)(props.onColumnResize)) {
@@ -222,20 +223,20 @@ var useTableLayout = function useTableLayout(props) {
222
223
  } else if (emptyNum === 0) {
223
224
  // 都有宽度按照比例分
224
225
  var all = dfWidth.reduce(function (a, b) {
225
- return a + b;
226
+ return (0, _number.toNum)(a) + (0, _number.toNum)(b);
226
227
  }, 0);
227
228
  tempcols = dfWidth.map(function (v) {
228
- return v / all * width;
229
+ return (0, _number.toNum)(v) / (0, _number.toNum)(all) * width;
229
230
  });
230
231
  } else {
231
232
  // 多余的平分
232
233
  var _all = dfWidth.reduce(function (a, b) {
233
- return (a || 0) + (b || 0);
234
+ return (0, _number.toNum)(a) + (0, _number.toNum)(b);
234
235
  }, 0);
235
236
  var rest = width - _all;
236
237
  var agv = rest > 0 ? rest / emptyNum : 0;
237
238
  tempcols = dfWidth.map(function (v) {
238
- return v ? v : agv;
239
+ return v ? (0, _number.toNum)(v) : agv;
239
240
  });
240
241
  }
241
242
  index += colspanNum;
@@ -75,7 +75,7 @@ export interface BaseTableProps<Item> {
75
75
  * @en TThe total width of the table, which defaults to the container width, must not be less than the sum of width set in columns
76
76
  * @cn 表格总宽度,默认为容器宽度,不可小于 columns 中设置的 width 之和
77
77
  */
78
- width?: number;
78
+ width?: number | string;
79
79
  /**
80
80
  * @en controlled expand rows
81
81
  * @cn 展开行受控
@@ -227,7 +227,7 @@ export interface TableColumnItem<DataItem> {
227
227
  * @en width
228
228
  * @cn 列宽
229
229
  */
230
- width?: number;
230
+ width?: number | string;
231
231
  /**
232
232
  * @cn 列对应的类名
233
233
  * @en classname of column
@@ -1 +1 @@
1
- {"version":3,"file":"use-table.type.d.ts","sourceRoot":"","sources":["use-table.type.ts"],"names":[],"mappings":"AAAA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AC;IAEpB;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;IAEvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAEnD;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB,CAAC,QAAQ,CAAE,SAAQ,eAAe,CAAC,QAAQ,CAAC;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC"}
@@ -4,4 +4,5 @@ export declare function validateNumber(num: unknown): boolean;
4
4
  export declare function isE(number: unknown): boolean;
5
5
  export declare function getNumberPrecision(number: unknown): number;
6
6
  export declare function sub(num1: number, num2: number): number;
7
+ export declare function toNum(v: number | string | undefined): number;
7
8
  //# sourceMappingURL=number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["number.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,YAM3C;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAK,UAEtD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,WAgB1C;AACD,wBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,WAIlC;AACD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,UAgBjD;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAY7C"}
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["number.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,YAM3C;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAK,UAEtD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,WAgB1C;AACD,wBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,WAIlC;AACD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,UAgBjD;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAY7C;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAe5D"}
@@ -7,6 +7,7 @@ exports.getNumberPrecision = getNumberPrecision;
7
7
  exports.isE = isE;
8
8
  exports.range = range;
9
9
  exports.sub = sub;
10
+ exports.toNum = toNum;
10
11
  exports.toPrecision = toPrecision;
11
12
  exports.validateNumber = validateNumber;
12
13
  function range(end) {
@@ -70,4 +71,17 @@ function sub(num1, num2) {
70
71
  }
71
72
  var maxPrediction = Math.max(getNumberPrecision(num1), getNumberPrecision(num2));
72
73
  return Number(number.toFixed(maxPrediction));
74
+ }
75
+ function toNum(v) {
76
+ if (v === undefined || v === null) {
77
+ return 0;
78
+ }
79
+ if (typeof v === 'number') {
80
+ return isNaN(v) ? 0 : v;
81
+ }
82
+ if (typeof v === 'string') {
83
+ var parsedValue = parseFloat(v);
84
+ return isNaN(parsedValue) ? 0 : parsedValue;
85
+ }
86
+ return 0;
73
87
  }
@@ -22,5 +22,6 @@ export declare const deepRemove: (target: ObjectType, path: string) => ObjectTyp
22
22
  export declare const deepHas: (target: ObjectType, path: string) => boolean;
23
23
  export declare const entries: (obj: ObjectType) => any[][];
24
24
  export declare const removeProps: <T extends ObjectType, K extends ObjectType>(target: T, remove: K) => Omit<T, keyof K>;
25
+ export declare const getAllKeyPaths: (obj: ObjectType, parentKey?: string) => string[];
25
26
  export {};
26
27
  //# sourceMappingURL=object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;AASD,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAGD,eAAO,MAAM,YAAY,QAAS,UAAU,UAG3C,CAAC;AAGF,eAAO,MAAM,SAAS,2CAEZ,UAAU,YACT,WAAW,eAwBrB,CAAC;AAEF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,+DA4BxC;AAED,UAAU,cAAc;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE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M,OAAO,WAAY,UAAU,QAAQ,MAAM,YAAW,WAAW,YAyB7E,CAAC;AAEF,eAAO,MAAM,UAAU,WAAY,UAAU,QAAQ,MAAM,eA0B1D,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAavD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAS,UAAU,YAItC,CAAC;AAEF,eAAO,MAAM,WAAW,wFAQvB,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,UAAU,cAAa,MAAM,KAAQ,MAAM,EAU9E,CAAC"}
@@ -3,12 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.entries = exports.deepSet = exports.deepRemove = exports.deepMerge = exports.deepHas = exports.deepGet = void 0;
6
+ exports.getAllKeyPaths = exports.entries = exports.deepSet = exports.deepRemove = exports.deepMerge = exports.deepHas = exports.deepGet = void 0;
7
7
  exports.insertPoint = insertPoint;
8
8
  exports.objectValues = void 0;
9
9
  exports.pathGenerator = pathGenerator;
10
10
  exports.removeProps = void 0;
11
11
  var _is = require("./is");
12
+ 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); }
12
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
14
  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."); }
14
15
  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; } }
@@ -268,4 +269,14 @@ var removeProps = exports.removeProps = function removeProps(target, remove) {
268
269
  _iterator5.f();
269
270
  }
270
271
  return a;
272
+ };
273
+ var getAllKeyPaths = exports.getAllKeyPaths = function getAllKeyPaths(obj) {
274
+ var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
275
+ return Object.keys(obj).reduce(function (keys, key) {
276
+ var newKey = parentKey ? "".concat(parentKey, ".").concat(key) : key;
277
+ if (Array.isArray(obj[key])) {
278
+ return keys.concat(newKey);
279
+ }
280
+ return keys.concat(obj[key] !== null && _typeof(obj[key]) === 'object' ? getAllKeyPaths(obj[key], newKey) : newKey);
281
+ }, []);
271
282
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AAyBA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAyKC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BAVd,MAAM;oCAgED,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAhFN,MAAM,GAAG,MAAM,EAAE,mBAAgB,QAAQ,IAAI,CAAC;qCA4I5D,MAAM;gCAzCE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;;;;;;oBAjDjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BAVd,MAAM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16
  import { usePrevious } from "../../common/use-default-value";
17
17
  var globalKey = '__global__&&@@';
18
18
  import { current, produce } from "../../utils/immer";
19
- import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone } from "../../utils";
19
+ import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone, getAllKeyPaths } from "../../utils";
20
20
  var emptyObj = {};
21
21
  var useForm = function useForm(props) {
22
22
  var _props$defaultValue = props.defaultValue,
@@ -196,11 +196,13 @@ var useForm = function useForm(props) {
196
196
  }
197
197
  });
198
198
  });
199
- var keys = Object.keys(vals);
200
- keys.forEach(function (key) {
199
+
200
+ // 获取vals的所有key,包括嵌套对象的key
201
+ var fullKeyPaths = getAllKeyPaths(vals);
202
+ fullKeyPaths.forEach(function (key) {
201
203
  delete context.serverErrors[key];
202
204
  });
203
- update(keys);
205
+ update(fullKeyPaths);
204
206
  });
205
207
  var getErrors = usePersistFn(function () {
206
208
  return context.errors;
@@ -13,7 +13,7 @@ declare const useTableLayout: (props: UseTableLayoutProps) => {
13
13
  floatLeft: boolean;
14
14
  floatRight: boolean;
15
15
  scrollBarWidth: number;
16
- colgroup: (number | undefined)[];
16
+ colgroup: (string | number | undefined)[];
17
17
  func: {
18
18
  scrollCheck: () => void;
19
19
  resetColGroup: () => void;
@@ -21,7 +21,7 @@ declare const useTableLayout: (props: UseTableLayoutProps) => {
21
21
  dragCol: (index: number, deltaX: number) => void;
22
22
  checkFloat: () => void;
23
23
  };
24
- width: number | undefined;
24
+ width: string | number | undefined;
25
25
  shouldLastColAuto: boolean | undefined;
26
26
  scrollWidth: number;
27
27
  maxScrollLeft: number;
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,M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AU,MAAM;;;;;;;;CAmO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -20,6 +20,7 @@ import usePersistFn from "../../common/use-persist-fn";
20
20
  import usePrevious from "../../common/use-previous";
21
21
  import { addResizeObserver } from "../../utils/dom/element";
22
22
  import { isFunc, isNumber } from "../../utils/is";
23
+ import { toNum } from "../../utils/number";
23
24
  var MIN_RESIZABLE_WIDTH = 20;
24
25
  function compareColumnWidth(curCols, preCols) {
25
26
  if (curCols.length !== preCols.length) return false;
@@ -152,7 +153,7 @@ var useTableLayout = function useTableLayout(props) {
152
153
  var resizeCol = usePersistFn(function (index) {
153
154
  if (!props.columnResizable) return;
154
155
  if (!colgroup) return;
155
- var deltaX = context.dragWidth - colgroup[index];
156
+ var deltaX = context.dragWidth - toNum(colgroup[index]);
156
157
  var newColgroup = _toConsumableArray(colgroup);
157
158
  newColgroup[index] = context.dragWidth;
158
159
  if (isFunc(props.onColumnResize)) {
@@ -213,20 +214,20 @@ var useTableLayout = function useTableLayout(props) {
213
214
  } else if (emptyNum === 0) {
214
215
  // 都有宽度按照比例分
215
216
  var all = dfWidth.reduce(function (a, b) {
216
- return a + b;
217
+ return toNum(a) + toNum(b);
217
218
  }, 0);
218
219
  tempcols = dfWidth.map(function (v) {
219
- return v / all * width;
220
+ return toNum(v) / toNum(all) * width;
220
221
  });
221
222
  } else {
222
223
  // 多余的平分
223
224
  var _all = dfWidth.reduce(function (a, b) {
224
- return (a || 0) + (b || 0);
225
+ return toNum(a) + toNum(b);
225
226
  }, 0);
226
227
  var rest = width - _all;
227
228
  var agv = rest > 0 ? rest / emptyNum : 0;
228
229
  tempcols = dfWidth.map(function (v) {
229
- return v ? v : agv;
230
+ return v ? toNum(v) : agv;
230
231
  });
231
232
  }
232
233
  index += colspanNum;
@@ -75,7 +75,7 @@ export interface BaseTableProps<Item> {
75
75
  * @en TThe total width of the table, which defaults to the container width, must not be less than the sum of width set in columns
76
76
  * @cn 表格总宽度,默认为容器宽度,不可小于 columns 中设置的 width 之和
77
77
  */
78
- width?: number;
78
+ width?: number | string;
79
79
  /**
80
80
  * @en controlled expand rows
81
81
  * @cn 展开行受控
@@ -227,7 +227,7 @@ export interface TableColumnItem<DataItem> {
227
227
  * @en width
228
228
  * @cn 列宽
229
229
  */
230
- width?: number;
230
+ width?: number | string;
231
231
  /**
232
232
  * @cn 列对应的类名
233
233
  * @en classname of column
@@ -1 +1 @@
1
- {"version":3,"file":"use-table.type.d.ts","sourceRoot":"","sources":["use-table.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,CAAC;AAC9C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAC9C,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAEnE,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,YAAY,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB;AACD,MAAM,WAAW,cAAc,CAAC,IAAI;IAClC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,YAAY,EAAE,CAAC;IACvC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9F;;;OAGG;IACH,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACd;;;;;;;;;;OAUG;I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CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC"}
@@ -4,4 +4,5 @@ export declare function validateNumber(num: unknown): boolean;
4
4
  export declare function isE(number: unknown): boolean;
5
5
  export declare function getNumberPrecision(number: unknown): number;
6
6
  export declare function sub(num1: number, num2: number): number;
7
+ export declare function toNum(v: number | string | undefined): number;
7
8
  //# sourceMappingURL=number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["number.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,YAM3C;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAK,UAEtD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,WAgB1C;AACD,wBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,WAIlC;AACD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,UAgBjD;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAY7C"}
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["number.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,YAM3C;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAK,UAEtD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,WAgB1C;AACD,wBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,WAIlC;AACD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,UAgBjD;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAY7C;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAe5D"}
@@ -59,4 +59,17 @@ export function sub(num1, num2) {
59
59
  }
60
60
  var maxPrediction = Math.max(getNumberPrecision(num1), getNumberPrecision(num2));
61
61
  return Number(number.toFixed(maxPrediction));
62
+ }
63
+ export function toNum(v) {
64
+ if (v === undefined || v === null) {
65
+ return 0;
66
+ }
67
+ if (typeof v === 'number') {
68
+ return isNaN(v) ? 0 : v;
69
+ }
70
+ if (typeof v === 'string') {
71
+ var parsedValue = parseFloat(v);
72
+ return isNaN(parsedValue) ? 0 : parsedValue;
73
+ }
74
+ return 0;
62
75
  }
@@ -22,5 +22,6 @@ export declare const deepRemove: (target: ObjectType, path: string) => ObjectTyp
22
22
  export declare const deepHas: (target: ObjectType, path: string) => boolean;
23
23
  export declare const entries: (obj: ObjectType) => any[][];
24
24
  export declare const removeProps: <T extends ObjectType, K extends ObjectType>(target: T, remove: K) => Omit<T, keyof K>;
25
+ export declare const getAllKeyPaths: (obj: ObjectType, parentKey?: string) => string[];
25
26
  export {};
26
27
  //# sourceMappingURL=object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAGvC;AASD,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAGD,eAAO,MAAM,YAAY,QAAS,UAAU,UAG3C,CAAC;AAGF,eAAO,MAAM,SAAS,2CAEZ,UAAU,YACT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OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,OAAO,WACV,UAAU,QACZ,MAAM,SACL,GAAG,YACD,cAAc,eAiDxB,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAAW,WAAW,YAyB7E,CAAC;AAEF,eAAO,MAAM,UAAU,WAAY,UAAU,QAAQ,MAAM,eA0B1D,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,UAAU,QAAQ,MAAM,YAavD,CAAC;AAEF,eAAO,MAAM,OAAO,QAAS,UAAU,YAItC,CAAC;AAEF,eAAO,MAAM,WAAW,wFAQvB,CAAC;AAEF,eAAO,MAAM,cAAc,QAAS,UAAU,cAAa,MAAM,KAAQ,MAAM,EAU9E,CAAC"}
@@ -1,3 +1,4 @@
1
+ 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
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
3
  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."); }
3
4
  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; } }
@@ -258,4 +259,14 @@ export var removeProps = function removeProps(target, remove) {
258
259
  _iterator5.f();
259
260
  }
260
261
  return a;
262
+ };
263
+ export var getAllKeyPaths = function getAllKeyPaths(obj) {
264
+ var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
265
+ return Object.keys(obj).reduce(function (keys, key) {
266
+ var newKey = parentKey ? "".concat(parentKey, ".").concat(key) : key;
267
+ if (Array.isArray(obj[key])) {
268
+ return keys.concat(newKey);
269
+ }
270
+ return keys.concat(obj[key] !== null && _typeof(obj[key]) === 'object' ? getAllKeyPaths(obj[key], newKey) : newKey);
271
+ }, []);
261
272
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.4.3-beta.9",
3
+ "version": "3.4.4-beta.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",