@uniformdev/context-ui 20.7.1-alpha.81 → 20.7.1-alpha.83
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.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.esm.js +256 -220
- package/dist/index.js +264 -228
- package/dist/index.mjs +256 -220
- package/package.json +7 -8
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
|
|
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
|
|
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
|
-
|
|
753
|
-
|
|
754
|
-
{
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
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,
|
|
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,6 +929,7 @@ 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,
|
|
913
935
|
getOptionValue: (option) => option.label,
|
|
@@ -946,8 +968,8 @@ var import_CgChevronRight = require("@react-icons/all-files/cg/CgChevronRight");
|
|
|
946
968
|
var import_design_system8 = require("@uniformdev/design-system");
|
|
947
969
|
|
|
948
970
|
// src/components/EditLink/EditLink.styles.ts
|
|
949
|
-
var
|
|
950
|
-
var editLink =
|
|
971
|
+
var import_react13 = require("@emotion/react");
|
|
972
|
+
var editLink = import_react13.css`
|
|
951
973
|
display: flex;
|
|
952
974
|
align-items: center;
|
|
953
975
|
font-weight: var(--fw-bold);
|
|
@@ -980,16 +1002,16 @@ var EditLink = ({ linkTo, name, linkText = `Edit ${name} Component` }) => {
|
|
|
980
1002
|
};
|
|
981
1003
|
|
|
982
1004
|
// src/components/EnrichmentTag/EnrichmentTag.tsx
|
|
983
|
-
var
|
|
1005
|
+
var import_react14 = require("@emotion/react");
|
|
984
1006
|
var import_CgCloseO = require("@react-icons/all-files/cg/CgCloseO");
|
|
985
1007
|
var import_CgMathMinus = require("@react-icons/all-files/cg/CgMathMinus");
|
|
986
1008
|
var import_CgMathPlus = require("@react-icons/all-files/cg/CgMathPlus");
|
|
987
1009
|
var import_context = require("@uniformdev/context");
|
|
988
1010
|
var import_design_system9 = require("@uniformdev/design-system");
|
|
989
1011
|
var import_immer = require("immer");
|
|
990
|
-
var
|
|
1012
|
+
var import_react15 = require("react");
|
|
991
1013
|
var import_jsx_runtime15 = require("@emotion/react/jsx-runtime");
|
|
992
|
-
var addEnrichmentLink =
|
|
1014
|
+
var addEnrichmentLink = import_react14.css`
|
|
993
1015
|
flex: 2;
|
|
994
1016
|
display: flex;
|
|
995
1017
|
width: 50%;
|
|
@@ -1008,19 +1030,19 @@ var EnrichmentTag = ({
|
|
|
1008
1030
|
displayTitle = true
|
|
1009
1031
|
}) => {
|
|
1010
1032
|
const { loading, result: dimensions, error } = useDimensions(contextConfig);
|
|
1011
|
-
const allEnrichments = (0,
|
|
1033
|
+
const allEnrichments = (0, import_react15.useMemo)(() => {
|
|
1012
1034
|
if (dimensions) return dimensions.dimensions.filter((dimension) => dimension.category === "ENR");
|
|
1013
1035
|
}, [dimensions]);
|
|
1014
|
-
const remainingEnrichments = (0,
|
|
1036
|
+
const remainingEnrichments = (0, import_react15.useMemo)(() => {
|
|
1015
1037
|
if (!value) return allEnrichments;
|
|
1016
1038
|
if (allEnrichments)
|
|
1017
1039
|
return allEnrichments.filter(
|
|
1018
1040
|
(enr) => !value.some((val) => (0, import_context.getEnrichmentVectorKey)(val.cat, val.key) === enr.dim)
|
|
1019
1041
|
);
|
|
1020
1042
|
}, [allEnrichments, value]);
|
|
1021
|
-
const [selectValue, setSelectValue] = (0,
|
|
1022
|
-
const [score, setScore] = (0,
|
|
1023
|
-
const [showAddNewEnrichmentTagPanel, setShowAddNewEnrichmentTagPanel] = (0,
|
|
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);
|
|
1024
1046
|
const selectedEnrichment = allEnrichments == null ? void 0 : allEnrichments.find((dimension) => dimension.dim === selectValue);
|
|
1025
1047
|
const addEnrichment = () => {
|
|
1026
1048
|
const [cat, key] = selectValue.split("_");
|
|
@@ -1178,7 +1200,7 @@ var NoEnrichmentsView = ({ contextConfig }) => /* @__PURE__ */ (0, import_jsx_ru
|
|
|
1178
1200
|
var getCappedValue = (value, maxCap = 100, minCap = 0) => {
|
|
1179
1201
|
return Math.max(Math.min(value, maxCap), minCap);
|
|
1180
1202
|
};
|
|
1181
|
-
var scoreCounterMinusButtonStyles =
|
|
1203
|
+
var scoreCounterMinusButtonStyles = import_react14.css`
|
|
1182
1204
|
position: absolute;
|
|
1183
1205
|
bottom: 0.875rem;
|
|
1184
1206
|
left: var(--spacing-sm);
|
|
@@ -1191,7 +1213,7 @@ var scoreCounterMinusButtonStyles = import_react13.css`
|
|
|
1191
1213
|
border: 1px solid var(--gray-300);
|
|
1192
1214
|
border-radius: var(--rounded-full);
|
|
1193
1215
|
`;
|
|
1194
|
-
var scoreCounterPlusButtonStyles =
|
|
1216
|
+
var scoreCounterPlusButtonStyles = import_react14.css`
|
|
1195
1217
|
${scoreCounterMinusButtonStyles}
|
|
1196
1218
|
left: auto;
|
|
1197
1219
|
right: var(--spacing-sm);
|
|
@@ -1339,7 +1361,7 @@ var SelectedEnrichments = ({ list, setList, dimIndex }) => {
|
|
|
1339
1361
|
|
|
1340
1362
|
// src/components/PersonalizationCriteria/PersonalizationCriteria.tsx
|
|
1341
1363
|
var import_design_system11 = require("@uniformdev/design-system");
|
|
1342
|
-
var
|
|
1364
|
+
var import_react18 = require("react");
|
|
1343
1365
|
var import_react_use = require("react-use");
|
|
1344
1366
|
var yup = __toESM(require("yup"));
|
|
1345
1367
|
|
|
@@ -1355,20 +1377,20 @@ function opHasRhs(op) {
|
|
|
1355
1377
|
}
|
|
1356
1378
|
|
|
1357
1379
|
// src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.tsx
|
|
1358
|
-
var
|
|
1380
|
+
var import_react17 = require("@emotion/react");
|
|
1359
1381
|
var import_CgCloseO2 = require("@react-icons/all-files/cg/CgCloseO");
|
|
1360
1382
|
var import_design_system10 = require("@uniformdev/design-system");
|
|
1361
1383
|
var import_immer2 = require("immer");
|
|
1362
1384
|
|
|
1363
1385
|
// src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.styles.ts
|
|
1364
|
-
var
|
|
1386
|
+
var import_react16 = require("@emotion/react");
|
|
1365
1387
|
var spaceBetweenCriteriaItems = "6rem";
|
|
1366
|
-
var criteriaItem =
|
|
1388
|
+
var criteriaItem = import_react16.css`
|
|
1367
1389
|
position: relative;
|
|
1368
1390
|
padding: var(--spacing-md) var(--spacing-base);
|
|
1369
1391
|
border: 1px solid var(--gray-300);
|
|
1370
|
-
box-shadow: var(--
|
|
1371
|
-
background-color: white;
|
|
1392
|
+
box-shadow: var(--elevation-200);
|
|
1393
|
+
background-color: var(--white);
|
|
1372
1394
|
border-radius: var(--rounded-base);
|
|
1373
1395
|
margin-top: ${spaceBetweenCriteriaItems};
|
|
1374
1396
|
display: flex;
|
|
@@ -1385,13 +1407,13 @@ var criteriaItem = import_react15.css`
|
|
|
1385
1407
|
}
|
|
1386
1408
|
|
|
1387
1409
|
&:first-of-type {
|
|
1388
|
-
margin-top:
|
|
1410
|
+
margin-top: 0;
|
|
1389
1411
|
&:before {
|
|
1390
1412
|
display: none;
|
|
1391
1413
|
}
|
|
1392
1414
|
}
|
|
1393
1415
|
`;
|
|
1394
|
-
var criteriaItemInner =
|
|
1416
|
+
var criteriaItemInner = import_react16.css`
|
|
1395
1417
|
display: flex;
|
|
1396
1418
|
row-gap: var(--spacing-base);
|
|
1397
1419
|
column-gap: var(--spacing-xs);
|
|
@@ -1399,23 +1421,23 @@ var criteriaItemInner = import_react15.css`
|
|
|
1399
1421
|
flex-wrap: wrap;
|
|
1400
1422
|
margin-right: var(--spacing-base);
|
|
1401
1423
|
`;
|
|
1402
|
-
var criteriaWrapper =
|
|
1424
|
+
var criteriaWrapper = import_react16.css`
|
|
1403
1425
|
width: 100%;
|
|
1404
1426
|
display: flex;
|
|
1405
1427
|
align-items: stretch;
|
|
1406
1428
|
position: relative;
|
|
1407
1429
|
`;
|
|
1408
|
-
var criteriaOperandWrapper =
|
|
1430
|
+
var criteriaOperandWrapper = import_react16.css`
|
|
1409
1431
|
flex: 2;
|
|
1410
1432
|
height: 52px;
|
|
1411
1433
|
min-width: 200px;
|
|
1412
1434
|
`;
|
|
1413
|
-
var criteriaOperatorWrapper =
|
|
1435
|
+
var criteriaOperatorWrapper = import_react16.css`
|
|
1414
1436
|
flex: 1;
|
|
1415
1437
|
flex-wrap: nowrap;
|
|
1416
1438
|
min-width: 80px;
|
|
1417
1439
|
`;
|
|
1418
|
-
var expand =
|
|
1440
|
+
var expand = import_react16.css`
|
|
1419
1441
|
height: 100%;
|
|
1420
1442
|
width: 100%;
|
|
1421
1443
|
`;
|
|
@@ -1433,7 +1455,8 @@ var PersonalizationCriteriaStatic = ({
|
|
|
1433
1455
|
onRemoveCriteria,
|
|
1434
1456
|
displayTitle = true,
|
|
1435
1457
|
components,
|
|
1436
|
-
errors = {}
|
|
1458
|
+
errors = {},
|
|
1459
|
+
readOnly
|
|
1437
1460
|
}) => {
|
|
1438
1461
|
var _a;
|
|
1439
1462
|
const currentValue = { crit: [], ...value };
|
|
@@ -1479,192 +1502,204 @@ var PersonalizationCriteriaStatic = ({
|
|
|
1479
1502
|
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Heading, { level: 5, withMarginBottom: false, children: "Personalization Variation" })
|
|
1480
1503
|
}
|
|
1481
1504
|
) : null,
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { css:
|
|
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
|
+
] }),
|
|
1493
1652
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1494
|
-
"
|
|
1653
|
+
"button",
|
|
1495
1654
|
{
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
css: expand,
|
|
1504
|
-
styles: { control: (base) => ({ ...base, height: "100%" }) },
|
|
1505
|
-
dimensions: dimensions.dimensions,
|
|
1506
|
-
quirks,
|
|
1507
|
-
onChange: (selection) => {
|
|
1508
|
-
if (!selection) {
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1511
|
-
if ("dim" in selection) {
|
|
1512
|
-
const newCriteria = {
|
|
1513
|
-
...currentCriteria,
|
|
1514
|
-
l: selection.dim,
|
|
1515
|
-
t: void 0,
|
|
1516
|
-
op: ">",
|
|
1517
|
-
r: 0
|
|
1518
|
-
};
|
|
1519
|
-
update(newCriteria, index);
|
|
1520
|
-
} else {
|
|
1521
|
-
update({ ...currentCriteria, l: selection.id, t: "q", op: "=", r: "" }, index);
|
|
1522
|
-
}
|
|
1523
|
-
},
|
|
1524
|
-
value: currentDimension != null ? currentDimension : currentQuirk,
|
|
1525
|
-
onMenuOpen,
|
|
1526
|
-
onMenuClose
|
|
1527
|
-
}
|
|
1528
|
-
)
|
|
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" })
|
|
1529
1662
|
}
|
|
1530
1663
|
),
|
|
1531
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1664
|
+
index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1532
1665
|
"div",
|
|
1533
1666
|
{
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1667
|
+
className: "criteria-group-operation",
|
|
1668
|
+
css: {
|
|
1669
|
+
position: "absolute",
|
|
1670
|
+
top: "-4rem",
|
|
1671
|
+
transform: "translateX(calc(1.5rem - 50%))"
|
|
1672
|
+
},
|
|
1537
1673
|
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1538
|
-
|
|
1539
|
-
{
|
|
1540
|
-
name: `op-${index}`,
|
|
1541
|
-
css: expand,
|
|
1542
|
-
styles: { control: (base) => ({ ...base, height: "100%" }) },
|
|
1543
|
-
value: currentCriteria.op,
|
|
1544
|
-
rhsType: currentQuirk ? "QUIRK" : currentDimension == null ? void 0 : currentDimension.category,
|
|
1545
|
-
onChange: (op) => {
|
|
1546
|
-
if (op === "+" || op === "-") {
|
|
1547
|
-
update({ ...currentCriteria, op, r: void 0, rDim: void 0 }, index);
|
|
1548
|
-
} else {
|
|
1549
|
-
update({ ...currentCriteria, op }, index);
|
|
1550
|
-
}
|
|
1551
|
-
},
|
|
1552
|
-
onMenuOpen,
|
|
1553
|
-
onMenuClose
|
|
1554
|
-
}
|
|
1555
|
-
)
|
|
1556
|
-
}
|
|
1557
|
-
),
|
|
1558
|
-
critHasRhs ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1559
|
-
"div",
|
|
1560
|
-
{
|
|
1561
|
-
css: [criteriaWrapper, criteriaOperandWrapper],
|
|
1562
|
-
className: "criteria-wrapper",
|
|
1563
|
-
"data-testid": "select-match-criteria",
|
|
1564
|
-
children: currentQuirk ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1565
|
-
"div",
|
|
1674
|
+
import_design_system10.InputInlineSelect,
|
|
1566
1675
|
{
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
{
|
|
1578
|
-
label: "quirk match value",
|
|
1579
|
-
showLabel: false,
|
|
1580
|
-
value: (_c = currentCriteria.r) != null ? _c : "",
|
|
1581
|
-
errorMessage: (_d = errors.rhs) == null ? void 0 : _d[index],
|
|
1582
|
-
onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
|
|
1583
|
-
options: [
|
|
1584
|
-
{ label: "Select\u2026", value: "" },
|
|
1585
|
-
...currentQuirk.options.map((o) => ({ label: o.name, value: o.value }))
|
|
1586
|
-
]
|
|
1587
|
-
}
|
|
1588
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1589
|
-
import_design_system10.Input,
|
|
1590
|
-
{
|
|
1591
|
-
type: "text",
|
|
1592
|
-
label: "quirk match value",
|
|
1593
|
-
showLabel: false,
|
|
1594
|
-
value: (_e = currentCriteria.r) != null ? _e : "",
|
|
1595
|
-
errorMessage: (_f = errors.rhs) == null ? void 0 : _f[index],
|
|
1596
|
-
onChange: (e) => update({ ...currentCriteria, r: e.currentTarget.value }, index),
|
|
1597
|
-
placeholder: "Enter a value"
|
|
1598
|
-
}
|
|
1599
|
-
)
|
|
1600
|
-
}
|
|
1601
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1602
|
-
CriteriaMatchMenu,
|
|
1603
|
-
{
|
|
1604
|
-
errorMessage: (_g = errors.rhs) == null ? void 0 : _g[index],
|
|
1605
|
-
css: expand,
|
|
1606
|
-
styles: { control: (base) => ({ ...base, height: "100%" }) },
|
|
1607
|
-
criteriaMatch: currentCriteria,
|
|
1608
|
-
onChange: (match) => {
|
|
1609
|
-
update(match, index);
|
|
1610
|
-
},
|
|
1611
|
-
isDisabled: !critHasLhs,
|
|
1612
|
-
dimensions,
|
|
1613
|
-
onMenuOpen,
|
|
1614
|
-
onMenuClose
|
|
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
|
+
}
|
|
1615
1686
|
}
|
|
1616
1687
|
)
|
|
1617
1688
|
}
|
|
1618
1689
|
) : null
|
|
1619
|
-
] })
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
"div",
|
|
1633
|
-
{
|
|
1634
|
-
className: "criteria-group-operation",
|
|
1635
|
-
css: {
|
|
1636
|
-
position: "absolute",
|
|
1637
|
-
top: "-4rem",
|
|
1638
|
-
transform: "translateX(calc(1.5rem - 50%))"
|
|
1639
|
-
},
|
|
1640
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1641
|
-
import_design_system10.InputInlineSelect,
|
|
1642
|
-
{
|
|
1643
|
-
"data-testid": "dropdown-button-combine",
|
|
1644
|
-
disabled: index > 1,
|
|
1645
|
-
value: (_h = currentValue.op) != null ? _h : "&",
|
|
1646
|
-
options: [
|
|
1647
|
-
{ label: "AND", value: "&" },
|
|
1648
|
-
{ label: "OR", value: "|" }
|
|
1649
|
-
],
|
|
1650
|
-
onChange: (v) => {
|
|
1651
|
-
setOp(v.value);
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
)
|
|
1655
|
-
}
|
|
1656
|
-
) : null
|
|
1657
|
-
] }, index);
|
|
1658
|
-
}) }),
|
|
1659
|
-
dimensions.dimensions.length === 0 && !(quirks == null ? void 0 : quirks.length) ? (components == null ? void 0 : components.NoDimensionsDefined) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(components.NoDimensionsDefined, {}) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Callout, { title: "Dimensions", type: "info", css: { marginBlock: "var(--spacing-base)" }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: "You do not have any dimensions configured." }) }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1660
|
-
import_design_system10.AddListButton,
|
|
1661
|
-
{
|
|
1662
|
-
"data-testid": "button-add-criteria",
|
|
1663
|
-
className: "add-more",
|
|
1664
|
-
buttonText: "Add Criteria",
|
|
1665
|
-
onButtonClick: addToList
|
|
1666
|
-
}
|
|
1667
|
-
)
|
|
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
|
+
] })
|
|
1668
1703
|
] });
|
|
1669
1704
|
};
|
|
1670
1705
|
|
|
@@ -1729,7 +1764,7 @@ var PersonalizationCriteria = ({
|
|
|
1729
1764
|
...staticProps
|
|
1730
1765
|
}) => {
|
|
1731
1766
|
var _a, _b;
|
|
1732
|
-
const [validationError, setValidationError] = (0,
|
|
1767
|
+
const [validationError, setValidationError] = (0, import_react18.useState)(void 0);
|
|
1733
1768
|
const { loading, result: dimensions, error } = useDimensions(contextConfig);
|
|
1734
1769
|
(0, import_react_use.useAsync)(async () => {
|
|
1735
1770
|
if (value && dimensions) {
|
|
@@ -1793,7 +1828,7 @@ function ProjectUIVersion({ children, versionMap, contextConfig }) {
|
|
|
1793
1828
|
}
|
|
1794
1829
|
|
|
1795
1830
|
// src/hooks/useValidateContextConfig.ts
|
|
1796
|
-
var
|
|
1831
|
+
var import_react19 = require("react");
|
|
1797
1832
|
|
|
1798
1833
|
// src/utils/validateContextConfig.ts
|
|
1799
1834
|
var import_api4 = require("@uniformdev/context/api");
|
|
@@ -1829,12 +1864,12 @@ var validateContextConfig = async (contextConfig) => {
|
|
|
1829
1864
|
|
|
1830
1865
|
// src/hooks/useValidateContextConfig.ts
|
|
1831
1866
|
var useValidateContextConfig = (contextConfig) => {
|
|
1832
|
-
const [state, setState] = (0,
|
|
1867
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
1833
1868
|
validating: false,
|
|
1834
1869
|
error: void 0
|
|
1835
1870
|
});
|
|
1836
1871
|
const { apiKey, apiHost, projectId } = contextConfig || {};
|
|
1837
|
-
(0,
|
|
1872
|
+
(0, import_react19.useEffect)(() => {
|
|
1838
1873
|
if (!apiKey || !apiHost) {
|
|
1839
1874
|
return;
|
|
1840
1875
|
}
|
|
@@ -1876,6 +1911,7 @@ __reExport(src_exports, require("@uniformdev/design-system"), module.exports);
|
|
|
1876
1911
|
contextCriteriaMenuOperators,
|
|
1877
1912
|
convertErrorsToObj,
|
|
1878
1913
|
enrichmentCriteriaMenuOperators,
|
|
1914
|
+
getValidCriteriaOperatorsFor,
|
|
1879
1915
|
isEnrichmentTagData,
|
|
1880
1916
|
isPersonalizationCriteriaData,
|
|
1881
1917
|
opHasRhs,
|