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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Claudio Savino
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ ### [Documentation](https://foxhound87.github.io/mobx-formkit) • [Live Demo](https://foxhound87.github.io/mobx-formkit-demo) • [Demo Code](https://github.com/foxhound87/mobx-formkit-demo) • [NPM](https://www.npmjs.com/package/mobx-formkit) • [Skills](https://github.com/foxhound87/skills) • [Tutorial](https://medium.com/@foxhound87/automagically-manage-react-forms-state-with-mobx-and-automatic-validation-2b00a32b9769) • [Join Discord Channel](https://discord.gg/CVV8w4zat4)
2
+
3
+ # MobX Formkit
4
+
5
+ ### Reactive MobX Form State Management
6
+
7
+ [![NPM](https://nodei.co/npm/mobx-formkit.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/mobx-formkit)
8
+ [![NPM Version](https://img.shields.io/npm/v/mobx-formkit?label=npm&logo=npm&style=for-the-badge)](https://www.npmjs.com/package/mobx-formkit)
9
+
10
+ ![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/foxhound87/mobx-formkit/ci.yml?branch=master)
11
+ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/foxhound87/mobx-formkit)
12
+ ![npm bundle size](https://img.shields.io/bundlephobia/min/mobx-formkit)
13
+ ![npm bundle size (gzip)](https://img.shields.io/bundlephobia/minzip/mobx-formkit)
14
+ [![Codecov Coverage](https://img.shields.io/codecov/c/github/foxhound87/mobx-formkit/master.svg)](https://codecov.io/gh/foxhound87/mobx-formkit)
15
+ [![node](https://img.shields.io/node/v/mobx-formkit.svg)]()
16
+ [![GitHub license](https://img.shields.io/github/license/foxhound87/mobx-formkit.svg)]()
17
+ ![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/foxhound87/mobx-formkit)
18
+ ![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/foxhound87/mobx-formkit)
19
+ [![Downloads](https://img.shields.io/npm/dt/mobx-formkit.svg)]()
20
+ [![Downloads](https://img.shields.io/npm/dm/mobx-formkit.svg)]()
21
+ [![Backers on Open Collective](https://opencollective.com/mobx-react-form/backers/badge.svg)](#backers)
22
+ [![Sponsors on Open Collective](https://opencollective.com/mobx-react-form/sponsors/badge.svg)](#sponsors)
23
+
24
+ <br>
25
+
26
+ ## Migrating from mobx-react-form
27
+
28
+ | What | Old | New |
29
+ | -------------------- | ---------------------------- | ---------------------------- |
30
+ | npm package | `mobx-react-form` | `mobx-formkit` |
31
+ | UMD globals | `MobxReactForm*` | `MobxFormkit*` |
32
+ | imports & everywhere | `mobx-react-form` | `mobx-formkit` |
33
+
34
+ > **Breaking (UMD):** UMD bundle filenames and script-tag globals changed from
35
+ > `MobxReactForm*` to `MobxFormkit*` — update `<script src>` paths and global
36
+ > references accordingly. There is no alias; APIs are otherwise identical.
37
+
38
+ ## Features
39
+
40
+ - Extensibles [Validation Plugins](https://foxhound87.github.io/mobx-formkit/validation/plugins.html).
41
+ - Sync & Async Validation (w/ Promises & automatic errors).
42
+ - Nested Fields (w/ Serialization & Validation).
43
+ - Nested Forms (w/ Nested Submission & Validation Hooks).
44
+ - [Event Hooks](https://foxhound87.github.io/mobx-formkit/events/event-hooks.html), [Event Handlers](https://foxhound87.github.io/mobx-formkit/events/event-handlers.html) & [Validation Hooks](https://foxhound87.github.io/mobx-formkit/events/validation-hooks.html)
45
+ - Functional [Computed Field Props](https://foxhound87.github.io/mobx-formkit/extra/computed-props.html)
46
+ - Field Props [Observers & Interceptors](https://foxhound87.github.io/mobx-formkit/extra/mobx-events.html)
47
+ - Field [Props Bindings](https://foxhound87.github.io/mobx-formkit/bindings/README.html) for custom Components.
48
+ - Support for Material UI, Ant Design, React Widgets, React Select, React Aria, Headless UI & more.
49
+ - [AI Agent Skills](https://github.com/foxhound87/skills): installable guides for AI coding assistants
50
+ - [Forms Composer](https://foxhound87.github.io/mobx-formkit/extra/composer.html): to handle multi-forms submit, validations and other actions
51
+ - Dedicated [DevTools](https://github.com/foxhound87/mobx-formkit-devtools) Package.
52
+
53
+ <br>
54
+
55
+ ## Quick Start
56
+
57
+ [![Edit form-quickstart](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/nrrZgG8y4)
58
+
59
+ ```bash
60
+ npm install --save mobx-formkit
61
+ ```
62
+
63
+ > **MobX 6 & 7 support**: `mobx-formkit` works with both `mobx@6` and `mobx@7` (peer dependency: `^6.0.0 || ^7.0.0`). For MobX 7 use the matching React bindings (`mobx-react@^10`).
64
+
65
+ #### Choose and Setup a Validation Plugin
66
+
67
+ Below we are creating a `plugins` object using the `validatorjs` package to enable `DVR` functionalities (Declarative Validation Rules).
68
+
69
+ ```javascript
70
+ import dvr from "mobx-formkit/lib/validators/DVR";
71
+ import validatorjs from "validatorjs";
72
+
73
+ const plugins = {
74
+ dvr: dvr({
75
+ package: validatorjs,
76
+ }),
77
+ };
78
+ ```
79
+
80
+ > See [Validation Plugins](https://foxhound87.github.io/mobx-formkit/validation/plugins.html) for more info on supported packages.
81
+
82
+ #### Define the Form Fields
83
+
84
+ Define the `fields` as a collection with a `rules` property for the validation.
85
+
86
+ ```javascript
87
+ const fields = [
88
+ {
89
+ name: "email",
90
+ label: "Email",
91
+ placeholder: "Insert Email",
92
+ rules: "required|email|string|between:5,25",
93
+ },
94
+ {
95
+ name: "password",
96
+ label: "Password",
97
+ placeholder: "Insert Password",
98
+ rules: "required|string|between:5,25",
99
+ type: "password",
100
+ },
101
+ {
102
+ name: "passwordConfirm",
103
+ label: "Password Confirmation",
104
+ placeholder: "Confirm Password",
105
+ rules: "required|string|same:password",
106
+ type: "password",
107
+ },
108
+ ];
109
+ ```
110
+
111
+ > See [Fields Definitions](https://foxhound87.github.io/mobx-formkit/fields/) and all available [Field Props](https://foxhound87.github.io/mobx-formkit/api-reference/fields-properties.html) on the docs.
112
+
113
+ #### Define the Validation Hooks
114
+
115
+ ```javascript
116
+ const hooks = {
117
+ onSuccess(form) {
118
+ alert("Form is valid! Send the request here.");
119
+ // get field values
120
+ console.log("Form Values!", form.values());
121
+ },
122
+ onError(form) {
123
+ alert("Form has errors!");
124
+ // get all form errors
125
+ console.log("All form errors", form.errors());
126
+ },
127
+ };
128
+ ```
129
+
130
+ > See more on the docs about the [Validation Hooks](https://foxhound87.github.io/mobx-formkit/events/validation-hooks.html) and the [Event Hooks](https://foxhound87.github.io/mobx-formkit/events/event-hooks.html)
131
+
132
+ #### Initialize the Form
133
+
134
+ Simply pass the `fields`, `plugins` and `hooks` objects to the constructor
135
+
136
+ ```javascript
137
+ import MobxFormkit from "mobx-formkit";
138
+
139
+ const myForm = new MobxFormkit({ fields }, { plugins, hooks });
140
+ ```
141
+
142
+ > Learn more on the docs about the [Form Instance](https://foxhound87.github.io/mobx-formkit/form/) and the [Form Options](https://foxhound87.github.io/mobx-formkit/form/form-options.html)
143
+
144
+ #### Pass the myForm to a react component
145
+
146
+ The package provide some built-in and ready to use Event Handlers:
147
+
148
+ `onSubmit(e)`, `onClear(e)`, `onReset(e)` & [more...](https://foxhound87.github.io/mobx-formkit/events/event-handlers.html)
149
+
150
+ ```javascript
151
+ import React from "react";
152
+ import { observer } from "mobx-react";
153
+
154
+ export default observer(({ myForm }) => (
155
+ <form onSubmit={myForm.onSubmit}>
156
+ <label htmlFor={myForm.$("email").id}>{myForm.$("email").label}</label>
157
+ <input {...myForm.$("email").bind()} />
158
+ <p>{myForm.$("email").error}</p>
159
+
160
+ {/* ... other inputs ... */}
161
+
162
+ <button type="submit" onClick={myForm.onSubmit}>
163
+ Submit
164
+ </button>
165
+ <button type="button" onClick={myForm.onClear}>
166
+ Clear
167
+ </button>
168
+ <button type="button" onClick={myForm.onReset}>
169
+ Reset
170
+ </button>
171
+
172
+ <p>{myForm.error}</p>
173
+ </form>
174
+ ));
175
+ ```
176
+
177
+ > See more on the docs about the [Field Props Bindings](https://foxhound87.github.io/mobx-formkit/bindings)
178
+
179
+ ###### Extending the Form class
180
+
181
+ [See how to implement the same configuration of this quickstart extending the Form class](https://foxhound87.github.io/mobx-formkit/quick-start-class.html)
182
+
183
+ <br>
184
+
185
+ ## Contributing
186
+
187
+ 1. Fork the repository
188
+ 2. Make applicable changes (with tests!)
189
+ 3. To run tests: `npm run test`
190
+ 4. Ensure builds succeed: `npm run build`
191
+ 5. Commit and run pre-commit checks: `npm run commit`
192
+
193
+ ### New Issues
194
+
195
+ When opening new issues, provide the setup of your form in a [CodeSandbox](https://codesandbox.io/).
196
+
197
+ These issues, and the ones which provides also PR with failing tests will get higher priority.
198
+
199
+ ### Contributors
200
+
201
+ This project exists thanks to all the people who contribute.
202
+ <a href="graphs/contributors"><img src="https://opencollective.com/mobx-react-form/contributors.svg?width=890&button=false" /></a>
203
+
204
+ ### Backers
205
+
206
+ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/mobx-react-form#backer)]
207
+
208
+ <a href="https://opencollective.com/mobx-react-form#backers" target="_blank"><img src="https://opencollective.com/mobx-react-form/backers.svg?width=890"></a>
209
+
210
+ ### Sponsors
211
+
212
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/mobx-react-form#sponsor)]
213
+
214
+ <img src="https://opencollective.com/mobx-react-form/sponsors.svg"/>
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ArrayMap: an ordered key-value collection backed by an observable array.
3
+ *
4
+ * Exposes the full ObservableMap-compatible API (get, set, has, delete,
5
+ * merge, forEach, keys, values, entries, intercept, etc.) while
6
+ * maintaining insertion order via an internal observable array.
7
+ *
8
+ * The observable array backing allows array-like operations such as
9
+ * `move(fromIndex, toIndex)` which directly re-orders entries via
10
+ * splice — fully MobX reactive.
11
+ */
12
+ export declare class ArrayMap<K = string, V = any> {
13
+ /** Duck-typing marker for utility code */
14
+ _isArrayMap: boolean;
15
+ /** Internal observable array: entries stored as [key, value] pairs */
16
+ private _entries;
17
+ constructor(entries?: [K, V][] | null);
18
+ get size(): number;
19
+ get(key: K): V | undefined;
20
+ set(key: K, value: V): this;
21
+ has(key: K): boolean;
22
+ delete(key: K): boolean;
23
+ clear(): void;
24
+ keys(): IterableIterator<K>;
25
+ values(): IterableIterator<V>;
26
+ entries(): IterableIterator<[K, V]>;
27
+ forEach(callbackfn: (value: V, key: K, map: this) => void, thisArg?: any): void;
28
+ toJSON(): {
29
+ [key: string]: V;
30
+ };
31
+ toString(): string;
32
+ merge(other: any): this;
33
+ replace(values: any): this;
34
+ get intercept(): any;
35
+ [Symbol.iterator](): IterableIterator<[K, V]>;
36
+ /**
37
+ * Move an entry from `fromIndex` to `toIndex`.
38
+ *
39
+ * Directly splices the internal observable array, so MobX
40
+ * tracks the change as a single array splice operation.
41
+ */
42
+ move(fromIndex: number, toIndex: number): void;
43
+ /**
44
+ * Expose the underlying observable array for direct MobX
45
+ * observation (e.g. `observe(arr, cb)` from mobx).
46
+ */
47
+ toArray(): Array<[K, V]>;
48
+ }
49
+ export default ArrayMap;
50
+ //# sourceMappingURL=ArrayMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArrayMap.d.ts","sourceRoot":"","sources":["../src/ArrayMap.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,qBAAa,QAAQ,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,GAAG;IACvC,0CAA0C;IAC1C,WAAW,UAAQ;IAEnB,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAA0D;gBAE9D,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI;IAUrC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAK1B,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAU3B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAIpB,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IASvB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAI3B,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAI7B,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAInC,OAAO,CACL,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,KAAK,IAAI,EACjD,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI;IAMP,MAAM,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;KAAE;IAQ9B,QAAQ,IAAI,MAAM;IAIlB,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAsBvB,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAK1B,IAAI,SAAS,IAAI,GAAG,CAEnB;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAQ7C;;;;;OAKG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAW9C;;;OAGG;IACH,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAGzB;AAED,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var mobx = require('mobx');
6
+
7
+ /**
8
+ * ArrayMap: an ordered key-value collection backed by an observable array.
9
+ *
10
+ * Exposes the full ObservableMap-compatible API (get, set, has, delete,
11
+ * merge, forEach, keys, values, entries, intercept, etc.) while
12
+ * maintaining insertion order via an internal observable array.
13
+ *
14
+ * The observable array backing allows array-like operations such as
15
+ * `move(fromIndex, toIndex)` which directly re-orders entries via
16
+ * splice — fully MobX reactive.
17
+ */
18
+ class ArrayMap {
19
+ /** Duck-typing marker for utility code */
20
+ _isArrayMap = true;
21
+ /** Internal observable array: entries stored as [key, value] pairs */
22
+ _entries = mobx.observable.array([]);
23
+ constructor(entries) {
24
+ if (entries && entries.length > 0) {
25
+ this._entries.replace(entries);
26
+ }
27
+ }
28
+ // ------------------------------------------------------------------
29
+ // ObservableMap-compatible API
30
+ // ------------------------------------------------------------------
31
+ get size() {
32
+ return this._entries.length;
33
+ }
34
+ get(key) {
35
+ const entry = this._entries.find(([k]) => k === key);
36
+ return entry ? entry[1] : undefined;
37
+ }
38
+ set(key, value) {
39
+ const existing = this._entries.find(([k]) => k === key);
40
+ if (existing) {
41
+ existing[1] = value;
42
+ }
43
+ else {
44
+ this._entries.push([key, value]);
45
+ }
46
+ return this;
47
+ }
48
+ has(key) {
49
+ return this._entries.some(([k]) => k === key);
50
+ }
51
+ delete(key) {
52
+ const index = this._entries.findIndex(([k]) => k === key);
53
+ if (index !== -1) {
54
+ this._entries.splice(index, 1);
55
+ return true;
56
+ }
57
+ return false;
58
+ }
59
+ clear() {
60
+ this._entries.clear();
61
+ }
62
+ keys() {
63
+ return this._entries.map(([k]) => k)[Symbol.iterator]();
64
+ }
65
+ values() {
66
+ return this._entries.map(([, v]) => v)[Symbol.iterator]();
67
+ }
68
+ entries() {
69
+ return this._entries[Symbol.iterator]();
70
+ }
71
+ forEach(callbackfn, thisArg) {
72
+ this._entries.forEach(([key, value]) => {
73
+ callbackfn.call(thisArg, value, key, this);
74
+ });
75
+ }
76
+ toJSON() {
77
+ const result = {};
78
+ this._entries.forEach(([key, value]) => {
79
+ result[String(key)] = value;
80
+ });
81
+ return result;
82
+ }
83
+ toString() {
84
+ return `[object ArrayMap]`;
85
+ }
86
+ merge(other) {
87
+ if (other && typeof other === "object") {
88
+ if (other.forEach && typeof other.forEach === "function") {
89
+ // ObservableMap or Map-like
90
+ other.forEach((value, key) => {
91
+ this.set(key, value);
92
+ });
93
+ }
94
+ else if (Array.isArray(other)) {
95
+ // Array of [key, value] pairs
96
+ other.forEach(([key, value]) => {
97
+ this.set(key, value);
98
+ });
99
+ }
100
+ else {
101
+ // Plain object { key: value }
102
+ Object.keys(other).forEach((key) => {
103
+ this.set(key, other[key]);
104
+ });
105
+ }
106
+ }
107
+ return this;
108
+ }
109
+ replace(values) {
110
+ this.clear();
111
+ return this.merge(values);
112
+ }
113
+ get intercept() {
114
+ return this._entries.intercept;
115
+ }
116
+ [Symbol.iterator]() {
117
+ return this._entries[Symbol.iterator]();
118
+ }
119
+ // ------------------------------------------------------------------
120
+ // Array-specific methods
121
+ // ------------------------------------------------------------------
122
+ /**
123
+ * Move an entry from `fromIndex` to `toIndex`.
124
+ *
125
+ * Directly splices the internal observable array, so MobX
126
+ * tracks the change as a single array splice operation.
127
+ */
128
+ move(fromIndex, toIndex) {
129
+ mobx.runInAction(() => {
130
+ if (fromIndex < 0 || fromIndex >= this._entries.length)
131
+ return;
132
+ if (toIndex < 0 || toIndex >= this._entries.length)
133
+ return;
134
+ if (fromIndex === toIndex)
135
+ return;
136
+ const [entry] = this._entries.splice(fromIndex, 1);
137
+ this._entries.splice(toIndex, 0, entry);
138
+ });
139
+ }
140
+ /**
141
+ * Expose the underlying observable array for direct MobX
142
+ * observation (e.g. `observe(arr, cb)` from mobx).
143
+ */
144
+ toArray() {
145
+ return this._entries;
146
+ }
147
+ }
148
+
149
+ exports.ArrayMap = ArrayMap;
150
+ exports.default = ArrayMap;
151
+ //# sourceMappingURL=ArrayMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArrayMap.js","sources":["../src/ArrayMap.ts"],"sourcesContent":[null],"names":["observable","runInAction"],"mappings":";;;;;;AAEA;;;;;;;;;;AAUG;MACU,QAAQ,CAAA;;IAEnB,WAAW,GAAG,IAAI;;AAGV,IAAA,QAAQ,GAA6BA,eAAU,CAAC,KAAK,CAAS,EAAE,CAAC;AAEzE,IAAA,WAAA,CAAY,OAAyB,EAAA;QACnC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACjC,YAAA,IA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,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;YAClD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC;AACzC,QAAA,CAAC,CAAC;IACJ;AAEA;;;AAGG;IACH,OAAO,GAAA;QACL,OAAO,IAAI,CAAC,QAAQ;IACtB;AACD;;;;;"}
package/lib/Base.d.ts ADDED
@@ -0,0 +1,237 @@
1
+ import ArrayMap from "./ArrayMap";
2
+ import { BaseInterface } from "./models/BaseInterface";
3
+ import { StateInterface } from "./models/StateInterface";
4
+ import { FieldInterface } from "./models/FieldInterface";
5
+ import { ValidateOptions } from "./models/ValidatorInterface";
6
+ import { SubmitHooks } from "./models/SharedActionsInterface";
7
+ export default abstract class Base<F extends Record<string, any> = Record<string, any>> implements BaseInterface<F> {
8
+ noop: () => void;
9
+ state: StateInterface;
10
+ fields: ArrayMap;
11
+ path: string | undefined | null;
12
+ $submitted: number;
13
+ $submitting: boolean;
14
+ $validated: number;
15
+ $validating: boolean;
16
+ $clearing: boolean;
17
+ $resetting: boolean;
18
+ $touched: boolean;
19
+ $changed: number;
20
+ $hooks: any;
21
+ $handlers: any;
22
+ constructor();
23
+ execHook: (name: string, fallback?: any, ...args: any[]) => any;
24
+ execHandler: (name: string, args: any, fallback?: any, hook?: any, execHook?: boolean) => any;
25
+ get resetting(): boolean;
26
+ get clearing(): boolean;
27
+ get submitted(): number;
28
+ get submitting(): boolean;
29
+ get validated(): number;
30
+ get validating(): boolean;
31
+ get hasIncrementalKeys(): boolean;
32
+ get hasNestedFields(): boolean;
33
+ get size(): number;
34
+ get changed(): number;
35
+ /**
36
+ Interceptor
37
+ */
38
+ intercept: (opt: any) => any;
39
+ /**
40
+ Observer
41
+ */
42
+ observe: (opt: any) => any;
43
+ /**
44
+ Event Handler: On Clear
45
+ */
46
+ onClear: (...args: any) => any;
47
+ /**
48
+ Event Handler: On Reset
49
+ */
50
+ onReset: (...args: any) => any;
51
+ /**
52
+ Event Handler: On Submit
53
+ */
54
+ onSubmit: (...args: any) => any;
55
+ /**
56
+ Event Handler: On Add
57
+ */
58
+ onAdd: (...args: any) => any;
59
+ /**
60
+ Event Handler: On Del
61
+ */
62
+ onDel: (...args: any) => any;
63
+ /******************************************************************
64
+ Initializer
65
+ */
66
+ initFields(initial: any, update?: boolean): void;
67
+ initField(key: string, path: string, data: any, update?: boolean): any;
68
+ /******************************************************************
69
+ Actions
70
+ */
71
+ validate(opt?: ValidateOptions, obj?: ValidateOptions): Promise<any>;
72
+ /**
73
+ Submit
74
+ */
75
+ submit(hooks?: SubmitHooks, { execOnSubmitHook, execValidationHooks, validate, }?: {
76
+ execOnSubmitHook?: boolean | undefined;
77
+ execValidationHooks?: boolean | undefined;
78
+ validate?: boolean | undefined;
79
+ }): Promise<any>;
80
+ /**
81
+ Check Field Computed Values
82
+ */
83
+ check(prop: string, deep?: boolean): boolean;
84
+ deepCheck(type: string, prop: string, fields: any): any;
85
+ firstError(): string | null;
86
+ /**
87
+ Update Field Values recurisvely
88
+ OR Create Field if 'undefined'
89
+ */
90
+ update(fields: any): void;
91
+ deepUpdate(fields: any, path?: string, recursion?: boolean, raw?: any): void;
92
+ /**
93
+ Get Fields Props
94
+ */
95
+ get(prop?: any, strict?: boolean): any;
96
+ /**
97
+ Get Fields Props Recursively
98
+ */
99
+ deepGet(prop: any, fields: any, strict?: boolean): any;
100
+ /**
101
+ Set Fields Props
102
+ */
103
+ set(prop: any, data?: any): void;
104
+ /**
105
+ Set Fields Props Recursively
106
+ */
107
+ deepSet(prop: any, data: any, path?: string, recursion?: boolean): void;
108
+ /**
109
+ Add Field
110
+ */
111
+ add(obj?: any, execEvent?: boolean): any;
112
+ /**
113
+ Del Field
114
+ */
115
+ del($path?: string | null, execEvent?: boolean): any;
116
+ /******************************************************************
117
+ Events
118
+ */
119
+ /**
120
+ MobX Event (observe/intercept)
121
+ */
122
+ MOBXEvent({ prop, key, path, call, type, }: any): void;
123
+ /**
124
+ Dispose MOBX Events
125
+ */
126
+ dispose(opt?: any): void;
127
+ /**
128
+ Dispose All Events (observe/intercept)
129
+ */
130
+ disposeAll(): void;
131
+ /**
132
+ Dispose Single Event (observe/intercept)
133
+ */
134
+ disposeSingle({ type, key, path }: any): void;
135
+ /******************************************************************
136
+ Utils
137
+ */
138
+ /**
139
+ Fields Selector
140
+ */
141
+ select(path: string | number, fields?: any, isStrict?: boolean): any;
142
+ /**
143
+ Get Container
144
+ */
145
+ container($path?: string | null): any;
146
+ /**
147
+ Has Field
148
+ */
149
+ has(path: string): boolean;
150
+ /**
151
+ Map Fields
152
+ */
153
+ map(cb: any): ReadonlyArray<FieldInterface>;
154
+ /**
155
+ * Iterates deeply over fields and invokes `iteratee` for each element.
156
+ * The iteratee is invoked with three arguments: (value, index|key, depth).
157
+ *
158
+ * @param {Function} iteratee The function invoked per iteration.
159
+ * @param {Array|Object} [fields=form.fields] fields to iterate over.
160
+ * @param {number} [depth=1] The recursion depth for internal use.
161
+ * @returns {Array} Returns [fields.values()] of input [fields] parameter.
162
+ * @example
163
+ *
164
+ * JSON.stringify(form)
165
+ * // => {
166
+ * "fields": {
167
+ * "state": {
168
+ * "fields": {
169
+ * "city": {
170
+ * "fields": { "places": {
171
+ * "fields": {},
172
+ * "key": "places", "path": "state.city.places", "$value": "NY Places"
173
+ * }
174
+ * },
175
+ * "key": "city", "path": "state.city", "$value": "New York"
176
+ * }
177
+ * },
178
+ * "key": "state", "path": "state", "$value": "USA"
179
+ * }
180
+ * }
181
+ * }
182
+ *
183
+ * const data = {};
184
+ * form.each(field => data[field.path] = field.value);
185
+ * // => {
186
+ * "state": "USA",
187
+ * "state.city": "New York",
188
+ * "state.city.places": "NY Places"
189
+ * }
190
+ *
191
+ */
192
+ each(iteratee: any, fields?: any, depth?: number): void;
193
+ reduce(iteratee: any, acc: any): any;
194
+ /******************************************************************
195
+ Array Operations
196
+ */
197
+ /**
198
+ Move a field from one index to another (for sortable lists).
199
+ */
200
+ move(fromIndex: number, toIndex: number): void;
201
+ /******************************************************************
202
+ Helpers
203
+ */
204
+ /**
205
+ Fields Selector (alias of select)
206
+ */
207
+ $(key: string): any;
208
+ /**
209
+ Fields Values (recursive with Nested Fields)
210
+ */
211
+ values(): any;
212
+ /**
213
+ Fields Errors (recursive with Nested Fields)
214
+ */
215
+ errors(): any;
216
+ /**
217
+ Fields Labels (recursive with Nested Fields)
218
+ */
219
+ labels(): any;
220
+ /**
221
+ Fields Placeholders (recursive with Nested Fields)
222
+ */
223
+ placeholders(): any;
224
+ /**
225
+ Fields Default Values (recursive with Nested Fields)
226
+ */
227
+ defaults(): any;
228
+ /**
229
+ Fields Initial Values (recursive with Nested Fields)
230
+ */
231
+ initials(): any;
232
+ /**
233
+ Fields Types (recursive with Nested Fields)
234
+ */
235
+ types(): any;
236
+ }
237
+ //# sourceMappingURL=Base.d.ts.map