@uniformdev/context-ui 20.8.1 → 20.8.2-alpha.15

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,10 @@ 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);
927
+ } else {
928
+ onChange(void 0);
879
929
  }
880
930
  },
881
931
  components: {
@@ -895,8 +945,8 @@ var import_CgChevronRight = require("@react-icons/all-files/cg/CgChevronRight");
895
945
  var import_design_system8 = require("@uniformdev/design-system");
896
946
 
897
947
  // src/components/EditLink/EditLink.styles.ts
898
- var import_react11 = require("@emotion/react");
899
- var editLink = import_react11.css`
948
+ var import_react12 = require("@emotion/react");
949
+ var editLink = import_react12.css`
900
950
  display: flex;
901
951
  align-items: center;
902
952
  font-weight: var(--fw-bold);
@@ -929,16 +979,16 @@ var EditLink = ({ linkTo, name, linkText = `Edit ${name} Component` }) => {
929
979
  };
930
980
 
931
981
  // src/components/EnrichmentTag/EnrichmentTag.tsx
932
- var import_react12 = require("@emotion/react");
982
+ var import_react13 = require("@emotion/react");
933
983
  var import_CgCloseO = require("@react-icons/all-files/cg/CgCloseO");
934
984
  var import_CgMathMinus = require("@react-icons/all-files/cg/CgMathMinus");
935
985
  var import_CgMathPlus = require("@react-icons/all-files/cg/CgMathPlus");
936
986
  var import_context = require("@uniformdev/context");
937
987
  var import_design_system9 = require("@uniformdev/design-system");
938
988
  var import_immer = require("immer");
939
- var import_react13 = require("react");
989
+ var import_react14 = require("react");
940
990
  var import_jsx_runtime15 = require("@emotion/react/jsx-runtime");
941
- var addEnrichmentLink = import_react12.css`
991
+ var addEnrichmentLink = import_react13.css`
942
992
  flex: 2;
943
993
  display: flex;
944
994
  width: 50%;
@@ -957,19 +1007,19 @@ var EnrichmentTag = ({
957
1007
  displayTitle = true
958
1008
  }) => {
959
1009
  const { loading, result: dimensions, error } = useDimensions(contextConfig);
960
- const allEnrichments = (0, import_react13.useMemo)(() => {
1010
+ const allEnrichments = (0, import_react14.useMemo)(() => {
961
1011
  if (dimensions) return dimensions.dimensions.filter((dimension) => dimension.category === "ENR");
962
1012
  }, [dimensions]);
963
- const remainingEnrichments = (0, import_react13.useMemo)(() => {
1013
+ const remainingEnrichments = (0, import_react14.useMemo)(() => {
964
1014
  if (!value) return allEnrichments;
965
1015
  if (allEnrichments)
966
1016
  return allEnrichments.filter(
967
1017
  (enr) => !value.some((val) => (0, import_context.getEnrichmentVectorKey)(val.cat, val.key) === enr.dim)
968
1018
  );
969
1019
  }, [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);
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);
973
1023
  const selectedEnrichment = allEnrichments == null ? void 0 : allEnrichments.find((dimension) => dimension.dim === selectValue);
974
1024
  const addEnrichment = () => {
975
1025
  const [cat, key] = selectValue.split("_");
@@ -1127,7 +1177,7 @@ var NoEnrichmentsView = ({ contextConfig }) => /* @__PURE__ */ (0, import_jsx_ru
1127
1177
  var getCappedValue = (value, maxCap = 100, minCap = 0) => {
1128
1178
  return Math.max(Math.min(value, maxCap), minCap);
1129
1179
  };
1130
- var scoreCounterMinusButtonStyles = import_react12.css`
1180
+ var scoreCounterMinusButtonStyles = import_react13.css`
1131
1181
  position: absolute;
1132
1182
  bottom: 0.875rem;
1133
1183
  left: var(--spacing-sm);
@@ -1140,7 +1190,7 @@ var scoreCounterMinusButtonStyles = import_react12.css`
1140
1190
  border: 1px solid var(--gray-300);
1141
1191
  border-radius: var(--rounded-full);
1142
1192
  `;
1143
- var scoreCounterPlusButtonStyles = import_react12.css`
1193
+ var scoreCounterPlusButtonStyles = import_react13.css`
1144
1194
  ${scoreCounterMinusButtonStyles}
1145
1195
  left: auto;
1146
1196
  right: var(--spacing-sm);
@@ -1288,7 +1338,7 @@ var SelectedEnrichments = ({ list, setList, dimIndex }) => {
1288
1338
 
1289
1339
  // src/components/PersonalizationCriteria/PersonalizationCriteria.tsx
1290
1340
  var import_design_system11 = require("@uniformdev/design-system");
1291
- var import_react16 = require("react");
1341
+ var import_react17 = require("react");
1292
1342
  var import_react_use = require("react-use");
1293
1343
  var yup = __toESM(require("yup"));
1294
1344
 
@@ -1304,15 +1354,15 @@ function opHasRhs(op) {
1304
1354
  }
1305
1355
 
1306
1356
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.tsx
1307
- var import_react15 = require("@emotion/react");
1357
+ var import_react16 = require("@emotion/react");
1308
1358
  var import_CgCloseO2 = require("@react-icons/all-files/cg/CgCloseO");
1309
1359
  var import_design_system10 = require("@uniformdev/design-system");
1310
1360
  var import_immer2 = require("immer");
1311
1361
 
1312
1362
  // src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.styles.ts
1313
- var import_react14 = require("@emotion/react");
1363
+ var import_react15 = require("@emotion/react");
1314
1364
  var spaceBetweenCriteriaItems = "6rem";
1315
- var criteriaItem = import_react14.css`
1365
+ var criteriaItem = import_react15.css`
1316
1366
  position: relative;
1317
1367
  padding: var(--spacing-md) var(--spacing-base);
1318
1368
  border: 1px solid var(--gray-300);
@@ -1340,29 +1390,31 @@ var criteriaItem = import_react14.css`
1340
1390
  }
1341
1391
  }
1342
1392
  `;
1343
- var criteriaItemInner = import_react14.css`
1393
+ var criteriaItemInner = import_react15.css`
1344
1394
  display: flex;
1345
- gap: var(--spacing-base);
1395
+ row-gap: var(--spacing-base);
1396
+ column-gap: var(--spacing-xs);
1346
1397
  flex-grow: 1;
1347
1398
  flex-wrap: wrap;
1348
1399
  margin-right: var(--spacing-base);
1349
1400
  `;
1350
- var criteriaWrapper = import_react14.css`
1401
+ var criteriaWrapper = import_react15.css`
1351
1402
  width: 100%;
1352
1403
  display: flex;
1353
1404
  align-items: stretch;
1354
1405
  position: relative;
1355
1406
  `;
1356
- var criteriaOperandWrapper = import_react14.css`
1407
+ var criteriaOperandWrapper = import_react15.css`
1357
1408
  flex: 2;
1358
1409
  height: 52px;
1359
1410
  min-width: 200px;
1360
1411
  `;
1361
- var criteriaOperatorWrapper = import_react14.css`
1412
+ var criteriaOperatorWrapper = import_react15.css`
1362
1413
  flex: 1;
1414
+ flex-wrap: nowrap;
1363
1415
  min-width: 80px;
1364
1416
  `;
1365
- var expand = import_react14.css`
1417
+ var expand = import_react15.css`
1366
1418
  height: 100%;
1367
1419
  width: 100%;
1368
1420
  `;
@@ -1373,6 +1425,7 @@ var PersonalizationCriteriaStatic = ({
1373
1425
  value,
1374
1426
  setValue,
1375
1427
  dimensions,
1428
+ quirks,
1376
1429
  onMenuOpen,
1377
1430
  onMenuClose,
1378
1431
  onAddCriteria,
@@ -1422,100 +1475,146 @@ var PersonalizationCriteriaStatic = ({
1422
1475
  fontSize: "var(--fs-md)",
1423
1476
  fontWeight: "var(--fw-bold)"
1424
1477
  },
1425
- children: "Personalize This"
1478
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Heading, { level: 5, withMarginBottom: false, children: "Personalization Variation" })
1426
1479
  }
1427
1480
  ) : null,
1428
1481
  (components == null ? void 0 : components.CustomVariantName) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.CustomVariantName, {}) : null,
1429
1482
  (components == null ? void 0 : components.ControlPercentage) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.ControlPercentage, {}) : null,
1430
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) => {
1431
- var _a2, _b, _c, _d;
1484
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1432
1485
  const critHasLhs = ((_a2 = currentCriteria.l) == null ? void 0 : _a2.length) > 0;
1433
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);
1434
1489
  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",
1490
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css: criteriaItemInner, className: "criteriaItemInner", children: [
1491
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1492
+ "div",
1493
+ {
1494
+ css: [criteriaWrapper, criteriaOperandWrapper],
1495
+ className: "criteria-wrapper",
1496
+ "data-testid": "select-criteria",
1497
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1498
+ DimensionMenu,
1445
1499
  {
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
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;
1462
1508
  }
1463
- )
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
1464
1525
  }
1465
- ),
1466
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1467
- "div",
1526
+ )
1527
+ }
1528
+ ),
1529
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1530
+ "div",
1531
+ {
1532
+ css: [criteriaWrapper, criteriaOperatorWrapper],
1533
+ className: "criteria-wrapper",
1534
+ "data-testid": "select-operator",
1535
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1536
+ CriteriaOperatorMenu,
1468
1537
  {
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
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);
1488
1548
  }
1489
- )
1549
+ },
1550
+ onMenuOpen,
1551
+ onMenuClose
1490
1552
  }
1491
- ),
1492
- critHasRhs ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
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)(
1493
1563
  "div",
1494
1564
  {
1495
- css: [criteriaWrapper, criteriaOperandWrapper],
1496
- className: "criteria-wrapper",
1497
- "data-testid": "select-match-criteria",
1498
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1499
- CriteriaMatchMenu,
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,
1500
1588
  {
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
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"
1512
1596
  }
1513
1597
  )
1514
1598
  }
1515
- ) : null
1516
- ]
1517
- }
1518
- ),
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
1613
+ }
1614
+ )
1615
+ }
1616
+ ) : null
1617
+ ] }),
1519
1618
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1520
1619
  "button",
1521
1620
  {
@@ -1541,7 +1640,7 @@ var PersonalizationCriteriaStatic = ({
1541
1640
  {
1542
1641
  "data-testid": "dropdown-button-combine",
1543
1642
  disabled: index > 1,
1544
- value: (_d = currentValue.op) != null ? _d : "&",
1643
+ value: (_h = currentValue.op) != null ? _h : "&",
1545
1644
  options: [
1546
1645
  { label: "AND", value: "&" },
1547
1646
  { label: "OR", value: "|" }
@@ -1628,7 +1727,7 @@ var PersonalizationCriteria = ({
1628
1727
  ...staticProps
1629
1728
  }) => {
1630
1729
  var _a, _b;
1631
- const [validationError, setValidationError] = (0, import_react16.useState)(void 0);
1730
+ const [validationError, setValidationError] = (0, import_react17.useState)(void 0);
1632
1731
  const { loading, result: dimensions, error } = useDimensions(contextConfig);
1633
1732
  (0, import_react_use.useAsync)(async () => {
1634
1733
  if (value && dimensions) {
@@ -1692,7 +1791,7 @@ function ProjectUIVersion({ children, versionMap, contextConfig }) {
1692
1791
  }
1693
1792
 
1694
1793
  // src/hooks/useValidateContextConfig.ts
1695
- var import_react17 = require("react");
1794
+ var import_react18 = require("react");
1696
1795
 
1697
1796
  // src/utils/validateContextConfig.ts
1698
1797
  var import_api4 = require("@uniformdev/context/api");
@@ -1728,12 +1827,12 @@ var validateContextConfig = async (contextConfig) => {
1728
1827
 
1729
1828
  // src/hooks/useValidateContextConfig.ts
1730
1829
  var useValidateContextConfig = (contextConfig) => {
1731
- const [state, setState] = (0, import_react17.useState)({
1830
+ const [state, setState] = (0, import_react18.useState)({
1732
1831
  validating: false,
1733
1832
  error: void 0
1734
1833
  });
1735
1834
  const { apiKey, apiHost, projectId } = contextConfig || {};
1736
- (0, import_react17.useEffect)(() => {
1835
+ (0, import_react18.useEffect)(() => {
1737
1836
  if (!apiKey || !apiHost) {
1738
1837
  return;
1739
1838
  }
@@ -1774,6 +1873,7 @@ __reExport(src_exports, require("@uniformdev/design-system"), module.exports);
1774
1873
  addEnrichmentLink,
1775
1874
  contextCriteriaMenuOperators,
1776
1875
  convertErrorsToObj,
1876
+ enrichmentCriteriaMenuOperators,
1777
1877
  isEnrichmentTagData,
1778
1878
  isPersonalizationCriteriaData,
1779
1879
  opHasRhs,