@sanity/vision 6.4.0-workbench.20260701093415 → 6.4.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.
|
@@ -4,7 +4,8 @@ import { useTranslation, useKeyValueStore, useClient, useCurrentUser, useDateTim
|
|
|
4
4
|
import { Spinner, rem, useTheme, Flex, Box, Label, Card, useTheme_v2, Text, Tooltip, useToast, Stack, TextInput, MenuButton, Menu, MenuItem, Code, Badge, Button, Dialog, Tab, TabList, Hotkeys, useClickOutsideEvent, Popover, Inline, Grid, Select, Container, Heading } from "@sanity/ui";
|
|
5
5
|
import { useState, useEffect, forwardRef, useRef, useImperativeHandle, Fragment, useEffectEvent, Component } from "react";
|
|
6
6
|
import { SplitPane } from "@rexxars/react-split-pane";
|
|
7
|
-
import {
|
|
7
|
+
import { ChevronLeftIcon } from "@sanity/icons/ChevronLeft";
|
|
8
|
+
import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
|
|
8
9
|
import { isHotkey } from "is-hotkey-esm";
|
|
9
10
|
import { closeBrackets } from "@codemirror/autocomplete";
|
|
10
11
|
import { history, defaultKeymap, historyKeymap } from "@codemirror/commands";
|
|
@@ -18,15 +19,28 @@ import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
|
18
19
|
import { tags } from "@lezer/highlight";
|
|
19
20
|
import { hues } from "@sanity/color";
|
|
20
21
|
import { visionLocaleNamespace } from "./index.js";
|
|
22
|
+
import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
|
|
21
23
|
import debounce from "lodash-es/debounce.js";
|
|
22
24
|
import JSON5 from "json5";
|
|
25
|
+
import { AddIcon } from "@sanity/icons/Add";
|
|
26
|
+
import { LockIcon } from "@sanity/icons/Lock";
|
|
27
|
+
import { SearchIcon } from "@sanity/icons/Search";
|
|
28
|
+
import { TrashIcon } from "@sanity/icons/Trash";
|
|
29
|
+
import { UnpublishIcon } from "@sanity/icons/Unpublish";
|
|
30
|
+
import { UsersIcon } from "@sanity/icons/Users";
|
|
23
31
|
import isEqual from "lodash-es/isEqual.js";
|
|
24
32
|
import { uuid } from "@sanity/uuid";
|
|
25
33
|
import { startWith, map } from "rxjs/operators";
|
|
34
|
+
import { PlayIcon } from "@sanity/icons/Play";
|
|
35
|
+
import { StopIcon } from "@sanity/icons/Stop";
|
|
36
|
+
import { CopyIcon } from "@sanity/icons/Copy";
|
|
37
|
+
import { HelpCircleIcon } from "@sanity/icons/HelpCircle";
|
|
26
38
|
import { json2csv } from "json-2-csv";
|
|
27
39
|
import { JsonInspector } from "@rexxars/react-json-inspector";
|
|
40
|
+
import { LinkIcon } from "@sanity/icons/Link";
|
|
28
41
|
import LRU from "quick-lru";
|
|
29
42
|
import { IntentLink } from "sanity/router";
|
|
43
|
+
import { DocumentSheetIcon } from "@sanity/icons/DocumentSheet";
|
|
30
44
|
import { useObservable } from "react-rx";
|
|
31
45
|
import { of, map as map$1, catchError } from "rxjs";
|
|
32
46
|
const API_VERSIONS = ["v1", "vX", "v2021-03-25", "v2021-10-21", "v2022-03-07", "v2025-02-19", `v${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}`], [DEFAULT_API_VERSION] = API_VERSIONS.slice(-1);
|
|
@@ -951,7 +965,7 @@ function QueryRecall(t0) {
|
|
|
951
965
|
handleSave();
|
|
952
966
|
}, $[75] = handleSave, $[76] = t18) : t18 = $[76];
|
|
953
967
|
let t19;
|
|
954
|
-
$[77] !== saving || $[78] !== t172 || $[79] !== t18 ? (t19 = /* @__PURE__ */ jsx(Button, { label: t172, icon: AddIcon, disabled: saving, onClick: t18, mode: "bleed" }), $[77] = saving, $[78] = t172, $[79] = t18, $[80] = t19) : t19 = $[80];
|
|
968
|
+
$[77] !== saving || $[78] !== t172 || $[79] !== t18 ? (t19 = /* @__PURE__ */ jsx(Button, { "aria-label": t172, icon: AddIcon, disabled: saving, onClick: t18, mode: "bleed" }), $[77] = saving, $[78] = t172, $[79] = t18, $[80] = t19) : t19 = $[80];
|
|
955
969
|
let t20;
|
|
956
970
|
$[81] !== t162 || $[82] !== t19 ? (t20 = /* @__PURE__ */ jsxs(Flex, { padding: 3, paddingTop: 2, paddingBottom: 0, justify: "space-between", align: "center", children: [
|
|
957
971
|
t162,
|
|
@@ -995,7 +1009,7 @@ function QueryRecall(t0) {
|
|
|
995
1009
|
t36
|
|
996
1010
|
] }), $[112] = t20, $[113] = t23, $[114] = t36, $[115] = t14) : t14 = $[115], T0 = Stack, t11 = "vision-query-recall-list", t12 = 3, t13 = filteredQueries?.map((q_5, index) => {
|
|
997
1011
|
const queryObj = getStateFromUrl(q_5.url), fullQueryPreview = queryObj?.query || "", shortQueryPreview = fullQueryPreview.split("{")[0], isSelected = selectedUrl === q_5.url, canMutateQuery = !q_5.shared || q_5.isOwnedByCurrentUser, areQueriesEqual = queryObj && currentQuery === queryObj.query && isEqual(currentParams, queryObj.params), isEdited = isSelected && !areQueriesEqual && canMutateQuery;
|
|
998
|
-
return /* @__PURE__ */ jsx(Card, {
|
|
1012
|
+
return /* @__PURE__ */ jsx(Card, { paddingX: compactMode ? 3 : 4, paddingY: compactMode ? 3 : 4, tone: "default", onClick: (event_0) => {
|
|
999
1013
|
if (event_0.target?.closest('[data-query-actions="true"]'))
|
|
1000
1014
|
return;
|
|
1001
1015
|
setSelectedUrl(q_5.url);
|
|
@@ -1059,7 +1073,7 @@ function QueryRecall(t0) {
|
|
|
1059
1073
|
maxWidth: "420px",
|
|
1060
1074
|
maxHeight: "220px",
|
|
1061
1075
|
overflow: "auto"
|
|
1062
|
-
}, children: /* @__PURE__ */ jsx(Code, { size: 1, children: fullQueryPreview }) }), placement: "top", portal: !0, children: /* @__PURE__ */ jsx(Code, {
|
|
1076
|
+
}, children: /* @__PURE__ */ jsx(Code, { size: 1, children: fullQueryPreview }) }), placement: "top", portal: !0, children: /* @__PURE__ */ jsx(Code, { size: 1, children: shortQueryPreview }) }) : /* @__PURE__ */ jsx(Code, {}),
|
|
1063
1077
|
compactMode ? /* @__PURE__ */ jsxs(Stack, { space: 1, style: {
|
|
1064
1078
|
paddingTop: 0,
|
|
1065
1079
|
minHeight: "30px"
|
|
@@ -1112,7 +1126,7 @@ function QueryRecall(t0) {
|
|
|
1112
1126
|
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "\u2022" }),
|
|
1113
1127
|
/* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: formatDate.format(new Date(q_5.savedAt || "")) })
|
|
1114
1128
|
] }),
|
|
1115
|
-
isEdited && /* @__PURE__ */ jsx(Button, { mode: "ghost", tone: "default",
|
|
1129
|
+
isEdited && /* @__PURE__ */ jsx(Button, { mode: "ghost", tone: "default", padding: 2, style: {
|
|
1116
1130
|
height: "24px",
|
|
1117
1131
|
position: "absolute",
|
|
1118
1132
|
right: "16px",
|
|
@@ -1128,7 +1142,7 @@ function QueryRecall(t0) {
|
|
|
1128
1142
|
let t15;
|
|
1129
1143
|
$[116] !== T0 || $[117] !== t11 || $[118] !== t12 || $[119] !== t13 ? (t15 = /* @__PURE__ */ jsx(T0, { id: t11, paddingY: t12, children: t13 }), $[116] = T0, $[117] = t11, $[118] = t12, $[119] = t13, $[120] = t15) : t15 = $[120];
|
|
1130
1144
|
let t16;
|
|
1131
|
-
$[121] !== handleConfirmShareQuery || $[122] !== shareDialogQuery || $[123] !== t ? (t16 = shareDialogQuery && /* @__PURE__ */ jsx(Dialog, { id: "vision-query-recall-share-dialog", width: 1, header: t("label.share"), onClose: () => setShareDialogQuery(null), footer: /* @__PURE__ */ jsxs(Flex, {
|
|
1145
|
+
$[121] !== handleConfirmShareQuery || $[122] !== shareDialogQuery || $[123] !== t ? (t16 = shareDialogQuery && /* @__PURE__ */ jsx(Dialog, { id: "vision-query-recall-share-dialog", width: 1, header: t("label.share"), onClose: () => setShareDialogQuery(null), footer: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", gap: 3, padding: 3, align: "center", children: [
|
|
1132
1146
|
/* @__PURE__ */ jsx(Button, { mode: "bleed", padding: 2, text: t("action.query-cancel"), onClick: () => setShareDialogQuery(null) }),
|
|
1133
1147
|
/* @__PURE__ */ jsx(Button, { padding: 2, tone: "primary", text: t("action.save-shared-query"), onClick: () => {
|
|
1134
1148
|
handleConfirmShareQuery();
|
|
@@ -1647,20 +1661,22 @@ const numeric = /^\d+$/;
|
|
|
1647
1661
|
function isArrayKeyOverLimit(segment, limit = 10) {
|
|
1648
1662
|
return numeric.test(segment) && parseInt(segment, 10) > limit;
|
|
1649
1663
|
}
|
|
1650
|
-
function preventSave(evt) {
|
|
1651
|
-
return evt.preventDefault();
|
|
1652
|
-
}
|
|
1653
1664
|
function SaveCsvButton(t0) {
|
|
1654
|
-
const $ = c(
|
|
1665
|
+
const $ = c(7), {
|
|
1655
1666
|
blobUrl
|
|
1656
1667
|
} = t0, {
|
|
1657
1668
|
t
|
|
1658
|
-
} = useTranslation(visionLocaleNamespace)
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1669
|
+
} = useTranslation(visionLocaleNamespace);
|
|
1670
|
+
if (!blobUrl) {
|
|
1671
|
+
let t12;
|
|
1672
|
+
$[0] !== t ? (t12 = t("result.save-result-as-csv.not-csv-encodable"), $[0] = t, $[1] = t12) : t12 = $[1];
|
|
1673
|
+
let t2;
|
|
1674
|
+
$[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Button, { disabled: !0, icon: DocumentSheetIcon, mode: "ghost", text: "CSV", tone: "default" }), $[2] = t2) : t2 = $[2];
|
|
1675
|
+
let t3;
|
|
1676
|
+
return $[3] !== t12 ? (t3 = /* @__PURE__ */ jsx(Tooltip, { content: t12, placement: "top", children: t2 }), $[3] = t12, $[4] = t3) : t3 = $[4], t3;
|
|
1677
|
+
}
|
|
1678
|
+
let t1;
|
|
1679
|
+
return $[5] !== blobUrl ? (t1 = /* @__PURE__ */ jsx(Button, { as: "a", download: "query-result.csv", href: blobUrl, icon: DocumentSheetIcon, mode: "ghost", text: "CSV", tone: "default" }), $[5] = blobUrl, $[6] = t1) : t1 = $[6], t1;
|
|
1664
1680
|
}
|
|
1665
1681
|
function SaveJsonButton(t0) {
|
|
1666
1682
|
const $ = c(2), {
|