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 +1 @@
1
- {"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../../src/context/ThemeContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAc5E,eAAO,MAAM,YAAY,6CAExB,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2J/C,CAAC;AAEF,eAAe,aAAa,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../../src/context/ThemeContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAc5E,eAAO,MAAM,YAAY,6CAExB,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA2L/C,CAAC;AAEF,eAAe,aAAa,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC"}
@@ -35,15 +35,19 @@ export interface ThemeProviderProps {
35
35
  * Context value provided by the ThemeProvider.
36
36
  *
37
37
  * @property {number} selectedScheme - Index of the currently active color scheme.
38
+ * @property {string} selectedSchemeName - Name of the currently active color scheme.
38
39
  * @property {ColorScheme[]} schemes - Array of available color schemes.
39
40
  * @property {Dispatch<SetStateAction<number>>} setSelectedScheme - Function to update the selected scheme index.
41
+ * @property {Dispatch<SetStateAction<string>>} setSelectedSchemeName - Function to update the selected scheme name.
40
42
  *
41
43
  * @example
42
- * const { selectedScheme, setSelectedScheme } = useContext(ThemeContext);
44
+ * const { selectedSchemeName, setSelectedSchemeName } = useContext(ThemeContext);
43
45
  */
44
46
  export interface ThemeContextType {
45
47
  selectedScheme: number;
48
+ selectedSchemeName: string;
46
49
  schemes: ColorScheme[];
47
50
  setSelectedScheme: React.Dispatch<React.SetStateAction<number>>;
51
+ setSelectedSchemeName: React.Dispatch<React.SetStateAction<string>>;
48
52
  }
49
53
  //# sourceMappingURL=ThemeContext.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeContext.types.d.ts","sourceRoot":"","sources":["../../../src/context/ThemeContext.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CACjE"}
1
+ {"version":3,"file":"ThemeContext.types.d.ts","sourceRoot":"","sources":["../../../src/context/ThemeContext.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAChE,qBAAqB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CACrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boreal-ui",
3
- "version": "0.0.892",
3
+ "version": "0.0.894",
4
4
  "readme": "README.npm.md",
5
5
  "description": "A modern, customizable React/Next.js component library",
6
6
  "author": "Davin Chiupka",
@@ -1 +0,0 @@
1
- "use strict";const N=require("react/jsx-runtime"),h=require("react"),R=require("./boreal-style-config-BB8MdwYx.cjs"),z=require("./colorSchemes.cjs.js"),b="boreal:selectedSchemeName",k="boreal:theme-change",w=4.5,$=3;function P(t,e=[]){const r=[...t];for(const o of e){const n=r.findIndex(a=>a.name===o.name);n>=0?r[n]=o:r.push(o)}return r}function C(t,e){return e?t.findIndex(r=>r.name===e):-1}function O({customSchemes:t=[],useOnlyCustomSchemes:e=!1}){return e?[...t]:P([...z.defaultColorSchemes],t)}function L(t,{initialSchemeName:e,savedSchemeName:r}){const o=C(t,e),n=C(t,r),a=C(t,R.getDefaultColorSchemeName());return o!==-1?o:n!==-1?n:a!==-1?a:0}function M(t){if(!t)return null;try{return t.getItem(b)}catch{return console.error("Failed to load saved theme name"),null}}function V(t,e){if(!t)return!1;try{return t.getItem(b)===e?!1:(t.setItem(b,e),!0)}catch{return console.error("Failed to save theme name"),!1}}function D(t,e=typeof window>"u"?void 0:window){e&&e.dispatchEvent(new CustomEvent(k,{detail:{schemeName:t}}))}function j(t){const e=t.trim(),r=/^#([\da-f])([\da-f])([\da-f])$/i.exec(e);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}function E(t){const e=j(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);let c=0,i=0;const f=(a+s)/2;if(a!==s){const u=a-s;switch(i=f>.5?u/(2-a-s):u/(a+s),a){case r:c=(o-n)/u+(o<n?6:0);break;case o:c=(n-r)/u+2;break;case n:c=(r-o)/u+4;break}c/=6}return{h:Math.round(c*360),s:Math.round(i*100),l:Math.round(f*100)}}function q(t,e,r){e/=100,r/=100;const o=s=>(s+t/30)%12,n=e*Math.min(r,1-r),a=s=>Math.round(255*(r-n*Math.max(-1,Math.min(o(s)-3,Math.min(9-o(s),1)))));return`#${[a(0),a(8),a(4)].map(s=>s.toString(16).padStart(2,"0")).join("")}`}function d(t,e){const{h:r,s:o,l:n}=E(t);return q(r,o,Math.min(100,Math.max(0,n+e)))}function _(t){const e=j(t)??"#000000",r=[1,3,5].map(o=>{const n=parseInt(e.slice(o,o+2),16)/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)});return .2126*r[0]+.7152*r[1]+.0722*r[2]}function x(t,e){const r=_(t),o=_(e),n=Math.max(r,o),a=Math.min(r,o);return(n+.05)/(a+.05)}function g(t,e,r=w){if(e&&x(t,e)>=r)return e;const o=x(t,"#000000"),n=x(t,"#ffffff");return o>=n?"#000000":"#ffffff"}function F(t,e,r){const o=d(e,r);return x(t,o)>=w?o:e}function A(t,e){const r=e==="#000000"?1:-1;for(let o=30;o>=0;o-=5){const n=d(e,o*r);if(x(t,n)>=w)return n}return e}function v(t,e,r){const o=d(t,r);if(x(o,e)>=w)return o;const{h:n,s:a,l:s}=E(t),c=e==="#ffffff";for(let i=4;i<=48;i+=4){const f=c?Math.max(0,s-i):Math.min(100,s+i),u=q(n,a,f);if(x(u,e)>=w)return u}return t}function I(t,e=14,r=14){const{h:o,s:n,l:a}=E(t),s=a>=50?Math.max(0,a-r):Math.min(100,a+e),c=n>8?Math.max(0,n-8):n,i=q(o,c,s);return x(t,i)>=$?i:g(t,void 0,$)}function B(t){const{primaryColor:e,secondaryColor:r,tertiaryColor:o,quaternaryColor:n,backgroundColor:a,forceTextColor:s}=t,c=g(a,s),i=g(e,s),f=g(r),u=g(o),l=g(n);return{"--primary-color":e,"--primary-color-light":d(e,10),"--primary-color-hover":v(e,i,-10),"--text-color-primary":i,"--text-color-primary-contrast":c,"--text-color":c,"--text-color-light":A(a,c),"--text-color-lighter":A(a,c),"--secondary-color":r,"--secondary-color-light":d(r,10),"--secondary-color-hover":v(r,f,-10),"--text-color-secondary":f,"--tertiary-color":o,"--tertiary-color-light":d(o,10),"--tertiary-color-hover":v(o,u,-10),"--text-color-tertiary":u,"--quaternary-color":n,"--quaternary-color-light":d(n,10),"--quaternary-color-hover":v(n,l,-10),"--text-color-quaternary":l,"--background-color":a,"--background-color-dark":d(a,-10),"--background-color-darker":d(a,-25),"--background-color-light":d(a,10),"--background-color-lighter":d(a,20),"--link-color":c,"--link-hover-color":F(a,c,c==="#ffffff"?-20:20),"--link-hover-color-primary":v(e,i,-10),"--link-hover-color-secondary":v(r,f,-10),"--link-hover-color-tertiary":v(o,u,-10),"--link-hover-color-quaternary":v(n,l,-10),"--focus-outline-color":c,"--divider-color":I(a),"--border-color":I(a),"--border-color-subtle":I(a,10,10),"--border-color-strong":I(a,20,20)}}function G(t,e){for(const[r,o]of Object.entries(e))t.setProperty(r,o)}function K(t,e=document){G(e.documentElement.style,B(t)),e.documentElement.dataset.borealTheme=t.name}function H({customSchemes:t=[],initialSchemeName:e,useOnlyCustomSchemes:r=!1}={}){const o=O({customSchemes:t,useOnlyCustomSchemes:r}),n=R.getDefaultColorSchemeName();return`(function(){try{var s=${JSON.stringify(o).replace(/</g,"\\u003c")};var k=${JSON.stringify(b)};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){}})();`}const J=h.createContext(void 0),U=({children:t,customSchemes:e=[],enableThemeScript:r=!0,initialSchemeName:o,useOnlyCustomSchemes:n=!1})=>{const a=h.useMemo(()=>JSON.stringify(e??[]),[e]),s=h.useMemo(()=>{try{const l=JSON.parse(a);if(Array.isArray(l))return l}catch{console.error("Failed to parse custom schemes")}return[]},[a]),c=h.useMemo(()=>O({customSchemes:s,useOnlyCustomSchemes:n}),[s,n]),[i,f]=h.useState(()=>L(c,{initialSchemeName:o,savedSchemeName:typeof window>"u"?null:M(window.localStorage)})),u=h.useRef(!1);return h.useEffect(()=>{const l=L(c,{initialSchemeName:o,savedSchemeName:typeof window>"u"?null:M(window.localStorage)});f(y=>o?l:c[y]?y:l)},[c,o]),h.useInsertionEffect(()=>{const l=c[i]??c[0];!l||typeof document>"u"||K(l,document)},[i,c]),h.useEffect(()=>{if(typeof window>"u")return;const l=m=>{const p=C(c,m);p!==-1&&f(S=>S===p?S:p)},y=m=>{var S;l((S=m.detail)==null?void 0:S.schemeName)},T=m=>{m.key===b&&l(m.newValue)};return window.addEventListener(k,y),window.addEventListener("storage",T),l(M(window.localStorage)),()=>{window.removeEventListener(k,y),window.removeEventListener("storage",T)}},[c]),h.useEffect(()=>{const l=c[i]??c[0];if(!l)return;const y=typeof window>"u"?void 0:window.localStorage,T=M(y),m=C(c,T);if(!u.current&&!o&&m!==-1&&m!==i){u.current=!0,f(m);return}u.current=!0,V(y,l.name)&&D(l.name)},[o,i,c]),N.jsxs(J.Provider,{value:{selectedScheme:i,setSelectedScheme:f,schemes:c},children:[r?N.jsx("script",{dangerouslySetInnerHTML:{__html:H({customSchemes:s,initialSchemeName:o,useOnlyCustomSchemes:n})},suppressHydrationWarning:!0}):null,t]})};exports.ThemeContext=J;exports.ThemeProvider=U;exports.getThemeInitializationScript=H;
@@ -1,342 +0,0 @@
1
- import { jsxs as J, jsx as j } from "react/jsx-runtime";
2
- import { createContext as V, useMemo as k, useState as z, useRef as P, useEffect as I, useInsertionEffect 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 = V(
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] = z(
272
- () => q(c, {
273
- initialSchemeName: o,
274
- savedSchemeName: typeof window > "u" ? null : T(window.localStorage)
275
- })
276
- ), u = P(!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]), F(() => {
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 +0,0 @@
1
- "use strict";const s=require("react/jsx-runtime"),a=require("react"),U=require("./Select-BkErbR5B.cjs"),E=require("./ThemeContext-D1VVOPG1.cjs"),i=require("./boreal-style-config-BB8MdwYx.cjs"),l=a.forwardRef(({theme:o=i.getDefaultTheme(),glass:c,shadow:d=i.getDefaultShadow(),rounding:u=i.getDefaultRounding(),"data-testid":m,testId:h=m??"theme-select",state:b="","aria-label":g="Select Theme","aria-description":S,"aria-labelledby":x,"aria-describedby":f,"aria-invalid":T,"aria-required":p,disabled:q,label:C,labelPosition:v,name:y,id:w},N)=>{const n=a.useContext(E.ThemeContext);if(!n)throw new Error("ThemeContext is undefined. Wrap with ThemeProvider.");const{selectedScheme:R,setSelectedScheme:j,schemes:t}=n,D=a.useMemo(()=>t.map((r,e)=>({value:String(e),label:r.name})),[t]),I=r=>{const e=Number.parseInt(String(r),10);!Number.isInteger(e)||!t[e]||j(e)};return s.jsx("div",{className:"control-container",children:s.jsx(U.Select,{ref:N,theme:o,glass:c,state:b,shadow:d,rounding:u,options:D,"data-testid":h,value:String(R),"aria-label":g,"aria-description":S,"aria-labelledby":x,"aria-describedby":f,"aria-invalid":T,"aria-required":p,disabled:q,label:C,labelPosition:v,name:y,id:w,onChange:I})})});l.displayName="UserThemeSettings";exports.UserThemeSettings=l;
@@ -1,71 +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 { S as j } from "./Select-BtEKKotT.js";
4
- import { T as E } from "./ThemeContext-DRXOWRyX.js";
5
- import { g as M, a as P, b as W } from "./boreal-style-config-rYvfCHLY.js";
6
- const k = U(
7
- ({
8
- theme: n = M(),
9
- glass: s,
10
- shadow: o = P(),
11
- rounding: d = W(),
12
- "data-testid": l,
13
- testId: m = l ?? "theme-select",
14
- state: c = "",
15
- "aria-label": h = "Select Theme",
16
- "aria-description": u,
17
- "aria-labelledby": b,
18
- "aria-describedby": f,
19
- "aria-invalid": g,
20
- "aria-required": p,
21
- disabled: S,
22
- label: x,
23
- labelPosition: T,
24
- name: v,
25
- id: w
26
- }, y) => {
27
- const r = q(E);
28
- if (!r)
29
- throw new Error("ThemeContext is undefined. Wrap with ThemeProvider.");
30
- const { selectedScheme: C, setSelectedScheme: N, schemes: a } = r, D = R(
31
- () => a.map((t, e) => ({
32
- value: String(e),
33
- label: t.name
34
- })),
35
- [a]
36
- ), I = (t) => {
37
- const e = Number.parseInt(String(t), 10);
38
- !Number.isInteger(e) || !a[e] || N(e);
39
- };
40
- return /* @__PURE__ */ i("div", { className: "control-container", children: /* @__PURE__ */ i(
41
- j,
42
- {
43
- ref: y,
44
- theme: n,
45
- glass: s,
46
- state: c,
47
- shadow: o,
48
- rounding: d,
49
- options: D,
50
- "data-testid": m,
51
- value: String(C),
52
- "aria-label": h,
53
- "aria-description": u,
54
- "aria-labelledby": b,
55
- "aria-describedby": f,
56
- "aria-invalid": g,
57
- "aria-required": p,
58
- disabled: S,
59
- label: x,
60
- labelPosition: T,
61
- name: v,
62
- id: w,
63
- onChange: I
64
- }
65
- ) });
66
- }
67
- );
68
- k.displayName = "UserThemeSettings";
69
- export {
70
- k as U
71
- };