@usertour/helpers 0.0.54 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/condition.test.cjs +2 -2
- package/dist/__tests__/condition.test.js +2 -2
- package/dist/__tests__/content-helper.test.cjs +2 -2
- package/dist/__tests__/content-helper.test.js +3 -3
- package/dist/{chunk-SIG4WTEF.js → chunk-5BEUHZSY.js} +1 -1
- package/dist/{chunk-3KG2HTZ3.js → chunk-7X2CUDBX.js} +3 -3
- package/dist/{chunk-XMAPBUWT.js → chunk-BKX55CAI.js} +0 -18
- package/dist/{chunk-2TMOS3DN.js → chunk-KARDMYE2.js} +2 -2
- package/dist/{chunk-G73OLXRF.js → chunk-UMC3BUA7.js} +1 -1
- package/dist/color.cjs +0 -19
- package/dist/color.d.cts +1 -17
- package/dist/color.d.ts +1 -17
- package/dist/color.js +1 -3
- package/dist/conditions/condition.cjs +2 -2
- package/dist/conditions/condition.js +2 -2
- package/dist/conditions/index.cjs +2 -2
- package/dist/conditions/index.js +2 -2
- package/dist/content-helper.cjs +2 -2
- package/dist/content-helper.js +3 -3
- package/dist/convert-settings.js +2 -2
- package/dist/helper.cjs +4 -4
- package/dist/helper.d.cts +8 -2
- package/dist/helper.d.ts +8 -2
- package/dist/helper.js +3 -3
- package/dist/index.cjs +4 -23
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -9
- package/package.json +1 -1
|
@@ -451,13 +451,13 @@ function hexToRgb(hex) {
|
|
|
451
451
|
b: Number.parseInt(result[3], 16)
|
|
452
452
|
} : null;
|
|
453
453
|
}
|
|
454
|
-
var
|
|
454
|
+
var isLight = (hex) => {
|
|
455
455
|
const rgb = hexToRgb(hex);
|
|
456
456
|
if (!rgb) {
|
|
457
457
|
return null;
|
|
458
458
|
}
|
|
459
459
|
const { r, g, b } = rgb;
|
|
460
|
-
if (r * 0.299 + g * 0.587 + b * 0.114 >
|
|
460
|
+
if (r * 0.299 + g * 0.587 + b * 0.114 > 250) {
|
|
461
461
|
return true;
|
|
462
462
|
}
|
|
463
463
|
return false;
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
evaluateRulesConditions,
|
|
3
3
|
filterConditionsByType,
|
|
4
4
|
isConditionsActived
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-5BEUHZSY.js";
|
|
6
6
|
import "../chunk-YYIGUZNZ.js";
|
|
7
7
|
import "../chunk-PAESAL23.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-7X2CUDBX.js";
|
|
9
9
|
import "../chunk-KYDXF7SU.js";
|
|
10
10
|
import "../chunk-JQWKLXW6.js";
|
|
11
11
|
import "../chunk-GFH3VWOC.js";
|
|
@@ -61,13 +61,13 @@ function hexToRgb(hex) {
|
|
|
61
61
|
b: Number.parseInt(result[3], 16)
|
|
62
62
|
} : null;
|
|
63
63
|
}
|
|
64
|
-
var
|
|
64
|
+
var isLight = (hex) => {
|
|
65
65
|
const rgb = hexToRgb(hex);
|
|
66
66
|
if (!rgb) {
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
69
|
const { r, g, b } = rgb;
|
|
70
|
-
if (r * 0.299 + g * 0.587 + b * 0.114 >
|
|
70
|
+
if (r * 0.299 + g * 0.587 + b * 0.114 > 250) {
|
|
71
71
|
return true;
|
|
72
72
|
}
|
|
73
73
|
return false;
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
isQuestionElement,
|
|
15
15
|
isRestrictedType,
|
|
16
16
|
processQuestionElements
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-KARDMYE2.js";
|
|
18
18
|
import "../chunk-7ODE2AIC.js";
|
|
19
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-5BEUHZSY.js";
|
|
20
20
|
import "../chunk-YYIGUZNZ.js";
|
|
21
21
|
import "../chunk-PAESAL23.js";
|
|
22
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-7X2CUDBX.js";
|
|
23
23
|
import "../chunk-KYDXF7SU.js";
|
|
24
24
|
import "../chunk-JQWKLXW6.js";
|
|
25
25
|
import "../chunk-GFH3VWOC.js";
|
|
@@ -31,13 +31,13 @@ function hexToRgb(hex) {
|
|
|
31
31
|
b: Number.parseInt(result[3], 16)
|
|
32
32
|
} : null;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var isLight = (hex) => {
|
|
35
35
|
const rgb = hexToRgb(hex);
|
|
36
36
|
if (!rgb) {
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
const { r, g, b } = rgb;
|
|
40
|
-
if (r * 0.299 + g * 0.587 + b * 0.114 >
|
|
40
|
+
if (r * 0.299 + g * 0.587 + b * 0.114 > 250) {
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
43
|
return false;
|
|
@@ -73,7 +73,7 @@ export {
|
|
|
73
73
|
absoluteUrl,
|
|
74
74
|
uuidV4,
|
|
75
75
|
hexToRgb,
|
|
76
|
-
|
|
76
|
+
isLight,
|
|
77
77
|
evalCode,
|
|
78
78
|
getRandomColor
|
|
79
79
|
};
|
|
@@ -23,23 +23,6 @@ var hexToRGBStr = (hex) => {
|
|
|
23
23
|
return "0, 0, 0";
|
|
24
24
|
}
|
|
25
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
26
|
function generateStateColors(baseColor, brandColor, options = {}) {
|
|
44
27
|
const {
|
|
45
28
|
brandHoverRatio = 0.175,
|
|
@@ -72,6 +55,5 @@ function generateStateColors(baseColor, brandColor, options = {}) {
|
|
|
72
55
|
export {
|
|
73
56
|
hexToHSLString,
|
|
74
57
|
hexToRGBStr,
|
|
75
|
-
generateAutoStateColors,
|
|
76
58
|
generateStateColors
|
|
77
59
|
};
|
package/dist/color.cjs
CHANGED
|
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/color.ts
|
|
31
31
|
var color_exports = {};
|
|
32
32
|
__export(color_exports, {
|
|
33
|
-
generateAutoStateColors: () => generateAutoStateColors,
|
|
34
33
|
generateStateColors: () => generateStateColors,
|
|
35
34
|
hexToHSLString: () => hexToHSLString,
|
|
36
35
|
hexToRGBStr: () => hexToRGBStr
|
|
@@ -60,23 +59,6 @@ var hexToRGBStr = (hex) => {
|
|
|
60
59
|
return "0, 0, 0";
|
|
61
60
|
}
|
|
62
61
|
};
|
|
63
|
-
function generateAutoStateColors(baseColor, brandColor, hoverRatio = 0.12, activeRatio = 0.24) {
|
|
64
|
-
const isBaseLight = (0, import_chroma_js.default)(baseColor).luminance() > 0.8;
|
|
65
|
-
const isBaseBrand = import_chroma_js.default.distance(baseColor, brandColor) < 10;
|
|
66
|
-
let hover;
|
|
67
|
-
let active;
|
|
68
|
-
if (isBaseBrand) {
|
|
69
|
-
hover = import_chroma_js.default.mix(baseColor, "#fff", hoverRatio, "rgb").hex();
|
|
70
|
-
active = import_chroma_js.default.mix(baseColor, "#fff", activeRatio, "rgb").hex();
|
|
71
|
-
} else if (isBaseLight) {
|
|
72
|
-
hover = import_chroma_js.default.mix(baseColor, brandColor, hoverRatio, "rgb").hex();
|
|
73
|
-
active = import_chroma_js.default.mix(baseColor, brandColor, activeRatio, "rgb").hex();
|
|
74
|
-
} else {
|
|
75
|
-
hover = import_chroma_js.default.mix(baseColor, brandColor, hoverRatio, "rgb").hex();
|
|
76
|
-
active = import_chroma_js.default.mix(baseColor, brandColor, activeRatio, "rgb").hex();
|
|
77
|
-
}
|
|
78
|
-
return { hover, active };
|
|
79
|
-
}
|
|
80
62
|
function generateStateColors(baseColor, brandColor, options = {}) {
|
|
81
63
|
const {
|
|
82
64
|
brandHoverRatio = 0.175,
|
|
@@ -107,7 +89,6 @@ function generateStateColors(baseColor, brandColor, options = {}) {
|
|
|
107
89
|
}
|
|
108
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
91
|
0 && (module.exports = {
|
|
110
|
-
generateAutoStateColors,
|
|
111
92
|
generateStateColors,
|
|
112
93
|
hexToHSLString,
|
|
113
94
|
hexToRGBStr
|
package/dist/color.d.cts
CHANGED
|
@@ -10,22 +10,6 @@ declare function hexToHSLString(hexColor: string): string;
|
|
|
10
10
|
* @returns RGB string format without alpha
|
|
11
11
|
*/
|
|
12
12
|
declare const hexToRGBStr: (hex: string) => string;
|
|
13
|
-
/**
|
|
14
|
-
* Automatically generate hover and active colors based on baseColor and brandColor.
|
|
15
|
-
* If baseColor is similar to brandColor, hover is mixed with white (LAB), active is darkened.
|
|
16
|
-
* If baseColor is light (e.g., white), hover/active are mixed with brandColor (LAB).
|
|
17
|
-
* Otherwise, hover is mixed with brandColor (LAB), active is darkened.
|
|
18
|
-
* @param baseColor - The base color (e.g., button or content background)
|
|
19
|
-
* @param brandColor - The brand color
|
|
20
|
-
* @param hoverRatio - Mix ratio for hover state (default 0.15)
|
|
21
|
-
* @param activeDarken - Darken factor for active state (default 0.12)
|
|
22
|
-
* @returns An object with hover and active color hex strings
|
|
23
|
-
* @deprecated Use generateStateColors instead
|
|
24
|
-
*/
|
|
25
|
-
declare function generateAutoStateColors(baseColor: string, brandColor: string, hoverRatio?: number, activeRatio?: number): {
|
|
26
|
-
hover: string;
|
|
27
|
-
active: string;
|
|
28
|
-
};
|
|
29
13
|
/**
|
|
30
14
|
* Configuration options for state color generation
|
|
31
15
|
*/
|
|
@@ -67,4 +51,4 @@ declare function generateStateColors(baseColor: string, brandColor: string, opti
|
|
|
67
51
|
active: string;
|
|
68
52
|
};
|
|
69
53
|
|
|
70
|
-
export { type StateColorOptions,
|
|
54
|
+
export { type StateColorOptions, generateStateColors, hexToHSLString, hexToRGBStr };
|
package/dist/color.d.ts
CHANGED
|
@@ -10,22 +10,6 @@ declare function hexToHSLString(hexColor: string): string;
|
|
|
10
10
|
* @returns RGB string format without alpha
|
|
11
11
|
*/
|
|
12
12
|
declare const hexToRGBStr: (hex: string) => string;
|
|
13
|
-
/**
|
|
14
|
-
* Automatically generate hover and active colors based on baseColor and brandColor.
|
|
15
|
-
* If baseColor is similar to brandColor, hover is mixed with white (LAB), active is darkened.
|
|
16
|
-
* If baseColor is light (e.g., white), hover/active are mixed with brandColor (LAB).
|
|
17
|
-
* Otherwise, hover is mixed with brandColor (LAB), active is darkened.
|
|
18
|
-
* @param baseColor - The base color (e.g., button or content background)
|
|
19
|
-
* @param brandColor - The brand color
|
|
20
|
-
* @param hoverRatio - Mix ratio for hover state (default 0.15)
|
|
21
|
-
* @param activeDarken - Darken factor for active state (default 0.12)
|
|
22
|
-
* @returns An object with hover and active color hex strings
|
|
23
|
-
* @deprecated Use generateStateColors instead
|
|
24
|
-
*/
|
|
25
|
-
declare function generateAutoStateColors(baseColor: string, brandColor: string, hoverRatio?: number, activeRatio?: number): {
|
|
26
|
-
hover: string;
|
|
27
|
-
active: string;
|
|
28
|
-
};
|
|
29
13
|
/**
|
|
30
14
|
* Configuration options for state color generation
|
|
31
15
|
*/
|
|
@@ -67,4 +51,4 @@ declare function generateStateColors(baseColor: string, brandColor: string, opti
|
|
|
67
51
|
active: string;
|
|
68
52
|
};
|
|
69
53
|
|
|
70
|
-
export { type StateColorOptions,
|
|
54
|
+
export { type StateColorOptions, generateStateColors, hexToHSLString, hexToRGBStr };
|
package/dist/color.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
generateAutoStateColors,
|
|
3
2
|
generateStateColors,
|
|
4
3
|
hexToHSLString,
|
|
5
4
|
hexToRGBStr
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BKX55CAI.js";
|
|
7
6
|
import "./chunk-XEO3YXBM.js";
|
|
8
7
|
export {
|
|
9
|
-
generateAutoStateColors,
|
|
10
8
|
generateStateColors,
|
|
11
9
|
hexToHSLString,
|
|
12
10
|
hexToRGBStr
|
|
@@ -466,13 +466,13 @@ function hexToRgb(hex) {
|
|
|
466
466
|
b: Number.parseInt(result[3], 16)
|
|
467
467
|
} : null;
|
|
468
468
|
}
|
|
469
|
-
var
|
|
469
|
+
var isLight = (hex) => {
|
|
470
470
|
const rgb = hexToRgb(hex);
|
|
471
471
|
if (!rgb) {
|
|
472
472
|
return null;
|
|
473
473
|
}
|
|
474
474
|
const { r, g, b } = rgb;
|
|
475
|
-
if (r * 0.299 + g * 0.587 + b * 0.114 >
|
|
475
|
+
if (r * 0.299 + g * 0.587 + b * 0.114 > 250) {
|
|
476
476
|
return true;
|
|
477
477
|
}
|
|
478
478
|
return false;
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
isConditionsActived,
|
|
9
9
|
isEqual,
|
|
10
10
|
regenerateConditionIds
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-5BEUHZSY.js";
|
|
12
12
|
import "../chunk-YYIGUZNZ.js";
|
|
13
13
|
import "../chunk-PAESAL23.js";
|
|
14
|
-
import "../chunk-
|
|
14
|
+
import "../chunk-7X2CUDBX.js";
|
|
15
15
|
import "../chunk-KYDXF7SU.js";
|
|
16
16
|
import "../chunk-JQWKLXW6.js";
|
|
17
17
|
import "../chunk-GFH3VWOC.js";
|
|
@@ -511,13 +511,13 @@ function hexToRgb(hex) {
|
|
|
511
511
|
b: Number.parseInt(result[3], 16)
|
|
512
512
|
} : null;
|
|
513
513
|
}
|
|
514
|
-
var
|
|
514
|
+
var isLight = (hex) => {
|
|
515
515
|
const rgb = hexToRgb(hex);
|
|
516
516
|
if (!rgb) {
|
|
517
517
|
return null;
|
|
518
518
|
}
|
|
519
519
|
const { r, g, b } = rgb;
|
|
520
|
-
if (r * 0.299 + g * 0.587 + b * 0.114 >
|
|
520
|
+
if (r * 0.299 + g * 0.587 + b * 0.114 > 250) {
|
|
521
521
|
return true;
|
|
522
522
|
}
|
|
523
523
|
return false;
|
package/dist/conditions/index.js
CHANGED
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
isConditionsActived,
|
|
10
10
|
isEqual,
|
|
11
11
|
regenerateConditionIds
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-5BEUHZSY.js";
|
|
13
13
|
import {
|
|
14
14
|
evaluateUrlCondition,
|
|
15
15
|
isMatchUrlPattern
|
|
16
16
|
} from "../chunk-YYIGUZNZ.js";
|
|
17
17
|
import "../chunk-PAESAL23.js";
|
|
18
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-7X2CUDBX.js";
|
|
19
19
|
import {
|
|
20
20
|
evaluateAttributeCondition
|
|
21
21
|
} from "../chunk-KYDXF7SU.js";
|
package/dist/content-helper.cjs
CHANGED
|
@@ -82,13 +82,13 @@ function hexToRgb(hex) {
|
|
|
82
82
|
b: Number.parseInt(result[3], 16)
|
|
83
83
|
} : null;
|
|
84
84
|
}
|
|
85
|
-
var
|
|
85
|
+
var isLight = (hex) => {
|
|
86
86
|
const rgb = hexToRgb(hex);
|
|
87
87
|
if (!rgb) {
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
90
|
const { r, g, b } = rgb;
|
|
91
|
-
if (r * 0.299 + g * 0.587 + b * 0.114 >
|
|
91
|
+
if (r * 0.299 + g * 0.587 + b * 0.114 > 250) {
|
|
92
92
|
return true;
|
|
93
93
|
}
|
|
94
94
|
return false;
|
package/dist/content-helper.js
CHANGED
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
isQuestionElement,
|
|
15
15
|
isRestrictedType,
|
|
16
16
|
processQuestionElements
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-KARDMYE2.js";
|
|
18
18
|
import "./chunk-7ODE2AIC.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-5BEUHZSY.js";
|
|
20
20
|
import "./chunk-YYIGUZNZ.js";
|
|
21
21
|
import "./chunk-PAESAL23.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-7X2CUDBX.js";
|
|
23
23
|
import "./chunk-KYDXF7SU.js";
|
|
24
24
|
import "./chunk-JQWKLXW6.js";
|
|
25
25
|
import "./chunk-GFH3VWOC.js";
|
package/dist/convert-settings.js
CHANGED
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
convertSettings,
|
|
3
3
|
convertToCssVars,
|
|
4
4
|
mergeThemeDefaultSettings
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-UMC3BUA7.js";
|
|
6
|
+
import "./chunk-BKX55CAI.js";
|
|
7
7
|
import "./chunk-GFH3VWOC.js";
|
|
8
8
|
import "./chunk-XEO3YXBM.js";
|
|
9
9
|
export {
|
package/dist/helper.cjs
CHANGED
|
@@ -27,7 +27,7 @@ __export(helper_exports, {
|
|
|
27
27
|
formatDate: () => formatDate,
|
|
28
28
|
getRandomColor: () => getRandomColor,
|
|
29
29
|
hexToRgb: () => hexToRgb,
|
|
30
|
-
|
|
30
|
+
isLight: () => isLight,
|
|
31
31
|
uuidV4: () => uuidV4
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(helper_exports);
|
|
@@ -63,13 +63,13 @@ function hexToRgb(hex) {
|
|
|
63
63
|
b: Number.parseInt(result[3], 16)
|
|
64
64
|
} : null;
|
|
65
65
|
}
|
|
66
|
-
var
|
|
66
|
+
var isLight = (hex) => {
|
|
67
67
|
const rgb = hexToRgb(hex);
|
|
68
68
|
if (!rgb) {
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
71
|
const { r, g, b } = rgb;
|
|
72
|
-
if (r * 0.299 + g * 0.587 + b * 0.114 >
|
|
72
|
+
if (r * 0.299 + g * 0.587 + b * 0.114 > 250) {
|
|
73
73
|
return true;
|
|
74
74
|
}
|
|
75
75
|
return false;
|
|
@@ -106,6 +106,6 @@ var getRandomColor = () => {
|
|
|
106
106
|
formatDate,
|
|
107
107
|
getRandomColor,
|
|
108
108
|
hexToRgb,
|
|
109
|
-
|
|
109
|
+
isLight,
|
|
110
110
|
uuidV4
|
|
111
111
|
});
|
package/dist/helper.d.cts
CHANGED
|
@@ -10,8 +10,14 @@ declare function hexToRgb(hex: string): {
|
|
|
10
10
|
g: number;
|
|
11
11
|
b: number;
|
|
12
12
|
} | null;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Check if a color is light (needs dark text).
|
|
15
|
+
* Only very light colors (close to white) return true.
|
|
16
|
+
* @param hex - Hex color string
|
|
17
|
+
* @returns true if the color is very light (luminance > 250), false otherwise
|
|
18
|
+
*/
|
|
19
|
+
declare const isLight: (hex: string) => boolean | null;
|
|
14
20
|
declare const evalCode: (code: string) => any;
|
|
15
21
|
declare const getRandomColor: () => string;
|
|
16
22
|
|
|
17
|
-
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb,
|
|
23
|
+
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isLight, uuidV4 };
|
package/dist/helper.d.ts
CHANGED
|
@@ -10,8 +10,14 @@ declare function hexToRgb(hex: string): {
|
|
|
10
10
|
g: number;
|
|
11
11
|
b: number;
|
|
12
12
|
} | null;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Check if a color is light (needs dark text).
|
|
15
|
+
* Only very light colors (close to white) return true.
|
|
16
|
+
* @param hex - Hex color string
|
|
17
|
+
* @returns true if the color is very light (luminance > 250), false otherwise
|
|
18
|
+
*/
|
|
19
|
+
declare const isLight: (hex: string) => boolean | null;
|
|
14
20
|
declare const evalCode: (code: string) => any;
|
|
15
21
|
declare const getRandomColor: () => string;
|
|
16
22
|
|
|
17
|
-
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb,
|
|
23
|
+
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isLight, uuidV4 };
|
package/dist/helper.js
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
formatDate,
|
|
7
7
|
getRandomColor,
|
|
8
8
|
hexToRgb,
|
|
9
|
-
|
|
9
|
+
isLight,
|
|
10
10
|
uuidV4
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7X2CUDBX.js";
|
|
12
12
|
import "./chunk-XEO3YXBM.js";
|
|
13
13
|
export {
|
|
14
14
|
absoluteUrl,
|
|
@@ -18,6 +18,6 @@ export {
|
|
|
18
18
|
formatDate,
|
|
19
19
|
getRandomColor,
|
|
20
20
|
hexToRgb,
|
|
21
|
-
|
|
21
|
+
isLight,
|
|
22
22
|
uuidV4
|
|
23
23
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -73,7 +73,6 @@ __export(src_exports, {
|
|
|
73
73
|
filterConditionsByType: () => filterConditionsByType,
|
|
74
74
|
filterNullAttributes: () => filterNullAttributes,
|
|
75
75
|
formatDate: () => formatDate,
|
|
76
|
-
generateAutoStateColors: () => generateAutoStateColors,
|
|
77
76
|
generateStateColors: () => generateStateColors,
|
|
78
77
|
generateUniqueCopyName: () => generateUniqueCopyName,
|
|
79
78
|
getAttributeType: () => getAttributeType,
|
|
@@ -102,7 +101,6 @@ __export(src_exports, {
|
|
|
102
101
|
isBoolean: () => isBoolean,
|
|
103
102
|
isClickableElement: () => isClickableElement,
|
|
104
103
|
isConditionsActived: () => isConditionsActived,
|
|
105
|
-
isDark: () => isDark,
|
|
106
104
|
isDate: () => isDate,
|
|
107
105
|
isDocument: () => isDocument,
|
|
108
106
|
isEmptyObject: () => isEmptyObject,
|
|
@@ -111,6 +109,7 @@ __export(src_exports, {
|
|
|
111
109
|
isFile: () => isFile,
|
|
112
110
|
isFormData: () => isFormData,
|
|
113
111
|
isFunction: () => isFunction,
|
|
112
|
+
isLight: () => isLight,
|
|
114
113
|
isMatchUrlPattern: () => isMatchUrlPattern,
|
|
115
114
|
isMissingRequiredData: () => isMissingRequiredData,
|
|
116
115
|
isNull: () => isNull,
|
|
@@ -177,23 +176,6 @@ var hexToRGBStr = (hex) => {
|
|
|
177
176
|
return "0, 0, 0";
|
|
178
177
|
}
|
|
179
178
|
};
|
|
180
|
-
function generateAutoStateColors(baseColor, brandColor, hoverRatio = 0.12, activeRatio = 0.24) {
|
|
181
|
-
const isBaseLight = (0, import_chroma_js.default)(baseColor).luminance() > 0.8;
|
|
182
|
-
const isBaseBrand = import_chroma_js.default.distance(baseColor, brandColor) < 10;
|
|
183
|
-
let hover;
|
|
184
|
-
let active;
|
|
185
|
-
if (isBaseBrand) {
|
|
186
|
-
hover = import_chroma_js.default.mix(baseColor, "#fff", hoverRatio, "rgb").hex();
|
|
187
|
-
active = import_chroma_js.default.mix(baseColor, "#fff", activeRatio, "rgb").hex();
|
|
188
|
-
} else if (isBaseLight) {
|
|
189
|
-
hover = import_chroma_js.default.mix(baseColor, brandColor, hoverRatio, "rgb").hex();
|
|
190
|
-
active = import_chroma_js.default.mix(baseColor, brandColor, activeRatio, "rgb").hex();
|
|
191
|
-
} else {
|
|
192
|
-
hover = import_chroma_js.default.mix(baseColor, brandColor, hoverRatio, "rgb").hex();
|
|
193
|
-
active = import_chroma_js.default.mix(baseColor, brandColor, activeRatio, "rgb").hex();
|
|
194
|
-
}
|
|
195
|
-
return { hover, active };
|
|
196
|
-
}
|
|
197
179
|
function generateStateColors(baseColor, brandColor, options = {}) {
|
|
198
180
|
const {
|
|
199
181
|
brandHoverRatio = 0.175,
|
|
@@ -1258,13 +1240,13 @@ function hexToRgb(hex) {
|
|
|
1258
1240
|
b: Number.parseInt(result[3], 16)
|
|
1259
1241
|
} : null;
|
|
1260
1242
|
}
|
|
1261
|
-
var
|
|
1243
|
+
var isLight = (hex) => {
|
|
1262
1244
|
const rgb = hexToRgb(hex);
|
|
1263
1245
|
if (!rgb) {
|
|
1264
1246
|
return null;
|
|
1265
1247
|
}
|
|
1266
1248
|
const { r, g, b } = rgb;
|
|
1267
|
-
if (r * 0.299 + g * 0.587 + b * 0.114 >
|
|
1249
|
+
if (r * 0.299 + g * 0.587 + b * 0.114 > 250) {
|
|
1268
1250
|
return true;
|
|
1269
1251
|
}
|
|
1270
1252
|
return false;
|
|
@@ -1979,7 +1961,6 @@ var duplicateStep = (step) => {
|
|
|
1979
1961
|
filterConditionsByType,
|
|
1980
1962
|
filterNullAttributes,
|
|
1981
1963
|
formatDate,
|
|
1982
|
-
generateAutoStateColors,
|
|
1983
1964
|
generateStateColors,
|
|
1984
1965
|
generateUniqueCopyName,
|
|
1985
1966
|
getAttributeType,
|
|
@@ -2008,7 +1989,6 @@ var duplicateStep = (step) => {
|
|
|
2008
1989
|
isBoolean,
|
|
2009
1990
|
isClickableElement,
|
|
2010
1991
|
isConditionsActived,
|
|
2011
|
-
isDark,
|
|
2012
1992
|
isDate,
|
|
2013
1993
|
isDocument,
|
|
2014
1994
|
isEmptyObject,
|
|
@@ -2017,6 +1997,7 @@ var duplicateStep = (step) => {
|
|
|
2017
1997
|
isFile,
|
|
2018
1998
|
isFormData,
|
|
2019
1999
|
isFunction,
|
|
2000
|
+
isLight,
|
|
2020
2001
|
isMatchUrlPattern,
|
|
2021
2002
|
isMissingRequiredData,
|
|
2022
2003
|
isNull,
|
package/dist/index.d.cts
CHANGED
|
@@ -7,8 +7,8 @@ export { isUrl } from './is-url.cjs';
|
|
|
7
7
|
export { AbortController, ArrayProto, XMLHttpRequest, assignableWindow, document, fetch, location, nativeForEach, nativeIndexOf, navigator, userAgent, window } from './globals.cjs';
|
|
8
8
|
export { buildConfig, defaultContentConfig, extractLinkUrl, isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments, replaceUserAttr } from './content.cjs';
|
|
9
9
|
export { deepClone, parseUrlParams, wait } from './utils.cjs';
|
|
10
|
-
export { StateColorOptions,
|
|
11
|
-
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb,
|
|
10
|
+
export { StateColorOptions, generateStateColors, hexToHSLString, hexToRGBStr } from './color.cjs';
|
|
11
|
+
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isLight, uuidV4 } from './helper.cjs';
|
|
12
12
|
export { allConditionsHaveIds, assignConditionIds, conditionsIsSame, evaluateRule, evaluateRulesConditions, filterConditionsByType, isConditionsActived, regenerateConditionIds } from './conditions/condition.cjs';
|
|
13
13
|
export { evaluateUrlCondition, isMatchUrlPattern } from './conditions/url.cjs';
|
|
14
14
|
export { convertTimeConditionLegacyToV2, evaluateTimeCondition, isTimeConditionDataLegacy, isTimeConditionDataV2, normalizeTimeConditionData } from './conditions/time.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export { isUrl } from './is-url.js';
|
|
|
7
7
|
export { AbortController, ArrayProto, XMLHttpRequest, assignableWindow, document, fetch, location, nativeForEach, nativeIndexOf, navigator, userAgent, window } from './globals.js';
|
|
8
8
|
export { buildConfig, defaultContentConfig, extractLinkUrl, isPublishedAtLeastOneEnvironment, isPublishedInAllEnvironments, replaceUserAttr } from './content.js';
|
|
9
9
|
export { deepClone, parseUrlParams, wait } from './utils.js';
|
|
10
|
-
export { StateColorOptions,
|
|
11
|
-
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb,
|
|
10
|
+
export { StateColorOptions, generateStateColors, hexToHSLString, hexToRGBStr } from './color.js';
|
|
11
|
+
export { absoluteUrl, cn, cuid, evalCode, formatDate, getRandomColor, hexToRgb, isLight, uuidV4 } from './helper.js';
|
|
12
12
|
export { allConditionsHaveIds, assignConditionIds, conditionsIsSame, evaluateRule, evaluateRulesConditions, filterConditionsByType, isConditionsActived, regenerateConditionIds } from './conditions/condition.js';
|
|
13
13
|
export { evaluateUrlCondition, isMatchUrlPattern } from './conditions/url.js';
|
|
14
14
|
export { convertTimeConditionLegacyToV2, evaluateTimeCondition, isTimeConditionDataLegacy, isTimeConditionDataV2, normalizeTimeConditionData } from './conditions/time.js';
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
isQuestionElement,
|
|
39
39
|
isRestrictedType,
|
|
40
40
|
processQuestionElements
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-KARDMYE2.js";
|
|
42
42
|
import "./chunk-7ODE2AIC.js";
|
|
43
43
|
import {
|
|
44
44
|
allConditionsHaveIds,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
isConditionsActived,
|
|
51
51
|
isEqual,
|
|
52
52
|
regenerateConditionIds
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-5BEUHZSY.js";
|
|
54
54
|
import {
|
|
55
55
|
evaluateUrlCondition,
|
|
56
56
|
isMatchUrlPattern
|
|
@@ -64,9 +64,9 @@ import {
|
|
|
64
64
|
formatDate,
|
|
65
65
|
getRandomColor,
|
|
66
66
|
hexToRgb,
|
|
67
|
-
|
|
67
|
+
isLight,
|
|
68
68
|
uuidV4
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-7X2CUDBX.js";
|
|
70
70
|
import {
|
|
71
71
|
evaluateAttributeCondition
|
|
72
72
|
} from "./chunk-KYDXF7SU.js";
|
|
@@ -82,13 +82,12 @@ import {
|
|
|
82
82
|
convertSettings,
|
|
83
83
|
convertToCssVars,
|
|
84
84
|
mergeThemeDefaultSettings
|
|
85
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-UMC3BUA7.js";
|
|
86
86
|
import {
|
|
87
|
-
generateAutoStateColors,
|
|
88
87
|
generateStateColors,
|
|
89
88
|
hexToHSLString,
|
|
90
89
|
hexToRGBStr
|
|
91
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-BKX55CAI.js";
|
|
92
91
|
import {
|
|
93
92
|
getCodeError,
|
|
94
93
|
getContentError,
|
|
@@ -186,7 +185,6 @@ export {
|
|
|
186
185
|
filterConditionsByType,
|
|
187
186
|
filterNullAttributes,
|
|
188
187
|
formatDate,
|
|
189
|
-
generateAutoStateColors,
|
|
190
188
|
generateStateColors,
|
|
191
189
|
generateUniqueCopyName,
|
|
192
190
|
getAttributeType,
|
|
@@ -215,7 +213,6 @@ export {
|
|
|
215
213
|
isBoolean,
|
|
216
214
|
isClickableElement,
|
|
217
215
|
isConditionsActived,
|
|
218
|
-
isDark,
|
|
219
216
|
isDate,
|
|
220
217
|
isDocument,
|
|
221
218
|
isEmptyObject,
|
|
@@ -224,6 +221,7 @@ export {
|
|
|
224
221
|
isFile,
|
|
225
222
|
isFormData,
|
|
226
223
|
isFunction,
|
|
224
|
+
isLight,
|
|
227
225
|
isMatchUrlPattern,
|
|
228
226
|
isMissingRequiredData,
|
|
229
227
|
isNull,
|