boreal-ui 0.0.892 → 0.0.893
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/core/{Footer-CmpLvoZb.cjs → Footer-BJY3pJtI.cjs} +1 -1
- package/dist/core/{Footer-CoFPqecX.js → Footer-_sn6Lt4E.js} +1 -1
- package/dist/core/Footer.cjs.js +1 -1
- package/dist/core/Footer.js +1 -1
- package/dist/core/{ThemeContext-D1VVOPG1.cjs → ThemeContext-In2I5IqP.cjs} +1 -1
- package/dist/core/{ThemeContext-DRXOWRyX.js → ThemeContext-xujmsbbI.js} +49 -49
- package/dist/core/ThemeProvider.cjs.js +1 -1
- package/dist/core/ThemeProvider.js +1 -1
- package/dist/core/{ThemeSelect-DxmyeZm_.js → ThemeSelect-BuKiPMK0.js} +1 -1
- package/dist/core/{ThemeSelect-CPpf-wbN.cjs → ThemeSelect-gR32Y8Ct.cjs} +1 -1
- package/dist/core/ThemeSelect.cjs.js +1 -1
- package/dist/core/ThemeSelect.js +1 -1
- package/dist/core/index.cjs.js +1 -1
- package/dist/core/index.js +3 -3
- package/dist/next/{Footer-D78Lzvjg.js → Footer-f4QC8dxP.js} +1 -1
- package/dist/next/Footer.js +1 -1
- package/dist/next/{NextThemeProvider-NpALBYoC.js → NextThemeProvider-DqpRUO1w.js} +1 -1
- package/dist/next/{ThemeContext-19HbcfZg.js → ThemeContext-Cdq5ypM0.js} +49 -49
- package/dist/next/ThemeProvider.js +2 -2
- package/dist/next/{ThemeSelect-BdFqSfT_.js → ThemeSelect-C-YFhG7Y.js} +1 -1
- package/dist/next/ThemeSelect.js +1 -1
- package/dist/next/index.js +4 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/context/ThemeContext.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";require('./Footer.css');const t=require("react/jsx-runtime"),ie=require("./propAliases-Bfsf5cJN.cjs"),Be=require("react"),r=require("./classNames-C7V3kfBj.cjs"),se=require("./boreal-style-config-BB8MdwYx.cjs"),y=require("./capitalize-CnTiekgk.cjs"),Ge=require("./IconButton-O0x6cSnS.cjs"),Re=require("./ThemeSelect-
|
|
1
|
+
"use strict";require('./Footer.css');const t=require("react/jsx-runtime"),ie=require("./propAliases-Bfsf5cJN.cjs"),Be=require("react"),r=require("./classNames-C7V3kfBj.cjs"),se=require("./boreal-style-config-BB8MdwYx.cjs"),y=require("./capitalize-CnTiekgk.cjs"),Ge=require("./IconButton-O0x6cSnS.cjs"),Re=require("./ThemeSelect-gR32Y8Ct.cjs"),k=c=>c.toLowerCase().trim().replace(/\s+/g,"-"),le=({theme:c=se.getDefaultTheme(),glass:v=se.getDefaultGlass(),attachment:ce="static",shadow:S="none",rounding:w="none",layout:m="inline",className:z="","data-testid":me,testId:n=me??"footer",copyright:i,copyrightInBottom:he,links:b=[],sections:q,logo:l,brandTitle:u,brandDescription:B,brandHref:G,brandTarget:R,brandRel:fe,socialLinks:N=[],showThemeSelect:E=!1,themeSelectLabel:be="Theme",bottomEnd:F,contentClassName:L,leftClassName:P,linksClassName:ue,linkClassName:Ne,logoClassName:T,socialClassName:xe,themeToggleClassName:je,brandClassName:_e,brandLinkClassName:U,brandTitleClassName:ge,brandDescriptionClassName:$e,sectionsClassName:Ce,sectionTitleClassName:H,actionsClassName:ye,actionGroupClassName:ve,bottomClassName:Se,bottomCopyrightClassName:we,bottomEndClassName:qe,copyrightClassName:J,IconButton:Fe,ImageComponent:K="img",ThemeSelect:Te,classMap:o,LinkWrapper:O=({href:j,children:_,...A})=>t.jsx("a",{href:j,...A,children:_}),"aria-label":Q,"aria-labelledby":V,"aria-describedby":W,navAriaLabel:X="Footer site links",socialNavAriaLabel:pe="Social media",themeSelectAriaLabel:Y="Theme selector",logoAriaLabel:x="Logo",logoDecorative:d=!1,labelId:f,...Z})=>{const j=ie.resolvePropAlias(ce),_=Be.useMemo(()=>r.combineClassNames(o.footer,o[c],v&&o.glass,m!=="inline"&&o[`layout${y.capitalize(m)}`],S!=="none"&&o[`shadow${y.capitalize(S)}`],w!=="none"&&o[`round${y.capitalize(w)}`],o[`attachment${y.capitalize(j)}`],z),[o,c,v,m,S,w,j,z]),D=typeof l=="string"||(e=>typeof e=="object"&&e!==null&&"src"in e)(l),a=D?typeof l=="string"?{src:l}:l:void 0,p=a==null?void 0:a.src,I=(a==null?void 0:a.width)??20,M=(a==null?void 0:a.height)??20,ee=q&&q.length>0?q:b.length>0?[{title:"Links",links:b,"aria-label":X,testId:"links"}]:[],te=he??m==="columns",oe=()=>D&&p?typeof K=="string"?t.jsx("img",{className:r.combineClassNames(o.logo,T),"data-testid":`${n}-logo`,loading:"lazy",src:p,alt:d?"":x,"aria-hidden":d?!0:void 0,height:M,width:I}):t.jsx(K,{className:r.combineClassNames(o.logo,T),"data-testid":`${n}-logo`,src:p,alt:d?"":x,"aria-hidden":d?!0:void 0,height:M,width:I}):l?t.jsx("span",{className:r.combineClassNames(o.logo,T),role:d?void 0:"img","aria-label":d?void 0:x,"aria-hidden":d?!0:void 0,"data-testid":`${n}-logo`,children:l}):null,re=(e,s,g)=>{const h=k(e.label||e.href||`link-${s}`),$=`${e.href??h}-${s}`,C=r.combineClassNames(o.link,g);return e.disabled?t.jsx("li",{children:t.jsx("span",{className:C,"data-testid":`${n}-link-${h}`,"aria-disabled":"true",title:e.title,children:e.label})},$):t.jsx("li",{children:t.jsx(O,{href:e.href,className:C,"data-testid":`${n}-link-${h}`,"aria-label":e["aria-label"],"aria-current":e["aria-current"],title:e.title,rel:e.rel,target:e.target,children:e.label})},$)},ne=()=>N.length===0?null:t.jsx("nav",{className:r.combineClassNames(o.social,xe),"aria-label":pe,"data-testid":`${n}-social`,children:N.map((e,s)=>t.jsx(Fe,{icon:e.icon,href:e.href,isExternal:e.isExternal??!0,shadow:"none","aria-label":e["aria-label"]??e.title,title:e.tooltip??e.title,theme:"clear",glass:v,disabled:e.disabled,rel:e.rel,target:e.target,"data-testid":`${n}-social-${k(e.title)}`},`${e.href??e.title}-${s}`))}),ae=()=>E?t.jsx("div",{className:r.combineClassNames(o.themeToggle,je),"data-testid":`${n}-theme-select`,"aria-label":Y,children:t.jsx(Te,{theme:"clear",label:be,labelPosition:m==="columns"?"top":"left",shadow:"none","aria-label":Y})}):null,ke=()=>{const e=t.jsxs(t.Fragment,{children:[oe(),u&&t.jsx("span",{className:r.combineClassNames(o.brandTitle,ge),"data-testid":`${n}-brand-title`,children:u})]});return t.jsxs("div",{className:r.combineClassNames(o.brand,_e),"data-testid":`${n}-brand`,children:[G?t.jsx(O,{href:G,className:r.combineClassNames(o.brandLink,U),target:R,rel:fe??(R==="_blank"?"noopener noreferrer":void 0),"aria-label":typeof u=="string"?u:x,children:e}):t.jsx("div",{className:r.combineClassNames(o.brandLink,U),children:e}),B&&t.jsx("p",{className:r.combineClassNames(o.brandDescription,$e),"data-testid":`${n}-brand-description`,children:B}),i&&!te&&t.jsx("div",{className:r.combineClassNames(o.copyright,J),"data-testid":`${n}-copyright`,children:t.jsx("p",{id:f,children:i})})]})},ze=()=>ee.length===0?null:t.jsx("div",{className:r.combineClassNames(o.sections,Ce),"data-testid":`${n}-sections`,children:ee.map((e,s)=>{const g=typeof e.title=="string"?e.title:`section-${s+1}`,h=e.testId??k(g);return t.jsxs("nav",{className:r.combineClassNames(o.section,e.className),"aria-label":e["aria-label"]??`${g} links`,"data-testid":`${n}-section-${h}`,children:[t.jsx("h2",{className:r.combineClassNames(o.sectionTitle,H,e.titleClassName),children:e.title}),t.jsx("ul",{className:r.combineClassNames(o.sectionList,e.listClassName),children:e.links.map(($,C)=>re($,C,e.linkClassName))})]},h)})});return m==="columns"?t.jsxs("footer",{className:_,"data-testid":n,role:"contentinfo","aria-label":Q,"aria-labelledby":V??f,"aria-describedby":W,...Z,children:[t.jsxs("div",{className:r.combineClassNames(o.content,L),children:[ke(),ze(),(N.length>0||E)&&t.jsxs("div",{className:r.combineClassNames(o.actions,ye),"data-testid":`${n}-actions`,children:[N.length>0&&t.jsxs("div",{className:r.combineClassNames(o.actionGroup,ve),children:[t.jsx("h2",{className:r.combineClassNames(o.sectionTitle,H),children:"Connect"}),ne()]}),ae()]})]}),(i||F)&&t.jsxs("div",{className:r.combineClassNames(o.bottom,Se),"data-testid":`${n}-bottom`,children:[i&&te&&t.jsx("p",{id:f,className:r.combineClassNames(o.bottomCopyright,we),"data-testid":`${n}-copyright`,children:i}),F&&t.jsx("div",{className:r.combineClassNames(o.bottomEnd,qe),"data-testid":`${n}-bottom-end`,children:F})]})]}):t.jsx("footer",{className:_,"data-testid":n,role:"contentinfo","aria-label":Q,"aria-labelledby":V??f,"aria-describedby":W,...Z,children:t.jsxs("div",{className:r.combineClassNames(o.content,L),children:[t.jsxs("div",{className:r.combineClassNames(o.left,P),"data-testid":`${n}-left`,children:[oe(),i&&t.jsx("div",{className:r.combineClassNames(o.copyright,J)??r.combineClassNames(o.left,P),"data-testid":`${n}-copyright`,children:t.jsx("p",{id:f,children:i})})]}),b.length>0&&t.jsx("nav",{className:r.combineClassNames(o.links,ue),"aria-label":X,"data-testid":`${n}-nav`,children:t.jsx("ul",{children:b.map((e,s)=>re(e,s,Ne))})}),ae(),ne()]})})};le.displayName="FooterBase";const Ee={footer:"footer",glass:"footer_glass",primary:"footer_primary",secondary:"footer_secondary",tertiary:"footer_tertiary",quaternary:"footer_quaternary",clear:"footer_clear",layoutColumns:"footer_layout-columns",shadowNone:"footer_shadow-None",shadowLight:"footer_shadow-Light",shadowMedium:"footer_shadow-Medium",shadowStrong:"footer_shadow-Strong",shadowIntense:"footer_shadow-Intense",roundNone:"footer_round-None",roundSmall:"footer_round-Small",roundMedium:"footer_round-Medium",roundLarge:"footer_round-Large",attachmentStatic:"footer_attachment-static",attachmentFixed:"footer_attachment-fixed",attachmentSticky:"footer_attachment-sticky",content:"footer_content",logo:"footer_logo",left:"footer_left",links:"footer_links",link:"footer_link",social:"footer_social",themeToggle:"footer_theme-toggle",copyright:"footer_copyright",brand:"footer_brand",brandLink:"footer_brand-link",brandTitle:"footer_brand-title",brandDescription:"footer_brand-description",sections:"footer_sections",section:"footer_section",sectionTitle:"footer_section-title",sectionList:"footer_section-list",actions:"footer_actions",actionGroup:"footer_action-group",bottom:"footer_bottom",bottomCopyright:"footer_bottom-copyright",bottomEnd:"footer_bottom-end"},de=c=>t.jsx(le,{...c,IconButton:Ge.IconButton,ThemeSelect:Re.UserThemeSettings,classMap:ie.expandClassMap(Ee)});de.displayName="Footer";exports.Footer=de;
|
|
@@ -5,7 +5,7 @@ import { c as o } from "./classNames-Dz0_huu_.js";
|
|
|
5
5
|
import { g as Ee, f as Le } from "./boreal-style-config-rYvfCHLY.js";
|
|
6
6
|
import { c as p } from "./capitalize-D_pj4b3P.js";
|
|
7
7
|
import { I as Pe } from "./IconButton-Dq8m4yuP.js";
|
|
8
|
-
import { U as Ue } from "./ThemeSelect-
|
|
8
|
+
import { U as Ue } from "./ThemeSelect-BuKiPMK0.js";
|
|
9
9
|
import './Footer.css';const B = (h) => h.toLowerCase().trim().replace(/\s+/g, "-"), de = ({
|
|
10
10
|
theme: h = Ee(),
|
|
11
11
|
glass: F = Le(),
|
package/dist/core/Footer.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Footer-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./Footer-BJY3pJtI.cjs");exports.default=e.Footer;
|
package/dist/core/Footer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const N=require("react/jsx-runtime"),h=require("react"),R=require("./boreal-style-config-BB8MdwYx.cjs"),z=require("./colorSchemes.cjs.js"),
|
|
1
|
+
"use strict";const N=require("react/jsx-runtime"),h=require("react"),R=require("./boreal-style-config-BB8MdwYx.cjs"),z=require("./colorSchemes.cjs.js"),w="boreal:selectedSchemeName",k="boreal:theme-change",T=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 S(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=S(t,e),n=S(t,r),a=S(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(w)}catch{return console.error("Failed to load saved theme name"),null}}function V(t,e){if(!t)return!1;try{return t.getItem(w)===e?!1:(t.setItem(w,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 m(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 p(t,e,r=T){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=m(e,r);return x(t,o)>=T?o:e}function A(t,e){const r=e==="#000000"?1:-1;for(let o=30;o>=0;o-=5){const n=m(e,o*r);if(x(t,n)>=T)return n}return e}function v(t,e,r){const o=m(t,r);if(x(o,e)>=T)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)>=T)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:p(t,void 0,$)}function B(t){const{primaryColor:e,secondaryColor:r,tertiaryColor:o,quaternaryColor:n,backgroundColor:a,forceTextColor:s}=t,c=p(a,s),i=p(e,s),f=p(r),u=p(o),l=p(n);return{"--primary-color":e,"--primary-color-light":m(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":m(r,10),"--secondary-color-hover":v(r,f,-10),"--text-color-secondary":f,"--tertiary-color":o,"--tertiary-color-light":m(o,10),"--tertiary-color-hover":v(o,u,-10),"--text-color-tertiary":u,"--quaternary-color":n,"--quaternary-color-light":m(n,10),"--quaternary-color-hover":v(n,l,-10),"--text-color-quaternary":l,"--background-color":a,"--background-color-dark":m(a,-10),"--background-color-darker":m(a,-25),"--background-color-light":m(a,10),"--background-color-lighter":m(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(w)};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=typeof window>"u"?null:M(window.localStorage),y=S(c,l),g=L(c,{initialSchemeName:o,savedSchemeName:l});f(d=>o?g:y!==-1?y:c[d]?d:g)},[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=d=>{const C=S(c,d);C!==-1&&f(b=>b===C?b:C)},y=d=>{var b;l((b=d.detail)==null?void 0:b.schemeName)},g=d=>{d.key===w&&l(d.newValue)};return window.addEventListener(k,y),window.addEventListener("storage",g),l(M(window.localStorage)),()=>{window.removeEventListener(k,y),window.removeEventListener("storage",g)}},[c]),h.useEffect(()=>{const l=c[i]??c[0];if(!l)return;const y=typeof window>"u"?void 0:window.localStorage,g=M(y),d=S(c,g);if(!u.current&&!o&&d!==-1&&d!==i){u.current=!0,f(d);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,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as J, jsx as j } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as V, useMemo as
|
|
2
|
+
import { createContext as V, useMemo as I, useState as z, useRef as P, useEffect as k, useInsertionEffect as F } from "react";
|
|
3
3
|
import { c as O } from "./boreal-style-config-rYvfCHLY.js";
|
|
4
4
|
import { defaultColorSchemes as B } from "./colorSchemes.js";
|
|
5
|
-
const
|
|
5
|
+
const w = "boreal:selectedSchemeName", E = "boreal:theme-change", b = 4.5, L = 3;
|
|
6
6
|
function D(t, e = []) {
|
|
7
7
|
const r = [...t];
|
|
8
8
|
for (const o of e) {
|
|
@@ -11,7 +11,7 @@ function D(t, e = []) {
|
|
|
11
11
|
}
|
|
12
12
|
return r;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function p(t, e) {
|
|
15
15
|
return e ? t.findIndex((r) => r.name === e) : -1;
|
|
16
16
|
}
|
|
17
17
|
function R({
|
|
@@ -24,13 +24,13 @@ function q(t, {
|
|
|
24
24
|
initialSchemeName: e,
|
|
25
25
|
savedSchemeName: r
|
|
26
26
|
}) {
|
|
27
|
-
const o =
|
|
27
|
+
const o = p(t, e), n = p(t, r), a = p(t, O());
|
|
28
28
|
return o !== -1 ? o : n !== -1 ? n : a !== -1 ? a : 0;
|
|
29
29
|
}
|
|
30
30
|
function T(t) {
|
|
31
31
|
if (!t) return null;
|
|
32
32
|
try {
|
|
33
|
-
return t.getItem(
|
|
33
|
+
return t.getItem(w);
|
|
34
34
|
} catch {
|
|
35
35
|
return console.error("Failed to load saved theme name"), null;
|
|
36
36
|
}
|
|
@@ -38,7 +38,7 @@ function T(t) {
|
|
|
38
38
|
function G(t, e) {
|
|
39
39
|
if (!t) return !1;
|
|
40
40
|
try {
|
|
41
|
-
return t.getItem(
|
|
41
|
+
return t.getItem(w) === e ? !1 : (t.setItem(w, e), !0);
|
|
42
42
|
} catch {
|
|
43
43
|
return console.error("Failed to save theme name"), !1;
|
|
44
44
|
}
|
|
@@ -86,7 +86,7 @@ function $(t, e, r) {
|
|
|
86
86
|
);
|
|
87
87
|
return `#${[a(0), a(8), a(4)].map((s) => s.toString(16).padStart(2, "0")).join("")}`;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function m(t, e) {
|
|
90
90
|
const { h: r, s: o, l: n } = N(t);
|
|
91
91
|
return $(r, o, Math.min(100, Math.max(0, n + e)));
|
|
92
92
|
}
|
|
@@ -101,40 +101,40 @@ function v(t, e) {
|
|
|
101
101
|
const r = _(t), o = _(e), n = Math.max(r, o), a = Math.min(r, o);
|
|
102
102
|
return (n + 0.05) / (a + 0.05);
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function g(t, e, r = b) {
|
|
105
105
|
if (e && v(t, e) >= r)
|
|
106
106
|
return e;
|
|
107
107
|
const o = v(t, "#000000"), n = v(t, "#ffffff");
|
|
108
108
|
return o >= n ? "#000000" : "#ffffff";
|
|
109
109
|
}
|
|
110
110
|
function U(t, e, r) {
|
|
111
|
-
const o =
|
|
112
|
-
return v(t, o) >=
|
|
111
|
+
const o = m(e, r);
|
|
112
|
+
return v(t, o) >= b ? o : e;
|
|
113
113
|
}
|
|
114
114
|
function A(t, e) {
|
|
115
115
|
const r = e === "#000000" ? 1 : -1;
|
|
116
116
|
for (let o = 30; o >= 0; o -= 5) {
|
|
117
|
-
const n =
|
|
118
|
-
if (v(t, n) >=
|
|
117
|
+
const n = m(e, o * r);
|
|
118
|
+
if (v(t, n) >= b)
|
|
119
119
|
return n;
|
|
120
120
|
}
|
|
121
121
|
return e;
|
|
122
122
|
}
|
|
123
123
|
function y(t, e, r) {
|
|
124
|
-
const o =
|
|
125
|
-
if (v(o, e) >=
|
|
124
|
+
const o = m(t, r);
|
|
125
|
+
if (v(o, e) >= b)
|
|
126
126
|
return o;
|
|
127
127
|
const { h: n, s: a, l: s } = N(t), c = e === "#ffffff";
|
|
128
128
|
for (let i = 4; i <= 48; i += 4) {
|
|
129
129
|
const f = c ? Math.max(0, s - i) : Math.min(100, s + i), u = $(n, a, f);
|
|
130
|
-
if (v(u, e) >=
|
|
130
|
+
if (v(u, e) >= b)
|
|
131
131
|
return u;
|
|
132
132
|
}
|
|
133
133
|
return t;
|
|
134
134
|
}
|
|
135
135
|
function M(t, e = 14, r = 14) {
|
|
136
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 :
|
|
137
|
+
return v(t, i) >= L ? i : g(t, void 0, L);
|
|
138
138
|
}
|
|
139
139
|
function W(t) {
|
|
140
140
|
const {
|
|
@@ -144,10 +144,10 @@ function W(t) {
|
|
|
144
144
|
quaternaryColor: n,
|
|
145
145
|
backgroundColor: a,
|
|
146
146
|
forceTextColor: s
|
|
147
|
-
} = t, c =
|
|
147
|
+
} = t, c = g(a, s), i = g(e, s), f = g(r), u = g(o), l = g(n);
|
|
148
148
|
return {
|
|
149
149
|
"--primary-color": e,
|
|
150
|
-
"--primary-color-light":
|
|
150
|
+
"--primary-color-light": m(e, 10),
|
|
151
151
|
"--primary-color-hover": y(
|
|
152
152
|
e,
|
|
153
153
|
i,
|
|
@@ -162,7 +162,7 @@ function W(t) {
|
|
|
162
162
|
c
|
|
163
163
|
),
|
|
164
164
|
"--secondary-color": r,
|
|
165
|
-
"--secondary-color-light":
|
|
165
|
+
"--secondary-color-light": m(r, 10),
|
|
166
166
|
"--secondary-color-hover": y(
|
|
167
167
|
r,
|
|
168
168
|
f,
|
|
@@ -170,7 +170,7 @@ function W(t) {
|
|
|
170
170
|
),
|
|
171
171
|
"--text-color-secondary": f,
|
|
172
172
|
"--tertiary-color": o,
|
|
173
|
-
"--tertiary-color-light":
|
|
173
|
+
"--tertiary-color-light": m(o, 10),
|
|
174
174
|
"--tertiary-color-hover": y(
|
|
175
175
|
o,
|
|
176
176
|
u,
|
|
@@ -178,7 +178,7 @@ function W(t) {
|
|
|
178
178
|
),
|
|
179
179
|
"--text-color-tertiary": u,
|
|
180
180
|
"--quaternary-color": n,
|
|
181
|
-
"--quaternary-color-light":
|
|
181
|
+
"--quaternary-color-light": m(n, 10),
|
|
182
182
|
"--quaternary-color-hover": y(
|
|
183
183
|
n,
|
|
184
184
|
l,
|
|
@@ -186,10 +186,10 @@ function W(t) {
|
|
|
186
186
|
),
|
|
187
187
|
"--text-color-quaternary": l,
|
|
188
188
|
"--background-color": a,
|
|
189
|
-
"--background-color-dark":
|
|
190
|
-
"--background-color-darker":
|
|
191
|
-
"--background-color-light":
|
|
192
|
-
"--background-color-lighter":
|
|
189
|
+
"--background-color-dark": m(a, -10),
|
|
190
|
+
"--background-color-darker": m(a, -25),
|
|
191
|
+
"--background-color-light": m(a, 10),
|
|
192
|
+
"--background-color-lighter": m(a, 20),
|
|
193
193
|
"--link-color": c,
|
|
194
194
|
"--link-hover-color": U(
|
|
195
195
|
a,
|
|
@@ -239,7 +239,7 @@ function Q({
|
|
|
239
239
|
useOnlyCustomSchemes: r = !1
|
|
240
240
|
} = {}) {
|
|
241
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(
|
|
242
|
+
return `(function(){try{var s=${JSON.stringify(o).replace(/</g, "\\u003c")};var k=${JSON.stringify(w)};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
243
|
}
|
|
244
244
|
const Z = V(
|
|
245
245
|
void 0
|
|
@@ -250,10 +250,10 @@ const Z = V(
|
|
|
250
250
|
initialSchemeName: o,
|
|
251
251
|
useOnlyCustomSchemes: n = !1
|
|
252
252
|
}) => {
|
|
253
|
-
const a =
|
|
253
|
+
const a = I(
|
|
254
254
|
() => JSON.stringify(e ?? []),
|
|
255
255
|
[e]
|
|
256
|
-
), s =
|
|
256
|
+
), s = I(() => {
|
|
257
257
|
try {
|
|
258
258
|
const l = JSON.parse(a);
|
|
259
259
|
if (Array.isArray(l))
|
|
@@ -262,7 +262,7 @@ const Z = V(
|
|
|
262
262
|
console.error("Failed to parse custom schemes");
|
|
263
263
|
}
|
|
264
264
|
return [];
|
|
265
|
-
}, [a]), c =
|
|
265
|
+
}, [a]), c = I(
|
|
266
266
|
() => R({
|
|
267
267
|
customSchemes: s,
|
|
268
268
|
useOnlyCustomSchemes: n
|
|
@@ -274,37 +274,37 @@ const Z = V(
|
|
|
274
274
|
savedSchemeName: typeof window > "u" ? null : T(window.localStorage)
|
|
275
275
|
})
|
|
276
276
|
), u = P(!1);
|
|
277
|
-
return
|
|
278
|
-
const l = q(c, {
|
|
277
|
+
return k(() => {
|
|
278
|
+
const l = typeof window > "u" ? null : T(window.localStorage), h = p(c, l), x = q(c, {
|
|
279
279
|
initialSchemeName: o,
|
|
280
|
-
savedSchemeName:
|
|
280
|
+
savedSchemeName: l
|
|
281
281
|
});
|
|
282
|
-
f((
|
|
282
|
+
f((d) => o ? x : h !== -1 ? h : c[d] ? d : x);
|
|
283
283
|
}, [c, o]), F(() => {
|
|
284
284
|
const l = c[i] ?? c[0];
|
|
285
285
|
!l || typeof document > "u" || Y(l, document);
|
|
286
|
-
}, [i, c]),
|
|
286
|
+
}, [i, c]), k(() => {
|
|
287
287
|
if (typeof window > "u") return;
|
|
288
|
-
const l = (
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
(
|
|
288
|
+
const l = (d) => {
|
|
289
|
+
const C = p(c, d);
|
|
290
|
+
C !== -1 && f(
|
|
291
|
+
(S) => S === C ? S : C
|
|
292
292
|
);
|
|
293
|
-
}, h = (
|
|
294
|
-
var
|
|
295
|
-
l((
|
|
296
|
-
},
|
|
297
|
-
|
|
293
|
+
}, h = (d) => {
|
|
294
|
+
var S;
|
|
295
|
+
l((S = d.detail) == null ? void 0 : S.schemeName);
|
|
296
|
+
}, x = (d) => {
|
|
297
|
+
d.key === w && l(d.newValue);
|
|
298
298
|
};
|
|
299
|
-
return window.addEventListener(E, h), window.addEventListener("storage",
|
|
300
|
-
window.removeEventListener(E, h), window.removeEventListener("storage",
|
|
299
|
+
return window.addEventListener(E, h), window.addEventListener("storage", x), l(T(window.localStorage)), () => {
|
|
300
|
+
window.removeEventListener(E, h), window.removeEventListener("storage", x);
|
|
301
301
|
};
|
|
302
|
-
}, [c]),
|
|
302
|
+
}, [c]), k(() => {
|
|
303
303
|
const l = c[i] ?? c[0];
|
|
304
304
|
if (!l) return;
|
|
305
|
-
const h = typeof window > "u" ? void 0 : window.localStorage,
|
|
306
|
-
if (!u.current && !o &&
|
|
307
|
-
u.current = !0, f(
|
|
305
|
+
const h = typeof window > "u" ? void 0 : window.localStorage, x = T(h), d = p(c, x);
|
|
306
|
+
if (!u.current && !o && d !== -1 && d !== i) {
|
|
307
|
+
u.current = !0, f(d);
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
310
|
u.current = !0, G(h, l.name) && K(l.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ThemeContext-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ThemeContext-In2I5IqP.cjs");exports.ThemeContext=e.ThemeContext;exports.ThemeProvider=e.ThemeProvider;exports.getThemeInitializationScript=e.getThemeInitializationScript;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as U, useContext as q, useMemo as R } from "react";
|
|
3
3
|
import { S as j } from "./Select-BtEKKotT.js";
|
|
4
|
-
import { T as E } from "./ThemeContext-
|
|
4
|
+
import { T as E } from "./ThemeContext-xujmsbbI.js";
|
|
5
5
|
import { g as M, a as P, b as W } from "./boreal-style-config-rYvfCHLY.js";
|
|
6
6
|
const k = U(
|
|
7
7
|
({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),a=require("react"),U=require("./Select-BkErbR5B.cjs"),E=require("./ThemeContext-
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),a=require("react"),U=require("./Select-BkErbR5B.cjs"),E=require("./ThemeContext-In2I5IqP.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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./ThemeSelect-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./ThemeSelect-gR32Y8Ct.cjs");exports.default=e.UserThemeSettings;
|
package/dist/core/ThemeSelect.js
CHANGED