@pipelex/mthds-form 0.25.0 → 0.27.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/dist/{chunk-QWHUUMSB.js → chunk-4VAO6BDE.js} +4 -4
- package/dist/{chunk-QWHUUMSB.js.map → chunk-4VAO6BDE.js.map} +1 -1
- package/dist/{chunk-QINLJ5RM.js → chunk-56WECFBD.js} +6 -3
- package/dist/chunk-56WECFBD.js.map +1 -0
- package/dist/{chunk-NA7SIQOH.js → chunk-AZIUFSIQ.js} +692 -100
- package/dist/chunk-AZIUFSIQ.js.map +1 -0
- package/dist/{chunk-JSPF4BQP.js → chunk-QQK6Y55E.js} +96 -3
- package/dist/chunk-QQK6Y55E.js.map +1 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +3 -3
- package/dist/core/native-content.d.ts +103 -1
- package/dist/core/native-content.js +1 -1
- package/dist/core/save-plan.js +3 -3
- package/dist/core/stuff-files.js +2 -2
- package/dist/generative/index.js +4 -4
- package/dist/react/index.d.ts +118 -3
- package/dist/react/index.js +4 -4
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-JSPF4BQP.js.map +0 -1
- package/dist/chunk-NA7SIQOH.js.map +0 -1
- package/dist/chunk-QINLJ5RM.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { planFileSave, planStuffSave, splitFileName, typedFileStem } from './chunk-
|
|
1
|
+
import { planFileSave, planStuffSave, splitFileName, typedFileStem } from './chunk-4VAO6BDE.js';
|
|
2
2
|
import { seedInputs, closeOptionalStructures, openOptionalStructures } from './chunk-VH5CDQDR.js';
|
|
3
3
|
import { sourceFileValue, roomForChosenFiles, roomForDroppedFiles, addChosenFiles, placeDroppedFiles, chosenFilesAdded } from './chunk-NSHGLM6A.js';
|
|
4
|
-
import { readStuffFile } from './chunk-
|
|
4
|
+
import { readStuffFile } from './chunk-56WECFBD.js';
|
|
5
5
|
import { apiInputsFromRunValues, sameRunValues, runValuesFromInputs, setValueAtPath } from './chunk-ZX52CQJ4.js';
|
|
6
|
-
import { TYPED_SCALAR_MARKERS, viewableUrl, isNativeDateNode, isNativeHtmlNode, readHtmlContent, isNativeCompositeNode, readCompositeContent, isNativePageNode, nativeVerdictOf, isNativeValueNode, readDateContent, formatDateContent, readPageContent, readYesNoContent, readRatingContent, readChoiceContent, readImageContent, readDataUrl,
|
|
6
|
+
import { TYPED_SCALAR_MARKERS, viewableUrl, splitCitations, webHref, isNativeDateNode, isNativeHtmlNode, readHtmlContent, isNativeCompositeNode, readCompositeContent, isNativePageNode, nativeVerdictOf, isNativeSearchResultNode, readSearchResultContent, isNativeValueNode, readDateContent, formatDateContent, readPageContent, readYesNoContent, readRatingContent, readChoiceContent, readDocumentContent, readImageContent, readDataUrl, citedSource } from './chunk-QQK6Y55E.js';
|
|
7
7
|
import { buildRunFields } from './chunk-ZB4RYUKV.js';
|
|
8
8
|
import { conceptCategory } from './chunk-FABY3DEY.js';
|
|
9
9
|
import { acceptLabel, acceptMap, isAcceptedFile, normalizeMimeType, formatOfFilename, DOCUMENT_FORMATS, IMAGE_FORMATS } from './chunk-XCO6GTEC.js';
|
|
@@ -12,10 +12,10 @@ import { ownProp } from './chunk-V3OV2XQT.js';
|
|
|
12
12
|
import { toStoredDateValue, toDateInputValue } from './chunk-GKV77RAS.js';
|
|
13
13
|
import { clsx } from 'clsx';
|
|
14
14
|
import { twMerge } from 'tailwind-merge';
|
|
15
|
-
import { ChevronDown, ChevronUp, Check, List, Braces, ListChecks, ToggleLeft, Hash, Image as Image$1, FileText, CalendarDays, Type, Folder, Search, X, ImageIcon, Loader2, ImageOff, Upload, Link2, EyeOff, Eye, Minus, Plus, Trash2, Sparkles, MoreHorizontal, TriangleAlert, FileDown, Copy, Download, ChevronRight } from 'lucide-react';
|
|
15
|
+
import { ChevronDown, ChevronUp, Check, List, Braces, ListChecks, ToggleLeft, Hash, Image as Image$1, FileText, CalendarDays, Type, Folder, Search, X, ImageIcon, Loader2, ImageOff, Upload, Link2, EyeOff, Eye, Minus, Plus, Trash2, Sparkles, MoreHorizontal, TriangleAlert, FileDown, Copy, Download, ChevronRight, ExternalLink, ChevronLeft } from 'lucide-react';
|
|
16
16
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
17
|
-
import * as
|
|
18
|
-
import { createContext, use, useId, useMemo, useContext, useState, useEffect, useRef, useLayoutEffect, useCallback, Fragment as Fragment$1 } from 'react';
|
|
17
|
+
import * as React9 from 'react';
|
|
18
|
+
import { createContext, use, useId, useMemo, useContext, useState, useEffect, useRef, useLayoutEffect, useCallback, Fragment as Fragment$1, useSyncExternalStore } from 'react';
|
|
19
19
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
20
20
|
import { useDropzone } from 'react-dropzone';
|
|
21
21
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
@@ -25,6 +25,7 @@ import { cva } from 'class-variance-authority';
|
|
|
25
25
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
26
26
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
27
27
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
28
|
+
import { createPortal } from 'react-dom';
|
|
28
29
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
29
30
|
import { marked } from 'marked';
|
|
30
31
|
|
|
@@ -114,7 +115,7 @@ function fieldLabel(title, name, presentation) {
|
|
|
114
115
|
if (title !== void 0) return title;
|
|
115
116
|
return presentation === "app" ? humanizeFieldName(name) : name;
|
|
116
117
|
}
|
|
117
|
-
var Switch =
|
|
118
|
+
var Switch = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
118
119
|
SwitchPrimitives.Root,
|
|
119
120
|
{
|
|
120
121
|
className: cn(
|
|
@@ -255,6 +256,8 @@ var EN_FIELD_STRINGS = {
|
|
|
255
256
|
preview: "Preview",
|
|
256
257
|
removeFileAria: "Remove file",
|
|
257
258
|
previewUnavailablePdf: "Preview unavailable - open to view.",
|
|
259
|
+
pdfViewerUnavailable: "This browser cannot show the PDF here.",
|
|
260
|
+
openInNewTab: "Open in a new tab",
|
|
258
261
|
// U+002D HYPHEN-MINUS, deliberately: not an en dash, not an em dash.
|
|
259
262
|
resultAbsent: "-",
|
|
260
263
|
resultAbsentDescription: "Not provided",
|
|
@@ -287,6 +290,12 @@ var EN_FIELD_STRINGS = {
|
|
|
287
290
|
ratingLevel: (position) => `Level ${position}`,
|
|
288
291
|
pageNumber: (position) => `Page ${position}`,
|
|
289
292
|
extractedTable: "Table",
|
|
293
|
+
searchSources: "Sources",
|
|
294
|
+
viewImage: (name) => `View ${name}`,
|
|
295
|
+
imagePosition: (position, count) => `${position} of ${count}`,
|
|
296
|
+
previousImage: "Previous picture",
|
|
297
|
+
nextImage: "Next picture",
|
|
298
|
+
openOriginal: "Open the original",
|
|
290
299
|
unsupportedFileType: (formats) => `That file type is not supported. Accepted formats: ${formats}.`,
|
|
291
300
|
dropFilesOrBrowse: "Drop files or click to browse",
|
|
292
301
|
dropFilesToAdd: "Drop to add the files",
|
|
@@ -431,6 +440,8 @@ var FR_FIELD_STRINGS = {
|
|
|
431
440
|
preview: "Aper\xE7u",
|
|
432
441
|
removeFileAria: "Retirer le fichier",
|
|
433
442
|
previewUnavailablePdf: "Aper\xE7u indisponible - ouvrez le fichier pour le consulter.",
|
|
443
|
+
pdfViewerUnavailable: "Ce navigateur ne peut pas afficher le PDF ici.",
|
|
444
|
+
openInNewTab: "Ouvrir dans un nouvel onglet",
|
|
434
445
|
// U+002D HYPHEN-MINUS, as in the English defaults.
|
|
435
446
|
resultAbsent: "-",
|
|
436
447
|
resultAbsentDescription: "Non renseign\xE9",
|
|
@@ -463,6 +474,12 @@ var FR_FIELD_STRINGS = {
|
|
|
463
474
|
ratingLevel: (position) => `Niveau ${position}`,
|
|
464
475
|
pageNumber: (position) => `Page ${position}`,
|
|
465
476
|
extractedTable: "Tableau",
|
|
477
|
+
searchSources: "Sources",
|
|
478
|
+
viewImage: (name) => `Voir ${name}`,
|
|
479
|
+
imagePosition: (position, count) => `${position} sur ${count}`,
|
|
480
|
+
previousImage: "Image pr\xE9c\xE9dente",
|
|
481
|
+
nextImage: "Image suivante",
|
|
482
|
+
openOriginal: "Ouvrir l\u2019original",
|
|
466
483
|
unsupportedFileType: (formats) => `Ce type de fichier n\u2019est pas pris en charge. Formats accept\xE9s\xA0: ${formats}.`,
|
|
467
484
|
dropFilesOrBrowse: "D\xE9posez des fichiers ou cliquez pour parcourir",
|
|
468
485
|
dropFilesToAdd: "D\xE9posez pour ajouter les fichiers",
|
|
@@ -841,7 +858,11 @@ function closeAutoFocus(onCloseAutoFocus, returnFocus) {
|
|
|
841
858
|
target.focus();
|
|
842
859
|
};
|
|
843
860
|
}
|
|
844
|
-
var
|
|
861
|
+
var keepPress = (event) => event.stopPropagation();
|
|
862
|
+
function DialogSurface({ children }) {
|
|
863
|
+
return /* @__PURE__ */ jsx("div", { className: "contents", onClick: keepPress, onMouseDown: keepPress, children });
|
|
864
|
+
}
|
|
865
|
+
var DialogOverlay = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
845
866
|
DialogPrimitive.Overlay,
|
|
846
867
|
{
|
|
847
868
|
ref,
|
|
@@ -850,7 +871,7 @@ var DialogOverlay = React5.forwardRef(({ className, ...props }, ref) => /* @__PU
|
|
|
850
871
|
}
|
|
851
872
|
));
|
|
852
873
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
853
|
-
var DialogContent =
|
|
874
|
+
var DialogContent = React9.forwardRef(({ className, layout = "dialog", returnFocus, onCloseAutoFocus, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogSurface, { children: [
|
|
854
875
|
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
855
876
|
/* @__PURE__ */ jsx(
|
|
856
877
|
DialogPrimitive.Content,
|
|
@@ -871,7 +892,7 @@ var DialogContent = React5.forwardRef(({ className, layout = "dialog", returnFoc
|
|
|
871
892
|
)
|
|
872
893
|
] }));
|
|
873
894
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
874
|
-
var DialogTitle =
|
|
895
|
+
var DialogTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
875
896
|
DialogPrimitive.Title,
|
|
876
897
|
{
|
|
877
898
|
ref,
|
|
@@ -880,7 +901,7 @@ var DialogTitle = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
880
901
|
}
|
|
881
902
|
));
|
|
882
903
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
883
|
-
var DialogDescription =
|
|
904
|
+
var DialogDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
884
905
|
DialogPrimitive.Description,
|
|
885
906
|
{
|
|
886
907
|
ref,
|
|
@@ -912,7 +933,7 @@ var toggleVariants = cva(
|
|
|
912
933
|
}
|
|
913
934
|
}
|
|
914
935
|
);
|
|
915
|
-
var Toggle =
|
|
936
|
+
var Toggle = React9.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
916
937
|
TogglePrimitive.Root,
|
|
917
938
|
{
|
|
918
939
|
ref,
|
|
@@ -921,11 +942,11 @@ var Toggle = React5.forwardRef(({ className, variant, size, ...props }, ref) =>
|
|
|
921
942
|
}
|
|
922
943
|
));
|
|
923
944
|
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
924
|
-
var ToggleGroupContext =
|
|
945
|
+
var ToggleGroupContext = React9.createContext({
|
|
925
946
|
size: "default",
|
|
926
947
|
variant: "default"
|
|
927
948
|
});
|
|
928
|
-
var ToggleGroup =
|
|
949
|
+
var ToggleGroup = React9.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
929
950
|
ToggleGroupPrimitive.Root,
|
|
930
951
|
{
|
|
931
952
|
ref,
|
|
@@ -935,8 +956,8 @@ var ToggleGroup = React5.forwardRef(({ className, variant, size, children, ...pr
|
|
|
935
956
|
}
|
|
936
957
|
));
|
|
937
958
|
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
938
|
-
var ToggleGroupItem =
|
|
939
|
-
const context =
|
|
959
|
+
var ToggleGroupItem = React9.forwardRef(({ className, children, variant, size, ...props }, ref) => {
|
|
960
|
+
const context = React9.useContext(ToggleGroupContext);
|
|
940
961
|
return /* @__PURE__ */ jsx(
|
|
941
962
|
ToggleGroupPrimitive.Item,
|
|
942
963
|
{
|
|
@@ -1005,7 +1026,6 @@ function FilePicker({
|
|
|
1005
1026
|
onCloseAutoFocus,
|
|
1006
1027
|
returnFocus: () => returnFocusTo?.current ?? heldFocus.current,
|
|
1007
1028
|
style: drag > 0 ? { transform: `translateY(${drag}px)` } : void 0,
|
|
1008
|
-
onClick: (event) => event.stopPropagation(),
|
|
1009
1029
|
children: /* @__PURE__ */ jsx(FilePickerBody, { ...props, onDrag: setDrag, onClose: () => onOpenChange(false) })
|
|
1010
1030
|
}
|
|
1011
1031
|
) });
|
|
@@ -1046,7 +1066,7 @@ function FilePickerBody({
|
|
|
1046
1066
|
return next;
|
|
1047
1067
|
});
|
|
1048
1068
|
const choices = [...chosen.values()];
|
|
1049
|
-
const
|
|
1069
|
+
const use8 = () => {
|
|
1050
1070
|
if (choices.length === 0) return;
|
|
1051
1071
|
onUse(choices);
|
|
1052
1072
|
onClose();
|
|
@@ -1151,7 +1171,7 @@ function FilePickerBody({
|
|
|
1151
1171
|
"button",
|
|
1152
1172
|
{
|
|
1153
1173
|
type: "button",
|
|
1154
|
-
onClick:
|
|
1174
|
+
onClick: use8,
|
|
1155
1175
|
disabled: choices.length === 0,
|
|
1156
1176
|
className: cn(
|
|
1157
1177
|
"flex h-12 w-full items-center justify-center rounded-md bg-primary px-4 text-[16px] font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",
|
|
@@ -1848,7 +1868,7 @@ function ClearButton({ disabled, onClick }) {
|
|
|
1848
1868
|
}
|
|
1849
1869
|
var Select = SelectPrimitive.Root;
|
|
1850
1870
|
var SelectValue = SelectPrimitive.Value;
|
|
1851
|
-
var SelectTrigger =
|
|
1871
|
+
var SelectTrigger = React9.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
1852
1872
|
SelectPrimitive.Trigger,
|
|
1853
1873
|
{
|
|
1854
1874
|
ref,
|
|
@@ -1867,7 +1887,7 @@ var SelectTrigger = React5.forwardRef(({ className, children, ...props }, ref) =
|
|
|
1867
1887
|
}
|
|
1868
1888
|
));
|
|
1869
1889
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
1870
|
-
var SelectScrollUpButton =
|
|
1890
|
+
var SelectScrollUpButton = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1871
1891
|
SelectPrimitive.ScrollUpButton,
|
|
1872
1892
|
{
|
|
1873
1893
|
ref,
|
|
@@ -1877,7 +1897,7 @@ var SelectScrollUpButton = React5.forwardRef(({ className, ...props }, ref) => /
|
|
|
1877
1897
|
}
|
|
1878
1898
|
));
|
|
1879
1899
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
1880
|
-
var SelectScrollDownButton =
|
|
1900
|
+
var SelectScrollDownButton = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1881
1901
|
SelectPrimitive.ScrollDownButton,
|
|
1882
1902
|
{
|
|
1883
1903
|
ref,
|
|
@@ -1887,7 +1907,7 @@ var SelectScrollDownButton = React5.forwardRef(({ className, ...props }, ref) =>
|
|
|
1887
1907
|
}
|
|
1888
1908
|
));
|
|
1889
1909
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
1890
|
-
var SelectContent =
|
|
1910
|
+
var SelectContent = React9.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
1891
1911
|
SelectPrimitive.Content,
|
|
1892
1912
|
{
|
|
1893
1913
|
ref,
|
|
@@ -1915,7 +1935,7 @@ var SelectContent = React5.forwardRef(({ className, children, position = "popper
|
|
|
1915
1935
|
}
|
|
1916
1936
|
) }));
|
|
1917
1937
|
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
1918
|
-
var SelectLabel =
|
|
1938
|
+
var SelectLabel = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1919
1939
|
SelectPrimitive.Label,
|
|
1920
1940
|
{
|
|
1921
1941
|
ref,
|
|
@@ -1924,7 +1944,7 @@ var SelectLabel = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
1924
1944
|
}
|
|
1925
1945
|
));
|
|
1926
1946
|
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
1927
|
-
var SelectItem =
|
|
1947
|
+
var SelectItem = React9.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
1928
1948
|
SelectPrimitive.Item,
|
|
1929
1949
|
{
|
|
1930
1950
|
ref,
|
|
@@ -1940,7 +1960,7 @@ var SelectItem = React5.forwardRef(({ className, children, ...props }, ref) => /
|
|
|
1940
1960
|
}
|
|
1941
1961
|
));
|
|
1942
1962
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
1943
|
-
var SelectSeparator =
|
|
1963
|
+
var SelectSeparator = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1944
1964
|
SelectPrimitive.Separator,
|
|
1945
1965
|
{
|
|
1946
1966
|
ref,
|
|
@@ -2909,7 +2929,7 @@ function FieldRenderer({ field, value, onChange, id, error, env }) {
|
|
|
2909
2929
|
}
|
|
2910
2930
|
}
|
|
2911
2931
|
var AlertDialog = AlertDialogPrimitive.Root;
|
|
2912
|
-
var AlertDialogContent =
|
|
2932
|
+
var AlertDialogContent = React9.forwardRef(({ className, returnFocus, onCloseAutoFocus, ...props }, ref) => /* @__PURE__ */ jsxs(DialogSurface, { children: [
|
|
2913
2933
|
/* @__PURE__ */ jsx(AlertDialogPrimitive.Overlay, { className: "fixed inset-0 z-50 bg-black/50" }),
|
|
2914
2934
|
/* @__PURE__ */ jsx(
|
|
2915
2935
|
AlertDialogPrimitive.Content,
|
|
@@ -2925,7 +2945,7 @@ var AlertDialogContent = React5.forwardRef(({ className, returnFocus, onCloseAut
|
|
|
2925
2945
|
)
|
|
2926
2946
|
] }));
|
|
2927
2947
|
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
2928
|
-
var AlertDialogTitle =
|
|
2948
|
+
var AlertDialogTitle = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2929
2949
|
AlertDialogPrimitive.Title,
|
|
2930
2950
|
{
|
|
2931
2951
|
ref,
|
|
@@ -2934,7 +2954,7 @@ var AlertDialogTitle = React5.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
2934
2954
|
}
|
|
2935
2955
|
));
|
|
2936
2956
|
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
2937
|
-
var AlertDialogDescription =
|
|
2957
|
+
var AlertDialogDescription = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2938
2958
|
AlertDialogPrimitive.Description,
|
|
2939
2959
|
{
|
|
2940
2960
|
ref,
|
|
@@ -2947,7 +2967,7 @@ var AlertDialogCancel = AlertDialogPrimitive.Cancel;
|
|
|
2947
2967
|
var AlertDialogAction = AlertDialogPrimitive.Action;
|
|
2948
2968
|
var DropdownMenu = DropdownMenuPrimitive.Root;
|
|
2949
2969
|
var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
2950
|
-
var DropdownMenuContent =
|
|
2970
|
+
var DropdownMenuContent = React9.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2951
2971
|
DropdownMenuPrimitive.Content,
|
|
2952
2972
|
{
|
|
2953
2973
|
ref,
|
|
@@ -2960,7 +2980,7 @@ var DropdownMenuContent = React5.forwardRef(({ className, sideOffset = 4, ...pro
|
|
|
2960
2980
|
}
|
|
2961
2981
|
));
|
|
2962
2982
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
2963
|
-
var DropdownMenuItem =
|
|
2983
|
+
var DropdownMenuItem = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2964
2984
|
DropdownMenuPrimitive.Item,
|
|
2965
2985
|
{
|
|
2966
2986
|
ref,
|
|
@@ -3091,7 +3111,6 @@ function FillWithExample({
|
|
|
3091
3111
|
className: "top-auto max-h-[calc(100dvh-1.5rem)]",
|
|
3092
3112
|
ref: sheet,
|
|
3093
3113
|
returnFocus: () => control.current ?? afterControl.current,
|
|
3094
|
-
onClick: (event) => event.stopPropagation(),
|
|
3095
3114
|
children: [
|
|
3096
3115
|
/* @__PURE__ */ jsx("div", { className: "px-4 pt-4 pb-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
3097
3116
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1 pt-1", children: [
|
|
@@ -3176,7 +3195,6 @@ function FillWithExample({
|
|
|
3176
3195
|
const row = rows.current.get(replacing.id);
|
|
3177
3196
|
return row?.isConnected ? row : control.current;
|
|
3178
3197
|
},
|
|
3179
|
-
onClick: (event) => event.stopPropagation(),
|
|
3180
3198
|
children: [
|
|
3181
3199
|
/* @__PURE__ */ jsx(AlertDialogTitle, { children: s.replaceEnteredTitle }),
|
|
3182
3200
|
/* @__PURE__ */ jsx(AlertDialogDescription, { children: s.replaceEnteredDescription(replacing.name) }),
|
|
@@ -3267,7 +3285,7 @@ function RenameExampleDialog({
|
|
|
3267
3285
|
onOpenChange: (next) => {
|
|
3268
3286
|
if (!next && state !== "busy") onCancel();
|
|
3269
3287
|
},
|
|
3270
|
-
children: /* @__PURE__ */ jsxs(DialogContent, { returnFocus,
|
|
3288
|
+
children: /* @__PURE__ */ jsxs(DialogContent, { returnFocus, children: [
|
|
3271
3289
|
/* @__PURE__ */ jsx(DialogTitle, { children: s.renameExampleTitle }),
|
|
3272
3290
|
/* @__PURE__ */ jsx(DialogDescription, { className: "sr-only", children: example.name }),
|
|
3273
3291
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
@@ -3346,7 +3364,7 @@ function DeleteExampleDialog({
|
|
|
3346
3364
|
onOpenChange: (next) => {
|
|
3347
3365
|
if (!next && state !== "busy") onCancel();
|
|
3348
3366
|
},
|
|
3349
|
-
children: /* @__PURE__ */ jsxs(AlertDialogContent, { returnFocus,
|
|
3367
|
+
children: /* @__PURE__ */ jsxs(AlertDialogContent, { returnFocus, children: [
|
|
3350
3368
|
/* @__PURE__ */ jsx(AlertDialogTitle, { children: s.deleteExampleTitle(example.name) }),
|
|
3351
3369
|
/* @__PURE__ */ jsx(AlertDialogDescription, { children: s.deleteExampleDescription }),
|
|
3352
3370
|
state === "failed" && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-[13px] text-destructive", children: s.deleteFailed }),
|
|
@@ -4098,6 +4116,7 @@ var ResultEnvContext = createContext({});
|
|
|
4098
4116
|
function ResultEnvProvider({
|
|
4099
4117
|
resolveUrl,
|
|
4100
4118
|
resolveUrls,
|
|
4119
|
+
resolveRendition,
|
|
4101
4120
|
resolveShareUrl,
|
|
4102
4121
|
proseImages,
|
|
4103
4122
|
tableColumns,
|
|
@@ -4111,6 +4130,7 @@ function ResultEnvProvider({
|
|
|
4111
4130
|
() => ({
|
|
4112
4131
|
resolveUrl,
|
|
4113
4132
|
resolveUrls,
|
|
4133
|
+
resolveRendition,
|
|
4114
4134
|
resolveShareUrl,
|
|
4115
4135
|
proseImages,
|
|
4116
4136
|
tableColumns,
|
|
@@ -4122,6 +4142,7 @@ function ResultEnvProvider({
|
|
|
4122
4142
|
[
|
|
4123
4143
|
resolveUrl,
|
|
4124
4144
|
resolveUrls,
|
|
4145
|
+
resolveRendition,
|
|
4125
4146
|
resolveShareUrl,
|
|
4126
4147
|
proseImages,
|
|
4127
4148
|
tableColumns,
|
|
@@ -4171,6 +4192,9 @@ function useMarkupResolvers() {
|
|
|
4171
4192
|
const { resolveUrl, resolveUrls } = use(ResultEnvContext);
|
|
4172
4193
|
return useMemo(() => ({ resolveUrl, resolveUrls }), [resolveUrl, resolveUrls]);
|
|
4173
4194
|
}
|
|
4195
|
+
function useResolveRendition() {
|
|
4196
|
+
return use(ResultEnvContext).resolveRendition;
|
|
4197
|
+
}
|
|
4174
4198
|
function useResolveShareUrl() {
|
|
4175
4199
|
return use(ResultEnvContext).resolveShareUrl;
|
|
4176
4200
|
}
|
|
@@ -4226,6 +4250,34 @@ function useTableColumns() {
|
|
|
4226
4250
|
function useTableLayout() {
|
|
4227
4251
|
return use(ResultEnvContext).tableLayout ?? "scroll";
|
|
4228
4252
|
}
|
|
4253
|
+
var OverlayLayerContext = createContext(null);
|
|
4254
|
+
function OverlayLayer({ children }) {
|
|
4255
|
+
const outer = use(OverlayLayerContext);
|
|
4256
|
+
const [holders, setHolders] = useState(0);
|
|
4257
|
+
const [target, setTarget] = useState(null);
|
|
4258
|
+
const acquire = useCallback(() => {
|
|
4259
|
+
setHolders((count) => count + 1);
|
|
4260
|
+
let released = false;
|
|
4261
|
+
return () => {
|
|
4262
|
+
if (released) return;
|
|
4263
|
+
released = true;
|
|
4264
|
+
setHolders((count) => count - 1);
|
|
4265
|
+
};
|
|
4266
|
+
}, []);
|
|
4267
|
+
const layer = useMemo(() => ({ target, acquire }), [target, acquire]);
|
|
4268
|
+
if (outer) return children;
|
|
4269
|
+
return /* @__PURE__ */ jsxs(OverlayLayerContext, { value: layer, children: [
|
|
4270
|
+
holders > 0 && /* @__PURE__ */ jsx("span", { ref: setTarget, "data-overlay-layer": true, className: "absolute size-0" }),
|
|
4271
|
+
children
|
|
4272
|
+
] });
|
|
4273
|
+
}
|
|
4274
|
+
function InOverlayLayer({ children }) {
|
|
4275
|
+
const layer = use(OverlayLayerContext);
|
|
4276
|
+
const acquire = layer?.acquire;
|
|
4277
|
+
useEffect(() => acquire?.(), [acquire]);
|
|
4278
|
+
if (!layer) return children;
|
|
4279
|
+
return layer.target ? createPortal(children, layer.target) : null;
|
|
4280
|
+
}
|
|
4229
4281
|
var ResultLocationContext = createContext(void 0);
|
|
4230
4282
|
function useResultLocation() {
|
|
4231
4283
|
return use(ResultLocationContext);
|
|
@@ -4237,7 +4289,7 @@ function ResultRoot({
|
|
|
4237
4289
|
}) {
|
|
4238
4290
|
const key = path.join("\0");
|
|
4239
4291
|
const location = useMemo(() => ({ baseName, path: key.split("\0") }), [baseName, key]);
|
|
4240
|
-
return /* @__PURE__ */ jsx(ResultLocationContext, { value: location, children });
|
|
4292
|
+
return /* @__PURE__ */ jsx(ResultLocationContext, { value: location, children: /* @__PURE__ */ jsx(OverlayLayer, { children }) });
|
|
4241
4293
|
}
|
|
4242
4294
|
function ResultAt({ segment, children }) {
|
|
4243
4295
|
const parent = use(ResultLocationContext);
|
|
@@ -4324,10 +4376,21 @@ function useFrameFocus(frame) {
|
|
|
4324
4376
|
}, [frame]);
|
|
4325
4377
|
return focused;
|
|
4326
4378
|
}
|
|
4379
|
+
var subscribe = () => () => {
|
|
4380
|
+
};
|
|
4381
|
+
function browserViewer() {
|
|
4382
|
+
return navigator.pdfViewerEnabled === false ? "no" : "yes";
|
|
4383
|
+
}
|
|
4384
|
+
function serverViewer() {
|
|
4385
|
+
return "unknown";
|
|
4386
|
+
}
|
|
4387
|
+
function usePdfViewer() {
|
|
4388
|
+
return useSyncExternalStore(subscribe, browserViewer, serverViewer);
|
|
4389
|
+
}
|
|
4327
4390
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
4328
4391
|
var TooltipRoot = TooltipPrimitive.Root;
|
|
4329
4392
|
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
4330
|
-
var TooltipContent =
|
|
4393
|
+
var TooltipContent = React9.forwardRef(({ className, sideOffset = 6, ...props }, ref) => /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
4331
4394
|
TooltipPrimitive.Content,
|
|
4332
4395
|
{
|
|
4333
4396
|
ref,
|
|
@@ -5317,14 +5380,240 @@ function useResolvedMarkup(markup) {
|
|
|
5317
5380
|
if (!needed) return markup;
|
|
5318
5381
|
return shown?.source === markup ? shown.html : void 0;
|
|
5319
5382
|
}
|
|
5383
|
+
var SWIPE_DISTANCE = 40;
|
|
5384
|
+
function ImageViewer({
|
|
5385
|
+
pictures,
|
|
5386
|
+
index,
|
|
5387
|
+
onIndexChange,
|
|
5388
|
+
onClose,
|
|
5389
|
+
returnFocus
|
|
5390
|
+
}) {
|
|
5391
|
+
const s = useFieldStrings();
|
|
5392
|
+
const panel = useRef(null);
|
|
5393
|
+
const swipe = useRef(null);
|
|
5394
|
+
const count = pictures.length;
|
|
5395
|
+
const at = Math.min(Math.max(index, 0), count - 1);
|
|
5396
|
+
const picture = pictures[at];
|
|
5397
|
+
if (!picture) return null;
|
|
5398
|
+
const several = count > 1;
|
|
5399
|
+
const go = (step) => {
|
|
5400
|
+
const next = at + step;
|
|
5401
|
+
if (next >= 0 && next < count) onIndexChange(next);
|
|
5402
|
+
};
|
|
5403
|
+
const onPointerDown = (event) => {
|
|
5404
|
+
swipe.current = event.pointerType === "touch" && event.isPrimary ? { id: event.pointerId, x: event.clientX, y: event.clientY } : null;
|
|
5405
|
+
};
|
|
5406
|
+
const onPointerUp = (event) => {
|
|
5407
|
+
const start = swipe.current;
|
|
5408
|
+
swipe.current = null;
|
|
5409
|
+
if (!start || start.id !== event.pointerId) return;
|
|
5410
|
+
const across = event.clientX - start.x;
|
|
5411
|
+
const down = event.clientY - start.y;
|
|
5412
|
+
if (Math.abs(across) < SWIPE_DISTANCE || Math.abs(across) < Math.abs(down) * 1.5) return;
|
|
5413
|
+
go(across < 0 ? 1 : -1);
|
|
5414
|
+
};
|
|
5415
|
+
return /* @__PURE__ */ jsx(InOverlayLayer, { children: /* @__PURE__ */ jsx(
|
|
5416
|
+
Dialog,
|
|
5417
|
+
{
|
|
5418
|
+
open: true,
|
|
5419
|
+
onOpenChange: (open) => {
|
|
5420
|
+
if (!open) onClose();
|
|
5421
|
+
},
|
|
5422
|
+
children: /* @__PURE__ */ jsxs(
|
|
5423
|
+
DialogContent,
|
|
5424
|
+
{
|
|
5425
|
+
ref: panel,
|
|
5426
|
+
returnFocus,
|
|
5427
|
+
onOpenAutoFocus: (event) => {
|
|
5428
|
+
event.preventDefault();
|
|
5429
|
+
panel.current?.focus();
|
|
5430
|
+
},
|
|
5431
|
+
onEscapeKeyDown: (event) => {
|
|
5432
|
+
if (event.target instanceof Element && event.target.closest("[data-file-name-backdrop]")) {
|
|
5433
|
+
event.preventDefault();
|
|
5434
|
+
}
|
|
5435
|
+
},
|
|
5436
|
+
onKeyDown: (event) => {
|
|
5437
|
+
if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
|
|
5438
|
+
return;
|
|
5439
|
+
}
|
|
5440
|
+
if (isTextEntry(event.target)) return;
|
|
5441
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
5442
|
+
event.preventDefault();
|
|
5443
|
+
event.stopPropagation();
|
|
5444
|
+
go(event.key === "ArrowLeft" ? -1 : 1);
|
|
5445
|
+
},
|
|
5446
|
+
...picture.caption ? {} : { "aria-describedby": void 0 },
|
|
5447
|
+
className: cn(
|
|
5448
|
+
"m-0 h-dvh w-full max-w-none gap-0 rounded-none border-0 p-0",
|
|
5449
|
+
"sm:m-auto sm:h-[calc(100dvh-4rem)] sm:w-[calc(100%-4rem)] sm:max-w-6xl sm:rounded-xl sm:border"
|
|
5450
|
+
),
|
|
5451
|
+
children: [
|
|
5452
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2 border-b border-border py-1.5 pr-1.5 pl-4", children: [
|
|
5453
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
5454
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "truncate text-[14px] font-medium", children: picture.name }),
|
|
5455
|
+
several && // A live region from the moment the viewer opens, so each move
|
|
5456
|
+
// is announced: one inserted with its text already in it is not.
|
|
5457
|
+
/* @__PURE__ */ jsx(
|
|
5458
|
+
"p",
|
|
5459
|
+
{
|
|
5460
|
+
"aria-live": "polite",
|
|
5461
|
+
"aria-atomic": "true",
|
|
5462
|
+
className: "text-[12px] text-muted-foreground",
|
|
5463
|
+
children: s.imagePosition(at + 1, count)
|
|
5464
|
+
}
|
|
5465
|
+
)
|
|
5466
|
+
] }),
|
|
5467
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
5468
|
+
/* @__PURE__ */ jsxs(
|
|
5469
|
+
"a",
|
|
5470
|
+
{
|
|
5471
|
+
href: picture.src,
|
|
5472
|
+
target: "_blank",
|
|
5473
|
+
rel: "noreferrer",
|
|
5474
|
+
className: cn(
|
|
5475
|
+
"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground max-sm:size-11 max-sm:justify-center max-sm:p-0",
|
|
5476
|
+
focusOutlineClass
|
|
5477
|
+
),
|
|
5478
|
+
children: [
|
|
5479
|
+
/* @__PURE__ */ jsx(ExternalLink, { "aria-hidden": true, className: "size-3.5" }),
|
|
5480
|
+
/* @__PURE__ */ jsx("span", { className: "max-sm:sr-only", children: s.openOriginal })
|
|
5481
|
+
]
|
|
5482
|
+
}
|
|
5483
|
+
),
|
|
5484
|
+
picture.actions,
|
|
5485
|
+
/* @__PURE__ */ jsx(
|
|
5486
|
+
DialogClose,
|
|
5487
|
+
{
|
|
5488
|
+
"aria-label": s.close,
|
|
5489
|
+
className: cn(
|
|
5490
|
+
"flex size-9 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground max-sm:size-11",
|
|
5491
|
+
focusOutlineClass
|
|
5492
|
+
),
|
|
5493
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "size-4" })
|
|
5494
|
+
}
|
|
5495
|
+
)
|
|
5496
|
+
] })
|
|
5497
|
+
] }),
|
|
5498
|
+
/* @__PURE__ */ jsxs(
|
|
5499
|
+
"div",
|
|
5500
|
+
{
|
|
5501
|
+
"data-viewer-stage": true,
|
|
5502
|
+
onPointerDown,
|
|
5503
|
+
onPointerUp,
|
|
5504
|
+
onPointerCancel: () => {
|
|
5505
|
+
swipe.current = null;
|
|
5506
|
+
},
|
|
5507
|
+
className: "relative min-h-0 flex-1 touch-pan-y touch-pinch-zoom",
|
|
5508
|
+
children: [
|
|
5509
|
+
/* @__PURE__ */ jsx(
|
|
5510
|
+
ViewerImage,
|
|
5511
|
+
{
|
|
5512
|
+
src: picture.src,
|
|
5513
|
+
alt: picture.caption ?? picture.name
|
|
5514
|
+
},
|
|
5515
|
+
picture.src
|
|
5516
|
+
),
|
|
5517
|
+
several && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5518
|
+
/* @__PURE__ */ jsx(
|
|
5519
|
+
StepButton2,
|
|
5520
|
+
{
|
|
5521
|
+
label: s.previousImage,
|
|
5522
|
+
unavailable: at === 0,
|
|
5523
|
+
onStep: () => go(-1),
|
|
5524
|
+
className: "left-2",
|
|
5525
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": true, className: "size-5" })
|
|
5526
|
+
}
|
|
5527
|
+
),
|
|
5528
|
+
/* @__PURE__ */ jsx(
|
|
5529
|
+
StepButton2,
|
|
5530
|
+
{
|
|
5531
|
+
label: s.nextImage,
|
|
5532
|
+
unavailable: at === count - 1,
|
|
5533
|
+
onStep: () => go(1),
|
|
5534
|
+
className: "right-2",
|
|
5535
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-5" })
|
|
5536
|
+
}
|
|
5537
|
+
)
|
|
5538
|
+
] })
|
|
5539
|
+
]
|
|
5540
|
+
}
|
|
5541
|
+
),
|
|
5542
|
+
picture.caption && /* @__PURE__ */ jsx(DialogDescription, { className: "max-h-24 shrink-0 overflow-y-auto border-t border-border px-4 py-2 text-[13px]", children: picture.caption })
|
|
5543
|
+
]
|
|
5544
|
+
}
|
|
5545
|
+
)
|
|
5546
|
+
}
|
|
5547
|
+
) });
|
|
5548
|
+
}
|
|
5549
|
+
function ViewerImage({ src, alt }) {
|
|
5550
|
+
const [loading, setLoading] = useState(true);
|
|
5551
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5552
|
+
loading && /* @__PURE__ */ jsx(
|
|
5553
|
+
"span",
|
|
5554
|
+
{
|
|
5555
|
+
role: "status",
|
|
5556
|
+
"aria-label": alt,
|
|
5557
|
+
className: "absolute inset-0 flex items-center justify-center",
|
|
5558
|
+
children: /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: "size-5 animate-spin text-muted-foreground" })
|
|
5559
|
+
}
|
|
5560
|
+
),
|
|
5561
|
+
/* @__PURE__ */ jsx(
|
|
5562
|
+
"img",
|
|
5563
|
+
{
|
|
5564
|
+
src,
|
|
5565
|
+
alt,
|
|
5566
|
+
referrerPolicy: "no-referrer",
|
|
5567
|
+
decoding: "async",
|
|
5568
|
+
draggable: false,
|
|
5569
|
+
onLoad: () => setLoading(false),
|
|
5570
|
+
onError: () => setLoading(false),
|
|
5571
|
+
className: cn(
|
|
5572
|
+
"absolute inset-0 size-full object-contain p-2 sm:p-4",
|
|
5573
|
+
loading && "opacity-0"
|
|
5574
|
+
)
|
|
5575
|
+
}
|
|
5576
|
+
)
|
|
5577
|
+
] });
|
|
5578
|
+
}
|
|
5579
|
+
function StepButton2({
|
|
5580
|
+
label,
|
|
5581
|
+
unavailable,
|
|
5582
|
+
onStep,
|
|
5583
|
+
className,
|
|
5584
|
+
children
|
|
5585
|
+
}) {
|
|
5586
|
+
return /* @__PURE__ */ jsx(
|
|
5587
|
+
"button",
|
|
5588
|
+
{
|
|
5589
|
+
type: "button",
|
|
5590
|
+
"aria-label": label,
|
|
5591
|
+
"aria-disabled": unavailable,
|
|
5592
|
+
onClick: () => {
|
|
5593
|
+
if (!unavailable) onStep();
|
|
5594
|
+
},
|
|
5595
|
+
className: cn(
|
|
5596
|
+
"absolute top-1/2 flex size-11 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-popover/90 text-foreground shadow-sm hover:bg-muted aria-disabled:opacity-40 aria-disabled:hover:bg-popover/90",
|
|
5597
|
+
focusOutlineClass,
|
|
5598
|
+
className
|
|
5599
|
+
),
|
|
5600
|
+
children
|
|
5601
|
+
}
|
|
5602
|
+
);
|
|
5603
|
+
}
|
|
5604
|
+
function isTextEntry(target) {
|
|
5605
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
5606
|
+
return target.isContentEditable || target.closest("input, textarea, select") !== null;
|
|
5607
|
+
}
|
|
5320
5608
|
var LEX_OPTIONS = { gfm: true, breaks: true };
|
|
5321
|
-
function Markdown({ text, className, proseImages }) {
|
|
5322
|
-
const tokens =
|
|
5609
|
+
function Markdown({ text, className, proseImages, citations }) {
|
|
5610
|
+
const tokens = React9.useMemo(() => marked.lexer(text, LEX_OPTIONS), [text]);
|
|
5323
5611
|
const fromEnv = useProseImages();
|
|
5324
5612
|
const mode = proseImages ?? fromEnv;
|
|
5325
|
-
return /* @__PURE__ */ jsx(ProseImagesContext, { value: mode, children: /* @__PURE__ */ jsx("div", { className: cn("space-y-2 text-[13px] leading-relaxed text-foreground", className), children: /* @__PURE__ */ jsx(Blocks, { tokens }) }) });
|
|
5613
|
+
return /* @__PURE__ */ jsx(ProseImagesContext, { value: mode, children: /* @__PURE__ */ jsx(CitationsContext, { value: citations, children: /* @__PURE__ */ jsx("div", { className: cn("space-y-2 text-[13px] leading-relaxed text-foreground", className), children: /* @__PURE__ */ jsx(Blocks, { tokens }) }) }) });
|
|
5326
5614
|
}
|
|
5327
|
-
var ProseImagesContext =
|
|
5615
|
+
var ProseImagesContext = React9.createContext("link");
|
|
5616
|
+
var CitationsContext = React9.createContext(void 0);
|
|
5328
5617
|
var HEADING_CLASS = {
|
|
5329
5618
|
1: "text-[16px] font-semibold",
|
|
5330
5619
|
2: "text-[14.5px] font-semibold",
|
|
@@ -5441,7 +5730,7 @@ function InlineToken({ token }) {
|
|
|
5441
5730
|
switch (token.type) {
|
|
5442
5731
|
case "text": {
|
|
5443
5732
|
const text = token;
|
|
5444
|
-
return text.tokens ? /* @__PURE__ */ jsx(Inline, { tokens: text.tokens }) : /* @__PURE__ */ jsx(
|
|
5733
|
+
return text.tokens ? /* @__PURE__ */ jsx(Inline, { tokens: text.tokens }) : /* @__PURE__ */ jsx(CitedText, { text: decode(text.text) });
|
|
5445
5734
|
}
|
|
5446
5735
|
case "escape":
|
|
5447
5736
|
return /* @__PURE__ */ jsx(Fragment, { children: token.text });
|
|
@@ -5458,7 +5747,9 @@ function InlineToken({ token }) {
|
|
|
5458
5747
|
case "link": {
|
|
5459
5748
|
const link = token;
|
|
5460
5749
|
const href = safeHref(link.href);
|
|
5461
|
-
if (!href)
|
|
5750
|
+
if (!href) {
|
|
5751
|
+
return /* @__PURE__ */ jsx(CitationsContext, { value: void 0, children: /* @__PURE__ */ jsx(Inline, { tokens: link.tokens }) });
|
|
5752
|
+
}
|
|
5462
5753
|
return (
|
|
5463
5754
|
// The flag is set for everything under the anchor, so a nested `image`
|
|
5464
5755
|
// token knows not to open one of its own — see {@link ProseImage}.
|
|
@@ -5480,9 +5771,34 @@ function InlineToken({ token }) {
|
|
|
5480
5771
|
return /* @__PURE__ */ jsx(Fragment, { children: rawOf(token) });
|
|
5481
5772
|
}
|
|
5482
5773
|
}
|
|
5774
|
+
function CitedText({ text }) {
|
|
5775
|
+
const citations = React9.use(CitationsContext);
|
|
5776
|
+
const insideLink = React9.use(InsideLinkContext);
|
|
5777
|
+
if (!citations || insideLink) return /* @__PURE__ */ jsx(Fragment, { children: text });
|
|
5778
|
+
return /* @__PURE__ */ jsx(Fragment, { children: splitCitations(text).map((segment, index) => {
|
|
5779
|
+
const target = "citation" in segment ? citations(segment.citation) : void 0;
|
|
5780
|
+
const href = target ? webHref(target.href) : void 0;
|
|
5781
|
+
if (!target || !href) return /* @__PURE__ */ jsx(React9.Fragment, { children: segment.text }, index);
|
|
5782
|
+
return /* @__PURE__ */ jsx(
|
|
5783
|
+
"a",
|
|
5784
|
+
{
|
|
5785
|
+
href,
|
|
5786
|
+
target: "_blank",
|
|
5787
|
+
rel: "noopener noreferrer",
|
|
5788
|
+
title: target.label,
|
|
5789
|
+
className: cn(
|
|
5790
|
+
"mx-px whitespace-nowrap rounded-sm underline underline-offset-2",
|
|
5791
|
+
focusOutlineClass
|
|
5792
|
+
),
|
|
5793
|
+
children: segment.text
|
|
5794
|
+
},
|
|
5795
|
+
index
|
|
5796
|
+
);
|
|
5797
|
+
}) });
|
|
5798
|
+
}
|
|
5483
5799
|
function ProseImage({ token }) {
|
|
5484
|
-
const mode =
|
|
5485
|
-
const insideLink =
|
|
5800
|
+
const mode = React9.use(ProseImagesContext);
|
|
5801
|
+
const insideLink = React9.use(InsideLinkContext);
|
|
5486
5802
|
const src = proseImageUrl(token.href);
|
|
5487
5803
|
if (!src) return /* @__PURE__ */ jsx(Fragment, { children: token.text });
|
|
5488
5804
|
if (mode === "load") {
|
|
@@ -5508,7 +5824,7 @@ function ProseImage({ token }) {
|
|
|
5508
5824
|
}
|
|
5509
5825
|
);
|
|
5510
5826
|
}
|
|
5511
|
-
var InsideLinkContext =
|
|
5827
|
+
var InsideLinkContext = React9.createContext(false);
|
|
5512
5828
|
function proseImageUrl(href) {
|
|
5513
5829
|
const url = viewableUrl(href);
|
|
5514
5830
|
return url && /^https?:/.test(url) ? url : void 0;
|
|
@@ -6359,6 +6675,7 @@ function pathLabel(url) {
|
|
|
6359
6675
|
return segment && segment.length > 0 ? segment : url;
|
|
6360
6676
|
}
|
|
6361
6677
|
var FILE_BUTTON_ON_A_PHONE = "max-sm:grid max-sm:size-11 max-sm:place-items-center";
|
|
6678
|
+
var CARD_ACTION = "inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[12px] hover:bg-card max-sm:min-h-11 max-sm:px-3";
|
|
6362
6679
|
function CopyButton({
|
|
6363
6680
|
value,
|
|
6364
6681
|
provide,
|
|
@@ -6473,7 +6790,7 @@ function useStuffFile(kind, value) {
|
|
|
6473
6790
|
const location = useResultLocation();
|
|
6474
6791
|
return location ? readStuffFile(kind, value, location.path.join(".")) : void 0;
|
|
6475
6792
|
}
|
|
6476
|
-
function FileDownloadButton({ file }) {
|
|
6793
|
+
function FileDownloadButton({ file, labelled = false }) {
|
|
6477
6794
|
const s = useFieldStrings();
|
|
6478
6795
|
const location = useResultLocation();
|
|
6479
6796
|
const resolve = useResolveUrl();
|
|
@@ -6502,7 +6819,7 @@ ${planned.url ?? planned.text}`;
|
|
|
6502
6819
|
const failed = state === "failed";
|
|
6503
6820
|
const label = s.downloadFile(planned.name);
|
|
6504
6821
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6505
|
-
/* @__PURE__ */
|
|
6822
|
+
/* @__PURE__ */ jsxs(
|
|
6506
6823
|
"button",
|
|
6507
6824
|
{
|
|
6508
6825
|
type: "button",
|
|
@@ -6521,12 +6838,17 @@ ${planned.url ?? planned.text}`;
|
|
|
6521
6838
|
title: failed ? s.downloadFileFailed : label,
|
|
6522
6839
|
...failed ? { "aria-describedby": statusId } : {},
|
|
6523
6840
|
className: cn(
|
|
6524
|
-
|
|
6841
|
+
labelled ? cn(CARD_ACTION, "disabled:opacity-60") : cn(
|
|
6842
|
+
"shrink-0 rounded p-0.5 hover:bg-card disabled:opacity-60",
|
|
6843
|
+
FILE_BUTTON_ON_A_PHONE
|
|
6844
|
+
),
|
|
6525
6845
|
focusOutlineClass,
|
|
6526
|
-
FILE_BUTTON_ON_A_PHONE,
|
|
6527
6846
|
failed ? "text-destructive" : "text-muted-foreground hover:text-foreground"
|
|
6528
6847
|
),
|
|
6529
|
-
children:
|
|
6848
|
+
children: [
|
|
6849
|
+
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" }),
|
|
6850
|
+
labelled && s.download
|
|
6851
|
+
]
|
|
6530
6852
|
}
|
|
6531
6853
|
),
|
|
6532
6854
|
/* @__PURE__ */ jsx("span", { id: statusId, role: "status", className: "sr-only", children: failed ? s.downloadFileFailed : "" }),
|
|
@@ -6556,7 +6878,32 @@ function previewableUrl(content, resolve) {
|
|
|
6556
6878
|
const renderable = content.mimeType ? PREVIEWABLE_MIME_RE.test(content.mimeType) : PREVIEWABLE_EXT_RE.test(named);
|
|
6557
6879
|
return renderable ? url : void 0;
|
|
6558
6880
|
}
|
|
6559
|
-
function
|
|
6881
|
+
function isPdfDocument(content, url) {
|
|
6882
|
+
return content.mimeType ? /^application\/pdf\s*(;|$)/i.test(content.mimeType) : /\.pdf(\?|#|$)/i.test(content.filename ?? url);
|
|
6883
|
+
}
|
|
6884
|
+
function DocumentPreview({
|
|
6885
|
+
url,
|
|
6886
|
+
name,
|
|
6887
|
+
pdf,
|
|
6888
|
+
file,
|
|
6889
|
+
whole
|
|
6890
|
+
}) {
|
|
6891
|
+
const viewer = usePdfViewer();
|
|
6892
|
+
const size = whole ? WHOLE_RESULT_FRAME : NESTED_FRAME;
|
|
6893
|
+
if (pdf && viewer === "no") return /* @__PURE__ */ jsx(PdfUnavailable, { url, name, file });
|
|
6894
|
+
if (pdf && viewer === "unknown") {
|
|
6895
|
+
return /* @__PURE__ */ jsx(
|
|
6896
|
+
"div",
|
|
6897
|
+
{
|
|
6898
|
+
"aria-hidden": true,
|
|
6899
|
+
className: cn(
|
|
6900
|
+
size,
|
|
6901
|
+
"flex items-center justify-center rounded-lg border border-border bg-card/40"
|
|
6902
|
+
),
|
|
6903
|
+
children: /* @__PURE__ */ jsx(Loader2, { className: "size-4 animate-spin text-muted-foreground" })
|
|
6904
|
+
}
|
|
6905
|
+
);
|
|
6906
|
+
}
|
|
6560
6907
|
return /* @__PURE__ */ jsx(
|
|
6561
6908
|
FocusFrame,
|
|
6562
6909
|
{
|
|
@@ -6564,19 +6911,56 @@ function DocumentPreview({ url, name }) {
|
|
|
6564
6911
|
title: name,
|
|
6565
6912
|
loading: "lazy",
|
|
6566
6913
|
referrerPolicy: "no-referrer",
|
|
6567
|
-
className: "
|
|
6914
|
+
className: cn(size, "rounded-lg border border-border bg-card/40")
|
|
6568
6915
|
}
|
|
6569
6916
|
);
|
|
6570
6917
|
}
|
|
6571
|
-
|
|
6918
|
+
var NESTED_FRAME = "h-112 w-full";
|
|
6919
|
+
var WHOLE_RESULT_FRAME = "aspect-[1/1.414] max-h-[80vh] min-h-80 w-full";
|
|
6920
|
+
function PdfUnavailable({
|
|
6921
|
+
url,
|
|
6922
|
+
name,
|
|
6923
|
+
file
|
|
6924
|
+
}) {
|
|
6925
|
+
const s = useFieldStrings();
|
|
6926
|
+
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: [
|
|
6927
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-2.5", children: [
|
|
6928
|
+
/* @__PURE__ */ jsx(FileText, { "aria-hidden": true, className: "mt-0.5 size-4 shrink-0 text-muted-foreground" }),
|
|
6929
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 space-y-0.5", children: [
|
|
6930
|
+
/* @__PURE__ */ jsx("p", { title: name, className: "truncate text-[13px] font-medium text-foreground", children: name }),
|
|
6931
|
+
/* @__PURE__ */ jsx("p", { className: "text-[12.5px] leading-relaxed text-muted-foreground", children: s.pdfViewerUnavailable })
|
|
6932
|
+
] })
|
|
6933
|
+
] }),
|
|
6934
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
6935
|
+
/* @__PURE__ */ jsxs(
|
|
6936
|
+
"a",
|
|
6937
|
+
{
|
|
6938
|
+
href: url,
|
|
6939
|
+
target: "_blank",
|
|
6940
|
+
rel: "noreferrer",
|
|
6941
|
+
className: cn(CARD_ACTION, "text-foreground", focusOutlineClass),
|
|
6942
|
+
children: [
|
|
6943
|
+
/* @__PURE__ */ jsx(ExternalLink, { "aria-hidden": true, className: "size-3.5" }),
|
|
6944
|
+
s.openInNewTab
|
|
6945
|
+
]
|
|
6946
|
+
}
|
|
6947
|
+
),
|
|
6948
|
+
file && /* @__PURE__ */ jsx(FileDownloadButton, { file, labelled: true })
|
|
6949
|
+
] })
|
|
6950
|
+
] });
|
|
6951
|
+
}
|
|
6952
|
+
function DocumentValue({ value, whole = false }) {
|
|
6572
6953
|
const s = useFieldStrings();
|
|
6573
6954
|
const resolve = useResolveUrl();
|
|
6955
|
+
const isApp = useFieldPresentation() === "app";
|
|
6574
6956
|
const [open, setOpen] = useState(false);
|
|
6575
6957
|
const file = useStuffFile("document", value);
|
|
6576
6958
|
const content = readDocumentContent(value);
|
|
6577
6959
|
if (!content) return /* @__PURE__ */ jsx(Absent, {});
|
|
6578
6960
|
const name = content.title ?? content.filename ?? fileLabel(content.url, content.filename, s);
|
|
6579
6961
|
const preview = previewableUrl(content, resolve);
|
|
6962
|
+
const pdf = preview !== void 0 && isPdfDocument(content, preview);
|
|
6963
|
+
const opened = whole && isApp && pdf;
|
|
6580
6964
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
6581
6965
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-start gap-2.5", children: [
|
|
6582
6966
|
/* @__PURE__ */ jsx(FileText, { "aria-hidden": true, className: "mt-0.5 size-4 shrink-0 text-muted-foreground" }),
|
|
@@ -6594,7 +6978,7 @@ function DocumentValue({ value }) {
|
|
|
6594
6978
|
),
|
|
6595
6979
|
content.snippet && /* @__PURE__ */ jsx("p", { className: "line-clamp-2 text-[12px] leading-relaxed text-muted-foreground", children: content.snippet })
|
|
6596
6980
|
] }),
|
|
6597
|
-
preview && /* @__PURE__ */ jsxs(
|
|
6981
|
+
preview && !opened && /* @__PURE__ */ jsxs(
|
|
6598
6982
|
"button",
|
|
6599
6983
|
{
|
|
6600
6984
|
type: "button",
|
|
@@ -6611,58 +6995,98 @@ function DocumentValue({ value }) {
|
|
|
6611
6995
|
}
|
|
6612
6996
|
)
|
|
6613
6997
|
] }),
|
|
6614
|
-
preview && open && /* @__PURE__ */ jsx(DocumentPreview, { url: preview, name })
|
|
6998
|
+
preview && (opened || open) && /* @__PURE__ */ jsx(DocumentPreview, { url: preview, name, pdf, file, whole: opened })
|
|
6615
6999
|
] });
|
|
6616
7000
|
}
|
|
7001
|
+
var TILE_RENDITION_SIDE = 576;
|
|
7002
|
+
var CELL_RENDITION_HEIGHT = 80;
|
|
7003
|
+
var CELL_RENDITION_WIDTH = 256;
|
|
7004
|
+
function renditionWidth(place, content) {
|
|
7005
|
+
const { width, height } = content;
|
|
7006
|
+
const ratio = width !== void 0 && height !== void 0 && width > 0 && height > 0 ? width / height : void 0;
|
|
7007
|
+
if (place === "tile") {
|
|
7008
|
+
return ratio === void 0 ? TILE_RENDITION_SIDE : Math.ceil(TILE_RENDITION_SIDE * Math.max(1, ratio));
|
|
7009
|
+
}
|
|
7010
|
+
return ratio === void 0 ? CELL_RENDITION_WIDTH : Math.max(CELL_RENDITION_WIDTH, Math.ceil(CELL_RENDITION_HEIGHT * ratio));
|
|
7011
|
+
}
|
|
7012
|
+
function renditionUrl(content, whole, resolveRendition, width) {
|
|
7013
|
+
return viewableUrl(resolveRendition?.(content.url, { width })) ?? whole;
|
|
7014
|
+
}
|
|
6617
7015
|
function ImageValue({
|
|
6618
7016
|
value,
|
|
6619
7017
|
inGallery = false,
|
|
6620
7018
|
inRow = false,
|
|
6621
7019
|
compact = false,
|
|
6622
|
-
downloadable = true
|
|
7020
|
+
downloadable = true,
|
|
7021
|
+
opener
|
|
6623
7022
|
}) {
|
|
6624
7023
|
const s = useFieldStrings();
|
|
7024
|
+
const presentation = useFieldPresentation();
|
|
6625
7025
|
const resolve = useResolveUrl();
|
|
7026
|
+
const resolveRendition = useResolveRendition();
|
|
6626
7027
|
const stuffFile = useStuffFile("image", value);
|
|
6627
7028
|
const file = downloadable ? stuffFile : void 0;
|
|
7029
|
+
const [viewing, setViewing] = useState(false);
|
|
7030
|
+
const ownButton = useRef(null);
|
|
7031
|
+
const frame = useRef(null);
|
|
6628
7032
|
const content = readImageContent(value);
|
|
7033
|
+
const src = content ? paintableUrl(content, resolve) : void 0;
|
|
7034
|
+
if (viewing && src === void 0) setViewing(false);
|
|
6629
7035
|
if (!content) return /* @__PURE__ */ jsx(Absent, {});
|
|
6630
|
-
const
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
7036
|
+
const place = inGallery ? "tile" : compact ? "cell" : void 0;
|
|
7037
|
+
const drawn = src !== void 0 && place !== void 0 ? renditionUrl(content, src, resolveRendition, renditionWidth(place, content)) : src;
|
|
7038
|
+
const name = src === void 0 ? "" : fileLabel(src, content.filename, s);
|
|
7039
|
+
const fileLine = src !== void 0 && !compact && !(inGallery && presentation === "app");
|
|
7040
|
+
const size = !inGallery && !compact && content.width && content.height ? { width: content.width, height: content.height } : void 0;
|
|
7041
|
+
return /* @__PURE__ */ jsxs("div", { ref: frame, className: inGallery ? "space-y-1" : "space-y-1.5", children: [
|
|
7042
|
+
src !== void 0 && drawn !== void 0 ? (
|
|
7043
|
+
// A button, not a link: the picture opens in the viewer over the
|
|
7044
|
+
// result. Enter and Space open it as a click does.
|
|
6637
7045
|
/* @__PURE__ */ jsx(
|
|
6638
|
-
"
|
|
7046
|
+
"button",
|
|
6639
7047
|
{
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
7048
|
+
ref: opener ? opener.ref : ownButton,
|
|
7049
|
+
type: "button",
|
|
7050
|
+
onClick: opener ? opener.open : () => setViewing(true),
|
|
7051
|
+
"aria-label": s.viewImage(name),
|
|
7052
|
+
"aria-haspopup": "dialog",
|
|
6644
7053
|
className: cn(
|
|
6645
|
-
|
|
7054
|
+
// BLOCK when the picture fills its column. A table cell's
|
|
7055
|
+
// thumbnail sizes itself, and is 44px square at the least below
|
|
7056
|
+
// `sm`, where it is tapped.
|
|
7057
|
+
compact ? "inline-flex items-center justify-center align-top max-sm:min-h-11 max-sm:min-w-11" : "block w-full",
|
|
7058
|
+
"cursor-zoom-in",
|
|
6646
7059
|
focusOutlineInsetClass
|
|
6647
7060
|
),
|
|
6648
7061
|
children: /* @__PURE__ */ jsx(
|
|
6649
7062
|
LoadingImage,
|
|
6650
7063
|
{
|
|
6651
|
-
src,
|
|
7064
|
+
src: drawn,
|
|
7065
|
+
...drawn !== src ? { fallbackSrc: src } : {},
|
|
6652
7066
|
alt: content.caption ?? s.preview,
|
|
7067
|
+
lazy: inGallery || compact,
|
|
7068
|
+
...size ? { size } : {},
|
|
7069
|
+
...inGallery ? (
|
|
7070
|
+
// The tile's box is square before anything arrives, and the
|
|
7071
|
+
// picture covers it once it does: tiles of one size, whatever
|
|
7072
|
+
// the pictures' shapes, and nothing moves when one lands.
|
|
7073
|
+
{ box: "aspect-square w-full overflow-hidden" }
|
|
7074
|
+
) : compact ? { box: "h-10 min-w-10" } : {},
|
|
6653
7075
|
className: cn(
|
|
6654
|
-
inGallery && "
|
|
6655
|
-
// A cell is one line tall. An image column rendered at the
|
|
6656
|
-
// height turns every row into a picture and the
|
|
6657
|
-
// slideshow, so a cell gets a thumbnail and the
|
|
6658
|
-
// the picture.
|
|
7076
|
+
inGallery && "absolute inset-0 size-full object-cover",
|
|
7077
|
+
// A cell is one line tall. An image column rendered at the
|
|
7078
|
+
// standalone height turns every row into a picture and the
|
|
7079
|
+
// table into a slideshow, so a cell gets a thumbnail and the
|
|
7080
|
+
// row's expansion gets the picture.
|
|
6659
7081
|
compact && "h-10 w-auto rounded border border-border object-cover",
|
|
6660
7082
|
// On its own: the full width it is given, capped generously in
|
|
6661
7083
|
// height. `max-h-64` was a 256px thumbnail in a panel several
|
|
6662
7084
|
// times that tall — a generated report image is the RESULT here,
|
|
6663
|
-
// not a decoration beside one, and it was unreadable at that
|
|
6664
|
-
// `object-contain` keeps the aspect ratio when the cap
|
|
6665
|
-
|
|
7085
|
+
// not a decoration beside one, and it was unreadable at that
|
|
7086
|
+
// size. `object-contain` keeps the aspect ratio when the cap
|
|
7087
|
+
// bites, and the payload's own width and height, when it states
|
|
7088
|
+
// them, reserve the box before the picture arrives.
|
|
7089
|
+
!inGallery && !compact && "h-auto max-h-176 w-full rounded-lg border border-border object-contain"
|
|
6666
7090
|
)
|
|
6667
7091
|
}
|
|
6668
7092
|
)
|
|
@@ -6708,7 +7132,7 @@ function ImageValue({
|
|
|
6708
7132
|
file
|
|
6709
7133
|
}
|
|
6710
7134
|
),
|
|
6711
|
-
|
|
7135
|
+
fileLine && /* @__PURE__ */ jsx("div", { className: inGallery ? "px-2.5" : void 0, children: /* @__PURE__ */ jsx(
|
|
6712
7136
|
FileRef,
|
|
6713
7137
|
{
|
|
6714
7138
|
url: src,
|
|
@@ -6727,6 +7151,24 @@ function ImageValue({
|
|
|
6727
7151
|
),
|
|
6728
7152
|
children: content.caption
|
|
6729
7153
|
}
|
|
7154
|
+
),
|
|
7155
|
+
viewing && src !== void 0 && /* @__PURE__ */ jsx(
|
|
7156
|
+
ImageViewer,
|
|
7157
|
+
{
|
|
7158
|
+
pictures: [
|
|
7159
|
+
{
|
|
7160
|
+
src,
|
|
7161
|
+
name,
|
|
7162
|
+
...content.caption ? { caption: content.caption } : {},
|
|
7163
|
+
actions: /* @__PURE__ */ jsx(FileActions, { copy: { url: src, storageUrl: content.url }, file })
|
|
7164
|
+
}
|
|
7165
|
+
],
|
|
7166
|
+
index: 0,
|
|
7167
|
+
onIndexChange: () => {
|
|
7168
|
+
},
|
|
7169
|
+
onClose: () => setViewing(false),
|
|
7170
|
+
returnFocus: () => ownButton.current ?? frame.current?.querySelector("a[href], button")
|
|
7171
|
+
}
|
|
6730
7172
|
)
|
|
6731
7173
|
] });
|
|
6732
7174
|
}
|
|
@@ -6776,32 +7218,59 @@ function RecordSummary({ field, value }) {
|
|
|
6776
7218
|
}
|
|
6777
7219
|
return /* @__PURE__ */ jsx(LeafValue, { field: naming, value: ownProp(value, naming.name), compact: true });
|
|
6778
7220
|
}
|
|
6779
|
-
function LoadingImage({
|
|
7221
|
+
function LoadingImage({
|
|
7222
|
+
src,
|
|
7223
|
+
fallbackSrc,
|
|
7224
|
+
alt,
|
|
7225
|
+
className,
|
|
7226
|
+
box,
|
|
7227
|
+
size,
|
|
7228
|
+
lazy = false
|
|
7229
|
+
}) {
|
|
6780
7230
|
const [state, setState] = useState("loading");
|
|
6781
|
-
const [current, setCurrent] = useState(src);
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
7231
|
+
const [current, setCurrent] = useState({ src, fallbackSrc });
|
|
7232
|
+
const [shown, setShown] = useState(src);
|
|
7233
|
+
if (current.src !== src || current.fallbackSrc !== fallbackSrc) {
|
|
7234
|
+
const next = current.src !== src ? src : shown === current.fallbackSrc ? fallbackSrc ?? src : shown;
|
|
7235
|
+
setCurrent({ src, fallbackSrc });
|
|
7236
|
+
if (next !== shown) {
|
|
7237
|
+
setShown(next);
|
|
7238
|
+
setState("loading");
|
|
7239
|
+
}
|
|
6785
7240
|
}
|
|
6786
|
-
|
|
7241
|
+
const reserved = box !== void 0 || size !== void 0;
|
|
7242
|
+
return /* @__PURE__ */ jsxs("span", { className: cn("relative block", box), children: [
|
|
6787
7243
|
state === "loading" && /* @__PURE__ */ jsx(
|
|
6788
7244
|
"span",
|
|
6789
7245
|
{
|
|
6790
7246
|
role: "status",
|
|
6791
7247
|
"aria-label": alt,
|
|
6792
|
-
className:
|
|
7248
|
+
className: cn(
|
|
7249
|
+
"absolute inset-0 flex items-center justify-center",
|
|
7250
|
+
// A box the caller drew is the frame; anything else gets one.
|
|
7251
|
+
box ? "bg-muted/40" : "rounded-lg border border-border bg-card/40"
|
|
7252
|
+
),
|
|
6793
7253
|
children: /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: "size-4 animate-spin text-muted-foreground" })
|
|
6794
7254
|
}
|
|
6795
7255
|
),
|
|
6796
7256
|
/* @__PURE__ */ jsx(
|
|
6797
7257
|
"img",
|
|
6798
7258
|
{
|
|
6799
|
-
src,
|
|
7259
|
+
src: shown,
|
|
6800
7260
|
alt,
|
|
6801
7261
|
referrerPolicy: "no-referrer",
|
|
7262
|
+
decoding: "async",
|
|
7263
|
+
...lazy ? { loading: "lazy" } : {},
|
|
7264
|
+
...size ? { width: size.width, height: size.height } : {},
|
|
6802
7265
|
onLoad: () => setState("done"),
|
|
6803
|
-
onError: () =>
|
|
6804
|
-
|
|
7266
|
+
onError: () => {
|
|
7267
|
+
if (fallbackSrc !== void 0 && shown !== fallbackSrc) setShown(fallbackSrc);
|
|
7268
|
+
else setState("done");
|
|
7269
|
+
},
|
|
7270
|
+
className: cn(
|
|
7271
|
+
className,
|
|
7272
|
+
state === "loading" && (reserved ? "opacity-0" : "min-h-40 opacity-0")
|
|
7273
|
+
)
|
|
6805
7274
|
}
|
|
6806
7275
|
)
|
|
6807
7276
|
] });
|
|
@@ -7264,13 +7733,65 @@ function ScalarLines({ field, items }) {
|
|
|
7264
7733
|
return /* @__PURE__ */ jsx("div", { className: "divide-y divide-border/60 overflow-hidden rounded-lg border border-border", children: items.map((item, index) => /* @__PURE__ */ jsx("div", { className: "bg-card/40 px-3 py-1.5", children: /* @__PURE__ */ jsx(LeafValue, { field, value: item }) }, index)) });
|
|
7265
7734
|
}
|
|
7266
7735
|
function ImageGallery({ items }) {
|
|
7736
|
+
const s = useFieldStrings();
|
|
7267
7737
|
const resolve = useResolveUrl();
|
|
7268
|
-
const
|
|
7738
|
+
const [viewing, setViewing] = useState(null);
|
|
7739
|
+
const tiles = useRef(/* @__PURE__ */ new Map());
|
|
7740
|
+
const gallery = useRef(null);
|
|
7741
|
+
const pictures = items.flatMap((item, entry) => {
|
|
7269
7742
|
const content = readImageContent(item);
|
|
7270
|
-
|
|
7743
|
+
const src = content ? paintableUrl(content, resolve) : void 0;
|
|
7744
|
+
return content && src !== void 0 ? [{ entry, item, content, src }] : [];
|
|
7271
7745
|
});
|
|
7272
|
-
|
|
7273
|
-
|
|
7746
|
+
const shown = viewing ? pictures.findIndex((picture) => picture.entry === viewing.entry) : -1;
|
|
7747
|
+
if (viewing && shown === -1) setViewing(null);
|
|
7748
|
+
const returnFocus = (opener) => () => {
|
|
7749
|
+
const first = [...tiles.current.entries()].sort(([a], [b]) => a - b)[0]?.[1];
|
|
7750
|
+
return tiles.current.get(opener) ?? first ?? gallery.current;
|
|
7751
|
+
};
|
|
7752
|
+
const frame = (children) => /* @__PURE__ */ jsx("div", { ref: gallery, tabIndex: -1, className: "outline-none", children });
|
|
7753
|
+
if (pictures.length === 0) return frame(/* @__PURE__ */ jsx(FileRows, { items, kind: "image" }));
|
|
7754
|
+
return frame(
|
|
7755
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7756
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(140px,1fr))] gap-2", children: items.map((item, index) => /* @__PURE__ */ jsx("div", { className: "overflow-hidden rounded-lg border border-border bg-card/40", children: /* @__PURE__ */ jsx(ResultAt, { segment: String(index), children: /* @__PURE__ */ jsx(
|
|
7757
|
+
ImageValue,
|
|
7758
|
+
{
|
|
7759
|
+
value: item,
|
|
7760
|
+
inGallery: true,
|
|
7761
|
+
opener: {
|
|
7762
|
+
open: () => setViewing({ entry: index, opener: index }),
|
|
7763
|
+
ref: (button) => {
|
|
7764
|
+
if (button) tiles.current.set(index, button);
|
|
7765
|
+
else tiles.current.delete(index);
|
|
7766
|
+
}
|
|
7767
|
+
}
|
|
7768
|
+
}
|
|
7769
|
+
) }) }, index)) }),
|
|
7770
|
+
viewing && shown !== -1 && /* @__PURE__ */ jsx(
|
|
7771
|
+
ImageViewer,
|
|
7772
|
+
{
|
|
7773
|
+
pictures: pictures.map(({ entry, item, content, src }) => ({
|
|
7774
|
+
src,
|
|
7775
|
+
name: fileLabel(src, content.filename, s),
|
|
7776
|
+
...content.caption ? { caption: content.caption } : {},
|
|
7777
|
+
actions: /* @__PURE__ */ jsx(ResultAt, { segment: String(entry), children: /* @__PURE__ */ jsx(ViewerFileActions, { value: item, src }) })
|
|
7778
|
+
})),
|
|
7779
|
+
index: shown,
|
|
7780
|
+
onIndexChange: (position) => {
|
|
7781
|
+
const picture = pictures[position];
|
|
7782
|
+
if (picture) setViewing({ entry: picture.entry, opener: viewing.opener });
|
|
7783
|
+
},
|
|
7784
|
+
onClose: () => setViewing(null),
|
|
7785
|
+
returnFocus: returnFocus(viewing.opener)
|
|
7786
|
+
}
|
|
7787
|
+
)
|
|
7788
|
+
] })
|
|
7789
|
+
);
|
|
7790
|
+
}
|
|
7791
|
+
function ViewerFileActions({ value, src }) {
|
|
7792
|
+
const file = useStuffFile("image", value);
|
|
7793
|
+
const content = readImageContent(value);
|
|
7794
|
+
return /* @__PURE__ */ jsx(FileActions, { copy: { url: src, ...content ? { storageUrl: content.url } : {} }, file });
|
|
7274
7795
|
}
|
|
7275
7796
|
function FileRows({ items, kind }) {
|
|
7276
7797
|
return /* @__PURE__ */ jsx("div", { className: "divide-y divide-border overflow-hidden rounded-lg border border-border", children: items.map((item, index) => /* @__PURE__ */ jsx("div", { className: "bg-card/40 px-3.5 py-2", children: /* @__PURE__ */ jsx(ResultAt, { segment: String(index), children: kind === "document" ? /* @__PURE__ */ jsx(DocumentValue, { value: item }) : /* @__PURE__ */ jsx(ImageValue, { value: item, inRow: true }) }) }, index)) });
|
|
@@ -7373,6 +7894,64 @@ function VerdictValue({ reading, prominent }) {
|
|
|
7373
7894
|
reading.measure !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-[12.5px] text-muted-foreground", children: reading.measure })
|
|
7374
7895
|
] });
|
|
7375
7896
|
}
|
|
7897
|
+
function SearchResultValue({ content }) {
|
|
7898
|
+
const s = useFieldStrings();
|
|
7899
|
+
const headingId = useId();
|
|
7900
|
+
const citations = (citation) => {
|
|
7901
|
+
const source = citedSource(content, citation);
|
|
7902
|
+
return source?.href ? { href: source.href, label: source.title ?? source.address } : void 0;
|
|
7903
|
+
};
|
|
7904
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7905
|
+
content.answer.trim() === "" ? /* @__PURE__ */ jsx(Absent, {}) : /* @__PURE__ */ jsx(Markdown, { text: content.answer, citations }),
|
|
7906
|
+
content.sources.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
7907
|
+
/* @__PURE__ */ jsx("p", { id: headingId, className: "text-[12px] font-medium text-muted-foreground", children: s.searchSources }),
|
|
7908
|
+
/* @__PURE__ */ jsx(
|
|
7909
|
+
"ul",
|
|
7910
|
+
{
|
|
7911
|
+
"aria-labelledby": headingId,
|
|
7912
|
+
className: "grid grid-cols-[max-content_minmax(0,1fr)] gap-x-2 gap-y-1",
|
|
7913
|
+
children: content.sources.map((source) => /* @__PURE__ */ jsxs(
|
|
7914
|
+
"li",
|
|
7915
|
+
{
|
|
7916
|
+
className: "col-span-2 grid grid-cols-subgrid items-baseline",
|
|
7917
|
+
children: [
|
|
7918
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-[11px] tabular-nums text-muted-foreground", children: source.citations.map((citation) => `[${citation}]`).join("") }),
|
|
7919
|
+
/* @__PURE__ */ jsx(SearchSource, { source })
|
|
7920
|
+
]
|
|
7921
|
+
},
|
|
7922
|
+
source.citations[0]
|
|
7923
|
+
))
|
|
7924
|
+
}
|
|
7925
|
+
)
|
|
7926
|
+
] })
|
|
7927
|
+
] });
|
|
7928
|
+
}
|
|
7929
|
+
function SearchSource({ source }) {
|
|
7930
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7931
|
+
/* @__PURE__ */ jsx(
|
|
7932
|
+
"span",
|
|
7933
|
+
{
|
|
7934
|
+
className: cn(
|
|
7935
|
+
"text-[13px] leading-5 wrap-anywhere text-foreground",
|
|
7936
|
+
source.href && "underline underline-offset-2"
|
|
7937
|
+
),
|
|
7938
|
+
children: source.title ?? source.address
|
|
7939
|
+
}
|
|
7940
|
+
),
|
|
7941
|
+
source.host && /* @__PURE__ */ jsx("span", { className: "block text-[12px] leading-4 text-muted-foreground wrap-anywhere", children: source.host })
|
|
7942
|
+
] });
|
|
7943
|
+
if (!source.href) return /* @__PURE__ */ jsx("div", { className: "min-w-0", children: body });
|
|
7944
|
+
return /* @__PURE__ */ jsx(
|
|
7945
|
+
"a",
|
|
7946
|
+
{
|
|
7947
|
+
href: source.href,
|
|
7948
|
+
target: "_blank",
|
|
7949
|
+
rel: "noopener noreferrer",
|
|
7950
|
+
className: cn("block min-w-0 rounded-sm max-sm:py-1.5", focusOutlineClass),
|
|
7951
|
+
children: body
|
|
7952
|
+
}
|
|
7953
|
+
);
|
|
7954
|
+
}
|
|
7376
7955
|
function isLongText(value) {
|
|
7377
7956
|
return typeof value === "string" && (value.includes("\n") || value.length > CELL_LENGTH_LIMIT);
|
|
7378
7957
|
}
|
|
@@ -7457,6 +8036,16 @@ function ResultNode({
|
|
|
7457
8036
|
/* @__PURE__ */ jsx(VerdictValue, { reading, prominent: whole })
|
|
7458
8037
|
] });
|
|
7459
8038
|
}
|
|
8039
|
+
const search = isApp && isNativeSearchResultNode(field) ? readSearchResultContent(unwrapped) : void 0;
|
|
8040
|
+
if (search) {
|
|
8041
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
8042
|
+
search.answer.trim() === "" ? header : /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
8043
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: header }),
|
|
8044
|
+
/* @__PURE__ */ jsx(CopyButton, { value: search.answer, label: s.copyText })
|
|
8045
|
+
] }),
|
|
8046
|
+
/* @__PURE__ */ jsx(SearchResultValue, { content: search })
|
|
8047
|
+
] });
|
|
8048
|
+
}
|
|
7460
8049
|
switch (field.kind) {
|
|
7461
8050
|
case "object": {
|
|
7462
8051
|
const memberValue = (child) => typeof unwrapped === "object" && unwrapped !== null ? ownProp(unwrapped, child.name) : void 0;
|
|
@@ -7542,9 +8131,12 @@ function ResultNode({
|
|
|
7542
8131
|
) : isApp && nativeVerdictOf(field.item) ? (
|
|
7543
8132
|
// Verdicts in `app`, one per line, each drawn by the verdict arm.
|
|
7544
8133
|
/* @__PURE__ */ jsx("div", { className: "divide-y divide-border/60 overflow-hidden rounded-lg border border-border", children: items.map((item, index) => /* @__PURE__ */ jsx("div", { className: "bg-card/40 px-3 py-1.5", children: /* @__PURE__ */ jsx(ResultAt, { segment: String(index), children: /* @__PURE__ */ jsx(ResultField, { field: field.item, value: item, depth: depth + 1, hideLabel: true }) }) }, index)) })
|
|
7545
|
-
) : columns ? (
|
|
8134
|
+
) : columns && !(isApp && isNativeSearchResultNode(field.item)) ? (
|
|
7546
8135
|
// Same shape every row: the labels are column headers, not per-row
|
|
7547
|
-
// labels. See `ObjectTable`.
|
|
8136
|
+
// labels. See `ObjectTable`. A list of search results in `app` is
|
|
8137
|
+
// the exception: a row would hide each answer's citations and its
|
|
8138
|
+
// sources until it is opened, so each search takes a card of its
|
|
8139
|
+
// own below and is drawn by the search arm. `studio` keeps the table.
|
|
7548
8140
|
/* @__PURE__ */ jsx(
|
|
7549
8141
|
ObjectTable,
|
|
7550
8142
|
{
|
|
@@ -7598,7 +8190,7 @@ function ResultNode({
|
|
|
7598
8190
|
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: header }),
|
|
7599
8191
|
/* @__PURE__ */ jsx(CopyButton, { value: copyText, label: s.copyText })
|
|
7600
8192
|
] }),
|
|
7601
|
-
isApp && field.kind === "text" && isLongText(unwrapped) ? /* @__PURE__ */ jsx(Markdown, { text: unwrapped }) : /* @__PURE__ */ jsx(LeafValue, { field, value })
|
|
8193
|
+
isApp && field.kind === "text" && isLongText(unwrapped) ? /* @__PURE__ */ jsx(Markdown, { text: unwrapped }) : field.kind === "document" && whole ? /* @__PURE__ */ jsx(DocumentValue, { value: unwrapped, whole: true }) : /* @__PURE__ */ jsx(LeafValue, { field, value })
|
|
7602
8194
|
] });
|
|
7603
8195
|
}
|
|
7604
8196
|
return null;
|
|
@@ -7859,6 +8451,6 @@ function pdfFileName(field, value, baseName) {
|
|
|
7859
8451
|
return name === void 0 ? "" : name.replace(/\.[^.]+$/, "");
|
|
7860
8452
|
}
|
|
7861
8453
|
|
|
7862
|
-
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, checkedAccentClass, cn, fieldControlClass, fieldStringsFor, focusOutlineClass, humanizeFieldName, linkTextClass, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, selectedBorderClass, selectedFillClass, selectedFillStrongClass, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveShareUrl, useResolveUrl, useResolvedUrl };
|
|
7863
|
-
//# sourceMappingURL=chunk-
|
|
7864
|
-
//# sourceMappingURL=chunk-
|
|
8454
|
+
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, checkedAccentClass, cn, fieldControlClass, fieldStringsFor, focusOutlineClass, humanizeFieldName, linkTextClass, renderHtmlPdf, resolveHtmlStorageUrls, saveInBrowser, selectedBorderClass, selectedFillClass, selectedFillStrongClass, useFieldDomId, useFieldPresentation, useFieldStrings, useMethodForm, useProseImages, useResolveRendition, useResolveShareUrl, useResolveUrl, useResolvedUrl };
|
|
8455
|
+
//# sourceMappingURL=chunk-AZIUFSIQ.js.map
|
|
8456
|
+
//# sourceMappingURL=chunk-AZIUFSIQ.js.map
|