@pipelex/mthds-form 0.17.0 → 0.18.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,13 +1,13 @@
1
1
  import { planFileSave, planStuffSave, splitFileName, typedFileStem } from './chunk-ICUEHNEH.js';
2
2
  import { seedInputs, closeOptionalStructures, openOptionalStructures } from './chunk-VH5CDQDR.js';
3
3
  import { readStuffFile } from './chunk-RRTI7AIR.js';
4
- import { setValueAtPath, apiInputsFromRunValues } from './chunk-MEXWXLR7.js';
4
+ import { setValueAtPath, apiInputsFromRunValues } from './chunk-PQ3ZX5MJ.js';
5
+ import { shownAsOptional, isFoldedOptional, anyOptionalStructureOpen, isOptionalStructure, computeReadiness, optionalStructureOpen, mustBeFilled, fieldFilled, isFilled } from './chunk-XO5OENNF.js';
5
6
  import { viewableUrl, isNativeDateNode, isNativeHtmlNode, readHtmlContent, isNativeCompositeNode, readCompositeContent, isNativeValueNode, readDateContent, formatDateContent, readImageContent, readDataUrl, readDocumentContent } from './chunk-CM4KVG53.js';
6
- import { buildRunFields } from './chunk-ZB4RYUKV.js';
7
+ import { buildRunFields } from './chunk-HVWE3TTC.js';
8
+ import { ownProp } from './chunk-V3OV2XQT.js';
7
9
  import { conceptCategory } from './chunk-FABY3DEY.js';
8
10
  import { acceptLabel, acceptMap, isAcceptedFile, formatOfFilename, DOCUMENT_FORMATS, IMAGE_FORMATS } from './chunk-XCO6GTEC.js';
9
- import { shownAsOptional, isFoldedOptional, anyOptionalStructureOpen, isOptionalStructure, computeReadiness, optionalStructureOpen, mustBeFilled, fieldFilled, isFilled } from './chunk-XO5OENNF.js';
10
- import { ownProp } from './chunk-V3OV2XQT.js';
11
11
  import { toStoredDateValue, toDateInputValue } from './chunk-GKV77RAS.js';
12
12
  import { clsx } from 'clsx';
13
13
  import { twMerge } from 'tailwind-merge';
@@ -112,6 +112,7 @@ var Switch = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
112
112
  {
113
113
  className: cn(
114
114
  "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
115
+ "max-sm:relative max-sm:after:absolute max-sm:after:-inset-x-0.5 max-sm:after:-inset-y-3 max-sm:after:content-['']",
115
116
  className
116
117
  ),
117
118
  ...props,
@@ -736,7 +737,7 @@ function FileField({
736
737
  type: "button",
737
738
  disabled: busy,
738
739
  onClick: () => setShowUrl(true),
739
- className: "flex w-fit items-center gap-1 font-mono text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50",
740
+ className: "flex w-fit items-center gap-1 font-mono text-[11px] text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50 max-sm:min-h-11",
740
741
  children: [
741
742
  /* @__PURE__ */ jsx(Link2, { className: "h-3 w-3" }),
742
743
  s.pasteUrlInstead
@@ -803,25 +804,27 @@ function FileChip({
803
804
  () => fileChipSubtitle(url, filename, formats, presentation, s),
804
805
  [url, filename, formats, presentation, s]
805
806
  );
806
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 rounded-md border border-border bg-input px-3 py-2.5", children: [
807
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border border-border bg-input px-3 py-2.5", children: [
807
808
  /* @__PURE__ */ jsx("span", { className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted", children: /* @__PURE__ */ jsx(FileText, { className: "h-4 w-4 text-muted-foreground" }) }),
808
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
809
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 basis-32 [contain:inline-size]", children: [
809
810
  /* @__PURE__ */ jsx("p", { className: "truncate text-[13px] font-medium text-foreground", children: value?.filename ?? s.uploadedFile }),
810
811
  subtitle && /* @__PURE__ */ jsx("p", { className: "truncate font-mono text-[10.5px] text-muted-foreground", children: subtitle })
811
812
  ] }),
812
- canPreview && /* @__PURE__ */ jsxs(
813
- "button",
814
- {
815
- type: "button",
816
- onClick: onTogglePreview,
817
- className: "inline-flex h-7 shrink-0 items-center gap-1 rounded-md border border-border px-2 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
818
- children: [
819
- previewOpen ? /* @__PURE__ */ jsx(EyeOff, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(Eye, { className: "h-3.5 w-3.5" }),
820
- s.preview
821
- ]
822
- }
823
- ),
824
- /* @__PURE__ */ jsx(ClearButton, { disabled, onClick: onClear })
813
+ /* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-3", children: [
814
+ canPreview && /* @__PURE__ */ jsxs(
815
+ "button",
816
+ {
817
+ type: "button",
818
+ onClick: onTogglePreview,
819
+ className: "inline-flex h-7 shrink-0 items-center gap-1 rounded-md border border-border px-2 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground max-sm:h-11 max-sm:px-3",
820
+ children: [
821
+ previewOpen ? /* @__PURE__ */ jsx(EyeOff, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(Eye, { className: "h-3.5 w-3.5" }),
822
+ s.preview
823
+ ]
824
+ }
825
+ ),
826
+ /* @__PURE__ */ jsx(ClearButton, { disabled, onClick: onClear })
827
+ ] })
825
828
  ] });
826
829
  }
827
830
  function ClearButton({ disabled, onClick }) {
@@ -833,7 +836,7 @@ function ClearButton({ disabled, onClick }) {
833
836
  onClick,
834
837
  disabled,
835
838
  "aria-label": s.removeFileAria,
836
- className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50",
839
+ className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50 max-sm:size-11",
837
840
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
838
841
  }
839
842
  );
@@ -1209,7 +1212,7 @@ function OptionalToggle({ count, expanded, onToggle, noun = "field" }) {
1209
1212
  type: "button",
1210
1213
  onClick: onToggle,
1211
1214
  "aria-expanded": expanded,
1212
- className: "flex w-fit items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground",
1215
+ className: "flex w-fit items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground max-sm:min-h-11",
1213
1216
  children: [
1214
1217
  expanded ? /* @__PURE__ */ jsx(Minus, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(Plus, { className: "h-3 w-3" }),
1215
1218
  expanded ? noun === "field" ? s.hideOptionalFields : s.hideOptionalInputs : noun === "field" ? s.optionalFieldsCount(count) : s.optionalInputsCount(count)
@@ -1381,7 +1384,7 @@ function ListField({ field, value, onChange, id, error, env }) {
1381
1384
  onClick: () => removeItem(index),
1382
1385
  disabled: env?.disabled || busy,
1383
1386
  "aria-label": s.removeItemAria(index + 1),
1384
- className: "mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-destructive disabled:opacity-50",
1387
+ className: "mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-destructive disabled:opacity-50 max-sm:mt-0 max-sm:size-11",
1385
1388
  children: /* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5" })
1386
1389
  }
1387
1390
  )
@@ -1396,7 +1399,7 @@ function ListField({ field, value, onChange, id, error, env }) {
1396
1399
  onClick: addItem,
1397
1400
  disabled: env?.disabled || isFull,
1398
1401
  className: cn(
1399
- "inline-flex h-9 w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border text-[13px] text-muted-foreground transition-colors",
1402
+ "inline-flex h-9 w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border text-[13px] text-muted-foreground transition-colors max-sm:h-11",
1400
1403
  "hover:border-primary/40 hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"
1401
1404
  ),
1402
1405
  children: [
@@ -1897,6 +1900,18 @@ function frameDocument(content, { styles, imgSrc, fontSrc }) {
1897
1900
  function escapeAttribute(value) {
1898
1901
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
1899
1902
  }
1903
+ var DEFAULT_PAGE_FONT = "system-ui, sans-serif";
1904
+ function pageDocument(content, {
1905
+ imgSrc = DEFAULT_IMG_SRC,
1906
+ fontSrc,
1907
+ fontFamily
1908
+ } = {}) {
1909
+ return frameDocument(content, {
1910
+ styles: frameStyles(pageTypography(fontFamily || DEFAULT_PAGE_FONT)),
1911
+ imgSrc,
1912
+ fontSrc: fontSrc ?? imgSrc
1913
+ });
1914
+ }
1900
1915
 
1901
1916
  // src/react/markup-storage.ts
1902
1917
  var MARKUP_RESOLVE_TIMEOUT_MS = 1e4;
@@ -2158,6 +2173,7 @@ function ResultEnvProvider({
2158
2173
  tableLayout,
2159
2174
  saveFiles,
2160
2175
  downloads,
2176
+ renderPdf,
2161
2177
  children
2162
2178
  }) {
2163
2179
  const env = useMemo(
@@ -2169,7 +2185,8 @@ function ResultEnvProvider({
2169
2185
  tableColumns,
2170
2186
  tableLayout,
2171
2187
  saveFiles,
2172
- downloads
2188
+ downloads,
2189
+ renderPdf
2173
2190
  }),
2174
2191
  [
2175
2192
  resolveUrl,
@@ -2179,7 +2196,8 @@ function ResultEnvProvider({
2179
2196
  tableColumns,
2180
2197
  tableLayout,
2181
2198
  saveFiles,
2182
- downloads
2199
+ downloads,
2200
+ renderPdf
2183
2201
  ]
2184
2202
  );
2185
2203
  return /* @__PURE__ */ jsx(ResultEnvContext, { value: env, children });
@@ -2259,6 +2277,9 @@ function useFileDownloadShown(kind) {
2259
2277
  function usePdfSaveShown() {
2260
2278
  return use(ResultEnvContext).downloads?.pdf ?? true;
2261
2279
  }
2280
+ function useRenderPdf() {
2281
+ return use(ResultEnvContext).renderPdf;
2282
+ }
2262
2283
  function useAskFileName() {
2263
2284
  return use(ResultEnvContext).downloads?.askFileName ?? false;
2264
2285
  }
@@ -2786,7 +2807,7 @@ var PT_PER_PX = 72 / 96;
2786
2807
  async function renderHtmlPdf(content, {
2787
2808
  imgSrc = DEFAULT_IMG_SRC,
2788
2809
  fontSrc,
2789
- fontFamily = "system-ui, sans-serif",
2810
+ fontFamily = DEFAULT_PAGE_FONT,
2790
2811
  title,
2791
2812
  scale = 3,
2792
2813
  quality = 0.92
@@ -2970,11 +2991,7 @@ async function openCopy(content, { imgSrc, fontSrc, fontFamily }) {
2970
2991
  opacity: "0",
2971
2992
  pointerEvents: "none"
2972
2993
  });
2973
- frame.srcdoc = frameDocument(content, {
2974
- styles: frameStyles(pageTypography(fontFamily)),
2975
- imgSrc,
2976
- fontSrc
2977
- });
2994
+ frame.srcdoc = pageDocument(content, { imgSrc, fontSrc, fontFamily });
2978
2995
  const loaded = new Promise(
2979
2996
  (resolve) => frame.addEventListener("load", () => resolve(), { once: true })
2980
2997
  );
@@ -3035,6 +3052,7 @@ function PdfDownloadButton({
3035
3052
  const s = useFieldStrings();
3036
3053
  const save = useSaveFiles();
3037
3054
  const resolvers = useMarkupResolvers();
3055
+ const hostPdf = useRenderPdf();
3038
3056
  const ref = useRef(null);
3039
3057
  const statusId = useId();
3040
3058
  const [state, setState] = useState("idle");
@@ -3050,12 +3068,12 @@ function PdfDownloadButton({
3050
3068
  const fontFamily = ref.current ? getComputedStyle(ref.current).fontFamily : void 0;
3051
3069
  const innerHtml = await resolveHtmlStorageUrls(content.innerHtml, resolvers);
3052
3070
  const page = innerHtml === content.innerHtml ? content : { ...content, innerHtml };
3053
- const { blob } = await renderHtmlPdf(page, {
3071
+ const blob = hostPdf ? await makeOnHost(hostPdf, page, { title, imgSrc, fontSrc, fontFamily }) : (await renderHtmlPdf(page, {
3054
3072
  ...title ? { title } : {},
3055
3073
  ...imgSrc === void 0 ? {} : { imgSrc },
3056
3074
  ...fontSrc === void 0 ? {} : { fontSrc },
3057
3075
  ...fontFamily ? { fontFamily } : {}
3058
- });
3076
+ })).blob;
3059
3077
  const { failed: missed } = await save([
3060
3078
  {
3061
3079
  name: chosen,
@@ -3098,6 +3116,11 @@ function PdfDownloadButton({
3098
3116
  dialog
3099
3117
  ] });
3100
3118
  }
3119
+ async function makeOnHost(render, page, { title, ...frame }) {
3120
+ const blob = await render({ html: pageDocument(page, frame), ...title ? { title } : {} });
3121
+ if (!(blob instanceof Blob) || blob.size === 0) throw new Error("The host made no PDF");
3122
+ return blob;
3123
+ }
3101
3124
  function pdfStem(name) {
3102
3125
  return (name ?? "").trim().replace(/\.pdf$/i, "").trim();
3103
3126
  }
@@ -3613,6 +3636,7 @@ function pathLabel(url) {
3613
3636
  const segment = path.split("/").filter(Boolean).pop();
3614
3637
  return segment && segment.length > 0 ? segment : url;
3615
3638
  }
3639
+ var FILE_BUTTON_ON_A_PHONE = "max-sm:grid max-sm:size-11 max-sm:place-items-center";
3616
3640
  function CopyButton({
3617
3641
  value,
3618
3642
  provide,
@@ -3649,7 +3673,10 @@ function CopyButton({
3649
3673
  },
3650
3674
  ...title ? { title } : {},
3651
3675
  "aria-label": label,
3652
- className: "shrink-0 rounded p-0.5 text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1",
3676
+ className: cn(
3677
+ "shrink-0 rounded p-0.5 text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1",
3678
+ FILE_BUTTON_ON_A_PHONE
3679
+ ),
3653
3680
  children: copied ? /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: "size-3.5" }) : /* @__PURE__ */ jsx(Copy, { "aria-hidden": true, className: "size-3.5" })
3654
3681
  }
3655
3682
  );
@@ -3687,7 +3714,7 @@ function FileRef({
3687
3714
  target: "_blank",
3688
3715
  rel: "noreferrer",
3689
3716
  title,
3690
- className: "min-w-0 truncate font-mono text-[12px] text-foreground underline underline-offset-2",
3717
+ className: "min-w-0 truncate font-mono text-[12px] text-foreground underline underline-offset-2 max-sm:min-w-11 max-sm:leading-11",
3691
3718
  children: label
3692
3719
  }
3693
3720
  ) : /* @__PURE__ */ jsx(
@@ -3769,6 +3796,7 @@ ${planned.url ?? planned.text}`;
3769
3796
  ...failed ? { "aria-describedby": statusId } : {},
3770
3797
  className: cn(
3771
3798
  "shrink-0 rounded p-0.5 hover:bg-card focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 disabled:opacity-60",
3799
+ FILE_BUTTON_ON_A_PHONE,
3772
3800
  failed ? "text-destructive" : "text-muted-foreground hover:text-foreground"
3773
3801
  ),
3774
3802
  children: state === "saving" ? /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: "size-3.5 animate-spin" }) : state === "saved" ? /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: "size-3.5" }) : failed ? /* @__PURE__ */ jsx(TriangleAlert, { "aria-hidden": true, className: "size-3.5" }) : /* @__PURE__ */ jsx(Download, { "aria-hidden": true, className: "size-3.5" })
@@ -3845,7 +3873,7 @@ function DocumentValue({ value }) {
3845
3873
  type: "button",
3846
3874
  onClick: () => setOpen((current) => !current),
3847
3875
  "aria-expanded": open,
3848
- className: "flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[12px] text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1",
3876
+ className: "flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[12px] text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 max-sm:min-h-11 max-sm:px-3",
3849
3877
  children: [
3850
3878
  open ? /* @__PURE__ */ jsx(EyeOff, { "aria-hidden": true, className: "size-3.5" }) : /* @__PURE__ */ jsx(Eye, { "aria-hidden": true, className: "size-3.5" }),
3851
3879
  s.preview
@@ -4064,7 +4092,9 @@ function isInlineColumn(field) {
4064
4092
  return TABULAR_KINDS.has(field.kind);
4065
4093
  }
4066
4094
  var CELL_LENGTH_LIMIT = 80;
4067
- var EXPAND_COLUMN = "2rem";
4095
+ var EXPAND_COLUMN = "var(--expand-column,2rem)";
4096
+ var EXPAND_COLUMN_WIDTH = "[--expand-column:2rem] max-sm:[--expand-column:3.25rem]";
4097
+ var TOGGLE = "mt-0.5 flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 max-sm:mt-0 max-sm:size-11";
4068
4098
  var STACK_NEVER_UP_TO = 3;
4069
4099
  var STACK_ALWAYS_BEYOND = 6;
4070
4100
  function stackingFor(columns) {
@@ -4077,9 +4107,9 @@ var STACKED = {
4077
4107
  head: "@max-[640px]:hidden",
4078
4108
  body: "@max-[640px]:block",
4079
4109
  row: "@max-[640px]:relative @max-[640px]:block @max-[640px]:px-3 @max-[640px]:py-2",
4080
- rowWithToggle: "@max-[640px]:pl-8",
4081
- toggle: "@max-[640px]:absolute @max-[640px]:top-2 @max-[640px]:left-1 @max-[640px]:p-0",
4082
- cell: "@max-[640px]:grid @max-[640px]:grid-cols-[minmax(0,min(40%,10rem))_minmax(0,1fr)] @max-[640px]:items-baseline @max-[640px]:gap-x-3 @max-[640px]:px-0 @max-[640px]:py-0.5",
4110
+ rowWithToggle: "@max-[640px]:pl-8 max-sm:@max-[640px]:pl-12",
4111
+ toggle: "@max-[640px]:absolute @max-[640px]:top-2 @max-[640px]:left-1 @max-[640px]:p-0 max-sm:@max-[640px]:top-0 max-sm:@max-[640px]:left-0",
4112
+ cell: "@max-[640px]:grid @max-[640px]:grid-cols-[minmax(0,min(40%,10rem))_minmax(0,1fr)] @max-[640px]:items-baseline @max-[640px]:gap-x-3 @max-[640px]:px-0 @max-[640px]:py-0.5 @max-[640px]:after:hidden",
4083
4113
  label: "@max-[640px]:block",
4084
4114
  detail: "@max-[640px]:block",
4085
4115
  detailInner: "@max-[640px]:px-0 @max-[640px]:py-1"
@@ -4089,9 +4119,9 @@ var STACKED = {
4089
4119
  head: "hidden",
4090
4120
  body: "block",
4091
4121
  row: "relative block px-3 py-2",
4092
- rowWithToggle: "pl-8",
4093
- toggle: "absolute top-2 left-1 p-0",
4094
- cell: "grid grid-cols-[minmax(0,min(40%,10rem))_minmax(0,1fr)] items-baseline gap-x-3 px-0 py-0.5",
4122
+ rowWithToggle: "pl-8 max-sm:pl-12",
4123
+ toggle: "absolute top-2 left-1 p-0 max-sm:top-0 max-sm:left-0",
4124
+ cell: "grid grid-cols-[minmax(0,min(40%,10rem))_minmax(0,1fr)] items-baseline gap-x-3 px-0 py-0.5 after:hidden",
4095
4125
  label: "block",
4096
4126
  detail: "block",
4097
4127
  detailInner: "px-0 py-1"
@@ -4099,6 +4129,25 @@ var STACKED = {
4099
4129
  };
4100
4130
  var FIT_CELL = "min-w-[min(8ch,14cqw)] wrap-anywhere [&>span]:whitespace-normal";
4101
4131
  var FIT_NAME = "min-w-[min(16ch,28cqw)] wrap-anywhere [&>span]:whitespace-normal";
4132
+ var WORD_FLOOR = "after:block after:h-0 after:max-w-[var(--fit-share,0px)] after:overflow-hidden after:invisible after:wrap-normal after:content-[attr(data-fit)]";
4133
+ var FIT_SHARE_BESIDE_NAME = {
4134
+ 2: "[--fit-share:calc(72cqw_-_3rem_-_var(--expand-column,2rem))]",
4135
+ 3: "[--fit-share:calc((72cqw_-_4.5rem_-_var(--expand-column,2rem))/2)]",
4136
+ 4: "[--fit-share:calc((72cqw_-_6rem_-_var(--expand-column,2rem))/3)]",
4137
+ 5: "[--fit-share:calc((72cqw_-_7.5rem_-_var(--expand-column,2rem))/4)]",
4138
+ 6: "[--fit-share:calc((72cqw_-_9rem_-_var(--expand-column,2rem))/5)]"
4139
+ };
4140
+ var FIT_SHARE_WITHOUT_NAME = {
4141
+ 1: "[--fit-share:calc(100cqw_-_1.5rem_-_var(--expand-column,2rem))]",
4142
+ 2: "[--fit-share:calc((100cqw_-_3rem_-_var(--expand-column,2rem))/2)]",
4143
+ 3: "[--fit-share:calc((100cqw_-_4.5rem_-_var(--expand-column,2rem))/3)]",
4144
+ 4: "[--fit-share:calc((100cqw_-_6rem_-_var(--expand-column,2rem))/4)]",
4145
+ 5: "[--fit-share:calc((100cqw_-_7.5rem_-_var(--expand-column,2rem))/5)]",
4146
+ 6: "[--fit-share:calc((100cqw_-_9rem_-_var(--expand-column,2rem))/6)]"
4147
+ };
4148
+ function cellWords(column, cell, presentation) {
4149
+ return typeof cell === "string" || typeof cell === "number" ? cellTitle(column, cell, presentation) : void 0;
4150
+ }
4102
4151
  function clampsInStack(column, name) {
4103
4152
  if (column === name || fitsACellWhole(column)) return false;
4104
4153
  return column.kind !== "list" && column.kind !== "document" && column.kind !== "image";
@@ -4138,6 +4187,9 @@ function ObjectTable({
4138
4187
  const fits = layout === "stack";
4139
4188
  const stacking = fits ? stackingFor(shown.length) : "never";
4140
4189
  const stacked = stacking === "never" ? void 0 : STACKED[stacking];
4190
+ const nameShown = name !== void 0 && shown.includes(name);
4191
+ const fitShare = fits ? (nameShown ? FIT_SHARE_BESIDE_NAME : FIT_SHARE_WITHOUT_NAME)[shown.length] : void 0;
4192
+ const floorsWords = (column) => fitShare !== void 0 && column !== name;
4141
4193
  useEffect(() => {
4142
4194
  const scroller = scrollerRef.current;
4143
4195
  if (!scroller || fits) return;
@@ -4184,107 +4236,125 @@ function ObjectTable({
4184
4236
  role: "group",
4185
4237
  "aria-label": label,
4186
4238
  ...fits ? {} : { tabIndex: 0 },
4187
- className: cn("overflow-x-auto rounded-lg border border-border", fits && "@container"),
4188
- children: /* @__PURE__ */ jsxs("table", { className: cn("w-full min-w-full border-collapse text-[13px]", stacked?.table), children: [
4189
- /* @__PURE__ */ jsx("thead", { className: stacked?.head, children: /* @__PURE__ */ jsxs("tr", { className: "border-b border-border bg-muted text-left", children: [
4190
- canExpand && /* @__PURE__ */ jsx("th", { scope: "col", style: { width: EXPAND_COLUMN }, className: "px-1", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: s.rowDetailsColumn }) }),
4191
- shown.map((column) => /* @__PURE__ */ jsx(
4192
- "th",
4193
- {
4194
- scope: "col",
4195
- className: cn(
4196
- // One line, or wrapped anywhere so a header is never what
4197
- // widens a table that has to fit its box. See `FIT_CELL`.
4198
- fits ? "wrap-anywhere" : "whitespace-nowrap",
4199
- "px-3 py-2 text-[12px] font-semibold text-foreground",
4200
- presentation === "app" ? void 0 : "font-mono"
4201
- ),
4202
- children: /* @__PURE__ */ jsx(Described, { description: column.description, children: fieldLabel(column.title, column.name, presentation) })
4203
- },
4204
- column.name
4205
- ))
4206
- ] }) }),
4207
- /* @__PURE__ */ jsx("tbody", { className: stacked?.body, children: items.map((item, index) => {
4208
- const isOpen = canExpand && expanded.has(index);
4209
- return /* @__PURE__ */ jsx(ResultAt, { segment: String(index), children: /* @__PURE__ */ jsxs(
4210
- "tr",
4211
- {
4212
- className: cn(
4213
- "border-b border-border/60 last:border-b-0",
4214
- stacked?.row,
4215
- canExpand && stacked?.rowWithToggle
4216
- ),
4217
- children: [
4218
- canExpand && /* @__PURE__ */ jsx("td", { className: cn("px-1 pt-px align-top", stacked?.toggle), children: /* @__PURE__ */ jsx(
4219
- "button",
4220
- {
4221
- type: "button",
4222
- onClick: () => toggle(index),
4223
- "aria-expanded": isOpen,
4224
- "aria-label": s.toggleRowDetails(index + 1),
4225
- className: "mt-0.5 flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-card hover:text-foreground focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1",
4226
- children: isOpen ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: "size-3.5" }) : /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-3.5" })
4227
- }
4228
- ) }),
4229
- isOpen ? /* @__PURE__ */ jsx("td", { colSpan: shown.length, className: cn("bg-card/40 p-0", stacked?.detail), children: /* @__PURE__ */ jsx(
4230
- "div",
4231
- {
4232
- className: cn(
4233
- !fits && "sticky left-0",
4234
- "px-3.5 py-3",
4235
- stacked?.detailInner
4236
- ),
4237
- ...viewportWidth && !fits ? {
4238
- style: {
4239
- // Minus the chevron column: this cell starts
4240
- // after it, so pinning it to the FULL visible
4241
- // width pushes its right edge that far past the
4242
- // scroller. See `EXPAND_COLUMN`.
4243
- width: canExpand ? `calc(${viewportWidth}px - ${EXPAND_COLUMN})` : viewportWidth
4239
+ className: cn(
4240
+ "overflow-x-auto rounded-lg border border-border",
4241
+ EXPAND_COLUMN_WIDTH,
4242
+ fits && "@container"
4243
+ ),
4244
+ children: /* @__PURE__ */ jsxs(
4245
+ "table",
4246
+ {
4247
+ className: cn("w-full min-w-full border-collapse text-[13px]", stacked?.table, fitShare),
4248
+ children: [
4249
+ /* @__PURE__ */ jsx("thead", { className: stacked?.head, children: /* @__PURE__ */ jsxs("tr", { className: "border-b border-border bg-muted text-left", children: [
4250
+ canExpand && /* @__PURE__ */ jsx("th", { scope: "col", style: { width: EXPAND_COLUMN }, className: "px-1", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: s.rowDetailsColumn }) }),
4251
+ shown.map((column) => /* @__PURE__ */ jsx(
4252
+ "th",
4253
+ {
4254
+ scope: "col",
4255
+ ...floorsWords(column) ? { "data-fit": fieldLabel(column.title, column.name, presentation) } : {},
4256
+ className: cn(
4257
+ // One line, or wrapped anywhere so a header is never what
4258
+ // widens a table that has to fit its box. See `FIT_CELL`.
4259
+ fits ? "wrap-anywhere" : "whitespace-nowrap",
4260
+ "px-3 py-2 text-[12px] font-semibold text-foreground",
4261
+ presentation === "app" ? void 0 : "font-mono",
4262
+ floorsWords(column) && WORD_FLOOR
4263
+ ),
4264
+ children: /* @__PURE__ */ jsx(Described, { description: column.description, children: fieldLabel(column.title, column.name, presentation) })
4265
+ },
4266
+ column.name
4267
+ ))
4268
+ ] }) }),
4269
+ /* @__PURE__ */ jsx("tbody", { className: stacked?.body, children: items.map((item, index) => {
4270
+ const isOpen = canExpand && expanded.has(index);
4271
+ return /* @__PURE__ */ jsx(ResultAt, { segment: String(index), children: /* @__PURE__ */ jsxs(
4272
+ "tr",
4273
+ {
4274
+ className: cn(
4275
+ "border-b border-border/60 last:border-b-0",
4276
+ stacked?.row,
4277
+ canExpand && stacked?.rowWithToggle
4278
+ ),
4279
+ children: [
4280
+ canExpand && /* @__PURE__ */ jsx("td", { className: cn("px-1 pt-px align-top", stacked?.toggle), children: /* @__PURE__ */ jsx(
4281
+ "button",
4282
+ {
4283
+ type: "button",
4284
+ onClick: () => toggle(index),
4285
+ "aria-expanded": isOpen,
4286
+ "aria-label": s.toggleRowDetails(index + 1),
4287
+ className: TOGGLE,
4288
+ children: isOpen ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: "size-3.5" }) : /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-3.5" })
4244
4289
  }
4245
- } : {},
4246
- children: /* @__PURE__ */ jsx(ResultField, { field: element, value: item, hideLabel: true })
4247
- }
4248
- ) }) : shown.map((column) => {
4249
- const cell = typeof item === "object" && item !== null ? ownProp(item, column.name) : void 0;
4250
- const columnLabel = fieldLabel(column.title, column.name, presentation);
4251
- return /* @__PURE__ */ jsxs(
4252
- "td",
4253
- {
4254
- className: cn("px-3 py-1.5 align-top", stacked?.cell),
4255
- children: [
4256
- stacked && /* @__PURE__ */ jsx(
4257
- "span",
4258
- {
4259
- className: cn(
4260
- "hidden text-[12px] text-muted-foreground wrap-anywhere",
4261
- presentation === "app" ? void 0 : "font-mono",
4262
- stacked.label
4263
- ),
4264
- children: canExpand ? columnLabel : /* @__PURE__ */ jsx(Described, { description: column.description, children: columnLabel })
4265
- }
4290
+ ) }),
4291
+ isOpen ? /* @__PURE__ */ jsx("td", { colSpan: shown.length, className: cn("bg-card/40 p-0", stacked?.detail), children: /* @__PURE__ */ jsx(
4292
+ "div",
4293
+ {
4294
+ className: cn(
4295
+ !fits && "sticky left-0",
4296
+ "px-3.5 py-3",
4297
+ stacked?.detailInner
4266
4298
  ),
4267
- /* @__PURE__ */ jsx(
4268
- "div",
4269
- {
4270
- className: fits ? column === name ? FIT_NAME : cn(FIT_CELL, clampsInStack(column, name) && "line-clamp-3") : cn(
4271
- "max-w-[44ch]",
4272
- column === name ? "max-w-none min-w-[16ch] wrap-anywhere [&>span]:whitespace-normal" : column.kind === "list" && isInlineColumn(column) ? "min-w-[16ch]" : "truncate"
4273
- ),
4274
- ...typeof cell === "string" || typeof cell === "number" ? { title: cellTitle(column, cell, presentation) } : {},
4275
- children: /* @__PURE__ */ jsx(ResultAt, { segment: column.name, children: /* @__PURE__ */ jsx(LeafValue, { field: column, value: cell, compact: true }) })
4299
+ ...viewportWidth && !fits ? {
4300
+ style: {
4301
+ // Minus the chevron column: this cell starts
4302
+ // after it, so pinning it to the FULL visible
4303
+ // width pushes its right edge that far past the
4304
+ // scroller. See `EXPAND_COLUMN`.
4305
+ width: canExpand ? `calc(${viewportWidth}px - ${EXPAND_COLUMN})` : viewportWidth
4276
4306
  }
4277
- )
4278
- ]
4279
- },
4280
- column.name
4281
- );
4282
- })
4283
- ]
4284
- }
4285
- ) }, index);
4286
- }) })
4287
- ] })
4307
+ } : {},
4308
+ children: /* @__PURE__ */ jsx(ResultField, { field: element, value: item, hideLabel: true })
4309
+ }
4310
+ ) }) : shown.map((column) => {
4311
+ const cell = typeof item === "object" && item !== null ? ownProp(item, column.name) : void 0;
4312
+ const columnLabel = fieldLabel(column.title, column.name, presentation);
4313
+ const words = floorsWords(column) ? cellWords(column, cell, presentation) : void 0;
4314
+ return /* @__PURE__ */ jsxs(
4315
+ "td",
4316
+ {
4317
+ ...words === void 0 ? {} : { "data-fit": words },
4318
+ className: cn(
4319
+ "px-3 py-1.5 align-top",
4320
+ floorsWords(column) && WORD_FLOOR,
4321
+ stacked?.cell
4322
+ ),
4323
+ children: [
4324
+ stacked && /* @__PURE__ */ jsx(
4325
+ "span",
4326
+ {
4327
+ className: cn(
4328
+ "hidden text-[12px] text-muted-foreground wrap-anywhere",
4329
+ presentation === "app" ? void 0 : "font-mono",
4330
+ stacked.label
4331
+ ),
4332
+ children: canExpand ? columnLabel : /* @__PURE__ */ jsx(Described, { description: column.description, children: columnLabel })
4333
+ }
4334
+ ),
4335
+ /* @__PURE__ */ jsx(
4336
+ "div",
4337
+ {
4338
+ className: fits ? column === name ? FIT_NAME : cn(FIT_CELL, clampsInStack(column, name) && "line-clamp-3") : cn(
4339
+ "max-w-[44ch]",
4340
+ column === name ? "max-w-none min-w-[16ch] wrap-anywhere [&>span]:whitespace-normal" : column.kind === "list" && isInlineColumn(column) ? "min-w-[16ch]" : "truncate"
4341
+ ),
4342
+ ...typeof cell === "string" || typeof cell === "number" ? { title: cellTitle(column, cell, presentation) } : {},
4343
+ children: /* @__PURE__ */ jsx(ResultAt, { segment: column.name, children: /* @__PURE__ */ jsx(LeafValue, { field: column, value: cell, compact: true }) })
4344
+ }
4345
+ )
4346
+ ]
4347
+ },
4348
+ column.name
4349
+ );
4350
+ })
4351
+ ]
4352
+ }
4353
+ ) }, index);
4354
+ }) })
4355
+ ]
4356
+ }
4357
+ )
4288
4358
  }
4289
4359
  )
4290
4360
  );
@@ -4785,5 +4855,5 @@ function pdfFileName(field, value, baseName) {
4785
4855
  }
4786
4856
 
4787
4857
  export { BooleanField, ConceptPill, DEFAULT_FIELD_STRINGS, DateField, DocumentField, EN_FIELD_STRINGS, EnumField, FIELD_STRINGS_BY_LOCALE, FR_FIELD_STRINGS, FieldDomIdProvider, FieldPresentationProvider, FieldRenderer, FieldShell, FieldStringsProvider, 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, cn, fieldControlClass, fieldStringsFor, humanizeFieldName, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveShareUrl, useResolveUrl, useResolvedUrl };
4788
- //# sourceMappingURL=chunk-LXYSQWZG.js.map
4789
- //# sourceMappingURL=chunk-LXYSQWZG.js.map
4858
+ //# sourceMappingURL=chunk-YY3JI6VI.js.map
4859
+ //# sourceMappingURL=chunk-YY3JI6VI.js.map