@uniformdev/context-ui 20.6.2-alpha.11 → 20.7.1-alpha.102

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/index.esm.js CHANGED
@@ -310,13 +310,17 @@ var quirkCriteriaMenuOperators = [
310
310
  value: "!="
311
311
  }
312
312
  ];
313
+ function getValidCriteriaOperatorsFor(rhsType) {
314
+ return rhsType === "QUIRK" ? quirkCriteriaMenuOperators : rhsType === "ENR" ? enrichmentCriteriaMenuOperators : contextCriteriaMenuOperators;
315
+ }
313
316
  function CriteriaOperatorMenu({ onChange, value, rhsType, ...props }) {
314
317
  var _a, _b;
315
- const operators = rhsType === "QUIRK" ? quirkCriteriaMenuOperators : rhsType === "ENR" ? enrichmentCriteriaMenuOperators : contextCriteriaMenuOperators;
318
+ const operators = getValidCriteriaOperatorsFor(rhsType);
316
319
  return /* @__PURE__ */ jsx6(
317
320
  InputComboBox,
318
321
  {
319
322
  ...props,
323
+ isDisabled: props.disabled,
320
324
  value: {
321
325
  label: (_b = (_a = operators.find((e) => e.value === value)) == null ? void 0 : _a.name) != null ? _b : value,
322
326
  value
@@ -553,7 +557,7 @@ function useDimensionsDataContext() {
553
557
 
554
558
  // src/components/DimensionMenu/CriteriaMatchMenu.tsx
555
559
  import { InputComboBox as InputComboBox3 } from "@uniformdev/design-system";
556
- import { useState as useState5 } from "react";
560
+ import { useEffect as useEffect4, useRef, useState as useState5 } from "react";
557
561
 
558
562
  // src/components/DimensionMenu/DimensionGroupHeading.tsx
559
563
  import { Icon } from "@uniformdev/design-system";
@@ -692,32 +696,38 @@ var DimensionOption = (props) => {
692
696
  };
693
697
 
694
698
  // src/components/DimensionMenu/DimensionValue.tsx
695
- import { Icon as Icon2 } from "@uniformdev/design-system";
699
+ import { css as css4 } from "@emotion/react";
700
+ import { Icon as Icon2, Tooltip } from "@uniformdev/design-system";
696
701
  import { jsx as jsx11, jsxs as jsxs4 } from "@emotion/react/jsx-runtime";
702
+ var styles = {
703
+ dimensionValueWrapper: css4`
704
+ white-space: normal;
705
+ overflow: hidden;
706
+ `,
707
+ dimensionName: css4`
708
+ color: var(--gray-500);
709
+ display: flex;
710
+ align-items: center;
711
+ gap: var(--spacing-xs);
712
+ `,
713
+ dimensionValue: css4`
714
+ color: var(--gray-700);
715
+ text-overflow: ellipsis;
716
+ overflow: hidden;
717
+ white-space: nowrap;
718
+ `
719
+ };
697
720
  function DimensionValue({ displayName }) {
721
+ var _a;
698
722
  const { type, name } = dimensionDisplayName(displayName);
699
- return /* @__PURE__ */ jsxs4(
700
- "div",
701
- {
702
- css: {
703
- whiteSpace: "normal",
704
- overflow: "hidden"
705
- },
706
- children: [
707
- type ? /* @__PURE__ */ jsxs4(
708
- "small",
709
- {
710
- css: { color: "var(--gray-500)", display: "flex", alignItems: "center", gap: "var(--spacing-xs)" },
711
- children: [
712
- type ? /* @__PURE__ */ jsx11(Icon2, { icon: dimensionIcon(type), iconColor: "currentColor", size: 16 }) : null,
713
- /* @__PURE__ */ jsx11("span", { "data-testid": "dimension-name", children: type })
714
- ]
715
- }
716
- ) : null,
717
- /* @__PURE__ */ jsx11("div", { css: { color: "var(--gray-700)" }, "data-testid": "dimension-value", children: name != null ? name : type })
718
- ]
719
- }
720
- );
723
+ const tooltip = (_a = name != null ? name : type) != null ? _a : "";
724
+ return /* @__PURE__ */ jsxs4("div", { css: styles.dimensionValueWrapper, children: [
725
+ type ? /* @__PURE__ */ jsxs4("small", { css: styles.dimensionName, children: [
726
+ type ? /* @__PURE__ */ jsx11(Icon2, { icon: dimensionIcon(type), iconColor: "currentColor", size: 16 }) : null,
727
+ /* @__PURE__ */ jsx11("span", { "data-testid": "dimension-name", children: type })
728
+ ] }) : null,
729
+ /* @__PURE__ */ jsx11(Tooltip, { title: tooltip, children: /* @__PURE__ */ jsx11("div", { css: styles.dimensionValue, "data-testid": "dimension-value", children: name != null ? name : type }) })
730
+ ] });
721
731
  }
722
732
 
723
733
  // src/components/DimensionMenu/DimensionSingleValue.tsx
@@ -740,6 +750,15 @@ function CriteriaMatchMenu({
740
750
  const [inputValue, setInputValue] = useState5(
741
751
  typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
742
752
  );
753
+ const currentInputValue = useRef(inputValue);
754
+ currentInputValue.current = inputValue;
755
+ useEffect4(() => {
756
+ if (currentInputValue.current !== criteriaMatch.r && !criteriaMatch.rDim) {
757
+ setInputValue(
758
+ typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
759
+ );
760
+ }
761
+ }, [criteriaMatch.r, criteriaMatch.rDim]);
743
762
  const rDim = criteriaMatch.rDim;
744
763
  const targetDim = criteriaMatch.rDim ? dimensions.dimIndex[criteriaMatch.rDim] : void 0;
745
764
  const groupedDimensions = useGroupedDimensions(dimensions.dimensions, void 0);
@@ -748,6 +767,7 @@ function CriteriaMatchMenu({
748
767
  InputComboBox3,
749
768
  {
750
769
  ...props,
770
+ isDisabled: props.disabled,
751
771
  inputValue,
752
772
  menuShouldScrollIntoView: true,
753
773
  value: {
@@ -855,8 +875,10 @@ function DimensionMenu({
855
875
  InputComboBox4,
856
876
  {
857
877
  ...props,
878
+ isDisabled: props.disabled,
858
879
  value: valueAsMenuOption,
859
880
  options: groupedDimensions,
881
+ getOptionValue: (option) => option.label,
860
882
  styles: {
861
883
  ...props.styles,
862
884
  valueContainer: (provided, state) => {
@@ -892,8 +914,8 @@ import { CgChevronRight } from "@react-icons/all-files/cg/CgChevronRight";
892
914
  import { Icon as Icon3 } from "@uniformdev/design-system";
893
915
 
894
916
  // src/components/EditLink/EditLink.styles.ts
895
- import { css as css4 } from "@emotion/react";
896
- var editLink = css4`
917
+ import { css as css5 } from "@emotion/react";
918
+ var editLink = css5`
897
919
  display: flex;
898
920
  align-items: center;
899
921
  font-weight: var(--fw-bold);
@@ -926,7 +948,7 @@ var EditLink = ({ linkTo, name, linkText = `Edit ${name} Component` }) => {
926
948
  };
927
949
 
928
950
  // src/components/EnrichmentTag/EnrichmentTag.tsx
929
- import { css as css5 } from "@emotion/react";
951
+ import { css as css6 } from "@emotion/react";
930
952
  import { CgCloseO } from "@react-icons/all-files/cg/CgCloseO";
931
953
  import { CgMathMinus } from "@react-icons/all-files/cg/CgMathMinus";
932
954
  import { CgMathPlus } from "@react-icons/all-files/cg/CgMathPlus";
@@ -943,7 +965,7 @@ import {
943
965
  import { produce } from "immer";
944
966
  import { useMemo as useMemo2, useState as useState6 } from "react";
945
967
  import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs8 } from "@emotion/react/jsx-runtime";
946
- var addEnrichmentLink = css5`
968
+ var addEnrichmentLink = css6`
947
969
  flex: 2;
948
970
  display: flex;
949
971
  width: 50%;
@@ -1132,7 +1154,7 @@ var NoEnrichmentsView = ({ contextConfig }) => /* @__PURE__ */ jsx16(Callout2, {
1132
1154
  var getCappedValue = (value, maxCap = 100, minCap = 0) => {
1133
1155
  return Math.max(Math.min(value, maxCap), minCap);
1134
1156
  };
1135
- var scoreCounterMinusButtonStyles = css5`
1157
+ var scoreCounterMinusButtonStyles = css6`
1136
1158
  position: absolute;
1137
1159
  bottom: 0.875rem;
1138
1160
  left: var(--spacing-sm);
@@ -1145,7 +1167,7 @@ var scoreCounterMinusButtonStyles = css5`
1145
1167
  border: 1px solid var(--gray-300);
1146
1168
  border-radius: var(--rounded-full);
1147
1169
  `;
1148
- var scoreCounterPlusButtonStyles = css5`
1170
+ var scoreCounterPlusButtonStyles = css6`
1149
1171
  ${scoreCounterMinusButtonStyles}
1150
1172
  left: auto;
1151
1173
  right: var(--spacing-sm);
@@ -1309,7 +1331,7 @@ function opHasRhs(op) {
1309
1331
  }
1310
1332
 
1311
1333
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.tsx
1312
- import { css as css7 } from "@emotion/react";
1334
+ import { css as css8 } from "@emotion/react";
1313
1335
  import { CgCloseO as CgCloseO2 } from "@react-icons/all-files/cg/CgCloseO";
1314
1336
  import {
1315
1337
  AddListButton as AddListButton3,
@@ -1319,19 +1341,20 @@ import {
1319
1341
  Input as Input2,
1320
1342
  InputInlineSelect,
1321
1343
  InputSelect as InputSelect2,
1322
- Paragraph
1344
+ Paragraph,
1345
+ VerticalRhythm
1323
1346
  } from "@uniformdev/design-system";
1324
1347
  import { produce as produce2 } from "immer";
1325
1348
 
1326
1349
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.styles.ts
1327
- import { css as css6 } from "@emotion/react";
1350
+ import { css as css7 } from "@emotion/react";
1328
1351
  var spaceBetweenCriteriaItems = "6rem";
1329
- var criteriaItem = css6`
1352
+ var criteriaItem = css7`
1330
1353
  position: relative;
1331
1354
  padding: var(--spacing-md) var(--spacing-base);
1332
1355
  border: 1px solid var(--gray-300);
1333
- box-shadow: var(--shadow-base);
1334
- background-color: white;
1356
+ box-shadow: var(--elevation-200);
1357
+ background-color: var(--white);
1335
1358
  border-radius: var(--rounded-base);
1336
1359
  margin-top: ${spaceBetweenCriteriaItems};
1337
1360
  display: flex;
@@ -1348,13 +1371,13 @@ var criteriaItem = css6`
1348
1371
  }
1349
1372
 
1350
1373
  &:first-of-type {
1351
- margin-top: var(--spacing-md);
1374
+ margin-top: 0;
1352
1375
  &:before {
1353
1376
  display: none;
1354
1377
  }
1355
1378
  }
1356
1379
  `;
1357
- var criteriaItemInner = css6`
1380
+ var criteriaItemInner = css7`
1358
1381
  display: flex;
1359
1382
  row-gap: var(--spacing-base);
1360
1383
  column-gap: var(--spacing-xs);
@@ -1362,23 +1385,23 @@ var criteriaItemInner = css6`
1362
1385
  flex-wrap: wrap;
1363
1386
  margin-right: var(--spacing-base);
1364
1387
  `;
1365
- var criteriaWrapper = css6`
1388
+ var criteriaWrapper = css7`
1366
1389
  width: 100%;
1367
1390
  display: flex;
1368
1391
  align-items: stretch;
1369
1392
  position: relative;
1370
1393
  `;
1371
- var criteriaOperandWrapper = css6`
1394
+ var criteriaOperandWrapper = css7`
1372
1395
  flex: 2;
1373
1396
  height: 52px;
1374
1397
  min-width: 200px;
1375
1398
  `;
1376
- var criteriaOperatorWrapper = css6`
1399
+ var criteriaOperatorWrapper = css7`
1377
1400
  flex: 1;
1378
1401
  flex-wrap: nowrap;
1379
1402
  min-width: 80px;
1380
1403
  `;
1381
- var expand = css6`
1404
+ var expand = css7`
1382
1405
  height: 100%;
1383
1406
  width: 100%;
1384
1407
  `;
@@ -1396,7 +1419,8 @@ var PersonalizationCriteriaStatic = ({
1396
1419
  onRemoveCriteria,
1397
1420
  displayTitle = true,
1398
1421
  components,
1399
- errors = {}
1422
+ errors = {},
1423
+ readOnly
1400
1424
  }) => {
1401
1425
  var _a;
1402
1426
  const currentValue = { crit: [], ...value };
@@ -1442,191 +1466,204 @@ var PersonalizationCriteriaStatic = ({
1442
1466
  children: /* @__PURE__ */ jsx17(Heading2, { level: 5, withMarginBottom: false, children: "Personalization Variation" })
1443
1467
  }
1444
1468
  ) : null,
1445
- (components == null ? void 0 : components.CustomVariantName) ? /* @__PURE__ */ jsx17(components.CustomVariantName, {}) : null,
1446
- (components == null ? void 0 : components.ControlPercentage) ? /* @__PURE__ */ jsx17(components.ControlPercentage, {}) : null,
1447
- !currentValue.crit.length ? /* @__PURE__ */ jsx17(Callout3, { title: "Default variant", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ jsx17(Paragraph, { children: 'This personalized variant has no match criteria and will be shown to any visitor that does not match any preceding variants. Ensure that default variants come last in the variant list. Personalize this variant by clicking "Add Criteria" to get started.' }) }) : /* @__PURE__ */ jsx17("div", { children: currentValue.crit.map((currentCriteria, index) => {
1448
- var _a2, _b, _c, _d, _e, _f, _g, _h;
1449
- const critHasLhs = ((_a2 = currentCriteria.l) == null ? void 0 : _a2.length) > 0;
1450
- const critHasRhs = opHasRhs(currentCriteria.op);
1451
- const currentDimension = dimensions.dimIndex[currentCriteria.l];
1452
- const currentQuirk = quirks == null ? void 0 : quirks.find((q) => q.id === currentCriteria.l);
1453
- return /* @__PURE__ */ jsxs9("div", { css: criteriaItem, "data-testid": "criteria-container", children: [
1454
- /* @__PURE__ */ jsxs9("div", { css: criteriaItemInner, className: "criteriaItemInner", children: [
1469
+ /* @__PURE__ */ jsxs9(VerticalRhythm, { children: [
1470
+ (components == null ? void 0 : components.CustomVariantName) ? /* @__PURE__ */ jsx17(components.CustomVariantName, {}) : null,
1471
+ (components == null ? void 0 : components.ControlPercentage) ? /* @__PURE__ */ jsx17(components.ControlPercentage, {}) : null,
1472
+ !currentValue.crit.length ? /* @__PURE__ */ jsx17(Callout3, { title: "Default variant", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ jsx17(Paragraph, { children: 'This personalized variant has no match criteria and will be shown to any visitor that does not match any preceding variants. Ensure that default variants come last in the variant list. Personalize this variant by clicking "Add Criteria" to get started.' }) }) : /* @__PURE__ */ jsx17("div", { children: currentValue.crit.map((currentCriteria, index) => {
1473
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1474
+ const critHasLhs = ((_a2 = currentCriteria.l) == null ? void 0 : _a2.length) > 0;
1475
+ const critHasRhs = opHasRhs(currentCriteria.op);
1476
+ const selectedValueIsQuirk = "t" in currentCriteria && currentCriteria.t === "q";
1477
+ const currentDimension = selectedValueIsQuirk ? void 0 : dimensions.dimIndex[currentCriteria.l];
1478
+ const currentQuirk = selectedValueIsQuirk ? quirks == null ? void 0 : quirks.find((q) => q.id === currentCriteria.l) : void 0;
1479
+ return /* @__PURE__ */ jsxs9("div", { css: criteriaItem, "data-testid": "criteria-container", children: [
1480
+ /* @__PURE__ */ jsxs9("div", { css: criteriaItemInner, className: "criteriaItemInner", children: [
1481
+ /* @__PURE__ */ jsx17(
1482
+ "div",
1483
+ {
1484
+ css: [criteriaWrapper, criteriaOperandWrapper],
1485
+ className: "criteria-wrapper",
1486
+ "data-testid": "select-criteria",
1487
+ children: /* @__PURE__ */ jsx17(
1488
+ DimensionMenu,
1489
+ {
1490
+ errorMessage: (_b = errors.lhs) == null ? void 0 : _b[index],
1491
+ css: expand,
1492
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1493
+ dimensions: dimensions.dimensions,
1494
+ quirks,
1495
+ onChange: (selection) => {
1496
+ if (!selection) {
1497
+ return;
1498
+ }
1499
+ if ("dim" in selection) {
1500
+ const validOperators = getValidCriteriaOperatorsFor(selection.category);
1501
+ const existingOpRemainsValid = !("t" in currentCriteria && currentCriteria.t === "q") && validOperators.some((op) => op.value === currentCriteria.op);
1502
+ const newCriteria = {
1503
+ ...currentCriteria,
1504
+ l: selection.dim,
1505
+ t: void 0,
1506
+ op: existingOpRemainsValid ? currentCriteria.op : ">",
1507
+ r: existingOpRemainsValid ? currentCriteria.r : 0,
1508
+ rDim: existingOpRemainsValid ? currentCriteria.rDim : void 0
1509
+ };
1510
+ update(newCriteria, index);
1511
+ } else {
1512
+ update({ ...currentCriteria, l: selection.id, t: "q", op: "=", r: "" }, index);
1513
+ }
1514
+ },
1515
+ value: currentDimension != null ? currentDimension : currentQuirk,
1516
+ onMenuOpen,
1517
+ onMenuClose,
1518
+ disabled: readOnly
1519
+ }
1520
+ )
1521
+ }
1522
+ ),
1523
+ /* @__PURE__ */ jsx17(
1524
+ "div",
1525
+ {
1526
+ css: [criteriaWrapper, criteriaOperatorWrapper],
1527
+ className: "criteria-wrapper",
1528
+ "data-testid": "select-operator",
1529
+ children: /* @__PURE__ */ jsx17(
1530
+ CriteriaOperatorMenu,
1531
+ {
1532
+ name: `op-${index}`,
1533
+ css: expand,
1534
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1535
+ value: currentCriteria.op,
1536
+ rhsType: currentQuirk ? "QUIRK" : currentDimension == null ? void 0 : currentDimension.category,
1537
+ onChange: (op) => {
1538
+ if (op === "+" || op === "-") {
1539
+ update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
1540
+ } else {
1541
+ update({ ...currentCriteria, op }, index);
1542
+ }
1543
+ },
1544
+ onMenuOpen,
1545
+ onMenuClose,
1546
+ disabled: readOnly
1547
+ }
1548
+ )
1549
+ }
1550
+ ),
1551
+ critHasRhs ? /* @__PURE__ */ jsx17(
1552
+ "div",
1553
+ {
1554
+ css: [criteriaWrapper, criteriaOperandWrapper],
1555
+ className: "criteria-wrapper",
1556
+ "data-testid": "select-match-criteria",
1557
+ children: currentQuirk ? /* @__PURE__ */ jsx17(
1558
+ "div",
1559
+ {
1560
+ css: css8`
1561
+ width: 100%;
1562
+ // InputSelect wrapper is unstylable so need a descendant selector
1563
+ // to full-width it
1564
+ & > * {
1565
+ width: 100%;
1566
+ }
1567
+ `,
1568
+ children: currentQuirk.options ? /* @__PURE__ */ jsx17(
1569
+ InputSelect2,
1570
+ {
1571
+ label: "quirk match value",
1572
+ showLabel: false,
1573
+ value: (_c = currentCriteria.r) != null ? _c : "",
1574
+ errorMessage: (_d = errors.rhs) == null ? void 0 : _d[index],
1575
+ onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1576
+ options: [
1577
+ { label: "Select\u2026", value: "" },
1578
+ ...currentQuirk.options.map((o) => ({ label: o.name, value: o.value }))
1579
+ ],
1580
+ disabled: readOnly
1581
+ }
1582
+ ) : /* @__PURE__ */ jsx17(
1583
+ Input2,
1584
+ {
1585
+ type: "text",
1586
+ label: "quirk match value",
1587
+ showLabel: false,
1588
+ value: (_e = currentCriteria.r) != null ? _e : "",
1589
+ errorMessage: (_f = errors.rhs) == null ? void 0 : _f[index],
1590
+ onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1591
+ placeholder: "Enter a value",
1592
+ disabled: readOnly
1593
+ }
1594
+ )
1595
+ }
1596
+ ) : /* @__PURE__ */ jsx17(
1597
+ CriteriaMatchMenu,
1598
+ {
1599
+ errorMessage: (_g = errors.rhs) == null ? void 0 : _g[index],
1600
+ css: expand,
1601
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1602
+ criteriaMatch: currentCriteria,
1603
+ onChange: (match) => {
1604
+ update(match, index);
1605
+ },
1606
+ isDisabled: !critHasLhs,
1607
+ dimensions,
1608
+ onMenuOpen,
1609
+ onMenuClose,
1610
+ disabled: readOnly
1611
+ }
1612
+ )
1613
+ }
1614
+ ) : null
1615
+ ] }),
1455
1616
  /* @__PURE__ */ jsx17(
1456
- "div",
1617
+ "button",
1457
1618
  {
1458
- css: [criteriaWrapper, criteriaOperandWrapper],
1459
- className: "criteria-wrapper",
1460
- "data-testid": "select-criteria",
1461
- children: /* @__PURE__ */ jsx17(
1462
- DimensionMenu,
1463
- {
1464
- errorMessage: (_b = errors.lhs) == null ? void 0 : _b[index],
1465
- css: expand,
1466
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1467
- dimensions: dimensions.dimensions,
1468
- quirks,
1469
- onChange: (selection) => {
1470
- if (!selection) {
1471
- return;
1472
- }
1473
- if ("dim" in selection) {
1474
- const newCriteria = {
1475
- ...currentCriteria,
1476
- l: selection.dim,
1477
- t: void 0,
1478
- op: ">",
1479
- r: 0
1480
- };
1481
- update(newCriteria, index);
1482
- } else {
1483
- update({ ...currentCriteria, l: selection.id, t: "q", op: "=", r: "" }, index);
1484
- }
1485
- },
1486
- value: currentDimension != null ? currentDimension : currentQuirk,
1487
- onMenuOpen,
1488
- onMenuClose
1489
- }
1490
- )
1619
+ type: "button",
1620
+ onClick: () => removeFromList(index),
1621
+ title: `Delete Personalization`,
1622
+ css: { backgroundColor: "transparent", backgroundImage: "none", borderWidth: 0 },
1623
+ "data-testid": "button-delete",
1624
+ disabled: readOnly,
1625
+ children: /* @__PURE__ */ jsx17(Icon5, { icon: CgCloseO2, iconColor: "red", size: "1.5rem" })
1491
1626
  }
1492
1627
  ),
1493
- /* @__PURE__ */ jsx17(
1628
+ index > 0 ? /* @__PURE__ */ jsx17(
1494
1629
  "div",
1495
1630
  {
1496
- css: [criteriaWrapper, criteriaOperatorWrapper],
1497
- className: "criteria-wrapper",
1498
- "data-testid": "select-operator",
1631
+ className: "criteria-group-operation",
1632
+ css: {
1633
+ position: "absolute",
1634
+ top: "-4rem",
1635
+ transform: "translateX(calc(1.5rem - 50%))"
1636
+ },
1499
1637
  children: /* @__PURE__ */ jsx17(
1500
- CriteriaOperatorMenu,
1638
+ InputInlineSelect,
1501
1639
  {
1502
- name: `op-${index}`,
1503
- css: expand,
1504
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1505
- value: currentCriteria.op,
1506
- rhsType: currentQuirk ? "QUIRK" : currentDimension == null ? void 0 : currentDimension.category,
1507
- onChange: (op) => {
1508
- if (op === "+" || op === "-") {
1509
- update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
1510
- } else {
1511
- update({ ...currentCriteria, op }, index);
1512
- }
1513
- },
1514
- onMenuOpen,
1515
- onMenuClose
1516
- }
1517
- )
1518
- }
1519
- ),
1520
- critHasRhs ? /* @__PURE__ */ jsx17(
1521
- "div",
1522
- {
1523
- css: [criteriaWrapper, criteriaOperandWrapper],
1524
- className: "criteria-wrapper",
1525
- "data-testid": "select-match-criteria",
1526
- children: currentQuirk ? /* @__PURE__ */ jsx17(
1527
- "div",
1528
- {
1529
- css: css7`
1530
- width: 100%;
1531
- // InputSelect wrapper is unstylable so need a descendant selector
1532
- // to full-width it
1533
- & > * {
1534
- width: 100%;
1535
- }
1536
- `,
1537
- children: currentQuirk.options ? /* @__PURE__ */ jsx17(
1538
- InputSelect2,
1539
- {
1540
- label: "quirk match value",
1541
- showLabel: false,
1542
- value: (_c = currentCriteria.r) != null ? _c : "",
1543
- errorMessage: (_d = errors.rhs) == null ? void 0 : _d[index],
1544
- onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1545
- options: [
1546
- { label: "Select\u2026", value: "" },
1547
- ...currentQuirk.options.map((o) => ({ label: o.name, value: o.value }))
1548
- ]
1549
- }
1550
- ) : /* @__PURE__ */ jsx17(
1551
- Input2,
1552
- {
1553
- type: "text",
1554
- label: "quirk match value",
1555
- showLabel: false,
1556
- value: (_e = currentCriteria.r) != null ? _e : "",
1557
- errorMessage: (_f = errors.rhs) == null ? void 0 : _f[index],
1558
- onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1559
- placeholder: "Enter a value"
1560
- }
1561
- )
1562
- }
1563
- ) : /* @__PURE__ */ jsx17(
1564
- CriteriaMatchMenu,
1565
- {
1566
- errorMessage: (_g = errors.rhs) == null ? void 0 : _g[index],
1567
- css: expand,
1568
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1569
- criteriaMatch: currentCriteria,
1570
- onChange: (match) => {
1571
- update(match, index);
1572
- },
1573
- isDisabled: !critHasLhs,
1574
- dimensions,
1575
- onMenuOpen,
1576
- onMenuClose
1640
+ "data-testid": "dropdown-button-combine",
1641
+ disabled: index > 1 || readOnly,
1642
+ value: (_h = currentValue.op) != null ? _h : "&",
1643
+ options: [
1644
+ { label: "AND", value: "&" },
1645
+ { label: "OR", value: "|" }
1646
+ ],
1647
+ onChange: (v) => {
1648
+ setOp(v.value);
1649
+ }
1577
1650
  }
1578
1651
  )
1579
1652
  }
1580
1653
  ) : null
1581
- ] }),
1582
- /* @__PURE__ */ jsx17(
1583
- "button",
1584
- {
1585
- type: "button",
1586
- onClick: () => removeFromList(index),
1587
- title: `Delete Personalization`,
1588
- css: { backgroundColor: "transparent", backgroundImage: "none", borderWidth: 0 },
1589
- "data-testid": "button-delete",
1590
- children: /* @__PURE__ */ jsx17(Icon5, { icon: CgCloseO2, iconColor: "red", size: "1.5rem" })
1591
- }
1592
- ),
1593
- index > 0 ? /* @__PURE__ */ jsx17(
1594
- "div",
1595
- {
1596
- className: "criteria-group-operation",
1597
- css: {
1598
- position: "absolute",
1599
- top: "-4rem",
1600
- transform: "translateX(calc(1.5rem - 50%))"
1601
- },
1602
- children: /* @__PURE__ */ jsx17(
1603
- InputInlineSelect,
1604
- {
1605
- "data-testid": "dropdown-button-combine",
1606
- disabled: index > 1,
1607
- value: (_h = currentValue.op) != null ? _h : "&",
1608
- options: [
1609
- { label: "AND", value: "&" },
1610
- { label: "OR", value: "|" }
1611
- ],
1612
- onChange: (v) => {
1613
- setOp(v.value);
1614
- }
1615
- }
1616
- )
1617
- }
1618
- ) : null
1619
- ] }, index);
1620
- }) }),
1621
- dimensions.dimensions.length === 0 ? (components == null ? void 0 : components.NoDimensionsDefined) ? /* @__PURE__ */ jsx17(components.NoDimensionsDefined, {}) : /* @__PURE__ */ jsx17(Callout3, { title: "Dimensions", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ jsx17("p", { children: "You do not have any dimensions configured." }) }) : /* @__PURE__ */ jsx17(
1622
- AddListButton3,
1623
- {
1624
- "data-testid": "button-add-criteria",
1625
- className: "add-more",
1626
- buttonText: "Add Criteria",
1627
- onButtonClick: addToList
1628
- }
1629
- )
1654
+ ] }, index);
1655
+ }) }),
1656
+ dimensions.dimensions.length === 0 && !(quirks == null ? void 0 : quirks.length) ? (components == null ? void 0 : components.NoDimensionsDefined) ? /* @__PURE__ */ jsx17(components.NoDimensionsDefined, {}) : /* @__PURE__ */ jsx17(Callout3, { title: "Dimensions", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ jsx17("p", { children: "You do not have any dimensions configured." }) }) : /* @__PURE__ */ jsx17(
1657
+ AddListButton3,
1658
+ {
1659
+ "data-testid": "button-add-criteria",
1660
+ className: "add-more",
1661
+ buttonText: "Add Criteria",
1662
+ onButtonClick: addToList,
1663
+ disabled: readOnly
1664
+ }
1665
+ )
1666
+ ] })
1630
1667
  ] });
1631
1668
  };
1632
1669
 
@@ -1755,7 +1792,7 @@ function ProjectUIVersion({ children, versionMap, contextConfig }) {
1755
1792
  }
1756
1793
 
1757
1794
  // src/hooks/useValidateContextConfig.ts
1758
- import { useEffect as useEffect4, useState as useState8 } from "react";
1795
+ import { useEffect as useEffect5, useState as useState8 } from "react";
1759
1796
 
1760
1797
  // src/utils/validateContextConfig.ts
1761
1798
  import { UncachedManifestClient } from "@uniformdev/context/api";
@@ -1796,7 +1833,7 @@ var useValidateContextConfig = (contextConfig) => {
1796
1833
  error: void 0
1797
1834
  });
1798
1835
  const { apiKey, apiHost, projectId } = contextConfig || {};
1799
- useEffect4(() => {
1836
+ useEffect5(() => {
1800
1837
  if (!apiKey || !apiHost) {
1801
1838
  return;
1802
1839
  }
@@ -1837,6 +1874,7 @@ export {
1837
1874
  contextCriteriaMenuOperators,
1838
1875
  convertErrorsToObj,
1839
1876
  enrichmentCriteriaMenuOperators,
1877
+ getValidCriteriaOperatorsFor,
1840
1878
  isEnrichmentTagData,
1841
1879
  isPersonalizationCriteriaData,
1842
1880
  opHasRhs,