@sheinx/hooks 3.8.0-beta.8 → 3.8.0-fix.1

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 (187) hide show
  1. package/cjs/common/use-filter/use-filter.d.ts.map +1 -1
  2. package/cjs/common/use-filter/use-filter.js +4 -1
  3. package/cjs/common/use-input-able/use-Input-able.d.ts.map +1 -1
  4. package/cjs/common/use-input-able/use-Input-able.js +6 -7
  5. package/cjs/common/use-position-style/check-border.d.ts +1 -0
  6. package/cjs/common/use-position-style/check-border.d.ts.map +1 -1
  7. package/cjs/common/use-position-style/check-border.js +2 -2
  8. package/cjs/common/use-position-style/index.d.ts.map +1 -1
  9. package/cjs/common/use-position-style/index.js +10 -4
  10. package/cjs/components/use-check/use-check.d.ts.map +1 -1
  11. package/cjs/components/use-check/use-check.js +10 -2
  12. package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  13. package/cjs/components/use-datepicker/use-datepicker-format.js +1 -0
  14. package/cjs/components/use-datepicker/use-time.d.ts +10 -8
  15. package/cjs/components/use-datepicker/use-time.d.ts.map +1 -1
  16. package/cjs/components/use-datepicker/use-time.js +19 -5
  17. package/cjs/components/use-datepicker/use-time.type.d.ts +5 -1
  18. package/cjs/components/use-datepicker/use-time.type.d.ts.map +1 -1
  19. package/cjs/components/use-datepicker/util.d.ts.map +1 -1
  20. package/cjs/components/use-datepicker/util.js +10 -1
  21. package/cjs/components/use-form/Provider.d.ts.map +1 -1
  22. package/cjs/components/use-form/Provider.js +7 -2
  23. package/cjs/components/use-form/form-schema-context.d.ts +6 -0
  24. package/cjs/components/use-form/form-schema-context.d.ts.map +1 -0
  25. package/cjs/components/use-form/form-schema-context.js +16 -0
  26. package/cjs/components/use-form/index.d.ts +2 -0
  27. package/cjs/components/use-form/index.d.ts.map +1 -1
  28. package/cjs/components/use-form/index.js +21 -1
  29. package/cjs/components/use-form/use-form-context.d.ts.map +1 -1
  30. package/cjs/components/use-form/use-form-context.js +11 -5
  31. package/cjs/components/use-form/use-form-context.type.d.ts +6 -0
  32. package/cjs/components/use-form/use-form-context.type.d.ts.map +1 -1
  33. package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  34. package/cjs/components/use-form/use-form-control/use-form-control.js +34 -4
  35. package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts +8 -2
  36. package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
  37. package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts +8 -0
  38. package/cjs/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
  39. package/cjs/components/use-form/use-form-item/form-item-context.d.ts +1 -0
  40. package/cjs/components/use-form/use-form-item/form-item-context.d.ts.map +1 -1
  41. package/cjs/components/use-form/use-form-item/form-item-context.js +2 -1
  42. package/cjs/components/use-form/use-form-item/index.d.ts +1 -0
  43. package/cjs/components/use-form/use-form-item/index.d.ts.map +1 -1
  44. package/cjs/components/use-form/use-form-item/index.js +7 -0
  45. package/cjs/components/use-form/use-form-item/use-form-item.d.ts +1 -1
  46. package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts +50 -0
  47. package/cjs/components/use-form/use-form-schema/form-schema-builder.d.ts.map +1 -0
  48. package/cjs/components/use-form/use-form-schema/form-schema-builder.js +377 -0
  49. package/cjs/components/use-form/use-form-schema/index.d.ts +3 -0
  50. package/cjs/components/use-form/use-form-schema/index.d.ts.map +1 -0
  51. package/cjs/components/use-form/use-form-schema/index.js +13 -0
  52. package/cjs/components/use-form/use-form.d.ts +4 -0
  53. package/cjs/components/use-form/use-form.d.ts.map +1 -1
  54. package/cjs/components/use-form/use-form.js +19 -9
  55. package/cjs/components/use-form/use-form.type.d.ts +46 -39
  56. package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
  57. package/cjs/components/use-input/use-input-number.d.ts.map +1 -1
  58. package/cjs/components/use-input/use-input-number.js +3 -1
  59. package/cjs/components/use-input/use-input-number.type.d.ts +1 -1
  60. package/cjs/components/use-input/use-input-number.type.d.ts.map +1 -1
  61. package/cjs/components/use-input/use-input.d.ts.map +1 -1
  62. package/cjs/components/use-input/use-input.js +4 -1
  63. package/cjs/components/use-pagination/use-pagination.d.ts.map +1 -1
  64. package/cjs/components/use-pagination/use-pagination.js +2 -1
  65. package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
  66. package/cjs/components/use-popup/use-popup.js +12 -24
  67. package/cjs/components/use-select/use-select.type.d.ts +27 -18
  68. package/cjs/components/use-select/use-select.type.d.ts.map +1 -1
  69. package/cjs/components/use-table/use-table-virtual.d.ts +6 -1
  70. package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
  71. package/cjs/components/use-table/use-table-virtual.js +5 -4
  72. package/cjs/components/use-table/use-table.type.d.ts +70 -92
  73. package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
  74. package/cjs/components/use-tree/use-tree-node.d.ts +7 -1
  75. package/cjs/components/use-tree/use-tree-node.d.ts.map +1 -1
  76. package/cjs/components/use-tree/use-tree-node.js +19 -1
  77. package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
  78. package/cjs/components/use-tree/use-tree.js +26 -19
  79. package/cjs/components/use-tree/use-tree.type.d.ts +7 -1
  80. package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
  81. package/cjs/utils/dom/document.d.ts +4 -0
  82. package/cjs/utils/dom/document.d.ts.map +1 -1
  83. package/cjs/utils/dom/document.js +19 -2
  84. package/cjs/utils/dom/element.d.ts +1 -0
  85. package/cjs/utils/dom/element.d.ts.map +1 -1
  86. package/cjs/utils/dom/element.js +5 -1
  87. package/cjs/utils/highlight.d.ts.map +1 -1
  88. package/cjs/utils/highlight.js +24 -11
  89. package/cjs/utils/lazyload.d.ts.map +1 -1
  90. package/cjs/utils/lazyload.js +33 -1
  91. package/cjs/utils/object.d.ts +6 -0
  92. package/cjs/utils/object.d.ts.map +1 -1
  93. package/cjs/utils/object.js +21 -1
  94. package/esm/common/use-filter/use-filter.d.ts.map +1 -1
  95. package/esm/common/use-filter/use-filter.js +4 -1
  96. package/esm/common/use-input-able/use-Input-able.d.ts.map +1 -1
  97. package/esm/common/use-input-able/use-Input-able.js +7 -8
  98. package/esm/common/use-position-style/check-border.d.ts +1 -0
  99. package/esm/common/use-position-style/check-border.d.ts.map +1 -1
  100. package/esm/common/use-position-style/check-border.js +2 -2
  101. package/esm/common/use-position-style/index.d.ts.map +1 -1
  102. package/esm/common/use-position-style/index.js +11 -5
  103. package/esm/components/use-check/use-check.d.ts.map +1 -1
  104. package/esm/components/use-check/use-check.js +10 -2
  105. package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  106. package/esm/components/use-datepicker/use-datepicker-format.js +1 -0
  107. package/esm/components/use-datepicker/use-time.d.ts +10 -8
  108. package/esm/components/use-datepicker/use-time.d.ts.map +1 -1
  109. package/esm/components/use-datepicker/use-time.js +19 -5
  110. package/esm/components/use-datepicker/use-time.type.d.ts +5 -1
  111. package/esm/components/use-datepicker/use-time.type.d.ts.map +1 -1
  112. package/esm/components/use-datepicker/util.d.ts.map +1 -1
  113. package/esm/components/use-datepicker/util.js +10 -1
  114. package/esm/components/use-form/Provider.d.ts.map +1 -1
  115. package/esm/components/use-form/Provider.js +7 -2
  116. package/esm/components/use-form/form-schema-context.d.ts +6 -0
  117. package/esm/components/use-form/form-schema-context.d.ts.map +1 -0
  118. package/esm/components/use-form/form-schema-context.js +8 -0
  119. package/esm/components/use-form/index.d.ts +2 -0
  120. package/esm/components/use-form/index.d.ts.map +1 -1
  121. package/esm/components/use-form/index.js +3 -1
  122. package/esm/components/use-form/use-form-context.d.ts.map +1 -1
  123. package/esm/components/use-form/use-form-context.js +11 -5
  124. package/esm/components/use-form/use-form-context.type.d.ts +6 -0
  125. package/esm/components/use-form/use-form-context.type.d.ts.map +1 -1
  126. package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  127. package/esm/components/use-form/use-form-control/use-form-control.js +34 -4
  128. package/esm/components/use-form/use-form-control/use-form-control.type.d.ts +8 -2
  129. package/esm/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
  130. package/esm/components/use-form/use-form-flow/use-form-datum.d.ts +8 -0
  131. package/esm/components/use-form/use-form-flow/use-form-datum.d.ts.map +1 -1
  132. package/esm/components/use-form/use-form-item/form-item-context.d.ts +1 -0
  133. package/esm/components/use-form/use-form-item/form-item-context.d.ts.map +1 -1
  134. package/esm/components/use-form/use-form-item/form-item-context.js +2 -1
  135. package/esm/components/use-form/use-form-item/index.d.ts +1 -0
  136. package/esm/components/use-form/use-form-item/index.d.ts.map +1 -1
  137. package/esm/components/use-form/use-form-item/index.js +2 -1
  138. package/esm/components/use-form/use-form-item/use-form-item.d.ts +1 -1
  139. package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts +50 -0
  140. package/esm/components/use-form/use-form-schema/form-schema-builder.d.ts.map +1 -0
  141. package/esm/components/use-form/use-form-schema/form-schema-builder.js +371 -0
  142. package/esm/components/use-form/use-form-schema/index.d.ts +3 -0
  143. package/esm/components/use-form/use-form-schema/index.d.ts.map +1 -0
  144. package/esm/components/use-form/use-form-schema/index.js +2 -0
  145. package/esm/components/use-form/use-form.d.ts +4 -0
  146. package/esm/components/use-form/use-form.d.ts.map +1 -1
  147. package/esm/components/use-form/use-form.js +19 -9
  148. package/esm/components/use-form/use-form.type.d.ts +46 -39
  149. package/esm/components/use-form/use-form.type.d.ts.map +1 -1
  150. package/esm/components/use-input/use-input-number.d.ts.map +1 -1
  151. package/esm/components/use-input/use-input-number.js +3 -1
  152. package/esm/components/use-input/use-input-number.type.d.ts +1 -1
  153. package/esm/components/use-input/use-input-number.type.d.ts.map +1 -1
  154. package/esm/components/use-input/use-input.d.ts.map +1 -1
  155. package/esm/components/use-input/use-input.js +4 -1
  156. package/esm/components/use-pagination/use-pagination.d.ts.map +1 -1
  157. package/esm/components/use-pagination/use-pagination.js +2 -1
  158. package/esm/components/use-popup/use-popup.d.ts.map +1 -1
  159. package/esm/components/use-popup/use-popup.js +12 -24
  160. package/esm/components/use-select/use-select.type.d.ts +27 -18
  161. package/esm/components/use-select/use-select.type.d.ts.map +1 -1
  162. package/esm/components/use-table/use-table-virtual.d.ts +6 -1
  163. package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
  164. package/esm/components/use-table/use-table-virtual.js +5 -4
  165. package/esm/components/use-table/use-table.type.d.ts +70 -92
  166. package/esm/components/use-table/use-table.type.d.ts.map +1 -1
  167. package/esm/components/use-tree/use-tree-node.d.ts +7 -1
  168. package/esm/components/use-tree/use-tree-node.d.ts.map +1 -1
  169. package/esm/components/use-tree/use-tree-node.js +19 -1
  170. package/esm/components/use-tree/use-tree.d.ts.map +1 -1
  171. package/esm/components/use-tree/use-tree.js +26 -19
  172. package/esm/components/use-tree/use-tree.type.d.ts +7 -1
  173. package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
  174. package/esm/utils/dom/document.d.ts +4 -0
  175. package/esm/utils/dom/document.d.ts.map +1 -1
  176. package/esm/utils/dom/document.js +18 -1
  177. package/esm/utils/dom/element.d.ts +1 -0
  178. package/esm/utils/dom/element.d.ts.map +1 -1
  179. package/esm/utils/dom/element.js +4 -0
  180. package/esm/utils/highlight.d.ts.map +1 -1
  181. package/esm/utils/highlight.js +24 -10
  182. package/esm/utils/lazyload.d.ts.map +1 -1
  183. package/esm/utils/lazyload.js +33 -1
  184. package/esm/utils/object.d.ts +6 -0
  185. package/esm/utils/object.d.ts.map +1 -1
  186. package/esm/utils/object.js +20 -0
  187. package/package.json +3 -3
@@ -3,8 +3,10 @@ export * from './use-form-item';
3
3
  export * from './use-form-fieldset';
4
4
  export * from './use-form-flow';
5
5
  export * from './use-form-context';
6
+ export * from './use-form-schema';
6
7
  export { default, default as useForm } from './use-form';
7
8
  export { useFormConfig } from './form-config-context';
8
9
  export { useFormFunc } from './form-func-context';
10
+ export { useFormSchema } from './form-schema-context';
9
11
  export type { BaseFormProps, FormCommonConfig, FormLabelConfig } from './use-form.type';
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
@@ -4,6 +4,8 @@ export * from "./use-form-item";
4
4
  export * from "./use-form-fieldset";
5
5
  export * from "./use-form-flow";
6
6
  export * from "./use-form-context";
7
+ export * from "./use-form-schema";
7
8
  export { default, default as useForm } from "./use-form";
8
9
  export { useFormConfig } from "./form-config-context";
9
- export { useFormFunc } from "./form-func-context";
10
+ export { useFormFunc } from "./form-func-context";
11
+ export { useFormSchema } from "./form-schema-context";
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-context.d.ts","sourceRoot":"","sources":["use-form-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,eAAO,MAAM,WAAW,oBAA+B,CAAC;AAExD,wBAAgB,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAQ7E;AAED,wBAAgB,eAAe,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAG/C"}
1
+ {"version":3,"file":"use-form-context.d.ts","sourceRoot":"","sources":["use-form-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,eAAO,MAAM,WAAW,oBAA+B,CAAC;AAExD,wBAAgB,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAG7E;AAED,wBAAgB,eAAe,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAG/C"}
@@ -1,11 +1,17 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  import React from 'react';
2
8
  export var FormContext = /*#__PURE__*/React.createContext({});
3
9
  export function useFormRef() {
4
- var ref = React.useRef({});
5
- var setFormRef = function setFormRef(formRef) {
6
- ref.current = formRef;
7
- };
8
- return [ref.current, setFormRef];
10
+ var _React$useState = React.useState({}),
11
+ _React$useState2 = _slicedToArray(_React$useState, 2),
12
+ formRef = _React$useState2[0],
13
+ setFormRef = _React$useState2[1];
14
+ return [formRef, setFormRef];
9
15
  }
10
16
  export function useFormInstance() {
11
17
  var formCtx = React.useContext(FormContext);
@@ -1,3 +1,4 @@
1
+ import { SchemaProperty } from './use-form-schema/form-schema-builder';
1
2
  export interface FormRef<Value = any> {
2
3
  /**
3
4
  * @en return form value
@@ -51,5 +52,10 @@ export interface FormRef<Value = any> {
51
52
  * @cn 滚动到指定字段
52
53
  */
53
54
  scrollToField: (name: string, scrollIntoViewOptions?: ScrollIntoViewOptions) => void;
55
+ /**
56
+ * @en get form schema
57
+ * @cn 获取表单的 schema
58
+ */
59
+ getFormSchema: () => SchemaProperty | undefined;
54
60
  }
55
61
  //# sourceMappingURL=use-form-context.type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-context.type.d.ts","sourceRoot":"","sources":["use-form-context.type.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,OAAO,CAAC,KAAK,GAAG,GAAG;IAClC;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,GAAG,KAAK,CAAC;IACzC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD;;;OAGG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5D;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACrE;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,GAAG,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACtF"}
1
+ {"version":3,"file":"use-form-context.type.d.ts","sourceRoot":"","sources":["use-form-context.type.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,MAAM,WAAW,OAAO,CAAC,KAAK,GAAG,GAAG;IAClC;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,GAAG,KAAK,CAAC;IACzC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD;;;OAGG;IACH,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5D;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE;;;OAGG;IACH,uBAAuB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACrE;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,GAAG,EAAE,CAAC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7C;;;OAGG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,qBAAqB,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAErF;;;OAGG;IACH,aAAa,EAAE,MAAM,cAAc,GAAG,SAAS,CAAC;CACjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAC;AA4BnF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBAiJpC,CAAC,YAAY,GAAG,EAAE;;;;;EA4DrD"}
1
+ {"version":3,"file":"use-form-control.d.ts","sourceRoot":"","sources":["use-form-control.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,yBAAyB,CAAC;AA4BnF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;;kBA4JpC,CAAC,YAAY,GAAG,EAAE;;;;;EAiFrD"}
@@ -48,7 +48,8 @@ export default function useFormControl(props) {
48
48
  defaultValue = props.defaultValue,
49
49
  rules = props.rules,
50
50
  onError = props.onError,
51
- getValidateProps = props.getValidateProps;
51
+ getValidateProps = props.getValidateProps,
52
+ clearToUndefined = props.clearToUndefined;
52
53
  var _useFieldSetConsumer = useFieldSetConsumer({
53
54
  name: props.name,
54
55
  bind: props.bind
@@ -95,7 +96,9 @@ export default function useFormControl(props) {
95
96
  var errors = arguments.length > 1 ? arguments[1] : undefined;
96
97
  var severErrors = arguments.length > 2 ? arguments[2] : undefined;
97
98
  if (!name) return;
98
- if (isArray(name)) {
99
+ // 加入defaultValue的判断,让其只对 https://github.com/sheinsight/shineout-next/pull/742 的场景生效
100
+ // 如果不加入defaultValue的判断,会导致 8ea43144-36a5-403a-9147-59d54087a110 的问题
101
+ if (isArray(name) && defaultValue !== undefined) {
99
102
  var _value = getValue(name, formValue);
100
103
  var _error = getError(name, errors, severErrors);
101
104
  if (_error !== errorState) {
@@ -106,7 +109,11 @@ export default function useFormControl(props) {
106
109
  var nextValue = [];
107
110
  name.forEach(function (n, index) {
108
111
  if (_value[index] === undefined && dv[index] !== undefined) {
109
- nextValue[index] = dv[index];
112
+ if (clearToUndefined) {
113
+ nextValue[index] = undefined;
114
+ } else {
115
+ nextValue[index] = dv[index];
116
+ }
110
117
  } else {
111
118
  nextValue[index] = _value[index];
112
119
  }
@@ -120,7 +127,11 @@ export default function useFormControl(props) {
120
127
  }
121
128
  if (!shallowEqual(_value2, latestInfo.valueState)) {
122
129
  if (_value2 === undefined && defaultValue !== undefined) {
123
- setValueState(defaultValue);
130
+ if (clearToUndefined) {
131
+ setValueState(undefined);
132
+ } else {
133
+ setValueState(defaultValue);
134
+ }
124
135
  } else {
125
136
  setValueState(_value2);
126
137
  }
@@ -213,8 +224,27 @@ export default function useFormControl(props) {
213
224
  if (onChangePo) onChangePo.apply(void 0, [v].concat(other));
214
225
  if (validateFieldSet) validateFieldSet();
215
226
  });
227
+ var initError = usePersistFn(function () {
228
+ var errors = formFunc === null || formFunc === void 0 ? void 0 : formFunc.getErrors();
229
+ if (isArray(name)) {
230
+ for (var i = 0; i < name.length; i++) {
231
+ var n = name[i];
232
+ var currentErrorInForm = errors === null || errors === void 0 ? void 0 : errors[n];
233
+ if (currentErrorInForm) {
234
+ setErrorState(currentErrorInForm);
235
+ break;
236
+ }
237
+ }
238
+ } else {
239
+ var _currentErrorInForm = errors === null || errors === void 0 ? void 0 : errors[name];
240
+ if (_currentErrorInForm) {
241
+ setErrorState(_currentErrorInForm);
242
+ }
243
+ }
244
+ });
216
245
  useEffect(function () {
217
246
  if (inForm && controlFunc) {
247
+ initError();
218
248
  if (isArray(name)) {
219
249
  var dv = isArray(defaultValue) ? defaultValue : [];
220
250
  name.forEach(function (n, index) {
@@ -24,14 +24,20 @@ export interface BaseFormControlProps<T> {
24
24
  */
25
25
  onError: ((error: Error | undefined) => void) | undefined;
26
26
  /**
27
- * @en When the value changes, it will link to verify the fields in the bind, which needs to be used with Form
28
- * @cn 当值改变是会联动校验 bind 中的字段, 需要配合 Form 使用
27
+ * @en Array of field names that should be re-validated when current field's value changes. Enables field linkage validation for dependent fields. Commonly used in scenarios like password confirmation, related dropdown selections, or interdependent form calculations
28
+ * @cn 当前字段值改变时需要重新校验的字段名称数组。启用字段间的联动校验功能。常用于密码确认、关联下拉选择或相互依赖的表单计算等场景
29
29
  */
30
30
  bind: string[] | undefined;
31
31
  /**
32
32
  * @private 内部属性 for validate
33
33
  */
34
34
  getValidateProps: (() => ObjectType) | undefined;
35
+ /**
36
+ * @en If set to true, the form will not automatically delete the data after the component is uninstalled
37
+ * @cn 设置为 true 组件后,有defaultValue时,允许undefined作为最终值
38
+ * @version 3.8.0
39
+ */
40
+ clearToUndefined?: boolean;
35
41
  }
36
42
  export interface FormControlContext {
37
43
  mounted: boolean;
@@ -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;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;CAClB"}
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;IAEjD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -1,7 +1,15 @@
1
1
  export interface FormDatum {
2
+ /**
3
+ * @en Set form field values. Accepts either an object to set multiple fields at once, or a field name with value to set a single field. Field names support nested paths like "user.name" or "items[0].price". Changes trigger form validation and re-render of affected Flow components
4
+ * @cn 设置表单字段值。可以接收对象以批量设置多个字段,或接收字段名和值以设置单个字段。字段名支持嵌套路径如 "user.name" 或 "items[0].price"。更改会触发表单校验和相关 Flow 组件的重新渲染
5
+ */
2
6
  set: (vals: {
3
7
  [name: string]: any;
4
8
  } | string, value?: any) => void;
9
+ /**
10
+ * @en Get form field value by name. When no name is provided, returns the entire form data object. Supports nested paths like "user.name" or "items[0].price" to access deeply nested values
11
+ * @cn 根据名称获取表单字段值。未提供名称时返回整个表单数据对象。支持嵌套路径如 "user.name" 或 "items[0].price" 来访问深层嵌套的值
12
+ */
5
13
  get: (name?: string) => any;
6
14
  }
7
15
  declare const useFormDatum: () => FormDatum | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"use-form-datum.d.ts","sourceRoot":"","sources":["use-form-datum.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,GAAG,EAAE,CAAC,IAAI,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnE;;;OAGG;IACH,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CAC7B;AAED,QAAA,MAAM,YAAY,6BAgBjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  export interface FormItemContextValueType {
3
+ label?: any;
3
4
  updateError: (name: string, error?: Error) => void;
4
5
  }
5
6
  export declare const FormItemContext: React.Context<FormItemContextValueType>;
@@ -1 +1 @@
1
- {"version":3,"file":"form-item-context.d.ts","sourceRoot":"","sources":["form-item-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,yCAE1B,CAAC"}
1
+ {"version":3,"file":"form-item-context.d.ts","sourceRoot":"","sources":["form-item-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CACpD;AAED,eAAO,MAAM,eAAe,yCAE1B,CAAC"}
@@ -3,4 +3,5 @@
3
3
  import * as React from 'react';
4
4
  export var FormItemContext = /*#__PURE__*/React.createContext({
5
5
  updateError: function updateError() {}
6
- });
6
+ });
7
+ FormItemContext.displayName = 'FormItemContext';
@@ -1,2 +1,3 @@
1
1
  export { default, default as useFormItem } from './use-form-item';
2
+ export { FormItemContext } from './form-item-context';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  "use client";
2
- export { default, default as useFormItem } from "./use-form-item";
2
+ export { default, default as useFormItem } from "./use-form-item";
3
+ export { FormItemContext } from "./form-item-context";
@@ -3,7 +3,7 @@ import type { FormItemContextValueType } from './form-item-context';
3
3
  declare const UseFormItem: () => {
4
4
  Provider: React.Provider<FormItemContextValueType>;
5
5
  ProviderValue: FormItemContextValueType;
6
- errors: (Error | undefined)[];
6
+ errors: Error[];
7
7
  labelConfig: import("..").FormCommonConfig;
8
8
  attributes: Record<string, string>;
9
9
  showError: boolean;
@@ -0,0 +1,50 @@
1
+ interface SchemaMeta {
2
+ type?: string;
3
+ required?: boolean;
4
+ title?: string;
5
+ format?: string;
6
+ items?: any;
7
+ enum?: any[] | {
8
+ anyOf?: any[];
9
+ oneOf?: any[];
10
+ };
11
+ description?: string;
12
+ [key: string]: any;
13
+ }
14
+ export interface SchemaProperty {
15
+ type?: string;
16
+ properties?: Record<string, SchemaProperty>;
17
+ items?: SchemaProperty;
18
+ required?: string[];
19
+ title?: string;
20
+ description?: string;
21
+ format?: string;
22
+ enum?: any;
23
+ [key: string]: any;
24
+ }
25
+ export declare class SchemaBuilder {
26
+ private schema;
27
+ constructor(formName: string);
28
+ updateSchema({ path, meta }: {
29
+ path: string;
30
+ meta: SchemaMeta;
31
+ }): void;
32
+ /**
33
+ * 根据组件信息构建 schema meta
34
+ */
35
+ buildSchemaFromComponent(params: {
36
+ componentElement: any;
37
+ rules?: any[];
38
+ label?: string;
39
+ finalFieldId?: string;
40
+ separator?: string;
41
+ }): SchemaMeta;
42
+ parsePath(path?: string): string[] | null;
43
+ mergeSchema(currentSchema: SchemaProperty, pathSegments: string[], meta: SchemaMeta): void;
44
+ handleArraySegment(currentSchema: SchemaProperty, remainingSegments: string[], meta: SchemaMeta): void;
45
+ handleObjectProperty(currentSchema: SchemaProperty, propertyName: string, remainingSegments: string[], meta: SchemaMeta): void;
46
+ handleRequired(parentSchema: SchemaProperty, propertyName: string, isRequired: boolean): void;
47
+ getFormSchema(): SchemaProperty;
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=form-schema-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-schema-builder.d.ts","sourceRoot":"","sources":["form-schema-builder.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG;QAAE,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAiB;gBACnB,QAAQ,EAAE,MAAM;IAQ5B,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,IAAI;IAMtE;;OAEG;IACH,wBAAwB,CAAC,MAAM,EAAE;QAC/B,gBAAgB,EAAE,GAAG,CAAC;QACtB,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,UAAU;IAuLd,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAuCzC,WAAW,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAkB1F,kBAAkB,CAAC,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IAatG,oBAAoB,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI;IA0B9H,cAAc,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI;IAwB7F,aAAa,IAAI,cAAc;CAGhC"}