@uniformdev/context-ui 20.3.1-alpha.0 → 20.3.1-alpha.7

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
@@ -46,6 +46,7 @@ __export(src_exports, {
46
46
  addEnrichmentLink: () => addEnrichmentLink,
47
47
  contextCriteriaMenuOperators: () => contextCriteriaMenuOperators,
48
48
  convertErrorsToObj: () => convertErrorsToObj,
49
+ enrichmentCriteriaMenuOperators: () => enrichmentCriteriaMenuOperators,
49
50
  isEnrichmentTagData: () => isEnrichmentTagData,
50
51
  isPersonalizationCriteriaData: () => isPersonalizationCriteriaData,
51
52
  opHasRhs: () => opHasRhs,
@@ -341,23 +342,39 @@ var contextCriteriaMenuOperators = [
341
342
  {
342
343
  name: "has the weakest score",
343
344
  value: "-"
344
- },
345
+ }
346
+ ];
347
+ var enrichmentCriteriaMenuOperators = [
348
+ ...contextCriteriaMenuOperators,
345
349
  {
346
350
  name: "has strongest category score",
347
351
  value: "^"
348
352
  }
349
353
  ];
350
- function CriteriaOperatorMenu({ onChange, value, ...props }) {
354
+ var quirkCriteriaMenuOperators = [
355
+ {
356
+ name: "=",
357
+ description: "equals",
358
+ value: "="
359
+ },
360
+ {
361
+ name: "\u2260",
362
+ description: "not equal",
363
+ value: "!="
364
+ }
365
+ ];
366
+ function CriteriaOperatorMenu({ onChange, value, rhsType, ...props }) {
351
367
  var _a, _b;
368
+ const operators = rhsType === "QUIRK" ? quirkCriteriaMenuOperators : rhsType === "ENR" ? enrichmentCriteriaMenuOperators : contextCriteriaMenuOperators;
352
369
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
353
370
  import_design_system2.InputComboBox,
354
371
  {
355
372
  ...props,
356
373
  value: {
357
- label: (_b = (_a = contextCriteriaMenuOperators.find((e) => e.value === value)) == null ? void 0 : _a.name) != null ? _b : value,
374
+ label: (_b = (_a = operators.find((e) => e.value === value)) == null ? void 0 : _a.name) != null ? _b : value,
358
375
  value
359
376
  },
360
- options: contextCriteriaMenuOperators.map((option) => ({
377
+ options: operators.map((option) => ({
361
378
  label: option.description ? `${option.name}:${option.description}` : option.name,
362
379
  value: option.value
363
380
  })),
@@ -589,24 +606,29 @@ function useDimensionsDataContext() {
589
606
 
590
607
  // src/components/DimensionMenu/CriteriaMatchMenu.tsx
591
608
  var import_design_system6 = require("@uniformdev/design-system");
592
- var import_react10 = require("react");
609
+ var import_react11 = require("react");
593
610
 
594
611
  // src/components/DimensionMenu/DimensionGroupHeading.tsx
595
612
  var import_design_system4 = require("@uniformdev/design-system");
596
613
 
597
614
  // src/components/DimensionMenu/utils.ts
615
+ var import_react9 = require("react");
598
616
  function dimensionToMenuOption(dimension) {
617
+ if ("dim" in dimension) {
618
+ return {
619
+ label: dimension.displayName,
620
+ value: dimension.dim,
621
+ original: dimension
622
+ };
623
+ }
624
+ const quirk = dimension;
599
625
  return {
600
- label: dimension.displayName,
601
- value: dimension.dim,
602
- isDisabled: false
626
+ label: `Quirk:${quirk.name}`,
627
+ value: quirk.id,
628
+ original: quirk
603
629
  };
604
630
  }
605
- function dimensionIcon(displayName) {
606
- if (!displayName) {
607
- return "unavailable";
608
- }
609
- const [type] = displayName.split(":");
631
+ function dimensionIcon(type) {
610
632
  switch (type.toLowerCase()) {
611
633
  case "signal":
612
634
  return "data";
@@ -618,25 +640,42 @@ function dimensionIcon(displayName) {
618
640
  return "user-list";
619
641
  }
620
642
  }
621
- function groupDimensions(dimensions) {
622
- const result = [];
623
- let lastType = "";
624
- for (const dim of dimensions) {
625
- const [type] = dim.displayName.split(":");
626
- if (lastType !== type) {
627
- result.push({ label: type, options: [] });
628
- lastType = type;
643
+ function useGroupedDimensions(dimensions, quirks) {
644
+ return (0, import_react9.useMemo)(() => {
645
+ const result = [];
646
+ let lastType = "";
647
+ for (const dim of dimensions) {
648
+ const { type } = dimensionDisplayName(dim.displayName);
649
+ if (lastType !== type) {
650
+ result.push({ label: type != null ? type : "", options: [] });
651
+ lastType = type != null ? type : "";
652
+ }
653
+ result[result.length - 1].options.push(dimensionToMenuOption(dim));
629
654
  }
630
- result[result.length - 1].options.push(dimensionToMenuOption(dim));
655
+ if (quirks == null ? void 0 : quirks.length) {
656
+ result.push({
657
+ label: "Quirks",
658
+ options: quirks.map(dimensionToMenuOption)
659
+ });
660
+ }
661
+ return result;
662
+ }, [dimensions, quirks]);
663
+ }
664
+ function dimensionDisplayName(displayName) {
665
+ if (!displayName) {
666
+ return {};
631
667
  }
632
- return result;
668
+ const colonIndex = displayName.indexOf(":");
669
+ const type = colonIndex >= 0 ? displayName.substring(0, colonIndex) : void 0;
670
+ const name = colonIndex >= 0 ? displayName.substring(colonIndex + 1) : displayName;
671
+ return { type, name };
633
672
  }
634
673
 
635
674
  // src/components/DimensionMenu/DimensionGroupHeading.tsx
636
675
  var import_jsx_runtime7 = require("@emotion/react/jsx-runtime");
637
676
  var DimensionGroupHeading = (props) => {
638
- var _a;
639
677
  const { data, getStyles, className } = props;
678
+ const { type } = dimensionDisplayName(data.label);
640
679
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
641
680
  "div",
642
681
  {
@@ -651,7 +690,7 @@ var DimensionGroupHeading = (props) => {
651
690
  {
652
691
  css: { color: "var(--gray-500)", display: "flex", alignItems: "center", gap: "var(--spacing-xs)" },
653
692
  children: [
654
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_design_system4.Icon, { icon: dimensionIcon((_a = data.label) != null ? _a : ""), iconColor: "currentColor", size: 16 }),
693
+ type ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_design_system4.Icon, { icon: dimensionIcon(type), iconColor: "currentColor", size: 16 }) : null,
655
694
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: data.label })
656
695
  ]
657
696
  }
@@ -661,14 +700,14 @@ var DimensionGroupHeading = (props) => {
661
700
  };
662
701
 
663
702
  // src/components/DimensionMenu/DimensionMenuErrorMessage.tsx
664
- var import_react9 = require("@emotion/react");
703
+ var import_react10 = require("@emotion/react");
665
704
  var import_jsx_runtime8 = require("@emotion/react/jsx-runtime");
666
705
  function DimensionMenuErrorMessage({ message }) {
667
706
  if (!message) return null;
668
707
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
669
708
  "div",
670
709
  {
671
- css: import_react9.css`
710
+ css: import_react10.css`
672
711
  color: var(--brand-primary-2);
673
712
  font-size: var(--fs-xs);
674
713
  position: absolute;
@@ -682,9 +721,8 @@ function DimensionMenuErrorMessage({ message }) {
682
721
  // src/components/DimensionMenu/DimensionOption.tsx
683
722
  var import_jsx_runtime9 = require("@emotion/react/jsx-runtime");
684
723
  var DimensionOption = (props) => {
685
- var _a, _b;
686
724
  const { data, getStyles, cx, isDisabled, isFocused, isSelected, className, innerRef, innerProps } = props;
687
- const [, value] = (_b = (_a = data.label) == null ? void 0 : _a.split(":")) != null ? _b : [];
725
+ const { name } = dimensionDisplayName(data.label);
688
726
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
689
727
  "div",
690
728
  {
@@ -701,7 +739,7 @@ var DimensionOption = (props) => {
701
739
  ref: innerRef,
702
740
  "aria-disabled": isDisabled,
703
741
  ...innerProps,
704
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { css: { color: "var(--gray-700)" }, children: value != null ? value : data.label })
742
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { css: { color: "var(--gray-700)" }, children: name != null ? name : data.label })
705
743
  }
706
744
  );
707
745
  };
@@ -710,7 +748,7 @@ var DimensionOption = (props) => {
710
748
  var import_design_system5 = require("@uniformdev/design-system");
711
749
  var import_jsx_runtime10 = require("@emotion/react/jsx-runtime");
712
750
  function DimensionValue({ displayName }) {
713
- const [type, name] = displayName.split(":");
751
+ const { type, name } = dimensionDisplayName(displayName);
714
752
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
715
753
  "div",
716
754
  {
@@ -719,7 +757,7 @@ function DimensionValue({ displayName }) {
719
757
  overflow: "hidden"
720
758
  },
721
759
  children: [
722
- name ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
760
+ type ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
723
761
  "small",
724
762
  {
725
763
  css: { color: "var(--gray-500)", display: "flex", alignItems: "center", gap: "var(--spacing-xs)" },
@@ -752,11 +790,12 @@ function CriteriaMatchMenu({
752
790
  ...props
753
791
  }) {
754
792
  var _a, _b;
755
- const [inputValue, setInputValue] = (0, import_react10.useState)(
793
+ const [inputValue, setInputValue] = (0, import_react11.useState)(
756
794
  typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
757
795
  );
758
796
  const rDim = criteriaMatch.rDim;
759
797
  const targetDim = criteriaMatch.rDim ? dimensions.dimIndex[criteriaMatch.rDim] : void 0;
798
+ const groupedDimensions = useGroupedDimensions(dimensions.dimensions, void 0);
760
799
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
761
800
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
762
801
  import_design_system6.InputComboBox,
@@ -775,7 +814,7 @@ function CriteriaMatchMenu({
775
814
  value: "",
776
815
  isDisabled: true
777
816
  },
778
- ...groupDimensions(dimensions.dimensions)
817
+ ...groupedDimensions
779
818
  ],
780
819
  styles: {
781
820
  ...props.styles,
@@ -854,14 +893,23 @@ function isInt(value) {
854
893
  // src/components/DimensionMenu/DimensionMenu.tsx
855
894
  var import_design_system7 = require("@uniformdev/design-system");
856
895
  var import_jsx_runtime13 = require("@emotion/react/jsx-runtime");
857
- function DimensionMenu({ onChange, value, dimensions, errorMessage, ...props }) {
896
+ function DimensionMenu({
897
+ onChange,
898
+ value,
899
+ dimensions,
900
+ errorMessage,
901
+ quirks,
902
+ ...props
903
+ }) {
904
+ const groupedDimensions = useGroupedDimensions(dimensions, quirks);
905
+ const valueAsMenuOption = value ? dimensionToMenuOption(value) : void 0;
858
906
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
859
907
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
860
908
  import_design_system7.InputComboBox,
861
909
  {
862
910
  ...props,
863
- value: value ? dimensionToMenuOption(value) : void 0,
864
- options: groupDimensions(dimensions),
911
+ value: valueAsMenuOption,
912
+ options: groupedDimensions,
865
913
  styles: {
866
914
  ...props.styles,
867
915
  valueContainer: (provided, state) => {
@@ -874,8 +922,8 @@ function DimensionMenu({ onChange, value, dimensions, errorMessage, ...props })
874
922
  }
875
923
  },
876
924
  onChange: (e) => {
877
- if (e) {
878
- onChange(dimensions.find((d) => d.dim === e.value));
925
+ if (e == null ? void 0 : e.original) {
926
+ onChange(e.original);
879
927
  }
880
928
  },
881
929
  components: {
@@ -895,8 +943,8 @@ var import_CgChevronRight = require("@react-icons/all-files/cg/CgChevronRight");
895
943
  var import_design_system8 = require("@uniformdev/design-system");
896
944
 
897
945
  // src/components/EditLink/EditLink.styles.ts
898
- var import_react11 = require("@emotion/react");
899
- var editLink = import_react11.css`
946
+ var import_react12 = require("@emotion/react");
947
+ var editLink = import_react12.css`
900
948
  display: flex;
901
949
  align-items: center;
902
950
  font-weight: var(--fw-bold);
@@ -929,16 +977,16 @@ var EditLink = ({ linkTo, name, linkText = `Edit ${name} Component` }) => {
929
977
  };
930
978
 
931
979
  // src/components/EnrichmentTag/EnrichmentTag.tsx
932
- var import_react12 = require("@emotion/react");
980
+ var import_react13 = require("@emotion/react");
933
981
  var import_CgCloseO = require("@react-icons/all-files/cg/CgCloseO");
934
982
  var import_CgMathMinus = require("@react-icons/all-files/cg/CgMathMinus");
935
983
  var import_CgMathPlus = require("@react-icons/all-files/cg/CgMathPlus");
936
984
  var import_context = require("@uniformdev/context");
937
985
  var import_design_system9 = require("@uniformdev/design-system");
938
986
  var import_immer = require("immer");
939
- var import_react13 = require("react");
987
+ var import_react14 = require("react");
940
988
  var import_jsx_runtime15 = require("@emotion/react/jsx-runtime");
941
- var addEnrichmentLink = import_react12.css`
989
+ var addEnrichmentLink = import_react13.css`
942
990
  flex: 2;
943
991
  display: flex;
944
992
  width: 50%;
@@ -957,19 +1005,19 @@ var EnrichmentTag = ({
957
1005
  displayTitle = true
958
1006
  }) => {
959
1007
  const { loading, result: dimensions, error } = useDimensions(contextConfig);
960
- const allEnrichments = (0, import_react13.useMemo)(() => {
1008
+ const allEnrichments = (0, import_react14.useMemo)(() => {
961
1009
  if (dimensions) return dimensions.dimensions.filter((dimension) => dimension.category === "ENR");
962
1010
  }, [dimensions]);
963
- const remainingEnrichments = (0, import_react13.useMemo)(() => {
1011
+ const remainingEnrichments = (0, import_react14.useMemo)(() => {
964
1012
  if (!value) return allEnrichments;
965
1013
  if (allEnrichments)
966
1014
  return allEnrichments.filter(
967
1015
  (enr) => !value.some((val) => (0, import_context.getEnrichmentVectorKey)(val.cat, val.key) === enr.dim)
968
1016
  );
969
1017
  }, [allEnrichments, value]);
970
- const [selectValue, setSelectValue] = (0, import_react13.useState)("");
971
- const [score, setScore] = (0, import_react13.useState)(50);
972
- const [showAddNewEnrichmentTagPanel, setShowAddNewEnrichmentTagPanel] = (0, import_react13.useState)(false);
1018
+ const [selectValue, setSelectValue] = (0, import_react14.useState)("");
1019
+ const [score, setScore] = (0, import_react14.useState)(50);
1020
+ const [showAddNewEnrichmentTagPanel, setShowAddNewEnrichmentTagPanel] = (0, import_react14.useState)(false);
973
1021
  const selectedEnrichment = allEnrichments == null ? void 0 : allEnrichments.find((dimension) => dimension.dim === selectValue);
974
1022
  const addEnrichment = () => {
975
1023
  const [cat, key] = selectValue.split("_");
@@ -1127,7 +1175,7 @@ var NoEnrichmentsView = ({ contextConfig }) => /* @__PURE__ */ (0, import_jsx_ru
1127
1175
  var getCappedValue = (value, maxCap = 100, minCap = 0) => {
1128
1176
  return Math.max(Math.min(value, maxCap), minCap);
1129
1177
  };
1130
- var scoreCounterMinusButtonStyles = import_react12.css`
1178
+ var scoreCounterMinusButtonStyles = import_react13.css`
1131
1179
  position: absolute;
1132
1180
  bottom: 0.875rem;
1133
1181
  left: var(--spacing-sm);
@@ -1140,7 +1188,7 @@ var scoreCounterMinusButtonStyles = import_react12.css`
1140
1188
  border: 1px solid var(--gray-300);
1141
1189
  border-radius: var(--rounded-full);
1142
1190
  `;
1143
- var scoreCounterPlusButtonStyles = import_react12.css`
1191
+ var scoreCounterPlusButtonStyles = import_react13.css`
1144
1192
  ${scoreCounterMinusButtonStyles}
1145
1193
  left: auto;
1146
1194
  right: var(--spacing-sm);
@@ -1288,7 +1336,7 @@ var SelectedEnrichments = ({ list, setList, dimIndex }) => {
1288
1336
 
1289
1337
  // src/components/PersonalizationCriteria/PersonalizationCriteria.tsx
1290
1338
  var import_design_system11 = require("@uniformdev/design-system");
1291
- var import_react16 = require("react");
1339
+ var import_react17 = require("react");
1292
1340
  var import_react_use = require("react-use");
1293
1341
  var yup = __toESM(require("yup"));
1294
1342
 
@@ -1304,15 +1352,15 @@ function opHasRhs(op) {
1304
1352
  }
1305
1353
 
1306
1354
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.tsx
1307
- var import_react15 = require("@emotion/react");
1355
+ var import_react16 = require("@emotion/react");
1308
1356
  var import_CgCloseO2 = require("@react-icons/all-files/cg/CgCloseO");
1309
1357
  var import_design_system10 = require("@uniformdev/design-system");
1310
1358
  var import_immer2 = require("immer");
1311
1359
 
1312
1360
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.styles.ts
1313
- var import_react14 = require("@emotion/react");
1361
+ var import_react15 = require("@emotion/react");
1314
1362
  var spaceBetweenCriteriaItems = "6rem";
1315
- var criteriaItem = import_react14.css`
1363
+ var criteriaItem = import_react15.css`
1316
1364
  position: relative;
1317
1365
  padding: var(--spacing-md) var(--spacing-base);
1318
1366
  border: 1px solid var(--gray-300);
@@ -1340,29 +1388,31 @@ var criteriaItem = import_react14.css`
1340
1388
  }
1341
1389
  }
1342
1390
  `;
1343
- var criteriaItemInner = import_react14.css`
1391
+ var criteriaItemInner = import_react15.css`
1344
1392
  display: flex;
1345
- gap: var(--spacing-base);
1393
+ row-gap: var(--spacing-base);
1394
+ column-gap: var(--spacing-xs);
1346
1395
  flex-grow: 1;
1347
1396
  flex-wrap: wrap;
1348
1397
  margin-right: var(--spacing-base);
1349
1398
  `;
1350
- var criteriaWrapper = import_react14.css`
1399
+ var criteriaWrapper = import_react15.css`
1351
1400
  width: 100%;
1352
1401
  display: flex;
1353
1402
  align-items: stretch;
1354
1403
  position: relative;
1355
1404
  `;
1356
- var criteriaOperandWrapper = import_react14.css`
1405
+ var criteriaOperandWrapper = import_react15.css`
1357
1406
  flex: 2;
1358
1407
  height: 52px;
1359
1408
  min-width: 200px;
1360
1409
  `;
1361
- var criteriaOperatorWrapper = import_react14.css`
1410
+ var criteriaOperatorWrapper = import_react15.css`
1362
1411
  flex: 1;
1412
+ flex-wrap: nowrap;
1363
1413
  min-width: 80px;
1364
1414
  `;
1365
- var expand = import_react14.css`
1415
+ var expand = import_react15.css`
1366
1416
  height: 100%;
1367
1417
  width: 100%;
1368
1418
  `;
@@ -1373,6 +1423,7 @@ var PersonalizationCriteriaStatic = ({
1373
1423
  value,
1374
1424
  setValue,
1375
1425
  dimensions,
1426
+ quirks,
1376
1427
  onMenuOpen,
1377
1428
  onMenuClose,
1378
1429
  onAddCriteria,
@@ -1428,94 +1479,137 @@ var PersonalizationCriteriaStatic = ({
1428
1479
  (components == null ? void 0 : components.CustomVariantName) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.CustomVariantName, {}) : null,
1429
1480
  (components == null ? void 0 : components.ControlPercentage) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.ControlPercentage, {}) : null,
1430
1481
  !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) => {
1431
- var _a2, _b, _c, _d;
1482
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1432
1483
  const critHasLhs = ((_a2 = currentCriteria.l) == null ? void 0 : _a2.length) > 0;
1433
1484
  const critHasRhs = opHasRhs(currentCriteria.op);
1485
+ const currentDimension = dimensions.dimIndex[currentCriteria.l];
1486
+ const currentQuirk = quirks == null ? void 0 : quirks.find((q) => q.id === currentCriteria.l);
1434
1487
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css: criteriaItem, "data-testid": "criteria-container", children: [
1435
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1436
- "div",
1437
- {
1438
- css: import_react15.css`
1439
- ${criteriaItemInner}/* grid-template-columns: minmax(0, 1fr) ${critHasRhs ? "minmax(0, 79px) minmax(0, 1fr)" : "minmax(0, 1fr)"} */
1440
- `,
1441
- className: "criteriaItemInner",
1442
- children: [
1443
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1444
- "div",
1488
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css: criteriaItemInner, className: "criteriaItemInner", children: [
1489
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1490
+ "div",
1491
+ {
1492
+ css: [criteriaWrapper, criteriaOperandWrapper],
1493
+ className: "criteria-wrapper",
1494
+ "data-testid": "select-criteria",
1495
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1496
+ DimensionMenu,
1445
1497
  {
1446
- css: [criteriaWrapper, criteriaOperandWrapper],
1447
- className: "criteria-wrapper",
1448
- "data-testid": "select-criteria",
1449
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1450
- DimensionMenu,
1451
- {
1452
- errorMessage: (_b = errors.lhs) == null ? void 0 : _b[index],
1453
- css: expand,
1454
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1455
- dimensions: dimensions.dimensions,
1456
- onChange: (dim) => {
1457
- update({ ...currentCriteria, l: dim.dim }, index);
1458
- },
1459
- value: dimensions.dimIndex[currentCriteria.l],
1460
- onMenuOpen,
1461
- onMenuClose
1498
+ errorMessage: (_b = errors.lhs) == null ? void 0 : _b[index],
1499
+ css: expand,
1500
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1501
+ dimensions: dimensions.dimensions,
1502
+ quirks,
1503
+ onChange: (selection) => {
1504
+ if ("dim" in selection) {
1505
+ const newCriteria = {
1506
+ ...currentCriteria,
1507
+ l: selection.dim,
1508
+ t: void 0,
1509
+ op: ">",
1510
+ r: 0
1511
+ };
1512
+ update(newCriteria, index);
1513
+ } else {
1514
+ update({ ...currentCriteria, l: selection.id, t: "q", op: "=", r: "" }, index);
1462
1515
  }
1463
- )
1516
+ },
1517
+ value: currentDimension != null ? currentDimension : currentQuirk,
1518
+ onMenuOpen,
1519
+ onMenuClose
1464
1520
  }
1465
- ),
1466
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1467
- "div",
1521
+ )
1522
+ }
1523
+ ),
1524
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1525
+ "div",
1526
+ {
1527
+ css: [criteriaWrapper, criteriaOperatorWrapper],
1528
+ className: "criteria-wrapper",
1529
+ "data-testid": "select-operator",
1530
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1531
+ CriteriaOperatorMenu,
1468
1532
  {
1469
- css: [criteriaWrapper, criteriaOperatorWrapper],
1470
- className: "criteria-wrapper",
1471
- "data-testid": "select-operator",
1472
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1473
- CriteriaOperatorMenu,
1474
- {
1475
- name: `op-${index}`,
1476
- css: expand,
1477
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1478
- value: currentCriteria.op,
1479
- onChange: (op) => {
1480
- if (op === "+" || op === "-") {
1481
- update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
1482
- } else {
1483
- update({ ...currentCriteria, op }, index);
1484
- }
1485
- },
1486
- onMenuOpen,
1487
- onMenuClose
1533
+ name: `op-${index}`,
1534
+ css: expand,
1535
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1536
+ value: currentCriteria.op,
1537
+ rhsType: currentQuirk ? "QUIRK" : currentDimension == null ? void 0 : currentDimension.category,
1538
+ onChange: (op) => {
1539
+ if (op === "+" || op === "-") {
1540
+ update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
1541
+ } else {
1542
+ update({ ...currentCriteria, op }, index);
1488
1543
  }
1489
- )
1544
+ },
1545
+ onMenuOpen,
1546
+ onMenuClose
1490
1547
  }
1491
- ),
1492
- critHasRhs ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1548
+ )
1549
+ }
1550
+ ),
1551
+ critHasRhs ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1552
+ "div",
1553
+ {
1554
+ css: [criteriaWrapper, criteriaOperandWrapper],
1555
+ className: "criteria-wrapper",
1556
+ "data-testid": "select-match-criteria",
1557
+ children: currentQuirk ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1493
1558
  "div",
1494
1559
  {
1495
- css: [criteriaWrapper, criteriaOperandWrapper],
1496
- className: "criteria-wrapper",
1497
- "data-testid": "select-match-criteria",
1498
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1499
- CriteriaMatchMenu,
1560
+ css: import_react16.css`
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__ */ (0, import_jsx_runtime16.jsx)(
1569
+ import_design_system10.InputSelect,
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
+ }
1581
+ ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1582
+ import_design_system10.Input,
1500
1583
  {
1501
- errorMessage: (_c = errors.rhs) == null ? void 0 : _c[index],
1502
- css: expand,
1503
- styles: { control: (base) => ({ ...base, height: "100%" }) },
1504
- criteriaMatch: currentCriteria,
1505
- onChange: (match) => {
1506
- update(match, index);
1507
- },
1508
- isDisabled: !critHasLhs,
1509
- dimensions,
1510
- onMenuOpen,
1511
- onMenuClose
1584
+ type: "text",
1585
+ label: "quirk match value",
1586
+ showLabel: false,
1587
+ value: (_e = currentCriteria.r) != null ? _e : "",
1588
+ errorMessage: (_f = errors.rhs) == null ? void 0 : _f[index],
1589
+ onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
1590
+ placeholder: "Enter a value"
1512
1591
  }
1513
1592
  )
1514
1593
  }
1515
- ) : null
1516
- ]
1517
- }
1518
- ),
1594
+ ) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1595
+ CriteriaMatchMenu,
1596
+ {
1597
+ errorMessage: (_g = errors.rhs) == null ? void 0 : _g[index],
1598
+ css: expand,
1599
+ styles: { control: (base) => ({ ...base, height: "100%" }) },
1600
+ criteriaMatch: currentCriteria,
1601
+ onChange: (match) => {
1602
+ update(match, index);
1603
+ },
1604
+ isDisabled: !critHasLhs,
1605
+ dimensions,
1606
+ onMenuOpen,
1607
+ onMenuClose
1608
+ }
1609
+ )
1610
+ }
1611
+ ) : null
1612
+ ] }),
1519
1613
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1520
1614
  "button",
1521
1615
  {
@@ -1541,7 +1635,7 @@ var PersonalizationCriteriaStatic = ({
1541
1635
  {
1542
1636
  "data-testid": "dropdown-button-combine",
1543
1637
  disabled: index > 1,
1544
- value: (_d = currentValue.op) != null ? _d : "&",
1638
+ value: (_h = currentValue.op) != null ? _h : "&",
1545
1639
  options: [
1546
1640
  { label: "AND", value: "&" },
1547
1641
  { label: "OR", value: "|" }
@@ -1628,7 +1722,7 @@ var PersonalizationCriteria = ({
1628
1722
  ...staticProps
1629
1723
  }) => {
1630
1724
  var _a, _b;
1631
- const [validationError, setValidationError] = (0, import_react16.useState)(void 0);
1725
+ const [validationError, setValidationError] = (0, import_react17.useState)(void 0);
1632
1726
  const { loading, result: dimensions, error } = useDimensions(contextConfig);
1633
1727
  (0, import_react_use.useAsync)(async () => {
1634
1728
  if (value && dimensions) {
@@ -1692,7 +1786,7 @@ function ProjectUIVersion({ children, versionMap, contextConfig }) {
1692
1786
  }
1693
1787
 
1694
1788
  // src/hooks/useValidateContextConfig.ts
1695
- var import_react17 = require("react");
1789
+ var import_react18 = require("react");
1696
1790
 
1697
1791
  // src/utils/validateContextConfig.ts
1698
1792
  var import_api4 = require("@uniformdev/context/api");
@@ -1728,12 +1822,12 @@ var validateContextConfig = async (contextConfig) => {
1728
1822
 
1729
1823
  // src/hooks/useValidateContextConfig.ts
1730
1824
  var useValidateContextConfig = (contextConfig) => {
1731
- const [state, setState] = (0, import_react17.useState)({
1825
+ const [state, setState] = (0, import_react18.useState)({
1732
1826
  validating: false,
1733
1827
  error: void 0
1734
1828
  });
1735
1829
  const { apiKey, apiHost, projectId } = contextConfig || {};
1736
- (0, import_react17.useEffect)(() => {
1830
+ (0, import_react18.useEffect)(() => {
1737
1831
  if (!apiKey || !apiHost) {
1738
1832
  return;
1739
1833
  }
@@ -1774,6 +1868,7 @@ __reExport(src_exports, require("@uniformdev/design-system"), module.exports);
1774
1868
  addEnrichmentLink,
1775
1869
  contextCriteriaMenuOperators,
1776
1870
  convertErrorsToObj,
1871
+ enrichmentCriteriaMenuOperators,
1777
1872
  isEnrichmentTagData,
1778
1873
  isPersonalizationCriteriaData,
1779
1874
  opHasRhs,