@getflip/swirl-components 0.114.0 → 0.115.0
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/components.json +18 -18
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-theme-provider.cjs.entry.js +42 -285
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/swirl-theme-provider/swirl-theme-provider.js +72 -99
- package/dist/collection/components/swirl-theme-provider/swirl-theme-provider.spec.js +67 -18
- package/dist/collection/components/swirl-theme-provider/swirl-theme-provider.stories.js +371 -17
- package/dist/collection/components/swirl-theme-provider/swirl-theme-provider.types.js +1 -0
- package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
- package/dist/components/swirl-theme-provider.js +46 -289
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-theme-provider.entry.js +42 -285
- package/dist/swirl-components/p-bceafa56.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-theme-provider/swirl-theme-provider.d.ts +15 -34
- package/dist/types/components/swirl-theme-provider/swirl-theme-provider.types.d.ts +45 -0
- package/dist/types/components.d.ts +11 -11
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/swirl-components/p-1a4c6557.entry.js +0 -1
- package/dist/typings.d.ts +0 -1
|
@@ -1,247 +1,14 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* A simple guard function:
|
|
5
|
-
*
|
|
6
|
-
* ```js
|
|
7
|
-
* Math.min(Math.max(low, value), high)
|
|
8
|
-
* ```
|
|
9
|
-
*/
|
|
10
|
-
function guard(low, high, value) {
|
|
11
|
-
return Math.min(Math.max(low, value), high);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class ColorError extends Error {
|
|
15
|
-
constructor(color) {
|
|
16
|
-
super(`Failed to parse color: "${color}"`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var ColorError$1 = ColorError;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Parses a color into red, gree, blue, alpha parts
|
|
25
|
-
*
|
|
26
|
-
* @param color the input color. Can be a RGB, RBGA, HSL, HSLA, or named color
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
function parseToRgba(color) {
|
|
30
|
-
if (typeof color !== 'string') throw new ColorError$1(color);
|
|
31
|
-
if (color.trim().toLowerCase() === 'transparent') return [0, 0, 0, 0];
|
|
32
|
-
let normalizedColor = color.trim();
|
|
33
|
-
normalizedColor = namedColorRegex.test(color) ? nameToHex(color) : color;
|
|
34
|
-
const reducedHexMatch = reducedHexRegex.exec(normalizedColor);
|
|
35
|
-
|
|
36
|
-
if (reducedHexMatch) {
|
|
37
|
-
const arr = Array.from(reducedHexMatch).slice(1);
|
|
38
|
-
return [...arr.slice(0, 3).map(x => parseInt(r(x, 2), 16)), parseInt(r(arr[3] || 'f', 2), 16) / 255];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const hexMatch = hexRegex.exec(normalizedColor);
|
|
42
|
-
|
|
43
|
-
if (hexMatch) {
|
|
44
|
-
const arr = Array.from(hexMatch).slice(1);
|
|
45
|
-
return [...arr.slice(0, 3).map(x => parseInt(x, 16)), parseInt(arr[3] || 'ff', 16) / 255];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const rgbaMatch = rgbaRegex.exec(normalizedColor);
|
|
49
|
-
|
|
50
|
-
if (rgbaMatch) {
|
|
51
|
-
const arr = Array.from(rgbaMatch).slice(1);
|
|
52
|
-
return [...arr.slice(0, 3).map(x => parseInt(x, 10)), parseFloat(arr[3] || '1')];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const hslaMatch = hslaRegex.exec(normalizedColor);
|
|
56
|
-
|
|
57
|
-
if (hslaMatch) {
|
|
58
|
-
const [h, s, l, a] = Array.from(hslaMatch).slice(1).map(parseFloat);
|
|
59
|
-
if (guard(0, 100, s) !== s) throw new ColorError$1(color);
|
|
60
|
-
if (guard(0, 100, l) !== l) throw new ColorError$1(color);
|
|
61
|
-
return [...hslToRgb(h, s, l), a || 1];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
throw new ColorError$1(color);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function hash(str) {
|
|
68
|
-
let hash = 5381;
|
|
69
|
-
let i = str.length;
|
|
70
|
-
|
|
71
|
-
while (i) {
|
|
72
|
-
hash = hash * 33 ^ str.charCodeAt(--i);
|
|
73
|
-
}
|
|
74
|
-
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
|
|
75
|
-
* integers. Since we want the results to be always positive, convert the
|
|
76
|
-
* signed int to an unsigned by doing an unsigned bitshift. */
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return (hash >>> 0) % 2341;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const colorToInt = x => parseInt(x.replace(/_/g, ''), 36);
|
|
83
|
-
|
|
84
|
-
const compressedColorMap = '1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm'.split(' ').reduce((acc, next) => {
|
|
85
|
-
const key = colorToInt(next.substring(0, 3));
|
|
86
|
-
const hex = colorToInt(next.substring(3)).toString(16); // NOTE: padStart could be used here but it breaks Node 6 compat
|
|
87
|
-
// https://github.com/ricokahler/color2k/issues/351
|
|
88
|
-
|
|
89
|
-
let prefix = '';
|
|
90
|
-
|
|
91
|
-
for (let i = 0; i < 6 - hex.length; i++) {
|
|
92
|
-
prefix += '0';
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
acc[key] = `${prefix}${hex}`;
|
|
96
|
-
return acc;
|
|
97
|
-
}, {});
|
|
98
|
-
/**
|
|
99
|
-
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
function nameToHex(color) {
|
|
103
|
-
const normalizedColorName = color.toLowerCase().trim();
|
|
104
|
-
const result = compressedColorMap[hash(normalizedColorName)];
|
|
105
|
-
if (!result) throw new ColorError$1(color);
|
|
106
|
-
return `#${result}`;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const r = (str, amount) => Array.from(Array(amount)).map(() => str).join('');
|
|
110
|
-
|
|
111
|
-
const reducedHexRegex = new RegExp(`^#${r('([a-f0-9])', 3)}([a-f0-9])?$`, 'i');
|
|
112
|
-
const hexRegex = new RegExp(`^#${r('([a-f0-9]{2})', 3)}([a-f0-9]{2})?$`, 'i');
|
|
113
|
-
const rgbaRegex = new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${r(',\\s*(\\d+)\\s*', 2)}(?:,\\s*([\\d.]+))?\\s*\\)$`, 'i');
|
|
114
|
-
const hslaRegex = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i;
|
|
115
|
-
const namedColorRegex = /^[a-z]+$/i;
|
|
116
|
-
|
|
117
|
-
const roundColor = color => {
|
|
118
|
-
return Math.round(color * 255);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const hslToRgb = (hue, saturation, lightness) => {
|
|
122
|
-
let l = lightness / 100;
|
|
123
|
-
|
|
124
|
-
if (saturation === 0) {
|
|
125
|
-
// achromatic
|
|
126
|
-
return [l, l, l].map(roundColor);
|
|
127
|
-
} // formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const huePrime = (hue % 360 + 360) % 360 / 60;
|
|
131
|
-
const chroma = (1 - Math.abs(2 * l - 1)) * (saturation / 100);
|
|
132
|
-
const secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
133
|
-
let red = 0;
|
|
134
|
-
let green = 0;
|
|
135
|
-
let blue = 0;
|
|
136
|
-
|
|
137
|
-
if (huePrime >= 0 && huePrime < 1) {
|
|
138
|
-
red = chroma;
|
|
139
|
-
green = secondComponent;
|
|
140
|
-
} else if (huePrime >= 1 && huePrime < 2) {
|
|
141
|
-
red = secondComponent;
|
|
142
|
-
green = chroma;
|
|
143
|
-
} else if (huePrime >= 2 && huePrime < 3) {
|
|
144
|
-
green = chroma;
|
|
145
|
-
blue = secondComponent;
|
|
146
|
-
} else if (huePrime >= 3 && huePrime < 4) {
|
|
147
|
-
green = secondComponent;
|
|
148
|
-
blue = chroma;
|
|
149
|
-
} else if (huePrime >= 4 && huePrime < 5) {
|
|
150
|
-
red = secondComponent;
|
|
151
|
-
blue = chroma;
|
|
152
|
-
} else if (huePrime >= 5 && huePrime < 6) {
|
|
153
|
-
red = chroma;
|
|
154
|
-
blue = secondComponent;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const lightnessModification = l - chroma / 2;
|
|
158
|
-
const finalRed = red + lightnessModification;
|
|
159
|
-
const finalGreen = green + lightnessModification;
|
|
160
|
-
const finalBlue = blue + lightnessModification;
|
|
161
|
-
return [finalRed, finalGreen, finalBlue].map(roundColor);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// taken from:
|
|
165
|
-
/**
|
|
166
|
-
* Parses a color in hue, saturation, lightness, and the alpha channel.
|
|
167
|
-
*
|
|
168
|
-
* Hue is a number between 0 and 360, saturation, lightness, and alpha are
|
|
169
|
-
* decimal percentages between 0 and 1
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
function parseToHsla(color) {
|
|
173
|
-
const [red, green, blue, alpha] = parseToRgba(color).map((value, index) => // 3rd index is alpha channel which is already normalized
|
|
174
|
-
index === 3 ? value : value / 255);
|
|
175
|
-
const max = Math.max(red, green, blue);
|
|
176
|
-
const min = Math.min(red, green, blue);
|
|
177
|
-
const lightness = (max + min) / 2; // achromatic
|
|
178
|
-
|
|
179
|
-
if (max === min) return [0, 0, lightness, alpha];
|
|
180
|
-
const delta = max - min;
|
|
181
|
-
const saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
182
|
-
const hue = 60 * (red === max ? (green - blue) / delta + (green < blue ? 6 : 0) : green === max ? (blue - red) / delta + 2 : (red - green) / delta + 4);
|
|
183
|
-
return [hue, saturation, lightness, alpha];
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Takes in hsla parts and constructs an hsla string
|
|
188
|
-
*
|
|
189
|
-
* @param hue The color circle (from 0 to 360) - 0 (or 360) is red, 120 is green, 240 is blue
|
|
190
|
-
* @param saturation Percentage of saturation, given as a decimal between 0 and 1
|
|
191
|
-
* @param lightness Percentage of lightness, given as a decimal between 0 and 1
|
|
192
|
-
* @param alpha Percentage of opacity, given as a decimal between 0 and 1
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
function hsla(hue, saturation, lightness, alpha) {
|
|
196
|
-
return `hsla(${(hue % 360).toFixed()}, ${guard(0, 100, saturation * 100).toFixed()}%, ${guard(0, 100, lightness * 100).toFixed()}%, ${parseFloat(guard(0, 1, alpha).toFixed(3))})`;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Takes in rgba parts and returns an rgba string
|
|
201
|
-
*
|
|
202
|
-
* @param red The amount of red in the red channel, given in a number between 0 and 255 inclusive
|
|
203
|
-
* @param green The amount of green in the red channel, given in a number between 0 and 255 inclusive
|
|
204
|
-
* @param blue The amount of blue in the red channel, given in a number between 0 and 255 inclusive
|
|
205
|
-
* @param alpha Percentage of opacity, given as a decimal between 0 and 1
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
function rgba(red, green, blue, alpha) {
|
|
209
|
-
return `rgba(${guard(0, 255, red).toFixed()}, ${guard(0, 255, green).toFixed()}, ${guard(0, 255, blue).toFixed()}, ${parseFloat(guard(0, 1, alpha).toFixed(3))})`;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Takes in any color and returns it as an rgba string.
|
|
214
|
-
*/
|
|
215
|
-
|
|
216
|
-
function toRgba(color) {
|
|
217
|
-
return rgba(...parseToRgba(color));
|
|
218
|
-
}
|
|
219
|
-
|
|
220
3
|
const swirlThemeProviderCss = ".sc-swirl-theme-provider-h{display:block}";
|
|
221
4
|
|
|
222
5
|
const preferredThemeStorageKey = "swirl-preferred-theme";
|
|
223
|
-
const tenantColorMapping = {
|
|
224
|
-
"--s-action-primary-default": "primary",
|
|
225
|
-
"--s-action-primary-hovered": "primaryHovered",
|
|
226
|
-
"--s-action-primary-pressed": "primaryPressed",
|
|
227
|
-
"--s-text-on-action-primary": "primaryContrast",
|
|
228
|
-
"--s-icon-on-action-primary": "primaryContrast",
|
|
229
|
-
"--s-surface-highlight-default": "secondary",
|
|
230
|
-
"--s-surface-highlight-hovered": "secondaryHovered",
|
|
231
|
-
"--s-surface-highlight-pressed": "secondaryPressed",
|
|
232
|
-
"--s-on-surface-highlight-default": "secondaryHovered",
|
|
233
|
-
"--s-text-on-surface-highlight": "secondaryContrast",
|
|
234
|
-
"--s-icon-on-surface-highlight": "secondaryContrast",
|
|
235
|
-
"--s-text-highlight": "text",
|
|
236
|
-
"--s-interactive-primary-default": "text",
|
|
237
|
-
"--s-interactive-primary-hovered": "textHovered",
|
|
238
|
-
"--s-interactive-primary-pressed": "textPressed",
|
|
239
|
-
};
|
|
240
6
|
const SwirlThemeProvider$1 = /*@__PURE__*/ proxyCustomElement(class SwirlThemeProvider extends HTMLElement {
|
|
241
7
|
constructor() {
|
|
242
8
|
super();
|
|
243
9
|
this.__registerHost();
|
|
244
10
|
this.themeChange = createEvent(this, "themeChange", 7);
|
|
11
|
+
this.setDesignTokens = [];
|
|
245
12
|
this.config = undefined;
|
|
246
13
|
}
|
|
247
14
|
componentWillLoad() {
|
|
@@ -255,27 +22,27 @@ const SwirlThemeProvider$1 = /*@__PURE__*/ proxyCustomElement(class SwirlThemePr
|
|
|
255
22
|
this.updateAppTheme();
|
|
256
23
|
}
|
|
257
24
|
/**
|
|
258
|
-
* Returns the active
|
|
25
|
+
* Returns the active OS theme.
|
|
259
26
|
* @returns SwirlTheme
|
|
260
27
|
*/
|
|
261
|
-
async
|
|
262
|
-
return this.
|
|
28
|
+
async getActiveOSTheme() {
|
|
29
|
+
return this.appOSTheme;
|
|
263
30
|
}
|
|
264
31
|
/**
|
|
265
|
-
* Returns the user's preferred theme stored in local storage.
|
|
32
|
+
* Returns the user's preferred OS theme stored in local storage.
|
|
266
33
|
* @returns SwirlTheme
|
|
267
34
|
*/
|
|
268
|
-
async
|
|
35
|
+
async getPreferredOSTheme() {
|
|
269
36
|
if (!Boolean(this.resolvedConfig.storage)) {
|
|
270
37
|
return;
|
|
271
38
|
}
|
|
272
39
|
return this.resolvedConfig.storage.getItem(preferredThemeStorageKey);
|
|
273
40
|
}
|
|
274
41
|
/**
|
|
275
|
-
* Sets the user's preferred theme and stores it in local storage. Overrides
|
|
276
|
-
* the
|
|
42
|
+
* Sets the user's preferred OS theme and stores it in local storage. Overrides
|
|
43
|
+
* the system theme.
|
|
277
44
|
*/
|
|
278
|
-
async
|
|
45
|
+
async setPreferredOSTheme(theme) {
|
|
279
46
|
if (!Boolean(this.resolvedConfig.storage)) {
|
|
280
47
|
return;
|
|
281
48
|
}
|
|
@@ -283,9 +50,9 @@ const SwirlThemeProvider$1 = /*@__PURE__*/ proxyCustomElement(class SwirlThemePr
|
|
|
283
50
|
this.updateAppTheme();
|
|
284
51
|
}
|
|
285
52
|
/**
|
|
286
|
-
* Resets the user's preferred theme, using the
|
|
53
|
+
* Resets the user's preferred OS theme, using the system theme instead.
|
|
287
54
|
*/
|
|
288
|
-
async
|
|
55
|
+
async resetPreferredOSTheme() {
|
|
289
56
|
if (!Boolean(this.resolvedConfig.storage)) {
|
|
290
57
|
return;
|
|
291
58
|
}
|
|
@@ -312,8 +79,8 @@ const SwirlThemeProvider$1 = /*@__PURE__*/ proxyCustomElement(class SwirlThemePr
|
|
|
312
79
|
});
|
|
313
80
|
}
|
|
314
81
|
async updateAppTheme() {
|
|
315
|
-
this.
|
|
316
|
-
if (this.
|
|
82
|
+
this.appOSTheme = (await this.getPreferredOSTheme()) || this.osTheme;
|
|
83
|
+
if (this.appOSTheme === "dark") {
|
|
317
84
|
document.documentElement.classList.remove("theme-light");
|
|
318
85
|
document.documentElement.classList.add("theme-dark");
|
|
319
86
|
}
|
|
@@ -322,59 +89,49 @@ const SwirlThemeProvider$1 = /*@__PURE__*/ proxyCustomElement(class SwirlThemePr
|
|
|
322
89
|
document.documentElement.classList.add("theme-light");
|
|
323
90
|
}
|
|
324
91
|
this.updateTenantVariables();
|
|
92
|
+
this.updateTenantAssets();
|
|
325
93
|
const themeChangeEventData = {
|
|
326
|
-
activeTheme: await this.
|
|
327
|
-
preferredTheme: await this.
|
|
94
|
+
activeTheme: await this.getActiveOSTheme(),
|
|
95
|
+
preferredTheme: await this.getPreferredOSTheme(),
|
|
328
96
|
};
|
|
329
|
-
if (!Boolean(this.
|
|
97
|
+
if (!Boolean(this.recentOSThemeChangeEventData) ||
|
|
330
98
|
themeChangeEventData.activeTheme !==
|
|
331
|
-
this.
|
|
99
|
+
this.recentOSThemeChangeEventData.activeTheme ||
|
|
332
100
|
themeChangeEventData.preferredTheme !==
|
|
333
|
-
this.
|
|
334
|
-
this.
|
|
335
|
-
this.themeChange.emit(this.
|
|
101
|
+
this.recentOSThemeChangeEventData.preferredTheme) {
|
|
102
|
+
this.recentOSThemeChangeEventData = themeChangeEventData;
|
|
103
|
+
this.themeChange.emit(this.recentOSThemeChangeEventData);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
updateTenantAssets() {
|
|
107
|
+
const theme = this.resolvedConfig?.themes?.[this.appOSTheme];
|
|
108
|
+
if (!Boolean(theme)) {
|
|
109
|
+
return;
|
|
336
110
|
}
|
|
111
|
+
document.head
|
|
112
|
+
.querySelector('link[rel="icon"]')
|
|
113
|
+
?.setAttribute("href", theme.favicon.link);
|
|
337
114
|
}
|
|
338
115
|
updateTenantVariables() {
|
|
339
|
-
const
|
|
340
|
-
if (!Boolean(
|
|
116
|
+
const theme = this.resolvedConfig?.themes?.[this.appOSTheme];
|
|
117
|
+
if (!Boolean(theme)) {
|
|
341
118
|
this.resetTenantVariables();
|
|
342
119
|
return;
|
|
343
120
|
}
|
|
344
121
|
const rootElement = this.resolvedConfig.rootElement;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const secondaryHovered = toRgba(hsla(secondaryHsla[0], secondaryHsla[1], secondaryHsla[2] + 0.07, 1));
|
|
352
|
-
const secondaryPressed = toRgba(hsla(secondaryHsla[0], secondaryHsla[1], secondaryHsla[2] + 0.15, 1));
|
|
353
|
-
const textHovered = toRgba(hsla(textHsla[0], textHsla[1] - 0.34, textHsla[2] + 0.1, 1));
|
|
354
|
-
const textPressed = toRgba(hsla(textHsla[0], textHsla[1] - 0.48, textHsla[2] + 0.2, 1));
|
|
355
|
-
const tenantThemeWithGeneratedStateColors = {
|
|
356
|
-
...tenantTheme,
|
|
357
|
-
primaryHovered: primaryHovered,
|
|
358
|
-
primaryPressed: primaryPressed,
|
|
359
|
-
secondaryHovered: secondaryHovered,
|
|
360
|
-
secondaryPressed: secondaryPressed,
|
|
361
|
-
textHovered: textHovered,
|
|
362
|
-
textPressed: textPressed,
|
|
363
|
-
};
|
|
364
|
-
// set custom properties for tenant theme colors
|
|
365
|
-
Object.entries(tenantColorMapping).forEach(([key, value]) => rootElement.style.setProperty(key, tenantThemeWithGeneratedStateColors[value]));
|
|
122
|
+
this.setDesignTokens = [];
|
|
123
|
+
theme.design_tokens.forEach((token) => {
|
|
124
|
+
const propertyName = `--s-${token.id}`;
|
|
125
|
+
rootElement.style.setProperty(propertyName, `rgba(${token.color.r}, ${token.color.g}, ${token.color.b}, ${token.color.a})`);
|
|
126
|
+
this.setDesignTokens.push(propertyName);
|
|
127
|
+
});
|
|
366
128
|
}
|
|
367
129
|
resetTenantVariables() {
|
|
368
130
|
const rootElement = this.resolvedConfig.rootElement;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
"secondaryHovered",
|
|
374
|
-
"secondaryPressed",
|
|
375
|
-
"textHovered",
|
|
376
|
-
"textPressed",
|
|
377
|
-
].forEach((key) => rootElement.style.removeProperty(key));
|
|
131
|
+
this.setDesignTokens.forEach((property) => {
|
|
132
|
+
rootElement.style.removeProperty(property);
|
|
133
|
+
});
|
|
134
|
+
this.setDesignTokens = [];
|
|
378
135
|
}
|
|
379
136
|
render() {
|
|
380
137
|
return (h(Host, null, h("slot", null)));
|
|
@@ -385,10 +142,10 @@ const SwirlThemeProvider$1 = /*@__PURE__*/ proxyCustomElement(class SwirlThemePr
|
|
|
385
142
|
static get style() { return swirlThemeProviderCss; }
|
|
386
143
|
}, [6, "swirl-theme-provider", {
|
|
387
144
|
"config": [16],
|
|
388
|
-
"
|
|
389
|
-
"
|
|
390
|
-
"
|
|
391
|
-
"
|
|
145
|
+
"getActiveOSTheme": [64],
|
|
146
|
+
"getPreferredOSTheme": [64],
|
|
147
|
+
"setPreferredOSTheme": [64],
|
|
148
|
+
"resetPreferredOSTheme": [64]
|
|
392
149
|
}]);
|
|
393
150
|
function defineCustomElement$1() {
|
|
394
151
|
if (typeof customElements === "undefined") {
|