@sheinx/hooks 3.5.0 → 3.5.1-beta.2

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.
Files changed (25) hide show
  1. package/cjs/components/use-form/Provider.js +2 -1
  2. package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  3. package/cjs/components/use-form/use-form-control/use-form-control.js +16 -2
  4. package/cjs/components/use-form/use-form-fieldset/fieldset-context.d.ts +2 -0
  5. package/cjs/components/use-form/use-form-fieldset/fieldset-context.d.ts.map +1 -1
  6. package/cjs/components/use-form/use-form-fieldset/fieldset-context.js +6 -3
  7. package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.d.ts +2 -0
  8. package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
  9. package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.js +2 -1
  10. package/cjs/components/use-form/use-form.d.ts.map +1 -1
  11. package/cjs/components/use-table/use-table-layout.d.ts.map +1 -1
  12. package/cjs/components/use-table/use-table-layout.js +10 -1
  13. package/esm/components/use-form/Provider.js +2 -1
  14. package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  15. package/esm/components/use-form/use-form-control/use-form-control.js +16 -2
  16. package/esm/components/use-form/use-form-fieldset/fieldset-context.d.ts +2 -0
  17. package/esm/components/use-form/use-form-fieldset/fieldset-context.d.ts.map +1 -1
  18. package/esm/components/use-form/use-form-fieldset/fieldset-context.js +6 -3
  19. package/esm/components/use-form/use-form-fieldset/use-form-fieldset.d.ts +2 -0
  20. package/esm/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
  21. package/esm/components/use-form/use-form-fieldset/use-form-fieldset.js +2 -1
  22. package/esm/components/use-form/use-form.d.ts.map +1 -1
  23. package/esm/components/use-table/use-table-layout.d.ts.map +1 -1
  24. package/esm/components/use-table/use-table-layout.js +10 -1
  25. package/package.json +1 -1
@@ -15,7 +15,8 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
15
15
  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; }
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
  var topPath = {
18
- path: ''
18
+ path: '',
19
+ validateFieldSet: function validateFieldSet() {}
19
20
  };
20
21
  var Provider = exports.Provider = function Provider(props) {
21
22
  var children = props.children,
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBA2IpC,CAAC,YAAY,GAAG,EAAE;;;;;EAiDrD"}
1
+ {"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAsJpC,CAAC,YAAY,GAAG,EAAE;;;;;EAkDrD"}
@@ -61,7 +61,8 @@ function useFormControl(props) {
61
61
  bind: props.bind
62
62
  }),
63
63
  name = _useFieldSetConsumer.name,
64
- bind = _useFieldSetConsumer.bind;
64
+ bind = _useFieldSetConsumer.bind,
65
+ validateFieldSet = _useFieldSetConsumer.validateFieldSet;
65
66
  var _React$useState = _react.default.useState(undefined),
66
67
  _React$useState2 = _slicedToArray(_React$useState, 2),
67
68
  errorState = _React$useState2[0],
@@ -158,7 +159,19 @@ function useFormControl(props) {
158
159
  bindValidate();
159
160
  return res;
160
161
  }).catch(function (e) {
161
- formFunc === null || formFunc === void 0 || formFunc.setError(name, e);
162
+ if ((0, _is.isArray)(e)) {
163
+ e.forEach(function (error, index) {
164
+ if (error) {
165
+ var _Object$keys, _Object$values;
166
+ var fieldSetName = (_Object$keys = Object.keys(error)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
167
+ var fieldSetError = (_Object$values = Object.values(error)) === null || _Object$values === void 0 ? void 0 : _Object$values[0];
168
+ var na = "".concat(name, "[").concat(index, "].").concat(fieldSetName);
169
+ if (fieldSetName && fieldSetError) {
170
+ formFunc === null || formFunc === void 0 || formFunc.setError(na, fieldSetError);
171
+ }
172
+ }
173
+ });
174
+ }
162
175
  onError === null || onError === void 0 || onError(e);
163
176
  bindValidate();
164
177
  return e;
@@ -199,6 +212,7 @@ function useFormControl(props) {
199
212
  other[_key - 1] = arguments[_key];
200
213
  }
201
214
  if (onChangePo) onChangePo.apply(void 0, [v].concat(other));
215
+ if (validateFieldSet) validateFieldSet();
202
216
  });
203
217
  (0, _react.useEffect)(function () {
204
218
  if (inForm && controlFunc) {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  declare const FieldsetContext: React.Context<{
3
3
  path: string;
4
+ validateFieldSet: () => void;
4
5
  }>;
5
6
  interface BaseFieldProps {
6
7
  bind?: string[];
@@ -9,6 +10,7 @@ interface BaseFieldProps {
9
10
  export declare const useFieldSetConsumer: <T extends BaseFieldProps>(props: T) => T & {
10
11
  name: string;
11
12
  bind: string[] | undefined;
13
+ validateFieldSet: () => void;
12
14
  };
13
15
  export default FieldsetContext;
14
16
  //# sourceMappingURL=fieldset-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fieldset-context.d.ts","sourceRoot":"","sources":["fieldset-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,QAAA,MAAM,eAAe;;EAA8B,CAAC;AAEpD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAiBD,eAAO,MAAM,mBAAmB;;;CAc/B,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"fieldset-context.d.ts","sourceRoot":"","sources":["fieldset-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,QAAA,MAAM,eAAe;;;EAA0D,CAAC;AAEhF,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAiBD,eAAO,MAAM,mBAAmB;;;;CAe/B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -15,7 +15,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
15
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
16
  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); }
17
17
  var FieldsetContext = /*#__PURE__*/(0, _react.createContext)({
18
- path: ''
18
+ path: '',
19
+ validateFieldSet: function validateFieldSet() {}
19
20
  });
20
21
  function extendName() {
21
22
  var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
@@ -31,7 +32,8 @@ function extendName() {
31
32
  }
32
33
  var useFieldSetConsumer = exports.useFieldSetConsumer = function useFieldSetConsumer(props) {
33
34
  var _React$useContext = _react.default.useContext(FieldsetContext),
34
- path = _React$useContext.path;
35
+ path = _React$useContext.path,
36
+ validateFieldSet = _React$useContext.validateFieldSet;
35
37
  var bind = _react.default.useMemo(function () {
36
38
  return path ? (props.bind || []).concat(path) : props.bind;
37
39
  }, [path, props.bind]);
@@ -40,7 +42,8 @@ var useFieldSetConsumer = exports.useFieldSetConsumer = function useFieldSetCons
40
42
  }, [path, props.name]);
41
43
  return _objectSpread(_objectSpread({}, props), {}, {
42
44
  name: name,
43
- bind: bind
45
+ bind: bind,
46
+ validateFieldSet: validateFieldSet
44
47
  });
45
48
  };
46
49
  var _default = exports.default = FieldsetContext;
@@ -3,9 +3,11 @@ import { BaseFormFieldSetProps } from './use-form-fieldset.type';
3
3
  export declare const useFormFieldSet: <T>(props: BaseFormFieldSetProps<T>) => {
4
4
  Provider: import("react").Provider<{
5
5
  path: string;
6
+ validateFieldSet: () => void;
6
7
  }>;
7
8
  ProviderValue: {
8
9
  path: string | (string[] & string);
10
+ validateFieldSet: () => void;
9
11
  };
10
12
  error: Error | undefined;
11
13
  value: T | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,eAAe;;;;;;;;;;;CA2B3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,eAAe;;;;;;;;;;;;;CA4B3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -29,7 +29,8 @@ var useFormFieldSet = exports.useFormFieldSet = function useFormFieldSet(props)
29
29
  console.error('[FieldSet] should render in Form');
30
30
  }
31
31
  var ProviderValue = {
32
- path: name
32
+ path: name,
33
+ validateFieldSet: function validateFieldSet() {}
33
34
  };
34
35
  return {
35
36
  Provider: _fieldsetContext.default.Provider,
@@ -1 +1 @@
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;;;;;;;;;wBA0KC;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;qCAgJ5D,MAAM;gCA3CE,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;iCAgJ5D,MAAM;4BA3CE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CAkQ9D,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,M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C,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;;;;;;;;CAsO5D,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;;;;;;;;CA+O5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -347,7 +347,16 @@ var useTableLayout = function useTableLayout(props) {
347
347
  checkScroll();
348
348
  checkFloat();
349
349
  }, [colgroup]);
350
- var tableWidth = isNaN(Number(props.width)) ? undefined : typeof props.width === 'number' ? props.width + deltaXSum : props.width;
350
+ var tableWidth = props.width;
351
+ if (typeof props.width === 'string' && props.width.endsWith('%')) {
352
+ tableWidth = props.width;
353
+ } else if (typeof props.width === 'number') {
354
+ tableWidth = props.width + deltaXSum;
355
+ } else if (!isNaN(Number(props.width))) {
356
+ tableWidth = props.width;
357
+ } else {
358
+ tableWidth = undefined;
359
+ }
351
360
  return {
352
361
  isScrollX: !!isScrollX,
353
362
  isScrollY: !!isScrollY,
@@ -5,7 +5,8 @@ import FieldSetContext from "./use-form-fieldset/fieldset-context";
5
5
  import * as React from 'react';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  var topPath = {
8
- path: ''
8
+ path: '',
9
+ validateFieldSet: function validateFieldSet() {}
9
10
  };
10
11
  export var Provider = function Provider(props) {
11
12
  var children = props.children,
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBA2IpC,CAAC,YAAY,GAAG,EAAE;;;;;EAiDrD"}
1
+ {"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAsJpC,CAAC,YAAY,GAAG,EAAE;;;;;EAkDrD"}
@@ -52,7 +52,8 @@ export default function useFormControl(props) {
52
52
  bind: props.bind
53
53
  }),
54
54
  name = _useFieldSetConsumer.name,
55
- bind = _useFieldSetConsumer.bind;
55
+ bind = _useFieldSetConsumer.bind,
56
+ validateFieldSet = _useFieldSetConsumer.validateFieldSet;
56
57
  var _React$useState = React.useState(undefined),
57
58
  _React$useState2 = _slicedToArray(_React$useState, 2),
58
59
  errorState = _React$useState2[0],
@@ -149,7 +150,19 @@ export default function useFormControl(props) {
149
150
  bindValidate();
150
151
  return res;
151
152
  }).catch(function (e) {
152
- formFunc === null || formFunc === void 0 || formFunc.setError(name, e);
153
+ if (isArray(e)) {
154
+ e.forEach(function (error, index) {
155
+ if (error) {
156
+ var _Object$keys, _Object$values;
157
+ var fieldSetName = (_Object$keys = Object.keys(error)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
158
+ var fieldSetError = (_Object$values = Object.values(error)) === null || _Object$values === void 0 ? void 0 : _Object$values[0];
159
+ var na = "".concat(name, "[").concat(index, "].").concat(fieldSetName);
160
+ if (fieldSetName && fieldSetError) {
161
+ formFunc === null || formFunc === void 0 || formFunc.setError(na, fieldSetError);
162
+ }
163
+ }
164
+ });
165
+ }
153
166
  onError === null || onError === void 0 || onError(e);
154
167
  bindValidate();
155
168
  return e;
@@ -190,6 +203,7 @@ export default function useFormControl(props) {
190
203
  other[_key - 1] = arguments[_key];
191
204
  }
192
205
  if (onChangePo) onChangePo.apply(void 0, [v].concat(other));
206
+ if (validateFieldSet) validateFieldSet();
193
207
  });
194
208
  useEffect(function () {
195
209
  if (inForm && controlFunc) {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  declare const FieldsetContext: React.Context<{
3
3
  path: string;
4
+ validateFieldSet: () => void;
4
5
  }>;
5
6
  interface BaseFieldProps {
6
7
  bind?: string[];
@@ -9,6 +10,7 @@ interface BaseFieldProps {
9
10
  export declare const useFieldSetConsumer: <T extends BaseFieldProps>(props: T) => T & {
10
11
  name: string;
11
12
  bind: string[] | undefined;
13
+ validateFieldSet: () => void;
12
14
  };
13
15
  export default FieldsetContext;
14
16
  //# sourceMappingURL=fieldset-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fieldset-context.d.ts","sourceRoot":"","sources":["fieldset-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,QAAA,MAAM,eAAe;;EAA8B,CAAC;AAEpD,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAiBD,eAAO,MAAM,mBAAmB;;;CAc/B,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"fieldset-context.d.ts","sourceRoot":"","sources":["fieldset-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,QAAA,MAAM,eAAe;;;EAA0D,CAAC;AAEhF,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAiBD,eAAO,MAAM,mBAAmB;;;;CAe/B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -8,7 +8,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
8
8
  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); }
9
9
  import React, { createContext } from 'react';
10
10
  var FieldsetContext = /*#__PURE__*/createContext({
11
- path: ''
11
+ path: '',
12
+ validateFieldSet: function validateFieldSet() {}
12
13
  });
13
14
  function extendName() {
14
15
  var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
@@ -24,7 +25,8 @@ function extendName() {
24
25
  }
25
26
  export var useFieldSetConsumer = function useFieldSetConsumer(props) {
26
27
  var _React$useContext = React.useContext(FieldsetContext),
27
- path = _React$useContext.path;
28
+ path = _React$useContext.path,
29
+ validateFieldSet = _React$useContext.validateFieldSet;
28
30
  var bind = React.useMemo(function () {
29
31
  return path ? (props.bind || []).concat(path) : props.bind;
30
32
  }, [path, props.bind]);
@@ -33,7 +35,8 @@ export var useFieldSetConsumer = function useFieldSetConsumer(props) {
33
35
  }, [path, props.name]);
34
36
  return _objectSpread(_objectSpread({}, props), {}, {
35
37
  name: name,
36
- bind: bind
38
+ bind: bind,
39
+ validateFieldSet: validateFieldSet
37
40
  });
38
41
  };
39
42
  export default FieldsetContext;
@@ -3,9 +3,11 @@ import { BaseFormFieldSetProps } from './use-form-fieldset.type';
3
3
  export declare const useFormFieldSet: <T>(props: BaseFormFieldSetProps<T>) => {
4
4
  Provider: import("react").Provider<{
5
5
  path: string;
6
+ validateFieldSet: () => void;
6
7
  }>;
7
8
  ProviderValue: {
8
9
  path: string | (string[] & string);
10
+ validateFieldSet: () => void;
9
11
  };
10
12
  error: Error | undefined;
11
13
  value: T | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,eAAe;;;;;;;;;;;CA2B3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"use-form-fieldset.d.ts","sourceRoot":"","sources":["use-form-fieldset.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,eAAe;;;;;;;;;;;;;CA4B3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -22,7 +22,8 @@ export var useFormFieldSet = function useFormFieldSet(props) {
22
22
  console.error('[FieldSet] should render in Form');
23
23
  }
24
24
  var ProviderValue = {
25
- path: name
25
+ path: name,
26
+ validateFieldSet: function validateFieldSet() {}
26
27
  };
27
28
  return {
28
29
  Provider: FieldsetContext.Provider,
@@ -1 +1 @@
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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AAS,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;iCAgJ5D,MAAM;4BA3CE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;;CA2Q9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -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;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;;;;;;;;CAsO5D,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;;;;;;;;CA+O5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -338,7 +338,16 @@ var useTableLayout = function useTableLayout(props) {
338
338
  checkScroll();
339
339
  checkFloat();
340
340
  }, [colgroup]);
341
- var tableWidth = isNaN(Number(props.width)) ? undefined : typeof props.width === 'number' ? props.width + deltaXSum : props.width;
341
+ var tableWidth = props.width;
342
+ if (typeof props.width === 'string' && props.width.endsWith('%')) {
343
+ tableWidth = props.width;
344
+ } else if (typeof props.width === 'number') {
345
+ tableWidth = props.width + deltaXSum;
346
+ } else if (!isNaN(Number(props.width))) {
347
+ tableWidth = props.width;
348
+ } else {
349
+ tableWidth = undefined;
350
+ }
342
351
  return {
343
352
  isScrollX: !!isScrollX,
344
353
  isScrollY: !!isScrollY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.5.0",
3
+ "version": "3.5.1-beta.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",