effect-atom-svelte 0.3.0 → 0.4.0
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/README.md +4 -1
- package/dist/Form.d.ts +605 -0
- package/dist/Form.js +67 -0
- package/dist/Hooks.svelte.d.ts +54 -0
- package/dist/Hooks.svelte.js +98 -64
- package/dist/HydrationBoundary.svelte +4 -5
- package/dist/Inspector.js +49 -32
- package/dist/RegistryContext.js +3 -1
- package/dist/ScopedAtom.js +15 -7
- package/dist/SvelteKit.d.ts +46 -12
- package/dist/SvelteKit.js +130 -18
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/internal/awaitWrite.d.ts +11 -0
- package/dist/internal/awaitWrite.js +27 -0
- package/dist/internal/boundaries.js +3 -1
- package/dist/internal/form/array.d.ts +21 -0
- package/dist/internal/form/array.js +57 -0
- package/dist/internal/form/constraints.d.ts +13 -0
- package/dist/internal/form/constraints.js +166 -0
- package/dist/internal/form/engine.d.ts +56 -0
- package/dist/internal/form/engine.js +842 -0
- package/dist/internal/form/engineOf.d.ts +26 -0
- package/dist/internal/form/engineOf.js +43 -0
- package/dist/internal/form/field.d.ts +30 -0
- package/dist/internal/form/field.js +68 -0
- package/dist/internal/form/group.d.ts +13 -0
- package/dist/internal/form/group.js +20 -0
- package/dist/internal/form/instance.d.ts +41 -0
- package/dist/internal/form/instance.js +135 -0
- package/dist/internal/form/issues.d.ts +23 -0
- package/dist/internal/form/issues.js +144 -0
- package/dist/internal/form/paths.d.ts +47 -0
- package/dist/internal/form/paths.js +175 -0
- package/dist/internal/form/types.d.ts +80 -0
- package/dist/internal/form/types.js +1 -0
- package/dist/internal/form/validationError.d.ts +13 -0
- package/dist/internal/form/validationError.js +6 -0
- package/dist/internal/hydration.js +3 -1
- package/dist/internal/nodeInternals.js +44 -11
- package/package.json +12 -10
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Exit } from "effect";
|
|
2
|
+
import { Atom } from "effect/reactivity";
|
|
3
|
+
import type { AtomRegistry } from "effect/reactivity";
|
|
4
|
+
import { ArrayImpl } from "./array.ts";
|
|
5
|
+
import type { Constraints } from "./constraints.ts";
|
|
6
|
+
import { FieldImpl } from "./field.ts";
|
|
7
|
+
import { GroupImpl } from "./group.ts";
|
|
8
|
+
import { InstanceImpl } from "./instance.ts";
|
|
9
|
+
import type { IndexPath, KeyPath } from "./paths.ts";
|
|
10
|
+
import type { Definition, EngineOptions, ErrorsInput, State } from "./types.ts";
|
|
11
|
+
export declare class Engine {
|
|
12
|
+
#private;
|
|
13
|
+
readonly definition: Definition;
|
|
14
|
+
readonly options: EngineOptions;
|
|
15
|
+
readonly registry: AtomRegistry.AtomRegistry;
|
|
16
|
+
readonly stateAtom: Atom.Writable<State>;
|
|
17
|
+
readonly valuesAtom: Atom.Writable<unknown>;
|
|
18
|
+
readonly root: InstanceImpl;
|
|
19
|
+
constructor(definition: Definition, options: EngineOptions);
|
|
20
|
+
/** Reads state and values through these instead, as `useForm` does to make them reactive. */
|
|
21
|
+
setReaders(state: () => State, values: () => unknown): void;
|
|
22
|
+
get state(): State;
|
|
23
|
+
get values(): unknown;
|
|
24
|
+
/** Writes a field's value, as typing into it does. */
|
|
25
|
+
setField(path: KeyPath, value: unknown): void;
|
|
26
|
+
/** Marks a field touched, as leaving it does, and checks it if `validateOn` says so. */
|
|
27
|
+
leave(path: KeyPath): void;
|
|
28
|
+
setTouched(path: KeyPath, touched: boolean): void;
|
|
29
|
+
setValues(values: unknown): void;
|
|
30
|
+
/** Changes an array and its item keys together, so state stays with each item. */
|
|
31
|
+
updateArray(path: KeyPath, f: (items: unknown[], keys: number[]) => void): void;
|
|
32
|
+
newKey(): number;
|
|
33
|
+
/** The current initial values change: a clean form takes them, a dirty one keeps its edits. */
|
|
34
|
+
setInitial(initial: unknown): void;
|
|
35
|
+
reset(values?: unknown): void;
|
|
36
|
+
revertToLastSubmit(): void;
|
|
37
|
+
setErrors(errors: ErrorsInput, source: "submit" | "manual"): void;
|
|
38
|
+
/**
|
|
39
|
+
* Checks the given paths (all by default), shows their errors, and says whether they passed: no
|
|
40
|
+
* Schema error and no external error at or under any of them.
|
|
41
|
+
*/
|
|
42
|
+
validate(paths?: readonly (string | IndexPath)[]): Promise<boolean>;
|
|
43
|
+
submit(args?: unknown): Promise<Exit.Exit<unknown, unknown>>;
|
|
44
|
+
/** The error to show on a path: from outside the Schema first, then the Schema's once revealed. */
|
|
45
|
+
errorAt(path: KeyPath): string | undefined;
|
|
46
|
+
indexPath(path: KeyPath): IndexPath | undefined;
|
|
47
|
+
/** Resolves `relative`, an index path below `base`, to a key path. */
|
|
48
|
+
resolve(base: KeyPath, relative: string | IndexPath): KeyPath;
|
|
49
|
+
elementId(path: KeyPath): string;
|
|
50
|
+
constraints(path: IndexPath): Constraints;
|
|
51
|
+
field(path: KeyPath): FieldImpl;
|
|
52
|
+
group(path: KeyPath): GroupImpl;
|
|
53
|
+
array(path: KeyPath): ArrayImpl;
|
|
54
|
+
/** Releases the instance's atoms; a submit in flight keeps them until it settles. */
|
|
55
|
+
dispose(): void;
|
|
56
|
+
}
|