@prototyp/skeletor 1.0.6 → 1.0.7

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 (188) hide show
  1. package/README.md +1 -102
  2. package/lib/module/hooks/index.js +1 -1
  3. package/lib/module/hooks/index.js.map +1 -1
  4. package/lib/module/hooks/skeleform/README.md +100 -0
  5. package/lib/module/hooks/skeleform/package.json +53 -0
  6. package/lib/module/hooks/{useForm.js → skeleform/src/index.js} +1 -1
  7. package/lib/module/hooks/skeleform/src/index.js.map +1 -0
  8. package/lib/module/hooks/skeleform/tsconfig.json +14 -0
  9. package/lib/module/hooks/skeleform/yarn.lock +5132 -0
  10. package/lib/typescript/components/Block/Block.d.ts.map +1 -0
  11. package/lib/typescript/components/Block/index.d.ts.map +1 -0
  12. package/lib/typescript/components/InputFocusScrollView/InputFocusScrollView.d.ts.map +1 -0
  13. package/lib/typescript/components/InputFocusScrollView/index.d.ts.map +1 -0
  14. package/lib/typescript/components/Screen/Screen.d.ts.map +1 -0
  15. package/lib/typescript/components/Screen/index.d.ts.map +1 -0
  16. package/lib/typescript/components/SkeletorProvider/SkeletorContext.d.ts.map +1 -0
  17. package/lib/typescript/components/SkeletorProvider/SkeletorProvider.d.ts.map +1 -0
  18. package/lib/typescript/components/SkeletorProvider/index.d.ts.map +1 -0
  19. package/lib/typescript/components/Text/Text.d.ts.map +1 -0
  20. package/lib/typescript/components/Text/index.d.ts.map +1 -0
  21. package/lib/typescript/components/index.d.ts.map +1 -0
  22. package/lib/typescript/{lib/module/hooks → hooks}/index.d.ts +1 -1
  23. package/lib/typescript/hooks/index.d.ts.map +1 -0
  24. package/lib/typescript/{src/hooks/useForm.d.ts → hooks/skeleform/src/index.d.ts} +1 -1
  25. package/lib/typescript/hooks/skeleform/src/index.d.ts.map +1 -0
  26. package/lib/typescript/hooks/useAndroidBackHandler.d.ts.map +1 -0
  27. package/lib/typescript/hooks/useAnimation.d.ts.map +1 -0
  28. package/lib/typescript/hooks/useAnimationTimeline.d.ts.map +1 -0
  29. package/lib/typescript/hooks/useAppState.d.ts.map +1 -0
  30. package/lib/typescript/hooks/useSkeletor.d.ts.map +1 -0
  31. package/lib/typescript/index.d.ts.map +1 -0
  32. package/lib/typescript/models/Alignment.d.ts.map +1 -0
  33. package/lib/typescript/models/Border.d.ts.map +1 -0
  34. package/lib/typescript/models/Size.d.ts.map +1 -0
  35. package/lib/typescript/models/SkeletorConfig.d.ts.map +1 -0
  36. package/lib/typescript/models/Spacing.d.ts.map +1 -0
  37. package/lib/typescript/models/index.d.ts.map +1 -0
  38. package/lib/typescript/utils/extractAlignmentProperties.d.ts.map +1 -0
  39. package/lib/typescript/utils/extractSizeProperties.d.ts.map +1 -0
  40. package/lib/typescript/utils/index.d.ts.map +1 -0
  41. package/package.json +7 -6
  42. package/lib/module/hooks/useForm.js.map +0 -1
  43. package/lib/typescript/lib/module/components/Block/Block.d.ts +0 -4
  44. package/lib/typescript/lib/module/components/Block/Block.d.ts.map +0 -1
  45. package/lib/typescript/lib/module/components/Block/index.d.ts.map +0 -1
  46. package/lib/typescript/lib/module/components/InputFocusScrollView/InputFocusScrollView.d.ts +0 -4
  47. package/lib/typescript/lib/module/components/InputFocusScrollView/InputFocusScrollView.d.ts.map +0 -1
  48. package/lib/typescript/lib/module/components/InputFocusScrollView/index.d.ts.map +0 -1
  49. package/lib/typescript/lib/module/components/Screen/Screen.d.ts +0 -5
  50. package/lib/typescript/lib/module/components/Screen/Screen.d.ts.map +0 -1
  51. package/lib/typescript/lib/module/components/Screen/index.d.ts.map +0 -1
  52. package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorContext.d.ts +0 -14
  53. package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorContext.d.ts.map +0 -1
  54. package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorProvider.d.ts +0 -8
  55. package/lib/typescript/lib/module/components/SkeletorProvider/SkeletorProvider.d.ts.map +0 -1
  56. package/lib/typescript/lib/module/components/SkeletorProvider/index.d.ts.map +0 -1
  57. package/lib/typescript/lib/module/components/Text/Text.d.ts +0 -4
  58. package/lib/typescript/lib/module/components/Text/Text.d.ts.map +0 -1
  59. package/lib/typescript/lib/module/components/Text/index.d.ts.map +0 -1
  60. package/lib/typescript/lib/module/components/index.d.ts.map +0 -1
  61. package/lib/typescript/lib/module/hooks/index.d.ts.map +0 -1
  62. package/lib/typescript/lib/module/hooks/useAndroidBackHandler.d.ts +0 -2
  63. package/lib/typescript/lib/module/hooks/useAndroidBackHandler.d.ts.map +0 -1
  64. package/lib/typescript/lib/module/hooks/useAnimation.d.ts +0 -9
  65. package/lib/typescript/lib/module/hooks/useAnimation.d.ts.map +0 -1
  66. package/lib/typescript/lib/module/hooks/useAnimationTimeline.d.ts +0 -10
  67. package/lib/typescript/lib/module/hooks/useAnimationTimeline.d.ts.map +0 -1
  68. package/lib/typescript/lib/module/hooks/useAppState.d.ts +0 -2
  69. package/lib/typescript/lib/module/hooks/useAppState.d.ts.map +0 -1
  70. package/lib/typescript/lib/module/hooks/useForm.d.ts +0 -33
  71. package/lib/typescript/lib/module/hooks/useForm.d.ts.map +0 -1
  72. package/lib/typescript/lib/module/hooks/useSkeletor.d.ts +0 -7
  73. package/lib/typescript/lib/module/hooks/useSkeletor.d.ts.map +0 -1
  74. package/lib/typescript/lib/module/index.d.ts.map +0 -1
  75. package/lib/typescript/lib/module/models/Alignment.d.ts +0 -2
  76. package/lib/typescript/lib/module/models/Alignment.d.ts.map +0 -1
  77. package/lib/typescript/lib/module/models/Border.d.ts +0 -2
  78. package/lib/typescript/lib/module/models/Border.d.ts.map +0 -1
  79. package/lib/typescript/lib/module/models/Size.d.ts +0 -2
  80. package/lib/typescript/lib/module/models/Size.d.ts.map +0 -1
  81. package/lib/typescript/lib/module/models/SkeletorConfig.d.ts +0 -1
  82. package/lib/typescript/lib/module/models/SkeletorConfig.d.ts.map +0 -1
  83. package/lib/typescript/lib/module/models/Spacing.d.ts +0 -2
  84. package/lib/typescript/lib/module/models/Spacing.d.ts.map +0 -1
  85. package/lib/typescript/lib/module/models/index.d.ts +0 -5
  86. package/lib/typescript/lib/module/models/index.d.ts.map +0 -1
  87. package/lib/typescript/lib/module/types/Font.d.d.ts +0 -1
  88. package/lib/typescript/lib/module/types/Font.d.d.ts.map +0 -1
  89. package/lib/typescript/lib/module/utils/extractAlignmentProperties.d.ts +0 -8
  90. package/lib/typescript/lib/module/utils/extractAlignmentProperties.d.ts.map +0 -1
  91. package/lib/typescript/lib/module/utils/extractSizeProperties.d.ts +0 -10
  92. package/lib/typescript/lib/module/utils/extractSizeProperties.d.ts.map +0 -1
  93. package/lib/typescript/lib/module/utils/index.d.ts.map +0 -1
  94. package/lib/typescript/src/components/Block/Block.d.ts.map +0 -1
  95. package/lib/typescript/src/components/Block/index.d.ts +0 -2
  96. package/lib/typescript/src/components/Block/index.d.ts.map +0 -1
  97. package/lib/typescript/src/components/InputFocusScrollView/InputFocusScrollView.d.ts.map +0 -1
  98. package/lib/typescript/src/components/InputFocusScrollView/index.d.ts +0 -2
  99. package/lib/typescript/src/components/InputFocusScrollView/index.d.ts.map +0 -1
  100. package/lib/typescript/src/components/Screen/Screen.d.ts.map +0 -1
  101. package/lib/typescript/src/components/Screen/index.d.ts +0 -2
  102. package/lib/typescript/src/components/Screen/index.d.ts.map +0 -1
  103. package/lib/typescript/src/components/SkeletorProvider/SkeletorContext.d.ts.map +0 -1
  104. package/lib/typescript/src/components/SkeletorProvider/SkeletorProvider.d.ts.map +0 -1
  105. package/lib/typescript/src/components/SkeletorProvider/index.d.ts +0 -3
  106. package/lib/typescript/src/components/SkeletorProvider/index.d.ts.map +0 -1
  107. package/lib/typescript/src/components/Text/Text.d.ts.map +0 -1
  108. package/lib/typescript/src/components/Text/index.d.ts +0 -2
  109. package/lib/typescript/src/components/Text/index.d.ts.map +0 -1
  110. package/lib/typescript/src/components/index.d.ts +0 -6
  111. package/lib/typescript/src/components/index.d.ts.map +0 -1
  112. package/lib/typescript/src/hooks/index.d.ts +0 -7
  113. package/lib/typescript/src/hooks/index.d.ts.map +0 -1
  114. package/lib/typescript/src/hooks/useAndroidBackHandler.d.ts.map +0 -1
  115. package/lib/typescript/src/hooks/useAnimation.d.ts.map +0 -1
  116. package/lib/typescript/src/hooks/useAnimationTimeline.d.ts.map +0 -1
  117. package/lib/typescript/src/hooks/useAppState.d.ts.map +0 -1
  118. package/lib/typescript/src/hooks/useForm.d.ts.map +0 -1
  119. package/lib/typescript/src/hooks/useSkeletor.d.ts.map +0 -1
  120. package/lib/typescript/src/index.d.ts +0 -5
  121. package/lib/typescript/src/index.d.ts.map +0 -1
  122. package/lib/typescript/src/models/Alignment.d.ts.map +0 -1
  123. package/lib/typescript/src/models/Border.d.ts.map +0 -1
  124. package/lib/typescript/src/models/Size.d.ts.map +0 -1
  125. package/lib/typescript/src/models/SkeletorConfig.d.ts.map +0 -1
  126. package/lib/typescript/src/models/Spacing.d.ts.map +0 -1
  127. package/lib/typescript/src/models/index.d.ts.map +0 -1
  128. package/lib/typescript/src/utils/extractAlignmentProperties.d.ts.map +0 -1
  129. package/lib/typescript/src/utils/extractSizeProperties.d.ts.map +0 -1
  130. package/lib/typescript/src/utils/index.d.ts +0 -3
  131. package/lib/typescript/src/utils/index.d.ts.map +0 -1
  132. package/src/components/Block/Block.tsx +0 -106
  133. package/src/components/Block/index.ts +0 -1
  134. package/src/components/InputFocusScrollView/InputFocusScrollView.tsx +0 -113
  135. package/src/components/InputFocusScrollView/index.ts +0 -1
  136. package/src/components/Screen/Screen.tsx +0 -91
  137. package/src/components/Screen/index.ts +0 -1
  138. package/src/components/SkeletorProvider/SkeletorContext.ts +0 -12
  139. package/src/components/SkeletorProvider/SkeletorProvider.tsx +0 -18
  140. package/src/components/SkeletorProvider/index.ts +0 -2
  141. package/src/components/Text/Text.tsx +0 -99
  142. package/src/components/Text/index.ts +0 -1
  143. package/src/components/index.ts +0 -5
  144. package/src/hooks/index.ts +0 -6
  145. package/src/hooks/useAndroidBackHandler.ts +0 -45
  146. package/src/hooks/useAnimation.ts +0 -62
  147. package/src/hooks/useAnimationTimeline.ts +0 -139
  148. package/src/hooks/useAppState.ts +0 -26
  149. package/src/hooks/useForm.ts +0 -208
  150. package/src/hooks/useSkeletor.ts +0 -7
  151. package/src/index.ts +0 -4
  152. package/src/models/Alignment.ts +0 -9
  153. package/src/models/Border.ts +0 -17
  154. package/src/models/Size.ts +0 -11
  155. package/src/models/SkeletorConfig.ts +0 -6
  156. package/src/models/Spacing.ts +0 -22
  157. package/src/models/index.ts +0 -5
  158. package/src/types/Font.d.ts +0 -1
  159. package/src/utils/extractAlignmentProperties.ts +0 -13
  160. package/src/utils/extractSizeProperties.ts +0 -13
  161. package/src/utils/index.ts +0 -2
  162. /package/lib/typescript/{src/components → components}/Block/Block.d.ts +0 -0
  163. /package/lib/typescript/{lib/module/components → components}/Block/index.d.ts +0 -0
  164. /package/lib/typescript/{src/components → components}/InputFocusScrollView/InputFocusScrollView.d.ts +0 -0
  165. /package/lib/typescript/{lib/module/components → components}/InputFocusScrollView/index.d.ts +0 -0
  166. /package/lib/typescript/{src/components → components}/Screen/Screen.d.ts +0 -0
  167. /package/lib/typescript/{lib/module/components → components}/Screen/index.d.ts +0 -0
  168. /package/lib/typescript/{src/components → components}/SkeletorProvider/SkeletorContext.d.ts +0 -0
  169. /package/lib/typescript/{src/components → components}/SkeletorProvider/SkeletorProvider.d.ts +0 -0
  170. /package/lib/typescript/{lib/module/components → components}/SkeletorProvider/index.d.ts +0 -0
  171. /package/lib/typescript/{src/components → components}/Text/Text.d.ts +0 -0
  172. /package/lib/typescript/{lib/module/components → components}/Text/index.d.ts +0 -0
  173. /package/lib/typescript/{lib/module/components → components}/index.d.ts +0 -0
  174. /package/lib/typescript/{src/hooks → hooks}/useAndroidBackHandler.d.ts +0 -0
  175. /package/lib/typescript/{src/hooks → hooks}/useAnimation.d.ts +0 -0
  176. /package/lib/typescript/{src/hooks → hooks}/useAnimationTimeline.d.ts +0 -0
  177. /package/lib/typescript/{src/hooks → hooks}/useAppState.d.ts +0 -0
  178. /package/lib/typescript/{src/hooks → hooks}/useSkeletor.d.ts +0 -0
  179. /package/lib/typescript/{lib/module/index.d.ts → index.d.ts} +0 -0
  180. /package/lib/typescript/{src/models → models}/Alignment.d.ts +0 -0
  181. /package/lib/typescript/{src/models → models}/Border.d.ts +0 -0
  182. /package/lib/typescript/{src/models → models}/Size.d.ts +0 -0
  183. /package/lib/typescript/{src/models → models}/SkeletorConfig.d.ts +0 -0
  184. /package/lib/typescript/{src/models → models}/Spacing.d.ts +0 -0
  185. /package/lib/typescript/{src/models → models}/index.d.ts +0 -0
  186. /package/lib/typescript/{src/utils → utils}/extractAlignmentProperties.d.ts +0 -0
  187. /package/lib/typescript/{src/utils → utils}/extractSizeProperties.d.ts +0 -0
  188. /package/lib/typescript/{lib/module/utils → utils}/index.d.ts +0 -0
package/README.md CHANGED
@@ -242,108 +242,7 @@ height?: "full" | "auto";
242
242
 
243
243
  ### useForm & useFormUtils
244
244
 
245
- ---
246
-
247
- Handle form value updates and validation with `useForm`. Full TypeScript support, ability to configure optional parameters, custom validation rules.
248
-
249
- Flexible in its function, supports multiple validation approaches through callbacks:
250
-
251
- 1. For on-change validation, use `update("prop", value, true)`
252
- 2. To trigger standalone validation, use `validate("prop")`
253
- 3. Validate entire form with `validateForm()`
254
-
255
- The order of importance when it comes to validating fields is:
256
-
257
- 1. Custom validation rule - will get the value as-is for your rule to validate it fully. The configuration rule receives the current value, state and optional flag values for you to validate against.
258
- 2. If there is no custom validation rule and the primitive value check returns false (there is no value), check if the field is optional. If optional, the validation result is `true`, otherwise it is `false`;
259
- 3. If all previous checks have not been triggered, return the primitive "has value" check result. This will return `false` for values such as: `null | undefined | NaN | "" | Invalid Date`. This will return `true` if you have a complex value type such as `object | Array`, <b>so in case you have a complex value type use a custom validation rule to get what you need</b>.
260
-
261
- #### Example 1: Simple use case with standalone validation on blur:
262
-
263
- ```javascript
264
- const {state, validation, update, validate} = useForm({email: "", password: "");
265
-
266
- ...
267
- <Input
268
- keyboardType="email-address"
269
- returnKeyType="next"
270
- label="E-mail Address"
271
- errorMessage="Email is not valid."
272
- emptyMessage="Email is a required field."
273
- placeholder="What's your email address?"
274
- value={state.email}
275
- textContentType="emailAddress"
276
- valid={validation.email}
277
- onChangeText={(text) => update("email", text)}
278
- onBlur={() => validate("email")}
279
- />
280
- ...
281
- ```
282
-
283
- #### Example 2: Simple use case with on-change validation:
284
-
285
- ```javascript
286
- // See example 1
287
- ...
288
- onChangeText={(text) => update("email", text, true)}
289
- ...
290
- ```
291
-
292
- #### Example 3: Simple use case with on-submit validation:
293
-
294
- ```javascript
295
- // See example 1
296
-
297
- function submit() {
298
- if(!validateForm()) {
299
- // Throw invalid error
300
- // validation object will be populated
301
- }
302
- }
303
-
304
- ...
305
- <Input
306
- keyboardType="email-address"
307
- returnKeyType="next"
308
- label="E-mail Address"
309
- errorMessage="Email is not valid."
310
- emptyMessage="Email is a required field."
311
- placeholder="What's your email address?"
312
- value={state.email}
313
- textContentType="emailAddress"
314
- valid={validation.email}
315
- onChangeText={(text) => update("email", text)}
316
- />
317
- <Button onPress={submit}>Submit</Button>
318
- ```
319
-
320
- #### Example 4: Form configuration
321
-
322
- ```javascript
323
- const { state, validation, update, validate } = useForm(
324
- { firstName: "", middleName: "", lastName: ""},
325
- {
326
- // If left empty, validation.middleName will be true
327
- optional: ["middleName"],
328
- // validation.lastName is invalid if lastName is <3 characters long
329
- // state can be used to compare with other values (ie repeat password)
330
- rules: { lastName: (value, state, optional) => value.length >= 3,
331
- }
332
- ```
333
-
334
- #### Example 5: useFormUtils
335
-
336
- Utility functions to help with standalone state validation, such as when re-validating a list of form values in a parent components.
337
-
338
- ```javascript
339
- const { stateValidation } = useFormUtils<Person>();
340
-
341
- function validatePeople() {
342
- return people.every(person => stateValidation(person).valid);
343
- }
344
- ```
345
-
346
- Other utilities: `doesValueExist`, `validateByRule`, `isOptional`, `fieldValidation`, `stateValidation`. Some are meant for internal `useForm` usage, such as `fieldValidation` and `validateByRule`, but are not unusable.
245
+ Read documentation about useForm here: https://github.com/prototypdigital/skeleform
347
246
 
348
247
  ### useAnimation & useAnimationTimeline
349
248
 
@@ -1,7 +1,7 @@
1
- export * from "./useForm";
2
1
  export * from "./useAnimation";
3
2
  export * from "./useAnimationTimeline";
4
3
  export * from "./useAppState";
5
4
  export * from "./useSkeletor";
6
5
  export * from "./useAndroidBackHandler";
6
+ export * from "./skeleform/src/index";
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,gBAAgB;AAC9B,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,yBAAyB"}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,yBAAyB;AACvC,cAAc,uBAAuB"}
@@ -0,0 +1,100 @@
1
+ # skeleform
2
+
3
+ Form management and validation toolkit originally a part of https://github.com/prototypdigital/skeletor
4
+
5
+ ### Usage
6
+
7
+ Handle form value updates and validation with `useForm`. Full TypeScript support, ability to configure optional parameters, custom validation rules.
8
+
9
+ Flexible in its function, supports multiple validation approaches through callbacks:
10
+
11
+ 1. For on-change validation, use `update("prop", value, true)`
12
+ 2. To trigger standalone validation, use `validate("prop")`
13
+ 3. Validate entire form with `validateForm()`
14
+
15
+ The order of importance when it comes to validating fields is:
16
+
17
+ 1. Custom validation rule - will get the value as-is for your rule to validate it fully. The configuration rule receives the current value, state and optional flag values for you to validate against.
18
+ 2. If there is no custom validation rule and the primitive value check returns false (there is no value), check if the field is optional. If optional, the validation result is `true`, otherwise it is `false`;
19
+ 3. If all previous checks have not been triggered, return the primitive "has value" check result. This will return `false` for values such as: `null | undefined | NaN | "" | Invalid Date`. This will return `true` if you have a complex value type such as `object | Array`, <b>so in case you have a complex value type use a custom validation rule to get what you need</b>.
20
+
21
+ #### Example 1: Simple use case with standalone validation on blur:
22
+
23
+ ```javascript
24
+ const {state, validation, update, validate} = useForm({email: "", password: "");
25
+
26
+ ...
27
+ <input
28
+ ...
29
+ value={state.email}
30
+ onChange={(e) => update("email", e.currentTarget.value)}
31
+ onBlur={() => validate("email")}
32
+ />
33
+ ...
34
+ ```
35
+
36
+ #### Example 2: Simple use case with on-change validation:
37
+
38
+ ```javascript
39
+ // See example 1
40
+ ...
41
+ onChange={(e) => update("email", e.currentTarget.value, true)}
42
+ ...
43
+ ```
44
+
45
+ #### Example 3: Simple use case with on-submit validation:
46
+
47
+ ```javascript
48
+ // See example 1
49
+
50
+ function submit() {
51
+ if(!validateForm()) {
52
+ // Throw invalid error
53
+ // validation object will be populated
54
+ }
55
+ }
56
+
57
+ ...
58
+ <input
59
+ ...
60
+ value={state.email}
61
+ onUpdate={(e) => update("email", e.currentTarget.value)}
62
+ />
63
+ <button onPress={submit}>Submit</button>
64
+ ```
65
+
66
+ Validation has three possible values:
67
+
68
+ 1. `undefined` = validation of the field value has not been done yet.
69
+ 2. `false` = validation has failed, the state value is not considered valid.
70
+ 3. `true` = validation has succeeded, the state value is considered valid.
71
+
72
+ What does that mean? Well, it means that when you have `validation.email === false`, you should show an error message on the field. `undefined | true` are not relevant for rendering, only functionally to block form submit events.
73
+
74
+ #### Example 4: Form configuration
75
+
76
+ ```javascript
77
+ const { state, validation, update, validate } = useForm(
78
+ { firstName: "", middleName: "", lastName: ""},
79
+ {
80
+ // If left empty, validation.middleName will be true
81
+ optional: ["middleName"],
82
+ // validation.lastName is invalid if lastName is <3 characters long
83
+ // state can be used to compare with other values (ie repeat password)
84
+ rules: { lastName: (value, state, optional) => value.length >= 3,
85
+ }
86
+ ```
87
+
88
+ #### Example 5: useFormUtils
89
+
90
+ Utility functions to help with standalone state validation, such as when re-validating a list of form values in a parent components.
91
+
92
+ ```javascript
93
+ const { stateValidation } = useFormUtils<Person>();
94
+
95
+ function validatePeople() {
96
+ return people.every(person => stateValidation(person).valid);
97
+ }
98
+ ```
99
+
100
+ Other utilities: `doesValueExist`, `validateByRule`, `isOptional`, `fieldValidation`, `stateValidation`. Some are meant for internal `useForm` usage, such as `fieldValidation` and `validateByRule`, but are not unusable.
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@prototyp/skeleform",
3
+ "description": "React/React-Native form management utility",
4
+ "author": "Luka Buljan <luka@prototyp.digital>",
5
+ "version": "1.0.1",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/prototypdigital/skeleform",
8
+ "repository": {
9
+ "type": "git",
10
+ "directory": "https://github.com/prototypdigital/skeleform"
11
+ },
12
+ "type": "module",
13
+ "main": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "prepack": "tsc"
23
+ },
24
+ "devDependencies": {
25
+ "@types/jest": "29.4.0",
26
+ "@types/react": "^18.0.24",
27
+ "jest": "29.4.2",
28
+ "react": "^18.2.0",
29
+ "typescript": "4.8.4"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "keywords": [
35
+ "react",
36
+ "react-native",
37
+ "typescript",
38
+ "form",
39
+ "input",
40
+ "state",
41
+ "validation",
42
+ "helpers",
43
+ "utilities",
44
+ "utils"
45
+ ],
46
+ "files": [
47
+ "dist",
48
+ "README.md"
49
+ ],
50
+ "eslintIgnore": [
51
+ "node_modules/"
52
+ ]
53
+ }
@@ -171,4 +171,4 @@ export function useFormUtils(config) {
171
171
  stateValidation
172
172
  };
173
173
  }
174
- //# sourceMappingURL=useForm.js.map
174
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","useForm","values","config","keys","Object","validation","setValidation","initialState","setInitialState","state","setState","fieldValidation","stateValidation","isOptional","useFormUtils","changed","filter","key","length","updatedState","forEach","update","value","shouldValidate","s","undefined","validate","validateForm","formValidationState","valid","isFormValid","some","resetState","resetInitialValues","resetValidation","clearForm","doesValueExist","isNaN","Date","valueOf","optional","includes","validateByRule","rules","hasValue","map"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAyB3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAO,CAAIC,MAAiB,EAAEC,MAAsB,EAAE;EACpE,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACF,MAAM,CAAmB;EAClD,MAAM,CAACI,UAAU,EAAEC,aAAa,CAAC,GAAGP,QAAQ,CAAgB,CAAC,CAAC,CAAC;EAC/D,MAAM,CAACQ,YAAY,EAAEC,eAAe,CAAC,GAAGT,QAAQ,CAACE,MAAM,CAAC;EACxD,MAAM,CAACQ,KAAK,EAAEC,QAAQ,CAAC,GAAGX,QAAQ,CAACE,MAAM,CAAC;EAC1C,MAAM;IAAEU,eAAe;IAAEC,eAAe;IAAEC;EAAW,CAAC,GAAGC,YAAY,CAACZ,MAAM,CAAC;EAE7EJ,SAAS,CAAC,MAAM;IACd,MAAMiB,OAAO,GAAGZ,IAAI,CAACa,MAAM,CAAEC,GAAG,IAAKhB,MAAM,CAACgB,GAAG,CAAC,KAAKV,YAAY,CAACU,GAAG,CAAC,CAAC;IACvE,IAAI,CAACF,OAAO,CAACG,MAAM,EAAE;MACnB;IACF;IAEA,MAAMC,YAAY,GAAG;MAAE,GAAGV;IAAM,CAAC;IACjCM,OAAO,CAACK,OAAO,CAAEH,GAAG,IAAME,YAAY,CAACF,GAAG,CAAC,GAAGhB,MAAM,CAACgB,GAAG,CAAE,CAAC;IAE3DT,eAAe,CAAC;MAAE,GAAGP,MAAM;MAAE,GAAGkB;IAAa,CAAC,CAAC;IAC/CT,QAAQ,CAACS,YAAY,CA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;AACA;AACA;EACE,SAASN,eAAe,CAACM,GAAY,EAAEK,KAAiB,EAAEb,KAAgB,EAAE;IAAA;IAC1E,MAAMmC,QAAQ,GAAGR,cAAc,CAACd,KAAK,CAAC;IACtC,MAAMkB,QAAQ,GAAG3B,UAAU,CAACI,GAAG,CAAC;;IAEhC;IACA,IAAI,CAAC,EAACf,MAAM,aAANA,MAAM,iCAANA,MAAM,CAAEyC,KAAK,2CAAb,eAAgB1B,GAAG,CAAC,GAAE,OAAOyB,cAAc,CAACzB,GAAG,EAAEK,KAAK,EAAEb,KAAK,CAAC;IACpE;IACA,IAAI,CAACmC,QAAQ,EAAE,OAAO,CAAC,CAACJ,QAAQ;IAChC;IACA,OAAOI,QAAQ;EACjB;EAEA,SAAShC,eAAe,CAACH,KAAgB,EAAE;IACzC,MAAMN,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACM,KAAK,CAAC,CAACoC,GAAG,CAAE5B,GAAG,IAAKA,GAAc,CAAC;IAC5D,MAAMZ,UAAyB,GAAG,CAAC,CAAC;IAEpCF,IAAI,CAACiB,OAAO,CAAEH,GAAG,IAAK;MACpB,MAAMK,KAAK,GAAGb,KAAK,CAACQ,GAAG,CAAC;MACxB;MACAZ,UAAU,CAACY,GAAG,CAAC,GAAGN,eAAe,CAACM,GAAG,EAAEK,KAAK,EAAEb,KAAK,CAAC,IAAI,KAAK;IAC/D,CAAC,CAAC;IAEF,OAAO;MACLoB,KAAK,EAAE,CAAC1B,IAAI,CAAC4B,IAAI,CAAEd,GAAG,IAAK,CAACZ,UAAU,CAACY,GAAG,CAAC,CAAC;MAC5CZ;IACF,CAAC;EACH;EAEA,OAAO;IACL+B,cAAc;IACdM,cAAc;IACd7B,UAAU;IACVF,eAAe;IACfC;EACF,CAAC;AACH"}
@@ -0,0 +1,14 @@
1
+ {
2
+ "include": ["src"] /* Include only the src directory */,
3
+ "compilerOptions": {
4
+ "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
5
+ "module": "ES6" /* Specify what module code is generated. */,
6
+ "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
7
+ "outDir": "dist",
8
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
9
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
10
+ "strict": true /* Enable all strict type-checking options. */,
11
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */,
12
+ "moduleResolution": "Node"
13
+ }
14
+ }