@strictly/react-form 0.0.21 → 0.0.23
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/hooks.d.ts +2 -3
- package/.out/core/mobx/specs/form_model.tests.js +7 -7
- package/.out/index.d.ts +0 -1
- package/.out/index.js +0 -1
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.turbo/turbo-build.log +7 -7
- package/core/mobx/hooks.tsx +7 -11
- package/core/mobx/specs/form_model.tests.ts +7 -7
- package/dist/index.d.cts +3 -21
- package/dist/index.d.ts +3 -21
- package/index.ts +0 -1
- package/package.json +11 -9
- package/.out/core/mobx/types.d.ts +0 -19
- package/.out/core/mobx/types.js +0 -1
- package/core/mobx/types.ts +0 -57
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,12 +7,12 @@ $ tsup
|
|
|
7
7
|
[34mCLI[39m Target: es6
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m60.71 KB[39m
|
|
11
|
-
[32mCJS[39m ⚡️ Build success in 127ms
|
|
12
10
|
[32mESM[39m [1mdist/index.js [22m[32m56.70 KB[39m
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m ⚡️ Build success in 139ms
|
|
12
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m60.71 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 141ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
18
|
-
Done in
|
|
15
|
+
[32mDTS[39m ⚡️ Build success in 31420ms
|
|
16
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m37.20 KB[39m
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m37.20 KB[39m
|
|
18
|
+
Done in 32.57s.
|
package/core/mobx/hooks.tsx
CHANGED
|
@@ -5,14 +5,10 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
useCallback,
|
|
7
7
|
} from 'react'
|
|
8
|
+
import type { ValueTypeOfField } from 'types/value_type_of_field'
|
|
8
9
|
import {
|
|
9
10
|
type FormModel,
|
|
10
11
|
} from './form_model'
|
|
11
|
-
import {
|
|
12
|
-
type FormFieldsOfModel,
|
|
13
|
-
type ToValueOfModelValuePath,
|
|
14
|
-
type ValuePathsOfModel,
|
|
15
|
-
} from './types'
|
|
16
12
|
|
|
17
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
14
|
type ValueOfModel<M extends FormModel<any, any, any, any, any>> = M extends FormModel<infer T, any, any, any, any>
|
|
@@ -22,14 +18,14 @@ type ValueOfModel<M extends FormModel<any, any, any, any, any>> = M extends Form
|
|
|
22
18
|
export function useDefaultMobxFormHooks<
|
|
23
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
20
|
M extends FormModel<any, any, any, any, any>,
|
|
25
|
-
F extends
|
|
21
|
+
F extends M['fields'] = M['fields'],
|
|
26
22
|
>(
|
|
27
23
|
model: M,
|
|
28
24
|
{
|
|
29
25
|
onValidFieldSubmit,
|
|
30
26
|
onValidFormSubmit,
|
|
31
27
|
}: {
|
|
32
|
-
onValidFieldSubmit?: <Path extends
|
|
28
|
+
onValidFieldSubmit?: <Path extends keyof F>(valuePath: Path) => void,
|
|
33
29
|
onValidFormSubmit?: (value: ValueOfModel<M>) => void,
|
|
34
30
|
} = {},
|
|
35
31
|
): {
|
|
@@ -40,9 +36,9 @@ export function useDefaultMobxFormHooks<
|
|
|
40
36
|
onFieldSubmit?(this: void, key: keyof F): boolean | void,
|
|
41
37
|
} {
|
|
42
38
|
const onFieldValueChange = useCallback(
|
|
43
|
-
function<Path extends
|
|
39
|
+
function<Path extends keyof F> (
|
|
44
40
|
path: Path,
|
|
45
|
-
value:
|
|
41
|
+
value: ValueTypeOfField<F[Path]>,
|
|
46
42
|
) {
|
|
47
43
|
// clear any validation
|
|
48
44
|
model.setFieldValue<Path>(path, value, null)
|
|
@@ -51,7 +47,7 @@ export function useDefaultMobxFormHooks<
|
|
|
51
47
|
)
|
|
52
48
|
|
|
53
49
|
const onFieldSubmit = useCallback(
|
|
54
|
-
function<Path extends
|
|
50
|
+
function<Path extends keyof F> (valuePath: Path) {
|
|
55
51
|
if (model.validateField(valuePath)) {
|
|
56
52
|
onValidFieldSubmit?.(valuePath)
|
|
57
53
|
}
|
|
@@ -64,7 +60,7 @@ export function useDefaultMobxFormHooks<
|
|
|
64
60
|
)
|
|
65
61
|
|
|
66
62
|
const onFieldBlur = useCallback(
|
|
67
|
-
function<Path extends
|
|
63
|
+
function<Path extends keyof F> (path: Path) {
|
|
68
64
|
// work around potential loss of focus prior to state potentially invalidating change triggering
|
|
69
65
|
// (e.g. changing a discriminator)
|
|
70
66
|
// TODO debounce?
|
|
@@ -93,7 +93,7 @@ describe('all', function () {
|
|
|
93
93
|
resetMockAdapter(originalBooleanToBooleanAdapter, booleanToBooleanAdapter)
|
|
94
94
|
})
|
|
95
95
|
|
|
96
|
-
describe('
|
|
96
|
+
describe('FlattenedTypePathsToAdaptersOf', function () {
|
|
97
97
|
type ConvenientFieldAdapter<
|
|
98
98
|
From,
|
|
99
99
|
Context,
|
|
@@ -1066,8 +1066,8 @@ describe('all', function () {
|
|
|
1066
1066
|
'x',
|
|
1067
1067
|
true,
|
|
1068
1068
|
)).narrow,
|
|
1069
|
-
'
|
|
1070
|
-
'
|
|
1069
|
+
'$:x.a': identityAdapter(0).narrow,
|
|
1070
|
+
'$:y.b': identityAdapter(false).narrow,
|
|
1071
1071
|
} as const
|
|
1072
1072
|
|
|
1073
1073
|
describe('isValuePathActive', function () {
|
|
@@ -1091,11 +1091,11 @@ describe('all', function () {
|
|
|
1091
1091
|
true,
|
|
1092
1092
|
],
|
|
1093
1093
|
[
|
|
1094
|
-
'
|
|
1094
|
+
'$:x.a',
|
|
1095
1095
|
true,
|
|
1096
1096
|
],
|
|
1097
1097
|
[
|
|
1098
|
-
'
|
|
1098
|
+
'$:y.b',
|
|
1099
1099
|
false,
|
|
1100
1100
|
],
|
|
1101
1101
|
] as const)('value path %s is active %s', function (path, expected) {
|
|
@@ -1124,11 +1124,11 @@ describe('all', function () {
|
|
|
1124
1124
|
true,
|
|
1125
1125
|
],
|
|
1126
1126
|
[
|
|
1127
|
-
'
|
|
1127
|
+
'$:x.a',
|
|
1128
1128
|
false,
|
|
1129
1129
|
],
|
|
1130
1130
|
[
|
|
1131
|
-
'
|
|
1131
|
+
'$:y.b',
|
|
1132
1132
|
true,
|
|
1133
1133
|
],
|
|
1134
1134
|
] as const)('value path %s is active %s', function (path, expected) {
|
package/dist/index.d.cts
CHANGED
|
@@ -159,27 +159,9 @@ declare abstract class FormModel<T extends Type, ValueToTypePaths extends Readon
|
|
|
159
159
|
validateAll(validation?: Validation): boolean;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
/**
|
|
163
|
-
* Used to extract the supported value paths from a model
|
|
164
|
-
*/
|
|
165
|
-
type ValuePathsOfModel<Model extends FormModel<any, any, any, any, any>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? keyof ValuePathsToAdapters : never;
|
|
166
|
-
/**
|
|
167
|
-
* Used to extract the render type (so the value that is passed to the view) of a given value path
|
|
168
|
-
* from a model
|
|
169
|
-
*/
|
|
170
|
-
type ToValueOfModelValuePath<Model extends FormModel<any, any, any, any, any>, K extends ValuePathsOfModel<Model>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? ToOfFieldAdapter<ValuePathsToAdapters[K]> : never;
|
|
171
|
-
/**
|
|
172
|
-
* Extracts the form fields from a form model. The recommended way is to
|
|
173
|
-
* define the form fields explicitly and use that type to enforce the types
|
|
174
|
-
* of your converters, but generating the FormFields from your model
|
|
175
|
-
* is less typing, albeit at the cost of potentially getting type errors
|
|
176
|
-
* reported a long way away from the source
|
|
177
|
-
*/
|
|
178
|
-
type FormFieldsOfModel<Model extends FormModel<any, any, any, any, any>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? FlattenedConvertedFieldsOf<ValuePathsToAdapters> : never;
|
|
179
|
-
|
|
180
162
|
type ValueOfModel<M extends FormModel<any, any, any, any, any>> = M extends FormModel<infer T, any, any, any, any> ? ValueOfType<ReadonlyTypeOfType<T>> : never;
|
|
181
|
-
declare function useDefaultMobxFormHooks<M extends FormModel<any, any, any, any, any>, F extends
|
|
182
|
-
onValidFieldSubmit?: <Path extends
|
|
163
|
+
declare function useDefaultMobxFormHooks<M extends FormModel<any, any, any, any, any>, F extends M['fields'] = M['fields']>(model: M, { onValidFieldSubmit, onValidFormSubmit, }?: {
|
|
164
|
+
onValidFieldSubmit?: <Path extends keyof F>(valuePath: Path) => void;
|
|
183
165
|
onValidFormSubmit?: (value: ValueOfModel<M>) => void;
|
|
184
166
|
}): {
|
|
185
167
|
onFormSubmit: () => void;
|
|
@@ -456,4 +438,4 @@ declare function mergeValidators<Validators1 extends Partial<Readonly<Record<Key
|
|
|
456
438
|
|
|
457
439
|
declare function Empty(): null;
|
|
458
440
|
|
|
459
|
-
export { AbstractSelectValueTypeConverter, type AnnotatedFieldConversion, type AnnotatedFieldConverter, type Annotation, type ContextOf, type ContextOfFieldAdapter, DefaultErrorRenderer, Empty, type ErrorOfField, type ErrorOfFieldAdapter, type ErrorRenderer, type ErrorRendererProps, type Field, type FieldAdapter, type FieldAdaptersOfValues, type FieldValueFactory, type Fields, type FieldsViewProps, type FlattenedAdaptersOfFields, type FlattenedConvertedFieldsOf, type FlattenedTypePathsToAdaptersOf, type FormFieldsOfFieldAdapters, type
|
|
441
|
+
export { AbstractSelectValueTypeConverter, type AnnotatedFieldConversion, type AnnotatedFieldConverter, type Annotation, type ContextOf, type ContextOfFieldAdapter, DefaultErrorRenderer, Empty, type ErrorOfField, type ErrorOfFieldAdapter, type ErrorRenderer, type ErrorRendererProps, type Field, type FieldAdapter, type FieldAdaptersOfValues, type FieldValueFactory, type Fields, type FieldsViewProps, type FlattenedAdaptersOfFields, type FlattenedConvertedFieldsOf, type FlattenedTypePathsToAdaptersOf, type FormFieldsOfFieldAdapters, type FormMode, FormModel, type FormProps, type FromOfFieldAdapter, IntegerToStringConverter, type MergedOfFieldAdaptersWithTwoWayConverter, type MergedOfFieldAdaptersWithValidators, type MergedOfValidator, type MergedOfValidators, NullableToBooleanConverter, type PartialComponent, type RefOfProps, SelectDiscriminatedUnionConverter, SelectLiteralConverter, SelectStringConverter, type ToOfFieldAdapter, TrimmingStringConverter, type TwoWayFieldConverter, type TwoWayFieldConverterWithValueFactory, type UnreliableFieldConversion, UnreliableFieldConversionType, type UnreliableFieldConverter, type UnsafePartialComponent, Validation, type ValuePathOfFieldAdapter, type ValuePathsToAdaptersOf, adapter, adapterFromPrototype, adapterFromTwoWayConverter, createPartialComponent, createPartialObserverComponent, createSimplePartialComponent, createUnsafePartialObserverComponent, identityAdapter, listAdapter, mergeAdaptersWithValidators, mergeFieldAdaptersWithTwoWayConverter, mergeValidators, prototypingFieldValueFactory, subFormFieldAdapters, trimmingStringAdapter, useDefaultMobxFormHooks, useMantineFormFields, usePartialComponent, usePartialObserverComponent, validatingConverter };
|
package/dist/index.d.ts
CHANGED
|
@@ -159,27 +159,9 @@ declare abstract class FormModel<T extends Type, ValueToTypePaths extends Readon
|
|
|
159
159
|
validateAll(validation?: Validation): boolean;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
/**
|
|
163
|
-
* Used to extract the supported value paths from a model
|
|
164
|
-
*/
|
|
165
|
-
type ValuePathsOfModel<Model extends FormModel<any, any, any, any, any>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? keyof ValuePathsToAdapters : never;
|
|
166
|
-
/**
|
|
167
|
-
* Used to extract the render type (so the value that is passed to the view) of a given value path
|
|
168
|
-
* from a model
|
|
169
|
-
*/
|
|
170
|
-
type ToValueOfModelValuePath<Model extends FormModel<any, any, any, any, any>, K extends ValuePathsOfModel<Model>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? ToOfFieldAdapter<ValuePathsToAdapters[K]> : never;
|
|
171
|
-
/**
|
|
172
|
-
* Extracts the form fields from a form model. The recommended way is to
|
|
173
|
-
* define the form fields explicitly and use that type to enforce the types
|
|
174
|
-
* of your converters, but generating the FormFields from your model
|
|
175
|
-
* is less typing, albeit at the cost of potentially getting type errors
|
|
176
|
-
* reported a long way away from the source
|
|
177
|
-
*/
|
|
178
|
-
type FormFieldsOfModel<Model extends FormModel<any, any, any, any, any>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? FlattenedConvertedFieldsOf<ValuePathsToAdapters> : never;
|
|
179
|
-
|
|
180
162
|
type ValueOfModel<M extends FormModel<any, any, any, any, any>> = M extends FormModel<infer T, any, any, any, any> ? ValueOfType<ReadonlyTypeOfType<T>> : never;
|
|
181
|
-
declare function useDefaultMobxFormHooks<M extends FormModel<any, any, any, any, any>, F extends
|
|
182
|
-
onValidFieldSubmit?: <Path extends
|
|
163
|
+
declare function useDefaultMobxFormHooks<M extends FormModel<any, any, any, any, any>, F extends M['fields'] = M['fields']>(model: M, { onValidFieldSubmit, onValidFormSubmit, }?: {
|
|
164
|
+
onValidFieldSubmit?: <Path extends keyof F>(valuePath: Path) => void;
|
|
183
165
|
onValidFormSubmit?: (value: ValueOfModel<M>) => void;
|
|
184
166
|
}): {
|
|
185
167
|
onFormSubmit: () => void;
|
|
@@ -456,4 +438,4 @@ declare function mergeValidators<Validators1 extends Partial<Readonly<Record<Key
|
|
|
456
438
|
|
|
457
439
|
declare function Empty(): null;
|
|
458
440
|
|
|
459
|
-
export { AbstractSelectValueTypeConverter, type AnnotatedFieldConversion, type AnnotatedFieldConverter, type Annotation, type ContextOf, type ContextOfFieldAdapter, DefaultErrorRenderer, Empty, type ErrorOfField, type ErrorOfFieldAdapter, type ErrorRenderer, type ErrorRendererProps, type Field, type FieldAdapter, type FieldAdaptersOfValues, type FieldValueFactory, type Fields, type FieldsViewProps, type FlattenedAdaptersOfFields, type FlattenedConvertedFieldsOf, type FlattenedTypePathsToAdaptersOf, type FormFieldsOfFieldAdapters, type
|
|
441
|
+
export { AbstractSelectValueTypeConverter, type AnnotatedFieldConversion, type AnnotatedFieldConverter, type Annotation, type ContextOf, type ContextOfFieldAdapter, DefaultErrorRenderer, Empty, type ErrorOfField, type ErrorOfFieldAdapter, type ErrorRenderer, type ErrorRendererProps, type Field, type FieldAdapter, type FieldAdaptersOfValues, type FieldValueFactory, type Fields, type FieldsViewProps, type FlattenedAdaptersOfFields, type FlattenedConvertedFieldsOf, type FlattenedTypePathsToAdaptersOf, type FormFieldsOfFieldAdapters, type FormMode, FormModel, type FormProps, type FromOfFieldAdapter, IntegerToStringConverter, type MergedOfFieldAdaptersWithTwoWayConverter, type MergedOfFieldAdaptersWithValidators, type MergedOfValidator, type MergedOfValidators, NullableToBooleanConverter, type PartialComponent, type RefOfProps, SelectDiscriminatedUnionConverter, SelectLiteralConverter, SelectStringConverter, type ToOfFieldAdapter, TrimmingStringConverter, type TwoWayFieldConverter, type TwoWayFieldConverterWithValueFactory, type UnreliableFieldConversion, UnreliableFieldConversionType, type UnreliableFieldConverter, type UnsafePartialComponent, Validation, type ValuePathOfFieldAdapter, type ValuePathsToAdaptersOf, adapter, adapterFromPrototype, adapterFromTwoWayConverter, createPartialComponent, createPartialObserverComponent, createSimplePartialComponent, createUnsafePartialObserverComponent, identityAdapter, listAdapter, mergeAdaptersWithValidators, mergeFieldAdaptersWithTwoWayConverter, mergeValidators, prototypingFieldValueFactory, subFormFieldAdapters, trimmingStringAdapter, useDefaultMobxFormHooks, useMantineFormFields, usePartialComponent, usePartialObserverComponent, validatingConverter };
|
package/index.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from './core/mobx/hooks'
|
|
|
8
8
|
export * from './core/mobx/merge_field_adapters_with_two_way_converter'
|
|
9
9
|
export * from './core/mobx/merge_field_adapters_with_validators'
|
|
10
10
|
export * from './core/mobx/sub_form_field_adapters'
|
|
11
|
-
export * from './core/mobx/types'
|
|
12
11
|
export * from './core/props'
|
|
13
12
|
export * from './field_converters/integer_to_string_converter'
|
|
14
13
|
export * from './field_converters/nullable_to_boolean_converter'
|
package/package.json
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Chris <chris.glover@gmail.com> (@madmaw)",
|
|
3
|
+
"dependencies": {
|
|
4
|
+
"@types/react": "^18.3.12",
|
|
5
|
+
"@types/react-dom": "^18.3.1",
|
|
6
|
+
"type-fest": "^4.27.0"
|
|
7
|
+
},
|
|
3
8
|
"description": "Types and utilities for creating React forms",
|
|
4
9
|
"devDependencies": {
|
|
5
10
|
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
@@ -17,8 +22,6 @@
|
|
|
17
22
|
"@strictly/support-vite": "*",
|
|
18
23
|
"@testing-library/dom": "^10.4.0",
|
|
19
24
|
"@testing-library/react": "^16.0.1",
|
|
20
|
-
"@types/react": "^18.3.12",
|
|
21
|
-
"@types/react-dom": "^18.3.1",
|
|
22
25
|
"@vitejs/plugin-react": "^4.3.3",
|
|
23
26
|
"concurrently": "^9.1.2",
|
|
24
27
|
"jsdom": "^25.0.1",
|
|
@@ -36,15 +39,14 @@
|
|
|
36
39
|
"license": "MIT",
|
|
37
40
|
"name": "@strictly/react-form",
|
|
38
41
|
"peerDependencies": {
|
|
39
|
-
"@mantine/core": "^7.
|
|
40
|
-
"@mantine/hooks": "^7.
|
|
42
|
+
"@mantine/core": "^7.0.0",
|
|
43
|
+
"@mantine/hooks": "^7.0.0",
|
|
41
44
|
"@strictly/base": "*",
|
|
42
45
|
"@strictly/define": "*",
|
|
43
|
-
"mobx": "^6.
|
|
46
|
+
"mobx": "^6.0.0",
|
|
44
47
|
"mobx-react": "^9.1.1",
|
|
45
|
-
"react": "^19.0.0 || ^18.
|
|
46
|
-
"react-dom": "^19.0.0 || ^18.
|
|
47
|
-
"type-fest": "^4.27.0"
|
|
48
|
+
"react": "^19.0.0 || ^18.0.0",
|
|
49
|
+
"react-dom": "^19.0.0 || ^18.0.0"
|
|
48
50
|
},
|
|
49
51
|
"publishConfig": {
|
|
50
52
|
"access": "public"
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
"test:watch": "vitest"
|
|
71
73
|
},
|
|
72
74
|
"type": "module",
|
|
73
|
-
"version": "0.0.
|
|
75
|
+
"version": "0.0.23",
|
|
74
76
|
"exports": {
|
|
75
77
|
".": {
|
|
76
78
|
"import": {
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type ToOfFieldAdapter } from './field_adapter';
|
|
2
|
-
import { type FlattenedConvertedFieldsOf, type FormModel } from './form_model';
|
|
3
|
-
/**
|
|
4
|
-
* Used to extract the supported value paths from a model
|
|
5
|
-
*/
|
|
6
|
-
export type ValuePathsOfModel<Model extends FormModel<any, any, any, any, any>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? keyof ValuePathsToAdapters : never;
|
|
7
|
-
/**
|
|
8
|
-
* Used to extract the render type (so the value that is passed to the view) of a given value path
|
|
9
|
-
* from a model
|
|
10
|
-
*/
|
|
11
|
-
export type ToValueOfModelValuePath<Model extends FormModel<any, any, any, any, any>, K extends ValuePathsOfModel<Model>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? ToOfFieldAdapter<ValuePathsToAdapters[K]> : never;
|
|
12
|
-
/**
|
|
13
|
-
* Extracts the form fields from a form model. The recommended way is to
|
|
14
|
-
* define the form fields explicitly and use that type to enforce the types
|
|
15
|
-
* of your converters, but generating the FormFields from your model
|
|
16
|
-
* is less typing, albeit at the cost of potentially getting type errors
|
|
17
|
-
* reported a long way away from the source
|
|
18
|
-
*/
|
|
19
|
-
export type FormFieldsOfModel<Model extends FormModel<any, any, any, any, any>> = Model extends FormModel<infer _1, infer _2, infer _3, infer _4, infer ValuePathsToAdapters> ? FlattenedConvertedFieldsOf<ValuePathsToAdapters> : never;
|
package/.out/core/mobx/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/core/mobx/types.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// TODO rename/split-out this file
|
|
2
|
-
import { type ToOfFieldAdapter } from './field_adapter'
|
|
3
|
-
import {
|
|
4
|
-
type FlattenedConvertedFieldsOf,
|
|
5
|
-
type FormModel,
|
|
6
|
-
} from './form_model'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Used to extract the supported value paths from a model
|
|
10
|
-
*/
|
|
11
|
-
export type ValuePathsOfModel<
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
Model extends FormModel<any, any, any, any, any>,
|
|
14
|
-
> = Model extends FormModel<
|
|
15
|
-
infer _1,
|
|
16
|
-
infer _2,
|
|
17
|
-
infer _3,
|
|
18
|
-
infer _4,
|
|
19
|
-
infer ValuePathsToAdapters
|
|
20
|
-
> ? keyof ValuePathsToAdapters
|
|
21
|
-
: never
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Used to extract the render type (so the value that is passed to the view) of a given value path
|
|
25
|
-
* from a model
|
|
26
|
-
*/
|
|
27
|
-
export type ToValueOfModelValuePath<
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
Model extends FormModel<any, any, any, any, any>,
|
|
30
|
-
K extends ValuePathsOfModel<Model>,
|
|
31
|
-
> = Model extends FormModel<
|
|
32
|
-
infer _1,
|
|
33
|
-
infer _2,
|
|
34
|
-
infer _3,
|
|
35
|
-
infer _4,
|
|
36
|
-
infer ValuePathsToAdapters
|
|
37
|
-
> ? ToOfFieldAdapter<ValuePathsToAdapters[K]>
|
|
38
|
-
: never
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Extracts the form fields from a form model. The recommended way is to
|
|
42
|
-
* define the form fields explicitly and use that type to enforce the types
|
|
43
|
-
* of your converters, but generating the FormFields from your model
|
|
44
|
-
* is less typing, albeit at the cost of potentially getting type errors
|
|
45
|
-
* reported a long way away from the source
|
|
46
|
-
*/
|
|
47
|
-
export type FormFieldsOfModel<
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
Model extends FormModel<any, any, any, any, any>,
|
|
50
|
-
> = Model extends FormModel<
|
|
51
|
-
infer _1,
|
|
52
|
-
infer _2,
|
|
53
|
-
infer _3,
|
|
54
|
-
infer _4,
|
|
55
|
-
infer ValuePathsToAdapters
|
|
56
|
-
> ? FlattenedConvertedFieldsOf<ValuePathsToAdapters>
|
|
57
|
-
: never
|