@stacksjs/components 0.2.955 → 0.2.957

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.
@@ -38,7 +38,7 @@ export const className = $props.className || ''
38
38
  * badge whose whole job is to distinguish would render two of its variants
39
39
  * identically. A wrong colour is worse than an unthemeable one.
40
40
  */
41
- const variantClasses = {
41
+ export const badgeColorClasses = {
42
42
  default: 'bg-surface-raised text-fg-strong',
43
43
  primary: 'bg-accent-soft text-accent-soft-ink',
44
44
  secondary: 'bg-secondary-soft text-secondary-soft-ink',
@@ -50,7 +50,7 @@ const variantClasses = {
50
50
 
51
51
  const sizeClasses = { sm: 'px-2 py-0.5 text-xs', md: 'px-2.5 py-0.5 text-sm', lg: 'px-3 py-1 text-base' }
52
52
 
53
- const dotColorClasses = {
53
+ export const badgeDotColorClasses = {
54
54
  default: 'bg-fg-soft',
55
55
  primary: 'bg-accent',
56
56
  secondary: 'bg-secondary',
@@ -60,13 +60,28 @@ const dotColorClasses = {
60
60
  info: 'bg-info',
61
61
  }
62
62
 
63
- export const badgeClasses = `inline-flex items-center gap-1.5 font-medium rounded-pill ${variantClasses[variant] || variantClasses.default} ${sizeClasses[size] || sizeClasses.md} ${className}`.trim()
64
- export const dotClasses = `w-2 h-2 rounded-full ${dotColorClasses[variant] || dotColorClasses.default}`.trim()
63
+ const initialVariant = Object.hasOwn(badgeColorClasses, variant) ? variant : 'default'
64
+ export const badgeClasses = `inline-flex items-center gap-1.5 font-medium rounded-pill ${badgeColorClasses[initialVariant]} ${sizeClasses[size] || sizeClasses.md} ${className}`.trim()
65
+ export const dotClasses = `w-2 h-2 rounded-full ${badgeDotColorClasses[initialVariant]}`.trim()
65
66
  export const removeButtonClasses = `ml-0.5 -mr-1 text-current hover:bg-black/10 dark:hover:bg-white/10 rounded-full p-0.5 transition-colors duration-150`.trim()
66
67
  </script>
67
68
 
68
69
  <script client>
69
70
  const emit = defineEmits()
71
+ const colorVariant = useReactiveProp('variant', {{ variant }})
72
+ const badgeColors = {{ badgeColorClasses }}
73
+ const dotColors = {{ badgeDotColorClasses }}
74
+ const callerClasses = {{ className }}.split(/\s+/)
75
+
76
+ function colorToggles(options, extraClasses = []) {
77
+ const tone = colorVariant()
78
+ const current = Object.hasOwn(options, tone) ? options[tone] : options.default
79
+ const retained = new Set([...current.split(' '), ...extraClasses])
80
+ return Object.fromEntries(Object.values(options).flatMap(classes => classes.split(' ').map(token => [token, retained.has(token)])))
81
+ }
82
+
83
+ const badgeColorToggles = derived(() => colorToggles(badgeColors, callerClasses))
84
+ const dotColorToggles = derived(() => colorToggles(dotColors))
70
85
 
71
86
  function onRemove() {
72
87
  emit('remove')
@@ -75,10 +90,11 @@ function onRemove() {
75
90
 
76
91
  <span
77
92
  class="{{ badgeClasses }}"
93
+ :class="badgeColorToggles()"
78
94
  @if(live)role="status" aria-live="{{ live }}"@endif
79
95
  >
80
96
  @if(dot)
81
- <span class="{{ dotClasses }}" aria-hidden="true"></span>
97
+ <span class="{{ dotClasses }}" :class="dotColorToggles()" aria-hidden="true"></span>
82
98
  @endif
83
99
 
84
100
  <slot />
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  var Ya={__stx:!0,src:"./components/CodeBlock.stx"};var Xa={__stx:!0,src:"./components/Footer.stx"};var Za={__stx:!0,src:"./components/Hero.stx"};var Qa={__stx:!0,src:"./components/Installation.stx"};function Ch(e){let{code:t,onSuccess:s,onError:a,timeout:n=2000}=e,o=!1,i=null;return{copied:o,copy:async()=>{try{if(!navigator.clipboard)throw Error("Clipboard API not available");await navigator.clipboard.writeText(t),o=!0,s?.(),i=setTimeout(()=>{o=!1,i=null},n)}catch(l){let d=l instanceof Error?l:Error("Failed to copy code");a?.(d),console.error("Failed to copy code:",d)}},reset:()=>{if(o=!1,i)clearTimeout(i),i=null}}}async function Th(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.error("Failed to copy to clipboard:",t),!1}}function en(){if(typeof window>"u")return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function yt(e){return e==="system"?en():e}function Eh(e={}){let{storageKey:t="theme",defaultTheme:s="system"}=e,a=s;if(typeof window<"u"&&typeof localStorage<"u"){let c=localStorage.getItem(t);if(c)a=c}let n=yt(a)==="dark",o=(c)=>{let l=yt(c);if(typeof document<"u")if(l==="dark")document.documentElement.classList.add("dark");else document.documentElement.classList.remove("dark");if(typeof localStorage<"u")localStorage.setItem(t,c)},i=(c)=>{a=c,o(c)},r=()=>{let l=yt(a)==="dark"?"light":"dark";i(l)};if(o(a),typeof window<"u"&&a==="system")window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(c)=>{if(a==="system")o("system")});return{isDark:n,theme:a,toggle:r,setTheme:i}}function tn(e,t){if(typeof document>"u")return;document.title=t?t.replace("%s",e):e}function W(e,t,s=!1){if(typeof document>"u")return;let a=s?"property":"name",n=document.querySelector(`meta[${a}="${e}"]`);if(!n)n=document.createElement("meta"),n.setAttribute(a,e),document.head.appendChild(n);n.setAttribute("content",t)}function sn(e,t){if(typeof document>"u")return;let s=document.querySelector(`link[rel="${e}"]`);if(!s)s=document.createElement("link"),s.setAttribute("rel",e),document.head.appendChild(s);s.setAttribute("href",t)}function Ah(e){let{title:t,description:s,author:a,keywords:n,ogImage:o,ogImageWidth:i,ogImageHeight:r,twitterCard:c="summary_large_image",twitterSite:l,twitterCreator:d,canonical:h}=e;if(t)tn(t),W("og:title",t,!0),W("twitter:title",t);if(s)W("description",s),W("og:description",s,!0),W("twitter:description",s);if(a)W("author",a);if(n&&n.length>0)W("keywords",n.join(", "));if(o)W("og:image",o,!0),W("twitter:image",o);if(i)W("og:image:width",i,!0);if(r)W("og:image:height",r,!0);if(W("twitter:card",c),l)W("twitter:site",l);if(d)W("twitter:creator",d);if(h)sn("canonical",h);if(W("og:type","website",!0),typeof window<"u")W("og:url",window.location.href,!0)}function Ph(e){let t=[],{title:s,description:a,author:n,keywords:o,ogImage:i,ogImageWidth:r,ogImageHeight:c,twitterCard:l="summary_large_image",twitterSite:d,twitterCreator:h,canonical:p}=e;if(s)t.push(`<title>${G(s)}</title>`),t.push(`<meta property="og:title" content="${G(s)}" />`),t.push(`<meta name="twitter:title" content="${G(s)}" />`);if(a)t.push(`<meta name="description" content="${G(a)}" />`),t.push(`<meta property="og:description" content="${G(a)}" />`),t.push(`<meta name="twitter:description" content="${G(a)}" />`);if(n)t.push(`<meta name="author" content="${G(n)}" />`);if(o&&o.length>0)t.push(`<meta name="keywords" content="${G(o.join(", "))}" />`);if(i)t.push(`<meta property="og:image" content="${G(i)}" />`),t.push(`<meta name="twitter:image" content="${G(i)}" />`);if(r)t.push(`<meta property="og:image:width" content="${G(r)}" />`);if(c)t.push(`<meta property="og:image:height" content="${G(c)}" />`);if(t.push(`<meta name="twitter:card" content="${G(l)}" />`),d)t.push(`<meta name="twitter:site" content="${G(d)}" />`);if(h)t.push(`<meta name="twitter:creator" content="${G(h)}" />`);if(p)t.push(`<link rel="canonical" href="${G(p)}" />`);return t.push('<meta property="og:type" content="website" />'),t.join(`
3
- `)}function G(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Rh(e,t,s={}){let{enabled:a=!0,ignore:n=[]}=s,o=(i)=>{if(!a||!e)return;let r=i.target;if(!e.contains(r)){if(!n.some((l)=>{let d=document.querySelectorAll(l);return Array.from(d).some((h)=>h.contains(r))}))t(i)}};if(typeof document<"u")document.addEventListener("mousedown",o),document.addEventListener("touchstart",o);return()=>{if(typeof document<"u")document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o)}}function Lh(e,t={}){let{enabled:s=!0,initialFocus:a=null,returnFocus:n=!0,fallbackFocus:o=null}=t,i=null,r=!1;function c(){if(!e)return[];let u=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");return Array.from(e.querySelectorAll(u))}function l(u){if(!s||!r||!e)return;let g=c();if(g.length===0){u.preventDefault();return}let m=g[0],w=g[g.length-1];if(u.shiftKey){if(document.activeElement===m||document.activeElement===e)u.preventDefault(),w.focus()}else if(document.activeElement===w)u.preventDefault(),m.focus()}function d(u){if(u.key==="Escape"&&s&&r)p()}function h(){if(!s||!e||r)return;if(i=document.activeElement,a)a.focus();else{let u=c();if(u.length>0)u[0].focus();else if(o)o.focus();else e.focus()}document.addEventListener("keydown",l),document.addEventListener("keydown",d),r=!0}function p(){if(!r)return;if(document.removeEventListener("keydown",l),document.removeEventListener("keydown",d),n&&i)i.focus();r=!1}return{activate:h,deactivate:p}}function Oh(e,t={}){let{enabled:s=!0,preventDefault:a=!0,stopPropagation:n=!1,target:o=typeof document<"u"?document:null}=t,i=Array.isArray(e)?e:[e],r=(c)=>{if(!s)return;i.forEach((l)=>{if(!(Array.isArray(l.key)?l.key:[l.key]).some((p)=>p.toLowerCase()===c.key.toLowerCase()))return;if(l.ctrl!==void 0&&l.ctrl!==c.ctrlKey)return;if(l.shift!==void 0&&l.shift!==c.shiftKey)return;if(l.alt!==void 0&&l.alt!==c.altKey)return;if(l.meta!==void 0&&l.meta!==c.metaKey)return;if(a)c.preventDefault();if(n)c.stopPropagation();l.handler(c)})};if(o)o.addEventListener("keydown",r);return()=>{if(o)o.removeEventListener("keydown",r)}}var zh={ESCAPE:"Escape",ENTER:"Enter",SPACE:" ",TAB:"Tab",ARROW_UP:"ArrowUp",ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",HOME:"Home",END:"End",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown"};function Fh(e,t,s={}){let{serializer:a=JSON.stringify,deserializer:n=JSON.parse,onError:o=console.error}=s,i=t;try{if(typeof window<"u"){let h=window.localStorage.getItem(e);if(h!==null)i=n(h)}}catch(h){o(h)}let r=i,c=new Set;function l(h){try{let p=typeof h==="function"?h(r):h;if(r=p,typeof window<"u")window.localStorage.setItem(e,a(p));c.forEach((u)=>u(p))}catch(p){o(p)}}function d(){try{if(r=t,typeof window<"u")window.localStorage.removeItem(e);c.forEach((h)=>h(t))}catch(h){o(h)}}if(typeof window<"u"){let h=(p)=>{if(p.key===e&&p.newValue!==null)try{let u=n(p.newValue);r=u,c.forEach((g)=>g(u))}catch(u){o(u)}else if(p.key===e&&p.newValue===null)r=t,c.forEach((u)=>u(t))};window.addEventListener("storage",h)}return{value:r,setValue:l,removeValue:d}}function Ce(e,t={}){let{defaultValue:s=!1}=t,a=s,n=null;if(typeof window<"u"&&"matchMedia"in window){n=window.matchMedia(e),a=n.matches;let i=(r)=>{a=r.matches};if(n.addEventListener)n.addEventListener("change",i);else n.addListener(i)}function o(){if(n)a=n.matches}return{matches:a,updateMatches:o}}var Te={xs:"(min-width: 320px)",sm:"(min-width: 640px)",md:"(min-width: 768px)",lg:"(min-width: 1024px)",xl:"(min-width: 1280px)","2xl":"(min-width: 1536px)",mobile:"(max-width: 767px)",tablet:"(min-width: 768px) and (max-width: 1023px)",desktop:"(min-width: 1024px)",dark:"(prefers-color-scheme: dark)",light:"(prefers-color-scheme: light)",reducedMotion:"(prefers-reduced-motion: reduce)",portrait:"(orientation: portrait)",landscape:"(orientation: landscape)"};function jh(e){return Ce(Te[e])}function Bh(){return Ce(Te.mobile)}function _h(){return Ce(Te.desktop)}function Kh(){return Ce(Te.dark)}function qh(){return Ce(Te.reducedMotion)}function He(){return globalThis.stx?.overlays}function Gh(e,t){He()?.open(e,t)}function Uh(e){He()?.close(e)}function Jh(e){return He()?.isTop(e)??!1}function Yh(){return He()?.list()??[]}var as=["gray","neutral","slate","zinc","red","green","yellow","blue","indigo"],Zh="--stx-color";function an(e,t){return t===void 0?`var(${e})`:`var(${e}, ${t})`}function Qh(e={}){let t={};for(let s of as){let a=e[s];if(!a||typeof a==="string")continue;let n={};for(let[o,i]of Object.entries(a))n[o]=an(`--stx-color-${s}-${o}`,i);t[s]=n}return t}function eu(e={}){let t=[];for(let s of as){let a=e[s];if(!a||typeof a==="string")continue;for(let n of Object.keys(a))t.push(`--stx-color-${s}-${n}`)}return t}var on="./Accordion-ehpymjam.stx";var ln="./AccordionItem-fc4ekdqf.stx";var dn="./AddressField-gcydmvkf.stx";var hn="./CommandBar-k35nsefs.stx";var fn="./ContentCard-gjsm9qrr.stx";var gn="./FloatingPanel-qp8cq8hz.stx";var bn="./SidebarDivider-6whech7a.stx";var wn="./SidebarRow-301dd797.stx";var kn="./SpaceSwitcher-297p5gnb.stx";var Cn="./TileGrid-nne4x506.stx";var $n="./AppearancePicker-30fetv0a.stx";var In="./Audio-ay34sh1f.stx";var Pn="./BiometricSignIn-6enqcn9e.stx";var Rn="./Login-4666t7j4.stx";var Ln="./Signup-pm2r0f2m.stx";var On="./TwoFactorChallenge-3tsbfdsd.stx";var Lu="session",zn={faceId:"Face ID",touchId:"Touch ID",fingerprint:"Fingerprint"};function ns(e){return typeof e==="string"?zn[e]||"":""}function Du(e){let t=ns(e);return t?`Sign in with ${t}`:""}function Hn(){let t=globalThis.craft?.biometrics;if(!t)return null;return["isAvailable","getBiometricType","storeCredential","getCredential","hasCredential","deleteCredential"].every((a)=>typeof t[a]==="function")?t:null}var Fe=Object.freeze({available:!1,kind:null,label:"",saved:!1});function Fn(e){let t=e?.code;return typeof t==="string"&&t?t:"UNKNOWN"}function Vn(e){return e instanceof Error?e.message:String(e??"")}function Ou(e="session",t){let s=String(e||"").trim()||"session",a=()=>t===void 0?Hn():t;async function n(){let c=a();if(!c)return Fe;try{if(!await c.isAvailable())return Fe;let l=await c.getBiometricType(),d=ns(l);if(!d)return Fe;return{available:!0,kind:l,label:d,saved:await c.hasCredential(s)===!0}}catch{return Fe}}async function o(c){let l=a();if(!l)return{status:"failed",code:"UNSUPPORTED",message:"Biometric sign-in is not available here."};try{let d=await l.getCredential(s,c||void 0);if(typeof d==="string"&&d)return{status:"signed-in",token:d};return await l.deleteCredential(s).catch(()=>{}),{status:"invalidated"}}catch(d){let h=Fn(d);if(h==="AUTHENTICATION_CANCELLED")return{status:"cancelled"};return{status:"failed",code:h,message:Vn(d)}}}async function i(c){let l=a();if(!l||typeof c!=="string"||!c)return!1;try{if(!await l.isAvailable())return!1;return await l.storeCredential(s,c),!0}catch{return!1}}async function r(){let c=a();if(!c)return;await c.deleteCredential(s).catch(()=>{})}return{probe:n,signIn:o,enable:i,forget:r}}var Bn="./Avatar-6gexb2xv.stx";var Kn="./Badge-33phrqza.stx";var Wn="./Breadcrumb-cgw1bb6s.stx";class X extends Error{component;context;constructor(e,t,s={}){let a=X.formatMessage(e,t,s);super(a);if(this.name="ComponentError",this.component=e,this.context={component:e,...s},Error.captureStackTrace)Error.captureStackTrace(this,X)}static formatMessage(e,t,s){let a=`[${e}] ${t}`;if(s.prop)a+=`
3
+ `)}function G(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Rh(e,t,s={}){let{enabled:a=!0,ignore:n=[]}=s,o=(i)=>{if(!a||!e)return;let r=i.target;if(!e.contains(r)){if(!n.some((l)=>{let d=document.querySelectorAll(l);return Array.from(d).some((h)=>h.contains(r))}))t(i)}};if(typeof document<"u")document.addEventListener("mousedown",o),document.addEventListener("touchstart",o);return()=>{if(typeof document<"u")document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o)}}function Lh(e,t={}){let{enabled:s=!0,initialFocus:a=null,returnFocus:n=!0,fallbackFocus:o=null}=t,i=null,r=!1;function c(){if(!e)return[];let u=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");return Array.from(e.querySelectorAll(u))}function l(u){if(!s||!r||!e)return;let g=c();if(g.length===0){u.preventDefault();return}let m=g[0],w=g[g.length-1];if(u.shiftKey){if(document.activeElement===m||document.activeElement===e)u.preventDefault(),w.focus()}else if(document.activeElement===w)u.preventDefault(),m.focus()}function d(u){if(u.key==="Escape"&&s&&r)p()}function h(){if(!s||!e||r)return;if(i=document.activeElement,a)a.focus();else{let u=c();if(u.length>0)u[0].focus();else if(o)o.focus();else e.focus()}document.addEventListener("keydown",l),document.addEventListener("keydown",d),r=!0}function p(){if(!r)return;if(document.removeEventListener("keydown",l),document.removeEventListener("keydown",d),n&&i)i.focus();r=!1}return{activate:h,deactivate:p}}function Oh(e,t={}){let{enabled:s=!0,preventDefault:a=!0,stopPropagation:n=!1,target:o=typeof document<"u"?document:null}=t,i=Array.isArray(e)?e:[e],r=(c)=>{if(!s)return;i.forEach((l)=>{if(!(Array.isArray(l.key)?l.key:[l.key]).some((p)=>p.toLowerCase()===c.key.toLowerCase()))return;if(l.ctrl!==void 0&&l.ctrl!==c.ctrlKey)return;if(l.shift!==void 0&&l.shift!==c.shiftKey)return;if(l.alt!==void 0&&l.alt!==c.altKey)return;if(l.meta!==void 0&&l.meta!==c.metaKey)return;if(a)c.preventDefault();if(n)c.stopPropagation();l.handler(c)})};if(o)o.addEventListener("keydown",r);return()=>{if(o)o.removeEventListener("keydown",r)}}var zh={ESCAPE:"Escape",ENTER:"Enter",SPACE:" ",TAB:"Tab",ARROW_UP:"ArrowUp",ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",HOME:"Home",END:"End",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown"};function Fh(e,t,s={}){let{serializer:a=JSON.stringify,deserializer:n=JSON.parse,onError:o=console.error}=s,i=t;try{if(typeof window<"u"){let h=window.localStorage.getItem(e);if(h!==null)i=n(h)}}catch(h){o(h)}let r=i,c=new Set;function l(h){try{let p=typeof h==="function"?h(r):h;if(r=p,typeof window<"u")window.localStorage.setItem(e,a(p));c.forEach((u)=>u(p))}catch(p){o(p)}}function d(){try{if(r=t,typeof window<"u")window.localStorage.removeItem(e);c.forEach((h)=>h(t))}catch(h){o(h)}}if(typeof window<"u"){let h=(p)=>{if(p.key===e&&p.newValue!==null)try{let u=n(p.newValue);r=u,c.forEach((g)=>g(u))}catch(u){o(u)}else if(p.key===e&&p.newValue===null)r=t,c.forEach((u)=>u(t))};window.addEventListener("storage",h)}return{value:r,setValue:l,removeValue:d}}function Ce(e,t={}){let{defaultValue:s=!1}=t,a=s,n=null;if(typeof window<"u"&&"matchMedia"in window){n=window.matchMedia(e),a=n.matches;let i=(r)=>{a=r.matches};if(n.addEventListener)n.addEventListener("change",i);else n.addListener(i)}function o(){if(n)a=n.matches}return{matches:a,updateMatches:o}}var Te={xs:"(min-width: 320px)",sm:"(min-width: 640px)",md:"(min-width: 768px)",lg:"(min-width: 1024px)",xl:"(min-width: 1280px)","2xl":"(min-width: 1536px)",mobile:"(max-width: 767px)",tablet:"(min-width: 768px) and (max-width: 1023px)",desktop:"(min-width: 1024px)",dark:"(prefers-color-scheme: dark)",light:"(prefers-color-scheme: light)",reducedMotion:"(prefers-reduced-motion: reduce)",portrait:"(orientation: portrait)",landscape:"(orientation: landscape)"};function jh(e){return Ce(Te[e])}function Bh(){return Ce(Te.mobile)}function _h(){return Ce(Te.desktop)}function Kh(){return Ce(Te.dark)}function qh(){return Ce(Te.reducedMotion)}function He(){return globalThis.stx?.overlays}function Gh(e,t){He()?.open(e,t)}function Uh(e){He()?.close(e)}function Jh(e){return He()?.isTop(e)??!1}function Yh(){return He()?.list()??[]}var as=["gray","neutral","slate","zinc","red","green","yellow","blue","indigo"],Zh="--stx-color";function an(e,t){return t===void 0?`var(${e})`:`var(${e}, ${t})`}function Qh(e={}){let t={};for(let s of as){let a=e[s];if(!a||typeof a==="string")continue;let n={};for(let[o,i]of Object.entries(a))n[o]=an(`--stx-color-${s}-${o}`,i);t[s]=n}return t}function eu(e={}){let t=[];for(let s of as){let a=e[s];if(!a||typeof a==="string")continue;for(let n of Object.keys(a))t.push(`--stx-color-${s}-${n}`)}return t}var on="./Accordion-ehpymjam.stx";var ln="./AccordionItem-fc4ekdqf.stx";var dn="./AddressField-gcydmvkf.stx";var hn="./CommandBar-k35nsefs.stx";var fn="./ContentCard-gjsm9qrr.stx";var gn="./FloatingPanel-qp8cq8hz.stx";var bn="./SidebarDivider-6whech7a.stx";var wn="./SidebarRow-301dd797.stx";var kn="./SpaceSwitcher-297p5gnb.stx";var Cn="./TileGrid-nne4x506.stx";var $n="./AppearancePicker-30fetv0a.stx";var In="./Audio-ay34sh1f.stx";var Pn="./BiometricSignIn-6enqcn9e.stx";var Rn="./Login-4666t7j4.stx";var Ln="./Signup-pm2r0f2m.stx";var On="./TwoFactorChallenge-3tsbfdsd.stx";var Lu="session",zn={faceId:"Face ID",touchId:"Touch ID",fingerprint:"Fingerprint"};function ns(e){return typeof e==="string"?zn[e]||"":""}function Du(e){let t=ns(e);return t?`Sign in with ${t}`:""}function Hn(){let t=globalThis.craft?.biometrics;if(!t)return null;return["isAvailable","getBiometricType","storeCredential","getCredential","hasCredential","deleteCredential"].every((a)=>typeof t[a]==="function")?t:null}var Fe=Object.freeze({available:!1,kind:null,label:"",saved:!1});function Fn(e){let t=e?.code;return typeof t==="string"&&t?t:"UNKNOWN"}function Vn(e){return e instanceof Error?e.message:String(e??"")}function Ou(e="session",t){let s=String(e||"").trim()||"session",a=()=>t===void 0?Hn():t;async function n(){let c=a();if(!c)return Fe;try{if(!await c.isAvailable())return Fe;let l=await c.getBiometricType(),d=ns(l);if(!d)return Fe;return{available:!0,kind:l,label:d,saved:await c.hasCredential(s)===!0}}catch{return Fe}}async function o(c){let l=a();if(!l)return{status:"failed",code:"UNSUPPORTED",message:"Biometric sign-in is not available here."};try{let d=await l.getCredential(s,c||void 0);if(typeof d==="string"&&d)return{status:"signed-in",token:d};return await l.deleteCredential(s).catch(()=>{}),{status:"invalidated"}}catch(d){let h=Fn(d);if(h==="AUTHENTICATION_CANCELLED")return{status:"cancelled"};return{status:"failed",code:h,message:Vn(d)}}}async function i(c){let l=a();if(!l||typeof c!=="string"||!c)return!1;try{if(!await l.isAvailable())return!1;return await l.storeCredential(s,c),!0}catch{return!1}}async function r(){let c=a();if(!c)return;await c.deleteCredential(s).catch(()=>{})}return{probe:n,signIn:o,enable:i,forget:r}}var Bn="./Avatar-6gexb2xv.stx";var Kn="./Badge-wnz3v82e.stx";var Wn="./Breadcrumb-cgw1bb6s.stx";class X extends Error{component;context;constructor(e,t,s={}){let a=X.formatMessage(e,t,s);super(a);if(this.name="ComponentError",this.component=e,this.context={component:e,...s},Error.captureStackTrace)Error.captureStackTrace(this,X)}static formatMessage(e,t,s){let a=`[${e}] ${t}`;if(s.prop)a+=`
4
4
  Prop: "${s.prop}"`;if(s.received!==void 0)a+=`
5
5
  Received: ${JSON.stringify(s.received)}`;if(s.expected!==void 0){let n=Array.isArray(s.expected)?s.expected.map((o)=>JSON.stringify(o)).join(", "):JSON.stringify(s.expected);a+=`
6
6
  Expected: ${n}`}if(s.details)a+=`
@@ -34,7 +34,65 @@ export declare const className: unknown;
34
34
  * `info` role would paint it blue, which is what `primary` already is, so a
35
35
  * badge whose whole job is to distinguish would render two of its variants
36
36
  * identically. A wrong colour is worse than an unthemeable one.
37
+ * @defaultValue
38
+ * ```ts
39
+ * {
40
+ * default: 'bg-surface-raised text-fg-strong',
41
+ * primary: 'bg-accent-soft text-accent-soft-ink',
42
+ * secondary: 'bg-secondary-soft text-secondary-soft-ink',
43
+ * success: 'bg-success-soft text-success-soft-ink',
44
+ * warning: 'bg-warning-soft text-warning-soft-ink',
45
+ * danger: 'bg-danger-soft text-danger-soft-ink',
46
+ * info: 'bg-info-soft text-info-soft-ink'
47
+ * }
48
+ * ```
37
49
  */
50
+ export declare const badgeColorClasses: {
51
+ /** @defaultValue 'bg-surface-raised text-fg-strong' */
52
+ default: string;
53
+ /** @defaultValue 'bg-accent-soft text-accent-soft-ink' */
54
+ primary: string;
55
+ /** @defaultValue 'bg-secondary-soft text-secondary-soft-ink' */
56
+ secondary: string;
57
+ /** @defaultValue 'bg-success-soft text-success-soft-ink' */
58
+ success: string;
59
+ /** @defaultValue 'bg-warning-soft text-warning-soft-ink' */
60
+ warning: string;
61
+ /** @defaultValue 'bg-danger-soft text-danger-soft-ink' */
62
+ danger: string;
63
+ /** @defaultValue 'bg-info-soft text-info-soft-ink' */
64
+ info: string
65
+ };
66
+ /**
67
+ * @defaultValue
68
+ * ```ts
69
+ * {
70
+ * default: 'bg-fg-soft',
71
+ * primary: 'bg-accent',
72
+ * secondary: 'bg-secondary',
73
+ * success: 'bg-success',
74
+ * warning: 'bg-warning',
75
+ * danger: 'bg-danger',
76
+ * info: 'bg-info'
77
+ * }
78
+ * ```
79
+ */
80
+ export declare const badgeDotColorClasses: {
81
+ /** @defaultValue 'bg-fg-soft' */
82
+ default: string;
83
+ /** @defaultValue 'bg-accent' */
84
+ primary: string;
85
+ /** @defaultValue 'bg-secondary' */
86
+ secondary: string;
87
+ /** @defaultValue 'bg-success' */
88
+ success: string;
89
+ /** @defaultValue 'bg-warning' */
90
+ warning: string;
91
+ /** @defaultValue 'bg-danger' */
92
+ danger: string;
93
+ /** @defaultValue 'bg-info' */
94
+ info: string
95
+ };
38
96
  export declare const badgeClasses: unknown;
39
97
  export declare const dotClasses: unknown;
40
98
  export declare const removeButtonClasses: unknown;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/components",
3
3
  "type": "module",
4
- "version": "0.2.955",
4
+ "version": "0.2.957",
5
5
  "description": "A modern component library built with STX, featuring headwind utility classes and TypeScript syntax highlighting.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -144,8 +144,8 @@
144
144
  "dependencies": {
145
145
  "@iconify-json/f7": "^1.2.2",
146
146
  "@stacksjs/ts-css": "^0.3.11",
147
- "@stacksjs/stx": "0.2.955",
148
- "bun-plugin-stx": "0.2.955",
147
+ "@stacksjs/stx": "0.2.957",
148
+ "bun-plugin-stx": "0.2.957",
149
149
  "ts-syntax-highlighter": "^0.2.20",
150
150
  "ts-video-player": "^0.1.11"
151
151
  },
@@ -38,7 +38,7 @@ export const className = $props.className || ''
38
38
  * badge whose whole job is to distinguish would render two of its variants
39
39
  * identically. A wrong colour is worse than an unthemeable one.
40
40
  */
41
- const variantClasses = {
41
+ export const badgeColorClasses = {
42
42
  default: 'bg-surface-raised text-fg-strong',
43
43
  primary: 'bg-accent-soft text-accent-soft-ink',
44
44
  secondary: 'bg-secondary-soft text-secondary-soft-ink',
@@ -50,7 +50,7 @@ const variantClasses = {
50
50
 
51
51
  const sizeClasses = { sm: 'px-2 py-0.5 text-xs', md: 'px-2.5 py-0.5 text-sm', lg: 'px-3 py-1 text-base' }
52
52
 
53
- const dotColorClasses = {
53
+ export const badgeDotColorClasses = {
54
54
  default: 'bg-fg-soft',
55
55
  primary: 'bg-accent',
56
56
  secondary: 'bg-secondary',
@@ -60,13 +60,28 @@ const dotColorClasses = {
60
60
  info: 'bg-info',
61
61
  }
62
62
 
63
- export const badgeClasses = `inline-flex items-center gap-1.5 font-medium rounded-pill ${variantClasses[variant] || variantClasses.default} ${sizeClasses[size] || sizeClasses.md} ${className}`.trim()
64
- export const dotClasses = `w-2 h-2 rounded-full ${dotColorClasses[variant] || dotColorClasses.default}`.trim()
63
+ const initialVariant = Object.hasOwn(badgeColorClasses, variant) ? variant : 'default'
64
+ export const badgeClasses = `inline-flex items-center gap-1.5 font-medium rounded-pill ${badgeColorClasses[initialVariant]} ${sizeClasses[size] || sizeClasses.md} ${className}`.trim()
65
+ export const dotClasses = `w-2 h-2 rounded-full ${badgeDotColorClasses[initialVariant]}`.trim()
65
66
  export const removeButtonClasses = `ml-0.5 -mr-1 text-current hover:bg-black/10 dark:hover:bg-white/10 rounded-full p-0.5 transition-colors duration-150`.trim()
66
67
  </script>
67
68
 
68
69
  <script client>
69
70
  const emit = defineEmits()
71
+ const colorVariant = useReactiveProp('variant', {{ variant }})
72
+ const badgeColors = {{ badgeColorClasses }}
73
+ const dotColors = {{ badgeDotColorClasses }}
74
+ const callerClasses = {{ className }}.split(/\s+/)
75
+
76
+ function colorToggles(options, extraClasses = []) {
77
+ const tone = colorVariant()
78
+ const current = Object.hasOwn(options, tone) ? options[tone] : options.default
79
+ const retained = new Set([...current.split(' '), ...extraClasses])
80
+ return Object.fromEntries(Object.values(options).flatMap(classes => classes.split(' ').map(token => [token, retained.has(token)])))
81
+ }
82
+
83
+ const badgeColorToggles = derived(() => colorToggles(badgeColors, callerClasses))
84
+ const dotColorToggles = derived(() => colorToggles(dotColors))
70
85
 
71
86
  function onRemove() {
72
87
  emit('remove')
@@ -75,10 +90,11 @@ function onRemove() {
75
90
 
76
91
  <span
77
92
  class="{{ badgeClasses }}"
93
+ :class="badgeColorToggles()"
78
94
  @if(live)role="status" aria-live="{{ live }}"@endif
79
95
  >
80
96
  @if(dot)
81
- <span class="{{ dotClasses }}" aria-hidden="true"></span>
97
+ <span class="{{ dotClasses }}" :class="dotColorToggles()" aria-hidden="true"></span>
82
98
  @endif
83
99
 
84
100
  <slot />