@uniformdev/context-ui 20.31.1-alpha.1 → 20.31.1-alpha.184

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.js CHANGED
@@ -47,6 +47,7 @@ __export(src_exports, {
47
47
  contextCriteriaMenuOperators: () => contextCriteriaMenuOperators,
48
48
  convertErrorsToObj: () => convertErrorsToObj,
49
49
  enrichmentCriteriaMenuOperators: () => enrichmentCriteriaMenuOperators,
50
+ getValidCriteriaOperatorsFor: () => getValidCriteriaOperatorsFor,
50
51
  isEnrichmentTagData: () => isEnrichmentTagData,
51
52
  isPersonalizationCriteriaData: () => isPersonalizationCriteriaData,
52
53
  opHasRhs: () => opHasRhs,
@@ -363,9 +364,12 @@ var quirkCriteriaMenuOperators = [
363
364
  value: "!="
364
365
  }
365
366
  ];
367
+ function getValidCriteriaOperatorsFor(rhsType) {
368
+ return rhsType === "QUIRK" ? quirkCriteriaMenuOperators : rhsType === "ENR" ? enrichmentCriteriaMenuOperators : contextCriteriaMenuOperators;
369
+ }
366
370
  function CriteriaOperatorMenu({ onChange, value, rhsType, ...props }) {
367
371
  var _a, _b;
368
- const operators = rhsType === "QUIRK" ? quirkCriteriaMenuOperators : rhsType === "ENR" ? enrichmentCriteriaMenuOperators : contextCriteriaMenuOperators;
372
+ const operators = getValidCriteriaOperatorsFor(rhsType);
369
373
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
370
374
  import_design_system2.InputComboBox,
371
375
  {
@@ -606,7 +610,7 @@ function useDimensionsDataContext() {
606
610
 
607
611
  // src/components/DimensionMenu/CriteriaMatchMenu.tsx
608
612
  var import_design_system6 = require("@uniformdev/design-system");
609
- var import_react11 = require("react");
613
+ var import_react12 = require("react");
610
614
 
611
615
  // src/components/DimensionMenu/DimensionGroupHeading.tsx
612
616
  var import_design_system4 = require("@uniformdev/design-system");
@@ -745,32 +749,38 @@ var DimensionOption = (props) => {
745
749
  };
746
750
 
747
751
  // src/components/DimensionMenu/DimensionValue.tsx
752
+ var import_react11 = require("@emotion/react");
748
753
  var import_design_system5 = require("@uniformdev/design-system");
749
754
  var import_jsx_runtime10 = require("@emotion/react/jsx-runtime");
755
+ var styles = {
756
+ dimensionValueWrapper: import_react11.css`
757
+ white-space: normal;
758
+ overflow: hidden;
759
+ `,
760
+ dimensionName: import_react11.css`
761
+ color: var(--gray-500);
762
+ display: flex;
763
+ align-items: center;
764
+ gap: var(--spacing-xs);
765
+ `,
766
+ dimensionValue: import_react11.css`
767
+ color: var(--gray-700);
768
+ text-overflow: ellipsis;
769
+ overflow: hidden;
770
+ white-space: nowrap;
771
+ `
772
+ };
750
773
  function DimensionValue({ displayName }) {
774
+ var _a;
751
775
  const { type, name } = dimensionDisplayName(displayName);
752
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
753
- "div",
754
- {
755
- css: {
756
- whiteSpace: "normal",
757
- overflow: "hidden"
758
- },
759
- children: [
760
- type ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
761
- "small",
762
- {
763
- css: { color: "var(--gray-500)", display: "flex", alignItems: "center", gap: "var(--spacing-xs)" },
764
- children: [
765
- type ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system5.Icon, { icon: dimensionIcon(type), iconColor: "currentColor", size: 16 }) : null,
766
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "data-testid": "dimension-name", children: type })
767
- ]
768
- }
769
- ) : null,
770
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { css: { color: "var(--gray-700)" }, "data-testid": "dimension-value", children: name != null ? name : type })
771
- ]
772
- }
773
- );
776
+ const tooltip = (_a = name != null ? name : type) != null ? _a : "";
777
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { css: styles.dimensionValueWrapper, children: [
778
+ type ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("small", { css: styles.dimensionName, children: [
779
+ type ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system5.Icon, { icon: dimensionIcon(type), iconColor: "currentColor", size: 16 }) : null,
780
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "data-testid": "dimension-name", children: type })
781
+ ] }) : null,
782
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system5.Tooltip, { title: tooltip, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { css: styles.dimensionValue, "data-testid": "dimension-value", children: name != null ? name : type }) })
783
+ ] });
774
784
  }
775
785
 
776
786
  // src/components/DimensionMenu/DimensionSingleValue.tsx
@@ -790,9 +800,18 @@ function CriteriaMatchMenu({
790
800
  ...props
791
801
  }) {
792
802
  var _a, _b;
793
- const [inputValue, setInputValue] = (0, import_react11.useState)(
803
+ const [inputValue, setInputValue] = (0, import_react12.useState)(
794
804
  typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
795
805
  );
806
+ const currentInputValue = (0, import_react12.useRef)(inputValue);
807
+ currentInputValue.current = inputValue;
808
+ (0, import_react12.useEffect)(() => {
809
+ if (currentInputValue.current !== criteriaMatch.r && !criteriaMatch.rDim) {
810
+ setInputValue(
811
+ typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
812
+ );
813
+ }
814
+ }, [criteriaMatch.r, criteriaMatch.rDim]);
796
815
  const rDim = criteriaMatch.rDim;
797
816
  const targetDim = criteriaMatch.rDim ? dimensions.dimIndex[criteriaMatch.rDim] : void 0;
798
817
  const groupedDimensions = useGroupedDimensions(dimensions.dimensions, void 0);
@@ -946,8 +965,8 @@ var import_CgChevronRight = require("@react-icons/all-files/cg/CgChevronRight");
946
965
  var import_design_system8 = require("@uniformdev/design-system");
947
966
 
948
967
  // src/components/EditLink/EditLink.styles.ts
949
- var import_react12 = require("@emotion/react");
950
- var editLink = import_react12.css`
968
+ var import_react13 = require("@emotion/react");
969
+ var editLink = import_react13.css`
951
970
  display: flex;
952
971
  align-items: center;
953
972
  font-weight: var(--fw-bold);
@@ -980,16 +999,16 @@ var EditLink = ({ linkTo, name, linkText = `Edit ${name} Component` }) => {
980
999
  };
981
1000
 
982
1001
  // src/components/EnrichmentTag/EnrichmentTag.tsx
983
- var import_react13 = require("@emotion/react");
1002
+ var import_react14 = require("@emotion/react");
984
1003
  var import_CgCloseO = require("@react-icons/all-files/cg/CgCloseO");
985
1004
  var import_CgMathMinus = require("@react-icons/all-files/cg/CgMathMinus");
986
1005
  var import_CgMathPlus = require("@react-icons/all-files/cg/CgMathPlus");
987
1006
  var import_context = require("@uniformdev/context");
988
1007
  var import_design_system9 = require("@uniformdev/design-system");
989
1008
  var import_immer = require("immer");
990
- var import_react14 = require("react");
1009
+ var import_react15 = require("react");
991
1010
  var import_jsx_runtime15 = require("@emotion/react/jsx-runtime");
992
- var addEnrichmentLink = import_react13.css`
1011
+ var addEnrichmentLink = import_react14.css`
993
1012
  flex: 2;
994
1013
  display: flex;
995
1014
  width: 50%;
@@ -1008,19 +1027,19 @@ var EnrichmentTag = ({
1008
1027
  displayTitle = true
1009
1028
  }) => {
1010
1029
  const { loading, result: dimensions, error } = useDimensions(contextConfig);
1011
- const allEnrichments = (0, import_react14.useMemo)(() => {
1030
+ const allEnrichments = (0, import_react15.useMemo)(() => {
1012
1031
  if (dimensions) return dimensions.dimensions.filter((dimension) => dimension.category === "ENR");
1013
1032
  }, [dimensions]);
1014
- const remainingEnrichments = (0, import_react14.useMemo)(() => {
1033
+ const remainingEnrichments = (0, import_react15.useMemo)(() => {
1015
1034
  if (!value) return allEnrichments;
1016
1035
  if (allEnrichments)
1017
1036
  return allEnrichments.filter(
1018
1037
  (enr) => !value.some((val) => (0, import_context.getEnrichmentVectorKey)(val.cat, val.key) === enr.dim)
1019
1038
  );
1020
1039
  }, [allEnrichments, value]);
1021
- const [selectValue, setSelectValue] = (0, import_react14.useState)("");
1022
- const [score, setScore] = (0, import_react14.useState)(50);
1023
- const [showAddNewEnrichmentTagPanel, setShowAddNewEnrichmentTagPanel] = (0, import_react14.useState)(false);
1040
+ const [selectValue, setSelectValue] = (0, import_react15.useState)("");
1041
+ const [score, setScore] = (0, import_react15.useState)(50);
1042
+ const [showAddNewEnrichmentTagPanel, setShowAddNewEnrichmentTagPanel] = (0, import_react15.useState)(false);
1024
1043
  const selectedEnrichment = allEnrichments == null ? void 0 : allEnrichments.find((dimension) => dimension.dim === selectValue);
1025
1044
  const addEnrichment = () => {
1026
1045
  const [cat, key] = selectValue.split("_");
@@ -1178,7 +1197,7 @@ var NoEnrichmentsView = ({ contextConfig }) => /* @__PURE__ */ (0, import_jsx_ru
1178
1197
  var getCappedValue = (value, maxCap = 100, minCap = 0) => {
1179
1198
  return Math.max(Math.min(value, maxCap), minCap);
1180
1199
  };
1181
- var scoreCounterMinusButtonStyles = import_react13.css`
1200
+ var scoreCounterMinusButtonStyles = import_react14.css`
1182
1201
  position: absolute;
1183
1202
  bottom: 0.875rem;
1184
1203
  left: var(--spacing-sm);
@@ -1191,7 +1210,7 @@ var scoreCounterMinusButtonStyles = import_react13.css`
1191
1210
  border: 1px solid var(--gray-300);
1192
1211
  border-radius: var(--rounded-full);
1193
1212
  `;
1194
- var scoreCounterPlusButtonStyles = import_react13.css`
1213
+ var scoreCounterPlusButtonStyles = import_react14.css`
1195
1214
  ${scoreCounterMinusButtonStyles}
1196
1215
  left: auto;
1197
1216
  right: var(--spacing-sm);
@@ -1339,7 +1358,7 @@ var SelectedEnrichments = ({ list, setList, dimIndex }) => {
1339
1358
 
1340
1359
  // src/components/PersonalizationCriteria/PersonalizationCriteria.tsx
1341
1360
  var import_design_system11 = require("@uniformdev/design-system");
1342
- var import_react17 = require("react");
1361
+ var import_react18 = require("react");
1343
1362
  var import_react_use = require("react-use");
1344
1363
  var yup = __toESM(require("yup"));
1345
1364
 
@@ -1355,20 +1374,20 @@ function opHasRhs(op) {
1355
1374
  }
1356
1375
 
1357
1376
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.tsx
1358
- var import_react16 = require("@emotion/react");
1377
+ var import_react17 = require("@emotion/react");
1359
1378
  var import_CgCloseO2 = require("@react-icons/all-files/cg/CgCloseO");
1360
1379
  var import_design_system10 = require("@uniformdev/design-system");
1361
1380
  var import_immer2 = require("immer");
1362
1381
 
1363
1382
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.styles.ts
1364
- var import_react15 = require("@emotion/react");
1383
+ var import_react16 = require("@emotion/react");
1365
1384
  var spaceBetweenCriteriaItems = "6rem";
1366
- var criteriaItem = import_react15.css`
1385
+ var criteriaItem = import_react16.css`
1367
1386
  position: relative;
1368
1387
  padding: var(--spacing-md) var(--spacing-base);
1369
1388
  border: 1px solid var(--gray-300);
1370
- box-shadow: var(--shadow-base);
1371
- background-color: white;
1389
+ box-shadow: var(--elevation-200);
1390
+ background-color: var(--white);
1372
1391
  border-radius: var(--rounded-base);
1373
1392
  margin-top: ${spaceBetweenCriteriaItems};
1374
1393
  display: flex;
@@ -1385,13 +1404,13 @@ var criteriaItem = import_react15.css`
1385
1404
  }
1386
1405
 
1387
1406
  &:first-of-type {
1388
- margin-top: var(--spacing-md);
1407
+ margin-top: 0;
1389
1408
  &:before {
1390
1409
  display: none;
1391
1410
  }
1392
1411
  }
1393
1412
  `;
1394
- var criteriaItemInner = import_react15.css`
1413
+ var criteriaItemInner = import_react16.css`
1395
1414
  display: flex;
1396
1415
  row-gap: var(--spacing-base);
1397
1416
  column-gap: var(--spacing-xs);
@@ -1399,23 +1418,23 @@ var criteriaItemInner = import_react15.css`
1399
1418
  flex-wrap: wrap;
1400
1419
  margin-right: var(--spacing-base);
1401
1420
  `;
1402
- var criteriaWrapper = import_react15.css`
1421
+ var criteriaWrapper = import_react16.css`
1403
1422
  width: 100%;
1404
1423
  display: flex;
1405
1424
  align-items: stretch;
1406
1425
  position: relative;
1407
1426
  `;
1408
- var criteriaOperandWrapper = import_react15.css`
1427
+ var criteriaOperandWrapper = import_react16.css`
1409
1428
  flex: 2;
1410
1429
  height: 52px;
1411
1430
  min-width: 200px;
1412
1431
  `;
1413
- var criteriaOperatorWrapper = import_react15.css`
1432
+ var criteriaOperatorWrapper = import_react16.css`
1414
1433
  flex: 1;
1415
1434
  flex-wrap: nowrap;
1416
1435
  min-width: 80px;
1417
1436
  `;
1418
- var expand = import_react15.css`
1437
+ var expand = import_react16.css`
1419
1438
  height: 100%;
1420
1439
  width: 100%;
1421
1440
  `;
@@ -1479,192 +1498,197 @@ var PersonalizationCriteriaStatic = ({
1479
1498
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Heading, { level: 5, withMarginBottom: false, children: "Personalization Variation" })
1480
1499
  }
1481
1500
  ) : null,
1482
- (components == null ? void 0 : components.CustomVariantName) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.CustomVariantName, {}) : null,
1483
- (components == null ? void 0 : components.ControlPercentage) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.ControlPercentage, {}) : null,
1484
- !currentValue.crit.length ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Callout, { title: "Default variant", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.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__ */ (0, import_jsx_runtime16.jsx)("div", { children: currentValue.crit.map((currentCriteria, index) => {
1485
- var _a2, _b, _c, _d, _e, _f, _g, _h;
1486
- const critHasLhs = ((_a2 = currentCriteria.l) == null ? void 0 : _a2.length) > 0;
1487
- const critHasRhs = opHasRhs(currentCriteria.op);
1488
- const selectedValueIsQuirk = "t" in currentCriteria && currentCriteria.t === "q";
1489
- const currentDimension = selectedValueIsQuirk ? void 0 : dimensions.dimIndex[currentCriteria.l];
1490
- const currentQuirk = selectedValueIsQuirk ? quirks == null ? void 0 : quirks.find((q) => q.id === currentCriteria.l) : void 0;
1491
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css: criteriaItem, "data-testid": "criteria-container", children: [
1492
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css: criteriaItemInner, className: "criteriaItemInner", children: [
1501
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_design_system10.VerticalRhythm, { children: [
1502
+ (components == null ? void 0 : components.CustomVariantName) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.CustomVariantName, {}) : null,
1503
+ (components == null ? void 0 : components.ControlPercentage) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.ControlPercentage, {}) : null,
1504
+ !currentValue.crit.length ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Callout, { title: "Default variant", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.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__ */ (0, import_jsx_runtime16.jsx)("div", { children: currentValue.crit.map((currentCriteria, index) => {
1505
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1506
+ const critHasLhs = ((_a2 = currentCriteria.l) == null ? void 0 : _a2.length) > 0;
1507
+ const critHasRhs = opHasRhs(currentCriteria.op);
1508
+ const selectedValueIsQuirk = "t" in currentCriteria && currentCriteria.t === "q";
1509
+ const currentDimension = selectedValueIsQuirk ? void 0 : dimensions.dimIndex[currentCriteria.l];
1510
+ const currentQuirk = selectedValueIsQuirk ? quirks == null ? void 0 : quirks.find((q) => q.id === currentCriteria.l) : void 0;
1511
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css: criteriaItem, "data-testid": "criteria-container", children: [
1512
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css: criteriaItemInner, className: "criteriaItemInner", children: [
1513
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1514
+ "div",
1515
+ {
1516
+ css: [criteriaWrapper, criteriaOperandWrapper],
1517
+ className: "criteria-wrapper",
1518
+ "data-testid": "select-criteria",
1519
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1520
+ DimensionMenu,
1521
+ {
1522
+ errorMessage: (_b = errors.lhs) == null ? void 0 : _b[index],
1523
+ css: expand,
1524
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1525
+ dimensions: dimensions.dimensions,
1526
+ quirks,
1527
+ onChange: (selection) => {
1528
+ if (!selection) {
1529
+ return;
1530
+ }
1531
+ if ("dim" in selection) {
1532
+ const validOperators = getValidCriteriaOperatorsFor(selection.category);
1533
+ const existingOpRemainsValid = !("t" in currentCriteria && currentCriteria.t === "q") && validOperators.some((op) => op.value === currentCriteria.op);
1534
+ const newCriteria = {
1535
+ ...currentCriteria,
1536
+ l: selection.dim,
1537
+ t: void 0,
1538
+ op: existingOpRemainsValid ? currentCriteria.op : ">",
1539
+ r: existingOpRemainsValid ? currentCriteria.r : 0,
1540
+ rDim: existingOpRemainsValid ? currentCriteria.rDim : void 0
1541
+ };
1542
+ update(newCriteria, index);
1543
+ } else {
1544
+ update({ ...currentCriteria, l: selection.id, t: "q", op: "=", r: "" }, index);
1545
+ }
1546
+ },
1547
+ value: currentDimension != null ? currentDimension : currentQuirk,
1548
+ onMenuOpen,
1549
+ onMenuClose
1550
+ }
1551
+ )
1552
+ }
1553
+ ),
1554
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1555
+ "div",
1556
+ {
1557
+ css: [criteriaWrapper, criteriaOperatorWrapper],
1558
+ className: "criteria-wrapper",
1559
+ "data-testid": "select-operator",
1560
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1561
+ CriteriaOperatorMenu,
1562
+ {
1563
+ name: `op-${index}`,
1564
+ css: expand,
1565
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1566
+ value: currentCriteria.op,
1567
+ rhsType: currentQuirk ? "QUIRK" : currentDimension == null ? void 0 : currentDimension.category,
1568
+ onChange: (op) => {
1569
+ if (op === "+" || op === "-") {
1570
+ update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
1571
+ } else {
1572
+ update({ ...currentCriteria, op }, index);
1573
+ }
1574
+ },
1575
+ onMenuOpen,
1576
+ onMenuClose
1577
+ }
1578
+ )
1579
+ }
1580
+ ),
1581
+ critHasRhs ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1582
+ "div",
1583
+ {
1584
+ css: [criteriaWrapper, criteriaOperandWrapper],
1585
+ className: "criteria-wrapper",
1586
+ "data-testid": "select-match-criteria",
1587
+ children: currentQuirk ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1588
+ "div",
1589
+ {
1590
+ css: import_react17.css`
1591
+ width: 100%;
1592
+ // InputSelect wrapper is unstylable so need a descendant selector
1593
+ // to full-width it
1594
+ & > * {
1595
+ width: 100%;
1596
+ }
1597
+ `,
1598
+ children: currentQuirk.options ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1599
+ import_design_system10.InputSelect,
1600
+ {
1601
+ label: "quirk match value",
1602
+ showLabel: false,
1603
+ value: (_c = currentCriteria.r) != null ? _c : "",
1604
+ errorMessage: (_d = errors.rhs) == null ? void 0 : _d[index],
1605
+ onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1606
+ options: [
1607
+ { label: "Select\u2026", value: "" },
1608
+ ...currentQuirk.options.map((o) => ({ label: o.name, value: o.value }))
1609
+ ]
1610
+ }
1611
+ ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1612
+ import_design_system10.Input,
1613
+ {
1614
+ type: "text",
1615
+ label: "quirk match value",
1616
+ showLabel: false,
1617
+ value: (_e = currentCriteria.r) != null ? _e : "",
1618
+ errorMessage: (_f = errors.rhs) == null ? void 0 : _f[index],
1619
+ onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1620
+ placeholder: "Enter a value"
1621
+ }
1622
+ )
1623
+ }
1624
+ ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1625
+ CriteriaMatchMenu,
1626
+ {
1627
+ errorMessage: (_g = errors.rhs) == null ? void 0 : _g[index],
1628
+ css: expand,
1629
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1630
+ criteriaMatch: currentCriteria,
1631
+ onChange: (match) => {
1632
+ update(match, index);
1633
+ },
1634
+ isDisabled: !critHasLhs,
1635
+ dimensions,
1636
+ onMenuOpen,
1637
+ onMenuClose
1638
+ }
1639
+ )
1640
+ }
1641
+ ) : null
1642
+ ] }),
1493
1643
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1494
- "div",
1644
+ "button",
1495
1645
  {
1496
- css: [criteriaWrapper, criteriaOperandWrapper],
1497
- className: "criteria-wrapper",
1498
- "data-testid": "select-criteria",
1499
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1500
- DimensionMenu,
1501
- {
1502
- errorMessage: (_b = errors.lhs) == null ? void 0 : _b[index],
1503
- css: expand,
1504
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1505
- dimensions: dimensions.dimensions,
1506
- quirks,
1507
- onChange: (selection) => {
1508
- if (!selection) {
1509
- return;
1510
- }
1511
- if ("dim" in selection) {
1512
- const newCriteria = {
1513
- ...currentCriteria,
1514
- l: selection.dim,
1515
- t: void 0,
1516
- op: ">",
1517
- r: 0
1518
- };
1519
- update(newCriteria, index);
1520
- } else {
1521
- update({ ...currentCriteria, l: selection.id, t: "q", op: "=", r: "" }, index);
1522
- }
1523
- },
1524
- value: currentDimension != null ? currentDimension : currentQuirk,
1525
- onMenuOpen,
1526
- onMenuClose
1527
- }
1528
- )
1646
+ type: "button",
1647
+ onClick: () => removeFromList(index),
1648
+ title: `Delete Personalization`,
1649
+ css: { backgroundColor: "transparent", backgroundImage: "none", borderWidth: 0 },
1650
+ "data-testid": "button-delete",
1651
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Icon, { icon: import_CgCloseO2.CgCloseO, iconColor: "red", size: "1.5rem" })
1529
1652
  }
1530
1653
  ),
1531
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1654
+ index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1532
1655
  "div",
1533
1656
  {
1534
- css: [criteriaWrapper, criteriaOperatorWrapper],
1535
- className: "criteria-wrapper",
1536
- "data-testid": "select-operator",
1657
+ className: "criteria-group-operation",
1658
+ css: {
1659
+ position: "absolute",
1660
+ top: "-4rem",
1661
+ transform: "translateX(calc(1.5rem - 50%))"
1662
+ },
1537
1663
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1538
- CriteriaOperatorMenu,
1539
- {
1540
- name: `op-${index}`,
1541
- css: expand,
1542
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1543
- value: currentCriteria.op,
1544
- rhsType: currentQuirk ? "QUIRK" : currentDimension == null ? void 0 : currentDimension.category,
1545
- onChange: (op) => {
1546
- if (op === "+" || op === "-") {
1547
- update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
1548
- } else {
1549
- update({ ...currentCriteria, op }, index);
1550
- }
1551
- },
1552
- onMenuOpen,
1553
- onMenuClose
1554
- }
1555
- )
1556
- }
1557
- ),
1558
- critHasRhs ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1559
- "div",
1560
- {
1561
- css: [criteriaWrapper, criteriaOperandWrapper],
1562
- className: "criteria-wrapper",
1563
- "data-testid": "select-match-criteria",
1564
- children: currentQuirk ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1565
- "div",
1664
+ import_design_system10.InputInlineSelect,
1566
1665
  {
1567
- css: import_react16.css`
1568
- width: 100%;
1569
- // InputSelect wrapper is unstylable so need a descendant selector
1570
- // to full-width it
1571
- & > * {
1572
- width: 100%;
1573
- }
1574
- `,
1575
- children: currentQuirk.options ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1576
- import_design_system10.InputSelect,
1577
- {
1578
- label: "quirk match value",
1579
- showLabel: false,
1580
- value: (_c = currentCriteria.r) != null ? _c : "",
1581
- errorMessage: (_d = errors.rhs) == null ? void 0 : _d[index],
1582
- onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1583
- options: [
1584
- { label: "Select\u2026", value: "" },
1585
- ...currentQuirk.options.map((o) => ({ label: o.name, value: o.value }))
1586
- ]
1587
- }
1588
- ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1589
- import_design_system10.Input,
1590
- {
1591
- type: "text",
1592
- label: "quirk match value",
1593
- showLabel: false,
1594
- value: (_e = currentCriteria.r) != null ? _e : "",
1595
- errorMessage: (_f = errors.rhs) == null ? void 0 : _f[index],
1596
- onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1597
- placeholder: "Enter a value"
1598
- }
1599
- )
1600
- }
1601
- ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1602
- CriteriaMatchMenu,
1603
- {
1604
- errorMessage: (_g = errors.rhs) == null ? void 0 : _g[index],
1605
- css: expand,
1606
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1607
- criteriaMatch: currentCriteria,
1608
- onChange: (match) => {
1609
- update(match, index);
1610
- },
1611
- isDisabled: !critHasLhs,
1612
- dimensions,
1613
- onMenuOpen,
1614
- onMenuClose
1666
+ "data-testid": "dropdown-button-combine",
1667
+ disabled: index > 1,
1668
+ value: (_h = currentValue.op) != null ? _h : "&",
1669
+ options: [
1670
+ { label: "AND", value: "&" },
1671
+ { label: "OR", value: "|" }
1672
+ ],
1673
+ onChange: (v) => {
1674
+ setOp(v.value);
1675
+ }
1615
1676
  }
1616
1677
  )
1617
1678
  }
1618
1679
  ) : null
1619
- ] }),
1620
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1621
- "button",
1622
- {
1623
- type: "button",
1624
- onClick: () => removeFromList(index),
1625
- title: `Delete Personalization`,
1626
- css: { backgroundColor: "transparent", backgroundImage: "none", borderWidth: 0 },
1627
- "data-testid": "button-delete",
1628
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Icon, { icon: import_CgCloseO2.CgCloseO, iconColor: "red", size: "1.5rem" })
1629
- }
1630
- ),
1631
- index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1632
- "div",
1633
- {
1634
- className: "criteria-group-operation",
1635
- css: {
1636
- position: "absolute",
1637
- top: "-4rem",
1638
- transform: "translateX(calc(1.5rem - 50%))"
1639
- },
1640
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1641
- import_design_system10.InputInlineSelect,
1642
- {
1643
- "data-testid": "dropdown-button-combine",
1644
- disabled: index > 1,
1645
- value: (_h = currentValue.op) != null ? _h : "&",
1646
- options: [
1647
- { label: "AND", value: "&" },
1648
- { label: "OR", value: "|" }
1649
- ],
1650
- onChange: (v) => {
1651
- setOp(v.value);
1652
- }
1653
- }
1654
- )
1655
- }
1656
- ) : null
1657
- ] }, index);
1658
- }) }),
1659
- dimensions.dimensions.length === 0 && !(quirks == null ? void 0 : quirks.length) ? (components == null ? void 0 : components.NoDimensionsDefined) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.NoDimensionsDefined, {}) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Callout, { title: "Dimensions", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: "You do not have any dimensions configured." }) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1660
- import_design_system10.AddListButton,
1661
- {
1662
- "data-testid": "button-add-criteria",
1663
- className: "add-more",
1664
- buttonText: "Add Criteria",
1665
- onButtonClick: addToList
1666
- }
1667
- )
1680
+ ] }, index);
1681
+ }) }),
1682
+ dimensions.dimensions.length === 0 && !(quirks == null ? void 0 : quirks.length) ? (components == null ? void 0 : components.NoDimensionsDefined) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.NoDimensionsDefined, {}) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Callout, { title: "Dimensions", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: "You do not have any dimensions configured." }) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1683
+ import_design_system10.AddListButton,
1684
+ {
1685
+ "data-testid": "button-add-criteria",
1686
+ className: "add-more",
1687
+ buttonText: "Add Criteria",
1688
+ onButtonClick: addToList
1689
+ }
1690
+ )
1691
+ ] })
1668
1692
  ] });
1669
1693
  };
1670
1694
 
@@ -1729,7 +1753,7 @@ var PersonalizationCriteria = ({
1729
1753
  ...staticProps
1730
1754
  }) => {
1731
1755
  var _a, _b;
1732
- const [validationError, setValidationError] = (0, import_react17.useState)(void 0);
1756
+ const [validationError, setValidationError] = (0, import_react18.useState)(void 0);
1733
1757
  const { loading, result: dimensions, error } = useDimensions(contextConfig);
1734
1758
  (0, import_react_use.useAsync)(async () => {
1735
1759
  if (value && dimensions) {
@@ -1793,7 +1817,7 @@ function ProjectUIVersion({ children, versionMap, contextConfig }) {
1793
1817
  }
1794
1818
 
1795
1819
  // src/hooks/useValidateContextConfig.ts
1796
- var import_react18 = require("react");
1820
+ var import_react19 = require("react");
1797
1821
 
1798
1822
  // src/utils/validateContextConfig.ts
1799
1823
  var import_api4 = require("@uniformdev/context/api");
@@ -1829,12 +1853,12 @@ var validateContextConfig = async (contextConfig) => {
1829
1853
 
1830
1854
  // src/hooks/useValidateContextConfig.ts
1831
1855
  var useValidateContextConfig = (contextConfig) => {
1832
- const [state, setState] = (0, import_react18.useState)({
1856
+ const [state, setState] = (0, import_react19.useState)({
1833
1857
  validating: false,
1834
1858
  error: void 0
1835
1859
  });
1836
1860
  const { apiKey, apiHost, projectId } = contextConfig || {};
1837
- (0, import_react18.useEffect)(() => {
1861
+ (0, import_react19.useEffect)(() => {
1838
1862
  if (!apiKey || !apiHost) {
1839
1863
  return;
1840
1864
  }
@@ -1876,6 +1900,7 @@ __reExport(src_exports, require("@uniformdev/design-system"), module.exports);
1876
1900
  contextCriteriaMenuOperators,
1877
1901
  convertErrorsToObj,
1878
1902
  enrichmentCriteriaMenuOperators,
1903
+ getValidCriteriaOperatorsFor,
1879
1904
  isEnrichmentTagData,
1880
1905
  isPersonalizationCriteriaData,
1881
1906
  opHasRhs,