@pipelex/mthds-form 0.21.0 → 0.22.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/dist/{chunk-3XDR2C4I.js → chunk-5IZWP2X4.js} +316 -65
- package/dist/chunk-5IZWP2X4.js.map +1 -0
- package/dist/field-renderer-lNhtw-Cz.d.ts +215 -0
- package/dist/generative/index.d.ts +1 -1
- package/dist/generative/index.js +1 -1
- package/dist/react/index.d.ts +86 -71
- package/dist/react/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-3XDR2C4I.js.map +0 -1
- package/dist/field-renderer-B3g16qZT.d.ts +0 -74
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { FileRunField, RunField } from './core/descriptor.js';
|
|
3
|
+
import { FileSource } from './core/sources.js';
|
|
4
|
+
|
|
5
|
+
/** The serializable value of a file field. URL is what the runner sends. */
|
|
6
|
+
interface FileValue {
|
|
7
|
+
url?: string;
|
|
8
|
+
filename?: string;
|
|
9
|
+
}
|
|
10
|
+
/** What a host's upload resolves to: the stored file's URL, or its URL and name. */
|
|
11
|
+
type UploadedFile = string | {
|
|
12
|
+
url: string;
|
|
13
|
+
filename?: string;
|
|
14
|
+
};
|
|
15
|
+
interface FileFieldProps {
|
|
16
|
+
field: FileRunField;
|
|
17
|
+
value: FileValue | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Called when a file is dropped/picked - the parent uploads and sets value.
|
|
20
|
+
*
|
|
21
|
+
* It may return the upload: a promise of what it stored, whose URL is the
|
|
22
|
+
* one the host writes into the value. The control then knows its upload's
|
|
23
|
+
* own result by that URL, so the dropped file's preview is kept for it
|
|
24
|
+
* whichever render the host writes it in, and a rejection retires the
|
|
25
|
+
* preview at once. Returning nothing leaves the control to judge the upload
|
|
26
|
+
* by when its value lands (docs/upload-seam.md).
|
|
27
|
+
*
|
|
28
|
+
* Absent means the host cannot store a file, and the control then offers no
|
|
29
|
+
* dropzone and no picker: the link input is open from the start, with a line
|
|
30
|
+
* saying a file cannot be uploaded here.
|
|
31
|
+
*/
|
|
32
|
+
onDropFile?: (file: File) => void | PromiseLike<UploadedFile | void>;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the link input is offered, `true` when absent. `false` removes the
|
|
35
|
+
* "paste a URL instead" toggle and the input behind it, and says nothing about
|
|
36
|
+
* which values are valid. With no `onDropFile` either, the control throws.
|
|
37
|
+
*/
|
|
38
|
+
allowUrl?: boolean;
|
|
39
|
+
/** Manual URL paste / clear flows through here too. */
|
|
40
|
+
onChange: (value: FileValue | undefined) => void;
|
|
41
|
+
id: string;
|
|
42
|
+
/** Parent-driven async state. */
|
|
43
|
+
uploading?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Why the host's upload of this field's file failed. Shown in the alert slot
|
|
46
|
+
* a refused format uses, until the host removes it. A clear or a typed link
|
|
47
|
+
* hides it until the host sends a different message or removes it; a refused
|
|
48
|
+
* pick shows its refusal in its place.
|
|
49
|
+
*/
|
|
50
|
+
uploadError?: string;
|
|
51
|
+
/** Resolve a `pipelex-storage://` URI to a viewable URL (stored-file preview). */
|
|
52
|
+
resolveUrl?: (uri: string) => Promise<string | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Where the field can take a file the host already stores. When given, the
|
|
55
|
+
* empty field offers "Choose from your team's files" under its own controls,
|
|
56
|
+
* and the chosen file is written through `onChange` as `{ url, filename }`,
|
|
57
|
+
* the value an upload writes. See docs/sources.md.
|
|
58
|
+
*/
|
|
59
|
+
fileSource?: FileSource;
|
|
60
|
+
error?: string;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** Document variant: a file shown as a PDF preview (or chip for other docs). */
|
|
64
|
+
declare function DocumentField(props: FileFieldProps): react.JSX.Element;
|
|
65
|
+
/** Image variant: a file shown as a real image preview. */
|
|
66
|
+
declare function ImageField(props: FileFieldProps): react.JSX.Element;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The moves a host makes to a list's rows, and what a move does to an id.
|
|
70
|
+
*
|
|
71
|
+
* A field's id is its value path, so a row's id is its position (`cvs.1`), and
|
|
72
|
+
* moving rows renumbers them. Two parties hold something by row and must move
|
|
73
|
+
* it when the rows move: the host, which keys what it knows about each upload
|
|
74
|
+
* by id, and the list control, which keys each row's React element by an
|
|
75
|
+
* identity of its own so the row's controls travel with it. `useMethodForm`
|
|
76
|
+
* makes every move itself (`removeItem`, `moveItem`), re-keys its own records
|
|
77
|
+
* as it does, and hands the list a log of those moves (`FieldEnv.rowMoves`),
|
|
78
|
+
* which the list replays on its row identities. One log, read by both, is what
|
|
79
|
+
* keeps them agreeing about which row is which. See docs/upload-seam.md, "What
|
|
80
|
+
* the form keeps by id moves with the rows it moves".
|
|
81
|
+
*/
|
|
82
|
+
/** One move of a list's rows, as a host records it for the list to replay. */
|
|
83
|
+
interface RowMove {
|
|
84
|
+
/**
|
|
85
|
+
* The move's number: each move is numbered above the one before it, for as
|
|
86
|
+
* long as the host lives, so a list knows which moves it has replayed.
|
|
87
|
+
*/
|
|
88
|
+
seq: number;
|
|
89
|
+
/** The list's id, the one its rows' ids extend (`cvs` for `cvs.1`). */
|
|
90
|
+
listId: string;
|
|
91
|
+
/**
|
|
92
|
+
* For each row of the list after the move, the index that row held before
|
|
93
|
+
* it. A row whose index is left out was removed.
|
|
94
|
+
*/
|
|
95
|
+
order: readonly number[];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Ambient state that any field in the tree may need, threaded unchanged through
|
|
100
|
+
* the recursion so containers don't have to re-plumb it for every child.
|
|
101
|
+
*/
|
|
102
|
+
interface FieldEnv {
|
|
103
|
+
disabled?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* A file field asks its parent to upload; the parent sets the value later.
|
|
106
|
+
*
|
|
107
|
+
* It may return the upload: a promise of what it stored (`UploadedFile`),
|
|
108
|
+
* whose URL is the one the host writes at the id, rejected when the upload
|
|
109
|
+
* writes nothing. The field then knows its upload's own result by that URL,
|
|
110
|
+
* so the dropped file's preview is kept for it whichever render the host
|
|
111
|
+
* writes it in. A host that returns nothing must write the result in the
|
|
112
|
+
* render it takes the id out of `uploadingIds`. `useMethodForm`'s `dropFile`
|
|
113
|
+
* returns its upload. See docs/upload-seam.md, "The local preview belongs to
|
|
114
|
+
* the value it was made for".
|
|
115
|
+
*
|
|
116
|
+
* Its presence is the capability. A host that supplies it gets a dropzone on
|
|
117
|
+
* every file field; a host that does not gets no dropzone and no file picker,
|
|
118
|
+
* because a file taken with nowhere to go used to be dropped without a word.
|
|
119
|
+
* See docs/upload-seam.md, "Which ways into a file value a host offers".
|
|
120
|
+
*/
|
|
121
|
+
onDropFile?: (id: string, file: File) => void | PromiseLike<UploadedFile | void>;
|
|
122
|
+
/**
|
|
123
|
+
* Whether a file field offers a link input, the way in that needs no upload.
|
|
124
|
+
* `true` when absent; `false` hides the "paste a URL instead" toggle and the
|
|
125
|
+
* input behind it on every file field.
|
|
126
|
+
*
|
|
127
|
+
* It governs that input and nothing else. A file value is a URL whichever way
|
|
128
|
+
* it arrived, so this says nothing about which values are valid: a web link
|
|
129
|
+
* the host writes is still shown on the field's card and can still be
|
|
130
|
+
* cleared. Setting it to `false` with no `onDropFile` leaves a file field no
|
|
131
|
+
* way in at all, and the field throws, naming its path, when it renders.
|
|
132
|
+
*/
|
|
133
|
+
allowUrl?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Removes a list's row on the host's side: `listId` is the list's id, the
|
|
136
|
+
* one its rows' ids extend (`cvs` for `cvs.1`), and `index` the row's.
|
|
137
|
+
*
|
|
138
|
+
* Its presence is the capability, and it is the host saying it follows
|
|
139
|
+
* rows. A list hands each removal to it instead of writing the shorter list
|
|
140
|
+
* through `onChange`, so the host removes the row and, in the same update,
|
|
141
|
+
* moves to its new id whatever it keeps by the id of a later row (an entry
|
|
142
|
+
* of `uploadErrors`, an upload in flight) and drops what it kept for the
|
|
143
|
+
* removed one. The list then holds back none of the host's `uploadErrors`,
|
|
144
|
+
* which it does for a host without this callback, since that host is
|
|
145
|
+
* handed only the shorter list and cannot re-key them. A host that also
|
|
146
|
+
* gives `rowMoves` records the removal there, and the list moves its rows'
|
|
147
|
+
* identities from that record alone. `useMethodForm`'s `removeItem` is this
|
|
148
|
+
* callback. See docs/upload-seam.md, "A list does not move a failure onto
|
|
149
|
+
* another row".
|
|
150
|
+
*/
|
|
151
|
+
onRemoveItem?: (listId: string, index: number) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Every move the host has made to a list's rows, oldest first, each
|
|
154
|
+
* numbered above the one before it (`RowMove`).
|
|
155
|
+
*
|
|
156
|
+
* A list keys each row's controls by an identity of its own, so that a row
|
|
157
|
+
* keeps them (a caret, a dropped file's preview, a dismissed failure) when
|
|
158
|
+
* an earlier row goes. It moves those identities itself for a removal it
|
|
159
|
+
* writes through `onChange`; for everything else a host does to the rows it
|
|
160
|
+
* would see only a new list, and match rows by position. Given this, a list
|
|
161
|
+
* replays every move made to it since it last rendered, the ones made to an
|
|
162
|
+
* outer list's rows included, which rename it, and moves no identity of its
|
|
163
|
+
* own accord: a host giving it records every move it makes here, a removal
|
|
164
|
+
* handed to `onRemoveItem` included. `useMethodForm`'s `rowMoves` is this
|
|
165
|
+
* log. See docs/upload-seam.md, "What the form keeps by id moves with the
|
|
166
|
+
* rows it moves".
|
|
167
|
+
*/
|
|
168
|
+
rowMoves?: readonly RowMove[];
|
|
169
|
+
/** Ids currently mid-upload. */
|
|
170
|
+
uploadingIds?: ReadonlySet<string>;
|
|
171
|
+
/**
|
|
172
|
+
* Why an upload failed, keyed by the same id `onDropFile` was handed, so the
|
|
173
|
+
* message shows on the field that took the file rather than under the whole
|
|
174
|
+
* form, where only its wording could say which input failed.
|
|
175
|
+
*
|
|
176
|
+
* The map is the host's truth about each upload attempt: a host removes an
|
|
177
|
+
* entry when the next file is dropped at that id, and sets it again if that
|
|
178
|
+
* upload fails too. A clear or a typed link on the field hides the message
|
|
179
|
+
* until the host sends a different one or removes it, and a list holds back
|
|
180
|
+
* the entries a row removal left at a renumbered position, unless the host
|
|
181
|
+
* re-keys them itself through `onRemoveItem`. A host should
|
|
182
|
+
* also remove an entry once another file, or none, is written at its id, so
|
|
183
|
+
* that a control mounted there later shows no failure under it:
|
|
184
|
+
* `useMethodForm` does this for every write of its values.
|
|
185
|
+
*/
|
|
186
|
+
uploadErrors?: ReadonlyMap<string, string>;
|
|
187
|
+
/** Resolve a `pipelex-storage://` URI to a browser-viewable URL (for previews
|
|
188
|
+
* of already-stored files). */
|
|
189
|
+
resolveUrl?: (uri: string) => Promise<string | null>;
|
|
190
|
+
/**
|
|
191
|
+
* Where a file field can take a file the host already stores. Its presence
|
|
192
|
+
* is the capability, as `onDropFile`'s is: every empty file field then
|
|
193
|
+
* offers "Choose from your team's files", and a list of files offers it for
|
|
194
|
+
* several at once. The choice is written as `{ url, filename }`, exactly as
|
|
195
|
+
* an upload's result is. See docs/sources.md.
|
|
196
|
+
*/
|
|
197
|
+
fileSource?: FileSource;
|
|
198
|
+
}
|
|
199
|
+
interface FieldRendererProps {
|
|
200
|
+
field: RunField;
|
|
201
|
+
value: unknown;
|
|
202
|
+
onChange: (value: unknown) => void;
|
|
203
|
+
/** Unique, stable id used for label linkage and upload tracking. */
|
|
204
|
+
id: string;
|
|
205
|
+
error?: string;
|
|
206
|
+
env?: FieldEnv;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The single dispatch point: a normalized `RunField` → the matching control.
|
|
210
|
+
* Object and list fields recurse back through here, so the whole form is one
|
|
211
|
+
* data-driven tree with no per-type branching anywhere else.
|
|
212
|
+
*/
|
|
213
|
+
declare function FieldRenderer({ field, value, onChange, id, error, env }: FieldRendererProps): react.JSX.Element;
|
|
214
|
+
|
|
215
|
+
export { DocumentField as D, type FieldEnv as F, ImageField as I, type RowMove as R, type UploadedFile as U, FieldRenderer as a, type FieldRendererProps as b, type FileValue as c };
|
|
@@ -9,7 +9,7 @@ import { Components, Renderer } from '@json-render/react';
|
|
|
9
9
|
import { B as BrandManifest } from '../manifest-DUeAWeqa.js';
|
|
10
10
|
export { b as brandManifestSchema } from '../manifest-DUeAWeqa.js';
|
|
11
11
|
import * as zod_v4_core from 'zod/v4/core';
|
|
12
|
-
import { F as FieldEnv } from '../field-renderer-
|
|
12
|
+
import { F as FieldEnv } from '../field-renderer-lNhtw-Cz.js';
|
|
13
13
|
export { seedInputs } from '../core/seed.js';
|
|
14
14
|
import '../core/contracts.js';
|
|
15
15
|
import 'mthds/protocol';
|
package/dist/generative/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn, brandInkClass, brandFillClass, brandFillInkClass, fieldControlClass, ResultRoot, ResultField, FieldRenderer, ToggleGroup, ToggleGroupItem, brandFillStrongClass, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../chunk-
|
|
2
|
+
import { cn, brandInkClass, brandFillClass, brandFillInkClass, fieldControlClass, ResultRoot, ResultField, FieldRenderer, ToggleGroup, ToggleGroupItem, brandFillStrongClass, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '../chunk-5IZWP2X4.js';
|
|
3
3
|
import '../chunk-ICUEHNEH.js';
|
|
4
4
|
export { seedInputs } from '../chunk-VH5CDQDR.js';
|
|
5
5
|
import '../chunk-EQJBM3NS.js';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { F as FieldEnv } from '../field-renderer-
|
|
2
|
-
export { a as FieldRenderer, b as FieldRendererProps } from '../field-renderer-
|
|
1
|
+
import { F as FieldEnv, R as RowMove, U as UploadedFile } from '../field-renderer-lNhtw-Cz.js';
|
|
2
|
+
export { D as DocumentField, a as FieldRenderer, b as FieldRendererProps, c as FileValue, I as ImageField } from '../field-renderer-lNhtw-Cz.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, RefObject, Ref } from 'react';
|
|
5
|
-
import { BooleanRunField, DateRunField, EnumRunField,
|
|
6
|
-
import { FileSource, ExampleSource, SourceFile, FormExample } from '../core/sources.js';
|
|
7
|
-
export { ExampleSourcePage, ExampleSourceQuery, FileSourcePage, FileSourceQuery, FileSourceScope } from '../core/sources.js';
|
|
5
|
+
import { BooleanRunField, DateRunField, EnumRunField, ListRunField, NumberRunField, ObjectRunField, ProseRunField, TextRunField, UnknownRunField, RunField, ConceptCategory } from '../core/descriptor.js';
|
|
8
6
|
import { PipeInputFormDescriptor, PipeIOContract } from 'mthds/protocol';
|
|
9
7
|
import { Readiness } from '../core/readiness.js';
|
|
8
|
+
import { FileSource, ExampleSource, SourceFile, FormExample } from '../core/sources.js';
|
|
9
|
+
export { ExampleSourcePage, ExampleSourceQuery, FileSourcePage, FileSourceQuery, FileSourceScope } from '../core/sources.js';
|
|
10
10
|
import { FileFormat } from '../core/file-formats.js';
|
|
11
11
|
import { SaveFiles, SaveFile, SaveResult } from '../core/save-plan.js';
|
|
12
12
|
import { StuffFileKind } from '../core/stuff-files.js';
|
|
@@ -65,57 +65,6 @@ interface EnumFieldProps {
|
|
|
65
65
|
*/
|
|
66
66
|
declare function EnumField({ field, value, onChange, id, error, disabled }: EnumFieldProps): react.JSX.Element;
|
|
67
67
|
|
|
68
|
-
/** The serializable value of a file field. URL is what the runner sends. */
|
|
69
|
-
interface FileValue {
|
|
70
|
-
url?: string;
|
|
71
|
-
filename?: string;
|
|
72
|
-
}
|
|
73
|
-
interface FileFieldProps {
|
|
74
|
-
field: FileRunField;
|
|
75
|
-
value: FileValue | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Called when a file is dropped/picked - the parent uploads and sets value.
|
|
78
|
-
*
|
|
79
|
-
* Absent means the host cannot store a file, and the control then offers no
|
|
80
|
-
* dropzone and no picker: the link input is open from the start, with a line
|
|
81
|
-
* saying a file cannot be uploaded here.
|
|
82
|
-
*/
|
|
83
|
-
onDropFile?: (file: File) => void;
|
|
84
|
-
/**
|
|
85
|
-
* Whether the link input is offered, `true` when absent. `false` removes the
|
|
86
|
-
* "paste a URL instead" toggle and the input behind it, and says nothing about
|
|
87
|
-
* which values are valid. With no `onDropFile` either, the control throws.
|
|
88
|
-
*/
|
|
89
|
-
allowUrl?: boolean;
|
|
90
|
-
/** Manual URL paste / clear flows through here too. */
|
|
91
|
-
onChange: (value: FileValue | undefined) => void;
|
|
92
|
-
id: string;
|
|
93
|
-
/** Parent-driven async state. */
|
|
94
|
-
uploading?: boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Why the host's upload of this field's file failed. Shown in the alert slot
|
|
97
|
-
* a refused format uses, until the host removes it. A clear or a typed link
|
|
98
|
-
* hides it until the host sends a different message or removes it; a refused
|
|
99
|
-
* pick shows its refusal in its place.
|
|
100
|
-
*/
|
|
101
|
-
uploadError?: string;
|
|
102
|
-
/** Resolve a `pipelex-storage://` URI to a viewable URL (stored-file preview). */
|
|
103
|
-
resolveUrl?: (uri: string) => Promise<string | null>;
|
|
104
|
-
/**
|
|
105
|
-
* Where the field can take a file the host already stores. When given, the
|
|
106
|
-
* empty field offers "Choose from your team's files" under its own controls,
|
|
107
|
-
* and the chosen file is written through `onChange` as `{ url, filename }`,
|
|
108
|
-
* the value an upload writes. See docs/sources.md.
|
|
109
|
-
*/
|
|
110
|
-
fileSource?: FileSource;
|
|
111
|
-
error?: string;
|
|
112
|
-
disabled?: boolean;
|
|
113
|
-
}
|
|
114
|
-
/** Document variant: a file shown as a PDF preview (or chip for other docs). */
|
|
115
|
-
declare function DocumentField(props: FileFieldProps): react.JSX.Element;
|
|
116
|
-
/** Image variant: a file shown as a real image preview. */
|
|
117
|
-
declare function ImageField(props: FileFieldProps): react.JSX.Element;
|
|
118
|
-
|
|
119
68
|
interface ListFieldProps {
|
|
120
69
|
field: ListRunField;
|
|
121
70
|
value: unknown[] | undefined;
|
|
@@ -147,7 +96,9 @@ interface ListFieldProps {
|
|
|
147
96
|
* control's state and not in the value, so a host that replaces `values`
|
|
148
97
|
* wholesale reconciles by length just as positions do. What a stable identity
|
|
149
98
|
* buys over a position is exactly the reorderings the KERNEL performs, and it
|
|
150
|
-
* performs one
|
|
99
|
+
* performs one, plus those a host tells it of: a host that moves rows itself
|
|
100
|
+
* logs each move in `FieldEnv.rowMoves`, as `useMethodForm` does, and the list
|
|
101
|
+
* replays the log on its keys (see `useRowKeys`).
|
|
151
102
|
*/
|
|
152
103
|
declare function ListField({ field, value, onChange, id, error, env }: ListFieldProps): react.JSX.Element;
|
|
153
104
|
|
|
@@ -551,12 +502,12 @@ declare function useFieldStrings(): FieldStrings;
|
|
|
551
502
|
*/
|
|
552
503
|
/** The form's values, keyed by input name, in the controls' own shape. */
|
|
553
504
|
type MethodFormValues = Record<string, unknown>;
|
|
554
|
-
/**
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
505
|
+
/**
|
|
506
|
+
* Where a dropped file goes: its field's id, which is its value path, split.
|
|
507
|
+
* It is the id the file was dropped at; if `removeItem` or `moveItem` moves
|
|
508
|
+
* that row while the file is arriving, the form writes the result at the
|
|
509
|
+
* row's new id.
|
|
510
|
+
*/
|
|
560
511
|
interface MethodFormUploadContext {
|
|
561
512
|
/** The field's id, a dotted value path (`photos.1`, `invoice.source`). */
|
|
562
513
|
id: string;
|
|
@@ -593,8 +544,11 @@ interface UseMethodFormOptions {
|
|
|
593
544
|
* Stores a dropped or picked file and resolves to what the field holds. Its
|
|
594
545
|
* presence is the capability: without it every file field is link-only (see
|
|
595
546
|
* docs/upload-seam.md). A rejection marks the field's upload as failed with
|
|
596
|
-
* `FieldStrings.uploadFailed
|
|
597
|
-
* it
|
|
547
|
+
* `FieldStrings.uploadFailed`, unless another file was written in its place
|
|
548
|
+
* while it was in flight. The next file dropped there clears the mark, and
|
|
549
|
+
* so does any write that changes the file at that path: a file chosen from
|
|
550
|
+
* `fileSource`, a typed link, a clear, a `setValues`. When it resolves to a
|
|
551
|
+
* bare URL, or omits the name, the file's own name is kept.
|
|
598
552
|
*/
|
|
599
553
|
uploadFile?: (file: File, context: MethodFormUploadContext) => Promise<UploadedFile>;
|
|
600
554
|
/**
|
|
@@ -644,8 +598,45 @@ interface MethodFormState {
|
|
|
644
598
|
}
|
|
645
599
|
/** The handle `useMethodForm` returns, and `MethodForm` renders. */
|
|
646
600
|
interface MethodFormController extends MethodFormState {
|
|
647
|
-
/**
|
|
601
|
+
/**
|
|
602
|
+
* Replace the values, or update them from the previous ones. A write that
|
|
603
|
+
* changes the file at an id in `failedUploadIds` ends that failure.
|
|
604
|
+
*
|
|
605
|
+
* A write is read by position: what the form keeps by id (a failed upload,
|
|
606
|
+
* an upload in flight) stays at its id, whatever the write did to the rows
|
|
607
|
+
* of a list. A value carries no identity for its rows, so a write that moves
|
|
608
|
+
* them cannot be told from one that replaces them; rows are moved with
|
|
609
|
+
* `removeItem` and `moveItem`, which carry all of it along.
|
|
610
|
+
*/
|
|
648
611
|
setValues: (next: MethodFormValues | ((previous: MethodFormValues) => MethodFormValues)) => void;
|
|
612
|
+
/**
|
|
613
|
+
* Removes the row at `index` of the list at `listId` (an id, the list's
|
|
614
|
+
* dotted value path: `attachments`, `candidates.1.letters`), and moves with
|
|
615
|
+
* every later row what the form keeps by its id: a failed upload's mark, an
|
|
616
|
+
* upload in flight, and the file that upload was dropped over. What it kept
|
|
617
|
+
* for the removed row goes with it, and an upload still arriving there
|
|
618
|
+
* writes nothing. `MethodForm` hands this to its lists as
|
|
619
|
+
* `FieldEnv.onRemoveItem`, so their remove buttons use it; a host rendering
|
|
620
|
+
* its own fields passes it the same way. A call naming no row of a list
|
|
621
|
+
* changes nothing.
|
|
622
|
+
*/
|
|
623
|
+
removeItem: (listId: string, index: number) => void;
|
|
624
|
+
/**
|
|
625
|
+
* Moves the row at `from` of the list at `listId` to `to`, the rows between
|
|
626
|
+
* them shifting by one, and carries what the form keeps by each moved row's
|
|
627
|
+
* id along with it, as `removeItem` does. A host reordering a list moves its
|
|
628
|
+
* rows with this rather than through `setValues`, which is read by
|
|
629
|
+
* position. A call naming no row of a list changes nothing.
|
|
630
|
+
*/
|
|
631
|
+
moveItem: (listId: string, from: number, to: number) => void;
|
|
632
|
+
/**
|
|
633
|
+
* Every move `removeItem` and `moveItem` have made since the last reset,
|
|
634
|
+
* oldest first. `MethodForm` hands it to its lists as `FieldEnv.rowMoves`,
|
|
635
|
+
* and a list replays it on the identities of its rows, so a row's controls
|
|
636
|
+
* move with the row whoever moved it; a host rendering its own fields passes
|
|
637
|
+
* it the same way, beside `removeItem`.
|
|
638
|
+
*/
|
|
639
|
+
rowMoves: readonly RowMove[];
|
|
649
640
|
/**
|
|
650
641
|
* Back to `values` (a past run's inputs, say), or to the initial values when
|
|
651
642
|
* none is given. Forgets the edits, the attempt, the failed uploads and any
|
|
@@ -664,12 +655,36 @@ interface MethodFormController extends MethodFormState {
|
|
|
664
655
|
* open preview. A host rendering its own fields keys them the same way.
|
|
665
656
|
*/
|
|
666
657
|
resets: number;
|
|
667
|
-
/**
|
|
658
|
+
/**
|
|
659
|
+
* Ids (value paths) with an upload in flight, each at its row's id as it is
|
|
660
|
+
* now: `removeItem` and `moveItem` carry an upload along with its row. Read
|
|
661
|
+
* by `MethodForm`.
|
|
662
|
+
*/
|
|
668
663
|
uploadingIds: ReadonlySet<string>;
|
|
669
|
-
/**
|
|
664
|
+
/**
|
|
665
|
+
* Ids whose last upload failed, and whose file nothing has replaced since:
|
|
666
|
+
* an upload marks its id only if its place still holds the file it was
|
|
667
|
+
* dropped over, and an id leaves the set when a new file is dropped there,
|
|
668
|
+
* when a write changes the file at its path (to another file or to none),
|
|
669
|
+
* when `removeItem` removes its row, and on a reset. `removeItem` and
|
|
670
|
+
* `moveItem` carry it to its row's new id. Read by `MethodForm`.
|
|
671
|
+
*/
|
|
670
672
|
failedUploadIds: ReadonlySet<string>;
|
|
671
|
-
/**
|
|
672
|
-
|
|
673
|
+
/**
|
|
674
|
+
* The upload seam `MethodForm` hands its file fields, when the host uploads:
|
|
675
|
+
* stores the file through `uploadFile` and writes it at the id's path, or at
|
|
676
|
+
* its row's new id when `removeItem` or `moveItem` moved that row while the
|
|
677
|
+
* file was arriving. It returns the upload, which resolves to the file it
|
|
678
|
+
* wrote once it lands, and rejects when it writes nothing: when it fails,
|
|
679
|
+
* or when a newer file dropped at the same id, a reset or the removal of its
|
|
680
|
+
* row replaces it. A file field matches that answer to its value, so a host
|
|
681
|
+
* rendering its own fields passes this as `FieldEnv.onDropFile` unchanged.
|
|
682
|
+
* Ignoring the promise is safe: the form handles its rejection itself.
|
|
683
|
+
*/
|
|
684
|
+
dropFile: ((id: string, file: File) => Promise<{
|
|
685
|
+
url: string;
|
|
686
|
+
filename: string;
|
|
687
|
+
}>) | undefined;
|
|
673
688
|
/** The host's file source, which `MethodForm` hands its file fields. */
|
|
674
689
|
fileSource: FileSource | undefined;
|
|
675
690
|
/** The host's example source, which `MethodForm` offers above the fields. */
|
|
@@ -1633,4 +1648,4 @@ declare function FieldDomIdProvider({ prefix, children, }: {
|
|
|
1633
1648
|
*/
|
|
1634
1649
|
declare function useFieldDomId(path: string): string;
|
|
1635
1650
|
|
|
1636
|
-
export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField,
|
|
1651
|
+
export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, type DownloadDisplay, EN_FIELD_STRINGS, EnumField, ExampleSource, FIELD_STRINGS_BY_LOCALE, FR_FIELD_STRINGS, FieldDomIdProvider, FieldEnv, type FieldPresentation, FieldPresentationProvider, FieldShell, type FieldStrings, FieldStringsProvider, FilePicker, FilePickerEntry, type FilePickerEntryProps, type FilePickerProps, FileSource, FillWithExample, type FillWithExampleProps, FormExample, type HtmlPdf, type HtmlPdfOptions, HtmlPreview, type HtmlPreviewProps, JsonView, ListField, Markdown, type MarkdownProps, type MarkupResolvers, MethodForm, type MethodFormController, type MethodFormProps, type MethodFormState, type MethodFormUploadContext, type MethodFormValues, NumberField, ObjectField, OptionalToggle, PdfDownloadButton, type PdfDownloadButtonProps, type PdfPage, ProseField, type ProseImages, type RenderPdf, type ResolveShareUrl, type ResolveUrl, type ResolveUrls, ResultEnvProvider, ResultField, type ResultFieldProps, RowMove, SUPPORTED_LOCALES, SourceFile, StuffViewer, type StuffViewerProps, type StuffViewerView, type TableLayout, TextField, UnknownField, UploadedFile, type UseMethodFormOptions, fieldControlClass, fieldStringsFor, humanizeFieldName, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveShareUrl, useResolveUrl, useResolvedUrl };
|
package/dist/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, DocumentField, EN_FIELD_STRINGS, EnumField, FIELD_STRINGS_BY_LOCALE, FR_FIELD_STRINGS, FieldDomIdProvider, FieldPresentationProvider, FieldRenderer, FieldShell, FieldStringsProvider, FilePicker, FilePickerEntry, FillWithExample, HtmlPreview, ImageField, JsonView, ListField, Markdown, MethodForm, NumberField, ObjectField, OptionalToggle, PdfDownloadButton, ProseField, ResultEnvProvider, ResultField, SUPPORTED_LOCALES, StuffViewer, TextField, UnknownField, fieldControlClass, fieldStringsFor, humanizeFieldName, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveShareUrl, useResolveUrl, useResolvedUrl } from '../chunk-
|
|
2
|
+
export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, DocumentField, EN_FIELD_STRINGS, EnumField, FIELD_STRINGS_BY_LOCALE, FR_FIELD_STRINGS, FieldDomIdProvider, FieldPresentationProvider, FieldRenderer, FieldShell, FieldStringsProvider, FilePicker, FilePickerEntry, FillWithExample, HtmlPreview, ImageField, JsonView, ListField, Markdown, MethodForm, NumberField, ObjectField, OptionalToggle, PdfDownloadButton, ProseField, ResultEnvProvider, ResultField, SUPPORTED_LOCALES, StuffViewer, TextField, UnknownField, fieldControlClass, fieldStringsFor, humanizeFieldName, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveShareUrl, useResolveUrl, useResolvedUrl } from '../chunk-5IZWP2X4.js';
|
|
3
3
|
import '../chunk-ICUEHNEH.js';
|
|
4
4
|
import '../chunk-VH5CDQDR.js';
|
|
5
5
|
import '../chunk-EQJBM3NS.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipelex/mthds-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Headless form kernel and control set for MTHDS method inputs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"lucide-react": "^0.462.0",
|
|
80
80
|
"marked": "^18.0.11",
|
|
81
81
|
"modern-screenshot": "^4.7.0",
|
|
82
|
-
"mthds": "^0.
|
|
82
|
+
"mthds": "^0.33.0",
|
|
83
83
|
"react-dropzone": "^14.3.8",
|
|
84
84
|
"tailwind-merge": "^3.6.0",
|
|
85
85
|
"zod": "^4.5.4"
|