@strictly/react-form 0.0.18 → 0.0.19
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/form_model.d.ts +12 -9
- package/.out/core/mobx/form_model.js +103 -137
- package/.out/core/mobx/hooks.js +3 -4
- package/.out/core/mobx/merge_field_adapters_with_two_way_converter.d.ts +1 -1
- package/.out/core/mobx/merge_field_adapters_with_validators.js +5 -1
- package/.out/core/mobx/specs/form_model.tests.js +28 -23
- package/.out/mantine/create_fields_view.d.ts +2 -1
- package/.out/mantine/hooks.d.ts +6 -5
- package/.out/mantine/specs/checkbox_hooks.stories.d.ts +5 -2
- package/.out/mantine/specs/checkbox_hooks.stories.js +3 -2
- package/.out/mantine/specs/text_input_hooks.stories.d.ts +3 -2
- package/.out/mantine/specs/text_input_hooks.stories.js +3 -2
- package/.out/mantine/types.d.ts +3 -3
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/util/partial.d.ts +5 -2
- package/.out/util/specs/partial.tests.d.ts +1 -0
- package/.out/util/specs/partial.tests.js +8 -0
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-check-types.log +1 -1
- package/.turbo/turbo-release$colon$exports.log +1 -1
- package/core/mobx/form_model.ts +95 -157
- package/core/mobx/hooks.tsx +6 -5
- package/core/mobx/merge_field_adapters_with_two_way_converter.ts +2 -1
- package/core/mobx/merge_field_adapters_with_validators.ts +1 -1
- package/core/mobx/specs/form_model.tests.ts +39 -27
- package/dist/index.cjs +93 -139
- package/dist/index.d.cts +28 -21
- package/dist/index.d.ts +28 -21
- package/dist/index.js +92 -139
- package/mantine/create_fields_view.tsx +8 -4
- package/mantine/hooks.tsx +23 -15
- package/mantine/specs/checkbox_hooks.stories.tsx +7 -1
- package/mantine/specs/text_input_hooks.stories.tsx +8 -1
- package/mantine/types.ts +12 -4
- package/package.json +1 -1
- package/util/partial.tsx +8 -1
- package/util/specs/partial.tests.tsx +21 -0
package/.out/mantine/hooks.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { type ListFieldsOfFields } from 'types/list_fields_of_fields';
|
|
|
10
10
|
import { type StringFieldsOfFields } from 'types/string_fields_of_fields';
|
|
11
11
|
import { type SubFormFields } from 'types/sub_form_fields';
|
|
12
12
|
import { type ValueTypeOfField } from 'types/value_type_of_field';
|
|
13
|
+
import { type RefOfProps } from 'util/partial';
|
|
13
14
|
import { type SuppliedCheckboxProps } from './create_checkbox';
|
|
14
15
|
import { type FieldViewProps } from './create_field_view';
|
|
15
16
|
import { type FieldsView } from './create_fields_view';
|
|
@@ -41,12 +42,12 @@ declare class MantineFormImpl<F extends Fields> implements MantineForm<F> {
|
|
|
41
42
|
onFieldBlur: ((this: void, key: keyof F) => void) | undefined;
|
|
42
43
|
onFieldSubmit: ((this: void, key: keyof F) => boolean | void) | undefined;
|
|
43
44
|
constructor(fields: F);
|
|
44
|
-
textInput<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedTextInputProps, TextInputProps, ErrorOfField<F[K]
|
|
45
|
-
textInput<K extends keyof StringFieldsOfFields<F>, P extends SuppliedTextInputProps<any>>(valuePath: K, TextInput?: ComponentType<P>): MantineFieldComponent<SuppliedTextInputProps, P, ErrorOfField<F[K]>>;
|
|
45
|
+
textInput<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedTextInputProps, TextInputProps, ErrorOfField<F[K]>, HTMLInputElement>;
|
|
46
|
+
textInput<K extends keyof StringFieldsOfFields<F>, P extends SuppliedTextInputProps<any>>(valuePath: K, TextInput?: ComponentType<P>): MantineFieldComponent<SuppliedTextInputProps, P, ErrorOfField<F[K]>, RefOfProps<P, HTMLInputElement>>;
|
|
46
47
|
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]>>;
|
|
47
|
-
select<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<
|
|
48
|
-
checkbox<K extends keyof BooleanFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedCheckboxProps, CheckboxProps, ErrorOfField<F[K]
|
|
49
|
-
checkbox<K extends keyof BooleanFieldsOfFields<F>, P extends SuppliedCheckboxProps>(valuePath: K, Checkbox: ComponentType<P>): MantineFieldComponent<SuppliedCheckboxProps, P, ErrorOfField<F[K]>>;
|
|
48
|
+
select<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedValueInputProps<ValueTypeOfField<F[K]>>, ComponentProps<typeof SimpleSelect>, ErrorOfField<F[K]>, HTMLSelectElement>;
|
|
49
|
+
checkbox<K extends keyof BooleanFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedCheckboxProps, CheckboxProps, ErrorOfField<F[K]>, HTMLInputElement>;
|
|
50
|
+
checkbox<K extends keyof BooleanFieldsOfFields<F>, P extends SuppliedCheckboxProps>(valuePath: K, Checkbox: ComponentType<P>): MantineFieldComponent<SuppliedCheckboxProps, P, ErrorOfField<F[K]>, RefOfProps<P, HTMLInputElement>>;
|
|
50
51
|
radioGroup<K extends keyof StringFieldsOfFields<F>, P extends RadioGroupProps = RadioGroupProps>(valuePath: K): MantineFieldComponent<SuppliedRadioGroupProps, P, ErrorOfField<F[K]>>;
|
|
51
52
|
radioGroup<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioGroupProps>(valuePath: K, RadioGroup: ComponentType<P>): MantineFieldComponent<SuppliedRadioGroupProps, P, ErrorOfField<F[K]>>;
|
|
52
53
|
radio<K extends keyof StringFieldsOfFields<F>>(valuePath: K, value: ValueTypeOfField<F[K]>): MantineFieldComponent<SuppliedRadioProps, RadioProps, ErrorOfField<F[K]>>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
2
2
|
import { type FieldsViewProps } from 'core/props';
|
|
3
|
+
import { type Ref } from 'react';
|
|
3
4
|
import { type Field } from 'types/field';
|
|
4
|
-
declare function Component({ ...props }: FieldsViewProps<{
|
|
5
|
+
declare function Component({ componentRef, ...props }: FieldsViewProps<{
|
|
5
6
|
$: Field<boolean, string>;
|
|
6
|
-
}>
|
|
7
|
+
}> & {
|
|
8
|
+
componentRef: Ref<HTMLInputElement>;
|
|
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>;
|
|
@@ -17,10 +17,10 @@ function ErrorRenderer({ error }) {
|
|
|
17
17
|
return `Error ${error}`;
|
|
18
18
|
}
|
|
19
19
|
function Component(_a) {
|
|
20
|
-
var props = __rest(_a, []);
|
|
20
|
+
var { componentRef } = _a, props = __rest(_a, ["componentRef"]);
|
|
21
21
|
const inputProps = useMantineFormFields(props);
|
|
22
22
|
const CheckboxComponent = inputProps.checkbox('$');
|
|
23
|
-
return (_jsx(CheckboxComponent, { ErrorRenderer: ErrorRenderer, label: CHECKBOX_LABEL }));
|
|
23
|
+
return (_jsx(CheckboxComponent, { ErrorRenderer: ErrorRenderer, label: CHECKBOX_LABEL, ref: componentRef }));
|
|
24
24
|
}
|
|
25
25
|
const meta = {
|
|
26
26
|
component: Component,
|
|
@@ -29,6 +29,7 @@ const meta = {
|
|
|
29
29
|
onFieldFocus: action('onFieldFocus'),
|
|
30
30
|
onFieldSubmit: action('onFieldSubmit'),
|
|
31
31
|
onFieldValueChange: action('onFieldValueChange'),
|
|
32
|
+
componentRef: action('componentRef'),
|
|
32
33
|
},
|
|
33
34
|
};
|
|
34
35
|
export default meta;
|
|
@@ -2,12 +2,13 @@ import { type TextInputProps } from '@mantine/core';
|
|
|
2
2
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
3
3
|
import { type FieldsViewProps } from 'core/props';
|
|
4
4
|
import { type SuppliedTextInputProps, type TextInputTarget } from 'mantine/create_text_input';
|
|
5
|
-
import { type ComponentType } from 'react';
|
|
5
|
+
import { type ComponentType, type Ref } from 'react';
|
|
6
6
|
import { type Field } from 'types/field';
|
|
7
7
|
type StoryTextInputProps<T extends TextInputTarget> = SuppliedTextInputProps<T> & Pick<TextInputProps, 'label'>;
|
|
8
|
-
declare function Component<T extends TextInputTarget>({ TextInput, ...props }: FieldsViewProps<{
|
|
8
|
+
declare function Component<T extends TextInputTarget>({ TextInput, componentRef, ...props }: FieldsViewProps<{
|
|
9
9
|
$: Field<string, string>;
|
|
10
10
|
}> & {
|
|
11
|
+
componentRef: Ref<HTMLInputElement>;
|
|
11
12
|
TextInput?: ComponentType<StoryTextInputProps<T>>;
|
|
12
13
|
}): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
declare const meta: Meta<typeof Component>;
|
|
@@ -18,10 +18,10 @@ function ErrorRenderer({ error }) {
|
|
|
18
18
|
return `error ${error}`;
|
|
19
19
|
}
|
|
20
20
|
function Component(_a) {
|
|
21
|
-
var { TextInput } = _a, props = __rest(_a, ["TextInput"]);
|
|
21
|
+
var { TextInput, componentRef } = _a, props = __rest(_a, ["TextInput", "componentRef"]);
|
|
22
22
|
const form = useMantineFormFields(props);
|
|
23
23
|
const TextInputComponent = form.textInput('$', TextInput);
|
|
24
|
-
return (_jsx(TextInputComponent, { ErrorRenderer: ErrorRenderer, label: TEXT_INPUT_LABEL }));
|
|
24
|
+
return (_jsx(TextInputComponent, { ErrorRenderer: ErrorRenderer, label: TEXT_INPUT_LABEL, ref: componentRef }));
|
|
25
25
|
}
|
|
26
26
|
const meta = {
|
|
27
27
|
component: Component,
|
|
@@ -30,6 +30,7 @@ const meta = {
|
|
|
30
30
|
onFieldFocus: action('onFieldFocus'),
|
|
31
31
|
onFieldSubmit: action('onFieldSubmit'),
|
|
32
32
|
onFieldValueChange: action('onFieldValueChange'),
|
|
33
|
+
componentRef: action('componentRef'),
|
|
33
34
|
},
|
|
34
35
|
};
|
|
35
36
|
export default meta;
|
package/.out/mantine/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComponentType } from 'react';
|
|
2
2
|
import { type Fields } from 'types/field';
|
|
3
|
-
import { type UnsafePartialComponent } from 'util/partial';
|
|
3
|
+
import { type RefOfProps, type UnsafePartialComponent } from 'util/partial';
|
|
4
4
|
import { type ErrorRenderer } from './error_renderer';
|
|
5
5
|
export type MantineForm<F extends Fields> = {
|
|
6
6
|
fields: F;
|
|
@@ -9,8 +9,8 @@ export type MantineForm<F extends Fields> = {
|
|
|
9
9
|
onFieldBlur: ((this: void, key: keyof F) => void) | undefined;
|
|
10
10
|
onFieldSubmit: ((this: void, key: keyof F) => boolean | void) | undefined;
|
|
11
11
|
};
|
|
12
|
-
export type MantineFieldComponent<T, P = T, E = any
|
|
12
|
+
export type MantineFieldComponent<T, P = T, E = any, R = RefOfProps<P>> = UnsafePartialComponent<ComponentType<P>, T, [
|
|
13
13
|
E
|
|
14
14
|
] extends [never] ? {} : {
|
|
15
15
|
ErrorRenderer: ErrorRenderer<E>;
|
|
16
|
-
}>;
|
|
16
|
+
}, R>;
|