@sanity/vision 6.4.0-next.38 → 6.4.0-workbench.20260701093415

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,8 +4,7 @@ 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 { ChevronLeftIcon } from "@sanity/icons/ChevronLeft";
8
- import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
7
+ import { ErrorOutlineIcon, UsersIcon, UnpublishIcon, TrashIcon, LockIcon, AddIcon, SearchIcon, StopIcon, PlayIcon, HelpCircleIcon, CopyIcon, LinkIcon, DocumentSheetIcon, ChevronLeftIcon, ChevronRightIcon } from "@sanity/icons";
9
8
  import { isHotkey } from "is-hotkey-esm";
10
9
  import { closeBrackets } from "@codemirror/autocomplete";
11
10
  import { history, defaultKeymap, historyKeymap } from "@codemirror/commands";
@@ -19,28 +18,15 @@ import { assignInlineVars } from "@vanilla-extract/dynamic";
19
18
  import { tags } from "@lezer/highlight";
20
19
  import { hues } from "@sanity/color";
21
20
  import { visionLocaleNamespace } from "./index.js";
22
- import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
23
21
  import debounce from "lodash-es/debounce.js";
24
22
  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";
31
23
  import isEqual from "lodash-es/isEqual.js";
32
24
  import { uuid } from "@sanity/uuid";
33
25
  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";
38
26
  import { json2csv } from "json-2-csv";
39
27
  import { JsonInspector } from "@rexxars/react-json-inspector";
40
- import { LinkIcon } from "@sanity/icons/Link";
41
28
  import LRU from "quick-lru";
42
29
  import { IntentLink } from "sanity/router";
43
- import { DocumentSheetIcon } from "@sanity/icons/DocumentSheet";
44
30
  import { useObservable } from "react-rx";
45
31
  import { of, map as map$1, catchError } from "rxjs";
46
32
  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);
@@ -965,7 +951,7 @@ function QueryRecall(t0) {
965
951
  handleSave();
966
952
  }, $[75] = handleSave, $[76] = t18) : t18 = $[76];
967
953
  let t19;
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];
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];
969
955
  let t20;
970
956
  $[81] !== t162 || $[82] !== t19 ? (t20 = /* @__PURE__ */ jsxs(Flex, { padding: 3, paddingTop: 2, paddingBottom: 0, justify: "space-between", align: "center", children: [
971
957
  t162,
@@ -1009,7 +995,7 @@ function QueryRecall(t0) {
1009
995
  t36
1010
996
  ] }), $[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) => {
1011
997
  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;
1012
- return /* @__PURE__ */ jsx(Card, { paddingX: compactMode ? 3 : 4, paddingY: compactMode ? 3 : 4, tone: "default", onClick: (event_0) => {
998
+ return /* @__PURE__ */ jsx(Card, { width: "fill", paddingX: compactMode ? 3 : 4, paddingY: compactMode ? 3 : 4, tone: "default", onClick: (event_0) => {
1013
999
  if (event_0.target?.closest('[data-query-actions="true"]'))
1014
1000
  return;
1015
1001
  setSelectedUrl(q_5.url);
@@ -1073,7 +1059,7 @@ function QueryRecall(t0) {
1073
1059
  maxWidth: "420px",
1074
1060
  maxHeight: "220px",
1075
1061
  overflow: "auto"
1076
- }, children: /* @__PURE__ */ jsx(Code, { size: 1, children: fullQueryPreview }) }), placement: "top", portal: !0, children: /* @__PURE__ */ jsx(Code, { size: 1, children: shortQueryPreview }) }) : /* @__PURE__ */ jsx(Code, {}),
1062
+ }, children: /* @__PURE__ */ jsx(Code, { size: 1, children: fullQueryPreview }) }), placement: "top", portal: !0, children: /* @__PURE__ */ jsx(Code, { muted: !0, size: 1, children: shortQueryPreview }) }) : /* @__PURE__ */ jsx(Code, { muted: !0 }),
1077
1063
  compactMode ? /* @__PURE__ */ jsxs(Stack, { space: 1, style: {
1078
1064
  paddingTop: 0,
1079
1065
  minHeight: "30px"
@@ -1126,7 +1112,7 @@ function QueryRecall(t0) {
1126
1112
  /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: "\u2022" }),
1127
1113
  /* @__PURE__ */ jsx(Text, { size: 1, muted: !0, children: formatDate.format(new Date(q_5.savedAt || "")) })
1128
1114
  ] }),
1129
- isEdited && /* @__PURE__ */ jsx(Button, { mode: "ghost", tone: "default", padding: 2, style: {
1115
+ isEdited && /* @__PURE__ */ jsx(Button, { mode: "ghost", tone: "default", size: 1, padding: 2, style: {
1130
1116
  height: "24px",
1131
1117
  position: "absolute",
1132
1118
  right: "16px",
@@ -1142,7 +1128,7 @@ function QueryRecall(t0) {
1142
1128
  let t15;
1143
1129
  $[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];
1144
1130
  let t16;
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: [
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, { width: "fill", justify: "flex-end", gap: 3, padding: 3, align: "center", children: [
1146
1132
  /* @__PURE__ */ jsx(Button, { mode: "bleed", padding: 2, text: t("action.query-cancel"), onClick: () => setShareDialogQuery(null) }),
1147
1133
  /* @__PURE__ */ jsx(Button, { padding: 2, tone: "primary", text: t("action.save-shared-query"), onClick: () => {
1148
1134
  handleConfirmShareQuery();
@@ -1661,22 +1647,20 @@ const numeric = /^\d+$/;
1661
1647
  function isArrayKeyOverLimit(segment, limit = 10) {
1662
1648
  return numeric.test(segment) && parseInt(segment, 10) > limit;
1663
1649
  }
1650
+ function preventSave(evt) {
1651
+ return evt.preventDefault();
1652
+ }
1664
1653
  function SaveCsvButton(t0) {
1665
- const $ = c(7), {
1654
+ const $ = c(9), {
1666
1655
  blobUrl
1667
1656
  } = t0, {
1668
1657
  t
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;
1658
+ } = useTranslation(visionLocaleNamespace), isDisabled = !blobUrl, t1 = isDisabled ? void 0 : "query-result.csv", t2 = isDisabled ? preventSave : void 0;
1659
+ let t3;
1660
+ $[0] !== blobUrl || $[1] !== isDisabled || $[2] !== t1 || $[3] !== t2 ? (t3 = /* @__PURE__ */ jsx(Button, { as: "a", disabled: isDisabled, download: t1, href: blobUrl, icon: DocumentSheetIcon, mode: "ghost", onClick: t2, text: "CSV", tone: "default" }), $[0] = blobUrl, $[1] = isDisabled, $[2] = t1, $[3] = t2, $[4] = t3) : t3 = $[4];
1661
+ const button = t3;
1662
+ let t4;
1663
+ return $[5] !== button || $[6] !== isDisabled || $[7] !== t ? (t4 = isDisabled ? /* @__PURE__ */ jsx(Tooltip, { content: t("result.save-result-as-csv.not-csv-encodable"), placement: "top", children: button }) : button, $[5] = button, $[6] = isDisabled, $[7] = t, $[8] = t4) : t4 = $[8], t4;
1680
1664
  }
1681
1665
  function SaveJsonButton(t0) {
1682
1666
  const $ = c(2), {