@structuralists/scaffolding 0.10.1 → 0.11.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/eslint.config.mjs +56 -2
- package/package.json +1 -1
- package/src/components/Chat/ChatRecipientsHeader/ChatRecipientsHeader.stories.tsx +4 -4
- package/src/components/Layout/Bar/Bar.stories.tsx +1 -1
- package/src/components/Layout/Panels/Panels.stories.tsx +1 -1
- package/src/components/Layout/Stack/Stack.stories.tsx +1 -1
- package/src/components/Modals/LargeModal/LargeModal.stories.tsx +1 -1
- package/src/components/Modals/MediumModal/MediumModal.stories.tsx +3 -3
- package/src/components/Modals/internal/ModalHeader.tsx +1 -1
- package/src/components/Overlays/Popover/Popover.stories.tsx +3 -3
- package/src/components/Overlays/Tooltip/Tooltip.stories.tsx +1 -1
- package/src/components/Tables/BigTable/BigTable.stories.tsx +1 -1
- package/src/forms/CLAUDE.md +115 -24
- package/src/{components/Forms → forms/elements}/Button/Button.stories.tsx +1 -1
- package/src/{components/Forms → forms/elements}/IconButton/index.tsx +1 -1
- package/src/{components/Forms → forms/elements}/Input/index.tsx +2 -0
- package/src/{components/Forms → forms/elements}/Input/types.ts +2 -1
- package/src/{components/Forms → forms/elements}/Select/MultiSelect/MultiSelect.stories.tsx +2 -2
- package/src/{components/Forms → forms/elements}/Select/MultiSelect/index.tsx +1 -1
- package/src/{components/Forms → forms/elements}/Select/SingleSelect/SingleSelect.stories.tsx +3 -3
- package/src/{components/Forms → forms/elements}/Select/SingleSelect/index.tsx +1 -1
- package/src/forms/plan.md +84 -38
- package/src/forms/state/bindings/SingleSelectForForm.tsx +45 -0
- package/src/forms/state/bindings/TextInputForForm.tsx +45 -0
- package/src/forms/{path → state/path}/path.test.ts +71 -1
- package/src/forms/state/path/path.ts +103 -0
- package/src/forms/{useFormState → state/useFormState}/FormDebugger.tsx +2 -1
- package/src/forms/{useFormState → state/useFormState}/errorAt.ts +8 -12
- package/src/forms/{useFormState → state/useFormState}/types.ts +33 -2
- package/src/forms/state/useFormState/useFieldBinding.test.tsx +165 -0
- package/src/forms/state/useFormState/useFieldBinding.ts +71 -0
- package/src/forms/{useFormState → state/useFormState}/useFormDebugger.test.tsx +1 -0
- package/src/forms/{useFormState → state/useFormState}/useFormState.stories.tsx +167 -4
- package/src/forms/{useFormState → state/useFormState}/useFormState.test-d.ts +80 -1
- package/src/forms/{useFormState → state/useFormState}/useFormState.ts +12 -3
- package/src/index.ts +10 -10
- package/src/storybook/Composition.stories.tsx +4 -4
- package/src/storybook/_StoryUtils.stories.tsx +1 -1
- package/src/forms/path/path.ts +0 -53
- /package/src/{components/Forms → forms/elements}/Button/index.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/Button/styles.module.css +0 -0
- /package/src/{components/Forms → forms/elements}/Button/types.ts +0 -0
- /package/src/{components/Forms → forms/elements}/ColorInput/index.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/ColorInput/styles.module.css +0 -0
- /package/src/{components/Forms → forms/elements}/ColorInput/types.ts +0 -0
- /package/src/{components/Forms → forms/elements}/Field/Field.stories.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/Field/index.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/Field/styles.module.css +0 -0
- /package/src/{components/Forms → forms/elements}/Field/types.ts +0 -0
- /package/src/{components/Forms → forms/elements}/IconButton/IconButton.stories.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/IconButton/styles.module.css +0 -0
- /package/src/{components/Forms → forms/elements}/IconButton/types.ts +0 -0
- /package/src/{components/Forms → forms/elements}/Input/Input.stories.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/Input/styles.module.css +0 -0
- /package/src/{components/Forms → forms/elements}/SearchInput/index.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/SearchInput/styles.module.css +0 -0
- /package/src/{components/Forms → forms/elements}/SearchInput/types.ts +0 -0
- /package/src/{components/Forms → forms/elements}/Select/MultiSelect/types.ts +0 -0
- /package/src/{components/Forms → forms/elements}/Select/SingleSelect/types.ts +0 -0
- /package/src/{components/Forms → forms/elements}/Select/index.ts +0 -0
- /package/src/{components/Forms → forms/elements}/Select/internal/OptionList.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/Select/internal/SelectTrigger.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/Select/internal/styles.module.css +0 -0
- /package/src/{components/Forms → forms/elements}/Textarea/Textarea.stories.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/Textarea/index.tsx +0 -0
- /package/src/{components/Forms → forms/elements}/Textarea/styles.module.css +0 -0
- /package/src/{components/Forms → forms/elements}/Textarea/types.ts +0 -0
- /package/src/forms/{path → state/path}/types.test-d.ts +0 -0
- /package/src/forms/{path → state/path}/types.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/FormDebugger.module.css +0 -0
- /package/src/forms/{useFormState → state/useFormState}/FormDebugger.test.tsx +0 -0
- /package/src/forms/{useFormState → state/useFormState}/deriveErrors.test.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/deriveErrors.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/errorAt.test.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/inspectable.test.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/inspectable.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/snapshotStore.test.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/snapshotStore.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/useFormDebugger.ts +0 -0
- /package/src/forms/{useFormState → state/useFormState}/useFormState.test.tsx +0 -0
- /package/src/forms/{useFormState → state/useFormState}/useFormSubmit.test.tsx +0 -0
- /package/src/forms/{useFormState → state/useFormState}/useFormSubmit.ts +0 -0
- /package/src/forms/{validations → state/validations}/perField.ts +0 -0
- /package/src/forms/{validations → state/validations}/types.test-d.ts +0 -0
- /package/src/forms/{validations → state/validations}/types.ts +0 -0
- /package/src/forms/{validations → state/validations}/walk.test.ts +0 -0
- /package/src/forms/{validations → state/validations}/walk.ts +0 -0
- /package/src/forms/{validators → state/validators}/validators.test.ts +0 -0
- /package/src/forms/{validators → state/validators}/validators.ts +0 -0
package/src/forms/path/path.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Cursor, CursorStep, Path, PathStep, ValueAt } from './types';
|
|
2
|
-
|
|
3
|
-
const makeCursor = <T>(steps: readonly CursorStep[]): Cursor<T> => ({
|
|
4
|
-
at<P extends Path<T>>(p: P): Cursor<ValueAt<T, P>> {
|
|
5
|
-
const keySteps: CursorStep[] = (p as readonly PathStep[]).map((key) => ({
|
|
6
|
-
kind: 'key',
|
|
7
|
-
key,
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
return makeCursor<ValueAt<T, P>>([...steps, ...keySteps]);
|
|
11
|
-
},
|
|
12
|
-
narrow<U extends T>(predicate: (val: T) => val is U): Cursor<U> {
|
|
13
|
-
return makeCursor<U>([
|
|
14
|
-
...steps,
|
|
15
|
-
{ kind: 'narrow', predicate: predicate as (val: unknown) => boolean },
|
|
16
|
-
]);
|
|
17
|
-
},
|
|
18
|
-
build() {
|
|
19
|
-
return [...steps];
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export const path = <T>(): Cursor<T> => makeCursor<T>([]);
|
|
24
|
-
|
|
25
|
-
// Walk steps against a value. Returns undefined if any step fails — a dead
|
|
26
|
-
// value (null or undefined) encountered mid-path, missing key, out-of-bounds
|
|
27
|
-
// index, or a narrow predicate that rejects the current value. Always
|
|
28
|
-
// undefined, never null, even when the dead value was null — ValueAt in
|
|
29
|
-
// ./types.ts mirrors this exactly (see "Union policy" in src/forms/CLAUDE.md).
|
|
30
|
-
// Callers using the typed cursor know what shape to expect; this is the
|
|
31
|
-
// runtime escape hatch that surfaces "the path didn't resolve."
|
|
32
|
-
export const read = (root: unknown, steps: readonly CursorStep[]): unknown => {
|
|
33
|
-
let cursor: unknown = root;
|
|
34
|
-
|
|
35
|
-
for (const step of steps) {
|
|
36
|
-
if (cursor == null) return undefined;
|
|
37
|
-
|
|
38
|
-
if (step.kind === 'narrow') {
|
|
39
|
-
if (!step.predicate(cursor)) return undefined;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (typeof step.key === 'number') {
|
|
44
|
-
if (!Array.isArray(cursor)) return undefined;
|
|
45
|
-
cursor = cursor[step.key];
|
|
46
|
-
} else {
|
|
47
|
-
if (typeof cursor !== 'object') return undefined;
|
|
48
|
-
cursor = (cursor as Record<string, unknown>)[step.key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return cursor;
|
|
53
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|