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