@tachybase/schema 0.23.41 → 0.23.48

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 (273) hide show
  1. package/lib/core/effects/index.d.ts +2 -0
  2. package/lib/core/effects/index.js +23 -0
  3. package/lib/core/effects/onFieldEffects.d.ts +27 -0
  4. package/lib/core/effects/onFieldEffects.js +158 -0
  5. package/lib/core/effects/onFormEffects.d.ts +24 -0
  6. package/lib/core/effects/onFormEffects.js +117 -0
  7. package/lib/core/global.d.js +0 -0
  8. package/lib/core/index.d.ts +4 -0
  9. package/lib/core/index.js +27 -0
  10. package/lib/core/models/ArrayField.d.ts +17 -0
  11. package/lib/core/models/ArrayField.js +145 -0
  12. package/lib/core/models/BaseField.d.ts +72 -0
  13. package/lib/core/models/BaseField.js +285 -0
  14. package/lib/core/models/Field.d.ts +70 -0
  15. package/lib/core/models/Field.js +426 -0
  16. package/lib/core/models/Form.d.ts +102 -0
  17. package/lib/core/models/Form.js +483 -0
  18. package/lib/core/models/Graph.d.ts +8 -0
  19. package/lib/core/models/Graph.js +77 -0
  20. package/lib/core/models/Heart.d.ts +16 -0
  21. package/lib/core/models/Heart.js +91 -0
  22. package/lib/core/models/LifeCycle.d.ts +14 -0
  23. package/lib/core/models/LifeCycle.js +64 -0
  24. package/lib/core/models/ObjectField.d.ts +12 -0
  25. package/lib/core/models/ObjectField.js +64 -0
  26. package/lib/core/models/Query.d.ts +18 -0
  27. package/lib/core/models/Query.js +105 -0
  28. package/lib/core/models/VoidField.d.ts +14 -0
  29. package/lib/core/models/VoidField.js +117 -0
  30. package/lib/core/models/index.d.ts +9 -0
  31. package/lib/core/models/index.js +37 -0
  32. package/lib/core/models/types.d.ts +9 -0
  33. package/lib/core/models/types.js +15 -0
  34. package/lib/core/shared/checkers.d.ts +117 -0
  35. package/lib/core/shared/checkers.js +109 -0
  36. package/lib/core/shared/constants.d.ts +48 -0
  37. package/lib/core/shared/constants.js +86 -0
  38. package/lib/core/shared/effective.d.ts +9 -0
  39. package/lib/core/shared/effective.js +91 -0
  40. package/lib/core/shared/externals.d.ts +8 -0
  41. package/lib/core/shared/externals.js +87 -0
  42. package/lib/core/shared/internals.d.ts +54 -0
  43. package/lib/core/shared/internals.js +956 -0
  44. package/lib/core/types.d.ts +275 -0
  45. package/lib/core/types.js +76 -0
  46. package/lib/grid/index.d.ts +67 -0
  47. package/lib/grid/index.js +378 -0
  48. package/lib/grid/observer.d.ts +19 -0
  49. package/lib/grid/observer.js +107 -0
  50. package/lib/index.d.ts +12 -24
  51. package/lib/index.js +27 -244
  52. package/lib/json-schema/compiler.d.ts +8 -0
  53. package/lib/json-schema/compiler.js +129 -0
  54. package/lib/json-schema/global.d.js +0 -0
  55. package/lib/json-schema/index.d.ts +2 -0
  56. package/lib/json-schema/index.js +23 -0
  57. package/lib/json-schema/patches.d.ts +5 -0
  58. package/lib/json-schema/patches.js +68 -0
  59. package/lib/json-schema/polyfills/SPECIFICATION_1_0.d.ts +2 -0
  60. package/lib/json-schema/polyfills/SPECIFICATION_1_0.js +132 -0
  61. package/lib/json-schema/polyfills/index.d.ts +1 -0
  62. package/lib/json-schema/polyfills/index.js +21 -0
  63. package/lib/json-schema/schema.d.ts +88 -0
  64. package/lib/json-schema/schema.js +231 -0
  65. package/lib/json-schema/shared.d.ts +62 -0
  66. package/lib/json-schema/shared.js +232 -0
  67. package/lib/json-schema/transformer.d.ts +4 -0
  68. package/lib/json-schema/transformer.js +238 -0
  69. package/lib/json-schema/types.d.ts +119 -0
  70. package/lib/json-schema/types.js +15 -0
  71. package/lib/path/contexts.d.ts +10 -0
  72. package/lib/path/contexts.js +49 -0
  73. package/lib/path/destructor.d.ts +15 -0
  74. package/lib/path/destructor.js +151 -0
  75. package/lib/path/index.d.ts +51 -0
  76. package/lib/path/index.js +513 -0
  77. package/lib/path/matcher.d.ts +33 -0
  78. package/lib/path/matcher.js +197 -0
  79. package/lib/path/parser.d.ts +33 -0
  80. package/lib/path/parser.js +379 -0
  81. package/lib/path/shared.d.ts +13 -0
  82. package/lib/path/shared.js +121 -0
  83. package/lib/path/tokenizer.d.ts +27 -0
  84. package/lib/path/tokenizer.js +269 -0
  85. package/lib/path/tokens.d.ts +27 -0
  86. package/lib/path/tokens.js +216 -0
  87. package/lib/path/types.d.ts +88 -0
  88. package/lib/path/types.js +63 -0
  89. package/lib/react/components/ArrayField.d.ts +6 -0
  90. package/lib/react/components/ArrayField.js +44 -0
  91. package/lib/react/components/ExpressionScope.d.ts +2 -0
  92. package/lib/react/components/ExpressionScope.js +35 -0
  93. package/lib/react/components/Field.d.ts +5 -0
  94. package/lib/react/components/Field.js +45 -0
  95. package/lib/react/components/FormConsumer.d.ts +2 -0
  96. package/lib/react/components/FormConsumer.js +36 -0
  97. package/lib/react/components/FormProvider.d.ts +2 -0
  98. package/lib/react/components/FormProvider.js +35 -0
  99. package/lib/react/components/ObjectField.d.ts +6 -0
  100. package/lib/react/components/ObjectField.js +39 -0
  101. package/lib/react/components/ReactiveField.d.ts +11 -0
  102. package/lib/react/components/ReactiveField.js +115 -0
  103. package/lib/react/components/RecordScope.d.ts +2 -0
  104. package/lib/react/components/RecordScope.js +65 -0
  105. package/lib/react/components/RecordsScope.d.ts +2 -0
  106. package/lib/react/components/RecordsScope.js +43 -0
  107. package/lib/react/components/RecursionField.d.ts +2 -0
  108. package/lib/react/components/RecursionField.js +105 -0
  109. package/lib/react/components/SchemaField.d.ts +41 -0
  110. package/lib/react/components/SchemaField.js +154 -0
  111. package/lib/react/components/VoidField.d.ts +5 -0
  112. package/lib/react/components/VoidField.js +39 -0
  113. package/lib/react/components/index.d.ts +11 -0
  114. package/lib/react/components/index.js +41 -0
  115. package/lib/react/global.d.js +0 -0
  116. package/lib/react/hooks/index.d.ts +6 -0
  117. package/lib/react/hooks/index.js +31 -0
  118. package/lib/react/hooks/useAttach.d.ts +6 -0
  119. package/lib/react/hooks/useAttach.js +35 -0
  120. package/lib/react/hooks/useExpressionScope.d.ts +1 -0
  121. package/lib/react/hooks/useExpressionScope.js +30 -0
  122. package/lib/react/hooks/useField.d.ts +2 -0
  123. package/lib/react/hooks/useField.js +32 -0
  124. package/lib/react/hooks/useFieldSchema.d.ts +2 -0
  125. package/lib/react/hooks/useFieldSchema.js +32 -0
  126. package/lib/react/hooks/useForm.d.ts +2 -0
  127. package/lib/react/hooks/useForm.js +32 -0
  128. package/lib/react/hooks/useFormEffects.d.ts +2 -0
  129. package/lib/react/hooks/useFormEffects.js +42 -0
  130. package/lib/react/hooks/useParentForm.d.ts +2 -0
  131. package/lib/react/hooks/useParentForm.js +40 -0
  132. package/lib/react/index.d.ts +5 -0
  133. package/lib/react/index.js +29 -0
  134. package/lib/react/shared/connect.d.ts +9 -0
  135. package/lib/react/shared/connect.js +118 -0
  136. package/lib/react/shared/context.d.ts +14 -0
  137. package/lib/react/shared/context.js +74 -0
  138. package/lib/react/shared/index.d.ts +2 -0
  139. package/lib/react/shared/index.js +23 -0
  140. package/lib/react/shared/render.d.ts +2 -0
  141. package/lib/react/shared/render.js +69 -0
  142. package/lib/react/types.d.ts +84 -0
  143. package/lib/react/types.js +15 -0
  144. package/lib/reactive/action.d.ts +2 -0
  145. package/lib/reactive/action.js +48 -0
  146. package/lib/reactive/annotations/box.d.ts +7 -0
  147. package/lib/reactive/annotations/box.js +76 -0
  148. package/lib/reactive/annotations/computed.d.ts +12 -0
  149. package/lib/reactive/annotations/computed.js +154 -0
  150. package/lib/reactive/annotations/index.d.ts +5 -0
  151. package/lib/reactive/annotations/index.js +29 -0
  152. package/lib/reactive/annotations/observable.d.ts +4 -0
  153. package/lib/reactive/annotations/observable.js +67 -0
  154. package/lib/reactive/annotations/ref.d.ts +6 -0
  155. package/lib/reactive/annotations/ref.js +78 -0
  156. package/lib/reactive/annotations/shallow.d.ts +2 -0
  157. package/lib/reactive/annotations/shallow.js +67 -0
  158. package/lib/reactive/array.d.ts +12 -0
  159. package/lib/reactive/array.js +83 -0
  160. package/lib/reactive/autorun.d.ts +7 -0
  161. package/lib/reactive/autorun.js +155 -0
  162. package/lib/reactive/batch.d.ts +2 -0
  163. package/lib/reactive/batch.js +40 -0
  164. package/lib/reactive/checkers.d.ts +10 -0
  165. package/lib/reactive/checkers.js +60 -0
  166. package/lib/reactive/environment.d.ts +28 -0
  167. package/lib/reactive/environment.js +76 -0
  168. package/lib/reactive/externals.d.ts +10 -0
  169. package/lib/reactive/externals.js +156 -0
  170. package/lib/reactive/global.d.js +0 -0
  171. package/lib/reactive/handlers.d.ts +4 -0
  172. package/lib/reactive/handlers.js +246 -0
  173. package/lib/reactive/index.d.ts +10 -0
  174. package/lib/reactive/index.js +39 -0
  175. package/lib/reactive/internals.d.ts +17 -0
  176. package/lib/reactive/internals.js +139 -0
  177. package/lib/reactive/model.d.ts +3 -0
  178. package/lib/reactive/model.js +68 -0
  179. package/lib/reactive/observable.d.ts +9 -0
  180. package/lib/reactive/observable.js +50 -0
  181. package/lib/reactive/observe.d.ts +2 -0
  182. package/lib/reactive/observe.js +58 -0
  183. package/lib/reactive/reaction.d.ts +21 -0
  184. package/lib/reactive/reaction.js +278 -0
  185. package/lib/reactive/tracker.d.ts +7 -0
  186. package/lib/reactive/tracker.js +63 -0
  187. package/lib/reactive/tree.d.ts +25 -0
  188. package/lib/reactive/tree.js +106 -0
  189. package/lib/reactive/types.d.ts +79 -0
  190. package/lib/reactive/types.js +21 -0
  191. package/lib/reactive/untracked.d.ts +4 -0
  192. package/lib/reactive/untracked.js +29 -0
  193. package/lib/reactive-react/hooks/index.d.ts +9 -0
  194. package/lib/reactive-react/hooks/index.js +48 -0
  195. package/lib/reactive-react/hooks/useCompatEffect.d.ts +2 -0
  196. package/lib/reactive-react/hooks/useCompatEffect.js +60 -0
  197. package/lib/reactive-react/hooks/useCompatFactory.d.ts +3 -0
  198. package/lib/reactive-react/hooks/useCompatFactory.js +74 -0
  199. package/lib/reactive-react/hooks/useDidUpdate.d.ts +1 -0
  200. package/lib/reactive-react/hooks/useDidUpdate.js +38 -0
  201. package/lib/reactive-react/hooks/useForceUpdate.d.ts +1 -0
  202. package/lib/reactive-react/hooks/useForceUpdate.js +76 -0
  203. package/lib/reactive-react/hooks/useLayoutEffect.d.ts +2 -0
  204. package/lib/reactive-react/hooks/useLayoutEffect.js +28 -0
  205. package/lib/reactive-react/hooks/useObserver.d.ts +2 -0
  206. package/lib/reactive-react/hooks/useObserver.js +43 -0
  207. package/lib/reactive-react/index.d.ts +3 -0
  208. package/lib/reactive-react/index.js +25 -0
  209. package/lib/reactive-react/observer.d.ts +8 -0
  210. package/lib/reactive-react/observer.js +64 -0
  211. package/lib/reactive-react/shared/gc.d.ts +8 -0
  212. package/lib/reactive-react/shared/gc.js +59 -0
  213. package/lib/reactive-react/shared/global.d.ts +1 -0
  214. package/lib/reactive-react/shared/global.js +50 -0
  215. package/lib/reactive-react/shared/immediate.d.ts +1 -0
  216. package/lib/reactive-react/shared/immediate.js +40 -0
  217. package/lib/reactive-react/shared/index.d.ts +2 -0
  218. package/lib/reactive-react/shared/index.js +23 -0
  219. package/lib/reactive-react/types.d.ts +14 -0
  220. package/lib/reactive-react/types.js +15 -0
  221. package/lib/shared/array.d.ts +35 -0
  222. package/lib/shared/array.js +189 -0
  223. package/lib/shared/case.d.ts +6 -0
  224. package/lib/shared/case.js +39 -0
  225. package/lib/shared/checkers.d.ts +21 -0
  226. package/lib/shared/checkers.js +77 -0
  227. package/lib/shared/clone.d.ts +2 -0
  228. package/lib/shared/clone.js +97 -0
  229. package/lib/shared/compare.d.ts +1 -0
  230. package/lib/shared/compare.js +129 -0
  231. package/lib/shared/defaults.d.ts +6 -0
  232. package/lib/shared/defaults.js +63 -0
  233. package/lib/shared/deprecate.d.ts +1 -0
  234. package/lib/shared/deprecate.js +42 -0
  235. package/lib/shared/global.d.ts +1 -0
  236. package/lib/shared/global.js +50 -0
  237. package/lib/shared/index.d.ts +16 -0
  238. package/lib/shared/index.js +51 -0
  239. package/lib/shared/instanceof.d.ts +1 -0
  240. package/lib/shared/instanceof.js +36 -0
  241. package/lib/shared/isEmpty.d.ts +3 -0
  242. package/lib/shared/isEmpty.js +94 -0
  243. package/lib/shared/merge.d.ts +12 -0
  244. package/lib/shared/merge.js +214 -0
  245. package/lib/shared/middleware.d.ts +4 -0
  246. package/lib/shared/middleware.js +41 -0
  247. package/lib/shared/path.d.ts +3 -0
  248. package/lib/shared/path.js +27 -0
  249. package/lib/shared/string.d.ts +1 -0
  250. package/lib/shared/string.js +38 -0
  251. package/lib/shared/subscribable.d.ts +11 -0
  252. package/lib/shared/subscribable.js +74 -0
  253. package/lib/shared/uid.d.ts +1 -0
  254. package/lib/shared/uid.js +35 -0
  255. package/lib/validator/formats.d.ts +16 -0
  256. package/lib/validator/formats.js +40 -0
  257. package/lib/validator/index.d.ts +4 -0
  258. package/lib/validator/index.js +27 -0
  259. package/lib/validator/locale.d.ts +219 -0
  260. package/lib/validator/locale.js +240 -0
  261. package/lib/validator/parser.d.ts +5 -0
  262. package/lib/validator/parser.js +153 -0
  263. package/lib/validator/registry.d.ts +15 -0
  264. package/lib/validator/registry.js +116 -0
  265. package/lib/validator/rules.d.ts +3 -0
  266. package/lib/validator/rules.js +154 -0
  267. package/lib/validator/template.d.ts +2 -0
  268. package/lib/validator/template.js +42 -0
  269. package/lib/validator/types.d.ts +62 -0
  270. package/lib/validator/types.js +28 -0
  271. package/lib/validator/validator.d.ts +2 -0
  272. package/lib/validator/validator.js +63 -0
  273. package/package.json +16 -10
@@ -0,0 +1,956 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var internals_exports = {};
20
+ __export(internals_exports, {
21
+ allowAssignDefaultValue: () => allowAssignDefaultValue,
22
+ batchReset: () => batchReset,
23
+ batchSubmit: () => batchSubmit,
24
+ batchValidate: () => batchValidate,
25
+ buildDataPath: () => buildDataPath,
26
+ buildFieldPath: () => buildFieldPath,
27
+ cleanupArrayChildren: () => cleanupArrayChildren,
28
+ cleanupObjectChildren: () => cleanupObjectChildren,
29
+ createBatchStateGetter: () => createBatchStateGetter,
30
+ createBatchStateSetter: () => createBatchStateSetter,
31
+ createChildrenFeedbackFilter: () => createChildrenFeedbackFilter,
32
+ createReaction: () => createReaction,
33
+ createReactions: () => createReactions,
34
+ createStateGetter: () => createStateGetter,
35
+ createStateSetter: () => createStateSetter,
36
+ deserialize: () => deserialize,
37
+ destroy: () => destroy,
38
+ exchangeArrayState: () => exchangeArrayState,
39
+ getArrayParent: () => getArrayParent,
40
+ getObjectParent: () => getObjectParent,
41
+ getTypedDefaultValue: () => getTypedDefaultValue,
42
+ getValidFieldDefaultValue: () => getValidFieldDefaultValue,
43
+ getValidFormValues: () => getValidFormValues,
44
+ getValuesFromEvent: () => getValuesFromEvent,
45
+ initFieldUpdate: () => initFieldUpdate,
46
+ initializeEnd: () => initializeEnd,
47
+ initializeStart: () => initializeStart,
48
+ isHTMLInputEvent: () => isHTMLInputEvent,
49
+ locateNode: () => locateNode,
50
+ matchFeedback: () => matchFeedback,
51
+ modifySelf: () => modifySelf,
52
+ patchFieldStates: () => patchFieldStates,
53
+ patchFormValues: () => patchFormValues,
54
+ queryFeedbackMessages: () => queryFeedbackMessages,
55
+ queryFeedbacks: () => queryFeedbacks,
56
+ resetSelf: () => resetSelf,
57
+ serialize: () => serialize,
58
+ setLoading: () => setLoading,
59
+ setSubmitting: () => setSubmitting,
60
+ setValidating: () => setValidating,
61
+ setValidatorRule: () => setValidatorRule,
62
+ spliceArrayState: () => spliceArrayState,
63
+ subscribeUpdate: () => subscribeUpdate,
64
+ triggerFormInitialValuesChange: () => triggerFormInitialValuesChange,
65
+ triggerFormValuesChange: () => triggerFormValuesChange,
66
+ updateFeedback: () => updateFeedback,
67
+ validateSelf: () => validateSelf,
68
+ validateToFeedbacks: () => validateToFeedbacks
69
+ });
70
+ module.exports = __toCommonJS(internals_exports);
71
+ var import_reactive = require("../../reactive");
72
+ var import_shared = require("../../shared");
73
+ var import_validator = require("../../validator");
74
+ var import_types = require("../types");
75
+ var import_constants = require("./constants");
76
+ var import_externals = require("./externals");
77
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
78
+ const notify = /* @__PURE__ */ __name((target, formType, fieldType) => {
79
+ if ((0, import_externals.isForm)(target)) {
80
+ target.notify(formType);
81
+ } else {
82
+ target.notify(fieldType);
83
+ }
84
+ }, "notify");
85
+ const isHTMLInputEvent = /* @__PURE__ */ __name((event, stopPropagation = true) => {
86
+ var _a;
87
+ if (event == null ? void 0 : event.target) {
88
+ if (typeof event.target === "object" && ("value" in event.target || "checked" in event.target)) return true;
89
+ if (stopPropagation) (_a = event.stopPropagation) == null ? void 0 : _a.call(event);
90
+ }
91
+ return false;
92
+ }, "isHTMLInputEvent");
93
+ const getValuesFromEvent = /* @__PURE__ */ __name((args) => {
94
+ return args.map((event) => {
95
+ if (event == null ? void 0 : event.target) {
96
+ if ((0, import_shared.isValid)(event.target.value)) return event.target.value;
97
+ if ((0, import_shared.isValid)(event.target.checked)) return event.target.checked;
98
+ return;
99
+ }
100
+ return event;
101
+ });
102
+ }, "getValuesFromEvent");
103
+ const getTypedDefaultValue = /* @__PURE__ */ __name((field) => {
104
+ if ((0, import_externals.isArrayField)(field)) return [];
105
+ if ((0, import_externals.isObjectField)(field)) return {};
106
+ }, "getTypedDefaultValue");
107
+ const buildFieldPath = /* @__PURE__ */ __name((field) => {
108
+ return buildDataPath(field.form.fields, field.address);
109
+ }, "buildFieldPath");
110
+ const buildDataPath = /* @__PURE__ */ __name((fields, pattern) => {
111
+ let prevArray = false;
112
+ const segments = pattern.segments;
113
+ const path = segments.reduce((path2, key, index) => {
114
+ const currentPath = path2.concat(key);
115
+ const currentAddress = segments.slice(0, index + 1);
116
+ const current = fields[currentAddress.join(".")];
117
+ if (prevArray) {
118
+ if (!(0, import_externals.isVoidField)(current)) {
119
+ prevArray = false;
120
+ }
121
+ return path2;
122
+ }
123
+ if (index >= segments.length - 1) {
124
+ return currentPath;
125
+ }
126
+ if ((0, import_externals.isVoidField)(current)) {
127
+ const parentAddress = segments.slice(0, index);
128
+ const parent = fields[parentAddress.join(".")];
129
+ if ((0, import_externals.isArrayField)(parent) && (0, import_shared.isNumberLike)(key)) {
130
+ prevArray = true;
131
+ return currentPath;
132
+ }
133
+ return path2;
134
+ } else {
135
+ prevArray = false;
136
+ }
137
+ return currentPath;
138
+ }, []);
139
+ return new import_shared.FormPath(path);
140
+ }, "buildDataPath");
141
+ const locateNode = /* @__PURE__ */ __name((field, address) => {
142
+ field.address = import_shared.FormPath.parse(address);
143
+ field.path = buildFieldPath(field);
144
+ field.form.indexes[field.path.toString()] = field.address.toString();
145
+ return field;
146
+ }, "locateNode");
147
+ const patchFieldStates = /* @__PURE__ */ __name((target, patches) => {
148
+ patches.forEach(({ type, address, oldAddress, payload }) => {
149
+ if (type === "remove") {
150
+ destroy(target, address, false);
151
+ } else if (type === "update") {
152
+ if (payload) {
153
+ target[address] = payload;
154
+ if (target[oldAddress] === payload) {
155
+ target[oldAddress] = void 0;
156
+ }
157
+ }
158
+ if (address && payload) {
159
+ locateNode(payload, address);
160
+ }
161
+ }
162
+ });
163
+ }, "patchFieldStates");
164
+ const destroy = /* @__PURE__ */ __name((target, address, forceClear = true) => {
165
+ const field = target[address];
166
+ field == null ? void 0 : field.dispose();
167
+ if ((0, import_externals.isDataField)(field) && forceClear) {
168
+ const form = field.form;
169
+ const path = field.path;
170
+ form.deleteValuesIn(path);
171
+ form.deleteInitialValuesIn(path);
172
+ }
173
+ delete target[address];
174
+ }, "destroy");
175
+ const patchFormValues = /* @__PURE__ */ __name((form, path, source) => {
176
+ const update = /* @__PURE__ */ __name((path2, source2) => {
177
+ if (path2.length) {
178
+ form.setValuesIn(path2, (0, import_shared.clone)(source2));
179
+ } else {
180
+ Object.assign(form.values, (0, import_shared.clone)(source2));
181
+ }
182
+ }, "update");
183
+ const patch = /* @__PURE__ */ __name((source2, path2 = []) => {
184
+ const targetValue = form.getValuesIn(path2);
185
+ const targetField = form.query(path2).take();
186
+ const isUnVoidField = targetField && !(0, import_externals.isVoidField)(targetField);
187
+ if (isUnVoidField && targetField.display === "none") {
188
+ targetField.caches.value = (0, import_shared.clone)(source2);
189
+ return;
190
+ }
191
+ if (allowAssignDefaultValue(targetValue, source2)) {
192
+ update(path2, source2);
193
+ } else {
194
+ if ((0, import_shared.isEmpty)(source2)) return;
195
+ if (import_constants.GlobalState.initializing) return;
196
+ if ((0, import_shared.isPlainObj)(targetValue) && (0, import_shared.isPlainObj)(source2)) {
197
+ (0, import_shared.each)(source2, (value, key) => {
198
+ patch(value, path2.concat(key));
199
+ });
200
+ } else {
201
+ if (targetField) {
202
+ if (isUnVoidField && !targetField.selfModified) {
203
+ update(path2, source2);
204
+ }
205
+ } else if (form.initialized) {
206
+ update(path2, source2);
207
+ }
208
+ }
209
+ }
210
+ }, "patch");
211
+ patch(source, path);
212
+ }, "patchFormValues");
213
+ const matchFeedback = /* @__PURE__ */ __name((search, feedback) => {
214
+ if (!search || !feedback) return false;
215
+ if (search.type && search.type !== feedback.type) return false;
216
+ if (search.code && search.code !== feedback.code) return false;
217
+ if (search.path && feedback.path) {
218
+ if (!import_shared.FormPath.parse(search.path).match(feedback.path)) return false;
219
+ }
220
+ if (search.address && feedback.address) {
221
+ if (!import_shared.FormPath.parse(search.address).match(feedback.address)) return false;
222
+ }
223
+ if (search.triggerType && search.triggerType !== feedback.triggerType) return false;
224
+ return true;
225
+ }, "matchFeedback");
226
+ const queryFeedbacks = /* @__PURE__ */ __name((field, search) => {
227
+ return field.feedbacks.filter((feedback) => {
228
+ var _a, _b, _c;
229
+ if (!((_a = feedback.messages) == null ? void 0 : _a.length)) return false;
230
+ return matchFeedback(search, {
231
+ ...feedback,
232
+ address: (_b = field.address) == null ? void 0 : _b.toString(),
233
+ path: (_c = field.path) == null ? void 0 : _c.toString()
234
+ });
235
+ });
236
+ }, "queryFeedbacks");
237
+ const queryFeedbackMessages = /* @__PURE__ */ __name((field, search) => {
238
+ if (!field.feedbacks.length) return [];
239
+ return queryFeedbacks(field, search).reduce(
240
+ (buf, info) => (0, import_shared.isEmpty)(info.messages) ? buf : buf.concat(info.messages),
241
+ []
242
+ );
243
+ }, "queryFeedbackMessages");
244
+ const updateFeedback = /* @__PURE__ */ __name((field, feedback) => {
245
+ if (!feedback) return;
246
+ return (0, import_reactive.batch)(() => {
247
+ var _a, _b;
248
+ if (!field.feedbacks.length) {
249
+ if (!((_a = feedback.messages) == null ? void 0 : _a.length)) {
250
+ return;
251
+ }
252
+ field.feedbacks = [feedback];
253
+ } else {
254
+ const searched = queryFeedbacks(field, feedback);
255
+ if (searched.length) {
256
+ field.feedbacks = field.feedbacks.reduce((buf, item) => {
257
+ var _a2;
258
+ if (searched.includes(item)) {
259
+ if ((_a2 = feedback.messages) == null ? void 0 : _a2.length) {
260
+ item.messages = feedback.messages;
261
+ return buf.concat(item);
262
+ } else {
263
+ return buf;
264
+ }
265
+ } else {
266
+ return buf.concat(item);
267
+ }
268
+ }, []);
269
+ return;
270
+ } else if ((_b = feedback.messages) == null ? void 0 : _b.length) {
271
+ field.feedbacks = field.feedbacks.concat(feedback);
272
+ }
273
+ }
274
+ });
275
+ }, "updateFeedback");
276
+ const validateToFeedbacks = /* @__PURE__ */ __name(async (field, triggerType = "onInput") => {
277
+ const results = await (0, import_validator.validate)(field.value, field.validator, {
278
+ triggerType,
279
+ validateFirst: field.props.validateFirst ?? field.form.props.validateFirst,
280
+ context: { field, form: field.form }
281
+ });
282
+ (0, import_reactive.batch)(() => {
283
+ (0, import_shared.each)(results, (messages, type) => {
284
+ field.setFeedback({
285
+ triggerType,
286
+ type,
287
+ code: (0, import_shared.pascalCase)(`validate-${type}`),
288
+ messages
289
+ });
290
+ });
291
+ });
292
+ return results;
293
+ }, "validateToFeedbacks");
294
+ const setValidatorRule = /* @__PURE__ */ __name((field, name, value) => {
295
+ if (!(0, import_shared.isValid)(value)) return;
296
+ const validators = (0, import_validator.parseValidatorDescriptions)(field.validator);
297
+ const hasRule = validators.some((desc) => name in desc);
298
+ const rule = {
299
+ [name]: value
300
+ };
301
+ if (hasRule) {
302
+ field.validator = validators.map((desc) => {
303
+ if ((0, import_shared.isPlainObj)(desc) && hasOwnProperty.call(desc, name)) {
304
+ desc[name] = value;
305
+ return desc;
306
+ }
307
+ return desc;
308
+ });
309
+ } else {
310
+ if (name === "required") {
311
+ field.validator = [rule].concat(validators);
312
+ } else {
313
+ field.validator = validators.concat(rule);
314
+ }
315
+ }
316
+ }, "setValidatorRule");
317
+ const spliceArrayState = /* @__PURE__ */ __name((field, props) => {
318
+ const { startIndex, deleteCount, insertCount } = {
319
+ startIndex: 0,
320
+ deleteCount: 0,
321
+ insertCount: 0,
322
+ ...props
323
+ };
324
+ const address = field.address.toString();
325
+ const addrLength = address.length;
326
+ const form = field.form;
327
+ const fields = form.fields;
328
+ const fieldPatches = [];
329
+ const offset = insertCount - deleteCount;
330
+ const isArrayChildren = /* @__PURE__ */ __name((identifier) => {
331
+ return identifier.indexOf(address) === 0 && identifier.length > addrLength;
332
+ }, "isArrayChildren");
333
+ const isAfterNode = /* @__PURE__ */ __name((identifier) => {
334
+ var _a;
335
+ const afterStr = identifier.substring(addrLength);
336
+ const number = (_a = afterStr.match(import_constants.NumberIndexReg)) == null ? void 0 : _a[1];
337
+ if (number === void 0) return false;
338
+ const index = Number(number);
339
+ return index > startIndex + deleteCount - 1;
340
+ }, "isAfterNode");
341
+ const isInsertNode = /* @__PURE__ */ __name((identifier) => {
342
+ var _a;
343
+ const afterStr = identifier.substring(addrLength);
344
+ const number = (_a = afterStr.match(import_constants.NumberIndexReg)) == null ? void 0 : _a[1];
345
+ if (number === void 0) return false;
346
+ const index = Number(number);
347
+ return index >= startIndex && index < startIndex + insertCount;
348
+ }, "isInsertNode");
349
+ const isDeleteNode = /* @__PURE__ */ __name((identifier) => {
350
+ var _a;
351
+ const preStr = identifier.substring(0, addrLength);
352
+ const afterStr = identifier.substring(addrLength);
353
+ const number = (_a = afterStr.match(import_constants.NumberIndexReg)) == null ? void 0 : _a[1];
354
+ if (number === void 0) return false;
355
+ const index = Number(number);
356
+ return index > startIndex && !fields[`${preStr}${afterStr.replace(/^\.\d+/, `.${index + deleteCount}`)}`] || index === startIndex;
357
+ }, "isDeleteNode");
358
+ const moveIndex = /* @__PURE__ */ __name((identifier) => {
359
+ var _a;
360
+ if (offset === 0) return identifier;
361
+ const preStr = identifier.substring(0, addrLength);
362
+ const afterStr = identifier.substring(addrLength);
363
+ const number = (_a = afterStr.match(import_constants.NumberIndexReg)) == null ? void 0 : _a[1];
364
+ if (number === void 0) return identifier;
365
+ const index = Number(number) + offset;
366
+ return `${preStr}${afterStr.replace(/^\.\d+/, `.${index}`)}`;
367
+ }, "moveIndex");
368
+ (0, import_reactive.batch)(() => {
369
+ (0, import_shared.each)(fields, (field2, identifier) => {
370
+ if (isArrayChildren(identifier)) {
371
+ if (isAfterNode(identifier)) {
372
+ const newIdentifier = moveIndex(identifier);
373
+ fieldPatches.push({
374
+ type: "update",
375
+ address: newIdentifier,
376
+ oldAddress: identifier,
377
+ payload: field2
378
+ });
379
+ }
380
+ if (isInsertNode(identifier) || isDeleteNode(identifier)) {
381
+ fieldPatches.push({ type: "remove", address: identifier });
382
+ }
383
+ }
384
+ });
385
+ patchFieldStates(fields, fieldPatches);
386
+ });
387
+ field.form.notify(import_types.LifeCycleTypes.ON_FORM_GRAPH_CHANGE);
388
+ }, "spliceArrayState");
389
+ const exchangeArrayState = /* @__PURE__ */ __name((field, props) => {
390
+ const { fromIndex, toIndex } = {
391
+ fromIndex: 0,
392
+ toIndex: 0,
393
+ ...props
394
+ };
395
+ const address = field.address.toString();
396
+ const fields = field.form.fields;
397
+ const addrLength = address.length;
398
+ const fieldPatches = [];
399
+ const isArrayChildren = /* @__PURE__ */ __name((identifier) => {
400
+ return identifier.indexOf(address) === 0 && identifier.length > addrLength;
401
+ }, "isArrayChildren");
402
+ const isDown = fromIndex < toIndex;
403
+ const isMoveNode = /* @__PURE__ */ __name((identifier) => {
404
+ var _a;
405
+ const afterStr = identifier.slice(address.length);
406
+ const number = (_a = afterStr.match(import_constants.NumberIndexReg)) == null ? void 0 : _a[1];
407
+ if (number === void 0) return false;
408
+ const index = Number(number);
409
+ return isDown ? index > fromIndex && index <= toIndex : index < fromIndex && index >= toIndex;
410
+ }, "isMoveNode");
411
+ const isFromNode = /* @__PURE__ */ __name((identifier) => {
412
+ var _a;
413
+ const afterStr = identifier.substring(addrLength);
414
+ const number = (_a = afterStr.match(import_constants.NumberIndexReg)) == null ? void 0 : _a[1];
415
+ if (number === void 0) return false;
416
+ const index = Number(number);
417
+ return index === fromIndex;
418
+ }, "isFromNode");
419
+ const moveIndex = /* @__PURE__ */ __name((identifier) => {
420
+ const preStr = identifier.substring(0, addrLength);
421
+ const afterStr = identifier.substring(addrLength);
422
+ const number = afterStr.match(import_constants.NumberIndexReg)[1];
423
+ const current = Number(number);
424
+ let index = current;
425
+ if (index === fromIndex) {
426
+ index = toIndex;
427
+ } else {
428
+ index += isDown ? -1 : 1;
429
+ }
430
+ return `${preStr}${afterStr.replace(/^\.\d+/, `.${index}`)}`;
431
+ }, "moveIndex");
432
+ (0, import_reactive.batch)(() => {
433
+ (0, import_shared.each)(fields, (field2, identifier) => {
434
+ if (isArrayChildren(identifier)) {
435
+ if (isMoveNode(identifier) || isFromNode(identifier)) {
436
+ const newIdentifier = moveIndex(identifier);
437
+ fieldPatches.push({
438
+ type: "update",
439
+ address: newIdentifier,
440
+ oldAddress: identifier,
441
+ payload: field2
442
+ });
443
+ if (!fields[newIdentifier]) {
444
+ fieldPatches.push({
445
+ type: "remove",
446
+ address: identifier
447
+ });
448
+ }
449
+ }
450
+ }
451
+ });
452
+ patchFieldStates(fields, fieldPatches);
453
+ });
454
+ field.form.notify(import_types.LifeCycleTypes.ON_FORM_GRAPH_CHANGE);
455
+ }, "exchangeArrayState");
456
+ const cleanupArrayChildren = /* @__PURE__ */ __name((field, start) => {
457
+ const address = field.address.toString();
458
+ const fields = field.form.fields;
459
+ const isArrayChildren = /* @__PURE__ */ __name((identifier) => {
460
+ return identifier.indexOf(address) === 0 && identifier.length > address.length;
461
+ }, "isArrayChildren");
462
+ const isNeedCleanup = /* @__PURE__ */ __name((identifier) => {
463
+ var _a;
464
+ const afterStr = identifier.slice(address.length);
465
+ const numStr = (_a = afterStr.match(import_constants.NumberIndexReg)) == null ? void 0 : _a[1];
466
+ if (numStr === void 0) return false;
467
+ const index = Number(numStr);
468
+ return index >= start;
469
+ }, "isNeedCleanup");
470
+ (0, import_reactive.batch)(() => {
471
+ (0, import_shared.each)(fields, (field2, identifier) => {
472
+ if (isArrayChildren(identifier) && isNeedCleanup(identifier)) {
473
+ field2.destroy();
474
+ }
475
+ });
476
+ });
477
+ }, "cleanupArrayChildren");
478
+ const cleanupObjectChildren = /* @__PURE__ */ __name((field, keys) => {
479
+ if (keys.length === 0) return;
480
+ const address = field.address.toString();
481
+ const fields = field.form.fields;
482
+ const isObjectChildren = /* @__PURE__ */ __name((identifier) => {
483
+ return identifier.indexOf(address) === 0 && identifier.length > address.length;
484
+ }, "isObjectChildren");
485
+ const isNeedCleanup = /* @__PURE__ */ __name((identifier) => {
486
+ var _a;
487
+ const afterStr = identifier.slice(address.length);
488
+ const key = (_a = afterStr.match(/^\.([^.]+)/)) == null ? void 0 : _a[1];
489
+ if (key === void 0) return false;
490
+ return keys.includes(key);
491
+ }, "isNeedCleanup");
492
+ (0, import_reactive.batch)(() => {
493
+ (0, import_shared.each)(fields, (field2, identifier) => {
494
+ if (isObjectChildren(identifier) && isNeedCleanup(identifier)) {
495
+ field2.destroy();
496
+ }
497
+ });
498
+ });
499
+ }, "cleanupObjectChildren");
500
+ const initFieldUpdate = import_reactive.batch.scope.bound((field) => {
501
+ const form = field.form;
502
+ const updates = import_shared.FormPath.ensureIn(form, "requests.updates", []);
503
+ const indexes = import_shared.FormPath.ensureIn(form, "requests.updateIndexes", {});
504
+ for (let index = 0; index < updates.length; index++) {
505
+ const { pattern, callbacks } = updates[index];
506
+ let removed = false;
507
+ if (field.match(pattern)) {
508
+ callbacks.forEach((callback) => {
509
+ field.setState(callback);
510
+ });
511
+ if (!pattern.isWildMatchPattern && !pattern.isMatchPattern) {
512
+ updates.splice(index--, 1);
513
+ removed = true;
514
+ }
515
+ }
516
+ if (!removed) {
517
+ indexes[pattern.toString()] = index;
518
+ } else {
519
+ delete indexes[pattern.toString()];
520
+ }
521
+ }
522
+ });
523
+ const subscribeUpdate = /* @__PURE__ */ __name((form, pattern, callback) => {
524
+ const updates = import_shared.FormPath.ensureIn(form, "requests.updates", []);
525
+ const indexes = import_shared.FormPath.ensureIn(form, "requests.updateIndexes", {});
526
+ const id = pattern.toString();
527
+ const current = indexes[id];
528
+ if ((0, import_shared.isValid)(current)) {
529
+ if (updates[current] && !updates[current].callbacks.some((fn) => fn.toString() === callback.toString() ? fn === callback : false)) {
530
+ updates[current].callbacks.push(callback);
531
+ }
532
+ } else {
533
+ indexes[id] = updates.length;
534
+ updates.push({
535
+ pattern,
536
+ callbacks: [callback]
537
+ });
538
+ }
539
+ }, "subscribeUpdate");
540
+ const deserialize = /* @__PURE__ */ __name((model, setter) => {
541
+ if (!model) return;
542
+ if ((0, import_shared.isFn)(setter)) {
543
+ setter(model);
544
+ } else {
545
+ for (let key in setter) {
546
+ if (!hasOwnProperty.call(setter, key)) continue;
547
+ if (import_constants.ReadOnlyProperties[key] || import_constants.ReservedProperties[key]) continue;
548
+ const MutuallyExclusiveKey = import_constants.MutuallyExclusiveProperties[key];
549
+ if (MutuallyExclusiveKey && hasOwnProperty.call(setter, MutuallyExclusiveKey) && !(0, import_shared.isValid)(setter[MutuallyExclusiveKey]))
550
+ continue;
551
+ const value = setter[key];
552
+ if ((0, import_shared.isFn)(value)) continue;
553
+ model[key] = value;
554
+ }
555
+ }
556
+ return model;
557
+ }, "deserialize");
558
+ const serialize = /* @__PURE__ */ __name((model, getter) => {
559
+ if ((0, import_shared.isFn)(getter)) {
560
+ return getter(model);
561
+ } else {
562
+ const results = {};
563
+ for (let key in model) {
564
+ if (!hasOwnProperty.call(model, key)) continue;
565
+ if (import_constants.ReservedProperties[key]) continue;
566
+ if (key === "address" || key === "path") {
567
+ results[key] = model[key].toString();
568
+ continue;
569
+ }
570
+ const value = model[key];
571
+ if ((0, import_shared.isFn)(value)) continue;
572
+ results[key] = (0, import_reactive.toJS)(value);
573
+ }
574
+ return results;
575
+ }
576
+ }, "serialize");
577
+ const createChildrenFeedbackFilter = /* @__PURE__ */ __name((field) => {
578
+ var _a;
579
+ const identifier = (_a = field.address) == null ? void 0 : _a.toString();
580
+ return ({ address }) => {
581
+ return address === identifier || address.indexOf(identifier + ".") === 0;
582
+ };
583
+ }, "createChildrenFeedbackFilter");
584
+ const createStateSetter = /* @__PURE__ */ __name((model) => {
585
+ return import_reactive.batch.bound((setter) => deserialize(model, setter));
586
+ }, "createStateSetter");
587
+ const createStateGetter = /* @__PURE__ */ __name((model) => {
588
+ return (getter) => serialize(model, getter);
589
+ }, "createStateGetter");
590
+ const createBatchStateSetter = /* @__PURE__ */ __name((form) => {
591
+ return import_reactive.batch.bound((pattern, payload) => {
592
+ if ((0, import_externals.isQuery)(pattern)) {
593
+ pattern.forEach((field) => {
594
+ field.setState(payload);
595
+ });
596
+ } else if ((0, import_externals.isGeneralField)(pattern)) {
597
+ pattern.setState(payload);
598
+ } else {
599
+ let matchCount = 0, path = import_shared.FormPath.parse(pattern);
600
+ form.query(path).forEach((field) => {
601
+ field.setState(payload);
602
+ matchCount++;
603
+ });
604
+ if (matchCount === 0 || path.isWildMatchPattern) {
605
+ subscribeUpdate(form, path, payload);
606
+ }
607
+ }
608
+ });
609
+ }, "createBatchStateSetter");
610
+ const createBatchStateGetter = /* @__PURE__ */ __name((form) => {
611
+ return (pattern, payload) => {
612
+ if ((0, import_externals.isQuery)(pattern)) {
613
+ return pattern.take(payload);
614
+ } else if ((0, import_externals.isGeneralField)(pattern)) {
615
+ return pattern.getState(payload);
616
+ } else {
617
+ return form.query(pattern).take((field) => {
618
+ return field.getState(payload);
619
+ });
620
+ }
621
+ };
622
+ }, "createBatchStateGetter");
623
+ const triggerFormInitialValuesChange = /* @__PURE__ */ __name((form, change) => {
624
+ if (Array.isArray(change.object) && change.key === "length") return;
625
+ if ((0, import_reactive.contains)(form.initialValues, change.object) || form.initialValues === change.value) {
626
+ if (change.type === "add" || change.type === "set") {
627
+ patchFormValues(form, change.path.slice(1), change.value);
628
+ }
629
+ if (form.initialized) {
630
+ form.notify(import_types.LifeCycleTypes.ON_FORM_INITIAL_VALUES_CHANGE);
631
+ }
632
+ }
633
+ }, "triggerFormInitialValuesChange");
634
+ const triggerFormValuesChange = /* @__PURE__ */ __name((form, change) => {
635
+ if (Array.isArray(change.object) && change.key === "length") return;
636
+ if (((0, import_reactive.contains)(form.values, change.object) || form.values === change.value) && form.initialized) {
637
+ form.notify(import_types.LifeCycleTypes.ON_FORM_VALUES_CHANGE);
638
+ }
639
+ }, "triggerFormValuesChange");
640
+ const setValidating = /* @__PURE__ */ __name((target, validating) => {
641
+ clearTimeout(target.requests.validate);
642
+ if (validating) {
643
+ target.requests.validate = setTimeout(() => {
644
+ (0, import_reactive.batch)(() => {
645
+ target.validating = validating;
646
+ notify(target, import_types.LifeCycleTypes.ON_FORM_VALIDATING, import_types.LifeCycleTypes.ON_FIELD_VALIDATING);
647
+ });
648
+ }, import_constants.RESPONSE_REQUEST_DURATION);
649
+ notify(target, import_types.LifeCycleTypes.ON_FORM_VALIDATE_START, import_types.LifeCycleTypes.ON_FIELD_VALIDATE_START);
650
+ } else {
651
+ if (target.validating !== validating) {
652
+ target.validating = validating;
653
+ }
654
+ notify(target, import_types.LifeCycleTypes.ON_FORM_VALIDATE_END, import_types.LifeCycleTypes.ON_FIELD_VALIDATE_END);
655
+ }
656
+ }, "setValidating");
657
+ const setSubmitting = /* @__PURE__ */ __name((target, submitting) => {
658
+ clearTimeout(target.requests.submit);
659
+ if (submitting) {
660
+ target.requests.submit = setTimeout(() => {
661
+ (0, import_reactive.batch)(() => {
662
+ target.submitting = submitting;
663
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMITTING, import_types.LifeCycleTypes.ON_FIELD_SUBMITTING);
664
+ });
665
+ }, import_constants.RESPONSE_REQUEST_DURATION);
666
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT_START, import_types.LifeCycleTypes.ON_FIELD_SUBMIT_START);
667
+ } else {
668
+ if (target.submitting !== submitting) {
669
+ target.submitting = submitting;
670
+ }
671
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT_END, import_types.LifeCycleTypes.ON_FIELD_SUBMIT_END);
672
+ }
673
+ }, "setSubmitting");
674
+ const setLoading = /* @__PURE__ */ __name((target, loading) => {
675
+ clearTimeout(target.requests.loading);
676
+ if (loading) {
677
+ target.requests.loading = setTimeout(() => {
678
+ (0, import_reactive.batch)(() => {
679
+ target.loading = loading;
680
+ notify(target, import_types.LifeCycleTypes.ON_FORM_LOADING, import_types.LifeCycleTypes.ON_FIELD_LOADING);
681
+ });
682
+ }, import_constants.RESPONSE_REQUEST_DURATION);
683
+ } else if (target.loading !== loading) {
684
+ target.loading = loading;
685
+ }
686
+ }, "setLoading");
687
+ const batchSubmit = /* @__PURE__ */ __name(async (target, onSubmit) => {
688
+ const getValues = /* @__PURE__ */ __name((target2) => {
689
+ if ((0, import_externals.isForm)(target2)) {
690
+ return (0, import_reactive.toJS)(target2.values);
691
+ }
692
+ return (0, import_reactive.toJS)(target2.value);
693
+ }, "getValues");
694
+ target.setSubmitting(true);
695
+ try {
696
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT_VALIDATE_START, import_types.LifeCycleTypes.ON_FIELD_SUBMIT_VALIDATE_START);
697
+ await target.validate();
698
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT_VALIDATE_SUCCESS, import_types.LifeCycleTypes.ON_FIELD_SUBMIT_VALIDATE_SUCCESS);
699
+ } catch (e) {
700
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT_VALIDATE_FAILED, import_types.LifeCycleTypes.ON_FIELD_SUBMIT_VALIDATE_FAILED);
701
+ }
702
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT_VALIDATE_END, import_types.LifeCycleTypes.ON_FIELD_SUBMIT_VALIDATE_END);
703
+ let results;
704
+ try {
705
+ if (target.invalid) {
706
+ throw target.errors;
707
+ }
708
+ if ((0, import_shared.isFn)(onSubmit)) {
709
+ results = await onSubmit(getValues(target));
710
+ } else {
711
+ results = getValues(target);
712
+ }
713
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT_SUCCESS, import_types.LifeCycleTypes.ON_FIELD_SUBMIT_SUCCESS);
714
+ } catch (e) {
715
+ target.setSubmitting(false);
716
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT_FAILED, import_types.LifeCycleTypes.ON_FIELD_SUBMIT_FAILED);
717
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT, import_types.LifeCycleTypes.ON_FIELD_SUBMIT);
718
+ throw e;
719
+ }
720
+ target.setSubmitting(false);
721
+ notify(target, import_types.LifeCycleTypes.ON_FORM_SUBMIT, import_types.LifeCycleTypes.ON_FIELD_SUBMIT);
722
+ return results;
723
+ }, "batchSubmit");
724
+ const shouldValidate = /* @__PURE__ */ __name((field) => {
725
+ const validatePattern = field.props.validatePattern ?? field.form.props.validatePattern ?? ["editable"];
726
+ const validateDisplay = field.props.validateDisplay ?? field.form.props.validateDisplay ?? ["visible"];
727
+ return validatePattern.includes(field.pattern) && validateDisplay.includes(field.display);
728
+ }, "shouldValidate");
729
+ const batchValidate = /* @__PURE__ */ __name(async (target, pattern, triggerType) => {
730
+ if ((0, import_externals.isForm)(target)) target.setValidating(true);
731
+ else {
732
+ if (!shouldValidate(target)) return;
733
+ }
734
+ const tasks = [];
735
+ target.query(pattern).forEach((field) => {
736
+ if (!(0, import_externals.isVoidField)(field)) {
737
+ tasks.push(validateSelf(field, triggerType, field === target));
738
+ }
739
+ });
740
+ await Promise.all(tasks);
741
+ if ((0, import_externals.isForm)(target)) target.setValidating(false);
742
+ if (target.invalid) {
743
+ notify(target, import_types.LifeCycleTypes.ON_FORM_VALIDATE_FAILED, import_types.LifeCycleTypes.ON_FIELD_VALIDATE_FAILED);
744
+ throw target.errors;
745
+ }
746
+ notify(target, import_types.LifeCycleTypes.ON_FORM_VALIDATE_SUCCESS, import_types.LifeCycleTypes.ON_FIELD_VALIDATE_SUCCESS);
747
+ }, "batchValidate");
748
+ const batchReset = /* @__PURE__ */ __name(async (target, pattern, options) => {
749
+ const tasks = [];
750
+ target.query(pattern).forEach((field) => {
751
+ if (!(0, import_externals.isVoidField)(field)) {
752
+ tasks.push(resetSelf(field, options, target === field));
753
+ }
754
+ });
755
+ if ((0, import_externals.isForm)(target)) {
756
+ target.modified = false;
757
+ }
758
+ notify(target, import_types.LifeCycleTypes.ON_FORM_RESET, import_types.LifeCycleTypes.ON_FIELD_RESET);
759
+ await Promise.all(tasks);
760
+ }, "batchReset");
761
+ const validateSelf = import_reactive.batch.bound(async (target, triggerType, noEmit = false) => {
762
+ const start = /* @__PURE__ */ __name(() => {
763
+ setValidating(target, true);
764
+ }, "start");
765
+ const end = /* @__PURE__ */ __name(() => {
766
+ setValidating(target, false);
767
+ if (noEmit) return;
768
+ if (target.selfValid) {
769
+ target.notify(import_types.LifeCycleTypes.ON_FIELD_VALIDATE_SUCCESS);
770
+ } else {
771
+ target.notify(import_types.LifeCycleTypes.ON_FIELD_VALIDATE_FAILED);
772
+ }
773
+ }, "end");
774
+ if (!shouldValidate(target)) return {};
775
+ start();
776
+ if (!triggerType) {
777
+ const allTriggerTypes = (0, import_validator.parseValidatorDescriptions)(target.validator).reduce(
778
+ (types, desc) => types.indexOf(desc.triggerType) > -1 ? types : types.concat(desc.triggerType),
779
+ []
780
+ );
781
+ const results2 = {};
782
+ for (let i = 0; i < allTriggerTypes.length; i++) {
783
+ const payload = await validateToFeedbacks(target, allTriggerTypes[i]);
784
+ (0, import_shared.each)(payload, (result, key) => {
785
+ results2[key] = results2[key] || [];
786
+ results2[key] = results2[key].concat(result);
787
+ });
788
+ }
789
+ end();
790
+ return results2;
791
+ }
792
+ const results = await validateToFeedbacks(target, triggerType);
793
+ end();
794
+ return results;
795
+ });
796
+ const resetSelf = import_reactive.batch.bound(async (target, options, noEmit = false) => {
797
+ const typedDefaultValue = getTypedDefaultValue(target);
798
+ target.modified = false;
799
+ target.selfModified = false;
800
+ target.visited = false;
801
+ target.feedbacks = [];
802
+ target.inputValue = typedDefaultValue;
803
+ target.inputValues = [];
804
+ target.caches = {};
805
+ if (!(0, import_shared.isUndef)(target.value)) {
806
+ if (options == null ? void 0 : options.forceClear) {
807
+ target.value = typedDefaultValue;
808
+ } else {
809
+ const initialValue = target.initialValue;
810
+ target.value = (0, import_reactive.toJS)(!(0, import_shared.isUndef)(initialValue) ? initialValue : typedDefaultValue);
811
+ }
812
+ }
813
+ if (!noEmit) {
814
+ target.notify(import_types.LifeCycleTypes.ON_FIELD_RESET);
815
+ }
816
+ if (options == null ? void 0 : options.validate) {
817
+ return await validateSelf(target);
818
+ }
819
+ });
820
+ const modifySelf = /* @__PURE__ */ __name((target) => {
821
+ if (target.selfModified) return;
822
+ target.selfModified = true;
823
+ target.modified = true;
824
+ let parent = target.parent;
825
+ while (parent) {
826
+ if ((0, import_externals.isDataField)(parent)) {
827
+ if (parent.modified) return;
828
+ parent.modified = true;
829
+ }
830
+ parent = parent.parent;
831
+ }
832
+ target.form.modified = true;
833
+ }, "modifySelf");
834
+ const getValidFormValues = /* @__PURE__ */ __name((values) => {
835
+ if ((0, import_reactive.isObservable)(values)) return values;
836
+ return (0, import_shared.clone)(values || {});
837
+ }, "getValidFormValues");
838
+ const getValidFieldDefaultValue = /* @__PURE__ */ __name((value, initialValue) => {
839
+ if (allowAssignDefaultValue(value, initialValue)) return (0, import_shared.clone)(initialValue);
840
+ return value;
841
+ }, "getValidFieldDefaultValue");
842
+ const allowAssignDefaultValue = /* @__PURE__ */ __name((target, source) => {
843
+ const isValidTarget = !(0, import_shared.isUndef)(target);
844
+ const isValidSource = !(0, import_shared.isUndef)(source);
845
+ if (!isValidTarget) {
846
+ return isValidSource;
847
+ }
848
+ if (typeof target === typeof source) {
849
+ if (target === "") return false;
850
+ if (target === 0) return false;
851
+ }
852
+ const isEmptyTarget = target !== null && (0, import_shared.isEmpty)(target, true);
853
+ const isEmptySource = source !== null && (0, import_shared.isEmpty)(source, true);
854
+ if (isEmptyTarget) {
855
+ return !isEmptySource;
856
+ }
857
+ return false;
858
+ }, "allowAssignDefaultValue");
859
+ const createReactions = /* @__PURE__ */ __name((field) => {
860
+ const reactions = (0, import_shared.toArr)(field.props.reactions);
861
+ field.form.addEffects(field, () => {
862
+ reactions.forEach((reaction2) => {
863
+ if ((0, import_shared.isFn)(reaction2)) {
864
+ field.disposers.push(
865
+ (0, import_reactive.autorun)(
866
+ import_reactive.batch.scope.bound(() => {
867
+ if (field.destroyed) return;
868
+ reaction2(field);
869
+ })
870
+ )
871
+ );
872
+ }
873
+ });
874
+ });
875
+ }, "createReactions");
876
+ const createReaction = /* @__PURE__ */ __name((tracker, scheduler) => {
877
+ return (0, import_reactive.reaction)(tracker, import_reactive.untracked.bound(scheduler));
878
+ }, "createReaction");
879
+ const initializeStart = /* @__PURE__ */ __name(() => {
880
+ import_constants.GlobalState.initializing = true;
881
+ }, "initializeStart");
882
+ const initializeEnd = /* @__PURE__ */ __name(() => {
883
+ import_reactive.batch.endpoint(() => {
884
+ import_constants.GlobalState.initializing = false;
885
+ });
886
+ }, "initializeEnd");
887
+ const getArrayParent = /* @__PURE__ */ __name((field, index = field.index) => {
888
+ if (index > -1) {
889
+ let parent = field.parent;
890
+ while (parent) {
891
+ if ((0, import_externals.isArrayField)(parent)) return parent;
892
+ if (parent === field.form) return;
893
+ parent = parent.parent;
894
+ }
895
+ }
896
+ }, "getArrayParent");
897
+ const getObjectParent = /* @__PURE__ */ __name((field) => {
898
+ let parent = field.parent;
899
+ while (parent) {
900
+ if ((0, import_externals.isArrayField)(parent)) return;
901
+ if ((0, import_externals.isObjectField)(parent)) return parent;
902
+ if (parent === field.form) return;
903
+ parent = parent.parent;
904
+ }
905
+ }, "getObjectParent");
906
+ // Annotate the CommonJS export names for ESM import in node:
907
+ 0 && (module.exports = {
908
+ allowAssignDefaultValue,
909
+ batchReset,
910
+ batchSubmit,
911
+ batchValidate,
912
+ buildDataPath,
913
+ buildFieldPath,
914
+ cleanupArrayChildren,
915
+ cleanupObjectChildren,
916
+ createBatchStateGetter,
917
+ createBatchStateSetter,
918
+ createChildrenFeedbackFilter,
919
+ createReaction,
920
+ createReactions,
921
+ createStateGetter,
922
+ createStateSetter,
923
+ deserialize,
924
+ destroy,
925
+ exchangeArrayState,
926
+ getArrayParent,
927
+ getObjectParent,
928
+ getTypedDefaultValue,
929
+ getValidFieldDefaultValue,
930
+ getValidFormValues,
931
+ getValuesFromEvent,
932
+ initFieldUpdate,
933
+ initializeEnd,
934
+ initializeStart,
935
+ isHTMLInputEvent,
936
+ locateNode,
937
+ matchFeedback,
938
+ modifySelf,
939
+ patchFieldStates,
940
+ patchFormValues,
941
+ queryFeedbackMessages,
942
+ queryFeedbacks,
943
+ resetSelf,
944
+ serialize,
945
+ setLoading,
946
+ setSubmitting,
947
+ setValidating,
948
+ setValidatorRule,
949
+ spliceArrayState,
950
+ subscribeUpdate,
951
+ triggerFormInitialValuesChange,
952
+ triggerFormValuesChange,
953
+ updateFeedback,
954
+ validateSelf,
955
+ validateToFeedbacks
956
+ });