@tachybase/schema 0.23.40 → 0.23.47

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
package/lib/index.js CHANGED
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
5
  var __export = (target, all) => {
7
6
  for (var name in all)
8
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -26,7 +25,7 @@ __export(src_exports, {
26
25
  FormConsumer: () => import_react.FormConsumer,
27
26
  FormContext: () => import_react.FormContext,
28
27
  FormProvider: () => import_react.FormProvider,
29
- NumberIndexReg: () => NumberIndexReg,
28
+ NumberIndexReg: () => import_constants.NumberIndexReg,
30
29
  ObjectFieldComponent: () => import_react.ObjectField,
31
30
  RecordScope: () => import_react.RecordScope,
32
31
  RecordsScope: () => import_react.RecordsScope,
@@ -36,18 +35,18 @@ __export(src_exports, {
36
35
  SchemaExpressionScopeContext: () => import_react.SchemaExpressionScopeContext,
37
36
  SchemaOptionsContext: () => import_react.SchemaOptionsContext,
38
37
  VoidFieldComponent: () => import_react.VoidField,
39
- buildDataPath: () => buildDataPath,
40
- buildFieldPath: () => buildFieldPath,
38
+ buildDataPath: () => import_internals.buildDataPath,
39
+ buildFieldPath: () => import_internals.buildFieldPath,
41
40
  connect: () => import_react.connect,
42
41
  createSchemaField: () => import_react.createSchemaField,
43
- destroy: () => destroy,
44
- exchangeArrayState: () => exchangeArrayState,
45
- locateNode: () => locateNode,
42
+ destroy: () => import_internals.destroy,
43
+ exchangeArrayState: () => import_internals.exchangeArrayState,
44
+ locateNode: () => import_internals.locateNode,
46
45
  mapProps: () => import_react.mapProps,
47
46
  mapReadPretty: () => import_react.mapReadPretty,
48
- patchFieldStates: () => patchFieldStates,
49
- spliceArrayState: () => spliceArrayState,
50
- useAttach: () => useAttach,
47
+ patchFieldStates: () => import_internals.patchFieldStates,
48
+ spliceArrayState: () => import_internals.spliceArrayState,
49
+ useAttach: () => import_useAttach.useAttach,
51
50
  useExpressionScope: () => import_react.useExpressionScope,
52
51
  useField: () => import_react.useField,
53
52
  useFieldSchema: () => import_react.useFieldSchema,
@@ -56,233 +55,17 @@ __export(src_exports, {
56
55
  useParentForm: () => import_react.useParentForm
57
56
  });
58
57
  module.exports = __toCommonJS(src_exports);
59
- var import_core = require("@formily/core");
60
- var import_reactive = require("@formily/reactive");
61
- var import_reactive_react = require("@formily/reactive-react");
62
- var import_shared = require("@formily/shared");
63
- __reExport(src_exports, require("@formily/core"), module.exports);
64
- __reExport(src_exports, require("@formily/grid"), module.exports);
65
- __reExport(src_exports, require("@formily/json-schema"), module.exports);
66
- var import_react = require("@formily/react");
67
- __reExport(src_exports, require("@formily/reactive"), module.exports);
68
- __reExport(src_exports, require("@formily/reactive-react"), module.exports);
69
- __reExport(src_exports, require("@formily/shared"), module.exports);
70
- __reExport(src_exports, require("@formily/validator"), module.exports);
71
- const useAttach = /* @__PURE__ */ __name((target) => {
72
- (0, import_reactive_react.unstable_useCompatEffect)(() => {
73
- target.onMount();
74
- return () => target.onUnmount();
75
- }, [target]);
76
- return target;
77
- }, "useAttach");
78
- const NumberIndexReg = /^\.(\d+)/;
79
- const exchangeArrayState = /* @__PURE__ */ __name((field, props) => {
80
- const { fromIndex, toIndex } = {
81
- fromIndex: 0,
82
- toIndex: 0,
83
- ...props
84
- };
85
- const address = field.address.toString();
86
- const fields = field.form.fields;
87
- const addrLength = address.length;
88
- const fieldPatches = [];
89
- const isArrayChildren = /* @__PURE__ */ __name((identifier) => {
90
- return identifier.indexOf(address) === 0 && identifier.length > addrLength;
91
- }, "isArrayChildren");
92
- const isDown = fromIndex < toIndex;
93
- const isMoveNode = /* @__PURE__ */ __name((identifier) => {
94
- var _a;
95
- const afterStr = identifier.slice(address.length);
96
- const number = (_a = afterStr.match(NumberIndexReg)) == null ? void 0 : _a[1];
97
- if (number === void 0) return false;
98
- const index = Number(number);
99
- return isDown ? index > fromIndex && index <= toIndex : index < fromIndex && index >= toIndex;
100
- }, "isMoveNode");
101
- const isFromNode = /* @__PURE__ */ __name((identifier) => {
102
- var _a;
103
- const afterStr = identifier.substring(addrLength);
104
- const number = (_a = afterStr.match(NumberIndexReg)) == null ? void 0 : _a[1];
105
- if (number === void 0) return false;
106
- const index = Number(number);
107
- return index === fromIndex;
108
- }, "isFromNode");
109
- const moveIndex = /* @__PURE__ */ __name((identifier) => {
110
- const preStr = identifier.substring(0, addrLength);
111
- const afterStr = identifier.substring(addrLength);
112
- const number = afterStr.match(NumberIndexReg)[1];
113
- const current = Number(number);
114
- let index = current;
115
- if (index === fromIndex) {
116
- index = toIndex;
117
- } else {
118
- index += isDown ? -1 : 1;
119
- }
120
- return `${preStr}${afterStr.replace(/^\.\d+/, `.${index}`)}`;
121
- }, "moveIndex");
122
- (0, import_reactive.batch)(() => {
123
- (0, import_shared.each)(fields, (field2, identifier) => {
124
- if (isArrayChildren(identifier)) {
125
- if (isMoveNode(identifier) || isFromNode(identifier)) {
126
- const newIdentifier = moveIndex(identifier);
127
- fieldPatches.push({
128
- type: "update",
129
- address: newIdentifier,
130
- oldAddress: identifier,
131
- payload: field2
132
- });
133
- if (!fields[newIdentifier]) {
134
- fieldPatches.push({
135
- type: "remove",
136
- address: identifier
137
- });
138
- }
139
- }
140
- }
141
- });
142
- patchFieldStates(fields, fieldPatches);
143
- });
144
- field.form.notify(import_core.LifeCycleTypes.ON_FORM_GRAPH_CHANGE);
145
- }, "exchangeArrayState");
146
- const patchFieldStates = /* @__PURE__ */ __name((target, patches) => {
147
- patches.forEach(({ type, address, oldAddress, payload }) => {
148
- if (type === "remove") {
149
- destroy(target, address, false);
150
- } else if (type === "update") {
151
- if (payload) {
152
- target[address] = payload;
153
- if (target[oldAddress] === payload) {
154
- target[oldAddress] = void 0;
155
- }
156
- }
157
- if (address && payload) {
158
- locateNode(payload, address);
159
- }
160
- }
161
- });
162
- }, "patchFieldStates");
163
- const destroy = /* @__PURE__ */ __name((target, address, forceClear = true) => {
164
- const field = target[address];
165
- field == null ? void 0 : field.dispose();
166
- if ((0, import_core.isDataField)(field) && forceClear) {
167
- const form = field.form;
168
- const path = field.path;
169
- form.deleteValuesIn(path);
170
- form.deleteInitialValuesIn(path);
171
- }
172
- delete target[address];
173
- }, "destroy");
174
- const locateNode = /* @__PURE__ */ __name((field, address) => {
175
- field.address = import_shared.FormPath.parse(address);
176
- field.path = buildFieldPath(field);
177
- field.form.indexes[field.path.toString()] = field.address.toString();
178
- return field;
179
- }, "locateNode");
180
- const buildFieldPath = /* @__PURE__ */ __name((field) => {
181
- return buildDataPath(field.form.fields, field.address);
182
- }, "buildFieldPath");
183
- const buildDataPath = /* @__PURE__ */ __name((fields, pattern) => {
184
- let prevArray = false;
185
- const segments = pattern.segments;
186
- const path = segments.reduce((path2, key, index) => {
187
- const currentPath = path2.concat(key);
188
- const currentAddress = segments.slice(0, index + 1);
189
- const current = fields[currentAddress.join(".")];
190
- if (prevArray) {
191
- if (!(0, import_core.isVoidField)(current)) {
192
- prevArray = false;
193
- }
194
- return path2;
195
- }
196
- if (index >= segments.length - 1) {
197
- return currentPath;
198
- }
199
- if ((0, import_core.isVoidField)(current)) {
200
- const parentAddress = segments.slice(0, index);
201
- const parent = fields[parentAddress.join(".")];
202
- if ((0, import_core.isArrayField)(parent) && (0, import_shared.isNumberLike)(key)) {
203
- prevArray = true;
204
- return currentPath;
205
- }
206
- return path2;
207
- } else {
208
- prevArray = false;
209
- }
210
- return currentPath;
211
- }, []);
212
- return new import_shared.FormPath(path);
213
- }, "buildDataPath");
214
- const spliceArrayState = /* @__PURE__ */ __name((field, props) => {
215
- const { startIndex, deleteCount, insertCount } = {
216
- startIndex: 0,
217
- deleteCount: 0,
218
- insertCount: 0,
219
- ...props
220
- };
221
- const address = field.address.toString();
222
- const addrLength = address.length;
223
- const form = field.form;
224
- const fields = form.fields;
225
- const fieldPatches = [];
226
- const offset = insertCount - deleteCount;
227
- const isArrayChildren = /* @__PURE__ */ __name((identifier) => {
228
- return identifier.indexOf(address) === 0 && identifier.length > addrLength;
229
- }, "isArrayChildren");
230
- const isAfterNode = /* @__PURE__ */ __name((identifier) => {
231
- var _a;
232
- const afterStr = identifier.substring(addrLength);
233
- const number = (_a = afterStr.match(NumberIndexReg)) == null ? void 0 : _a[1];
234
- if (number === void 0) return false;
235
- const index = Number(number);
236
- return index > startIndex + deleteCount - 1;
237
- }, "isAfterNode");
238
- const isInsertNode = /* @__PURE__ */ __name((identifier) => {
239
- var _a;
240
- const afterStr = identifier.substring(addrLength);
241
- const number = (_a = afterStr.match(NumberIndexReg)) == null ? void 0 : _a[1];
242
- if (number === void 0) return false;
243
- const index = Number(number);
244
- return index >= startIndex && index < startIndex + insertCount;
245
- }, "isInsertNode");
246
- const isDeleteNode = /* @__PURE__ */ __name((identifier) => {
247
- var _a;
248
- const preStr = identifier.substring(0, addrLength);
249
- const afterStr = identifier.substring(addrLength);
250
- const number = (_a = afterStr.match(NumberIndexReg)) == null ? void 0 : _a[1];
251
- if (number === void 0) return false;
252
- const index = Number(number);
253
- return index > startIndex && !fields[`${preStr}${afterStr.replace(/^\.\d+/, `.${index + deleteCount}`)}`] || index === startIndex;
254
- }, "isDeleteNode");
255
- const moveIndex = /* @__PURE__ */ __name((identifier) => {
256
- var _a;
257
- if (offset === 0) return identifier;
258
- const preStr = identifier.substring(0, addrLength);
259
- const afterStr = identifier.substring(addrLength);
260
- const number = (_a = afterStr.match(NumberIndexReg)) == null ? void 0 : _a[1];
261
- if (number === void 0) return identifier;
262
- const index = Number(number) + offset;
263
- return `${preStr}${afterStr.replace(/^\.\d+/, `.${index}`)}`;
264
- }, "moveIndex");
265
- (0, import_reactive.batch)(() => {
266
- (0, import_shared.each)(fields, (field2, identifier) => {
267
- if (isArrayChildren(identifier)) {
268
- if (isAfterNode(identifier)) {
269
- const newIdentifier = moveIndex(identifier);
270
- fieldPatches.push({
271
- type: "update",
272
- address: newIdentifier,
273
- oldAddress: identifier,
274
- payload: field2
275
- });
276
- }
277
- if (isInsertNode(identifier) || isDeleteNode(identifier)) {
278
- fieldPatches.push({ type: "remove", address: identifier });
279
- }
280
- }
281
- });
282
- patchFieldStates(fields, fieldPatches);
283
- });
284
- field.form.notify(import_core.LifeCycleTypes.ON_FORM_GRAPH_CHANGE);
285
- }, "spliceArrayState");
58
+ var import_internals = require("./core/shared/internals");
59
+ var import_constants = require("./core/shared/constants");
60
+ var import_useAttach = require("./react/hooks/useAttach");
61
+ __reExport(src_exports, require("./core"), module.exports);
62
+ __reExport(src_exports, require("./grid"), module.exports);
63
+ __reExport(src_exports, require("./json-schema"), module.exports);
64
+ var import_react = require("./react");
65
+ __reExport(src_exports, require("./reactive"), module.exports);
66
+ __reExport(src_exports, require("./reactive-react"), module.exports);
67
+ __reExport(src_exports, require("./shared"), module.exports);
68
+ __reExport(src_exports, require("./validator"), module.exports);
286
69
  // Annotate the CommonJS export names for ESM import in node:
287
70
  0 && (module.exports = {
288
71
  ArrayFieldComponent,
@@ -320,11 +103,11 @@ const spliceArrayState = /* @__PURE__ */ __name((field, props) => {
320
103
  useForm,
321
104
  useFormEffects,
322
105
  useParentForm,
323
- ...require("@formily/core"),
324
- ...require("@formily/grid"),
325
- ...require("@formily/json-schema"),
326
- ...require("@formily/reactive"),
327
- ...require("@formily/reactive-react"),
328
- ...require("@formily/shared"),
329
- ...require("@formily/validator")
106
+ ...require("./core"),
107
+ ...require("./grid"),
108
+ ...require("./json-schema"),
109
+ ...require("./reactive"),
110
+ ...require("./reactive-react"),
111
+ ...require("./shared"),
112
+ ...require("./validator")
330
113
  });
@@ -0,0 +1,8 @@
1
+ import { IGeneralFieldState } from '../core';
2
+ import { ISchema } from './types';
3
+ export declare const silent: (value?: boolean) => void;
4
+ export declare const registerCompiler: (compiler: (expression: string, scope: any) => any) => void;
5
+ export declare const shallowCompile: <Source = any, Scope = any>(source: Source, scope?: Scope) => any;
6
+ export declare const compile: <Source = any, Scope = any>(source: Source, scope?: Scope) => any;
7
+ export declare const patchCompile: (targetState: IGeneralFieldState, sourceState: any, scope: any) => void;
8
+ export declare const patchSchemaCompile: (targetState: IGeneralFieldState, sourceSchema: ISchema, scope: any, demand?: boolean) => void;
@@ -0,0 +1,129 @@
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 compiler_exports = {};
20
+ __export(compiler_exports, {
21
+ compile: () => compile,
22
+ patchCompile: () => patchCompile,
23
+ patchSchemaCompile: () => patchSchemaCompile,
24
+ registerCompiler: () => registerCompiler,
25
+ shallowCompile: () => shallowCompile,
26
+ silent: () => silent
27
+ });
28
+ module.exports = __toCommonJS(compiler_exports);
29
+ var import_reactive = require("../reactive");
30
+ var import_shared = require("../shared");
31
+ var import_shared2 = require("./shared");
32
+ const ExpRE = /^\s*\{\{([\s\S]*)\}\}\s*$/;
33
+ const Registry = {
34
+ silent: false,
35
+ compile(expression, scope = {}) {
36
+ if (Registry.silent) {
37
+ try {
38
+ return new Function("$root", `with($root) { return (${expression}); }`)(scope);
39
+ } catch {
40
+ }
41
+ } else {
42
+ return new Function("$root", `with($root) { return (${expression}); }`)(scope);
43
+ }
44
+ }
45
+ };
46
+ const silent = /* @__PURE__ */ __name((value = true) => {
47
+ Registry.silent = !!value;
48
+ }, "silent");
49
+ const registerCompiler = /* @__PURE__ */ __name((compiler) => {
50
+ if ((0, import_shared.isFn)(compiler)) {
51
+ Registry.compile = compiler;
52
+ }
53
+ }, "registerCompiler");
54
+ const shallowCompile = /* @__PURE__ */ __name((source, scope) => {
55
+ if ((0, import_shared.isStr)(source)) {
56
+ const matched = source.match(ExpRE);
57
+ if (!matched) return source;
58
+ return Registry.compile(matched[1], scope);
59
+ }
60
+ return source;
61
+ }, "shallowCompile");
62
+ const compile = /* @__PURE__ */ __name((source, scope) => {
63
+ const seenObjects = [];
64
+ const compile2 = /* @__PURE__ */ __name((source2) => {
65
+ if ((0, import_shared.isStr)(source2)) {
66
+ return shallowCompile(source2, scope);
67
+ } else if ((0, import_shared.isArr)(source2)) {
68
+ return source2.map((value) => compile2(value));
69
+ } else if ((0, import_shared.isPlainObj)(source2)) {
70
+ if ((0, import_shared2.isNoNeedCompileObject)(source2)) return source2;
71
+ const seenIndex = seenObjects.indexOf(source2);
72
+ if (seenIndex > -1) {
73
+ return source2;
74
+ }
75
+ const addIndex = seenObjects.length;
76
+ seenObjects.push(source2);
77
+ const results = (0, import_shared.reduce)(
78
+ source2,
79
+ (buf, value, key) => {
80
+ buf[key] = compile2(value);
81
+ return buf;
82
+ },
83
+ {}
84
+ );
85
+ seenObjects.splice(addIndex, 1);
86
+ return results;
87
+ }
88
+ return source2;
89
+ }, "compile");
90
+ return compile2(source);
91
+ }, "compile");
92
+ const patchCompile = /* @__PURE__ */ __name((targetState, sourceState, scope) => {
93
+ (0, import_shared2.traverse)(sourceState, (value, pattern) => {
94
+ const compiled = compile(value, scope);
95
+ if (compiled === void 0) return;
96
+ const path = import_shared.FormPath.parse(pattern);
97
+ const key = path.segments[0];
98
+ if (import_shared2.hasOwnProperty.call(targetState, key)) {
99
+ (0, import_reactive.untracked)(() => import_shared.FormPath.setIn(targetState, path, compiled));
100
+ }
101
+ });
102
+ }, "patchCompile");
103
+ const patchSchemaCompile = /* @__PURE__ */ __name((targetState, sourceSchema, scope, demand = false) => {
104
+ (0, import_shared2.traverseSchema)(sourceSchema, (value, path, omitCompile) => {
105
+ let compiled = value;
106
+ let collected = (0, import_reactive.hasCollected)(() => {
107
+ if (!omitCompile) {
108
+ compiled = compile(value, scope);
109
+ }
110
+ });
111
+ if (compiled === void 0) return;
112
+ if (demand) {
113
+ if (collected || !targetState.initialized) {
114
+ (0, import_shared2.patchStateFormSchema)(targetState, path, compiled);
115
+ }
116
+ } else {
117
+ (0, import_shared2.patchStateFormSchema)(targetState, path, compiled);
118
+ }
119
+ });
120
+ }, "patchSchemaCompile");
121
+ // Annotate the CommonJS export names for ESM import in node:
122
+ 0 && (module.exports = {
123
+ compile,
124
+ patchCompile,
125
+ patchSchemaCompile,
126
+ registerCompiler,
127
+ shallowCompile,
128
+ silent
129
+ });
File without changes
@@ -0,0 +1,2 @@
1
+ export * from './schema';
2
+ export * from './types';
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var json_schema_exports = {};
16
+ module.exports = __toCommonJS(json_schema_exports);
17
+ __reExport(json_schema_exports, require("./schema"), module.exports);
18
+ __reExport(json_schema_exports, require("./types"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./schema"),
22
+ ...require("./types")
23
+ });
@@ -0,0 +1,5 @@
1
+ import { SchemaPatch } from './types';
2
+ export declare const reducePatches: (schema: any) => any;
3
+ export declare const registerPatches: (...args: SchemaPatch[]) => void;
4
+ export declare const registerPolyfills: (version: string, patch: SchemaPatch) => void;
5
+ export declare const enablePolyfills: (versions?: string[]) => void;
@@ -0,0 +1,68 @@
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 patches_exports = {};
20
+ __export(patches_exports, {
21
+ enablePolyfills: () => enablePolyfills,
22
+ reducePatches: () => reducePatches,
23
+ registerPatches: () => registerPatches,
24
+ registerPolyfills: () => registerPolyfills
25
+ });
26
+ module.exports = __toCommonJS(patches_exports);
27
+ var import_shared = require("../shared");
28
+ const patches = [];
29
+ const polyfills = {};
30
+ const reducePatches = /* @__PURE__ */ __name((schema) => {
31
+ return patches.reduce(
32
+ (buf, patch) => {
33
+ return patch(buf);
34
+ },
35
+ { ...schema }
36
+ );
37
+ }, "reducePatches");
38
+ const registerPatches = /* @__PURE__ */ __name((...args) => {
39
+ args.forEach((patch) => {
40
+ if ((0, import_shared.isFn)(patch)) {
41
+ patches.push(patch);
42
+ }
43
+ });
44
+ }, "registerPatches");
45
+ const registerPolyfills = /* @__PURE__ */ __name((version, patch) => {
46
+ if (version && (0, import_shared.isFn)(patch)) {
47
+ polyfills[version] = polyfills[version] || [];
48
+ polyfills[version].push(patch);
49
+ }
50
+ }, "registerPolyfills");
51
+ const enablePolyfills = /* @__PURE__ */ __name((versions) => {
52
+ if ((0, import_shared.isArr)(versions)) {
53
+ versions.forEach((version) => {
54
+ if ((0, import_shared.isArr)(polyfills[version])) {
55
+ polyfills[version].forEach((patch) => {
56
+ registerPatches(patch);
57
+ });
58
+ }
59
+ });
60
+ }
61
+ }, "enablePolyfills");
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ enablePolyfills,
65
+ reducePatches,
66
+ registerPatches,
67
+ registerPolyfills
68
+ });
@@ -0,0 +1,2 @@
1
+ export declare const registerVoidComponents: (components: string[]) => void;
2
+ export declare const registerTypeDefaultComponents: (maps: Record<string, string>) => void;