@uniformdev/context-ui 20.35.0 → 20.35.1-alpha.58
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 +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.esm.js +239 -219
- package/dist/index.js +251 -232
- package/dist/index.mjs +239 -219
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -374,6 +374,7 @@ function CriteriaOperatorMenu({ onChange, value, rhsType, ...props }) {
|
|
|
374
374
|
import_design_system2.InputComboBox,
|
|
375
375
|
{
|
|
376
376
|
...props,
|
|
377
|
+
isDisabled: props.disabled,
|
|
377
378
|
value: {
|
|
378
379
|
label: (_b = (_a = operators.find((e) => e.value === value)) == null ? void 0 : _a.name) != null ? _b : value,
|
|
379
380
|
value
|
|
@@ -610,7 +611,7 @@ function useDimensionsDataContext() {
|
|
|
610
611
|
|
|
611
612
|
// src/components/DimensionMenu/CriteriaMatchMenu.tsx
|
|
612
613
|
var import_design_system6 = require("@uniformdev/design-system");
|
|
613
|
-
var
|
|
614
|
+
var import_react12 = require("react");
|
|
614
615
|
|
|
615
616
|
// src/components/DimensionMenu/DimensionGroupHeading.tsx
|
|
616
617
|
var import_design_system4 = require("@uniformdev/design-system");
|
|
@@ -749,32 +750,38 @@ var DimensionOption = (props) => {
|
|
|
749
750
|
};
|
|
750
751
|
|
|
751
752
|
// src/components/DimensionMenu/DimensionValue.tsx
|
|
753
|
+
var import_react11 = require("@emotion/react");
|
|
752
754
|
var import_design_system5 = require("@uniformdev/design-system");
|
|
753
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
|
+
};
|
|
754
774
|
function DimensionValue({ displayName }) {
|
|
775
|
+
var _a;
|
|
755
776
|
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
|
-
);
|
|
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
|
+
] });
|
|
778
785
|
}
|
|
779
786
|
|
|
780
787
|
// src/components/DimensionMenu/DimensionSingleValue.tsx
|
|
@@ -794,12 +801,12 @@ function CriteriaMatchMenu({
|
|
|
794
801
|
...props
|
|
795
802
|
}) {
|
|
796
803
|
var _a, _b;
|
|
797
|
-
const [inputValue, setInputValue] = (0,
|
|
804
|
+
const [inputValue, setInputValue] = (0, import_react12.useState)(
|
|
798
805
|
typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
|
|
799
806
|
);
|
|
800
|
-
const currentInputValue = (0,
|
|
807
|
+
const currentInputValue = (0, import_react12.useRef)(inputValue);
|
|
801
808
|
currentInputValue.current = inputValue;
|
|
802
|
-
(0,
|
|
809
|
+
(0, import_react12.useEffect)(() => {
|
|
803
810
|
if (currentInputValue.current !== criteriaMatch.r && !criteriaMatch.rDim) {
|
|
804
811
|
setInputValue(
|
|
805
812
|
typeof criteriaMatch.r !== "undefined" && isInt(criteriaMatch.r) !== null ? criteriaMatch.r.toString(10) : ""
|
|
@@ -814,6 +821,7 @@ function CriteriaMatchMenu({
|
|
|
814
821
|
import_design_system6.InputComboBox,
|
|
815
822
|
{
|
|
816
823
|
...props,
|
|
824
|
+
isDisabled: props.disabled,
|
|
817
825
|
inputValue,
|
|
818
826
|
menuShouldScrollIntoView: true,
|
|
819
827
|
value: {
|
|
@@ -921,6 +929,7 @@ function DimensionMenu({
|
|
|
921
929
|
import_design_system7.InputComboBox,
|
|
922
930
|
{
|
|
923
931
|
...props,
|
|
932
|
+
isDisabled: props.disabled,
|
|
924
933
|
value: valueAsMenuOption,
|
|
925
934
|
options: groupedDimensions,
|
|
926
935
|
getOptionValue: (option) => option.label,
|
|
@@ -959,8 +968,8 @@ var import_CgChevronRight = require("@react-icons/all-files/cg/CgChevronRight");
|
|
|
959
968
|
var import_design_system8 = require("@uniformdev/design-system");
|
|
960
969
|
|
|
961
970
|
// src/components/EditLink/EditLink.styles.ts
|
|
962
|
-
var
|
|
963
|
-
var editLink =
|
|
971
|
+
var import_react13 = require("@emotion/react");
|
|
972
|
+
var editLink = import_react13.css`
|
|
964
973
|
display: flex;
|
|
965
974
|
align-items: center;
|
|
966
975
|
font-weight: var(--fw-bold);
|
|
@@ -993,16 +1002,16 @@ var EditLink = ({ linkTo, name, linkText = `Edit ${name} Component` }) => {
|
|
|
993
1002
|
};
|
|
994
1003
|
|
|
995
1004
|
// src/components/EnrichmentTag/EnrichmentTag.tsx
|
|
996
|
-
var
|
|
1005
|
+
var import_react14 = require("@emotion/react");
|
|
997
1006
|
var import_CgCloseO = require("@react-icons/all-files/cg/CgCloseO");
|
|
998
1007
|
var import_CgMathMinus = require("@react-icons/all-files/cg/CgMathMinus");
|
|
999
1008
|
var import_CgMathPlus = require("@react-icons/all-files/cg/CgMathPlus");
|
|
1000
1009
|
var import_context = require("@uniformdev/context");
|
|
1001
1010
|
var import_design_system9 = require("@uniformdev/design-system");
|
|
1002
1011
|
var import_immer = require("immer");
|
|
1003
|
-
var
|
|
1012
|
+
var import_react15 = require("react");
|
|
1004
1013
|
var import_jsx_runtime15 = require("@emotion/react/jsx-runtime");
|
|
1005
|
-
var addEnrichmentLink =
|
|
1014
|
+
var addEnrichmentLink = import_react14.css`
|
|
1006
1015
|
flex: 2;
|
|
1007
1016
|
display: flex;
|
|
1008
1017
|
width: 50%;
|
|
@@ -1021,19 +1030,19 @@ var EnrichmentTag = ({
|
|
|
1021
1030
|
displayTitle = true
|
|
1022
1031
|
}) => {
|
|
1023
1032
|
const { loading, result: dimensions, error } = useDimensions(contextConfig);
|
|
1024
|
-
const allEnrichments = (0,
|
|
1033
|
+
const allEnrichments = (0, import_react15.useMemo)(() => {
|
|
1025
1034
|
if (dimensions) return dimensions.dimensions.filter((dimension) => dimension.category === "ENR");
|
|
1026
1035
|
}, [dimensions]);
|
|
1027
|
-
const remainingEnrichments = (0,
|
|
1036
|
+
const remainingEnrichments = (0, import_react15.useMemo)(() => {
|
|
1028
1037
|
if (!value) return allEnrichments;
|
|
1029
1038
|
if (allEnrichments)
|
|
1030
1039
|
return allEnrichments.filter(
|
|
1031
1040
|
(enr) => !value.some((val) => (0, import_context.getEnrichmentVectorKey)(val.cat, val.key) === enr.dim)
|
|
1032
1041
|
);
|
|
1033
1042
|
}, [allEnrichments, value]);
|
|
1034
|
-
const [selectValue, setSelectValue] = (0,
|
|
1035
|
-
const [score, setScore] = (0,
|
|
1036
|
-
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);
|
|
1037
1046
|
const selectedEnrichment = allEnrichments == null ? void 0 : allEnrichments.find((dimension) => dimension.dim === selectValue);
|
|
1038
1047
|
const addEnrichment = () => {
|
|
1039
1048
|
const [cat, key] = selectValue.split("_");
|
|
@@ -1191,7 +1200,7 @@ var NoEnrichmentsView = ({ contextConfig }) => /* @__PURE__ */ (0, import_jsx_ru
|
|
|
1191
1200
|
var getCappedValue = (value, maxCap = 100, minCap = 0) => {
|
|
1192
1201
|
return Math.max(Math.min(value, maxCap), minCap);
|
|
1193
1202
|
};
|
|
1194
|
-
var scoreCounterMinusButtonStyles =
|
|
1203
|
+
var scoreCounterMinusButtonStyles = import_react14.css`
|
|
1195
1204
|
position: absolute;
|
|
1196
1205
|
bottom: 0.875rem;
|
|
1197
1206
|
left: var(--spacing-sm);
|
|
@@ -1204,7 +1213,7 @@ var scoreCounterMinusButtonStyles = import_react13.css`
|
|
|
1204
1213
|
border: 1px solid var(--gray-300);
|
|
1205
1214
|
border-radius: var(--rounded-full);
|
|
1206
1215
|
`;
|
|
1207
|
-
var scoreCounterPlusButtonStyles =
|
|
1216
|
+
var scoreCounterPlusButtonStyles = import_react14.css`
|
|
1208
1217
|
${scoreCounterMinusButtonStyles}
|
|
1209
1218
|
left: auto;
|
|
1210
1219
|
right: var(--spacing-sm);
|
|
@@ -1352,7 +1361,7 @@ var SelectedEnrichments = ({ list, setList, dimIndex }) => {
|
|
|
1352
1361
|
|
|
1353
1362
|
// src/components/PersonalizationCriteria/PersonalizationCriteria.tsx
|
|
1354
1363
|
var import_design_system11 = require("@uniformdev/design-system");
|
|
1355
|
-
var
|
|
1364
|
+
var import_react18 = require("react");
|
|
1356
1365
|
var import_react_use = require("react-use");
|
|
1357
1366
|
var yup = __toESM(require("yup"));
|
|
1358
1367
|
|
|
@@ -1368,20 +1377,20 @@ function opHasRhs(op) {
|
|
|
1368
1377
|
}
|
|
1369
1378
|
|
|
1370
1379
|
// src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.tsx
|
|
1371
|
-
var
|
|
1380
|
+
var import_react17 = require("@emotion/react");
|
|
1372
1381
|
var import_CgCloseO2 = require("@react-icons/all-files/cg/CgCloseO");
|
|
1373
1382
|
var import_design_system10 = require("@uniformdev/design-system");
|
|
1374
1383
|
var import_immer2 = require("immer");
|
|
1375
1384
|
|
|
1376
1385
|
// src/components/PersonalizationCriteria/PersonalizationCriteriaStatic.styles.ts
|
|
1377
|
-
var
|
|
1386
|
+
var import_react16 = require("@emotion/react");
|
|
1378
1387
|
var spaceBetweenCriteriaItems = "6rem";
|
|
1379
|
-
var criteriaItem =
|
|
1388
|
+
var criteriaItem = import_react16.css`
|
|
1380
1389
|
position: relative;
|
|
1381
1390
|
padding: var(--spacing-md) var(--spacing-base);
|
|
1382
1391
|
border: 1px solid var(--gray-300);
|
|
1383
|
-
box-shadow: var(--
|
|
1384
|
-
background-color: white;
|
|
1392
|
+
box-shadow: var(--elevation-200);
|
|
1393
|
+
background-color: var(--white);
|
|
1385
1394
|
border-radius: var(--rounded-base);
|
|
1386
1395
|
margin-top: ${spaceBetweenCriteriaItems};
|
|
1387
1396
|
display: flex;
|
|
@@ -1398,13 +1407,13 @@ var criteriaItem = import_react15.css`
|
|
|
1398
1407
|
}
|
|
1399
1408
|
|
|
1400
1409
|
&:first-of-type {
|
|
1401
|
-
margin-top:
|
|
1410
|
+
margin-top: 0;
|
|
1402
1411
|
&:before {
|
|
1403
1412
|
display: none;
|
|
1404
1413
|
}
|
|
1405
1414
|
}
|
|
1406
1415
|
`;
|
|
1407
|
-
var criteriaItemInner =
|
|
1416
|
+
var criteriaItemInner = import_react16.css`
|
|
1408
1417
|
display: flex;
|
|
1409
1418
|
row-gap: var(--spacing-base);
|
|
1410
1419
|
column-gap: var(--spacing-xs);
|
|
@@ -1412,23 +1421,23 @@ var criteriaItemInner = import_react15.css`
|
|
|
1412
1421
|
flex-wrap: wrap;
|
|
1413
1422
|
margin-right: var(--spacing-base);
|
|
1414
1423
|
`;
|
|
1415
|
-
var criteriaWrapper =
|
|
1424
|
+
var criteriaWrapper = import_react16.css`
|
|
1416
1425
|
width: 100%;
|
|
1417
1426
|
display: flex;
|
|
1418
1427
|
align-items: stretch;
|
|
1419
1428
|
position: relative;
|
|
1420
1429
|
`;
|
|
1421
|
-
var criteriaOperandWrapper =
|
|
1430
|
+
var criteriaOperandWrapper = import_react16.css`
|
|
1422
1431
|
flex: 2;
|
|
1423
1432
|
height: 52px;
|
|
1424
1433
|
min-width: 200px;
|
|
1425
1434
|
`;
|
|
1426
|
-
var criteriaOperatorWrapper =
|
|
1435
|
+
var criteriaOperatorWrapper = import_react16.css`
|
|
1427
1436
|
flex: 1;
|
|
1428
1437
|
flex-wrap: nowrap;
|
|
1429
1438
|
min-width: 80px;
|
|
1430
1439
|
`;
|
|
1431
|
-
var expand =
|
|
1440
|
+
var expand = import_react16.css`
|
|
1432
1441
|
height: 100%;
|
|
1433
1442
|
width: 100%;
|
|
1434
1443
|
`;
|
|
@@ -1446,7 +1455,8 @@ var PersonalizationCriteriaStatic = ({
|
|
|
1446
1455
|
onRemoveCriteria,
|
|
1447
1456
|
displayTitle = true,
|
|
1448
1457
|
components,
|
|
1449
|
-
errors = {}
|
|
1458
|
+
errors = {},
|
|
1459
|
+
readOnly
|
|
1450
1460
|
}) => {
|
|
1451
1461
|
var _a;
|
|
1452
1462
|
const currentValue = { crit: [], ...value };
|
|
@@ -1492,195 +1502,204 @@ var PersonalizationCriteriaStatic = ({
|
|
|
1492
1502
|
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_design_system10.Heading, { level: 5, withMarginBottom: false, children: "Personalization Variation" })
|
|
1493
1503
|
}
|
|
1494
1504
|
) : null,
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
/* @__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
|
+
] }),
|
|
1506
1652
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1507
|
-
"
|
|
1653
|
+
"button",
|
|
1508
1654
|
{
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
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
|
-
)
|
|
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" })
|
|
1545
1662
|
}
|
|
1546
1663
|
),
|
|
1547
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1664
|
+
index > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1548
1665
|
"div",
|
|
1549
1666
|
{
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1667
|
+
className: "criteria-group-operation",
|
|
1668
|
+
css: {
|
|
1669
|
+
position: "absolute",
|
|
1670
|
+
top: "-4rem",
|
|
1671
|
+
transform: "translateX(calc(1.5rem - 50%))"
|
|
1672
|
+
},
|
|
1553
1673
|
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",
|
|
1674
|
+
import_design_system10.InputInlineSelect,
|
|
1582
1675
|
{
|
|
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
|
|
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
|
+
}
|
|
1631
1686
|
}
|
|
1632
1687
|
)
|
|
1633
1688
|
}
|
|
1634
1689
|
) : null
|
|
1635
|
-
] })
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
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
|
-
)
|
|
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
|
+
] })
|
|
1684
1703
|
] });
|
|
1685
1704
|
};
|
|
1686
1705
|
|
|
@@ -1745,7 +1764,7 @@ var PersonalizationCriteria = ({
|
|
|
1745
1764
|
...staticProps
|
|
1746
1765
|
}) => {
|
|
1747
1766
|
var _a, _b;
|
|
1748
|
-
const [validationError, setValidationError] = (0,
|
|
1767
|
+
const [validationError, setValidationError] = (0, import_react18.useState)(void 0);
|
|
1749
1768
|
const { loading, result: dimensions, error } = useDimensions(contextConfig);
|
|
1750
1769
|
(0, import_react_use.useAsync)(async () => {
|
|
1751
1770
|
if (value && dimensions) {
|
|
@@ -1809,7 +1828,7 @@ function ProjectUIVersion({ children, versionMap, contextConfig }) {
|
|
|
1809
1828
|
}
|
|
1810
1829
|
|
|
1811
1830
|
// src/hooks/useValidateContextConfig.ts
|
|
1812
|
-
var
|
|
1831
|
+
var import_react19 = require("react");
|
|
1813
1832
|
|
|
1814
1833
|
// src/utils/validateContextConfig.ts
|
|
1815
1834
|
var import_api4 = require("@uniformdev/context/api");
|
|
@@ -1845,12 +1864,12 @@ var validateContextConfig = async (contextConfig) => {
|
|
|
1845
1864
|
|
|
1846
1865
|
// src/hooks/useValidateContextConfig.ts
|
|
1847
1866
|
var useValidateContextConfig = (contextConfig) => {
|
|
1848
|
-
const [state, setState] = (0,
|
|
1867
|
+
const [state, setState] = (0, import_react19.useState)({
|
|
1849
1868
|
validating: false,
|
|
1850
1869
|
error: void 0
|
|
1851
1870
|
});
|
|
1852
1871
|
const { apiKey, apiHost, projectId } = contextConfig || {};
|
|
1853
|
-
(0,
|
|
1872
|
+
(0, import_react19.useEffect)(() => {
|
|
1854
1873
|
if (!apiKey || !apiHost) {
|
|
1855
1874
|
return;
|
|
1856
1875
|
}
|