@sheinx/hooks 3.5.2 → 3.5.3-beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. package/cjs/common/use-list-select/use-list-select-multiple.js +1 -1
  2. package/cjs/components/use-datepicker/use-datepicker-format.d.ts +1 -1
  3. package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  4. package/cjs/components/use-datepicker/use-datepicker-format.js +6 -3
  5. package/cjs/components/use-datepicker/use-datepicker-range.d.ts +2 -0
  6. package/cjs/components/use-datepicker/use-datepicker-range.d.ts.map +1 -1
  7. package/cjs/components/use-datepicker/use-datepicker-range.js +15 -0
  8. package/cjs/components/use-datepicker/use-time.d.ts +1 -1
  9. package/cjs/components/use-datepicker/use-time.d.ts.map +1 -1
  10. package/cjs/components/use-datepicker/use-time.js +20 -4
  11. package/cjs/components/use-datepicker/use-time.type.d.ts +2 -0
  12. package/cjs/components/use-datepicker/use-time.type.d.ts.map +1 -1
  13. package/cjs/components/use-datepicker/util.d.ts.map +1 -1
  14. package/cjs/components/use-datepicker/util.js +5 -2
  15. package/cjs/components/use-form/form-func-context.d.ts +2 -2
  16. package/cjs/components/use-form/form-func-context.d.ts.map +1 -1
  17. package/cjs/components/use-form/use-form-context.type.d.ts +12 -2
  18. package/cjs/components/use-form/use-form-context.type.d.ts.map +1 -1
  19. package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  20. package/cjs/components/use-form/use-form-control/use-form-control.js +6 -6
  21. package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts +4 -0
  22. package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
  23. package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
  24. package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.js +2 -1
  25. package/cjs/components/use-form/use-form.d.ts +5 -3
  26. package/cjs/components/use-form/use-form.d.ts.map +1 -1
  27. package/cjs/components/use-form/use-form.js +113 -40
  28. package/cjs/components/use-form/use-form.type.d.ts +27 -7
  29. package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
  30. package/cjs/components/use-table/use-table-expand.d.ts.map +1 -1
  31. package/cjs/components/use-table/use-table-expand.js +3 -2
  32. package/cjs/components/use-tabs/context.d.ts +3 -3
  33. package/cjs/components/use-tabs/context.d.ts.map +1 -1
  34. package/cjs/components/use-tabs/context.js +4 -1
  35. package/cjs/components/use-tabs/context.type.d.ts +15 -3
  36. package/cjs/components/use-tabs/context.type.d.ts.map +1 -1
  37. package/cjs/components/use-tabs/use-tabs.d.ts +4 -2
  38. package/cjs/components/use-tabs/use-tabs.d.ts.map +1 -1
  39. package/cjs/components/use-tabs/use-tabs.js +6 -0
  40. package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
  41. package/cjs/components/use-tree/use-tree.js +2 -1
  42. package/cjs/components/use-upload/xhr.d.ts.map +1 -1
  43. package/cjs/components/use-upload/xhr.js +2 -1
  44. package/cjs/utils/dom/element.d.ts +1 -0
  45. package/cjs/utils/dom/element.d.ts.map +1 -1
  46. package/cjs/utils/dom/element.js +5 -0
  47. package/cjs/utils/index.d.ts +1 -0
  48. package/cjs/utils/index.d.ts.map +1 -1
  49. package/cjs/utils/index.js +12 -0
  50. package/cjs/utils/lazyload.d.ts.map +1 -1
  51. package/cjs/utils/lazyload.js +4 -1
  52. package/cjs/utils/number.d.ts.map +1 -1
  53. package/cjs/utils/number.js +2 -1
  54. package/cjs/utils/render.d.ts.map +1 -1
  55. package/cjs/utils/render.js +2 -1
  56. package/cjs/utils/rule/length.d.ts.map +1 -1
  57. package/cjs/utils/rule/length.js +2 -1
  58. package/cjs/utils/rule/regexp.d.ts.map +1 -1
  59. package/cjs/utils/rule/regexp.js +2 -1
  60. package/cjs/utils/rule/rule.d.ts.map +1 -1
  61. package/cjs/utils/rule/rule.js +3 -2
  62. package/cjs/utils/validate/get-rule.js +1 -1
  63. package/cjs/utils/validate/type.d.ts.map +1 -1
  64. package/cjs/utils/validate/type.js +2 -1
  65. package/cjs/utils/warning.d.ts +8 -0
  66. package/cjs/utils/warning.d.ts.map +1 -0
  67. package/cjs/utils/warning.js +36 -0
  68. package/esm/common/use-list-select/use-list-select-multiple.js +1 -1
  69. package/esm/components/use-datepicker/use-datepicker-format.d.ts +1 -1
  70. package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  71. package/esm/components/use-datepicker/use-datepicker-format.js +6 -3
  72. package/esm/components/use-datepicker/use-datepicker-range.d.ts +2 -0
  73. package/esm/components/use-datepicker/use-datepicker-range.d.ts.map +1 -1
  74. package/esm/components/use-datepicker/use-datepicker-range.js +15 -0
  75. package/esm/components/use-datepicker/use-time.d.ts +1 -1
  76. package/esm/components/use-datepicker/use-time.d.ts.map +1 -1
  77. package/esm/components/use-datepicker/use-time.js +20 -4
  78. package/esm/components/use-datepicker/use-time.type.d.ts +2 -0
  79. package/esm/components/use-datepicker/use-time.type.d.ts.map +1 -1
  80. package/esm/components/use-datepicker/util.d.ts.map +1 -1
  81. package/esm/components/use-datepicker/util.js +4 -2
  82. package/esm/components/use-form/form-func-context.d.ts +2 -2
  83. package/esm/components/use-form/form-func-context.d.ts.map +1 -1
  84. package/esm/components/use-form/use-form-context.type.d.ts +12 -2
  85. package/esm/components/use-form/use-form-context.type.d.ts.map +1 -1
  86. package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  87. package/esm/components/use-form/use-form-control/use-form-control.js +6 -6
  88. package/esm/components/use-form/use-form-control/use-form-control.type.d.ts +4 -0
  89. package/esm/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
  90. package/esm/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
  91. package/esm/components/use-form/use-form-fieldset/use-form-fieldset.js +2 -1
  92. package/esm/components/use-form/use-form.d.ts +5 -3
  93. package/esm/components/use-form/use-form.d.ts.map +1 -1
  94. package/esm/components/use-form/use-form.js +113 -40
  95. package/esm/components/use-form/use-form.type.d.ts +27 -7
  96. package/esm/components/use-form/use-form.type.d.ts.map +1 -1
  97. package/esm/components/use-table/use-table-expand.d.ts.map +1 -1
  98. package/esm/components/use-table/use-table-expand.js +3 -2
  99. package/esm/components/use-tabs/context.d.ts +3 -3
  100. package/esm/components/use-tabs/context.d.ts.map +1 -1
  101. package/esm/components/use-tabs/context.js +4 -1
  102. package/esm/components/use-tabs/context.type.d.ts +15 -3
  103. package/esm/components/use-tabs/context.type.d.ts.map +1 -1
  104. package/esm/components/use-tabs/use-tabs.d.ts +4 -2
  105. package/esm/components/use-tabs/use-tabs.d.ts.map +1 -1
  106. package/esm/components/use-tabs/use-tabs.js +6 -0
  107. package/esm/components/use-tree/use-tree.d.ts.map +1 -1
  108. package/esm/components/use-tree/use-tree.js +2 -1
  109. package/esm/components/use-upload/xhr.d.ts.map +1 -1
  110. package/esm/components/use-upload/xhr.js +2 -1
  111. package/esm/utils/dom/element.d.ts +1 -0
  112. package/esm/utils/dom/element.d.ts.map +1 -1
  113. package/esm/utils/dom/element.js +4 -0
  114. package/esm/utils/index.d.ts +1 -0
  115. package/esm/utils/index.d.ts.map +1 -1
  116. package/esm/utils/index.js +1 -0
  117. package/esm/utils/lazyload.d.ts.map +1 -1
  118. package/esm/utils/lazyload.js +5 -2
  119. package/esm/utils/number.d.ts.map +1 -1
  120. package/esm/utils/number.js +2 -1
  121. package/esm/utils/render.d.ts.map +1 -1
  122. package/esm/utils/render.js +2 -1
  123. package/esm/utils/rule/length.d.ts.map +1 -1
  124. package/esm/utils/rule/length.js +2 -1
  125. package/esm/utils/rule/regexp.d.ts.map +1 -1
  126. package/esm/utils/rule/regexp.js +2 -1
  127. package/esm/utils/rule/rule.d.ts.map +1 -1
  128. package/esm/utils/rule/rule.js +3 -2
  129. package/esm/utils/validate/get-rule.js +1 -1
  130. package/esm/utils/validate/type.d.ts.map +1 -1
  131. package/esm/utils/validate/type.js +2 -1
  132. package/esm/utils/warning.d.ts +8 -0
  133. package/esm/utils/warning.d.ts.map +1 -0
  134. package/esm/utils/warning.js +30 -0
  135. package/package.json +1 -1
@@ -2,6 +2,10 @@ import { ObjectType } from '../../../common/type';
2
2
  import { FormItemRule } from '../../../utils/rule/rule.type';
3
3
  export interface BaseFormControlProps<T> {
4
4
  name: string | string[];
5
+ /**
6
+ * @private 内部属性 for validate
7
+ */
8
+ formName?: string;
5
9
  /**
6
10
  * @en default Value
7
11
  * @cn 默认值
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-control.type.d.ts","sourceRoot":"","sources":["use-form-control.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5D;;;OAGG;IACH,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACnC;;OAEG;IACH,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC1D;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC3B;;OAEG;IACH,gBAAgB,EAAE,CAAC,MAAM,UAAU,CAAC,GAAG,SAAS,CAAC;CAClD"}
1
+ {"version":3,"file":"use-form-control.type.d.ts","sourceRoot":"","sources":["use-form-control.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5D;;;OAGG;IACH,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACnC;;OAEG;IACH,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC1D;;;OAGG;IACH,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC3B;;OAEG;IACH,gBAAgB,EAAE,CAAC,MAAM,UAAU,CAAC,GAAG,SAAS,CAAC;CAClD"}
@@ -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;;;;;;;;;;;;;CA4B3B,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;AAMjE,eAAO,MAAM,eAAe;;;;;;;;;;;;;CA4B3B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import FieldsetContext from "./fieldset-context";
2
2
  import { useFormControl } from "../use-form-control";
3
+ import { devUseWarning } from "../../../utils";
3
4
  var emptyFunc = function emptyFunc() {};
4
5
  var emptyArr = [];
5
6
  export var useFormFieldSet = function useFormFieldSet(props) {
@@ -19,7 +20,7 @@ export var useFormFieldSet = function useFormFieldSet(props) {
19
20
  onChange = _useFormControl.onChange,
20
21
  name = _useFormControl.name;
21
22
  if (!inForm) {
22
- console.error('[FieldSet] should render in Form');
23
+ devUseWarning.error('[FieldSet] should render in Form');
23
24
  }
24
25
  var ProviderValue = {
25
26
  path: name,
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ProviderProps, UseFormProps, UseFormSlotProps } from './use-form.type';
2
+ import { ProviderProps, UseFormProps, UseFormSlotProps, ValidateFnConfig } from './use-form.type';
3
3
  import { ObjectType } from '../../common/type';
4
4
  declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
5
5
  getFormProps: <TOther extends ObjectType = ObjectType>(externalProps?: TOther) => UseFormSlotProps<TOther>;
@@ -20,10 +20,11 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
20
20
  setError: (name: string, e: Error | undefined) => void;
21
21
  getErrors: () => ObjectType<Error | undefined>;
22
22
  clearValidate: (names?: string[]) => void;
23
- validateFields: (fields?: string | string[], config?: any) => Promise<true>;
23
+ validateFields: (fields?: string | string[], config?: ValidateFnConfig) => Promise<T>;
24
24
  validateFieldset: (name: string) => void;
25
25
  insertError: (name: string, index: number, error?: Error) => void;
26
26
  spliceError: (name: string, index: number) => void;
27
+ scrollToField: (name: string, scrollIntoViewOptions?: ScrollIntoViewOptions) => void;
27
28
  };
28
29
  };
29
30
  formFunc: {
@@ -39,10 +40,11 @@ declare const useForm: <T extends ObjectType>(props: UseFormProps<T>) => {
39
40
  setError: (name: string, e: Error | undefined) => void;
40
41
  getErrors: () => ObjectType<Error | undefined>;
41
42
  clearValidate: (names?: string[]) => void;
42
- validateFields: (fields?: string | string[], config?: any) => Promise<true>;
43
+ validateFields: (fields?: string | string[], config?: ValidateFnConfig) => Promise<T>;
43
44
  validateFieldset: (name: string) => void;
44
45
  insertError: (name: string, index: number, error?: Error) => void;
45
46
  spliceError: (name: string, index: number) => void;
47
+ scrollToField: (name: string, scrollIntoViewOptions?: ScrollIntoViewOptions) => void;
46
48
  };
47
49
  };
48
50
  export default useForm;
@@ -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;;;;;;;;;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;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;;CA6Q9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":";AA8BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAsPC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE;8BAnId,MAAM;oCA6LD,OAAO;;6BAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCAxJxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;qCAsNvB,MAAM;gCA3CE,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;kCAhHpD,MAAM,0BAAyB,qBAAqB;;;;;;oBA2DjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;0BAnId,MAAM;gCA6LD,OAAO;;yBAfb,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCAxJxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;iCAsNvB,MAAM;4BA3CE,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;8BAhHpD,MAAM,0BAAyB,qBAAqB;;CAgY9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,12 +1,12 @@
1
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); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
2
5
  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; }
3
6
  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; }
4
7
  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; }
5
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
9
  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); }
7
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
8
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
10
  import * as React from 'react';
11
11
  import { Provider } from "./Provider";
12
12
  import useLatestObj from "../../common/use-latest-obj";
@@ -16,7 +16,7 @@ import { insertValue, spliceValue } from "../../utils/flat";
16
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, getAllKeyPaths } from "../../utils";
19
+ import { deepGet, deepRemove, deepSet, docScroll, extractEventHandlers, isArray, isObject, shallowEqual, wrapFormError, deepClone, getAllKeyPaths, devUseWarning, getFieldId, getClosestScrollContainer } from "../../utils";
20
20
  var emptyObj = {};
21
21
  var useForm = function useForm(props) {
22
22
  var _props$defaultValue = props.defaultValue,
@@ -36,6 +36,7 @@ var useForm = function useForm(props) {
36
36
  _props$throttle = props.throttle,
37
37
  throttle = _props$throttle === void 0 ? 1000 : _props$throttle,
38
38
  size = props.size,
39
+ formName = props.name,
39
40
  reserveAble = props.reserveAble,
40
41
  scrollParent = props.scrollParent;
41
42
  var deepSetOptions = {
@@ -43,7 +44,7 @@ var useForm = function useForm(props) {
43
44
  forceSet: true
44
45
  };
45
46
  var preValue = usePrevious(props.value);
46
- var formRef = React.useRef();
47
+ var formDomRef = React.useRef();
47
48
  var _React$useRef = React.useRef({
48
49
  defaultValues: {},
49
50
  validateMap: {},
@@ -105,9 +106,9 @@ var useForm = function useForm(props) {
105
106
  onError === null || onError === void 0 || onError(err);
106
107
  if (!props.scrollToError) return;
107
108
  setTimeout(function () {
108
- var _formRef$current;
109
+ var _formDomRef$current;
109
110
  var selector = "[".concat(getDataAttributeName('status'), "=\"error\"]");
110
- var el = (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.querySelector(selector);
111
+ var el = (_formDomRef$current = formDomRef.current) === null || _formDomRef$current === void 0 ? void 0 : _formDomRef$current.querySelector(selector);
111
112
  if (el) {
112
113
  el.scrollIntoView();
113
114
  var focusableSelectors = 'textarea, input,[tabindex]:not([tabindex="-1"])';
@@ -130,32 +131,106 @@ var useForm = function useForm(props) {
130
131
  context.value = newValue;
131
132
  (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, context.value);
132
133
  });
134
+ var getValue = usePersistFn(function (name) {
135
+ if (name) {
136
+ return deepGet(context.value, name);
137
+ }
138
+ return context.value;
139
+ });
133
140
  var validateFields = usePersistFn(function (fields) {
134
141
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
135
142
  return new Promise(function (resolve, reject) {
136
- var files2 = fields ? (isArray(fields) ? fields : [fields]).filter(function (key) {
143
+ var finalFields = fields ? (isArray(fields) ? fields : [fields]).filter(function (key) {
137
144
  return context.validateMap[key];
138
145
  }) : Object.keys(context.validateMap);
139
- var validates = files2.map(function (key) {
146
+ var validates = finalFields.map(function (key) {
140
147
  var validateField = context.validateMap[key];
141
148
  return Array.from(validateField).map(function (validate) {
142
149
  return validate(key, deepGet(context.value, key), context.value, config);
143
150
  });
144
151
  });
145
- Promise.all(validates.flat()).then(function (results) {
146
- var error = results.find(function (n) {
147
- return n !== true;
148
- });
149
- if (error !== undefined) {
150
- reject(error);
151
- } else {
152
- resolve(true);
152
+ if (config.type === 'withValue') {
153
+ var validatorValue = context.value;
154
+ if (fields) {
155
+ var fieldArray = isArray(fields) ? fields : [fields];
156
+ validatorValue = fieldArray.reduce(function (prev, cur) {
157
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, cur, getValue(cur)));
158
+ }, {});
153
159
  }
154
- }).catch(function (e) {
155
- reject(wrapFormError(e));
156
- });
160
+ Promise.all(validates.flat()).then(function (results) {
161
+ var errors = results.filter(function (n) {
162
+ return n !== true;
163
+ });
164
+ if (errors.length > 0) {
165
+ var errorFields = [];
166
+ for (var _key in context.errors) {
167
+ if (context.errors[_key]) {
168
+ var _context$errors$_key;
169
+ errorFields.push({
170
+ name: _key,
171
+ errors: [((_context$errors$_key = context.errors[_key]) === null || _context$errors$_key === void 0 ? void 0 : _context$errors$_key.message) || '']
172
+ });
173
+ }
174
+ }
175
+ reject({
176
+ values: validatorValue,
177
+ errorFields: errorFields
178
+ });
179
+ } else {
180
+ resolve(validatorValue);
181
+ }
182
+ });
183
+ } else {
184
+ Promise.all(validates.flat()).then(function (results) {
185
+ var error = results.find(function (n) {
186
+ return n !== true;
187
+ });
188
+ if (error !== undefined) {
189
+ reject(error);
190
+ } else {
191
+ resolve(true);
192
+ }
193
+ }).catch(function (e) {
194
+ reject(wrapFormError(e));
195
+ });
196
+ }
157
197
  });
158
198
  });
199
+ var scrollToField = usePersistFn(function (name) {
200
+ var _document;
201
+ var scrollIntoViewOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
202
+ if (!name) return;
203
+ var fieldId = getFieldId(name, formName);
204
+ if (!fieldId) return;
205
+ var element = (_document = document) === null || _document === void 0 ? void 0 : _document.getElementById(fieldId);
206
+ if (element) {
207
+ // 查找可滚动的父元素
208
+ var parentEl = getClosestScrollContainer(element);
209
+ if (parentEl) {
210
+ var parentRect = parentEl.getBoundingClientRect();
211
+ var elementRect = element.getBoundingClientRect();
212
+
213
+ // 判断父元素是否在可见范围内
214
+ var isVisibleY = elementRect.top >= parentRect.top && elementRect.bottom <= parentRect.bottom;
215
+ var isVisibleX = elementRect.left >= parentRect.left && elementRect.right <= parentRect.right;
216
+ if (!isVisibleY || !isVisibleX) {
217
+ // 计算元素相对于父元素的偏移量
218
+ var offsetTop = element.offsetTop - parentEl.offsetTop;
219
+ var offsetLeft = element.offsetLeft - parentEl.offsetLeft;
220
+ parentEl.scrollTop = offsetTop;
221
+ parentEl.scrollLeft = offsetLeft;
222
+ }
223
+ } else {
224
+ // 如果没有找到可滚动的父元素,使用默认行为
225
+ element.scrollIntoView(_objectSpread({
226
+ behavior: 'smooth'
227
+ }, scrollIntoViewOptions));
228
+ }
229
+ } else {
230
+ // todo: 统一警告|错误信息(by Tom)
231
+ console.warn("[shineout] fieldId: ".concat(fieldId, " not found"));
232
+ }
233
+ });
159
234
  var remove = function remove() {
160
235
  if (!context.removeArr.size) return;
161
236
  if (context.unmounted) return;
@@ -173,12 +248,6 @@ var useForm = function useForm(props) {
173
248
  }
174
249
  context.removeTimer = setTimeout(remove);
175
250
  };
176
- var getValue = usePersistFn(function (name) {
177
- if (name) {
178
- return deepGet(context.value, name);
179
- }
180
- return context.value;
181
- });
182
251
  var setValue = usePersistFn(function (vals) {
183
252
  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
184
253
  validate: false
@@ -186,9 +255,11 @@ var useForm = function useForm(props) {
186
255
  onChange(function (draft) {
187
256
  var values = Object.keys(vals);
188
257
  // 针对 name 为数组模式,如 datepicker 的 name={['startTime', 'endTime']} 时,前者校验可能需要依赖后者,因此需要提前将后者数据整合至 draft 用于多字段整合校验
189
- var nextDraft = Object.assign({}, current(draft), vals);
258
+ var nextDraft = current(draft);
259
+ values.forEach(function (key) {
260
+ deepSet(nextDraft, key, vals[key], deepSetOptions);
261
+ });
190
262
  values.forEach(function (key) {
191
- deepSet(draft, key, vals[key], deepSetOptions);
192
263
  if (option.validate) {
193
264
  var _context$validateMap$;
194
265
  (_context$validateMap$ = context.validateMap[key]) === null || _context$validateMap$ === void 0 || _context$validateMap$.forEach(function (validate) {
@@ -247,7 +318,7 @@ var useForm = function useForm(props) {
247
318
  context.submitLock = false;
248
319
  }, throttle);
249
320
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
250
- var _props$onSubmit, _ref2, result, _props$onSubmit2, _ref3;
321
+ var _props$onSubmit, _context$value, result, _props$onSubmit2, _context$value2;
251
322
  return _regeneratorRuntime().wrap(function _callee$(_context) {
252
323
  while (1) switch (_context.prev = _context.next) {
253
324
  case 0:
@@ -255,7 +326,7 @@ var useForm = function useForm(props) {
255
326
  _context.next = 3;
256
327
  break;
257
328
  }
258
- (_props$onSubmit = props.onSubmit) === null || _props$onSubmit === void 0 || _props$onSubmit.call(props, (_ref2 = context.value) !== null && _ref2 !== void 0 ? _ref2 : {});
329
+ (_props$onSubmit = props.onSubmit) === null || _props$onSubmit === void 0 || _props$onSubmit.call(props, (_context$value = context.value) !== null && _context$value !== void 0 ? _context$value : {});
259
330
  return _context.abrupt("return");
260
331
  case 3:
261
332
  _context.next = 5;
@@ -270,7 +341,7 @@ var useForm = function useForm(props) {
270
341
  _context.next = 10;
271
342
  break;
272
343
  }
273
- (_props$onSubmit2 = props.onSubmit) === null || _props$onSubmit2 === void 0 || _props$onSubmit2.call(props, (_ref3 = context.value) !== null && _ref3 !== void 0 ? _ref3 : {});
344
+ (_props$onSubmit2 = props.onSubmit) === null || _props$onSubmit2 === void 0 || _props$onSubmit2.call(props, (_context$value2 = context.value) !== null && _context$value2 !== void 0 ? _context$value2 : {});
274
345
  _context.next = 12;
275
346
  break;
276
347
  case 10:
@@ -329,7 +400,7 @@ var useForm = function useForm(props) {
329
400
  var externalProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
330
401
  var externalEventHandlers = extractEventHandlers(externalProps);
331
402
  return _objectSpread(_objectSpread(_objectSpread({}, externalProps), externalEventHandlers), {}, {
332
- ref: formRef,
403
+ ref: formDomRef,
333
404
  disabled: !!disabled,
334
405
  onSubmit: handleSubmit(externalEventHandlers),
335
406
  onReset: handleReset(externalEventHandlers)
@@ -340,8 +411,8 @@ var useForm = function useForm(props) {
340
411
  });
341
412
  var controlFunc = useLatestObj({
342
413
  bind: function bind(n, df, validate, updateFn) {
343
- if (context.names.has(n)) {
344
- console.warn("name \"".concat(n, "\" already exist"));
414
+ if (process.env.NODE_ENV !== 'production' && context.names.has(n)) {
415
+ devUseWarning.warn("name \"".concat(n, "\" already exist in Form component"));
345
416
  }
346
417
  context.names.add(n);
347
418
  if (!context.validateMap[n]) {
@@ -363,10 +434,10 @@ var useForm = function useForm(props) {
363
434
  });
364
435
  }
365
436
  },
366
- unbind: function unbind(n, reserveAble, validateFiled, update) {
437
+ unbind: function unbind(n, reserveAble, validateField, update) {
367
438
  var validateFieldSet = context.validateMap[n];
368
- if (validateFiled && validateFieldSet.has(validateFiled)) {
369
- validateFieldSet.delete(validateFiled);
439
+ if (validateField && validateFieldSet.has(validateField)) {
440
+ validateFieldSet.delete(validateField);
370
441
  }
371
442
  var updateFieldSet = context.updateMap[n];
372
443
  if (update && updateFieldSet.has(update)) {
@@ -427,7 +498,8 @@ var useForm = function useForm(props) {
427
498
  validateFields: validateFields,
428
499
  validateFieldset: validateFieldset,
429
500
  insertError: insertError,
430
- spliceError: spliceError
501
+ spliceError: spliceError,
502
+ scrollToField: scrollToField
431
503
  });
432
504
  var formConfig = React.useMemo(function () {
433
505
  return {
@@ -438,9 +510,10 @@ var useForm = function useForm(props) {
438
510
  inline: inline,
439
511
  disabled: disabled,
440
512
  size: size,
441
- reserveAble: reserveAble
513
+ reserveAble: reserveAble,
514
+ formName: formName
442
515
  };
443
- }, [labelWidth, labelAlign, labelVerticalAlign, keepErrorHeight, inline, disabled, size, reserveAble]);
516
+ }, [labelWidth, labelAlign, labelVerticalAlign, keepErrorHeight, inline, disabled, size, reserveAble, formName]);
444
517
  var updateValue = function updateValue() {
445
518
  if (props.value !== context.lastValue && props.value !== context.value) {
446
519
  context.value = deepClone(props.value) || emptyObj;
@@ -3,9 +3,19 @@ import { ReactNode } from 'react';
3
3
  import { AddNoProps, ObjectType } from '../../common/type';
4
4
  import { FormItemRule } from '../../utils/rule/rule.type';
5
5
  import { FormError } from '../../utils';
6
- export type ValidateFn = (name: string, value: any, formData: ObjectType, config?: {
6
+ export type KeyType = string | number | symbol;
7
+ export interface ValidationError<T> {
8
+ values: T;
9
+ errorFields: {
10
+ name: string;
11
+ errors: string[];
12
+ }[];
13
+ }
14
+ export type ValidateFnConfig = {
15
+ type?: 'forcePass' | 'withValue';
7
16
  ignoreBind?: boolean;
8
- }) => Promise<boolean | FormError>;
17
+ };
18
+ export type ValidateFn = (name: string, value: any, formData: ObjectType, config?: ValidateFnConfig) => Promise<true | FormError>;
9
19
  export type UpdateFn = (formValue: ObjectType, errors: ObjectType<Error | undefined>, serverErrors: ObjectType<Error | undefined>) => void;
10
20
  export interface FormContextValueType {
11
21
  func?: {
@@ -74,8 +84,14 @@ export interface FormCommonConfig extends FormLabelConfig {
74
84
  * @version 3.5.0
75
85
  */
76
86
  reserveAble?: boolean;
87
+ /**
88
+ * @en The name of the form, will be used as the prefix of the form field id, and can enable the <label for="id" /> function after setting
89
+ * @cn 表单名称,会作为表单字段 id 的前缀,设置后可开启 <label for="id" /> 功能
90
+ * @version 3.5.2
91
+ */
92
+ formName?: string;
77
93
  }
78
- export interface FormFunc {
94
+ export interface FormFunc<T = any> {
79
95
  setValue: (vals: {
80
96
  [key: string]: any;
81
97
  }, option?: {
@@ -87,9 +103,7 @@ export interface FormFunc {
87
103
  setError: (name: string, e: Error | undefined) => void;
88
104
  getErrors: () => ObjectType<Error | undefined>;
89
105
  clearValidate: (names?: string[]) => void;
90
- validateFields: (fields?: string | string[], config?: {
91
- ignoreBind?: boolean;
92
- }) => Promise<true>;
106
+ validateFields: (fields?: string | string[], config?: ValidateFnConfig) => Promise<Partial<T>>;
93
107
  validateFieldset: (name: string) => void;
94
108
  insertError: (name: string, index: number, error?: Error) => void;
95
109
  spliceError: (name: string, index: number) => void;
@@ -155,13 +169,19 @@ export interface BaseFormProps<T> extends FormCommonConfig {
155
169
  * @private 内部属性
156
170
  */
157
171
  error?: ObjectType<string | Error>;
172
+ /**
173
+ * @en The name of the form, will be used as the prefix of the form field id, and can enable the <label for="id" /> function after setting
174
+ * @cn 表单名称,会作为表单字段 id 的前缀,设置后可使用 formRef 的 scrollToField 方法
175
+ * @version 3.5.3
176
+ */
177
+ name?: string;
158
178
  }
159
179
  export type UseFormProps<T> = BaseFormProps<T>;
160
180
  export type FormContext = {
161
181
  defaultValues: ObjectType;
162
182
  validateMap: ObjectType<Set<(name: string, v: any, formValue: ObjectType, config?: {
163
183
  ignoreBind?: boolean;
164
- }) => Promise<boolean | FormError>>>;
184
+ }) => Promise<true | FormError>>>;
165
185
  removeArr: Set<string>;
166
186
  removeTimer?: number | NodeJS.Timeout;
167
187
  names: Set<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form.type.d.ts","sourceRoot":"","sources":["use-form.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,UAAU,EACpB,MAAM,CAAC,EAAE;IACP,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,KACE,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAA;AAEjC,MAAM,MAAM,QAAQ,GAAG,CACrB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,EACrC,YAAY,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,KACxC,IAAI,CAAA;AAET,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE;QACL,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAC,UAAU,EAAE,MAAM,CAAC,EAAC,QAAQ,KAAM,IAAI,CAAC;QAC5F,IAAI,EAAE,CACJ,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,GAAG,EACP,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,QAAQ,KACb,IAAI,CAAC;QACV,YAAY,EAAE,CAAC,SAAS,EACtB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC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EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,YAAY,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAEhJ,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACrC,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IACtC,YAAY,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,CACzE,mBAAmB,EACnB,MAAM,CACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-table-expand.d.ts","sourceRoot":"","sources":["use-table-expand.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIrE,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC7F,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,cAAc,UAAW,mBAAmB;6BAa/C,kBAAkB,GAAG,CAAC,QAAQ,GAAG,SAAS,MAAM;wBAThB,GAAG,SAAS,MAAM;CA2C3D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"use-table-expand.d.ts","sourceRoot":"","sources":["use-table-expand.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKrE,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC7F,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,cAAc,UAAW,mBAAmB;6BAa/C,kBAAkB,GAAG,CAAC,QAAQ,GAAG,SAAS,MAAM;wBAThB,GAAG,SAAS,MAAM;CA2C3D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -10,7 +10,8 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import React, { useEffect } from 'react';
12
12
  import usePersistFn from "../../common/use-persist-fn";
13
- import { getKey } from "../..//utils/render";
13
+ import { getKey } from "../../utils/render";
14
+ import { devUseWarning } from "../../utils";
14
15
  export var useTableExpand = function useTableExpand(props) {
15
16
  var columns = props.columns,
16
17
  expandKeys = props.expandKeys;
@@ -52,7 +53,7 @@ export var useTableExpand = function useTableExpand(props) {
52
53
  return col.type === 'expand' || col.type === 'row-expand';
53
54
  }).length;
54
55
  if (expandNum > 1) {
55
- console.error('columns should not have more than one expand column');
56
+ devUseWarning.error('columns should not have more than one expand column');
56
57
  }
57
58
  });
58
59
  return {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { TabsProviderProps, TabsContextProps } from './context.type';
3
- export declare const TabsContext: React.Context<TabsContextProps>;
4
- export declare const Provider: (props: TabsProviderProps) => JSX.Element;
5
- export declare const useTabsContext: () => TabsContextProps;
3
+ export declare const TabsContext: React.Context<TabsContextProps<any>>;
4
+ export declare const Provider: <TabData>(props: TabsProviderProps<TabData>) => JSX.Element;
5
+ export declare const useTabsContext: <TabData>() => TabsContextProps<TabData>;
6
6
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,eAAO,MAAM,WAAW,iCAA4C,CAAC;AAErE,eAAO,MAAM,QAAQ,UAAW,iBAAiB,gBAGhD,CAAC;AAEF,eAAO,MAAM,cAAc,wBAAsC,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,eAAO,MAAM,WAAW,sCAA8E,CAAC;AAEvG,eAAO,MAAM,QAAQ,6DAGpB,CAAC;AAEF,eAAO,MAAM,cAAc,0CAA8E,CAAC"}
@@ -2,7 +2,10 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
- export var TabsContext = /*#__PURE__*/React.createContext({});
5
+ export var TabsContext = /*#__PURE__*/React.createContext({
6
+ tabs: [],
7
+ setTabs: function setTabs() {}
8
+ });
6
9
  export var Provider = function Provider(props) {
7
10
  var children = props.children,
8
11
  value = props.value;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { TabsShapeType } from './use-tabs.type';
3
- export interface TabsContextProps {
3
+ export interface TabsContextProps<TabData = any> {
4
4
  /**
5
5
  * @private 内部属性
6
6
  */
@@ -34,9 +34,21 @@ export interface TabsContextProps {
34
34
  * @private 内部属性
35
35
  */
36
36
  onCollapsible?: () => void;
37
+ /**
38
+ * @private 内部属性
39
+ */
40
+ tabs: TabData[];
41
+ /**
42
+ * @private 内部属性
43
+ */
44
+ setTabs: React.Dispatch<React.SetStateAction<TabData[]>>;
45
+ /**
46
+ * @private 内部属性
47
+ */
48
+ color?: string;
37
49
  }
38
- export interface TabsProviderProps {
39
- value: TabsContextProps;
50
+ export interface TabsProviderProps<TabData> {
51
+ value: TabsContextProps<TabData>;
40
52
  children?: React.ReactNode;
41
53
  }
42
54
  //# sourceMappingURL=context.type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.type.d.ts","sourceRoot":"","sources":["context.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,gBAAgB,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
1
+ {"version":3,"file":"context.type.d.ts","sourceRoot":"","sources":["context.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,gBAAgB,CAAC,OAAO,GAAG,GAAG;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B;;OAEG;IACH,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB,CAAC,OAAO;IACxC,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { BaseTabsProps } from './use-tabs.type';
3
- declare const useTabs: (props: BaseTabsProps) => {
3
+ declare const useTabs: <TabData = any>(props: BaseTabsProps) => {
4
4
  active: string | number | undefined;
5
5
  onChange: (key: string | number) => void;
6
- Provider: (props: import("./context.type").TabsProviderProps) => JSX.Element;
6
+ tabs: TabData[];
7
+ setTabs: import("react").Dispatch<import("react").SetStateAction<TabData[]>>;
8
+ Provider: <TabData_1>(props: import("./context.type").TabsProviderProps<TabData_1>) => JSX.Element;
7
9
  };
8
10
  export default useTabs;
9
11
  //# sourceMappingURL=use-tabs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-tabs.d.ts","sourceRoot":"","sources":["use-tabs.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,QAAA,MAAM,OAAO,UAAW,aAAa;;oBAWR,MAAM,GAAG,MAAM;;CAU3C,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-tabs.d.ts","sourceRoot":"","sources":["use-tabs.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,QAAA,MAAM,OAAO,yBAA0B,aAAa;;oBAYvB,MAAM,GAAG,MAAM;;;;CAY3C,CAAC;AAEF,eAAe,OAAO,CAAC"}