@uniformdev/context-ui 20.7.1-alpha.79 → 20.7.1-alpha.83

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.mjs 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,6 +875,7 @@ function DimensionMenu({
855
875
  InputComboBox4,
856
876
  {
857
877
  ...props,
878
+ isDisabled: props.disabled,
858
879
  value: valueAsMenuOption,
859
880
  options: groupedDimensions,
860
881
  getOptionValue: (option) => option.label,
@@ -893,8 +914,8 @@ import { CgChevronRight } from "@react-icons/all-files/cg/CgChevronRight";
893
914
  import { Icon as Icon3 } from "@uniformdev/design-system";
894
915
 
895
916
  // src/components/EditLink/EditLink.styles.ts
896
- import { css as css4 } from "@emotion/react";
897
- var editLink = css4`
917
+ import { css as css5 } from "@emotion/react";
918
+ var editLink = css5`
898
919
  display: flex;
899
920
  align-items: center;
900
921
  font-weight: var(--fw-bold);
@@ -927,7 +948,7 @@ var EditLink = ({ linkTo, name, linkText = `Edit ${name} Component` }) => {
927
948
  };
928
949
 
929
950
  // src/components/EnrichmentTag/EnrichmentTag.tsx
930
- import { css as css5 } from "@emotion/react";
951
+ import { css as css6 } from "@emotion/react";
931
952
  import { CgCloseO } from "@react-icons/all-files/cg/CgCloseO";
932
953
  import { CgMathMinus } from "@react-icons/all-files/cg/CgMathMinus";
933
954
  import { CgMathPlus } from "@react-icons/all-files/cg/CgMathPlus";
@@ -944,7 +965,7 @@ import {
944
965
  import { produce } from "immer";
945
966
  import { useMemo as useMemo2, useState as useState6 } from "react";
946
967
  import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs8 } from "@emotion/react/jsx-runtime";
947
- var addEnrichmentLink = css5`
968
+ var addEnrichmentLink = css6`
948
969
  flex: 2;
949
970
  display: flex;
950
971
  width: 50%;
@@ -1133,7 +1154,7 @@ var NoEnrichmentsView = ({ contextConfig }) => /* @__PURE__ */ jsx16(Callout2, {
1133
1154
  var getCappedValue = (value, maxCap = 100, minCap = 0) => {
1134
1155
  return Math.max(Math.min(value, maxCap), minCap);
1135
1156
  };
1136
- var scoreCounterMinusButtonStyles = css5`
1157
+ var scoreCounterMinusButtonStyles = css6`
1137
1158
  position: absolute;
1138
1159
  bottom: 0.875rem;
1139
1160
  left: var(--spacing-sm);
@@ -1146,7 +1167,7 @@ var scoreCounterMinusButtonStyles = css5`
1146
1167
  border: 1px solid var(--gray-300);
1147
1168
  border-radius: var(--rounded-full);
1148
1169
  `;
1149
- var scoreCounterPlusButtonStyles = css5`
1170
+ var scoreCounterPlusButtonStyles = css6`
1150
1171
  ${scoreCounterMinusButtonStyles}
1151
1172
  left: auto;
1152
1173
  right: var(--spacing-sm);
@@ -1310,7 +1331,7 @@ function opHasRhs(op) {
1310
1331
  }
1311
1332
 
1312
1333
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.tsx
1313
- import { css as css7 } from "@emotion/react";
1334
+ import { css as css8 } from "@emotion/react";
1314
1335
  import { CgCloseO as CgCloseO2 } from "@react-icons/all-files/cg/CgCloseO";
1315
1336
  import {
1316
1337
  AddListButton as AddListButton3,
@@ -1320,19 +1341,20 @@ import {
1320
1341
  Input as Input2,
1321
1342
  InputInlineSelect,
1322
1343
  InputSelect as InputSelect2,
1323
- Paragraph
1344
+ Paragraph,
1345
+ VerticalRhythm
1324
1346
  } from "@uniformdev/design-system";
1325
1347
  import { produce as produce2 } from "immer";
1326
1348
 
1327
1349
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.styles.ts
1328
- import { css as css6 } from "@emotion/react";
1350
+ import { css as css7 } from "@emotion/react";
1329
1351
  var spaceBetweenCriteriaItems = "6rem";
1330
- var criteriaItem = css6`
1352
+ var criteriaItem = css7`
1331
1353
  position: relative;
1332
1354
  padding: var(--spacing-md) var(--spacing-base);
1333
1355
  border: 1px solid var(--gray-300);
1334
- box-shadow: var(--shadow-base);
1335
- background-color: white;
1356
+ box-shadow: var(--elevation-200);
1357
+ background-color: var(--white);
1336
1358
  border-radius: var(--rounded-base);
1337
1359
  margin-top: ${spaceBetweenCriteriaItems};
1338
1360
  display: flex;
@@ -1349,13 +1371,13 @@ var criteriaItem = css6`
1349
1371
  }
1350
1372
 
1351
1373
  &:first-of-type {
1352
- margin-top: var(--spacing-md);
1374
+ margin-top: 0;
1353
1375
  &:before {
1354
1376
  display: none;
1355
1377
  }
1356
1378
  }
1357
1379
  `;
1358
- var criteriaItemInner = css6`
1380
+ var criteriaItemInner = css7`
1359
1381
  display: flex;
1360
1382
  row-gap: var(--spacing-base);
1361
1383
  column-gap: var(--spacing-xs);
@@ -1363,23 +1385,23 @@ var criteriaItemInner = css6`
1363
1385
  flex-wrap: wrap;
1364
1386
  margin-right: var(--spacing-base);
1365
1387
  `;
1366
- var criteriaWrapper = css6`
1388
+ var criteriaWrapper = css7`
1367
1389
  width: 100%;
1368
1390
  display: flex;
1369
1391
  align-items: stretch;
1370
1392
  position: relative;
1371
1393
  `;
1372
- var criteriaOperandWrapper = css6`
1394
+ var criteriaOperandWrapper = css7`
1373
1395
  flex: 2;
1374
1396
  height: 52px;
1375
1397
  min-width: 200px;
1376
1398
  `;
1377
- var criteriaOperatorWrapper = css6`
1399
+ var criteriaOperatorWrapper = css7`
1378
1400
  flex: 1;
1379
1401
  flex-wrap: nowrap;
1380
1402
  min-width: 80px;
1381
1403
  `;
1382
- var expand = css6`
1404
+ var expand = css7`
1383
1405
  height: 100%;
1384
1406
  width: 100%;
1385
1407
  `;
@@ -1397,7 +1419,8 @@ var PersonalizationCriteriaStatic = ({
1397
1419
  onRemoveCriteria,
1398
1420
  displayTitle = true,
1399
1421
  components,
1400
- errors = {}
1422
+ errors = {},
1423
+ readOnly
1401
1424
  }) => {
1402
1425
  var _a;
1403
1426
  const currentValue = { crit: [], ...value };
@@ -1443,192 +1466,204 @@ var PersonalizationCriteriaStatic = ({
1443
1466
  children: /* @__PURE__ */ jsx17(Heading2, { level: 5, withMarginBottom: false, children: "Personalization Variation" })
1444
1467
  }
1445
1468
  ) : null,
1446
- (components == null ? void 0 : components.CustomVariantName) ? /* @__PURE__ */ jsx17(components.CustomVariantName, {}) : null,
1447
- (components == null ? void 0 : components.ControlPercentage) ? /* @__PURE__ */ jsx17(components.ControlPercentage, {}) : null,
1448
- !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) => {
1449
- var _a2, _b, _c, _d, _e, _f, _g, _h;
1450
- const critHasLhs = ((_a2 = currentCriteria.l) == null ? void 0 : _a2.length) > 0;
1451
- const critHasRhs = opHasRhs(currentCriteria.op);
1452
- const selectedValueIsQuirk = "t" in currentCriteria && currentCriteria.t === "q";
1453
- const currentDimension = selectedValueIsQuirk ? void 0 : dimensions.dimIndex[currentCriteria.l];
1454
- const currentQuirk = selectedValueIsQuirk ? quirks == null ? void 0 : quirks.find((q) => q.id === currentCriteria.l) : void 0;
1455
- return /* @__PURE__ */ jsxs9("div", { css: criteriaItem, "data-testid": "criteria-container", children: [
1456
- /* @__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
+ ] }),
1457
1616
  /* @__PURE__ */ jsx17(
1458
- "div",
1617
+ "button",
1459
1618
  {
1460
- css: [criteriaWrapper, criteriaOperandWrapper],
1461
- className: "criteria-wrapper",
1462
- "data-testid": "select-criteria",
1463
- children: /* @__PURE__ */ jsx17(
1464
- DimensionMenu,
1465
- {
1466
- errorMessage: (_b = errors.lhs) == null ? void 0 : _b[index],
1467
- css: expand,
1468
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1469
- dimensions: dimensions.dimensions,
1470
- quirks,
1471
- onChange: (selection) => {
1472
- if (!selection) {
1473
- return;
1474
- }
1475
- if ("dim" in selection) {
1476
- const newCriteria = {
1477
- ...currentCriteria,
1478
- l: selection.dim,
1479
- t: void 0,
1480
- op: ">",
1481
- r: 0
1482
- };
1483
- update(newCriteria, index);
1484
- } else {
1485
- update({ ...currentCriteria, l: selection.id, t: "q", op: "=", r: "" }, index);
1486
- }
1487
- },
1488
- value: currentDimension != null ? currentDimension : currentQuirk,
1489
- onMenuOpen,
1490
- onMenuClose
1491
- }
1492
- )
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" })
1493
1626
  }
1494
1627
  ),
1495
- /* @__PURE__ */ jsx17(
1628
+ index > 0 ? /* @__PURE__ */ jsx17(
1496
1629
  "div",
1497
1630
  {
1498
- css: [criteriaWrapper, criteriaOperatorWrapper],
1499
- className: "criteria-wrapper",
1500
- "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
+ },
1501
1637
  children: /* @__PURE__ */ jsx17(
1502
- CriteriaOperatorMenu,
1638
+ InputInlineSelect,
1503
1639
  {
1504
- name: `op-${index}`,
1505
- css: expand,
1506
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1507
- value: currentCriteria.op,
1508
- rhsType: currentQuirk ? "QUIRK" : currentDimension == null ? void 0 : currentDimension.category,
1509
- onChange: (op) => {
1510
- if (op === "+" || op === "-") {
1511
- update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
1512
- } else {
1513
- update({ ...currentCriteria, op }, index);
1514
- }
1515
- },
1516
- onMenuOpen,
1517
- onMenuClose
1518
- }
1519
- )
1520
- }
1521
- ),
1522
- critHasRhs ? /* @__PURE__ */ jsx17(
1523
- "div",
1524
- {
1525
- css: [criteriaWrapper, criteriaOperandWrapper],
1526
- className: "criteria-wrapper",
1527
- "data-testid": "select-match-criteria",
1528
- children: currentQuirk ? /* @__PURE__ */ jsx17(
1529
- "div",
1530
- {
1531
- css: css7`
1532
- width: 100%;
1533
- // InputSelect wrapper is unstylable so need a descendant selector
1534
- // to full-width it
1535
- & > * {
1536
- width: 100%;
1537
- }
1538
- `,
1539
- children: currentQuirk.options ? /* @__PURE__ */ jsx17(
1540
- InputSelect2,
1541
- {
1542
- label: "quirk match value",
1543
- showLabel: false,
1544
- value: (_c = currentCriteria.r) != null ? _c : "",
1545
- errorMessage: (_d = errors.rhs) == null ? void 0 : _d[index],
1546
- onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1547
- options: [
1548
- { label: "Select\u2026", value: "" },
1549
- ...currentQuirk.options.map((o) => ({ label: o.name, value: o.value }))
1550
- ]
1551
- }
1552
- ) : /* @__PURE__ */ jsx17(
1553
- Input2,
1554
- {
1555
- type: "text",
1556
- label: "quirk match value",
1557
- showLabel: false,
1558
- value: (_e = currentCriteria.r) != null ? _e : "",
1559
- errorMessage: (_f = errors.rhs) == null ? void 0 : _f[index],
1560
- onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1561
- placeholder: "Enter a value"
1562
- }
1563
- )
1564
- }
1565
- ) : /* @__PURE__ */ jsx17(
1566
- CriteriaMatchMenu,
1567
- {
1568
- errorMessage: (_g = errors.rhs) == null ? void 0 : _g[index],
1569
- css: expand,
1570
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1571
- criteriaMatch: currentCriteria,
1572
- onChange: (match) => {
1573
- update(match, index);
1574
- },
1575
- isDisabled: !critHasLhs,
1576
- dimensions,
1577
- onMenuOpen,
1578
- 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
+ }
1579
1650
  }
1580
1651
  )
1581
1652
  }
1582
1653
  ) : null
1583
- ] }),
1584
- /* @__PURE__ */ jsx17(
1585
- "button",
1586
- {
1587
- type: "button",
1588
- onClick: () => removeFromList(index),
1589
- title: `Delete Personalization`,
1590
- css: { backgroundColor: "transparent", backgroundImage: "none", borderWidth: 0 },
1591
- "data-testid": "button-delete",
1592
- children: /* @__PURE__ */ jsx17(Icon5, { icon: CgCloseO2, iconColor: "red", size: "1.5rem" })
1593
- }
1594
- ),
1595
- index > 0 ? /* @__PURE__ */ jsx17(
1596
- "div",
1597
- {
1598
- className: "criteria-group-operation",
1599
- css: {
1600
- position: "absolute",
1601
- top: "-4rem",
1602
- transform: "translateX(calc(1.5rem - 50%))"
1603
- },
1604
- children: /* @__PURE__ */ jsx17(
1605
- InputInlineSelect,
1606
- {
1607
- "data-testid": "dropdown-button-combine",
1608
- disabled: index > 1,
1609
- value: (_h = currentValue.op) != null ? _h : "&",
1610
- options: [
1611
- { label: "AND", value: "&" },
1612
- { label: "OR", value: "|" }
1613
- ],
1614
- onChange: (v) => {
1615
- setOp(v.value);
1616
- }
1617
- }
1618
- )
1619
- }
1620
- ) : null
1621
- ] }, index);
1622
- }) }),
1623
- 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(
1624
- AddListButton3,
1625
- {
1626
- "data-testid": "button-add-criteria",
1627
- className: "add-more",
1628
- buttonText: "Add Criteria",
1629
- onButtonClick: addToList
1630
- }
1631
- )
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
+ ] })
1632
1667
  ] });
1633
1668
  };
1634
1669
 
@@ -1757,7 +1792,7 @@ function ProjectUIVersion({ children, versionMap, contextConfig }) {
1757
1792
  }
1758
1793
 
1759
1794
  // src/hooks/useValidateContextConfig.ts
1760
- import { useEffect as useEffect4, useState as useState8 } from "react";
1795
+ import { useEffect as useEffect5, useState as useState8 } from "react";
1761
1796
 
1762
1797
  // src/utils/validateContextConfig.ts
1763
1798
  import { UncachedManifestClient } from "@uniformdev/context/api";
@@ -1798,7 +1833,7 @@ var useValidateContextConfig = (contextConfig) => {
1798
1833
  error: void 0
1799
1834
  });
1800
1835
  const { apiKey, apiHost, projectId } = contextConfig || {};
1801
- useEffect4(() => {
1836
+ useEffect5(() => {
1802
1837
  if (!apiKey || !apiHost) {
1803
1838
  return;
1804
1839
  }
@@ -1839,6 +1874,7 @@ export {
1839
1874
  contextCriteriaMenuOperators,
1840
1875
  convertErrorsToObj,
1841
1876
  enrichmentCriteriaMenuOperators,
1877
+ getValidCriteriaOperatorsFor,
1842
1878
  isEnrichmentTagData,
1843
1879
  isPersonalizationCriteriaData,
1844
1880
  opHasRhs,