@uniformdev/context-ui 20.36.1-alpha.1 → 20.36.2-alpha.90
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.esm.js +227 -218
- package/dist/index.js +239 -231
- package/dist/index.mjs +227 -218
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -610,7 +610,7 @@ function useDimensionsDataContext() {
|
|
|
610
610
|
|
|
611
611
|
// src/components/DimensionMenu/CriteriaMatchMenu.tsx
|
|
612
612
|
var import_design_system6 = require("@uniformdev/design-system");
|
|
613
|
-
var
|
|
613
|
+
var import_react12 = require("react");
|
|
614
614
|
|
|
615
615
|
// src/components/DimensionMenu/DimensionGroupHeading.tsx
|
|
616
616
|
var import_design_system4 = require("@uniformdev/design-system");
|
|
@@ -749,32 +749,38 @@ var DimensionOption = (props) => {
|
|
|
749
749
|
};
|
|
750
750
|
|
|
751
751
|
// src/components/DimensionMenu/DimensionValue.tsx
|
|
752
|
+
var import_react11 = require("@emotion/react");
|
|
752
753
|
var import_design_system5 = require("@uniformdev/design-system");
|
|
753
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
|
+
};
|
|
754
773
|
function DimensionValue({ displayName }) {
|
|
774
|
+
var _a;
|
|
755
775
|
const { type, name } = dimensionDisplayName(displayName);
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
{
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
type ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
765
|
-
"small",
|
|
766
|
-
{
|
|
767
|
-
css: { color: "var(--gray-500)", display: "flex", alignItems: "center", gap: "var(--spacing-xs)" },
|
|
768
|
-
children: [
|
|
769
|
-
type ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system5.Icon, { icon: dimensionIcon(type), iconColor: "currentColor", size: 16 }) : null,
|
|
770
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { "data-testid": "dimension-name", children: type })
|
|
771
|
-
]
|
|
772
|
-
}
|
|
773
|
-
) : null,
|
|
774
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { css: { color: "var(--gray-700)" }, "data-testid": "dimension-value", children: name != null ? name : type })
|
|
775
|
-
]
|
|
776
|
-
}
|
|
777
|
-
);
|
|
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
|
+
] });
|
|
778
784
|
}
|
|
779
785
|
|
|
780
786
|
// src/components/DimensionMenu/DimensionSingleValue.tsx
|
|
@@ -794,12 +800,12 @@ function CriteriaMatchMenu({
|
|
|
794
800
|
...props
|
|
795
801
|
}) {
|
|
796
802
|
var _a, _b;
|
|
797
|
-
const [inputValue, setInputValue] = (0,
|
|
803
|
+
const [inputValue, setInputValue] = (0, import_react12.useState)(
|
|
798
804
|
typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
|
|
799
805
|
);
|
|
800
|
-
const currentInputValue = (0,
|
|
806
|
+
const currentInputValue = (0, import_react12.useRef)(inputValue);
|
|
801
807
|
currentInputValue.current = inputValue;
|
|
802
|
-
(0,
|
|
808
|
+
(0, import_react12.useEffect)(() => {
|
|
803
809
|
if (currentInputValue.current !== criteriaMatch.r && !criteriaMatch.rDim) {
|
|
804
810
|
setInputValue(
|
|
805
811
|
typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
|
|
@@ -959,8 +965,8 @@ var import_CgChevronRight = require("@react-icons/all-files/cg/CgChevronRight");
|
|
|
959
965
|
var import_design_system8 = require("@uniformdev/design-system");
|
|
960
966
|
|
|
961
967
|
// src/components/EditLink/EditLink.styles.ts
|
|
962
|
-
var
|
|
963
|
-
var editLink =
|
|
968
|
+
var import_react13 = require("@emotion/react");
|
|
969
|
+
var editLink = import_react13.css`
|
|
964
970
|
display: flex;
|
|
965
971
|
align-items: center;
|
|
966
972
|
font-weight: var(--fw-bold);
|
|
@@ -993,16 +999,16 @@ var EditLink = ({ linkTo, name, linkText = `Edit ${name} Component` }) => {
|
|
|
993
999
|
};
|
|
994
1000
|
|
|
995
1001
|
// src/components/EnrichmentTag/EnrichmentTag.tsx
|
|
996
|
-
var
|
|
1002
|
+
var import_react14 = require("@emotion/react");
|
|
997
1003
|
var import_CgCloseO = require("@react-icons/all-files/cg/CgCloseO");
|
|
998
1004
|
var import_CgMathMinus = require("@react-icons/all-files/cg/CgMathMinus");
|
|
999
1005
|
var import_CgMathPlus = require("@react-icons/all-files/cg/CgMathPlus");
|
|
1000
1006
|
var import_context = require("@uniformdev/context");
|
|
1001
1007
|
var import_design_system9 = require("@uniformdev/design-system");
|
|
1002
1008
|
var import_immer = require("immer");
|
|
1003
|
-
var
|
|
1009
|
+
var import_react15 = require("react");
|
|
1004
1010
|
var import_jsx_runtime15 = require("@emotion/react/jsx-runtime");
|
|
1005
|
-
var addEnrichmentLink =
|
|
1011
|
+
var addEnrichmentLink = import_react14.css`
|
|
1006
1012
|
flex: 2;
|
|
1007
1013
|
display: flex;
|
|
1008
1014
|
width: 50%;
|
|
@@ -1021,19 +1027,19 @@ var EnrichmentTag = ({
|
|
|
1021
1027
|
displayTitle = true
|
|
1022
1028
|
}) => {
|
|
1023
1029
|
const { loading, result: dimensions, error } = useDimensions(contextConfig);
|
|
1024
|
-
const allEnrichments = (0,
|
|
1030
|
+
const allEnrichments = (0, import_react15.useMemo)(() => {
|
|
1025
1031
|
if (dimensions) return dimensions.dimensions.filter((dimension) => dimension.category === "ENR");
|
|
1026
1032
|
}, [dimensions]);
|
|
1027
|
-
const remainingEnrichments = (0,
|
|
1033
|
+
const remainingEnrichments = (0, import_react15.useMemo)(() => {
|
|
1028
1034
|
if (!value) return allEnrichments;
|
|
1029
1035
|
if (allEnrichments)
|
|
1030
1036
|
return allEnrichments.filter(
|
|
1031
1037
|
(enr) => !value.some((val) => (0, import_context.getEnrichmentVectorKey)(val.cat, val.key) === enr.dim)
|
|
1032
1038
|
);
|
|
1033
1039
|
}, [allEnrichments, value]);
|
|
1034
|
-
const [selectValue, setSelectValue] = (0,
|
|
1035
|
-
const [score, setScore] = (0,
|
|
1036
|
-
const [showAddNewEnrichmentTagPanel, setShowAddNewEnrichmentTagPanel] = (0,
|
|
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);
|
|
1037
1043
|
const selectedEnrichment = allEnrichments == null ? void 0 : allEnrichments.find((dimension) => dimension.dim === selectValue);
|
|
1038
1044
|
const addEnrichment = () => {
|
|
1039
1045
|
const [cat, key] = selectValue.split("_");
|
|
@@ -1191,7 +1197,7 @@ var NoEnrichmentsView = ({ contextConfig }) => /* @__PURE__ */ (0, import_jsx_ru
|
|
|
1191
1197
|
var getCappedValue = (value, maxCap = 100, minCap = 0) => {
|
|
1192
1198
|
return Math.max(Math.min(value, maxCap), minCap);
|
|
1193
1199
|
};
|
|
1194
|
-
var scoreCounterMinusButtonStyles =
|
|
1200
|
+
var scoreCounterMinusButtonStyles = import_react14.css`
|
|
1195
1201
|
position: absolute;
|
|
1196
1202
|
bottom: 0.875rem;
|
|
1197
1203
|
left: var(--spacing-sm);
|
|
@@ -1204,7 +1210,7 @@ var scoreCounterMinusButtonStyles = import_react13.css`
|
|
|
1204
1210
|
border: 1px solid var(--gray-300);
|
|
1205
1211
|
border-radius: var(--rounded-full);
|
|
1206
1212
|
`;
|
|
1207
|
-
var scoreCounterPlusButtonStyles =
|
|
1213
|
+
var scoreCounterPlusButtonStyles = import_react14.css`
|
|
1208
1214
|
${scoreCounterMinusButtonStyles}
|
|
1209
1215
|
left: auto;
|
|
1210
1216
|
right: var(--spacing-sm);
|
|
@@ -1352,7 +1358,7 @@ var SelectedEnrichments = ({ list, setList, dimIndex }) => {
|
|
|
1352
1358
|
|
|
1353
1359
|
// src/components/PersonalizationCriteria/PersonalizationCriteria.tsx
|
|
1354
1360
|
var import_design_system11 = require("@uniformdev/design-system");
|
|
1355
|
-
var
|
|
1361
|
+
var import_react18 = require("react");
|
|
1356
1362
|
var import_react_use = require("react-use");
|
|
1357
1363
|
var yup = __toESM(require("yup"));
|
|
1358
1364
|
|
|
@@ -1368,20 +1374,20 @@ function opHasRhs(op) {
|
|
|
1368
1374
|
}
|
|
1369
1375
|
|
|
1370
1376
|
// src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.tsx
|
|
1371
|
-
var
|
|
1377
|
+
var import_react17 = require("@emotion/react");
|
|
1372
1378
|
var import_CgCloseO2 = require("@react-icons/all-files/cg/CgCloseO");
|
|
1373
1379
|
var import_design_system10 = require("@uniformdev/design-system");
|
|
1374
1380
|
var import_immer2 = require("immer");
|
|
1375
1381
|
|
|
1376
1382
|
// src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.styles.ts
|
|
1377
|
-
var
|
|
1383
|
+
var import_react16 = require("@emotion/react");
|
|
1378
1384
|
var spaceBetweenCriteriaItems = "6rem";
|
|
1379
|
-
var criteriaItem =
|
|
1385
|
+
var criteriaItem = import_react16.css`
|
|
1380
1386
|
position: relative;
|
|
1381
1387
|
padding: var(--spacing-md) var(--spacing-base);
|
|
1382
1388
|
border: 1px solid var(--gray-300);
|
|
1383
|
-
box-shadow: var(--
|
|
1384
|
-
background-color: white;
|
|
1389
|
+
box-shadow: var(--elevation-200);
|
|
1390
|
+
background-color: var(--white);
|
|
1385
1391
|
border-radius: var(--rounded-base);
|
|
1386
1392
|
margin-top: ${spaceBetweenCriteriaItems};
|
|
1387
1393
|
display: flex;
|
|
@@ -1398,13 +1404,13 @@ var criteriaItem = import_react15.css`
|
|
|
1398
1404
|
}
|
|
1399
1405
|
|
|
1400
1406
|
&:first-of-type {
|
|
1401
|
-
margin-top:
|
|
1407
|
+
margin-top: 0;
|
|
1402
1408
|
&:before {
|
|
1403
1409
|
display: none;
|
|
1404
1410
|
}
|
|
1405
1411
|
}
|
|
1406
1412
|
`;
|
|
1407
|
-
var criteriaItemInner =
|
|
1413
|
+
var criteriaItemInner = import_react16.css`
|
|
1408
1414
|
display: flex;
|
|
1409
1415
|
row-gap: var(--spacing-base);
|
|
1410
1416
|
column-gap: var(--spacing-xs);
|
|
@@ -1412,23 +1418,23 @@ var criteriaItemInner = import_react15.css`
|
|
|
1412
1418
|
flex-wrap: wrap;
|
|
1413
1419
|
margin-right: var(--spacing-base);
|
|
1414
1420
|
`;
|
|
1415
|
-
var criteriaWrapper =
|
|
1421
|
+
var criteriaWrapper = import_react16.css`
|
|
1416
1422
|
width: 100%;
|
|
1417
1423
|
display: flex;
|
|
1418
1424
|
align-items: stretch;
|
|
1419
1425
|
position: relative;
|
|
1420
1426
|
`;
|
|
1421
|
-
var criteriaOperandWrapper =
|
|
1427
|
+
var criteriaOperandWrapper = import_react16.css`
|
|
1422
1428
|
flex: 2;
|
|
1423
1429
|
height: 52px;
|
|
1424
1430
|
min-width: 200px;
|
|
1425
1431
|
`;
|
|
1426
|
-
var criteriaOperatorWrapper =
|
|
1432
|
+
var criteriaOperatorWrapper = import_react16.css`
|
|
1427
1433
|
flex: 1;
|
|
1428
1434
|
flex-wrap: nowrap;
|
|
1429
1435
|
min-width: 80px;
|
|
1430
1436
|
`;
|
|
1431
|
-
var expand =
|
|
1437
|
+
var expand = import_react16.css`
|
|
1432
1438
|
height: 100%;
|
|
1433
1439
|
width: 100%;
|
|
1434
1440
|
`;
|
|
@@ -1492,195 +1498,197 @@ var PersonalizationCriteriaStatic = ({
|
|
|
1492
1498
|
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Heading, { level: 5, withMarginBottom: false, children: "Personalization Variation" })
|
|
1493
1499
|
}
|
|
1494
1500
|
) : null,
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css:
|
|
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
|
+
] }),
|
|
1506
1643
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1507
|
-
"
|
|
1644
|
+
"button",
|
|
1508
1645
|
{
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
errorMessage: (_b = errors.lhs) == null ? void 0 : _b[index],
|
|
1516
|
-
css: expand,
|
|
1517
|
-
styles: { control: (base) => ({ ...base, height: "100%" }) },
|
|
1518
|
-
dimensions: dimensions.dimensions,
|
|
1519
|
-
quirks,
|
|
1520
|
-
onChange: (selection) => {
|
|
1521
|
-
if (!selection) {
|
|
1522
|
-
return;
|
|
1523
|
-
}
|
|
1524
|
-
if ("dim" in selection) {
|
|
1525
|
-
const validOperators = getValidCriteriaOperatorsFor(selection.category);
|
|
1526
|
-
const existingOpRemainsValid = !("t" in currentCriteria && currentCriteria.t === "q") && validOperators.some((op) => op.value === currentCriteria.op);
|
|
1527
|
-
const newCriteria = {
|
|
1528
|
-
...currentCriteria,
|
|
1529
|
-
l: selection.dim,
|
|
1530
|
-
t: void 0,
|
|
1531
|
-
op: existingOpRemainsValid ? currentCriteria.op : ">",
|
|
1532
|
-
r: existingOpRemainsValid ? currentCriteria.r : 0,
|
|
1533
|
-
rDim: existingOpRemainsValid ? currentCriteria.rDim : void 0
|
|
1534
|
-
};
|
|
1535
|
-
update(newCriteria, index);
|
|
1536
|
-
} else {
|
|
1537
|
-
update({ ...currentCriteria, l: selection.id, t: "q", op: "=", r: "" }, index);
|
|
1538
|
-
}
|
|
1539
|
-
},
|
|
1540
|
-
value: currentDimension != null ? currentDimension : currentQuirk,
|
|
1541
|
-
onMenuOpen,
|
|
1542
|
-
onMenuClose
|
|
1543
|
-
}
|
|
1544
|
-
)
|
|
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" })
|
|
1545
1652
|
}
|
|
1546
1653
|
),
|
|
1547
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1654
|
+
index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1548
1655
|
"div",
|
|
1549
1656
|
{
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1657
|
+
className: "criteria-group-operation",
|
|
1658
|
+
css: {
|
|
1659
|
+
position: "absolute",
|
|
1660
|
+
top: "-4rem",
|
|
1661
|
+
transform: "translateX(calc(1.5rem - 50%))"
|
|
1662
|
+
},
|
|
1553
1663
|
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1554
|
-
|
|
1555
|
-
{
|
|
1556
|
-
name: `op-${index}`,
|
|
1557
|
-
css: expand,
|
|
1558
|
-
styles: { control: (base) => ({ ...base, height: "100%" }) },
|
|
1559
|
-
value: currentCriteria.op,
|
|
1560
|
-
rhsType: currentQuirk ? "QUIRK" : currentDimension == null ? void 0 : currentDimension.category,
|
|
1561
|
-
onChange: (op) => {
|
|
1562
|
-
if (op === "+" || op === "-") {
|
|
1563
|
-
update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
|
|
1564
|
-
} else {
|
|
1565
|
-
update({ ...currentCriteria, op }, index);
|
|
1566
|
-
}
|
|
1567
|
-
},
|
|
1568
|
-
onMenuOpen,
|
|
1569
|
-
onMenuClose
|
|
1570
|
-
}
|
|
1571
|
-
)
|
|
1572
|
-
}
|
|
1573
|
-
),
|
|
1574
|
-
critHasRhs ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1575
|
-
"div",
|
|
1576
|
-
{
|
|
1577
|
-
css: [criteriaWrapper, criteriaOperandWrapper],
|
|
1578
|
-
className: "criteria-wrapper",
|
|
1579
|
-
"data-testid": "select-match-criteria",
|
|
1580
|
-
children: currentQuirk ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1581
|
-
"div",
|
|
1664
|
+
import_design_system10.InputInlineSelect,
|
|
1582
1665
|
{
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
{
|
|
1594
|
-
label: "quirk match value",
|
|
1595
|
-
showLabel: false,
|
|
1596
|
-
value: (_c = currentCriteria.r) != null ? _c : "",
|
|
1597
|
-
errorMessage: (_d = errors.rhs) == null ? void 0 : _d[index],
|
|
1598
|
-
onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
|
|
1599
|
-
options: [
|
|
1600
|
-
{ label: "Select\u2026", value: "" },
|
|
1601
|
-
...currentQuirk.options.map((o) => ({ label: o.name, value: o.value }))
|
|
1602
|
-
]
|
|
1603
|
-
}
|
|
1604
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1605
|
-
import_design_system10.Input,
|
|
1606
|
-
{
|
|
1607
|
-
type: "text",
|
|
1608
|
-
label: "quirk match value",
|
|
1609
|
-
showLabel: false,
|
|
1610
|
-
value: (_e = currentCriteria.r) != null ? _e : "",
|
|
1611
|
-
errorMessage: (_f = errors.rhs) == null ? void 0 : _f[index],
|
|
1612
|
-
onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
|
|
1613
|
-
placeholder: "Enter a value"
|
|
1614
|
-
}
|
|
1615
|
-
)
|
|
1616
|
-
}
|
|
1617
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1618
|
-
CriteriaMatchMenu,
|
|
1619
|
-
{
|
|
1620
|
-
errorMessage: (_g = errors.rhs) == null ? void 0 : _g[index],
|
|
1621
|
-
css: expand,
|
|
1622
|
-
styles: { control: (base) => ({ ...base, height: "100%" }) },
|
|
1623
|
-
criteriaMatch: currentCriteria,
|
|
1624
|
-
onChange: (match) => {
|
|
1625
|
-
update(match, index);
|
|
1626
|
-
},
|
|
1627
|
-
isDisabled: !critHasLhs,
|
|
1628
|
-
dimensions,
|
|
1629
|
-
onMenuOpen,
|
|
1630
|
-
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
|
+
}
|
|
1631
1676
|
}
|
|
1632
1677
|
)
|
|
1633
1678
|
}
|
|
1634
1679
|
) : null
|
|
1635
|
-
] })
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1648
|
-
"div",
|
|
1649
|
-
{
|
|
1650
|
-
className: "criteria-group-operation",
|
|
1651
|
-
css: {
|
|
1652
|
-
position: "absolute",
|
|
1653
|
-
top: "-4rem",
|
|
1654
|
-
transform: "translateX(calc(1.5rem - 50%))"
|
|
1655
|
-
},
|
|
1656
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1657
|
-
import_design_system10.InputInlineSelect,
|
|
1658
|
-
{
|
|
1659
|
-
"data-testid": "dropdown-button-combine",
|
|
1660
|
-
disabled: index > 1,
|
|
1661
|
-
value: (_h = currentValue.op) != null ? _h : "&",
|
|
1662
|
-
options: [
|
|
1663
|
-
{ label: "AND", value: "&" },
|
|
1664
|
-
{ label: "OR", value: "|" }
|
|
1665
|
-
],
|
|
1666
|
-
onChange: (v) => {
|
|
1667
|
-
setOp(v.value);
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
)
|
|
1671
|
-
}
|
|
1672
|
-
) : null
|
|
1673
|
-
] }, index);
|
|
1674
|
-
}) }),
|
|
1675
|
-
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)(
|
|
1676
|
-
import_design_system10.AddListButton,
|
|
1677
|
-
{
|
|
1678
|
-
"data-testid": "button-add-criteria",
|
|
1679
|
-
className: "add-more",
|
|
1680
|
-
buttonText: "Add Criteria",
|
|
1681
|
-
onButtonClick: addToList
|
|
1682
|
-
}
|
|
1683
|
-
)
|
|
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
|
+
] })
|
|
1684
1692
|
] });
|
|
1685
1693
|
};
|
|
1686
1694
|
|
|
@@ -1745,7 +1753,7 @@ var PersonalizationCriteria = ({
|
|
|
1745
1753
|
...staticProps
|
|
1746
1754
|
}) => {
|
|
1747
1755
|
var _a, _b;
|
|
1748
|
-
const [validationError, setValidationError] = (0,
|
|
1756
|
+
const [validationError, setValidationError] = (0, import_react18.useState)(void 0);
|
|
1749
1757
|
const { loading, result: dimensions, error } = useDimensions(contextConfig);
|
|
1750
1758
|
(0, import_react_use.useAsync)(async () => {
|
|
1751
1759
|
if (value && dimensions) {
|
|
@@ -1809,7 +1817,7 @@ function ProjectUIVersion({ children, versionMap, contextConfig }) {
|
|
|
1809
1817
|
}
|
|
1810
1818
|
|
|
1811
1819
|
// src/hooks/useValidateContextConfig.ts
|
|
1812
|
-
var
|
|
1820
|
+
var import_react19 = require("react");
|
|
1813
1821
|
|
|
1814
1822
|
// src/utils/validateContextConfig.ts
|
|
1815
1823
|
var import_api4 = require("@uniformdev/context/api");
|
|
@@ -1845,12 +1853,12 @@ var validateContextConfig = async (contextConfig) => {
|
|
|
1845
1853
|
|
|
1846
1854
|
// src/hooks/useValidateContextConfig.ts
|
|
1847
1855
|
var useValidateContextConfig = (contextConfig) => {
|
|
1848
|
-
const [state, setState] = (0,
|
|
1856
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
1849
1857
|
validating: false,
|
|
1850
1858
|
error: void 0
|
|
1851
1859
|
});
|
|
1852
1860
|
const { apiKey, apiHost, projectId } = contextConfig || {};
|
|
1853
|
-
(0,
|
|
1861
|
+
(0, import_react19.useEffect)(() => {
|
|
1854
1862
|
if (!apiKey || !apiHost) {
|
|
1855
1863
|
return;
|
|
1856
1864
|
}
|