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