@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,426 @@
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 Field_exports = {};
20
+ __export(Field_exports, {
21
+ Field: () => Field
22
+ });
23
+ module.exports = __toCommonJS(Field_exports);
24
+ var import_reactive = require("../../reactive");
25
+ var import_shared = require("../../shared");
26
+ var import_validator = require("../../validator");
27
+ var import_internals = require("../shared/internals");
28
+ var import_types = require("../types");
29
+ var import_BaseField = require("./BaseField");
30
+ const _Field = class _Field extends import_BaseField.BaseField {
31
+ constructor(address, props, form, designable) {
32
+ super();
33
+ this.displayName = "Field";
34
+ this.caches = {};
35
+ this.requests = {};
36
+ this.setDataSource = /* @__PURE__ */ __name((dataSource) => {
37
+ this.dataSource = dataSource;
38
+ }, "setDataSource");
39
+ this.setFeedback = /* @__PURE__ */ __name((feedback) => {
40
+ (0, import_internals.updateFeedback)(this, feedback);
41
+ }, "setFeedback");
42
+ this.setSelfErrors = /* @__PURE__ */ __name((messages) => {
43
+ this.selfErrors = messages;
44
+ }, "setSelfErrors");
45
+ this.setSelfWarnings = /* @__PURE__ */ __name((messages) => {
46
+ this.selfWarnings = messages;
47
+ }, "setSelfWarnings");
48
+ this.setSelfSuccesses = /* @__PURE__ */ __name((messages) => {
49
+ this.selfSuccesses = messages;
50
+ }, "setSelfSuccesses");
51
+ this.setValidator = /* @__PURE__ */ __name((validator) => {
52
+ this.validator = validator;
53
+ }, "setValidator");
54
+ this.setValidatorRule = /* @__PURE__ */ __name((name, value) => {
55
+ (0, import_internals.setValidatorRule)(this, name, value);
56
+ }, "setValidatorRule");
57
+ this.setRequired = /* @__PURE__ */ __name((required) => {
58
+ this.required = required;
59
+ }, "setRequired");
60
+ this.setValue = /* @__PURE__ */ __name((value) => {
61
+ if (this.destroyed) return;
62
+ if (!this.initialized) {
63
+ if (this.display === "none") {
64
+ this.caches.value = value;
65
+ return;
66
+ }
67
+ value = (0, import_internals.getValidFieldDefaultValue)(value, this.initialValue);
68
+ if (!(0, import_internals.allowAssignDefaultValue)(this.value, value) && !this.designable) {
69
+ return;
70
+ }
71
+ }
72
+ this.form.setValuesIn(this.path, value);
73
+ }, "setValue");
74
+ this.setInitialValue = /* @__PURE__ */ __name((initialValue) => {
75
+ if (this.destroyed) return;
76
+ if (!this.initialized) {
77
+ if (!(0, import_internals.allowAssignDefaultValue)(this.initialValue, initialValue) && !this.designable) {
78
+ return;
79
+ }
80
+ }
81
+ this.form.setInitialValuesIn(this.path, initialValue);
82
+ }, "setInitialValue");
83
+ this.setLoading = /* @__PURE__ */ __name((loading) => {
84
+ (0, import_internals.setLoading)(this, loading);
85
+ }, "setLoading");
86
+ this.setValidating = /* @__PURE__ */ __name((validating) => {
87
+ (0, import_internals.setValidating)(this, validating);
88
+ }, "setValidating");
89
+ this.setSubmitting = /* @__PURE__ */ __name((submitting) => {
90
+ (0, import_internals.setSubmitting)(this, submitting);
91
+ }, "setSubmitting");
92
+ this.setState = (0, import_internals.createStateSetter)(this);
93
+ this.getState = (0, import_internals.createStateGetter)(this);
94
+ this.onInput = /* @__PURE__ */ __name(async (...args) => {
95
+ const isHTMLInputEventFromSelf = /* @__PURE__ */ __name((args2) => {
96
+ var _a, _b;
97
+ return (0, import_internals.isHTMLInputEvent)(args2[0]) && "currentTarget" in args2[0] ? ((_a = args2[0]) == null ? void 0 : _a.target) === ((_b = args2[0]) == null ? void 0 : _b.currentTarget) : true;
98
+ }, "isHTMLInputEventFromSelf");
99
+ const getValues = /* @__PURE__ */ __name((args2) => {
100
+ var _a;
101
+ if ((_a = args2[0]) == null ? void 0 : _a.target) {
102
+ if (!(0, import_internals.isHTMLInputEvent)(args2[0])) return args2;
103
+ }
104
+ return (0, import_internals.getValuesFromEvent)(args2);
105
+ }, "getValues");
106
+ if (!isHTMLInputEventFromSelf(args)) return;
107
+ const values = getValues(args);
108
+ const value = values[0];
109
+ this.caches.inputting = true;
110
+ this.inputValue = value;
111
+ this.inputValues = values;
112
+ this.value = value;
113
+ this.modify();
114
+ this.notify(import_types.LifeCycleTypes.ON_FIELD_INPUT_VALUE_CHANGE);
115
+ this.notify(import_types.LifeCycleTypes.ON_FORM_INPUT_CHANGE, this.form);
116
+ await (0, import_internals.validateSelf)(this, "onInput");
117
+ this.caches.inputting = false;
118
+ }, "onInput");
119
+ this.onFocus = /* @__PURE__ */ __name(async (...args) => {
120
+ var _a;
121
+ if ((_a = args[0]) == null ? void 0 : _a.target) {
122
+ if (!(0, import_internals.isHTMLInputEvent)(args[0], false)) return;
123
+ }
124
+ this.active = true;
125
+ this.visited = true;
126
+ await (0, import_internals.validateSelf)(this, "onFocus");
127
+ }, "onFocus");
128
+ this.onBlur = /* @__PURE__ */ __name(async (...args) => {
129
+ var _a;
130
+ if ((_a = args[0]) == null ? void 0 : _a.target) {
131
+ if (!(0, import_internals.isHTMLInputEvent)(args[0], false)) return;
132
+ }
133
+ this.active = false;
134
+ await (0, import_internals.validateSelf)(this, "onBlur");
135
+ }, "onBlur");
136
+ this.validate = /* @__PURE__ */ __name((triggerType) => {
137
+ return (0, import_internals.batchValidate)(this, `${this.address}.**`, triggerType);
138
+ }, "validate");
139
+ this.submit = /* @__PURE__ */ __name((onSubmit) => {
140
+ return (0, import_internals.batchSubmit)(this, onSubmit);
141
+ }, "submit");
142
+ this.reset = /* @__PURE__ */ __name((options) => {
143
+ return (0, import_internals.batchReset)(this, `${this.address}.**`, options);
144
+ }, "reset");
145
+ this.queryFeedbacks = /* @__PURE__ */ __name((search) => {
146
+ return (0, import_internals.queryFeedbacks)(this, search);
147
+ }, "queryFeedbacks");
148
+ this.modify = /* @__PURE__ */ __name(() => (0, import_internals.modifySelf)(this), "modify");
149
+ this.form = form;
150
+ this.props = props;
151
+ this.designable = designable;
152
+ (0, import_internals.initializeStart)();
153
+ this.locate(address);
154
+ this.initialize();
155
+ this.makeObservable();
156
+ this.makeReactive();
157
+ this.onInit();
158
+ (0, import_internals.initializeEnd)();
159
+ }
160
+ initialize() {
161
+ this.initialized = false;
162
+ this.loading = false;
163
+ this.validating = false;
164
+ this.submitting = false;
165
+ this.selfModified = false;
166
+ this.active = false;
167
+ this.visited = false;
168
+ this.mounted = false;
169
+ this.unmounted = false;
170
+ this.inputValues = [];
171
+ this.inputValue = null;
172
+ this.feedbacks = [];
173
+ this.title = this.props.title;
174
+ this.description = this.props.description;
175
+ this.display = this.props.display;
176
+ this.pattern = this.props.pattern;
177
+ this.editable = this.props.editable;
178
+ this.disabled = this.props.disabled;
179
+ this.readOnly = this.props.readOnly;
180
+ this.readPretty = this.props.readPretty;
181
+ this.visible = this.props.visible;
182
+ this.hidden = this.props.hidden;
183
+ this.dataSource = this.props.dataSource;
184
+ this.validator = this.props.validator;
185
+ this.required = this.props.required;
186
+ this.content = this.props.content;
187
+ this.initialValue = this.props.initialValue;
188
+ this.value = this.props.value;
189
+ this.data = this.props.data;
190
+ this.decorator = (0, import_shared.toArr)(this.props.decorator);
191
+ this.component = (0, import_shared.toArr)(this.props.component);
192
+ }
193
+ makeObservable() {
194
+ if (this.designable) return;
195
+ (0, import_reactive.define)(this, {
196
+ path: import_reactive.observable.ref,
197
+ title: import_reactive.observable.ref,
198
+ description: import_reactive.observable.ref,
199
+ dataSource: import_reactive.observable.ref,
200
+ selfDisplay: import_reactive.observable.ref,
201
+ selfPattern: import_reactive.observable.ref,
202
+ loading: import_reactive.observable.ref,
203
+ validating: import_reactive.observable.ref,
204
+ submitting: import_reactive.observable.ref,
205
+ selfModified: import_reactive.observable.ref,
206
+ modified: import_reactive.observable.ref,
207
+ active: import_reactive.observable.ref,
208
+ visited: import_reactive.observable.ref,
209
+ initialized: import_reactive.observable.ref,
210
+ mounted: import_reactive.observable.ref,
211
+ unmounted: import_reactive.observable.ref,
212
+ inputValue: import_reactive.observable.ref,
213
+ inputValues: import_reactive.observable.ref,
214
+ decoratorType: import_reactive.observable.ref,
215
+ componentType: import_reactive.observable.ref,
216
+ content: import_reactive.observable.ref,
217
+ feedbacks: import_reactive.observable.ref,
218
+ decoratorProps: import_reactive.observable,
219
+ componentProps: import_reactive.observable,
220
+ validator: import_reactive.observable.shallow,
221
+ data: import_reactive.observable.shallow,
222
+ component: import_reactive.observable.computed,
223
+ decorator: import_reactive.observable.computed,
224
+ errors: import_reactive.observable.computed,
225
+ warnings: import_reactive.observable.computed,
226
+ successes: import_reactive.observable.computed,
227
+ valid: import_reactive.observable.computed,
228
+ invalid: import_reactive.observable.computed,
229
+ selfErrors: import_reactive.observable.computed,
230
+ selfWarnings: import_reactive.observable.computed,
231
+ selfSuccesses: import_reactive.observable.computed,
232
+ selfValid: import_reactive.observable.computed,
233
+ selfInvalid: import_reactive.observable.computed,
234
+ validateStatus: import_reactive.observable.computed,
235
+ value: import_reactive.observable.computed,
236
+ initialValue: import_reactive.observable.computed,
237
+ display: import_reactive.observable.computed,
238
+ pattern: import_reactive.observable.computed,
239
+ required: import_reactive.observable.computed,
240
+ hidden: import_reactive.observable.computed,
241
+ visible: import_reactive.observable.computed,
242
+ disabled: import_reactive.observable.computed,
243
+ readOnly: import_reactive.observable.computed,
244
+ readPretty: import_reactive.observable.computed,
245
+ editable: import_reactive.observable.computed,
246
+ indexes: import_reactive.observable.computed,
247
+ setDisplay: import_reactive.action,
248
+ setTitle: import_reactive.action,
249
+ setDescription: import_reactive.action,
250
+ setDataSource: import_reactive.action,
251
+ setValue: import_reactive.action,
252
+ setPattern: import_reactive.action,
253
+ setInitialValue: import_reactive.action,
254
+ setLoading: import_reactive.action,
255
+ setValidating: import_reactive.action,
256
+ setFeedback: import_reactive.action,
257
+ setSelfErrors: import_reactive.action,
258
+ setSelfWarnings: import_reactive.action,
259
+ setSelfSuccesses: import_reactive.action,
260
+ setValidator: import_reactive.action,
261
+ setRequired: import_reactive.action,
262
+ setComponent: import_reactive.action,
263
+ setComponentProps: import_reactive.action,
264
+ setDecorator: import_reactive.action,
265
+ setDecoratorProps: import_reactive.action,
266
+ setData: import_reactive.action,
267
+ setContent: import_reactive.action,
268
+ validate: import_reactive.action,
269
+ reset: import_reactive.action,
270
+ onInit: import_reactive.batch,
271
+ onInput: import_reactive.batch,
272
+ onMount: import_reactive.batch,
273
+ onUnmount: import_reactive.batch,
274
+ onFocus: import_reactive.batch,
275
+ onBlur: import_reactive.batch
276
+ });
277
+ }
278
+ makeReactive() {
279
+ if (this.designable) return;
280
+ this.disposers.push(
281
+ (0, import_internals.createReaction)(
282
+ () => this.value,
283
+ (value) => {
284
+ this.notify(import_types.LifeCycleTypes.ON_FIELD_VALUE_CHANGE);
285
+ if ((0, import_shared.isValid)(value)) {
286
+ if (this.selfModified && !this.caches.inputting) {
287
+ (0, import_internals.validateSelf)(this);
288
+ }
289
+ if (!(0, import_shared.isEmpty)(value) && this.display === "none") {
290
+ this.caches.value = (0, import_reactive.toJS)(value);
291
+ this.form.deleteValuesIn(this.path);
292
+ }
293
+ }
294
+ }
295
+ ),
296
+ (0, import_internals.createReaction)(
297
+ () => this.initialValue,
298
+ () => {
299
+ this.notify(import_types.LifeCycleTypes.ON_FIELD_INITIAL_VALUE_CHANGE);
300
+ }
301
+ ),
302
+ (0, import_internals.createReaction)(
303
+ () => this.display,
304
+ (display) => {
305
+ const value = this.value;
306
+ if (display !== "none") {
307
+ if (value === void 0 && this.caches.value !== void 0) {
308
+ this.setValue(this.caches.value);
309
+ this.caches.value = void 0;
310
+ }
311
+ } else {
312
+ this.caches.value = (0, import_reactive.toJS)(value) ?? (0, import_reactive.toJS)(this.initialValue);
313
+ this.form.deleteValuesIn(this.path);
314
+ }
315
+ if (display === "none" || display === "hidden") {
316
+ this.setFeedback({
317
+ type: "error",
318
+ messages: []
319
+ });
320
+ }
321
+ }
322
+ ),
323
+ (0, import_internals.createReaction)(
324
+ () => this.pattern,
325
+ (pattern) => {
326
+ if (pattern !== "editable") {
327
+ this.setFeedback({
328
+ type: "error",
329
+ messages: []
330
+ });
331
+ }
332
+ }
333
+ )
334
+ );
335
+ (0, import_internals.createReactions)(this);
336
+ }
337
+ get selfErrors() {
338
+ return (0, import_internals.queryFeedbackMessages)(this, {
339
+ type: "error"
340
+ });
341
+ }
342
+ get errors() {
343
+ return this.form.errors.filter((0, import_internals.createChildrenFeedbackFilter)(this));
344
+ }
345
+ get selfWarnings() {
346
+ return (0, import_internals.queryFeedbackMessages)(this, {
347
+ type: "warning"
348
+ });
349
+ }
350
+ get warnings() {
351
+ return this.form.warnings.filter((0, import_internals.createChildrenFeedbackFilter)(this));
352
+ }
353
+ get selfSuccesses() {
354
+ return (0, import_internals.queryFeedbackMessages)(this, {
355
+ type: "success"
356
+ });
357
+ }
358
+ get successes() {
359
+ return this.form.successes.filter((0, import_internals.createChildrenFeedbackFilter)(this));
360
+ }
361
+ get selfValid() {
362
+ return !this.selfErrors.length;
363
+ }
364
+ get valid() {
365
+ return !this.errors.length;
366
+ }
367
+ get selfInvalid() {
368
+ return !this.selfValid;
369
+ }
370
+ get invalid() {
371
+ return !this.valid;
372
+ }
373
+ get value() {
374
+ return this.form.getValuesIn(this.path);
375
+ }
376
+ get initialValue() {
377
+ return this.form.getInitialValuesIn(this.path);
378
+ }
379
+ get required() {
380
+ const validators = (0, import_shared.isArr)(this.validator) ? this.validator : (0, import_validator.parseValidatorDescriptions)(this.validator);
381
+ return validators.some((desc) => !!(desc == null ? void 0 : desc["required"]));
382
+ }
383
+ get validateStatus() {
384
+ if (this.validating) return "validating";
385
+ if (this.selfInvalid) return "error";
386
+ if (this.selfWarnings.length) return "warning";
387
+ if (this.selfSuccesses.length) return "success";
388
+ }
389
+ set required(required) {
390
+ if (this.required === required) return;
391
+ this.setValidatorRule("required", required);
392
+ }
393
+ set value(value) {
394
+ this.setValue(value);
395
+ }
396
+ set initialValue(initialValue) {
397
+ this.setInitialValue(initialValue);
398
+ }
399
+ set selfErrors(messages) {
400
+ this.setFeedback({
401
+ type: "error",
402
+ code: "EffectError",
403
+ messages
404
+ });
405
+ }
406
+ set selfWarnings(messages) {
407
+ this.setFeedback({
408
+ type: "warning",
409
+ code: "EffectWarning",
410
+ messages
411
+ });
412
+ }
413
+ set selfSuccesses(messages) {
414
+ this.setFeedback({
415
+ type: "success",
416
+ code: "EffectSuccess",
417
+ messages
418
+ });
419
+ }
420
+ };
421
+ __name(_Field, "Field");
422
+ let Field = _Field;
423
+ // Annotate the CommonJS export names for ESM import in node:
424
+ 0 && (module.exports = {
425
+ Field
426
+ });
@@ -0,0 +1,102 @@
1
+ import { FormPathPattern } from '../../shared';
2
+ import { FormDisplayTypes, FormPatternTypes, HeartSubscriber, IFieldFactoryProps, IFieldResetOptions, IFieldStateGetter, IFieldStateSetter, IFormFeedback, IFormFields, IFormGraph, IFormMergeStrategy, IFormProps, IFormRequests, IFormState, IModelGetter, IModelSetter, ISearchFeedback, IVoidFieldFactoryProps, JSXComponent } from '../types';
3
+ import { ArrayField } from './ArrayField';
4
+ import { Field } from './Field';
5
+ import { Graph } from './Graph';
6
+ import { Heart } from './Heart';
7
+ import { ObjectField } from './ObjectField';
8
+ import { Query } from './Query';
9
+ import { VoidField } from './VoidField';
10
+ export declare class Form<ValueType extends object = any> {
11
+ displayName: string;
12
+ id: string;
13
+ initialized: boolean;
14
+ validating: boolean;
15
+ submitting: boolean;
16
+ loading: boolean;
17
+ modified: boolean;
18
+ pattern: FormPatternTypes;
19
+ display: FormDisplayTypes;
20
+ values: ValueType;
21
+ initialValues: ValueType;
22
+ mounted: boolean;
23
+ unmounted: boolean;
24
+ props: IFormProps<ValueType>;
25
+ heart: Heart;
26
+ graph: Graph;
27
+ fields: IFormFields;
28
+ requests: IFormRequests;
29
+ indexes: Record<string, string>;
30
+ disposers: (() => void)[];
31
+ constructor(props: IFormProps<ValueType>);
32
+ protected initialize(props: IFormProps<ValueType>): void;
33
+ protected makeValues(): void;
34
+ protected makeObservable(): void;
35
+ protected makeReactive(): void;
36
+ get valid(): boolean;
37
+ get invalid(): boolean;
38
+ get errors(): IFormFeedback[];
39
+ get warnings(): IFormFeedback[];
40
+ get successes(): IFormFeedback[];
41
+ get lifecycles(): import("./LifeCycle").LifeCycle<any>[];
42
+ get hidden(): boolean;
43
+ get visible(): boolean;
44
+ set hidden(hidden: boolean);
45
+ set visible(visible: boolean);
46
+ get editable(): boolean;
47
+ set editable(editable: boolean);
48
+ get readOnly(): boolean;
49
+ set readOnly(readOnly: boolean);
50
+ get disabled(): boolean;
51
+ set disabled(disabled: boolean);
52
+ get readPretty(): boolean;
53
+ set readPretty(readPretty: boolean);
54
+ /** 创建字段 **/
55
+ createField: <Decorator extends unknown, Component extends unknown>(props: IFieldFactoryProps<Decorator, Component>) => Field<Decorator, Component>;
56
+ createArrayField: <Decorator extends unknown, Component extends unknown>(props: IFieldFactoryProps<Decorator, Component>) => ArrayField<Decorator, Component>;
57
+ createObjectField: <Decorator extends unknown, Component extends unknown>(props: IFieldFactoryProps<Decorator, Component>) => ObjectField<Decorator, Component>;
58
+ createVoidField: <Decorator extends unknown, Component extends unknown>(props: IVoidFieldFactoryProps<Decorator, Component>) => VoidField<Decorator, Component>;
59
+ /** 状态操作模型 **/
60
+ setValues: (values: any, strategy?: IFormMergeStrategy) => void;
61
+ setInitialValues: (initialValues: any, strategy?: IFormMergeStrategy) => void;
62
+ setValuesIn: (pattern: FormPathPattern, value: any) => void;
63
+ deleteValuesIn: (pattern: FormPathPattern) => void;
64
+ existValuesIn: (pattern: FormPathPattern) => any;
65
+ getValuesIn: (pattern: FormPathPattern) => any;
66
+ setInitialValuesIn: (pattern: FormPathPattern, initialValue: any) => void;
67
+ deleteInitialValuesIn: (pattern: FormPathPattern) => void;
68
+ existInitialValuesIn: (pattern: FormPathPattern) => any;
69
+ getInitialValuesIn: (pattern: FormPathPattern) => any;
70
+ setLoading: (loading: boolean) => void;
71
+ setSubmitting: (submitting: boolean) => void;
72
+ setValidating: (validating: boolean) => void;
73
+ setDisplay: (display: FormDisplayTypes) => void;
74
+ setPattern: (pattern: FormPatternTypes) => void;
75
+ addEffects: (id: any, effects: IFormProps["effects"]) => void;
76
+ removeEffects: (id: any) => void;
77
+ setEffects: (effects: IFormProps["effects"]) => void;
78
+ clearErrors: (pattern?: FormPathPattern) => void;
79
+ clearWarnings: (pattern?: FormPathPattern) => void;
80
+ clearSuccesses: (pattern?: FormPathPattern) => void;
81
+ query: (pattern: FormPathPattern) => Query;
82
+ queryFeedbacks: (search: ISearchFeedback) => IFormFeedback[];
83
+ notify: (type: string, payload?: any) => void;
84
+ subscribe: (subscriber?: HeartSubscriber) => number;
85
+ unsubscribe: (id: number) => void;
86
+ /**事件钩子**/
87
+ onInit: () => void;
88
+ onMount: () => void;
89
+ onUnmount: () => void;
90
+ setState: IModelSetter<IFormState<ValueType>>;
91
+ getState: IModelGetter<IFormState<ValueType>>;
92
+ setFormState: IModelSetter<IFormState<ValueType>>;
93
+ getFormState: IModelGetter<IFormState<ValueType>>;
94
+ setFieldState: IFieldStateSetter;
95
+ getFieldState: IFieldStateGetter;
96
+ getFormGraph: () => IFormGraph;
97
+ setFormGraph: (graph: IFormGraph) => void;
98
+ clearFormGraph: (pattern?: FormPathPattern, forceClear?: boolean) => void;
99
+ validate: (pattern?: FormPathPattern) => Promise<void>;
100
+ submit: <T>(onSubmit?: (values: ValueType) => Promise<T> | void) => Promise<T>;
101
+ reset: (pattern?: FormPathPattern, options?: IFieldResetOptions) => Promise<void>;
102
+ }