@usertour/helpers 0.0.45 → 0.0.47
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/__tests__/condition.test.cjs +2 -2
- package/dist/__tests__/condition.test.js +1 -1
- package/dist/{chunk-MU3AHQEC.js → chunk-GK5DM6EN.js} +10 -8
- package/dist/{chunk-SLM6E7HG.js → chunk-SIG4WTEF.js} +2 -2
- package/dist/conditions/condition.cjs +2 -2
- package/dist/conditions/condition.js +1 -1
- package/dist/conditions/index.cjs +2 -2
- package/dist/conditions/index.js +1 -1
- package/dist/content-helper.js +1 -1
- package/dist/content.cjs +10 -8
- package/dist/content.js +1 -1
- package/dist/index.cjs +12 -10
- package/dist/index.js +2 -2
- package/package.json +2 -2
|
@@ -521,9 +521,9 @@ var evaluateRule = async (condition, options) => {
|
|
|
521
521
|
var _a, _b;
|
|
522
522
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
523
523
|
const conditionId = condition.id;
|
|
524
|
-
if (activatedIds == null ? void 0 : activatedIds.includes(conditionId))
|
|
524
|
+
if (conditionId && (activatedIds == null ? void 0 : activatedIds.includes(conditionId)))
|
|
525
525
|
return true;
|
|
526
|
-
if (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId))
|
|
526
|
+
if (conditionId && (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId)))
|
|
527
527
|
return false;
|
|
528
528
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[condition.type];
|
|
529
529
|
if (customEvaluator) {
|
|
@@ -59,6 +59,14 @@ var buildConfig = (config) => {
|
|
|
59
59
|
hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
+
var extractUserAttributeValue = (element, userAttributes) => {
|
|
63
|
+
if (!userAttributes || !("attrCode" in element) || typeof element.attrCode !== "string") {
|
|
64
|
+
return "fallback" in element && typeof element.fallback === "string" ? element.fallback : "";
|
|
65
|
+
}
|
|
66
|
+
const attrValue = userAttributes[element.attrCode];
|
|
67
|
+
const fallback = "fallback" in element && typeof element.fallback === "string" ? element.fallback : "";
|
|
68
|
+
return attrValue != null ? attrValue : fallback;
|
|
69
|
+
};
|
|
62
70
|
var extractLinkUrl = (value, userAttributes) => {
|
|
63
71
|
let url = "";
|
|
64
72
|
try {
|
|
@@ -66,13 +74,7 @@ var extractLinkUrl = (value, userAttributes) => {
|
|
|
66
74
|
if ("children" in v && Array.isArray(v.children)) {
|
|
67
75
|
for (const vc of v.children) {
|
|
68
76
|
if ("type" in vc && vc.type === "user-attribute") {
|
|
69
|
-
|
|
70
|
-
const attrValue = userAttributes[vc.attrCode];
|
|
71
|
-
const fallback = "fallback" in vc && typeof vc.fallback === "string" ? vc.fallback : "";
|
|
72
|
-
url += attrValue != null ? attrValue : fallback;
|
|
73
|
-
} else if ("fallback" in vc && typeof vc.fallback === "string") {
|
|
74
|
-
url += vc.fallback;
|
|
75
|
-
}
|
|
77
|
+
url += String(extractUserAttributeValue(vc, userAttributes));
|
|
76
78
|
} else if ("text" in vc && typeof vc.text === "string") {
|
|
77
79
|
url += vc.text;
|
|
78
80
|
}
|
|
@@ -89,7 +91,7 @@ var replaceUserAttrForElement = (data, userAttributes) => {
|
|
|
89
91
|
v.children = replaceUserAttrForElement(v.children, userAttributes);
|
|
90
92
|
}
|
|
91
93
|
if (v.type === "user-attribute" && userAttributes) {
|
|
92
|
-
const value =
|
|
94
|
+
const value = extractUserAttributeValue(v, userAttributes);
|
|
93
95
|
if (!isUndefined(value)) {
|
|
94
96
|
v.value = String(value);
|
|
95
97
|
}
|
|
@@ -51,9 +51,9 @@ var evaluateRule = async (condition, options) => {
|
|
|
51
51
|
var _a, _b;
|
|
52
52
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
53
53
|
const conditionId = condition.id;
|
|
54
|
-
if (activatedIds == null ? void 0 : activatedIds.includes(conditionId))
|
|
54
|
+
if (conditionId && (activatedIds == null ? void 0 : activatedIds.includes(conditionId)))
|
|
55
55
|
return true;
|
|
56
|
-
if (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId))
|
|
56
|
+
if (conditionId && (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId)))
|
|
57
57
|
return false;
|
|
58
58
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[condition.type];
|
|
59
59
|
if (customEvaluator) {
|
|
@@ -539,9 +539,9 @@ var evaluateRule = async (condition, options) => {
|
|
|
539
539
|
var _a, _b;
|
|
540
540
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
541
541
|
const conditionId = condition.id;
|
|
542
|
-
if (activatedIds == null ? void 0 : activatedIds.includes(conditionId))
|
|
542
|
+
if (conditionId && (activatedIds == null ? void 0 : activatedIds.includes(conditionId)))
|
|
543
543
|
return true;
|
|
544
|
-
if (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId))
|
|
544
|
+
if (conditionId && (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId)))
|
|
545
545
|
return false;
|
|
546
546
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[condition.type];
|
|
547
547
|
if (customEvaluator) {
|
|
@@ -584,9 +584,9 @@ var evaluateRule = async (condition, options) => {
|
|
|
584
584
|
var _a, _b;
|
|
585
585
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
586
586
|
const conditionId = condition.id;
|
|
587
|
-
if (activatedIds == null ? void 0 : activatedIds.includes(conditionId))
|
|
587
|
+
if (conditionId && (activatedIds == null ? void 0 : activatedIds.includes(conditionId)))
|
|
588
588
|
return true;
|
|
589
|
-
if (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId))
|
|
589
|
+
if (conditionId && (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId)))
|
|
590
590
|
return false;
|
|
591
591
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[condition.type];
|
|
592
592
|
if (customEvaluator) {
|
package/dist/conditions/index.js
CHANGED
package/dist/content-helper.js
CHANGED
package/dist/content.cjs
CHANGED
|
@@ -90,6 +90,14 @@ var buildConfig = (config) => {
|
|
|
90
90
|
hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
+
var extractUserAttributeValue = (element, userAttributes) => {
|
|
94
|
+
if (!userAttributes || !("attrCode" in element) || typeof element.attrCode !== "string") {
|
|
95
|
+
return "fallback" in element && typeof element.fallback === "string" ? element.fallback : "";
|
|
96
|
+
}
|
|
97
|
+
const attrValue = userAttributes[element.attrCode];
|
|
98
|
+
const fallback = "fallback" in element && typeof element.fallback === "string" ? element.fallback : "";
|
|
99
|
+
return attrValue != null ? attrValue : fallback;
|
|
100
|
+
};
|
|
93
101
|
var extractLinkUrl = (value, userAttributes) => {
|
|
94
102
|
let url = "";
|
|
95
103
|
try {
|
|
@@ -97,13 +105,7 @@ var extractLinkUrl = (value, userAttributes) => {
|
|
|
97
105
|
if ("children" in v && Array.isArray(v.children)) {
|
|
98
106
|
for (const vc of v.children) {
|
|
99
107
|
if ("type" in vc && vc.type === "user-attribute") {
|
|
100
|
-
|
|
101
|
-
const attrValue = userAttributes[vc.attrCode];
|
|
102
|
-
const fallback = "fallback" in vc && typeof vc.fallback === "string" ? vc.fallback : "";
|
|
103
|
-
url += attrValue != null ? attrValue : fallback;
|
|
104
|
-
} else if ("fallback" in vc && typeof vc.fallback === "string") {
|
|
105
|
-
url += vc.fallback;
|
|
106
|
-
}
|
|
108
|
+
url += String(extractUserAttributeValue(vc, userAttributes));
|
|
107
109
|
} else if ("text" in vc && typeof vc.text === "string") {
|
|
108
110
|
url += vc.text;
|
|
109
111
|
}
|
|
@@ -120,7 +122,7 @@ var replaceUserAttrForElement = (data, userAttributes) => {
|
|
|
120
122
|
v.children = replaceUserAttrForElement(v.children, userAttributes);
|
|
121
123
|
}
|
|
122
124
|
if (v.type === "user-attribute" && userAttributes) {
|
|
123
|
-
const value =
|
|
125
|
+
const value = extractUserAttributeValue(v, userAttributes);
|
|
124
126
|
if (!isUndefined(value)) {
|
|
125
127
|
v.value = String(value);
|
|
126
128
|
}
|
package/dist/content.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1053,6 +1053,14 @@ var buildConfig = (config) => {
|
|
|
1053
1053
|
hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
|
|
1054
1054
|
};
|
|
1055
1055
|
};
|
|
1056
|
+
var extractUserAttributeValue = (element, userAttributes) => {
|
|
1057
|
+
if (!userAttributes || !("attrCode" in element) || typeof element.attrCode !== "string") {
|
|
1058
|
+
return "fallback" in element && typeof element.fallback === "string" ? element.fallback : "";
|
|
1059
|
+
}
|
|
1060
|
+
const attrValue = userAttributes[element.attrCode];
|
|
1061
|
+
const fallback = "fallback" in element && typeof element.fallback === "string" ? element.fallback : "";
|
|
1062
|
+
return attrValue != null ? attrValue : fallback;
|
|
1063
|
+
};
|
|
1056
1064
|
var extractLinkUrl = (value, userAttributes) => {
|
|
1057
1065
|
let url = "";
|
|
1058
1066
|
try {
|
|
@@ -1060,13 +1068,7 @@ var extractLinkUrl = (value, userAttributes) => {
|
|
|
1060
1068
|
if ("children" in v && Array.isArray(v.children)) {
|
|
1061
1069
|
for (const vc of v.children) {
|
|
1062
1070
|
if ("type" in vc && vc.type === "user-attribute") {
|
|
1063
|
-
|
|
1064
|
-
const attrValue = userAttributes[vc.attrCode];
|
|
1065
|
-
const fallback = "fallback" in vc && typeof vc.fallback === "string" ? vc.fallback : "";
|
|
1066
|
-
url += attrValue != null ? attrValue : fallback;
|
|
1067
|
-
} else if ("fallback" in vc && typeof vc.fallback === "string") {
|
|
1068
|
-
url += vc.fallback;
|
|
1069
|
-
}
|
|
1071
|
+
url += String(extractUserAttributeValue(vc, userAttributes));
|
|
1070
1072
|
} else if ("text" in vc && typeof vc.text === "string") {
|
|
1071
1073
|
url += vc.text;
|
|
1072
1074
|
}
|
|
@@ -1083,7 +1085,7 @@ var replaceUserAttrForElement = (data, userAttributes) => {
|
|
|
1083
1085
|
v.children = replaceUserAttrForElement(v.children, userAttributes);
|
|
1084
1086
|
}
|
|
1085
1087
|
if (v.type === "user-attribute" && userAttributes) {
|
|
1086
|
-
const value =
|
|
1088
|
+
const value = extractUserAttributeValue(v, userAttributes);
|
|
1087
1089
|
if (!isUndefined(value)) {
|
|
1088
1090
|
v.value = String(value);
|
|
1089
1091
|
}
|
|
@@ -1559,9 +1561,9 @@ var evaluateRule = async (condition, options) => {
|
|
|
1559
1561
|
var _a, _b;
|
|
1560
1562
|
const { typeControl = {}, activatedIds, deactivatedIds, customEvaluators } = options;
|
|
1561
1563
|
const conditionId = condition.id;
|
|
1562
|
-
if (activatedIds == null ? void 0 : activatedIds.includes(conditionId))
|
|
1564
|
+
if (conditionId && (activatedIds == null ? void 0 : activatedIds.includes(conditionId)))
|
|
1563
1565
|
return true;
|
|
1564
|
-
if (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId))
|
|
1566
|
+
if (conditionId && (deactivatedIds == null ? void 0 : deactivatedIds.includes(conditionId)))
|
|
1565
1567
|
return false;
|
|
1566
1568
|
const customEvaluator = customEvaluators == null ? void 0 : customEvaluators[condition.type];
|
|
1567
1569
|
if (customEvaluator) {
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
isConditionsActived,
|
|
34
34
|
isEqual,
|
|
35
35
|
regenerateConditionIds
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-SIG4WTEF.js";
|
|
37
37
|
import {
|
|
38
38
|
evaluateUrlCondition,
|
|
39
39
|
isMatchUrlPattern
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
isPublishedAtLeastOneEnvironment,
|
|
61
61
|
isPublishedInAllEnvironments,
|
|
62
62
|
replaceUserAttr
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-GK5DM6EN.js";
|
|
64
64
|
import {
|
|
65
65
|
convertSettings,
|
|
66
66
|
convertToCssVars,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usertour/helpers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Utility functions and helpers shared across the UserTour project",
|
|
6
6
|
"homepage": "https://www.usertour.io",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@paralleldrive/cuid2": "^2.2.2",
|
|
32
|
-
"@usertour/types": "^0.0.
|
|
32
|
+
"@usertour/types": "^0.0.33",
|
|
33
33
|
"chroma-js": "^3.1.2",
|
|
34
34
|
"class-variance-authority": "^0.4.0",
|
|
35
35
|
"clsx": "^1.2.1",
|