@pipelex/mthds-form 0.35.1 → 0.36.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,5 +1,5 @@
1
1
  "use client";
2
- import { cn, headingClass, checkedAccentClass, focusOutlineClass, useResolveUrl, panelSurfaceClass, panelFlatShadowClass, linkTextClass, actionShadowClass, panelRaisedShadowClass, fieldControlClass, useFieldPresentation, useFieldStrings, fieldLabel, ResultRoot, ResultField, FieldRenderer, enumLabeler, ToggleGroup, ToggleGroupItem, selectedFillStrongClass, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, selectedBorderClass, selectedFillClass, isThenable, FieldPresentationProvider } from '../chunk-TD62R3P6.js';
2
+ import { cn, headingClass, checkedAccentClass, focusOutlineClass, useResolveUrl, panelSurfaceClass, panelFlatShadowClass, linkTextClass, actionShadowClass, panelRaisedShadowClass, fieldControlClass, useFieldPresentation, useFieldStrings, fieldLabel, ResultRoot, ResultField, FieldRenderer, enumLabeler, ToggleGroup, ToggleGroupItem, selectedFillStrongClass, Switch, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, selectedBorderClass, selectedFillClass, isThenable, FieldPresentationProvider } from '../chunk-ROM2KLQD.js';
3
3
  import { baseCatalog, catalog, frameComponents, shareAmount, INPUTS_ROOT, joinPath, resultFieldAtPath, segmentsUnder, RESULT_ROOT, inputFieldAtPath, definitionChain, unwrapped } from '../chunk-XLTYIIUY.js';
4
4
  export { COMPONENT_NAMES, COMPONENT_RENDERINGS, COMPOSER_COMPONENTS, CUSTOM_COMPONENTS, DESIGNER_BRIEF_CONCEPT, DESIGNER_CATALOG_CONCEPT, FRAMES, FRAME_COMPONENTS, ICON_NAMES, INPUTS_ROOT, METRIC_FORMATS, PICKED_SHADCN, PRODUCT_COMPONENTS, PROMPT_HASH, REPAIR_ATTEMPTS, RESULT_COMPONENTS, RESULT_ROOT, absoluteHatchPath, catalog, componentNamesFor, designerCatalog, fieldAtSegments, findFixture, fixtureId, fixtureLabel, formatProblems, frameCatalog, inputBrief, inputFieldAtPath, isDelegatedInput, isDelegatedResult, joinPath, jsonlLines, layoutCheck, layoutCheckProblems, layoutFits, layoutProblems, payloadToState, promptHashSubject, repeatBasePathOf, resultBrief, resultFieldAtPath, seedLine, segmentsUnder, specFromJsonl, specToJsonl, validateAgainstCatalog, writtenSampleOf } from '../chunk-XLTYIIUY.js';
5
5
  import '../chunk-4VAO6BDE.js';
@@ -326,6 +326,12 @@ interface FieldStrings {
326
326
  pdfViewerUnavailable: string;
327
327
  /** The link that opens a file in a new tab, where it cannot be shown in the page. */
328
328
  openInNewTab: string;
329
+ /** Said in a document's preview while the host makes a PDF of it. */
330
+ documentPdfPreparing: string;
331
+ /** Said in a document's preview when the host could not make a PDF of it and gives no reason. */
332
+ documentPdfFailed: string;
333
+ /** Said in a document's preview when the host has no PDF of it to offer. */
334
+ documentPdfUnavailable: string;
329
335
  /**
330
336
  * What a result slot the run resolved as an absence SHOWS — a dash, not a
331
337
  * sentence. Beside forty values in a grid, "not provided" repeated is louder
@@ -1069,6 +1075,94 @@ interface RenditionRequest {
1069
1075
  * missing copy costs the reader the wait, never the picture.
1070
1076
  */
1071
1077
  type ResolveRendition = (url: string, request: RenditionRequest) => string | undefined;
1078
+ /**
1079
+ * What the payload declares about a document a host is asked for a PDF of, so
1080
+ * that a host can decide by the document's format.
1081
+ */
1082
+ interface DocumentPdfRequest {
1083
+ filename?: string;
1084
+ mimeType?: string;
1085
+ }
1086
+ /**
1087
+ * Where the PDF of a document stands, in the host's answer.
1088
+ *
1089
+ * - `ready`: `url` is where the PDF is read. It is the URL of a document the
1090
+ * view will frame, so it passes the same gate as any resolver's answer: an
1091
+ * `http(s):` URL, or a root-relative path on the host's own origin. An answer
1092
+ * the gate refuses reads as `unavailable`.
1093
+ * - `preparing`: the host is making the PDF. The view says so and asks again.
1094
+ * - `failed`: the host could not make the PDF. `message`, when the host can
1095
+ * say why (a file protected by a password), is shown to the reader as it
1096
+ * stands, so it must be in the reader's language; with none, the view says
1097
+ * the package's `documentPdfFailed`. The reader is offered to try again.
1098
+ * - `unavailable`: there is no PDF of this document to be had, and asking
1099
+ * again would not change that (a file past the host's limits). The view says
1100
+ * there is no preview.
1101
+ */
1102
+ type DocumentPdfAnswer = {
1103
+ state: 'ready';
1104
+ url: string;
1105
+ } | {
1106
+ state: 'preparing';
1107
+ } | {
1108
+ state: 'failed';
1109
+ message?: string;
1110
+ } | {
1111
+ state: 'unavailable';
1112
+ };
1113
+ /**
1114
+ * One question to the host about one document: where does its PDF stand?
1115
+ *
1116
+ * The view asks when the reader opens the preview, and again while the answer
1117
+ * is `preparing`, so asking twice must not start the work twice. An ask that
1118
+ * throws, rejects, answers something else or takes longer than thirty seconds
1119
+ * reads as `failed`.
1120
+ */
1121
+ type AskDocumentPdf = () => Promise<DocumentPdfAnswer>;
1122
+ /**
1123
+ * The host's seam for a PDF of a document the browser cannot render itself,
1124
+ * such as a Word, Excel or PowerPoint file.
1125
+ *
1126
+ * ## Why a result view needs one
1127
+ *
1128
+ * A browser renders a PDF and a picture and nothing else a run hands back, so
1129
+ * a `.docx` result is a name and a download. The kernel cannot convert it,
1130
+ * since it holds a reference and the host holds the file; a host that can make
1131
+ * a PDF of the file (a conversion service behind its storage) answers here.
1132
+ *
1133
+ * ## Why deciding and asking are apart
1134
+ *
1135
+ * Deciding is this function, which answers synchronously and is pure, as
1136
+ * `ResolveRendition` is. It is called while the view renders, for every
1137
+ * document the browser cannot render, and says only whether this host has a
1138
+ * way to a PDF of this document: `undefined` means it has none, and the view
1139
+ * behaves exactly as it does with no such function, offering no preview. So
1140
+ * the Preview toggle is decided with no round trip, and a server render and
1141
+ * the first browser render agree.
1142
+ *
1143
+ * Asking is the {@link AskDocumentPdf} it returns, which is the round
1144
+ * trip. It is asked only when a reader opens the preview, because a conversion
1145
+ * is real work and a run's result can hold many documents nobody will open: a
1146
+ * host that converts on first request therefore converts only what someone
1147
+ * asked to see.
1148
+ *
1149
+ * ## The contract
1150
+ *
1151
+ * Called with the document's own `url` member, exactly as `resolveUrl` is, and
1152
+ * what the payload declares about it. The view decides which documents to ask
1153
+ * about only from whether the browser renders them, so a host answers for the
1154
+ * formats it converts, and the kernel keeps no list of them.
1155
+ *
1156
+ * - **A first view does not wait.** The ask is expected to answer quickly,
1157
+ * `preparing` while the PDF is being made, and the view shows that it is
1158
+ * preparing and asks again, at growing intervals, until the answer changes.
1159
+ * It stops after three minutes and reads that as `failed`, and it stops when
1160
+ * the reader closes the preview.
1161
+ * - **It only ever shows pages.** The PDF is framed, or linked from the card
1162
+ * shown where the browser has no PDF viewer, and it is nothing else: the
1163
+ * document's name, its copy control and every download keep the original.
1164
+ */
1165
+ type ResolveDocumentPdf = (url: string, request: DocumentPdfRequest) => AskDocumentPdf | undefined;
1072
1166
  /**
1073
1167
  * How a stored reference becomes a URL that works OUTSIDE this page — pasted
1074
1168
  * into another tab, another app, a colleague's message.
@@ -1215,6 +1309,13 @@ interface ResultEnv {
1215
1309
  * {@link ResolveRendition}.
1216
1310
  */
1217
1311
  resolveRendition?: ResolveRendition;
1312
+ /**
1313
+ * A PDF of a document the browser cannot render, such as a Word file, which
1314
+ * the view shows in that document's preview. Optional; unset, or for a
1315
+ * document it does not answer, the document offers no preview. See
1316
+ * {@link ResolveDocumentPdf}.
1317
+ */
1318
+ resolveDocumentPdf?: ResolveDocumentPdf;
1218
1319
  resolveShareUrl?: ResolveShareUrl;
1219
1320
  proseImages?: ProseImages;
1220
1321
  /**
@@ -1273,7 +1374,7 @@ interface ResultEnv {
1273
1374
  */
1274
1375
  framed?: boolean;
1275
1376
  }
1276
- declare function ResultEnvProvider({ resolveUrl, resolveUrls, resolveRendition, resolveShareUrl, proseImages, tableColumns, tableLayout, saveFiles, downloads, renderPdf, framed, children, }: ResultEnv & {
1377
+ declare function ResultEnvProvider({ resolveUrl, resolveUrls, resolveRendition, resolveDocumentPdf, resolveShareUrl, proseImages, tableColumns, tableLayout, saveFiles, downloads, renderPdf, framed, children, }: ResultEnv & {
1277
1378
  children: ReactNode;
1278
1379
  }): react.JSX.Element;
1279
1380
  /**
@@ -1291,6 +1392,8 @@ declare function useResolvedUrl(url: string): string;
1291
1392
  declare function useResolveUrl(): ResolveUrl | undefined;
1292
1393
  /** The host's smaller copies of a picture, when it supplies them. */
1293
1394
  declare function useResolveRendition(): ResolveRendition | undefined;
1395
+ /** The host's way to a PDF of a document the browser cannot render, when it supplies one. */
1396
+ declare function useResolveDocumentPdf(): ResolveDocumentPdf | undefined;
1294
1397
  /** The share-URL minter, when the host supplies one. */
1295
1398
  declare function useResolveShareUrl(): ResolveShareUrl | undefined;
1296
1399
  /** The prose-image policy, defaulted to the safe answer for a host that stated none. */
@@ -1799,4 +1902,4 @@ declare function FieldDomIdProvider({ prefix, children, }: {
1799
1902
  */
1800
1903
  declare function useFieldDomId(path: string): string;
1801
1904
 
1802
- 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, FieldPresentation, 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, useFieldStrings, useMethodForm, useProseImages, useResolveRendition, useResolveShareUrl, useResolveUrl, useResolvedUrl };
1905
+ export { type AskDocumentPdf, BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, type DocumentPdfAnswer, type DocumentPdfRequest, type DownloadDisplay, EN_FIELD_STRINGS, EnumField, type ExamplePickerSource, ExampleSource, FIELD_STRINGS_BY_LOCALE, FR_FIELD_STRINGS, FieldDomIdProvider, FieldEnv, FieldPresentation, 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 ResolveDocumentPdf, 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, useFieldStrings, useMethodForm, useProseImages, useResolveDocumentPdf, useResolveRendition, useResolveShareUrl, useResolveUrl, useResolvedUrl };
@@ -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, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveRendition, useResolveShareUrl, useResolveUrl, useResolvedUrl } from '../chunk-TD62R3P6.js';
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, useResolveDocumentPdf, useResolveRendition, useResolveShareUrl, useResolveUrl, useResolvedUrl } from '../chunk-ROM2KLQD.js';
3
3
  import '../chunk-4VAO6BDE.js';
4
4
  import '../chunk-AURDKAIC.js';
5
5
  import '../chunk-L23R3JNQ.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelex/mthds-form",
3
- "version": "0.35.1",
3
+ "version": "0.36.0",
4
4
  "description": "Headless form kernel and control set for MTHDS method inputs",
5
5
  "license": "MIT",
6
6
  "repository": {