cross-state 0.53.3 → 0.54.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/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/diff-BQ8bB3Wk.d.cts +22 -0
- package/dist/diff-gZezL04N.d.ts +22 -0
- package/dist/extendedJson-BZkQBXEv.js +29 -0
- package/dist/extendedJson-BZkQBXEv.js.map +1 -0
- package/dist/extendedJson-Dn2F7Edo.cjs +53 -0
- package/dist/extendedJson-Dn2F7Edo.cjs.map +1 -0
- package/dist/hash-BV06P7va.js +19 -0
- package/dist/hash-BV06P7va.js.map +1 -0
- package/dist/hash-CJPl7SRj.cjs +30 -0
- package/dist/hash-CJPl7SRj.cjs.map +1 -0
- package/dist/index.cjs +49 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +59 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/mutative/index.cjs +3 -0
- package/dist/mutative/index.d.cts +3 -0
- package/dist/mutative/index.d.ts +3 -0
- package/dist/mutative/index.js +3 -0
- package/dist/mutative/register.cjs +10 -0
- package/dist/mutative/register.cjs.map +1 -0
- package/dist/mutative/register.d.cts +11 -0
- package/dist/mutative/register.d.ts +9 -0
- package/dist/mutative/register.js +10 -0
- package/dist/mutative/register.js.map +1 -0
- package/dist/mutativeMethods-6QzygG3W.d.cts +13 -0
- package/dist/mutativeMethods-Br3xN2Iq.d.ts +13 -0
- package/dist/mutativeMethods-CZKeRIDL.js +27 -0
- package/dist/mutativeMethods-CZKeRIDL.js.map +1 -0
- package/dist/mutativeMethods-CgXk_bMt.cjs +33 -0
- package/dist/mutativeMethods-CgXk_bMt.cjs.map +1 -0
- package/dist/patchMethods-C3L7Kh8T.d.cts +48 -0
- package/dist/patchMethods-D5YJwcpn.cjs +264 -0
- package/dist/patchMethods-D5YJwcpn.cjs.map +1 -0
- package/dist/patchMethods-DRPfkhAe.js +241 -0
- package/dist/patchMethods-DRPfkhAe.js.map +1 -0
- package/dist/patchMethods-Dxad6HF6.d.ts +48 -0
- package/dist/patches/index.cjs +5 -0
- package/dist/patches/index.d.cts +4 -0
- package/dist/patches/index.d.ts +4 -0
- package/dist/patches/index.js +5 -0
- package/dist/patches/register.cjs +11 -0
- package/dist/patches/register.cjs.map +1 -0
- package/dist/patches/register.d.cts +12 -0
- package/dist/patches/register.d.ts +10 -0
- package/dist/patches/register.js +11 -0
- package/dist/patches/register.js.map +1 -0
- package/dist/persist/register.cjs +13 -0
- package/dist/persist/register.cjs.map +1 -0
- package/dist/persist/register.d.cts +15 -0
- package/dist/persist/register.d.ts +13 -0
- package/dist/persist/register.js +13 -0
- package/dist/persist/register.js.map +1 -0
- package/dist/persist-BluRVcW6.js +258 -0
- package/dist/persist-BluRVcW6.js.map +1 -0
- package/dist/persist-CPjpg6D0.d.ts +61 -0
- package/dist/persist-CztClydq.cjs +263 -0
- package/dist/persist-CztClydq.cjs.map +1 -0
- package/dist/persist-D7MAsyyW.d.cts +61 -0
- package/dist/propAccess-ByqBjC19.cjs +173 -0
- package/dist/propAccess-ByqBjC19.cjs.map +1 -0
- package/dist/propAccess-DGchzVfy.js +113 -0
- package/dist/propAccess-DGchzVfy.js.map +1 -0
- package/dist/react/index.cjs +622 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +306 -0
- package/dist/react/index.d.ts +306 -0
- package/dist/react/index.js +602 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/register.cjs +16 -0
- package/dist/react/register.cjs.map +1 -0
- package/dist/react/register.d.cts +16 -0
- package/dist/react/register.d.ts +14 -0
- package/dist/react/register.js +16 -0
- package/dist/react/register.js.map +1 -0
- package/dist/scope-DI1OFHcr.d.ts +167 -0
- package/dist/scope-DO5vpLPV.d.cts +167 -0
- package/dist/scope-DU5dFP1T.js +322 -0
- package/dist/scope-DU5dFP1T.js.map +1 -0
- package/dist/scope-DvqvkIHB.cjs +369 -0
- package/dist/scope-DvqvkIHB.cjs.map +1 -0
- package/dist/store-BEsiS8y7.d.cts +242 -0
- package/dist/store-BWMWEUpu.cjs +819 -0
- package/dist/store-BWMWEUpu.cjs.map +1 -0
- package/dist/store-DKaeE840.d.ts +242 -0
- package/dist/store-Dr8gM3lq.js +730 -0
- package/dist/store-Dr8gM3lq.js.map +1 -0
- package/dist/storeMethods-AIJSwxHz.js +315 -0
- package/dist/storeMethods-AIJSwxHz.js.map +1 -0
- package/dist/storeMethods-BQwU2Uia.d.cts +107 -0
- package/dist/storeMethods-C4luym7C.d.ts +107 -0
- package/dist/storeMethods-DVVsmUg1.cjs +375 -0
- package/dist/storeMethods-DVVsmUg1.cjs.map +1 -0
- package/package.json +92 -135
- package/dist/cjs/hash.cjs +0 -30
- package/dist/cjs/hash.cjs.map +0 -1
- package/dist/cjs/index.cjs +0 -56
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index2.cjs +0 -300
- package/dist/cjs/index2.cjs.map +0 -1
- package/dist/cjs/mutative/index.cjs +0 -10
- package/dist/cjs/mutative/index.cjs.map +0 -1
- package/dist/cjs/mutative/register.cjs +0 -8
- package/dist/cjs/mutative/register.cjs.map +0 -1
- package/dist/cjs/mutativeMethods.cjs +0 -29
- package/dist/cjs/mutativeMethods.cjs.map +0 -1
- package/dist/cjs/patches/index.cjs +0 -10
- package/dist/cjs/patches/index.cjs.map +0 -1
- package/dist/cjs/patches/register.cjs +0 -8
- package/dist/cjs/patches/register.cjs.map +0 -1
- package/dist/cjs/persist/register.cjs +0 -11
- package/dist/cjs/persist/register.cjs.map +0 -1
- package/dist/cjs/persist.cjs +0 -302
- package/dist/cjs/persist.cjs.map +0 -1
- package/dist/cjs/propAccess.cjs +0 -162
- package/dist/cjs/propAccess.cjs.map +0 -1
- package/dist/cjs/react/index.cjs +0 -628
- package/dist/cjs/react/index.cjs.map +0 -1
- package/dist/cjs/react/register.cjs +0 -13
- package/dist/cjs/react/register.cjs.map +0 -1
- package/dist/cjs/scope.cjs +0 -400
- package/dist/cjs/scope.cjs.map +0 -1
- package/dist/cjs/store.cjs +0 -829
- package/dist/cjs/store.cjs.map +0 -1
- package/dist/cjs/storeMethods.cjs +0 -856
- package/dist/cjs/storeMethods.cjs.map +0 -1
- package/dist/cjs/urlStore.cjs +0 -120
- package/dist/cjs/urlStore.cjs.map +0 -1
- package/dist/es/hash.mjs +0 -27
- package/dist/es/hash.mjs.map +0 -1
- package/dist/es/index.mjs +0 -20
- package/dist/es/index.mjs.map +0 -1
- package/dist/es/index2.mjs +0 -291
- package/dist/es/index2.mjs.map +0 -1
- package/dist/es/mutative/index.mjs +0 -2
- package/dist/es/mutative/index.mjs.map +0 -1
- package/dist/es/mutative/register.mjs +0 -6
- package/dist/es/mutative/register.mjs.map +0 -1
- package/dist/es/mutativeMethods.mjs +0 -27
- package/dist/es/mutativeMethods.mjs.map +0 -1
- package/dist/es/patches/index.mjs +0 -2
- package/dist/es/patches/index.mjs.map +0 -1
- package/dist/es/patches/register.mjs +0 -6
- package/dist/es/patches/register.mjs.map +0 -1
- package/dist/es/persist/register.mjs +0 -9
- package/dist/es/persist/register.mjs.map +0 -1
- package/dist/es/persist.mjs +0 -300
- package/dist/es/persist.mjs.map +0 -1
- package/dist/es/propAccess.mjs +0 -151
- package/dist/es/propAccess.mjs.map +0 -1
- package/dist/es/react/index.mjs +0 -611
- package/dist/es/react/index.mjs.map +0 -1
- package/dist/es/react/register.mjs +0 -11
- package/dist/es/react/register.mjs.map +0 -1
- package/dist/es/scope.mjs +0 -391
- package/dist/es/scope.mjs.map +0 -1
- package/dist/es/store.mjs +0 -812
- package/dist/es/store.mjs.map +0 -1
- package/dist/es/storeMethods.mjs +0 -845
- package/dist/es/storeMethods.mjs.map +0 -1
- package/dist/es/urlStore.mjs +0 -116
- package/dist/es/urlStore.mjs.map +0 -1
- package/dist/types/core/cache.d.ts +0 -119
- package/dist/types/core/commonTypes.d.ts +0 -76
- package/dist/types/core/index.d.ts +0 -6
- package/dist/types/core/resourceGroup.d.ts +0 -16
- package/dist/types/core/scope.d.ts +0 -5
- package/dist/types/core/store.d.ts +0 -86
- package/dist/types/core/urlStore.d.ts +0 -21
- package/dist/types/index.d.ts +0 -14
- package/dist/types/lib/applyPatches.d.ts +0 -2
- package/dist/types/lib/autobind.d.ts +0 -1
- package/dist/types/lib/cacheState.d.ts +0 -20
- package/dist/types/lib/calcDuration.d.ts +0 -2
- package/dist/types/lib/calculatedValue.d.ts +0 -9
- package/dist/types/lib/castArray.d.ts +0 -1
- package/dist/types/lib/clone.d.ts +0 -1
- package/dist/types/lib/constrain.d.ts +0 -1
- package/dist/types/lib/debounce.d.ts +0 -12
- package/dist/types/lib/deferred.d.ts +0 -5
- package/dist/types/lib/diff.d.ts +0 -17
- package/dist/types/lib/disposable.d.ts +0 -3
- package/dist/types/lib/equals.d.ts +0 -3
- package/dist/types/lib/extendedJson.d.ts +0 -5
- package/dist/types/lib/forwardError.d.ts +0 -1
- package/dist/types/lib/hash.d.ts +0 -5
- package/dist/types/lib/helpers.d.ts +0 -2
- package/dist/types/lib/instanceCache.d.ts +0 -18
- package/dist/types/lib/isPromise.d.ts +0 -1
- package/dist/types/lib/makeSelector.d.ts +0 -2
- package/dist/types/lib/maybePromise.d.ts +0 -1
- package/dist/types/lib/path.d.ts +0 -41
- package/dist/types/lib/promiseChain.d.ts +0 -5
- package/dist/types/lib/promiseWithCancel.d.ts +0 -8
- package/dist/types/lib/promiseWithState.d.ts +0 -9
- package/dist/types/lib/propAccess.d.ts +0 -7
- package/dist/types/lib/queue.d.ts +0 -11
- package/dist/types/lib/standardMethods.d.ts +0 -20
- package/dist/types/lib/throttle.d.ts +0 -2
- package/dist/types/lib/trackingProxy.d.ts +0 -2
- package/dist/types/lib/trie.d.ts +0 -11
- package/dist/types/lib/typeHelpers.d.ts +0 -12
- package/dist/types/lib/unwrapPromise.d.ts +0 -1
- package/dist/types/lib/updateHelpers.d.ts +0 -1
- package/dist/types/lib/wildcardMatch.d.ts +0 -3
- package/dist/types/mutative/index.d.ts +0 -1
- package/dist/types/mutative/mutativeMethods.d.ts +0 -11
- package/dist/types/mutative/register.d.ts +0 -7
- package/dist/types/patches/index.d.ts +0 -1
- package/dist/types/patches/patchMethods.d.ts +0 -44
- package/dist/types/patches/register.d.ts +0 -7
- package/dist/types/persist/index.d.ts +0 -3
- package/dist/types/persist/persist.d.ts +0 -40
- package/dist/types/persist/persistPathHelpers.d.ts +0 -6
- package/dist/types/persist/persistStorage.d.ts +0 -17
- package/dist/types/persist/register.d.ts +0 -9
- package/dist/types/react/cacheMethods.d.ts +0 -5
- package/dist/types/react/form/customInput.d.ts +0 -6
- package/dist/types/react/form/form.d.ts +0 -98
- package/dist/types/react/form/formField.d.ts +0 -68
- package/dist/types/react/form/formForEach.d.ts +0 -19
- package/dist/types/react/form/index.d.ts +0 -3
- package/dist/types/react/form/useFormAutosave.d.ts +0 -9
- package/dist/types/react/index.d.ts +0 -11
- package/dist/types/react/loadingBoundary.d.ts +0 -21
- package/dist/types/react/register.d.ts +0 -15
- package/dist/types/react/scope.d.ts +0 -24
- package/dist/types/react/scopeMethods.d.ts +0 -20
- package/dist/types/react/storeMethods.d.ts +0 -15
- package/dist/types/react/useCache.d.ts +0 -34
- package/dist/types/react/useDecoupledState.d.ts +0 -7
- package/dist/types/react/useProp.d.ts +0 -8
- package/dist/types/react/useStore.d.ts +0 -16
- package/dist/types/react/useUrlParamScope.d.ts +0 -4
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import "../scope-DI1OFHcr.js";
|
|
2
|
+
import { Constrain, Duration, GetKeys, Join, MaybePromise, Object_, Path as Path$1, PathAsString, Selector, Store, Update, UpdateFunction, Value, WildcardPathAsString, WildcardValue } from "../store-DKaeE840.js";
|
|
3
|
+
import { ScopeProps, ScopeProvider, UseCacheArray, UseCacheValue, UseStoreOptions, cacheMethods, scopeMethods, storeMethods, useCache, useScope, useStore } from "../storeMethods-C4luym7C.js";
|
|
4
|
+
import React$1, { Component, ComponentPropsWithoutRef, Context, FormEvent, FunctionComponent, HTMLProps, ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/react/form/customInput.d.ts
|
|
7
|
+
interface CustomInputProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
name: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
declare function CustomInput({
|
|
12
|
+
name,
|
|
13
|
+
children,
|
|
14
|
+
...props
|
|
15
|
+
}: CustomInputProps): React.JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/react/form/formField.d.ts
|
|
18
|
+
interface FormFieldComponentProps<TValue, TPath> {
|
|
19
|
+
name: TPath;
|
|
20
|
+
value: TValue;
|
|
21
|
+
onChange: (event: {
|
|
22
|
+
target: {
|
|
23
|
+
value: TValue;
|
|
24
|
+
};
|
|
25
|
+
} | TValue | undefined, ...args: any[]) => void;
|
|
26
|
+
onBlur: (...args: any[]) => void;
|
|
27
|
+
}
|
|
28
|
+
type FormFieldInfos<TDraft, TOriginal, TPath extends string> = Field<TDraft, TOriginal, TPath> & {
|
|
29
|
+
hasTriggeredValidations: boolean;
|
|
30
|
+
};
|
|
31
|
+
type NativeInputType = "input" | "select" | "textarea";
|
|
32
|
+
type PartialComponentType<P> = (new (props: P, context?: any) => Component<P, any>) | ((props: P, context?: any) => ReactNode);
|
|
33
|
+
type FormFieldComponent = NativeInputType | PartialComponentType<any>;
|
|
34
|
+
type FieldValue<T extends FormFieldComponent> = ComponentPropsWithoutRef<T>["value"];
|
|
35
|
+
type FieldChangeValue<T extends FormFieldComponent> = ComponentPropsWithoutRef<T> extends {
|
|
36
|
+
onChange?: (update: infer U) => void;
|
|
37
|
+
} ? U extends {
|
|
38
|
+
target: {
|
|
39
|
+
value: infer V;
|
|
40
|
+
};
|
|
41
|
+
} ? V : U : never;
|
|
42
|
+
type MakeOptional<T, Keys extends string> = Omit<T, Keys> & Partial<Pick<T, Keys & keyof T>>;
|
|
43
|
+
type FormFieldProps<TPath, TDraft> = {
|
|
44
|
+
name: TPath & PathAsString<TDraft>;
|
|
45
|
+
commitOnBlur?: boolean;
|
|
46
|
+
commitDebounce?: number;
|
|
47
|
+
};
|
|
48
|
+
type FormFieldPropsWithRender<TDraft, TOriginal, TPath extends string> = FormFieldProps<TPath, TDraft> & NoInfer<{
|
|
49
|
+
component?: undefined;
|
|
50
|
+
render: (props: FormFieldComponentProps<Value<TDraft, TPath>, TPath>, info: FormFieldInfos<TDraft, TOriginal, TPath>, form: FormContext<TDraft, TOriginal>) => ReactNode;
|
|
51
|
+
inputFilter?: undefined;
|
|
52
|
+
defaultValue?: undefined;
|
|
53
|
+
serialize?: undefined;
|
|
54
|
+
deserialize?: undefined;
|
|
55
|
+
onChange?: undefined;
|
|
56
|
+
onBlur?: undefined;
|
|
57
|
+
}>;
|
|
58
|
+
type Serialize<TDraft, TOriginal, TPath, TComponent extends FormFieldComponent> = (value: Value<TDraft, TPath>, formState: FormInstance<TDraft, TOriginal>) => FieldValue<TComponent>;
|
|
59
|
+
type Deserialize<TDraft, TOriginal, TPath, TComponent extends FormFieldComponent> = (value: FieldChangeValue<TComponent>, formState: FormInstance<TDraft, TOriginal>) => Value<TDraft, TPath>;
|
|
60
|
+
type FormFieldPropsWithComponent<TDraft, TOriginal, TPath extends string, TComponent extends FormFieldComponent> = FormFieldProps<TPath, TDraft> & {
|
|
61
|
+
component?: TComponent;
|
|
62
|
+
render?: undefined;
|
|
63
|
+
} & NoInfer<{
|
|
64
|
+
inputFilter?: (value: FieldChangeValue<TComponent>) => boolean;
|
|
65
|
+
} & MakeOptional<Omit<ComponentPropsWithoutRef<TComponent>, "id" | "name" | "value" | "defaultValue">, "onChange" | "onBlur"> & (Value<TDraft, TPath> extends Exclude<FieldValue<TComponent>, undefined> ? {
|
|
66
|
+
defaultValue?: FieldValue<TComponent>;
|
|
67
|
+
serialize?: Serialize<TDraft, TOriginal, TPath, TComponent>;
|
|
68
|
+
} : Value<TDraft, TPath> extends FieldValue<TComponent> ? {
|
|
69
|
+
defaultValue: FieldValue<TComponent>;
|
|
70
|
+
serialize?: Serialize<TDraft, TOriginal, TPath, TComponent>;
|
|
71
|
+
} | {
|
|
72
|
+
defaultValue?: FieldValue<TComponent>;
|
|
73
|
+
serialize: Serialize<TDraft, TOriginal, TPath, TComponent>;
|
|
74
|
+
} : {
|
|
75
|
+
serialize: Serialize<TDraft, TOriginal, TPath, TComponent>;
|
|
76
|
+
}) & (FieldChangeValue<TComponent> extends Value<TDraft, TPath> ? {
|
|
77
|
+
deserialize?: Deserialize<TDraft, TOriginal, TPath, TComponent>;
|
|
78
|
+
} : {
|
|
79
|
+
deserialize: Deserialize<TDraft, TOriginal, TPath, TComponent>;
|
|
80
|
+
})>;
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/react/form/formForEach.d.ts
|
|
83
|
+
type ElementName<TDraft, TPath extends string> = keyof { [Path in TPath as Join<Path, GetKeys<NonNullable<Value<TDraft, Path>>> & (string | number)>]: 1 };
|
|
84
|
+
interface FormForEachProps<TDraft, TPath extends string> {
|
|
85
|
+
name: TPath & PathAsString<TDraft>;
|
|
86
|
+
renderElement?: (props: {
|
|
87
|
+
name: ElementName<TDraft, TPath>;
|
|
88
|
+
key: `${GetKeys<NonNullable<Value<TDraft, TPath>>> & (string | number)}`;
|
|
89
|
+
index: number;
|
|
90
|
+
remove: () => void;
|
|
91
|
+
}) => ReactNode;
|
|
92
|
+
children?: (props: {
|
|
93
|
+
setValue: (value: Value<TDraft, TPath> | ((value: Value<TDraft, TPath>) => Value<TDraft, TPath>)) => void;
|
|
94
|
+
} & FieldHelperMethods<TDraft, TPath>) => ReactNode;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/react/form/useFormAutosave.d.ts
|
|
98
|
+
interface FormAutosaveOptions<TDraft, TOriginal> {
|
|
99
|
+
save: (draft: TDraft, form: FormContext<TDraft, TOriginal>) => MaybePromise<void>;
|
|
100
|
+
debounce?: Duration;
|
|
101
|
+
resetAfterSave?: boolean;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/react/form/form.d.ts
|
|
105
|
+
type Transform<TDraft> = Path$1<TDraft> | "" extends infer TPath ? TPath extends TPath ? {
|
|
106
|
+
update: (value: Value<TDraft, TPath>, store: Store<TDraft>) => void | TDraft;
|
|
107
|
+
} & (TPath extends "" ? {
|
|
108
|
+
trigger?: "";
|
|
109
|
+
} : {
|
|
110
|
+
trigger: TPath;
|
|
111
|
+
}) : never : never;
|
|
112
|
+
interface FormOptions<TDraft, TOriginal> {
|
|
113
|
+
defaultValue: TDraft;
|
|
114
|
+
validations?: Validations<TDraft, TOriginal>;
|
|
115
|
+
localizeError?: (error: string, field: string) => string | undefined;
|
|
116
|
+
autoSave?: FormAutosaveOptions<TDraft, TOriginal>;
|
|
117
|
+
transform?: Transform<TDraft>[];
|
|
118
|
+
validatedClass?: string;
|
|
119
|
+
}
|
|
120
|
+
type Validations<TDraft, TOriginal> = { [TPath in WildcardPathAsString<TDraft>]?: Record<string, Validation<TDraft, TOriginal, TPath>> } & Record<string, Record<string, Validation<TDraft, TOriginal, any>>>;
|
|
121
|
+
type Validation<TDraft, TOriginal, TPath> = (value: WildcardValue<TDraft, TPath>, context: {
|
|
122
|
+
draft: TDraft;
|
|
123
|
+
original: TOriginal;
|
|
124
|
+
field: PathAsString<TDraft> | "";
|
|
125
|
+
}) => boolean;
|
|
126
|
+
type Field<TDraft, TOriginal, TPath extends string> = {
|
|
127
|
+
originalValue: Value<TOriginal, TPath> | undefined;
|
|
128
|
+
value: Value<TDraft, TPath>;
|
|
129
|
+
setValue: (value: Update<Value<TDraft, TPath>>) => void;
|
|
130
|
+
hasChange: boolean;
|
|
131
|
+
errors: string[];
|
|
132
|
+
} & (Value<TDraft, TPath> extends Object_ ? FieldHelperMethods<TDraft, TPath> : {});
|
|
133
|
+
type FieldHelperMethods<TDraft, TPath extends string> = {
|
|
134
|
+
names: ElementName<TDraft, TPath>[];
|
|
135
|
+
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;
|
|
136
|
+
remove: Value<TDraft, TPath> extends readonly any[] ? (index: number) => void : (key: string) => void;
|
|
137
|
+
};
|
|
138
|
+
interface FormState<TDraft> {
|
|
139
|
+
draft: TDraft | undefined;
|
|
140
|
+
hasTriggeredValidations: boolean;
|
|
141
|
+
saveScheduled: boolean;
|
|
142
|
+
saveInProgress: boolean;
|
|
143
|
+
}
|
|
144
|
+
interface FormDerivedState<TDraft> {
|
|
145
|
+
draft: TDraft;
|
|
146
|
+
hasTriggeredValidations: boolean;
|
|
147
|
+
saveScheduled: boolean;
|
|
148
|
+
saveInProgress: boolean;
|
|
149
|
+
hasChanges: boolean;
|
|
150
|
+
errors: Map<string, string[]>;
|
|
151
|
+
isValid: boolean;
|
|
152
|
+
}
|
|
153
|
+
interface FormContext<TDraft, TOriginal> {
|
|
154
|
+
formState: Store<FormState<TDraft>>;
|
|
155
|
+
options: FormOptions<TDraft, TOriginal>;
|
|
156
|
+
original: TOriginal | undefined;
|
|
157
|
+
getField: <TPath extends string>(path: TPath) => Field<TDraft, TOriginal, TPath>;
|
|
158
|
+
getDraft: () => TDraft;
|
|
159
|
+
hasTriggeredValidations: () => boolean;
|
|
160
|
+
saveScheduled: () => boolean;
|
|
161
|
+
saveInProgress: () => boolean;
|
|
162
|
+
hasChanges: () => boolean;
|
|
163
|
+
getErrors: () => Map<string, string[]>;
|
|
164
|
+
isValid: () => boolean;
|
|
165
|
+
validate: () => boolean;
|
|
166
|
+
reset: () => void;
|
|
167
|
+
}
|
|
168
|
+
interface FormInstance<TDraft, TOriginal> extends FormDerivedState<TDraft>, Pick<FormContext<TDraft, TOriginal>, "options" | "original" | "getField" | "validate" | "reset"> {}
|
|
169
|
+
declare class Form<TDraft, TOriginal extends TDraft = TDraft> {
|
|
170
|
+
readonly options: FormOptions<TDraft, TOriginal>;
|
|
171
|
+
context: Context<FormContext<TDraft, TOriginal> | null>;
|
|
172
|
+
constructor(options: FormOptions<TDraft, TOriginal>);
|
|
173
|
+
useForm(): FormContext<TDraft, TOriginal>;
|
|
174
|
+
useFormState<S>(selector: (state: FormInstance<TDraft, TOriginal>) => S, useStoreOptions?: UseStoreOptions<S>): S;
|
|
175
|
+
useField<TPath extends string>(path: TPath, useStoreOptions?: UseStoreOptions<any>): Field<TDraft, TOriginal, TPath>;
|
|
176
|
+
Form({
|
|
177
|
+
original,
|
|
178
|
+
defaultValue,
|
|
179
|
+
validations,
|
|
180
|
+
localizeError,
|
|
181
|
+
autoSave,
|
|
182
|
+
transform,
|
|
183
|
+
validatedClass,
|
|
184
|
+
...formProps
|
|
185
|
+
}: {
|
|
186
|
+
original?: TOriginal;
|
|
187
|
+
onSubmit?: (event: FormEvent<HTMLFormElement>, form: FormInstance<TDraft, TOriginal>) => void;
|
|
188
|
+
} & Partial<FormOptions<TDraft, TOriginal>> & Omit<HTMLProps<HTMLFormElement>, "defaultValue" | "autoSave" | "onSubmit">): React.JSX.Element;
|
|
189
|
+
FormState<S>({
|
|
190
|
+
selector,
|
|
191
|
+
children
|
|
192
|
+
}: {
|
|
193
|
+
selector: (form: FormInstance<TDraft, TOriginal>) => S;
|
|
194
|
+
children: (selectedState: S) => ReactNode;
|
|
195
|
+
}): React.JSX.Element;
|
|
196
|
+
Field<const TPath extends string>(props: FormFieldPropsWithRender<TDraft, TOriginal, TPath>): React.JSX.Element;
|
|
197
|
+
Field<const TPath extends string, const TComponent extends FormFieldComponent = "input">(props: FormFieldPropsWithComponent<TDraft, TOriginal, TPath, TComponent>): React.JSX.Element;
|
|
198
|
+
ForEach<const TPath extends string>(props: FormForEachProps<TDraft, TPath>): React.JSX.Element;
|
|
199
|
+
withForm<TProps extends Record<string, unknown>>(Component: React.ComponentType<TProps>, formProps?: Parameters<this["Form"]>[0]): FunctionComponent<TProps>;
|
|
200
|
+
}
|
|
201
|
+
declare function createForm<TDraft, TOriginal extends TDraft = TDraft>(options: FormOptions<TDraft, TOriginal>): Form<TDraft, TOriginal>;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/react/loadingBoundary.d.ts
|
|
204
|
+
interface LoadingBoundaryEntry {
|
|
205
|
+
label?: ReactNode;
|
|
206
|
+
}
|
|
207
|
+
interface LoadingBoundaryProps {
|
|
208
|
+
/**
|
|
209
|
+
* Fallback node to render when there are loading components within the boundary.
|
|
210
|
+
*/
|
|
211
|
+
fallback?: ReactNode | ((entries: LoadingBoundaryEntry[]) => ReactNode);
|
|
212
|
+
/**
|
|
213
|
+
* Child node to render when there are no loading components within the boundary.
|
|
214
|
+
*/
|
|
215
|
+
children?: ReactNode;
|
|
216
|
+
/**
|
|
217
|
+
* Add a loading state from outside the boundary. Useful for when you want to
|
|
218
|
+
* show a loading state for a component that is not a child of the boundary.
|
|
219
|
+
*/
|
|
220
|
+
isLoading?: boolean;
|
|
221
|
+
}
|
|
222
|
+
declare function LoadingBoundary({
|
|
223
|
+
fallback,
|
|
224
|
+
children,
|
|
225
|
+
isLoading: isLoadingExternal
|
|
226
|
+
}: LoadingBoundaryProps): React.JSX.Element;
|
|
227
|
+
declare function useLoadingBoundary(isLoading: boolean | undefined, label?: ReactNode): void;
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/react/url/urlContext.d.ts
|
|
230
|
+
type Location = string | {
|
|
231
|
+
pathname: string;
|
|
232
|
+
search: string;
|
|
233
|
+
hash: string;
|
|
234
|
+
};
|
|
235
|
+
interface UrlContextType {
|
|
236
|
+
location: Location;
|
|
237
|
+
navigate: (navigate: (from: Location) => string) => void;
|
|
238
|
+
}
|
|
239
|
+
type UrlContextProviderProps = {
|
|
240
|
+
children?: ReactNode;
|
|
241
|
+
} & ({
|
|
242
|
+
location: UrlContextType["location"];
|
|
243
|
+
} | {
|
|
244
|
+
locationHook: () => UrlContextType["location"];
|
|
245
|
+
}) & ({
|
|
246
|
+
navigate: UrlContextType["navigate"];
|
|
247
|
+
} | {
|
|
248
|
+
navigateHook: () => UrlContextType["navigate"];
|
|
249
|
+
});
|
|
250
|
+
declare const UrlContext: Context<UrlContextType | undefined>;
|
|
251
|
+
declare function UrlProvider({
|
|
252
|
+
children,
|
|
253
|
+
...props
|
|
254
|
+
}: UrlContextProviderProps): React$1.JSX.Element;
|
|
255
|
+
declare function useUrlContext(): UrlContextType;
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/react/url/urlOptions.d.ts
|
|
258
|
+
interface UrlOptions<T> {
|
|
259
|
+
key: string;
|
|
260
|
+
type?: "search" | "hash";
|
|
261
|
+
serialize?: (value: T) => string;
|
|
262
|
+
deserialize?: (value: string) => T;
|
|
263
|
+
defaultValue: T;
|
|
264
|
+
writeDefaultValue?: boolean;
|
|
265
|
+
onCommit?: (value: T) => void;
|
|
266
|
+
persist?: {
|
|
267
|
+
id: string;
|
|
268
|
+
} | null;
|
|
269
|
+
}
|
|
270
|
+
interface UrlOptionsWithoutDefaults<T> extends Omit<UrlOptions<T | undefined>, "defaultValue"> {
|
|
271
|
+
defaultValue?: T | undefined;
|
|
272
|
+
}
|
|
273
|
+
declare function createUrlOptions<T>(options: UrlOptions<T>): Required<UrlOptions<T>>;
|
|
274
|
+
declare function createUrlOptions<T>(options: UrlOptionsWithoutDefaults<T>): Required<UrlOptions<T | undefined>>;
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/react/url/urlStore.d.ts
|
|
277
|
+
declare class UrlStore<T> {
|
|
278
|
+
readonly options: Required<UrlOptions<T>>;
|
|
279
|
+
constructor(options: Required<UrlOptions<T>>);
|
|
280
|
+
useStore(): T;
|
|
281
|
+
useProp(): [T, update: (value: T) => void];
|
|
282
|
+
parse(location: Location): T | undefined;
|
|
283
|
+
}
|
|
284
|
+
declare function createUrlStore<T>(options: UrlOptions<T>): UrlStore<T>;
|
|
285
|
+
declare function createUrlStore<T>(options: UrlOptionsWithoutDefaults<T>): UrlStore<T | undefined>;
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/react/url/useUrlParam.d.ts
|
|
288
|
+
declare function useUrlParam<T>(store: UrlStore<T>): [T, update: UpdateFunction<T>];
|
|
289
|
+
declare function useUrlParam<T>(options: UrlOptions<T>): [T, update: UpdateFunction<T>];
|
|
290
|
+
declare function useUrlParam<T>(options: UrlOptionsWithoutDefaults<T>): [T | undefined, update: UpdateFunction<T | undefined>];
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/react/useDecoupledState.d.ts
|
|
293
|
+
interface UseDecoupledStateOptions<T> {
|
|
294
|
+
debounce?: Duration;
|
|
295
|
+
throttle?: Duration;
|
|
296
|
+
onCommit?: (value: T) => void;
|
|
297
|
+
}
|
|
298
|
+
declare function useDecoupledState<T>(value: T, onChange: (value: T) => void, options?: UseDecoupledStateOptions<T>): [state: T, setState: (value: T) => void];
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/react/useProp.d.ts
|
|
301
|
+
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"]];
|
|
302
|
+
declare function useProp<T, const P>(store: Store<T>, selector: Constrain<P, Path$1<T>>, options?: UseStoreOptions<Value<T, P>>): [value: Value<T, P>, setValue: Store<Value<T, P>>["set"]];
|
|
303
|
+
declare function useProp<T>(store: Store<T>, options?: UseStoreOptions<T>): [value: T, setValue: Store<T>["set"]];
|
|
304
|
+
//#endregion
|
|
305
|
+
export { CustomInput, CustomInputProps, Field, Form, FormContext, FormDerivedState, FormFieldComponent, FormFieldProps, FormInstance, FormOptions, FormState, LoadingBoundary, type LoadingBoundaryEntry, type LoadingBoundaryProps, type ScopeProps, ScopeProvider, Transform, UrlContext, type UrlContextProviderProps, type UrlContextType, type UrlOptions, type UrlOptionsWithoutDefaults, UrlProvider, type UrlStore, type UseCacheArray, type UseCacheValue, type UseDecoupledStateOptions, type UseStoreOptions, Validation, Validations, cacheMethods, createForm, createUrlOptions, createUrlStore, scopeMethods, storeMethods, useCache, useDecoupledState, useLoadingBoundary, useProp, useScope, useStore, useUrlContext, useUrlParam };
|
|
306
|
+
//# sourceMappingURL=index.d.ts.map
|