@strictly/react-form 0.0.7 → 0.0.9
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.
- package/.out/core/mobx/field_adapter_builder.d.ts +4 -0
- package/.out/core/mobx/field_adapter_builder.js +31 -0
- package/.out/core/mobx/hooks.d.ts +5 -1
- package/.out/core/mobx/hooks.js +13 -3
- package/.out/core/mobx/specs/sub_form_field_adapters.tests.js +56 -9
- package/.out/core/mobx/sub_form_field_adapters.d.ts +5 -5
- package/.out/core/mobx/sub_form_field_adapters.js +13 -10
- package/.out/field_converters/chain_field_converter.js +3 -3
- package/.out/field_converters/nullable_to_boolean_converter.d.ts +2 -2
- package/.out/mantine/create_checkbox.js +1 -0
- package/.out/mantine/create_fields_view.d.ts +1 -1
- package/.out/mantine/create_fields_view.js +4 -4
- package/.out/mantine/create_form.d.ts +1 -1
- package/.out/mantine/create_list.d.ts +1 -1
- package/.out/mantine/create_pill.d.ts +1 -1
- package/.out/mantine/create_radio.d.ts +1 -1
- package/.out/mantine/create_radio_group.js +1 -0
- package/.out/mantine/create_text_input.js +7 -2
- package/.out/mantine/create_value_input.js +1 -0
- package/.out/mantine/error_renderer.d.ts +7 -3
- package/.out/mantine/error_renderer.js +1 -1
- package/.out/mantine/hooks.d.ts +9 -9
- package/.out/mantine/specs/checkbox_hooks.stories.d.ts +2 -6
- package/.out/mantine/specs/checkbox_hooks.stories.js +4 -16
- package/.out/mantine/specs/fields_view_hooks.stories.d.ts +1 -1
- package/.out/mantine/specs/fields_view_hooks.stories.js +6 -3
- package/.out/mantine/specs/form_hooks.stories.d.ts +2 -2
- package/.out/mantine/specs/form_hooks.stories.js +4 -1
- package/.out/mantine/specs/radio_group_hooks.stories.d.ts +2 -6
- package/.out/mantine/specs/radio_group_hooks.stories.js +5 -17
- package/.out/mantine/specs/select_hooks.stories.d.ts +2 -6
- package/.out/mantine/specs/select_hooks.stories.js +4 -16
- package/.out/mantine/specs/text_input_hooks.stories.d.ts +2 -5
- package/.out/mantine/specs/text_input_hooks.stories.js +5 -5
- package/.out/mantine/specs/value_input_hooks.stories.d.ts +2 -5
- package/.out/mantine/specs/value_input_hooks.stories.js +5 -5
- package/.out/mantine/types.d.ts +4 -2
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/types/specs/{error_type_of_field.tests.js → error_of_field.tests.js} +1 -1
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-check-types.log +1 -1
- package/core/mobx/field_adapter_builder.ts +71 -0
- package/core/mobx/hooks.ts +24 -6
- package/core/mobx/specs/sub_form_field_adapters.tests.ts +108 -15
- package/core/mobx/sub_form_field_adapters.ts +41 -25
- package/dist/index.cjs +108 -49
- package/dist/index.d.cts +35 -24
- package/dist/index.d.ts +35 -24
- package/dist/index.js +107 -49
- package/field_converters/chain_field_converter.ts +3 -3
- package/field_converters/nullable_to_boolean_converter.ts +2 -3
- package/mantine/create_checkbox.tsx +2 -1
- package/mantine/create_fields_view.tsx +17 -14
- package/mantine/create_form.tsx +2 -2
- package/mantine/create_list.tsx +1 -1
- package/mantine/create_pill.tsx +1 -1
- package/mantine/create_radio.tsx +1 -1
- package/mantine/create_radio_group.tsx +6 -2
- package/mantine/create_text_input.tsx +9 -3
- package/mantine/create_value_input.tsx +2 -1
- package/mantine/error_renderer.ts +13 -4
- package/mantine/hooks.tsx +19 -14
- package/mantine/specs/__snapshots__/checkbox_hooks.tests.tsx.snap +1 -64
- package/mantine/specs/__snapshots__/fields_view_hooks.tests.tsx.snap +52 -52
- package/mantine/specs/__snapshots__/radio_group_hooks.tests.tsx.snap +1 -179
- package/mantine/specs/__snapshots__/select_hooks.tests.tsx.snap +1 -83
- package/mantine/specs/__snapshots__/text_input_hooks.tests.tsx.snap +27 -27
- package/mantine/specs/__snapshots__/value_input_hooks.tests.tsx.snap +31 -31
- package/mantine/specs/checkbox_hooks.stories.tsx +5 -21
- package/mantine/specs/fields_view_hooks.stories.tsx +16 -4
- package/mantine/specs/form_hooks.stories.tsx +10 -3
- package/mantine/specs/radio_group_hooks.stories.tsx +6 -20
- package/mantine/specs/select_hooks.stories.tsx +5 -21
- package/mantine/specs/text_input_hooks.stories.tsx +5 -8
- package/mantine/specs/value_input_hooks.stories.tsx +5 -8
- package/mantine/types.ts +7 -3
- package/package.json +2 -1
- package/types/specs/{error_type_of_field.tests.ts → error_of_field.tests.ts} +1 -1
- /package/.out/types/specs/{error_type_of_field.tests.d.ts → error_of_field.tests.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`mantine checkbox hooks > renders
|
|
3
|
+
exports[`mantine checkbox hooks > renders Disabled 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<style
|
|
6
6
|
data-mantine-styles="classes"
|
|
@@ -9,7 +9,6 @@ exports[`mantine checkbox hooks > renders CustomError 1`] = `
|
|
|
9
9
|
</style>
|
|
10
10
|
<div
|
|
11
11
|
class="m_46b77525 mantine-InputWrapper-root mantine-TextInput-root"
|
|
12
|
-
data-error="true"
|
|
13
12
|
>
|
|
14
13
|
<label
|
|
15
14
|
class="m_8fdc1311 mantine-InputWrapper-label mantine-TextInput-label"
|
|
@@ -20,32 +19,25 @@ exports[`mantine checkbox hooks > renders CustomError 1`] = `
|
|
|
20
19
|
</label>
|
|
21
20
|
<div
|
|
22
21
|
class="m_6c018570 mantine-Input-wrapper mantine-TextInput-wrapper"
|
|
23
|
-
data-
|
|
22
|
+
data-disabled="true"
|
|
24
23
|
data-variant="default"
|
|
25
|
-
style="--input-margin-bottom: calc(var(--mantine-spacing-xs) / 2);"
|
|
26
24
|
>
|
|
27
25
|
<input
|
|
28
|
-
aria-
|
|
29
|
-
aria-invalid="true"
|
|
26
|
+
aria-invalid="false"
|
|
30
27
|
class="m_8fb7ebe7 mantine-Input-input mantine-TextInput-input"
|
|
31
|
-
data-
|
|
28
|
+
data-disabled="true"
|
|
32
29
|
data-variant="default"
|
|
30
|
+
disabled=""
|
|
33
31
|
id="mantine-0cyk5rcyk"
|
|
34
32
|
name="$"
|
|
35
33
|
value="xxx"
|
|
36
34
|
/>
|
|
37
35
|
</div>
|
|
38
|
-
<p
|
|
39
|
-
class="m_8f816625 mantine-InputWrapper-error mantine-TextInput-error"
|
|
40
|
-
id="mantine-0cyk5rcyk-error"
|
|
41
|
-
>
|
|
42
|
-
custom error
|
|
43
|
-
</p>
|
|
44
36
|
</div>
|
|
45
37
|
</div>
|
|
46
38
|
`;
|
|
47
39
|
|
|
48
|
-
exports[`mantine checkbox hooks > renders
|
|
40
|
+
exports[`mantine checkbox hooks > renders Empty 1`] = `
|
|
49
41
|
<div>
|
|
50
42
|
<style
|
|
51
43
|
data-mantine-styles="classes"
|
|
@@ -57,32 +49,29 @@ exports[`mantine checkbox hooks > renders Disabled 1`] = `
|
|
|
57
49
|
>
|
|
58
50
|
<label
|
|
59
51
|
class="m_8fdc1311 mantine-InputWrapper-label mantine-TextInput-label"
|
|
60
|
-
for="mantine-
|
|
61
|
-
id="mantine-
|
|
52
|
+
for="mantine-0px4bipx4"
|
|
53
|
+
id="mantine-0px4bipx4-label"
|
|
62
54
|
>
|
|
63
55
|
Text Input
|
|
64
56
|
</label>
|
|
65
57
|
<div
|
|
66
58
|
class="m_6c018570 mantine-Input-wrapper mantine-TextInput-wrapper"
|
|
67
|
-
data-disabled="true"
|
|
68
59
|
data-variant="default"
|
|
69
60
|
>
|
|
70
61
|
<input
|
|
71
62
|
aria-invalid="false"
|
|
72
63
|
class="m_8fb7ebe7 mantine-Input-input mantine-TextInput-input"
|
|
73
|
-
data-disabled="true"
|
|
74
64
|
data-variant="default"
|
|
75
|
-
|
|
76
|
-
id="mantine-0cyk5rcyk"
|
|
65
|
+
id="mantine-0px4bipx4"
|
|
77
66
|
name="$"
|
|
78
|
-
value="
|
|
67
|
+
value=""
|
|
79
68
|
/>
|
|
80
69
|
</div>
|
|
81
70
|
</div>
|
|
82
71
|
</div>
|
|
83
72
|
`;
|
|
84
73
|
|
|
85
|
-
exports[`mantine checkbox hooks > renders
|
|
74
|
+
exports[`mantine checkbox hooks > renders Error 1`] = `
|
|
86
75
|
<div>
|
|
87
76
|
<style
|
|
88
77
|
data-mantine-styles="classes"
|
|
@@ -91,27 +80,38 @@ exports[`mantine checkbox hooks > renders Empty 1`] = `
|
|
|
91
80
|
</style>
|
|
92
81
|
<div
|
|
93
82
|
class="m_46b77525 mantine-InputWrapper-root mantine-TextInput-root"
|
|
83
|
+
data-error="true"
|
|
94
84
|
>
|
|
95
85
|
<label
|
|
96
86
|
class="m_8fdc1311 mantine-InputWrapper-label mantine-TextInput-label"
|
|
97
|
-
for="mantine-
|
|
98
|
-
id="mantine-
|
|
87
|
+
for="mantine-0cyk5rcyk"
|
|
88
|
+
id="mantine-0cyk5rcyk-label"
|
|
99
89
|
>
|
|
100
90
|
Text Input
|
|
101
91
|
</label>
|
|
102
92
|
<div
|
|
103
93
|
class="m_6c018570 mantine-Input-wrapper mantine-TextInput-wrapper"
|
|
94
|
+
data-error="true"
|
|
104
95
|
data-variant="default"
|
|
96
|
+
style="--input-margin-bottom: calc(var(--mantine-spacing-xs) / 2);"
|
|
105
97
|
>
|
|
106
98
|
<input
|
|
107
|
-
aria-
|
|
99
|
+
aria-describedby="mantine-0cyk5rcyk-error"
|
|
100
|
+
aria-invalid="true"
|
|
108
101
|
class="m_8fb7ebe7 mantine-Input-input mantine-TextInput-input"
|
|
102
|
+
data-error="true"
|
|
109
103
|
data-variant="default"
|
|
110
|
-
id="mantine-
|
|
104
|
+
id="mantine-0cyk5rcyk"
|
|
111
105
|
name="$"
|
|
112
|
-
value=""
|
|
106
|
+
value="xxx"
|
|
113
107
|
/>
|
|
114
108
|
</div>
|
|
109
|
+
<p
|
|
110
|
+
class="m_8f816625 mantine-InputWrapper-error mantine-TextInput-error"
|
|
111
|
+
id="mantine-0cyk5rcyk-error"
|
|
112
|
+
>
|
|
113
|
+
error error
|
|
114
|
+
</p>
|
|
115
115
|
</div>
|
|
116
116
|
</div>
|
|
117
117
|
`;
|
|
@@ -335,7 +335,7 @@ exports[`mantine value input hooks > renders AnSlider 1`] = `
|
|
|
335
335
|
</div>
|
|
336
336
|
`;
|
|
337
337
|
|
|
338
|
-
exports[`mantine value input hooks > renders
|
|
338
|
+
exports[`mantine value input hooks > renders DisabledNumberInput 1`] = `
|
|
339
339
|
<div>
|
|
340
340
|
<style
|
|
341
341
|
data-mantine-styles="classes"
|
|
@@ -344,7 +344,6 @@ exports[`mantine value input hooks > renders CustomErrorNumberInput 1`] = `
|
|
|
344
344
|
</style>
|
|
345
345
|
<div
|
|
346
346
|
class="m_e2f5cd4e m_46b77525 mantine-InputWrapper-root mantine-NumberInput-root"
|
|
347
|
-
data-error="true"
|
|
348
347
|
>
|
|
349
348
|
<label
|
|
350
349
|
class="m_8fdc1311 mantine-InputWrapper-label mantine-NumberInput-label"
|
|
@@ -355,17 +354,17 @@ exports[`mantine value input hooks > renders CustomErrorNumberInput 1`] = `
|
|
|
355
354
|
</label>
|
|
356
355
|
<div
|
|
357
356
|
class="m_6c018570 mantine-Input-wrapper mantine-NumberInput-wrapper"
|
|
358
|
-
data-
|
|
357
|
+
data-disabled="true"
|
|
359
358
|
data-variant="default"
|
|
360
359
|
data-with-right-section="true"
|
|
361
|
-
style="--input-
|
|
360
|
+
style="--input-right-section-width: var(--ni-right-section-width-sm); --input-right-section-pointer-events: none;"
|
|
362
361
|
>
|
|
363
362
|
<input
|
|
364
|
-
aria-
|
|
365
|
-
aria-invalid="true"
|
|
363
|
+
aria-invalid="false"
|
|
366
364
|
class="m_8fb7ebe7 mantine-Input-input mantine-NumberInput-input"
|
|
367
|
-
data-
|
|
365
|
+
data-disabled="true"
|
|
368
366
|
data-variant="default"
|
|
367
|
+
disabled=""
|
|
369
368
|
id="mantine-0cyk5rcyk"
|
|
370
369
|
inputmode="numeric"
|
|
371
370
|
name="$"
|
|
@@ -383,6 +382,7 @@ exports[`mantine value input hooks > renders CustomErrorNumberInput 1`] = `
|
|
|
383
382
|
aria-hidden="true"
|
|
384
383
|
class="mantine-focus-auto m_80b4b171 mantine-NumberInput-control m_87cf2631 mantine-UnstyledButton-root"
|
|
385
384
|
data-direction="up"
|
|
385
|
+
disabled=""
|
|
386
386
|
tabindex="-1"
|
|
387
387
|
type="button"
|
|
388
388
|
>
|
|
@@ -404,6 +404,7 @@ exports[`mantine value input hooks > renders CustomErrorNumberInput 1`] = `
|
|
|
404
404
|
aria-hidden="true"
|
|
405
405
|
class="mantine-focus-auto m_80b4b171 mantine-NumberInput-control m_87cf2631 mantine-UnstyledButton-root"
|
|
406
406
|
data-direction="down"
|
|
407
|
+
disabled=""
|
|
407
408
|
tabindex="-1"
|
|
408
409
|
type="button"
|
|
409
410
|
>
|
|
@@ -423,17 +424,11 @@ exports[`mantine value input hooks > renders CustomErrorNumberInput 1`] = `
|
|
|
423
424
|
</div>
|
|
424
425
|
</div>
|
|
425
426
|
</div>
|
|
426
|
-
<p
|
|
427
|
-
class="m_8f816625 mantine-InputWrapper-error mantine-NumberInput-error"
|
|
428
|
-
id="mantine-0cyk5rcyk-error"
|
|
429
|
-
>
|
|
430
|
-
a custom error
|
|
431
|
-
</p>
|
|
432
427
|
</div>
|
|
433
428
|
</div>
|
|
434
429
|
`;
|
|
435
430
|
|
|
436
|
-
exports[`mantine value input hooks > renders
|
|
431
|
+
exports[`mantine value input hooks > renders EmptyNumberInput 1`] = `
|
|
437
432
|
<div>
|
|
438
433
|
<style
|
|
439
434
|
data-mantine-styles="classes"
|
|
@@ -445,29 +440,26 @@ exports[`mantine value input hooks > renders DisabledNumberInput 1`] = `
|
|
|
445
440
|
>
|
|
446
441
|
<label
|
|
447
442
|
class="m_8fdc1311 mantine-InputWrapper-label mantine-NumberInput-label"
|
|
448
|
-
for="mantine-
|
|
449
|
-
id="mantine-
|
|
443
|
+
for="mantine-0px4bipx4"
|
|
444
|
+
id="mantine-0px4bipx4-label"
|
|
450
445
|
>
|
|
451
446
|
Number Input
|
|
452
447
|
</label>
|
|
453
448
|
<div
|
|
454
449
|
class="m_6c018570 mantine-Input-wrapper mantine-NumberInput-wrapper"
|
|
455
|
-
data-disabled="true"
|
|
456
450
|
data-variant="default"
|
|
457
451
|
data-with-right-section="true"
|
|
458
|
-
style="--input-right-section-width: var(--ni-right-section-width-sm);
|
|
452
|
+
style="--input-right-section-width: var(--ni-right-section-width-sm);"
|
|
459
453
|
>
|
|
460
454
|
<input
|
|
461
455
|
aria-invalid="false"
|
|
462
456
|
class="m_8fb7ebe7 mantine-Input-input mantine-NumberInput-input"
|
|
463
|
-
data-disabled="true"
|
|
464
457
|
data-variant="default"
|
|
465
|
-
|
|
466
|
-
id="mantine-0cyk5rcyk"
|
|
458
|
+
id="mantine-0px4bipx4"
|
|
467
459
|
inputmode="numeric"
|
|
468
460
|
name="$"
|
|
469
461
|
type="text"
|
|
470
|
-
value="
|
|
462
|
+
value=""
|
|
471
463
|
/>
|
|
472
464
|
<div
|
|
473
465
|
class="m_82577fc2 mantine-Input-section mantine-NumberInput-section"
|
|
@@ -480,7 +472,6 @@ exports[`mantine value input hooks > renders DisabledNumberInput 1`] = `
|
|
|
480
472
|
aria-hidden="true"
|
|
481
473
|
class="mantine-focus-auto m_80b4b171 mantine-NumberInput-control m_87cf2631 mantine-UnstyledButton-root"
|
|
482
474
|
data-direction="up"
|
|
483
|
-
disabled=""
|
|
484
475
|
tabindex="-1"
|
|
485
476
|
type="button"
|
|
486
477
|
>
|
|
@@ -502,7 +493,6 @@ exports[`mantine value input hooks > renders DisabledNumberInput 1`] = `
|
|
|
502
493
|
aria-hidden="true"
|
|
503
494
|
class="mantine-focus-auto m_80b4b171 mantine-NumberInput-control m_87cf2631 mantine-UnstyledButton-root"
|
|
504
495
|
data-direction="down"
|
|
505
|
-
disabled=""
|
|
506
496
|
tabindex="-1"
|
|
507
497
|
type="button"
|
|
508
498
|
>
|
|
@@ -526,7 +516,7 @@ exports[`mantine value input hooks > renders DisabledNumberInput 1`] = `
|
|
|
526
516
|
</div>
|
|
527
517
|
`;
|
|
528
518
|
|
|
529
|
-
exports[`mantine value input hooks > renders
|
|
519
|
+
exports[`mantine value input hooks > renders ErrorNumberInput 1`] = `
|
|
530
520
|
<div>
|
|
531
521
|
<style
|
|
532
522
|
data-mantine-styles="classes"
|
|
@@ -535,29 +525,33 @@ exports[`mantine value input hooks > renders EmptyNumberInput 1`] = `
|
|
|
535
525
|
</style>
|
|
536
526
|
<div
|
|
537
527
|
class="m_e2f5cd4e m_46b77525 mantine-InputWrapper-root mantine-NumberInput-root"
|
|
528
|
+
data-error="true"
|
|
538
529
|
>
|
|
539
530
|
<label
|
|
540
531
|
class="m_8fdc1311 mantine-InputWrapper-label mantine-NumberInput-label"
|
|
541
|
-
for="mantine-
|
|
542
|
-
id="mantine-
|
|
532
|
+
for="mantine-0cyk5rcyk"
|
|
533
|
+
id="mantine-0cyk5rcyk-label"
|
|
543
534
|
>
|
|
544
535
|
Number Input
|
|
545
536
|
</label>
|
|
546
537
|
<div
|
|
547
538
|
class="m_6c018570 mantine-Input-wrapper mantine-NumberInput-wrapper"
|
|
539
|
+
data-error="true"
|
|
548
540
|
data-variant="default"
|
|
549
541
|
data-with-right-section="true"
|
|
550
|
-
style="--input-right-section-width: var(--ni-right-section-width-sm);"
|
|
542
|
+
style="--input-margin-bottom: calc(var(--mantine-spacing-xs) / 2); --input-right-section-width: var(--ni-right-section-width-sm);"
|
|
551
543
|
>
|
|
552
544
|
<input
|
|
553
|
-
aria-
|
|
545
|
+
aria-describedby="mantine-0cyk5rcyk-error"
|
|
546
|
+
aria-invalid="true"
|
|
554
547
|
class="m_8fb7ebe7 mantine-Input-input mantine-NumberInput-input"
|
|
548
|
+
data-error="true"
|
|
555
549
|
data-variant="default"
|
|
556
|
-
id="mantine-
|
|
550
|
+
id="mantine-0cyk5rcyk"
|
|
557
551
|
inputmode="numeric"
|
|
558
552
|
name="$"
|
|
559
553
|
type="text"
|
|
560
|
-
value=""
|
|
554
|
+
value="3"
|
|
561
555
|
/>
|
|
562
556
|
<div
|
|
563
557
|
class="m_82577fc2 mantine-Input-section mantine-NumberInput-section"
|
|
@@ -610,6 +604,12 @@ exports[`mantine value input hooks > renders EmptyNumberInput 1`] = `
|
|
|
610
604
|
</div>
|
|
611
605
|
</div>
|
|
612
606
|
</div>
|
|
607
|
+
<p
|
|
608
|
+
class="m_8f816625 mantine-InputWrapper-error mantine-NumberInput-error"
|
|
609
|
+
id="mantine-0cyk5rcyk-error"
|
|
610
|
+
>
|
|
611
|
+
error an error
|
|
612
|
+
</p>
|
|
613
613
|
</div>
|
|
614
614
|
</div>
|
|
615
615
|
`;
|
|
@@ -4,19 +4,19 @@ import {
|
|
|
4
4
|
type StoryObj,
|
|
5
5
|
} from '@storybook/react'
|
|
6
6
|
import { type FieldsViewProps } from 'core/props'
|
|
7
|
-
import { type ErrorRenderer } from 'mantine/error_renderer'
|
|
8
7
|
import { useMantineFormFields } from 'mantine/hooks'
|
|
9
8
|
import { type Field } from 'types/field'
|
|
10
9
|
import { CHECKBOX_LABEL } from './checkbox_constants'
|
|
11
10
|
|
|
11
|
+
function ErrorRenderer({ error }: { error: string }) {
|
|
12
|
+
return `Error ${error}`
|
|
13
|
+
}
|
|
14
|
+
|
|
12
15
|
function Component({
|
|
13
|
-
ErrorRenderer,
|
|
14
16
|
...props
|
|
15
17
|
}: FieldsViewProps<{
|
|
16
18
|
$: Field<boolean, string>,
|
|
17
|
-
}>
|
|
18
|
-
ErrorRenderer?: ErrorRenderer,
|
|
19
|
-
}) {
|
|
19
|
+
}>) {
|
|
20
20
|
const inputProps = useMantineFormFields(props)
|
|
21
21
|
const CheckboxComponent = inputProps.checkbox('$')
|
|
22
22
|
return (
|
|
@@ -101,19 +101,3 @@ export const Error: Story = {
|
|
|
101
101
|
},
|
|
102
102
|
},
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
export const CustomError: Story = {
|
|
106
|
-
args: {
|
|
107
|
-
fields: {
|
|
108
|
-
$: {
|
|
109
|
-
readonly: false,
|
|
110
|
-
required: false,
|
|
111
|
-
value: true,
|
|
112
|
-
error: 'error',
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
ErrorRenderer: function () {
|
|
116
|
-
return 'custom error'
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
}
|
|
@@ -13,6 +13,10 @@ import { type Field } from 'types/field'
|
|
|
13
13
|
|
|
14
14
|
const onClick = action('some button clicked')
|
|
15
15
|
|
|
16
|
+
function ErrorRenderer({ error }: { error: string }) {
|
|
17
|
+
return `error ${error}`
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
function SubFieldsView(props: FieldsViewProps<{
|
|
17
21
|
$: Field<string, string>,
|
|
18
22
|
}> & {
|
|
@@ -22,7 +26,10 @@ function SubFieldsView(props: FieldsViewProps<{
|
|
|
22
26
|
const TextInput = form.textInput('$')
|
|
23
27
|
return (
|
|
24
28
|
<Stack>
|
|
25
|
-
<TextInput
|
|
29
|
+
<TextInput
|
|
30
|
+
ErrorRenderer={ErrorRenderer}
|
|
31
|
+
label='sub fields view'
|
|
32
|
+
/>
|
|
26
33
|
<Button onClick={props.onClick}>
|
|
27
34
|
Bonus Button
|
|
28
35
|
</Button>
|
|
@@ -39,8 +46,13 @@ function Component(props: FieldsViewProps<{
|
|
|
39
46
|
const TextInput = form.textInput('$')
|
|
40
47
|
return (
|
|
41
48
|
<Stack>
|
|
42
|
-
<TextInput
|
|
43
|
-
|
|
49
|
+
<TextInput
|
|
50
|
+
ErrorRenderer={ErrorRenderer}
|
|
51
|
+
label='fields view'
|
|
52
|
+
/>
|
|
53
|
+
<FieldsView
|
|
54
|
+
onClick={onClick}
|
|
55
|
+
/>
|
|
44
56
|
</Stack>
|
|
45
57
|
)
|
|
46
58
|
}
|
|
@@ -127,7 +139,7 @@ export const Disabled: Story = {
|
|
|
127
139
|
},
|
|
128
140
|
}
|
|
129
141
|
|
|
130
|
-
export const
|
|
142
|
+
export const Errors: Story = {
|
|
131
143
|
args: {
|
|
132
144
|
fields: {
|
|
133
145
|
$: {
|
|
@@ -18,6 +18,10 @@ import { type Field } from 'types/field'
|
|
|
18
18
|
|
|
19
19
|
const onCancel = action('canceled')
|
|
20
20
|
|
|
21
|
+
function ErrorRenderer({ error }: { error: string }) {
|
|
22
|
+
return `error ${error}`
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
function SubForm({
|
|
22
26
|
value,
|
|
23
27
|
onValueChange,
|
|
@@ -44,15 +48,18 @@ function SubForm({
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
function Component(props: FieldsViewProps<{
|
|
47
|
-
$: Field<string>,
|
|
48
|
-
'$.a': Field<number>,
|
|
51
|
+
$: Field<string, string>,
|
|
52
|
+
'$.a': Field<number, string>,
|
|
49
53
|
}>) {
|
|
50
54
|
const form = useMantineFormFields(props)
|
|
51
55
|
const Form = form.form('$.a', SubForm)
|
|
52
56
|
const TextInput = form.textInput('$')
|
|
53
57
|
return (
|
|
54
58
|
<Stack>
|
|
55
|
-
<TextInput
|
|
59
|
+
<TextInput
|
|
60
|
+
ErrorRenderer={ErrorRenderer}
|
|
61
|
+
label='fields view'
|
|
62
|
+
/>
|
|
56
63
|
<Form onCancel={onCancel} />
|
|
57
64
|
</Stack>
|
|
58
65
|
)
|
|
@@ -19,14 +19,15 @@ import {
|
|
|
19
19
|
type RadioValue,
|
|
20
20
|
} from './radio_group_constants'
|
|
21
21
|
|
|
22
|
+
function ErrorRenderer({ error }: { error: string }) {
|
|
23
|
+
return `custom error ${error}`
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
function Component({
|
|
23
|
-
ErrorRenderer,
|
|
24
27
|
...props
|
|
25
28
|
}: FieldsViewProps<{
|
|
26
29
|
$: Field<RadioValue | null, string>,
|
|
27
|
-
}>
|
|
28
|
-
ErrorRenderer?: ErrorRenderer,
|
|
29
|
-
}) {
|
|
30
|
+
}>) {
|
|
30
31
|
const form = useMantineFormFields(props)
|
|
31
32
|
const RadioGroupComponent = form.radioGroup('$')
|
|
32
33
|
|
|
@@ -41,6 +42,7 @@ function Component({
|
|
|
41
42
|
const RadioComponent = form.radio('$', value)
|
|
42
43
|
return (
|
|
43
44
|
<RadioComponent
|
|
45
|
+
ErrorRenderer={ErrorRenderer}
|
|
44
46
|
key={label}
|
|
45
47
|
label={label}
|
|
46
48
|
/>
|
|
@@ -125,19 +127,3 @@ export const Error: Story = {
|
|
|
125
127
|
},
|
|
126
128
|
},
|
|
127
129
|
}
|
|
128
|
-
|
|
129
|
-
export const CustomError: Story = {
|
|
130
|
-
args: {
|
|
131
|
-
fields: {
|
|
132
|
-
$: {
|
|
133
|
-
readonly: false,
|
|
134
|
-
required: false,
|
|
135
|
-
value: '2',
|
|
136
|
-
error: 'error',
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
ErrorRenderer: function () {
|
|
140
|
-
return 'custom error'
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
}
|
|
@@ -4,19 +4,19 @@ import {
|
|
|
4
4
|
type StoryObj,
|
|
5
5
|
} from '@storybook/react'
|
|
6
6
|
import { type FieldsViewProps } from 'core/props'
|
|
7
|
-
import { type ErrorRenderer } from 'mantine/error_renderer'
|
|
8
7
|
import { useMantineFormFields } from 'mantine/hooks'
|
|
9
8
|
import { type Field } from 'types/field'
|
|
10
9
|
import { SELECT_LABEL } from './select_hooks_constant'
|
|
11
10
|
|
|
11
|
+
function ErrorRenderer({ error }: { error: string }) {
|
|
12
|
+
return `Error ${error}`
|
|
13
|
+
}
|
|
14
|
+
|
|
12
15
|
function Component({
|
|
13
|
-
ErrorRenderer,
|
|
14
16
|
...props
|
|
15
17
|
}: FieldsViewProps<{
|
|
16
18
|
$: Field<string | null, string>,
|
|
17
|
-
}>
|
|
18
|
-
ErrorRenderer?: ErrorRenderer,
|
|
19
|
-
}) {
|
|
19
|
+
}>) {
|
|
20
20
|
const form = useMantineFormFields(props)
|
|
21
21
|
const SelectComponent = form.select('$')
|
|
22
22
|
return (
|
|
@@ -106,19 +106,3 @@ export const DisabledSelect: Story = {
|
|
|
106
106
|
},
|
|
107
107
|
},
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
export const CustomErrorSelect: Story = {
|
|
111
|
-
args: {
|
|
112
|
-
fields: {
|
|
113
|
-
$: {
|
|
114
|
-
readonly: false,
|
|
115
|
-
required: true,
|
|
116
|
-
value: 'c',
|
|
117
|
-
error: 'error',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
ErrorRenderer: function () {
|
|
121
|
-
return 'custom error'
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
}
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
type SuppliedTextInputProps,
|
|
14
14
|
type TextInputTarget,
|
|
15
15
|
} from 'mantine/create_text_input'
|
|
16
|
-
import { type ErrorRenderer } from 'mantine/error_renderer'
|
|
17
16
|
import { useMantineFormFields } from 'mantine/hooks'
|
|
18
17
|
import { type ComponentType } from 'react'
|
|
19
18
|
import { type Field } from 'types/field'
|
|
@@ -21,16 +20,17 @@ import { TEXT_INPUT_LABEL } from './text_input_constants'
|
|
|
21
20
|
|
|
22
21
|
type StoryTextInputProps<T extends TextInputTarget> = SuppliedTextInputProps<T> & Pick<TextInputProps, 'label'>
|
|
23
22
|
|
|
23
|
+
function ErrorRenderer({ error }: { error: string }) {
|
|
24
|
+
return `error ${error}`
|
|
25
|
+
}
|
|
26
|
+
|
|
24
27
|
function Component<T extends TextInputTarget>({
|
|
25
28
|
TextInput,
|
|
26
|
-
ErrorRenderer,
|
|
27
29
|
...props
|
|
28
30
|
}: FieldsViewProps<{
|
|
29
31
|
$: Field<string, string>,
|
|
30
32
|
}> & {
|
|
31
33
|
TextInput?: ComponentType<StoryTextInputProps<T>>,
|
|
32
|
-
} & {
|
|
33
|
-
ErrorRenderer?: ErrorRenderer,
|
|
34
34
|
}) {
|
|
35
35
|
const form = useMantineFormFields(props)
|
|
36
36
|
const TextInputComponent = form.textInput<'$', StoryTextInputProps<T>>('$', TextInput)
|
|
@@ -106,7 +106,7 @@ export const Disabled: Story = {
|
|
|
106
106
|
},
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
export const
|
|
109
|
+
export const Error: Story = {
|
|
110
110
|
args: {
|
|
111
111
|
fields: {
|
|
112
112
|
$: {
|
|
@@ -116,9 +116,6 @@ export const CustomError: Story = {
|
|
|
116
116
|
error: 'error',
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
|
-
ErrorRenderer: function () {
|
|
120
|
-
return 'custom error'
|
|
121
|
-
},
|
|
122
119
|
},
|
|
123
120
|
}
|
|
124
121
|
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
} from '@storybook/react'
|
|
16
16
|
import { type FieldsViewProps } from 'core/props'
|
|
17
17
|
import { type SuppliedValueInputProps } from 'mantine/create_value_input'
|
|
18
|
-
import { type ErrorRenderer } from 'mantine/error_renderer'
|
|
19
18
|
import { useMantineFormFields } from 'mantine/hooks'
|
|
20
19
|
import {
|
|
21
20
|
type ComponentType,
|
|
@@ -26,6 +25,10 @@ import {
|
|
|
26
25
|
SLIDER_LABEL,
|
|
27
26
|
} from './value_input_constants'
|
|
28
27
|
|
|
28
|
+
function ErrorRenderer({ error }: { error: string }) {
|
|
29
|
+
return `error ${error}`
|
|
30
|
+
}
|
|
31
|
+
|
|
29
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
33
|
type StoryValueInputProps<V> = SuppliedValueInputProps<V, any>
|
|
31
34
|
|
|
@@ -34,7 +37,6 @@ function Component<
|
|
|
34
37
|
P extends StoryValueInputProps<V>,
|
|
35
38
|
>({
|
|
36
39
|
ValueInput,
|
|
37
|
-
ErrorRenderer,
|
|
38
40
|
inputProps,
|
|
39
41
|
...props
|
|
40
42
|
}: FieldsViewProps<{
|
|
@@ -43,8 +45,6 @@ function Component<
|
|
|
43
45
|
ValueInput: ComponentType<P>,
|
|
44
46
|
} & {
|
|
45
47
|
inputProps: P,
|
|
46
|
-
} & {
|
|
47
|
-
ErrorRenderer?: ErrorRenderer,
|
|
48
48
|
}) {
|
|
49
49
|
const form = useMantineFormFields(props)
|
|
50
50
|
const ValueInputComponent = form.valueInput<'$', P>('$', ValueInput)
|
|
@@ -124,7 +124,7 @@ export const RequiredNumberInput: Story<number | string, NumberInputProps> = {
|
|
|
124
124
|
},
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export const
|
|
127
|
+
export const ErrorNumberInput: Story<number | string, NumberInputProps> = {
|
|
128
128
|
args: {
|
|
129
129
|
fields: {
|
|
130
130
|
$: {
|
|
@@ -135,9 +135,6 @@ export const CustomErrorNumberInput: Story<number | string, NumberInputProps> =
|
|
|
135
135
|
},
|
|
136
136
|
},
|
|
137
137
|
ValueInput: NumberInput,
|
|
138
|
-
ErrorRenderer: function () {
|
|
139
|
-
return 'a custom error'
|
|
140
|
-
},
|
|
141
138
|
inputProps: {
|
|
142
139
|
label: NUMBER_INPUT_LABEL,
|
|
143
140
|
},
|
package/mantine/types.ts
CHANGED
|
@@ -12,6 +12,10 @@ export type MantineForm<F extends Fields> = {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
export type MantineFieldComponent<T, P = T, E = any> = UnsafePartialComponent<
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export type MantineFieldComponent<T, P = T, E = any> = UnsafePartialComponent<
|
|
16
|
+
ComponentType<P>,
|
|
17
|
+
T,
|
|
18
|
+
// escape hatch for never comparisons `E extends never` will not work, always returning never
|
|
19
|
+
// https://github.com/microsoft/TypeScript/issues/31751
|
|
20
|
+
[E] extends [never] ? {} : { ErrorRenderer: ErrorRenderer<E> }
|
|
21
|
+
>
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@storybook/builder-vite": "^8.4.5",
|
|
23
23
|
"@storybook/react": "^8.4.5",
|
|
24
24
|
"@storybook/react-vite": "^8.4.5",
|
|
25
|
+
"@storybook/test": "^8.4.5",
|
|
25
26
|
"@storybook/test-runner": "^0.21.0",
|
|
26
27
|
"@strictly/support-vite": "*",
|
|
27
28
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -69,7 +70,7 @@
|
|
|
69
70
|
"test:watch": "vitest"
|
|
70
71
|
},
|
|
71
72
|
"type": "module",
|
|
72
|
-
"version": "0.0.
|
|
73
|
+
"version": "0.0.9",
|
|
73
74
|
"exports": {
|
|
74
75
|
".": {
|
|
75
76
|
"import": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ErrorOfField } from 'types/error_of_field'
|
|
2
2
|
import { type Field } from 'types/field'
|
|
3
3
|
|
|
4
|
-
describe('
|
|
4
|
+
describe('ErrorOfField', function () {
|
|
5
5
|
it('equals expected type', function () {
|
|
6
6
|
const e = Symbol()
|
|
7
7
|
type E = typeof e
|
|
File without changes
|