@strictly/react-form 0.0.1 → 0.0.3

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 (173) hide show
  1. package/.out/core/mobx/field_adapter.d.ts +7 -6
  2. package/.out/core/mobx/field_adapter_builder.d.ts +12 -13
  3. package/.out/core/mobx/field_adapter_builder.js +8 -12
  4. package/.out/core/mobx/field_adapters_of_values.d.ts +4 -0
  5. package/.out/core/mobx/flattened_adapters_of_fields.d.ts +2 -2
  6. package/.out/core/mobx/flattened_list_types_of_type.d.ts +8 -0
  7. package/.out/core/mobx/form_fields_of_field_adapters.d.ts +8 -0
  8. package/.out/core/mobx/form_presenter.d.ts +21 -24
  9. package/.out/core/mobx/form_presenter.js +64 -69
  10. package/.out/core/mobx/merge_field_adapters_with_two_way_converter.d.ts +13 -0
  11. package/.out/core/mobx/merge_field_adapters_with_two_way_converter.js +11 -0
  12. package/.out/core/mobx/merge_field_adapters_with_validators.d.ts +11 -0
  13. package/.out/core/mobx/merge_field_adapters_with_validators.js +45 -0
  14. package/.out/core/mobx/specs/fixtures.d.ts +7 -0
  15. package/.out/core/mobx/specs/fixtures.js +20 -0
  16. package/.out/core/mobx/specs/flattened_adapters_of_fields.tests.js +5 -2
  17. package/.out/core/mobx/specs/{flattened_list_type_defs_of.tests.js → flattened_list_types_of_types.tests.js} +7 -7
  18. package/.out/core/mobx/specs/form_presenter.tests.js +162 -60
  19. package/.out/core/mobx/specs/merge_field_adapters_with_two_way_converter.js +89 -0
  20. package/.out/core/mobx/specs/merge_field_adapters_with_validators.tests.js +172 -0
  21. package/.out/core/mobx/types.d.ts +2 -2
  22. package/.out/field_converters/chain_field_converter.d.ts +3 -3
  23. package/.out/field_converters/chain_field_converter.js +17 -12
  24. package/.out/field_converters/identity_converter.d.ts +3 -3
  25. package/.out/field_converters/identity_converter.js +10 -6
  26. package/.out/field_converters/integer_to_string_converter.d.ts +5 -4
  27. package/.out/field_converters/integer_to_string_converter.js +13 -6
  28. package/.out/field_converters/list_converter.d.ts +2 -2
  29. package/.out/field_converters/list_converter.js +6 -1
  30. package/.out/field_converters/maybe_identity_converter.d.ts +3 -3
  31. package/.out/field_converters/maybe_identity_converter.js +3 -1
  32. package/.out/field_converters/nullable_to_boolean_converter.d.ts +9 -8
  33. package/.out/field_converters/nullable_to_boolean_converter.js +13 -7
  34. package/.out/field_converters/select_value_type_converter.d.ts +20 -15
  35. package/.out/field_converters/select_value_type_converter.js +29 -14
  36. package/.out/field_converters/specs/chain_field_converter.tests.d.ts +1 -0
  37. package/.out/field_converters/specs/chain_field_converter.tests.js +251 -0
  38. package/.out/field_converters/trimming_string_converter.d.ts +3 -3
  39. package/.out/field_converters/trimming_string_converter.js +7 -3
  40. package/.out/field_converters/validating_converter.d.ts +3 -3
  41. package/.out/field_converters/validating_converter.js +7 -5
  42. package/.out/index.d.ts +9 -2
  43. package/.out/index.js +9 -2
  44. package/.out/mantine/create_checkbox.d.ts +2 -3
  45. package/.out/mantine/create_checkbox.js +6 -5
  46. package/.out/mantine/create_pill.js +2 -2
  47. package/.out/mantine/create_radio.js +1 -1
  48. package/.out/mantine/create_radio_group.d.ts +2 -3
  49. package/.out/mantine/create_radio_group.js +4 -3
  50. package/.out/mantine/create_text_input.d.ts +2 -3
  51. package/.out/mantine/create_text_input.js +6 -5
  52. package/.out/mantine/create_value_input.d.ts +2 -3
  53. package/.out/mantine/create_value_input.js +6 -5
  54. package/.out/mantine/error_renderer.d.ts +6 -0
  55. package/.out/mantine/error_renderer.js +5 -0
  56. package/.out/mantine/hooks.d.ts +9 -13
  57. package/.out/mantine/hooks.js +10 -15
  58. package/.out/mantine/specs/checkbox_hooks.stories.d.ts +7 -2
  59. package/.out/mantine/specs/checkbox_hooks.stories.js +33 -6
  60. package/.out/mantine/specs/list_hooks.stories.js +2 -2
  61. package/.out/mantine/specs/radio_group_hooks.stories.d.ts +7 -2
  62. package/.out/mantine/specs/radio_group_hooks.stories.js +33 -6
  63. package/.out/mantine/specs/select_hooks.stories.d.ts +8 -2
  64. package/.out/mantine/specs/select_hooks.stories.js +45 -8
  65. package/.out/mantine/specs/text_input_hooks.stories.d.ts +5 -1
  66. package/.out/mantine/specs/text_input_hooks.stories.js +23 -8
  67. package/.out/mantine/specs/value_input_hooks.stories.d.ts +7 -2
  68. package/.out/mantine/specs/value_input_hooks.stories.js +49 -15
  69. package/.out/mantine/types.d.ts +4 -1
  70. package/.out/tsconfig.tsbuildinfo +1 -1
  71. package/.out/types/error_of_field.d.ts +2 -0
  72. package/.out/types/error_of_field.js +1 -0
  73. package/.out/types/field.d.ts +1 -1
  74. package/.out/types/field_converters.d.ts +17 -10
  75. package/.out/types/field_converters.js +5 -5
  76. package/.out/types/flattened_validators_of_fields.d.ts +8 -0
  77. package/.out/types/flattened_validators_of_fields.js +1 -0
  78. package/.out/types/merge_validators.d.ts +7 -0
  79. package/.out/types/merge_validators.js +38 -0
  80. package/.out/types/specs/flattened_validators_of_fields.tests.d.ts +1 -0
  81. package/.out/types/specs/flattened_validators_of_fields.tests.js +16 -0
  82. package/.out/types/specs/merge_validators.tests.d.ts +1 -0
  83. package/.out/types/specs/merge_validators.tests.js +192 -0
  84. package/.out/util/partial.d.ts +11 -5
  85. package/.out/util/partial.js +55 -15
  86. package/.turbo/turbo-build.log +9 -9
  87. package/.turbo/turbo-check-types.log +1 -1
  88. package/.turbo/turbo-release$colon$exports.log +1 -1
  89. package/README.md +5 -1
  90. package/core/mobx/field_adapter.ts +15 -7
  91. package/core/mobx/field_adapter_builder.ts +39 -75
  92. package/core/mobx/field_adapters_of_values.ts +17 -0
  93. package/core/mobx/flattened_adapters_of_fields.ts +3 -3
  94. package/core/mobx/flattened_list_types_of_type.ts +17 -0
  95. package/core/mobx/form_fields_of_field_adapters.ts +16 -0
  96. package/core/mobx/form_presenter.ts +117 -104
  97. package/core/mobx/merge_field_adapters_with_two_way_converter.ts +68 -0
  98. package/core/mobx/merge_field_adapters_with_validators.ts +99 -0
  99. package/core/mobx/specs/fixtures.ts +73 -0
  100. package/core/mobx/specs/flattened_adapters_of_fields.tests.ts +23 -2
  101. package/core/mobx/specs/flattened_list_types_of_types.tests.ts +35 -0
  102. package/core/mobx/specs/form_presenter.tests.ts +248 -124
  103. package/core/mobx/specs/merge_field_adapters_with_two_way_converter.ts +140 -0
  104. package/core/mobx/specs/merge_field_adapters_with_validators.tests.ts +259 -0
  105. package/core/mobx/types.ts +3 -3
  106. package/dist/index.cjs +527 -10412
  107. package/dist/index.d.cts +153 -111
  108. package/dist/index.d.ts +153 -111
  109. package/dist/index.js +527 -10420
  110. package/field_converters/chain_field_converter.ts +37 -23
  111. package/field_converters/identity_converter.ts +14 -10
  112. package/field_converters/integer_to_string_converter.ts +15 -9
  113. package/field_converters/list_converter.ts +8 -3
  114. package/field_converters/maybe_identity_converter.ts +7 -4
  115. package/field_converters/nullable_to_boolean_converter.ts +23 -16
  116. package/field_converters/select_value_type_converter.ts +86 -26
  117. package/field_converters/specs/chain_field_converter.tests.ts +302 -0
  118. package/field_converters/trimming_string_converter.ts +11 -6
  119. package/field_converters/validating_converter.ts +21 -11
  120. package/index.ts +9 -2
  121. package/mantine/create_checkbox.tsx +15 -8
  122. package/mantine/create_list.tsx +1 -4
  123. package/mantine/create_pill.tsx +2 -2
  124. package/mantine/create_radio.tsx +1 -1
  125. package/mantine/create_radio_group.tsx +8 -6
  126. package/mantine/create_text_input.tsx +20 -8
  127. package/mantine/create_value_input.tsx +17 -8
  128. package/mantine/error_renderer.ts +15 -0
  129. package/mantine/hooks.tsx +25 -51
  130. package/mantine/specs/__snapshots__/checkbox_hooks.tests.tsx.snap +126 -0
  131. package/mantine/specs/__snapshots__/radio_group_hooks.tests.tsx.snap +356 -0
  132. package/mantine/specs/__snapshots__/select_hooks.tests.tsx.snap +208 -12
  133. package/mantine/specs/__snapshots__/text_input_hooks.tests.tsx.snap +45 -0
  134. package/mantine/specs/__snapshots__/value_input_hooks.tests.tsx.snap +194 -8
  135. package/mantine/specs/checkbox_hooks.stories.tsx +47 -7
  136. package/mantine/specs/list_hooks.stories.tsx +2 -2
  137. package/mantine/specs/radio_group_hooks.stories.tsx +47 -7
  138. package/mantine/specs/select_hooks.stories.tsx +55 -8
  139. package/mantine/specs/text_input_hooks.stories.tsx +32 -7
  140. package/mantine/specs/value_input_hooks.stories.tsx +57 -16
  141. package/mantine/types.ts +5 -1
  142. package/package.json +20 -7
  143. package/tsconfig.json +1 -0
  144. package/types/error_of_field.ts +3 -0
  145. package/types/field.ts +1 -1
  146. package/types/field_converters.ts +21 -10
  147. package/types/flattened_validators_of_fields.ts +34 -0
  148. package/types/merge_validators.ts +80 -0
  149. package/types/specs/error_type_of_field.tests.ts +2 -2
  150. package/types/specs/flattened_validators_of_fields.tests.ts +93 -0
  151. package/types/specs/merge_validators.tests.ts +267 -0
  152. package/util/partial.tsx +200 -16
  153. package/.out/core/mobx/flattened_list_type_defs_of.d.ts +0 -8
  154. package/.out/field_validators/minimum_string_length_field_validator.d.ts +0 -2
  155. package/.out/field_validators/minimum_string_length_field_validator.js +0 -8
  156. package/.out/types/error_type_of_field.d.ts +0 -2
  157. package/.out/types/field_validator.d.ts +0 -3
  158. package/.out/types/flattened_form_fields_of.d.ts +0 -9
  159. package/.out/types/specs/flattened_form_fields_of.tests.js +0 -13
  160. package/core/mobx/flattened_list_type_defs_of.ts +0 -17
  161. package/core/mobx/specs/flattened_list_type_defs_of.tests.ts +0 -35
  162. package/field_validators/minimum_string_length_field_validator.ts +0 -13
  163. package/mantine/specs/__snapshots__/check_box_hooks.tests.tsx.snap +0 -227
  164. package/types/error_type_of_field.ts +0 -3
  165. package/types/field_validator.ts +0 -7
  166. package/types/flattened_form_fields_of.ts +0 -16
  167. package/types/specs/flattened_form_fields_of.tests.ts +0 -43
  168. /package/.out/core/mobx/{flattened_list_type_defs_of.js → field_adapters_of_values.js} +0 -0
  169. /package/.out/core/mobx/{specs/flattened_list_type_defs_of.tests.d.ts → flattened_list_types_of_type.js} +0 -0
  170. /package/.out/{types/error_type_of_field.js → core/mobx/form_fields_of_field_adapters.js} +0 -0
  171. /package/.out/{types/field_validator.js → core/mobx/specs/flattened_list_types_of_types.tests.d.ts} +0 -0
  172. /package/.out/{types/flattened_form_fields_of.js → core/mobx/specs/merge_field_adapters_with_two_way_converter.d.ts} +0 -0
  173. /package/.out/{types/specs/flattened_form_fields_of.tests.d.ts → core/mobx/specs/merge_field_adapters_with_validators.tests.d.ts} +0 -0
@@ -1,35 +0,0 @@
1
- import {
2
- list,
3
- nullType,
4
- numberType,
5
- object,
6
- record,
7
- stringType,
8
- union,
9
- } from '@strictly/define'
10
- import {
11
- type FlattenedListTypeDefsOf,
12
- } from 'core/mobx/flattened_list_type_defs_of'
13
-
14
- describe('FlattenedListTypeDefsOf', function () {
15
- it('filters lists types', function () {
16
- const listTypeDef = list(numberType)
17
- const recordTypeDef = record<typeof stringType, string>(stringType)
18
- const objectTypeDef = object()
19
- const unionTypeDef = union().add('0', numberType).add('1', nullType)
20
- const typeDef = object()
21
- .set('literal', numberType)
22
- .set('list', listTypeDef)
23
- .set('record', recordTypeDef)
24
- .set('object', objectTypeDef)
25
- .set('union', unionTypeDef)
26
-
27
- type F = FlattenedListTypeDefsOf<typeof typeDef>
28
-
29
- type E = {
30
- readonly '$.list': typeof listTypeDef.narrow,
31
- }
32
-
33
- expectTypeOf<F>().toEqualTypeOf<E>()
34
- })
35
- })
@@ -1,13 +0,0 @@
1
- import { type FieldValidator } from 'types/field_validator'
2
-
3
- export function minimumStringLengthFieldValidatorFactory<E, ValuePath extends string, Context>(
4
- minimumLength: number,
5
- error: E,
6
- ): FieldValidator<string, E, ValuePath, Context> {
7
- return function (value: string) {
8
- if (value.length < minimumLength) {
9
- return error
10
- }
11
- return null
12
- }
13
- }
@@ -1,227 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`checkbox mantine hooks > renders Disabled 1`] = `
4
- <div>
5
- <style
6
- data-mantine-styles="classes"
7
- >
8
- @media (max-width: 35.99375em) {.mantine-visible-from-xs {display: none !important;}}@media (min-width: 36em) {.mantine-hidden-from-xs {display: none !important;}}@media (max-width: 47.99375em) {.mantine-visible-from-sm {display: none !important;}}@media (min-width: 48em) {.mantine-hidden-from-sm {display: none !important;}}@media (max-width: 61.99375em) {.mantine-visible-from-md {display: none !important;}}@media (min-width: 62em) {.mantine-hidden-from-md {display: none !important;}}@media (max-width: 74.99375em) {.mantine-visible-from-lg {display: none !important;}}@media (min-width: 75em) {.mantine-hidden-from-lg {display: none !important;}}@media (max-width: 87.99375em) {.mantine-visible-from-xl {display: none !important;}}@media (min-width: 88em) {.mantine-hidden-from-xl {display: none !important;}}
9
- </style>
10
- <div
11
- class="m_bf2d988c mantine-Checkbox-root m_5f75b09e mantine-Checkbox-root"
12
- data-label-position="right"
13
- style="--checkbox-color: var(--mantine-color-blue-filled);"
14
- >
15
- <div
16
- class="m_5f6e695e mantine-Checkbox-body"
17
- >
18
- <div
19
- class="m_26062bec mantine-Checkbox-inner"
20
- data-label-position="right"
21
- >
22
- <input
23
- class="mantine-focus-auto m_26063560 mantine-Checkbox-input"
24
- disabled=""
25
- id="mantine-0px4bipx4"
26
- name="$"
27
- type="checkbox"
28
- />
29
- <svg
30
- aria-hidden="true"
31
- class="m_bf295423 mantine-Checkbox-icon"
32
- fill="none"
33
- viewBox="0 0 10 7"
34
- xmlns="http://www.w3.org/2000/svg"
35
- >
36
- <path
37
- clip-rule="evenodd"
38
- d="M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z"
39
- fill="currentColor"
40
- fill-rule="evenodd"
41
- />
42
- </svg>
43
- </div>
44
- <div
45
- class="m_d3ea56bb mantine-Checkbox-labelWrapper"
46
- data-disabled="true"
47
- >
48
- <label
49
- class="m_8ee546b8 mantine-Checkbox-label"
50
- data-disabled="true"
51
- for="mantine-0px4bipx4"
52
- >
53
- Checkbox
54
- </label>
55
- </div>
56
- </div>
57
- </div>
58
- </div>
59
- `;
60
-
61
- exports[`checkbox mantine hooks > renders Off 1`] = `
62
- <div>
63
- <style
64
- data-mantine-styles="classes"
65
- >
66
- @media (max-width: 35.99375em) {.mantine-visible-from-xs {display: none !important;}}@media (min-width: 36em) {.mantine-hidden-from-xs {display: none !important;}}@media (max-width: 47.99375em) {.mantine-visible-from-sm {display: none !important;}}@media (min-width: 48em) {.mantine-hidden-from-sm {display: none !important;}}@media (max-width: 61.99375em) {.mantine-visible-from-md {display: none !important;}}@media (min-width: 62em) {.mantine-hidden-from-md {display: none !important;}}@media (max-width: 74.99375em) {.mantine-visible-from-lg {display: none !important;}}@media (min-width: 75em) {.mantine-hidden-from-lg {display: none !important;}}@media (max-width: 87.99375em) {.mantine-visible-from-xl {display: none !important;}}@media (min-width: 88em) {.mantine-hidden-from-xl {display: none !important;}}
67
- </style>
68
- <div
69
- class="m_bf2d988c mantine-Checkbox-root m_5f75b09e mantine-Checkbox-root"
70
- data-label-position="right"
71
- style="--checkbox-color: var(--mantine-color-blue-filled);"
72
- >
73
- <div
74
- class="m_5f6e695e mantine-Checkbox-body"
75
- >
76
- <div
77
- class="m_26062bec mantine-Checkbox-inner"
78
- data-label-position="right"
79
- >
80
- <input
81
- class="mantine-focus-auto m_26063560 mantine-Checkbox-input"
82
- id="mantine-12voha2vo"
83
- name="$"
84
- type="checkbox"
85
- />
86
- <svg
87
- aria-hidden="true"
88
- class="m_bf295423 mantine-Checkbox-icon"
89
- fill="none"
90
- viewBox="0 0 10 7"
91
- xmlns="http://www.w3.org/2000/svg"
92
- >
93
- <path
94
- clip-rule="evenodd"
95
- d="M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z"
96
- fill="currentColor"
97
- fill-rule="evenodd"
98
- />
99
- </svg>
100
- </div>
101
- <div
102
- class="m_d3ea56bb mantine-Checkbox-labelWrapper"
103
- >
104
- <label
105
- class="m_8ee546b8 mantine-Checkbox-label"
106
- for="mantine-12voha2vo"
107
- >
108
- Checkbox
109
- </label>
110
- </div>
111
- </div>
112
- </div>
113
- </div>
114
- `;
115
-
116
- exports[`checkbox mantine hooks > renders On 1`] = `
117
- <div>
118
- <style
119
- data-mantine-styles="classes"
120
- >
121
- @media (max-width: 35.99375em) {.mantine-visible-from-xs {display: none !important;}}@media (min-width: 36em) {.mantine-hidden-from-xs {display: none !important;}}@media (max-width: 47.99375em) {.mantine-visible-from-sm {display: none !important;}}@media (min-width: 48em) {.mantine-hidden-from-sm {display: none !important;}}@media (max-width: 61.99375em) {.mantine-visible-from-md {display: none !important;}}@media (min-width: 62em) {.mantine-hidden-from-md {display: none !important;}}@media (max-width: 74.99375em) {.mantine-visible-from-lg {display: none !important;}}@media (min-width: 75em) {.mantine-hidden-from-lg {display: none !important;}}@media (max-width: 87.99375em) {.mantine-visible-from-xl {display: none !important;}}@media (min-width: 88em) {.mantine-hidden-from-xl {display: none !important;}}
122
- </style>
123
- <div
124
- class="m_bf2d988c mantine-Checkbox-root m_5f75b09e mantine-Checkbox-root"
125
- data-checked="true"
126
- data-label-position="right"
127
- style="--checkbox-color: var(--mantine-color-blue-filled);"
128
- >
129
- <div
130
- class="m_5f6e695e mantine-Checkbox-body"
131
- >
132
- <div
133
- class="m_26062bec mantine-Checkbox-inner"
134
- data-label-position="right"
135
- >
136
- <input
137
- checked=""
138
- class="mantine-focus-auto m_26063560 mantine-Checkbox-input"
139
- id="mantine-0px4bipx4"
140
- name="$"
141
- type="checkbox"
142
- />
143
- <svg
144
- aria-hidden="true"
145
- class="m_bf295423 mantine-Checkbox-icon"
146
- fill="none"
147
- viewBox="0 0 10 7"
148
- xmlns="http://www.w3.org/2000/svg"
149
- >
150
- <path
151
- clip-rule="evenodd"
152
- d="M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z"
153
- fill="currentColor"
154
- fill-rule="evenodd"
155
- />
156
- </svg>
157
- </div>
158
- <div
159
- class="m_d3ea56bb mantine-Checkbox-labelWrapper"
160
- >
161
- <label
162
- class="m_8ee546b8 mantine-Checkbox-label"
163
- for="mantine-0px4bipx4"
164
- >
165
- Checkbox
166
- </label>
167
- </div>
168
- </div>
169
- </div>
170
- </div>
171
- `;
172
-
173
- exports[`checkbox mantine hooks > renders Required 1`] = `
174
- <div>
175
- <style
176
- data-mantine-styles="classes"
177
- >
178
- @media (max-width: 35.99375em) {.mantine-visible-from-xs {display: none !important;}}@media (min-width: 36em) {.mantine-hidden-from-xs {display: none !important;}}@media (max-width: 47.99375em) {.mantine-visible-from-sm {display: none !important;}}@media (min-width: 48em) {.mantine-hidden-from-sm {display: none !important;}}@media (max-width: 61.99375em) {.mantine-visible-from-md {display: none !important;}}@media (min-width: 62em) {.mantine-hidden-from-md {display: none !important;}}@media (max-width: 74.99375em) {.mantine-visible-from-lg {display: none !important;}}@media (min-width: 75em) {.mantine-hidden-from-lg {display: none !important;}}@media (max-width: 87.99375em) {.mantine-visible-from-xl {display: none !important;}}@media (min-width: 88em) {.mantine-hidden-from-xl {display: none !important;}}
179
- </style>
180
- <div
181
- class="m_bf2d988c mantine-Checkbox-root m_5f75b09e mantine-Checkbox-root"
182
- data-label-position="right"
183
- style="--checkbox-color: var(--mantine-color-blue-filled);"
184
- >
185
- <div
186
- class="m_5f6e695e mantine-Checkbox-body"
187
- >
188
- <div
189
- class="m_26062bec mantine-Checkbox-inner"
190
- data-label-position="right"
191
- >
192
- <input
193
- class="mantine-focus-auto m_26063560 mantine-Checkbox-input"
194
- id="mantine-0px4bipx4"
195
- name="$"
196
- required=""
197
- type="checkbox"
198
- />
199
- <svg
200
- aria-hidden="true"
201
- class="m_bf295423 mantine-Checkbox-icon"
202
- fill="none"
203
- viewBox="0 0 10 7"
204
- xmlns="http://www.w3.org/2000/svg"
205
- >
206
- <path
207
- clip-rule="evenodd"
208
- d="M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z"
209
- fill="currentColor"
210
- fill-rule="evenodd"
211
- />
212
- </svg>
213
- </div>
214
- <div
215
- class="m_d3ea56bb mantine-Checkbox-labelWrapper"
216
- >
217
- <label
218
- class="m_8ee546b8 mantine-Checkbox-label"
219
- for="mantine-0px4bipx4"
220
- >
221
- Checkbox
222
- </label>
223
- </div>
224
- </div>
225
- </div>
226
- </div>
227
- `;
@@ -1,3 +0,0 @@
1
- import { type Field } from './field'
2
-
3
- export type ErrorTypeOfField<F extends Field> = F extends Field<infer _V, infer E> ? E : never
@@ -1,7 +0,0 @@
1
- export type FieldValidator<V, E, ValuePath extends string, Context> = {
2
- (
3
- value: V,
4
- valuePath: ValuePath,
5
- context: Context,
6
- ): E | null,
7
- }
@@ -1,16 +0,0 @@
1
- import { type PrintableOf } from '@strictly/base'
2
- import { type ValueOf } from 'type-fest'
3
- import { type Field } from './field'
4
-
5
- /**
6
- * Maps type paths to value paths for
7
- */
8
- export type FlattenedFormFieldsOf<
9
- JsonPaths extends Record<string, string>,
10
- TypePathsToFormFields extends Partial<Readonly<Record<ValueOf<JsonPaths>, Field>>>,
11
- > = keyof TypePathsToFormFields extends ValueOf<JsonPaths> ? {
12
- readonly [K in keyof JsonPaths as unknown extends TypePathsToFormFields[JsonPaths[K]] ? never : K]:
13
- TypePathsToFormFields[JsonPaths[K]]
14
- }
15
- // TODO is there a better way of enforcing the types are a subset?
16
- : `fields missing paths: ${PrintableOf<Exclude<keyof TypePathsToFormFields, ValueOf<JsonPaths>>>}`
@@ -1,43 +0,0 @@
1
- import { type Field } from 'types/field'
2
- import { type FlattenedFormFieldsOf } from 'types/flattened_form_fields_of'
3
-
4
- describe('FlattenedFormFieldsOf', function () {
5
- describe('subset', function () {
6
- it('equals expected type', function () {
7
- type T = FlattenedFormFieldsOf<
8
- {
9
- readonly a: 'x',
10
- readonly b: 'y',
11
- readonly c: 'z',
12
- },
13
- {
14
- readonly x: Field<1, string>,
15
- readonly z: Field<3, string>,
16
- }
17
- >
18
-
19
- expectTypeOf<T>().toEqualTypeOf<{
20
- readonly a: Field<1, string>,
21
- readonly c: Field<3, string>,
22
- }>()
23
- })
24
- })
25
-
26
- describe('overlap', function () {
27
- it('errors to callee', function () {
28
- type T = FlattenedFormFieldsOf<
29
- {
30
- readonly a: 'x',
31
- readonly b: 'y',
32
- readonly c: 'z',
33
- },
34
- {
35
- readonly w: Field<0, string>,
36
- readonly x: Field<1, string>,
37
- }
38
- >
39
-
40
- expectTypeOf<T>().toEqualTypeOf<'fields missing paths: w'>()
41
- })
42
- })
43
- })