mobx-formkit 1.0.0

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 (256) hide show
  1. package/AGENTS.md +761 -0
  2. package/LICENSE +21 -0
  3. package/README.md +214 -0
  4. package/lib/ArrayMap.d.ts +50 -0
  5. package/lib/ArrayMap.d.ts.map +1 -0
  6. package/lib/ArrayMap.js +151 -0
  7. package/lib/ArrayMap.js.map +1 -0
  8. package/lib/Base.d.ts +237 -0
  9. package/lib/Base.d.ts.map +1 -0
  10. package/lib/Base.js +872 -0
  11. package/lib/Base.js.map +1 -0
  12. package/lib/Bindings.d.ts +28 -0
  13. package/lib/Bindings.d.ts.map +1 -0
  14. package/lib/Bindings.js +73 -0
  15. package/lib/Bindings.js.map +1 -0
  16. package/lib/Field.d.ts +195 -0
  17. package/lib/Field.d.ts.map +1 -0
  18. package/lib/Field.js +734 -0
  19. package/lib/Field.js.map +1 -0
  20. package/lib/Form.d.ts +75 -0
  21. package/lib/Form.d.ts.map +1 -0
  22. package/lib/Form.js +199 -0
  23. package/lib/Form.js.map +1 -0
  24. package/lib/Options.d.ts +9 -0
  25. package/lib/Options.d.ts.map +1 -0
  26. package/lib/Options.js +85 -0
  27. package/lib/Options.js.map +1 -0
  28. package/lib/State.d.ts +43 -0
  29. package/lib/State.d.ts.map +1 -0
  30. package/lib/State.js +147 -0
  31. package/lib/State.js.map +1 -0
  32. package/lib/Validator.d.ts +25 -0
  33. package/lib/Validator.d.ts.map +1 -0
  34. package/lib/Validator.js +143 -0
  35. package/lib/Validator.js.map +1 -0
  36. package/lib/compat.d.ts +29 -0
  37. package/lib/compat.d.ts.map +1 -0
  38. package/lib/compat.js +117 -0
  39. package/lib/compat.js.map +1 -0
  40. package/lib/composer.d.ts +26 -0
  41. package/lib/composer.d.ts.map +1 -0
  42. package/lib/composer.js +65 -0
  43. package/lib/composer.js.map +1 -0
  44. package/lib/esm/ArrayMap.js +146 -0
  45. package/lib/esm/ArrayMap.js.map +1 -0
  46. package/lib/esm/Base.js +868 -0
  47. package/lib/esm/Base.js.map +1 -0
  48. package/lib/esm/Bindings.js +69 -0
  49. package/lib/esm/Bindings.js.map +1 -0
  50. package/lib/esm/Field.js +730 -0
  51. package/lib/esm/Field.js.map +1 -0
  52. package/lib/esm/Form.js +195 -0
  53. package/lib/esm/Form.js.map +1 -0
  54. package/lib/esm/Options.js +81 -0
  55. package/lib/esm/Options.js.map +1 -0
  56. package/lib/esm/State.js +143 -0
  57. package/lib/esm/State.js.map +1 -0
  58. package/lib/esm/Validator.js +139 -0
  59. package/lib/esm/Validator.js.map +1 -0
  60. package/lib/esm/compat.js +96 -0
  61. package/lib/esm/compat.js.map +1 -0
  62. package/lib/esm/composer.js +63 -0
  63. package/lib/esm/composer.js.map +1 -0
  64. package/lib/esm/index.js +8 -0
  65. package/lib/esm/index.js.map +1 -0
  66. package/lib/esm/models/FieldProps.js +116 -0
  67. package/lib/esm/models/FieldProps.js.map +1 -0
  68. package/lib/esm/models/OptionsModel.js +51 -0
  69. package/lib/esm/models/OptionsModel.js.map +1 -0
  70. package/lib/esm/models/StateInterface.js +9 -0
  71. package/lib/esm/models/StateInterface.js.map +1 -0
  72. package/lib/esm/models/ValidatorInterface.js +8 -0
  73. package/lib/esm/models/ValidatorInterface.js.map +1 -0
  74. package/lib/esm/parser.js +235 -0
  75. package/lib/esm/parser.js.map +1 -0
  76. package/lib/esm/props.js +118 -0
  77. package/lib/esm/props.js.map +1 -0
  78. package/lib/esm/utils.js +156 -0
  79. package/lib/esm/utils.js.map +1 -0
  80. package/lib/esm/validators/AJV.js +105 -0
  81. package/lib/esm/validators/AJV.js.map +1 -0
  82. package/lib/esm/validators/DVR.js +104 -0
  83. package/lib/esm/validators/DVR.js.map +1 -0
  84. package/lib/esm/validators/JOI.js +54 -0
  85. package/lib/esm/validators/JOI.js.map +1 -0
  86. package/lib/esm/validators/VALIBOT.js +50 -0
  87. package/lib/esm/validators/VALIBOT.js.map +1 -0
  88. package/lib/esm/validators/VINEJS.js +60 -0
  89. package/lib/esm/validators/VINEJS.js.map +1 -0
  90. package/lib/esm/validators/VJF.js +88 -0
  91. package/lib/esm/validators/VJF.js.map +1 -0
  92. package/lib/esm/validators/YUP.js +69 -0
  93. package/lib/esm/validators/YUP.js.map +1 -0
  94. package/lib/esm/validators/ZOD.js +43 -0
  95. package/lib/esm/validators/ZOD.js.map +1 -0
  96. package/lib/index.d.ts +7 -0
  97. package/lib/index.d.ts.map +1 -0
  98. package/lib/index.js +15 -0
  99. package/lib/index.js.map +1 -0
  100. package/lib/models/BaseInterface.d.ts +40 -0
  101. package/lib/models/BaseInterface.d.ts.map +1 -0
  102. package/lib/models/BindingsInterface.d.ts +18 -0
  103. package/lib/models/BindingsInterface.d.ts.map +1 -0
  104. package/lib/models/FieldInterface.d.ts +88 -0
  105. package/lib/models/FieldInterface.d.ts.map +1 -0
  106. package/lib/models/FieldProps.d.ts +111 -0
  107. package/lib/models/FieldProps.d.ts.map +1 -0
  108. package/lib/models/FieldProps.js +116 -0
  109. package/lib/models/FieldProps.js.map +1 -0
  110. package/lib/models/FormInterface.d.ts +184 -0
  111. package/lib/models/FormInterface.d.ts.map +1 -0
  112. package/lib/models/OptionsInterface.d.ts +8 -0
  113. package/lib/models/OptionsInterface.d.ts.map +1 -0
  114. package/lib/models/OptionsModel.d.ts +99 -0
  115. package/lib/models/OptionsModel.d.ts.map +1 -0
  116. package/lib/models/OptionsModel.js +51 -0
  117. package/lib/models/OptionsModel.js.map +1 -0
  118. package/lib/models/SharedActionsInterface.d.ts +27 -0
  119. package/lib/models/SharedActionsInterface.d.ts.map +1 -0
  120. package/lib/models/SharedEventsInterface.d.ts +8 -0
  121. package/lib/models/SharedEventsInterface.d.ts.map +1 -0
  122. package/lib/models/SharedHelpersInterface.d.ts +26 -0
  123. package/lib/models/SharedHelpersInterface.d.ts.map +1 -0
  124. package/lib/models/SharedInitializerInterface.d.ts +6 -0
  125. package/lib/models/SharedInitializerInterface.d.ts.map +1 -0
  126. package/lib/models/SharedUtilsInterface.d.ts +10 -0
  127. package/lib/models/SharedUtilsInterface.d.ts.map +1 -0
  128. package/lib/models/StateInterface.d.ts +37 -0
  129. package/lib/models/StateInterface.d.ts.map +1 -0
  130. package/lib/models/StateInterface.js +9 -0
  131. package/lib/models/StateInterface.js.map +1 -0
  132. package/lib/models/ValidatorInterface.d.ts +74 -0
  133. package/lib/models/ValidatorInterface.d.ts.map +1 -0
  134. package/lib/models/ValidatorInterface.js +8 -0
  135. package/lib/models/ValidatorInterface.js.map +1 -0
  136. package/lib/parser.d.ts +13 -0
  137. package/lib/parser.d.ts.map +1 -0
  138. package/lib/parser.js +247 -0
  139. package/lib/parser.js.map +1 -0
  140. package/lib/props.d.ts +14 -0
  141. package/lib/props.d.ts.map +1 -0
  142. package/lib/props.js +120 -0
  143. package/lib/props.js.map +1 -0
  144. package/lib/utils.d.ts +34 -0
  145. package/lib/utils.d.ts.map +1 -0
  146. package/lib/utils.js +182 -0
  147. package/lib/utils.js.map +1 -0
  148. package/lib/validators/AJV.d.ts +4 -0
  149. package/lib/validators/AJV.d.ts.map +1 -0
  150. package/lib/validators/AJV.js +109 -0
  151. package/lib/validators/AJV.js.map +1 -0
  152. package/lib/validators/DVR.d.ts +4 -0
  153. package/lib/validators/DVR.d.ts.map +1 -0
  154. package/lib/validators/DVR.js +108 -0
  155. package/lib/validators/DVR.js.map +1 -0
  156. package/lib/validators/JOI.d.ts +4 -0
  157. package/lib/validators/JOI.d.ts.map +1 -0
  158. package/lib/validators/JOI.js +58 -0
  159. package/lib/validators/JOI.js.map +1 -0
  160. package/lib/validators/VALIBOT.d.ts +4 -0
  161. package/lib/validators/VALIBOT.d.ts.map +1 -0
  162. package/lib/validators/VALIBOT.js +73 -0
  163. package/lib/validators/VALIBOT.js.map +1 -0
  164. package/lib/validators/VINEJS.d.ts +4 -0
  165. package/lib/validators/VINEJS.d.ts.map +1 -0
  166. package/lib/validators/VINEJS.js +64 -0
  167. package/lib/validators/VINEJS.js.map +1 -0
  168. package/lib/validators/VJF.d.ts +4 -0
  169. package/lib/validators/VJF.d.ts.map +1 -0
  170. package/lib/validators/VJF.js +92 -0
  171. package/lib/validators/VJF.js.map +1 -0
  172. package/lib/validators/YUP.d.ts +4 -0
  173. package/lib/validators/YUP.d.ts.map +1 -0
  174. package/lib/validators/YUP.js +73 -0
  175. package/lib/validators/YUP.js.map +1 -0
  176. package/lib/validators/ZOD.d.ts +4 -0
  177. package/lib/validators/ZOD.d.ts.map +1 -0
  178. package/lib/validators/ZOD.js +47 -0
  179. package/lib/validators/ZOD.js.map +1 -0
  180. package/package.json +183 -0
  181. package/src/ArrayMap.ts +165 -0
  182. package/src/Base.ts +1229 -0
  183. package/src/Bindings.ts +85 -0
  184. package/src/Field.ts +1034 -0
  185. package/src/Form.ts +264 -0
  186. package/src/Options.ts +91 -0
  187. package/src/State.ts +183 -0
  188. package/src/Validator.ts +177 -0
  189. package/src/compat.ts +104 -0
  190. package/src/composer.ts +82 -0
  191. package/src/index.ts +7 -0
  192. package/src/models/BaseInterface.ts +45 -0
  193. package/src/models/BindingsInterface.ts +25 -0
  194. package/src/models/FieldInterface.ts +97 -0
  195. package/src/models/FieldProps.ts +116 -0
  196. package/src/models/FormInterface.ts +203 -0
  197. package/src/models/OptionsInterface.ts +9 -0
  198. package/src/models/OptionsModel.ts +100 -0
  199. package/src/models/SharedActionsInterface.ts +30 -0
  200. package/src/models/SharedEventsInterface.ts +8 -0
  201. package/src/models/SharedHelpersInterface.ts +12 -0
  202. package/src/models/SharedInitializerInterface.ts +6 -0
  203. package/src/models/SharedUtilsInterface.ts +10 -0
  204. package/src/models/StateInterface.ts +44 -0
  205. package/src/models/ValidatorInterface.ts +88 -0
  206. package/src/parser.ts +327 -0
  207. package/src/props.ts +127 -0
  208. package/src/utils.ts +218 -0
  209. package/src/validators/AJV.ts +140 -0
  210. package/src/validators/DVR.ts +145 -0
  211. package/src/validators/JOI.ts +79 -0
  212. package/src/validators/VALIBOT.ts +70 -0
  213. package/src/validators/VINEJS.ts +83 -0
  214. package/src/validators/VJF.ts +123 -0
  215. package/src/validators/YUP.ts +90 -0
  216. package/src/validators/ZOD.ts +66 -0
  217. package/umd/MobxFormkit.umd.js +3093 -0
  218. package/umd/MobxFormkit.umd.js.map +1 -0
  219. package/umd/MobxFormkit.umd.min.js +2 -0
  220. package/umd/MobxFormkit.umd.min.js.map +1 -0
  221. package/umd/MobxFormkitComposer.umd.js +183 -0
  222. package/umd/MobxFormkitComposer.umd.js.map +1 -0
  223. package/umd/MobxFormkitComposer.umd.min.js +2 -0
  224. package/umd/MobxFormkitComposer.umd.min.js.map +1 -0
  225. package/umd/MobxFormkitValidatorAJV.umd.js +113 -0
  226. package/umd/MobxFormkitValidatorAJV.umd.js.map +1 -0
  227. package/umd/MobxFormkitValidatorAJV.umd.min.js +2 -0
  228. package/umd/MobxFormkitValidatorAJV.umd.min.js.map +1 -0
  229. package/umd/MobxFormkitValidatorDVR.umd.js +110 -0
  230. package/umd/MobxFormkitValidatorDVR.umd.js.map +1 -0
  231. package/umd/MobxFormkitValidatorDVR.umd.min.js +2 -0
  232. package/umd/MobxFormkitValidatorDVR.umd.min.js.map +1 -0
  233. package/umd/MobxFormkitValidatorJOI.umd.js +62 -0
  234. package/umd/MobxFormkitValidatorJOI.umd.js.map +1 -0
  235. package/umd/MobxFormkitValidatorJOI.umd.min.js +2 -0
  236. package/umd/MobxFormkitValidatorJOI.umd.min.js.map +1 -0
  237. package/umd/MobxFormkitValidatorVALIBOT.umd.js +8032 -0
  238. package/umd/MobxFormkitValidatorVALIBOT.umd.js.map +1 -0
  239. package/umd/MobxFormkitValidatorVALIBOT.umd.min.js +2 -0
  240. package/umd/MobxFormkitValidatorVALIBOT.umd.min.js.map +1 -0
  241. package/umd/MobxFormkitValidatorVINEJS.umd.js +11737 -0
  242. package/umd/MobxFormkitValidatorVINEJS.umd.js.map +1 -0
  243. package/umd/MobxFormkitValidatorVINEJS.umd.min.js +2 -0
  244. package/umd/MobxFormkitValidatorVINEJS.umd.min.js.map +1 -0
  245. package/umd/MobxFormkitValidatorVJF.umd.js +96 -0
  246. package/umd/MobxFormkitValidatorVJF.umd.js.map +1 -0
  247. package/umd/MobxFormkitValidatorVJF.umd.min.js +2 -0
  248. package/umd/MobxFormkitValidatorVJF.umd.min.js.map +1 -0
  249. package/umd/MobxFormkitValidatorYUP.umd.js +77 -0
  250. package/umd/MobxFormkitValidatorYUP.umd.js.map +1 -0
  251. package/umd/MobxFormkitValidatorYUP.umd.min.js +2 -0
  252. package/umd/MobxFormkitValidatorYUP.umd.min.js.map +1 -0
  253. package/umd/MobxFormkitValidatorZOD.umd.js +49 -0
  254. package/umd/MobxFormkitValidatorZOD.umd.js.map +1 -0
  255. package/umd/MobxFormkitValidatorZOD.umd.min.js +2 -0
  256. package/umd/MobxFormkitValidatorZOD.umd.min.js.map +1 -0
@@ -0,0 +1,868 @@
1
+ import { toJS, action, computed, observable, observe, intercept } from 'mobx';
2
+ import { makeObservable } from './compat.js';
3
+ import { ArrayMap } from './ArrayMap.js';
4
+ import { forIn, get, merge, transform, isPlainObject, each, has, set } from 'lodash-es';
5
+ import { $try, hasIntKeys, isEvent, pathToStruct, allowedProps, checkPropOccurrence, getObservableMapValues, throwError, isArrayOfObjects, maxKey, hasSome } from './utils.js';
6
+ import { prepareFieldsData, mergeSchemaDefaults, parseInput, pathToFieldsTree, parseCheckOutput, parseCheckArray, defaultValue, parsePath } from './parser.js';
7
+ import { FieldPropsEnum, SeparatedPropsMode, AllowedFieldPropsTypes } from './models/FieldProps.js';
8
+ import { OptionsEnum } from './models/OptionsModel.js';
9
+ import { ValidationHooks } from './models/ValidatorInterface.js';
10
+ import { props } from './props.js';
11
+
12
+ class Base {
13
+ noop = () => { };
14
+ state;
15
+ fields = new ArrayMap();
16
+ path;
17
+ $submitted = 0;
18
+ $submitting = false;
19
+ $validated = 0;
20
+ $validating = false;
21
+ $clearing = false;
22
+ $resetting = false;
23
+ $touched = false;
24
+ $changed = 0;
25
+ $hooks = {};
26
+ $handlers = {};
27
+ constructor() {
28
+ makeObservable(this, {
29
+ $submitted: observable,
30
+ $submitting: observable,
31
+ $validated: observable,
32
+ $validating: observable,
33
+ $clearing: observable,
34
+ $resetting: observable,
35
+ $touched: observable,
36
+ $changed: observable,
37
+ $hooks: observable,
38
+ $handlers: observable,
39
+ changed: computed,
40
+ submitted: computed,
41
+ submitting: computed,
42
+ validated: computed,
43
+ validating: computed,
44
+ clearing: computed,
45
+ resetting: computed,
46
+ hasIncrementalKeys: computed,
47
+ hasNestedFields: computed,
48
+ size: computed,
49
+ // initialization
50
+ initField: action,
51
+ // actions
52
+ submit: action,
53
+ deepUpdate: action,
54
+ set: action,
55
+ add: action,
56
+ del: action,
57
+ });
58
+ }
59
+ execHook = (name, fallback = {}, ...args) => $try(fallback[name], this.$hooks[name], this.noop).apply(this, [this, ...args]);
60
+ execHandler = (name, args, fallback = undefined, hook = null, execHook = true) => [
61
+ $try(this.$handlers[name] && this.$handlers[name].apply(this, [this]), fallback, this.noop).apply(this, [...args]),
62
+ execHook && this.execHook(hook || name, {}, ...args),
63
+ ];
64
+ get resetting() {
65
+ return this.hasNestedFields
66
+ ? this.check(FieldPropsEnum.resetting, true)
67
+ : this.$resetting;
68
+ }
69
+ get clearing() {
70
+ return this.hasNestedFields
71
+ ? this.check(FieldPropsEnum.clearing, true)
72
+ : this.$clearing;
73
+ }
74
+ get submitted() {
75
+ return toJS(this.$submitted);
76
+ }
77
+ get submitting() {
78
+ return toJS(this.$submitting);
79
+ }
80
+ get validated() {
81
+ return toJS(this.$validated);
82
+ }
83
+ get validating() {
84
+ return toJS(this.$validating);
85
+ }
86
+ get hasIncrementalKeys() {
87
+ return !!this.fields.size && hasIntKeys(this.fields);
88
+ }
89
+ get hasNestedFields() {
90
+ return this.fields.size !== 0;
91
+ }
92
+ get size() {
93
+ return this.fields.size;
94
+ }
95
+ get changed() {
96
+ return this.path != null && this.hasNestedFields
97
+ ? this.reduce((acc, field) => acc + field.changed, 0) + this.$changed
98
+ : this.$changed;
99
+ }
100
+ /**
101
+ Interceptor
102
+ */
103
+ intercept = (opt) => this.MOBXEvent(typeof opt === "function"
104
+ ? { type: "interceptor", call: opt }
105
+ : { type: "interceptor", ...opt });
106
+ /**
107
+ Observer
108
+ */
109
+ observe = (opt) => this.MOBXEvent(typeof opt === "function"
110
+ ? { type: "observer", call: opt }
111
+ : { type: "observer", ...opt });
112
+ /**
113
+ Event Handler: On Clear
114
+ */
115
+ onClear = (...args) => this.execHandler(FieldPropsEnum.onClear, args, (e) => {
116
+ isEvent(e) && e.preventDefault();
117
+ this.clear(true, false);
118
+ });
119
+ /**
120
+ Event Handler: On Reset
121
+ */
122
+ onReset = (...args) => this.execHandler(FieldPropsEnum.onReset, args, (e) => {
123
+ isEvent(e) && e.preventDefault();
124
+ this.reset(true, false);
125
+ });
126
+ /**
127
+ Event Handler: On Submit
128
+ */
129
+ onSubmit = (...args) => this.execHandler(FieldPropsEnum.onSubmit, args, (e, o = {}) => {
130
+ isEvent(e) && e.preventDefault();
131
+ this.submit(o);
132
+ }, null, false);
133
+ /**
134
+ Event Handler: On Add
135
+ */
136
+ onAdd = (...args) => this.execHandler(FieldPropsEnum.onAdd, args, (e, val) => {
137
+ isEvent(e) && e.preventDefault();
138
+ this.add(isEvent(val) ? null : val, false);
139
+ });
140
+ /**
141
+ Event Handler: On Del
142
+ */
143
+ onDel = (...args) => this.execHandler(FieldPropsEnum.onDel, args, (e, path) => {
144
+ isEvent(e) && e.preventDefault();
145
+ this.del(isEvent(path) ? this.path : path, false);
146
+ });
147
+ /******************************************************************
148
+ Initializer
149
+ */
150
+ initFields(initial, update = false) {
151
+ const fallback = this.state.options.get(OptionsEnum.fallback);
152
+ const $path = (key) => [this.path, key].join(".").replace(/^\.+/, "");
153
+ let fields;
154
+ fields = prepareFieldsData(initial, this.state.strict, fallback);
155
+ fields = mergeSchemaDefaults(fields, this.validator);
156
+ // create fields
157
+ forIn(fields, (field, key) => {
158
+ const path = $path(key);
159
+ const $f = this.select(path, null, false);
160
+ if ($f == null) {
161
+ if (fallback) {
162
+ this.initField(key, path, field, update);
163
+ }
164
+ else {
165
+ const structPath = pathToStruct(path);
166
+ const struct = this.state.struct();
167
+ const found = struct
168
+ .filter((s) => s.startsWith(structPath))
169
+ .find((s) => s.charAt(structPath.length) === "." ||
170
+ s.substring(structPath.length, structPath.length + 2) ===
171
+ "[]" ||
172
+ s === structPath);
173
+ if (found)
174
+ this.initField(key, path, field, update);
175
+ }
176
+ }
177
+ });
178
+ }
179
+ initField(key, path, data, update = false) {
180
+ const initial = this.state.get("current", "props");
181
+ const struct = pathToStruct(path);
182
+ // try to get props from separated objects
183
+ const _try = (prop) => {
184
+ const t = get(initial[prop], struct);
185
+ if ([
186
+ FieldPropsEnum.input,
187
+ FieldPropsEnum.output,
188
+ FieldPropsEnum.converter,
189
+ ].includes(prop) &&
190
+ typeof t !== "function")
191
+ return undefined;
192
+ return t;
193
+ };
194
+ const props = {
195
+ $value: get(initial[SeparatedPropsMode.values], path),
196
+ $computed: _try(SeparatedPropsMode.computed),
197
+ $label: _try(SeparatedPropsMode.labels),
198
+ $placeholder: _try(SeparatedPropsMode.placeholders),
199
+ $default: _try(SeparatedPropsMode.defaults),
200
+ $initial: _try(SeparatedPropsMode.initials),
201
+ $disabled: _try(SeparatedPropsMode.disabled),
202
+ $deleted: _try(SeparatedPropsMode.deleted),
203
+ $type: _try(SeparatedPropsMode.types),
204
+ $related: _try(SeparatedPropsMode.related),
205
+ $rules: _try(SeparatedPropsMode.rules),
206
+ $options: _try(SeparatedPropsMode.options),
207
+ $bindings: _try(SeparatedPropsMode.bindings),
208
+ $extra: _try(SeparatedPropsMode.extra),
209
+ $hooks: _try(SeparatedPropsMode.hooks),
210
+ $handlers: _try(SeparatedPropsMode.handlers),
211
+ $validatedWith: _try(SeparatedPropsMode.validatedWith),
212
+ $validators: _try(SeparatedPropsMode.validators),
213
+ $observers: _try(SeparatedPropsMode.observers),
214
+ $interceptors: _try(SeparatedPropsMode.interceptors),
215
+ $converters: _try(SeparatedPropsMode.converters),
216
+ $input: _try(SeparatedPropsMode.input),
217
+ $output: _try(SeparatedPropsMode.output),
218
+ $autoFocus: _try(SeparatedPropsMode.autoFocus),
219
+ $ref: _try(SeparatedPropsMode.refs),
220
+ $nullable: _try(SeparatedPropsMode.nullable),
221
+ $autoComplete: _try(SeparatedPropsMode.autoComplete),
222
+ };
223
+ const field = this.state.form.makeField({
224
+ key,
225
+ path,
226
+ struct,
227
+ data,
228
+ props,
229
+ update,
230
+ state: this.state,
231
+ }, (data && data[FieldPropsEnum.class]) || _try(SeparatedPropsMode.classes));
232
+ this.fields.merge({ [key]: field });
233
+ return field;
234
+ }
235
+ /******************************************************************
236
+ Actions
237
+ */
238
+ validate(opt, obj) {
239
+ const $opt = merge({}, opt, { path: this.path });
240
+ return this.state.form.validator.validate($opt, obj);
241
+ }
242
+ /**
243
+ Submit
244
+ */
245
+ submit(hooks = {}, { execOnSubmitHook = true, execValidationHooks = true, validate = true, } = {}) {
246
+ const execOnSubmit = () => this.execHook(FieldPropsEnum.onSubmit, hooks);
247
+ const submit = execOnSubmitHook ? execOnSubmit() : undefined;
248
+ this.$submitting = true;
249
+ this.$submitted += 1;
250
+ if (!validate ||
251
+ !this.state.options.get(OptionsEnum.validateOnSubmit, this)) {
252
+ return Promise.resolve(submit)
253
+ .then(action(() => (this.$submitting = false)))
254
+ .catch(action((err) => {
255
+ this.$submitting = false;
256
+ throw err;
257
+ }))
258
+ .then(() => this);
259
+ }
260
+ const exec = (isValid) => isValid
261
+ ? this.execHook(ValidationHooks.onSuccess, hooks)
262
+ : this.execHook(ValidationHooks.onError, hooks);
263
+ return this.validate({
264
+ showErrors: this.state.options.get(OptionsEnum.showErrorsOnSubmit, this),
265
+ })
266
+ .then(({ isValid }) => {
267
+ const handler = execValidationHooks ? exec(isValid) : undefined;
268
+ if (isValid)
269
+ return Promise.all([submit, handler]);
270
+ const $err = this.state.options.get(OptionsEnum.defaultGenericError, this);
271
+ const $throw = this.state.options.get(OptionsEnum.submitThrowsError, this);
272
+ if ($throw && $err)
273
+ this.invalidate();
274
+ return Promise.all([submit, handler]);
275
+ })
276
+ .then(action(() => (this.$submitting = false)))
277
+ .catch(action((err) => {
278
+ this.$submitting = false;
279
+ throw err;
280
+ }))
281
+ .then(() => this);
282
+ }
283
+ /**
284
+ Check Field Computed Values
285
+ */
286
+ check(prop, deep = false) {
287
+ allowedProps(AllowedFieldPropsTypes.computed, [prop]);
288
+ return deep
289
+ ? checkPropOccurrence({
290
+ type: props.occurrences[prop],
291
+ data: this.deepCheck(props.occurrences[prop], prop, this.fields),
292
+ })
293
+ : this[prop];
294
+ }
295
+ deepCheck(type, prop, fields) {
296
+ const $fields = getObservableMapValues(fields);
297
+ return transform($fields, (check, field) => {
298
+ if (!field.fields.size || !Array.isArray(field.initial)) {
299
+ check.push(field[prop]);
300
+ }
301
+ check.push(checkPropOccurrence({
302
+ data: this.deepCheck(type, prop, field.fields),
303
+ type,
304
+ }));
305
+ return check;
306
+ }, []);
307
+ }
308
+ firstError() {
309
+ if (!this.state.options.get(OptionsEnum.bubbleUpErrorMessages, this))
310
+ return null;
311
+ for (const field of getObservableMapValues(this.fields)) {
312
+ if (field.error)
313
+ return field.error;
314
+ if (field.fields.size) {
315
+ const nested = field.firstError();
316
+ if (nested)
317
+ return nested;
318
+ }
319
+ }
320
+ return null;
321
+ }
322
+ /**
323
+ Update Field Values recurisvely
324
+ OR Create Field if 'undefined'
325
+ */
326
+ update(fields) {
327
+ if (!isPlainObject(fields)) {
328
+ throw new Error("The update() method accepts only plain objects.");
329
+ }
330
+ this.deepUpdate(prepareFieldsData({ fields }, this.state.strict), undefined, undefined, fields);
331
+ }
332
+ deepUpdate(fields, path = "", recursion = true, raw) {
333
+ each(fields, (field, key) => {
334
+ const $key = has(field, FieldPropsEnum.name) ? field.name : key;
335
+ const $path = `${path}.${$key}`.replace(/^\.+/, "");
336
+ const strictUpdate = this.state.options.get(OptionsEnum.strictUpdate, this);
337
+ const $field = this.select($path, null, strictUpdate);
338
+ const $container = this.select(path, null, false) ||
339
+ this.state.form.select(this.path ?? "", null, false);
340
+ const applyInputConverterOnUpdate = this.state.options.get(OptionsEnum.applyInputConverterOnUpdate, this);
341
+ if ($field != null && field !== void 0) {
342
+ if (Array.isArray($field.values())) {
343
+ const n = Math.max(-1, ...Object.keys(field.fields || {}).map(Number));
344
+ getObservableMapValues($field.fields).forEach(($f) => {
345
+ if (Number($f.name) > n) {
346
+ $field.$changed++;
347
+ $field.state.form.$changed++;
348
+ $field.fields.delete($f.name);
349
+ }
350
+ });
351
+ }
352
+ if (field?.fields) {
353
+ const fallback = this.state.options.get(OptionsEnum.fallback);
354
+ const x = this.state
355
+ .struct()
356
+ .findIndex((s) => s.startsWith($field.path.replace(/\.\d+\./, "[].") + "[]"));
357
+ if (!fallback && $field.fields.size === 0 && x < 0) {
358
+ $field.value = parseInput(applyInputConverterOnUpdate ? $field.$input : (val) => val, {
359
+ fallbackValueOption: this.state.options.get(OptionsEnum.fallbackValue, this),
360
+ separated: get(raw, $path),
361
+ });
362
+ return;
363
+ }
364
+ }
365
+ if (field === null || field.fields == null) {
366
+ $field.value = parseInput(applyInputConverterOnUpdate ? $field.$input : (val) => val, {
367
+ fallbackValueOption: this.state.options.get(OptionsEnum.fallbackValue, this),
368
+ separated: field,
369
+ });
370
+ return;
371
+ }
372
+ }
373
+ if ($container != null && $field == null) {
374
+ // get full path when using update() with select() - FIX: #179
375
+ const $newFieldPath = [this.path, $path].join(".").replace(/^\.+/, "");
376
+ // init field into the container field
377
+ $container.$changed++;
378
+ $container.state.form.$changed++;
379
+ $container.initField($key, $newFieldPath, field, true);
380
+ }
381
+ else if (recursion) {
382
+ if (has(field, FieldPropsEnum.fields) && field.fields != null) {
383
+ // handle nested fields if defined
384
+ this.deepUpdate(field.fields, $path);
385
+ }
386
+ else {
387
+ // handle nested fields if undefined or null
388
+ const $fields = pathToFieldsTree(this.state.struct(), $path);
389
+ this.deepUpdate($fields, $path, false);
390
+ }
391
+ }
392
+ });
393
+ }
394
+ /**
395
+ Get Fields Props
396
+ */
397
+ get(prop = null, strict = true) {
398
+ if (prop == null) {
399
+ return this.deepGet([...props.computed, ...props.editable, ...props.validation], this.fields, strict);
400
+ }
401
+ allowedProps(AllowedFieldPropsTypes.all, Array.isArray(prop) ? prop : [prop]);
402
+ if (typeof prop === "string") {
403
+ if ([FieldPropsEnum.hooks, FieldPropsEnum.handlers].includes(prop)) {
404
+ return this[`$${prop}`];
405
+ }
406
+ if (strict && this.fields.size === 0) {
407
+ const retrieveNullifiedEmptyStrings = this.state.options.get(OptionsEnum.retrieveNullifiedEmptyStrings, this);
408
+ return parseCheckOutput(this, prop, strict ? retrieveNullifiedEmptyStrings : false);
409
+ }
410
+ const value = this.deepGet(prop, this.fields, strict);
411
+ const removeNullishValuesInArrays = this.state.options.get(OptionsEnum.removeNullishValuesInArrays, this);
412
+ return parseCheckArray(this, value, prop, strict ? removeNullishValuesInArrays : false);
413
+ }
414
+ return this.deepGet(prop, this.fields, strict);
415
+ }
416
+ /**
417
+ Get Fields Props Recursively
418
+ */
419
+ deepGet(prop, fields, strict = true) {
420
+ const _fieldsArr = getObservableMapValues(fields);
421
+ const _result = transform(_fieldsArr, (obj, field) => {
422
+ const $nested = ($fields) => $fields.size !== 0 ? this.deepGet(prop, $fields, strict) : undefined;
423
+ Object.assign(obj, {
424
+ [field.key]: { fields: $nested(field.fields) },
425
+ });
426
+ if (typeof prop === "string") {
427
+ const opt = this.state.options;
428
+ const removeProp = (opt.get(OptionsEnum.retrieveOnlyDirtyFieldsValues, this) &&
429
+ prop === FieldPropsEnum.value &&
430
+ field.isPristine) ||
431
+ (opt.get(OptionsEnum.retrieveOnlyEnabledFieldsValues, this) &&
432
+ prop === FieldPropsEnum.value &&
433
+ field.disabled) ||
434
+ (opt.get(OptionsEnum.retrieveOnlyEnabledFieldsErrors, this) &&
435
+ prop === FieldPropsEnum.error &&
436
+ field.disabled &&
437
+ field.isValid &&
438
+ (!field.error || !field.hasError)) ||
439
+ (opt.get(OptionsEnum.softDelete, this) &&
440
+ prop === FieldPropsEnum.value &&
441
+ field.deleted);
442
+ if (field.fields.size === 0) {
443
+ delete obj[field.key];
444
+ if (removeProp)
445
+ return obj;
446
+ const retrieveNullifiedEmptyStrings = this.state.options.get(OptionsEnum.retrieveNullifiedEmptyStrings, this);
447
+ return Object.assign(obj, {
448
+ [field.key]: parseCheckOutput(field, prop, strict ? retrieveNullifiedEmptyStrings : false),
449
+ });
450
+ }
451
+ let value = this.deepGet(prop, field.fields, strict);
452
+ if (prop === FieldPropsEnum.value)
453
+ value = field.$output(value);
454
+ delete obj[field.key];
455
+ if (removeProp)
456
+ return obj;
457
+ const removeNullishValuesInArrays = this.state.options.get(OptionsEnum.removeNullishValuesInArrays, this);
458
+ return Object.assign(obj, {
459
+ [field.key]: parseCheckArray(field, value, prop, strict ? removeNullishValuesInArrays : false),
460
+ });
461
+ }
462
+ each(prop, ($prop) => Object.assign(obj[field.key], {
463
+ [$prop]: field[$prop],
464
+ }));
465
+ return obj;
466
+ }, {});
467
+ // Array fields with integer keys must preserve _entries order
468
+ // (JavaScript Object.assign sorts integer-like keys regardless of insertion order)
469
+ if (typeof prop === "string" &&
470
+ _fieldsArr.length > 0 &&
471
+ hasIntKeys(fields)) {
472
+ const keysInResult = new Set(Object.keys(_result));
473
+ return _fieldsArr
474
+ .filter((f) => keysInResult.has(String(f.key)))
475
+ .map((f) => _result[String(f.key)]);
476
+ }
477
+ return _result;
478
+ }
479
+ /**
480
+ Set Fields Props
481
+ */
482
+ set(prop, data) {
483
+ // UPDATE CUSTOM PROP
484
+ if (typeof prop === "string" && data !== void 0) {
485
+ allowedProps(AllowedFieldPropsTypes.editable, [prop]);
486
+ const isPlain = [FieldPropsEnum.hooks, FieldPropsEnum.handlers].includes(prop);
487
+ const deep = (data !== null &&
488
+ typeof data === "object" &&
489
+ prop === FieldPropsEnum.value) ||
490
+ (isPlainObject(data) && !isPlain);
491
+ if (deep && this.hasNestedFields)
492
+ return this.deepSet(prop, data, "", true);
493
+ if (prop === FieldPropsEnum.value) {
494
+ const applyInputConverterOnSet = this.state.options.get(OptionsEnum.applyInputConverterOnSet, this);
495
+ this.value = parseInput(applyInputConverterOnSet ? this.$input : (val) => val, {
496
+ fallbackValueOption: this.state.options.get(OptionsEnum.fallbackValue, this),
497
+ separated: data,
498
+ });
499
+ }
500
+ else if (isPlain) {
501
+ Object.assign(this[`$${prop}`], data);
502
+ }
503
+ else {
504
+ set(this, `$${prop}`, data);
505
+ }
506
+ return;
507
+ }
508
+ // NO PROP NAME PROVIDED ("prop" is value)
509
+ if (data == null) {
510
+ if (this.hasNestedFields)
511
+ this.deepSet(FieldPropsEnum.value, prop, "", true);
512
+ else
513
+ this.set(FieldPropsEnum.value, prop);
514
+ }
515
+ }
516
+ /**
517
+ Set Fields Props Recursively
518
+ */
519
+ deepSet(prop, data, path = "", recursion = false) {
520
+ const err = "You are updating a not existent field:";
521
+ const isStrict = this.state.options.get(OptionsEnum.strictSet, this);
522
+ if (data == null) {
523
+ this.each((field) => (field.$value = defaultValue({
524
+ fallbackValueOption: this.state.options.get(OptionsEnum.fallbackValue, this),
525
+ value: field.$value,
526
+ nullable: field.$nullable,
527
+ type: field.type,
528
+ })));
529
+ return;
530
+ }
531
+ each(data, ($val, $key) => {
532
+ const $path = `${path}.${$key}`.replace(/^\.+/, "");
533
+ // get the field by path joining keys recursively
534
+ const field = this.select($path, null, isStrict);
535
+ // if no field found when is strict update, throw error
536
+ if (isStrict)
537
+ throwError($path, field, err);
538
+ // update the field/fields if defined
539
+ if (field !== void 0) {
540
+ // update field values or others props
541
+ if ($val !== void 0) {
542
+ field.set(prop, $val, recursion);
543
+ }
544
+ // update values recursively only if field has nested
545
+ if (field.fields.size && $val !== null && typeof $val === "object") {
546
+ this.deepSet(prop, $val, $path, recursion);
547
+ }
548
+ }
549
+ });
550
+ }
551
+ /**
552
+ Add Field
553
+ */
554
+ add(obj, execEvent = true) {
555
+ if (isArrayOfObjects(obj)) {
556
+ each(obj, (values) => this.update({
557
+ [maxKey(this.fields)]: values,
558
+ }));
559
+ this.$changed++;
560
+ this.state.form.$changed++;
561
+ execEvent && this.execHook(FieldPropsEnum.onAdd);
562
+ return this;
563
+ }
564
+ let key;
565
+ if (has(obj, FieldPropsEnum.key))
566
+ key = obj.key;
567
+ if (has(obj, FieldPropsEnum.name))
568
+ key = obj.name;
569
+ if (!key)
570
+ key = maxKey(this.fields);
571
+ const $path = ($key) => [this.path, $key].join(".").replace(/^\.+/, "");
572
+ const tree = pathToFieldsTree(this.state.struct(), this.path ?? "", 0, true);
573
+ const field = this.initField(key, $path(key), merge(tree[0], obj));
574
+ const hasValues = has(obj, FieldPropsEnum.value) || has(obj, FieldPropsEnum.fields);
575
+ if (!hasValues) {
576
+ // When the struct defines nested fields and obj is a plain object
577
+ // without field-definition props (key, name), treat obj properties
578
+ // directly as nested field values (e.g. add({ firstname: 'John' }))
579
+ if (tree[0]?.fields &&
580
+ isPlainObject(obj) &&
581
+ !hasSome(obj, [FieldPropsEnum.key, FieldPropsEnum.name])) {
582
+ each(obj, (val, fieldName) => {
583
+ const nestedField = field.select(fieldName);
584
+ if (nestedField && !nestedField.hasNestedFields) {
585
+ nestedField.set(FieldPropsEnum.value, val);
586
+ }
587
+ });
588
+ }
589
+ else if (!this.state.options.get(OptionsEnum.preserveDeletedFieldsValues, this)) {
590
+ const fallbackValueOption = this.state.options.get(OptionsEnum.fallbackValue, this);
591
+ field.$value = defaultValue({
592
+ fallbackValueOption,
593
+ value: field.$value,
594
+ nullable: field.$nullable,
595
+ type: field.type,
596
+ });
597
+ field.each((f) => (f.$value = defaultValue({
598
+ fallbackValueOption,
599
+ value: f.$value,
600
+ nullable: f.$nullable,
601
+ type: f.type,
602
+ })));
603
+ }
604
+ }
605
+ this.$changed++;
606
+ this.state.form.$changed++;
607
+ execEvent && this.execHook(FieldPropsEnum.onAdd);
608
+ return field;
609
+ }
610
+ /**
611
+ Del Field
612
+ */
613
+ del($path = null, execEvent = true) {
614
+ const isStrict = this.state.options.get(OptionsEnum.strictDelete, this);
615
+ const path = parsePath($path ?? this.path ?? "");
616
+ const fullpath = [this.path ?? "", path ?? ""]
617
+ .join(".")
618
+ .replace(/^\.+|\.+$/g, "");
619
+ const container = this.container($path);
620
+ const keys = path.split(".");
621
+ const lastKey = keys[keys.length - 1];
622
+ if (isStrict && !container.fields.has(lastKey)) {
623
+ const msg = `Key "${lastKey}" not found when trying to delete field`;
624
+ throwError(fullpath, null, msg);
625
+ }
626
+ container.$changed++;
627
+ container.state.form.$changed++;
628
+ if (this.state.options.get(OptionsEnum.softDelete, this)) {
629
+ return this.select(fullpath).set(FieldPropsEnum.deleted, true);
630
+ }
631
+ container.each((field) => field.debouncedValidation.cancel());
632
+ execEvent && this.execHook(FieldPropsEnum.onDel);
633
+ return container.fields.delete(lastKey);
634
+ }
635
+ /******************************************************************
636
+ Events
637
+ */
638
+ /**
639
+ MobX Event (observe/intercept)
640
+ */
641
+ MOBXEvent({ prop = FieldPropsEnum.value, key = null, path = null, call, type, }) {
642
+ let $prop = key || prop;
643
+ allowedProps(AllowedFieldPropsTypes.observable, [$prop]);
644
+ const $instance = this.select(path || this.path, null, false) || this;
645
+ const $call = (change) => call.apply(null, [
646
+ {
647
+ change,
648
+ form: this.state.form,
649
+ path: $instance.path || null,
650
+ field: $instance.path ? $instance : null,
651
+ },
652
+ ]);
653
+ let fn;
654
+ let ffn;
655
+ if (type === "observer") {
656
+ fn = observe;
657
+ ffn = (cb) => observe($instance.fields.toArray(), cb); // fields
658
+ }
659
+ if (type === "interceptor") {
660
+ $prop = `$${prop}`;
661
+ fn = intercept;
662
+ ffn = $instance.fields.intercept; // fields
663
+ }
664
+ const $dkey = $instance.path ? `${$prop}@${$instance.path}` : $prop;
665
+ merge(this.state.disposers[type], {
666
+ [$dkey]: $prop === FieldPropsEnum.fields
667
+ ? ffn.apply((change) => $call(change))
668
+ : fn($instance, $prop, (change) => $call(change)),
669
+ });
670
+ }
671
+ /**
672
+ Dispose MOBX Events
673
+ */
674
+ dispose(opt = null) {
675
+ if (this.path && opt)
676
+ return this.disposeSingle(opt);
677
+ return this.disposeAll();
678
+ }
679
+ /**
680
+ Dispose All Events (observe/intercept)
681
+ */
682
+ disposeAll() {
683
+ const dispose = (disposer) => disposer.apply();
684
+ each(this.state.disposers.interceptor, dispose);
685
+ each(this.state.disposers.observer, dispose);
686
+ this.state.disposers = { interceptor: {}, observer: {} };
687
+ return;
688
+ }
689
+ /**
690
+ Dispose Single Event (observe/intercept)
691
+ */
692
+ disposeSingle({ type, key = FieldPropsEnum.value, path = null }) {
693
+ const $path = parsePath(path ?? this.path ?? "");
694
+ // eslint-disable-next-line
695
+ if (type === "interceptor")
696
+ key = `$${key}`; // target observables
697
+ const disposersType = this.state.disposers[type];
698
+ disposersType[`${key}@${$path}`].apply();
699
+ delete disposersType[`${key}@${$path}`];
700
+ }
701
+ /******************************************************************
702
+ Utils
703
+ */
704
+ /**
705
+ Fields Selector
706
+ */
707
+ select(path, fields = null, isStrict = true) {
708
+ const $path = parsePath(String(path));
709
+ const keys = $path.split(".");
710
+ const headKey = keys[0];
711
+ keys.shift();
712
+ let $fields = fields == null ? this.fields.get(headKey) : fields.get(headKey);
713
+ let stop = false;
714
+ each(keys, ($key) => {
715
+ if (stop)
716
+ return;
717
+ if ($fields == null) {
718
+ $fields = undefined;
719
+ stop = true;
720
+ }
721
+ else {
722
+ $fields = $fields.fields.get($key);
723
+ }
724
+ });
725
+ if (isStrict && this.state.options.get(OptionsEnum.strictSelect, this)) {
726
+ throwError(String(path), $fields);
727
+ }
728
+ return $fields;
729
+ }
730
+ /**
731
+ Get Container
732
+ */
733
+ container($path) {
734
+ const path = parsePath($path ?? this.path ?? "");
735
+ const cpath = path.replace(/[^./]+$/, "").replace(/^\.+|\.+$/g, "");
736
+ if (!!this.path && $path == null) {
737
+ return cpath !== ""
738
+ ? this.state.form.select(cpath, null, false)
739
+ : this.state.form;
740
+ }
741
+ return cpath !== "" ? this.select(cpath, null, false) : this;
742
+ }
743
+ /**
744
+ Has Field
745
+ */
746
+ has(path) {
747
+ return this.fields.has(path);
748
+ }
749
+ /**
750
+ Map Fields
751
+ */
752
+ map(cb) {
753
+ return getObservableMapValues(this.fields).map(cb);
754
+ }
755
+ /**
756
+ * Iterates deeply over fields and invokes `iteratee` for each element.
757
+ * The iteratee is invoked with three arguments: (value, index|key, depth).
758
+ *
759
+ * @param {Function} iteratee The function invoked per iteration.
760
+ * @param {Array|Object} [fields=form.fields] fields to iterate over.
761
+ * @param {number} [depth=1] The recursion depth for internal use.
762
+ * @returns {Array} Returns [fields.values()] of input [fields] parameter.
763
+ * @example
764
+ *
765
+ * JSON.stringify(form)
766
+ * // => {
767
+ * "fields": {
768
+ * "state": {
769
+ * "fields": {
770
+ * "city": {
771
+ * "fields": { "places": {
772
+ * "fields": {},
773
+ * "key": "places", "path": "state.city.places", "$value": "NY Places"
774
+ * }
775
+ * },
776
+ * "key": "city", "path": "state.city", "$value": "New York"
777
+ * }
778
+ * },
779
+ * "key": "state", "path": "state", "$value": "USA"
780
+ * }
781
+ * }
782
+ * }
783
+ *
784
+ * const data = {};
785
+ * form.each(field => data[field.path] = field.value);
786
+ * // => {
787
+ * "state": "USA",
788
+ * "state.city": "New York",
789
+ * "state.city.places": "NY Places"
790
+ * }
791
+ *
792
+ */
793
+ each(iteratee, fields = null, depth = 0) {
794
+ const $fields = fields || this.fields;
795
+ getObservableMapValues($fields).forEach((field, index) => {
796
+ iteratee(field, index, depth);
797
+ if (field.fields.size !== 0) {
798
+ this.each(iteratee, field.fields, depth + 1);
799
+ }
800
+ });
801
+ }
802
+ reduce(iteratee, acc) {
803
+ return getObservableMapValues(this.fields).reduce(iteratee, acc);
804
+ }
805
+ /******************************************************************
806
+ Array Operations
807
+ */
808
+ /**
809
+ Move a field from one index to another (for sortable lists).
810
+ */
811
+ move(fromIndex, toIndex) {
812
+ this.fields.move(fromIndex, toIndex);
813
+ }
814
+ /******************************************************************
815
+ Helpers
816
+ */
817
+ /**
818
+ Fields Selector (alias of select)
819
+ */
820
+ $(key) {
821
+ return this.select(key);
822
+ }
823
+ /**
824
+ Fields Values (recursive with Nested Fields)
825
+ */
826
+ values() {
827
+ return this.get(FieldPropsEnum.value);
828
+ }
829
+ /**
830
+ Fields Errors (recursive with Nested Fields)
831
+ */
832
+ errors() {
833
+ return this.get(FieldPropsEnum.error);
834
+ }
835
+ /**
836
+ Fields Labels (recursive with Nested Fields)
837
+ */
838
+ labels() {
839
+ return this.get(FieldPropsEnum.label);
840
+ }
841
+ /**
842
+ Fields Placeholders (recursive with Nested Fields)
843
+ */
844
+ placeholders() {
845
+ return this.get(FieldPropsEnum.placeholder);
846
+ }
847
+ /**
848
+ Fields Default Values (recursive with Nested Fields)
849
+ */
850
+ defaults() {
851
+ return this.get(FieldPropsEnum.default);
852
+ }
853
+ /**
854
+ Fields Initial Values (recursive with Nested Fields)
855
+ */
856
+ initials() {
857
+ return this.get(FieldPropsEnum.initial);
858
+ }
859
+ /**
860
+ Fields Types (recursive with Nested Fields)
861
+ */
862
+ types() {
863
+ return this.get(FieldPropsEnum.type);
864
+ }
865
+ }
866
+
867
+ export { Base as default };
868
+ //# sourceMappingURL=Base.js.map