@strictly/react-form 0.0.4 → 0.0.6
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 +1 -1
- package/.out/core/mobx/field_adapter_builder.js +1 -2
- package/.out/core/mobx/hooks.d.ts +10 -0
- package/.out/core/mobx/hooks.js +47 -0
- package/.out/core/props.d.ts +2 -2
- package/.out/index.d.ts +1 -0
- package/.out/index.js +1 -0
- package/.out/mantine/create_fields_view.d.ts +7 -0
- package/.out/mantine/{create_sub_form.js → create_fields_view.js} +4 -5
- package/.out/mantine/create_form.d.ts +7 -0
- package/.out/mantine/create_form.js +13 -0
- package/.out/mantine/create_list.d.ts +5 -4
- package/.out/mantine/create_list.js +4 -2
- package/.out/mantine/hooks.d.ts +8 -5
- package/.out/mantine/hooks.js +17 -7
- package/.out/mantine/specs/checkbox_hooks.stories.d.ts +2 -2
- package/.out/mantine/specs/checkbox_hooks.stories.js +2 -2
- package/.out/mantine/specs/{sub_form_hooks.stories.d.ts → fields_view_hooks.stories.d.ts} +2 -2
- package/.out/mantine/specs/{sub_form_hooks.stories.js → fields_view_hooks.stories.js} +9 -8
- package/.out/mantine/specs/fields_view_hooks.tests.d.ts +1 -0
- package/.out/mantine/specs/fields_view_hooks.tests.js +12 -0
- package/.out/mantine/specs/form_hooks.stories.d.ts +12 -0
- package/.out/mantine/specs/form_hooks.stories.js +60 -0
- package/.out/mantine/specs/form_hooks.tests.d.ts +1 -0
- package/.out/mantine/specs/form_hooks.tests.js +12 -0
- package/.out/mantine/specs/list_hooks.stories.d.ts +2 -2
- package/.out/mantine/specs/list_hooks.stories.js +8 -8
- package/.out/mantine/specs/radio_group_hooks.stories.d.ts +2 -2
- package/.out/mantine/specs/radio_group_hooks.stories.js +2 -2
- package/.out/mantine/specs/select_hooks.stories.d.ts +2 -2
- package/.out/mantine/specs/select_hooks.stories.js +2 -2
- package/.out/mantine/specs/text_input_hooks.stories.d.ts +2 -2
- package/.out/mantine/specs/text_input_hooks.stories.js +2 -2
- package/.out/mantine/specs/value_input_hooks.stories.d.ts +2 -2
- package/.out/mantine/specs/value_input_hooks.stories.js +2 -2
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-check-types.log +1 -1
- package/core/mobx/field_adapter_builder.ts +3 -4
- package/core/mobx/hooks.ts +94 -0
- package/core/props.ts +2 -2
- package/dist/index.cjs +175 -95
- package/dist/index.d.cts +48 -39
- package/dist/index.d.ts +48 -39
- package/dist/index.js +170 -86
- package/index.ts +1 -0
- package/mantine/{create_sub_form.tsx → create_fields_view.tsx} +27 -16
- package/mantine/create_form.tsx +43 -0
- package/mantine/create_list.tsx +10 -4
- package/mantine/hooks.tsx +51 -16
- package/mantine/specs/__snapshots__/fields_view_hooks.tests.tsx.snap +460 -0
- package/mantine/specs/__snapshots__/form_hooks.tests.tsx.snap +273 -0
- package/mantine/specs/__snapshots__/list_hooks.tests.tsx.snap +56 -8
- package/mantine/specs/checkbox_hooks.stories.tsx +4 -4
- package/mantine/specs/{sub_form_hooks.stories.tsx → fields_view_hooks.stories.tsx} +23 -11
- package/mantine/specs/fields_view_hooks.tests.tsx +15 -0
- package/mantine/specs/form_hooks.stories.tsx +107 -0
- package/mantine/specs/form_hooks.tests.tsx +15 -0
- package/mantine/specs/list_hooks.stories.tsx +20 -10
- package/mantine/specs/radio_group_hooks.stories.tsx +4 -4
- package/mantine/specs/select_hooks.stories.tsx +4 -4
- package/mantine/specs/text_input_hooks.stories.tsx +4 -4
- package/mantine/specs/value_input_hooks.stories.tsx +4 -4
- package/package.json +1 -1
- package/.out/field_converters/list_converter.d.ts +0 -2
- package/.out/field_converters/list_converter.js +0 -13
- package/.out/mantine/create_sub_form.d.ts +0 -6
- package/field_converters/list_converter.ts +0 -20
|
@@ -3,21 +3,21 @@ import {
|
|
|
3
3
|
type Meta,
|
|
4
4
|
type StoryObj,
|
|
5
5
|
} from '@storybook/react'
|
|
6
|
-
import { type
|
|
6
|
+
import { type FieldsViewProps } from 'core/props'
|
|
7
7
|
import { type ErrorRenderer } from 'mantine/error_renderer'
|
|
8
|
-
import {
|
|
8
|
+
import { useMantineFormFields } from 'mantine/hooks'
|
|
9
9
|
import { type Field } from 'types/field'
|
|
10
10
|
import { SELECT_LABEL } from './select_hooks_constant'
|
|
11
11
|
|
|
12
12
|
function Component({
|
|
13
13
|
ErrorRenderer,
|
|
14
14
|
...props
|
|
15
|
-
}:
|
|
15
|
+
}: FieldsViewProps<{
|
|
16
16
|
$: Field<string | null, string>,
|
|
17
17
|
}> & {
|
|
18
18
|
ErrorRenderer?: ErrorRenderer,
|
|
19
19
|
}) {
|
|
20
|
-
const form =
|
|
20
|
+
const form = useMantineFormFields(props)
|
|
21
21
|
const SelectComponent = form.select('$')
|
|
22
22
|
return (
|
|
23
23
|
<SelectComponent
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
type Meta,
|
|
9
9
|
type StoryObj,
|
|
10
10
|
} from '@storybook/react'
|
|
11
|
-
import { type
|
|
11
|
+
import { type FieldsViewProps } from 'core/props'
|
|
12
12
|
import {
|
|
13
13
|
type SuppliedTextInputProps,
|
|
14
14
|
type TextInputTarget,
|
|
15
15
|
} from 'mantine/create_text_input'
|
|
16
16
|
import { type ErrorRenderer } from 'mantine/error_renderer'
|
|
17
|
-
import {
|
|
17
|
+
import { useMantineFormFields } from 'mantine/hooks'
|
|
18
18
|
import { type ComponentType } from 'react'
|
|
19
19
|
import { type Field } from 'types/field'
|
|
20
20
|
import { TEXT_INPUT_LABEL } from './text_input_constants'
|
|
@@ -25,14 +25,14 @@ function Component<T extends TextInputTarget>({
|
|
|
25
25
|
TextInput,
|
|
26
26
|
ErrorRenderer,
|
|
27
27
|
...props
|
|
28
|
-
}:
|
|
28
|
+
}: FieldsViewProps<{
|
|
29
29
|
$: Field<string, string>,
|
|
30
30
|
}> & {
|
|
31
31
|
TextInput?: ComponentType<StoryTextInputProps<T>>,
|
|
32
32
|
} & {
|
|
33
33
|
ErrorRenderer?: ErrorRenderer,
|
|
34
34
|
}) {
|
|
35
|
-
const form =
|
|
35
|
+
const form = useMantineFormFields(props)
|
|
36
36
|
const TextInputComponent = form.textInput<'$', StoryTextInputProps<T>>('$', TextInput)
|
|
37
37
|
return (
|
|
38
38
|
<TextInputComponent
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
type Meta,
|
|
14
14
|
type StoryObj,
|
|
15
15
|
} from '@storybook/react'
|
|
16
|
-
import { type
|
|
16
|
+
import { type FieldsViewProps } from 'core/props'
|
|
17
17
|
import { type SuppliedValueInputProps } from 'mantine/create_value_input'
|
|
18
18
|
import { type ErrorRenderer } from 'mantine/error_renderer'
|
|
19
|
-
import {
|
|
19
|
+
import { useMantineFormFields } from 'mantine/hooks'
|
|
20
20
|
import {
|
|
21
21
|
type ComponentType,
|
|
22
22
|
} from 'react'
|
|
@@ -37,7 +37,7 @@ function Component<
|
|
|
37
37
|
ErrorRenderer,
|
|
38
38
|
inputProps,
|
|
39
39
|
...props
|
|
40
|
-
}:
|
|
40
|
+
}: FieldsViewProps<{
|
|
41
41
|
$: Field<V, string>,
|
|
42
42
|
}> & {
|
|
43
43
|
ValueInput: ComponentType<P>,
|
|
@@ -46,7 +46,7 @@ function Component<
|
|
|
46
46
|
} & {
|
|
47
47
|
ErrorRenderer?: ErrorRenderer,
|
|
48
48
|
}) {
|
|
49
|
-
const form =
|
|
49
|
+
const form = useMantineFormFields(props)
|
|
50
50
|
const ValueInputComponent = form.valueInput<'$', P>('$', ValueInput)
|
|
51
51
|
return (
|
|
52
52
|
<ValueInputComponent
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function listConverter() {
|
|
2
|
-
return function (from, valuePath) {
|
|
3
|
-
const value = from.map(function (_v, i) {
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
5
|
-
return `${valuePath}.${i}`;
|
|
6
|
-
});
|
|
7
|
-
return {
|
|
8
|
-
value,
|
|
9
|
-
required: false,
|
|
10
|
-
readonly: false,
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { FormProps } from 'core/props';
|
|
2
|
-
import type { ComponentType } from 'react';
|
|
3
|
-
import type { AllFieldsOfFields } from 'types/all_fields_of_fields';
|
|
4
|
-
import type { Fields } from 'types/field';
|
|
5
|
-
import type { SubFormFields } from 'types/sub_form_fields';
|
|
6
|
-
export declare function createSubForm<F extends Fields, K extends keyof AllFieldsOfFields<F>, S extends Fields = SubFormFields<F, K>>(valuePath: K, SubForm: ComponentType<FormProps<S>>, observableProps: FormProps<F>): () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type AnnotatedFieldConverter } from 'types/field_converters'
|
|
2
|
-
|
|
3
|
-
export function listConverter<
|
|
4
|
-
E,
|
|
5
|
-
K extends string,
|
|
6
|
-
ValuePath extends string,
|
|
7
|
-
Context,
|
|
8
|
-
>(): AnnotatedFieldConverter<readonly E[], K[], ValuePath, Context> {
|
|
9
|
-
return function (from: readonly E[], valuePath: ValuePath) {
|
|
10
|
-
const value = from.map(function (_v, i) {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
12
|
-
return `${valuePath as string}.${i}` as K
|
|
13
|
-
})
|
|
14
|
-
return {
|
|
15
|
-
value,
|
|
16
|
-
required: false,
|
|
17
|
-
readonly: false,
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|