@pipelex/mthds-form 0.21.0 → 0.23.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.
@@ -1,74 +0,0 @@
1
- import * as react from 'react';
2
- import { RunField } from './core/descriptor.js';
3
- import { FileSource } from './core/sources.js';
4
-
5
- /**
6
- * Ambient state that any field in the tree may need, threaded unchanged through
7
- * the recursion so containers don't have to re-plumb it for every child.
8
- */
9
- interface FieldEnv {
10
- disabled?: boolean;
11
- /**
12
- * A file field asks its parent to upload; the parent sets the value later.
13
- *
14
- * Its presence is the capability. A host that supplies it gets a dropzone on
15
- * every file field; a host that does not gets no dropzone and no file picker,
16
- * because a file taken with nowhere to go used to be dropped without a word.
17
- * See docs/upload-seam.md, "Which ways into a file value a host offers".
18
- */
19
- onDropFile?: (id: string, file: File) => void;
20
- /**
21
- * Whether a file field offers a link input, the way in that needs no upload.
22
- * `true` when absent; `false` hides the "paste a URL instead" toggle and the
23
- * input behind it on every file field.
24
- *
25
- * It governs that input and nothing else. A file value is a URL whichever way
26
- * it arrived, so this says nothing about which values are valid: a web link
27
- * the host writes is still shown on the field's card and can still be
28
- * cleared. Setting it to `false` with no `onDropFile` leaves a file field no
29
- * way in at all, and the field throws, naming its path, when it renders.
30
- */
31
- allowUrl?: boolean;
32
- /** Ids currently mid-upload. */
33
- uploadingIds?: ReadonlySet<string>;
34
- /**
35
- * Why an upload failed, keyed by the same id `onDropFile` was handed, so the
36
- * message shows on the field that took the file rather than under the whole
37
- * form, where only its wording could say which input failed.
38
- *
39
- * The map is the host's truth about each upload attempt: a host removes an
40
- * entry when the next file is dropped at that id, and sets it again if that
41
- * upload fails too. A clear or a typed link on the field hides the message
42
- * until the host sends a different one or removes it, and a list holds back
43
- * the entries a row removal left at a renumbered position.
44
- */
45
- uploadErrors?: ReadonlyMap<string, string>;
46
- /** Resolve a `pipelex-storage://` URI to a browser-viewable URL (for previews
47
- * of already-stored files). */
48
- resolveUrl?: (uri: string) => Promise<string | null>;
49
- /**
50
- * Where a file field can take a file the host already stores. Its presence
51
- * is the capability, as `onDropFile`'s is: every empty file field then
52
- * offers "Choose from your team's files", and a list of files offers it for
53
- * several at once. The choice is written as `{ url, filename }`, exactly as
54
- * an upload's result is. See docs/sources.md.
55
- */
56
- fileSource?: FileSource;
57
- }
58
- interface FieldRendererProps {
59
- field: RunField;
60
- value: unknown;
61
- onChange: (value: unknown) => void;
62
- /** Unique, stable id used for label linkage and upload tracking. */
63
- id: string;
64
- error?: string;
65
- env?: FieldEnv;
66
- }
67
- /**
68
- * The single dispatch point: a normalized `RunField` → the matching control.
69
- * Object and list fields recurse back through here, so the whole form is one
70
- * data-driven tree with no per-type branching anywhere else.
71
- */
72
- declare function FieldRenderer({ field, value, onChange, id, error, env }: FieldRendererProps): react.JSX.Element;
73
-
74
- export { type FieldEnv as F, FieldRenderer as a, type FieldRendererProps as b };