@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.
@@ -0,0 +1,1257 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // src/__tests__/convert-settings.test.ts
26
+ var import_types2 = require("@usertour/types");
27
+
28
+ // src/convert-settings.ts
29
+ var import_types = require("@usertour/types");
30
+
31
+ // src/color.ts
32
+ var import_chroma_js = __toESM(require("chroma-js"), 1);
33
+ function hexToHSLString(hexColor) {
34
+ try {
35
+ const color = (0, import_chroma_js.default)(hexColor);
36
+ const [h, s, l] = color.hsl();
37
+ const hDeg = Math.round(h || 0);
38
+ const sPct = Math.round(s * 100);
39
+ const lPct = Math.round(l * 100);
40
+ return `${hDeg} ${sPct}% ${lPct}%`;
41
+ } catch (error) {
42
+ console.warn(`Failed to convert ${hexColor} to HSL string:`, error);
43
+ return "0 0% 0%";
44
+ }
45
+ }
46
+ var hexToRGBStr = (hex) => {
47
+ try {
48
+ const color = (0, import_chroma_js.default)(hex);
49
+ const [r, g, b] = color.rgb();
50
+ return `${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}`;
51
+ } catch (error) {
52
+ console.warn(`Failed to convert ${hex} to RGB string:`, error);
53
+ return "0, 0, 0";
54
+ }
55
+ };
56
+
57
+ // src/convert-settings.ts
58
+ var import_deepmerge_ts = require("deepmerge-ts");
59
+
60
+ // src/type-utils.ts
61
+ var nativeIsArray = Array.isArray;
62
+ var ObjProto = Object.prototype;
63
+ var objToString = ObjProto.toString;
64
+ var objHasOwn = ObjProto.hasOwnProperty;
65
+ var isUndefined = (x) => x === void 0;
66
+
67
+ // src/utils.ts
68
+ var deepClone = (obj) => {
69
+ try {
70
+ return structuredClone(obj);
71
+ } catch (error) {
72
+ console.warn("structuredClone failed, falling back to JSON method:", error);
73
+ return JSON.parse(JSON.stringify(obj));
74
+ }
75
+ };
76
+
77
+ // src/convert-settings.ts
78
+ var defaultFontFamily = '-apple-system, "system-ui", "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"';
79
+ var mergeWithDefaults = (0, import_deepmerge_ts.deepmergeCustom)({
80
+ mergeOthers: (values) => {
81
+ const settingsValue = values[values.length - 1];
82
+ if (settingsValue === null || settingsValue === void 0) {
83
+ return values[0];
84
+ }
85
+ return settingsValue;
86
+ }
87
+ });
88
+ var resolveAutoValue = (value, fallback) => {
89
+ if (value === "Auto" || value === void 0 || value === null) {
90
+ return fallback;
91
+ }
92
+ return value;
93
+ };
94
+ var mergeThemeDefaultSettings = (settings) => {
95
+ const base = deepClone(import_types.defaultSettings);
96
+ return mergeWithDefaults(base, settings);
97
+ };
98
+ var convertSettings = (settings) => {
99
+ const data = mergeThemeDefaultSettings(settings);
100
+ data.mainColor.hover = resolveAutoValue(data.mainColor.hover, data.mainColor.autoHover);
101
+ data.mainColor.active = resolveAutoValue(
102
+ data.mainColor.active,
103
+ data.mainColor.autoActive
104
+ );
105
+ data.brandColor.hover = resolveAutoValue(
106
+ data.brandColor.hover,
107
+ data.brandColor.autoHover
108
+ );
109
+ data.brandColor.active = resolveAutoValue(
110
+ data.brandColor.active,
111
+ data.brandColor.autoActive
112
+ );
113
+ data.border.borderColor = resolveAutoValue(data.border.borderColor, data.mainColor.color);
114
+ data.buttons.primary.textColor.color = resolveAutoValue(
115
+ data.buttons.primary.textColor.color,
116
+ data.brandColor.color
117
+ );
118
+ data.buttons.primary.textColor.hover = resolveAutoValue(
119
+ data.buttons.primary.textColor.hover,
120
+ data.brandColor.color
121
+ );
122
+ data.buttons.primary.textColor.active = resolveAutoValue(
123
+ data.buttons.primary.textColor.active,
124
+ data.brandColor.color
125
+ );
126
+ data.buttons.primary.backgroundColor.background = resolveAutoValue(
127
+ data.buttons.primary.backgroundColor.background,
128
+ data.brandColor.background
129
+ );
130
+ data.buttons.primary.backgroundColor.hover = resolveAutoValue(
131
+ data.buttons.primary.backgroundColor.hover,
132
+ data.brandColor.autoHover
133
+ );
134
+ data.buttons.primary.backgroundColor.active = resolveAutoValue(
135
+ data.buttons.primary.backgroundColor.active,
136
+ data.brandColor.autoActive
137
+ );
138
+ data.buttons.primary.border.color.color = resolveAutoValue(
139
+ data.buttons.primary.border.color.color,
140
+ data.brandColor.background
141
+ );
142
+ data.buttons.primary.border.color.hover = resolveAutoValue(
143
+ data.buttons.primary.border.color.hover,
144
+ data.brandColor.autoHover
145
+ );
146
+ data.buttons.primary.border.color.active = resolveAutoValue(
147
+ data.buttons.primary.border.color.active,
148
+ data.brandColor.autoActive
149
+ );
150
+ data.buttons.secondary.textColor.color = resolveAutoValue(
151
+ data.buttons.secondary.textColor.color,
152
+ data.brandColor.background
153
+ );
154
+ data.buttons.secondary.textColor.hover = resolveAutoValue(
155
+ data.buttons.secondary.textColor.hover,
156
+ data.brandColor.background
157
+ );
158
+ data.buttons.secondary.textColor.active = resolveAutoValue(
159
+ data.buttons.secondary.textColor.active,
160
+ data.brandColor.background
161
+ );
162
+ data.buttons.secondary.backgroundColor.background = resolveAutoValue(
163
+ data.buttons.secondary.backgroundColor.background,
164
+ data.mainColor.background
165
+ );
166
+ data.buttons.secondary.backgroundColor.hover = resolveAutoValue(
167
+ data.buttons.secondary.backgroundColor.hover,
168
+ data.mainColor.autoHover
169
+ );
170
+ data.buttons.secondary.backgroundColor.active = resolveAutoValue(
171
+ data.buttons.secondary.backgroundColor.active,
172
+ data.mainColor.autoActive
173
+ );
174
+ data.buttons.secondary.border.color.color = resolveAutoValue(
175
+ data.buttons.secondary.border.color.color,
176
+ data.brandColor.background
177
+ );
178
+ data.buttons.secondary.border.color.hover = resolveAutoValue(
179
+ data.buttons.secondary.border.color.hover,
180
+ data.brandColor.background
181
+ );
182
+ data.buttons.secondary.border.color.active = resolveAutoValue(
183
+ data.buttons.secondary.border.color.active,
184
+ data.brandColor.background
185
+ );
186
+ data.font.linkColor = resolveAutoValue(data.font.linkColor, data.brandColor.background);
187
+ data.xbutton.color = resolveAutoValue(data.xbutton.color, data.mainColor.color);
188
+ data.progress.color = resolveAutoValue(data.progress.color, data.brandColor.background);
189
+ data.launcherBeacon.color = resolveAutoValue(
190
+ data.launcherBeacon.color,
191
+ data.brandColor.background
192
+ );
193
+ data.launcherIcon.color.color = resolveAutoValue(
194
+ data.launcherIcon.color.color,
195
+ data.brandColor.background
196
+ );
197
+ data.launcherIcon.color.hover = resolveAutoValue(
198
+ data.launcherIcon.color.hover,
199
+ data.brandColor.autoHover
200
+ );
201
+ data.launcherIcon.color.active = resolveAutoValue(
202
+ data.launcherIcon.color.active,
203
+ data.brandColor.autoActive
204
+ );
205
+ data.checklistLauncher.color.color = resolveAutoValue(
206
+ data.checklistLauncher.color.color,
207
+ data.brandColor.color
208
+ );
209
+ data.checklistLauncher.color.background = resolveAutoValue(
210
+ data.checklistLauncher.color.background,
211
+ data.brandColor.background
212
+ );
213
+ data.checklistLauncher.color.hover = resolveAutoValue(
214
+ data.checklistLauncher.color.hover,
215
+ data.brandColor.autoHover
216
+ );
217
+ data.checklistLauncher.color.active = resolveAutoValue(
218
+ data.checklistLauncher.color.active,
219
+ data.brandColor.autoActive
220
+ );
221
+ data.checklistLauncher.counter.color = resolveAutoValue(
222
+ data.checklistLauncher.counter.color,
223
+ data.brandColor.background
224
+ );
225
+ data.checklistLauncher.counter.background = resolveAutoValue(
226
+ data.checklistLauncher.counter.background,
227
+ data.brandColor.color
228
+ );
229
+ data.survey.color = resolveAutoValue(data.survey.color, data.brandColor.background);
230
+ data.launcherButtons.primary.textColor.color = resolveAutoValue(
231
+ data.launcherButtons.primary.textColor.color,
232
+ data.brandColor.color
233
+ );
234
+ data.launcherButtons.primary.textColor.hover = resolveAutoValue(
235
+ data.launcherButtons.primary.textColor.hover,
236
+ data.brandColor.color
237
+ );
238
+ data.launcherButtons.primary.textColor.active = resolveAutoValue(
239
+ data.launcherButtons.primary.textColor.active,
240
+ data.brandColor.color
241
+ );
242
+ data.launcherButtons.primary.backgroundColor.background = resolveAutoValue(
243
+ data.launcherButtons.primary.backgroundColor.background,
244
+ data.brandColor.background
245
+ );
246
+ data.launcherButtons.primary.backgroundColor.hover = resolveAutoValue(
247
+ data.launcherButtons.primary.backgroundColor.hover,
248
+ data.brandColor.autoHover
249
+ );
250
+ data.launcherButtons.primary.backgroundColor.active = resolveAutoValue(
251
+ data.launcherButtons.primary.backgroundColor.active,
252
+ data.brandColor.autoActive
253
+ );
254
+ data.launcherButtons.primary.border.color.color = resolveAutoValue(
255
+ data.launcherButtons.primary.border.color.color,
256
+ data.brandColor.background
257
+ );
258
+ data.launcherButtons.primary.border.color.hover = resolveAutoValue(
259
+ data.launcherButtons.primary.border.color.hover,
260
+ data.brandColor.autoHover
261
+ );
262
+ data.launcherButtons.primary.border.color.active = resolveAutoValue(
263
+ data.launcherButtons.primary.border.color.active,
264
+ data.brandColor.autoActive
265
+ );
266
+ if (data.font.fontFamily === "System font") {
267
+ data.font.fontFamily = defaultFontFamily;
268
+ } else if (!data.font.fontFamily.includes("sans-serif")) {
269
+ data.font.fontFamily += ", sans-serif;";
270
+ }
271
+ return data;
272
+ };
273
+ var convertToCssVars = (settings, type = "tooltip") => {
274
+ const cssMapping = {
275
+ "--usertour-background": hexToHSLString(settings.mainColor.background),
276
+ "--usertour-foreground": hexToHSLString(settings.mainColor.color),
277
+ "--usertour-brand-active-background-color": hexToHSLString(
278
+ settings.brandColor.autoActive
279
+ ),
280
+ "--usertour-brand-hover-background-color": hexToHSLString(
281
+ settings.brandColor.autoHover
282
+ ),
283
+ "--usertour-font-family": settings.font.fontFamily,
284
+ "--usertour-font-size": `${settings.font.fontSize}px`,
285
+ "--usertour-main-background-color": settings.mainColor.background,
286
+ "--usertour-main-foreground-color": settings.mainColor.color,
287
+ "--usertour-main-hover-background-color": hexToHSLString(
288
+ settings.mainColor.autoHover
289
+ ),
290
+ "--usertour-main-active-background-color": hexToHSLString(
291
+ settings.mainColor.autoActive
292
+ ),
293
+ "--usertour-line-height": `${settings.font.lineHeight}px`,
294
+ "--usertour-widget-popper-border-radius": `${settings.border.borderRadius}px`,
295
+ "--usertour-font-weight-normal": settings.font.fontWeightNormal,
296
+ "--usertour-font-weight-bold": settings.font.fontWeightBold,
297
+ "--usertour-h1-font-size": `${settings.font.h1FontSize}px`,
298
+ "--usertour-h2-font-size": `${settings.font.h2FontSize}px`,
299
+ "--usertour-link-color": hexToHSLString(settings.font.linkColor),
300
+ "--usertour-widget-popper-border-width": settings.border.borderWidthEnabled ? `${settings.border.borderWidth}px` : "0px",
301
+ "--usertour-widget-popper-border-color": settings.border.borderColor,
302
+ "--usertour-button-border-radius": `${settings.buttons.borderRadius}px`,
303
+ "--usertour-button-height": `${settings.buttons.height}px`,
304
+ "--usertour-button-min-width": `${settings.buttons.minWidth}px`,
305
+ "--usertour-button-px": `${settings.buttons.px}px`,
306
+ "--usertour-primary": settings.buttons.primary.backgroundColor.background,
307
+ "--usertour-primary-hover": settings.buttons.primary.backgroundColor.hover,
308
+ "--usertour-primary-active": settings.buttons.primary.backgroundColor.active,
309
+ "--usertour-primary-foreground": settings.buttons.primary.textColor.color,
310
+ "--usertour-primary-foreground-hover": settings.buttons.primary.textColor.hover,
311
+ "--usertour-primary-foreground-active": settings.buttons.primary.textColor.active,
312
+ "--usertour-primary-border-width": settings.buttons.primary.border.enabled ? `${settings.buttons.primary.border.borderWidth}px` : "0px",
313
+ "--usertour-primary-border-color": settings.buttons.primary.border.color.color,
314
+ "--usertour-primary-border-hover": settings.buttons.primary.border.color.hover,
315
+ "--usertour-primary-border-active": settings.buttons.primary.border.color.active,
316
+ "--usertour-primary-font-weight": settings.buttons.primary.fontWeight,
317
+ "--usertour-secondary": settings.buttons.secondary.backgroundColor.background,
318
+ "--usertour-secondary-hover": settings.buttons.secondary.backgroundColor.hover,
319
+ "--usertour-secondary-active": settings.buttons.secondary.backgroundColor.active,
320
+ "--usertour-secondary-foreground": settings.buttons.secondary.textColor.color,
321
+ "--usertour-secondary-foreground-hover": settings.buttons.secondary.textColor.hover,
322
+ "--usertour-secondary-foreground-active": settings.buttons.secondary.textColor.active,
323
+ "--usertour-secondary-border-width": settings.buttons.secondary.border.enabled ? `${settings.buttons.secondary.border.borderWidth}px` : "0px",
324
+ "--usertour-secondary-border-color": settings.buttons.secondary.border.color.color,
325
+ "--usertour-secondary-border-hover": settings.buttons.secondary.border.color.hover,
326
+ "--usertour-secondary-border-active": settings.buttons.secondary.border.color.active,
327
+ "--usertour-secondary-font-weight": settings.buttons.secondary.fontWeight,
328
+ "--usertour-backdrop-color-rgb": hexToRGBStr(settings.backdrop.color),
329
+ "--usertour-backdrop-highlight-color-rgb": hexToRGBStr(settings.backdrop.highlight.color),
330
+ "--usertour-backdrop-highlight-opacity": settings.backdrop.highlight.opacity / 100,
331
+ "--usertour-backdrop-highlight-radius": `${settings.backdrop.highlight.radius}px`,
332
+ "--usertour-backdrop-highlight-spread": `${settings.backdrop.highlight.spread}px`,
333
+ "--usertour-backdrop-opacity": settings.backdrop.opacity / 100,
334
+ "--usertour-progress-bar-color": settings.progress.color,
335
+ "--usertour-progress-bar-height": `${settings.progress.height}px`,
336
+ "--usertour-narrow-progress-bar-height": `${settings.progress.narrowHeight}px`,
337
+ "--usertour-squared-progress-bar-height": `${settings.progress.chainSquaredHeight}px`,
338
+ "--usertour-rounded-progress-bar-height": `${settings.progress.chainRoundedHeight}px`,
339
+ "--usertour-dotted-progress-bar-height": `${settings.progress.dotsHeight}px`,
340
+ "--usertour-numbered-progress-bar-height": `${settings.progress.numberedHeight}px`,
341
+ "--usertour-widget-popper-padding": type === "modal" ? `${settings.modal.padding}px` : void 0,
342
+ "--usertour-xbutton": settings.xbutton.color,
343
+ "--usertour-widget-launcher-icon-color": settings.launcherIcon.color.color,
344
+ "--usertour-widget-launcher-icon-hover-color": settings.launcherIcon.color.hover,
345
+ "--usertour-widget-launcher-icon-active-color": settings.launcherIcon.color.active,
346
+ "--usertour-widget-launcher-icon-size": `${settings.launcherIcon.size}px`,
347
+ "--usertour-widget-beacon-color": settings.launcherBeacon.color,
348
+ "--usertour-widget-beacon-size": `${settings.launcherBeacon.size}px`,
349
+ "--usertour-widget-launcher-icon-opacity": settings.launcherIcon.opacity / 100,
350
+ "--usertour-widget-popper-padding-top": "2px",
351
+ "--usertour-widget-popper-padding-bottom": "2px",
352
+ "--usertour-checklist-trigger-active-background-color": settings.checklistLauncher.color.active,
353
+ "--usertour-checklist-trigger-background-color": settings.checklistLauncher.color.background,
354
+ "--usertour-checklist-trigger-border-radius": `${settings.checklistLauncher.borderRadius}px`,
355
+ "--usertour-checklist-trigger-counter-background-color": settings.checklistLauncher.counter.background,
356
+ "--usertour-checklist-trigger-counter-font-color": settings.checklistLauncher.counter.color,
357
+ "--usertour-checklist-trigger-font-color-rgb": settings.checklistLauncher.color.color,
358
+ "--usertour-checklist-trigger-font-color": hexToHSLString(
359
+ settings.checklistLauncher.color.color
360
+ ),
361
+ "--usertour-checklist-trigger-font-weight": settings.checklistLauncher.fontWeight,
362
+ "--usertour-checkmark-background-color": settings.checklist.checkmarkColor,
363
+ "--usertour-checklist-trigger-height": `${settings.checklistLauncher.height}px`,
364
+ "--usertour-checklist-trigger-hover-background-color": settings.checklistLauncher.color.hover,
365
+ "--usertour-question-color": hexToHSLString(settings.survey.color),
366
+ "--usertour-launcher-button-height": `${settings.launcherButtons.height}px`,
367
+ "--usertour-launcher-button-width": settings.launcherButtons.width === 0 ? "auto" : `${settings.launcherButtons.width}px`,
368
+ "--usertour-launcher-button-horizontal-padding": `${settings.launcherButtons.px}px`,
369
+ "--usertour-launcher-button-border-radius": `${settings.launcherButtons.borderRadius}px`,
370
+ "--usertour-launcher-button-background-color": settings.launcherButtons.primary.backgroundColor.background,
371
+ "--usertour-launcher-button-hover-background-color": settings.launcherButtons.primary.backgroundColor.hover,
372
+ "--usertour-launcher-button-active-background-color": settings.launcherButtons.primary.backgroundColor.active,
373
+ "--usertour-launcher-button-font-color": settings.launcherButtons.primary.textColor.color,
374
+ "--usertour-launcher-button-hover-font-color": settings.launcherButtons.primary.textColor.hover,
375
+ "--usertour-launcher-button-active-font-color": settings.launcherButtons.primary.textColor.active,
376
+ "--usertour-launcher-button-font-weight": settings.launcherButtons.primary.fontWeight,
377
+ "--usertour-launcher-button-border-width": settings.launcherButtons.primary.border.enabled ? `${settings.launcherButtons.primary.border.borderWidth}px` : "0px",
378
+ "--usertour-launcher-button-border-color": settings.launcherButtons.primary.border.color.color,
379
+ "--usertour-launcher-button-hover-border-color": settings.launcherButtons.primary.border.color.hover,
380
+ "--usertour-launcher-button-active-border-color": settings.launcherButtons.primary.border.color.active
381
+ };
382
+ if (settings.backdrop.highlight.type === "inside") {
383
+ cssMapping["--usertour-backdrop-highlight-inset"] = "inset";
384
+ }
385
+ let css = "";
386
+ for (const key in cssMapping) {
387
+ const value = cssMapping[key];
388
+ if (!isUndefined(value)) {
389
+ css += `${key}:${value};`;
390
+ }
391
+ }
392
+ return css;
393
+ };
394
+
395
+ // src/__tests__/convert-settings.test.ts
396
+ var originalDefaultMainColorHover = import_types2.defaultSettings.mainColor.hover;
397
+ var originalDefaultBrandColorHover = import_types2.defaultSettings.brandColor.hover;
398
+ describe("convert-settings", () => {
399
+ const completeSettings = {
400
+ mainColor: {
401
+ background: "#FFFFFF",
402
+ color: "#0f172a",
403
+ hover: "Auto",
404
+ active: "Auto",
405
+ autoHover: "#e7eefd",
406
+ autoActive: "#cedcfb"
407
+ },
408
+ brandColor: {
409
+ background: "#2563eb",
410
+ color: "#ffffff",
411
+ hover: "Auto",
412
+ active: "Auto",
413
+ autoHover: "#4b7eee",
414
+ autoActive: "#2055c9"
415
+ },
416
+ font: {
417
+ fontFamily: "System font",
418
+ fontSize: 16,
419
+ lineHeight: 24,
420
+ fontWeightNormal: 400,
421
+ fontWeightBold: 600,
422
+ h1FontSize: 24,
423
+ h2FontSize: 20,
424
+ linkColor: "Auto"
425
+ },
426
+ border: {
427
+ borderRadius: "10",
428
+ borderWidthEnabled: false,
429
+ borderWidth: 1,
430
+ borderColor: "Auto"
431
+ },
432
+ xbutton: {
433
+ color: "Auto"
434
+ },
435
+ progress: {
436
+ enabled: true,
437
+ color: "Auto",
438
+ height: 2,
439
+ type: "full-width",
440
+ position: "top",
441
+ narrowHeight: 5,
442
+ chainSquaredHeight: 4,
443
+ chainRoundedHeight: 6,
444
+ dotsHeight: 6,
445
+ numberedHeight: 12
446
+ },
447
+ survey: {
448
+ color: "Auto"
449
+ },
450
+ launcherBeacon: {
451
+ color: "Auto",
452
+ size: 16
453
+ },
454
+ launcherIcon: {
455
+ color: {
456
+ color: "Auto",
457
+ hover: "Auto",
458
+ active: "Auto",
459
+ background: "#1d4ed8"
460
+ },
461
+ opacity: 100,
462
+ size: 16
463
+ },
464
+ checklist: {
465
+ checkmarkColor: "#4ade80",
466
+ width: 360,
467
+ placement: {
468
+ position: "rightBottom",
469
+ positionOffsetX: 20,
470
+ positionOffsetY: 20
471
+ }
472
+ },
473
+ checklistLauncher: {
474
+ borderRadius: 30,
475
+ height: 60,
476
+ fontWeight: 600,
477
+ placement: {
478
+ position: "rightBottom",
479
+ positionOffsetX: 100,
480
+ positionOffsetY: 20
481
+ },
482
+ color: {
483
+ color: "Auto",
484
+ hover: "Auto",
485
+ active: "Auto",
486
+ background: "Auto"
487
+ },
488
+ counter: {
489
+ color: "Auto",
490
+ background: "Auto"
491
+ }
492
+ },
493
+ buttons: {
494
+ height: 32,
495
+ minWidth: 0,
496
+ px: 16,
497
+ borderRadius: 8,
498
+ primary: {
499
+ fontWeight: 600,
500
+ textColor: {
501
+ color: "Auto",
502
+ hover: "Auto",
503
+ active: "Auto",
504
+ background: "#FFFFFF"
505
+ },
506
+ backgroundColor: {
507
+ color: "#FFFFFF",
508
+ hover: "Auto",
509
+ active: "Auto",
510
+ background: "Auto"
511
+ },
512
+ border: {
513
+ enabled: false,
514
+ borderWidth: 1,
515
+ color: {
516
+ color: "Auto",
517
+ hover: "Auto",
518
+ active: "Auto",
519
+ background: "#FFFFFF"
520
+ }
521
+ }
522
+ },
523
+ secondary: {
524
+ fontWeight: 600,
525
+ textColor: {
526
+ color: "Auto",
527
+ hover: "Auto",
528
+ active: "Auto",
529
+ background: "#FFFFFF"
530
+ },
531
+ backgroundColor: {
532
+ color: "#FFFFFF",
533
+ hover: "Auto",
534
+ active: "Auto",
535
+ background: "Auto"
536
+ },
537
+ border: {
538
+ enabled: true,
539
+ borderWidth: 1,
540
+ color: {
541
+ color: "Auto",
542
+ hover: "Auto",
543
+ active: "Auto",
544
+ background: "#FFFFFF"
545
+ }
546
+ }
547
+ }
548
+ },
549
+ launcherButtons: {
550
+ height: 32,
551
+ width: 0,
552
+ px: 16,
553
+ borderRadius: 8,
554
+ primary: {
555
+ fontWeight: 600,
556
+ textColor: {
557
+ color: "Auto",
558
+ hover: "Auto",
559
+ active: "Auto",
560
+ background: "#FFFFFF"
561
+ },
562
+ backgroundColor: {
563
+ color: "#FFFFFF",
564
+ hover: "Auto",
565
+ active: "Auto",
566
+ background: "Auto"
567
+ },
568
+ border: {
569
+ enabled: false,
570
+ borderWidth: 1,
571
+ color: {
572
+ color: "Auto",
573
+ hover: "Auto",
574
+ active: "Auto",
575
+ background: "#FFFFFF"
576
+ }
577
+ }
578
+ }
579
+ },
580
+ tooltip: {
581
+ width: 300,
582
+ notchSize: 20
583
+ },
584
+ modal: {
585
+ width: 600,
586
+ padding: 40
587
+ },
588
+ backdrop: {
589
+ color: "#000000",
590
+ opacity: 40,
591
+ highlight: {
592
+ type: "outside",
593
+ radius: 4,
594
+ spread: 0,
595
+ color: "#ffffff",
596
+ opacity: 50
597
+ }
598
+ }
599
+ };
600
+ describe("mergeThemeDefaultSettings", () => {
601
+ it("should merge with defaultSettings for empty input", () => {
602
+ const result = mergeThemeDefaultSettings({});
603
+ expect(result.mainColor).toBeDefined();
604
+ expect(result.brandColor).toBeDefined();
605
+ expect(result.buttons).toBeDefined();
606
+ expect(result.font).toBeDefined();
607
+ });
608
+ it("should override defaultSettings with provided values", () => {
609
+ const customSettings = {
610
+ mainColor: {
611
+ background: "#000000",
612
+ color: "#ffffff",
613
+ hover: "#333333",
614
+ active: "#666666"
615
+ }
616
+ };
617
+ const result = mergeThemeDefaultSettings(customSettings);
618
+ expect(result.mainColor.background).toBe("#000000");
619
+ expect(result.mainColor.color).toBe("#ffffff");
620
+ });
621
+ });
622
+ describe("convertSettings - Auto value resolution", () => {
623
+ describe("mainColor Auto values", () => {
624
+ it("should resolve mainColor.hover from autoHover when set to Auto", () => {
625
+ const result = convertSettings(completeSettings);
626
+ expect(result.mainColor.hover).toBe(completeSettings.mainColor.autoHover);
627
+ });
628
+ it("should resolve mainColor.active from autoActive when set to Auto", () => {
629
+ const result = convertSettings(completeSettings);
630
+ expect(result.mainColor.active).toBe(completeSettings.mainColor.autoActive);
631
+ });
632
+ it("should keep custom hover value when not Auto", () => {
633
+ const settings = {
634
+ ...completeSettings,
635
+ mainColor: {
636
+ ...completeSettings.mainColor,
637
+ hover: "#custom123"
638
+ }
639
+ };
640
+ const result = convertSettings(settings);
641
+ expect(result.mainColor.hover).toBe("#custom123");
642
+ });
643
+ });
644
+ describe("brandColor Auto values", () => {
645
+ it("should resolve brandColor.hover from autoHover when set to Auto", () => {
646
+ const result = convertSettings(completeSettings);
647
+ expect(result.brandColor.hover).toBe(completeSettings.brandColor.autoHover);
648
+ });
649
+ it("should resolve brandColor.active from autoActive when set to Auto", () => {
650
+ const result = convertSettings(completeSettings);
651
+ expect(result.brandColor.active).toBe(completeSettings.brandColor.autoActive);
652
+ });
653
+ });
654
+ describe("border Auto values", () => {
655
+ it("should resolve border.borderColor from mainColor.color when set to Auto", () => {
656
+ const result = convertSettings(completeSettings);
657
+ expect(result.border.borderColor).toBe(completeSettings.mainColor.color);
658
+ });
659
+ });
660
+ describe("primary button Auto values", () => {
661
+ it("should resolve primary button textColor from brandColor.color when set to Auto", () => {
662
+ const result = convertSettings(completeSettings);
663
+ expect(result.buttons.primary.textColor.color).toBe(completeSettings.brandColor.color);
664
+ expect(result.buttons.primary.textColor.hover).toBe(completeSettings.brandColor.color);
665
+ expect(result.buttons.primary.textColor.active).toBe(completeSettings.brandColor.color);
666
+ });
667
+ it("should resolve primary button backgroundColor from brandColor when set to Auto", () => {
668
+ const result = convertSettings(completeSettings);
669
+ expect(result.buttons.primary.backgroundColor.background).toBe(
670
+ completeSettings.brandColor.background
671
+ );
672
+ expect(result.buttons.primary.backgroundColor.hover).toBe(
673
+ completeSettings.brandColor.autoHover
674
+ );
675
+ expect(result.buttons.primary.backgroundColor.active).toBe(
676
+ completeSettings.brandColor.autoActive
677
+ );
678
+ });
679
+ it("should resolve primary button border.color from brandColor when set to Auto", () => {
680
+ const result = convertSettings(completeSettings);
681
+ expect(result.buttons.primary.border.color.color).toBe(
682
+ completeSettings.brandColor.background
683
+ );
684
+ expect(result.buttons.primary.border.color.hover).toBe(
685
+ completeSettings.brandColor.autoHover
686
+ );
687
+ expect(result.buttons.primary.border.color.active).toBe(
688
+ completeSettings.brandColor.autoActive
689
+ );
690
+ });
691
+ });
692
+ describe("secondary button Auto values", () => {
693
+ it("should resolve secondary button textColor from brandColor.background when set to Auto", () => {
694
+ const result = convertSettings(completeSettings);
695
+ expect(result.buttons.secondary.textColor.color).toBe(
696
+ completeSettings.brandColor.background
697
+ );
698
+ expect(result.buttons.secondary.textColor.hover).toBe(
699
+ completeSettings.brandColor.background
700
+ );
701
+ expect(result.buttons.secondary.textColor.active).toBe(
702
+ completeSettings.brandColor.background
703
+ );
704
+ });
705
+ it("should resolve secondary button backgroundColor from mainColor when set to Auto", () => {
706
+ const result = convertSettings(completeSettings);
707
+ expect(result.buttons.secondary.backgroundColor.background).toBe(
708
+ completeSettings.mainColor.background
709
+ );
710
+ expect(result.buttons.secondary.backgroundColor.hover).toBe(
711
+ completeSettings.mainColor.autoHover
712
+ );
713
+ expect(result.buttons.secondary.backgroundColor.active).toBe(
714
+ completeSettings.mainColor.autoActive
715
+ );
716
+ });
717
+ it("should resolve secondary button border.color from brandColor.background when set to Auto", () => {
718
+ const result = convertSettings(completeSettings);
719
+ expect(result.buttons.secondary.border.color.color).toBe(
720
+ completeSettings.brandColor.background
721
+ );
722
+ expect(result.buttons.secondary.border.color.hover).toBe(
723
+ completeSettings.brandColor.background
724
+ );
725
+ expect(result.buttons.secondary.border.color.active).toBe(
726
+ completeSettings.brandColor.background
727
+ );
728
+ });
729
+ });
730
+ describe("font Auto values", () => {
731
+ it("should resolve font.linkColor from brandColor.background when set to Auto", () => {
732
+ const result = convertSettings(completeSettings);
733
+ expect(result.font.linkColor).toBe(completeSettings.brandColor.background);
734
+ });
735
+ });
736
+ describe("xbutton Auto values", () => {
737
+ it("should resolve xbutton.color from mainColor.color when set to Auto", () => {
738
+ const result = convertSettings(completeSettings);
739
+ expect(result.xbutton.color).toBe(completeSettings.mainColor.color);
740
+ });
741
+ });
742
+ describe("progress Auto values", () => {
743
+ it("should resolve progress.color from brandColor.background when set to Auto", () => {
744
+ const result = convertSettings(completeSettings);
745
+ expect(result.progress.color).toBe(completeSettings.brandColor.background);
746
+ });
747
+ });
748
+ describe("launcherBeacon Auto values", () => {
749
+ it("should resolve launcherBeacon.color from brandColor.background when set to Auto", () => {
750
+ const settings = {
751
+ ...completeSettings,
752
+ launcherBeacon: {
753
+ ...completeSettings.launcherBeacon,
754
+ color: "Auto"
755
+ }
756
+ };
757
+ const result = convertSettings(settings);
758
+ expect(result.launcherBeacon.color).toBe(completeSettings.brandColor.background);
759
+ });
760
+ });
761
+ describe("launcherIcon Auto values", () => {
762
+ it("should resolve launcherIcon.color values from brandColor when set to Auto", () => {
763
+ const result = convertSettings(completeSettings);
764
+ expect(result.launcherIcon.color.color).toBe(completeSettings.brandColor.background);
765
+ expect(result.launcherIcon.color.hover).toBe(completeSettings.brandColor.autoHover);
766
+ expect(result.launcherIcon.color.active).toBe(completeSettings.brandColor.autoActive);
767
+ });
768
+ });
769
+ describe("checklistLauncher Auto values", () => {
770
+ it("should resolve checklistLauncher.color values from brandColor when set to Auto", () => {
771
+ const result = convertSettings(completeSettings);
772
+ expect(result.checklistLauncher.color.color).toBe(completeSettings.brandColor.color);
773
+ expect(result.checklistLauncher.color.background).toBe(
774
+ completeSettings.brandColor.background
775
+ );
776
+ expect(result.checklistLauncher.color.hover).toBe(completeSettings.brandColor.autoHover);
777
+ expect(result.checklistLauncher.color.active).toBe(completeSettings.brandColor.autoActive);
778
+ });
779
+ it("should resolve checklistLauncher.counter values from brandColor when set to Auto", () => {
780
+ const result = convertSettings(completeSettings);
781
+ expect(result.checklistLauncher.counter.color).toBe(completeSettings.brandColor.background);
782
+ expect(result.checklistLauncher.counter.background).toBe(completeSettings.brandColor.color);
783
+ });
784
+ });
785
+ describe("survey Auto values", () => {
786
+ it("should resolve survey.color from brandColor.background when set to Auto", () => {
787
+ const result = convertSettings(completeSettings);
788
+ expect(result.survey.color).toBe(completeSettings.brandColor.background);
789
+ });
790
+ });
791
+ describe("launcherButtons Auto values", () => {
792
+ it("should resolve launcherButtons primary textColor from brandColor.color when set to Auto", () => {
793
+ const result = convertSettings(completeSettings);
794
+ expect(result.launcherButtons.primary.textColor.color).toBe(
795
+ completeSettings.brandColor.color
796
+ );
797
+ expect(result.launcherButtons.primary.textColor.hover).toBe(
798
+ completeSettings.brandColor.color
799
+ );
800
+ expect(result.launcherButtons.primary.textColor.active).toBe(
801
+ completeSettings.brandColor.color
802
+ );
803
+ });
804
+ it("should resolve launcherButtons primary backgroundColor from brandColor when set to Auto", () => {
805
+ const result = convertSettings(completeSettings);
806
+ expect(result.launcherButtons.primary.backgroundColor.background).toBe(
807
+ completeSettings.brandColor.background
808
+ );
809
+ expect(result.launcherButtons.primary.backgroundColor.hover).toBe(
810
+ completeSettings.brandColor.autoHover
811
+ );
812
+ expect(result.launcherButtons.primary.backgroundColor.active).toBe(
813
+ completeSettings.brandColor.autoActive
814
+ );
815
+ });
816
+ it("should resolve launcherButtons primary border.color from brandColor when set to Auto", () => {
817
+ const result = convertSettings(completeSettings);
818
+ expect(result.launcherButtons.primary.border.color.color).toBe(
819
+ completeSettings.brandColor.background
820
+ );
821
+ expect(result.launcherButtons.primary.border.color.hover).toBe(
822
+ completeSettings.brandColor.autoHover
823
+ );
824
+ expect(result.launcherButtons.primary.border.color.active).toBe(
825
+ completeSettings.brandColor.autoActive
826
+ );
827
+ });
828
+ });
829
+ describe("font family handling", () => {
830
+ it("should convert System font to full font family string", () => {
831
+ const result = convertSettings(completeSettings);
832
+ expect(result.font.fontFamily).toContain("apple-system");
833
+ expect(result.font.fontFamily).toContain("Segoe UI");
834
+ });
835
+ it("should append sans-serif to custom font family", () => {
836
+ const settings = {
837
+ ...completeSettings,
838
+ font: {
839
+ ...completeSettings.font,
840
+ fontFamily: "CustomFont"
841
+ }
842
+ };
843
+ const result = convertSettings(settings);
844
+ expect(result.font.fontFamily).toContain("CustomFont");
845
+ expect(result.font.fontFamily).toContain("sans-serif");
846
+ });
847
+ });
848
+ });
849
+ describe("convertSettings - Missing data fallback (defaultSettings layer)", () => {
850
+ it("should handle empty settings object with defaultSettings fallback", () => {
851
+ const result = convertSettings({});
852
+ expect(result.mainColor).toBeDefined();
853
+ expect(result.brandColor).toBeDefined();
854
+ expect(result.buttons).toBeDefined();
855
+ expect(result.font).toBeDefined();
856
+ expect(result.border).toBeDefined();
857
+ });
858
+ it("should handle missing mainColor with defaultSettings fallback", () => {
859
+ const settings = { brandColor: completeSettings.brandColor };
860
+ const result = convertSettings(settings);
861
+ expect(result.mainColor.background).toBe(import_types2.defaultSettings.mainColor.background);
862
+ });
863
+ it("should handle missing buttons with defaultSettings fallback", () => {
864
+ const settings = {
865
+ mainColor: completeSettings.mainColor,
866
+ brandColor: completeSettings.brandColor
867
+ };
868
+ const result = convertSettings(settings);
869
+ expect(result.buttons.height).toBe(import_types2.defaultSettings.buttons.height);
870
+ expect(result.buttons.primary).toBeDefined();
871
+ expect(result.buttons.secondary).toBeDefined();
872
+ });
873
+ it("should handle missing nested properties with defaultSettings fallback", () => {
874
+ const settings = {
875
+ buttons: {
876
+ height: 40
877
+ // missing primary and secondary
878
+ }
879
+ };
880
+ const result = convertSettings(settings);
881
+ expect(result.buttons.height).toBe(40);
882
+ expect(result.buttons.primary).toBeDefined();
883
+ expect(result.buttons.secondary).toBeDefined();
884
+ });
885
+ it("should handle missing progress with defaultSettings fallback", () => {
886
+ const settings = {
887
+ mainColor: completeSettings.mainColor,
888
+ brandColor: completeSettings.brandColor
889
+ };
890
+ const result = convertSettings(settings);
891
+ expect(result.progress).toBeDefined();
892
+ expect(result.progress.height).toBe(import_types2.defaultSettings.progress.height);
893
+ });
894
+ it("should handle missing checklistLauncher with defaultSettings fallback", () => {
895
+ const settings = {
896
+ mainColor: completeSettings.mainColor,
897
+ brandColor: completeSettings.brandColor
898
+ };
899
+ const result = convertSettings(settings);
900
+ expect(result.checklistLauncher).toBeDefined();
901
+ expect(result.checklistLauncher.borderRadius).toBe(
902
+ import_types2.defaultSettings.checklistLauncher.borderRadius
903
+ );
904
+ });
905
+ it("should handle missing launcherIcon with defaultSettings fallback", () => {
906
+ const settings = {
907
+ mainColor: completeSettings.mainColor,
908
+ brandColor: completeSettings.brandColor
909
+ };
910
+ const result = convertSettings(settings);
911
+ expect(result.launcherIcon).toBeDefined();
912
+ expect(result.launcherIcon.size).toBe(import_types2.defaultSettings.launcherIcon.size);
913
+ });
914
+ it("should handle missing launcherButtons with defaultSettings fallback", () => {
915
+ const settings = {
916
+ mainColor: completeSettings.mainColor,
917
+ brandColor: completeSettings.brandColor
918
+ };
919
+ const result = convertSettings(settings);
920
+ expect(result.launcherButtons).toBeDefined();
921
+ expect(result.launcherButtons.height).toBe(import_types2.defaultSettings.launcherButtons.height);
922
+ expect(result.launcherButtons.width).toBe(import_types2.defaultSettings.launcherButtons.width);
923
+ expect(result.launcherButtons.px).toBe(import_types2.defaultSettings.launcherButtons.px);
924
+ expect(result.launcherButtons.borderRadius).toBe(
925
+ import_types2.defaultSettings.launcherButtons.borderRadius
926
+ );
927
+ expect(result.launcherButtons.primary).toBeDefined();
928
+ });
929
+ });
930
+ describe("convertSettings - Combined fallback (missing data + Auto resolution)", () => {
931
+ it("should apply both defaultSettings fallback and Auto resolution for empty input", () => {
932
+ const result = convertSettings({});
933
+ expect(result.mainColor.background).toBe(import_types2.defaultSettings.mainColor.background);
934
+ expect(result.mainColor.hover).toBe(import_types2.defaultSettings.mainColor.autoHover);
935
+ expect(result.mainColor.active).toBe(import_types2.defaultSettings.mainColor.autoActive);
936
+ expect(result.brandColor.hover).toBe(import_types2.defaultSettings.brandColor.autoHover);
937
+ expect(result.brandColor.active).toBe(import_types2.defaultSettings.brandColor.autoActive);
938
+ });
939
+ it("should resolve Auto values using defaultSettings when source settings are missing", () => {
940
+ const result = convertSettings({});
941
+ expect(result.border.borderColor).toBe(import_types2.defaultSettings.mainColor.color);
942
+ expect(result.xbutton.color).toBe(import_types2.defaultSettings.mainColor.color);
943
+ expect(result.font.linkColor).toBe(import_types2.defaultSettings.brandColor.background);
944
+ expect(result.progress.color).toBe(import_types2.defaultSettings.brandColor.background);
945
+ });
946
+ it("should resolve button Auto values using defaultSettings when settings are missing", () => {
947
+ const result = convertSettings({});
948
+ expect(result.buttons.primary.textColor.color).toBe(import_types2.defaultSettings.brandColor.color);
949
+ expect(result.buttons.primary.backgroundColor.background).toBe(
950
+ import_types2.defaultSettings.brandColor.background
951
+ );
952
+ expect(result.buttons.primary.backgroundColor.hover).toBe(
953
+ import_types2.defaultSettings.brandColor.autoHover
954
+ );
955
+ expect(result.buttons.secondary.textColor.color).toBe(import_types2.defaultSettings.brandColor.background);
956
+ expect(result.buttons.secondary.backgroundColor.background).toBe(
957
+ import_types2.defaultSettings.mainColor.background
958
+ );
959
+ expect(result.launcherButtons.primary.textColor.color).toBe(import_types2.defaultSettings.brandColor.color);
960
+ expect(result.launcherButtons.primary.backgroundColor.background).toBe(
961
+ import_types2.defaultSettings.brandColor.background
962
+ );
963
+ expect(result.launcherButtons.primary.backgroundColor.hover).toBe(
964
+ import_types2.defaultSettings.brandColor.autoHover
965
+ );
966
+ });
967
+ it("should handle partial settings with correct fallback chain", () => {
968
+ const partialSettings = {
969
+ mainColor: {
970
+ background: "#FF0000",
971
+ color: "#00FF00",
972
+ hover: "Auto",
973
+ active: "Auto",
974
+ autoHover: "#FF5555",
975
+ autoActive: "#FF9999"
976
+ }
977
+ };
978
+ const result = convertSettings(partialSettings);
979
+ expect(result.mainColor.background).toBe("#FF0000");
980
+ expect(result.mainColor.hover).toBe("#FF5555");
981
+ expect(result.mainColor.active).toBe("#FF9999");
982
+ expect(result.brandColor.background).toBe(import_types2.defaultSettings.brandColor.background);
983
+ expect(result.border.borderColor).not.toBe("Auto");
984
+ expect(result.border.borderColor).toMatch(/^#[0-9a-fA-F]{6}$/);
985
+ });
986
+ });
987
+ describe("convertToCssVars", () => {
988
+ it("should generate CSS variables string for complete settings", () => {
989
+ const convertedSettings = convertSettings(completeSettings);
990
+ const css = convertToCssVars(convertedSettings);
991
+ expect(css).toContain("--usertour-background:");
992
+ expect(css).toContain("--usertour-foreground:");
993
+ expect(css).toContain("--usertour-primary:");
994
+ expect(css).toContain("--usertour-secondary:");
995
+ expect(css).toContain("--usertour-font-family:");
996
+ });
997
+ it("should include button CSS variables", () => {
998
+ const convertedSettings = convertSettings(completeSettings);
999
+ const css = convertToCssVars(convertedSettings);
1000
+ expect(css).toContain("--usertour-primary-hover:");
1001
+ expect(css).toContain("--usertour-primary-active:");
1002
+ expect(css).toContain("--usertour-primary-foreground:");
1003
+ expect(css).toContain("--usertour-secondary-hover:");
1004
+ expect(css).toContain("--usertour-secondary-active:");
1005
+ expect(css).toContain("--usertour-secondary-foreground:");
1006
+ });
1007
+ it("should include backdrop CSS variables", () => {
1008
+ const convertedSettings = convertSettings(completeSettings);
1009
+ const css = convertToCssVars(convertedSettings);
1010
+ expect(css).toContain("--usertour-backdrop-color-rgb:");
1011
+ expect(css).toContain("--usertour-backdrop-opacity:");
1012
+ expect(css).toContain("--usertour-backdrop-highlight-opacity:");
1013
+ });
1014
+ it("should include progress bar CSS variables", () => {
1015
+ const convertedSettings = convertSettings(completeSettings);
1016
+ const css = convertToCssVars(convertedSettings);
1017
+ expect(css).toContain("--usertour-progress-bar-color:");
1018
+ expect(css).toContain("--usertour-progress-bar-height:");
1019
+ });
1020
+ it("should include checklist launcher CSS variables", () => {
1021
+ const convertedSettings = convertSettings(completeSettings);
1022
+ const css = convertToCssVars(convertedSettings);
1023
+ expect(css).toContain("--usertour-checklist-trigger-background-color:");
1024
+ expect(css).toContain("--usertour-checklist-trigger-font-color:");
1025
+ expect(css).toContain("--usertour-checklist-trigger-counter-background-color:");
1026
+ });
1027
+ it("should include launcher icon CSS variables", () => {
1028
+ const convertedSettings = convertSettings(completeSettings);
1029
+ const css = convertToCssVars(convertedSettings);
1030
+ expect(css).toContain("--usertour-widget-launcher-icon-color:");
1031
+ expect(css).toContain("--usertour-widget-launcher-icon-hover-color:");
1032
+ expect(css).toContain("--usertour-widget-beacon-color:");
1033
+ });
1034
+ it("should include launcher button CSS variables", () => {
1035
+ const convertedSettings = convertSettings(completeSettings);
1036
+ const css = convertToCssVars(convertedSettings);
1037
+ expect(css).toContain("--usertour-launcher-button-height:");
1038
+ expect(css).toContain("--usertour-launcher-button-width:");
1039
+ expect(css).toContain("--usertour-launcher-button-horizontal-padding:");
1040
+ expect(css).toContain("--usertour-launcher-button-border-radius:");
1041
+ expect(css).toContain("--usertour-launcher-button-background-color:");
1042
+ expect(css).toContain("--usertour-launcher-button-hover-background-color:");
1043
+ expect(css).toContain("--usertour-launcher-button-active-background-color:");
1044
+ expect(css).toContain("--usertour-launcher-button-font-color:");
1045
+ expect(css).toContain("--usertour-launcher-button-hover-font-color:");
1046
+ expect(css).toContain("--usertour-launcher-button-active-font-color:");
1047
+ expect(css).toContain("--usertour-launcher-button-font-weight:");
1048
+ expect(css).toContain("--usertour-launcher-button-border-width:");
1049
+ expect(css).toContain("--usertour-launcher-button-border-color:");
1050
+ expect(css).toContain("--usertour-launcher-button-hover-border-color:");
1051
+ expect(css).toContain("--usertour-launcher-button-active-border-color:");
1052
+ });
1053
+ it("should set launcher button width to auto when width is 0", () => {
1054
+ const convertedSettings = convertSettings(completeSettings);
1055
+ const css = convertToCssVars(convertedSettings);
1056
+ expect(css).toContain("--usertour-launcher-button-width:auto");
1057
+ });
1058
+ it("should set launcher button border width to 0px when border is disabled", () => {
1059
+ const convertedSettings = convertSettings(completeSettings);
1060
+ const css = convertToCssVars(convertedSettings);
1061
+ expect(css).toContain("--usertour-launcher-button-border-width:0px");
1062
+ });
1063
+ it("should add modal padding for modal type", () => {
1064
+ const convertedSettings = convertSettings(completeSettings);
1065
+ const css = convertToCssVars(convertedSettings, "modal");
1066
+ expect(css).toContain("--usertour-widget-popper-padding:");
1067
+ expect(css).toContain("40px");
1068
+ });
1069
+ it("should not add modal padding for tooltip type", () => {
1070
+ const convertedSettings = convertSettings(completeSettings);
1071
+ const css = convertToCssVars(convertedSettings, "tooltip");
1072
+ const modalPaddingMatch = css.match(/--usertour-widget-popper-padding:[^;]+;/);
1073
+ expect(modalPaddingMatch).toBeNull();
1074
+ });
1075
+ it("should add backdrop inset for inside highlight type", () => {
1076
+ const settings = {
1077
+ ...completeSettings,
1078
+ backdrop: {
1079
+ ...completeSettings.backdrop,
1080
+ highlight: {
1081
+ ...completeSettings.backdrop.highlight,
1082
+ type: "inside"
1083
+ }
1084
+ }
1085
+ };
1086
+ const convertedSettings = convertSettings(settings);
1087
+ const css = convertToCssVars(convertedSettings);
1088
+ expect(css).toContain("--usertour-backdrop-highlight-inset:inset");
1089
+ });
1090
+ it("should work correctly with defaultSettings fallback for empty input", () => {
1091
+ const convertedSettings = convertSettings({});
1092
+ const css = convertToCssVars(convertedSettings);
1093
+ expect(css).toContain("--usertour-background:");
1094
+ expect(css).toContain("--usertour-primary:");
1095
+ expect(css.length).toBeGreaterThan(0);
1096
+ });
1097
+ });
1098
+ describe("Edge cases and error handling", () => {
1099
+ it("should handle undefined values in nested objects gracefully", () => {
1100
+ const settings = {
1101
+ mainColor: {
1102
+ background: "#FFFFFF",
1103
+ color: "#000000"
1104
+ // hover, active, autoHover, autoActive are undefined
1105
+ },
1106
+ brandColor: {
1107
+ background: "#2563eb",
1108
+ color: "#ffffff"
1109
+ }
1110
+ };
1111
+ expect(() => convertSettings(settings)).not.toThrow();
1112
+ const result = convertSettings(settings);
1113
+ expect(result.mainColor).toBeDefined();
1114
+ });
1115
+ it("should handle partial settings without throwing", () => {
1116
+ const settings = {
1117
+ mainColor: completeSettings.mainColor,
1118
+ brandColor: completeSettings.brandColor
1119
+ // progress is missing, not null
1120
+ };
1121
+ expect(() => convertSettings(settings)).not.toThrow();
1122
+ const result = convertSettings(settings);
1123
+ expect(result.progress).toBeDefined();
1124
+ expect(result.progress.color).toBe(completeSettings.brandColor.background);
1125
+ });
1126
+ it("should preserve non-Auto values throughout the conversion", () => {
1127
+ const settings = {
1128
+ ...completeSettings,
1129
+ mainColor: {
1130
+ ...completeSettings.mainColor,
1131
+ hover: "#custom-hover",
1132
+ active: "#custom-active"
1133
+ },
1134
+ buttons: {
1135
+ ...completeSettings.buttons,
1136
+ primary: {
1137
+ ...completeSettings.buttons.primary,
1138
+ textColor: {
1139
+ ...completeSettings.buttons.primary.textColor,
1140
+ color: "#custom-text"
1141
+ }
1142
+ }
1143
+ }
1144
+ };
1145
+ const result = convertSettings(settings);
1146
+ expect(result.mainColor.hover).toBe("#custom-hover");
1147
+ expect(result.mainColor.active).toBe("#custom-active");
1148
+ expect(result.buttons.primary.textColor.color).toBe("#custom-text");
1149
+ });
1150
+ it("should handle deeply nested missing properties", () => {
1151
+ const settings = {
1152
+ brandColor: completeSettings.brandColor,
1153
+ buttons: {
1154
+ primary: {
1155
+ textColor: {
1156
+ // only color is provided as non-Auto value
1157
+ color: "#FF0000",
1158
+ hover: "Auto",
1159
+ active: "Auto",
1160
+ background: "#FFFFFF"
1161
+ }
1162
+ }
1163
+ }
1164
+ };
1165
+ const result = convertSettings(settings);
1166
+ expect(result.buttons.primary.textColor.color).toBe("#FF0000");
1167
+ expect(result.buttons.primary.textColor.hover).toBe(completeSettings.brandColor.color);
1168
+ expect(result.buttons.primary.backgroundColor).toBeDefined();
1169
+ });
1170
+ it("should fallback to defaultSettings when values are explicitly null", () => {
1171
+ const settings = {
1172
+ mainColor: {
1173
+ background: null,
1174
+ color: "#00FF00",
1175
+ hover: "Auto",
1176
+ active: "Auto",
1177
+ autoHover: null,
1178
+ autoActive: "#FF9999"
1179
+ },
1180
+ font: {
1181
+ fontSize: null,
1182
+ linkColor: "Auto"
1183
+ }
1184
+ };
1185
+ const result = convertSettings(settings);
1186
+ expect(result.mainColor.background).toBe(import_types2.defaultSettings.mainColor.background);
1187
+ expect(result.mainColor.autoHover).toBe(import_types2.defaultSettings.mainColor.autoHover);
1188
+ expect(result.font.fontSize).toBe(import_types2.defaultSettings.font.fontSize);
1189
+ expect(result.mainColor.color).toBe("#00FF00");
1190
+ expect(result.mainColor.autoActive).toBe("#FF9999");
1191
+ });
1192
+ it("should fallback to defaultSettings when values are explicitly undefined", () => {
1193
+ const settings = {
1194
+ mainColor: {
1195
+ background: void 0,
1196
+ color: "#00FF00",
1197
+ hover: "Auto",
1198
+ active: "Auto"
1199
+ },
1200
+ buttons: {
1201
+ height: void 0,
1202
+ borderRadius: 16
1203
+ }
1204
+ };
1205
+ const result = convertSettings(settings);
1206
+ expect(result.mainColor.background).toBe(import_types2.defaultSettings.mainColor.background);
1207
+ expect(result.buttons.height).toBe(import_types2.defaultSettings.buttons.height);
1208
+ expect(result.mainColor.color).toBe("#00FF00");
1209
+ expect(result.buttons.borderRadius).toBe(16);
1210
+ });
1211
+ it("should handle mixed null, undefined, and valid values correctly", () => {
1212
+ const settings = {
1213
+ mainColor: {
1214
+ background: null,
1215
+ color: void 0,
1216
+ hover: "Auto",
1217
+ active: "#custom-active",
1218
+ autoHover: "#custom-auto-hover",
1219
+ autoActive: null
1220
+ },
1221
+ progress: {
1222
+ enabled: true,
1223
+ color: null,
1224
+ height: void 0
1225
+ }
1226
+ };
1227
+ const result = convertSettings(settings);
1228
+ expect(result.mainColor.background).toBe(import_types2.defaultSettings.mainColor.background);
1229
+ expect(result.mainColor.color).toBe(import_types2.defaultSettings.mainColor.color);
1230
+ expect(result.mainColor.autoActive).toBe(import_types2.defaultSettings.mainColor.autoActive);
1231
+ expect(result.progress.height).toBe(import_types2.defaultSettings.progress.height);
1232
+ expect(result.mainColor.active).toBe("#custom-active");
1233
+ expect(result.mainColor.autoHover).toBe("#custom-auto-hover");
1234
+ expect(result.progress.enabled).toBe(true);
1235
+ expect(result.mainColor.hover).toBe("#custom-auto-hover");
1236
+ expect(result.progress.color).toBe(import_types2.defaultSettings.brandColor.background);
1237
+ });
1238
+ it("should NOT mutate defaultSettings when converting settings", () => {
1239
+ convertSettings({});
1240
+ convertSettings({});
1241
+ convertSettings({});
1242
+ expect(import_types2.defaultSettings.mainColor.hover).toBe(originalDefaultMainColorHover);
1243
+ expect(import_types2.defaultSettings.brandColor.hover).toBe(originalDefaultBrandColorHover);
1244
+ expect(import_types2.defaultSettings.mainColor.hover).toBe("Auto");
1245
+ expect(import_types2.defaultSettings.brandColor.hover).toBe("Auto");
1246
+ });
1247
+ it("should return independent objects on each call", () => {
1248
+ const result1 = convertSettings({});
1249
+ const result2 = convertSettings({});
1250
+ expect(result1).not.toBe(result2);
1251
+ expect(result1.mainColor).not.toBe(result2.mainColor);
1252
+ expect(result1.brandColor).not.toBe(result2.brandColor);
1253
+ result1.mainColor.color = "#MODIFIED";
1254
+ expect(result2.mainColor.color).not.toBe("#MODIFIED");
1255
+ });
1256
+ });
1257
+ });