@strictly/react-form 0.0.1
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/.eslintrc.cjs +26 -0
- package/.out/.storybook/main.d.ts +3 -0
- package/.out/.storybook/main.js +32 -0
- package/.out/.storybook/preview.d.ts +4 -0
- package/.out/.storybook/preview.js +20 -0
- package/.out/.vitest/install_deterministic_random.d.ts +2 -0
- package/.out/.vitest/install_deterministic_random.js +15 -0
- package/.out/.vitest/install_storybook_preview.d.ts +1 -0
- package/.out/.vitest/install_storybook_preview.js +7 -0
- package/.out/.vitest/match_media.d.ts +1 -0
- package/.out/.vitest/match_media.js +5 -0
- package/.out/.vitest/resize_observer.d.ts +1 -0
- package/.out/.vitest/resize_observer.js +4 -0
- package/.out/core/mobx/field_adapter.d.ts +9 -0
- package/.out/core/mobx/field_adapter.js +1 -0
- package/.out/core/mobx/field_adapter_builder.d.ts +22 -0
- package/.out/core/mobx/field_adapter_builder.js +56 -0
- package/.out/core/mobx/flattened_adapters_of_fields.d.ts +9 -0
- package/.out/core/mobx/flattened_adapters_of_fields.js +1 -0
- package/.out/core/mobx/flattened_list_type_defs_of.d.ts +8 -0
- package/.out/core/mobx/flattened_list_type_defs_of.js +1 -0
- package/.out/core/mobx/form_presenter.d.ts +61 -0
- package/.out/core/mobx/form_presenter.js +425 -0
- package/.out/core/mobx/specs/flattened_adapters_of_fields.tests.d.ts +1 -0
- package/.out/core/mobx/specs/flattened_adapters_of_fields.tests.js +13 -0
- package/.out/core/mobx/specs/flattened_list_type_defs_of.tests.d.ts +1 -0
- package/.out/core/mobx/specs/flattened_list_type_defs_of.tests.js +16 -0
- package/.out/core/mobx/specs/form_presenter.tests.d.ts +1 -0
- package/.out/core/mobx/specs/form_presenter.tests.js +697 -0
- package/.out/core/mobx/types.d.ts +19 -0
- package/.out/core/mobx/types.js +1 -0
- package/.out/core/props.d.ts +12 -0
- package/.out/core/props.js +1 -0
- package/.out/field_converters/chain_field_converter.d.ts +3 -0
- package/.out/field_converters/chain_field_converter.js +46 -0
- package/.out/field_converters/identity_converter.d.ts +3 -0
- package/.out/field_converters/identity_converter.js +14 -0
- package/.out/field_converters/integer_to_string_converter.d.ts +7 -0
- package/.out/field_converters/integer_to_string_converter.js +26 -0
- package/.out/field_converters/list_converter.d.ts +2 -0
- package/.out/field_converters/list_converter.js +8 -0
- package/.out/field_converters/maybe_identity_converter.d.ts +8 -0
- package/.out/field_converters/maybe_identity_converter.js +15 -0
- package/.out/field_converters/nullable_to_boolean_converter.d.ts +11 -0
- package/.out/field_converters/nullable_to_boolean_converter.js +31 -0
- package/.out/field_converters/select_value_type_converter.d.ts +23 -0
- package/.out/field_converters/select_value_type_converter.js +60 -0
- package/.out/field_converters/trimming_string_converter.d.ts +6 -0
- package/.out/field_converters/trimming_string_converter.js +14 -0
- package/.out/field_converters/validating_converter.d.ts +3 -0
- package/.out/field_converters/validating_converter.js +21 -0
- package/.out/field_validators/minimum_string_length_field_validator.d.ts +2 -0
- package/.out/field_validators/minimum_string_length_field_validator.js +8 -0
- package/.out/field_value_factories/prototyping_field_value_factory.d.ts +2 -0
- package/.out/field_value_factories/prototyping_field_value_factory.js +5 -0
- package/.out/index.d.ts +16 -0
- package/.out/index.js +16 -0
- package/.out/mantine/create_checkbox.d.ts +9 -0
- package/.out/mantine/create_checkbox.js +37 -0
- package/.out/mantine/create_list.d.ts +15 -0
- package/.out/mantine/create_list.js +16 -0
- package/.out/mantine/create_pill.d.ts +7 -0
- package/.out/mantine/create_pill.js +15 -0
- package/.out/mantine/create_radio.d.ts +8 -0
- package/.out/mantine/create_radio.js +10 -0
- package/.out/mantine/create_radio_group.d.ts +9 -0
- package/.out/mantine/create_radio_group.js +34 -0
- package/.out/mantine/create_text_input.d.ts +19 -0
- package/.out/mantine/create_text_input.js +38 -0
- package/.out/mantine/create_value_input.d.ts +17 -0
- package/.out/mantine/create_value_input.js +38 -0
- package/.out/mantine/hooks.d.ts +56 -0
- package/.out/mantine/hooks.js +135 -0
- package/.out/mantine/specs/checkbox_constants.d.ts +1 -0
- package/.out/mantine/specs/checkbox_constants.js +1 -0
- package/.out/mantine/specs/checkbox_hooks.stories.d.ts +13 -0
- package/.out/mantine/specs/checkbox_hooks.stories.js +63 -0
- package/.out/mantine/specs/checkbox_hooks.tests.d.ts +1 -0
- package/.out/mantine/specs/checkbox_hooks.tests.js +74 -0
- package/.out/mantine/specs/list_hooks.stories.d.ts +11 -0
- package/.out/mantine/specs/list_hooks.stories.js +48 -0
- package/.out/mantine/specs/list_hooks.tests.d.ts +1 -0
- package/.out/mantine/specs/list_hooks.tests.js +12 -0
- package/.out/mantine/specs/radio_group_constants.d.ts +4 -0
- package/.out/mantine/specs/radio_group_constants.js +11 -0
- package/.out/mantine/specs/radio_group_hooks.stories.d.ts +14 -0
- package/.out/mantine/specs/radio_group_hooks.stories.js +68 -0
- package/.out/mantine/specs/radio_group_hooks.tests.d.ts +1 -0
- package/.out/mantine/specs/radio_group_hooks.tests.js +62 -0
- package/.out/mantine/specs/select_hooks.stories.d.ts +12 -0
- package/.out/mantine/specs/select_hooks.stories.js +57 -0
- package/.out/mantine/specs/select_hooks.tests.d.ts +1 -0
- package/.out/mantine/specs/select_hooks.tests.js +12 -0
- package/.out/mantine/specs/select_hooks_constant.d.ts +1 -0
- package/.out/mantine/specs/select_hooks_constant.js +1 -0
- package/.out/mantine/specs/text_input_constants.d.ts +1 -0
- package/.out/mantine/specs/text_input_constants.js +1 -0
- package/.out/mantine/specs/text_input_hooks.stories.d.ts +21 -0
- package/.out/mantine/specs/text_input_hooks.stories.js +88 -0
- package/.out/mantine/specs/text_input_hooks.tests.d.ts +1 -0
- package/.out/mantine/specs/text_input_hooks.tests.js +79 -0
- package/.out/mantine/specs/value_input_constants.d.ts +2 -0
- package/.out/mantine/specs/value_input_constants.js +2 -0
- package/.out/mantine/specs/value_input_hooks.stories.d.ts +23 -0
- package/.out/mantine/specs/value_input_hooks.stories.js +124 -0
- package/.out/mantine/specs/value_input_hooks.tests.d.ts +1 -0
- package/.out/mantine/specs/value_input_hooks.tests.js +12 -0
- package/.out/mantine/types.d.ts +11 -0
- package/.out/mantine/types.js +1 -0
- package/.out/tsconfig.json +27 -0
- package/.out/tsconfig.tsbuildinfo +1 -0
- package/.out/tsup.config.d.ts +3 -0
- package/.out/tsup.config.js +12 -0
- package/.out/types/all_fields_of_fields.d.ts +5 -0
- package/.out/types/all_fields_of_fields.js +1 -0
- package/.out/types/boolean_fields_of_fields.d.ts +5 -0
- package/.out/types/boolean_fields_of_fields.js +1 -0
- package/.out/types/error_type_of_field.d.ts +2 -0
- package/.out/types/error_type_of_field.js +1 -0
- package/.out/types/field.d.ts +7 -0
- package/.out/types/field.js +1 -0
- package/.out/types/field_converters.d.ts +29 -0
- package/.out/types/field_converters.js +5 -0
- package/.out/types/field_validator.d.ts +3 -0
- package/.out/types/field_validator.js +1 -0
- package/.out/types/flattened_form_fields_of.d.ts +9 -0
- package/.out/types/flattened_form_fields_of.js +1 -0
- package/.out/types/list_fields_of_fields.d.ts +5 -0
- package/.out/types/list_fields_of_fields.js +1 -0
- package/.out/types/specs/boolean_fields_of_fields.tests.d.ts +1 -0
- package/.out/types/specs/boolean_fields_of_fields.tests.js +11 -0
- package/.out/types/specs/error_type_of_field.tests.d.ts +1 -0
- package/.out/types/specs/error_type_of_field.tests.js +7 -0
- package/.out/types/specs/flattened_form_fields_of.tests.d.ts +1 -0
- package/.out/types/specs/flattened_form_fields_of.tests.js +13 -0
- package/.out/types/specs/string_fields_of_fields.tests.d.ts +1 -0
- package/.out/types/specs/string_fields_of_fields.tests.js +19 -0
- package/.out/types/specs/value_type_of_field.tests.d.ts +1 -0
- package/.out/types/specs/value_type_of_field.tests.js +7 -0
- package/.out/types/string_fields_of_fields.d.ts +5 -0
- package/.out/types/string_fields_of_fields.js +1 -0
- package/.out/types/value_type_of_field.d.ts +2 -0
- package/.out/types/value_type_of_field.js +1 -0
- package/.out/util/partial.d.ts +11 -0
- package/.out/util/partial.js +74 -0
- package/.out/vitest.workspace.d.ts +2 -0
- package/.out/vitest.workspace.js +22 -0
- package/.storybook/main.ts +40 -0
- package/.storybook/preview.tsx +28 -0
- package/.storybook/vite.config.mts +38 -0
- package/.turbo/turbo-build.log +18 -0
- package/.turbo/turbo-check-types.log +3 -0
- package/.turbo/turbo-release$colon$exports.log +3 -0
- package/.vitest/install_deterministic_random.ts +17 -0
- package/.vitest/install_storybook_preview.ts +9 -0
- package/.vitest/match_media.ts +7 -0
- package/.vitest/resize_observer.ts +5 -0
- package/README.md +2 -0
- package/core/mobx/field_adapter.ts +32 -0
- package/core/mobx/field_adapter_builder.ts +313 -0
- package/core/mobx/flattened_adapters_of_fields.ts +35 -0
- package/core/mobx/flattened_list_type_defs_of.ts +17 -0
- package/core/mobx/form_presenter.ts +705 -0
- package/core/mobx/specs/flattened_adapters_of_fields.tests.ts +72 -0
- package/core/mobx/specs/flattened_list_type_defs_of.tests.ts +35 -0
- package/core/mobx/specs/form_presenter.tests.ts +989 -0
- package/core/mobx/types.ts +54 -0
- package/core/props.ts +21 -0
- package/dist/index.cjs +11479 -0
- package/dist/index.d.cts +345 -0
- package/dist/index.d.ts +345 -0
- package/dist/index.js +11486 -0
- package/field_converters/chain_field_converter.ts +74 -0
- package/field_converters/identity_converter.ts +39 -0
- package/field_converters/integer_to_string_converter.ts +32 -0
- package/field_converters/list_converter.ts +15 -0
- package/field_converters/maybe_identity_converter.ts +23 -0
- package/field_converters/nullable_to_boolean_converter.ts +56 -0
- package/field_converters/select_value_type_converter.ts +141 -0
- package/field_converters/trimming_string_converter.ts +23 -0
- package/field_converters/validating_converter.ts +35 -0
- package/field_validators/minimum_string_length_field_validator.ts +13 -0
- package/field_value_factories/prototyping_field_value_factory.ts +11 -0
- package/index.ts +16 -0
- package/mantine/create_checkbox.tsx +79 -0
- package/mantine/create_list.tsx +58 -0
- package/mantine/create_pill.tsx +43 -0
- package/mantine/create_radio.tsx +36 -0
- package/mantine/create_radio_group.tsx +71 -0
- package/mantine/create_text_input.tsx +80 -0
- package/mantine/create_value_input.tsx +81 -0
- package/mantine/hooks.tsx +394 -0
- package/mantine/specs/__snapshots__/check_box_hooks.tests.tsx.snap +227 -0
- package/mantine/specs/__snapshots__/checkbox_hooks.tests.tsx.snap +227 -0
- package/mantine/specs/__snapshots__/list_hooks.tests.tsx.snap +68 -0
- package/mantine/specs/__snapshots__/radio_group_hooks.tests.tsx.snap +695 -0
- package/mantine/specs/__snapshots__/select_hooks.tests.tsx.snap +225 -0
- package/mantine/specs/__snapshots__/text_input_hooks.tests.tsx.snap +202 -0
- package/mantine/specs/__snapshots__/value_input_hooks.tests.tsx.snap +613 -0
- package/mantine/specs/checkbox_constants.ts +1 -0
- package/mantine/specs/checkbox_hooks.stories.tsx +79 -0
- package/mantine/specs/checkbox_hooks.tests.tsx +100 -0
- package/mantine/specs/list_hooks.stories.tsx +83 -0
- package/mantine/specs/list_hooks.tests.tsx +15 -0
- package/mantine/specs/radio_group_constants.ts +12 -0
- package/mantine/specs/radio_group_hooks.stories.tsx +103 -0
- package/mantine/specs/radio_group_hooks.tests.tsx +92 -0
- package/mantine/specs/select_hooks.stories.tsx +77 -0
- package/mantine/specs/select_hooks.tests.tsx +14 -0
- package/mantine/specs/select_hooks_constant.ts +1 -0
- package/mantine/specs/text_input_constants.ts +1 -0
- package/mantine/specs/text_input_hooks.stories.tsx +124 -0
- package/mantine/specs/text_input_hooks.tests.tsx +106 -0
- package/mantine/specs/value_input_constants.ts +2 -0
- package/mantine/specs/value_input_hooks.stories.tsx +182 -0
- package/mantine/specs/value_input_hooks.tests.tsx +14 -0
- package/mantine/types.ts +13 -0
- package/package.exports.json +18 -0
- package/package.json +74 -0
- package/tsconfig.build.json +13 -0
- package/tsconfig.json +27 -0
- package/tsup.config.ts +16 -0
- package/types/all_fields_of_fields.ts +9 -0
- package/types/boolean_fields_of_fields.ts +8 -0
- package/types/error_type_of_field.ts +3 -0
- package/types/field.ts +9 -0
- package/types/field_converters.ts +64 -0
- package/types/field_validator.ts +7 -0
- package/types/flattened_form_fields_of.ts +16 -0
- package/types/list_fields_of_fields.ts +7 -0
- package/types/specs/boolean_fields_of_fields.tests.ts +23 -0
- package/types/specs/error_type_of_field.tests.ts +10 -0
- package/types/specs/flattened_form_fields_of.tests.ts +43 -0
- package/types/specs/string_fields_of_fields.tests.ts +40 -0
- package/types/specs/value_type_of_field.tests.ts +10 -0
- package/types/string_fields_of_fields.ts +6 -0
- package/types/value_type_of_field.ts +3 -0
- package/util/partial.tsx +200 -0
- package/vitest.workspace.ts +26 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { Maybe, ElementOfArray, StringKeyOf as StringKeyOf$1, PrintableOf } from '@strictly/base';
|
|
2
|
+
import { Type, ValueTypeOf, ReadonlyTypeDefOf, FlattenedTypeDefsOf, ListTypeDef, FlattenedValueTypesOf, MobxValueTypeOf, Accessor, UnionTypeDef, ValueTypesOfDiscriminatedUnion, LiteralTypeDef } from '@strictly/define';
|
|
3
|
+
import { ValueOf, SimplifyDeep, ReadonlyDeep, StringKeyOf } from 'type-fest';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { CheckboxProps, PillProps, RadioProps, RadioGroupProps, TextInputProps, SelectProps } from '@mantine/core';
|
|
6
|
+
import { ComponentType, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, DependencyList } from 'react';
|
|
7
|
+
|
|
8
|
+
declare enum FieldConversionResult {
|
|
9
|
+
Success = 0,
|
|
10
|
+
Failure = 1
|
|
11
|
+
}
|
|
12
|
+
type FieldConversion<V, E> = {
|
|
13
|
+
type: FieldConversionResult.Success;
|
|
14
|
+
value: V;
|
|
15
|
+
} | {
|
|
16
|
+
type: FieldConversionResult.Failure;
|
|
17
|
+
error: E;
|
|
18
|
+
value: Maybe<V>;
|
|
19
|
+
};
|
|
20
|
+
type FieldConverter<From, To, E, ValuePath extends string, Context> = {
|
|
21
|
+
(from: From, valuePath: ValuePath, context: Context): FieldConversion<To, E>;
|
|
22
|
+
};
|
|
23
|
+
type SafeFieldConverter<From, To, ValuePath extends string, Context> = {
|
|
24
|
+
(from: From, valuePath: ValuePath, context: Context): To;
|
|
25
|
+
};
|
|
26
|
+
type TwoWayFieldConverter<From, To, E, ValuePath extends string, Context> = {
|
|
27
|
+
convert: SafeFieldConverter<From, To, ValuePath, Context>;
|
|
28
|
+
revert: FieldConverter<To, From, E, ValuePath, Context>;
|
|
29
|
+
};
|
|
30
|
+
type FieldValueFactory<V, ValuePath extends string, Context> = {
|
|
31
|
+
(valuePath: ValuePath, context: Context): V;
|
|
32
|
+
};
|
|
33
|
+
type TwoWayFieldConverterWithValueFactory<From, To, E, ValuePath extends string, Context> = TwoWayFieldConverter<From, To, E, ValuePath, Context> & {
|
|
34
|
+
readonly create: FieldValueFactory<From, ValuePath, Context>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type FieldValidator<V, E, ValuePath extends string, Context> = {
|
|
38
|
+
(value: V, valuePath: ValuePath, context: Context): E | null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
declare class FieldAdapterBuilder<From, To, E, ValuePath extends string, Context> {
|
|
42
|
+
readonly convert: SafeFieldConverter<From, To, ValuePath, Context>;
|
|
43
|
+
readonly create: FieldValueFactory<From, ValuePath, Context>;
|
|
44
|
+
readonly revert?: FieldConverter<To, From, E, ValuePath, Context> | undefined;
|
|
45
|
+
constructor(convert: SafeFieldConverter<From, To, ValuePath, Context>, create: FieldValueFactory<From, ValuePath, Context>, revert?: FieldConverter<To, From, E, ValuePath, Context> | undefined);
|
|
46
|
+
validateFrom<E2>(...validators: readonly FieldValidator<From, E2, ValuePath, Context>[]): FieldAdapterBuilder<From, To, E | E2, ValuePath, Context>;
|
|
47
|
+
validateTo<E2>(...validators: readonly FieldValidator<To, E2, ValuePath, Context>[]): FieldAdapterBuilder<From, To, E | E2, ValuePath, Context>;
|
|
48
|
+
chain<To2, E2 = E>(converter: SafeFieldConverter<To, To2, ValuePath, Context>, reverter?: FieldConverter<To2, To, E2, ValuePath, Context>): FieldAdapterBuilder<From, To2, E | E2, ValuePath, Context>;
|
|
49
|
+
withReverter(reverter: FieldConverter<To, From, E, ValuePath, Context>): FieldAdapterBuilder<From, To, E, ValuePath, Context>;
|
|
50
|
+
withIdentity(isFrom: (from: To | From) => from is From): FieldAdapterBuilder<From, To | From, E, ValuePath, Context>;
|
|
51
|
+
}
|
|
52
|
+
declare function adapter<From, To, ValuePath extends string, Context>(converter: SafeFieldConverter<From, To, ValuePath, Context>, valueFactory: FieldValueFactory<From, ValuePath, Context>): FieldAdapterBuilder<From, To, never, ValuePath, Context>;
|
|
53
|
+
declare function adapter<From, To, E, ValuePath extends string, Context>(converter: SafeFieldConverter<From, To, ValuePath, Context>, valueFactory: FieldValueFactory<From, ValuePath, Context>, reverter: FieldConverter<To, From, E, ValuePath, Context>): FieldAdapterBuilder<From, To, E, ValuePath, Context>;
|
|
54
|
+
declare function adapterFromTwoWayConverter<From, To, E, ValuePath extends string, Context>(converter: TwoWayFieldConverter<From, To, E, ValuePath, Context>, valueFactory: FieldValueFactory<From, ValuePath, Context>): FieldAdapterBuilder<From, To, E, ValuePath, Context>;
|
|
55
|
+
declare function adapterFromTwoWayConverter<From, To, E, ValuePath extends string, Context>(converter: TwoWayFieldConverterWithValueFactory<From, To, E, ValuePath, Context>): FieldAdapterBuilder<From, To, E, ValuePath, Context>;
|
|
56
|
+
declare function adapterFromPrototype<From, To, ValuePath extends string, Context>(converter: SafeFieldConverter<From, To, ValuePath, Context>, prototype: From): FieldAdapterBuilder<From, To, never, ValuePath, Context>;
|
|
57
|
+
declare function adapterFromPrototype<From, To, E, ValuePath extends string, Context>(converter: TwoWayFieldConverter<From, To, E, ValuePath, Context>, prototype: From): FieldAdapterBuilder<From, To, E, ValuePath, Context>;
|
|
58
|
+
declare function identityAdapter<V, ValuePath extends string, Context>(prototype: V): FieldAdapterBuilder<V, V, never, ValuePath, Context>;
|
|
59
|
+
declare function listAdapter<E, K extends string, ValuePath extends string, Context>(): FieldAdapterBuilder<readonly E[], readonly K[], never, ValuePath, Context>;
|
|
60
|
+
|
|
61
|
+
type FieldAdapter<From = any, To = any, E = any, ValuePath extends string = any, Context = any> = {
|
|
62
|
+
readonly convert: SafeFieldConverter<From, To, ValuePath, Context>;
|
|
63
|
+
readonly create: FieldValueFactory<From, ValuePath, Context>;
|
|
64
|
+
readonly revert?: FieldConverter<To, From, E, ValuePath, Context>;
|
|
65
|
+
};
|
|
66
|
+
type ToTypeOfFieldAdapter<C extends FieldAdapter> = C extends FieldAdapter<infer _F, infer To> ? To : never;
|
|
67
|
+
type ErrorTypeOfFieldAdapter<C extends FieldAdapter> = C extends FieldAdapter<infer _From, infer _To, infer E> ? NonNullable<E> : never;
|
|
68
|
+
|
|
69
|
+
type Field<V = any, E = any> = {
|
|
70
|
+
readonly value: V;
|
|
71
|
+
readonly error?: E | undefined;
|
|
72
|
+
readonly disabled: boolean;
|
|
73
|
+
readonly required: boolean;
|
|
74
|
+
};
|
|
75
|
+
type Fields = Readonly<Record<string, Field>>;
|
|
76
|
+
|
|
77
|
+
type FlattenedAdaptersOfFields<ValuePathsToTypePaths extends Readonly<Record<string, string>>, FlattenedTypeDefs extends Partial<Readonly<Record<ValueOf<ValuePathsToTypePaths>, Type>>>, FormFields extends Partial<Readonly<Record<keyof ValuePathsToTypePaths, Field>>>> = SimplifyDeep<{
|
|
78
|
+
readonly [K in keyof ValuePathsToTypePaths as FormFields[K] extends Field ? ValuePathsToTypePaths[K] : never]: AdapterOfField<NonNullable<FormFields[K]>, FlattenedTypeDefs[ValuePathsToTypePaths[K]], K>;
|
|
79
|
+
}>;
|
|
80
|
+
type AdapterOfField<F extends Field, T extends Type | undefined, ValuePath extends string | number | symbol> = ValuePath extends string ? F extends Field<infer V, infer E> ? undefined extends T ? FieldAdapter<V, V, E, ValuePath> : FieldAdapter<ValueTypeOf<ReadonlyTypeDefOf<NonNullable<T>>>, V, E, ValuePath> : never : never;
|
|
81
|
+
|
|
82
|
+
type FlattenedListTypeDefsOf<T extends Type> = FlattenedListTypeDefsOfFlattened<SimplifyDeep<FlattenedTypeDefsOf<T, null>>>;
|
|
83
|
+
type FlattenedListTypeDefsOfFlattened<T extends Readonly<Record<string, Type>>> = {
|
|
84
|
+
[K in keyof T as T[K]['definition'] extends ListTypeDef ? K : never]: T[K];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
type FlattenedConvertedFieldsOf<ValuePathsToAdapters extends Readonly<Record<string, FieldAdapter>>> = {
|
|
88
|
+
readonly [K in keyof ValuePathsToAdapters]: Field<ToTypeOfFieldAdapter<ValuePathsToAdapters[K]>, ErrorTypeOfFieldAdapter<ValuePathsToAdapters[K]>>;
|
|
89
|
+
};
|
|
90
|
+
type FlattenedTypePathsToAdaptersOf<FlattenedValues extends Readonly<Record<string, any>>, Context> = {
|
|
91
|
+
readonly [K in keyof FlattenedValues]?: FieldAdapter<ReadonlyDeep<FlattenedValues[K]>, any, any, any, Context>;
|
|
92
|
+
};
|
|
93
|
+
type FieldOverride<V = any> = {
|
|
94
|
+
value: V;
|
|
95
|
+
};
|
|
96
|
+
type FlattenedFieldOverrides<ValuePathsToAdapters extends Readonly<Record<string, FieldAdapter>>> = {
|
|
97
|
+
-readonly [K in keyof ValuePathsToAdapters]?: FieldOverride<ToTypeOfFieldAdapter<ValuePathsToAdapters[K]>>;
|
|
98
|
+
};
|
|
99
|
+
type FlattenedErrors<ValuePathsToAdapters extends Readonly<Record<string, FieldAdapter>>> = {
|
|
100
|
+
-readonly [K in keyof ValuePathsToAdapters]?: ErrorTypeOfFieldAdapter<ValuePathsToAdapters[K]>;
|
|
101
|
+
};
|
|
102
|
+
type ValuePathsToAdaptersOf<TypePathsToAdapters extends Partial<Readonly<Record<string, FieldAdapter>>>, ValuePathsToTypePaths extends Readonly<Record<string, string>>> = keyof TypePathsToAdapters extends ValueOf<ValuePathsToTypePaths> ? {
|
|
103
|
+
readonly [K in keyof ValuePathsToTypePaths as unknown extends TypePathsToAdapters[ValuePathsToTypePaths[K]] ? never : K]: NonNullable<TypePathsToAdapters[ValuePathsToTypePaths[K]]>;
|
|
104
|
+
} : never;
|
|
105
|
+
declare class FormPresenter<T extends Type, ValueToTypePaths extends Readonly<Record<string, string>>, TypePathsToAdapters extends FlattenedTypePathsToAdaptersOf<FlattenedValueTypesOf<T, '*'>, ValueTypeOf<ReadonlyTypeDefOf<T>>>, ValuePathsToAdapters extends ValuePathsToAdaptersOf<TypePathsToAdapters, ValueToTypePaths> = ValuePathsToAdaptersOf<TypePathsToAdapters, ValueToTypePaths>> {
|
|
106
|
+
readonly typeDef: T;
|
|
107
|
+
private readonly adapters;
|
|
108
|
+
constructor(typeDef: T, adapters: TypePathsToAdapters);
|
|
109
|
+
private maybeGetAdapterForValuePath;
|
|
110
|
+
private getAdapterForValuePath;
|
|
111
|
+
typePath<K extends keyof ValueToTypePaths>(valuePath: K): ValueToTypePaths[K];
|
|
112
|
+
setFieldValueAndValidate<K extends keyof ValuePathsToAdapters>(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>, valuePath: K, value: ToTypeOfFieldAdapter<ValuePathsToAdapters[K]>): boolean;
|
|
113
|
+
setFieldValue<K extends keyof ValuePathsToAdapters>(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>, valuePath: K, value: ToTypeOfFieldAdapter<ValuePathsToAdapters[K]>): boolean;
|
|
114
|
+
addListItem<K extends keyof FlattenedListTypeDefsOf<T>>(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>, valuePath: K, elementValue: Maybe<ElementOfArray<FlattenedValueTypesOf<T>[K]>>, index?: number): void;
|
|
115
|
+
removeListItem<K extends keyof FlattenedListTypeDefsOf<T>>(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>, elementValuePath: `${K}.${number}`): void;
|
|
116
|
+
private internalSetFieldValue;
|
|
117
|
+
clearFieldError<K extends keyof ValuePathsToAdapters>(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>, valuePath: K): void;
|
|
118
|
+
clearFieldValue<K extends StringKeyOf<ValuePathsToAdapters>>(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>, valuePath: K): void;
|
|
119
|
+
clearAll(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>, value: ValueTypeOf<T>): void;
|
|
120
|
+
validateField<K extends keyof ValuePathsToAdapters>(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>, valuePath: K): boolean;
|
|
121
|
+
validateAll(model: FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>): boolean;
|
|
122
|
+
createModel(value: ValueTypeOf<ReadonlyTypeDefOf<T>>): FormModel<T, ValueToTypePaths, TypePathsToAdapters, ValuePathsToAdapters>;
|
|
123
|
+
}
|
|
124
|
+
declare class FormModel<T extends Type, ValueToTypePaths extends Readonly<Record<string, string>>, TypePathsToAdapters extends FlattenedTypePathsToAdaptersOf<FlattenedValueTypesOf<T, '*'>, ValueTypeOf<ReadonlyTypeDefOf<T>>>, ValuePathsToAdapters extends ValuePathsToAdaptersOf<TypePathsToAdapters, ValueToTypePaths> = ValuePathsToAdaptersOf<TypePathsToAdapters, ValueToTypePaths>> {
|
|
125
|
+
private readonly typeDef;
|
|
126
|
+
private readonly adapters;
|
|
127
|
+
accessor value: MobxValueTypeOf<T>;
|
|
128
|
+
accessor fieldOverrides: FlattenedFieldOverrides<ValuePathsToAdapters>;
|
|
129
|
+
accessor errors: FlattenedErrors<ValuePathsToAdapters>;
|
|
130
|
+
private readonly flattenedTypeDefs;
|
|
131
|
+
constructor(typeDef: T, value: ValueTypeOf<ReadonlyTypeDefOf<T>>, adapters: TypePathsToAdapters);
|
|
132
|
+
get fields(): SimplifyDeep<FlattenedConvertedFieldsOf<ValuePathsToAdapters>>;
|
|
133
|
+
private get knownFields();
|
|
134
|
+
private maybeSynthesizeFieldByValuePath;
|
|
135
|
+
private synthesizeFieldByPaths;
|
|
136
|
+
getAccessorForValuePath(valuePath: keyof ValuePathsToAdapters): Accessor | undefined;
|
|
137
|
+
get accessors(): Readonly<Record<string, Accessor>>;
|
|
138
|
+
protected isDisabled(_valuePath: keyof ValuePathsToAdapters): boolean;
|
|
139
|
+
protected isRequired(_valuePath: keyof ValuePathsToAdapters): boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Used to extract the supported value paths from a presenter
|
|
144
|
+
*/
|
|
145
|
+
type ValuePathsOfPresenter<Presenter extends FormPresenter<any, any, any, any>> = Presenter extends FormPresenter<infer _1, infer _2, infer _3, infer ValuePathsToAdapters> ? keyof ValuePathsToAdapters : never;
|
|
146
|
+
/**
|
|
147
|
+
* Used to extract the render type (so the value that is passed to the view) of a given value path
|
|
148
|
+
* from a presenter
|
|
149
|
+
*/
|
|
150
|
+
type ToTypeOfPresenterValuePath<Presenter extends FormPresenter<any, any, any, any>, K extends ValuePathsOfPresenter<Presenter>> = Presenter extends FormPresenter<infer _1, infer _2, infer _3, infer ValuePathsToAdapters> ? ToTypeOfFieldAdapter<ValuePathsToAdapters[K]> : never;
|
|
151
|
+
/**
|
|
152
|
+
* Extracts the form fields from the presenter. The recommended way is to
|
|
153
|
+
* define the form fields explicitly and use that type to enforce the types
|
|
154
|
+
* of your converters, but generating the FormFields from your presenter
|
|
155
|
+
* is less typing, albeit at the cost of potentially getting type errors
|
|
156
|
+
* reported a long way away from the source
|
|
157
|
+
*/
|
|
158
|
+
type FormFieldsOfPresenter<Presenter extends FormPresenter<any, any, any, any>> = Presenter extends FormPresenter<infer _1, infer _2, infer _3, infer ValuePathsToAdapters> ? FlattenedConvertedFieldsOf<ValuePathsToAdapters> : never;
|
|
159
|
+
|
|
160
|
+
type FormProps<F extends Fields> = {
|
|
161
|
+
fields: F;
|
|
162
|
+
onFieldValueChange<K extends keyof F>(this: void, key: K, value: F[K]['value']): void;
|
|
163
|
+
onFieldFocus?(this: void, key: keyof F): void;
|
|
164
|
+
onFieldBlur?(this: void, key: keyof F): void;
|
|
165
|
+
onFieldSubmit?(this: void, key: keyof F): boolean | void;
|
|
166
|
+
};
|
|
167
|
+
type EditorProps<O> = {
|
|
168
|
+
value: O;
|
|
169
|
+
onValueChange: (value: O) => void;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
declare class IntegerToStringConverter<E, ValuePath extends string, Context> implements TwoWayFieldConverter<number, string, E, ValuePath, Context> {
|
|
173
|
+
private readonly isNanError;
|
|
174
|
+
constructor(isNanError: E);
|
|
175
|
+
convert(from: number): string;
|
|
176
|
+
revert(from: string): FieldConversion<number, E>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare class NullableToBooleanConverter<T extends Type, E, ValuePath extends string, Context> implements TwoWayFieldConverterWithValueFactory<ValueTypeOf<ReadonlyTypeDefOf<T>> | null, boolean, E, ValuePath, Context> {
|
|
180
|
+
private readonly typeDef;
|
|
181
|
+
private readonly prototype;
|
|
182
|
+
readonly defaultValue: ValueTypeOf<ReadonlyTypeDefOf<T>> | null;
|
|
183
|
+
constructor(typeDef: T, prototype: ValueTypeOf<ReadonlyTypeDefOf<T>>, defaultToNull?: boolean);
|
|
184
|
+
convert(from: ValueTypeOf<ReadonlyTypeDefOf<T>> | null): boolean;
|
|
185
|
+
revert(from: boolean): FieldConversion<ValueTypeOf<ReadonlyTypeDefOf<T>> | null, E>;
|
|
186
|
+
create(): ValueTypeOf<ReadonlyTypeDefOf<T>> | null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare abstract class AbstractSelectValueTypeConverter<T extends Type, To extends string | null, Values extends Readonly<Record<NonNullable<To>, ValueTypeOf<T>>>, NoSuchValueError, ValuePath extends string, Context> implements TwoWayFieldConverterWithValueFactory<ValueTypeOf<T>, keyof Values | null, NoSuchValueError, ValuePath, Context> {
|
|
190
|
+
protected readonly typeDef: T;
|
|
191
|
+
protected readonly values: Values;
|
|
192
|
+
private readonly defaultValueKey;
|
|
193
|
+
private readonly noSuchValueError;
|
|
194
|
+
constructor(typeDef: T, values: Values, defaultValueKey: keyof Values | null, noSuchValueError: NoSuchValueError | null);
|
|
195
|
+
revert(from: keyof Values | null): FieldConversion<ValueTypeOf<T>, NoSuchValueError>;
|
|
196
|
+
convert(from: ValueTypeOf<T>): To;
|
|
197
|
+
protected abstract doConvert(from: ValueTypeOf<T>): To;
|
|
198
|
+
create(): ValueTypeOf<T>;
|
|
199
|
+
}
|
|
200
|
+
declare class SelectDiscriminatedUnionConverter<U extends UnionTypeDef, To extends StringKeyOf$1<U['unions']> | null, ValuePath extends string, Context> extends AbstractSelectValueTypeConverter<Type<U>, To, ValueTypesOfDiscriminatedUnion<U>, never, ValuePath, Context> {
|
|
201
|
+
constructor(typeDef: Type<U>, values: ValueTypesOfDiscriminatedUnion<U>, defaultValueKey: keyof U['unions']);
|
|
202
|
+
protected doConvert(from: ValueTypeOf<Type<U>>): any;
|
|
203
|
+
}
|
|
204
|
+
declare class SelectLiteralConverter<L extends string | number | null, To extends string | null, Values extends Record<NonNullable<L>, NonNullable<To>>, NoSuchValueError, ValuePath extends string, Context> extends AbstractSelectValueTypeConverter<Type<LiteralTypeDef<L>>, To, Record<NonNullable<To>, L>, NoSuchValueError, ValuePath, Context> {
|
|
205
|
+
private readonly valuesToStrings;
|
|
206
|
+
constructor(typeDef: Type<LiteralTypeDef<L>>, valuesToStrings: Values, defaultValue: L | null, noSuchValueError: NoSuchValueError | null);
|
|
207
|
+
protected doConvert(from: L): Values[NonNullable<L>];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare class TrimmingStringConverter<ValuePath extends string, Context> implements TwoWayFieldConverter<string, string, never, ValuePath, Context> {
|
|
211
|
+
constructor();
|
|
212
|
+
convert(to: string): string;
|
|
213
|
+
revert(from: string): FieldConversion<string, never>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare function validatingConverter<V, E, ValuePath extends string, Context>(validators?: readonly FieldValidator<V, E, ValuePath, Context>[]): FieldConverter<V, V, E, ValuePath, Context>;
|
|
217
|
+
|
|
218
|
+
declare function minimumStringLengthFieldValidatorFactory<E, ValuePath extends string, Context>(minimumLength: number, error: E): FieldValidator<string, E, ValuePath, Context>;
|
|
219
|
+
|
|
220
|
+
declare function prototypingFieldValueFactory<V, ValuePath extends string, Context>(prototype: V): FieldValueFactory<V, ValuePath, Context>;
|
|
221
|
+
|
|
222
|
+
type ValueTypeOfField<F extends Field> = F extends Field<infer V> ? V : never;
|
|
223
|
+
|
|
224
|
+
type AllFieldsOfFields<F extends Fields> = {
|
|
225
|
+
[K in keyof F as ValueTypeOfField<F[K]> extends any ? K : never]: F[K];
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
type BooleanFieldsOfFields<F extends Fields> = {
|
|
229
|
+
[K in keyof F as ValueTypeOfField<F[K]> extends boolean ? K : never]: F[K];
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
type ErrorTypeOfField<F extends Field> = F extends Field<infer _V, infer E> ? E : never;
|
|
233
|
+
|
|
234
|
+
type ListFieldsOfFields<F extends Fields> = {
|
|
235
|
+
[K in keyof F as ValueTypeOfField<F[K]> extends readonly any[] ? K : never]: F[K];
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
type StringFieldsOfFields<F extends Fields> = {
|
|
239
|
+
[K in keyof F as ValueTypeOfField<F[K]> extends string | undefined | null ? K : never]: F[K];
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
type PartialComponent<Component extends ComponentType<any>, CurriedProps, AdditionalProps = {}> = Exclude<keyof CurriedProps, keyof ComponentProps<Component>> extends never ? UnsafePartialComponent<Component, CurriedProps, AdditionalProps> : keyof CurriedProps extends (string | number) ? `unmatched prop: ${Exclude<keyof CurriedProps, keyof ComponentProps<Component>>}` : Exclude<keyof CurriedProps, keyof ComponentProps<Component>>;
|
|
243
|
+
type UnsafePartialComponent<Component extends ComponentType<any>, CurriedProps, AdditionalProps = {}> = ForwardRefExoticComponent<PropsWithoutRef<RemainingComponentProps<Component, CurriedProps> & AdditionalProps>>;
|
|
244
|
+
declare function createSimplePartialComponent<Component extends ComponentType<any>, CurriedProps extends Partial<ComponentProps<Component>>>(Component: Component, curriedProps: CurriedProps): PartialComponent<Component, CurriedProps>;
|
|
245
|
+
declare function createPartialComponent<Component extends ComponentType<any>, CurriedProps extends Partial<ComponentProps<Component>>, AdditionalProps = {}>(Component: Component, curriedPropsSource: (additionalProps: AdditionalProps) => CurriedProps): PartialComponent<Component, CurriedProps, AdditionalProps>;
|
|
246
|
+
declare function usePartialComponent<Component extends ComponentType<any>, CurriedProps extends Partial<ComponentProps<Component>>, AdditionalProps = {}>(createCurriedProps: (additionalProps: AdditionalProps) => CurriedProps, deps: DependencyList, Component: Component): PartialComponent<Component, CurriedProps, AdditionalProps>;
|
|
247
|
+
declare function createPartialObserverComponent<Component extends ComponentType<any>, CurriedProps extends Partial<ComponentProps<Component>>, AdditionalProps = {}>(Component: Component, curriedPropsSource: (additionalProps: AdditionalProps) => CurriedProps): PartialComponent<Component, CurriedProps, AdditionalProps>;
|
|
248
|
+
declare function createUnsafePartialObserverComponent<Component extends ComponentType<any>, CurriedProps, AdditionalProps = {}>(Component: Component, curriedPropsSource: (additionalProps: AdditionalProps) => CurriedProps): UnsafePartialComponent<Component, CurriedProps, AdditionalProps>;
|
|
249
|
+
declare function usePartialObserverComponent<Component extends ComponentType<any>, CurriedProps extends Partial<ComponentProps<Component>>, AdditionalProps = {}>(curriedPropsSource: (additionalProps: AdditionalProps) => CurriedProps, deps: DependencyList, Component: Component): PartialComponent<Component, CurriedProps, AdditionalProps>;
|
|
250
|
+
type RemainingComponentProps<Component extends ComponentType, CurriedProps> = Omit<ComponentProps<Component>, keyof CurriedProps> & JSX.IntrinsicAttributes;
|
|
251
|
+
|
|
252
|
+
type MantineForm<F extends Fields> = {
|
|
253
|
+
fields: F;
|
|
254
|
+
onFieldValueChange: (<K extends keyof F>(this: void, key: K, value: F[K]['value']) => void) | undefined;
|
|
255
|
+
onFieldFocus: ((this: void, key: keyof F) => void) | undefined;
|
|
256
|
+
onFieldBlur: ((this: void, key: keyof F) => void) | undefined;
|
|
257
|
+
onFieldSubmit: ((this: void, key: keyof F) => boolean | void) | undefined;
|
|
258
|
+
};
|
|
259
|
+
type MantineFieldComponent<T, P = T> = UnsafePartialComponent<ComponentType<P>, T>;
|
|
260
|
+
|
|
261
|
+
type SuppliedCheckboxProps = Pick<CheckboxProps, 'name' | 'checked' | 'disabled' | 'required' | 'error' | 'onChange' | 'onFocus' | 'onBlur' | 'onKeyUp'>;
|
|
262
|
+
|
|
263
|
+
type SuppliedListProps<Value = any> = {
|
|
264
|
+
values: readonly Value[];
|
|
265
|
+
};
|
|
266
|
+
declare function DefaultList<Value>({ values, children, }: SuppliedListProps<Value> & {
|
|
267
|
+
children: (value: Value, index: number) => React.ReactNode;
|
|
268
|
+
}): react_jsx_runtime.JSX.Element;
|
|
269
|
+
|
|
270
|
+
type SuppliedPillProps = Pick<PillProps, 'children' | 'disabled'>;
|
|
271
|
+
|
|
272
|
+
type SuppliedRadioProps = Pick<RadioProps, 'value' | 'disabled'>;
|
|
273
|
+
|
|
274
|
+
type SuppliedRadioGroupProps = Pick<RadioGroupProps, 'name' | 'value' | 'required' | 'error' | 'onChange' | 'onFocus' | 'onBlur' | 'onKeyUp'>;
|
|
275
|
+
|
|
276
|
+
type TextInputTarget = Element & {
|
|
277
|
+
value: string;
|
|
278
|
+
};
|
|
279
|
+
type SuppliedTextInputProps<T extends TextInputTarget = TextInputTarget> = Partial<{
|
|
280
|
+
name: string;
|
|
281
|
+
value: string | number | readonly string[] | undefined;
|
|
282
|
+
disabled: boolean;
|
|
283
|
+
required: boolean;
|
|
284
|
+
onChange: (e: React.ChangeEvent<T>) => void;
|
|
285
|
+
onFocus: (e: React.FocusEvent<T>) => void;
|
|
286
|
+
onBlur: (e: React.FocusEvent<T>) => void;
|
|
287
|
+
onKeyUp: (e: React.KeyboardEvent<T>) => void;
|
|
288
|
+
}>;
|
|
289
|
+
|
|
290
|
+
type SuppliedValueInputProps<V, T extends Element = Element> = Partial<{
|
|
291
|
+
name: string;
|
|
292
|
+
value: V;
|
|
293
|
+
disabled: boolean;
|
|
294
|
+
required: boolean;
|
|
295
|
+
onChange: (value: V) => void;
|
|
296
|
+
onFocus: (e: React.FocusEvent<T>) => void;
|
|
297
|
+
onBlur: (e: React.FocusEvent<T>) => void;
|
|
298
|
+
onKeyUp: (e: React.KeyboardEvent<T>) => void;
|
|
299
|
+
}>;
|
|
300
|
+
|
|
301
|
+
declare function SimpleSelect(props: SelectProps & {
|
|
302
|
+
onChange?: (value: string | null) => void;
|
|
303
|
+
}): react_jsx_runtime.JSX.Element;
|
|
304
|
+
type ErrorRendererProps<E> = {
|
|
305
|
+
error: E;
|
|
306
|
+
};
|
|
307
|
+
type ErrorRenderer<E = any> = React.ComponentType<ErrorRendererProps<E>>;
|
|
308
|
+
declare function useMantineForm<F extends Fields>({ onFieldValueChange, onFieldBlur, onFieldFocus, onFieldSubmit, fields, }: FormProps<F>): MantineFormImpl<F>;
|
|
309
|
+
declare class MantineFormImpl<F extends Fields> implements MantineForm<F> {
|
|
310
|
+
private readonly textInputCache;
|
|
311
|
+
private readonly valueInputCache;
|
|
312
|
+
private readonly checkboxCache;
|
|
313
|
+
private readonly radioGroupCache;
|
|
314
|
+
private readonly radioCache;
|
|
315
|
+
private readonly pillCache;
|
|
316
|
+
private readonly listCache;
|
|
317
|
+
accessor fields: F;
|
|
318
|
+
onFieldValueChange: (<K extends keyof F>(this: void, key: K, value: F[K]['value']) => void) | undefined;
|
|
319
|
+
onFieldFocus: ((this: void, key: keyof F) => void) | undefined;
|
|
320
|
+
onFieldBlur: ((this: void, key: keyof F) => void) | undefined;
|
|
321
|
+
onFieldSubmit: ((this: void, key: keyof F) => boolean | void) | undefined;
|
|
322
|
+
constructor(fields: F);
|
|
323
|
+
textInput<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedTextInputProps, TextInputProps>;
|
|
324
|
+
textInput<K extends keyof StringFieldsOfFields<F>, P extends SuppliedTextInputProps<any>>(valuePath: K, TextInput?: ComponentType<P>, ErrorRenderer?: ErrorRenderer<ErrorTypeOfField<F[K]>>): MantineFieldComponent<SuppliedTextInputProps, P>;
|
|
325
|
+
valueInput<K extends keyof AllFieldsOfFields<F>, P extends SuppliedValueInputProps<ValueTypeOfField<F[K]>, any>>(valuePath: K, ValueInput: ComponentType<P>, ErrorRenderer?: ErrorRenderer<ErrorTypeOfField<F[K]>>): MantineFieldComponent<SuppliedValueInputProps<ValueTypeOfField<F[K]>>, P>;
|
|
326
|
+
select<K extends keyof StringFieldsOfFields<F>>(valuePath: K, ErrorRenderer?: ErrorRenderer<ErrorTypeOfField<F[K]>>): MantineFieldComponent<SuppliedTextInputProps, ComponentProps<typeof SimpleSelect>>;
|
|
327
|
+
checkbox<K extends keyof BooleanFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedCheckboxProps, CheckboxProps>;
|
|
328
|
+
checkbox<K extends keyof BooleanFieldsOfFields<F>, P extends SuppliedCheckboxProps>(valuePath: K, Checkbox: ComponentType<P>, ErrorRenderer?: ErrorRenderer<ErrorTypeOfField<F[K]>>): MantineFieldComponent<SuppliedCheckboxProps, P>;
|
|
329
|
+
radioGroup<K extends keyof StringFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedRadioGroupProps, RadioGroupProps>;
|
|
330
|
+
radioGroup<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioGroupProps>(valuePath: K, RadioGroup: ComponentType<P>, ErrorRenderer?: ErrorRenderer<ErrorTypeOfField<F[K]>>): MantineFieldComponent<SuppliedRadioGroupProps, P>;
|
|
331
|
+
radio<K extends keyof StringFieldsOfFields<F>>(valuePath: K, value: ValueTypeOfField<F[K]>): MantineFieldComponent<SuppliedRadioProps, RadioProps>;
|
|
332
|
+
radio<K extends keyof StringFieldsOfFields<F>, P extends SuppliedRadioProps>(valuePath: K, value: ValueTypeOfField<F[K]>, Radio: ComponentType<P>): MantineFieldComponent<SuppliedRadioProps, P>;
|
|
333
|
+
pill<K extends keyof AllFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedPillProps, PillProps>;
|
|
334
|
+
pill<K extends keyof AllFieldsOfFields<F>, P extends SuppliedPillProps>(valuePath: K, Pill: ComponentType<P>): MantineFieldComponent<SuppliedPillProps, P>;
|
|
335
|
+
list<K extends keyof ListFieldsOfFields<F>>(valuePath: K): MantineFieldComponent<SuppliedListProps<ElementOfArray<F[K]>>, ComponentProps<typeof DefaultList<ElementOfArray<F[K]>>>>;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Maps type paths to value paths for
|
|
340
|
+
*/
|
|
341
|
+
type FlattenedFormFieldsOf<JsonPaths extends Record<string, string>, TypePathsToFormFields extends Partial<Readonly<Record<ValueOf<JsonPaths>, Field>>>> = keyof TypePathsToFormFields extends ValueOf<JsonPaths> ? {
|
|
342
|
+
readonly [K in keyof JsonPaths as unknown extends TypePathsToFormFields[JsonPaths[K]] ? never : K]: TypePathsToFormFields[JsonPaths[K]];
|
|
343
|
+
} : `fields missing paths: ${PrintableOf<Exclude<keyof TypePathsToFormFields, ValueOf<JsonPaths>>>}`;
|
|
344
|
+
|
|
345
|
+
export { AbstractSelectValueTypeConverter, type EditorProps, type ErrorRenderer, type ErrorRendererProps, type Field, type Fields, type FlattenedAdaptersOfFields, type FlattenedConvertedFieldsOf, type FlattenedFormFieldsOf, type FlattenedTypePathsToAdaptersOf, type FormFieldsOfPresenter, FormModel, FormPresenter, type FormProps, IntegerToStringConverter, NullableToBooleanConverter, type PartialComponent, SelectDiscriminatedUnionConverter, SelectLiteralConverter, type ToTypeOfPresenterValuePath, TrimmingStringConverter, type UnsafePartialComponent, type ValuePathsOfPresenter, type ValuePathsToAdaptersOf, adapter, adapterFromPrototype, adapterFromTwoWayConverter, createPartialComponent, createPartialObserverComponent, createSimplePartialComponent, createUnsafePartialObserverComponent, identityAdapter, listAdapter, minimumStringLengthFieldValidatorFactory, prototypingFieldValueFactory, useMantineForm, usePartialComponent, usePartialObserverComponent, validatingConverter };
|