@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.
- package/.out/core/mobx/field_adapter.d.ts +7 -6
- package/.out/core/mobx/field_adapter_builder.d.ts +12 -13
- package/.out/core/mobx/field_adapter_builder.js +8 -12
- package/.out/core/mobx/field_adapters_of_values.d.ts +4 -0
- package/.out/core/mobx/flattened_adapters_of_fields.d.ts +2 -2
- package/.out/core/mobx/flattened_list_types_of_type.d.ts +8 -0
- package/.out/core/mobx/form_fields_of_field_adapters.d.ts +8 -0
- package/.out/core/mobx/form_presenter.d.ts +21 -24
- package/.out/core/mobx/form_presenter.js +64 -69
- package/.out/core/mobx/merge_field_adapters_with_two_way_converter.d.ts +13 -0
- package/.out/core/mobx/merge_field_adapters_with_two_way_converter.js +11 -0
- package/.out/core/mobx/merge_field_adapters_with_validators.d.ts +11 -0
- package/.out/core/mobx/merge_field_adapters_with_validators.js +45 -0
- package/.out/core/mobx/specs/fixtures.d.ts +7 -0
- package/.out/core/mobx/specs/fixtures.js +20 -0
- package/.out/core/mobx/specs/flattened_adapters_of_fields.tests.js +5 -2
- package/.out/core/mobx/specs/{flattened_list_type_defs_of.tests.js → flattened_list_types_of_types.tests.js} +7 -7
- package/.out/core/mobx/specs/form_presenter.tests.js +162 -60
- package/.out/core/mobx/specs/merge_field_adapters_with_two_way_converter.js +89 -0
- package/.out/core/mobx/specs/merge_field_adapters_with_validators.tests.js +172 -0
- package/.out/core/mobx/types.d.ts +2 -2
- package/.out/field_converters/chain_field_converter.d.ts +3 -3
- package/.out/field_converters/chain_field_converter.js +17 -12
- package/.out/field_converters/identity_converter.d.ts +3 -3
- package/.out/field_converters/identity_converter.js +10 -6
- package/.out/field_converters/integer_to_string_converter.d.ts +5 -4
- package/.out/field_converters/integer_to_string_converter.js +13 -6
- package/.out/field_converters/list_converter.d.ts +2 -2
- package/.out/field_converters/list_converter.js +6 -1
- package/.out/field_converters/maybe_identity_converter.d.ts +3 -3
- package/.out/field_converters/maybe_identity_converter.js +3 -1
- package/.out/field_converters/nullable_to_boolean_converter.d.ts +9 -8
- package/.out/field_converters/nullable_to_boolean_converter.js +13 -7
- package/.out/field_converters/select_value_type_converter.d.ts +20 -15
- package/.out/field_converters/select_value_type_converter.js +29 -14
- package/.out/field_converters/specs/chain_field_converter.tests.d.ts +1 -0
- package/.out/field_converters/specs/chain_field_converter.tests.js +251 -0
- package/.out/field_converters/trimming_string_converter.d.ts +3 -3
- package/.out/field_converters/trimming_string_converter.js +7 -3
- package/.out/field_converters/validating_converter.d.ts +3 -3
- package/.out/field_converters/validating_converter.js +7 -5
- package/.out/index.d.ts +9 -2
- package/.out/index.js +9 -2
- package/.out/mantine/create_checkbox.d.ts +2 -3
- package/.out/mantine/create_checkbox.js +6 -5
- package/.out/mantine/create_pill.js +2 -2
- package/.out/mantine/create_radio.js +1 -1
- package/.out/mantine/create_radio_group.d.ts +2 -3
- package/.out/mantine/create_radio_group.js +4 -3
- package/.out/mantine/create_text_input.d.ts +2 -3
- package/.out/mantine/create_text_input.js +6 -5
- package/.out/mantine/create_value_input.d.ts +2 -3
- package/.out/mantine/create_value_input.js +6 -5
- package/.out/mantine/error_renderer.d.ts +6 -0
- package/.out/mantine/error_renderer.js +5 -0
- package/.out/mantine/hooks.d.ts +9 -13
- package/.out/mantine/hooks.js +10 -15
- package/.out/mantine/specs/checkbox_hooks.stories.d.ts +7 -2
- package/.out/mantine/specs/checkbox_hooks.stories.js +33 -6
- package/.out/mantine/specs/list_hooks.stories.js +2 -2
- package/.out/mantine/specs/radio_group_hooks.stories.d.ts +7 -2
- package/.out/mantine/specs/radio_group_hooks.stories.js +33 -6
- package/.out/mantine/specs/select_hooks.stories.d.ts +8 -2
- package/.out/mantine/specs/select_hooks.stories.js +45 -8
- package/.out/mantine/specs/text_input_hooks.stories.d.ts +5 -1
- package/.out/mantine/specs/text_input_hooks.stories.js +23 -8
- package/.out/mantine/specs/value_input_hooks.stories.d.ts +7 -2
- package/.out/mantine/specs/value_input_hooks.stories.js +49 -15
- package/.out/mantine/types.d.ts +4 -1
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/types/error_of_field.d.ts +2 -0
- package/.out/types/error_of_field.js +1 -0
- package/.out/types/field.d.ts +1 -1
- package/.out/types/field_converters.d.ts +17 -10
- package/.out/types/field_converters.js +5 -5
- package/.out/types/flattened_validators_of_fields.d.ts +8 -0
- package/.out/types/flattened_validators_of_fields.js +1 -0
- package/.out/types/merge_validators.d.ts +7 -0
- package/.out/types/merge_validators.js +38 -0
- package/.out/types/specs/flattened_validators_of_fields.tests.d.ts +1 -0
- package/.out/types/specs/flattened_validators_of_fields.tests.js +16 -0
- package/.out/types/specs/merge_validators.tests.d.ts +1 -0
- package/.out/types/specs/merge_validators.tests.js +192 -0
- package/.out/util/partial.d.ts +11 -5
- package/.out/util/partial.js +55 -15
- package/.turbo/turbo-build.log +9 -9
- package/.turbo/turbo-check-types.log +1 -1
- package/.turbo/turbo-release$colon$exports.log +1 -1
- package/README.md +5 -1
- package/core/mobx/field_adapter.ts +15 -7
- package/core/mobx/field_adapter_builder.ts +39 -75
- package/core/mobx/field_adapters_of_values.ts +17 -0
- package/core/mobx/flattened_adapters_of_fields.ts +3 -3
- package/core/mobx/flattened_list_types_of_type.ts +17 -0
- package/core/mobx/form_fields_of_field_adapters.ts +16 -0
- package/core/mobx/form_presenter.ts +117 -104
- package/core/mobx/merge_field_adapters_with_two_way_converter.ts +68 -0
- package/core/mobx/merge_field_adapters_with_validators.ts +99 -0
- package/core/mobx/specs/fixtures.ts +73 -0
- package/core/mobx/specs/flattened_adapters_of_fields.tests.ts +23 -2
- package/core/mobx/specs/flattened_list_types_of_types.tests.ts +35 -0
- package/core/mobx/specs/form_presenter.tests.ts +248 -124
- package/core/mobx/specs/merge_field_adapters_with_two_way_converter.ts +140 -0
- package/core/mobx/specs/merge_field_adapters_with_validators.tests.ts +259 -0
- package/core/mobx/types.ts +3 -3
- package/dist/index.cjs +459 -211
- package/dist/index.d.cts +153 -111
- package/dist/index.d.ts +153 -111
- package/dist/index.js +453 -200
- package/field_converters/chain_field_converter.ts +37 -23
- package/field_converters/identity_converter.ts +14 -10
- package/field_converters/integer_to_string_converter.ts +15 -9
- package/field_converters/list_converter.ts +8 -3
- package/field_converters/maybe_identity_converter.ts +7 -4
- package/field_converters/nullable_to_boolean_converter.ts +23 -16
- package/field_converters/select_value_type_converter.ts +86 -26
- package/field_converters/specs/chain_field_converter.tests.ts +302 -0
- package/field_converters/trimming_string_converter.ts +11 -6
- package/field_converters/validating_converter.ts +21 -11
- package/index.ts +9 -2
- package/mantine/create_checkbox.tsx +15 -8
- package/mantine/create_list.tsx +1 -4
- package/mantine/create_pill.tsx +2 -2
- package/mantine/create_radio.tsx +1 -1
- package/mantine/create_radio_group.tsx +8 -6
- package/mantine/create_text_input.tsx +20 -8
- package/mantine/create_value_input.tsx +17 -8
- package/mantine/error_renderer.ts +15 -0
- package/mantine/hooks.tsx +25 -51
- package/mantine/specs/__snapshots__/checkbox_hooks.tests.tsx.snap +126 -0
- package/mantine/specs/__snapshots__/radio_group_hooks.tests.tsx.snap +356 -0
- package/mantine/specs/__snapshots__/select_hooks.tests.tsx.snap +208 -12
- package/mantine/specs/__snapshots__/text_input_hooks.tests.tsx.snap +45 -0
- package/mantine/specs/__snapshots__/value_input_hooks.tests.tsx.snap +194 -8
- package/mantine/specs/checkbox_hooks.stories.tsx +47 -7
- package/mantine/specs/list_hooks.stories.tsx +2 -2
- package/mantine/specs/radio_group_hooks.stories.tsx +47 -7
- package/mantine/specs/select_hooks.stories.tsx +55 -8
- package/mantine/specs/text_input_hooks.stories.tsx +32 -7
- package/mantine/specs/value_input_hooks.stories.tsx +57 -16
- package/mantine/types.ts +5 -1
- package/package.json +16 -4
- package/tsconfig.json +1 -0
- package/types/error_of_field.ts +3 -0
- package/types/field.ts +1 -1
- package/types/field_converters.ts +21 -10
- package/types/flattened_validators_of_fields.ts +34 -0
- package/types/merge_validators.ts +80 -0
- package/types/specs/error_type_of_field.tests.ts +2 -2
- package/types/specs/flattened_validators_of_fields.tests.ts +93 -0
- package/types/specs/merge_validators.tests.ts +267 -0
- package/util/partial.tsx +200 -16
- package/.out/core/mobx/flattened_list_type_defs_of.d.ts +0 -8
- package/.out/field_validators/minimum_string_length_field_validator.d.ts +0 -2
- package/.out/field_validators/minimum_string_length_field_validator.js +0 -8
- package/.out/types/error_type_of_field.d.ts +0 -2
- package/.out/types/field_validator.d.ts +0 -3
- package/.out/types/flattened_form_fields_of.d.ts +0 -9
- package/.out/types/specs/flattened_form_fields_of.tests.js +0 -13
- package/core/mobx/flattened_list_type_defs_of.ts +0 -17
- package/core/mobx/specs/flattened_list_type_defs_of.tests.ts +0 -35
- package/field_validators/minimum_string_length_field_validator.ts +0 -13
- package/mantine/specs/__snapshots__/check_box_hooks.tests.tsx.snap +0 -227
- package/types/error_type_of_field.ts +0 -3
- package/types/field_validator.ts +0 -7
- package/types/flattened_form_fields_of.ts +0 -16
- package/types/specs/flattened_form_fields_of.tests.ts +0 -43
- /package/.out/core/mobx/{flattened_list_type_defs_of.js → field_adapters_of_values.js} +0 -0
- /package/.out/core/mobx/{specs/flattened_list_type_defs_of.tests.d.ts → flattened_list_types_of_type.js} +0 -0
- /package/.out/{types/error_type_of_field.js → core/mobx/form_fields_of_field_adapters.js} +0 -0
- /package/.out/{types/field_validator.js → core/mobx/specs/flattened_list_types_of_types.tests.d.ts} +0 -0
- /package/.out/{types/flattened_form_fields_of.js → core/mobx/specs/merge_field_adapters_with_two_way_converter.d.ts} +0 -0
- /package/.out/{types/specs/flattened_form_fields_of.tests.d.ts → core/mobx/specs/merge_field_adapters_with_validators.tests.d.ts} +0 -0
|
@@ -3,10 +3,10 @@ import { JsonInput, NumberInput, Rating, Slider, } from '@mantine/core';
|
|
|
3
3
|
import { action } from '@storybook/addon-actions';
|
|
4
4
|
import { useMantineForm } from 'mantine/hooks';
|
|
5
5
|
import { NUMBER_INPUT_LABEL, SLIDER_LABEL, } from './value_input_constants';
|
|
6
|
-
function Component({ ValueInput,
|
|
6
|
+
function Component({ ValueInput, ErrorRenderer, inputProps, ...props }) {
|
|
7
7
|
const form = useMantineForm(props);
|
|
8
8
|
const ValueInputComponent = form.valueInput('$', ValueInput);
|
|
9
|
-
return (_jsx(ValueInputComponent, { ...
|
|
9
|
+
return (_jsx(ValueInputComponent, { ...inputProps, ErrorRenderer: ErrorRenderer }));
|
|
10
10
|
}
|
|
11
11
|
const meta = {
|
|
12
12
|
component: Component,
|
|
@@ -22,13 +22,13 @@ export const EmptyNumberInput = {
|
|
|
22
22
|
args: {
|
|
23
23
|
fields: {
|
|
24
24
|
$: {
|
|
25
|
-
|
|
26
|
-
required:
|
|
25
|
+
readonly: false,
|
|
26
|
+
required: false,
|
|
27
27
|
value: '',
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
ValueInput: NumberInput,
|
|
31
|
-
|
|
31
|
+
inputProps: {
|
|
32
32
|
label: NUMBER_INPUT_LABEL,
|
|
33
33
|
},
|
|
34
34
|
},
|
|
@@ -37,13 +37,47 @@ export const PopulatedNumberInput = {
|
|
|
37
37
|
args: {
|
|
38
38
|
fields: {
|
|
39
39
|
$: {
|
|
40
|
-
|
|
40
|
+
readonly: false,
|
|
41
41
|
required: false,
|
|
42
42
|
value: 3,
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
ValueInput: NumberInput,
|
|
46
|
-
|
|
46
|
+
inputProps: {
|
|
47
|
+
label: NUMBER_INPUT_LABEL,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
export const RequiredNumberInput = {
|
|
52
|
+
args: {
|
|
53
|
+
fields: {
|
|
54
|
+
$: {
|
|
55
|
+
readonly: false,
|
|
56
|
+
required: true,
|
|
57
|
+
value: 3,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
ValueInput: NumberInput,
|
|
61
|
+
inputProps: {
|
|
62
|
+
label: NUMBER_INPUT_LABEL,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
export const CustomErrorNumberInput = {
|
|
67
|
+
args: {
|
|
68
|
+
fields: {
|
|
69
|
+
$: {
|
|
70
|
+
readonly: false,
|
|
71
|
+
required: false,
|
|
72
|
+
value: 3,
|
|
73
|
+
error: 'an error',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
ValueInput: NumberInput,
|
|
77
|
+
ErrorRenderer: function () {
|
|
78
|
+
return 'a custom error';
|
|
79
|
+
},
|
|
80
|
+
inputProps: {
|
|
47
81
|
label: NUMBER_INPUT_LABEL,
|
|
48
82
|
},
|
|
49
83
|
},
|
|
@@ -52,13 +86,13 @@ export const DisabledNumberInput = {
|
|
|
52
86
|
args: {
|
|
53
87
|
fields: {
|
|
54
88
|
$: {
|
|
55
|
-
|
|
89
|
+
readonly: true,
|
|
56
90
|
required: false,
|
|
57
91
|
value: 3,
|
|
58
92
|
},
|
|
59
93
|
},
|
|
60
94
|
ValueInput: NumberInput,
|
|
61
|
-
|
|
95
|
+
inputProps: {
|
|
62
96
|
label: NUMBER_INPUT_LABEL,
|
|
63
97
|
},
|
|
64
98
|
},
|
|
@@ -67,13 +101,13 @@ export const AnSlider = {
|
|
|
67
101
|
args: {
|
|
68
102
|
fields: {
|
|
69
103
|
$: {
|
|
70
|
-
|
|
104
|
+
readonly: false,
|
|
71
105
|
required: false,
|
|
72
106
|
value: 3,
|
|
73
107
|
},
|
|
74
108
|
},
|
|
75
109
|
ValueInput: Slider,
|
|
76
|
-
|
|
110
|
+
inputProps: {
|
|
77
111
|
label: SLIDER_LABEL,
|
|
78
112
|
min: 1,
|
|
79
113
|
max: 10,
|
|
@@ -98,26 +132,26 @@ export const AnRating = {
|
|
|
98
132
|
args: {
|
|
99
133
|
fields: {
|
|
100
134
|
$: {
|
|
101
|
-
|
|
135
|
+
readonly: false,
|
|
102
136
|
required: false,
|
|
103
137
|
value: 2,
|
|
104
138
|
},
|
|
105
139
|
},
|
|
106
140
|
ValueInput: Rating,
|
|
107
|
-
|
|
141
|
+
inputProps: {},
|
|
108
142
|
},
|
|
109
143
|
};
|
|
110
144
|
export const AnJsonInput = {
|
|
111
145
|
args: {
|
|
112
146
|
fields: {
|
|
113
147
|
$: {
|
|
114
|
-
|
|
148
|
+
readonly: false,
|
|
115
149
|
required: false,
|
|
116
150
|
value: '{}',
|
|
117
151
|
},
|
|
118
152
|
},
|
|
119
153
|
ValueInput: JsonInput,
|
|
120
|
-
|
|
154
|
+
inputProps: {
|
|
121
155
|
rows: 8,
|
|
122
156
|
},
|
|
123
157
|
},
|
package/.out/mantine/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ComponentType } from 'react';
|
|
2
2
|
import { type Fields } from 'types/field';
|
|
3
3
|
import { type UnsafePartialComponent } from 'util/partial';
|
|
4
|
+
import { type ErrorRenderer } from './error_renderer';
|
|
4
5
|
export type MantineForm<F extends Fields> = {
|
|
5
6
|
fields: F;
|
|
6
7
|
onFieldValueChange: (<K extends keyof F>(this: void, key: K, value: F[K]['value']) => void) | undefined;
|
|
@@ -8,4 +9,6 @@ export type MantineForm<F extends Fields> = {
|
|
|
8
9
|
onFieldBlur: ((this: void, key: keyof F) => void) | undefined;
|
|
9
10
|
onFieldSubmit: ((this: void, key: keyof F) => boolean | void) | undefined;
|
|
10
11
|
};
|
|
11
|
-
export type MantineFieldComponent<T, P = T> = UnsafePartialComponent<ComponentType<P>, T
|
|
12
|
+
export type MantineFieldComponent<T, P = T, E = any> = UnsafePartialComponent<ComponentType<P>, T, {
|
|
13
|
+
ErrorRenderer?: ErrorRenderer<E>;
|
|
14
|
+
}>;
|