@usertour/helpers 0.0.59 → 0.0.61
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__/convert-settings.test.cjs +1257 -0
- package/dist/__tests__/convert-settings.test.d.cts +2 -0
- package/dist/__tests__/convert-settings.test.d.ts +2 -0
- package/dist/__tests__/convert-settings.test.js +874 -0
- package/dist/chunk-XKSTKX45.js +336 -0
- package/dist/convert-settings.cjs +211 -116
- package/dist/convert-settings.js +2 -1
- package/dist/index.cjs +252 -167
- package/dist/index.js +6 -6
- package/package.json +2 -2
- package/dist/chunk-MA5IMKG6.js +0 -248
package/dist/chunk-MA5IMKG6.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hexToHSLString,
|
|
3
|
-
hexToRGBStr
|
|
4
|
-
} from "./chunk-FZFHBCB6.js";
|
|
5
|
-
import {
|
|
6
|
-
isUndefined
|
|
7
|
-
} from "./chunk-GFH3VWOC.js";
|
|
8
|
-
|
|
9
|
-
// src/convert-settings.ts
|
|
10
|
-
import { defaultSettings } from "@usertour/types";
|
|
11
|
-
import { deepmerge } from "deepmerge-ts";
|
|
12
|
-
var defaultFontFamily = '-apple-system, "system-ui", "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.mainColor.color;
|
|
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-color-rgb": hexToRGBStr(settings.backdrop.highlight.color),
|
|
194
|
-
"--usertour-backdrop-highlight-opacity": settings.backdrop.highlight.opacity / 100,
|
|
195
|
-
"--usertour-backdrop-highlight-radius": `${settings.backdrop.highlight.radius}px`,
|
|
196
|
-
"--usertour-backdrop-highlight-spread": `${settings.backdrop.highlight.spread}px`,
|
|
197
|
-
"--usertour-backdrop-opacity": settings.backdrop.opacity / 100,
|
|
198
|
-
"--usertour-progress-bar-color": settings.progress.color,
|
|
199
|
-
"--usertour-progress-bar-height": `${settings.progress.height}px`,
|
|
200
|
-
"--usertour-narrow-progress-bar-height": `${settings.progress.narrowHeight}px`,
|
|
201
|
-
"--usertour-squared-progress-bar-height": `${settings.progress.chainSquaredHeight}px`,
|
|
202
|
-
"--usertour-rounded-progress-bar-height": `${settings.progress.chainRoundedHeight}px`,
|
|
203
|
-
"--usertour-dotted-progress-bar-height": `${settings.progress.dotsHeight}px`,
|
|
204
|
-
"--usertour-numbered-progress-bar-height": `${settings.progress.numberedHeight}px`,
|
|
205
|
-
"--usertour-widget-popper-padding": type === "modal" ? `${settings.modal.padding}px` : void 0,
|
|
206
|
-
"--usertour-xbutton": settings.xbutton.color,
|
|
207
|
-
"--usertour-widget-launcher-icon-color": settings.launcherIcon.color.color,
|
|
208
|
-
"--usertour-widget-launcher-icon-hover-color": settings.launcherIcon.color.hover,
|
|
209
|
-
"--usertour-widget-launcher-icon-active-color": settings.launcherIcon.color.active,
|
|
210
|
-
"--usertour-widget-launcher-icon-size": `${settings.launcherIcon.size}px`,
|
|
211
|
-
"--usertour-widget-beacon-color": settings.launcherBeacon.color,
|
|
212
|
-
"--usertour-widget-beacon-size": `${settings.launcherBeacon.size}px`,
|
|
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": hexToHSLString(
|
|
223
|
-
settings.checklistLauncher.color.color
|
|
224
|
-
),
|
|
225
|
-
"--usertour-checklist-trigger-font-weight": settings.checklistLauncher.fontWeight,
|
|
226
|
-
"--usertour-checkmark-background-color": settings.checklist.checkmarkColor,
|
|
227
|
-
"--usertour-checklist-trigger-height": `${settings.checklistLauncher.height}px`,
|
|
228
|
-
"--usertour-checklist-trigger-hover-background-color": settings.checklistLauncher.color.hover,
|
|
229
|
-
"--usertour-question-color": hexToHSLString(settings.survey.color)
|
|
230
|
-
};
|
|
231
|
-
if (settings.backdrop.highlight.type === "inside") {
|
|
232
|
-
cssMapping["--usertour-backdrop-highlight-inset"] = "inset";
|
|
233
|
-
}
|
|
234
|
-
let css = "";
|
|
235
|
-
for (const key in cssMapping) {
|
|
236
|
-
const value = cssMapping[key];
|
|
237
|
-
if (!isUndefined(value)) {
|
|
238
|
-
css += `${key}:${value};`;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return css;
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
export {
|
|
245
|
-
mergeThemeDefaultSettings,
|
|
246
|
-
convertSettings,
|
|
247
|
-
convertToCssVars
|
|
248
|
-
};
|