sanity 6.6.1-next.2 → 6.7.0-next.17

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
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
- import { Autocomplete, Stack, Flex, Box, Text, TextInput, TextArea, useToast, Card, Menu, Badge, Container, rem, Skeleton } from "@sanity/ui";
4
+ import { Autocomplete, Stack, Flex, Box, Text, TextInput, TextArea, Inline, 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, MenuItem, MenuButton, Tooltip } from "./index.js";
6
+ import { Button, Tooltip, Dialog, MenuItem, MenuButton } 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";
@@ -126,7 +126,7 @@ import "@portabletext/react";
126
126
  import "@sanity/icons/LinkRemoved";
127
127
  import "@sanity/asset-utils";
128
128
  import "@sanity/icons/AccessDenied";
129
- import "@sanity/icons/HelpCircle";
129
+ import { HelpCircleIcon } from "@sanity/icons/HelpCircle";
130
130
  import "@sanity/image-url";
131
131
  import { customAlphabet } from "nanoid";
132
132
  import "lodash-es/castArray.js";
@@ -294,6 +294,13 @@ function getConditionValueValidationError(value) {
294
294
  if (value.includes(":"))
295
295
  return "invalid";
296
296
  }
297
+ function getPriorityValidationError(priority) {
298
+ if (!Number.isFinite(priority))
299
+ return "invalid";
300
+ }
301
+ function getPriorityInputValidationError(input) {
302
+ return input.trim() === "" ? "invalid" : getPriorityValidationError(Number(input));
303
+ }
297
304
  const createVariantIdSuffix = customAlphabet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 8);
298
305
  function createVariantId() {
299
306
  return `${VARIANT_DOCUMENTS_PATH}.${createVariantIdSuffix()}`;
@@ -439,9 +446,10 @@ function getPortableTextDescriptionValue(description) {
439
446
  return !Array.isArray(description) || !description.every(isPortableTextBlock) ? "" : toPlainText(description);
440
447
  }
441
448
  function VariantForm(props) {
442
- const $ = c(108), {
449
+ const $ = c(147), {
443
450
  onChange,
444
451
  onConditionValidityChange,
452
+ onPriorityValidityChange,
445
453
  showValidation: t0,
446
454
  value
447
455
  } = props, showValidation = t0 === void 0 ? !1 : t0, {
@@ -451,150 +459,193 @@ function VariantForm(props) {
451
459
  } = useAllVariants();
452
460
  let t1;
453
461
  $[0] !== variants ? (t1 = buildConditionSuggestionIndex(variants), $[0] = variants, $[1] = t1) : t1 = $[1];
454
- const suggestionIndex = t1, titleId = useId(), descriptionId = useId();
462
+ const suggestionIndex = t1, titleId = useId(), descriptionId = useId(), priorityId = useId();
455
463
  let t2;
456
464
  $[2] !== value.conditions ? (t2 = () => getConditionRows(value.conditions), $[2] = value.conditions, $[3] = t2) : t2 = $[3];
457
465
  const [conditionRows, setConditionRows] = useState(t2);
458
466
  let t3;
459
- $[4] !== conditionRows ? (t3 = getConditionRowsValidation(conditionRows), $[4] = conditionRows, $[5] = t3) : t3 = $[5];
460
- const conditionsValidation = t3;
467
+ $[4] !== value.priority ? (t3 = () => String(value.priority), $[4] = value.priority, $[5] = t3) : t3 = $[5];
468
+ const [priorityInput, setPriorityInput] = useState(t3);
461
469
  let t4;
462
- $[6] !== value ? (t4 = getVariantTitleValue(value), $[6] = value, $[7] = t4) : t4 = $[7];
463
- const showTitleError = showValidation && !t4, lastConditionRow = conditionRows[conditionRows.length - 1];
470
+ $[6] !== conditionRows ? (t4 = getConditionRowsValidation(conditionRows), $[6] = conditionRows, $[7] = t4) : t4 = $[7];
471
+ const conditionsValidation = t4;
464
472
  let t5;
465
- $[8] !== conditionsValidation || $[9] !== lastConditionRow ? (t5 = lastConditionRow && !hasConditionRowsValidationErrors(conditionsValidation), $[8] = conditionsValidation, $[9] = lastConditionRow, $[10] = t5) : t5 = $[10];
466
- const canAddCondition = !!t5;
473
+ $[8] !== value ? (t5 = getVariantTitleValue(value), $[8] = value, $[9] = t5) : t5 = $[9];
474
+ const showTitleError = showValidation && !t5;
467
475
  let t6;
468
- $[11] !== onChange || $[12] !== onConditionValidityChange ? (t6 = (nextRows) => {
476
+ $[10] !== priorityInput ? (t6 = getPriorityInputValidationError(priorityInput), $[10] = priorityInput, $[11] = t6) : t6 = $[11];
477
+ const priorityValidationError = t6, showPriorityError = showValidation && priorityValidationError, lastConditionRow = conditionRows[conditionRows.length - 1];
478
+ let t7;
479
+ $[12] !== conditionsValidation || $[13] !== lastConditionRow ? (t7 = lastConditionRow && !hasConditionRowsValidationErrors(conditionsValidation), $[12] = conditionsValidation, $[13] = lastConditionRow, $[14] = t7) : t7 = $[14];
480
+ const canAddCondition = !!t7;
481
+ let t8;
482
+ $[15] !== onChange || $[16] !== onConditionValidityChange ? (t8 = (nextRows) => {
469
483
  const rows = nextRows.length ? nextRows : getConditionRows({});
470
484
  setConditionRows(rows);
471
485
  const nextRowsValidation = getConditionRowsValidation(rows), nextRowsInvalid = hasConditionRowsValidationErrors(nextRowsValidation);
472
- onConditionValidityChange?.(nextRowsInvalid), (nextRows.length === 0 || !nextRowsInvalid) && onChange(["conditions"], getConditionsFromRows(nextRows));
473
- }, $[11] = onChange, $[12] = onConditionValidityChange, $[13] = t6) : t6 = $[13];
474
- const updateConditionRows = t6;
475
- let t7;
476
- $[14] !== onChange ? (t7 = (event) => {
486
+ onConditionValidityChange(nextRowsInvalid), (nextRows.length === 0 || !nextRowsInvalid) && onChange(["conditions"], getConditionsFromRows(nextRows));
487
+ }, $[15] = onChange, $[16] = onConditionValidityChange, $[17] = t8) : t8 = $[17];
488
+ const updateConditionRows = t8;
489
+ let t9;
490
+ $[18] !== onChange ? (t9 = (event) => {
477
491
  onChange(["metadata", "title"], event.currentTarget.value);
478
- }, $[14] = onChange, $[15] = t7) : t7 = $[15];
479
- const handleTitleChange = t7;
480
- let t8;
481
- $[16] !== onChange ? (t8 = (event_0) => {
492
+ }, $[18] = onChange, $[19] = t9) : t9 = $[19];
493
+ const handleTitleChange = t9;
494
+ let t10;
495
+ $[20] !== onChange ? (t10 = (event_0) => {
482
496
  onChange(["metadata", "description"], createPortableTextDescription(event_0.currentTarget.value));
483
- }, $[16] = onChange, $[17] = t8) : t8 = $[17];
484
- const handleDescriptionChange = t8;
485
- let t9;
486
- $[18] !== conditionRows || $[19] !== updateConditionRows ? (t9 = (index, field, nextValue) => {
497
+ }, $[20] = onChange, $[21] = t10) : t10 = $[21];
498
+ const handleDescriptionChange = t10;
499
+ let t11;
500
+ $[22] !== onChange || $[23] !== onPriorityValidityChange ? (t11 = (event_1) => {
501
+ const rawValue = event_1.currentTarget.value, nextValue = event_1.currentTarget.valueAsNumber;
502
+ setPriorityInput(rawValue);
503
+ const priorityValidationError_0 = getPriorityInputValidationError(rawValue);
504
+ onPriorityValidityChange(!!priorityValidationError_0), Number.isFinite(nextValue) && onChange(["priority"], nextValue);
505
+ }, $[22] = onChange, $[23] = onPriorityValidityChange, $[24] = t11) : t11 = $[24];
506
+ const handlePriorityChange = t11;
507
+ let t12;
508
+ $[25] !== conditionRows || $[26] !== updateConditionRows ? (t12 = (index, field, nextValue_0) => {
487
509
  const nextRows_0 = conditionRows.map((row, rowIndex) => rowIndex === index ? {
488
510
  ...row,
489
- [field]: nextValue
511
+ [field]: nextValue_0
490
512
  } : row);
491
513
  updateConditionRows(nextRows_0);
492
- }, $[18] = conditionRows, $[19] = updateConditionRows, $[20] = t9) : t9 = $[20];
493
- const handleConditionChange = t9;
494
- let t10;
495
- $[21] !== canAddCondition || $[22] !== conditionRows || $[23] !== updateConditionRows ? (t10 = () => {
514
+ }, $[25] = conditionRows, $[26] = updateConditionRows, $[27] = t12) : t12 = $[27];
515
+ const handleConditionChange = t12;
516
+ let t13;
517
+ $[28] !== canAddCondition || $[29] !== conditionRows || $[30] !== updateConditionRows ? (t13 = () => {
496
518
  canAddCondition && updateConditionRows([...conditionRows, {
497
519
  id: randomKey(12),
498
520
  key: "",
499
521
  value: ""
500
522
  }]);
501
- }, $[21] = canAddCondition, $[22] = conditionRows, $[23] = updateConditionRows, $[24] = t10) : t10 = $[24];
502
- const handleAddCondition = t10;
503
- let t11;
504
- $[25] !== conditionRows || $[26] !== updateConditionRows ? (t11 = (index_0) => {
523
+ }, $[28] = canAddCondition, $[29] = conditionRows, $[30] = updateConditionRows, $[31] = t13) : t13 = $[31];
524
+ const handleAddCondition = t13;
525
+ let t14;
526
+ $[32] !== conditionRows || $[33] !== updateConditionRows ? (t14 = (index_0) => {
505
527
  const nextRows_1 = conditionRows.filter((_, rowIndex_0) => rowIndex_0 !== index_0);
506
528
  updateConditionRows(nextRows_1);
507
- }, $[25] = conditionRows, $[26] = updateConditionRows, $[27] = t11) : t11 = $[27];
508
- const handleRemoveCondition = t11;
509
- let t12;
510
- $[28] !== t ? (t12 = t("dialog.create.variant-title.label"), $[28] = t, $[29] = t12) : t12 = $[29];
511
- let t13;
512
- $[30] !== t12 || $[31] !== titleId ? (t13 = /* @__PURE__ */ jsx(Text, { as: "label", htmlFor: titleId, size: 1, weight: "medium", children: t12 }), $[30] = t12, $[31] = titleId, $[32] = t13) : t13 = $[32];
513
- const t14 = showTitleError ? "true" : void 0;
529
+ }, $[32] = conditionRows, $[33] = updateConditionRows, $[34] = t14) : t14 = $[34];
530
+ const handleRemoveCondition = t14;
514
531
  let t15;
515
- $[33] !== showTitleError || $[34] !== t ? (t15 = showTitleError ? t("dialog.create.variant-title.required") : void 0, $[33] = showTitleError, $[34] = t, $[35] = t15) : t15 = $[35];
532
+ $[35] !== t ? (t15 = t("dialog.create.variant-title.label"), $[35] = t, $[36] = t15) : t15 = $[36];
516
533
  let t16;
517
- $[36] !== t ? (t16 = t("dialog.create.variant-title.placeholder"), $[36] = t, $[37] = t16) : t16 = $[37];
518
- const t17 = typeof value.metadata?.title == "string" ? value.metadata.title : "";
534
+ $[37] !== t15 || $[38] !== titleId ? (t16 = /* @__PURE__ */ jsx(Text, { as: "label", htmlFor: titleId, size: 1, weight: "medium", children: t15 }), $[37] = t15, $[38] = titleId, $[39] = t16) : t16 = $[39];
535
+ const t17 = showTitleError ? "true" : void 0;
519
536
  let t18;
520
- $[38] !== handleTitleChange || $[39] !== t14 || $[40] !== t15 || $[41] !== t16 || $[42] !== t17 || $[43] !== titleId ? (t18 = /* @__PURE__ */ jsx(TextInput, { autoFocus: !0, "aria-invalid": t14, customValidity: t15, "data-testid": "variant-form-title", fontSize: 2, id: titleId, onChange: handleTitleChange, placeholder: t16, value: t17 }), $[38] = handleTitleChange, $[39] = t14, $[40] = t15, $[41] = t16, $[42] = t17, $[43] = titleId, $[44] = t18) : t18 = $[44];
537
+ $[40] !== showTitleError || $[41] !== t ? (t18 = showTitleError ? t("dialog.create.variant-title.required") : void 0, $[40] = showTitleError, $[41] = t, $[42] = t18) : t18 = $[42];
521
538
  let t19;
522
- $[45] !== showTitleError || $[46] !== t ? (t19 = showTitleError && /* @__PURE__ */ jsx(TextWithTone, { "data-testid": "variant-form-title-error", size: 1, tone: "critical", children: t("dialog.create.variant-title.required") }), $[45] = showTitleError, $[46] = t, $[47] = t19) : t19 = $[47];
523
- let t20;
524
- $[48] !== t13 || $[49] !== t18 || $[50] !== t19 ? (t20 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
525
- t13,
526
- t18,
527
- t19
528
- ] }), $[48] = t13, $[49] = t18, $[50] = t19, $[51] = t20) : t20 = $[51];
539
+ $[43] !== t ? (t19 = t("dialog.create.variant-title.placeholder"), $[43] = t, $[44] = t19) : t19 = $[44];
540
+ const t20 = typeof value.metadata?.title == "string" ? value.metadata.title : "";
529
541
  let t21;
530
- $[52] !== t ? (t21 = t("dialog.create.description.label"), $[52] = t, $[53] = t21) : t21 = $[53];
542
+ $[45] !== handleTitleChange || $[46] !== t17 || $[47] !== t18 || $[48] !== t19 || $[49] !== t20 || $[50] !== titleId ? (t21 = /* @__PURE__ */ jsx(TextInput, { autoFocus: !0, "aria-invalid": t17, customValidity: t18, "data-testid": "variant-form-title", fontSize: 2, id: titleId, onChange: handleTitleChange, placeholder: t19, value: t20 }), $[45] = handleTitleChange, $[46] = t17, $[47] = t18, $[48] = t19, $[49] = t20, $[50] = titleId, $[51] = t21) : t21 = $[51];
531
543
  let t22;
532
- $[54] !== descriptionId || $[55] !== t21 ? (t22 = /* @__PURE__ */ jsx(Text, { as: "label", htmlFor: descriptionId, size: 1, weight: "medium", children: t21 }), $[54] = descriptionId, $[55] = t21, $[56] = t22) : t22 = $[56];
544
+ $[52] !== showTitleError || $[53] !== t ? (t22 = showTitleError && /* @__PURE__ */ jsx(TextWithTone, { "data-testid": "variant-form-title-error", size: 1, tone: "critical", children: t("dialog.create.variant-title.required") }), $[52] = showTitleError, $[53] = t, $[54] = t22) : t22 = $[54];
533
545
  let t23;
534
- $[57] !== t ? (t23 = t("dialog.create.description.placeholder"), $[57] = t, $[58] = t23) : t23 = $[58];
535
- const t24 = value.metadata?.description;
546
+ $[55] !== t16 || $[56] !== t21 || $[57] !== t22 ? (t23 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
547
+ t16,
548
+ t21,
549
+ t22
550
+ ] }), $[55] = t16, $[56] = t21, $[57] = t22, $[58] = t23) : t23 = $[58];
551
+ let t24;
552
+ $[59] !== t ? (t24 = t("dialog.create.description.label"), $[59] = t, $[60] = t24) : t24 = $[60];
536
553
  let t25;
537
- $[59] !== t24 ? (t25 = getPortableTextDescriptionValue(t24), $[59] = t24, $[60] = t25) : t25 = $[60];
554
+ $[61] !== descriptionId || $[62] !== t24 ? (t25 = /* @__PURE__ */ jsx(Text, { as: "label", htmlFor: descriptionId, size: 1, weight: "medium", children: t24 }), $[61] = descriptionId, $[62] = t24, $[63] = t25) : t25 = $[63];
538
555
  let t26;
539
- $[61] !== descriptionId || $[62] !== handleDescriptionChange || $[63] !== t23 || $[64] !== t25 ? (t26 = /* @__PURE__ */ jsx(TextArea, { "data-testid": "variant-form-description", fontSize: 1, id: descriptionId, onChange: handleDescriptionChange, placeholder: t23, rows: 3, value: t25 }), $[61] = descriptionId, $[62] = handleDescriptionChange, $[63] = t23, $[64] = t25, $[65] = t26) : t26 = $[65];
540
- let t27;
541
- $[66] !== t22 || $[67] !== t26 ? (t27 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
542
- t22,
543
- t26
544
- ] }), $[66] = t22, $[67] = t26, $[68] = t27) : t27 = $[68];
556
+ $[64] !== t ? (t26 = t("dialog.create.description.placeholder"), $[64] = t, $[65] = t26) : t26 = $[65];
557
+ const t27 = value.metadata?.description;
545
558
  let t28;
546
- $[69] !== t ? (t28 = t("dialog.create.conditions.title"), $[69] = t, $[70] = t28) : t28 = $[70];
559
+ $[66] !== t27 ? (t28 = getPortableTextDescriptionValue(t27), $[66] = t27, $[67] = t28) : t28 = $[67];
547
560
  let t29;
548
- $[71] !== t28 ? (t29 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t28 }), $[71] = t28, $[72] = t29) : t29 = $[72];
561
+ $[68] !== descriptionId || $[69] !== handleDescriptionChange || $[70] !== t26 || $[71] !== t28 ? (t29 = /* @__PURE__ */ jsx(TextArea, { "data-testid": "variant-form-description", fontSize: 1, id: descriptionId, onChange: handleDescriptionChange, placeholder: t26, rows: 3, value: t28 }), $[68] = descriptionId, $[69] = handleDescriptionChange, $[70] = t26, $[71] = t28, $[72] = t29) : t29 = $[72];
549
562
  let t30;
550
- $[73] !== t ? (t30 = t("dialog.create.conditions.description"), $[73] = t, $[74] = t30) : t30 = $[74];
563
+ $[73] !== t25 || $[74] !== t29 ? (t30 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
564
+ t25,
565
+ t29
566
+ ] }), $[73] = t25, $[74] = t29, $[75] = t30) : t30 = $[75];
551
567
  let t31;
552
- $[75] !== t30 ? (t31 = /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t30 }), $[75] = t30, $[76] = t31) : t31 = $[76];
568
+ $[76] !== t ? (t31 = t("dialog.create.priority.label"), $[76] = t, $[77] = t31) : t31 = $[77];
553
569
  let t32;
554
- $[77] !== t29 || $[78] !== t31 ? (t32 = /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
555
- t29,
556
- t31
557
- ] }), $[77] = t29, $[78] = t31, $[79] = t32) : t32 = $[79];
570
+ $[78] !== priorityId || $[79] !== t31 ? (t32 = /* @__PURE__ */ jsx(Text, { as: "label", htmlFor: priorityId, size: 1, weight: "medium", children: t31 }), $[78] = priorityId, $[79] = t31, $[80] = t32) : t32 = $[80];
558
571
  let t33;
559
- $[80] !== conditionRows || $[81] !== conditionsValidation || $[82] !== handleConditionChange || $[83] !== handleRemoveCondition || $[84] !== showValidation || $[85] !== suggestionIndex || $[86] !== t ? (t33 = conditionRows.map((row_0, index_1) => {
572
+ $[81] !== t ? (t33 = t("dialog.create.priority.tooltip"), $[81] = t, $[82] = t33) : t33 = $[82];
573
+ let t34;
574
+ $[83] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t34 = /* @__PURE__ */ jsx(HelpCircleIcon, { "data-testid": "variant-form-priority-help" }), $[83] = t34) : t34 = $[83];
575
+ let t35;
576
+ $[84] !== t33 ? (t35 = /* @__PURE__ */ jsx(Tooltip, { content: t33, placement: "right", children: t34 }), $[84] = t33, $[85] = t35) : t35 = $[85];
577
+ let t36;
578
+ $[86] !== t32 || $[87] !== t35 ? (t36 = /* @__PURE__ */ jsxs(Inline, { space: 1, children: [
579
+ t32,
580
+ t35
581
+ ] }), $[86] = t32, $[87] = t35, $[88] = t36) : t36 = $[88];
582
+ const t37 = showPriorityError ? "true" : void 0;
583
+ let t38;
584
+ $[89] !== priorityValidationError || $[90] !== showPriorityError || $[91] !== t ? (t38 = showPriorityError && priorityValidationError ? t(`dialog.create.priority.${priorityValidationError}`) : void 0, $[89] = priorityValidationError, $[90] = showPriorityError, $[91] = t, $[92] = t38) : t38 = $[92];
585
+ let t39;
586
+ $[93] !== handlePriorityChange || $[94] !== priorityId || $[95] !== priorityInput || $[96] !== t37 || $[97] !== t38 ? (t39 = /* @__PURE__ */ jsx(TextInput, { "aria-invalid": t37, customValidity: t38, "data-testid": "variant-form-priority", fontSize: 2, id: priorityId, inputMode: "decimal", onChange: handlePriorityChange, type: "number", value: priorityInput }), $[93] = handlePriorityChange, $[94] = priorityId, $[95] = priorityInput, $[96] = t37, $[97] = t38, $[98] = t39) : t39 = $[98];
587
+ let t40;
588
+ $[99] !== priorityValidationError || $[100] !== showPriorityError || $[101] !== t ? (t40 = showPriorityError && priorityValidationError && /* @__PURE__ */ jsx(TextWithTone, { "data-testid": "variant-form-priority-error", size: 1, tone: "critical", children: t(`dialog.create.priority.${priorityValidationError}`) }), $[99] = priorityValidationError, $[100] = showPriorityError, $[101] = t, $[102] = t40) : t40 = $[102];
589
+ let t41;
590
+ $[103] !== t36 || $[104] !== t39 || $[105] !== t40 ? (t41 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
591
+ t36,
592
+ t39,
593
+ t40
594
+ ] }), $[103] = t36, $[104] = t39, $[105] = t40, $[106] = t41) : t41 = $[106];
595
+ let t42;
596
+ $[107] !== t ? (t42 = t("dialog.create.conditions.title"), $[107] = t, $[108] = t42) : t42 = $[108];
597
+ let t43;
598
+ $[109] !== t42 ? (t43 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t42 }), $[109] = t42, $[110] = t43) : t43 = $[110];
599
+ let t44;
600
+ $[111] !== t ? (t44 = t("dialog.create.conditions.description"), $[111] = t, $[112] = t44) : t44 = $[112];
601
+ let t45;
602
+ $[113] !== t44 ? (t45 = /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t44 }), $[113] = t44, $[114] = t45) : t45 = $[114];
603
+ let t46;
604
+ $[115] !== t43 || $[116] !== t45 ? (t46 = /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
605
+ t43,
606
+ t45
607
+ ] }), $[115] = t43, $[116] = t45, $[117] = t46) : t46 = $[117];
608
+ let t47;
609
+ $[118] !== conditionRows || $[119] !== conditionsValidation || $[120] !== handleConditionChange || $[121] !== handleRemoveCondition || $[122] !== showValidation || $[123] !== suggestionIndex || $[124] !== t ? (t47 = conditionRows.map((row_0, index_1) => {
560
610
  const validation = conditionsValidation.get(index_1) ?? getEmptyConditionRowValidation(), valueValidation = showValidation ? validation.value : null, conditionValidationError = validation.key || valueValidation;
561
611
  return /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
562
612
  /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, children: [
563
- /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(ConditionAutocompleteInput, { autoFocus: index_1 > 0, ariaLabel: t("dialog.create.condition-key.label"), customValidity: validation.key ? t(validation.key) : void 0, invalid: !!validation.key, onChange: (nextValue_0) => handleConditionChange(index_1, "key", nextValue_0), options: getConditionKeyOptions(suggestionIndex, conditionRows, index_1), placeholder: t("dialog.create.condition-key.placeholder"), testId: "variant-form-condition-key", value: row_0.key }) }),
564
- /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(ConditionAutocompleteInput, { ariaLabel: t("dialog.create.condition-value.label"), customValidity: valueValidation ? t(valueValidation) : void 0, invalid: !!valueValidation, onChange: (nextValue_1) => handleConditionChange(index_1, "value", nextValue_1), options: getConditionValueOptions(suggestionIndex, row_0.key), placeholder: t("dialog.create.condition-value.placeholder"), testId: "variant-form-condition-value", value: row_0.value }) }),
613
+ /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(ConditionAutocompleteInput, { autoFocus: index_1 > 0, ariaLabel: t("dialog.create.condition-key.label"), customValidity: validation.key ? t(validation.key) : void 0, invalid: !!validation.key, onChange: (nextValue_1) => handleConditionChange(index_1, "key", nextValue_1), options: getConditionKeyOptions(suggestionIndex, conditionRows, index_1), placeholder: t("dialog.create.condition-key.placeholder"), testId: "variant-form-condition-key", value: row_0.key }) }),
614
+ /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(ConditionAutocompleteInput, { ariaLabel: t("dialog.create.condition-value.label"), customValidity: valueValidation ? t(valueValidation) : void 0, invalid: !!valueValidation, onChange: (nextValue_2) => handleConditionChange(index_1, "value", nextValue_2), options: getConditionValueOptions(suggestionIndex, row_0.key), placeholder: t("dialog.create.condition-value.placeholder"), testId: "variant-form-condition-value", value: row_0.value }) }),
565
615
  /* @__PURE__ */ jsx(Button, { disabled: isConditionRowEmpty(row_0) && conditionRows.length === 1, icon: TrashIcon, mode: "bleed", onClick: () => handleRemoveCondition(index_1), tone: "critical", tooltipProps: {
566
616
  content: t("dialog.create.remove-condition")
567
617
  }, type: "button" })
568
618
  ] }),
569
619
  conditionValidationError && /* @__PURE__ */ jsx(TextWithTone, { "data-testid": validation.key ? "variant-form-condition-key-error" : "variant-form-condition-value-error", size: 1, tone: "critical", children: t(conditionValidationError) })
570
620
  ] }, row_0.id);
571
- }), $[80] = conditionRows, $[81] = conditionsValidation, $[82] = handleConditionChange, $[83] = handleRemoveCondition, $[84] = showValidation, $[85] = suggestionIndex, $[86] = t, $[87] = t33) : t33 = $[87];
572
- let t34;
573
- $[88] !== t33 ? (t34 = /* @__PURE__ */ jsx(Stack, { space: 2, children: t33 }), $[88] = t33, $[89] = t34) : t34 = $[89];
574
- const t35 = !canAddCondition;
575
- let t36;
576
- $[90] !== t ? (t36 = t("dialog.create.action.add-condition"), $[90] = t, $[91] = t36) : t36 = $[91];
577
- let t37;
578
- $[92] !== canAddCondition || $[93] !== t ? (t37 = canAddCondition ? null : {
621
+ }), $[118] = conditionRows, $[119] = conditionsValidation, $[120] = handleConditionChange, $[121] = handleRemoveCondition, $[122] = showValidation, $[123] = suggestionIndex, $[124] = t, $[125] = t47) : t47 = $[125];
622
+ let t48;
623
+ $[126] !== t47 ? (t48 = /* @__PURE__ */ jsx(Stack, { space: 2, children: t47 }), $[126] = t47, $[127] = t48) : t48 = $[127];
624
+ const t49 = !canAddCondition;
625
+ let t50;
626
+ $[128] !== t ? (t50 = t("dialog.create.action.add-condition"), $[128] = t, $[129] = t50) : t50 = $[129];
627
+ let t51;
628
+ $[130] !== canAddCondition || $[131] !== t ? (t51 = canAddCondition ? null : {
579
629
  content: t("dialog.create.action.add-condition.disabled-hint")
580
- }, $[92] = canAddCondition, $[93] = t, $[94] = t37) : t37 = $[94];
581
- let t38;
582
- $[95] !== handleAddCondition || $[96] !== t35 || $[97] !== t36 || $[98] !== t37 ? (t38 = /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(Button, { disabled: t35, icon: AddIcon, mode: "ghost", onClick: handleAddCondition, text: t36, tooltipProps: t37, type: "button" }) }), $[95] = handleAddCondition, $[96] = t35, $[97] = t36, $[98] = t37, $[99] = t38) : t38 = $[99];
583
- let t39;
584
- $[100] !== t32 || $[101] !== t34 || $[102] !== t38 ? (t39 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
585
- t32,
586
- t34,
587
- t38
588
- ] }), $[100] = t32, $[101] = t34, $[102] = t38, $[103] = t39) : t39 = $[103];
589
- let t40;
590
- return $[104] !== t20 || $[105] !== t27 || $[106] !== t39 ? (t40 = /* @__PURE__ */ jsxs(Stack, { space: 5, children: [
591
- t20,
592
- t27,
593
- t39
594
- ] }), $[104] = t20, $[105] = t27, $[106] = t39, $[107] = t40) : t40 = $[107], t40;
630
+ }, $[130] = canAddCondition, $[131] = t, $[132] = t51) : t51 = $[132];
631
+ let t52;
632
+ $[133] !== handleAddCondition || $[134] !== t49 || $[135] !== t50 || $[136] !== t51 ? (t52 = /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(Button, { disabled: t49, icon: AddIcon, mode: "ghost", onClick: handleAddCondition, text: t50, tooltipProps: t51, type: "button" }) }), $[133] = handleAddCondition, $[134] = t49, $[135] = t50, $[136] = t51, $[137] = t52) : t52 = $[137];
633
+ let t53;
634
+ $[138] !== t46 || $[139] !== t48 || $[140] !== t52 ? (t53 = /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
635
+ t46,
636
+ t48,
637
+ t52
638
+ ] }), $[138] = t46, $[139] = t48, $[140] = t52, $[141] = t53) : t53 = $[141];
639
+ let t54;
640
+ return $[142] !== t23 || $[143] !== t30 || $[144] !== t41 || $[145] !== t53 ? (t54 = /* @__PURE__ */ jsxs(Stack, { space: 5, children: [
641
+ t23,
642
+ t30,
643
+ t41,
644
+ t53
645
+ ] }), $[142] = t23, $[143] = t30, $[144] = t41, $[145] = t53, $[146] = t54) : t54 = $[146], t54;
595
646
  }
596
647
  function VariantDialog(props) {
597
- const $ = c(35), {
648
+ const $ = c(36), {
598
649
  confirmDataTestId,
599
650
  confirmText,
600
651
  errorTitle,
@@ -606,17 +657,17 @@ function VariantDialog(props) {
606
657
  renderCancelButton: t0
607
658
  } = props, renderCancelButton = t0 === void 0 ? !1 : t0, toast = useToast(), {
608
659
  t
609
- } = useTranslation(variantsLocaleNamespace), [variant, setVariant] = useState(initialValue), [isSubmitting, setIsSubmitting] = useState(!1), [showValidation, setShowValidation] = useState(!1), [conditionsInvalid, setConditionsInvalid] = useState(!1);
660
+ } = useTranslation(variantsLocaleNamespace), [variant, setVariant] = useState(initialValue), [isSubmitting, setIsSubmitting] = useState(!1), [showValidation, setShowValidation] = useState(!1), [conditionsInvalid, setConditionsInvalid] = useState(!1), [priorityInvalid, setPriorityInvalid] = useState(!1);
610
661
  let t1;
611
- $[0] !== conditionsInvalid || $[1] !== variant ? (t1 = getIsVariantInvalid(variant) || conditionsInvalid, $[0] = conditionsInvalid, $[1] = variant, $[2] = t1) : t1 = $[2];
662
+ $[0] !== conditionsInvalid || $[1] !== priorityInvalid || $[2] !== variant ? (t1 = getIsVariantInvalid(variant) || conditionsInvalid || priorityInvalid, $[0] = conditionsInvalid, $[1] = priorityInvalid, $[2] = variant, $[3] = t1) : t1 = $[3];
612
663
  const invalid = t1;
613
664
  let t2;
614
- $[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = (path, nextValue) => {
665
+ $[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = (path, nextValue) => {
615
666
  setVariant((currentVariant) => applyPatches([at(path, set(nextValue))], currentVariant));
616
- }, $[3] = t2) : t2 = $[3];
667
+ }, $[4] = t2) : t2 = $[4];
617
668
  const handleVariantChange = t2;
618
669
  let t3;
619
- $[4] !== errorTitle || $[5] !== invalid || $[6] !== onSubmit || $[7] !== toast || $[8] !== variant ? (t3 = async (event) => {
670
+ $[5] !== errorTitle || $[6] !== invalid || $[7] !== onSubmit || $[8] !== toast || $[9] !== variant ? (t3 = async (event) => {
620
671
  if (event.preventDefault(), invalid) {
621
672
  setShowValidation(!0);
622
673
  return;
@@ -632,26 +683,26 @@ function VariantDialog(props) {
632
683
  title: errorTitle
633
684
  });
634
685
  }
635
- }, $[4] = errorTitle, $[5] = invalid, $[6] = onSubmit, $[7] = toast, $[8] = variant, $[9] = t3) : t3 = $[9];
686
+ }, $[5] = errorTitle, $[6] = invalid, $[7] = onSubmit, $[8] = toast, $[9] = variant, $[10] = t3) : t3 = $[10];
636
687
  const handleSubmit = t3, t4 = isSubmitting ? void 0 : onCancel, t5 = isSubmitting ? void 0 : onCancel;
637
688
  let t6;
638
- $[10] !== showValidation || $[11] !== variant ? (t6 = /* @__PURE__ */ jsx(Box, { paddingBottom: 4, children: /* @__PURE__ */ jsx(VariantForm, { onChange: handleVariantChange, onConditionValidityChange: setConditionsInvalid, showValidation, value: variant }) }), $[10] = showValidation, $[11] = variant, $[12] = t6) : t6 = $[12];
689
+ $[11] !== showValidation || $[12] !== variant ? (t6 = /* @__PURE__ */ jsx(Box, { paddingBottom: 4, children: /* @__PURE__ */ jsx(VariantForm, { onChange: handleVariantChange, onConditionValidityChange: setConditionsInvalid, onPriorityValidityChange: setPriorityInvalid, showValidation, value: variant }) }), $[11] = showValidation, $[12] = variant, $[13] = t6) : t6 = $[13];
639
690
  let t7;
640
- $[13] !== isSubmitting || $[14] !== onCancel || $[15] !== renderCancelButton || $[16] !== t ? (t7 = renderCancelButton && /* @__PURE__ */ jsx(Button, { disabled: isSubmitting, mode: "ghost", onClick: onCancel, text: t("dialog.edit.action.cancel"), type: "button" }), $[13] = isSubmitting, $[14] = onCancel, $[15] = renderCancelButton, $[16] = t, $[17] = t7) : t7 = $[17];
691
+ $[14] !== isSubmitting || $[15] !== onCancel || $[16] !== renderCancelButton || $[17] !== t ? (t7 = renderCancelButton && /* @__PURE__ */ jsx(Button, { disabled: isSubmitting, mode: "ghost", onClick: onCancel, text: t("dialog.edit.action.cancel"), type: "button" }), $[14] = isSubmitting, $[15] = onCancel, $[16] = renderCancelButton, $[17] = t, $[18] = t7) : t7 = $[18];
641
692
  let t8;
642
- $[18] !== confirmDataTestId || $[19] !== confirmText || $[20] !== isSubmitting ? (t8 = /* @__PURE__ */ jsx(Button, { "data-testid": confirmDataTestId, disabled: isSubmitting, loading: isSubmitting, size: "large", text: confirmText, type: "submit" }), $[18] = confirmDataTestId, $[19] = confirmText, $[20] = isSubmitting, $[21] = t8) : t8 = $[21];
693
+ $[19] !== confirmDataTestId || $[20] !== confirmText || $[21] !== isSubmitting ? (t8 = /* @__PURE__ */ jsx(Button, { "data-testid": confirmDataTestId, disabled: isSubmitting, loading: isSubmitting, size: "large", text: confirmText, type: "submit" }), $[19] = confirmDataTestId, $[20] = confirmText, $[21] = isSubmitting, $[22] = t8) : t8 = $[22];
643
694
  let t9;
644
- $[22] !== t7 || $[23] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Flex, { gap: 2, justify: "flex-end", paddingTop: 5, children: [
695
+ $[23] !== t7 || $[24] !== t8 ? (t9 = /* @__PURE__ */ jsxs(Flex, { gap: 2, justify: "flex-end", paddingTop: 5, children: [
645
696
  t7,
646
697
  t8
647
- ] }), $[22] = t7, $[23] = t8, $[24] = t9) : t9 = $[24];
698
+ ] }), $[23] = t7, $[24] = t8, $[25] = t9) : t9 = $[25];
648
699
  let t10;
649
- $[25] !== handleSubmit || $[26] !== t6 || $[27] !== t9 ? (t10 = /* @__PURE__ */ jsx(Card, { borderTop: !0, padding: 4, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
700
+ $[26] !== handleSubmit || $[27] !== t6 || $[28] !== t9 ? (t10 = /* @__PURE__ */ jsx(Card, { borderTop: !0, padding: 4, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
650
701
  t6,
651
702
  t9
652
- ] }) }), $[25] = handleSubmit, $[26] = t6, $[27] = t9, $[28] = t10) : t10 = $[28];
703
+ ] }) }), $[26] = handleSubmit, $[27] = t6, $[28] = t9, $[29] = t10) : t10 = $[29];
653
704
  let t11;
654
- return $[29] !== header || $[30] !== id || $[31] !== t10 || $[32] !== t4 || $[33] !== t5 ? (t11 = /* @__PURE__ */ jsx(Dialog, { __unstable_autoFocus: !1, header, id, onClickOutside: t4, onClose: t5, padding: !1, width: 1, children: t10 }), $[29] = header, $[30] = id, $[31] = t10, $[32] = t4, $[33] = t5, $[34] = t11) : t11 = $[34], t11;
705
+ return $[30] !== header || $[31] !== id || $[32] !== t10 || $[33] !== t4 || $[34] !== t5 ? (t11 = /* @__PURE__ */ jsx(Dialog, { __unstable_autoFocus: !1, header, id, onClickOutside: t4, onClose: t5, padding: !1, width: 1, children: t10 }), $[30] = header, $[31] = id, $[32] = t10, $[33] = t4, $[34] = t5, $[35] = t11) : t11 = $[35], t11;
655
706
  }
656
707
  function toEditableVariant(variant) {
657
708
  return {