@gospore/theme 1.0.140 → 1.0.142
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/theme.cjs.js +2 -2
- package/dist/theme.cjs.js.map +1 -1
- package/dist/theme.css +2 -1
- package/dist/theme.es.js +493 -557
- package/dist/theme.es.js.map +1 -1
- package/dist/theme.umd.js +2 -2
- package/dist/theme.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/theme.es.js
CHANGED
|
@@ -1,565 +1,501 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed as e, createBlock as t, createElementBlock as n, createElementVNode as r, createVNode as i, inject as a, normalizeStyle as o, onBeforeUnmount as s, openBlock as c, provide as l, ref as u, renderSlot as d, unref as f, watch as p, withCtx as m } from "vue";
|
|
2
2
|
import "what-input";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { DropdownItemGroup as h, DropdownItemRadio as g, DropdownMenu as _ } from "@gospore/dropdown-menu";
|
|
4
|
+
//#region src/modeStorage.js
|
|
5
|
+
var v = [
|
|
6
|
+
"auto",
|
|
7
|
+
"light",
|
|
8
|
+
"dark"
|
|
9
|
+
], y = "gospore-theme-mode", b = 3600 * 24 * 365, x = "(prefers-color-scheme: dark)";
|
|
10
|
+
function S() {
|
|
11
|
+
if (typeof document > "u") return null;
|
|
12
|
+
let e = T(y);
|
|
13
|
+
return e && v.includes(e) ? e : null;
|
|
10
14
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
u && I.push(`domain=${u}`), D && I.push("Secure"), document.cookie = [
|
|
20
|
-
`${encodeURIComponent(vt)}=${encodeURIComponent(a)}`,
|
|
21
|
-
...I
|
|
22
|
-
].join("; ");
|
|
15
|
+
function C(e) {
|
|
16
|
+
if (typeof document > "u" || !v.includes(e)) return;
|
|
17
|
+
let t = typeof window < "u" ? window.location.hostname : "", n = typeof window < "u" ? window.location.protocol : "", r = E(t), i = n === "https:", a = [
|
|
18
|
+
"path=/",
|
|
19
|
+
`max-age=${b}`,
|
|
20
|
+
"SameSite=Lax"
|
|
21
|
+
];
|
|
22
|
+
r && a.push(`domain=${r}`), i && a.push("Secure"), document.cookie = [`${encodeURIComponent(y)}=${encodeURIComponent(e)}`, ...a].join("; ");
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
document.documentElement.setAttribute("dark-mode", m);
|
|
24
|
+
function w(e) {
|
|
25
|
+
if (typeof document > "u") return;
|
|
26
|
+
let t = typeof e == "string" && v.includes(e) ? e : S() ?? "auto";
|
|
27
|
+
console.log("Applying theme mode:", t);
|
|
28
|
+
let n = D(t);
|
|
29
|
+
document.documentElement.setAttribute("dark-mode", n);
|
|
31
30
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (u.startsWith(l))
|
|
38
|
-
return decodeURIComponent(u.slice(l.length));
|
|
39
|
-
return null;
|
|
31
|
+
function T(e) {
|
|
32
|
+
if (typeof document > "u" || !document.cookie) return null;
|
|
33
|
+
let t = `${encodeURIComponent(e)}=`, n = document.cookie.split("; ");
|
|
34
|
+
for (let e of n) if (e.startsWith(t)) return decodeURIComponent(e.slice(t.length));
|
|
35
|
+
return null;
|
|
40
36
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const m = a.split(".");
|
|
47
|
-
return m.length <= 1 ? null : m.length === 2 ? a : m.slice(-2).join(".");
|
|
37
|
+
function E(e) {
|
|
38
|
+
if (!e || e === "localhost") return null;
|
|
39
|
+
if (/^\d+(?:\.\d+){3}$/.test(e)) return e;
|
|
40
|
+
let t = e.split(".");
|
|
41
|
+
return t.length <= 1 ? null : t.length === 2 ? e : t.slice(-2).join(".");
|
|
48
42
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return !1;
|
|
59
|
-
}
|
|
43
|
+
function D(e) {
|
|
44
|
+
if (e === "dark") return !0;
|
|
45
|
+
if (e === "light" || typeof window > "u") return !1;
|
|
46
|
+
try {
|
|
47
|
+
let e = typeof window.matchMedia == "function" ? window.matchMedia(x) : null;
|
|
48
|
+
return e ? e.matches : !1;
|
|
49
|
+
} catch {
|
|
50
|
+
return !1;
|
|
51
|
+
}
|
|
60
52
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/portalHost.js
|
|
55
|
+
var O = Symbol.for("gospore.theme.portalHost");
|
|
56
|
+
function k() {
|
|
57
|
+
let t = a(O, null);
|
|
58
|
+
console.log("Using theme portal host:", t);
|
|
59
|
+
let n = typeof document < "u" ? document.body : "body";
|
|
60
|
+
return e(() => t?.value ?? n);
|
|
67
61
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}, {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
S,
|
|
509
|
-
(_) => {
|
|
510
|
-
if (!D.includes(_)) {
|
|
511
|
-
S.value = "auto";
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
L.value = !1, X("update:mode", _), Qt(_);
|
|
515
|
-
},
|
|
516
|
-
{ immediate: !0 }
|
|
517
|
-
), (_, M) => (_t(), Vt(w(Gt), {
|
|
518
|
-
open: L.value,
|
|
519
|
-
"onUpdate:open": M[3] || (M[3] = (y) => L.value = y),
|
|
520
|
-
text: "Theme",
|
|
521
|
-
"aria-label": "Select theme mode"
|
|
522
|
-
}, {
|
|
523
|
-
default: bt(() => [
|
|
524
|
-
K(w(jt), { title: "Theme" }, {
|
|
525
|
-
default: bt(() => [
|
|
526
|
-
K(w(Z), {
|
|
527
|
-
checked: S.value,
|
|
528
|
-
"onUpdate:checked": M[0] || (M[0] = (y) => S.value = y),
|
|
529
|
-
value: "auto",
|
|
530
|
-
label: w(u).auto,
|
|
531
|
-
"aria-label": `${w(u).auto} mode`
|
|
532
|
-
}, null, 8, ["checked", "label", "aria-label"]),
|
|
533
|
-
M[4] || (M[4] = Ct("hr", {
|
|
534
|
-
class: "theme-switcher-divider",
|
|
535
|
-
role: "separator"
|
|
536
|
-
}, null, -1)),
|
|
537
|
-
K(w(Z), {
|
|
538
|
-
checked: S.value,
|
|
539
|
-
"onUpdate:checked": M[1] || (M[1] = (y) => S.value = y),
|
|
540
|
-
value: "light",
|
|
541
|
-
label: w(u).light,
|
|
542
|
-
"aria-label": `${w(u).light} mode`
|
|
543
|
-
}, null, 8, ["checked", "label", "aria-label"]),
|
|
544
|
-
K(w(Z), {
|
|
545
|
-
checked: S.value,
|
|
546
|
-
"onUpdate:checked": M[2] || (M[2] = (y) => S.value = y),
|
|
547
|
-
value: "dark",
|
|
548
|
-
label: w(u).dark,
|
|
549
|
-
"aria-label": `${w(u).dark} mode`
|
|
550
|
-
}, null, 8, ["checked", "label", "aria-label"])
|
|
551
|
-
]),
|
|
552
|
-
_: 1
|
|
553
|
-
})
|
|
554
|
-
]),
|
|
555
|
-
_: 1
|
|
556
|
-
}, 8, ["open"]));
|
|
557
|
-
}
|
|
558
|
-
}, se = /* @__PURE__ */ te(ee, [["__scopeId", "data-v-bcbc87cb"]]);
|
|
559
|
-
export {
|
|
560
|
-
ce as Theme,
|
|
561
|
-
se as ThemeSwitcher,
|
|
562
|
-
Tt as themePortalHostKey,
|
|
563
|
-
ae as useThemePortalTarget
|
|
564
|
-
};
|
|
565
|
-
//# sourceMappingURL=theme.es.js.map
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/Theme.vue
|
|
64
|
+
var ee = "(prefers-color-scheme: dark)", te = "(prefers-reduced-motion: reduce)", ne = 200, A = 3.8, j = 1.8, M = 1.15, N = 1.08, P = 2.5, F = 3, I = "#ffffff", L = "#1f2228", R = /* @__PURE__ */ Object.assign({ name: "Theme" }, {
|
|
65
|
+
__name: "Theme",
|
|
66
|
+
props: {
|
|
67
|
+
mode: {
|
|
68
|
+
type: String,
|
|
69
|
+
validator: (e) => [
|
|
70
|
+
"auto",
|
|
71
|
+
"light",
|
|
72
|
+
"dark"
|
|
73
|
+
].includes(e)
|
|
74
|
+
},
|
|
75
|
+
accentColor: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: !1,
|
|
78
|
+
default: void 0
|
|
79
|
+
},
|
|
80
|
+
exposeGlobalAccent: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: !1
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
setup(t) {
|
|
86
|
+
let i = t, a = [], f = /* @__PURE__ */ new Set();
|
|
87
|
+
function m() {
|
|
88
|
+
let e = document.documentElement;
|
|
89
|
+
if (!e) return;
|
|
90
|
+
f.forEach((t) => {
|
|
91
|
+
e.style.removeProperty(t);
|
|
92
|
+
}), f.clear();
|
|
93
|
+
let t = [...a].reverse().find((e) => e.enabled && e.vars && Object.keys(e.vars).length > 0);
|
|
94
|
+
t && Object.entries(t.vars).forEach(([t, n]) => {
|
|
95
|
+
e.style.setProperty(t, n), f.add(t);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
let h = window.matchMedia(ee), g = window.matchMedia(te), _ = k();
|
|
99
|
+
w(_);
|
|
100
|
+
let v = u(_), y = u({ darkMode: C(_) }), b = u(null);
|
|
101
|
+
h.addEventListener("change", T), p(() => i.mode, () => {
|
|
102
|
+
x();
|
|
103
|
+
}, { immediate: !0 }), p(() => y.value.darkMode, (e, t) => {
|
|
104
|
+
if (t === void 0) {
|
|
105
|
+
E(e);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
D(() => {
|
|
109
|
+
E(e);
|
|
110
|
+
});
|
|
111
|
+
}, { immediate: !0 }), s(() => {
|
|
112
|
+
h.removeEventListener("change", T);
|
|
113
|
+
let e = a.indexOf($);
|
|
114
|
+
e !== -1 && a.splice(e, 1), m();
|
|
115
|
+
});
|
|
116
|
+
function x() {
|
|
117
|
+
let e = k();
|
|
118
|
+
v.value = e, y.value.darkMode = C(e);
|
|
119
|
+
}
|
|
120
|
+
function C(e) {
|
|
121
|
+
return e === "dark" ? !0 : e === "light" ? !1 : h.matches;
|
|
122
|
+
}
|
|
123
|
+
function T(e) {
|
|
124
|
+
!e || v.value !== "auto" || (y.value.darkMode = e.matches);
|
|
125
|
+
}
|
|
126
|
+
function E(e) {
|
|
127
|
+
document.documentElement.setAttribute("dark-mode", e);
|
|
128
|
+
}
|
|
129
|
+
function D(e) {
|
|
130
|
+
if (g.matches) {
|
|
131
|
+
e();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
let t = document.startViewTransition?.bind(document);
|
|
135
|
+
if (t) {
|
|
136
|
+
t(() => {
|
|
137
|
+
e();
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
e();
|
|
142
|
+
let n = document.documentElement;
|
|
143
|
+
typeof n.animate == "function" && window.requestAnimationFrame(() => {
|
|
144
|
+
n.animate([{ opacity: .85 }, { opacity: 1 }], {
|
|
145
|
+
duration: ne,
|
|
146
|
+
easing: "ease-in-out"
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function k() {
|
|
151
|
+
return i.mode ?? S() ?? "auto";
|
|
152
|
+
}
|
|
153
|
+
l("theme", y), l(O, b);
|
|
154
|
+
function R(e) {
|
|
155
|
+
if (!e) return null;
|
|
156
|
+
let t = e.trim().toLowerCase();
|
|
157
|
+
if (!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t)) return null;
|
|
158
|
+
if (t.length === 4) {
|
|
159
|
+
let e = t[1], n = t[2], r = t[3];
|
|
160
|
+
return `#${e}${e}${n}${n}${r}${r}`;
|
|
161
|
+
}
|
|
162
|
+
return t;
|
|
163
|
+
}
|
|
164
|
+
function z(e) {
|
|
165
|
+
let t = R(e);
|
|
166
|
+
return t ? {
|
|
167
|
+
r: parseInt(t.slice(1, 3), 16),
|
|
168
|
+
g: parseInt(t.slice(3, 5), 16),
|
|
169
|
+
b: parseInt(t.slice(5, 7), 16)
|
|
170
|
+
} : null;
|
|
171
|
+
}
|
|
172
|
+
function B({ r: e, g: t, b: n }) {
|
|
173
|
+
let r = (e) => e.toString(16).padStart(2, "0");
|
|
174
|
+
return `#${r(e)}${r(t)}${r(n)}`;
|
|
175
|
+
}
|
|
176
|
+
function V(e) {
|
|
177
|
+
return Math.max(0, Math.min(1, e));
|
|
178
|
+
}
|
|
179
|
+
function H(e) {
|
|
180
|
+
return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
181
|
+
}
|
|
182
|
+
function U(e) {
|
|
183
|
+
let t = V(e);
|
|
184
|
+
return t <= .0031308 ? 12.92 * t : 1.055 * t ** (1 / 2.4) - .055;
|
|
185
|
+
}
|
|
186
|
+
function W({ r: e, g: t, b: n }) {
|
|
187
|
+
let r = e / 255, i = t / 255, a = n / 255, o = H(r), s = H(i), c = H(a), l = .4122214708 * o + .5363325363 * s + .0514459929 * c, u = .2119034982 * o + .6806995451 * s + .1073969566 * c, d = .0883024619 * o + .2817188376 * s + .6299787005 * c, f = Math.cbrt(l), p = Math.cbrt(u), m = Math.cbrt(d), h = .2104542553 * f + .793617785 * p - .0040720468 * m, g = 1.9779984951 * f - 2.428592205 * p + .4505937099 * m, _ = .0259040371 * f + .7827717662 * p - .808675766 * m, v = Math.sqrt(g * g + _ * _), y = 180 / Math.PI * Math.atan2(_, g);
|
|
188
|
+
return y < 0 && (y += 360), {
|
|
189
|
+
l: h,
|
|
190
|
+
c: v,
|
|
191
|
+
h: y
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function G(e, t, n, r = !1) {
|
|
195
|
+
let i = n * Math.PI / 180, a = t * Math.cos(i), o = t * Math.sin(i), s = e + .3963377774 * a + .2158037573 * o, c = e - .1055613458 * a - .0638541728 * o, l = e - .0894841775 * a - 1.291485548 * o, u = r ? V(s) : s, d = r ? V(c) : c, f = r ? V(l) : l;
|
|
196
|
+
if (!r && (u < -1e-4 || u > 1.0001 || d < -1e-4 || d > 1.0001 || f < -1e-4 || f > 1.0001)) return null;
|
|
197
|
+
let p = u * u * u, m = d * d * d, h = f * f * f, g = 4.0767416621 * p - 3.3077115913 * m + .2309699292 * h, _ = -1.2684380046 * p + 2.6097574011 * m - .3413193965 * h, v = -.0041960863 * p - .7034186147 * m + 1.707614701 * h;
|
|
198
|
+
if (r) g = V(g), _ = V(_), v = V(v);
|
|
199
|
+
else if (g < -1e-4 || g > 1.0001 || _ < -1e-4 || _ > 1.0001 || v < -1e-4 || v > 1.0001) return null;
|
|
200
|
+
let y = V(U(g)), b = V(U(_)), x = V(U(v));
|
|
201
|
+
return {
|
|
202
|
+
r: Math.round(y * 255),
|
|
203
|
+
g: Math.round(b * 255),
|
|
204
|
+
b: Math.round(x * 255)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function K(e, t, n) {
|
|
208
|
+
let r = t;
|
|
209
|
+
for (let t = 0; t < 8; t += 1) {
|
|
210
|
+
let t = G(e, r, n);
|
|
211
|
+
if (t) return t;
|
|
212
|
+
r *= .9;
|
|
213
|
+
}
|
|
214
|
+
return G(e, V(r), n, !0) || {
|
|
215
|
+
r: 0,
|
|
216
|
+
g: 0,
|
|
217
|
+
b: 0
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function q(e) {
|
|
221
|
+
let t = z(e);
|
|
222
|
+
if (!t) return 0;
|
|
223
|
+
let n = H(t.r / 255), r = H(t.g / 255), i = H(t.b / 255);
|
|
224
|
+
return .2126 * n + .7152 * r + .0722 * i;
|
|
225
|
+
}
|
|
226
|
+
function J(e, t) {
|
|
227
|
+
let n = q(e), r = q(t), i = Math.max(n, r), a = Math.min(n, r);
|
|
228
|
+
return (i + .05) / (a + .05);
|
|
229
|
+
}
|
|
230
|
+
function re(e, t, n = {}) {
|
|
231
|
+
let r = n.minContrast ?? A, i = n.preferDark !== !1, a = Math.max(.01, Math.min(.06, (e.c || .12) * (n.chromaScale ?? .25))), o = n.initialLightness ?? (i ? .24 : .94), s = i ? -1 : 1, c = n.step ?? .03, l = V(o), u = B(K(l, a, e.h)), d = J(t, u);
|
|
232
|
+
for (let n = 0; n < 48; n += 1) {
|
|
233
|
+
let n = B(K(l, a, e.h)), i = J(t, n);
|
|
234
|
+
if (i > d && (d = i, u = n), i >= r) return n;
|
|
235
|
+
if (l = V(l + s * c), l === 0 || l === 1) break;
|
|
236
|
+
}
|
|
237
|
+
let f = "#101214", p = "#ffffff", m = J(t, f), h = J(t, p);
|
|
238
|
+
return m >= r || h >= r ? m >= h ? f : p : u;
|
|
239
|
+
}
|
|
240
|
+
function Y(e, t, n = {}) {
|
|
241
|
+
let r = n.minContrast ?? A, i = n.darkCandidate ?? "#101214", a = n.lightCandidate ?? "#ffffff", o = n.preferredCandidate, s = n.preferredMinContrast ?? r, c = n.preferredSwitchDelta ?? 0, l = J(t, i), u = J(t, a), d = l >= r, f = u >= r, p = u >= s, m = l >= s;
|
|
242
|
+
if (d || f) return o === "light" && p ? a : o === "dark" && m ? i : o === "light" && f ? !d || l - u <= c ? a : i : o === "dark" && d ? !f || u - l <= c ? i : a : d && f ? l >= u ? i : a : d ? i : a;
|
|
243
|
+
let h = l >= u;
|
|
244
|
+
return re(e, t, {
|
|
245
|
+
minContrast: r,
|
|
246
|
+
preferDark: h,
|
|
247
|
+
initialLightness: h ? .2 : .96,
|
|
248
|
+
chromaScale: .1
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
let ie = [
|
|
252
|
+
100,
|
|
253
|
+
200,
|
|
254
|
+
300,
|
|
255
|
+
400,
|
|
256
|
+
500,
|
|
257
|
+
600,
|
|
258
|
+
700,
|
|
259
|
+
800,
|
|
260
|
+
900,
|
|
261
|
+
1e3
|
|
262
|
+
], X = [
|
|
263
|
+
.9,
|
|
264
|
+
.84,
|
|
265
|
+
.78,
|
|
266
|
+
.72,
|
|
267
|
+
.67,
|
|
268
|
+
.62,
|
|
269
|
+
.56,
|
|
270
|
+
.5,
|
|
271
|
+
.44,
|
|
272
|
+
.38
|
|
273
|
+
], ae = [
|
|
274
|
+
.28,
|
|
275
|
+
.4,
|
|
276
|
+
.54,
|
|
277
|
+
.7,
|
|
278
|
+
.86,
|
|
279
|
+
1,
|
|
280
|
+
1.08,
|
|
281
|
+
1.14,
|
|
282
|
+
1.2,
|
|
283
|
+
1.24
|
|
284
|
+
];
|
|
285
|
+
function Z(e, t, n, r) {
|
|
286
|
+
let i = t[t.length - 1];
|
|
287
|
+
for (let i of t) {
|
|
288
|
+
let t = e[i];
|
|
289
|
+
if (t && J(t, n) >= r) return i;
|
|
290
|
+
}
|
|
291
|
+
return i;
|
|
292
|
+
}
|
|
293
|
+
function oe(e) {
|
|
294
|
+
let t = e.l - X[5], n = e.c > .02 ? .02 : 0;
|
|
295
|
+
return ie.reduce((r, i, a) => (r[i] = B(K(V(X[a] + t), Math.min(.4, Math.max(n, e.c * ae[a])), e.h)), r), {});
|
|
296
|
+
}
|
|
297
|
+
function se(e, t) {
|
|
298
|
+
let n = [
|
|
299
|
+
100,
|
|
300
|
+
200,
|
|
301
|
+
300,
|
|
302
|
+
400,
|
|
303
|
+
500,
|
|
304
|
+
600,
|
|
305
|
+
700
|
|
306
|
+
], r = Z(t, n, I, N), i = n.indexOf(r), a = n[Math.min(i + 1, n.length - 1)], o = n[Math.min(i + 2, n.length - 1)], s = [
|
|
307
|
+
1e3,
|
|
308
|
+
900,
|
|
309
|
+
800,
|
|
310
|
+
700,
|
|
311
|
+
600,
|
|
312
|
+
500
|
|
313
|
+
], c = Z(t, s, L, N), l = s.indexOf(c), u = s[Math.min(l + 1, s.length - 1)], d = s[Math.min(l + 2, s.length - 1)], f = Z(t, [
|
|
314
|
+
200,
|
|
315
|
+
300,
|
|
316
|
+
400,
|
|
317
|
+
500,
|
|
318
|
+
600,
|
|
319
|
+
700,
|
|
320
|
+
800
|
|
321
|
+
], I, M), p = Z(t, [
|
|
322
|
+
900,
|
|
323
|
+
800,
|
|
324
|
+
700,
|
|
325
|
+
600,
|
|
326
|
+
500,
|
|
327
|
+
400
|
|
328
|
+
], L, M), m = [
|
|
329
|
+
600,
|
|
330
|
+
700,
|
|
331
|
+
800,
|
|
332
|
+
900,
|
|
333
|
+
1e3
|
|
334
|
+
], h = Z(t, m, I, j), g = m.indexOf(h), _ = m[Math.min(g + 1, m.length - 1)], v = m[Math.min(g + 2, m.length - 1)], y = [
|
|
335
|
+
400,
|
|
336
|
+
300,
|
|
337
|
+
200,
|
|
338
|
+
100
|
|
339
|
+
], b = Z(t, y, L, j), x = y.indexOf(b), S = y[Math.min(x + 1, y.length - 1)], C = y[Math.min(x + 2, y.length - 1)], w = {
|
|
340
|
+
"--color-brand-surface-soft-light": t[r],
|
|
341
|
+
"--color-brand-surface-soft-hovered-light": t[a],
|
|
342
|
+
"--color-brand-surface-soft-pressed-light": t[o],
|
|
343
|
+
"--color-brand-surface-soft-dark": t[c],
|
|
344
|
+
"--color-brand-surface-soft-hovered-dark": t[u],
|
|
345
|
+
"--color-brand-surface-soft-pressed-dark": t[d],
|
|
346
|
+
"--color-brand-surface-subtle-light": t[f],
|
|
347
|
+
"--color-brand-surface-subtle-dark": t[p],
|
|
348
|
+
"--color-brand-surface-strong-light": t[h],
|
|
349
|
+
"--color-brand-surface-strong-hovered-light": t[_],
|
|
350
|
+
"--color-brand-surface-strong-pressed-light": t[v],
|
|
351
|
+
"--color-brand-surface-strong-dark": t[b],
|
|
352
|
+
"--color-brand-surface-strong-hovered-dark": t[S],
|
|
353
|
+
"--color-brand-surface-strong-pressed-dark": t[C]
|
|
354
|
+
}, T = t[600];
|
|
355
|
+
return w["--color-brand-on-soft-light"] = J(w["--color-brand-surface-soft-light"], T) >= A ? T : Y(e, w["--color-brand-surface-soft-light"], { minContrast: A }), w["--color-brand-on-soft-dark"] = Y(e, w["--color-brand-surface-soft-dark"], { minContrast: A }), w["--color-brand-on-subtle-light"] = Y(e, w["--color-brand-surface-subtle-light"], {
|
|
356
|
+
minContrast: P,
|
|
357
|
+
preferredCandidate: "light",
|
|
358
|
+
preferredMinContrast: P,
|
|
359
|
+
preferredSwitchDelta: F
|
|
360
|
+
}), w["--color-brand-on-subtle-dark"] = Y(e, w["--color-brand-surface-subtle-dark"], { minContrast: A }), w["--color-brand-on-strong-light"] = Y(e, w["--color-brand-surface-strong-light"], {
|
|
361
|
+
minContrast: P,
|
|
362
|
+
preferredCandidate: "light",
|
|
363
|
+
preferredMinContrast: P,
|
|
364
|
+
preferredSwitchDelta: F
|
|
365
|
+
}), w["--color-brand-on-strong-dark"] = Y(e, w["--color-brand-surface-strong-dark"], { minContrast: A }), w["--color-brand-text-light"] = w["--color-brand-surface-strong-light"], w["--color-brand-text-dark"] = w["--color-brand-surface-strong-dark"], w["--color-brand-icon-light"] = w["--color-brand-surface-strong-light"], w["--color-brand-icon-dark"] = w["--color-brand-surface-strong-dark"], w["--color-brand-border-light"] = w["--color-brand-surface-strong-light"], w["--color-brand-border-dark"] = w["--color-brand-surface-strong-dark"], w;
|
|
366
|
+
}
|
|
367
|
+
function ce(e) {
|
|
368
|
+
let t = R(e);
|
|
369
|
+
if (!t) return null;
|
|
370
|
+
let n = z(t);
|
|
371
|
+
if (!n) return null;
|
|
372
|
+
let r = W(n), i = oe(r);
|
|
373
|
+
return i[600] = t, {
|
|
374
|
+
"--color-brand-seed": t,
|
|
375
|
+
"--color-brand-100": i[100],
|
|
376
|
+
"--color-brand-200": i[200],
|
|
377
|
+
"--color-brand-300": i[300],
|
|
378
|
+
"--color-brand-400": i[400],
|
|
379
|
+
"--color-brand-500": i[500],
|
|
380
|
+
"--color-brand-600": i[600],
|
|
381
|
+
"--color-brand-700": i[700],
|
|
382
|
+
"--color-brand-800": i[800],
|
|
383
|
+
"--color-brand-900": i[900],
|
|
384
|
+
"--color-brand-1000": i[1e3],
|
|
385
|
+
...se(r, i)
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
let Q = e(() => ce(i.accentColor) ?? {}), $ = {
|
|
389
|
+
vars: {},
|
|
390
|
+
enabled: !!i.exposeGlobalAccent
|
|
391
|
+
};
|
|
392
|
+
return a.push($), p(() => i.exposeGlobalAccent, (e) => {
|
|
393
|
+
$.enabled = !!e, m();
|
|
394
|
+
}, { immediate: !0 }), p(Q, (e) => {
|
|
395
|
+
e && Object.keys(e).length > 0 ? $.vars = { ...e } : $.vars = {}, m();
|
|
396
|
+
}, { immediate: !0 }), (e, t) => (c(), n("div", {
|
|
397
|
+
class: "theme",
|
|
398
|
+
style: o(Q.value)
|
|
399
|
+
}, [d(e.$slots, "default"), r("div", {
|
|
400
|
+
ref_key: "portalHost",
|
|
401
|
+
ref: b,
|
|
402
|
+
class: "theme__portal-host"
|
|
403
|
+
}, null, 512)], 4));
|
|
404
|
+
}
|
|
405
|
+
}), z = /* @__PURE__ */ ((e, t) => {
|
|
406
|
+
let n = e.__vccOpts || e;
|
|
407
|
+
for (let [e, r] of t) n[e] = r;
|
|
408
|
+
return n;
|
|
409
|
+
})({
|
|
410
|
+
__name: "ThemeSwitcher",
|
|
411
|
+
props: { mode: {
|
|
412
|
+
type: String,
|
|
413
|
+
default: "auto",
|
|
414
|
+
validator: (e) => [
|
|
415
|
+
"auto",
|
|
416
|
+
"light",
|
|
417
|
+
"dark"
|
|
418
|
+
].includes(e)
|
|
419
|
+
} },
|
|
420
|
+
emits: ["update:mode"],
|
|
421
|
+
setup(n, { emit: a }) {
|
|
422
|
+
let o = [
|
|
423
|
+
{
|
|
424
|
+
value: "auto",
|
|
425
|
+
label: "System"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
value: "light",
|
|
429
|
+
label: "Light"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
value: "dark",
|
|
433
|
+
label: "Dark"
|
|
434
|
+
}
|
|
435
|
+
].reduce((e, t) => (e[t.value] = t.label, e), {}), s = v, l = n, d = a;
|
|
436
|
+
w();
|
|
437
|
+
let y = u(!1), b = S() ?? l.mode, x = u(s.includes(b) ? b : "auto");
|
|
438
|
+
return e(() => o[x.value] ?? o.auto), p(() => l.mode, (e) => {
|
|
439
|
+
s.includes(e) && e !== x.value && (x.value = e);
|
|
440
|
+
}), p(x, (e) => {
|
|
441
|
+
if (!s.includes(e)) {
|
|
442
|
+
x.value = "auto";
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
y.value = !1, d("update:mode", e), C(e);
|
|
446
|
+
}, { immediate: !0 }), (e, n) => (c(), t(f(_), {
|
|
447
|
+
open: y.value,
|
|
448
|
+
"onUpdate:open": n[3] ||= (e) => y.value = e,
|
|
449
|
+
text: "Theme",
|
|
450
|
+
"aria-label": "Select theme mode"
|
|
451
|
+
}, {
|
|
452
|
+
default: m(() => [i(f(h), { title: "Theme" }, {
|
|
453
|
+
default: m(() => [
|
|
454
|
+
i(f(g), {
|
|
455
|
+
checked: x.value,
|
|
456
|
+
"onUpdate:checked": n[0] ||= (e) => x.value = e,
|
|
457
|
+
value: "auto",
|
|
458
|
+
label: f(o).auto,
|
|
459
|
+
"aria-label": `${f(o).auto} mode`
|
|
460
|
+
}, null, 8, [
|
|
461
|
+
"checked",
|
|
462
|
+
"label",
|
|
463
|
+
"aria-label"
|
|
464
|
+
]),
|
|
465
|
+
n[4] ||= r("hr", {
|
|
466
|
+
class: "theme-switcher-divider",
|
|
467
|
+
role: "separator"
|
|
468
|
+
}, null, -1),
|
|
469
|
+
i(f(g), {
|
|
470
|
+
checked: x.value,
|
|
471
|
+
"onUpdate:checked": n[1] ||= (e) => x.value = e,
|
|
472
|
+
value: "light",
|
|
473
|
+
label: f(o).light,
|
|
474
|
+
"aria-label": `${f(o).light} mode`
|
|
475
|
+
}, null, 8, [
|
|
476
|
+
"checked",
|
|
477
|
+
"label",
|
|
478
|
+
"aria-label"
|
|
479
|
+
]),
|
|
480
|
+
i(f(g), {
|
|
481
|
+
checked: x.value,
|
|
482
|
+
"onUpdate:checked": n[2] ||= (e) => x.value = e,
|
|
483
|
+
value: "dark",
|
|
484
|
+
label: f(o).dark,
|
|
485
|
+
"aria-label": `${f(o).dark} mode`
|
|
486
|
+
}, null, 8, [
|
|
487
|
+
"checked",
|
|
488
|
+
"label",
|
|
489
|
+
"aria-label"
|
|
490
|
+
])
|
|
491
|
+
]),
|
|
492
|
+
_: 1
|
|
493
|
+
})]),
|
|
494
|
+
_: 1
|
|
495
|
+
}, 8, ["open"]));
|
|
496
|
+
}
|
|
497
|
+
}, [["__scopeId", "data-v-bcbc87cb"]]);
|
|
498
|
+
//#endregion
|
|
499
|
+
export { R as Theme, z as ThemeSwitcher, O as themePortalHostKey, k as useThemePortalTarget };
|
|
500
|
+
|
|
501
|
+
//# sourceMappingURL=theme.es.js.map
|