@pipelex/mthds-form 0.8.0 → 0.9.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.
Files changed (44) hide show
  1. package/README.md +6 -3
  2. package/dist/chunk-AZZAAGNX.js +194 -0
  3. package/dist/chunk-AZZAAGNX.js.map +1 -0
  4. package/dist/{chunk-IIU3YK4O.js → chunk-DARLDVJM.js} +3 -3
  5. package/dist/{chunk-IIU3YK4O.js.map → chunk-DARLDVJM.js.map} +1 -1
  6. package/dist/{chunk-R7B7ID25.js → chunk-IUWLOSAM.js} +4 -4
  7. package/dist/{chunk-R7B7ID25.js.map → chunk-IUWLOSAM.js.map} +1 -1
  8. package/dist/chunk-KG4IYFWI.js +2721 -0
  9. package/dist/chunk-KG4IYFWI.js.map +1 -0
  10. package/dist/{chunk-J4L32LD6.js → chunk-KIEOLP2L.js} +3 -3
  11. package/dist/{chunk-J4L32LD6.js.map → chunk-KIEOLP2L.js.map} +1 -1
  12. package/dist/{chunk-4BSBBG2T.js → chunk-S4CB423P.js} +3 -3
  13. package/dist/{chunk-4BSBBG2T.js.map → chunk-S4CB423P.js.map} +1 -1
  14. package/dist/{chunk-XYQ7NXQZ.js → chunk-WYH56SOZ.js} +2 -2
  15. package/dist/chunk-WYH56SOZ.js.map +1 -0
  16. package/dist/{chunk-YEVVR6FE.js → chunk-Y2ND6W4W.js} +3 -3
  17. package/dist/{chunk-YEVVR6FE.js.map → chunk-Y2ND6W4W.js.map} +1 -1
  18. package/dist/{chunk-T4NSAGOS.js → chunk-YABRYTQ4.js} +4 -4
  19. package/dist/{chunk-T4NSAGOS.js.map → chunk-YABRYTQ4.js.map} +1 -1
  20. package/dist/core/contracts.d.ts +4 -4
  21. package/dist/core/contracts.js +1 -1
  22. package/dist/core/derive.js +2 -2
  23. package/dist/core/gate.js +3 -3
  24. package/dist/core/gating-fields.js +2 -2
  25. package/dist/core/index.d.ts +1 -1
  26. package/dist/core/index.js +8 -8
  27. package/dist/core/native-content.d.ts +56 -9
  28. package/dist/core/native-content.js +1 -1
  29. package/dist/core/output-form.js +2 -2
  30. package/dist/core/stuff-files.js +2 -2
  31. package/dist/core/values.js +3 -3
  32. package/dist/field-renderer-BSU2hMf6.d.ts +34 -0
  33. package/dist/generative/index.d.ts +2013 -0
  34. package/dist/generative/index.js +3171 -0
  35. package/dist/generative/index.js.map +1 -0
  36. package/dist/react/index.d.ts +42 -36
  37. package/dist/react/index.js +8 -2614
  38. package/dist/react/index.js.map +1 -1
  39. package/dist/styles.css +1 -1
  40. package/dist/ui-designer.mthds +304 -0
  41. package/package.json +19 -7
  42. package/dist/chunk-45C2MKK6.js +0 -94
  43. package/dist/chunk-45C2MKK6.js.map +0 -1
  44. package/dist/chunk-XYQ7NXQZ.js.map +0 -1
@@ -1,40 +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 { RunField, BooleanRunField, DateRunField, EnumRunField, FileRunField, ListRunField, NumberRunField, ObjectRunField, ProseRunField, TextRunField, UnknownRunField, ConceptCategory } from '../core/descriptor.js';
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
9
 
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;
37
-
38
10
  interface BooleanFieldProps {
39
11
  field: BooleanRunField;
40
12
  value: boolean | undefined;
@@ -385,11 +357,28 @@ type ResolveUrl = (url: string) => string | undefined;
385
357
  * storage is public anyway.
386
358
  */
387
359
  type ResolveShareUrl = (url: string) => Promise<string | undefined>;
360
+ /**
361
+ * What a `prose` value's markdown images do — and the default is not to load
362
+ * them.
363
+ *
364
+ * A prose value is MODEL OUTPUT, and `![](https://attacker/collect?…)` in it is
365
+ * a request the browser makes the moment the result is painted, before anyone
366
+ * has read a word. Nothing was clicked and nothing was consented to, so the
367
+ * exfiltration channel is open by default in a view whose whole content is
368
+ * untrusted. `'link'` closes it: the image renders as a link carrying its alt
369
+ * text, so nothing the model wrote is lost and the fetch waits for a click.
370
+ *
371
+ * `'load'` is the opt-in, for a host that knows where its prose images come
372
+ * from — a method that composes a report out of its own stored figures, say.
373
+ * Only `http:` and `https:` are ever painted or linked either way.
374
+ */
375
+ type ProseImages = 'link' | 'load';
388
376
  interface ResultEnv {
389
377
  resolveUrl?: ResolveUrl;
390
378
  resolveShareUrl?: ResolveShareUrl;
379
+ proseImages?: ProseImages;
391
380
  }
392
- declare function ResultEnvProvider({ resolveUrl, resolveShareUrl, children, }: ResultEnv & {
381
+ declare function ResultEnvProvider({ resolveUrl, resolveShareUrl, proseImages, children, }: ResultEnv & {
393
382
  children: ReactNode;
394
383
  }): react.JSX.Element;
395
384
  /**
@@ -398,14 +387,17 @@ declare function ResultEnvProvider({ resolveUrl, resolveShareUrl, children, }: R
398
387
  * Every file arm calls this rather than reading the context and remembering to
399
388
  * apply it: `useResolvedUrl(url)` is the URL to actually use, and a component
400
389
  * that forgets to call it is the bug this shape prevents. An unresolvable
401
- * reference comes back as the reference, so the arms' existing
402
- * `isViewableUrl` check still decides whether it can be linked or only named.
390
+ * reference comes back as the reference, so the arms' own `viewableUrl` check
391
+ * still decides whether it can be linked or only named — and, when it can, what
392
+ * string they use.
403
393
  */
404
394
  declare function useResolvedUrl(url: string): string;
405
395
  /** For the non-React readers that need the same answer (previewability). */
406
396
  declare function useResolveUrl(): ResolveUrl | undefined;
407
397
  /** The share-URL minter, when the host supplies one. */
408
398
  declare function useResolveShareUrl(): ResolveShareUrl | undefined;
399
+ /** The prose-image policy, defaulted to the safe answer for a host that stated none. */
400
+ declare function useProseImages(): ProseImages;
409
401
 
410
402
  interface HtmlPreviewProps {
411
403
  content: HtmlContentView;
@@ -431,8 +423,14 @@ declare function HtmlPreview({ content, maxHeight, imgSrc, }: HtmlPreviewProps):
431
423
  interface MarkdownProps {
432
424
  text: string;
433
425
  className?: string;
426
+ /**
427
+ * What an image in this text does. Defaults to the surrounding
428
+ * `ResultEnvProvider`'s `proseImages`, and to `'link'` outside one — see
429
+ * {@link ProseImages} for why the default is not to load.
430
+ */
431
+ proseImages?: ProseImages;
434
432
  }
435
- declare function Markdown({ text, className }: MarkdownProps): react.JSX.Element;
433
+ declare function Markdown({ text, className, proseImages }: MarkdownProps): react.JSX.Element;
436
434
 
437
435
  interface FieldShellProps {
438
436
  name: string;
@@ -502,12 +500,20 @@ interface FieldStrings {
502
500
  itemsCount: (count: number) => string;
503
501
  /** The same badge for a list the method gave an exact count (`Concept[N]`). */
504
502
  itemsCountOf: (count: number, total: number) => string;
503
+ /** What a record's table cell says when none of its fields can name it. */
504
+ fieldsCount: (count: number) => string;
505
505
  uploading: string;
506
506
  dropToUpload: string;
507
507
  dropOrBrowse: string;
508
508
  pasteUrlInstead: string;
509
509
  urlPlaceholder: string;
510
510
  uploadedFile: string;
511
+ /**
512
+ * What names a file carried INSIDE its own URL (a `data:` URL), where a
513
+ * reference would otherwise be printed: its format and its decoded size. The
514
+ * string itself is forty thousand characters of base64 and says nothing.
515
+ */
516
+ encodedFileSummary: (format: string, bytes: number) => string;
511
517
  preview: string;
512
518
  removeFileAria: string;
513
519
  previewUnavailablePdf: string;
@@ -621,4 +627,4 @@ declare function useFieldPresentation(): FieldPresentation;
621
627
  */
622
628
  declare function humanizeFieldName(name: string): string;
623
629
 
624
- export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, DocumentField, EnumField, FieldDomIdProvider, type FieldEnv, type FieldPresentation, FieldPresentationProvider, FieldRenderer, type FieldRendererProps, FieldShell, type FieldStrings, FieldStringsProvider, type FileValue, HtmlPreview, type HtmlPreviewProps, ImageField, JsonView, ListField, Markdown, type MarkdownProps, NumberField, ObjectField, OptionalToggle, ProseField, type ResolveForDownload, type ResolveShareUrl, type ResolveUrl, ResultEnvProvider, ResultField, type ResultFieldProps, StuffViewer, type StuffViewerProps, type StuffViewerView, TextField, UnknownField, downloadStuff, fieldControlClass, humanizeFieldName, useFieldDomId, useFieldPresentation, useFieldStrings, useResolveShareUrl, useResolveUrl, useResolvedUrl };
630
+ 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 };