@pipelex/mthds-form 0.27.0 → 0.29.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-GHVVULHY.js +42 -0
- package/dist/chunk-GHVVULHY.js.map +1 -0
- package/dist/{chunk-4DPYGNJ3.js → chunk-IBBAJXIO.js} +3 -3
- package/dist/{chunk-4DPYGNJ3.js.map → chunk-IBBAJXIO.js.map} +1 -1
- package/dist/{chunk-NSHGLM6A.js → chunk-L23R3JNQ.js} +2 -2
- package/dist/chunk-L23R3JNQ.js.map +1 -0
- package/dist/{chunk-AZIUFSIQ.js → chunk-RHX7LQRL.js} +72 -46
- package/dist/chunk-RHX7LQRL.js.map +1 -0
- package/dist/core/gate.js +2 -2
- package/dist/core/humanize.d.ts +77 -0
- package/dist/core/humanize.js +3 -0
- package/dist/core/humanize.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +4 -3
- package/dist/core/sources.d.ts +32 -7
- package/dist/core/sources.js +1 -1
- package/dist/{field-renderer-CH-biG8C.d.ts → field-renderer-Dz03dpig.d.ts} +3 -2
- package/dist/generative/index.d.ts +1 -1
- package/dist/generative/index.js +9 -5
- package/dist/generative/index.js.map +1 -1
- package/dist/react/index.d.ts +79 -54
- package/dist/react/index.js +3 -2
- package/package.json +1 -1
- package/dist/chunk-AZIUFSIQ.js.map +0 -1
- package/dist/chunk-NSHGLM6A.js.map +0 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FieldEnv, R as RowMove, a as FilePickerSource, U as UploadedFile } from '../field-renderer-
|
|
2
|
-
export { D as DocumentField, b as FieldRenderer, c as FieldRendererProps, d as FilePicker, e as FilePickerEntry, f as FilePickerEntryProps, g as FilePickerProps, h as FileValue, I as ImageField } from '../field-renderer-
|
|
1
|
+
import { F as FieldEnv, R as RowMove, a as FilePickerSource, U as UploadedFile } from '../field-renderer-Dz03dpig.js';
|
|
2
|
+
export { D as DocumentField, b as FieldRenderer, c as FieldRendererProps, d as FilePicker, e as FilePickerEntry, f as FilePickerEntryProps, g as FilePickerProps, h as FileValue, I as ImageField } from '../field-renderer-Dz03dpig.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import { BooleanRunField, DateRunField, EnumRunField, ListRunField, NumberRunField, ObjectRunField, ProseRunField, TextRunField, UnknownRunField, RunField, ConceptCategory } from '../core/descriptor.js';
|
|
@@ -7,6 +7,7 @@ import { PipeInputFormDescriptor, PipeIOContract } from 'mthds/protocol';
|
|
|
7
7
|
import { Readiness } from '../core/readiness.js';
|
|
8
8
|
import { ExampleSource, FormExample } from '../core/sources.js';
|
|
9
9
|
export { ExampleSourcePage, ExampleSourceQuery, FileSource, FileSourcePage, FileSourceQuery, FileSourceScope, SourceFile } from '../core/sources.js';
|
|
10
|
+
export { humanizeFieldName } from '../core/humanize.js';
|
|
10
11
|
import { SaveFiles, SaveFile, SaveResult } from '../core/save-plan.js';
|
|
11
12
|
import { StuffFileKind } from '../core/stuff-files.js';
|
|
12
13
|
import { HtmlContentView } from '../core/native-content.js';
|
|
@@ -177,6 +178,67 @@ interface UnknownFieldProps {
|
|
|
177
178
|
*/
|
|
178
179
|
declare function UnknownField({ field, value, onChange, id, error, disabled }: UnknownFieldProps): react.JSX.Element;
|
|
179
180
|
|
|
181
|
+
/**
|
|
182
|
+
* An example source as the control set takes it: the kernel's `ExampleSource`,
|
|
183
|
+
* which lists the examples and says what may be done with them, and what a
|
|
184
|
+
* row says under the example's name, which only a renderer can draw. Every
|
|
185
|
+
* `ExampleSource` is one, so a host that describes nothing passes its source
|
|
186
|
+
* as it is.
|
|
187
|
+
*/
|
|
188
|
+
interface ExamplePickerSource extends ExampleSource {
|
|
189
|
+
/**
|
|
190
|
+
* Draws a line under a row's name: what the example holds, say, or that it
|
|
191
|
+
* no longer fits the form. It receives the example as `list` returned it and
|
|
192
|
+
* the fields the control reads examples back against, the form's own. What
|
|
193
|
+
* it returns is drawn inside the row's button, under the name, in the list's
|
|
194
|
+
* small muted type unless it styles itself, and is read with the name as the
|
|
195
|
+
* row's accessible name, so it is phrasing content with nothing interactive
|
|
196
|
+
* in it: text, a `<span>`, a decorative icon. It wraps within the row and
|
|
197
|
+
* never widens it; a host wanting one line truncates its own element. A row
|
|
198
|
+
* it returns what React renders nothing for stays the one line of its name:
|
|
199
|
+
* `null`, `undefined`, `true`, `false` or `''`, or an array of nothing but
|
|
200
|
+
* those, an empty one included. It is declared as a method,
|
|
201
|
+
* as `FilePickerSource.renderGlyph` is, so a source whose `renderDetail`
|
|
202
|
+
* takes the host's own example type, the type its `list` answers with, is
|
|
203
|
+
* still accepted.
|
|
204
|
+
*/
|
|
205
|
+
renderDetail?(example: FormExample, fields: readonly RunField[]): ReactNode;
|
|
206
|
+
}
|
|
207
|
+
interface FillWithExampleProps {
|
|
208
|
+
/** The host's examples of this method, and what each row says under its name. */
|
|
209
|
+
source: ExamplePickerSource;
|
|
210
|
+
/** The form's fields, which an example's inputs are read back against. */
|
|
211
|
+
fields: RunField[];
|
|
212
|
+
/**
|
|
213
|
+
* Whether the form holds a value the person typed or attached. An untouched
|
|
214
|
+
* form fills at once; a touched one asks "Replace what you entered?" first.
|
|
215
|
+
* `useMethodForm` reports it as `touched`; a host holding its own values
|
|
216
|
+
* compares them with the ones it last set (`sameRunValues`).
|
|
217
|
+
*/
|
|
218
|
+
touched: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Sets the whole form's values to the example's, read back into the
|
|
221
|
+
* controls' shape (`runValuesFromInputs`). Never a run.
|
|
222
|
+
*/
|
|
223
|
+
onFill: (values: Record<string, unknown>, example: FormExample) => void;
|
|
224
|
+
/** Holds the control shut, as a host does while a run is in flight. */
|
|
225
|
+
disabled?: boolean;
|
|
226
|
+
className?: string;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* "Fill with an example", and everything behind it.
|
|
230
|
+
*
|
|
231
|
+
* With `hideWhenEmpty`, the control reads the list as it mounts and again each
|
|
232
|
+
* time the list closes (a delete may have taken the last example), and is
|
|
233
|
+
* offered once the method is known to have an example, or when the list could
|
|
234
|
+
* not be read, so a failure is shown rather than hidden. That read follows the
|
|
235
|
+
* list past empty pages, and while it is under way the control keeps the last
|
|
236
|
+
* answer rather than blinking out. The list itself never vanishes while it is
|
|
237
|
+
* open. Without `hideWhenEmpty`, the control is always offered and an empty
|
|
238
|
+
* list says how to make one.
|
|
239
|
+
*/
|
|
240
|
+
declare function FillWithExample({ source, fields, touched, onFill, disabled, className, }: FillWithExampleProps): react.JSX.Element | null;
|
|
241
|
+
|
|
180
242
|
/**
|
|
181
243
|
* How a field's LABEL chrome, and the enum values a person reads, should read.
|
|
182
244
|
* What a control stores never changes.
|
|
@@ -189,17 +251,19 @@ declare function UnknownField({ field, value, onChange, id, error, disabled }: U
|
|
|
189
251
|
* - `app`: the field's name as a human question in sans, no concept pill. Inside
|
|
190
252
|
* a method app, `full_name` and `native.Text` are implementation detail; the
|
|
191
253
|
* person filling the form has never seen the method's source. An enum value
|
|
192
|
-
* follows the label and reads as words
|
|
254
|
+
* follows the label and reads as words, worded by the kernel's rule
|
|
255
|
+
* (`enumValueLabeler` in the core entry).
|
|
193
256
|
*
|
|
194
257
|
* An enum value is the only value the two presentations show differently. A
|
|
195
258
|
* number, a text, a date and every other value render the same in both.
|
|
196
259
|
*
|
|
197
260
|
* Deliberately a context rather than a prop or a `FieldEnv` flag: only the
|
|
198
261
|
* components that own label chrome or an enum value's wording read it -
|
|
199
|
-
* `FieldShell`, `ObjectField`, `BooleanField`, `ListField`, `EnumField
|
|
200
|
-
* result view
|
|
201
|
-
* `
|
|
202
|
-
*
|
|
262
|
+
* `FieldShell`, `ObjectField`, `BooleanField`, `ListField`, `EnumField`, the
|
|
263
|
+
* result view and the generative layer's choice controls (`Select`, `Radio`,
|
|
264
|
+
* `Segmented`) - plus the file control, whose card hides a storage reference
|
|
265
|
+
* in `app`, and threading a prop would have meant editing every field control
|
|
266
|
+
* and both recursive containers.
|
|
203
267
|
*/
|
|
204
268
|
type FieldPresentation = 'studio' | 'app';
|
|
205
269
|
declare function FieldPresentationProvider({ presentation, children, }: {
|
|
@@ -207,14 +271,6 @@ declare function FieldPresentationProvider({ presentation, children, }: {
|
|
|
207
271
|
children: ReactNode;
|
|
208
272
|
}): react.JSX.Element;
|
|
209
273
|
declare function useFieldPresentation(): FieldPresentation;
|
|
210
|
-
/**
|
|
211
|
-
* `full_name` → `Full name`. Only the first word is capitalised: these are
|
|
212
|
-
* labels, not titles, and Title Case on every word reads as a form from 2009.
|
|
213
|
-
* Takes IDENTIFIERS only - snake_case or kebab-case names, where a separator
|
|
214
|
-
* is structure. An authored `title` never goes through here: it is already
|
|
215
|
-
* human-facing, and its hyphens are spelling (`E-mail address`), not structure.
|
|
216
|
-
*/
|
|
217
|
-
declare function humanizeFieldName(name: string): string;
|
|
218
274
|
|
|
219
275
|
interface FieldStrings {
|
|
220
276
|
/** Badge on an optional field's header row. */
|
|
@@ -518,6 +574,8 @@ interface FieldStrings {
|
|
|
518
574
|
replaceEnteredConfirm: string;
|
|
519
575
|
/** The accessible name of an example row's menu, given the example's name. */
|
|
520
576
|
exampleActions: (name: string) => string;
|
|
577
|
+
/** The row menu's items, in its order: Open, offered when the source opens examples, then Rename and Delete. */
|
|
578
|
+
openExample: string;
|
|
521
579
|
renameExample: string;
|
|
522
580
|
deleteExample: string;
|
|
523
581
|
/** The rename dialog: its title, the name field's label, and its button while it works. */
|
|
@@ -636,9 +694,11 @@ interface UseMethodFormOptions {
|
|
|
636
694
|
* Where the form can take a saved example of the method. When given,
|
|
637
695
|
* `MethodForm` offers "Fill with an example" above the fields, which sets
|
|
638
696
|
* every value at once (as `reset` does) and never starts a run; a touched
|
|
639
|
-
* form asks before it replaces what was entered.
|
|
697
|
+
* form asks before it replaces what was entered. Its `open`, when given,
|
|
698
|
+
* hands a row's example to the host's own surface, and its `renderDetail`
|
|
699
|
+
* draws a line under each row's name. See docs/sources.md.
|
|
640
700
|
*/
|
|
641
|
-
exampleSource?:
|
|
701
|
+
exampleSource?: ExamplePickerSource;
|
|
642
702
|
}
|
|
643
703
|
/** What the form says to its consumer: the values, the run inputs, the gate. */
|
|
644
704
|
interface MethodFormState {
|
|
@@ -761,7 +821,7 @@ interface MethodFormController extends MethodFormState {
|
|
|
761
821
|
/** The host's file source, which `MethodForm` hands its file fields. */
|
|
762
822
|
fileSource: FilePickerSource | undefined;
|
|
763
823
|
/** The host's example source, which `MethodForm` offers above the fields. */
|
|
764
|
-
exampleSource:
|
|
824
|
+
exampleSource: ExamplePickerSource | undefined;
|
|
765
825
|
}
|
|
766
826
|
/**
|
|
767
827
|
* The state of one method's input form. See `UseMethodFormOptions` for what it
|
|
@@ -814,41 +874,6 @@ interface MethodFormProps {
|
|
|
814
874
|
*/
|
|
815
875
|
declare function MethodForm({ locale, strings, presentation, ...props }: MethodFormProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
816
876
|
|
|
817
|
-
interface FillWithExampleProps {
|
|
818
|
-
/** The host's examples of this method. */
|
|
819
|
-
source: ExampleSource;
|
|
820
|
-
/** The form's fields, which an example's inputs are read back against. */
|
|
821
|
-
fields: RunField[];
|
|
822
|
-
/**
|
|
823
|
-
* Whether the form holds a value the person typed or attached. An untouched
|
|
824
|
-
* form fills at once; a touched one asks "Replace what you entered?" first.
|
|
825
|
-
* `useMethodForm` reports it as `touched`; a host holding its own values
|
|
826
|
-
* compares them with the ones it last set (`sameRunValues`).
|
|
827
|
-
*/
|
|
828
|
-
touched: boolean;
|
|
829
|
-
/**
|
|
830
|
-
* Sets the whole form's values to the example's, read back into the
|
|
831
|
-
* controls' shape (`runValuesFromInputs`). Never a run.
|
|
832
|
-
*/
|
|
833
|
-
onFill: (values: Record<string, unknown>, example: FormExample) => void;
|
|
834
|
-
/** Holds the control shut, as a host does while a run is in flight. */
|
|
835
|
-
disabled?: boolean;
|
|
836
|
-
className?: string;
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* "Fill with an example", and everything behind it.
|
|
840
|
-
*
|
|
841
|
-
* With `hideWhenEmpty`, the control reads the list as it mounts and again each
|
|
842
|
-
* time the list closes (a delete may have taken the last example), and is
|
|
843
|
-
* offered once the method is known to have an example, or when the list could
|
|
844
|
-
* not be read, so a failure is shown rather than hidden. That read follows the
|
|
845
|
-
* list past empty pages, and while it is under way the control keeps the last
|
|
846
|
-
* answer rather than blinking out. The list itself never vanishes while it is
|
|
847
|
-
* open. Without `hideWhenEmpty`, the control is always offered and an empty
|
|
848
|
-
* list says how to make one.
|
|
849
|
-
*/
|
|
850
|
-
declare function FillWithExample({ source, fields, touched, onFill, disabled, className, }: FillWithExampleProps): react.JSX.Element | null;
|
|
851
|
-
|
|
852
877
|
interface ResultFieldProps {
|
|
853
878
|
field: RunField;
|
|
854
879
|
value: unknown;
|
|
@@ -1741,4 +1766,4 @@ declare function FieldDomIdProvider({ prefix, children, }: {
|
|
|
1741
1766
|
*/
|
|
1742
1767
|
declare function useFieldDomId(path: string): string;
|
|
1743
1768
|
|
|
1744
|
-
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, FilePickerSource, FillWithExample, type FillWithExampleProps, FormExample, type HtmlPdf, type HtmlPdfOptions, HtmlPreview, type HtmlPreviewProps, JsonView, ListField, Markdown, type MarkdownCitation, 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 RenditionRequest, type ResolveRendition, type ResolveShareUrl, type ResolveUrl, type ResolveUrls, ResultEnvProvider, ResultField, type ResultFieldProps, RowMove, SUPPORTED_LOCALES, StuffViewer, type StuffViewerProps, type StuffViewerView, type TableLayout, TextField, UnknownField, UploadedFile, type UseMethodFormOptions, fieldControlClass, fieldStringsFor,
|
|
1769
|
+
export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, type DownloadDisplay, EN_FIELD_STRINGS, EnumField, type ExamplePickerSource, ExampleSource, FIELD_STRINGS_BY_LOCALE, FR_FIELD_STRINGS, FieldDomIdProvider, FieldEnv, type FieldPresentation, FieldPresentationProvider, FieldShell, type FieldStrings, FieldStringsProvider, FilePickerSource, FillWithExample, type FillWithExampleProps, FormExample, type HtmlPdf, type HtmlPdfOptions, HtmlPreview, type HtmlPreviewProps, JsonView, ListField, Markdown, type MarkdownCitation, 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 RenditionRequest, type ResolveRendition, type ResolveShareUrl, type ResolveUrl, type ResolveUrls, ResultEnvProvider, ResultField, type ResultFieldProps, RowMove, SUPPORTED_LOCALES, StuffViewer, type StuffViewerProps, type StuffViewerView, type TableLayout, TextField, UnknownField, UploadedFile, type UseMethodFormOptions, fieldControlClass, fieldStringsFor, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveRendition, useResolveShareUrl, useResolveUrl, useResolvedUrl };
|
package/dist/react/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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,
|
|
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, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveRendition, useResolveShareUrl, useResolveUrl, useResolvedUrl } from '../chunk-RHX7LQRL.js';
|
|
3
3
|
import '../chunk-4VAO6BDE.js';
|
|
4
4
|
import '../chunk-VH5CDQDR.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-L23R3JNQ.js';
|
|
6
6
|
import '../chunk-56WECFBD.js';
|
|
7
7
|
import '../chunk-ZX52CQJ4.js';
|
|
8
|
+
export { humanizeFieldName } from '../chunk-GHVVULHY.js';
|
|
8
9
|
import '../chunk-QQK6Y55E.js';
|
|
9
10
|
import '../chunk-ZB4RYUKV.js';
|
|
10
11
|
import '../chunk-FABY3DEY.js';
|