@pipelex/mthds-form 0.8.0 → 0.10.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 +9 -3
- package/dist/{chunk-4BSBBG2T.js → chunk-4JQAJT7C.js} +3 -3
- package/dist/{chunk-4BSBBG2T.js.map → chunk-4JQAJT7C.js.map} +1 -1
- package/dist/{chunk-T4NSAGOS.js → chunk-4KGQ65TQ.js} +4 -4
- package/dist/{chunk-T4NSAGOS.js.map → chunk-4KGQ65TQ.js.map} +1 -1
- package/dist/chunk-CAKQ5VFT.js +35 -0
- package/dist/chunk-CAKQ5VFT.js.map +1 -0
- package/dist/{chunk-IIU3YK4O.js → chunk-DARLDVJM.js} +3 -3
- package/dist/{chunk-IIU3YK4O.js.map → chunk-DARLDVJM.js.map} +1 -1
- package/dist/{chunk-25I6JDIK.js → chunk-FABY3DEY.js} +2 -2
- package/dist/chunk-FABY3DEY.js.map +1 -0
- package/dist/chunk-G6BWZUGV.js +2840 -0
- package/dist/chunk-G6BWZUGV.js.map +1 -0
- package/dist/{chunk-R7B7ID25.js → chunk-IUWLOSAM.js} +4 -4
- package/dist/{chunk-R7B7ID25.js.map → chunk-IUWLOSAM.js.map} +1 -1
- package/dist/chunk-TID7ZN63.js +198 -0
- package/dist/chunk-TID7ZN63.js.map +1 -0
- package/dist/{chunk-XYQ7NXQZ.js → chunk-WYH56SOZ.js} +2 -2
- package/dist/chunk-WYH56SOZ.js.map +1 -0
- package/dist/chunk-XCO6GTEC.js +38 -0
- package/dist/chunk-XCO6GTEC.js.map +1 -0
- package/dist/{chunk-YEVVR6FE.js → chunk-Y2ND6W4W.js} +3 -3
- package/dist/{chunk-YEVVR6FE.js.map → chunk-Y2ND6W4W.js.map} +1 -1
- package/dist/{chunk-J4L32LD6.js → chunk-ZB4RYUKV.js} +5 -5
- package/dist/chunk-ZB4RYUKV.js.map +1 -0
- package/dist/core/contracts.d.ts +4 -4
- package/dist/core/contracts.js +1 -1
- package/dist/core/derive.d.ts +1 -0
- package/dist/core/derive.js +3 -3
- package/dist/core/descriptor.d.ts +13 -2
- package/dist/core/descriptor.js +1 -1
- package/dist/core/file-formats.d.ts +34 -7
- package/dist/core/file-formats.js +1 -1
- package/dist/core/gate.js +3 -3
- package/dist/core/gating-fields.d.ts +1 -0
- package/dist/core/gating-fields.js +2 -2
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.js +11 -10
- package/dist/core/narrow-file-formats.d.ts +50 -0
- package/dist/core/narrow-file-formats.js +4 -0
- package/dist/core/narrow-file-formats.js.map +1 -0
- package/dist/core/native-content.d.ts +75 -19
- package/dist/core/native-content.js +1 -1
- package/dist/core/output-form.js +2 -2
- package/dist/core/readiness.d.ts +1 -0
- package/dist/core/stuff-files.d.ts +1 -0
- package/dist/core/stuff-files.js +2 -2
- package/dist/core/values.d.ts +1 -0
- package/dist/core/values.js +4 -4
- package/dist/field-renderer-BSU2hMf6.d.ts +34 -0
- package/dist/generative/index.d.ts +2106 -0
- package/dist/generative/index.js +3093 -0
- package/dist/generative/index.js.map +1 -0
- package/dist/layout-design.mthds +452 -0
- package/dist/react/index.d.ts +107 -45
- package/dist/react/index.js +8 -2614
- package/dist/react/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +19 -7
- package/dist/chunk-25I6JDIK.js.map +0 -1
- package/dist/chunk-2JWRG53S.js +0 -33
- package/dist/chunk-2JWRG53S.js.map +0 -1
- package/dist/chunk-45C2MKK6.js +0 -94
- package/dist/chunk-45C2MKK6.js.map +0 -1
- package/dist/chunk-J4L32LD6.js.map +0 -1
- package/dist/chunk-XYQ7NXQZ.js.map +0 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -1,39 +1,12 @@
|
|
|
1
|
+
import { F as FieldEnv } from '../field-renderer-BSU2hMf6.js';
|
|
2
|
+
export { a as FieldRenderer, b as FieldRendererProps } from '../field-renderer-BSU2hMf6.js';
|
|
1
3
|
import * as react from 'react';
|
|
2
4
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
5
|
+
import { BooleanRunField, DateRunField, EnumRunField, FileRunField, ListRunField, NumberRunField, ObjectRunField, ProseRunField, TextRunField, UnknownRunField, RunField, ConceptCategory } from '../core/descriptor.js';
|
|
4
6
|
import { HtmlContentView } from '../core/native-content.js';
|
|
5
7
|
import '../core/contracts.js';
|
|
6
8
|
import 'mthds/protocol';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Ambient state that any field in the tree may need, threaded unchanged through
|
|
10
|
-
* the recursion so containers don't have to re-plumb it for every child.
|
|
11
|
-
*/
|
|
12
|
-
interface FieldEnv {
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
/** A file field asks its parent to upload; the parent sets the value later. */
|
|
15
|
-
onDropFile?: (id: string, file: File) => void;
|
|
16
|
-
/** Ids currently mid-upload. */
|
|
17
|
-
uploadingIds?: ReadonlySet<string>;
|
|
18
|
-
/** Resolve a `pipelex-storage://` URI to a browser-viewable URL (for previews
|
|
19
|
-
* of already-stored files). */
|
|
20
|
-
resolveUrl?: (uri: string) => Promise<string | null>;
|
|
21
|
-
}
|
|
22
|
-
interface FieldRendererProps {
|
|
23
|
-
field: RunField;
|
|
24
|
-
value: unknown;
|
|
25
|
-
onChange: (value: unknown) => void;
|
|
26
|
-
/** Unique, stable id used for label linkage and upload tracking. */
|
|
27
|
-
id: string;
|
|
28
|
-
error?: string;
|
|
29
|
-
env?: FieldEnv;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The single dispatch point: a normalized `RunField` → the matching control.
|
|
33
|
-
* Object and list fields recurse back through here, so the whole form is one
|
|
34
|
-
* data-driven tree with no per-type branching anywhere else.
|
|
35
|
-
*/
|
|
36
|
-
declare function FieldRenderer({ field, value, onChange, id, error, env }: FieldRendererProps): react.JSX.Element;
|
|
9
|
+
import '../core/file-formats.js';
|
|
37
10
|
|
|
38
11
|
interface BooleanFieldProps {
|
|
39
12
|
field: BooleanRunField;
|
|
@@ -76,6 +49,14 @@ interface EnumFieldProps {
|
|
|
76
49
|
* Pick-one. A short option set (≤4, each label brief) renders as a segmented
|
|
77
50
|
* control - every choice visible at a glance - and falls back to a select once
|
|
78
51
|
* the set grows past what fits on a row.
|
|
52
|
+
*
|
|
53
|
+
* An option's LABEL follows the presentation and its value does not. In `app`
|
|
54
|
+
* a person picks "Unit price differs from po" and the form stores
|
|
55
|
+
* `unit_price_differs_from_po`, because the result that run produces shows the
|
|
56
|
+
* same field in words too, and a form and its result have to read the same
|
|
57
|
+
* way - which is why both apply one rule, including its fallback to the codes
|
|
58
|
+
* when two options would read the same. The segmented rule measures the label
|
|
59
|
+
* it shows, which is the text that has to fit on the row.
|
|
79
60
|
*/
|
|
80
61
|
declare function EnumField({ field, value, onChange, id, error, disabled }: EnumFieldProps): react.JSX.Element;
|
|
81
62
|
|
|
@@ -385,11 +366,44 @@ type ResolveUrl = (url: string) => string | undefined;
|
|
|
385
366
|
* storage is public anyway.
|
|
386
367
|
*/
|
|
387
368
|
type ResolveShareUrl = (url: string) => Promise<string | undefined>;
|
|
369
|
+
/**
|
|
370
|
+
* What a `prose` value's markdown images do — and the default is not to load
|
|
371
|
+
* them.
|
|
372
|
+
*
|
|
373
|
+
* A prose value is MODEL OUTPUT, and `` in it is
|
|
374
|
+
* a request the browser makes the moment the result is painted, before anyone
|
|
375
|
+
* has read a word. Nothing was clicked and nothing was consented to, so the
|
|
376
|
+
* exfiltration channel is open by default in a view whose whole content is
|
|
377
|
+
* untrusted. `'link'` closes it: the image renders as a link carrying its alt
|
|
378
|
+
* text, so nothing the model wrote is lost and the fetch waits for a click.
|
|
379
|
+
*
|
|
380
|
+
* `'load'` is the opt-in, for a host that knows where its prose images come
|
|
381
|
+
* from — a method that composes a report out of its own stored figures, say.
|
|
382
|
+
* Only `http:` and `https:` are ever painted or linked either way.
|
|
383
|
+
*/
|
|
384
|
+
type ProseImages = 'link' | 'load';
|
|
388
385
|
interface ResultEnv {
|
|
389
386
|
resolveUrl?: ResolveUrl;
|
|
390
387
|
resolveShareUrl?: ResolveShareUrl;
|
|
388
|
+
proseImages?: ProseImages;
|
|
389
|
+
/**
|
|
390
|
+
* How many data columns a table of records shows. Five when unset.
|
|
391
|
+
*
|
|
392
|
+
* A record with more fields than this keeps the columns a reader decides on —
|
|
393
|
+
* its name first, then the values that fit a cell whole — and the rest move
|
|
394
|
+
* into the row's detail, one click away. The columns shown keep the order the
|
|
395
|
+
* method's author wrote them in. A record within the budget shows every field.
|
|
396
|
+
*
|
|
397
|
+
* It is a COUNT rather than a width the view measures, and that is the point:
|
|
398
|
+
* a count renders the same table on a server, in a test and in a browser,
|
|
399
|
+
* where a measured budget would change the table's shape after hydration, and
|
|
400
|
+
* differently from one host to the next. A host that knows its panel is wide
|
|
401
|
+
* raises it; `Infinity` shows every column. A value below one reads as one,
|
|
402
|
+
* which is the record's name alone.
|
|
403
|
+
*/
|
|
404
|
+
tableColumns?: number;
|
|
391
405
|
}
|
|
392
|
-
declare function ResultEnvProvider({ resolveUrl, resolveShareUrl, children, }: ResultEnv & {
|
|
406
|
+
declare function ResultEnvProvider({ resolveUrl, resolveShareUrl, proseImages, tableColumns, children, }: ResultEnv & {
|
|
393
407
|
children: ReactNode;
|
|
394
408
|
}): react.JSX.Element;
|
|
395
409
|
/**
|
|
@@ -398,14 +412,17 @@ declare function ResultEnvProvider({ resolveUrl, resolveShareUrl, children, }: R
|
|
|
398
412
|
* Every file arm calls this rather than reading the context and remembering to
|
|
399
413
|
* apply it: `useResolvedUrl(url)` is the URL to actually use, and a component
|
|
400
414
|
* that forgets to call it is the bug this shape prevents. An unresolvable
|
|
401
|
-
* reference comes back as the reference, so the arms'
|
|
402
|
-
*
|
|
415
|
+
* reference comes back as the reference, so the arms' own `viewableUrl` check
|
|
416
|
+
* still decides whether it can be linked or only named — and, when it can, what
|
|
417
|
+
* string they use.
|
|
403
418
|
*/
|
|
404
419
|
declare function useResolvedUrl(url: string): string;
|
|
405
420
|
/** For the non-React readers that need the same answer (previewability). */
|
|
406
421
|
declare function useResolveUrl(): ResolveUrl | undefined;
|
|
407
422
|
/** The share-URL minter, when the host supplies one. */
|
|
408
423
|
declare function useResolveShareUrl(): ResolveShareUrl | undefined;
|
|
424
|
+
/** The prose-image policy, defaulted to the safe answer for a host that stated none. */
|
|
425
|
+
declare function useProseImages(): ProseImages;
|
|
409
426
|
|
|
410
427
|
interface HtmlPreviewProps {
|
|
411
428
|
content: HtmlContentView;
|
|
@@ -431,8 +448,14 @@ declare function HtmlPreview({ content, maxHeight, imgSrc, }: HtmlPreviewProps):
|
|
|
431
448
|
interface MarkdownProps {
|
|
432
449
|
text: string;
|
|
433
450
|
className?: string;
|
|
451
|
+
/**
|
|
452
|
+
* What an image in this text does. Defaults to the surrounding
|
|
453
|
+
* `ResultEnvProvider`'s `proseImages`, and to `'link'` outside one — see
|
|
454
|
+
* {@link ProseImages} for why the default is not to load.
|
|
455
|
+
*/
|
|
456
|
+
proseImages?: ProseImages;
|
|
434
457
|
}
|
|
435
|
-
declare function Markdown({ text, className }: MarkdownProps): react.JSX.Element;
|
|
458
|
+
declare function Markdown({ text, className, proseImages }: MarkdownProps): react.JSX.Element;
|
|
436
459
|
|
|
437
460
|
interface FieldShellProps {
|
|
438
461
|
name: string;
|
|
@@ -502,12 +525,41 @@ interface FieldStrings {
|
|
|
502
525
|
itemsCount: (count: number) => string;
|
|
503
526
|
/** The same badge for a list the method gave an exact count (`Concept[N]`). */
|
|
504
527
|
itemsCountOf: (count: number, total: number) => string;
|
|
528
|
+
/** What a record's table cell says when none of its fields can name it. */
|
|
529
|
+
fieldsCount: (count: number) => string;
|
|
505
530
|
uploading: string;
|
|
506
531
|
dropToUpload: string;
|
|
507
532
|
dropOrBrowse: string;
|
|
508
533
|
pasteUrlInstead: string;
|
|
534
|
+
/**
|
|
535
|
+
* The placeholder in the URL a person may paste instead of uploading. It names
|
|
536
|
+
* the web's own scheme only: a host whose runner also takes its own storage
|
|
537
|
+
* references can say so by overriding it, and no default shows an end user a
|
|
538
|
+
* platform's storage scheme.
|
|
539
|
+
*/
|
|
509
540
|
urlPlaceholder: string;
|
|
541
|
+
/**
|
|
542
|
+
* The accessible name of that URL input, given the field's label as the form
|
|
543
|
+
* shows it. The field's label is bound to the file input, so without this the
|
|
544
|
+
* placeholder was the only thing a screen reader announced here.
|
|
545
|
+
*
|
|
546
|
+
* The label is EMPTY inside a list row: the list drops each row's label, and
|
|
547
|
+
* the row number it shows instead is a bare glyph tied to no control. So every
|
|
548
|
+
* row's input currently carries the same generic name, and giving rows
|
|
549
|
+
* distinct names is a separate piece of work on the list control.
|
|
550
|
+
*/
|
|
551
|
+
fileUrlAria: (label: string) => string;
|
|
552
|
+
/**
|
|
553
|
+
* The title of an attached file's card when the value carries no filename.
|
|
554
|
+
* True of a pasted link as well as of an upload, which "Uploaded file" was not.
|
|
555
|
+
*/
|
|
510
556
|
uploadedFile: string;
|
|
557
|
+
/**
|
|
558
|
+
* What names a file carried INSIDE its own URL (a `data:` URL), where a
|
|
559
|
+
* reference would otherwise be printed: its format and its decoded size. The
|
|
560
|
+
* string itself is forty thousand characters of base64 and says nothing.
|
|
561
|
+
*/
|
|
562
|
+
encodedFileSummary: (format: string, bytes: number) => string;
|
|
511
563
|
preview: string;
|
|
512
564
|
removeFileAria: string;
|
|
513
565
|
previewUnavailablePdf: string;
|
|
@@ -554,10 +606,11 @@ interface FieldStrings {
|
|
|
554
606
|
no: string;
|
|
555
607
|
/**
|
|
556
608
|
* Shown when a picked file is not a format this slot accepts. Takes the
|
|
557
|
-
*
|
|
558
|
-
*
|
|
609
|
+
* slot's own formats as the hint names them (`PNG, JPG`), after any narrowing
|
|
610
|
+
* a host applied, so the message names what WOULD have worked - "not
|
|
611
|
+
* accepted" on its own leaves the user guessing at the list they just failed.
|
|
559
612
|
*/
|
|
560
|
-
unsupportedFileType: (
|
|
613
|
+
unsupportedFileType: (formats: string) => string;
|
|
561
614
|
/** The optional-entries disclosure ("field" inside a concept, "input" at top level). */
|
|
562
615
|
hideOptionalFields: string;
|
|
563
616
|
hideOptionalInputs: string;
|
|
@@ -592,19 +645,28 @@ declare function FieldDomIdProvider({ prefix, children, }: {
|
|
|
592
645
|
declare function useFieldDomId(path: string): string;
|
|
593
646
|
|
|
594
647
|
/**
|
|
595
|
-
* How a field's LABEL chrome
|
|
648
|
+
* How a field's LABEL chrome, and the enum values a person reads, should read.
|
|
649
|
+
* What a control stores never changes.
|
|
596
650
|
*
|
|
597
651
|
* - `studio` (default): the field's name verbatim in mono, with its concept
|
|
598
652
|
* pill. The name IS the identifier a builder writes in the `.mthds` file, so
|
|
599
|
-
* showing it exactly - and typed - is the point.
|
|
653
|
+
* showing it exactly - and typed - is the point. An enum value is shown as its
|
|
654
|
+
* code for the same reason: it has to match the bundle and the JSON the
|
|
655
|
+
* builder reads next.
|
|
600
656
|
* - `app`: the field's name as a human question in sans, no concept pill. Inside
|
|
601
657
|
* a method app, `full_name` and `native.Text` are implementation detail; the
|
|
602
|
-
* person filling the form has never seen the method's source.
|
|
658
|
+
* person filling the form has never seen the method's source. An enum value
|
|
659
|
+
* follows the label and reads as words.
|
|
660
|
+
*
|
|
661
|
+
* An enum value is the only value the two presentations show differently. A
|
|
662
|
+
* number, a text, a date and every other value render the same in both.
|
|
603
663
|
*
|
|
604
664
|
* Deliberately a context rather than a prop or a `FieldEnv` flag: only the
|
|
605
|
-
* components that own label chrome read it -
|
|
606
|
-
* `
|
|
607
|
-
*
|
|
665
|
+
* components that own label chrome or an enum value's wording read it -
|
|
666
|
+
* `FieldShell`, `ObjectField`, `BooleanField`, `ListField`, `EnumField` and the
|
|
667
|
+
* result view - plus the file control, whose card hides a storage reference in
|
|
668
|
+
* `app`, and threading a prop would have meant editing every field control and
|
|
669
|
+
* both recursive containers.
|
|
608
670
|
*/
|
|
609
671
|
type FieldPresentation = 'studio' | 'app';
|
|
610
672
|
declare function FieldPresentationProvider({ presentation, children, }: {
|
|
@@ -621,4 +683,4 @@ declare function useFieldPresentation(): FieldPresentation;
|
|
|
621
683
|
*/
|
|
622
684
|
declare function humanizeFieldName(name: string): string;
|
|
623
685
|
|
|
624
|
-
export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, DocumentField, EnumField, FieldDomIdProvider,
|
|
686
|
+
export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, DocumentField, EnumField, FieldDomIdProvider, FieldEnv, type FieldPresentation, FieldPresentationProvider, FieldShell, type FieldStrings, FieldStringsProvider, type FileValue, HtmlPreview, type HtmlPreviewProps, ImageField, JsonView, ListField, Markdown, type MarkdownProps, NumberField, ObjectField, OptionalToggle, ProseField, type ProseImages, type ResolveForDownload, type ResolveShareUrl, type ResolveUrl, ResultEnvProvider, ResultField, type ResultFieldProps, StuffViewer, type StuffViewerProps, type StuffViewerView, TextField, UnknownField, downloadStuff, fieldControlClass, humanizeFieldName, useFieldDomId, useFieldPresentation, useFieldStrings, useProseImages, useResolveShareUrl, useResolveUrl, useResolvedUrl };
|