@usertour/helpers 0.0.1
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/README.md +68 -0
- package/dist/auth.cjs +161 -0
- package/dist/auth.d.cts +8 -0
- package/dist/auth.d.ts +8 -0
- package/dist/auth.js +15 -0
- package/dist/chunk-2AEGAICC.js +13 -0
- package/dist/chunk-3KG2HTZ3.js +79 -0
- package/dist/chunk-3ZGH3NRU.js +103 -0
- package/dist/chunk-64BFWPHJ.js +50 -0
- package/dist/chunk-BBPZYUJR.js +28 -0
- package/dist/chunk-FGFMTWFT.js +23 -0
- package/dist/chunk-FNQIIEWK.js +121 -0
- package/dist/chunk-FW54TSA3.js +41 -0
- package/dist/chunk-G5P7KULU.js +223 -0
- package/dist/chunk-GFH3VWOC.js +70 -0
- package/dist/chunk-H7VA3ML2.js +29 -0
- package/dist/chunk-USHOKNHQ.js +243 -0
- package/dist/chunk-VT24VOAZ.js +48 -0
- package/dist/chunk-XEO3YXBM.js +10 -0
- package/dist/chunk-ZNFXGN3M.js +25 -0
- package/dist/color.cjs +84 -0
- package/dist/color.d.cts +29 -0
- package/dist/color.d.ts +29 -0
- package/dist/color.js +11 -0
- package/dist/condition.cjs +157 -0
- package/dist/condition.d.cts +7 -0
- package/dist/condition.d.ts +7 -0
- package/dist/condition.js +11 -0
- package/dist/content-settings.cjs +76 -0
- package/dist/content-settings.d.cts +7 -0
- package/dist/content-settings.d.ts +7 -0
- package/dist/content-settings.js +11 -0
- package/dist/content.cjs +53 -0
- package/dist/content.d.cts +6 -0
- package/dist/content.d.ts +6 -0
- package/dist/content.js +9 -0
- package/dist/convert-settings.cjs +308 -0
- package/dist/convert-settings.d.cts +7 -0
- package/dist/convert-settings.d.ts +7 -0
- package/dist/convert-settings.js +13 -0
- package/dist/error.cjs +259 -0
- package/dist/error.d.cts +56 -0
- package/dist/error.d.ts +56 -0
- package/dist/error.js +37 -0
- package/dist/globals.cjs +64 -0
- package/dist/globals.d.cts +27 -0
- package/dist/globals.d.ts +27 -0
- package/dist/globals.js +29 -0
- package/dist/helper.cjs +111 -0
- package/dist/helper.d.cts +17 -0
- package/dist/helper.d.ts +17 -0
- package/dist/helper.js +23 -0
- package/dist/index.cjs +1165 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +178 -0
- package/dist/is-url.cjs +49 -0
- package/dist/is-url.d.cts +14 -0
- package/dist/is-url.d.ts +14 -0
- package/dist/is-url.js +7 -0
- package/dist/settings.cjs +65 -0
- package/dist/settings.d.cts +5 -0
- package/dist/settings.d.ts +5 -0
- package/dist/settings.js +7 -0
- package/dist/storage.cjs +142 -0
- package/dist/storage.d.cts +25 -0
- package/dist/storage.d.ts +25 -0
- package/dist/storage.js +8 -0
- package/dist/type-utils.cjs +109 -0
- package/dist/type-utils.d.cts +18 -0
- package/dist/type-utils.d.ts +18 -0
- package/dist/type-utils.js +37 -0
- package/dist/utils.cjs +37 -0
- package/dist/utils.d.cts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +7 -0
- package/dist/vite-env.d.cjs +1 -0
- package/dist/vite-env.d.d.cts +1 -0
- package/dist/vite-env.d.d.ts +1 -0
- package/dist/vite-env.d.js +0 -0
- package/package.json +56 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/settings.ts
|
|
2
|
+
var defaultStep = {
|
|
3
|
+
name: "step",
|
|
4
|
+
type: "tooltip",
|
|
5
|
+
sequence: 0,
|
|
6
|
+
setting: {
|
|
7
|
+
height: 0,
|
|
8
|
+
width: 250,
|
|
9
|
+
skippable: true,
|
|
10
|
+
enabledBackdrop: false,
|
|
11
|
+
enabledBlockTarget: false,
|
|
12
|
+
explicitCompletionStep: false,
|
|
13
|
+
align: "center",
|
|
14
|
+
side: "bottom",
|
|
15
|
+
sideOffset: 0,
|
|
16
|
+
alignOffset: 0,
|
|
17
|
+
alignType: "auto",
|
|
18
|
+
position: "center",
|
|
19
|
+
positionOffsetX: 0,
|
|
20
|
+
positionOffsetY: 0
|
|
21
|
+
},
|
|
22
|
+
data: [
|
|
23
|
+
{
|
|
24
|
+
type: "paragraph",
|
|
25
|
+
children: [{ text: "" }]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
target: {
|
|
29
|
+
selectors: null,
|
|
30
|
+
content: "",
|
|
31
|
+
sequence: "1st",
|
|
32
|
+
precision: "stricter",
|
|
33
|
+
isDynamicContent: false,
|
|
34
|
+
customSelector: "",
|
|
35
|
+
type: "auto"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
defaultStep
|
|
41
|
+
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// src/error.ts
|
|
2
|
+
import {
|
|
3
|
+
AttributeDataType,
|
|
4
|
+
ContentActionsItemType
|
|
5
|
+
} from "@usertour/types";
|
|
6
|
+
var isValidSelector = (selector) => {
|
|
7
|
+
if (!selector) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (selector.type === "auto" && !selector.selectors) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (selector.type === "manual" && !selector.customSelector) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
};
|
|
18
|
+
var getUserAttrError = (data, attributes) => {
|
|
19
|
+
const ret = { showError: false, errorInfo: "" };
|
|
20
|
+
const item = attributes.find((item2) => item2.id === (data == null ? void 0 : data.attrId));
|
|
21
|
+
if (!(data == null ? void 0 : data.attrId) || !item) {
|
|
22
|
+
ret.showError = true;
|
|
23
|
+
ret.errorInfo = "Please select a attribute";
|
|
24
|
+
} else if ((data == null ? void 0 : data.logic) === "between" && (!(data == null ? void 0 : data.value) || !(data == null ? void 0 : data.value2))) {
|
|
25
|
+
ret.showError = true;
|
|
26
|
+
ret.errorInfo = "Please enter a value";
|
|
27
|
+
} else if ((item == null ? void 0 : item.dataType) !== AttributeDataType.Boolean) {
|
|
28
|
+
if (data.logic !== "any" && data.logic !== "empty") {
|
|
29
|
+
if ((item == null ? void 0 : item.dataType) === AttributeDataType.List) {
|
|
30
|
+
if (!data.listValues || data.listValues.length === 0) {
|
|
31
|
+
ret.showError = true;
|
|
32
|
+
ret.errorInfo = "Please enter a value";
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
if (!data.value || data.value === "") {
|
|
36
|
+
ret.showError = true;
|
|
37
|
+
ret.errorInfo = "Please enter a value";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return ret;
|
|
43
|
+
};
|
|
44
|
+
var getUrlPatternError = (data) => {
|
|
45
|
+
const ret = { showError: false, errorInfo: "" };
|
|
46
|
+
const hasExcludes = data.excludes && data.excludes.length > 0;
|
|
47
|
+
const hasIncludes = data.includes && data.includes.length > 0;
|
|
48
|
+
if (!hasExcludes && !hasIncludes) {
|
|
49
|
+
ret.showError = true;
|
|
50
|
+
ret.errorInfo = "Enter at least one URL pattern";
|
|
51
|
+
}
|
|
52
|
+
return ret;
|
|
53
|
+
};
|
|
54
|
+
var getCurrentTimeError = (data) => {
|
|
55
|
+
const ret = { showError: false, errorInfo: "" };
|
|
56
|
+
if (!data.startDate && !data.endDate) {
|
|
57
|
+
ret.showError = true;
|
|
58
|
+
ret.errorInfo = "Either start or end time be filled in";
|
|
59
|
+
}
|
|
60
|
+
return ret;
|
|
61
|
+
};
|
|
62
|
+
var getWaitError = (data) => {
|
|
63
|
+
const ret = { showError: false, errorInfo: "" };
|
|
64
|
+
if (data.second === void 0) {
|
|
65
|
+
ret.showError = true;
|
|
66
|
+
ret.errorInfo = "Enter wait time";
|
|
67
|
+
}
|
|
68
|
+
return ret;
|
|
69
|
+
};
|
|
70
|
+
var getElementError = (data) => {
|
|
71
|
+
const ret = { showError: false, errorInfo: "" };
|
|
72
|
+
if (!isValidSelector(data.elementData)) {
|
|
73
|
+
ret.showError = true;
|
|
74
|
+
ret.errorInfo = "Please select an element";
|
|
75
|
+
}
|
|
76
|
+
return ret;
|
|
77
|
+
};
|
|
78
|
+
var getTextInputError = (data) => {
|
|
79
|
+
const ret = { showError: false, errorInfo: "" };
|
|
80
|
+
if (data.logic !== "any" && data.logic !== "empty" && data.value === "") {
|
|
81
|
+
ret.showError = true;
|
|
82
|
+
ret.errorInfo = "Please enter a value";
|
|
83
|
+
} else if (!isValidSelector(data.elementData)) {
|
|
84
|
+
ret.showError = true;
|
|
85
|
+
ret.errorInfo = "Please select an element";
|
|
86
|
+
}
|
|
87
|
+
return ret;
|
|
88
|
+
};
|
|
89
|
+
var getTextFillError = (data) => {
|
|
90
|
+
const ret = { showError: false, errorInfo: "" };
|
|
91
|
+
if (!isValidSelector(data.elementData)) {
|
|
92
|
+
ret.showError = true;
|
|
93
|
+
ret.errorInfo = "Please select an element";
|
|
94
|
+
}
|
|
95
|
+
return ret;
|
|
96
|
+
};
|
|
97
|
+
var getSegmentError = (data) => {
|
|
98
|
+
const ret = { showError: false, errorInfo: "" };
|
|
99
|
+
if (!data.segmentId) {
|
|
100
|
+
ret.showError = true;
|
|
101
|
+
ret.errorInfo = "Please select an segment";
|
|
102
|
+
}
|
|
103
|
+
return ret;
|
|
104
|
+
};
|
|
105
|
+
var getContentError = (data) => {
|
|
106
|
+
const ret = { showError: false, errorInfo: "" };
|
|
107
|
+
if (!data.contentId) {
|
|
108
|
+
ret.showError = true;
|
|
109
|
+
ret.errorInfo = "Please select a flow";
|
|
110
|
+
}
|
|
111
|
+
return ret;
|
|
112
|
+
};
|
|
113
|
+
var getStepError = (data) => {
|
|
114
|
+
const ret = { showError: false, errorInfo: "" };
|
|
115
|
+
if (!data.stepCvid) {
|
|
116
|
+
ret.showError = true;
|
|
117
|
+
ret.errorInfo = "Please select a step";
|
|
118
|
+
}
|
|
119
|
+
return ret;
|
|
120
|
+
};
|
|
121
|
+
var getNavitateError = (data) => {
|
|
122
|
+
const ret = { showError: false, errorInfo: "" };
|
|
123
|
+
if (!data.value || data.value === "") {
|
|
124
|
+
ret.showError = true;
|
|
125
|
+
ret.errorInfo = "Enter the navigator url";
|
|
126
|
+
}
|
|
127
|
+
return ret;
|
|
128
|
+
};
|
|
129
|
+
var getCodeError = (data) => {
|
|
130
|
+
const ret = { showError: false, errorInfo: "" };
|
|
131
|
+
if (!data.value) {
|
|
132
|
+
ret.showError = true;
|
|
133
|
+
ret.errorInfo = "Enter the code ";
|
|
134
|
+
}
|
|
135
|
+
return ret;
|
|
136
|
+
};
|
|
137
|
+
var errorHandlerMapping = {
|
|
138
|
+
"current-page": getUrlPatternError,
|
|
139
|
+
"user-attr": getUserAttrError,
|
|
140
|
+
time: getCurrentTimeError,
|
|
141
|
+
wait: getWaitError,
|
|
142
|
+
element: getElementError,
|
|
143
|
+
"text-input": getTextInputError,
|
|
144
|
+
"text-fill": getTextFillError,
|
|
145
|
+
segment: getSegmentError,
|
|
146
|
+
content: getContentError
|
|
147
|
+
};
|
|
148
|
+
var hasError = (conds, attributes) => {
|
|
149
|
+
for (const cond of conds) {
|
|
150
|
+
const condType = cond.type;
|
|
151
|
+
const condErroFn = errorHandlerMapping[condType];
|
|
152
|
+
if (condErroFn) {
|
|
153
|
+
const { showError } = condErroFn(cond.data, attributes);
|
|
154
|
+
if (showError) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (cond.conditions) {
|
|
159
|
+
if (hasError(cond.conditions, attributes) === true) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
};
|
|
166
|
+
var errorActionHandlerMapping = {
|
|
167
|
+
[ContentActionsItemType.STEP_GOTO]: getStepError,
|
|
168
|
+
[ContentActionsItemType.PAGE_NAVIGATE]: getNavitateError,
|
|
169
|
+
[ContentActionsItemType.FLOW_START]: getContentError,
|
|
170
|
+
[ContentActionsItemType.JAVASCRIPT_EVALUATE]: getCodeError
|
|
171
|
+
};
|
|
172
|
+
var hasActionError = (conds) => {
|
|
173
|
+
for (const cond of conds) {
|
|
174
|
+
const condType = cond.type;
|
|
175
|
+
const condErroFn = errorActionHandlerMapping[condType];
|
|
176
|
+
if (condErroFn) {
|
|
177
|
+
const { showError } = condErroFn(cond.data);
|
|
178
|
+
if (showError) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (cond.conditions) {
|
|
183
|
+
if (hasActionError(cond.conditions) === true) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
};
|
|
190
|
+
function isErrorWithMessage(error) {
|
|
191
|
+
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
192
|
+
}
|
|
193
|
+
function toErrorWithMessage(maybeError) {
|
|
194
|
+
if (isErrorWithMessage(maybeError))
|
|
195
|
+
return maybeError;
|
|
196
|
+
try {
|
|
197
|
+
return new Error(JSON.stringify(maybeError));
|
|
198
|
+
} catch {
|
|
199
|
+
return new Error(String(maybeError));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function getErrorMessage(error) {
|
|
203
|
+
return toErrorWithMessage(error).message;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
isValidSelector,
|
|
208
|
+
getUserAttrError,
|
|
209
|
+
getUrlPatternError,
|
|
210
|
+
getCurrentTimeError,
|
|
211
|
+
getWaitError,
|
|
212
|
+
getElementError,
|
|
213
|
+
getTextInputError,
|
|
214
|
+
getTextFillError,
|
|
215
|
+
getSegmentError,
|
|
216
|
+
getContentError,
|
|
217
|
+
getStepError,
|
|
218
|
+
getNavitateError,
|
|
219
|
+
getCodeError,
|
|
220
|
+
hasError,
|
|
221
|
+
hasActionError,
|
|
222
|
+
getErrorMessage
|
|
223
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/type-utils.ts
|
|
2
|
+
var nativeIsArray = Array.isArray;
|
|
3
|
+
var ObjProto = Object.prototype;
|
|
4
|
+
var objToString = ObjProto.toString;
|
|
5
|
+
var objHasOwn = ObjProto.hasOwnProperty;
|
|
6
|
+
var isArray = nativeIsArray || ((obj) => objToString.call(obj) === "[object Array]");
|
|
7
|
+
var isUint8Array = (x) => objToString.call(x) === "[object Uint8Array]";
|
|
8
|
+
var isFunction = (f) => {
|
|
9
|
+
return typeof f === "function";
|
|
10
|
+
};
|
|
11
|
+
var isObject = (x) => {
|
|
12
|
+
return x === Object(x) && !isArray(x);
|
|
13
|
+
};
|
|
14
|
+
var isEmptyObject = (x) => {
|
|
15
|
+
if (isObject(x)) {
|
|
16
|
+
for (const key in x) {
|
|
17
|
+
if (objHasOwn.call(x, key)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
var isUndefined = (x) => x === void 0;
|
|
26
|
+
var isString = (x) => {
|
|
27
|
+
return objToString.call(x) === "[object String]";
|
|
28
|
+
};
|
|
29
|
+
var isEmptyString = (x) => isString(x) && x.trim().length === 0;
|
|
30
|
+
var isNull = (x) => {
|
|
31
|
+
return x === null;
|
|
32
|
+
};
|
|
33
|
+
var isNullish = (x) => isUndefined(x) || isNull(x);
|
|
34
|
+
var isDate = (x) => {
|
|
35
|
+
return objToString.call(x) === "[object Date]";
|
|
36
|
+
};
|
|
37
|
+
var isNumber = (x) => {
|
|
38
|
+
return objToString.call(x) === "[object Number]";
|
|
39
|
+
};
|
|
40
|
+
var isBoolean = (x) => {
|
|
41
|
+
return objToString.call(x) === "[object Boolean]";
|
|
42
|
+
};
|
|
43
|
+
var isDocument = (x) => {
|
|
44
|
+
return x instanceof Document;
|
|
45
|
+
};
|
|
46
|
+
var isFormData = (x) => {
|
|
47
|
+
return x instanceof FormData;
|
|
48
|
+
};
|
|
49
|
+
var isFile = (x) => {
|
|
50
|
+
return x instanceof File;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
isArray,
|
|
55
|
+
isUint8Array,
|
|
56
|
+
isFunction,
|
|
57
|
+
isObject,
|
|
58
|
+
isEmptyObject,
|
|
59
|
+
isUndefined,
|
|
60
|
+
isString,
|
|
61
|
+
isEmptyString,
|
|
62
|
+
isNull,
|
|
63
|
+
isNullish,
|
|
64
|
+
isDate,
|
|
65
|
+
isNumber,
|
|
66
|
+
isBoolean,
|
|
67
|
+
isDocument,
|
|
68
|
+
isFormData,
|
|
69
|
+
isFile
|
|
70
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/globals.ts
|
|
2
|
+
var win = typeof window !== "undefined" ? window : void 0;
|
|
3
|
+
var global = typeof globalThis !== "undefined" ? globalThis : win;
|
|
4
|
+
var ArrayProto = Array.prototype;
|
|
5
|
+
var nativeForEach = ArrayProto.forEach;
|
|
6
|
+
var nativeIndexOf = ArrayProto.indexOf;
|
|
7
|
+
var navigator = global == null ? void 0 : global.navigator;
|
|
8
|
+
var document = global == null ? void 0 : global.document;
|
|
9
|
+
var location = global == null ? void 0 : global.location;
|
|
10
|
+
var fetch = global == null ? void 0 : global.fetch;
|
|
11
|
+
var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
|
|
12
|
+
var AbortController = global == null ? void 0 : global.AbortController;
|
|
13
|
+
var userAgent = navigator == null ? void 0 : navigator.userAgent;
|
|
14
|
+
var assignableWindow = win != null ? win : {};
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
win,
|
|
18
|
+
ArrayProto,
|
|
19
|
+
nativeForEach,
|
|
20
|
+
nativeIndexOf,
|
|
21
|
+
navigator,
|
|
22
|
+
document,
|
|
23
|
+
location,
|
|
24
|
+
fetch,
|
|
25
|
+
XMLHttpRequest,
|
|
26
|
+
AbortController,
|
|
27
|
+
userAgent,
|
|
28
|
+
assignableWindow
|
|
29
|
+
};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isUndefined
|
|
3
|
+
} from "./chunk-GFH3VWOC.js";
|
|
4
|
+
import {
|
|
5
|
+
hexToHSLString,
|
|
6
|
+
hexToRGBStr
|
|
7
|
+
} from "./chunk-VT24VOAZ.js";
|
|
8
|
+
|
|
9
|
+
// src/convert-settings.ts
|
|
10
|
+
import { defaultSettings } from "@usertour/types";
|
|
11
|
+
import { deepmerge } from "deepmerge-ts";
|
|
12
|
+
var defaultFontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';
|
|
13
|
+
var mergeThemeDefaultSettings = (settings) => {
|
|
14
|
+
return deepmerge(defaultSettings, settings);
|
|
15
|
+
};
|
|
16
|
+
var convertSettings = (settings) => {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
18
|
+
const data = mergeThemeDefaultSettings(settings);
|
|
19
|
+
if (settings.mainColor.hover === "Auto") {
|
|
20
|
+
data.mainColor.hover = settings.mainColor.autoHover;
|
|
21
|
+
}
|
|
22
|
+
if (settings.mainColor.active === "Auto") {
|
|
23
|
+
data.mainColor.active = settings.mainColor.autoActive;
|
|
24
|
+
}
|
|
25
|
+
if (settings.brandColor.hover === "Auto") {
|
|
26
|
+
data.brandColor.hover = settings.brandColor.autoHover;
|
|
27
|
+
}
|
|
28
|
+
if (settings.brandColor.active === "Auto") {
|
|
29
|
+
data.brandColor.active = settings.brandColor.autoActive;
|
|
30
|
+
}
|
|
31
|
+
if (settings.border.borderColor === "Auto") {
|
|
32
|
+
data.border.borderColor = settings.mainColor.color;
|
|
33
|
+
}
|
|
34
|
+
if (settings.buttons.primary.textColor.color === "Auto") {
|
|
35
|
+
data.buttons.primary.textColor.color = settings.brandColor.color;
|
|
36
|
+
}
|
|
37
|
+
if (settings.buttons.primary.textColor.hover === "Auto") {
|
|
38
|
+
data.buttons.primary.textColor.hover = settings.brandColor.color;
|
|
39
|
+
}
|
|
40
|
+
if (settings.buttons.primary.textColor.active === "Auto") {
|
|
41
|
+
data.buttons.primary.textColor.active = settings.brandColor.color;
|
|
42
|
+
}
|
|
43
|
+
if (settings.buttons.primary.backgroundColor.background === "Auto") {
|
|
44
|
+
data.buttons.primary.backgroundColor.background = settings.brandColor.background;
|
|
45
|
+
}
|
|
46
|
+
if (settings.buttons.primary.backgroundColor.hover === "Auto") {
|
|
47
|
+
data.buttons.primary.backgroundColor.hover = settings.brandColor.autoHover;
|
|
48
|
+
}
|
|
49
|
+
if (settings.buttons.primary.backgroundColor.active === "Auto") {
|
|
50
|
+
data.buttons.primary.backgroundColor.active = settings.brandColor.autoActive;
|
|
51
|
+
}
|
|
52
|
+
if (settings.buttons.primary.border.color.color === "Auto") {
|
|
53
|
+
data.buttons.primary.border.color.color = settings.brandColor.background;
|
|
54
|
+
}
|
|
55
|
+
if (settings.buttons.primary.border.color.hover === "Auto") {
|
|
56
|
+
data.buttons.primary.border.color.hover = settings.brandColor.autoHover;
|
|
57
|
+
}
|
|
58
|
+
if (settings.buttons.primary.border.color.active === "Auto") {
|
|
59
|
+
data.buttons.primary.border.color.active = settings.brandColor.autoActive;
|
|
60
|
+
}
|
|
61
|
+
if (settings.buttons.secondary.textColor.color === "Auto") {
|
|
62
|
+
data.buttons.secondary.textColor.color = settings.brandColor.background;
|
|
63
|
+
}
|
|
64
|
+
if (settings.buttons.secondary.textColor.hover === "Auto") {
|
|
65
|
+
data.buttons.secondary.textColor.hover = settings.brandColor.background;
|
|
66
|
+
}
|
|
67
|
+
if (settings.buttons.secondary.textColor.active === "Auto") {
|
|
68
|
+
data.buttons.secondary.textColor.active = settings.brandColor.background;
|
|
69
|
+
}
|
|
70
|
+
if (settings.buttons.secondary.backgroundColor.background === "Auto") {
|
|
71
|
+
data.buttons.secondary.backgroundColor.background = settings.mainColor.background;
|
|
72
|
+
}
|
|
73
|
+
if (settings.buttons.secondary.backgroundColor.hover === "Auto") {
|
|
74
|
+
data.buttons.secondary.backgroundColor.hover = settings.mainColor.autoHover;
|
|
75
|
+
}
|
|
76
|
+
if (settings.buttons.secondary.backgroundColor.active === "Auto") {
|
|
77
|
+
data.buttons.secondary.backgroundColor.active = settings.mainColor.autoActive;
|
|
78
|
+
}
|
|
79
|
+
if (settings.buttons.secondary.border.color.color === "Auto") {
|
|
80
|
+
data.buttons.secondary.border.color.color = settings.brandColor.background;
|
|
81
|
+
}
|
|
82
|
+
if (settings.buttons.secondary.border.color.hover === "Auto") {
|
|
83
|
+
data.buttons.secondary.border.color.hover = settings.brandColor.background;
|
|
84
|
+
}
|
|
85
|
+
if (settings.buttons.secondary.border.color.active === "Auto") {
|
|
86
|
+
data.buttons.secondary.border.color.active = settings.brandColor.background;
|
|
87
|
+
}
|
|
88
|
+
if (settings.font.linkColor === "Auto") {
|
|
89
|
+
data.font.linkColor = settings.brandColor.background;
|
|
90
|
+
}
|
|
91
|
+
if (settings.xbutton.color === "Auto") {
|
|
92
|
+
data.xbutton.color = settings.brandColor.background;
|
|
93
|
+
}
|
|
94
|
+
if (((_a = settings == null ? void 0 : settings.progress) == null ? void 0 : _a.color) === "Auto") {
|
|
95
|
+
data.progress.color = settings.brandColor.background;
|
|
96
|
+
}
|
|
97
|
+
if (((_b = settings == null ? void 0 : settings.launcherBeacon) == null ? void 0 : _b.color) === "Auto") {
|
|
98
|
+
data.launcherBeacon.color = settings.brandColor.background;
|
|
99
|
+
}
|
|
100
|
+
if (((_d = (_c = settings == null ? void 0 : settings.launcherIcon) == null ? void 0 : _c.color) == null ? void 0 : _d.color) === "Auto") {
|
|
101
|
+
data.launcherIcon.color.color = settings.brandColor.background;
|
|
102
|
+
}
|
|
103
|
+
if (((_f = (_e = settings == null ? void 0 : settings.launcherIcon) == null ? void 0 : _e.color) == null ? void 0 : _f.hover) === "Auto") {
|
|
104
|
+
data.launcherIcon.color.hover = settings.brandColor.autoHover;
|
|
105
|
+
}
|
|
106
|
+
if (((_h = (_g = settings == null ? void 0 : settings.launcherIcon) == null ? void 0 : _g.color) == null ? void 0 : _h.active) === "Auto") {
|
|
107
|
+
data.launcherIcon.color.active = settings.brandColor.autoActive;
|
|
108
|
+
}
|
|
109
|
+
if (((_j = (_i = settings.checklistLauncher) == null ? void 0 : _i.color) == null ? void 0 : _j.color) === "Auto") {
|
|
110
|
+
data.checklistLauncher.color.color = settings.brandColor.color;
|
|
111
|
+
}
|
|
112
|
+
if (((_l = (_k = settings.checklistLauncher) == null ? void 0 : _k.color) == null ? void 0 : _l.background) === "Auto") {
|
|
113
|
+
data.checklistLauncher.color.background = settings.brandColor.background;
|
|
114
|
+
}
|
|
115
|
+
if (((_n = (_m = settings.checklistLauncher) == null ? void 0 : _m.color) == null ? void 0 : _n.hover) === "Auto") {
|
|
116
|
+
data.checklistLauncher.color.hover = settings.brandColor.autoHover;
|
|
117
|
+
}
|
|
118
|
+
if (((_p = (_o = settings.checklistLauncher) == null ? void 0 : _o.color) == null ? void 0 : _p.active) === "Auto") {
|
|
119
|
+
data.checklistLauncher.color.active = settings.brandColor.autoActive;
|
|
120
|
+
}
|
|
121
|
+
if (((_r = (_q = settings.checklistLauncher) == null ? void 0 : _q.counter) == null ? void 0 : _r.color) === "Auto") {
|
|
122
|
+
data.checklistLauncher.counter.color = settings.brandColor.background;
|
|
123
|
+
}
|
|
124
|
+
if (((_t = (_s = settings.checklistLauncher) == null ? void 0 : _s.counter) == null ? void 0 : _t.background) === "Auto") {
|
|
125
|
+
data.checklistLauncher.counter.background = settings.brandColor.color;
|
|
126
|
+
}
|
|
127
|
+
if (((_u = settings.survey) == null ? void 0 : _u.color) === "Auto") {
|
|
128
|
+
data.survey.color = settings.brandColor.background;
|
|
129
|
+
}
|
|
130
|
+
if (settings.font.fontFamily === "System font") {
|
|
131
|
+
data.font.fontFamily = defaultFontFamily;
|
|
132
|
+
} else {
|
|
133
|
+
data.font.fontFamily += ", sans-serif;";
|
|
134
|
+
}
|
|
135
|
+
return data;
|
|
136
|
+
};
|
|
137
|
+
var convertToCssVars = (settings, type = "tooltip") => {
|
|
138
|
+
const cssMapping = {
|
|
139
|
+
"--usertour-background": hexToHSLString(settings.mainColor.background),
|
|
140
|
+
"--usertour-foreground": hexToHSLString(settings.mainColor.color),
|
|
141
|
+
"--usertour-brand-active-background-color": hexToHSLString(
|
|
142
|
+
settings.brandColor.autoActive
|
|
143
|
+
),
|
|
144
|
+
"--usertour-brand-hover-background-color": hexToHSLString(
|
|
145
|
+
settings.brandColor.autoHover
|
|
146
|
+
),
|
|
147
|
+
"--usertour-font-family": settings.font.fontFamily,
|
|
148
|
+
"--usertour-font-size": `${settings.font.fontSize}px`,
|
|
149
|
+
"--usertour-main-background-color": settings.mainColor.background,
|
|
150
|
+
"--usertour-main-foreground-color": settings.mainColor.color,
|
|
151
|
+
"--usertour-main-hover-background-color": hexToHSLString(
|
|
152
|
+
settings.mainColor.autoHover
|
|
153
|
+
),
|
|
154
|
+
"--usertour-main-active-background-color": hexToHSLString(
|
|
155
|
+
settings.mainColor.autoActive
|
|
156
|
+
),
|
|
157
|
+
"--usertour-line-height": `${settings.font.lineHeight}px`,
|
|
158
|
+
"--usertour-widget-popper-border-radius": `${settings.border.borderRadius}px`,
|
|
159
|
+
"--usertour-font-weight-normal": settings.font.fontWeightNormal,
|
|
160
|
+
"--usertour-font-weight-bold": settings.font.fontWeightBold,
|
|
161
|
+
"--usertour-h1-font-size": `${settings.font.h1FontSize}px`,
|
|
162
|
+
"--usertour-h2-font-size": `${settings.font.h2FontSize}px`,
|
|
163
|
+
"--usertour-link-color": hexToHSLString(settings.font.linkColor),
|
|
164
|
+
"--usertour-widget-popper-border-width": settings.border.borderWidthEnabled ? `${settings.border.borderWidth}px` : "0px",
|
|
165
|
+
"--usertour-widget-popper-border-color": settings.border.borderColor,
|
|
166
|
+
"--usertour-button-border-radius": `${settings.buttons.borderRadius}px`,
|
|
167
|
+
"--usertour-button-height": `${settings.buttons.height}px`,
|
|
168
|
+
"--usertour-button-min-width": `${settings.buttons.minWidth}px`,
|
|
169
|
+
"--usertour-button-px": `${settings.buttons.px}px`,
|
|
170
|
+
"--usertour-primary": settings.buttons.primary.backgroundColor.background,
|
|
171
|
+
"--usertour-primary-hover": settings.buttons.primary.backgroundColor.hover,
|
|
172
|
+
"--usertour-primary-active": settings.buttons.primary.backgroundColor.active,
|
|
173
|
+
"--usertour-primary-foreground": settings.buttons.primary.textColor.color,
|
|
174
|
+
"--usertour-primary-foreground-hover": settings.buttons.primary.textColor.hover,
|
|
175
|
+
"--usertour-primary-foreground-active": settings.buttons.primary.textColor.active,
|
|
176
|
+
"--usertour-primary-border-width": settings.buttons.primary.border.enabled ? `${settings.buttons.primary.border.borderWidth}px` : "0px",
|
|
177
|
+
"--usertour-primary-border-color": settings.buttons.primary.border.color.color,
|
|
178
|
+
"--usertour-primary-border-hover": settings.buttons.primary.border.color.hover,
|
|
179
|
+
"--usertour-primary-border-active": settings.buttons.primary.border.color.active,
|
|
180
|
+
"--usertour-primary-font-weight": settings.buttons.primary.fontWeight,
|
|
181
|
+
"--usertour-secondary": settings.buttons.secondary.backgroundColor.background,
|
|
182
|
+
"--usertour-secondary-hover": settings.buttons.secondary.backgroundColor.hover,
|
|
183
|
+
"--usertour-secondary-active": settings.buttons.secondary.backgroundColor.active,
|
|
184
|
+
"--usertour-secondary-foreground": settings.buttons.secondary.textColor.color,
|
|
185
|
+
"--usertour-secondary-foreground-hover": settings.buttons.secondary.textColor.hover,
|
|
186
|
+
"--usertour-secondary-foreground-active": settings.buttons.secondary.textColor.active,
|
|
187
|
+
"--usertour-secondary-border-width": settings.buttons.secondary.border.enabled ? `${settings.buttons.secondary.border.borderWidth}px` : "0px",
|
|
188
|
+
"--usertour-secondary-border-color": settings.buttons.secondary.border.color.color,
|
|
189
|
+
"--usertour-secondary-border-hover": settings.buttons.secondary.border.color.hover,
|
|
190
|
+
"--usertour-secondary-border-active": settings.buttons.secondary.border.color.active,
|
|
191
|
+
"--usertour-secondary-font-weight": settings.buttons.secondary.fontWeight,
|
|
192
|
+
"--usertour-backdrop-color-rgb": hexToRGBStr(settings.backdrop.color),
|
|
193
|
+
"--usertour-backdrop-highlight-inset": settings.backdrop.highlight.type === "inside" ? "inset" : null,
|
|
194
|
+
"--usertour-backdrop-highlight-color-rgb": hexToRGBStr(settings.backdrop.highlight.color),
|
|
195
|
+
"--usertour-backdrop-highlight-opacity": settings.backdrop.highlight.opacity / 100,
|
|
196
|
+
"--usertour-backdrop-highlight-radius": `${settings.backdrop.highlight.radius}px`,
|
|
197
|
+
"--usertour-backdrop-highlight-spread": `${settings.backdrop.highlight.spread}px`,
|
|
198
|
+
"--usertour-backdrop-opacity": settings.backdrop.opacity / 100,
|
|
199
|
+
"--usertour-progress-bar-color": settings.progress.color,
|
|
200
|
+
"--usertour-progress-bar-height": `${settings.progress.height}px`,
|
|
201
|
+
"--usertour-narrow-progress-bar-height": `${settings.progress.narrowHeight}px`,
|
|
202
|
+
"--usertour-squared-progress-bar-height": `${settings.progress.chainSquaredHeight}px`,
|
|
203
|
+
"--usertour-rounded-progress-bar-height": `${settings.progress.chainRoundedHeight}px`,
|
|
204
|
+
"--usertour-dotted-progress-bar-height": `${settings.progress.dotsHeight}px`,
|
|
205
|
+
"--usertour-numbered-progress-bar-height": `${settings.progress.numberedHeight}px`,
|
|
206
|
+
"--usertour-widget-popper-padding": type === "modal" ? `${settings.modal.padding}px` : void 0,
|
|
207
|
+
"--usertour-xbutton": settings.xbutton.color,
|
|
208
|
+
"--usertour-widget-launcher-icon-color": settings.launcherIcon.color.color,
|
|
209
|
+
"--usertour-widget-launcher-icon-hover-color": settings.launcherIcon.color.hover,
|
|
210
|
+
"--usertour-widget-launcher-icon-active-color": settings.launcherIcon.color.active,
|
|
211
|
+
"--usertour-widget-launcher-icon-size": `${settings.launcherIcon.size}px`,
|
|
212
|
+
"--usertour-widget-beacon-color": settings.launcherBeacon.color,
|
|
213
|
+
"--usertour-widget-launcher-icon-opacity": settings.launcherIcon.opacity / 100,
|
|
214
|
+
"--usertour-widget-popper-padding-top": "2px",
|
|
215
|
+
"--usertour-widget-popper-padding-bottom": "2px",
|
|
216
|
+
"--usertour-checklist-trigger-active-background-color": settings.checklistLauncher.color.active,
|
|
217
|
+
"--usertour-checklist-trigger-background-color": settings.checklistLauncher.color.background,
|
|
218
|
+
"--usertour-checklist-trigger-border-radius": `${settings.checklistLauncher.borderRadius}px`,
|
|
219
|
+
"--usertour-checklist-trigger-counter-background-color": settings.checklistLauncher.counter.background,
|
|
220
|
+
"--usertour-checklist-trigger-counter-font-color": settings.checklistLauncher.counter.color,
|
|
221
|
+
"--usertour-checklist-trigger-font-color-rgb": settings.checklistLauncher.color.color,
|
|
222
|
+
"--usertour-checklist-trigger-font-color": settings.checklistLauncher.color.color,
|
|
223
|
+
"--usertour-checklist-trigger-font-weight": settings.checklistLauncher.fontWeight,
|
|
224
|
+
"--usertour-checkmark-background-color": settings.checklist.checkmarkColor,
|
|
225
|
+
"--usertour-checklist-trigger-height": `${settings.checklistLauncher.height}px`,
|
|
226
|
+
"--usertour-checklist-trigger-hover-background-color": settings.checklistLauncher.color.hover,
|
|
227
|
+
"--usertour-question-color": hexToHSLString(settings.survey.color)
|
|
228
|
+
};
|
|
229
|
+
let css = "";
|
|
230
|
+
for (const key in cssMapping) {
|
|
231
|
+
const value = cssMapping[key];
|
|
232
|
+
if (!isUndefined(value)) {
|
|
233
|
+
css += `${key}:${value};`;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return css;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export {
|
|
240
|
+
mergeThemeDefaultSettings,
|
|
241
|
+
convertSettings,
|
|
242
|
+
convertToCssVars
|
|
243
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/color.ts
|
|
2
|
+
import chroma from "chroma-js";
|
|
3
|
+
function hexToHSLString(hexColor) {
|
|
4
|
+
try {
|
|
5
|
+
const color = chroma(hexColor);
|
|
6
|
+
const [h, s, l] = color.hsl();
|
|
7
|
+
const hDeg = Math.round(h || 0);
|
|
8
|
+
const sPct = Math.round(s * 100);
|
|
9
|
+
const lPct = Math.round(l * 100);
|
|
10
|
+
return `${hDeg} ${sPct}% ${lPct}%`;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.warn(`Failed to convert ${hexColor} to HSL string:`, error);
|
|
13
|
+
return "0 0% 0%";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
var hexToRGBStr = (hex) => {
|
|
17
|
+
try {
|
|
18
|
+
const color = chroma(hex);
|
|
19
|
+
const [r, g, b] = color.rgb();
|
|
20
|
+
return `${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}`;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.warn(`Failed to convert ${hex} to RGB string:`, error);
|
|
23
|
+
return "0, 0, 0";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function generateAutoStateColors(baseColor, brandColor, hoverRatio = 0.12, activeRatio = 0.24) {
|
|
27
|
+
const isBaseLight = chroma(baseColor).luminance() > 0.8;
|
|
28
|
+
const isBaseBrand = chroma.distance(baseColor, brandColor) < 10;
|
|
29
|
+
let hover;
|
|
30
|
+
let active;
|
|
31
|
+
if (isBaseBrand) {
|
|
32
|
+
hover = chroma.mix(baseColor, "#fff", hoverRatio, "rgb").hex();
|
|
33
|
+
active = chroma.mix(baseColor, "#fff", activeRatio, "rgb").hex();
|
|
34
|
+
} else if (isBaseLight) {
|
|
35
|
+
hover = chroma.mix(baseColor, brandColor, hoverRatio, "rgb").hex();
|
|
36
|
+
active = chroma.mix(baseColor, brandColor, activeRatio, "rgb").hex();
|
|
37
|
+
} else {
|
|
38
|
+
hover = chroma.mix(baseColor, brandColor, hoverRatio, "rgb").hex();
|
|
39
|
+
active = chroma.mix(baseColor, brandColor, activeRatio, "rgb").hex();
|
|
40
|
+
}
|
|
41
|
+
return { hover, active };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
hexToHSLString,
|
|
46
|
+
hexToRGBStr,
|
|
47
|
+
generateAutoStateColors
|
|
48
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__publicField
|
|
10
|
+
};
|