@strictly/react-form 0.0.33 → 0.0.35
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 +4 -3
- package/.out/tsconfig.tsbuildinfo +1 -1
- package/.out/util/Partial.d.ts +1 -1
- package/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-check-types.log +1 -1
- package/core/mobx/hooks.tsx +16 -3
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/package.json +3 -3
- package/util/Partial.tsx +1 -0
package/.out/util/Partial.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FriendlyExhaustiveArrayOfUnion } from '@strictly/base';
|
|
2
|
-
import { type ComponentProps, type ComponentType, type DependencyList, type ForwardRefExoticComponent, type PropsWithoutRef, type Ref, type RefAttributes } from 'react';
|
|
2
|
+
import { type ComponentProps, type ComponentType, type DependencyList, type ForwardRefExoticComponent, type JSX, type PropsWithoutRef, type Ref, type RefAttributes } from 'react';
|
|
3
3
|
export type RefOfProps<P, Fallback = unknown> = P extends RefAttributes<infer R> ? R : Fallback;
|
|
4
4
|
export 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>>;
|
|
5
5
|
export type UnsafePartialComponent<Component extends ComponentType<any>, CurriedProps, AdditionalProps = {}, R = RefOfProps<ComponentProps<Component>>> = ForwardRefExoticComponent<PropsWithoutRef<RemainingComponentProps<Component, CurriedProps> & AdditionalProps> & {
|
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[32m64.19 KB[39m
|
|
11
|
-
[32mCJS[39m ⚡️ Build success in 102ms
|
|
12
10
|
[32mESM[39m [1mdist/index.js [22m[32m60.01 KB[39m
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m ⚡️ Build success in 153ms
|
|
12
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m64.19 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 158ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m38.
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m38.
|
|
18
|
-
Done in
|
|
15
|
+
[32mDTS[39m ⚡️ Build success in 5621ms
|
|
16
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m38.70 KB[39m
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m38.70 KB[39m
|
|
18
|
+
Done in 7.27s.
|
package/core/mobx/hooks.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ReadonlyTypeOfType,
|
|
3
|
+
type Type,
|
|
3
4
|
type ValueOfType,
|
|
4
5
|
} from '@strictly/define'
|
|
5
6
|
import {
|
|
@@ -13,13 +14,25 @@ import {
|
|
|
13
14
|
import { peek } from './peek'
|
|
14
15
|
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
type
|
|
17
|
+
type FormModelInterface<T extends Type = any> = Pick<
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
FormModel<T, any, any, any, any>,
|
|
20
|
+
| 'fields'
|
|
21
|
+
| 'value'
|
|
22
|
+
| 'getValidation'
|
|
23
|
+
| 'validateField'
|
|
24
|
+
| 'setFieldValue'
|
|
25
|
+
| 'validateSubmit'
|
|
26
|
+
| 'isFieldDirty'
|
|
27
|
+
| 'isValuePathActive'
|
|
28
|
+
>
|
|
29
|
+
|
|
30
|
+
type ValueOfModel<M extends FormModelInterface> = M extends FormModelInterface<infer T>
|
|
17
31
|
? ValueOfType<ReadonlyTypeOfType<T>>
|
|
18
32
|
: never
|
|
19
33
|
|
|
20
34
|
export function useDefaultMobxFormHooks<
|
|
21
|
-
|
|
22
|
-
M extends FormModel<any, any, any, any, any>,
|
|
35
|
+
M extends FormModelInterface,
|
|
23
36
|
F extends M['fields'] = M['fields'],
|
|
24
37
|
>(
|
|
25
38
|
model: M,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe, ElementOfArray, StringConcatOf, StringKeyOf as StringKeyOf$1, ExhaustiveArrayOfUnion, FriendlyExhaustiveArrayOfUnion } from '@strictly/base';
|
|
2
2
|
import { Type, ValueOfType, ReadonlyTypeOfType, FlattenedTypesOfType, ListTypeDef, FlattenedValuesOfType, Accessor, Validator, UnionTypeDef, ValueTypesOfDiscriminatedUnion, LiteralTypeDef } from '@strictly/define';
|
|
3
3
|
import { ValueOf, SimplifyDeep, ReadonlyDeep, UnionToIntersection, StringKeyOf, Simplify } from 'type-fest';
|
|
4
|
-
import { ComponentType, RefAttributes, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, Ref, DependencyList } from 'react';
|
|
4
|
+
import { ComponentType, RefAttributes, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, Ref, DependencyList, JSX } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { CheckboxProps, PillProps, RadioProps, RadioGroupProps, TextInputProps, SelectProps } from '@mantine/core';
|
|
7
7
|
import { Observer } from 'mobx-react';
|
|
@@ -181,8 +181,9 @@ declare abstract class FormModel<T extends Type, ValueToTypePaths extends Readon
|
|
|
181
181
|
validateSubmit(): boolean;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
type
|
|
185
|
-
|
|
184
|
+
type FormModelInterface<T extends Type = any> = Pick<FormModel<T, any, any, any, any>, 'fields' | 'value' | 'getValidation' | 'validateField' | 'setFieldValue' | 'validateSubmit' | 'isFieldDirty' | 'isValuePathActive'>;
|
|
185
|
+
type ValueOfModel<M extends FormModelInterface> = M extends FormModelInterface<infer T> ? ValueOfType<ReadonlyTypeOfType<T>> : never;
|
|
186
|
+
declare function useDefaultMobxFormHooks<M extends FormModelInterface, F extends M['fields'] = M['fields']>(model: M, { onValidFieldSubmit, onValidFormSubmit, }?: {
|
|
186
187
|
onValidFieldSubmit?: <Path extends keyof F>(valuePath: Path) => void;
|
|
187
188
|
onValidFormSubmit?: (value: ValueOfModel<M>) => void;
|
|
188
189
|
}): {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe, ElementOfArray, StringConcatOf, StringKeyOf as StringKeyOf$1, ExhaustiveArrayOfUnion, FriendlyExhaustiveArrayOfUnion } from '@strictly/base';
|
|
2
2
|
import { Type, ValueOfType, ReadonlyTypeOfType, FlattenedTypesOfType, ListTypeDef, FlattenedValuesOfType, Accessor, Validator, UnionTypeDef, ValueTypesOfDiscriminatedUnion, LiteralTypeDef } from '@strictly/define';
|
|
3
3
|
import { ValueOf, SimplifyDeep, ReadonlyDeep, UnionToIntersection, StringKeyOf, Simplify } from 'type-fest';
|
|
4
|
-
import { ComponentType, RefAttributes, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, Ref, DependencyList } from 'react';
|
|
4
|
+
import { ComponentType, RefAttributes, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, Ref, DependencyList, JSX } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { CheckboxProps, PillProps, RadioProps, RadioGroupProps, TextInputProps, SelectProps } from '@mantine/core';
|
|
7
7
|
import { Observer } from 'mobx-react';
|
|
@@ -181,8 +181,9 @@ declare abstract class FormModel<T extends Type, ValueToTypePaths extends Readon
|
|
|
181
181
|
validateSubmit(): boolean;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
type
|
|
185
|
-
|
|
184
|
+
type FormModelInterface<T extends Type = any> = Pick<FormModel<T, any, any, any, any>, 'fields' | 'value' | 'getValidation' | 'validateField' | 'setFieldValue' | 'validateSubmit' | 'isFieldDirty' | 'isValuePathActive'>;
|
|
185
|
+
type ValueOfModel<M extends FormModelInterface> = M extends FormModelInterface<infer T> ? ValueOfType<ReadonlyTypeOfType<T>> : never;
|
|
186
|
+
declare function useDefaultMobxFormHooks<M extends FormModelInterface, F extends M['fields'] = M['fields']>(model: M, { onValidFieldSubmit, onValidFormSubmit, }?: {
|
|
186
187
|
onValidFieldSubmit?: <Path extends keyof F>(valuePath: Path) => void;
|
|
187
188
|
onValidFormSubmit?: (value: ValueOfModel<M>) => void;
|
|
188
189
|
}): {
|
package/package.json
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"@strictly/support-vite": "*",
|
|
19
19
|
"@testing-library/dom": "^10.4.0",
|
|
20
20
|
"@testing-library/react": "^16.0.1",
|
|
21
|
-
"@types/react": "^
|
|
22
|
-
"@types/react-dom": "^
|
|
21
|
+
"@types/react": "^19.0.0",
|
|
22
|
+
"@types/react-dom": "^19.0.0",
|
|
23
23
|
"@vitejs/plugin-react": "^4.3.3",
|
|
24
24
|
"concurrently": "^9.1.2",
|
|
25
25
|
"jsdom": "^25.0.1",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"test:watch": "vitest"
|
|
74
74
|
},
|
|
75
75
|
"type": "module",
|
|
76
|
-
"version": "0.0.
|
|
76
|
+
"version": "0.0.35",
|
|
77
77
|
"exports": {
|
|
78
78
|
".": {
|
|
79
79
|
"import": {
|