@pipelex/mthds-form 0.36.1 → 0.36.2

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.
@@ -7383,10 +7383,12 @@ function PdfUnavailable({
7383
7383
  function ConvertedDocumentPreview({
7384
7384
  ask,
7385
7385
  name,
7386
- file
7386
+ file,
7387
+ whole
7387
7388
  }) {
7388
7389
  const s = useFieldStrings();
7389
7390
  const { answer, retry } = useDocumentPdf(ask);
7391
+ const size = whole ? WHOLE_RESULT_FRAME : NESTED_FRAME;
7390
7392
  const preparing = useRef(null);
7391
7393
  const retried = useRef(false);
7392
7394
  useEffect(() => {
@@ -7402,7 +7404,7 @@ function ConvertedDocumentPreview({
7402
7404
  role: "status",
7403
7405
  tabIndex: -1,
7404
7406
  className: cn(
7405
- NESTED_FRAME,
7407
+ size,
7406
7408
  "flex items-center justify-center gap-2 rounded-lg border border-border bg-card/40 text-[12px] text-muted-foreground outline-none"
7407
7409
  ),
7408
7410
  children: [
@@ -7413,35 +7415,47 @@ function ConvertedDocumentPreview({
7413
7415
  );
7414
7416
  }
7415
7417
  if (answer.state === "failed") {
7416
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 rounded-lg border border-border bg-card/40 px-3.5 py-3 sm:flex-row sm:items-center", children: [
7417
- /* @__PURE__ */ jsxs(
7418
- "p",
7419
- {
7420
- role: "alert",
7421
- className: "flex min-w-0 flex-1 items-start gap-2 text-[12.5px] leading-relaxed text-muted-foreground",
7422
- children: [
7423
- /* @__PURE__ */ jsx(TriangleAlert, { "aria-hidden": true, className: "mt-0.5 size-3.5 shrink-0" }),
7424
- /* @__PURE__ */ jsx("span", { children: answer.message ?? s.documentPdfFailed })
7425
- ]
7426
- }
7427
- ),
7428
- /* @__PURE__ */ jsx(
7429
- "button",
7430
- {
7431
- type: "button",
7432
- onClick: () => {
7433
- retried.current = true;
7434
- retry();
7435
- },
7436
- className: cn(CARD_ACTION, "text-foreground", focusOutlineClass),
7437
- children: s.tryAgain
7438
- }
7439
- )
7440
- ] });
7418
+ return /* @__PURE__ */ jsxs(
7419
+ "div",
7420
+ {
7421
+ className: cn(
7422
+ "flex flex-col gap-3 rounded-lg border border-border bg-card/40 px-3.5 py-3",
7423
+ whole ? cn(size, "items-center justify-center") : "sm:flex-row sm:items-center"
7424
+ ),
7425
+ children: [
7426
+ /* @__PURE__ */ jsxs(
7427
+ "p",
7428
+ {
7429
+ role: "alert",
7430
+ className: cn(
7431
+ "flex min-w-0 items-start gap-2 text-[12.5px] leading-relaxed text-muted-foreground",
7432
+ !whole && "flex-1"
7433
+ ),
7434
+ children: [
7435
+ /* @__PURE__ */ jsx(TriangleAlert, { "aria-hidden": true, className: "mt-0.5 size-3.5 shrink-0" }),
7436
+ /* @__PURE__ */ jsx("span", { children: answer.message ?? s.documentPdfFailed })
7437
+ ]
7438
+ }
7439
+ ),
7440
+ /* @__PURE__ */ jsx(
7441
+ "button",
7442
+ {
7443
+ type: "button",
7444
+ onClick: () => {
7445
+ retried.current = true;
7446
+ retry();
7447
+ },
7448
+ className: cn(CARD_ACTION, "text-foreground", focusOutlineClass),
7449
+ children: s.tryAgain
7450
+ }
7451
+ )
7452
+ ]
7453
+ }
7454
+ );
7441
7455
  }
7442
7456
  const gated = answer.state === "ready" ? viewableUrl(answer.url) : void 0;
7443
7457
  const url = gated && frameableUrl({ url: gated, fromResolver: true });
7444
- if (url) return /* @__PURE__ */ jsx(DocumentPreview, { url, name, pdf: true, file, whole: false });
7458
+ if (url) return /* @__PURE__ */ jsx(DocumentPreview, { url, name, pdf: true, file, whole });
7445
7459
  return /* @__PURE__ */ jsx(
7446
7460
  "p",
7447
7461
  {
@@ -7451,12 +7465,16 @@ function ConvertedDocumentPreview({
7451
7465
  }
7452
7466
  );
7453
7467
  }
7454
- function DocumentValue({ value, whole = false }) {
7468
+ function DocumentValue({
7469
+ value,
7470
+ whole = false,
7471
+ startsOpen = false
7472
+ }) {
7455
7473
  const s = useFieldStrings();
7456
7474
  const resolve = useResolveUrl();
7457
7475
  const resolveDocumentPdf = useResolveDocumentPdf();
7458
7476
  const isApp = useFieldPresentation() === "app";
7459
- const [open, setOpen] = useState(false);
7477
+ const [open, setOpen] = useState(startsOpen);
7460
7478
  const file = useStuffFile("document", value);
7461
7479
  const content = readDocumentContent(value);
7462
7480
  if (!content) return /* @__PURE__ */ jsx(Absent, {});
@@ -7466,11 +7484,11 @@ function DocumentValue({ value, whole = false }) {
7466
7484
  const name = title || label;
7467
7485
  const preview = previewableUrl(content, resolve);
7468
7486
  const pdf = preview !== void 0 && isPdfDocument(content, preview);
7469
- const opened = whole && isApp && pdf;
7470
7487
  const askPdf = preview === void 0 && !browserRenders(content, content.url) ? resolveDocumentPdf?.(content.url, {
7471
7488
  filename: content.filename,
7472
7489
  mimeType: content.mimeType
7473
7490
  }) : void 0;
7491
+ const opened = whole && isApp && (preview !== void 0 || askPdf !== void 0);
7474
7492
  return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
7475
7493
  /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-start gap-2.5", children: [
7476
7494
  /* @__PURE__ */ jsx(
@@ -7516,7 +7534,16 @@ function DocumentValue({ value, whole = false }) {
7516
7534
  )
7517
7535
  ] }),
7518
7536
  preview && (opened || open) && /* @__PURE__ */ jsx(DocumentPreview, { url: preview, name, pdf, file, whole: opened }),
7519
- askPdf && open && /* @__PURE__ */ jsx(ConvertedDocumentPreview, { ask: askPdf, name, file }, content.url)
7537
+ askPdf && (opened || open) && /* @__PURE__ */ jsx(
7538
+ ConvertedDocumentPreview,
7539
+ {
7540
+ ask: askPdf,
7541
+ name,
7542
+ file,
7543
+ whole: opened
7544
+ },
7545
+ content.url
7546
+ )
7520
7547
  ] });
7521
7548
  }
7522
7549
  var TILE_RENDITION_SIDE = 576;
@@ -8583,6 +8610,17 @@ function PanelResult({
8583
8610
  }) {
8584
8611
  return /* @__PURE__ */ jsx(PanelResultContext, { value: hostHeaded ? HOST_HEADED_PANEL : TITLED_PANEL, children });
8585
8612
  }
8613
+ var DeliveredDocumentContext = createContext(false);
8614
+ function loneDocumentMember(field) {
8615
+ let lone;
8616
+ for (const child of field.fields) {
8617
+ if (child.kind === "list" && child.item.kind === "document") return void 0;
8618
+ if (child.kind !== "document") continue;
8619
+ if (lone !== void 0) return void 0;
8620
+ lone = child.name;
8621
+ }
8622
+ return lone;
8623
+ }
8586
8624
  function ResultField(props) {
8587
8625
  const location = useResultLocation();
8588
8626
  const panel = use(PanelResultContext);
@@ -8604,6 +8642,7 @@ function ResultNode({
8604
8642
  const pdfShown = usePdfSaveShown();
8605
8643
  const location = useResultLocation();
8606
8644
  const isApp = useFieldPresentation() === "app";
8645
+ const delivered = use(DeliveredDocumentContext);
8607
8646
  const header = hideLabel ? null : /* @__PURE__ */ jsx(Label2, { field, describe: true });
8608
8647
  const copyText = (field.kind === "text" || field.kind === "prose") && typeof unwrapped === "string" && unwrapped !== "" ? unwrapped : void 0;
8609
8648
  if (isNativeDateNode(field)) {
@@ -8669,6 +8708,7 @@ function ResultNode({
8669
8708
  case "object": {
8670
8709
  const memberValue = (child) => typeof unwrapped === "object" && unwrapped !== null ? ownProp(unwrapped, child.name) : void 0;
8671
8710
  const sharesALine = (child) => isInlineColumn(child) && !(isApp && child.kind === "text" && isLongText(unwrap(child, memberValue(child))));
8711
+ const lone = whole && isApp ? loneDocumentMember(field) : void 0;
8672
8712
  return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
8673
8713
  header,
8674
8714
  /* @__PURE__ */ jsx(
@@ -8703,7 +8743,7 @@ function ResultNode({
8703
8743
  sharesALine(child) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
8704
8744
  /* @__PURE__ */ jsx("div", { className: "min-w-0", children: /* @__PURE__ */ jsx(Label2, { field: child, describe: true }) }),
8705
8745
  /* @__PURE__ */ jsx("div", { className: "flex min-w-0 justify-end **:data-chips:justify-end", children: /* @__PURE__ */ jsx("div", { className: "min-w-0 text-left wrap-break-word", children: /* @__PURE__ */ jsx(LeafValue, { field: child, value: memberValue(child) }) }) })
8706
- ] }, child.name) : /* @__PURE__ */ jsx("div", { className: "col-span-2 min-w-0", children: /* @__PURE__ */ jsx(ResultAt, { segment: child.name, children: /* @__PURE__ */ jsx(ResultField, { field: child, value: memberValue(child), depth: depth + 1 }) }) }, child.name)
8746
+ ] }, child.name) : /* @__PURE__ */ jsx("div", { className: "col-span-2 min-w-0", children: /* @__PURE__ */ jsx(ResultAt, { segment: child.name, children: child.name === lone ? /* @__PURE__ */ jsx(DeliveredDocumentContext, { value: true, children: /* @__PURE__ */ jsx(ResultField, { field: child, value: memberValue(child), depth: depth + 1 }) }) : /* @__PURE__ */ jsx(ResultField, { field: child, value: memberValue(child), depth: depth + 1 }) }) }, child.name)
8707
8747
  )
8708
8748
  )
8709
8749
  }
@@ -8827,7 +8867,7 @@ function ResultNode({
8827
8867
  headed && /* @__PURE__ */ jsx(Label2, { field, describe: true, unseen: true }),
8828
8868
  /* @__PURE__ */ jsx("div", { className: "float-right ml-2", children: /* @__PURE__ */ jsx(CopyButton, { value: copyText, label: s.copyText }) })
8829
8869
  ] }),
8830
- typeset !== void 0 ? /* @__PURE__ */ jsx(Markdown, { text: typeset }) : field.kind === "document" && whole ? /* @__PURE__ */ jsx(DocumentValue, { value: unwrapped, whole: true }) : /* @__PURE__ */ jsx(LeafValue, { field, value })
8870
+ typeset !== void 0 ? /* @__PURE__ */ jsx(Markdown, { text: typeset }) : field.kind === "document" && (whole || delivered) ? /* @__PURE__ */ jsx(DocumentValue, { value: unwrapped, whole, startsOpen: delivered }) : /* @__PURE__ */ jsx(LeafValue, { field, value })
8831
8871
  ]
8832
8872
  }
8833
8873
  );
@@ -9141,5 +9181,5 @@ function pdfFileName(field, value, baseName) {
9141
9181
  }
9142
9182
 
9143
9183
  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, ResultRoot, SUPPORTED_LOCALES, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, StuffViewer, Switch, TextField, ToggleGroup, ToggleGroupItem, UnknownField, actionShadowClass, checkedAccentClass, cn, enumLabeler, fieldControlClass, fieldLabel, fieldStringsFor, focusOutlineClass, headingClass, isThenable, linkTextClass, panelFlatShadowClass, panelRaisedShadowClass, panelSurfaceClass, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, selectedBorderClass, selectedFillClass, selectedFillStrongClass, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveDocumentPdf, useResolveRendition, useResolveShareUrl, useResolveUrl, useResolvedUrl };
9144
- //# sourceMappingURL=chunk-TPHIENRU.js.map
9145
- //# sourceMappingURL=chunk-TPHIENRU.js.map
9184
+ //# sourceMappingURL=chunk-7SOGQRMN.js.map
9185
+ //# sourceMappingURL=chunk-7SOGQRMN.js.map