boreal-ui 0.0.892 → 0.0.894

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.
Files changed (33) hide show
  1. package/dist/core/{Footer-CmpLvoZb.cjs → Footer-CqEL5lCo.cjs} +1 -1
  2. package/dist/core/{Footer-CoFPqecX.js → Footer-W9ItlBXS.js} +1 -1
  3. package/dist/core/Footer.cjs.js +1 -1
  4. package/dist/core/Footer.js +1 -1
  5. package/dist/core/ThemeContext-BNZ28nPu.cjs +1 -0
  6. package/dist/core/ThemeContext-wbHzxDs2.js +367 -0
  7. package/dist/core/ThemeProvider.cjs.js +1 -1
  8. package/dist/core/ThemeProvider.js +1 -1
  9. package/dist/core/ThemeSelect-B7LNF0B5.cjs +1 -0
  10. package/dist/core/ThemeSelect-C8cxeht_.js +71 -0
  11. package/dist/core/ThemeSelect.cjs.js +1 -1
  12. package/dist/core/ThemeSelect.js +1 -1
  13. package/dist/core/index.cjs.js +1 -1
  14. package/dist/core/index.js +3 -3
  15. package/dist/next/{Footer-D78Lzvjg.js → Footer-1gaUlUeU.js} +1 -1
  16. package/dist/next/Footer.js +1 -1
  17. package/dist/next/{NextThemeProvider-NpALBYoC.js → NextThemeProvider-Dy9dtA1A.js} +1 -1
  18. package/dist/next/ThemeContext-BdDCc3xM.js +367 -0
  19. package/dist/next/ThemeProvider.js +2 -2
  20. package/dist/next/ThemeSelect-8AG_tLAW.js +72 -0
  21. package/dist/next/ThemeSelect.js +1 -1
  22. package/dist/next/index.js +4 -4
  23. package/dist/tsconfig.build.tsbuildinfo +1 -1
  24. package/dist/types/context/ThemeContext.d.ts.map +1 -1
  25. package/dist/types/context/ThemeContext.types.d.ts +5 -1
  26. package/dist/types/context/ThemeContext.types.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/core/ThemeContext-D1VVOPG1.cjs +0 -1
  29. package/dist/core/ThemeContext-DRXOWRyX.js +0 -342
  30. package/dist/core/ThemeSelect-CPpf-wbN.cjs +0 -1
  31. package/dist/core/ThemeSelect-DxmyeZm_.js +0 -71
  32. package/dist/next/ThemeContext-19HbcfZg.js +0 -342
  33. package/dist/next/ThemeSelect-BdFqSfT_.js +0 -72
@@ -1,342 +0,0 @@
1
- import { jsxs as J, jsx as j } from "react/jsx-runtime";
2
- import { useMemo as k, useState as V, useRef as z, useEffect as I, useInsertionEffect as P, createContext as F } from "react";
3
- import { c as O } from "./boreal-style-config-rYvfCHLY.js";
4
- import { defaultColorSchemes as B } from "./colorSchemes.js";
5
- const S = "boreal:selectedSchemeName", E = "boreal:theme-change", w = 4.5, L = 3;
6
- function D(t, e = []) {
7
- const r = [...t];
8
- for (const o of e) {
9
- const n = r.findIndex((a) => a.name === o.name);
10
- n >= 0 ? r[n] = o : r.push(o);
11
- }
12
- return r;
13
- }
14
- function C(t, e) {
15
- return e ? t.findIndex((r) => r.name === e) : -1;
16
- }
17
- function R({
18
- customSchemes: t = [],
19
- useOnlyCustomSchemes: e = !1
20
- }) {
21
- return e ? [...t] : D([...B], t);
22
- }
23
- function q(t, {
24
- initialSchemeName: e,
25
- savedSchemeName: r
26
- }) {
27
- const o = C(t, e), n = C(t, r), a = C(t, O());
28
- return o !== -1 ? o : n !== -1 ? n : a !== -1 ? a : 0;
29
- }
30
- function T(t) {
31
- if (!t) return null;
32
- try {
33
- return t.getItem(S);
34
- } catch {
35
- return console.error("Failed to load saved theme name"), null;
36
- }
37
- }
38
- function G(t, e) {
39
- if (!t) return !1;
40
- try {
41
- return t.getItem(S) === e ? !1 : (t.setItem(S, e), !0);
42
- } catch {
43
- return console.error("Failed to save theme name"), !1;
44
- }
45
- }
46
- function K(t, e = typeof window > "u" ? void 0 : window) {
47
- e && e.dispatchEvent(
48
- new CustomEvent(E, {
49
- detail: { schemeName: t }
50
- })
51
- );
52
- }
53
- function H(t) {
54
- const e = t.trim(), r = /^#([\da-f])([\da-f])([\da-f])$/i.exec(e);
55
- return r ? `#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`.toLowerCase() : /^#[\da-f]{6}([\da-f]{2})?$/i.exec(e) ? e.slice(0, 7).toLowerCase() : null;
56
- }
57
- function N(t) {
58
- const e = H(t) ?? "#000000", r = parseInt(e.slice(1, 3), 16) / 255, o = parseInt(e.slice(3, 5), 16) / 255, n = parseInt(e.slice(5, 7), 16) / 255, a = Math.max(r, o, n), s = Math.min(r, o, n);
59
- let c = 0, i = 0;
60
- const f = (a + s) / 2;
61
- if (a !== s) {
62
- const u = a - s;
63
- switch (i = f > 0.5 ? u / (2 - a - s) : u / (a + s), a) {
64
- case r:
65
- c = (o - n) / u + (o < n ? 6 : 0);
66
- break;
67
- case o:
68
- c = (n - r) / u + 2;
69
- break;
70
- case n:
71
- c = (r - o) / u + 4;
72
- break;
73
- }
74
- c /= 6;
75
- }
76
- return {
77
- h: Math.round(c * 360),
78
- s: Math.round(i * 100),
79
- l: Math.round(f * 100)
80
- };
81
- }
82
- function $(t, e, r) {
83
- e /= 100, r /= 100;
84
- const o = (s) => (s + t / 30) % 12, n = e * Math.min(r, 1 - r), a = (s) => Math.round(
85
- 255 * (r - n * Math.max(-1, Math.min(o(s) - 3, Math.min(9 - o(s), 1))))
86
- );
87
- return `#${[a(0), a(8), a(4)].map((s) => s.toString(16).padStart(2, "0")).join("")}`;
88
- }
89
- function d(t, e) {
90
- const { h: r, s: o, l: n } = N(t);
91
- return $(r, o, Math.min(100, Math.max(0, n + e)));
92
- }
93
- function _(t) {
94
- const e = H(t) ?? "#000000", r = [1, 3, 5].map((o) => {
95
- const n = parseInt(e.slice(o, o + 2), 16) / 255;
96
- return n <= 0.03928 ? n / 12.92 : Math.pow((n + 0.055) / 1.055, 2.4);
97
- });
98
- return 0.2126 * r[0] + 0.7152 * r[1] + 0.0722 * r[2];
99
- }
100
- function v(t, e) {
101
- const r = _(t), o = _(e), n = Math.max(r, o), a = Math.min(r, o);
102
- return (n + 0.05) / (a + 0.05);
103
- }
104
- function x(t, e, r = w) {
105
- if (e && v(t, e) >= r)
106
- return e;
107
- const o = v(t, "#000000"), n = v(t, "#ffffff");
108
- return o >= n ? "#000000" : "#ffffff";
109
- }
110
- function U(t, e, r) {
111
- const o = d(e, r);
112
- return v(t, o) >= w ? o : e;
113
- }
114
- function A(t, e) {
115
- const r = e === "#000000" ? 1 : -1;
116
- for (let o = 30; o >= 0; o -= 5) {
117
- const n = d(e, o * r);
118
- if (v(t, n) >= w)
119
- return n;
120
- }
121
- return e;
122
- }
123
- function y(t, e, r) {
124
- const o = d(t, r);
125
- if (v(o, e) >= w)
126
- return o;
127
- const { h: n, s: a, l: s } = N(t), c = e === "#ffffff";
128
- for (let i = 4; i <= 48; i += 4) {
129
- const f = c ? Math.max(0, s - i) : Math.min(100, s + i), u = $(n, a, f);
130
- if (v(u, e) >= w)
131
- return u;
132
- }
133
- return t;
134
- }
135
- function M(t, e = 14, r = 14) {
136
- const { h: o, s: n, l: a } = N(t), s = a >= 50 ? Math.max(0, a - r) : Math.min(100, a + e), c = n > 8 ? Math.max(0, n - 8) : n, i = $(o, c, s);
137
- return v(t, i) >= L ? i : x(t, void 0, L);
138
- }
139
- function W(t) {
140
- const {
141
- primaryColor: e,
142
- secondaryColor: r,
143
- tertiaryColor: o,
144
- quaternaryColor: n,
145
- backgroundColor: a,
146
- forceTextColor: s
147
- } = t, c = x(a, s), i = x(e, s), f = x(r), u = x(o), l = x(n);
148
- return {
149
- "--primary-color": e,
150
- "--primary-color-light": d(e, 10),
151
- "--primary-color-hover": y(
152
- e,
153
- i,
154
- -10
155
- ),
156
- "--text-color-primary": i,
157
- "--text-color-primary-contrast": c,
158
- "--text-color": c,
159
- "--text-color-light": A(a, c),
160
- "--text-color-lighter": A(
161
- a,
162
- c
163
- ),
164
- "--secondary-color": r,
165
- "--secondary-color-light": d(r, 10),
166
- "--secondary-color-hover": y(
167
- r,
168
- f,
169
- -10
170
- ),
171
- "--text-color-secondary": f,
172
- "--tertiary-color": o,
173
- "--tertiary-color-light": d(o, 10),
174
- "--tertiary-color-hover": y(
175
- o,
176
- u,
177
- -10
178
- ),
179
- "--text-color-tertiary": u,
180
- "--quaternary-color": n,
181
- "--quaternary-color-light": d(n, 10),
182
- "--quaternary-color-hover": y(
183
- n,
184
- l,
185
- -10
186
- ),
187
- "--text-color-quaternary": l,
188
- "--background-color": a,
189
- "--background-color-dark": d(a, -10),
190
- "--background-color-darker": d(a, -25),
191
- "--background-color-light": d(a, 10),
192
- "--background-color-lighter": d(a, 20),
193
- "--link-color": c,
194
- "--link-hover-color": U(
195
- a,
196
- c,
197
- c === "#ffffff" ? -20 : 20
198
- ),
199
- "--link-hover-color-primary": y(
200
- e,
201
- i,
202
- -10
203
- ),
204
- "--link-hover-color-secondary": y(
205
- r,
206
- f,
207
- -10
208
- ),
209
- "--link-hover-color-tertiary": y(
210
- o,
211
- u,
212
- -10
213
- ),
214
- "--link-hover-color-quaternary": y(
215
- n,
216
- l,
217
- -10
218
- ),
219
- "--focus-outline-color": c,
220
- "--divider-color": M(a),
221
- "--border-color": M(a),
222
- "--border-color-subtle": M(a, 10, 10),
223
- "--border-color-strong": M(a, 20, 20)
224
- };
225
- }
226
- function X(t, e) {
227
- for (const [r, o] of Object.entries(e))
228
- t.setProperty(r, o);
229
- }
230
- function Y(t, e = document) {
231
- X(
232
- e.documentElement.style,
233
- W(t)
234
- ), e.documentElement.dataset.borealTheme = t.name;
235
- }
236
- function Q({
237
- customSchemes: t = [],
238
- initialSchemeName: e,
239
- useOnlyCustomSchemes: r = !1
240
- } = {}) {
241
- const o = R({ customSchemes: t, useOnlyCustomSchemes: r }), n = O();
242
- return `(function(){try{var s=${JSON.stringify(o).replace(/</g, "\\u003c")};var k=${JSON.stringify(S)};var initial=${JSON.stringify(e ?? null)};var fallback=${JSON.stringify(n)};var saved=null;try{saved=localStorage.getItem(k)}catch(e){}var name=initial||saved||fallback;var scheme=s.find(function(x){return x.name===name})||s.find(function(x){return x.name===fallback})||s[0];if(!scheme)return;var d=document.documentElement.style;var hex=function(v){v=String(v||"").trim();var m=/^#([\\da-f])([\\da-f])([\\da-f])$/i.exec(v);if(m)return("#"+m[1]+m[1]+m[2]+m[2]+m[3]+m[3]).toLowerCase();return /^#[\\da-f]{6}([\\da-f]{2})?$/i.test(v)?v.slice(0,7).toLowerCase():"#000000"};var lum=function(v){v=hex(v);var r=[1,3,5].map(function(i){var c=parseInt(v.slice(i,i+2),16)/255;return c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4)});return .2126*r[0]+.7152*r[1]+.0722*r[2]};var contrast=function(a,b){var x=lum(a),y=lum(b),l=Math.max(x,y),q=Math.min(x,y);return(l+.05)/(q+.05)};var text=function(bg,preferred,min){min=min||4.5;if(preferred&&contrast(bg,preferred)>=min)return preferred;return contrast(bg,"#000000")>=contrast(bg,"#ffffff")?"#000000":"#ffffff"};var set=function(n,v){d.setProperty(n,v)};var page=text(scheme.backgroundColor,scheme.forceTextColor);set("--primary-color",scheme.primaryColor);set("--secondary-color",scheme.secondaryColor);set("--tertiary-color",scheme.tertiaryColor);set("--quaternary-color",scheme.quaternaryColor);set("--background-color",scheme.backgroundColor);set("--text-color",page);set("--text-color-primary",text(scheme.primaryColor,scheme.forceTextColor));set("--text-color-primary-contrast",page);set("--text-color-secondary",text(scheme.secondaryColor));set("--text-color-tertiary",text(scheme.tertiaryColor));set("--text-color-quaternary",text(scheme.quaternaryColor));set("--link-color",page);set("--focus-outline-color",page);document.documentElement.dataset.borealTheme=scheme.name}catch(e){}})();`;
243
- }
244
- const Z = F(
245
- void 0
246
- ), ne = ({
247
- children: t,
248
- customSchemes: e = [],
249
- enableThemeScript: r = !0,
250
- initialSchemeName: o,
251
- useOnlyCustomSchemes: n = !1
252
- }) => {
253
- const a = k(
254
- () => JSON.stringify(e ?? []),
255
- [e]
256
- ), s = k(() => {
257
- try {
258
- const l = JSON.parse(a);
259
- if (Array.isArray(l))
260
- return l;
261
- } catch {
262
- console.error("Failed to parse custom schemes");
263
- }
264
- return [];
265
- }, [a]), c = k(
266
- () => R({
267
- customSchemes: s,
268
- useOnlyCustomSchemes: n
269
- }),
270
- [s, n]
271
- ), [i, f] = V(
272
- () => q(c, {
273
- initialSchemeName: o,
274
- savedSchemeName: typeof window > "u" ? null : T(window.localStorage)
275
- })
276
- ), u = z(!1);
277
- return I(() => {
278
- const l = q(c, {
279
- initialSchemeName: o,
280
- savedSchemeName: typeof window > "u" ? null : T(window.localStorage)
281
- });
282
- f((h) => o ? l : c[h] ? h : l);
283
- }, [c, o]), P(() => {
284
- const l = c[i] ?? c[0];
285
- !l || typeof document > "u" || Y(l, document);
286
- }, [i, c]), I(() => {
287
- if (typeof window > "u") return;
288
- const l = (m) => {
289
- const g = C(c, m);
290
- g !== -1 && f(
291
- (p) => p === g ? p : g
292
- );
293
- }, h = (m) => {
294
- var p;
295
- l((p = m.detail) == null ? void 0 : p.schemeName);
296
- }, b = (m) => {
297
- m.key === S && l(m.newValue);
298
- };
299
- return window.addEventListener(E, h), window.addEventListener("storage", b), l(T(window.localStorage)), () => {
300
- window.removeEventListener(E, h), window.removeEventListener("storage", b);
301
- };
302
- }, [c]), I(() => {
303
- const l = c[i] ?? c[0];
304
- if (!l) return;
305
- const h = typeof window > "u" ? void 0 : window.localStorage, b = T(h), m = C(c, b);
306
- if (!u.current && !o && m !== -1 && m !== i) {
307
- u.current = !0, f(m);
308
- return;
309
- }
310
- u.current = !0, G(h, l.name) && K(l.name);
311
- }, [o, i, c]), /* @__PURE__ */ J(
312
- Z.Provider,
313
- {
314
- value: {
315
- selectedScheme: i,
316
- setSelectedScheme: f,
317
- schemes: c
318
- },
319
- children: [
320
- r ? /* @__PURE__ */ j(
321
- "script",
322
- {
323
- dangerouslySetInnerHTML: {
324
- __html: Q({
325
- customSchemes: s,
326
- initialSchemeName: o,
327
- useOnlyCustomSchemes: n
328
- })
329
- },
330
- suppressHydrationWarning: !0
331
- }
332
- ) : null,
333
- t
334
- ]
335
- }
336
- );
337
- };
338
- export {
339
- Z as T,
340
- ne as a,
341
- Q as g
342
- };
@@ -1,72 +0,0 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { forwardRef as U, useContext as q, useMemo as R } from "react";
3
- import "./globals.js";
4
- import { g as j, a as E, b as M } from "./boreal-style-config-rYvfCHLY.js";
5
- import { S as P } from "./Select-BJoe21vP.js";
6
- import { T as W } from "./ThemeContext-19HbcfZg.js";
7
- const k = U(
8
- ({
9
- theme: n = j(),
10
- glass: s,
11
- shadow: o = E(),
12
- rounding: d = M(),
13
- state: l = "",
14
- "data-testid": m,
15
- testId: c = m ?? "theme-select",
16
- "aria-label": h = "Select Theme",
17
- "aria-description": u,
18
- "aria-labelledby": b,
19
- "aria-describedby": p,
20
- "aria-invalid": f,
21
- "aria-required": g,
22
- disabled: S,
23
- label: x,
24
- labelPosition: T,
25
- name: v,
26
- id: w
27
- }, y) => {
28
- const r = q(W);
29
- if (!r)
30
- throw new Error("ThemeContext is undefined. Wrap with ThemeProvider.");
31
- const { selectedScheme: C, setSelectedScheme: N, schemes: a } = r, D = R(
32
- () => a.map((t, e) => ({
33
- value: String(e),
34
- label: t.name
35
- })),
36
- [a]
37
- ), I = (t) => {
38
- const e = Number.parseInt(String(t), 10);
39
- !Number.isInteger(e) || !a[e] || N(e);
40
- };
41
- return /* @__PURE__ */ i("div", { className: "control-container", children: /* @__PURE__ */ i(
42
- P,
43
- {
44
- ref: y,
45
- theme: n,
46
- glass: s,
47
- state: l,
48
- shadow: o,
49
- rounding: d,
50
- options: D,
51
- "data-testid": c,
52
- value: String(C),
53
- "aria-label": h,
54
- "aria-description": u,
55
- "aria-labelledby": b,
56
- "aria-describedby": p,
57
- "aria-invalid": f,
58
- "aria-required": g,
59
- disabled: S,
60
- label: x,
61
- labelPosition: T,
62
- name: v,
63
- id: w,
64
- onChange: I
65
- }
66
- ) });
67
- }
68
- );
69
- k.displayName = "UserThemeSettings";
70
- export {
71
- k as U
72
- };