cross-state 1.9.5 → 1.9.7
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/dist/{diff-Bcr0h7-x.d.cts → diff-BzE2cDaU.d.cts} +2 -2
- package/dist/{diff-CwiTYAVK.d.ts → diff-Cvc-z20n.d.ts} +2 -2
- package/dist/{extendedJson-DA3RQ_ly.js → extendedJson-BOmrkRrD.js} +2 -2
- package/dist/{extendedJson-DA3RQ_ly.js.map → extendedJson-BOmrkRrD.js.map} +1 -1
- package/dist/{extendedJson-DzXMFE1P.cjs → extendedJson-pbOLcymB.cjs} +2 -2
- package/dist/{extendedJson-DzXMFE1P.cjs.map → extendedJson-pbOLcymB.cjs.map} +1 -1
- package/dist/index.cjs +10 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/mutative/index.cjs +2 -1
- package/dist/mutative/index.d.cts +1 -1
- package/dist/mutative/index.d.ts +1 -1
- package/dist/mutative/index.js +1 -1
- package/dist/mutative/register.cjs +2 -2
- package/dist/mutative/register.cjs.map +1 -1
- package/dist/mutative/register.d.cts +2 -2
- package/dist/mutative/register.d.ts +2 -2
- package/dist/mutative/register.js +2 -2
- package/dist/mutative/register.js.map +1 -1
- package/dist/{mutativeMethods-CwDMtUNs.cjs → mutativeMethods-AiKkraqx.cjs} +1 -1
- package/dist/mutativeMethods-AiKkraqx.cjs.map +1 -0
- package/dist/{mutativeMethods-Do8JiJ5A.d.cts → mutativeMethods-BHPlSHBi.d.cts} +2 -2
- package/dist/{mutativeMethods-t67Kp1uA.d.ts → mutativeMethods-COQxFB3B.d.ts} +2 -2
- package/dist/{mutativeMethods-BrDU8SwY.js → mutativeMethods-qVJ36MY5.js} +1 -1
- package/dist/mutativeMethods-qVJ36MY5.js.map +1 -0
- package/dist/{patchMethods-C21iQqML.d.ts → patchMethods--ekCkYUF.d.ts} +4 -4
- package/dist/{patchMethods-CZje49Dk.cjs → patchMethods-BBQDDqwe.cjs} +9 -9
- package/dist/patchMethods-BBQDDqwe.cjs.map +1 -0
- package/dist/{patchMethods-Cui462lc.js → patchMethods-D3cdG80W.js} +9 -9
- package/dist/patchMethods-D3cdG80W.js.map +1 -0
- package/dist/{patchMethods-Cyb6MEOG.d.cts → patchMethods-R3f7HxTy.d.cts} +4 -4
- package/dist/patches/index.cjs +2 -1
- package/dist/patches/index.d.cts +1 -1
- package/dist/patches/index.d.ts +1 -1
- package/dist/patches/index.js +1 -1
- package/dist/patches/register.cjs +2 -2
- package/dist/patches/register.cjs.map +1 -1
- package/dist/patches/register.d.cts +2 -2
- package/dist/patches/register.d.ts +2 -2
- package/dist/patches/register.js +2 -2
- package/dist/patches/register.js.map +1 -1
- package/dist/{path-Il5r4PV4.cjs → path-B9-Z0127.cjs} +1 -1
- package/dist/{path-Il5r4PV4.cjs.map → path-B9-Z0127.cjs.map} +1 -1
- package/dist/{path-CCEtQjMB.js → path-C-5jTZu5.js} +1 -1
- package/dist/{path-CCEtQjMB.js.map → path-C-5jTZu5.js.map} +1 -1
- package/dist/persist/register.cjs +2 -2
- package/dist/persist/register.cjs.map +1 -1
- package/dist/persist/register.d.cts +2 -2
- package/dist/persist/register.d.ts +2 -2
- package/dist/persist/register.js +2 -2
- package/dist/persist/register.js.map +1 -1
- package/dist/{persist-CG1WHP6D.cjs → persist-B341lrOA.cjs} +43 -45
- package/dist/persist-B341lrOA.cjs.map +1 -0
- package/dist/{persist-CkZ7CzW8.d.cts → persist-CoSWtRt0.d.cts} +3 -3
- package/dist/{persist-3Nff6j1f.d.ts → persist-XVT4fROX.d.ts} +3 -3
- package/dist/{persist-CNA2sYtB.js → persist-xv73m7UR.js} +43 -45
- package/dist/persist-xv73m7UR.js.map +1 -0
- package/dist/{propAccess-BxCKNeOj.js → propAccess-CsUaG5V_.js} +8 -8
- package/dist/propAccess-CsUaG5V_.js.map +1 -0
- package/dist/{propAccess-udIdjqwY.cjs → propAccess-DdLF12Jq.cjs} +8 -8
- package/dist/propAccess-DdLF12Jq.cjs.map +1 -0
- package/dist/react/index.cjs +118 -117
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +98 -98
- package/dist/react/index.d.ts +97 -97
- package/dist/react/index.js +119 -119
- package/dist/react/index.js.map +1 -1
- package/dist/react/register.cjs +3 -3
- package/dist/react/register.cjs.map +1 -1
- package/dist/react/register.d.cts +2 -2
- package/dist/react/register.d.ts +2 -2
- package/dist/react/register.js +3 -3
- package/dist/react/register.js.map +1 -1
- package/dist/{scope-DkX72a-2.cjs → scope-8MUrzqlS.cjs} +60 -60
- package/dist/scope-8MUrzqlS.cjs.map +1 -0
- package/dist/{scope-8uUaV6I8.d.cts → scope-BQjncWGt.d.cts} +25 -25
- package/dist/{scope-CQE3HDNI.js → scope-BfaweXvz.js} +61 -61
- package/dist/scope-BfaweXvz.js.map +1 -0
- package/dist/{scope-qdOAlRWQ.d.ts → scope-BztVo2P8.d.ts} +25 -25
- package/dist/{store-D4q5zD7q.js → store-BmlnyYal.js} +81 -81
- package/dist/store-BmlnyYal.js.map +1 -0
- package/dist/{store-Cq1PqvEo.d.ts → store-dThvqc0k.d.cts} +55 -55
- package/dist/{store-21GsOOLS.d.cts → store-dThvqc0k.d.ts} +55 -55
- package/dist/{store-CPqOf4y5.cjs → store-fmAYV5hy.cjs} +80 -80
- package/dist/store-fmAYV5hy.cjs.map +1 -0
- package/dist/{storeMethods-BjuI0joo.d.cts → storeMethods-CYX3AAnA.d.ts} +4 -4
- package/dist/{storeMethods-BZb4k7Ma.cjs → storeMethods-DYgUGHSk.cjs} +14 -14
- package/dist/storeMethods-DYgUGHSk.cjs.map +1 -0
- package/dist/{storeMethods-CK9-Q17H.d.ts → storeMethods-DrMQ7hqX.d.cts} +4 -4
- package/dist/{storeMethods-CWeGkXoz.js → storeMethods-pGlt0zfb.js} +14 -14
- package/dist/storeMethods-pGlt0zfb.js.map +1 -0
- package/package.json +46 -63
- package/dist/mutativeMethods-BrDU8SwY.js.map +0 -1
- package/dist/mutativeMethods-CwDMtUNs.cjs.map +0 -1
- package/dist/patchMethods-CZje49Dk.cjs.map +0 -1
- package/dist/patchMethods-Cui462lc.js.map +0 -1
- package/dist/persist-CG1WHP6D.cjs.map +0 -1
- package/dist/persist-CNA2sYtB.js.map +0 -1
- package/dist/propAccess-BxCKNeOj.js.map +0 -1
- package/dist/propAccess-udIdjqwY.cjs.map +0 -1
- package/dist/scope-CQE3HDNI.js.map +0 -1
- package/dist/scope-DkX72a-2.cjs.map +0 -1
- package/dist/store-CPqOf4y5.cjs.map +0 -1
- package/dist/store-D4q5zD7q.js.map +0 -1
- package/dist/storeMethods-BZb4k7Ma.cjs.map +0 -1
- package/dist/storeMethods-CWeGkXoz.js.map +0 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as useScope, c as UseCacheValue, d as useStore, i as ScopeProvider, l as useCache, n as scopeMethods, o as cacheMethods, r as ScopeProps, s as UseCacheArray, t as storeMethods, u as UseStoreOptions } from "../storeMethods-
|
|
1
|
+
import { B as Selector, C as Value, D as Object_, E as WildcardValue, H as Update, K as MaybePromise, L as Duration, O as Constrain, T as WildcardPathAsString, g as Path$1, m as Join, p as GetKeys, r as Store, v as PathAsString, y as SettablePath } from "../store-dThvqc0k.cjs";
|
|
2
|
+
import { a as useScope, c as UseCacheValue, d as useStore, i as ScopeProvider, l as useCache, n as scopeMethods, o as cacheMethods, r as ScopeProps, s as UseCacheArray, t as storeMethods, u as UseStoreOptions } from "../storeMethods-DrMQ7hqX.cjs";
|
|
3
3
|
import { Draft } from "mutative";
|
|
4
4
|
import { Component, ComponentPropsWithoutRef, Context, FormEvent, FunctionComponent, HTMLProps, ReactNode } from "react";
|
|
5
5
|
|
|
@@ -15,8 +15,8 @@ declare function CustomInput({
|
|
|
15
15
|
}: CustomInputProps): React.JSX.Element;
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/react/form/formField.d.ts
|
|
18
|
-
interface FormFieldComponentProps<TValue, TPath
|
|
19
|
-
name: TPath
|
|
18
|
+
interface FormFieldComponentProps<TValue, TPath> {
|
|
19
|
+
name: TPath;
|
|
20
20
|
value: TValue;
|
|
21
21
|
onChange: (event: {
|
|
22
22
|
target: {
|
|
@@ -26,77 +26,43 @@ interface FormFieldComponentProps<TValue, TPath$1> {
|
|
|
26
26
|
onBlur: (...args: any[]) => void;
|
|
27
27
|
"data-invalid"?: boolean;
|
|
28
28
|
}
|
|
29
|
-
type FormFieldInfos<TDraft, TOriginal, TPath
|
|
29
|
+
type FormFieldInfos<TDraft, TOriginal, TPath extends string> = Field<TDraft, TOriginal, TPath> & {
|
|
30
30
|
hasTriggeredValidations: boolean;
|
|
31
31
|
};
|
|
32
32
|
type NativeInputType = "input" | "select" | "textarea";
|
|
33
33
|
type PartialComponentType<P> = (new (props: P, context?: any) => Component<P, any>) | ((props: P, context?: any) => ReactNode);
|
|
34
34
|
type FormFieldComponent = NativeInputType | PartialComponentType<any>;
|
|
35
|
-
interface FormFieldProps<TPath
|
|
36
|
-
name: TPath
|
|
35
|
+
interface FormFieldProps<TPath, TDraft> extends FieldOptions {
|
|
36
|
+
name: TPath extends PathAsString<TDraft> ? TPath : PathAsString<TDraft>;
|
|
37
37
|
commitOnBlur?: boolean;
|
|
38
38
|
commitDebounce?: Duration;
|
|
39
39
|
}
|
|
40
|
-
interface FormFieldPropsWithRender<TDraft, TOriginal, TPath
|
|
41
|
-
render: NoInfer<(props: FormFieldComponentProps<Value<TDraft, TPath
|
|
40
|
+
interface FormFieldPropsWithRender<TDraft, TOriginal, TPath extends string> extends FormFieldProps<TPath, TDraft> {
|
|
41
|
+
render: NoInfer<(props: FormFieldComponentProps<Value<TDraft, TPath>, TPath>, info: FormFieldInfos<TDraft, TOriginal, TPath>, form: FormContext<TDraft, TOriginal>) => ReactNode>;
|
|
42
42
|
children?: undefined;
|
|
43
43
|
}
|
|
44
|
-
interface FormFieldPropsWithChildren<TDraft, TOriginal, TPath
|
|
44
|
+
interface FormFieldPropsWithChildren<TDraft, TOriginal, TPath extends string> extends FormFieldProps<TPath, TDraft> {
|
|
45
45
|
render?: undefined;
|
|
46
|
-
children: NoInfer<(props: FormFieldComponentProps<Value<TDraft, TPath
|
|
46
|
+
children: NoInfer<(props: FormFieldComponentProps<Value<TDraft, TPath>, TPath>, info: FormFieldInfos<TDraft, TOriginal, TPath>, form: FormContext<TDraft, TOriginal>) => ReactNode>;
|
|
47
47
|
}
|
|
48
48
|
//#endregion
|
|
49
|
-
//#region src/react/form/legacyFormField.d.ts
|
|
50
|
-
type FieldValue<T$1 extends FormFieldComponent> = ComponentPropsWithoutRef<T$1>["value"];
|
|
51
|
-
type FieldChangeValue<T$1 extends FormFieldComponent> = ComponentPropsWithoutRef<T$1> extends {
|
|
52
|
-
onChange?: (update: infer U) => void;
|
|
53
|
-
} ? U extends {
|
|
54
|
-
target: {
|
|
55
|
-
value: infer V;
|
|
56
|
-
};
|
|
57
|
-
} ? V : U : never;
|
|
58
|
-
type MakeOptional<T$1, Keys extends string> = Omit<T$1, Keys> & Partial<Pick<T$1, Keys & keyof T$1>>;
|
|
59
|
-
type Serialize<TDraft, TOriginal, TPath$1, TComponent extends FormFieldComponent> = (value: Value<TDraft, TPath$1>, formState: FormInstance<TDraft, TOriginal>) => FieldValue<TComponent>;
|
|
60
|
-
type Deserialize<TDraft, TOriginal, TPath$1, TComponent extends FormFieldComponent> = (value: FieldChangeValue<TComponent>, formState: FormInstance<TDraft, TOriginal>) => Value<TDraft, TPath$1>;
|
|
61
|
-
type FormFieldPropsWithComponent<TDraft, TOriginal, TPath$1 extends string, TComponent extends FormFieldComponent> = FormFieldProps<TPath$1, TDraft> & {
|
|
62
|
-
component: TComponent;
|
|
63
|
-
render?: undefined;
|
|
64
|
-
} & NoInfer<{
|
|
65
|
-
inputFilter?: (value: FieldChangeValue<TComponent>) => boolean;
|
|
66
|
-
} & MakeOptional<Omit<ComponentPropsWithoutRef<TComponent>, "id" | "name" | "value" | "defaultValue">, "onChange" | "onBlur"> & (Value<TDraft, TPath$1> extends Exclude<FieldValue<TComponent>, undefined> ? {
|
|
67
|
-
defaultValue?: FieldValue<TComponent>;
|
|
68
|
-
serialize?: Serialize<TDraft, TOriginal, TPath$1, TComponent>;
|
|
69
|
-
} : Value<TDraft, TPath$1> extends FieldValue<TComponent> ? {
|
|
70
|
-
defaultValue: FieldValue<TComponent>;
|
|
71
|
-
serialize?: Serialize<TDraft, TOriginal, TPath$1, TComponent>;
|
|
72
|
-
} | {
|
|
73
|
-
defaultValue?: FieldValue<TComponent>;
|
|
74
|
-
serialize: Serialize<TDraft, TOriginal, TPath$1, TComponent>;
|
|
75
|
-
} : {
|
|
76
|
-
serialize: Serialize<TDraft, TOriginal, TPath$1, TComponent>;
|
|
77
|
-
}) & (FieldChangeValue<TComponent> extends Value<TDraft, TPath$1> ? {
|
|
78
|
-
deserialize?: Deserialize<TDraft, TOriginal, TPath$1, TComponent>;
|
|
79
|
-
} : {
|
|
80
|
-
deserialize: Deserialize<TDraft, TOriginal, TPath$1, TComponent>;
|
|
81
|
-
})>;
|
|
82
|
-
//#endregion
|
|
83
49
|
//#region src/react/form/formForEach.d.ts
|
|
84
|
-
type ElementName<TDraft, TPath
|
|
85
|
-
type ItemValue<T
|
|
86
|
-
interface FormForEachProps<TDraft, TPath
|
|
87
|
-
name: TPath
|
|
50
|
+
type ElementName<TDraft, TPath extends string> = keyof { [Path in TPath as Join<Path, GetKeys<NonNullable<Value<TDraft, Path>>> & (string | number)>]: 1 };
|
|
51
|
+
type ItemValue<T> = T extends readonly (infer U)[] ? U : T[keyof T];
|
|
52
|
+
interface FormForEachProps<TDraft, TPath extends string> {
|
|
53
|
+
name: TPath extends PathAsString<TDraft> ? TPath : PathAsString<TDraft>;
|
|
88
54
|
renderElement?: (props: {
|
|
89
|
-
name: ElementName<TDraft, TPath
|
|
90
|
-
key: `${GetKeys<NonNullable<Value<TDraft, TPath
|
|
55
|
+
name: ElementName<TDraft, TPath>;
|
|
56
|
+
key: `${GetKeys<NonNullable<Value<TDraft, TPath>>> & (string | number)}`;
|
|
91
57
|
index: number;
|
|
92
58
|
remove: () => void;
|
|
93
59
|
count: number;
|
|
94
60
|
}) => ReactNode;
|
|
95
|
-
renderAdditionalElement?: NonNullable<Value<TDraft, TPath
|
|
96
|
-
filter?: (item: ItemValue<NonNullable<Value<TDraft, TPath
|
|
61
|
+
renderAdditionalElement?: NonNullable<Value<TDraft, TPath>> extends readonly any[] ? boolean : never;
|
|
62
|
+
filter?: (item: ItemValue<NonNullable<Value<TDraft, TPath>>>, key: GetKeys<NonNullable<Value<TDraft, TPath>>>, parent: NonNullable<Value<TDraft, TPath>>) => boolean;
|
|
97
63
|
children?: (props: {
|
|
98
|
-
setValue: (value: Value<TDraft, TPath
|
|
99
|
-
} & FieldHelperMethods<TDraft, TPath
|
|
64
|
+
setValue: (value: Value<TDraft, TPath> | ((value: Value<TDraft, TPath>) => Value<TDraft, TPath>)) => void;
|
|
65
|
+
} & FieldHelperMethods<TDraft, TPath>) => ReactNode;
|
|
100
66
|
}
|
|
101
67
|
//#endregion
|
|
102
68
|
//#region src/react/form/formOnOriginalChange.d.ts
|
|
@@ -116,6 +82,40 @@ interface FormAutosaveOptions<TDraft, TOriginal> {
|
|
|
116
82
|
equals?: (a: any, b: any) => boolean;
|
|
117
83
|
}
|
|
118
84
|
//#endregion
|
|
85
|
+
//#region src/react/form/legacyFormField.d.ts
|
|
86
|
+
type FieldValue<T extends FormFieldComponent> = ComponentPropsWithoutRef<T>["value"];
|
|
87
|
+
type FieldChangeValue<T extends FormFieldComponent> = ComponentPropsWithoutRef<T> extends {
|
|
88
|
+
onChange?: (update: infer U) => void;
|
|
89
|
+
} ? U extends {
|
|
90
|
+
target: {
|
|
91
|
+
value: infer V;
|
|
92
|
+
};
|
|
93
|
+
} ? V : U : never;
|
|
94
|
+
type MakeOptional<T, Keys extends string> = Omit<T, Keys> & Partial<Pick<T, Keys & keyof T>>;
|
|
95
|
+
type Serialize<TDraft, TOriginal, TPath, TComponent extends FormFieldComponent> = (value: Value<TDraft, TPath>, formState: FormInstance<TDraft, TOriginal>) => FieldValue<TComponent>;
|
|
96
|
+
type Deserialize<TDraft, TOriginal, TPath, TComponent extends FormFieldComponent> = (value: FieldChangeValue<TComponent>, formState: FormInstance<TDraft, TOriginal>) => Value<TDraft, TPath>;
|
|
97
|
+
type FormFieldPropsWithComponent<TDraft, TOriginal, TPath extends string, TComponent extends FormFieldComponent> = FormFieldProps<TPath, TDraft> & {
|
|
98
|
+
component: TComponent;
|
|
99
|
+
render?: undefined;
|
|
100
|
+
} & NoInfer<{
|
|
101
|
+
inputFilter?: (value: FieldChangeValue<TComponent>) => boolean;
|
|
102
|
+
} & MakeOptional<Omit<ComponentPropsWithoutRef<TComponent>, "id" | "name" | "value" | "defaultValue">, "onChange" | "onBlur"> & (Value<TDraft, TPath> extends Exclude<FieldValue<TComponent>, undefined> ? {
|
|
103
|
+
defaultValue?: FieldValue<TComponent>;
|
|
104
|
+
serialize?: Serialize<TDraft, TOriginal, TPath, TComponent>;
|
|
105
|
+
} : Value<TDraft, TPath> extends FieldValue<TComponent> ? {
|
|
106
|
+
defaultValue: FieldValue<TComponent>;
|
|
107
|
+
serialize?: Serialize<TDraft, TOriginal, TPath, TComponent>;
|
|
108
|
+
} | {
|
|
109
|
+
defaultValue?: FieldValue<TComponent>;
|
|
110
|
+
serialize: Serialize<TDraft, TOriginal, TPath, TComponent>;
|
|
111
|
+
} : {
|
|
112
|
+
serialize: Serialize<TDraft, TOriginal, TPath, TComponent>;
|
|
113
|
+
}) & (FieldChangeValue<TComponent> extends Value<TDraft, TPath> ? {
|
|
114
|
+
deserialize?: Deserialize<TDraft, TOriginal, TPath, TComponent>;
|
|
115
|
+
} : {
|
|
116
|
+
deserialize: Deserialize<TDraft, TOriginal, TPath, TComponent>;
|
|
117
|
+
})>;
|
|
118
|
+
//#endregion
|
|
119
119
|
//#region src/react/form/form.d.ts
|
|
120
120
|
interface Transform<TDraft, TOriginal> {
|
|
121
121
|
(value: Draft<TDraft>, context: TransformContext<TDraft, TOriginal>): void | TDraft;
|
|
@@ -135,7 +135,7 @@ interface FormOptions<TDraft, TOriginal> {
|
|
|
135
135
|
original?: TOriginal;
|
|
136
136
|
onSubmit?: (event: FormEvent<HTMLFormElement>, form: FormInstance<TDraft, TOriginal>) => void;
|
|
137
137
|
reportValidity?: boolean | "browser" | "scrollTo";
|
|
138
|
-
transformFieldProps?: <TPath
|
|
138
|
+
transformFieldProps?: <TPath extends string>(props: FormFieldComponentProps<Value<TDraft, TPath>, TPath>, info: FormFieldInfos<TDraft, TOriginal, TPath>, form: FormContext<TDraft, TOriginal>) => FormFieldComponentProps<Value<TDraft, TPath>, TPath>;
|
|
139
139
|
onOriginalChange?: OnOriginalChange<TDraft, TOriginal>;
|
|
140
140
|
}
|
|
141
141
|
type Validations<TDraft, TOriginal> = ((context: {
|
|
@@ -145,23 +145,23 @@ type Validations<TDraft, TOriginal> = ((context: {
|
|
|
145
145
|
name: string;
|
|
146
146
|
error: string;
|
|
147
147
|
}>) | ({ [TPath in WildcardPathAsString<TDraft>]?: Record<string, Validation<TDraft, TOriginal, TPath>> } & Record<string, Record<string, Validation<TDraft, TOriginal, any>>>);
|
|
148
|
-
type Validation<TDraft, TOriginal, TPath
|
|
148
|
+
type Validation<TDraft, TOriginal, TPath> = (value: WildcardValue<TDraft, TPath>, context: {
|
|
149
149
|
draft: TDraft;
|
|
150
150
|
original: TOriginal;
|
|
151
151
|
field: PathAsString<TDraft> | "";
|
|
152
152
|
}) => boolean;
|
|
153
|
-
type Field<TDraft, TOriginal, TPath
|
|
154
|
-
originalValue: Value<TOriginal, TPath
|
|
155
|
-
value: Value<TDraft, TPath
|
|
156
|
-
setValue: (value: Update<Value<TDraft, TPath
|
|
153
|
+
type Field<TDraft, TOriginal, TPath extends string> = {
|
|
154
|
+
originalValue: Value<TOriginal, TPath> | undefined;
|
|
155
|
+
value: Value<TDraft, TPath>;
|
|
156
|
+
setValue: (value: Update<Value<TDraft, TPath>>) => void;
|
|
157
157
|
removeValue: () => void;
|
|
158
158
|
hasChange: boolean;
|
|
159
159
|
errors: string[];
|
|
160
|
-
} & (Value<TDraft, TPath
|
|
161
|
-
type FieldHelperMethods<TDraft, TPath
|
|
162
|
-
names: ElementName<TDraft, TPath
|
|
163
|
-
add: NonNullable<Value<TDraft, TPath
|
|
164
|
-
remove: NonNullable<Value<TDraft, TPath
|
|
160
|
+
} & (Value<TDraft, TPath> extends Object_ ? FieldHelperMethods<TDraft, TPath> : {});
|
|
161
|
+
type FieldHelperMethods<TDraft, TPath extends string> = {
|
|
162
|
+
names: ElementName<TDraft, TPath>[];
|
|
163
|
+
add: NonNullable<Value<TDraft, TPath>> extends readonly (infer T)[] ? (element: T) => void : NonNullable<Value<TDraft, TPath>> extends Record<infer K, infer V> ? (key: K, value: V) => void : never;
|
|
164
|
+
remove: NonNullable<Value<TDraft, TPath>> extends readonly any[] ? (index: number) => void : (key: string) => void;
|
|
165
165
|
};
|
|
166
166
|
interface FormState<TDraft> {
|
|
167
167
|
draft: TDraft | undefined;
|
|
@@ -180,7 +180,7 @@ interface FormContext<TDraft, TOriginal> {
|
|
|
180
180
|
formState: Store<FormState<TDraft>>;
|
|
181
181
|
options: FormOptions<TDraft, TOriginal>;
|
|
182
182
|
original: TOriginal | undefined;
|
|
183
|
-
getField: <TPath
|
|
183
|
+
getField: <TPath extends string>(name: TPath extends PathAsString<TDraft> ? TPath : PathAsString<TDraft>, options?: FieldOptions) => Field<TDraft, TOriginal, TPath>;
|
|
184
184
|
getDraft: () => TDraft;
|
|
185
185
|
hasTriggeredValidations: () => boolean;
|
|
186
186
|
saveInProgress: () => boolean;
|
|
@@ -206,11 +206,11 @@ declare class Form<TDraft, TOriginal extends TDraft = TDraft> {
|
|
|
206
206
|
constructor(options: FormOptions<TDraft, TOriginal>);
|
|
207
207
|
useForm(): FormContext<TDraft, TOriginal>;
|
|
208
208
|
useFormState<S>(selector: (state: FormInstance<TDraft, TOriginal>) => S, useStoreOptions?: UseStoreOptions<S>): S;
|
|
209
|
-
useField<TPath
|
|
209
|
+
useField<TPath extends string>(name: TPath extends PathAsString<TDraft> ? TPath : PathAsString<TDraft>, {
|
|
210
210
|
includeNestedErrors,
|
|
211
211
|
...useStoreOptions
|
|
212
|
-
}?: FieldOptions & UseStoreOptions<unknown>): Field<TDraft, TOriginal, TPath
|
|
213
|
-
useFieldProps<TPath
|
|
212
|
+
}?: FieldOptions & UseStoreOptions<unknown>): Field<TDraft, TOriginal, TPath>;
|
|
213
|
+
useFieldProps<TPath extends string>(name: TPath extends PathAsString<TDraft> ? TPath : PathAsString<TDraft>, options?: Omit<FormFieldProps<TPath, TDraft>, "name">): FormFieldComponentProps<Value<TDraft, TPath>, TPath>;
|
|
214
214
|
Form({
|
|
215
215
|
defaultValue,
|
|
216
216
|
validations,
|
|
@@ -233,11 +233,11 @@ declare class Form<TDraft, TOriginal extends TDraft = TDraft> {
|
|
|
233
233
|
selector: (form: FormInstance<TDraft, TOriginal>) => S;
|
|
234
234
|
children: (selectedState: S) => ReactNode;
|
|
235
235
|
}): React.JSX.Element;
|
|
236
|
-
Field<const TPath
|
|
237
|
-
Field<const TPath
|
|
236
|
+
Field<const TPath extends string>(props: FormFieldPropsWithRender<TDraft, TOriginal, TPath>): React.JSX.Element;
|
|
237
|
+
Field<const TPath extends string>(props: FormFieldPropsWithChildren<TDraft, TOriginal, TPath>): React.JSX.Element;
|
|
238
238
|
/** @deprecated */
|
|
239
|
-
Field<const TPath
|
|
240
|
-
ForEach<const TPath
|
|
239
|
+
Field<const TPath extends string, const TComponent extends FormFieldComponent = "input">(props: FormFieldPropsWithComponent<TDraft, TOriginal, TPath, TComponent>): React.JSX.Element;
|
|
240
|
+
ForEach<const TPath extends string>(props: FormForEachProps<TDraft, TPath>): React.JSX.Element;
|
|
241
241
|
withForm<TProps extends Record<string, unknown>>(Component: React.ComponentType<TProps>, formProps?: Parameters<this["Form"]>[0]): FunctionComponent<TProps>;
|
|
242
242
|
}
|
|
243
243
|
declare function createForm<TDraft, TOriginal extends TDraft = TDraft>(options: FormOptions<TDraft, TOriginal>): Form<TDraft, TOriginal>;
|
|
@@ -272,34 +272,34 @@ declare function LoadingBoundary({
|
|
|
272
272
|
declare function useLoadingBoundary(isLoading: boolean | undefined, label?: ReactNode): void;
|
|
273
273
|
//#endregion
|
|
274
274
|
//#region src/react/url/urlOptions.d.ts
|
|
275
|
-
interface UrlOptions<T
|
|
275
|
+
interface UrlOptions<T> {
|
|
276
276
|
key: string;
|
|
277
277
|
type?: "search" | "hash";
|
|
278
|
-
serialize?: (value: T
|
|
279
|
-
deserialize?: (value: string) => T
|
|
280
|
-
defaultValue: T
|
|
278
|
+
serialize?: (value: T) => string;
|
|
279
|
+
deserialize?: (value: string) => T;
|
|
280
|
+
defaultValue: T;
|
|
281
281
|
writeDefaultValue?: boolean;
|
|
282
|
-
onCommit?: (value: T
|
|
282
|
+
onCommit?: (value: T) => void;
|
|
283
283
|
persist?: {
|
|
284
284
|
id: string;
|
|
285
285
|
} | null;
|
|
286
286
|
path?: string | RegExp | (string | RegExp)[] | null;
|
|
287
287
|
}
|
|
288
|
-
interface UrlOptionsWithoutDefaults<T
|
|
289
|
-
defaultValue?: T
|
|
288
|
+
interface UrlOptionsWithoutDefaults<T> extends Omit<UrlOptions<T | undefined>, "defaultValue"> {
|
|
289
|
+
defaultValue?: T | undefined;
|
|
290
290
|
}
|
|
291
|
-
declare function createUrlOptions<T
|
|
292
|
-
declare function createUrlOptions<T
|
|
291
|
+
declare function createUrlOptions<T>(options: UrlOptions<T>): Required<UrlOptions<T>>;
|
|
292
|
+
declare function createUrlOptions<T>(options: UrlOptionsWithoutDefaults<T>): Required<UrlOptions<T | undefined>>;
|
|
293
293
|
//#endregion
|
|
294
294
|
//#region src/react/url/urlParamStore.d.ts
|
|
295
295
|
declare const urlStore: Store<string>;
|
|
296
|
-
declare class UrlParamStore<T
|
|
297
|
-
readonly urlOptions: Required<UrlOptions<T
|
|
296
|
+
declare class UrlParamStore<T> extends Store<T> {
|
|
297
|
+
readonly urlOptions: Required<UrlOptions<T>>;
|
|
298
298
|
readonly storageKey: string | null;
|
|
299
299
|
private lastHref?;
|
|
300
300
|
private lastStorageValue?;
|
|
301
301
|
private lastValue?;
|
|
302
|
-
constructor(urlOptions: Required<UrlOptions<T
|
|
302
|
+
constructor(urlOptions: Required<UrlOptions<T>>);
|
|
303
303
|
private watch;
|
|
304
304
|
private getUrlValue;
|
|
305
305
|
private getStorageValue;
|
|
@@ -307,25 +307,25 @@ declare class UrlParamStore<T$1> extends Store<T$1> {
|
|
|
307
307
|
private calc;
|
|
308
308
|
private updateUrl;
|
|
309
309
|
private updateStorage;
|
|
310
|
-
set(update: Update<T
|
|
311
|
-
set<const P>(path: Constrain<P, Path$1<T
|
|
312
|
-
parse(path: string): T
|
|
310
|
+
set(update: Update<T>): void;
|
|
311
|
+
set<const P>(path: Constrain<P, Path$1<T>>, update: Update<Value<T, P>>): void;
|
|
312
|
+
parse(path: string): T;
|
|
313
313
|
}
|
|
314
|
-
declare function createUrlParam<T
|
|
315
|
-
declare function createUrlParam<T
|
|
314
|
+
declare function createUrlParam<T>(options: UrlOptions<T>): UrlParamStore<T>;
|
|
315
|
+
declare function createUrlParam<T>(options: UrlOptionsWithoutDefaults<T>): UrlParamStore<T | undefined>;
|
|
316
316
|
//#endregion
|
|
317
317
|
//#region src/react/useDecoupledState.d.ts
|
|
318
|
-
interface UseDecoupledStateOptions<T
|
|
318
|
+
interface UseDecoupledStateOptions<T> {
|
|
319
319
|
debounce?: Duration;
|
|
320
320
|
throttle?: Duration;
|
|
321
|
-
onCommit?: (value: T
|
|
321
|
+
onCommit?: (value: T) => void;
|
|
322
322
|
}
|
|
323
|
-
declare function useDecoupledState<T
|
|
323
|
+
declare function useDecoupledState<T>(value: T, onChange: (value: T) => MaybePromise<void>, options?: UseDecoupledStateOptions<T>): [state: T, setState: (value: T) => void];
|
|
324
324
|
//#endregion
|
|
325
325
|
//#region src/react/useProp.d.ts
|
|
326
|
-
declare function useProp<T
|
|
327
|
-
declare function useProp<T
|
|
328
|
-
declare function useProp<T
|
|
326
|
+
declare function useProp<T, S>(store: Store<T>, selector: Selector<T, S>, updater: (value: S) => Update<T>, options?: UseStoreOptions<S>): [value: S, setValue: Store<S>["set"]];
|
|
327
|
+
declare function useProp<T, const P>(store: Store<T>, selector: Constrain<P, SettablePath<T>>, options?: UseStoreOptions<Value<T, P>>): [value: Value<T, P>, setValue: Store<Value<T, P>>["set"]];
|
|
328
|
+
declare function useProp<T>(store: Store<T>, options?: UseStoreOptions<T>): [value: T, setValue: Store<T>["set"]];
|
|
329
329
|
//#endregion
|
|
330
|
-
export { CustomInput, CustomInputProps, Field, Form, FormContext, FormDerivedState, FormFieldComponent, FormFieldComponentProps, FormFieldInfos, FormFieldProps, FormFieldPropsWithChildren, FormFieldPropsWithRender, FormInstance, FormOptions, FormState, LoadingBoundary, type LoadingBoundaryEntry, type LoadingBoundaryProps, type ScopeProps, ScopeProvider, Transform, type UrlOptions, type UrlOptionsWithoutDefaults, type UrlParamStore, type UseCacheArray, type UseCacheValue, type UseDecoupledStateOptions, type UseStoreOptions, Validation, Validations, cacheMethods, createForm, createUrlOptions, createUrlParam, scopeMethods, storeMethods, urlStore, useCache, useClosestForm, useDecoupledState, useLoadingBoundary, useProp, useScope, useStore };
|
|
330
|
+
export { CustomInput, type CustomInputProps, type Field, Form, type FormContext, type FormDerivedState, type FormFieldComponent, type FormFieldComponentProps, type FormFieldInfos, type FormFieldProps, type FormFieldPropsWithChildren, type FormFieldPropsWithRender, type FormInstance, type FormOptions, type FormState, LoadingBoundary, type LoadingBoundaryEntry, type LoadingBoundaryProps, type ScopeProps, ScopeProvider, type Transform, type UrlOptions, type UrlOptionsWithoutDefaults, type UrlParamStore, type UseCacheArray, type UseCacheValue, type UseDecoupledStateOptions, type UseStoreOptions, type Validation, type Validations, cacheMethods, createForm, createUrlOptions, createUrlParam, scopeMethods, storeMethods, urlStore, useCache, useClosestForm, useDecoupledState, useLoadingBoundary, useProp, useScope, useStore };
|
|
331
331
|
//# sourceMappingURL=index.d.cts.map
|