sanity 6.6.0-next.29 → 6.6.0-next.30

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,9 +1,9 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
3
  import { useRouter, IntentLink, StateLink } from "sanity/router";
4
4
  import { Autocomplete, Stack, Flex, Box, Text, TextInput, TextArea, useToast, Card, Menu, Badge, Container, rem, Skeleton } from "@sanity/ui";
5
5
  import { useId, useState, useMemo, useCallback, forwardRef, memo } from "react";
6
- import { Button, Dialog, MenuButton, MenuItem, Tooltip } from "./index.js";
6
+ import { Button, Dialog, MenuItem, MenuButton, Tooltip } from "./index.js";
7
7
  import { getVariantId, variantsClient, useClient, VARIANTS_STUDIO_CLIENT_OPTIONS, VARIANT_DOCUMENTS_PATH, useTranslation, variantsLocaleNamespace, useAllVariants, TextWithTone, DOCUMENT_SYSTEM_FIELD, useBundleDocuments, usePerspective, useSetVariant, getVariantTitle, isPublishedBundleId, ContextMenuButton, RelativeTime, isReleaseBundle, getReleaseDocumentIdFromReleaseId, getReleaseIdFromReleaseDocumentId, ReleaseTitle, RELEASES_INTENT, useDocumentPresence, DocumentPreviewPresence, useDocumentPreviewValues, SanityDefaultPreview, useSchema, ToneIcon, useActiveReleases, decodeVariantIdFromRoute, LoadingBlock, getVariantDescription, getVariantConditionsText, useVariantsStore, listenQuery, filterVariantsForSearch } from "./index2.js";
8
8
  import "history";
9
9
  import "sanity/_singletons";
@@ -812,25 +812,70 @@ function groupVariantDocumentsByGroup(documents) {
812
812
  };
813
813
  });
814
814
  }
815
+ function DeleteVariantDialog(t0) {
816
+ const $ = c(23), {
817
+ isDeleting,
818
+ onClose,
819
+ onConfirm,
820
+ variantTitle
821
+ } = t0, {
822
+ t
823
+ } = useTranslation(variantsLocaleNamespace);
824
+ let t1;
825
+ $[0] !== isDeleting ? (t1 = {
826
+ disabled: isDeleting
827
+ }, $[0] = isDeleting, $[1] = t1) : t1 = $[1];
828
+ let t2;
829
+ $[2] !== t ? (t2 = t("dialog.delete.action.confirm"), $[2] = t, $[3] = t2) : t2 = $[3];
830
+ let t3;
831
+ $[4] !== isDeleting || $[5] !== onConfirm || $[6] !== t2 ? (t3 = {
832
+ disabled: isDeleting,
833
+ loading: isDeleting,
834
+ onClick: onConfirm,
835
+ text: t2,
836
+ tone: "critical"
837
+ }, $[4] = isDeleting, $[5] = onConfirm, $[6] = t2, $[7] = t3) : t3 = $[7];
838
+ let t4;
839
+ $[8] !== t1 || $[9] !== t3 ? (t4 = {
840
+ cancelButton: t1,
841
+ confirmButton: t3
842
+ }, $[8] = t1, $[9] = t3, $[10] = t4) : t4 = $[10];
843
+ let t5;
844
+ $[11] !== t ? (t5 = t("dialog.delete.title"), $[11] = t, $[12] = t5) : t5 = $[12];
845
+ const t6 = isDeleting ? void 0 : onClose;
846
+ let t7;
847
+ $[13] !== t || $[14] !== variantTitle ? (t7 = t("dialog.delete.description", {
848
+ title: variantTitle
849
+ }), $[13] = t, $[14] = variantTitle, $[15] = t7) : t7 = $[15];
850
+ let t8;
851
+ $[16] !== t7 ? (t8 = /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t7 }), $[16] = t7, $[17] = t8) : t8 = $[17];
852
+ let t9;
853
+ return $[18] !== t4 || $[19] !== t5 || $[20] !== t6 || $[21] !== t8 ? (t9 = /* @__PURE__ */ jsx(Dialog, { "data-testid": "delete-variant-dialog", footer: t4, header: t5, id: "delete-variant-dialog", onClose: t6, children: t8 }), $[18] = t4, $[19] = t5, $[20] = t6, $[21] = t8, $[22] = t9) : t9 = $[22], t9;
854
+ }
815
855
  function useVariantDeleteAction(variantId, options) {
816
856
  const {
817
857
  documentCount,
818
858
  documentsLoading = !1,
819
- onDeleted
859
+ onDeleted,
860
+ variantTitle = ""
820
861
  } = options ?? {}, {
821
862
  t
822
863
  } = useTranslation(variantsLocaleNamespace), toast = useToast(), {
823
864
  deleteVariant
824
- } = useVariantOperations(), [isDeleting, setIsDeleting] = useState(!1), hasDocuments = typeof documentCount == "number" && documentCount > 0, countUnknown = documentsLoading || documentCount === void 0 || documentCount === null, deleteDisabled = isDeleting || countUnknown || hasDocuments, deleteDisabledTooltip = useMemo(() => {
865
+ } = useVariantOperations(), [isDeleting, setIsDeleting] = useState(!1), [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(!1), hasDocuments = typeof documentCount == "number" && documentCount > 0, countUnknown = documentsLoading || documentCount === void 0 || documentCount === null, deleteDisabled = isDeleting || countUnknown || hasDocuments, deleteDisabledTooltip = useMemo(() => {
825
866
  if (!(!hasDocuments || typeof documentCount != "number"))
826
867
  return t(documentCount === 1 ? "overview.action.delete-variant.disabled-hint_one" : "overview.action.delete-variant.disabled-hint_other", {
827
868
  count: documentCount
828
869
  });
829
- }, [documentCount, hasDocuments, t]), handleDelete = useCallback(async () => {
870
+ }, [documentCount, hasDocuments, t]), handleDelete = useCallback(() => {
871
+ countUnknown || hasDocuments || setIsDeleteDialogOpen(!0);
872
+ }, [countUnknown, hasDocuments]), handleCloseDeleteDialog = useCallback(() => {
873
+ isDeleting || setIsDeleteDialogOpen(!1);
874
+ }, [isDeleting]), handleConfirmDelete = useCallback(async () => {
830
875
  if (!(countUnknown || hasDocuments)) {
831
876
  setIsDeleting(!0);
832
877
  try {
833
- await deleteVariant(variantId), setIsDeleting(!1), onDeleted?.();
878
+ await deleteVariant(variantId), setIsDeleting(!1), setIsDeleteDialogOpen(!1), onDeleted?.();
834
879
  } catch (error) {
835
880
  console.error(error), toast.push({
836
881
  closable: !0,
@@ -843,12 +888,16 @@ function useVariantDeleteAction(variantId, options) {
843
888
  return {
844
889
  deleteDisabled,
845
890
  deleteDisabledTooltip,
891
+ handleCloseDeleteDialog,
892
+ handleConfirmDelete,
846
893
  handleDelete,
847
- isDeleting
894
+ isDeleteDialogOpen,
895
+ isDeleting,
896
+ variantTitle
848
897
  };
849
898
  }
850
899
  function VariantDetailMenuButton(t0) {
851
- const $ = c(24), {
900
+ const $ = c(36), {
852
901
  documentCount,
853
902
  documentsLoading: t1,
854
903
  variant
@@ -856,39 +905,54 @@ function VariantDetailMenuButton(t0) {
856
905
  t
857
906
  } = useTranslation(variantsLocaleNamespace), router = useRouter();
858
907
  let t2;
859
- $[0] !== router ? (t2 = () => router.navigate({}), $[0] = router, $[1] = t2) : t2 = $[1];
908
+ $[0] !== variant ? (t2 = getVariantTitle(variant), $[0] = variant, $[1] = t2) : t2 = $[1];
909
+ const variantTitle = t2;
860
910
  let t3;
861
- $[2] !== documentCount || $[3] !== documentsLoading || $[4] !== t2 ? (t3 = {
911
+ $[2] !== router ? (t3 = () => router.navigate({}), $[2] = router, $[3] = t3) : t3 = $[3];
912
+ let t4;
913
+ $[4] !== documentCount || $[5] !== documentsLoading || $[6] !== t3 || $[7] !== variantTitle ? (t4 = {
862
914
  documentCount,
863
915
  documentsLoading,
864
- onDeleted: t2
865
- }, $[2] = documentCount, $[3] = documentsLoading, $[4] = t2, $[5] = t3) : t3 = $[5];
916
+ onDeleted: t3,
917
+ variantTitle
918
+ }, $[4] = documentCount, $[5] = documentsLoading, $[6] = t3, $[7] = variantTitle, $[8] = t4) : t4 = $[8];
866
919
  const {
867
920
  deleteDisabled,
868
921
  deleteDisabledTooltip,
922
+ handleCloseDeleteDialog,
923
+ handleConfirmDelete,
869
924
  handleDelete,
870
- isDeleting
871
- } = useVariantDeleteAction(variant._id, t3);
872
- let t4;
873
- $[6] !== isDeleting ? (t4 = /* @__PURE__ */ jsx(ContextMenuButton, { disabled: isDeleting, loading: isDeleting }), $[6] = isDeleting, $[7] = t4) : t4 = $[7];
925
+ isDeleteDialogOpen,
926
+ isDeleting,
927
+ variantTitle: dialogVariantTitle
928
+ } = useVariantDeleteAction(variant._id, t4);
874
929
  let t5;
875
- $[8] !== variant._id ? (t5 = getVariantId(variant._id), $[8] = variant._id, $[9] = t5) : t5 = $[9];
876
- const t6 = `variant-detail-actions-${t5}`;
877
- let t7;
878
- $[10] !== t ? (t7 = t("overview.action.delete-variant"), $[10] = t, $[11] = t7) : t7 = $[11];
930
+ $[9] !== isDeleting ? (t5 = /* @__PURE__ */ jsx(ContextMenuButton, { disabled: isDeleting, loading: isDeleting }), $[9] = isDeleting, $[10] = t5) : t5 = $[10];
931
+ let t6;
932
+ $[11] !== variant._id ? (t6 = getVariantId(variant._id), $[11] = variant._id, $[12] = t6) : t6 = $[12];
933
+ const t7 = `variant-detail-actions-${t6}`;
879
934
  let t8;
880
- $[12] !== deleteDisabledTooltip ? (t8 = deleteDisabledTooltip ? {
881
- content: deleteDisabledTooltip
882
- } : void 0, $[12] = deleteDisabledTooltip, $[13] = t8) : t8 = $[13];
935
+ $[13] !== t ? (t8 = t("overview.action.delete-variant"), $[13] = t, $[14] = t8) : t8 = $[14];
883
936
  let t9;
884
- $[14] !== deleteDisabled || $[15] !== handleDelete || $[16] !== t7 || $[17] !== t8 ? (t9 = /* @__PURE__ */ jsx(Menu, { children: /* @__PURE__ */ jsx(MenuItem, { disabled: deleteDisabled, onClick: handleDelete, text: t7, tone: "critical", tooltipProps: t8 }) }), $[14] = deleteDisabled, $[15] = handleDelete, $[16] = t7, $[17] = t8, $[18] = t9) : t9 = $[18];
937
+ $[15] !== deleteDisabledTooltip ? (t9 = deleteDisabledTooltip ? {
938
+ content: deleteDisabledTooltip
939
+ } : void 0, $[15] = deleteDisabledTooltip, $[16] = t9) : t9 = $[16];
885
940
  let t10;
886
- $[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t10 = {
941
+ $[17] !== deleteDisabled || $[18] !== handleDelete || $[19] !== t8 || $[20] !== t9 ? (t10 = /* @__PURE__ */ jsx(Menu, { children: /* @__PURE__ */ jsx(MenuItem, { disabled: deleteDisabled, onClick: handleDelete, text: t8, tone: "critical", tooltipProps: t9 }) }), $[17] = deleteDisabled, $[18] = handleDelete, $[19] = t8, $[20] = t9, $[21] = t10) : t10 = $[21];
942
+ let t11;
943
+ $[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t11 = {
887
944
  placement: "bottom-end",
888
945
  portal: !0
889
- }, $[19] = t10) : t10 = $[19];
890
- let t11;
891
- return $[20] !== t4 || $[21] !== t6 || $[22] !== t9 ? (t11 = /* @__PURE__ */ jsx(MenuButton, { button: t4, id: t6, menu: t9, popover: t10 }), $[20] = t4, $[21] = t6, $[22] = t9, $[23] = t11) : t11 = $[23], t11;
946
+ }, $[22] = t11) : t11 = $[22];
947
+ let t12;
948
+ $[23] !== t10 || $[24] !== t5 || $[25] !== t7 ? (t12 = /* @__PURE__ */ jsx(MenuButton, { button: t5, id: t7, menu: t10, popover: t11 }), $[23] = t10, $[24] = t5, $[25] = t7, $[26] = t12) : t12 = $[26];
949
+ let t13;
950
+ $[27] !== dialogVariantTitle || $[28] !== handleCloseDeleteDialog || $[29] !== handleConfirmDelete || $[30] !== isDeleteDialogOpen || $[31] !== isDeleting ? (t13 = isDeleteDialogOpen && /* @__PURE__ */ jsx(DeleteVariantDialog, { isDeleting, onClose: handleCloseDeleteDialog, onConfirm: handleConfirmDelete, variantTitle: dialogVariantTitle }), $[27] = dialogVariantTitle, $[28] = handleCloseDeleteDialog, $[29] = handleConfirmDelete, $[30] = isDeleteDialogOpen, $[31] = isDeleting, $[32] = t13) : t13 = $[32];
951
+ let t14;
952
+ return $[33] !== t12 || $[34] !== t13 ? (t14 = /* @__PURE__ */ jsxs(Fragment, { children: [
953
+ t12,
954
+ t13
955
+ ] }), $[33] = t12, $[34] = t13, $[35] = t14) : t14 = $[35], t14;
892
956
  }
893
957
  function VariantDetailFooter(t0) {
894
958
  const $ = c(16), {
@@ -1448,42 +1512,57 @@ function useVariantsDocumentCounts() {
1448
1512
  return $[0] !== client || $[1] !== state$ ? (t0 = getVariantsDocumentCounts(client, state$), $[0] = client, $[1] = state$, $[2] = t0) : t0 = $[2], useObservable(t0, INITIAL_STATE);
1449
1513
  }
1450
1514
  function VariantMenuButton(t0) {
1451
- const $ = c(20), {
1515
+ const $ = c(32), {
1452
1516
  documentCount,
1453
1517
  variant
1454
1518
  } = t0, {
1455
1519
  t
1456
1520
  } = useTranslation(variantsLocaleNamespace);
1457
1521
  let t1;
1458
- $[0] !== documentCount ? (t1 = {
1459
- documentCount
1460
- }, $[0] = documentCount, $[1] = t1) : t1 = $[1];
1522
+ $[0] !== variant ? (t1 = getVariantTitle(variant), $[0] = variant, $[1] = t1) : t1 = $[1];
1523
+ const variantTitle = t1;
1524
+ let t2;
1525
+ $[2] !== documentCount || $[3] !== variantTitle ? (t2 = {
1526
+ documentCount,
1527
+ variantTitle
1528
+ }, $[2] = documentCount, $[3] = variantTitle, $[4] = t2) : t2 = $[4];
1461
1529
  const {
1462
1530
  deleteDisabled,
1463
1531
  deleteDisabledTooltip,
1532
+ handleCloseDeleteDialog,
1533
+ handleConfirmDelete,
1464
1534
  handleDelete,
1465
- isDeleting
1466
- } = useVariantDeleteAction(variant._id, t1);
1467
- let t2;
1468
- $[2] !== isDeleting ? (t2 = /* @__PURE__ */ jsx(ContextMenuButton, { disabled: isDeleting, loading: isDeleting }), $[2] = isDeleting, $[3] = t2) : t2 = $[3];
1535
+ isDeleteDialogOpen,
1536
+ isDeleting,
1537
+ variantTitle: dialogVariantTitle
1538
+ } = useVariantDeleteAction(variant._id, t2);
1469
1539
  let t3;
1470
- $[4] !== variant._id ? (t3 = getVariantId(variant._id), $[4] = variant._id, $[5] = t3) : t3 = $[5];
1471
- const t4 = `variant-actions-${t3}`;
1472
- let t5;
1473
- $[6] !== t ? (t5 = t("overview.action.delete-variant"), $[6] = t, $[7] = t5) : t5 = $[7];
1540
+ $[5] !== isDeleting ? (t3 = /* @__PURE__ */ jsx(ContextMenuButton, { disabled: isDeleting, loading: isDeleting }), $[5] = isDeleting, $[6] = t3) : t3 = $[6];
1541
+ let t4;
1542
+ $[7] !== variant._id ? (t4 = getVariantId(variant._id), $[7] = variant._id, $[8] = t4) : t4 = $[8];
1543
+ const t5 = `variant-actions-${t4}`;
1474
1544
  let t6;
1475
- $[8] !== deleteDisabledTooltip ? (t6 = deleteDisabledTooltip ? {
1476
- content: deleteDisabledTooltip
1477
- } : void 0, $[8] = deleteDisabledTooltip, $[9] = t6) : t6 = $[9];
1545
+ $[9] !== t ? (t6 = t("overview.action.delete-variant"), $[9] = t, $[10] = t6) : t6 = $[10];
1478
1546
  let t7;
1479
- $[10] !== deleteDisabled || $[11] !== handleDelete || $[12] !== t5 || $[13] !== t6 ? (t7 = /* @__PURE__ */ jsx(Menu, { children: /* @__PURE__ */ jsx(MenuItem, { disabled: deleteDisabled, onClick: handleDelete, text: t5, tone: "critical", tooltipProps: t6 }) }), $[10] = deleteDisabled, $[11] = handleDelete, $[12] = t5, $[13] = t6, $[14] = t7) : t7 = $[14];
1547
+ $[11] !== deleteDisabledTooltip ? (t7 = deleteDisabledTooltip ? {
1548
+ content: deleteDisabledTooltip
1549
+ } : void 0, $[11] = deleteDisabledTooltip, $[12] = t7) : t7 = $[12];
1480
1550
  let t8;
1481
- $[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t8 = {
1551
+ $[13] !== deleteDisabled || $[14] !== handleDelete || $[15] !== t6 || $[16] !== t7 ? (t8 = /* @__PURE__ */ jsx(Menu, { children: /* @__PURE__ */ jsx(MenuItem, { disabled: deleteDisabled, onClick: handleDelete, text: t6, tone: "critical", tooltipProps: t7 }) }), $[13] = deleteDisabled, $[14] = handleDelete, $[15] = t6, $[16] = t7, $[17] = t8) : t8 = $[17];
1552
+ let t9;
1553
+ $[18] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = {
1482
1554
  placement: "bottom-end",
1483
1555
  portal: !0
1484
- }, $[15] = t8) : t8 = $[15];
1485
- let t9;
1486
- return $[16] !== t2 || $[17] !== t4 || $[18] !== t7 ? (t9 = /* @__PURE__ */ jsx(MenuButton, { button: t2, id: t4, menu: t7, popover: t8 }), $[16] = t2, $[17] = t4, $[18] = t7, $[19] = t9) : t9 = $[19], t9;
1556
+ }, $[18] = t9) : t9 = $[18];
1557
+ let t10;
1558
+ $[19] !== t3 || $[20] !== t5 || $[21] !== t8 ? (t10 = /* @__PURE__ */ jsx(MenuButton, { button: t3, id: t5, menu: t8, popover: t9 }), $[19] = t3, $[20] = t5, $[21] = t8, $[22] = t10) : t10 = $[22];
1559
+ let t11;
1560
+ $[23] !== dialogVariantTitle || $[24] !== handleCloseDeleteDialog || $[25] !== handleConfirmDelete || $[26] !== isDeleteDialogOpen || $[27] !== isDeleting ? (t11 = isDeleteDialogOpen && /* @__PURE__ */ jsx(DeleteVariantDialog, { isDeleting, onClose: handleCloseDeleteDialog, onConfirm: handleConfirmDelete, variantTitle: dialogVariantTitle }), $[23] = dialogVariantTitle, $[24] = handleCloseDeleteDialog, $[25] = handleConfirmDelete, $[26] = isDeleteDialogOpen, $[27] = isDeleting, $[28] = t11) : t11 = $[28];
1561
+ let t12;
1562
+ return $[29] !== t10 || $[30] !== t11 ? (t12 = /* @__PURE__ */ jsxs(Fragment, { children: [
1563
+ t10,
1564
+ t11
1565
+ ] }), $[29] = t10, $[30] = t11, $[31] = t12) : t12 = $[31], t12;
1487
1566
  }
1488
1567
  const BASE_PANEL = "M64 150.174V81.8262C64 79.1748 65.498 76.751 67.8695 75.5653L103.87 57.5652C108.524 55.2381 114 58.6226 114 63.8262V132.174C114 134.825 112.502 137.249 110.131 138.435L74.1305 156.435C69.4762 158.762 64 155.377 64 150.174Z", LINES_FULL = ["M72 86 L106 86", "M72 96 L102 96", "M72 106 L104 106", "M72 116 L98 116"], LINES_MEDIUM = ["M72 88 L100 88", "M72 98 L96 98", "M72 108 L102 108"], LINES_SHORT = ["M72 90 L94 90", "M72 100 L92 100"], VariantIllustration = () => {
1489
1568
  const $ = c(6);