@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.
- 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 +527 -10412
- package/dist/index.d.cts +153 -111
- package/dist/index.d.ts +153 -111
- package/dist/index.js +527 -10420
- 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 +20 -7
- 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
package/.out/mantine/hooks.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type FormProps } from 'core/props';
|
|
|
4
4
|
import { type ComponentProps, type ComponentType } from 'react';
|
|
5
5
|
import { type AllFieldsOfFields } from 'types/all_fields_of_fields';
|
|
6
6
|
import { type BooleanFieldsOfFields } from 'types/boolean_fields_of_fields';
|
|
7
|
-
import { type
|
|
7
|
+
import { type ErrorOfField } from 'types/error_of_field';
|
|
8
8
|
import { type Fields } from 'types/field';
|
|
9
9
|
import { type ListFieldsOfFields } from 'types/list_fields_of_fields';
|
|
10
10
|
import { type StringFieldsOfFields } from 'types/string_fields_of_fields';
|
|
@@ -20,10 +20,6 @@ import { type MantineFieldComponent, type MantineForm } from './types';
|
|
|
20
20
|
declare function SimpleSelect(props: SelectProps & {
|
|
21
21
|
onChange?: (value: string | null) => void;
|
|
22
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
export type ErrorRendererProps<E> = {
|
|
24
|
-
error: E;
|
|
25
|
-
};
|
|
26
|
-
export type ErrorRenderer<E = any> = React.ComponentType<ErrorRendererProps<E>>;
|
|
27
23
|
export declare function useMantineForm<F extends Fields>({ onFieldValueChange, onFieldBlur, onFieldFocus, onFieldSubmit, fields, }: FormProps<F>): MantineFormImpl<F>;
|
|
28
24
|
declare class MantineFormImpl<F extends Fields> implements MantineForm<F> {
|
|
29
25
|
private readonly textInputCache;
|
|
@@ -40,16 +36,16 @@ declare class MantineFormImpl<F extends Fields> implements MantineForm<F> {
|
|
|
40
36
|
onFieldSubmit: ((this: void, key: keyof F) => boolean | void) | undefined;
|
|
41
37
|
constructor(fields: F);
|
|
42
38
|
textInput<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedTextInputProps, TextInputProps>;
|
|
43
|
-
textInput<K extends keyof StringFieldsOfFields<F>, P extends SuppliedTextInputProps<any>>(valuePath: K, TextInput?: ComponentType<P
|
|
44
|
-
valueInput<K extends keyof AllFieldsOfFields<F>, P extends SuppliedValueInputProps<ValueTypeOfField<F[K]>, any>>(valuePath: K, ValueInput: ComponentType<P
|
|
45
|
-
select<K extends keyof StringFieldsOfFields<F>>(valuePath: K
|
|
39
|
+
textInput<K extends keyof StringFieldsOfFields<F>, P extends SuppliedTextInputProps<any>>(valuePath: K, TextInput?: ComponentType<P>): MantineFieldComponent<SuppliedTextInputProps, P>;
|
|
40
|
+
valueInput<K extends keyof AllFieldsOfFields<F>, P extends SuppliedValueInputProps<ValueTypeOfField<F[K]>, any>>(valuePath: K, ValueInput: ComponentType<P>): MantineFieldComponent<SuppliedValueInputProps<ValueTypeOfField<F[K]>>, P, ErrorOfField<F[K]>>;
|
|
41
|
+
select<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedTextInputProps, ComponentProps<typeof SimpleSelect>, ErrorOfField<F[K]>>;
|
|
46
42
|
checkbox<K extends keyof BooleanFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedCheckboxProps, CheckboxProps>;
|
|
47
|
-
checkbox<K extends keyof BooleanFieldsOfFields<F>, P extends SuppliedCheckboxProps>(valuePath: K, Checkbox: ComponentType<P
|
|
43
|
+
checkbox<K extends keyof BooleanFieldsOfFields<F>, P extends SuppliedCheckboxProps>(valuePath: K, Checkbox: ComponentType<P>): MantineFieldComponent<SuppliedCheckboxProps, P, ErrorOfField<F[K]>>;
|
|
48
44
|
radioGroup<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedRadioGroupProps, RadioGroupProps>;
|
|
49
|
-
radioGroup<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioGroupProps>(valuePath: K, RadioGroup: ComponentType<P
|
|
50
|
-
radio<K extends keyof StringFieldsOfFields<F>>(valuePath: K, value: ValueTypeOfField<F[K]>): MantineFieldComponent<SuppliedRadioProps, RadioProps
|
|
51
|
-
radio<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioProps>(valuePath: K, value: ValueTypeOfField<F[K]>, Radio: ComponentType<P>): MantineFieldComponent<SuppliedRadioProps, P
|
|
52
|
-
pill<K extends keyof AllFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedPillProps, PillProps
|
|
45
|
+
radioGroup<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioGroupProps>(valuePath: K, RadioGroup: ComponentType<P>): MantineFieldComponent<SuppliedRadioGroupProps, P>;
|
|
46
|
+
radio<K extends keyof StringFieldsOfFields<F>>(valuePath: K, value: ValueTypeOfField<F[K]>): MantineFieldComponent<SuppliedRadioProps, RadioProps, ErrorOfField<F[K]>>;
|
|
47
|
+
radio<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioProps>(valuePath: K, value: ValueTypeOfField<F[K]>, Radio: ComponentType<P>): MantineFieldComponent<SuppliedRadioProps, P, ErrorOfField<F[K]>>;
|
|
48
|
+
pill<K extends keyof AllFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedPillProps, PillProps, ErrorOfField<F[K]>>;
|
|
53
49
|
pill<K extends keyof AllFieldsOfFields<F>, P extends SuppliedPillProps>(valuePath: K, Pill: ComponentType<P>): MantineFieldComponent<SuppliedPillProps, P>;
|
|
54
50
|
list<K extends keyof ListFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedListProps<ElementOfArray<F[K]>>, ComponentProps<typeof DefaultList<ElementOfArray<F[K]>>>>;
|
|
55
51
|
}
|
package/.out/mantine/hooks.js
CHANGED
|
@@ -13,11 +13,6 @@ import { createValueInput, } from './create_value_input';
|
|
|
13
13
|
function SimpleSelect(props) {
|
|
14
14
|
return _jsx(Select, { ...props });
|
|
15
15
|
}
|
|
16
|
-
function DefaultErrorRenderer({ error,
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
}) {
|
|
19
|
-
return error;
|
|
20
|
-
}
|
|
21
16
|
export function useMantineForm({ onFieldValueChange, onFieldBlur, onFieldFocus, onFieldSubmit, fields, }) {
|
|
22
17
|
const form = useMemo(function () {
|
|
23
18
|
return new MantineFormImpl(fields);
|
|
@@ -78,39 +73,39 @@ class MantineFormImpl {
|
|
|
78
73
|
}
|
|
79
74
|
textInput(valuePath,
|
|
80
75
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
81
|
-
TextInput = TextInputImpl
|
|
76
|
+
TextInput = TextInputImpl) {
|
|
82
77
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
83
78
|
return this.textInputCache.retrieveOrCreate(valuePath,
|
|
84
79
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
85
|
-
TextInput
|
|
80
|
+
TextInput);
|
|
86
81
|
}
|
|
87
|
-
valueInput(valuePath, ValueInput
|
|
82
|
+
valueInput(valuePath, ValueInput) {
|
|
88
83
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
89
84
|
return this.valueInputCache.retrieveOrCreate(valuePath,
|
|
90
85
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
91
|
-
ValueInput
|
|
86
|
+
ValueInput);
|
|
92
87
|
}
|
|
93
|
-
select(valuePath
|
|
88
|
+
select(valuePath) {
|
|
94
89
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
95
90
|
return this.valueInputCache.retrieveOrCreate(valuePath,
|
|
96
91
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
97
|
-
SimpleSelect
|
|
92
|
+
SimpleSelect);
|
|
98
93
|
}
|
|
99
94
|
checkbox(valuePath,
|
|
100
95
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
101
|
-
Checkbox = CheckboxImpl
|
|
96
|
+
Checkbox = CheckboxImpl) {
|
|
102
97
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
103
98
|
return this.checkboxCache.retrieveOrCreate(valuePath,
|
|
104
99
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
105
|
-
Checkbox
|
|
100
|
+
Checkbox);
|
|
106
101
|
}
|
|
107
102
|
radioGroup(valuePath,
|
|
108
103
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
109
|
-
RadioGroup = RadioImpl.Group
|
|
104
|
+
RadioGroup = RadioImpl.Group) {
|
|
110
105
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
111
106
|
return this.radioGroupCache.retrieveOrCreate(valuePath,
|
|
112
107
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
113
|
-
RadioGroup
|
|
108
|
+
RadioGroup);
|
|
114
109
|
}
|
|
115
110
|
radio(valuePath, value,
|
|
116
111
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
2
2
|
import { type FormProps } from 'core/props';
|
|
3
|
+
import { type ErrorRenderer } from 'mantine/error_renderer';
|
|
3
4
|
import { type Field } from 'types/field';
|
|
4
|
-
declare function Component(props: FormProps<{
|
|
5
|
+
declare function Component({ ErrorRenderer, ...props }: FormProps<{
|
|
5
6
|
$: Field<boolean, string>;
|
|
6
|
-
}>
|
|
7
|
+
}> & {
|
|
8
|
+
ErrorRenderer?: ErrorRenderer;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
10
|
declare const meta: Meta<typeof Component>;
|
|
8
11
|
export default meta;
|
|
9
12
|
type Story = StoryObj<typeof Component>;
|
|
@@ -11,3 +14,5 @@ export declare const Off: Story;
|
|
|
11
14
|
export declare const On: Story;
|
|
12
15
|
export declare const Required: Story;
|
|
13
16
|
export declare const Disabled: Story;
|
|
17
|
+
export declare const Error: Story;
|
|
18
|
+
export declare const CustomError: Story;
|
|
@@ -2,10 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import { useMantineForm } from 'mantine/hooks';
|
|
4
4
|
import { CHECKBOX_LABEL } from './checkbox_constants';
|
|
5
|
-
function Component(props) {
|
|
5
|
+
function Component({ ErrorRenderer, ...props }) {
|
|
6
6
|
const inputProps = useMantineForm(props);
|
|
7
7
|
const CheckboxComponent = inputProps.checkbox('$');
|
|
8
|
-
return _jsx(CheckboxComponent, { label: CHECKBOX_LABEL });
|
|
8
|
+
return (_jsx(CheckboxComponent, { ErrorRenderer: ErrorRenderer, label: CHECKBOX_LABEL }));
|
|
9
9
|
}
|
|
10
10
|
const meta = {
|
|
11
11
|
component: Component,
|
|
@@ -21,7 +21,7 @@ export const Off = {
|
|
|
21
21
|
args: {
|
|
22
22
|
fields: {
|
|
23
23
|
$: {
|
|
24
|
-
|
|
24
|
+
readonly: false,
|
|
25
25
|
required: false,
|
|
26
26
|
value: false,
|
|
27
27
|
},
|
|
@@ -32,7 +32,7 @@ export const On = {
|
|
|
32
32
|
args: {
|
|
33
33
|
fields: {
|
|
34
34
|
$: {
|
|
35
|
-
|
|
35
|
+
readonly: false,
|
|
36
36
|
required: false,
|
|
37
37
|
value: true,
|
|
38
38
|
},
|
|
@@ -43,7 +43,7 @@ export const Required = {
|
|
|
43
43
|
args: {
|
|
44
44
|
fields: {
|
|
45
45
|
$: {
|
|
46
|
-
|
|
46
|
+
readonly: false,
|
|
47
47
|
required: true,
|
|
48
48
|
value: false,
|
|
49
49
|
},
|
|
@@ -54,10 +54,37 @@ export const Disabled = {
|
|
|
54
54
|
args: {
|
|
55
55
|
fields: {
|
|
56
56
|
$: {
|
|
57
|
-
|
|
57
|
+
readonly: true,
|
|
58
58
|
required: false,
|
|
59
59
|
value: false,
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
};
|
|
64
|
+
export const Error = {
|
|
65
|
+
args: {
|
|
66
|
+
fields: {
|
|
67
|
+
$: {
|
|
68
|
+
readonly: false,
|
|
69
|
+
required: false,
|
|
70
|
+
value: true,
|
|
71
|
+
error: 'error',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
export const CustomError = {
|
|
77
|
+
args: {
|
|
78
|
+
fields: {
|
|
79
|
+
$: {
|
|
80
|
+
readonly: false,
|
|
81
|
+
required: false,
|
|
82
|
+
value: true,
|
|
83
|
+
error: 'error',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
ErrorRenderer: function () {
|
|
87
|
+
return 'custom error';
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -23,7 +23,7 @@ export const Empty = {
|
|
|
23
23
|
args: {
|
|
24
24
|
fields: {
|
|
25
25
|
$: {
|
|
26
|
-
|
|
26
|
+
readonly: false,
|
|
27
27
|
required: false,
|
|
28
28
|
value: [],
|
|
29
29
|
},
|
|
@@ -34,7 +34,7 @@ export const Populated = {
|
|
|
34
34
|
args: {
|
|
35
35
|
fields: {
|
|
36
36
|
$: {
|
|
37
|
-
|
|
37
|
+
readonly: false,
|
|
38
38
|
required: false,
|
|
39
39
|
value: [
|
|
40
40
|
'$.4',
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
2
2
|
import { type FormProps } from 'core/props';
|
|
3
|
+
import { type ErrorRenderer } from 'mantine/error_renderer';
|
|
3
4
|
import { type Field } from 'types/field';
|
|
4
5
|
import { type RadioValue } from './radio_group_constants';
|
|
5
|
-
declare function Component(props: FormProps<{
|
|
6
|
+
declare function Component({ ErrorRenderer, ...props }: FormProps<{
|
|
6
7
|
$: Field<RadioValue | null, string>;
|
|
7
|
-
}>
|
|
8
|
+
}> & {
|
|
9
|
+
ErrorRenderer?: ErrorRenderer;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
11
|
declare const meta: Meta<typeof Component>;
|
|
9
12
|
export default meta;
|
|
10
13
|
type Story = StoryObj<typeof Component>;
|
|
@@ -12,3 +15,5 @@ export declare const Empty: Story;
|
|
|
12
15
|
export declare const Populated: Story;
|
|
13
16
|
export declare const Required: Story;
|
|
14
17
|
export declare const Disabled: Story;
|
|
18
|
+
export declare const Error: Story;
|
|
19
|
+
export declare const CustomError: Story;
|
|
@@ -3,10 +3,10 @@ import { Stack, } from '@mantine/core';
|
|
|
3
3
|
import { action } from '@storybook/addon-actions';
|
|
4
4
|
import { useMantineForm } from 'mantine/hooks';
|
|
5
5
|
import { RADIO_GROUP_LABEL, RADIO_LABELS, RADIO_VALUES, } from './radio_group_constants';
|
|
6
|
-
function Component(props) {
|
|
6
|
+
function Component({ ErrorRenderer, ...props }) {
|
|
7
7
|
const form = useMantineForm(props);
|
|
8
8
|
const RadioGroupComponent = form.radioGroup('$');
|
|
9
|
-
return (_jsx(RadioGroupComponent, { label: RADIO_GROUP_LABEL, children: _jsx(Stack, { children: RADIO_VALUES.map(function (value) {
|
|
9
|
+
return (_jsx(RadioGroupComponent, { ErrorRenderer: ErrorRenderer, label: RADIO_GROUP_LABEL, children: _jsx(Stack, { children: RADIO_VALUES.map(function (value) {
|
|
10
10
|
const label = RADIO_LABELS[value];
|
|
11
11
|
const RadioComponent = form.radio('$', value);
|
|
12
12
|
return (_jsx(RadioComponent, { label: label }, label));
|
|
@@ -26,7 +26,7 @@ export const Empty = {
|
|
|
26
26
|
args: {
|
|
27
27
|
fields: {
|
|
28
28
|
$: {
|
|
29
|
-
|
|
29
|
+
readonly: false,
|
|
30
30
|
required: false,
|
|
31
31
|
value: null,
|
|
32
32
|
},
|
|
@@ -37,7 +37,7 @@ export const Populated = {
|
|
|
37
37
|
args: {
|
|
38
38
|
fields: {
|
|
39
39
|
$: {
|
|
40
|
-
|
|
40
|
+
readonly: false,
|
|
41
41
|
required: false,
|
|
42
42
|
value: '3',
|
|
43
43
|
},
|
|
@@ -48,7 +48,7 @@ export const Required = {
|
|
|
48
48
|
args: {
|
|
49
49
|
fields: {
|
|
50
50
|
$: {
|
|
51
|
-
|
|
51
|
+
readonly: false,
|
|
52
52
|
required: true,
|
|
53
53
|
value: '1',
|
|
54
54
|
},
|
|
@@ -59,10 +59,37 @@ export const Disabled = {
|
|
|
59
59
|
args: {
|
|
60
60
|
fields: {
|
|
61
61
|
$: {
|
|
62
|
-
|
|
62
|
+
readonly: true,
|
|
63
63
|
required: false,
|
|
64
64
|
value: '2',
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
|
+
export const Error = {
|
|
70
|
+
args: {
|
|
71
|
+
fields: {
|
|
72
|
+
$: {
|
|
73
|
+
readonly: false,
|
|
74
|
+
required: false,
|
|
75
|
+
value: '2',
|
|
76
|
+
error: 'error',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
export const CustomError = {
|
|
82
|
+
args: {
|
|
83
|
+
fields: {
|
|
84
|
+
$: {
|
|
85
|
+
readonly: false,
|
|
86
|
+
required: false,
|
|
87
|
+
value: '2',
|
|
88
|
+
error: 'error',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
ErrorRenderer: function () {
|
|
92
|
+
return 'custom error';
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
2
2
|
import { type FormProps } from 'core/props';
|
|
3
|
+
import { type ErrorRenderer } from 'mantine/error_renderer';
|
|
3
4
|
import { type Field } from 'types/field';
|
|
4
|
-
declare function Component(props: FormProps<{
|
|
5
|
+
declare function Component({ ErrorRenderer, ...props }: FormProps<{
|
|
5
6
|
$: Field<string | null, string>;
|
|
6
|
-
}>
|
|
7
|
+
}> & {
|
|
8
|
+
ErrorRenderer?: ErrorRenderer;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
10
|
declare const meta: Meta<typeof Component>;
|
|
8
11
|
export default meta;
|
|
9
12
|
type Story = StoryObj<typeof Component>;
|
|
10
13
|
export declare const EmptySelect: Story;
|
|
11
14
|
export declare const PopulatedSelect: Story;
|
|
12
15
|
export declare const InvalidSelect: Story;
|
|
16
|
+
export declare const RequiredSelect: Story;
|
|
17
|
+
export declare const DisabledSelect: Story;
|
|
18
|
+
export declare const CustomErrorSelect: Story;
|
|
@@ -2,10 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import { useMantineForm } from 'mantine/hooks';
|
|
4
4
|
import { SELECT_LABEL } from './select_hooks_constant';
|
|
5
|
-
function Component(props) {
|
|
5
|
+
function Component({ ErrorRenderer, ...props }) {
|
|
6
6
|
const form = useMantineForm(props);
|
|
7
7
|
const SelectComponent = form.select('$');
|
|
8
|
-
return (_jsx(SelectComponent, { data: [
|
|
8
|
+
return (_jsx(SelectComponent, { ErrorRenderer: ErrorRenderer, data: [
|
|
9
9
|
'a',
|
|
10
10
|
'b',
|
|
11
11
|
'c',
|
|
@@ -25,8 +25,8 @@ export const EmptySelect = {
|
|
|
25
25
|
args: {
|
|
26
26
|
fields: {
|
|
27
27
|
$: {
|
|
28
|
-
|
|
29
|
-
required:
|
|
28
|
+
readonly: false,
|
|
29
|
+
required: false,
|
|
30
30
|
value: '',
|
|
31
31
|
},
|
|
32
32
|
},
|
|
@@ -36,8 +36,8 @@ export const PopulatedSelect = {
|
|
|
36
36
|
args: {
|
|
37
37
|
fields: {
|
|
38
38
|
$: {
|
|
39
|
-
|
|
40
|
-
required:
|
|
39
|
+
readonly: false,
|
|
40
|
+
required: false,
|
|
41
41
|
value: 'a',
|
|
42
42
|
},
|
|
43
43
|
},
|
|
@@ -47,11 +47,48 @@ export const InvalidSelect = {
|
|
|
47
47
|
args: {
|
|
48
48
|
fields: {
|
|
49
49
|
$: {
|
|
50
|
-
|
|
51
|
-
required:
|
|
50
|
+
readonly: false,
|
|
51
|
+
required: false,
|
|
52
52
|
value: 'd',
|
|
53
53
|
error: 'invalid option',
|
|
54
54
|
},
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
|
+
export const RequiredSelect = {
|
|
59
|
+
args: {
|
|
60
|
+
fields: {
|
|
61
|
+
$: {
|
|
62
|
+
readonly: false,
|
|
63
|
+
required: true,
|
|
64
|
+
value: 'a',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
export const DisabledSelect = {
|
|
70
|
+
args: {
|
|
71
|
+
fields: {
|
|
72
|
+
$: {
|
|
73
|
+
readonly: true,
|
|
74
|
+
required: false,
|
|
75
|
+
value: 'a',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
export const CustomErrorSelect = {
|
|
81
|
+
args: {
|
|
82
|
+
fields: {
|
|
83
|
+
$: {
|
|
84
|
+
readonly: false,
|
|
85
|
+
required: true,
|
|
86
|
+
value: 'c',
|
|
87
|
+
error: 'error',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
ErrorRenderer: function () {
|
|
91
|
+
return 'custom error';
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -2,13 +2,16 @@ import { type TextInputProps } from '@mantine/core';
|
|
|
2
2
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
3
3
|
import { type FormProps } from 'core/props';
|
|
4
4
|
import { type SuppliedTextInputProps, type TextInputTarget } from 'mantine/create_text_input';
|
|
5
|
+
import { type ErrorRenderer } from 'mantine/error_renderer';
|
|
5
6
|
import { type ComponentType } from 'react';
|
|
6
7
|
import { type Field } from 'types/field';
|
|
7
8
|
type StoryTextInputProps<T extends TextInputTarget> = SuppliedTextInputProps<T> & Pick<TextInputProps, 'label'>;
|
|
8
|
-
declare function Component<T extends TextInputTarget>({ TextInput, ...props }: FormProps<{
|
|
9
|
+
declare function Component<T extends TextInputTarget>({ TextInput, ErrorRenderer, ...props }: FormProps<{
|
|
9
10
|
$: Field<string, string>;
|
|
10
11
|
}> & {
|
|
11
12
|
TextInput?: ComponentType<StoryTextInputProps<T>>;
|
|
13
|
+
} & {
|
|
14
|
+
ErrorRenderer?: ErrorRenderer;
|
|
12
15
|
}): import("react/jsx-runtime").JSX.Element;
|
|
13
16
|
declare const meta: Meta<typeof Component>;
|
|
14
17
|
export default meta;
|
|
@@ -17,5 +20,6 @@ export declare const Empty: Story;
|
|
|
17
20
|
export declare const Populated: Story;
|
|
18
21
|
export declare const Required: Story;
|
|
19
22
|
export declare const Disabled: Story;
|
|
23
|
+
export declare const CustomError: Story;
|
|
20
24
|
export declare const OverriddenTextarea: Story<HTMLTextAreaElement>;
|
|
21
25
|
export declare const OverriddenPillsInputField: Story;
|
|
@@ -3,10 +3,10 @@ import { PillsInputField, Textarea, } from '@mantine/core';
|
|
|
3
3
|
import { action } from '@storybook/addon-actions';
|
|
4
4
|
import { useMantineForm } from 'mantine/hooks';
|
|
5
5
|
import { TEXT_INPUT_LABEL } from './text_input_constants';
|
|
6
|
-
function Component({ TextInput, ...props }) {
|
|
6
|
+
function Component({ TextInput, ErrorRenderer, ...props }) {
|
|
7
7
|
const form = useMantineForm(props);
|
|
8
8
|
const TextInputComponent = form.textInput('$', TextInput);
|
|
9
|
-
return _jsx(TextInputComponent, { label: TEXT_INPUT_LABEL });
|
|
9
|
+
return (_jsx(TextInputComponent, { ErrorRenderer: ErrorRenderer, label: TEXT_INPUT_LABEL }));
|
|
10
10
|
}
|
|
11
11
|
const meta = {
|
|
12
12
|
component: Component,
|
|
@@ -22,7 +22,7 @@ export const Empty = {
|
|
|
22
22
|
args: {
|
|
23
23
|
fields: {
|
|
24
24
|
$: {
|
|
25
|
-
|
|
25
|
+
readonly: false,
|
|
26
26
|
required: false,
|
|
27
27
|
value: '',
|
|
28
28
|
},
|
|
@@ -33,7 +33,7 @@ export const Populated = {
|
|
|
33
33
|
args: {
|
|
34
34
|
fields: {
|
|
35
35
|
$: {
|
|
36
|
-
|
|
36
|
+
readonly: false,
|
|
37
37
|
required: false,
|
|
38
38
|
value: 'Hello',
|
|
39
39
|
},
|
|
@@ -44,7 +44,7 @@ export const Required = {
|
|
|
44
44
|
args: {
|
|
45
45
|
fields: {
|
|
46
46
|
$: {
|
|
47
|
-
|
|
47
|
+
readonly: false,
|
|
48
48
|
required: true,
|
|
49
49
|
value: 'xxx',
|
|
50
50
|
},
|
|
@@ -55,18 +55,33 @@ export const Disabled = {
|
|
|
55
55
|
args: {
|
|
56
56
|
fields: {
|
|
57
57
|
$: {
|
|
58
|
-
|
|
58
|
+
readonly: true,
|
|
59
59
|
required: false,
|
|
60
60
|
value: 'xxx',
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
};
|
|
65
|
+
export const CustomError = {
|
|
66
|
+
args: {
|
|
67
|
+
fields: {
|
|
68
|
+
$: {
|
|
69
|
+
readonly: false,
|
|
70
|
+
required: false,
|
|
71
|
+
value: 'xxx',
|
|
72
|
+
error: 'error',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
ErrorRenderer: function () {
|
|
76
|
+
return 'custom error';
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
65
80
|
export const OverriddenTextarea = {
|
|
66
81
|
args: {
|
|
67
82
|
fields: {
|
|
68
83
|
$: {
|
|
69
|
-
|
|
84
|
+
readonly: false,
|
|
70
85
|
required: false,
|
|
71
86
|
value: 'Textarea',
|
|
72
87
|
},
|
|
@@ -78,7 +93,7 @@ export const OverriddenPillsInputField = {
|
|
|
78
93
|
args: {
|
|
79
94
|
fields: {
|
|
80
95
|
$: {
|
|
81
|
-
|
|
96
|
+
readonly: false,
|
|
82
97
|
required: false,
|
|
83
98
|
value: 'PillsInputField',
|
|
84
99
|
},
|
|
@@ -2,21 +2,26 @@ import { type JsonInputProps, type NumberInputProps, type RatingProps, type Slid
|
|
|
2
2
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
3
3
|
import { type FormProps } from 'core/props';
|
|
4
4
|
import { type SuppliedValueInputProps } from 'mantine/create_value_input';
|
|
5
|
+
import { type ErrorRenderer } from 'mantine/error_renderer';
|
|
5
6
|
import { type ComponentType } from 'react';
|
|
6
7
|
import { type Field } from 'types/field';
|
|
7
8
|
type StoryValueInputProps<V> = SuppliedValueInputProps<V, any>;
|
|
8
|
-
declare function Component<V, P extends StoryValueInputProps<V>>({ ValueInput,
|
|
9
|
+
declare function Component<V, P extends StoryValueInputProps<V>>({ ValueInput, ErrorRenderer, inputProps, ...props }: FormProps<{
|
|
9
10
|
$: Field<V, string>;
|
|
10
11
|
}> & {
|
|
11
12
|
ValueInput: ComponentType<P>;
|
|
12
13
|
} & {
|
|
13
|
-
|
|
14
|
+
inputProps: P;
|
|
15
|
+
} & {
|
|
16
|
+
ErrorRenderer?: ErrorRenderer;
|
|
14
17
|
}): import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
declare const meta: Meta<typeof Component>;
|
|
16
19
|
export default meta;
|
|
17
20
|
type Story<V, P extends StoryValueInputProps<V>> = StoryObj<typeof Component<V, P>>;
|
|
18
21
|
export declare const EmptyNumberInput: Story<number | string, NumberInputProps>;
|
|
19
22
|
export declare const PopulatedNumberInput: Story<number | string, NumberInputProps>;
|
|
23
|
+
export declare const RequiredNumberInput: Story<number | string, NumberInputProps>;
|
|
24
|
+
export declare const CustomErrorNumberInput: Story<number | string, NumberInputProps>;
|
|
20
25
|
export declare const DisabledNumberInput: Story<number | string, NumberInputProps>;
|
|
21
26
|
export declare const AnSlider: Story<number, SliderProps>;
|
|
22
27
|
export declare const AnRating: Story<number, RatingProps>;
|