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