@strictly/react-form 0.0.1 → 0.0.2

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 +459 -211
  107. package/dist/index.d.cts +153 -111
  108. package/dist/index.d.ts +153 -111
  109. package/dist/index.js +453 -200
  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 +16 -4
  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
@@ -0,0 +1,15 @@
1
+ import { type ComponentType } from 'react'
2
+
3
+ export type ErrorRendererProps<E> = {
4
+ error: E,
5
+ }
6
+
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ export type ErrorRenderer<E = any> = ComponentType<ErrorRendererProps<E>>
9
+
10
+ export function DefaultErrorRenderer({
11
+ error,
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ }: ErrorRendererProps<any>) {
14
+ return error
15
+ }
package/mantine/hooks.tsx CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  } from 'react'
30
30
  import { type AllFieldsOfFields } from 'types/all_fields_of_fields'
31
31
  import { type BooleanFieldsOfFields } from 'types/boolean_fields_of_fields'
32
- import { type ErrorTypeOfField } from 'types/error_type_of_field'
32
+ import { type ErrorOfField } from 'types/error_of_field'
33
33
  import {
34
34
  type Fields,
35
35
  } from 'types/field'
@@ -76,20 +76,6 @@ function SimpleSelect(props: SelectProps & {
76
76
  return <Select {...props} />
77
77
  }
78
78
 
79
- export type ErrorRendererProps<E> = {
80
- error: E,
81
- }
82
-
83
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
- export type ErrorRenderer<E = any> = React.ComponentType<ErrorRendererProps<E>>
85
-
86
- function DefaultErrorRenderer({
87
- error,
88
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- }: ErrorRendererProps<any>) {
90
- return error
91
- }
92
-
93
79
  export function useMantineForm<
94
80
  F extends Fields,
95
81
  >({
@@ -146,27 +132,27 @@ class MantineFormImpl<
146
132
  F extends Fields,
147
133
  > implements MantineForm<F> {
148
134
  private readonly textInputCache: Cache<
149
- [keyof StringFieldsOfFields<F>, ComponentType<SuppliedTextInputProps>, ErrorRenderer],
135
+ [keyof StringFieldsOfFields<F>, ComponentType<SuppliedTextInputProps>],
150
136
  MantineFieldComponent<SuppliedTextInputProps>
151
137
  > = new Cache(
152
138
  createTextInput.bind(this),
153
139
  )
154
140
  private readonly valueInputCache: Cache<
155
141
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
156
- [keyof AllFieldsOfFields<F>, ComponentType<SuppliedValueInputProps<any>>, ErrorRenderer],
142
+ [keyof AllFieldsOfFields<F>, ComponentType<SuppliedValueInputProps<any>>],
157
143
  MantineFieldComponent<SuppliedTextInputProps>
158
144
  > = new Cache(
159
145
  createValueInput.bind(this),
160
146
  )
161
147
 
162
148
  private readonly checkboxCache: Cache<
163
- [keyof BooleanFieldsOfFields<F>, ComponentType<SuppliedCheckboxProps>, ErrorRenderer],
149
+ [keyof BooleanFieldsOfFields<F>, ComponentType<SuppliedCheckboxProps>],
164
150
  MantineFieldComponent<SuppliedCheckboxProps>
165
151
  > = new Cache(
166
152
  createCheckbox.bind(this),
167
153
  )
168
154
  private readonly radioGroupCache: Cache<
169
- [keyof StringFieldsOfFields<F>, ComponentType<SuppliedRadioGroupProps>, ErrorRenderer],
155
+ [keyof StringFieldsOfFields<F>, ComponentType<SuppliedRadioGroupProps>],
170
156
  MantineFieldComponent<SuppliedRadioGroupProps>
171
157
  > = new Cache(
172
158
  createRadioGroup.bind(this),
@@ -211,7 +197,6 @@ class MantineFormImpl<
211
197
  >(
212
198
  valuePath: K,
213
199
  TextInput?: ComponentType<P>,
214
- ErrorRenderer?: ErrorRenderer<ErrorTypeOfField<F[K]>>,
215
200
  ): MantineFieldComponent<SuppliedTextInputProps, P>
216
201
  textInput<
217
202
  K extends keyof StringFieldsOfFields<F>,
@@ -221,15 +206,13 @@ class MantineFormImpl<
221
206
  valuePath: K,
222
207
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
223
208
  TextInput: ComponentType<P> = TextInputImpl as ComponentType<P>,
224
- ErrorRenderer: ErrorRenderer<ErrorTypeOfField<F[K]>> = DefaultErrorRenderer,
225
- ): MantineFieldComponent<SuppliedTextInputProps, P> {
209
+ ): MantineFieldComponent<SuppliedTextInputProps, P, ErrorOfField<F[K]>> {
226
210
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
227
211
  return this.textInputCache.retrieveOrCreate(
228
212
  valuePath,
229
213
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
230
214
  TextInput as ComponentType<SuppliedTextInputProps>,
231
- ErrorRenderer,
232
- ) as MantineFieldComponent<SuppliedTextInputProps, P>
215
+ ) as MantineFieldComponent<SuppliedTextInputProps, P, ErrorOfField<F[K]>>
233
216
  }
234
217
 
235
218
  valueInput<
@@ -239,30 +222,24 @@ class MantineFormImpl<
239
222
  >(
240
223
  valuePath: K,
241
224
  ValueInput: ComponentType<P>,
242
- ErrorRenderer: ErrorRenderer<ErrorTypeOfField<F[K]>> = DefaultErrorRenderer,
243
- ): MantineFieldComponent<SuppliedValueInputProps<ValueTypeOfField<F[K]>>, P> {
225
+ ): MantineFieldComponent<SuppliedValueInputProps<ValueTypeOfField<F[K]>>, P, ErrorOfField<F[K]>> {
244
226
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
245
227
  return this.valueInputCache.retrieveOrCreate(
246
228
  valuePath,
247
229
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
248
230
  ValueInput as ComponentType<SuppliedValueInputProps<ValueTypeOfField<F[K]>>>,
249
- ErrorRenderer,
250
- ) as MantineFieldComponent<SuppliedTextInputProps, P>
231
+ ) as MantineFieldComponent<SuppliedTextInputProps, P, ErrorOfField<F[K]>>
251
232
  }
252
233
 
253
234
  select<
254
235
  K extends keyof StringFieldsOfFields<F>,
255
- >(
256
- valuePath: K,
257
- ErrorRenderer: ErrorRenderer<ErrorTypeOfField<F[K]>> = DefaultErrorRenderer,
258
- ) {
236
+ >(valuePath: K) {
259
237
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
260
238
  return this.valueInputCache.retrieveOrCreate(
261
239
  valuePath,
262
240
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
263
241
  SimpleSelect as ComponentType<SuppliedValueInputProps<ValueTypeOfField<F[K]>>>,
264
- ErrorRenderer,
265
- ) as MantineFieldComponent<SuppliedTextInputProps, ComponentProps<typeof SimpleSelect>>
242
+ ) as MantineFieldComponent<SuppliedTextInputProps, ComponentProps<typeof SimpleSelect>, ErrorOfField<F[K]>>
266
243
  }
267
244
 
268
245
  checkbox<
@@ -274,20 +251,17 @@ class MantineFormImpl<
274
251
  >(
275
252
  valuePath: K,
276
253
  Checkbox: ComponentType<P>,
277
- ErrorRenderer?: ErrorRenderer<ErrorTypeOfField<F[K]>>,
278
- ): MantineFieldComponent<SuppliedCheckboxProps, P>
254
+ ): MantineFieldComponent<SuppliedCheckboxProps, P, ErrorOfField<F[K]>>
279
255
  checkbox<K extends keyof BooleanFieldsOfFields<F>, P extends SuppliedCheckboxProps>(
280
256
  valuePath: K,
281
257
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
282
258
  Checkbox: ComponentType<P> = CheckboxImpl as ComponentType<P>,
283
- ErrorRenderer: ErrorRenderer<ErrorTypeOfField<F[K]>> = DefaultErrorRenderer,
284
- ): MantineFieldComponent<SuppliedCheckboxProps, P> {
259
+ ): MantineFieldComponent<SuppliedCheckboxProps, P, ErrorOfField<F[K]>> {
285
260
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
286
261
  return this.checkboxCache.retrieveOrCreate(
287
262
  valuePath,
288
263
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
289
264
  Checkbox as ComponentType<SuppliedCheckboxProps>,
290
- ErrorRenderer,
291
265
  ) as MantineFieldComponent<SuppliedCheckboxProps, P>
292
266
  }
293
267
 
@@ -300,7 +274,6 @@ class MantineFormImpl<
300
274
  >(
301
275
  valuePath: K,
302
276
  RadioGroup: ComponentType<P>,
303
- ErrorRenderer?: ErrorRenderer<ErrorTypeOfField<F[K]>>,
304
277
  ): MantineFieldComponent<SuppliedRadioGroupProps, P>
305
278
  radioGroup<
306
279
  K extends keyof StringFieldsOfFields<F>,
@@ -309,15 +282,13 @@ class MantineFormImpl<
309
282
  valuePath: K,
310
283
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
311
284
  RadioGroup: ComponentType<P> = RadioImpl.Group as ComponentType<PropsWithChildren<P>>,
312
- ErrorRenderer: ErrorRenderer<ErrorTypeOfField<F[K]>> = DefaultErrorRenderer,
313
- ): MantineFieldComponent<SuppliedRadioGroupProps, P> {
285
+ ): MantineFieldComponent<SuppliedRadioGroupProps, P, ErrorOfField<F[K]>> {
314
286
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
315
287
  return this.radioGroupCache.retrieveOrCreate(
316
288
  valuePath,
317
289
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
318
290
  RadioGroup as ComponentType<SuppliedRadioGroupProps>,
319
- ErrorRenderer,
320
- ) as MantineFieldComponent<SuppliedRadioGroupProps, P>
291
+ ) as MantineFieldComponent<SuppliedRadioGroupProps, P, ErrorOfField<F[K]>>
321
292
  }
322
293
 
323
294
  radio<
@@ -325,7 +296,7 @@ class MantineFormImpl<
325
296
  >(
326
297
  valuePath: K,
327
298
  value: ValueTypeOfField<F[K]>,
328
- ): MantineFieldComponent<SuppliedRadioProps, RadioProps>
299
+ ): MantineFieldComponent<SuppliedRadioProps, RadioProps, ErrorOfField<F[K]>>
329
300
  radio<
330
301
  K extends keyof StringFieldsOfFields<F>,
331
302
  P extends SuppliedRadioProps,
@@ -333,7 +304,7 @@ class MantineFormImpl<
333
304
  valuePath: K,
334
305
  value: ValueTypeOfField<F[K]>,
335
306
  Radio: ComponentType<P>,
336
- ): MantineFieldComponent<SuppliedRadioProps, P>
307
+ ): MantineFieldComponent<SuppliedRadioProps, P, ErrorOfField<F[K]>>
337
308
  radio<
338
309
  K extends keyof StringFieldsOfFields<F>,
339
310
  P extends SuppliedRadioProps,
@@ -342,7 +313,7 @@ class MantineFormImpl<
342
313
  value: ValueTypeOfField<F[K]>,
343
314
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
344
315
  Radio: ComponentType<P> = RadioImpl as ComponentType<P>,
345
- ): MantineFieldComponent<SuppliedRadioProps, P> {
316
+ ): MantineFieldComponent<SuppliedRadioProps, P, ErrorOfField<F[K]>> {
346
317
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
347
318
  return this.radioCache.retrieveOrCreate(
348
319
  valuePath,
@@ -352,7 +323,9 @@ class MantineFormImpl<
352
323
  ) as MantineFieldComponent<SuppliedRadioProps, P>
353
324
  }
354
325
 
355
- pill<K extends keyof AllFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedPillProps, PillProps>
326
+ pill<
327
+ K extends keyof AllFieldsOfFields<F>,
328
+ >(valuePath: K): MantineFieldComponent<SuppliedPillProps, PillProps, ErrorOfField<F[K]>>
356
329
  pill<
357
330
  K extends keyof AllFieldsOfFields<F>,
358
331
  P extends SuppliedPillProps,
@@ -367,13 +340,13 @@ class MantineFormImpl<
367
340
  valuePath: K,
368
341
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
369
342
  Pill: ComponentType<P> = PillImpl as ComponentType<P>,
370
- ): MantineFieldComponent<SuppliedPillProps, P> {
343
+ ): MantineFieldComponent<SuppliedPillProps, P, ErrorOfField<F[K]>> {
371
344
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
372
345
  return this.pillCache.retrieveOrCreate(
373
346
  valuePath,
374
347
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
375
348
  Pill as ComponentType<SuppliedPillProps>,
376
- ) as MantineFieldComponent<SuppliedPillProps, P>
349
+ ) as MantineFieldComponent<SuppliedPillProps, P, ErrorOfField<F[K]>>
377
350
  }
378
351
 
379
352
  list<
@@ -388,7 +361,8 @@ class MantineFormImpl<
388
361
  DefaultList,
389
362
  ) as MantineFieldComponent<
390
363
  SuppliedListProps<ElementOfArray<F[K]>>,
391
- ComponentProps<typeof DefaultList<ElementOfArray<F[K]>>>
364
+ ComponentProps<typeof DefaultList<ElementOfArray<F[K]>>>,
365
+ ErrorOfField<F[K]>
392
366
  >
393
367
  }
394
368
  }
@@ -1,5 +1,68 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
+ exports[`mantine checkbox hooks > renders CustomError 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-checked="true"
13
+ data-label-position="right"
14
+ style="--checkbox-color: var(--mantine-color-blue-filled);"
15
+ >
16
+ <div
17
+ class="m_5f6e695e mantine-Checkbox-body"
18
+ >
19
+ <div
20
+ class="m_26062bec mantine-Checkbox-inner"
21
+ data-label-position="right"
22
+ >
23
+ <input
24
+ checked=""
25
+ class="mantine-focus-auto m_26063560 mantine-Checkbox-input"
26
+ data-error="true"
27
+ id="mantine-0cyk5rcyk"
28
+ name="$"
29
+ type="checkbox"
30
+ />
31
+ <svg
32
+ aria-hidden="true"
33
+ class="m_bf295423 mantine-Checkbox-icon"
34
+ fill="none"
35
+ viewBox="0 0 10 7"
36
+ xmlns="http://www.w3.org/2000/svg"
37
+ >
38
+ <path
39
+ clip-rule="evenodd"
40
+ 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"
41
+ fill="currentColor"
42
+ fill-rule="evenodd"
43
+ />
44
+ </svg>
45
+ </div>
46
+ <div
47
+ class="m_d3ea56bb mantine-Checkbox-labelWrapper"
48
+ >
49
+ <label
50
+ class="m_8ee546b8 mantine-Checkbox-label"
51
+ for="mantine-0cyk5rcyk"
52
+ >
53
+ Checkbox
54
+ </label>
55
+ <p
56
+ class="m_8e8a99cc mantine-Checkbox-error m_8f816625 mantine-InputWrapper-error"
57
+ >
58
+ custom error
59
+ </p>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ </div>
64
+ `;
65
+
3
66
  exports[`mantine checkbox hooks > renders Disabled 1`] = `
4
67
  <div>
5
68
  <style
@@ -58,6 +121,69 @@ exports[`mantine checkbox hooks > renders Disabled 1`] = `
58
121
  </div>
59
122
  `;
60
123
 
124
+ exports[`mantine checkbox hooks > renders Error 1`] = `
125
+ <div>
126
+ <style
127
+ data-mantine-styles="classes"
128
+ >
129
+ @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;}}
130
+ </style>
131
+ <div
132
+ class="m_bf2d988c mantine-Checkbox-root m_5f75b09e mantine-Checkbox-root"
133
+ data-checked="true"
134
+ data-label-position="right"
135
+ style="--checkbox-color: var(--mantine-color-blue-filled);"
136
+ >
137
+ <div
138
+ class="m_5f6e695e mantine-Checkbox-body"
139
+ >
140
+ <div
141
+ class="m_26062bec mantine-Checkbox-inner"
142
+ data-label-position="right"
143
+ >
144
+ <input
145
+ checked=""
146
+ class="mantine-focus-auto m_26063560 mantine-Checkbox-input"
147
+ data-error="true"
148
+ id="mantine-0cyk5rcyk"
149
+ name="$"
150
+ type="checkbox"
151
+ />
152
+ <svg
153
+ aria-hidden="true"
154
+ class="m_bf295423 mantine-Checkbox-icon"
155
+ fill="none"
156
+ viewBox="0 0 10 7"
157
+ xmlns="http://www.w3.org/2000/svg"
158
+ >
159
+ <path
160
+ clip-rule="evenodd"
161
+ 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"
162
+ fill="currentColor"
163
+ fill-rule="evenodd"
164
+ />
165
+ </svg>
166
+ </div>
167
+ <div
168
+ class="m_d3ea56bb mantine-Checkbox-labelWrapper"
169
+ >
170
+ <label
171
+ class="m_8ee546b8 mantine-Checkbox-label"
172
+ for="mantine-0cyk5rcyk"
173
+ >
174
+ Checkbox
175
+ </label>
176
+ <p
177
+ class="m_8e8a99cc mantine-Checkbox-error m_8f816625 mantine-InputWrapper-error"
178
+ >
179
+ error
180
+ </p>
181
+ </div>
182
+ </div>
183
+ </div>
184
+ </div>
185
+ `;
186
+
61
187
  exports[`mantine checkbox hooks > renders Off 1`] = `
62
188
  <div>
63
189
  <style