@compa11y/web 0.1.3 → 0.1.5

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.
@@ -1,4 +1,4 @@
1
- var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(){super(),this._internals=null,this._id=o.generateId(this.tagName.toLowerCase().replace("a11y-","")),"attachInternals"in this&&(this._internals=this.attachInternals())}static get observedAttributes(){return[]}connectedCallback(){this.setupAccessibility(),this.render(),this.setupEventListeners()}disconnectedCallback(){this.cleanupEventListeners()}attributeChangedCallback(e,t,i){t!==i&&this.onAttributeChange(e,t,i)}setupEventListeners(){}cleanupEventListeners(){}onAttributeChange(e,t,i){}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,cancelable:!0}))}getSlot(e){var t;return((t=this.shadowRoot)==null?void 0:t.querySelector(`slot[name="${e}"]`))??null}getSlottedElements(e){var s;const t=e?`slot[name="${e}"]`:"slot:not([name])",i=(s=this.shadowRoot)==null?void 0:s.querySelector(t);return(i==null?void 0:i.assignedElements())??[]}}function b(d,e){customElements.get(d)||customElements.define(d,e)}const V=`
1
+ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(){super(),this._internals=null,this._id=o.generateId(this.tagName.toLowerCase().replace("a11y-","")),"attachInternals"in this&&(this._internals=this.attachInternals())}static get observedAttributes(){return[]}connectedCallback(){this.setupAccessibility(),this.render(),this.setupEventListeners()}disconnectedCallback(){this.cleanupEventListeners()}attributeChangedCallback(e,t,i){t!==i&&this.onAttributeChange(e,t,i)}setupEventListeners(){}cleanupEventListeners(){}onAttributeChange(e,t,i){}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,cancelable:!0}))}getSlot(e){var t;return((t=this.shadowRoot)==null?void 0:t.querySelector(`slot[name="${e}"]`))??null}getSlottedElements(e){var s;const t=e?`slot[name="${e}"]`:"slot:not([name])",i=(s=this.shadowRoot)==null?void 0:s.querySelector(t);return(i==null?void 0:i.assignedElements())??[]}}function b(d,e){customElements.get(d)||customElements.define(d,e)}const S=`
2
2
  appearance: none;
3
3
  background: none;
4
4
  border: none;
@@ -30,7 +30,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
30
30
  outline-offset: 2px;
31
31
  }
32
32
 
33
- `,W=`
33
+ `,Z=`
34
34
  ${p}
35
35
 
36
36
  :host {
@@ -69,7 +69,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
69
69
  margin: 0 0 1rem 0;
70
70
  color: var(--compa11y-dialog-description-color, #666);
71
71
  }
72
- `,J=`
72
+ `,ee=`
73
73
  ${p}
74
74
 
75
75
  :host {
@@ -121,7 +121,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
121
121
  margin: 0.25rem 0;
122
122
  background: var(--compa11y-menu-separator-color, #e0e0e0);
123
123
  }
124
- `,Q=`
124
+ `,te=`
125
125
  ${p}
126
126
 
127
127
  .tablist {
@@ -137,7 +137,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
137
137
  }
138
138
 
139
139
  ::slotted([role="tab"]) {
140
- ${V}
140
+ ${S}
141
141
  padding: var(--compa11y-tab-padding, 0.75rem 1rem);
142
142
  border-bottom: 2px solid transparent;
143
143
  margin-bottom: -1px;
@@ -167,7 +167,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
167
167
  ::slotted([role="tabpanel"][hidden]) {
168
168
  display: none;
169
169
  }
170
- `,Z=`
170
+ `,ie=`
171
171
  ${p}
172
172
 
173
173
  :host {
@@ -226,7 +226,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
226
226
  }
227
227
 
228
228
  .clear-button {
229
- ${V}
229
+ ${S}
230
230
  position: absolute;
231
231
  right: 1.5rem;
232
232
  width: 1.25rem;
@@ -308,7 +308,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
308
308
  .options-source {
309
309
  display: none;
310
310
  }
311
- `,ee=`
311
+ `,se=`
312
312
  ${p}
313
313
 
314
314
  :host {
@@ -438,7 +438,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
438
438
  .options-source {
439
439
  display: none;
440
440
  }
441
- `,te=`
441
+ `,ae=`
442
442
  ${p}
443
443
 
444
444
  :host {
@@ -542,7 +542,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
542
542
  opacity: 0.5;
543
543
  cursor: not-allowed;
544
544
  }
545
- `,ie=`
545
+ `,re=`
546
546
  ${p}
547
547
 
548
548
  :host {
@@ -621,7 +621,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
621
621
  color: var(--compa11y-input-error-color, #ef4444);
622
622
  font-size: var(--compa11y-input-error-size, 0.8125rem);
623
623
  }
624
- `,se=`
624
+ `,oe=`
625
625
  ${p}
626
626
 
627
627
  :host {
@@ -702,7 +702,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
702
702
  color: var(--compa11y-textarea-error-color, #ef4444);
703
703
  font-size: var(--compa11y-textarea-error-size, 0.8125rem);
704
704
  }
705
- `,ae=`
705
+ `,le=`
706
706
  ${p}
707
707
 
708
708
  :host {
@@ -817,7 +817,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
817
817
  border-radius: 50%;
818
818
  animation: compa11y-spin 0.6s linear infinite;
819
819
  }
820
- `,re=`
820
+ `,ne=`
821
821
  ${p}
822
822
 
823
823
  :host {
@@ -839,9 +839,10 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
839
839
  cursor: not-allowed;
840
840
  }
841
841
 
842
+ /* Focus indicator lives on the active option (via data-focused),
843
+ not on the container, to avoid a double focus ring. */
842
844
  :host(:focus-visible) .listbox-wrapper {
843
- outline: 2px solid var(--compa11y-focus-color, #0066cc);
844
- outline-offset: 2px;
845
+ outline: none;
845
846
  }
846
847
 
847
848
  :host([orientation="horizontal"]) .listbox-wrapper {
@@ -850,7 +851,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
850
851
  max-height: none;
851
852
  overflow-y: visible;
852
853
  }
853
- `,oe=`
854
+ `,he=`
854
855
  ${p}
855
856
 
856
857
  :host {
@@ -899,7 +900,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
899
900
  :host([aria-selected="true"]) .check-mark {
900
901
  visibility: visible;
901
902
  }
902
- `,le=`
903
+ `,de=`
903
904
  ${p}
904
905
 
905
906
  :host {
@@ -918,7 +919,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
918
919
  :host([disabled]) {
919
920
  opacity: 0.5;
920
921
  }
921
- `,ne=`
922
+ `,ce=`
922
923
  ${p}
923
924
 
924
925
  :host {
@@ -1081,7 +1082,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1081
1082
  color: HighlightText;
1082
1083
  }
1083
1084
  }
1084
- `,he=`
1085
+ `,ue=`
1085
1086
  ${p}
1086
1087
 
1087
1088
  :host {
@@ -1123,7 +1124,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1123
1124
  :host([disabled]) {
1124
1125
  opacity: 0.5;
1125
1126
  }
1126
- `,de=`
1127
+ `,be=`
1127
1128
  ${p}
1128
1129
 
1129
1130
  :host {
@@ -1176,7 +1177,7 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1176
1177
  :host([disabled]) {
1177
1178
  opacity: 0.5;
1178
1179
  }
1179
- `,ce=`
1180
+ `,pe=`
1180
1181
  ${p}
1181
1182
 
1182
1183
  :host {
@@ -1296,8 +1297,117 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1296
1297
  background: HighlightText;
1297
1298
  }
1298
1299
  }
1299
- `,X='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';class O extends u{constructor(){super(...arguments),this._open=!1,this._previouslyFocused=null,this._triggerElement=null,this.handleTriggerClick=()=>{this.open=!0},this.handleClose=()=>{this.open=!1},this.handleKeyDown=e=>{var t;if(this._open){if(e.key==="Escape"){this.getAttribute("close-on-escape")!=="false"&&(e.preventDefault(),this.handleClose());return}if(e.key==="Tab"){e.preventDefault();const i=this.getFocusableElements();if(i.length===0)return;const s=((t=this.shadowRoot)==null?void 0:t.activeElement)||document.activeElement;let a=i.findIndex(n=>n===s);a===-1&&(a=e.shiftKey?0:i.length-1);let r;e.shiftKey?r=a===0?i.length-1:a-1:r=a===i.length-1?0:a+1;const h=i[r];h&&h.focus()}}}}static get observedAttributes(){return["open","trigger","close-on-outside-click","close-on-escape"]}get open(){return this._open}set open(e){const t=this._open;this._open=e,e!==t&&(e?this.showDialog():this.hideDialog()),this.toggleAttribute("open",e)}setupAccessibility(){}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-title`,i=`${this._id}-desc`;e.innerHTML=`
1300
- <style>${W}</style>
1300
+ `,me=`
1301
+ ${p}
1302
+
1303
+ :host {
1304
+ position: fixed;
1305
+ z-index: var(--compa11y-toast-z-index, 9999);
1306
+ padding: var(--compa11y-toast-viewport-padding, 1rem);
1307
+ display: flex;
1308
+ flex-direction: column;
1309
+ gap: var(--compa11y-toast-gap, 0.5rem);
1310
+ pointer-events: none;
1311
+ }
1312
+
1313
+ /* Position variants */
1314
+ :host([position="top-left"]) { top: 0; left: 0; }
1315
+ :host([position="top-center"]) { top: 0; left: 50%; transform: translateX(-50%); }
1316
+ :host([position="top-right"]) { top: 0; right: 0; }
1317
+ :host([position="bottom-left"]) { bottom: 0; left: 0; }
1318
+ :host(:not([position])),
1319
+ :host([position="bottom-right"]) { bottom: 0; right: 0; }
1320
+ :host([position="bottom-center"]) { bottom: 0; left: 50%; transform: translateX(-50%); }
1321
+
1322
+ .toast {
1323
+ pointer-events: auto;
1324
+ display: flex;
1325
+ align-items: flex-start;
1326
+ gap: 0.75rem;
1327
+ padding: var(--compa11y-toast-padding, 0.75rem 1rem);
1328
+ background: var(--compa11y-toast-bg, white);
1329
+ border: var(--compa11y-toast-border, 1px solid #e0e0e0);
1330
+ border-radius: var(--compa11y-toast-radius, 6px);
1331
+ box-shadow: var(--compa11y-toast-shadow, 0 4px 12px rgba(0, 0, 0, 0.15));
1332
+ min-width: var(--compa11y-toast-min-width, 250px);
1333
+ max-width: var(--compa11y-toast-max-width, 420px);
1334
+ }
1335
+
1336
+ .toast[data-type="error"] {
1337
+ border-left: 4px solid var(--compa11y-toast-error-color, #ef4444);
1338
+ }
1339
+
1340
+ .toast[data-type="warning"] {
1341
+ border-left: 4px solid var(--compa11y-toast-warning-color, #f59e0b);
1342
+ }
1343
+
1344
+ .toast[data-type="success"] {
1345
+ border-left: 4px solid var(--compa11y-toast-success-color, #22c55e);
1346
+ }
1347
+
1348
+ .toast[data-type="info"] {
1349
+ border-left: 4px solid var(--compa11y-toast-info-color, #3b82f6);
1350
+ }
1351
+
1352
+ .toast-content {
1353
+ flex: 1;
1354
+ min-width: 0;
1355
+ }
1356
+
1357
+ .toast-title {
1358
+ font-weight: var(--compa11y-toast-title-weight, 600);
1359
+ font-size: var(--compa11y-toast-title-size, 0.875rem);
1360
+ }
1361
+
1362
+ .toast-description {
1363
+ color: var(--compa11y-toast-description-color, #666);
1364
+ font-size: var(--compa11y-toast-description-size, 0.8125rem);
1365
+ margin-top: 0.125rem;
1366
+ }
1367
+
1368
+ .toast-close {
1369
+ ${S}
1370
+ flex-shrink: 0;
1371
+ width: 1.5rem;
1372
+ height: 1.5rem;
1373
+ display: flex;
1374
+ align-items: center;
1375
+ justify-content: center;
1376
+ border-radius: var(--compa11y-toast-close-radius, 4px);
1377
+ color: var(--compa11y-toast-close-color, #999);
1378
+ font-size: 1.125rem;
1379
+ line-height: 1;
1380
+ }
1381
+
1382
+ .toast-close:hover {
1383
+ background: var(--compa11y-toast-close-hover-bg, rgba(0, 0, 0, 0.05));
1384
+ color: var(--compa11y-toast-close-hover-color, #333);
1385
+ }
1386
+
1387
+ .toast-close:focus-visible {
1388
+ outline: 2px solid var(--compa11y-focus-color, #0066cc);
1389
+ outline-offset: 2px;
1390
+ }
1391
+
1392
+ .toast-action {
1393
+ ${S}
1394
+ margin-top: 0.375rem;
1395
+ font-size: var(--compa11y-toast-action-size, 0.8125rem);
1396
+ font-weight: 500;
1397
+ color: var(--compa11y-toast-action-color, #0066cc);
1398
+ text-decoration: underline;
1399
+ }
1400
+
1401
+ .toast-action:hover {
1402
+ color: var(--compa11y-toast-action-hover-color, #0052a3);
1403
+ }
1404
+
1405
+ .toast-action:focus-visible {
1406
+ outline: 2px solid var(--compa11y-focus-color, #0066cc);
1407
+ outline-offset: 2px;
1408
+ }
1409
+ `,J='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';let k=0,Q="";function ge(){k===0&&(Q=document.body.style.overflow,document.body.style.overflow="hidden"),k++}function ve(){k--,k<=0&&(k=0,document.body.style.overflow=Q)}class O extends u{constructor(){super(...arguments),this._open=!1,this._previouslyFocused=null,this._triggerElement=null,this.handleTriggerClick=()=>{this.open=!0},this.handleClose=()=>{this.open=!1},this.handleKeyDown=e=>{var t;if(this._open){if(e.key==="Escape"){this.getAttribute("close-on-escape")!=="false"&&(e.preventDefault(),this.handleClose());return}if(e.key==="Tab"){e.preventDefault();const i=this.getFocusableElements();if(i.length===0)return;const s=((t=this.shadowRoot)==null?void 0:t.activeElement)||document.activeElement;let a=i.findIndex(n=>n===s);a===-1&&(a=e.shiftKey?0:i.length-1);let r;e.shiftKey?r=a===0?i.length-1:a-1:r=a===i.length-1?0:a+1;const h=i[r];h&&h.focus()}}}}static get observedAttributes(){return["open","trigger","close-on-outside-click","close-on-escape"]}get open(){return this._open}set open(e){const t=this._open;this._open=e,e!==t&&(e?this.showDialog():this.hideDialog()),this.toggleAttribute("open",e)}setupAccessibility(){}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-title`,i=`${this._id}-desc`;e.innerHTML=`
1410
+ <style>${Z}</style>
1301
1411
  <div class="overlay" part="overlay"></div>
1302
1412
  <div
1303
1413
  class="dialog"
@@ -1320,8 +1430,8 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1320
1430
  <slot name="actions"></slot>
1321
1431
  </div>
1322
1432
  </div>
1323
- `,this._open||(this.style.display="none")}setupEventListeners(){var i;const e=this.getAttribute("trigger");if(e){const s=()=>{this._triggerElement=document.querySelector(e),this._triggerElement&&(this._triggerElement.addEventListener("click",this.handleTriggerClick),this._triggerElement.hasAttribute("tabindex")||this._triggerElement.setAttribute("tabindex","0"))};s(),this._triggerElement||requestAnimationFrame(()=>{s(),this._triggerElement||setTimeout(s,0)})}const t=(i=this.shadowRoot)==null?void 0:i.querySelector(".overlay");this.getAttribute("close-on-outside-click")!=="false"&&(t==null||t.addEventListener("click",this.handleClose)),this.addEventListener("keydown",this.handleKeyDown)}cleanupEventListeners(){var e;(e=this._triggerElement)==null||e.removeEventListener("click",this.handleTriggerClick),this.removeEventListener("keydown",this.handleKeyDown)}onAttributeChange(e,t,i){e==="open"&&(this.open=i!==null)}getFocusableElements(){const e=[];return this.querySelectorAll(X).forEach(i=>e.push(i)),this.shadowRoot&&this.shadowRoot.querySelectorAll(X).forEach(s=>{s.classList.contains("overlay")||e.push(s)}),e}showDialog(){this._previouslyFocused=document.activeElement,this.style.display="flex",requestAnimationFrame(()=>{const t=this.getFocusableElements()[0];t&&t.focus()}),document.body.style.overflow="hidden",o.announce("Dialog opened",{politeness:"polite"}),this.emit("a11y-dialog-open")}hideDialog(){var e;this.style.display="none",document.body.style.overflow="",(e=this._previouslyFocused)==null||e.focus(),this._previouslyFocused=null,o.announce("Dialog closed",{politeness:"polite"}),this.emit("a11y-dialog-close")}show(){this.open=!0}close(){this.open=!1}}b("a11y-dialog",O);class z extends u{constructor(){super(...arguments),this._open=!1,this._highlightedIndex=-1,this._menuItems=[],this.updateMenuItems=()=>{this._menuItems=Array.from(this.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')),this._menuItems.forEach((e,t)=>{e.id=e.id||`${this._id}-item-${t}`,e.setAttribute("tabindex","-1")})},this._lastClickTime=0,this.handleTriggerClick=()=>{const e=Date.now();e-this._lastClickTime<50||(this._lastClickTime=e,this.toggle())},this.handleTriggerKeyDown=e=>{switch(e.key){case"Enter":case" ":e.preventDefault(),this.toggle(),this._open&&this.highlightItem(0);break;case"ArrowDown":e.preventDefault(),this._open||this.show(),this.highlightItem(0);break;case"ArrowUp":e.preventDefault(),this._open||this.show(),this.highlightItem(this._menuItems.length-1);break}},this.handleMenuKeyDown=e=>{if(!this._open)return;const t=e.target;if(!(!t.hasAttribute("role")||t.getAttribute("role")!=="menuitem"))switch(e.key){case"ArrowDown":e.preventDefault(),this.highlightItem((this._highlightedIndex+1)%this._menuItems.length);break;case"ArrowUp":e.preventDefault(),this.highlightItem((this._highlightedIndex-1+this._menuItems.length)%this._menuItems.length);break;case"Home":e.preventDefault(),this.highlightItem(0);break;case"End":e.preventDefault(),this.highlightItem(this._menuItems.length-1);break;case"Enter":case" ":e.preventDefault(),this.selectItem(this._highlightedIndex);break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.close();break}},this.handleItemClick=e=>{const t=e.target;if(t.getAttribute("role")==="menuitem"&&t.getAttribute("aria-disabled")!=="true"){const i=this._menuItems.indexOf(t);this.selectItem(i)}},this.handleMouseOver=e=>{const t=e.target;if(t.getAttribute("role")==="menuitem"){const i=this._menuItems.indexOf(t);i!==-1&&this.highlightItem(i,!1)}},this.handleOutsideClick=e=>{if(!this._open)return;e.composedPath().includes(this)||this.close()}}static get observedAttributes(){return["open"]}get open(){return this._open}set open(e){const t=this._open;this._open=e,e!==t&&this.updateMenuVisibility(),this.toggleAttribute("open",e)}setupAccessibility(){const e=this.querySelector('[slot="trigger"]');e&&(e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded",String(this._open)),e.id=e.id||`${this._id}-trigger`,e.hasAttribute("tabindex")||e.setAttribute("tabindex","0"))}render(){const e=this.attachShadow({mode:"open"});e.innerHTML=`
1324
- <style>${J}</style>
1433
+ `,this._open||(this.style.display="none")}setupEventListeners(){var i;const e=this.getAttribute("trigger");if(e){const s=()=>{this._triggerElement=document.querySelector(e),this._triggerElement&&(this._triggerElement.addEventListener("click",this.handleTriggerClick),this._triggerElement.hasAttribute("tabindex")||this._triggerElement.setAttribute("tabindex","0"))};s(),this._triggerElement||requestAnimationFrame(()=>{s(),this._triggerElement||setTimeout(s,0)})}const t=(i=this.shadowRoot)==null?void 0:i.querySelector(".overlay");this.getAttribute("close-on-outside-click")!=="false"&&(t==null||t.addEventListener("click",this.handleClose)),this.addEventListener("keydown",this.handleKeyDown)}cleanupEventListeners(){var e;(e=this._triggerElement)==null||e.removeEventListener("click",this.handleTriggerClick),this.removeEventListener("keydown",this.handleKeyDown)}onAttributeChange(e,t,i){e==="open"&&(this.open=i!==null)}getFocusableElements(){const e=[];return this.querySelectorAll(J).forEach(i=>e.push(i)),this.shadowRoot&&this.shadowRoot.querySelectorAll(J).forEach(s=>{s.classList.contains("overlay")||e.push(s)}),e}showDialog(){this._previouslyFocused=document.activeElement,this.style.display="flex",requestAnimationFrame(()=>{const t=this.getFocusableElements()[0];t&&t.focus()}),ge(),o.announce("Dialog opened",{politeness:"polite"}),this.emit("a11y-dialog-open")}hideDialog(){var e;this.style.display="none",ve(),(e=this._previouslyFocused)==null||e.focus(),this._previouslyFocused=null,o.announce("Dialog closed",{politeness:"polite"}),this.emit("a11y-dialog-close")}show(){this.open=!0}close(){this.open=!1}}b("a11y-dialog",O);class D extends u{constructor(){super(...arguments),this._open=!1,this._highlightedIndex=-1,this._menuItems=[],this._triggerEl=null,this._triggerSlotEl=null,this._defaultSlotEl=null,this.updateMenuItems=()=>{this._menuItems=Array.from(this.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')),this._menuItems.forEach((e,t)=>{e.id=e.id||`${this._id}-item-${t}`,e.setAttribute("tabindex","-1")})},this._lastClickTime=0,this.handleTriggerClick=()=>{const e=Date.now();e-this._lastClickTime<50||(this._lastClickTime=e,this.toggle())},this.handleTriggerKeyDown=e=>{switch(e.key){case"Enter":case" ":e.preventDefault(),this.toggle(),this._open&&this.highlightItem(0);break;case"ArrowDown":e.preventDefault(),this._open||this.show(),this.highlightItem(0);break;case"ArrowUp":e.preventDefault(),this._open||this.show(),this.highlightItem(this._menuItems.length-1);break}},this.handleMenuKeyDown=e=>{if(!this._open)return;const t=e.target;if(!(!t.hasAttribute("role")||t.getAttribute("role")!=="menuitem"))switch(e.key){case"ArrowDown":e.preventDefault(),this.highlightItem((this._highlightedIndex+1)%this._menuItems.length);break;case"ArrowUp":e.preventDefault(),this.highlightItem((this._highlightedIndex-1+this._menuItems.length)%this._menuItems.length);break;case"Home":e.preventDefault(),this.highlightItem(0);break;case"End":e.preventDefault(),this.highlightItem(this._menuItems.length-1);break;case"Enter":case" ":e.preventDefault(),this.selectItem(this._highlightedIndex);break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.close();break}},this.handleItemClick=e=>{const t=e.target;if(t.getAttribute("role")==="menuitem"&&t.getAttribute("aria-disabled")!=="true"){const i=this._menuItems.indexOf(t);this.selectItem(i)}},this.handleMouseOver=e=>{const t=e.target;if(t.getAttribute("role")==="menuitem"){const i=this._menuItems.indexOf(t);i!==-1&&this.highlightItem(i,!1)}},this.handleOutsideClick=e=>{if(!this._open)return;e.composedPath().includes(this)||this.close()}}static get observedAttributes(){return["open"]}get open(){return this._open}set open(e){const t=this._open;this._open=e,e!==t&&this.updateMenuVisibility(),this.toggleAttribute("open",e)}setupAccessibility(){const e=this.querySelector('[slot="trigger"]');e&&(e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded",String(this._open)),e.id=e.id||`${this._id}-trigger`,e.hasAttribute("tabindex")||e.setAttribute("tabindex","0"))}render(){const e=this.attachShadow({mode:"open"});e.innerHTML=`
1434
+ <style>${ee}</style>
1325
1435
  <slot name="trigger"></slot>
1326
1436
  <div
1327
1437
  class="menu-content"
@@ -1333,8 +1443,8 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1333
1443
  >
1334
1444
  <slot></slot>
1335
1445
  </div>
1336
- `}setupEventListeners(){var s,a;const e=this.querySelector('[slot="trigger"]');e==null||e.addEventListener("click",this.handleTriggerClick),e==null||e.addEventListener("keydown",this.handleTriggerKeyDown);const t=(s=this.shadowRoot)==null?void 0:s.querySelector('slot[name="trigger"]');t==null||t.addEventListener("click",this.handleTriggerClick),this.addEventListener("click",this.handleItemClick),this.addEventListener("keydown",this.handleMenuKeyDown),this.addEventListener("mouseover",this.handleMouseOver),document.addEventListener("mousedown",this.handleOutsideClick);const i=(a=this.shadowRoot)==null?void 0:a.querySelector("slot:not([name])");i==null||i.addEventListener("slotchange",this.updateMenuItems),this.updateMenuItems()}cleanupEventListeners(){document.removeEventListener("mousedown",this.handleOutsideClick)}onAttributeChange(e,t,i){e==="open"&&(this.open=i!==null)}highlightItem(e,t=!0){var s;if(this._highlightedIndex>=0){const a=this._menuItems[this._highlightedIndex];a==null||a.removeAttribute("data-highlighted")}this._highlightedIndex=e;const i=this._menuItems[e];if(i){i.setAttribute("data-highlighted","true"),t&&i.focus();const a=(s=this.shadowRoot)==null?void 0:s.querySelector('[role="menu"]');a==null||a.setAttribute("aria-activedescendant",i.id)}}selectItem(e){const t=this._menuItems[e];t&&(this.emit("a11y-menu-select",{item:t,index:e}),t.click()),this.close()}updateMenuVisibility(){var i;const e=(i=this.shadowRoot)==null?void 0:i.querySelector(".menu-content"),t=this.querySelector('[slot="trigger"]');this._open?(e==null||e.removeAttribute("hidden"),t==null||t.setAttribute("aria-expanded","true"),this.updateMenuItems(),this.emit("a11y-menu-open")):(e==null||e.setAttribute("hidden",""),t==null||t.setAttribute("aria-expanded","false"),this._highlightedIndex=-1,this._menuItems.forEach(s=>{s.removeAttribute("data-highlighted")}),t==null||t.focus(),this.emit("a11y-menu-close"))}show(){this.open=!0}close(){this.open=!1}toggle(){this.open=!this._open}}b("a11y-menu",z);class q extends u{constructor(){super(...arguments),this._tabs=[],this._panels=[],this._selectedIndex=0,this.updateTabsAndPanels=()=>{this._tabs=Array.from(this.querySelectorAll('[role="tab"]')),this._panels=Array.from(this.querySelectorAll('[role="tabpanel"]')),this._tabs.forEach((e,t)=>{const i=this._panels[t],s=e.id||`${this._id}-tab-${t}`,a=(i==null?void 0:i.id)||`${this._id}-panel-${t}`;e.id=s,e.setAttribute("aria-controls",a),e.setAttribute("tabindex",t===this._selectedIndex?"0":"-1"),e.setAttribute("aria-selected",String(t===this._selectedIndex)),e.hasAttribute("slot")||e.setAttribute("slot","tab"),i&&(i.id=a,i.setAttribute("aria-labelledby",s),i.setAttribute("tabindex","0"),i.hidden=t!==this._selectedIndex,i.hasAttribute("slot")||i.setAttribute("slot","panel"))}),this.updateSelection()},this.handleClick=e=>{const t=e.target;if(t.getAttribute("role")==="tab"){const i=this._tabs.indexOf(t);i!==-1&&t.getAttribute("aria-disabled")!=="true"&&this.selectTab(i)}},this.handleKeyDown=e=>{var h;if(e.target.getAttribute("role")!=="tab")return;const i=this.orientation==="horizontal",s=i?"ArrowRight":"ArrowDown",a=i?"ArrowLeft":"ArrowUp";let r=this._selectedIndex;switch(e.key){case s:e.preventDefault(),r=(this._selectedIndex+1)%this._tabs.length;break;case a:e.preventDefault(),r=(this._selectedIndex-1+this._tabs.length)%this._tabs.length;break;case"Home":e.preventDefault(),r=0;break;case"End":e.preventDefault(),r=this._tabs.length-1;break;default:return}(h=this._tabs[r])==null||h.focus(),this.activationMode==="automatic"&&this.selectTab(r)}}static get observedAttributes(){return["orientation","activation-mode","selected-index"]}get selectedIndex(){return this._selectedIndex}set selectedIndex(e){e>=0&&e<this._tabs.length&&(this._selectedIndex=e,this.updateSelection())}get orientation(){return this.getAttribute("orientation")||"horizontal"}get activationMode(){return this.getAttribute("activation-mode")||"automatic"}setupAccessibility(){this.updateTabsAndPanels()}render(){const e=this.attachShadow({mode:"open"});e.innerHTML=`
1337
- <style>${Q}</style>
1446
+ `}setupEventListeners(){var e,t,i,s,a,r;this._triggerEl=this.querySelector('[slot="trigger"]'),(e=this._triggerEl)==null||e.addEventListener("click",this.handleTriggerClick),(t=this._triggerEl)==null||t.addEventListener("keydown",this.handleTriggerKeyDown),this._triggerSlotEl=((i=this.shadowRoot)==null?void 0:i.querySelector('slot[name="trigger"]'))??null,(s=this._triggerSlotEl)==null||s.addEventListener("click",this.handleTriggerClick),this.addEventListener("click",this.handleItemClick),this.addEventListener("keydown",this.handleMenuKeyDown),this.addEventListener("mouseover",this.handleMouseOver),document.addEventListener("mousedown",this.handleOutsideClick),this._defaultSlotEl=((a=this.shadowRoot)==null?void 0:a.querySelector("slot:not([name])"))??null,(r=this._defaultSlotEl)==null||r.addEventListener("slotchange",this.updateMenuItems),this.updateMenuItems()}cleanupEventListeners(){var e,t,i,s;(e=this._triggerEl)==null||e.removeEventListener("click",this.handleTriggerClick),(t=this._triggerEl)==null||t.removeEventListener("keydown",this.handleTriggerKeyDown),(i=this._triggerSlotEl)==null||i.removeEventListener("click",this.handleTriggerClick),this.removeEventListener("click",this.handleItemClick),this.removeEventListener("keydown",this.handleMenuKeyDown),this.removeEventListener("mouseover",this.handleMouseOver),document.removeEventListener("mousedown",this.handleOutsideClick),(s=this._defaultSlotEl)==null||s.removeEventListener("slotchange",this.updateMenuItems)}onAttributeChange(e,t,i){e==="open"&&(this.open=i!==null)}highlightItem(e,t=!0){var s;if(this._highlightedIndex>=0){const a=this._menuItems[this._highlightedIndex];a==null||a.removeAttribute("data-highlighted")}this._highlightedIndex=e;const i=this._menuItems[e];if(i){i.setAttribute("data-highlighted","true"),t&&i.focus();const a=(s=this.shadowRoot)==null?void 0:s.querySelector('[role="menu"]');a==null||a.setAttribute("aria-activedescendant",i.id)}}selectItem(e){const t=this._menuItems[e];t&&(this.emit("a11y-menu-select",{item:t,index:e}),t.click()),this.close()}updateMenuVisibility(){var i;const e=(i=this.shadowRoot)==null?void 0:i.querySelector(".menu-content"),t=this.querySelector('[slot="trigger"]');this._open?(e==null||e.removeAttribute("hidden"),t==null||t.setAttribute("aria-expanded","true"),this.updateMenuItems(),this.emit("a11y-menu-open")):(e==null||e.setAttribute("hidden",""),t==null||t.setAttribute("aria-expanded","false"),this._highlightedIndex=-1,this._menuItems.forEach(s=>{s.removeAttribute("data-highlighted")}),t==null||t.focus(),this.emit("a11y-menu-close"))}show(){this.open=!0}close(){this.open=!1}toggle(){this.open=!this._open}}b("a11y-menu",D);class q extends u{constructor(){super(...arguments),this._tabs=[],this._panels=[],this._selectedIndex=0,this._focusedIndex=0,this._tabSlotEl=null,this._panelSlotEl=null,this._defaultSlotEl=null,this.updateTabsAndPanels=()=>{this._tabs=Array.from(this.querySelectorAll('[role="tab"]')),this._panels=Array.from(this.querySelectorAll('[role="tabpanel"]')),this._tabs.forEach((e,t)=>{const i=this._panels[t],s=e.id||`${this._id}-tab-${t}`,a=(i==null?void 0:i.id)||`${this._id}-panel-${t}`;e.id=s,e.setAttribute("aria-controls",a),e.setAttribute("tabindex",t===this._selectedIndex?"0":"-1"),e.setAttribute("aria-selected",String(t===this._selectedIndex)),e.hasAttribute("slot")||e.setAttribute("slot","tab"),i&&(i.id=a,i.setAttribute("aria-labelledby",s),i.setAttribute("tabindex","0"),i.hidden=t!==this._selectedIndex,i.hasAttribute("slot")||i.setAttribute("slot","panel"))}),this.updateSelection()},this.handleClick=e=>{const t=e.target;if(t.getAttribute("role")==="tab"){const i=this._tabs.indexOf(t);i!==-1&&t.getAttribute("aria-disabled")!=="true"&&(this._focusedIndex=i,this.selectTab(i))}},this.handleKeyDown=e=>{var h;if(e.target.getAttribute("role")!=="tab")return;const i=this.orientation==="horizontal",s=i?"ArrowRight":"ArrowDown",a=i?"ArrowLeft":"ArrowUp";let r=this._focusedIndex;switch(e.key){case s:e.preventDefault(),r=(this._focusedIndex+1)%this._tabs.length;break;case a:e.preventDefault(),r=(this._focusedIndex-1+this._tabs.length)%this._tabs.length;break;case"Home":e.preventDefault(),r=0;break;case"End":e.preventDefault(),r=this._tabs.length-1;break;case"Enter":case" ":e.preventDefault(),this.selectTab(this._focusedIndex);return;default:return}this._focusedIndex=r,(h=this._tabs[r])==null||h.focus(),this.activationMode==="automatic"&&this.selectTab(r)}}static get observedAttributes(){return["orientation","activation-mode","selected-index"]}get selectedIndex(){return this._selectedIndex}set selectedIndex(e){e>=0&&e<this._tabs.length&&(this._selectedIndex=e,this.updateSelection())}get orientation(){return this.getAttribute("orientation")||"horizontal"}get activationMode(){return this.getAttribute("activation-mode")||"automatic"}setupAccessibility(){this.updateTabsAndPanels()}render(){const e=this.attachShadow({mode:"open"});e.innerHTML=`
1447
+ <style>${te}</style>
1338
1448
  <div class="tablist" role="tablist" aria-orientation="${this.orientation}" part="tablist">
1339
1449
  <slot name="tab"></slot>
1340
1450
  </div>
@@ -1342,8 +1452,8 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1342
1452
  <slot name="panel"></slot>
1343
1453
  </div>
1344
1454
  <slot></slot>
1345
- `}setupEventListeners(){var s,a,r;this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown);const e=(s=this.shadowRoot)==null?void 0:s.querySelector('slot[name="tab"]'),t=(a=this.shadowRoot)==null?void 0:a.querySelector('slot[name="panel"]'),i=(r=this.shadowRoot)==null?void 0:r.querySelector("slot:not([name])");e==null||e.addEventListener("slotchange",this.updateTabsAndPanels),t==null||t.addEventListener("slotchange",this.updateTabsAndPanels),i==null||i.addEventListener("slotchange",this.updateTabsAndPanels)}onAttributeChange(e,t,i){var s;if(e==="orientation"){const a=(s=this.shadowRoot)==null?void 0:s.querySelector('[role="tablist"]');a==null||a.setAttribute("aria-orientation",i||"horizontal")}e==="selected-index"&&i&&(this.selectedIndex=parseInt(i,10))}selectTab(e){const t=this._selectedIndex;if(this._selectedIndex=e,this.updateSelection(),t!==e){const i=this._tabs[e];o.announce(`${(i==null?void 0:i.textContent)||"Tab"} selected`),this.emit("a11y-tabs-change",{index:e,tab:this._tabs[e],panel:this._panels[e]})}}updateSelection(){this._tabs.forEach((e,t)=>{const i=t===this._selectedIndex;e.setAttribute("aria-selected",String(i)),e.setAttribute("tabindex",i?"0":"-1")}),this._panels.forEach((e,t)=>{e.hidden=t!==this._selectedIndex})}select(e){this.selectTab(e)}next(){this.selectTab((this._selectedIndex+1)%this._tabs.length)}previous(){this.selectTab((this._selectedIndex-1+this._tabs.length)%this._tabs.length)}}b("a11y-tabs",q);class D extends u{constructor(){super(...arguments),this._open=!1,this._highlightedIndex=-1,this._options=[],this._filteredOptions=[],this._inputValue="",this._selectedValue=null,this._inputElement=null,this._listboxElement=null,this.updateOptions=()=>{const e=Array.from(this.querySelectorAll("option"));this._options=e.map(t=>({value:t.getAttribute("value")||t.textContent||"",label:t.textContent||"",disabled:t.hasAttribute("disabled"),element:t})),this._filteredOptions=[...this._options],this.renderOptions()},this.handleInput=e=>{const t=e.target;this._inputValue=t.value;const i=this._inputValue.toLowerCase();this._filteredOptions=i?this._options.filter(a=>a.label.toLowerCase().includes(i)):[...this._options],this.renderOptions(),this.open=!0,this._highlightedIndex=0,this.updateHighlight(),this.updateClearButton();const s=this._filteredOptions.length;o.announce(s===0?"No results":`${s} result${s===1?"":"s"} available`)},this.handleFocus=()=>{this.open=!0},this.handleBlur=()=>{setTimeout(()=>{var e;(e=this.shadowRoot)!=null&&e.activeElement||(this.open=!1)},150)},this.handleKeyDown=e=>{switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this._highlightedIndex=Math.min(this._highlightedIndex+1,this._filteredOptions.length-1):(this.open=!0,this._highlightedIndex=0),this.updateHighlight();break;case"ArrowUp":e.preventDefault(),this._open?this._highlightedIndex=Math.max(this._highlightedIndex-1,0):(this.open=!0,this._highlightedIndex=this._filteredOptions.length-1),this.updateHighlight();break;case"Enter":if(e.preventDefault(),this._open&&this._highlightedIndex>=0){const t=this._filteredOptions[this._highlightedIndex];t&&!t.disabled&&this.selectOption(t)}break;case"Escape":e.preventDefault(),this.open=!1,this._highlightedIndex=-1;break;case"Home":this._open&&(e.preventDefault(),this._highlightedIndex=0,this.updateHighlight());break;case"End":this._open&&(e.preventDefault(),this._highlightedIndex=this._filteredOptions.length-1,this.updateHighlight());break;case"Tab":this._open&&(this.open=!1,this._highlightedIndex=-1);break}},this.handleOptionClick=e=>{const t=e.currentTarget,i=parseInt(t.dataset.index||"0",10),s=this._filteredOptions[i];s&&!s.disabled&&this.selectOption(s)},this.handleOptionHover=e=>{const t=e.currentTarget,i=parseInt(t.dataset.index||"0",10),s=this._filteredOptions[i];s&&!s.disabled&&(this._highlightedIndex=i,this.updateHighlight())},this.handleClear=()=>{this._inputValue="",this._selectedValue=null,this._inputElement&&(this._inputElement.value="",this._inputElement.focus()),this._filteredOptions=[...this._options],this.renderOptions(),this.updateClearButton(),this.emit("a11y-combobox-clear"),this.emit("a11y-combobox-change",{value:null,label:null})},this.handleOutsideClick=e=>{if(!this._open)return;e.composedPath().includes(this)||(this.open=!1)}}static get observedAttributes(){return["open","value","placeholder","disabled","clearable"]}get open(){return this._open}set open(e){const t=this._open;this._open=e,e!==t&&this.updateListboxVisibility(),this.toggleAttribute("open",e)}get value(){return this._selectedValue}set value(e){this._selectedValue=e;const t=this._options.find(i=>i.value===e);t&&(this._inputValue=t.label,this._inputElement&&(this._inputElement.value=t.label)),this.setAttribute("value",e||"")}setupAccessibility(){}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-input`,i=`${this._id}-listbox`,s=this.getAttribute("placeholder")||"Search...",a=this.hasAttribute("clearable");e.innerHTML=`
1346
- <style>${Z}</style>
1455
+ `}setupEventListeners(){var e,t,i,s,a,r;this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this._tabSlotEl=((e=this.shadowRoot)==null?void 0:e.querySelector('slot[name="tab"]'))??null,this._panelSlotEl=((t=this.shadowRoot)==null?void 0:t.querySelector('slot[name="panel"]'))??null,this._defaultSlotEl=((i=this.shadowRoot)==null?void 0:i.querySelector("slot:not([name])"))??null,(s=this._tabSlotEl)==null||s.addEventListener("slotchange",this.updateTabsAndPanels),(a=this._panelSlotEl)==null||a.addEventListener("slotchange",this.updateTabsAndPanels),(r=this._defaultSlotEl)==null||r.addEventListener("slotchange",this.updateTabsAndPanels)}cleanupEventListeners(){var e,t,i;this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown),(e=this._tabSlotEl)==null||e.removeEventListener("slotchange",this.updateTabsAndPanels),(t=this._panelSlotEl)==null||t.removeEventListener("slotchange",this.updateTabsAndPanels),(i=this._defaultSlotEl)==null||i.removeEventListener("slotchange",this.updateTabsAndPanels)}onAttributeChange(e,t,i){var s;if(e==="orientation"){const a=(s=this.shadowRoot)==null?void 0:s.querySelector('[role="tablist"]');a==null||a.setAttribute("aria-orientation",i||"horizontal")}e==="selected-index"&&i&&(this.selectedIndex=parseInt(i,10))}selectTab(e){const t=this._selectedIndex;if(this._selectedIndex=e,this._focusedIndex=e,this.updateSelection(),t!==e){const i=this._tabs[e];o.announce(`${(i==null?void 0:i.textContent)||"Tab"} selected`),this.emit("a11y-tabs-change",{index:e,tab:this._tabs[e],panel:this._panels[e]})}}updateSelection(){this._tabs.forEach((e,t)=>{const i=t===this._selectedIndex;e.setAttribute("aria-selected",String(i)),e.setAttribute("tabindex",i?"0":"-1")}),this._panels.forEach((e,t)=>{e.hidden=t!==this._selectedIndex})}select(e){this.selectTab(e)}next(){this.selectTab((this._selectedIndex+1)%this._tabs.length)}previous(){this.selectTab((this._selectedIndex-1+this._tabs.length)%this._tabs.length)}}b("a11y-tabs",q);class R extends u{constructor(){super(...arguments),this._open=!1,this._highlightedIndex=-1,this._options=[],this._filteredOptions=[],this._inputValue="",this._selectedValue=null,this._inputElement=null,this._listboxElement=null,this.updateOptions=()=>{const e=Array.from(this.querySelectorAll("option"));this._options=e.map(t=>({value:t.getAttribute("value")||t.textContent||"",label:t.textContent||"",disabled:t.hasAttribute("disabled"),element:t})),this._filteredOptions=[...this._options],this.renderOptions()},this.handleInput=e=>{const t=e.target;this._inputValue=t.value;const i=this._inputValue.toLowerCase();this._filteredOptions=i?this._options.filter(a=>a.label.toLowerCase().includes(i)):[...this._options],this.renderOptions(),this.open=!0,this._highlightedIndex=0,this.updateHighlight(),this.updateClearButton();const s=this._filteredOptions.length;o.announce(s===0?"No results":`${s} result${s===1?"":"s"} available`)},this.handleFocus=()=>{this.open=!0},this.handleBlur=()=>{setTimeout(()=>{var e;(e=this.shadowRoot)!=null&&e.activeElement||(this.open=!1)},150)},this.handleKeyDown=e=>{switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this._highlightedIndex=Math.min(this._highlightedIndex+1,this._filteredOptions.length-1):(this.open=!0,this._highlightedIndex=0),this.updateHighlight();break;case"ArrowUp":e.preventDefault(),this._open?this._highlightedIndex=Math.max(this._highlightedIndex-1,0):(this.open=!0,this._highlightedIndex=this._filteredOptions.length-1),this.updateHighlight();break;case"Enter":if(e.preventDefault(),this._open&&this._highlightedIndex>=0){const t=this._filteredOptions[this._highlightedIndex];t&&!t.disabled&&this.selectOption(t)}break;case"Escape":e.preventDefault(),this.open=!1,this._highlightedIndex=-1;break;case"Home":this._open&&(e.preventDefault(),this._highlightedIndex=0,this.updateHighlight());break;case"End":this._open&&(e.preventDefault(),this._highlightedIndex=this._filteredOptions.length-1,this.updateHighlight());break;case"Tab":this._open&&(this.open=!1,this._highlightedIndex=-1);break}},this.handleOptionClick=e=>{const t=e.currentTarget,i=parseInt(t.dataset.index||"0",10),s=this._filteredOptions[i];s&&!s.disabled&&this.selectOption(s)},this.handleOptionHover=e=>{const t=e.currentTarget,i=parseInt(t.dataset.index||"0",10),s=this._filteredOptions[i];s&&!s.disabled&&(this._highlightedIndex=i,this.updateHighlight())},this.handleClear=()=>{this._inputValue="",this._selectedValue=null,this._inputElement&&(this._inputElement.value="",this._inputElement.focus()),this._filteredOptions=[...this._options],this.renderOptions(),this.updateClearButton(),this.emit("a11y-combobox-clear"),this.emit("a11y-combobox-change",{value:null,label:null})},this.handleOutsideClick=e=>{if(!this._open)return;e.composedPath().includes(this)||(this.open=!1)}}static get observedAttributes(){return["open","value","placeholder","disabled","clearable"]}get open(){return this._open}set open(e){const t=this._open;this._open=e,e!==t&&this.updateListboxVisibility(),this.toggleAttribute("open",e)}get value(){return this._selectedValue}set value(e){this._selectedValue=e;const t=this._options.find(i=>i.value===e);t&&(this._inputValue=t.label,this._inputElement&&(this._inputElement.value=t.label)),this.setAttribute("value",e||"")}setupAccessibility(){}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-input`,i=`${this._id}-listbox`,s=this.getAttribute("placeholder")||"Search...",a=this.hasAttribute("clearable");e.innerHTML=`
1456
+ <style>${ie}</style>
1347
1457
  <div class="combobox-wrapper" part="wrapper">
1348
1458
  <div class="input-wrapper" part="input-wrapper">
1349
1459
  <input
@@ -1394,9 +1504,9 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1394
1504
  part="option"
1395
1505
  ${e.disabled?'class="disabled"':""}
1396
1506
  >${e.label}</li>
1397
- `).join(""),this._listboxElement.querySelectorAll('[role="option"]').forEach(e=>{e.addEventListener("click",this.handleOptionClick),e.addEventListener("mouseenter",this.handleOptionHover)}))}selectOption(e){this._selectedValue=e.value,this._inputValue=e.label,this._inputElement&&(this._inputElement.value=e.label),this.open=!1,this._highlightedIndex=-1,this.renderOptions(),this.updateClearButton(),o.announce(`${e.label} selected`),this.emit("a11y-combobox-select",{value:e.value,label:e.label}),this.emit("a11y-combobox-change",{value:e.value,label:e.label})}updateHighlight(){var e,t,i,s;if((e=this._listboxElement)==null||e.querySelectorAll('[role="option"]').forEach((a,r)=>{a.classList.toggle("highlighted",r===this._highlightedIndex)}),this._highlightedIndex>=0){const a=`${this._id}-option-${this._highlightedIndex}`;(t=this._inputElement)==null||t.setAttribute("aria-activedescendant",a);const r=(i=this._listboxElement)==null?void 0:i.querySelector(`#${a}`);r==null||r.scrollIntoView({block:"nearest",behavior:"smooth"})}else(s=this._inputElement)==null||s.removeAttribute("aria-activedescendant")}updateListboxVisibility(){!this._listboxElement||!this._inputElement||(this._open?(this._listboxElement.hidden=!1,this._inputElement.setAttribute("aria-expanded","true"),this.updateListboxPosition(),this.emit("a11y-combobox-open")):(this._listboxElement.hidden=!0,this._inputElement.setAttribute("aria-expanded","false"),this._highlightedIndex=-1,this.updateHighlight(),this._listboxElement.style.top="",this._listboxElement.style.bottom="",this.removeAttribute("data-position"),this.emit("a11y-combobox-close")))}updateListboxPosition(){if(!this._listboxElement||!this._inputElement)return;const e=this._inputElement.getBoundingClientRect(),t=window.innerHeight,i=Math.min(this._listboxElement.scrollHeight,200),s=t-e.bottom,a=e.top;s<i+8&&a>s?(this._listboxElement.style.top="auto",this._listboxElement.style.bottom="100%",this._listboxElement.style.marginTop="0",this._listboxElement.style.marginBottom="4px",this.setAttribute("data-position","top")):(this._listboxElement.style.top="100%",this._listboxElement.style.bottom="auto",this._listboxElement.style.marginTop="4px",this._listboxElement.style.marginBottom="0",this.setAttribute("data-position","bottom"))}updateClearButton(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".clear-button");e&&(e.hidden=!this._inputValue)}show(){this.open=!0}close(){this.open=!1}clear(){this.handleClear()}}b("a11y-combobox",D);class T extends u{constructor(){super(...arguments),this._checked=!1,this._button=null,this._label=null,this.handleClick=()=>{this.toggle()},this.handleKeyDown=e=>{this.disabled||(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())},this.handleLabelClick=()=>{var e;this.disabled||(this.toggle(),(e=this._button)==null||e.focus())}}static get observedAttributes(){return["checked","disabled","label","size","aria-label"]}get checked(){return this._checked}set checked(e){const t=this._checked;this._checked=e,this.toggleAttribute("checked",e),e!==t&&(this.updateVisualState(),this.emit("change",{checked:e}))}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e),this.updateDisabledState()}get label(){return this.getAttribute("label")||""}set label(e){e?this.setAttribute("label",e):this.removeAttribute("label")}get size(){const e=this.getAttribute("size");return e==="sm"||e==="lg"?e:"md"}set size(e){this.setAttribute("size",e)}setupAccessibility(){var e;this.getAttribute("role"),typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&!this.label&&!this.getAttribute("aria-label")&&console.warn(`[compa11y/Switch] Switch has no accessible label. Add label="..." or aria-label="..." attribute.
1507
+ `).join(""),this._listboxElement.querySelectorAll('[role="option"]').forEach(e=>{e.addEventListener("click",this.handleOptionClick),e.addEventListener("mouseenter",this.handleOptionHover)}))}selectOption(e){this._selectedValue=e.value,this._inputValue=e.label,this._inputElement&&(this._inputElement.value=e.label),this.open=!1,this._highlightedIndex=-1,this.renderOptions(),this.updateClearButton(),o.announce(`${e.label} selected`),this.emit("a11y-combobox-select",{value:e.value,label:e.label}),this.emit("a11y-combobox-change",{value:e.value,label:e.label})}updateHighlight(){var e,t,i,s;if((e=this._listboxElement)==null||e.querySelectorAll('[role="option"]').forEach((a,r)=>{a.classList.toggle("highlighted",r===this._highlightedIndex)}),this._highlightedIndex>=0){const a=`${this._id}-option-${this._highlightedIndex}`;(t=this._inputElement)==null||t.setAttribute("aria-activedescendant",a);const r=(i=this._listboxElement)==null?void 0:i.querySelector(`#${a}`);r==null||r.scrollIntoView({block:"nearest",behavior:"smooth"})}else(s=this._inputElement)==null||s.removeAttribute("aria-activedescendant")}updateListboxVisibility(){!this._listboxElement||!this._inputElement||(this._open?(this._listboxElement.hidden=!1,this._inputElement.setAttribute("aria-expanded","true"),this.updateListboxPosition(),this.emit("a11y-combobox-open")):(this._listboxElement.hidden=!0,this._inputElement.setAttribute("aria-expanded","false"),this._highlightedIndex=-1,this.updateHighlight(),this._listboxElement.style.top="",this._listboxElement.style.bottom="",this.removeAttribute("data-position"),this.emit("a11y-combobox-close")))}updateListboxPosition(){if(!this._listboxElement||!this._inputElement)return;const e=this._inputElement.getBoundingClientRect(),t=window.innerHeight,i=Math.min(this._listboxElement.scrollHeight,200),s=t-e.bottom,a=e.top;s<i+8&&a>s?(this._listboxElement.style.top="auto",this._listboxElement.style.bottom="100%",this._listboxElement.style.marginTop="0",this._listboxElement.style.marginBottom="4px",this.setAttribute("data-position","top")):(this._listboxElement.style.top="100%",this._listboxElement.style.bottom="auto",this._listboxElement.style.marginTop="4px",this._listboxElement.style.marginBottom="0",this.setAttribute("data-position","bottom"))}updateClearButton(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".clear-button");e&&(e.hidden=!this._inputValue)}show(){this.open=!0}close(){this.open=!1}clear(){this.handleClear()}}b("a11y-combobox",R);class H extends u{constructor(){super(...arguments),this._checked=!1,this._button=null,this._label=null,this.handleClick=()=>{this.toggle()},this.handleKeyDown=e=>{this.disabled||(e.key===" "||e.key==="Enter")&&(e.preventDefault(),this.toggle())},this.handleLabelClick=()=>{var e;this.disabled||(this.toggle(),(e=this._button)==null||e.focus())}}static get observedAttributes(){return["checked","disabled","label","size","aria-label"]}get checked(){return this._checked}set checked(e){const t=this._checked;this._checked=e,this.toggleAttribute("checked",e),e!==t&&(this.updateVisualState(),this.emit("change",{checked:e}))}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e),this.updateDisabledState()}get label(){return this.getAttribute("label")||""}set label(e){e?this.setAttribute("label",e):this.removeAttribute("label")}get size(){const e=this.getAttribute("size");return e==="sm"||e==="lg"?e:"md"}set size(e){this.setAttribute("size",e)}setupAccessibility(){var e;this.getAttribute("role"),typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&!this.label&&!this.getAttribute("aria-label")&&console.warn(`[compa11y/Switch] Switch has no accessible label. Add label="..." or aria-label="..." attribute.
1398
1508
  💡 Suggestion: <a11y-switch label="Enable feature"></a11y-switch>`)}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-label`,i=!!this.label,s=this.getAttribute("aria-label"),a=i?"":s?`aria-label="${s}"`:"",r=i?`aria-labelledby="${t}"`:"";e.innerHTML=`
1399
- <style>${te}</style>
1509
+ <style>${ae}</style>
1400
1510
  <div class="switch-wrapper size-${this.size}" part="wrapper">
1401
1511
  <button
1402
1512
  type="button"
@@ -1413,8 +1523,8 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1413
1523
  </button>
1414
1524
  ${i?`<label id="${t}" class="switch-label ${this.disabled?"disabled":""}" part="label">${this.label}</label>`:""}
1415
1525
  </div>
1416
- `,this._button=e.querySelector("button"),this._label=e.querySelector("label")}setupEventListeners(){var e,t,i;(e=this._button)==null||e.addEventListener("click",this.handleClick),(t=this._button)==null||t.addEventListener("keydown",this.handleKeyDown),(i=this._label)==null||i.addEventListener("click",this.handleLabelClick)}cleanupEventListeners(){var e,t,i;(e=this._button)==null||e.removeEventListener("click",this.handleClick),(t=this._button)==null||t.removeEventListener("keydown",this.handleKeyDown),(i=this._label)==null||i.removeEventListener("click",this.handleLabelClick)}onAttributeChange(e,t,i){switch(e){case"checked":this._checked=i!==null,this.updateVisualState();break;case"disabled":this.updateDisabledState();break;case"label":case"aria-label":this.shadowRoot&&(this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break;case"size":this.updateSizeClass();break}}updateVisualState(){this._button&&(this._button.setAttribute("aria-checked",String(this._checked)),this._button.classList.toggle("checked",this._checked))}updateDisabledState(){this._button&&(this.disabled?(this._button.setAttribute("disabled",""),this._button.setAttribute("tabindex","-1")):(this._button.removeAttribute("disabled"),this._button.setAttribute("tabindex","0"))),this._label&&this._label.classList.toggle("disabled",this.disabled)}updateSizeClass(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".switch-wrapper");e&&(e.classList.remove("size-sm","size-md","size-lg"),e.classList.add(`size-${this.size}`))}toggle(){if(this.disabled)return;this.checked=!this.checked;const e=this.label||this.getAttribute("aria-label")||"Switch";o.announcePolite(`${e} ${this.checked?"on":"off"}`)}setChecked(e){this.checked=e}}b("a11y-switch",T);class R extends u{constructor(){super(...arguments),this._open=!1,this._highlightedIndex=-1,this._options=[],this._selectedValue=null,this._triggerElement=null,this._listboxElement=null,this._typeAhead=null,this.updateOptions=()=>{const e=Array.from(this.querySelectorAll("option"));this._options=e.map(t=>({value:t.getAttribute("value")||t.textContent||"",label:t.textContent||"",disabled:t.hasAttribute("disabled"),element:t})),this._typeAhead=o.createTypeAhead(this._options.map(t=>t.label),{timeout:500}),this.renderOptions(),this.updateTriggerText()},this.handleTriggerClick=()=>{var e;(e=this._triggerElement)!=null&&e.disabled||(this._open?(this.open=!1,this._highlightedIndex=-1):this.openAndHighlight())},this.handleKeyDown=e=>{var t;switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this.highlightNext():this.openAndHighlight();break;case"ArrowUp":e.preventDefault(),this._open?this.highlightPrevious():this.openAndHighlight(!0);break;case"Enter":if(e.preventDefault(),this._open&&this._highlightedIndex>=0){const i=this._options[this._highlightedIndex];i&&!i.disabled&&this.selectOption(i)}else this._open||this.openAndHighlight();break;case" ":if(e.preventDefault(),this._open&&this._highlightedIndex>=0){const i=this._options[this._highlightedIndex];i&&!i.disabled&&this.selectOption(i)}else this._open||this.openAndHighlight();break;case"Escape":e.preventDefault(),this._open&&(this.open=!1,this._highlightedIndex=-1);break;case"Home":this._open&&(e.preventDefault(),this._highlightedIndex=this.findFirstEnabled(),this.updateHighlight());break;case"End":this._open&&(e.preventDefault(),this._highlightedIndex=this.findLastEnabled(),this.updateHighlight());break;case"Tab":this._open&&(this.open=!1,this._highlightedIndex=-1);break;default:if(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey){const i=(t=this._typeAhead)==null?void 0:t.type(e.key);if(i){const s=this._options.findIndex(a=>a.label===i&&!a.disabled);s>=0&&(this._open||(this.open=!0),this._highlightedIndex=s,this.updateHighlight())}}break}},this.handleBlur=()=>{setTimeout(()=>{var e;(e=this.shadowRoot)!=null&&e.activeElement||(this.open=!1,this._highlightedIndex=-1)},150)},this.handleListboxMouseDown=e=>{e.preventDefault()},this.handleOptionClick=e=>{const t=e.currentTarget,i=parseInt(t.dataset.index||"0",10),s=this._options[i];s&&!s.disabled&&this.selectOption(s)},this.handleOptionHover=e=>{const t=e.currentTarget,i=parseInt(t.dataset.index||"0",10),s=this._options[i];s&&!s.disabled&&(this._highlightedIndex=i,this.updateHighlight())},this.handleOutsideClick=e=>{if(!this._open)return;e.composedPath().includes(this)||(this.open=!1,this._highlightedIndex=-1)}}static get observedAttributes(){return["open","value","placeholder","disabled"]}get open(){return this._open}set open(e){const t=this._open;this._open=e,e!==t&&this.updateListboxVisibility(),this.toggleAttribute("open",e)}get value(){return this._selectedValue}set value(e){this._selectedValue=e,this.updateTriggerText(),this.setAttribute("value",e||"")}setupAccessibility(){}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-trigger`,i=`${this._id}-listbox`,s=this.getAttribute("placeholder")||"Select an option...",a=this.getAttribute("aria-label")||"",r=this.getAttribute("aria-labelledby")||"";e.innerHTML=`
1417
- <style>${ee}</style>
1526
+ `,this._button=e.querySelector("button"),this._label=e.querySelector("label")}setupEventListeners(){var e,t,i;(e=this._button)==null||e.addEventListener("click",this.handleClick),(t=this._button)==null||t.addEventListener("keydown",this.handleKeyDown),(i=this._label)==null||i.addEventListener("click",this.handleLabelClick)}cleanupEventListeners(){var e,t,i;(e=this._button)==null||e.removeEventListener("click",this.handleClick),(t=this._button)==null||t.removeEventListener("keydown",this.handleKeyDown),(i=this._label)==null||i.removeEventListener("click",this.handleLabelClick)}onAttributeChange(e,t,i){switch(e){case"checked":this._checked=i!==null,this.updateVisualState();break;case"disabled":this.updateDisabledState();break;case"label":case"aria-label":this.shadowRoot&&(this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break;case"size":this.updateSizeClass();break}}updateVisualState(){this._button&&(this._button.setAttribute("aria-checked",String(this._checked)),this._button.classList.toggle("checked",this._checked))}updateDisabledState(){this._button&&(this.disabled?(this._button.setAttribute("disabled",""),this._button.setAttribute("tabindex","-1")):(this._button.removeAttribute("disabled"),this._button.setAttribute("tabindex","0"))),this._label&&this._label.classList.toggle("disabled",this.disabled)}updateSizeClass(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".switch-wrapper");e&&(e.classList.remove("size-sm","size-md","size-lg"),e.classList.add(`size-${this.size}`))}toggle(){if(this.disabled)return;this.checked=!this.checked;const e=this.label||this.getAttribute("aria-label")||"Switch";o.announcePolite(`${e} ${this.checked?"on":"off"}`)}setChecked(e){this.checked=e}}b("a11y-switch",H);class B extends u{constructor(){super(...arguments),this._open=!1,this._highlightedIndex=-1,this._options=[],this._selectedValue=null,this._triggerElement=null,this._listboxElement=null,this._typeAhead=null,this.updateOptions=()=>{const e=Array.from(this.querySelectorAll("option"));this._options=e.map(t=>({value:t.getAttribute("value")||t.textContent||"",label:t.textContent||"",disabled:t.hasAttribute("disabled"),element:t})),this._typeAhead=o.createTypeAhead(this._options.map(t=>t.label),{timeout:500}),this.renderOptions(),this.updateTriggerText()},this.handleTriggerClick=()=>{var e;(e=this._triggerElement)!=null&&e.disabled||(this._open?(this.open=!1,this._highlightedIndex=-1):this.openAndHighlight())},this.handleKeyDown=e=>{var t;switch(e.key){case"ArrowDown":e.preventDefault(),this._open?this.highlightNext():this.openAndHighlight();break;case"ArrowUp":e.preventDefault(),this._open?this.highlightPrevious():this.openAndHighlight(!0);break;case"Enter":if(e.preventDefault(),this._open&&this._highlightedIndex>=0){const i=this._options[this._highlightedIndex];i&&!i.disabled&&this.selectOption(i)}else this._open||this.openAndHighlight();break;case" ":if(e.preventDefault(),this._open&&this._highlightedIndex>=0){const i=this._options[this._highlightedIndex];i&&!i.disabled&&this.selectOption(i)}else this._open||this.openAndHighlight();break;case"Escape":e.preventDefault(),this._open&&(this.open=!1,this._highlightedIndex=-1);break;case"Home":this._open&&(e.preventDefault(),this._highlightedIndex=this.findFirstEnabled(),this.updateHighlight());break;case"End":this._open&&(e.preventDefault(),this._highlightedIndex=this.findLastEnabled(),this.updateHighlight());break;case"Tab":this._open&&(this.open=!1,this._highlightedIndex=-1);break;default:if(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey){const i=(t=this._typeAhead)==null?void 0:t.type(e.key);if(i){const s=this._options.findIndex(a=>a.label===i&&!a.disabled);s>=0&&(this._open||(this.open=!0),this._highlightedIndex=s,this.updateHighlight())}}break}},this.handleBlur=()=>{setTimeout(()=>{var e;(e=this.shadowRoot)!=null&&e.activeElement||(this.open=!1,this._highlightedIndex=-1)},150)},this.handleListboxMouseDown=e=>{e.preventDefault()},this.handleOptionClick=e=>{const t=e.currentTarget,i=parseInt(t.dataset.index||"0",10),s=this._options[i];s&&!s.disabled&&this.selectOption(s)},this.handleOptionHover=e=>{const t=e.currentTarget,i=parseInt(t.dataset.index||"0",10),s=this._options[i];s&&!s.disabled&&(this._highlightedIndex=i,this.updateHighlight())},this.handleOutsideClick=e=>{if(!this._open)return;e.composedPath().includes(this)||(this.open=!1,this._highlightedIndex=-1)}}static get observedAttributes(){return["open","value","placeholder","disabled"]}get open(){return this._open}set open(e){const t=this._open;this._open=e,e!==t&&this.updateListboxVisibility(),this.toggleAttribute("open",e)}get value(){return this._selectedValue}set value(e){this._selectedValue=e,this.updateTriggerText(),this.setAttribute("value",e||"")}setupAccessibility(){}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-trigger`,i=`${this._id}-listbox`,s=this.getAttribute("placeholder")||"Select an option...",a=this.getAttribute("aria-label")||"",r=this.getAttribute("aria-labelledby")||"";e.innerHTML=`
1527
+ <style>${se}</style>
1418
1528
  <div class="select-wrapper" part="wrapper">
1419
1529
  <button
1420
1530
  id="${t}"
@@ -1458,77 +1568,77 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1458
1568
  <span class="option-text">${e.label}</span>
1459
1569
  ${this._selectedValue===e.value?'<span class="check-mark" aria-hidden="true">&#10003;</span>':""}
1460
1570
  </li>
1461
- `).join(""),this._listboxElement.querySelectorAll('[role="option"]').forEach(e=>{e.addEventListener("click",this.handleOptionClick),e.addEventListener("mouseenter",this.handleOptionHover)}))}openAndHighlight(e=!1){this.open=!0;const t=this._options.findIndex(i=>i.value===this._selectedValue);t>=0?this._highlightedIndex=t:this._highlightedIndex=e?this.findLastEnabled():this.findFirstEnabled(),this.updateHighlight(),o.announce(`${this._options.length} option${this._options.length===1?"":"s"} available`)}selectOption(e){this._selectedValue=e.value,this.updateTriggerText(),this.open=!1,this._highlightedIndex=-1,this.renderOptions(),o.announce(`${e.label} selected`),this.emit("a11y-select-change",{value:e.value,label:e.label}),this.emit("change",{value:e.value,label:e.label})}updateTriggerText(){var s;const e=(s=this.shadowRoot)==null?void 0:s.querySelector(".select-value");if(!e)return;const t=this._options.find(a=>a.value===this._selectedValue),i=this.getAttribute("placeholder")||"Select an option...";t?(e.textContent=t.label,e.classList.remove("placeholder")):(e.textContent=i,e.classList.add("placeholder"))}highlightNext(){const e=this.findNextEnabled(this._highlightedIndex,1);e>=0&&(this._highlightedIndex=e,this.updateHighlight())}highlightPrevious(){const e=this.findNextEnabled(this._highlightedIndex,-1);e>=0&&(this._highlightedIndex=e,this.updateHighlight())}findNextEnabled(e,t){var r;const i=this._options.length;let s=e+t;s<0&&(s=i-1),s>=i&&(s=0);const a=s;for(;(r=this._options[s])!=null&&r.disabled;)if(s+=t,s<0&&(s=i-1),s>=i&&(s=0),s===a)return-1;return s}findFirstEnabled(){return this._options.findIndex(e=>!e.disabled)}findLastEnabled(){var e;for(let t=this._options.length-1;t>=0;t--)if(!((e=this._options[t])!=null&&e.disabled))return t;return-1}updateHighlight(){var e,t,i,s;if((e=this._listboxElement)==null||e.querySelectorAll('[role="option"]').forEach((a,r)=>{a.classList.toggle("highlighted",r===this._highlightedIndex)}),this._highlightedIndex>=0){const a=`${this._id}-option-${this._highlightedIndex}`;(t=this._triggerElement)==null||t.setAttribute("aria-activedescendant",a);const r=(i=this._listboxElement)==null?void 0:i.querySelector(`#${a}`);r==null||r.scrollIntoView({block:"nearest",behavior:"smooth"})}else(s=this._triggerElement)==null||s.removeAttribute("aria-activedescendant")}updateListboxVisibility(){!this._listboxElement||!this._triggerElement||(this._open?(this._listboxElement.hidden=!1,this._triggerElement.setAttribute("aria-expanded","true"),this.updateListboxPosition(),this.emit("a11y-select-open")):(this._listboxElement.hidden=!0,this._triggerElement.setAttribute("aria-expanded","false"),this._highlightedIndex=-1,this.updateHighlight(),this._listboxElement.style.top="",this._listboxElement.style.bottom="",this.removeAttribute("data-position"),this.emit("a11y-select-close")))}updateListboxPosition(){if(!this._listboxElement||!this._triggerElement)return;const e=this._triggerElement.getBoundingClientRect(),t=window.innerHeight,i=Math.min(this._listboxElement.scrollHeight,200),s=t-e.bottom,a=e.top;s<i+8&&a>s?(this._listboxElement.style.top="auto",this._listboxElement.style.bottom="100%",this._listboxElement.style.marginTop="0",this._listboxElement.style.marginBottom="4px",this.setAttribute("data-position","top")):(this._listboxElement.style.top="100%",this._listboxElement.style.bottom="auto",this._listboxElement.style.marginTop="4px",this._listboxElement.style.marginBottom="0",this.setAttribute("data-position","bottom"))}show(){this.open=!0}close(){this.open=!1}}b("a11y-select",R);class B extends u{constructor(){super(...arguments),this._value="",this._inputEl=null,this._labelEl=null,this._hintEl=null,this._errorEl=null,this.handleInput=e=>{const t=e.target;this._value=t.value,this.emit("input",{value:this._value})},this.handleChange=e=>{const t=e.target;this._value=t.value,this.emit("change",{value:this._value})},this.handleFocus=()=>{this.emit("a11y-input-focus")},this.handleBlur=()=>{this.emit("a11y-input-blur")}}static get observedAttributes(){return["label","hint","error","type","placeholder","value","disabled","readonly","required","name","autocomplete","maxlength","minlength","pattern","inputmode","aria-label","aria-labelledby"]}get value(){return this._value}set value(e){const t=this._value;this._value=e,this._inputEl&&this._inputEl.value!==e&&(this._inputEl.value=e),e!==t&&this.setAttribute("value",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e)}get readOnly(){return this.hasAttribute("readonly")}set readOnly(e){this.toggleAttribute("readonly",e)}get required(){return this.hasAttribute("required")}set required(e){this.toggleAttribute("required",e)}get error(){return this.getAttribute("error")||""}set error(e){e?this.setAttribute("error",e):this.removeAttribute("error")}setupAccessibility(){var e;typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&(this.hasAttribute("label")||this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||console.warn(`[compa11y/Input] Input has no accessible label. Add label="...", aria-label="...", or aria-labelledby="..." attribute.
1462
- 💡 Suggestion: <a11y-input label="Full Name"></a11y-input>`))}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-field`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=this.getAttribute("label")||"",h=this.getAttribute("hint")||"",n=this.getAttribute("error")||"",g=this.getAttribute("type")||"text",c=this.getAttribute("placeholder")||"",m=this.getAttribute("name")||"",f=this.getAttribute("autocomplete")||"",v=this.getAttribute("maxlength"),y=this.getAttribute("minlength"),k=this.getAttribute("pattern"),w=this.getAttribute("inputmode"),S=this.getAttribute("aria-label")||"",I=this.getAttribute("aria-labelledby")||"",C=this.disabled,x=this.readOnly,_=this.required,A=!!n,E=[];h&&E.push(s),A&&E.push(a);const Y=E.length?`aria-describedby="${E.join(" ")}"`:"",$=!r&&S?`aria-label="${S}"`:"",pe=!r&&I?`aria-labelledby="${I}"`:r?`aria-labelledby="${i}"`:"";this.setAttribute("data-error",A?"true":"false"),e.innerHTML=`
1463
- <style>${ie}</style>
1571
+ `).join(""),this._listboxElement.querySelectorAll('[role="option"]').forEach(e=>{e.addEventListener("click",this.handleOptionClick),e.addEventListener("mouseenter",this.handleOptionHover)}))}openAndHighlight(e=!1){this.open=!0;const t=this._options.findIndex(i=>i.value===this._selectedValue);t>=0?this._highlightedIndex=t:this._highlightedIndex=e?this.findLastEnabled():this.findFirstEnabled(),this.updateHighlight(),o.announce(`${this._options.length} option${this._options.length===1?"":"s"} available`)}selectOption(e){this._selectedValue=e.value,this.updateTriggerText(),this.open=!1,this._highlightedIndex=-1,this.renderOptions(),o.announce(`${e.label} selected`),this.emit("a11y-select-change",{value:e.value,label:e.label}),this.emit("change",{value:e.value,label:e.label})}updateTriggerText(){var s;const e=(s=this.shadowRoot)==null?void 0:s.querySelector(".select-value");if(!e)return;const t=this._options.find(a=>a.value===this._selectedValue),i=this.getAttribute("placeholder")||"Select an option...";t?(e.textContent=t.label,e.classList.remove("placeholder")):(e.textContent=i,e.classList.add("placeholder"))}highlightNext(){const e=this.findNextEnabled(this._highlightedIndex,1);e>=0&&(this._highlightedIndex=e,this.updateHighlight())}highlightPrevious(){const e=this.findNextEnabled(this._highlightedIndex,-1);e>=0&&(this._highlightedIndex=e,this.updateHighlight())}findNextEnabled(e,t){var r;const i=this._options.length;let s=e+t;s<0&&(s=i-1),s>=i&&(s=0);const a=s;for(;(r=this._options[s])!=null&&r.disabled;)if(s+=t,s<0&&(s=i-1),s>=i&&(s=0),s===a)return-1;return s}findFirstEnabled(){return this._options.findIndex(e=>!e.disabled)}findLastEnabled(){var e;for(let t=this._options.length-1;t>=0;t--)if(!((e=this._options[t])!=null&&e.disabled))return t;return-1}updateHighlight(){var e,t,i,s;if((e=this._listboxElement)==null||e.querySelectorAll('[role="option"]').forEach((a,r)=>{a.classList.toggle("highlighted",r===this._highlightedIndex)}),this._highlightedIndex>=0){const a=`${this._id}-option-${this._highlightedIndex}`;(t=this._triggerElement)==null||t.setAttribute("aria-activedescendant",a);const r=(i=this._listboxElement)==null?void 0:i.querySelector(`#${a}`);r==null||r.scrollIntoView({block:"nearest",behavior:"smooth"})}else(s=this._triggerElement)==null||s.removeAttribute("aria-activedescendant")}updateListboxVisibility(){!this._listboxElement||!this._triggerElement||(this._open?(this._listboxElement.hidden=!1,this._triggerElement.setAttribute("aria-expanded","true"),this.updateListboxPosition(),this.emit("a11y-select-open")):(this._listboxElement.hidden=!0,this._triggerElement.setAttribute("aria-expanded","false"),this._highlightedIndex=-1,this.updateHighlight(),this._listboxElement.style.top="",this._listboxElement.style.bottom="",this.removeAttribute("data-position"),this.emit("a11y-select-close")))}updateListboxPosition(){if(!this._listboxElement||!this._triggerElement)return;const e=this._triggerElement.getBoundingClientRect(),t=window.innerHeight,i=Math.min(this._listboxElement.scrollHeight,200),s=t-e.bottom,a=e.top;s<i+8&&a>s?(this._listboxElement.style.top="auto",this._listboxElement.style.bottom="100%",this._listboxElement.style.marginTop="0",this._listboxElement.style.marginBottom="4px",this.setAttribute("data-position","top")):(this._listboxElement.style.top="100%",this._listboxElement.style.bottom="auto",this._listboxElement.style.marginTop="4px",this._listboxElement.style.marginBottom="0",this.setAttribute("data-position","bottom"))}show(){this.open=!0}close(){this.open=!1}}b("a11y-select",B);class P extends u{constructor(){super(...arguments),this._value="",this._inputEl=null,this._labelEl=null,this._hintEl=null,this._errorEl=null,this.handleInput=e=>{const t=e.target;this._value=t.value,this.emit("input",{value:this._value})},this.handleChange=e=>{const t=e.target;this._value=t.value,this.emit("change",{value:this._value})},this.handleFocus=()=>{this.emit("a11y-input-focus")},this.handleBlur=()=>{this.emit("a11y-input-blur")}}static get observedAttributes(){return["label","hint","error","type","placeholder","value","disabled","readonly","required","name","autocomplete","maxlength","minlength","pattern","inputmode","aria-label","aria-labelledby"]}get value(){return this._value}set value(e){const t=this._value;this._value=e,this._inputEl&&this._inputEl.value!==e&&(this._inputEl.value=e),e!==t&&this.setAttribute("value",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e)}get readOnly(){return this.hasAttribute("readonly")}set readOnly(e){this.toggleAttribute("readonly",e)}get required(){return this.hasAttribute("required")}set required(e){this.toggleAttribute("required",e)}get error(){return this.getAttribute("error")||""}set error(e){e?this.setAttribute("error",e):this.removeAttribute("error")}setupAccessibility(){var e;typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&(this.hasAttribute("label")||this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||console.warn(`[compa11y/Input] Input has no accessible label. Add label="...", aria-label="...", or aria-labelledby="..." attribute.
1572
+ 💡 Suggestion: <a11y-input label="Full Name"></a11y-input>`))}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-field`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=this.getAttribute("label")||"",h=this.getAttribute("hint")||"",n=this.getAttribute("error")||"",m=this.getAttribute("type")||"text",c=this.getAttribute("placeholder")||"",g=this.getAttribute("name")||"",v=this.getAttribute("autocomplete")||"",f=this.getAttribute("maxlength"),_=this.getAttribute("minlength"),w=this.getAttribute("pattern"),$=this.getAttribute("inputmode"),C=this.getAttribute("aria-label")||"",T=this.getAttribute("aria-labelledby")||"",z=this.disabled,x=this.readOnly,y=this.required,A=!!n,E=[];h&&E.push(s),A&&E.push(a);const X=E.length?`aria-describedby="${E.join(" ")}"`:"",L=!r&&C?`aria-label="${C}"`:"",ye=!r&&T?`aria-labelledby="${T}"`:r?`aria-labelledby="${i}"`:"";this.setAttribute("data-error",A?"true":"false"),e.innerHTML=`
1573
+ <style>${re}</style>
1464
1574
  <div class="input-wrapper" part="wrapper">
1465
1575
  ${r?`<label id="${i}" for="${t}" class="input-label" part="label">
1466
- ${r}${_?'<span class="input-required" aria-hidden="true" part="required">*</span>':""}
1576
+ ${r}${y?'<span class="input-required" aria-hidden="true" part="required">*</span>':""}
1467
1577
  </label>`:""}
1468
1578
  <input
1469
1579
  id="${t}"
1470
- type="${g}"
1580
+ type="${m}"
1471
1581
  value="${this._value}"
1472
1582
  ${c?`placeholder="${c}"`:""}
1473
- ${m?`name="${m}"`:""}
1474
- ${f?`autocomplete="${f}"`:""}
1475
- ${v?`maxlength="${v}"`:""}
1476
- ${y?`minlength="${y}"`:""}
1477
- ${k?`pattern="${k}"`:""}
1478
- ${w?`inputmode="${w}"`:""}
1479
- ${$}
1480
- ${pe}
1481
- ${Y}
1583
+ ${g?`name="${g}"`:""}
1584
+ ${v?`autocomplete="${v}"`:""}
1585
+ ${f?`maxlength="${f}"`:""}
1586
+ ${_?`minlength="${_}"`:""}
1587
+ ${w?`pattern="${w}"`:""}
1588
+ ${$?`inputmode="${$}"`:""}
1589
+ ${L}
1590
+ ${ye}
1591
+ ${X}
1482
1592
  ${A?'aria-invalid="true"':""}
1483
- ${_?'aria-required="true"':""}
1484
- ${C?"disabled":""}
1593
+ ${y?'aria-required="true"':""}
1594
+ ${z?"disabled":""}
1485
1595
  ${x?"readonly":""}
1486
1596
  part="field"
1487
1597
  />
1488
1598
  ${h?`<div id="${s}" class="input-hint" part="hint">${h}</div>`:""}
1489
1599
  ${A?`<div id="${a}" class="input-error" role="alert" part="error">${n}</div>`:""}
1490
1600
  </div>
1491
- `,this._inputEl=e.querySelector("input"),this._labelEl=e.querySelector("label"),this._hintEl=e.querySelector(".input-hint"),this._errorEl=e.querySelector(".input-error");const G=this.getAttribute("value");G&&this._inputEl&&(this._value=G,this._inputEl.value=G)}setupEventListeners(){var e,t,i,s;(e=this._inputEl)==null||e.addEventListener("input",this.handleInput),(t=this._inputEl)==null||t.addEventListener("change",this.handleChange),(i=this._inputEl)==null||i.addEventListener("focus",this.handleFocus),(s=this._inputEl)==null||s.addEventListener("blur",this.handleBlur)}cleanupEventListeners(){var e,t,i,s;(e=this._inputEl)==null||e.removeEventListener("input",this.handleInput),(t=this._inputEl)==null||t.removeEventListener("change",this.handleChange),(i=this._inputEl)==null||i.removeEventListener("focus",this.handleFocus),(s=this._inputEl)==null||s.removeEventListener("blur",this.handleBlur)}onAttributeChange(e,t,i){switch(e){case"value":this._value=i||"",this._inputEl&&this._inputEl.value!==this._value&&(this._inputEl.value=this._value);break;case"error":this.updateError(i||"");break;case"hint":this.updateHint(i||"");break;case"disabled":this._inputEl&&(i!==null?this._inputEl.setAttribute("disabled",""):this._inputEl.removeAttribute("disabled"));break;case"readonly":this._inputEl&&(i!==null?this._inputEl.setAttribute("readonly",""):this._inputEl.removeAttribute("readonly"));break;case"required":this._inputEl&&(i!==null?this._inputEl.setAttribute("aria-required","true"):this._inputEl.removeAttribute("aria-required")),this.updateRequiredIndicator(i!==null);break;case"placeholder":this._inputEl&&(i?this._inputEl.setAttribute("placeholder",i):this._inputEl.removeAttribute("placeholder"));break;case"type":this._inputEl&&(this._inputEl.type=i||"text");break;case"name":this._inputEl&&(i?this._inputEl.setAttribute("name",i):this._inputEl.removeAttribute("name"));break;case"autocomplete":this._inputEl&&(i?this._inputEl.setAttribute("autocomplete",i):this._inputEl.removeAttribute("autocomplete"));break;case"maxlength":this._inputEl&&(i?this._inputEl.setAttribute("maxlength",i):this._inputEl.removeAttribute("maxlength"));break;case"minlength":this._inputEl&&(i?this._inputEl.setAttribute("minlength",i):this._inputEl.removeAttribute("minlength"));break;case"pattern":this._inputEl&&(i?this._inputEl.setAttribute("pattern",i):this._inputEl.removeAttribute("pattern"));break;case"inputmode":this._inputEl&&(i?this._inputEl.setAttribute("inputmode",i):this._inputEl.removeAttribute("inputmode"));break;case"label":case"aria-label":case"aria-labelledby":this.shadowRoot&&(this.cleanupEventListeners(),this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break}}updateError(e){var i;const t=!!e;if(this.setAttribute("data-error",t?"true":"false"),this._inputEl&&(t?this._inputEl.setAttribute("aria-invalid","true"):this._inputEl.removeAttribute("aria-invalid")),t){if(this._errorEl)this._errorEl.textContent=e;else{const s=`${this._id}-error`,a=document.createElement("div");a.id=s,a.className="input-error",a.setAttribute("role","alert"),a.setAttribute("part","error"),a.textContent=e;const r=(i=this.shadowRoot)==null?void 0:i.querySelector(".input-wrapper");r==null||r.appendChild(a),this._errorEl=a,o.announceAssertive(e)}this.updateAriaDescribedBy()}else this._errorEl&&(this._errorEl.remove(),this._errorEl=null),this.updateAriaDescribedBy()}updateHint(e){var t;if(e)if(this._hintEl)this._hintEl.textContent=e;else{const i=`${this._id}-hint`,s=document.createElement("div");s.id=i,s.className="input-hint",s.setAttribute("part","hint"),s.textContent=e;const a=(t=this.shadowRoot)==null?void 0:t.querySelector(".input-wrapper");this._errorEl?a==null||a.insertBefore(s,this._errorEl):a==null||a.appendChild(s),this._hintEl=s}else this._hintEl&&(this._hintEl.remove(),this._hintEl=null);this.updateAriaDescribedBy()}updateAriaDescribedBy(){if(!this._inputEl)return;const e=[];this._hintEl&&e.push(this._hintEl.id),this._errorEl&&e.push(this._errorEl.id),e.length>0?this._inputEl.setAttribute("aria-describedby",e.join(" ")):this._inputEl.removeAttribute("aria-describedby")}updateRequiredIndicator(e){if(!this._labelEl)return;const t=this._labelEl.querySelector(".input-required");if(e&&!t){const i=document.createElement("span");i.className="input-required",i.setAttribute("aria-hidden","true"),i.setAttribute("part","required"),i.textContent="*",this._labelEl.appendChild(i)}else!e&&t&&t.remove()}focus(){var e;(e=this._inputEl)==null||e.focus()}blur(){var e;(e=this._inputEl)==null||e.blur()}select(){var e;(e=this._inputEl)==null||e.select()}}b("a11y-input",B);class H extends u{constructor(){super(...arguments),this._value="",this._textareaEl=null,this._labelEl=null,this._hintEl=null,this._errorEl=null,this.handleInput=e=>{const t=e.target;this._value=t.value,this.emit("input",{value:this._value})},this.handleChange=e=>{const t=e.target;this._value=t.value,this.emit("change",{value:this._value})},this.handleFocus=()=>{this.emit("a11y-textarea-focus")},this.handleBlur=()=>{this.emit("a11y-textarea-blur")}}static get observedAttributes(){return["label","hint","error","rows","resize","placeholder","value","disabled","readonly","required","name","autocomplete","maxlength","minlength","aria-label","aria-labelledby"]}get value(){return this._value}set value(e){const t=this._value;this._value=e,this._textareaEl&&this._textareaEl.value!==e&&(this._textareaEl.value=e),e!==t&&this.setAttribute("value",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e)}get readOnly(){return this.hasAttribute("readonly")}set readOnly(e){this.toggleAttribute("readonly",e)}get required(){return this.hasAttribute("required")}set required(e){this.toggleAttribute("required",e)}get error(){return this.getAttribute("error")||""}set error(e){e?this.setAttribute("error",e):this.removeAttribute("error")}setupAccessibility(){var e;typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&(this.hasAttribute("label")||this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||console.warn(`[compa11y/Textarea] Textarea has no accessible label. Add label="...", aria-label="...", or aria-labelledby="..." attribute.
1492
- 💡 Suggestion: <a11y-textarea label="Description"></a11y-textarea>`))}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-field`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=this.getAttribute("label")||"",h=this.getAttribute("hint")||"",n=this.getAttribute("error")||"",g=this.getAttribute("rows")||"3",c=this.getAttribute("placeholder")||"",m=this.getAttribute("name")||"",f=this.getAttribute("autocomplete")||"",v=this.getAttribute("maxlength"),y=this.getAttribute("minlength"),k=this.getAttribute("aria-label")||"",w=this.getAttribute("aria-labelledby")||"",S=this.disabled,I=this.readOnly,C=this.required,x=!!n,_=[];h&&_.push(s),x&&_.push(a);const A=_.length?`aria-describedby="${_.join(" ")}"`:"",E=!r&&k?`aria-label="${k}"`:"",Y=!r&&w?`aria-labelledby="${w}"`:r?`aria-labelledby="${i}"`:"";this.setAttribute("data-error",x?"true":"false"),e.innerHTML=`
1493
- <style>${se}</style>
1601
+ `,this._inputEl=e.querySelector("input"),this._labelEl=e.querySelector("label"),this._hintEl=e.querySelector(".input-hint"),this._errorEl=e.querySelector(".input-error");const W=this.getAttribute("value");W&&this._inputEl&&(this._value=W,this._inputEl.value=W)}setupEventListeners(){var e,t,i,s;(e=this._inputEl)==null||e.addEventListener("input",this.handleInput),(t=this._inputEl)==null||t.addEventListener("change",this.handleChange),(i=this._inputEl)==null||i.addEventListener("focus",this.handleFocus),(s=this._inputEl)==null||s.addEventListener("blur",this.handleBlur)}cleanupEventListeners(){var e,t,i,s;(e=this._inputEl)==null||e.removeEventListener("input",this.handleInput),(t=this._inputEl)==null||t.removeEventListener("change",this.handleChange),(i=this._inputEl)==null||i.removeEventListener("focus",this.handleFocus),(s=this._inputEl)==null||s.removeEventListener("blur",this.handleBlur)}onAttributeChange(e,t,i){switch(e){case"value":this._value=i||"",this._inputEl&&this._inputEl.value!==this._value&&(this._inputEl.value=this._value);break;case"error":this.updateError(i||"");break;case"hint":this.updateHint(i||"");break;case"disabled":this._inputEl&&(i!==null?this._inputEl.setAttribute("disabled",""):this._inputEl.removeAttribute("disabled"));break;case"readonly":this._inputEl&&(i!==null?this._inputEl.setAttribute("readonly",""):this._inputEl.removeAttribute("readonly"));break;case"required":this._inputEl&&(i!==null?this._inputEl.setAttribute("aria-required","true"):this._inputEl.removeAttribute("aria-required")),this.updateRequiredIndicator(i!==null);break;case"placeholder":this._inputEl&&(i?this._inputEl.setAttribute("placeholder",i):this._inputEl.removeAttribute("placeholder"));break;case"type":this._inputEl&&(this._inputEl.type=i||"text");break;case"name":this._inputEl&&(i?this._inputEl.setAttribute("name",i):this._inputEl.removeAttribute("name"));break;case"autocomplete":this._inputEl&&(i?this._inputEl.setAttribute("autocomplete",i):this._inputEl.removeAttribute("autocomplete"));break;case"maxlength":this._inputEl&&(i?this._inputEl.setAttribute("maxlength",i):this._inputEl.removeAttribute("maxlength"));break;case"minlength":this._inputEl&&(i?this._inputEl.setAttribute("minlength",i):this._inputEl.removeAttribute("minlength"));break;case"pattern":this._inputEl&&(i?this._inputEl.setAttribute("pattern",i):this._inputEl.removeAttribute("pattern"));break;case"inputmode":this._inputEl&&(i?this._inputEl.setAttribute("inputmode",i):this._inputEl.removeAttribute("inputmode"));break;case"label":case"aria-label":case"aria-labelledby":this.shadowRoot&&(this.cleanupEventListeners(),this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break}}updateError(e){var i;const t=!!e;if(this.setAttribute("data-error",t?"true":"false"),this._inputEl&&(t?this._inputEl.setAttribute("aria-invalid","true"):this._inputEl.removeAttribute("aria-invalid")),t){if(this._errorEl)this._errorEl.textContent=e;else{const s=`${this._id}-error`,a=document.createElement("div");a.id=s,a.className="input-error",a.setAttribute("role","alert"),a.setAttribute("part","error"),a.textContent=e;const r=(i=this.shadowRoot)==null?void 0:i.querySelector(".input-wrapper");r==null||r.appendChild(a),this._errorEl=a,o.announceAssertive(e)}this.updateAriaDescribedBy()}else this._errorEl&&(this._errorEl.remove(),this._errorEl=null),this.updateAriaDescribedBy()}updateHint(e){var t;if(e)if(this._hintEl)this._hintEl.textContent=e;else{const i=`${this._id}-hint`,s=document.createElement("div");s.id=i,s.className="input-hint",s.setAttribute("part","hint"),s.textContent=e;const a=(t=this.shadowRoot)==null?void 0:t.querySelector(".input-wrapper");this._errorEl?a==null||a.insertBefore(s,this._errorEl):a==null||a.appendChild(s),this._hintEl=s}else this._hintEl&&(this._hintEl.remove(),this._hintEl=null);this.updateAriaDescribedBy()}updateAriaDescribedBy(){if(!this._inputEl)return;const e=[];this._hintEl&&e.push(this._hintEl.id),this._errorEl&&e.push(this._errorEl.id),e.length>0?this._inputEl.setAttribute("aria-describedby",e.join(" ")):this._inputEl.removeAttribute("aria-describedby")}updateRequiredIndicator(e){if(!this._labelEl)return;const t=this._labelEl.querySelector(".input-required");if(e&&!t){const i=document.createElement("span");i.className="input-required",i.setAttribute("aria-hidden","true"),i.setAttribute("part","required"),i.textContent="*",this._labelEl.appendChild(i)}else!e&&t&&t.remove()}focus(){var e;(e=this._inputEl)==null||e.focus()}blur(){var e;(e=this._inputEl)==null||e.blur()}select(){var e;(e=this._inputEl)==null||e.select()}}b("a11y-input",P);class M extends u{constructor(){super(...arguments),this._value="",this._textareaEl=null,this._labelEl=null,this._hintEl=null,this._errorEl=null,this.handleInput=e=>{const t=e.target;this._value=t.value,this.emit("input",{value:this._value})},this.handleChange=e=>{const t=e.target;this._value=t.value,this.emit("change",{value:this._value})},this.handleFocus=()=>{this.emit("a11y-textarea-focus")},this.handleBlur=()=>{this.emit("a11y-textarea-blur")}}static get observedAttributes(){return["label","hint","error","rows","resize","placeholder","value","disabled","readonly","required","name","autocomplete","maxlength","minlength","aria-label","aria-labelledby"]}get value(){return this._value}set value(e){const t=this._value;this._value=e,this._textareaEl&&this._textareaEl.value!==e&&(this._textareaEl.value=e),e!==t&&this.setAttribute("value",e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e)}get readOnly(){return this.hasAttribute("readonly")}set readOnly(e){this.toggleAttribute("readonly",e)}get required(){return this.hasAttribute("required")}set required(e){this.toggleAttribute("required",e)}get error(){return this.getAttribute("error")||""}set error(e){e?this.setAttribute("error",e):this.removeAttribute("error")}setupAccessibility(){var e;typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&(this.hasAttribute("label")||this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||console.warn(`[compa11y/Textarea] Textarea has no accessible label. Add label="...", aria-label="...", or aria-labelledby="..." attribute.
1602
+ 💡 Suggestion: <a11y-textarea label="Description"></a11y-textarea>`))}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-field`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=this.getAttribute("label")||"",h=this.getAttribute("hint")||"",n=this.getAttribute("error")||"",m=this.getAttribute("rows")||"3",c=this.getAttribute("placeholder")||"",g=this.getAttribute("name")||"",v=this.getAttribute("autocomplete")||"",f=this.getAttribute("maxlength"),_=this.getAttribute("minlength"),w=this.getAttribute("aria-label")||"",$=this.getAttribute("aria-labelledby")||"",C=this.disabled,T=this.readOnly,z=this.required,x=!!n,y=[];h&&y.push(s),x&&y.push(a);const A=y.length?`aria-describedby="${y.join(" ")}"`:"",E=!r&&w?`aria-label="${w}"`:"",X=!r&&$?`aria-labelledby="${$}"`:r?`aria-labelledby="${i}"`:"";this.setAttribute("data-error",x?"true":"false"),e.innerHTML=`
1603
+ <style>${oe}</style>
1494
1604
  <div class="textarea-wrapper" part="wrapper">
1495
1605
  ${r?`<label id="${i}" for="${t}" class="textarea-label" part="label">
1496
- ${r}${C?'<span class="textarea-required" aria-hidden="true" part="required">*</span>':""}
1606
+ ${r}${z?'<span class="textarea-required" aria-hidden="true" part="required">*</span>':""}
1497
1607
  </label>`:""}
1498
1608
  <textarea
1499
1609
  id="${t}"
1500
- rows="${g}"
1610
+ rows="${m}"
1501
1611
  ${c?`placeholder="${c}"`:""}
1502
- ${m?`name="${m}"`:""}
1503
- ${f?`autocomplete="${f}"`:""}
1504
- ${v?`maxlength="${v}"`:""}
1505
- ${y?`minlength="${y}"`:""}
1612
+ ${g?`name="${g}"`:""}
1613
+ ${v?`autocomplete="${v}"`:""}
1614
+ ${f?`maxlength="${f}"`:""}
1615
+ ${_?`minlength="${_}"`:""}
1506
1616
  ${E}
1507
- ${Y}
1617
+ ${X}
1508
1618
  ${A}
1509
1619
  ${x?'aria-invalid="true"':""}
1510
- ${C?'aria-required="true"':""}
1511
- ${S?"disabled":""}
1512
- ${I?"readonly":""}
1620
+ ${z?'aria-required="true"':""}
1621
+ ${C?"disabled":""}
1622
+ ${T?"readonly":""}
1513
1623
  part="field"
1514
1624
  >${this._value}</textarea>
1515
1625
  ${h?`<div id="${s}" class="textarea-hint" part="hint">${h}</div>`:""}
1516
1626
  ${x?`<div id="${a}" class="textarea-error" role="alert" part="error">${n}</div>`:""}
1517
1627
  </div>
1518
- `,this._textareaEl=e.querySelector("textarea"),this._labelEl=e.querySelector("label"),this._hintEl=e.querySelector(".textarea-hint"),this._errorEl=e.querySelector(".textarea-error");const $=this.getAttribute("value");$&&this._textareaEl&&(this._value=$,this._textareaEl.value=$)}setupEventListeners(){var e,t,i,s;(e=this._textareaEl)==null||e.addEventListener("input",this.handleInput),(t=this._textareaEl)==null||t.addEventListener("change",this.handleChange),(i=this._textareaEl)==null||i.addEventListener("focus",this.handleFocus),(s=this._textareaEl)==null||s.addEventListener("blur",this.handleBlur)}cleanupEventListeners(){var e,t,i,s;(e=this._textareaEl)==null||e.removeEventListener("input",this.handleInput),(t=this._textareaEl)==null||t.removeEventListener("change",this.handleChange),(i=this._textareaEl)==null||i.removeEventListener("focus",this.handleFocus),(s=this._textareaEl)==null||s.removeEventListener("blur",this.handleBlur)}onAttributeChange(e,t,i){switch(e){case"value":this._value=i||"",this._textareaEl&&this._textareaEl.value!==this._value&&(this._textareaEl.value=this._value);break;case"error":this.updateError(i||"");break;case"hint":this.updateHint(i||"");break;case"disabled":this._textareaEl&&(i!==null?this._textareaEl.setAttribute("disabled",""):this._textareaEl.removeAttribute("disabled"));break;case"readonly":this._textareaEl&&(i!==null?this._textareaEl.setAttribute("readonly",""):this._textareaEl.removeAttribute("readonly"));break;case"required":this._textareaEl&&(i!==null?this._textareaEl.setAttribute("aria-required","true"):this._textareaEl.removeAttribute("aria-required")),this.updateRequiredIndicator(i!==null);break;case"placeholder":this._textareaEl&&(i?this._textareaEl.setAttribute("placeholder",i):this._textareaEl.removeAttribute("placeholder"));break;case"rows":this._textareaEl&&(this._textareaEl.rows=parseInt(i||"3",10));break;case"name":this._textareaEl&&(i?this._textareaEl.setAttribute("name",i):this._textareaEl.removeAttribute("name"));break;case"autocomplete":this._textareaEl&&(i?this._textareaEl.setAttribute("autocomplete",i):this._textareaEl.removeAttribute("autocomplete"));break;case"maxlength":this._textareaEl&&(i?this._textareaEl.setAttribute("maxlength",i):this._textareaEl.removeAttribute("maxlength"));break;case"minlength":this._textareaEl&&(i?this._textareaEl.setAttribute("minlength",i):this._textareaEl.removeAttribute("minlength"));break;case"resize":this._textareaEl&&(this._textareaEl.style.resize=i||"vertical");break;case"label":case"aria-label":case"aria-labelledby":this.shadowRoot&&(this.cleanupEventListeners(),this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break}}updateError(e){var i;const t=!!e;if(this.setAttribute("data-error",t?"true":"false"),this._textareaEl&&(t?this._textareaEl.setAttribute("aria-invalid","true"):this._textareaEl.removeAttribute("aria-invalid")),t){if(this._errorEl)this._errorEl.textContent=e;else{const s=`${this._id}-error`,a=document.createElement("div");a.id=s,a.className="textarea-error",a.setAttribute("role","alert"),a.setAttribute("part","error"),a.textContent=e;const r=(i=this.shadowRoot)==null?void 0:i.querySelector(".textarea-wrapper");r==null||r.appendChild(a),this._errorEl=a,o.announceAssertive(e)}this.updateAriaDescribedBy()}else this._errorEl&&(this._errorEl.remove(),this._errorEl=null),this.updateAriaDescribedBy()}updateHint(e){var t;if(e)if(this._hintEl)this._hintEl.textContent=e;else{const i=`${this._id}-hint`,s=document.createElement("div");s.id=i,s.className="textarea-hint",s.setAttribute("part","hint"),s.textContent=e;const a=(t=this.shadowRoot)==null?void 0:t.querySelector(".textarea-wrapper");this._errorEl?a==null||a.insertBefore(s,this._errorEl):a==null||a.appendChild(s),this._hintEl=s}else this._hintEl&&(this._hintEl.remove(),this._hintEl=null);this.updateAriaDescribedBy()}updateAriaDescribedBy(){if(!this._textareaEl)return;const e=[];this._hintEl&&e.push(this._hintEl.id),this._errorEl&&e.push(this._errorEl.id),e.length>0?this._textareaEl.setAttribute("aria-describedby",e.join(" ")):this._textareaEl.removeAttribute("aria-describedby")}updateRequiredIndicator(e){if(!this._labelEl)return;const t=this._labelEl.querySelector(".textarea-required");if(e&&!t){const i=document.createElement("span");i.className="textarea-required",i.setAttribute("aria-hidden","true"),i.setAttribute("part","required"),i.textContent="*",this._labelEl.appendChild(i)}else!e&&t&&t.remove()}focus(){var e;(e=this._textareaEl)==null||e.focus()}blur(){var e;(e=this._textareaEl)==null||e.blur()}select(){var e;(e=this._textareaEl)==null||e.select()}}b("a11y-textarea",H);class P extends u{constructor(){super(...arguments),this._buttonEl=null,this.handleClick=e=>{if(this.disabled||this.loading){e.preventDefault(),e.stopPropagation();return}this.emit("a11y-button-click")}}static get observedAttributes(){return["variant","size","disabled","discoverable","loading","type","aria-label"]}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e)}get discoverable(){return this.hasAttribute("discoverable")}set discoverable(e){this.toggleAttribute("discoverable",e)}get loading(){return this.hasAttribute("loading")}set loading(e){this.toggleAttribute("loading",e)}get variant(){return this.getAttribute("variant")||"secondary"}set variant(e){this.setAttribute("variant",e)}get size(){return this.getAttribute("size")||"md"}set size(e){this.setAttribute("size",e)}setupAccessibility(){var e,t;typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&((t=this.textContent)!=null&&t.trim()||this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||console.warn(`[compa11y/Button] Button has no accessible label. Add text content, aria-label="...", or aria-labelledby="..." attribute.
1519
- 💡 Suggestion: <a11y-button>Click me</a11y-button>`))}render(){const e=this.attachShadow({mode:"open"}),t=this.variant,i=this.size,s=this.getAttribute("type")||"button",a=this.getAttribute("aria-label")||"",r=this.disabled,h=this.discoverable,n=this.loading,g=r||n,c=r&&!h;e.innerHTML=`
1520
- <style>${ae}</style>
1628
+ `,this._textareaEl=e.querySelector("textarea"),this._labelEl=e.querySelector("label"),this._hintEl=e.querySelector(".textarea-hint"),this._errorEl=e.querySelector(".textarea-error");const L=this.getAttribute("value");L&&this._textareaEl&&(this._value=L,this._textareaEl.value=L)}setupEventListeners(){var e,t,i,s;(e=this._textareaEl)==null||e.addEventListener("input",this.handleInput),(t=this._textareaEl)==null||t.addEventListener("change",this.handleChange),(i=this._textareaEl)==null||i.addEventListener("focus",this.handleFocus),(s=this._textareaEl)==null||s.addEventListener("blur",this.handleBlur)}cleanupEventListeners(){var e,t,i,s;(e=this._textareaEl)==null||e.removeEventListener("input",this.handleInput),(t=this._textareaEl)==null||t.removeEventListener("change",this.handleChange),(i=this._textareaEl)==null||i.removeEventListener("focus",this.handleFocus),(s=this._textareaEl)==null||s.removeEventListener("blur",this.handleBlur)}onAttributeChange(e,t,i){switch(e){case"value":this._value=i||"",this._textareaEl&&this._textareaEl.value!==this._value&&(this._textareaEl.value=this._value);break;case"error":this.updateError(i||"");break;case"hint":this.updateHint(i||"");break;case"disabled":this._textareaEl&&(i!==null?this._textareaEl.setAttribute("disabled",""):this._textareaEl.removeAttribute("disabled"));break;case"readonly":this._textareaEl&&(i!==null?this._textareaEl.setAttribute("readonly",""):this._textareaEl.removeAttribute("readonly"));break;case"required":this._textareaEl&&(i!==null?this._textareaEl.setAttribute("aria-required","true"):this._textareaEl.removeAttribute("aria-required")),this.updateRequiredIndicator(i!==null);break;case"placeholder":this._textareaEl&&(i?this._textareaEl.setAttribute("placeholder",i):this._textareaEl.removeAttribute("placeholder"));break;case"rows":this._textareaEl&&(this._textareaEl.rows=parseInt(i||"3",10));break;case"name":this._textareaEl&&(i?this._textareaEl.setAttribute("name",i):this._textareaEl.removeAttribute("name"));break;case"autocomplete":this._textareaEl&&(i?this._textareaEl.setAttribute("autocomplete",i):this._textareaEl.removeAttribute("autocomplete"));break;case"maxlength":this._textareaEl&&(i?this._textareaEl.setAttribute("maxlength",i):this._textareaEl.removeAttribute("maxlength"));break;case"minlength":this._textareaEl&&(i?this._textareaEl.setAttribute("minlength",i):this._textareaEl.removeAttribute("minlength"));break;case"resize":this._textareaEl&&(this._textareaEl.style.resize=i||"vertical");break;case"label":case"aria-label":case"aria-labelledby":this.shadowRoot&&(this.cleanupEventListeners(),this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break}}updateError(e){var i;const t=!!e;if(this.setAttribute("data-error",t?"true":"false"),this._textareaEl&&(t?this._textareaEl.setAttribute("aria-invalid","true"):this._textareaEl.removeAttribute("aria-invalid")),t){if(this._errorEl)this._errorEl.textContent=e;else{const s=`${this._id}-error`,a=document.createElement("div");a.id=s,a.className="textarea-error",a.setAttribute("role","alert"),a.setAttribute("part","error"),a.textContent=e;const r=(i=this.shadowRoot)==null?void 0:i.querySelector(".textarea-wrapper");r==null||r.appendChild(a),this._errorEl=a,o.announceAssertive(e)}this.updateAriaDescribedBy()}else this._errorEl&&(this._errorEl.remove(),this._errorEl=null),this.updateAriaDescribedBy()}updateHint(e){var t;if(e)if(this._hintEl)this._hintEl.textContent=e;else{const i=`${this._id}-hint`,s=document.createElement("div");s.id=i,s.className="textarea-hint",s.setAttribute("part","hint"),s.textContent=e;const a=(t=this.shadowRoot)==null?void 0:t.querySelector(".textarea-wrapper");this._errorEl?a==null||a.insertBefore(s,this._errorEl):a==null||a.appendChild(s),this._hintEl=s}else this._hintEl&&(this._hintEl.remove(),this._hintEl=null);this.updateAriaDescribedBy()}updateAriaDescribedBy(){if(!this._textareaEl)return;const e=[];this._hintEl&&e.push(this._hintEl.id),this._errorEl&&e.push(this._errorEl.id),e.length>0?this._textareaEl.setAttribute("aria-describedby",e.join(" ")):this._textareaEl.removeAttribute("aria-describedby")}updateRequiredIndicator(e){if(!this._labelEl)return;const t=this._labelEl.querySelector(".textarea-required");if(e&&!t){const i=document.createElement("span");i.className="textarea-required",i.setAttribute("aria-hidden","true"),i.setAttribute("part","required"),i.textContent="*",this._labelEl.appendChild(i)}else!e&&t&&t.remove()}focus(){var e;(e=this._textareaEl)==null||e.focus()}blur(){var e;(e=this._textareaEl)==null||e.blur()}select(){var e;(e=this._textareaEl)==null||e.select()}}b("a11y-textarea",M);class F extends u{constructor(){super(...arguments),this._buttonEl=null,this.handleClick=e=>{if(this.disabled||this.loading){e.preventDefault(),e.stopPropagation();return}this.emit("a11y-button-click")}}static get observedAttributes(){return["variant","size","disabled","discoverable","loading","type","aria-label"]}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e)}get discoverable(){return this.hasAttribute("discoverable")}set discoverable(e){this.toggleAttribute("discoverable",e)}get loading(){return this.hasAttribute("loading")}set loading(e){this.toggleAttribute("loading",e)}get variant(){return this.getAttribute("variant")||"secondary"}set variant(e){this.setAttribute("variant",e)}get size(){return this.getAttribute("size")||"md"}set size(e){this.setAttribute("size",e)}setupAccessibility(){var e,t;typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&((t=this.textContent)!=null&&t.trim()||this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||console.warn(`[compa11y/Button] Button has no accessible label. Add text content, aria-label="...", or aria-labelledby="..." attribute.
1629
+ 💡 Suggestion: <a11y-button>Click me</a11y-button>`))}render(){const e=this.attachShadow({mode:"open"}),t=this.variant,i=this.size,s=this.getAttribute("type")||"button",a=this.getAttribute("aria-label")||"",r=this.disabled,h=this.discoverable,n=this.loading,m=r||n,c=r&&!h;e.innerHTML=`
1630
+ <style>${le}</style>
1521
1631
  <button
1522
1632
  class="variant-${t} size-${i}"
1523
1633
  type="${s}"
1524
1634
  ${c?"disabled":""}
1525
- ${g?'aria-disabled="true"':""}
1635
+ ${m?'aria-disabled="true"':""}
1526
1636
  ${n?'aria-busy="true"':""}
1527
1637
  ${a?`aria-label="${a}"`:""}
1528
1638
  part="button"
1529
1639
  >${n?'<span class="button-spinner" aria-hidden="true" part="spinner"></span>':""}<slot></slot></button>
1530
- `,this._buttonEl=e.querySelector("button")}setupEventListeners(){var e;(e=this._buttonEl)==null||e.addEventListener("click",this.handleClick)}cleanupEventListeners(){var e;(e=this._buttonEl)==null||e.removeEventListener("click",this.handleClick)}onAttributeChange(e,t,i){switch(e){case"variant":{if(!this._buttonEl)break;const a=this._buttonEl.className.split(" ").filter(r=>!r.startsWith("variant-"));a.push(`variant-${i||"secondary"}`),this._buttonEl.className=a.join(" ");break}case"size":{if(!this._buttonEl)break;const a=this._buttonEl.className.split(" ").filter(r=>!r.startsWith("size-"));a.push(`size-${i||"md"}`),this._buttonEl.className=a.join(" ");break}case"disabled":case"discoverable":this.updateDisabledState();break;case"loading":this.updateLoadingState();break;case"type":this._buttonEl&&(this._buttonEl.type=i||"button");break;case"aria-label":this._buttonEl&&(i?this._buttonEl.setAttribute("aria-label",i):this._buttonEl.removeAttribute("aria-label"));break}}updateDisabledState(){if(!this._buttonEl)return;const e=this.disabled,t=this.discoverable,i=this.loading,s=e&&!t,a=e||i;s?this._buttonEl.setAttribute("disabled",""):this._buttonEl.removeAttribute("disabled"),a?this._buttonEl.setAttribute("aria-disabled","true"):this._buttonEl.removeAttribute("aria-disabled")}updateLoadingState(){if(!this._buttonEl)return;if(this.loading){if(this._buttonEl.setAttribute("aria-busy","true"),this._buttonEl.setAttribute("aria-disabled","true"),!this._buttonEl.querySelector(".button-spinner")){const t=document.createElement("span");t.className="button-spinner",t.setAttribute("aria-hidden","true"),t.setAttribute("part","spinner"),this._buttonEl.insertBefore(t,this._buttonEl.firstChild)}}else{this._buttonEl.removeAttribute("aria-busy");const t=this._buttonEl.querySelector(".button-spinner");t==null||t.remove(),this.updateDisabledState()}}focus(){var e;(e=this._buttonEl)==null||e.focus()}blur(){var e;(e=this._buttonEl)==null||e.blur()}click(){var e;(e=this._buttonEl)==null||e.click()}}b("a11y-button",P);class M extends u{constructor(){super(...arguments),this._label="",this._disabled=!1}static get observedAttributes(){return["label","disabled"]}get label(){return this._label}set label(e){this._label=e,this.setAttribute("label",e),this.updateLabel()}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}setupAccessibility(){this.setAttribute("role","group"),this._label=this.getAttribute("label")||"",this._disabled=this.hasAttribute("disabled"),this._disabled&&this.setAttribute("aria-disabled","true")}render(){this.shadowRoot||this.attachShadow({mode:"open"});const e=`${this._id}-label`;this.shadowRoot.innerHTML=`
1531
- <style>${le}</style>
1640
+ `,this._buttonEl=e.querySelector("button")}setupEventListeners(){var e;(e=this._buttonEl)==null||e.addEventListener("click",this.handleClick)}cleanupEventListeners(){var e;(e=this._buttonEl)==null||e.removeEventListener("click",this.handleClick)}onAttributeChange(e,t,i){switch(e){case"variant":{if(!this._buttonEl)break;const a=this._buttonEl.className.split(" ").filter(r=>!r.startsWith("variant-"));a.push(`variant-${i||"secondary"}`),this._buttonEl.className=a.join(" ");break}case"size":{if(!this._buttonEl)break;const a=this._buttonEl.className.split(" ").filter(r=>!r.startsWith("size-"));a.push(`size-${i||"md"}`),this._buttonEl.className=a.join(" ");break}case"disabled":case"discoverable":this.updateDisabledState();break;case"loading":this.updateLoadingState();break;case"type":this._buttonEl&&(this._buttonEl.type=i||"button");break;case"aria-label":this._buttonEl&&(i?this._buttonEl.setAttribute("aria-label",i):this._buttonEl.removeAttribute("aria-label"));break}}updateDisabledState(){if(!this._buttonEl)return;const e=this.disabled,t=this.discoverable,i=this.loading,s=e&&!t,a=e||i;s?this._buttonEl.setAttribute("disabled",""):this._buttonEl.removeAttribute("disabled"),a?this._buttonEl.setAttribute("aria-disabled","true"):this._buttonEl.removeAttribute("aria-disabled")}updateLoadingState(){if(!this._buttonEl)return;if(this.loading){if(this._buttonEl.setAttribute("aria-busy","true"),this._buttonEl.setAttribute("aria-disabled","true"),!this._buttonEl.querySelector(".button-spinner")){const t=document.createElement("span");t.className="button-spinner",t.setAttribute("aria-hidden","true"),t.setAttribute("part","spinner"),this._buttonEl.insertBefore(t,this._buttonEl.firstChild)}}else{this._buttonEl.removeAttribute("aria-busy");const t=this._buttonEl.querySelector(".button-spinner");t==null||t.remove(),this.updateDisabledState()}}focus(){var e;(e=this._buttonEl)==null||e.focus()}blur(){var e;(e=this._buttonEl)==null||e.blur()}click(){var e;(e=this._buttonEl)==null||e.click()}}b("a11y-button",F);class K extends u{constructor(){super(...arguments),this._label="",this._disabled=!1}static get observedAttributes(){return["label","disabled"]}get label(){return this._label}set label(e){this._label=e,this.setAttribute("label",e),this.updateLabel()}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}setupAccessibility(){this.setAttribute("role","group"),this._label=this.getAttribute("label")||"",this._disabled=this.hasAttribute("disabled"),this._disabled&&this.setAttribute("aria-disabled","true")}render(){this.shadowRoot||this.attachShadow({mode:"open"});const e=`${this._id}-label`;this.shadowRoot.innerHTML=`
1641
+ <style>${de}</style>
1532
1642
  <div class="optgroup-wrapper" part="group">
1533
1643
  <div class="optgroup-label" part="label" id="${e}" role="presentation">
1534
1644
  ${this._label}
@@ -1537,24 +1647,24 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1537
1647
  <slot></slot>
1538
1648
  </div>
1539
1649
  </div>
1540
- `,this.setAttribute("aria-labelledby",e)}setupEventListeners(){}cleanupEventListeners(){}updateLabel(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".optgroup-label");e&&(e.textContent=this._label)}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"label":this._label=i||"",this.updateLabel();break;case"disabled":this._disabled=i!==null,this._disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");break}}}class F extends u{constructor(){super(...arguments),this._value="",this._disabled=!1,this._selected=!1,this._discoverable=!0,this.handleClick=e=>{if(this.effectivelyDisabled){e.preventDefault();return}this.dispatchEvent(new CustomEvent("option-select",{detail:{value:this._value},bubbles:!0,composed:!0}))}}static get observedAttributes(){return["value","disabled","discoverable"]}get value(){return this._value}set value(e){this._value=e,this.setAttribute("value",e)}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.setAttribute("aria-selected",String(t)))}get discoverable(){return this._discoverable}set discoverable(e){this._discoverable=!!e}get effectivelyDisabled(){if(this._disabled)return!0;const e=this.closest("a11y-optgroup");return(e==null?void 0:e.disabled)??!1}setupAccessibility(){this.setAttribute("role","option"),this.setAttribute("aria-selected","false"),this._value=this.getAttribute("value")||"",this._disabled=this.hasAttribute("disabled"),this._disabled&&this.setAttribute("aria-disabled","true");const e=this.getAttribute("discoverable");(e==="false"||e==="0")&&(this._discoverable=!1)}render(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
1541
- <style>${oe}</style>
1650
+ `,this.setAttribute("aria-labelledby",e)}setupEventListeners(){}cleanupEventListeners(){}updateLabel(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".optgroup-label");e&&(e.textContent=this._label)}onAttributeChange(e,t,i){switch(e){case"label":this._label=i||"",this.updateLabel();break;case"disabled":this._disabled=i!==null,this._disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");break}}}class N extends u{constructor(){super(...arguments),this._value="",this._disabled=!1,this._selected=!1,this._discoverable=!0,this.handleClick=e=>{if(this.effectivelyDisabled){e.preventDefault();return}this.dispatchEvent(new CustomEvent("option-select",{detail:{value:this._value},bubbles:!0,composed:!0}))}}static get observedAttributes(){return["value","disabled","discoverable"]}get value(){return this._value}set value(e){this._value=e,this.setAttribute("value",e)}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.setAttribute("aria-selected",String(t)))}get discoverable(){return this._discoverable}set discoverable(e){this._discoverable=!!e}get effectivelyDisabled(){if(this._disabled)return!0;const e=this.closest("a11y-optgroup");return(e==null?void 0:e.disabled)??!1}setupAccessibility(){this.setAttribute("role","option"),this.setAttribute("aria-selected","false"),this._value=this.getAttribute("value")||"",this._disabled=this.hasAttribute("disabled"),this._disabled&&this.setAttribute("aria-disabled","true");const e=this.getAttribute("discoverable");(e==="false"||e==="0")&&(this._discoverable=!1)}render(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
1651
+ <style>${he}</style>
1542
1652
  <div class="option-wrapper" part="option">
1543
1653
  <span class="option-content" part="content"><slot></slot></span>
1544
1654
  <span class="check-mark" part="check" aria-hidden="true">&#10003;</span>
1545
1655
  </div>
1546
- `}setupEventListeners(){this.addEventListener("click",this.handleClick)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick)}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"value":this._value=i||"";break;case"disabled":this._disabled=i!==null,this._disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");break;case"discoverable":i===null?this._discoverable=!0:i==="false"||i==="0"?this._discoverable=!1:this._discoverable=!0;break}}}class K extends u{constructor(){super(...arguments),this._value=null,this._values=new Set,this._multiple=!1,this._disabled=!1,this._discoverable=!0,this._orientation="vertical",this._focusedIndex=-1,this._typeAhead=null,this.handleFocus=()=>{if(this._focusedIndex>=0)return;const e=this.getAllOptions();if(!this._multiple&&this._value){const t=e.findIndex(i=>i.value===this._value);if(t>=0){this._focusedIndex=t,this.updateFocusHighlight();return}}else if(this._multiple&&this._values.size>0){const t=e.findIndex(i=>this._values.has(i.value));if(t>=0){this._focusedIndex=t,this.updateFocusHighlight();return}}this._focusedIndex=this.findFirstEnabled(),this.updateFocusHighlight()},this.handleOptionSelect=e=>{var r;if(this._disabled)return;const t=(r=e.detail)==null?void 0:r.value;if(t===void 0)return;const i=this.getAllOptions(),s=i.find(h=>h.value===t);if(!s)return;const a=i.indexOf(s);this._focusedIndex=a,this.updateFocusHighlight(),this.selectOption(s),this.focus()},this.handleKeyDown=e=>{var a,r,h;if(this._disabled&&!this._discoverable)return;const t=this.getAllOptions();if(t.length===0)return;let i=null,s=!1;if(this._multiple)switch(e.key){case"ArrowDown":e.shiftKey?(i=this.findNextEnabled(this._focusedIndex,1),i>=0&&this.toggleOptionSelection(t[i])):i=this.findNextEnabled(this._focusedIndex,1),s=!0;break;case"ArrowUp":e.shiftKey?(i=this.findNextEnabled(this._focusedIndex,-1),i>=0&&this.toggleOptionSelection(t[i])):i=this.findNextEnabled(this._focusedIndex,-1),s=!0;break;case" ":this._focusedIndex>=0&&t[this._focusedIndex]!=null&&this.toggleOptionSelection(t[this._focusedIndex]),s=!0;break;case"Home":e.ctrlKey&&e.shiftKey?(this.selectRange(this.findFirstEnabled(),this._focusedIndex),i=this.findFirstEnabled()):i=this.findFirstEnabled(),s=!0;break;case"End":e.ctrlKey&&e.shiftKey?(this.selectRange(this._focusedIndex,this.findLastEnabled()),i=this.findLastEnabled()):i=this.findLastEnabled(),s=!0;break;case"a":(e.ctrlKey||e.metaKey)&&(this.toggleSelectAll(),s=!0);break;default:if(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey){const n=(a=this._typeAhead)==null?void 0:a.type(e.key);if(n){const g=t.findIndex(c=>{var m;return(((m=c.textContent)==null?void 0:m.trim())||"")===n&&!c.effectivelyDisabled});g>=0&&(i=g,s=!0)}}break}else switch(e.key){case"ArrowDown":i=this.findNextEnabled(this._focusedIndex,1),s=!0;break;case"ArrowUp":i=this.findNextEnabled(this._focusedIndex,-1),s=!0;break;case"Home":i=this.findFirstEnabled(),s=!0;break;case"End":i=this.findLastEnabled(),s=!0;break;default:if(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey){const n=(r=this._typeAhead)==null?void 0:r.type(e.key);if(n){const g=t.findIndex(c=>{var m;return(((m=c.textContent)==null?void 0:m.trim())||"")===n&&!c.effectivelyDisabled});g>=0&&(i=g,s=!0)}}break}if(s&&(e.preventDefault(),e.stopPropagation()),i!==null&&i>=0){this._focusedIndex=i,this.updateFocusHighlight();const n=t[i];if(!this._multiple&&n)this.selectSingle(n);else if(n){const g=((h=n.textContent)==null?void 0:h.trim())||n.value,c=this._values.has(n.value);o.announcePolite(`${g}${c?", selected":""}`)}}}}static get observedAttributes(){return["value","multiple","disabled","discoverable","orientation","aria-label","aria-labelledby"]}get value(){return this._multiple?Array.from(this._values):this._value||""}set value(e){if(this._multiple){const t=Array.isArray(e)?e:String(e).split(",").filter(Boolean);this._values=new Set(t),this.setAttribute("value",t.join(","))}else{const t=Array.isArray(e)?e[0]||"":String(e);this._value=t,this.setAttribute("value",t)}this.syncOptionStates()}get multiple(){return this._multiple}set multiple(e){const t=!!e;this._multiple!==t&&(this._multiple=t,t?(this.setAttribute("multiple",""),this.setAttribute("aria-multiselectable","true")):(this.removeAttribute("multiple"),this.removeAttribute("aria-multiselectable")))}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get discoverable(){return this._discoverable}set discoverable(e){this._discoverable=!!e}get orientation(){return this._orientation}set orientation(e){this._orientation=e,this.setAttribute("orientation",e),this.setAttribute("aria-orientation",e)}setupAccessibility(){this.setAttribute("role","listbox"),this.setAttribute("aria-orientation",this._orientation),!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&process.env.NODE_ENV!=="production"&&console.warn("[Compa11y Listbox]: Listbox has no accessible label. Use aria-label or aria-labelledby."),this._multiple=this.hasAttribute("multiple"),this._multiple&&this.setAttribute("aria-multiselectable","true"),this._disabled=this.hasAttribute("disabled"),this._disabled&&this.setAttribute("aria-disabled","true");const t=this.getAttribute("orientation");(t==="horizontal"||t==="vertical")&&(this._orientation=t);const i=this.getAttribute("discoverable");(i==="false"||i==="0")&&(this._discoverable=!1);const s=this.getAttribute("value");s&&(this._multiple?this._values=new Set(s.split(",").filter(Boolean)):this._value=s),this._disabled&&!this._discoverable?this.setAttribute("tabindex","-1"):this.setAttribute("tabindex","0")}render(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
1547
- <style>${re}</style>
1656
+ `}setupEventListeners(){this.addEventListener("click",this.handleClick)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick)}onAttributeChange(e,t,i){switch(e){case"value":this._value=i||"";break;case"disabled":this._disabled=i!==null,this._disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");break;case"discoverable":i===null?this._discoverable=!0:i==="false"||i==="0"?this._discoverable=!1:this._discoverable=!0;break}}}class j extends u{constructor(){super(...arguments),this._value=null,this._values=new Set,this._multiple=!1,this._disabled=!1,this._discoverable=!0,this._orientation="vertical",this._focusedIndex=-1,this._typeAhead=null,this.handleFocus=()=>{if(this._focusedIndex>=0)return;const e=this.getAllOptions();if(!this._multiple&&this._value){const t=e.findIndex(i=>i.value===this._value);if(t>=0){this._focusedIndex=t,this.updateFocusHighlight();return}}else if(this._multiple&&this._values.size>0){const t=e.findIndex(i=>this._values.has(i.value));if(t>=0){this._focusedIndex=t,this.updateFocusHighlight();return}}this._focusedIndex=this.findFirstEnabled(),this.updateFocusHighlight()},this.handleOptionSelect=e=>{var r;if(this._disabled)return;const t=(r=e.detail)==null?void 0:r.value;if(t===void 0)return;const i=this.getAllOptions(),s=i.find(h=>h.value===t);if(!s)return;const a=i.indexOf(s);this._focusedIndex=a,this.updateFocusHighlight(),this.selectOption(s),this.focus()},this.handleKeyDown=e=>{var a,r,h;if(this._disabled&&!this._discoverable)return;const t=this.getAllOptions();if(t.length===0)return;let i=null,s=!1;if(this._multiple)switch(e.key){case"ArrowDown":e.shiftKey?(i=this.findNextEnabled(this._focusedIndex,1),i>=0&&this.toggleOptionSelection(t[i])):i=this.findNextEnabled(this._focusedIndex,1),s=!0;break;case"ArrowUp":e.shiftKey?(i=this.findNextEnabled(this._focusedIndex,-1),i>=0&&this.toggleOptionSelection(t[i])):i=this.findNextEnabled(this._focusedIndex,-1),s=!0;break;case" ":this._focusedIndex>=0&&t[this._focusedIndex]!=null&&this.toggleOptionSelection(t[this._focusedIndex]),s=!0;break;case"Home":e.ctrlKey&&e.shiftKey?(this.selectRange(this.findFirstEnabled(),this._focusedIndex),i=this.findFirstEnabled()):i=this.findFirstEnabled(),s=!0;break;case"End":e.ctrlKey&&e.shiftKey?(this.selectRange(this._focusedIndex,this.findLastEnabled()),i=this.findLastEnabled()):i=this.findLastEnabled(),s=!0;break;case"a":(e.ctrlKey||e.metaKey)&&(this.toggleSelectAll(),s=!0);break;default:if(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey){const n=(a=this._typeAhead)==null?void 0:a.type(e.key);if(n){const m=t.findIndex(c=>{var g;return(((g=c.textContent)==null?void 0:g.trim())||"")===n&&!c.effectivelyDisabled});m>=0&&(i=m,s=!0)}}break}else switch(e.key){case"ArrowDown":i=this.findNextEnabled(this._focusedIndex,1),s=!0;break;case"ArrowUp":i=this.findNextEnabled(this._focusedIndex,-1),s=!0;break;case"Home":i=this.findFirstEnabled(),s=!0;break;case"End":i=this.findLastEnabled(),s=!0;break;default:if(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey){const n=(r=this._typeAhead)==null?void 0:r.type(e.key);if(n){const m=t.findIndex(c=>{var g;return(((g=c.textContent)==null?void 0:g.trim())||"")===n&&!c.effectivelyDisabled});m>=0&&(i=m,s=!0)}}break}if(s&&(e.preventDefault(),e.stopPropagation()),i!==null&&i>=0){this._focusedIndex=i,this.updateFocusHighlight();const n=t[i];if(!this._multiple&&n)this.selectSingle(n);else if(n){const m=((h=n.textContent)==null?void 0:h.trim())||n.value,c=this._values.has(n.value);o.announcePolite(`${m}${c?", selected":""}`)}}}}static get observedAttributes(){return["value","multiple","disabled","discoverable","orientation","aria-label","aria-labelledby"]}get value(){return this._multiple?Array.from(this._values):this._value||""}set value(e){if(this._multiple){const t=Array.isArray(e)?e:String(e).split(",").filter(Boolean);this._values=new Set(t),this.setAttribute("value",t.join(","))}else{const t=Array.isArray(e)?e[0]||"":String(e);this._value=t,this.setAttribute("value",t)}this.syncOptionStates()}get multiple(){return this._multiple}set multiple(e){const t=!!e;this._multiple!==t&&(this._multiple=t,t?(this.setAttribute("multiple",""),this.setAttribute("aria-multiselectable","true")):(this.removeAttribute("multiple"),this.removeAttribute("aria-multiselectable")))}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get discoverable(){return this._discoverable}set discoverable(e){this._discoverable=!!e}get orientation(){return this._orientation}set orientation(e){this._orientation=e,this.setAttribute("orientation",e),this.setAttribute("aria-orientation",e)}setupAccessibility(){this.setAttribute("role","listbox"),this.setAttribute("aria-orientation",this._orientation),!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&process.env.NODE_ENV!=="production"&&console.warn("[Compa11y Listbox]: Listbox has no accessible label. Use aria-label or aria-labelledby."),this._multiple=this.hasAttribute("multiple"),this._multiple&&this.setAttribute("aria-multiselectable","true"),this._disabled=this.hasAttribute("disabled"),this._disabled&&this.setAttribute("aria-disabled","true");const t=this.getAttribute("orientation");(t==="horizontal"||t==="vertical")&&(this._orientation=t);const i=this.getAttribute("discoverable");(i==="false"||i==="0")&&(this._discoverable=!1);const s=this.getAttribute("value");s&&(this._multiple?this._values=new Set(s.split(",").filter(Boolean)):this._value=s),this._disabled&&!this._discoverable?this.setAttribute("tabindex","-1"):this.setAttribute("tabindex","0")}render(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
1657
+ <style>${ne}</style>
1548
1658
  <div class="listbox-wrapper" part="wrapper">
1549
1659
  <slot></slot>
1550
1660
  </div>
1551
- `}setupEventListeners(){var t;this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("focus",this.handleFocus),this.addEventListener("option-select",this.handleOptionSelect);const e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot");e&&e.addEventListener("slotchange",()=>{this.rebuildTypeAhead(),this.syncOptionStates()}),this.rebuildTypeAhead(),this.syncOptionStates()}cleanupEventListeners(){this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("focus",this.handleFocus),this.removeEventListener("option-select",this.handleOptionSelect)}getAllOptions(){return Array.from(this.querySelectorAll("a11y-option"))}getEnabledOptions(){return this.getAllOptions().filter(e=>!e.effectivelyDisabled)}getEnabledIndices(){const e=this.getAllOptions(),t=[];return e.forEach((i,s)=>{i.effectivelyDisabled||t.push(s)}),t}syncOptionStates(){this.getAllOptions().forEach(t=>{this._multiple?t.selected=this._values.has(t.value):t.selected=t.value===this._value})}updateFocusHighlight(){const e=this.getAllOptions();e.forEach((i,s)=>{s===this._focusedIndex?i.toggleAttribute("data-focused",!0):i.removeAttribute("data-focused")});const t=this._focusedIndex>=0?e[this._focusedIndex]:void 0;t?(this.setAttribute("aria-activedescendant",t.id),t.scrollIntoView({block:"nearest"})):this.removeAttribute("aria-activedescendant")}findNextEnabled(e,t){const i=this.getEnabledIndices();if(i.length===0)return-1;const s=i.indexOf(e);if(s===-1)return t===1?i[0]:i[i.length-1];const a=s+t;return a<0||a>=i.length?-1:i[a]}findFirstEnabled(){const e=this.getEnabledIndices();return e.length>0?e[0]:-1}findLastEnabled(){const e=this.getEnabledIndices();return e.length>0?e[e.length-1]:-1}selectOption(e){e.effectivelyDisabled||this._disabled||(this._multiple?this.toggleOptionSelection(e):this.selectSingle(e))}selectSingle(e){var i;const t=this._value;if(this._value=e.value,this.setAttribute("value",e.value),this.syncOptionStates(),t!==this._value){const s=((i=e.textContent)==null?void 0:i.trim())||e.value;this.emit("change",{value:this._value,label:s}),this.emit("a11y-listbox-change",{value:this._value,label:s}),o.announcePolite(`${s} selected`)}}toggleOptionSelection(e){var s;if(e.effectivelyDisabled||this._disabled)return;const t=((s=e.textContent)==null?void 0:s.trim())||e.value;this._values.has(e.value)?(this._values.delete(e.value),e.selected=!1,o.announcePolite(`${t} deselected`)):(this._values.add(e.value),e.selected=!0,o.announcePolite(`${t} selected`));const i=Array.from(this._values);this.setAttribute("value",i.join(",")),this.emit("change",{value:i}),this.emit("a11y-listbox-change",{value:i})}selectRange(e,t){const i=this.getAllOptions(),s=Math.min(e,t),a=Math.max(e,t);for(let h=s;h<=a;h++){const n=i[h];n&&!n.effectivelyDisabled&&(this._values.add(n.value),n.selected=!0)}const r=Array.from(this._values);this.setAttribute("value",r.join(",")),this.emit("change",{value:r}),this.emit("a11y-listbox-change",{value:r}),o.announcePolite(`${a-s+1} items selected`)}toggleSelectAll(){const e=this.getEnabledOptions();e.every(s=>this._values.has(s.value))?(this._values.clear(),this.getAllOptions().forEach(s=>s.selected=!1),o.announcePolite("All deselected")):(e.forEach(s=>{this._values.add(s.value),s.selected=!0}),o.announcePolite("All selected"));const i=Array.from(this._values);this.setAttribute("value",i.join(",")),this.emit("change",{value:i}),this.emit("a11y-listbox-change",{value:i})}rebuildTypeAhead(){const e=this.getAllOptions().map(t=>{var i;return((i=t.textContent)==null?void 0:i.trim())||""});this._typeAhead=o.createTypeAhead(e,{timeout:500})}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"value":this._multiple?this._values=new Set((i||"").split(",").filter(Boolean)):this._value=i||null,this.syncOptionStates();break;case"multiple":this._multiple=i!==null,this._multiple?(this.setAttribute("aria-multiselectable","true"),this._value&&(this._values=new Set([this._value]),this._value=null)):(this.removeAttribute("aria-multiselectable"),this._values.size>0&&(this._value=Array.from(this._values)[0]??null,this._values.clear())),this.syncOptionStates();break;case"disabled":this._disabled=i!==null,this._disabled?(this.setAttribute("aria-disabled","true"),this._discoverable||this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"));break;case"discoverable":i===null?this._discoverable=!0:i==="false"||i==="0"?this._discoverable=!1:this._discoverable=!0;break;case"orientation":(i==="horizontal"||i==="vertical")&&(this._orientation=i,this.setAttribute("aria-orientation",i));break}}}b("a11y-optgroup",M),b("a11y-option",F),b("a11y-listbox",K);const ue=`<svg class="checkbox-check" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
1661
+ `}setupEventListeners(){var t;this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("focus",this.handleFocus),this.addEventListener("option-select",this.handleOptionSelect);const e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot");e&&e.addEventListener("slotchange",()=>{this.rebuildTypeAhead(),this.syncOptionStates()}),this.rebuildTypeAhead(),this.syncOptionStates()}cleanupEventListeners(){this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("focus",this.handleFocus),this.removeEventListener("option-select",this.handleOptionSelect)}getAllOptions(){return Array.from(this.querySelectorAll("a11y-option"))}getEnabledOptions(){return this.getAllOptions().filter(e=>!e.effectivelyDisabled)}getEnabledIndices(){const e=this.getAllOptions(),t=[];return e.forEach((i,s)=>{i.effectivelyDisabled||t.push(s)}),t}syncOptionStates(){this.getAllOptions().forEach(t=>{this._multiple?t.selected=this._values.has(t.value):t.selected=t.value===this._value})}updateFocusHighlight(){const e=this.getAllOptions();e.forEach((i,s)=>{s===this._focusedIndex?i.toggleAttribute("data-focused",!0):i.removeAttribute("data-focused")});const t=this._focusedIndex>=0?e[this._focusedIndex]:void 0;t?(this.setAttribute("aria-activedescendant",t.id),t.scrollIntoView({block:"nearest"})):this.removeAttribute("aria-activedescendant")}findNextEnabled(e,t){const i=this.getEnabledIndices();if(i.length===0)return-1;const s=i.indexOf(e);if(s===-1)return t===1?i[0]:i[i.length-1];const a=s+t;return a<0||a>=i.length?-1:i[a]}findFirstEnabled(){const e=this.getEnabledIndices();return e.length>0?e[0]:-1}findLastEnabled(){const e=this.getEnabledIndices();return e.length>0?e[e.length-1]:-1}selectOption(e){e.effectivelyDisabled||this._disabled||(this._multiple?this.toggleOptionSelection(e):this.selectSingle(e))}selectSingle(e){var i;const t=this._value;if(this._value=e.value,this.setAttribute("value",e.value),this.syncOptionStates(),t!==this._value){const s=((i=e.textContent)==null?void 0:i.trim())||e.value;this.emit("change",{value:this._value,label:s}),this.emit("a11y-listbox-change",{value:this._value,label:s}),o.announcePolite(`${s} selected`)}}toggleOptionSelection(e){var s;if(e.effectivelyDisabled||this._disabled)return;const t=((s=e.textContent)==null?void 0:s.trim())||e.value;this._values.has(e.value)?(this._values.delete(e.value),e.selected=!1,o.announcePolite(`${t} deselected`)):(this._values.add(e.value),e.selected=!0,o.announcePolite(`${t} selected`));const i=Array.from(this._values);this.setAttribute("value",i.join(",")),this.emit("change",{value:i}),this.emit("a11y-listbox-change",{value:i})}selectRange(e,t){const i=this.getAllOptions(),s=Math.min(e,t),a=Math.max(e,t);for(let h=s;h<=a;h++){const n=i[h];n&&!n.effectivelyDisabled&&(this._values.add(n.value),n.selected=!0)}const r=Array.from(this._values);this.setAttribute("value",r.join(",")),this.emit("change",{value:r}),this.emit("a11y-listbox-change",{value:r}),o.announcePolite(`${a-s+1} items selected`)}toggleSelectAll(){const e=this.getEnabledOptions();e.every(s=>this._values.has(s.value))?(this._values.clear(),this.getAllOptions().forEach(s=>s.selected=!1),o.announcePolite("All deselected")):(e.forEach(s=>{this._values.add(s.value),s.selected=!0}),o.announcePolite("All selected"));const i=Array.from(this._values);this.setAttribute("value",i.join(",")),this.emit("change",{value:i}),this.emit("a11y-listbox-change",{value:i})}rebuildTypeAhead(){const e=this.getAllOptions().map(t=>{var i;return((i=t.textContent)==null?void 0:i.trim())||""});this._typeAhead=o.createTypeAhead(e,{timeout:500})}onAttributeChange(e,t,i){switch(e){case"value":this._multiple?this._values=new Set((i||"").split(",").filter(Boolean)):this._value=i||null,this.syncOptionStates();break;case"multiple":this._multiple=i!==null,this._multiple?(this.setAttribute("aria-multiselectable","true"),this._value&&(this._values=new Set([this._value]),this._value=null)):(this.removeAttribute("aria-multiselectable"),this._values.size>0&&(this._value=Array.from(this._values)[0]??null,this._values.clear())),this.syncOptionStates();break;case"disabled":this._disabled=i!==null,this._disabled?(this.setAttribute("aria-disabled","true"),this._discoverable||this.setAttribute("tabindex","-1")):(this.removeAttribute("aria-disabled"),this.setAttribute("tabindex","0"));break;case"discoverable":i===null?this._discoverable=!0:i==="false"||i==="0"?this._discoverable=!1:this._discoverable=!0;break;case"orientation":(i==="horizontal"||i==="vertical")&&(this._orientation=i,this.setAttribute("aria-orientation",i));break}}}b("a11y-optgroup",K),b("a11y-option",N),b("a11y-listbox",j);const fe=`<svg class="checkbox-check" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
1552
1662
  <path d="M2.5 6L5 8.5L9.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
1553
- </svg>`,be=`<svg class="checkbox-dash" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
1663
+ </svg>`,_e=`<svg class="checkbox-dash" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
1554
1664
  <path d="M3 6H9" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
1555
- </svg>`;class L extends u{constructor(){super(...arguments),this._checked=!1,this._indeterminate=!1,this._input=null,this.handleChange=()=>{if(!this._input)return;this._checked=this._input.checked,this.toggleAttribute("checked",this._checked),this._indeterminate&&(this._indeterminate=!1,this.removeAttribute("indeterminate"),this._input.indeterminate=!1),this.updateVisualState(),this.emit("change",{checked:this._checked,value:this.value});const e=this.label||this.getAttribute("aria-label")||"Checkbox";o.announcePolite(`${e} ${this._checked?"checked":"unchecked"}`)}}static get observedAttributes(){return["checked","indeterminate","disabled","label","hint","error","value","name","required","size","aria-label","aria-describedby"]}get checked(){return this._checked}set checked(e){const t=this._checked;this._checked=e,this.toggleAttribute("checked",e),e!==t&&(this.updateVisualState(),this.emit("change",{checked:e,value:this.value}))}get indeterminate(){return this._indeterminate}set indeterminate(e){const t=this._indeterminate;this._indeterminate=e,this.toggleAttribute("indeterminate",e),e!==t&&this.updateVisualState()}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e),this.updateDisabledState()}get value(){return this.getAttribute("value")||""}set value(e){e?this.setAttribute("value",e):this.removeAttribute("value")}get label(){return this.getAttribute("label")||""}set label(e){e?this.setAttribute("label",e):this.removeAttribute("label")}get hint(){return this.getAttribute("hint")||""}set hint(e){e?this.setAttribute("hint",e):this.removeAttribute("hint")}get error(){return this.getAttribute("error")||""}set error(e){e?this.setAttribute("error",e):this.removeAttribute("error")}get size(){const e=this.getAttribute("size");return e==="sm"||e==="lg"?e:"md"}set size(e){this.setAttribute("size",e)}get required(){return this.hasAttribute("required")}set required(e){this.toggleAttribute("required",e)}setupAccessibility(){var e;this._checked=this.hasAttribute("checked"),this._indeterminate=this.hasAttribute("indeterminate"),typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&!this.label&&!this.getAttribute("aria-label")&&console.warn(`[compa11y/Checkbox] Checkbox has no accessible label. Add label="..." or aria-label="..." attribute.
1556
- 💡 Suggestion: <a11y-checkbox label="Accept terms"></a11y-checkbox>`)}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-input`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=!!this.label,h=!!this.hint,n=!!this.error,g=this.getAttribute("aria-label"),c=this.getAttribute("name")||"",m=this.getAttribute("aria-describedby")||"",f=[];m&&f.push(m),h&&f.push(s),n&&f.push(a);const v=f.length?`aria-describedby="${f.join(" ")}"`:"",y=!r&&g?`aria-label="${g}"`:"";e.innerHTML=`
1557
- <style>${ne}</style>
1665
+ </svg>`;class I extends u{constructor(){super(...arguments),this._checked=!1,this._indeterminate=!1,this._input=null,this.handleChange=()=>{if(!this._input)return;this._checked=this._input.checked,this.toggleAttribute("checked",this._checked),this._indeterminate&&(this._indeterminate=!1,this.removeAttribute("indeterminate"),this._input.indeterminate=!1),this.updateVisualState(),this.emit("change",{checked:this._checked,value:this.value});const e=this.label||this.getAttribute("aria-label")||"Checkbox";o.announcePolite(`${e} ${this._checked?"checked":"unchecked"}`)}}static get observedAttributes(){return["checked","indeterminate","disabled","label","hint","error","value","name","required","size","aria-label","aria-describedby"]}get checked(){return this._checked}set checked(e){const t=this._checked;this._checked=e,this.toggleAttribute("checked",e),e!==t&&(this.updateVisualState(),this.emit("change",{checked:e,value:this.value}))}get indeterminate(){return this._indeterminate}set indeterminate(e){const t=this._indeterminate;this._indeterminate=e,this.toggleAttribute("indeterminate",e),e!==t&&this.updateVisualState()}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e),this.updateDisabledState()}get value(){return this.getAttribute("value")||""}set value(e){e?this.setAttribute("value",e):this.removeAttribute("value")}get label(){return this.getAttribute("label")||""}set label(e){e?this.setAttribute("label",e):this.removeAttribute("label")}get hint(){return this.getAttribute("hint")||""}set hint(e){e?this.setAttribute("hint",e):this.removeAttribute("hint")}get error(){return this.getAttribute("error")||""}set error(e){e?this.setAttribute("error",e):this.removeAttribute("error")}get size(){const e=this.getAttribute("size");return e==="sm"||e==="lg"?e:"md"}set size(e){this.setAttribute("size",e)}get required(){return this.hasAttribute("required")}set required(e){this.toggleAttribute("required",e)}setupAccessibility(){var e;this._checked=this.hasAttribute("checked"),this._indeterminate=this.hasAttribute("indeterminate"),typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&!this.label&&!this.getAttribute("aria-label")&&console.warn(`[compa11y/Checkbox] Checkbox has no accessible label. Add label="..." or aria-label="..." attribute.
1666
+ 💡 Suggestion: <a11y-checkbox label="Accept terms"></a11y-checkbox>`)}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-input`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=!!this.label,h=!!this.hint,n=!!this.error,m=this.getAttribute("aria-label"),c=this.getAttribute("name")||"",g=this.getAttribute("aria-describedby")||"",v=[];g&&v.push(g),h&&v.push(s),n&&v.push(a);const f=v.length?`aria-describedby="${v.join(" ")}"`:"",_=!r&&m?`aria-label="${m}"`:"";e.innerHTML=`
1667
+ <style>${ce}</style>
1558
1668
  <div class="checkbox-wrapper size-${this.size}" part="wrapper">
1559
1669
  <div class="checkbox-control">
1560
1670
  <input
@@ -1566,14 +1676,14 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1566
1676
  ${this._checked?"checked":""}
1567
1677
  ${this.disabled?"disabled":""}
1568
1678
  ${this.required?'required aria-required="true"':""}
1569
- ${v}
1570
- ${y}
1679
+ ${f}
1680
+ ${_}
1571
1681
  ${n?'aria-invalid="true"':""}
1572
1682
  part="input"
1573
1683
  />
1574
1684
  <div class="checkbox-indicator" part="indicator" aria-hidden="true">
1575
- ${ue}
1576
- ${be}
1685
+ ${fe}
1686
+ ${_e}
1577
1687
  </div>
1578
1688
  </div>
1579
1689
  ${r||h||n?`<div class="checkbox-content">
@@ -1582,9 +1692,9 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1582
1692
  ${n?`<div id="${a}" class="checkbox-error" role="alert" part="error">${this.error}</div>`:""}
1583
1693
  </div>`:""}
1584
1694
  </div>
1585
- `,this._input=e.querySelector("input"),this._input&&this._indeterminate&&(this._input.indeterminate=!0)}setupEventListeners(){var e;(e=this._input)==null||e.addEventListener("change",this.handleChange)}cleanupEventListeners(){var e;(e=this._input)==null||e.removeEventListener("change",this.handleChange)}onAttributeChange(e,t,i){switch(e){case"checked":this._checked=i!==null,this.updateVisualState();break;case"indeterminate":this._indeterminate=i!==null,this.updateVisualState();break;case"disabled":this.updateDisabledState();break;case"label":case"hint":case"error":case"aria-label":case"aria-describedby":case"required":case"name":this.shadowRoot&&(this.cleanupEventListeners(),this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break;case"size":this.updateSizeClass();break}}updateVisualState(){this._input&&(this._input.checked=this._checked,this._input.indeterminate=this._indeterminate)}updateDisabledState(){this._input&&(this.disabled?this._input.setAttribute("disabled",""):this._input.removeAttribute("disabled"))}updateSizeClass(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".checkbox-wrapper");e&&(e.classList.remove("size-sm","size-md","size-lg"),e.classList.add(`size-${this.size}`))}toggle(){if(this.disabled)return;this._indeterminate?(this.indeterminate=!1,this.checked=!0):this.checked=!this.checked;const e=this.label||this.getAttribute("aria-label")||"Checkbox";o.announcePolite(`${e} ${this.checked?"checked":"unchecked"}`)}setChecked(e){this.checked=e}}class N extends u{constructor(){super(...arguments),this._value=[],this.handleChildChange=e=>{const t=e.target;if(!(t instanceof L)||t===this)return;const i=t.value;i&&(t.checked?this._value.includes(i)||(this._value=[...this._value,i]):this._value=this._value.filter(s=>s!==i),this.emit("change",{value:this._value}))}}static get observedAttributes(){return["disabled","legend","error","orientation","aria-label","aria-labelledby"]}get value(){return[...this._value]}set value(e){this._value=[...e],this.syncCheckboxStates()}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e),this.syncDisabledState()}get legend(){return this.getAttribute("legend")||""}set legend(e){e?this.setAttribute("legend",e):this.removeAttribute("legend")}get error(){return this.getAttribute("error")||""}set error(e){e?this.setAttribute("error",e):this.removeAttribute("error")}get orientation(){return this.getAttribute("orientation")==="horizontal"?"horizontal":"vertical"}set orientation(e){this.setAttribute("orientation",e)}setupAccessibility(){var e;typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&!this.legend&&!this.getAttribute("aria-label")&&!this.getAttribute("aria-labelledby")&&console.warn(`[compa11y/CheckboxGroup] CheckboxGroup has no accessible label. Add legend="..." or aria-label="..." attribute.
1695
+ `,this._input=e.querySelector("input"),this._input&&this._indeterminate&&(this._input.indeterminate=!0)}setupEventListeners(){var e;(e=this._input)==null||e.addEventListener("change",this.handleChange)}cleanupEventListeners(){var e;(e=this._input)==null||e.removeEventListener("change",this.handleChange)}onAttributeChange(e,t,i){switch(e){case"checked":this._checked=i!==null,this.updateVisualState();break;case"indeterminate":this._indeterminate=i!==null,this.updateVisualState();break;case"disabled":this.updateDisabledState();break;case"label":case"hint":case"error":case"aria-label":case"aria-describedby":case"required":case"name":this.shadowRoot&&(this.cleanupEventListeners(),this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break;case"size":this.updateSizeClass();break}}updateVisualState(){this._input&&(this._input.checked=this._checked,this._input.indeterminate=this._indeterminate)}updateDisabledState(){this._input&&(this.disabled?this._input.setAttribute("disabled",""):this._input.removeAttribute("disabled"))}updateSizeClass(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector(".checkbox-wrapper");e&&(e.classList.remove("size-sm","size-md","size-lg"),e.classList.add(`size-${this.size}`))}toggle(){if(this.disabled)return;this._indeterminate?(this.indeterminate=!1,this.checked=!0):this.checked=!this.checked;const e=this.label||this.getAttribute("aria-label")||"Checkbox";o.announcePolite(`${e} ${this.checked?"checked":"unchecked"}`)}setChecked(e){this.checked=e}}class U extends u{constructor(){super(...arguments),this._value=[],this.handleChildChange=e=>{const t=e.target;if(!(t instanceof I)||t===this)return;const i=t.value;i&&(t.checked?this._value.includes(i)||(this._value=[...this._value,i]):this._value=this._value.filter(s=>s!==i),this.emit("change",{value:this._value}))}}static get observedAttributes(){return["disabled","legend","error","orientation","aria-label","aria-labelledby"]}get value(){return[...this._value]}set value(e){this._value=[...e],this.syncCheckboxStates()}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",e),this.syncDisabledState()}get legend(){return this.getAttribute("legend")||""}set legend(e){e?this.setAttribute("legend",e):this.removeAttribute("legend")}get error(){return this.getAttribute("error")||""}set error(e){e?this.setAttribute("error",e):this.removeAttribute("error")}get orientation(){return this.getAttribute("orientation")==="horizontal"?"horizontal":"vertical"}set orientation(e){this.setAttribute("orientation",e)}setupAccessibility(){var e;typeof process<"u"&&((e=process.env)==null?void 0:e.NODE_ENV)!=="production"&&!this.legend&&!this.getAttribute("aria-label")&&!this.getAttribute("aria-labelledby")&&console.warn(`[compa11y/CheckboxGroup] CheckboxGroup has no accessible label. Add legend="..." or aria-label="..." attribute.
1586
1696
  💡 Suggestion: <a11y-checkbox-group legend="Select options"></a11y-checkbox-group>`),this.initValueFromChildren()}render(){const e=this.attachShadow({mode:"open"}),t=`${this._id}-error`,i=!!this.legend,s=!!this.error,a=this.getAttribute("aria-label"),r=this.getAttribute("aria-labelledby");e.innerHTML=`
1587
- <style>${he}</style>
1697
+ <style>${ue}</style>
1588
1698
  <fieldset
1589
1699
  part="fieldset"
1590
1700
  ${a?`aria-label="${a}"`:""}
@@ -1598,8 +1708,8 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1598
1708
  </div>
1599
1709
  ${s?`<div id="${t}" class="checkbox-group-error" role="alert" part="error">${this.error}</div>`:""}
1600
1710
  </fieldset>
1601
- `}setupEventListeners(){this.addEventListener("change",this.handleChildChange)}cleanupEventListeners(){this.removeEventListener("change",this.handleChildChange)}onAttributeChange(e,t,i){switch(e){case"disabled":this.syncDisabledState();break;case"legend":case"error":case"aria-label":case"aria-labelledby":this.shadowRoot&&(this.cleanupEventListeners(),this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break}}initValueFromChildren(){requestAnimationFrame(()=>{const e=this.querySelectorAll("a11y-checkbox"),t=[];e.forEach(i=>{i.hasAttribute("checked")&&i.getAttribute("value")&&t.push(i.getAttribute("value"))}),this._value=t})}syncCheckboxStates(){this.querySelectorAll("a11y-checkbox").forEach(t=>{const i=t.value;i&&(t.checked=this._value.includes(i))})}syncDisabledState(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector("fieldset");e&&(this.disabled?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}}b("a11y-checkbox",L),b("a11y-checkbox-group",N);class j extends u{constructor(){super(...arguments),this._value="",this._disabled=!1,this._discoverable=!0,this._orientation="vertical",this._required=!1,this._name="",this.handleRadioSelect=e=>{var i;if(this._disabled)return;const t=(i=e.detail)==null?void 0:i.value;t!==void 0&&this.selectRadio(t)},this.handleKeyDown=e=>{if(this._disabled)return;const t=this.getEnabledRadios();if(t.length===0)return;const i=t.findIndex(a=>a.value===this._value);let s=null;switch(e.key){case"ArrowDown":case"ArrowRight":s=i<0?0:(i+1)%t.length;break;case"ArrowUp":case"ArrowLeft":s=i<0?t.length-1:(i-1+t.length)%t.length;break;case"Home":s=0;break;case"End":s=t.length-1;break;case" ":e.preventDefault(),e.stopPropagation();{const a=t.find(r=>r===document.activeElement||r.contains(document.activeElement));if(a&&a.value!==this._value){this.selectRadio(a.value);const r=a.getAttribute("label")||a.value;o.announcePolite(`${r} selected`)}}return;default:return}if(s!==null){e.preventDefault(),e.stopPropagation();const a=t[s];if(a){this.selectRadio(a.value),a.focus();const r=a.getAttribute("label")||a.value;o.announcePolite(`${r} selected`)}}}}static get observedAttributes(){return["value","disabled","discoverable","orientation","required","name","legend","hint","error","aria-label","aria-labelledby"]}get value(){return this._value}set value(e){this._value!==e&&(this._value=e,this.setAttribute("value",e),this.syncRadioStates())}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")),this.syncRadioStates())}get discoverable(){return this._discoverable}set discoverable(e){this._discoverable=!!e}get required(){return this._required}set required(e){this._required=!!e,this._required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required")}get name(){return this._name}set name(e){this._name=e,this.setAttribute("name",e)}get orientation(){return this._orientation}set orientation(e){this._orientation=e,this.setAttribute("orientation",e),this.setAttribute("aria-orientation",e)}setupAccessibility(){this.setAttribute("role","radiogroup"),this.setAttribute("aria-orientation",this._orientation),!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||this.hasAttribute("legend"))&&process.env.NODE_ENV!=="production"&&console.warn("[Compa11y RadioGroup]: RadioGroup has no accessible label. Use legend, aria-label, or aria-labelledby.");const t=this.getAttribute("value");t&&(this._value=t),this._disabled=this.hasAttribute("disabled"),this._disabled&&this.setAttribute("aria-disabled","true");const i=this.getAttribute("orientation");(i==="horizontal"||i==="vertical")&&(this._orientation=i),this._required=this.hasAttribute("required"),this._required&&this.setAttribute("aria-required","true"),this._name=this.getAttribute("name")||this._id;const s=this.getAttribute("discoverable");(s==="false"||s==="0")&&(this._discoverable=!1),this.hasAttribute("error")&&this.getAttribute("error")&&this.setAttribute("aria-invalid","true")}render(){this.shadowRoot||this.attachShadow({mode:"open"});const e=this.shadowRoot,t=this.getAttribute("legend")||"",i=this.getAttribute("hint")||"",s=this.getAttribute("error")||"",a=i?`${this._id}-hint`:"",r=s?`${this._id}-error`:"",h=[a,r].filter(Boolean).join(" ");h?this.setAttribute("aria-describedby",h):this.removeAttribute("aria-describedby"),e.innerHTML=`
1602
- <style>${de}</style>
1711
+ `}setupEventListeners(){this.addEventListener("change",this.handleChildChange)}cleanupEventListeners(){this.removeEventListener("change",this.handleChildChange)}onAttributeChange(e,t,i){switch(e){case"disabled":this.syncDisabledState();break;case"legend":case"error":case"aria-label":case"aria-labelledby":this.shadowRoot&&(this.cleanupEventListeners(),this.shadowRoot.innerHTML="",this.render(),this.setupEventListeners());break}}initValueFromChildren(){requestAnimationFrame(()=>{const e=this.querySelectorAll("a11y-checkbox"),t=[];e.forEach(i=>{i.hasAttribute("checked")&&i.getAttribute("value")&&t.push(i.getAttribute("value"))}),this._value=t})}syncCheckboxStates(){this.querySelectorAll("a11y-checkbox").forEach(t=>{const i=t.value;i&&(t.checked=this._value.includes(i))})}syncDisabledState(){var t;const e=(t=this.shadowRoot)==null?void 0:t.querySelector("fieldset");e&&(this.disabled?e.setAttribute("disabled",""):e.removeAttribute("disabled"))}}b("a11y-checkbox",I),b("a11y-checkbox-group",U);class Y extends u{constructor(){super(...arguments),this._value="",this._disabled=!1,this._discoverable=!0,this._orientation="vertical",this._required=!1,this._name="",this.handleRadioSelect=e=>{var i;if(this._disabled)return;const t=(i=e.detail)==null?void 0:i.value;t!==void 0&&this.selectRadio(t)},this.handleKeyDown=e=>{if(this._disabled)return;const t=this.getEnabledRadios();if(t.length===0)return;const i=t.findIndex(a=>a.value===this._value);let s=null;switch(e.key){case"ArrowDown":case"ArrowRight":s=i<0?0:(i+1)%t.length;break;case"ArrowUp":case"ArrowLeft":s=i<0?t.length-1:(i-1+t.length)%t.length;break;case"Home":s=0;break;case"End":s=t.length-1;break;case" ":e.preventDefault(),e.stopPropagation();{const a=t.find(r=>r===document.activeElement||r.contains(document.activeElement));if(a&&a.value!==this._value){this.selectRadio(a.value);const r=a.getAttribute("label")||a.value;o.announcePolite(`${r} selected`)}}return;default:return}if(s!==null){e.preventDefault(),e.stopPropagation();const a=t[s];if(a){this.selectRadio(a.value),a.focus();const r=a.getAttribute("label")||a.value;o.announcePolite(`${r} selected`)}}}}static get observedAttributes(){return["value","disabled","discoverable","orientation","required","name","legend","hint","error","aria-label","aria-labelledby"]}get value(){return this._value}set value(e){this._value!==e&&(this._value=e,this.setAttribute("value",e),this.syncRadioStates())}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")),this.syncRadioStates())}get discoverable(){return this._discoverable}set discoverable(e){this._discoverable=!!e}get required(){return this._required}set required(e){this._required=!!e,this._required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required")}get name(){return this._name}set name(e){this._name=e,this.setAttribute("name",e)}get orientation(){return this._orientation}set orientation(e){this._orientation=e,this.setAttribute("orientation",e),this.setAttribute("aria-orientation",e)}setupAccessibility(){this.setAttribute("role","radiogroup"),this.setAttribute("aria-orientation",this._orientation),!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||this.hasAttribute("legend"))&&process.env.NODE_ENV!=="production"&&console.warn("[Compa11y RadioGroup]: RadioGroup has no accessible label. Use legend, aria-label, or aria-labelledby.");const t=this.getAttribute("value");t&&(this._value=t),this._disabled=this.hasAttribute("disabled"),this._disabled&&this.setAttribute("aria-disabled","true");const i=this.getAttribute("orientation");(i==="horizontal"||i==="vertical")&&(this._orientation=i),this._required=this.hasAttribute("required"),this._required&&this.setAttribute("aria-required","true"),this._name=this.getAttribute("name")||this._id;const s=this.getAttribute("discoverable");(s==="false"||s==="0")&&(this._discoverable=!1),this.hasAttribute("error")&&this.getAttribute("error")&&this.setAttribute("aria-invalid","true")}render(){this.shadowRoot||this.attachShadow({mode:"open"});const e=this.shadowRoot,t=this.getAttribute("legend")||"",i=this.getAttribute("hint")||"",s=this.getAttribute("error")||"",a=i?`${this._id}-hint`:"",r=s?`${this._id}-error`:"",h=[a,r].filter(Boolean).join(" ");h?this.setAttribute("aria-describedby",h):this.removeAttribute("aria-describedby"),e.innerHTML=`
1712
+ <style>${be}</style>
1603
1713
  <fieldset part="fieldset">
1604
1714
  ${t?`<legend part="legend">${t}${this._required?'<span class="radio-group-required" aria-hidden="true"> *</span>':""}</legend>`:""}
1605
1715
  <div class="radio-group-items" part="items">
@@ -1608,8 +1718,8 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1608
1718
  ${i?`<div class="radio-group-hint" id="${a}" part="hint">${i}</div>`:""}
1609
1719
  ${s?`<div class="radio-group-error" id="${r}" part="error" role="alert">${s}</div>`:""}
1610
1720
  </fieldset>
1611
- `}setupEventListeners(){var t;this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("radio-select",this.handleRadioSelect);const e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot");e&&e.addEventListener("slotchange",()=>{this.syncRadioStates()})}cleanupEventListeners(){this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("radio-select",this.handleRadioSelect)}getRadios(){return Array.from(this.querySelectorAll("a11y-radio"))}getEnabledRadios(){return this.getRadios().filter(e=>!e.disabled&&!this._disabled)}syncRadioStates(){const e=this.getRadios(),t=this.getEnabledRadios();e.forEach(i=>{const s=i.value===this._value;i.checked=s,s||!this._value&&t[0]===i?i.setAttribute("tabindex","0"):i.setAttribute("tabindex","-1")})}selectRadio(e){this._disabled||(this._value=e,this.setAttribute("value",e),this.syncRadioStates(),this.hasAttribute("aria-invalid")&&this.removeAttribute("aria-invalid"),this.emit("change",{value:e}),this.emit("a11y-radiogroup-change",{value:e}))}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"value":this._value=i||"",this.syncRadioStates();break;case"disabled":this._disabled=i!==null,this._disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.syncRadioStates();break;case"discoverable":i===null?this._discoverable=!0:i==="false"||i==="0"?this._discoverable=!1:this._discoverable=!0;break;case"orientation":(i==="horizontal"||i==="vertical")&&(this._orientation=i,this.setAttribute("aria-orientation",i));break;case"required":this._required=i!==null,this._required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required");break;case"name":this._name=i||"";break;case"error":i?this.setAttribute("aria-invalid","true"):this.removeAttribute("aria-invalid"),this.render();break;case"legend":case"hint":this.render();break}}}class U extends u{constructor(){super(...arguments),this._value="",this._checked=!1,this._disabled=!1,this._discoverable=!0,this.handleClick=e=>{if(this._disabled){e.preventDefault();return}this.dispatchEvent(new CustomEvent("radio-select",{detail:{value:this._value},bubbles:!0,composed:!0}));const t=this.getAttribute("label")||this._value;o.announcePolite(`${t} selected`)},this.handleKeyDown=e=>{if(!this._disabled&&e.key==="Enter"){e.preventDefault(),this.dispatchEvent(new CustomEvent("radio-select",{detail:{value:this._value},bubbles:!0,composed:!0}));const t=this.getAttribute("label")||this._value;o.announcePolite(`${t} selected`)}}}static get observedAttributes(){return["value","label","hint","disabled","discoverable","checked"]}get value(){return this._value}set value(e){this._value=e,this.setAttribute("value",e)}get checked(){return this._checked}set checked(e){const t=!!e;this._checked!==t&&(this._checked=t,t?this.setAttribute("checked",""):this.removeAttribute("checked"),this.setAttribute("aria-checked",String(t)),this.updateVisual())}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get discoverable(){return this._discoverable}set discoverable(e){let t;typeof e=="string"?t=e!=="false"&&e!=="0":t=!!e,this._discoverable!==t&&(this._discoverable=t,t?this.setAttribute("discoverable",""):this.removeAttribute("discoverable"))}setupAccessibility(){this.setAttribute("role","radio"),this.setAttribute("aria-checked","false"),this._value=this.getAttribute("value")||"",this._checked=this.hasAttribute("checked"),this._disabled=this.hasAttribute("disabled"),this._checked&&this.setAttribute("aria-checked","true"),this._disabled&&this.setAttribute("aria-disabled","true");const e=this.getAttribute("discoverable");(e==="false"||e==="0")&&(this._discoverable=!1),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){this.shadowRoot||this.attachShadow({mode:"open"});const e=this.shadowRoot,t=this.getAttribute("label")||"",i=this.getAttribute("hint")||"",s=t?`${this._id}-label`:"",a=i?`${this._id}-hint`:"";s&&this.setAttribute("aria-labelledby",s),a&&this.setAttribute("aria-describedby",a),e.innerHTML=`
1612
- <style>${ce}</style>
1721
+ `}setupEventListeners(){var t;this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("radio-select",this.handleRadioSelect);const e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot");e&&e.addEventListener("slotchange",()=>{this.syncRadioStates()})}cleanupEventListeners(){this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("radio-select",this.handleRadioSelect)}getRadios(){return Array.from(this.querySelectorAll("a11y-radio"))}getEnabledRadios(){return this.getRadios().filter(e=>!e.disabled&&!this._disabled)}syncRadioStates(){const e=this.getRadios(),t=this.getEnabledRadios();e.forEach(i=>{const s=i.value===this._value;i.checked=s,s||!this._value&&t[0]===i?i.setAttribute("tabindex","0"):i.setAttribute("tabindex","-1")})}selectRadio(e){this._disabled||(this._value=e,this.setAttribute("value",e),this.syncRadioStates(),this.hasAttribute("aria-invalid")&&this.removeAttribute("aria-invalid"),this.emit("change",{value:e}),this.emit("a11y-radiogroup-change",{value:e}))}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"value":this._value=i||"",this.syncRadioStates();break;case"disabled":this._disabled=i!==null,this._disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled"),this.syncRadioStates();break;case"discoverable":i===null?this._discoverable=!0:i==="false"||i==="0"?this._discoverable=!1:this._discoverable=!0;break;case"orientation":(i==="horizontal"||i==="vertical")&&(this._orientation=i,this.setAttribute("aria-orientation",i));break;case"required":this._required=i!==null,this._required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required");break;case"name":this._name=i||"";break;case"error":i?this.setAttribute("aria-invalid","true"):this.removeAttribute("aria-invalid"),this.render();break;case"legend":case"hint":this.render();break}}}class G extends u{constructor(){super(...arguments),this._value="",this._checked=!1,this._disabled=!1,this._discoverable=!0,this.handleClick=e=>{if(this._disabled){e.preventDefault();return}this.dispatchEvent(new CustomEvent("radio-select",{detail:{value:this._value},bubbles:!0,composed:!0}));const t=this.getAttribute("label")||this._value;o.announcePolite(`${t} selected`)},this.handleKeyDown=e=>{if(!this._disabled&&e.key==="Enter"){e.preventDefault(),this.dispatchEvent(new CustomEvent("radio-select",{detail:{value:this._value},bubbles:!0,composed:!0}));const t=this.getAttribute("label")||this._value;o.announcePolite(`${t} selected`)}}}static get observedAttributes(){return["value","label","hint","disabled","discoverable","checked"]}get value(){return this._value}set value(e){this._value=e,this.setAttribute("value",e)}get checked(){return this._checked}set checked(e){const t=!!e;this._checked!==t&&(this._checked=t,t?this.setAttribute("checked",""):this.removeAttribute("checked"),this.setAttribute("aria-checked",String(t)),this.updateVisual())}get disabled(){return this._disabled}set disabled(e){const t=!!e;this._disabled!==t&&(this._disabled=t,t?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get discoverable(){return this._discoverable}set discoverable(e){let t;typeof e=="string"?t=e!=="false"&&e!=="0":t=!!e,this._discoverable!==t&&(this._discoverable=t,t?this.setAttribute("discoverable",""):this.removeAttribute("discoverable"))}setupAccessibility(){this.setAttribute("role","radio"),this.setAttribute("aria-checked","false"),this._value=this.getAttribute("value")||"",this._checked=this.hasAttribute("checked"),this._disabled=this.hasAttribute("disabled"),this._checked&&this.setAttribute("aria-checked","true"),this._disabled&&this.setAttribute("aria-disabled","true");const e=this.getAttribute("discoverable");(e==="false"||e==="0")&&(this._discoverable=!1),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){this.shadowRoot||this.attachShadow({mode:"open"});const e=this.shadowRoot,t=this.getAttribute("label")||"",i=this.getAttribute("hint")||"",s=t?`${this._id}-label`:"",a=i?`${this._id}-hint`:"";s&&this.setAttribute("aria-labelledby",s),a&&this.setAttribute("aria-describedby",a),e.innerHTML=`
1722
+ <style>${pe}</style>
1613
1723
  <div class="radio-wrapper" part="wrapper">
1614
1724
  <div class="radio-control" part="control">
1615
1725
  <input
@@ -1629,4 +1739,13 @@ var compa11y=function(l,o){"use strict";class u extends HTMLElement{constructor(
1629
1739
  </div>`:""}
1630
1740
  <slot></slot>
1631
1741
  </div>
1632
- `}setupEventListeners(){this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}updateVisual(){if(!this.shadowRoot)return;const e=this.shadowRoot.querySelector(".radio-dot");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"scale(1)":"scale(0)");const t=this.shadowRoot.querySelector(".radio-circle");t&&(this._checked?(t.style.background="var(--compa11y-radio-checked-bg, #0066cc)",t.style.borderColor="var(--compa11y-radio-checked-border, #0066cc)"):(t.style.background="var(--compa11y-radio-bg, white)",t.style.borderColor=""))}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"value":this._value=i||"";break;case"checked":this._checked=i!==null,this.setAttribute("aria-checked",String(this._checked)),this.updateVisual();break;case"disabled":this._disabled=i!==null,this._disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");break;case"discoverable":i===null?this._discoverable=!0:i==="false"||i==="0"?this._discoverable=!1:this._discoverable=!0;break;case"label":case"hint":this.render();break}}}if(b("a11y-radio-group",j),b("a11y-radio",U),typeof window<"u"){const d=()=>{o.initAnnouncer(),o.initFocusVisible()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d(),window.compa11y={A11yDialog:O,A11yMenu:z,A11yTabs:q,A11yCombobox:D,A11ySwitch:T,A11ySelect:R,A11yInput:B,A11yTextarea:H,A11yButton:P,A11yListbox:K,A11yOption:F,A11yOptgroup:M,A11yCheckbox:L,A11yCheckboxGroup:N,A11yRadioGroup:j,A11yRadio:U,initAnnouncer:o.initAnnouncer,announce:o.announce,announcePolite:o.announcePolite,announceAssertive:o.announceAssertive,announceStatus:o.announceStatus,announceError:o.announceError,initFocusVisible:o.initFocusVisible,createFocusTrap:o.createFocusTrap,createFocusScope:o.createFocusScope,createRovingTabindex:o.createRovingTabindex,createKeyboardManager:o.createKeyboardManager,KeyboardPatterns:o.KeyboardPatterns,createTypeAhead:o.createTypeAhead,aria:o.aria,buildAriaProps:o.buildAriaProps,hasAccessibleName:o.hasAccessibleName,isBrowser:o.isBrowser,prefersReducedMotion:o.prefersReducedMotion,prefersHighContrast:o.prefersHighContrast,prefersDarkMode:o.prefersDarkMode}}return Object.defineProperty(l,"KeyboardPatterns",{enumerable:!0,get:()=>o.KeyboardPatterns}),Object.defineProperty(l,"announce",{enumerable:!0,get:()=>o.announce}),Object.defineProperty(l,"announceAssertive",{enumerable:!0,get:()=>o.announceAssertive}),Object.defineProperty(l,"announceError",{enumerable:!0,get:()=>o.announceError}),Object.defineProperty(l,"announcePolite",{enumerable:!0,get:()=>o.announcePolite}),Object.defineProperty(l,"announceStatus",{enumerable:!0,get:()=>o.announceStatus}),Object.defineProperty(l,"aria",{enumerable:!0,get:()=>o.aria}),Object.defineProperty(l,"buildAriaProps",{enumerable:!0,get:()=>o.buildAriaProps}),Object.defineProperty(l,"createFocusScope",{enumerable:!0,get:()=>o.createFocusScope}),Object.defineProperty(l,"createFocusTrap",{enumerable:!0,get:()=>o.createFocusTrap}),Object.defineProperty(l,"createKeyboardManager",{enumerable:!0,get:()=>o.createKeyboardManager}),Object.defineProperty(l,"createRovingTabindex",{enumerable:!0,get:()=>o.createRovingTabindex}),Object.defineProperty(l,"createTypeAhead",{enumerable:!0,get:()=>o.createTypeAhead}),Object.defineProperty(l,"hasAccessibleName",{enumerable:!0,get:()=>o.hasAccessibleName}),Object.defineProperty(l,"initAnnouncer",{enumerable:!0,get:()=>o.initAnnouncer}),Object.defineProperty(l,"initFocusVisible",{enumerable:!0,get:()=>o.initFocusVisible}),Object.defineProperty(l,"isBrowser",{enumerable:!0,get:()=>o.isBrowser}),Object.defineProperty(l,"prefersDarkMode",{enumerable:!0,get:()=>o.prefersDarkMode}),Object.defineProperty(l,"prefersHighContrast",{enumerable:!0,get:()=>o.prefersHighContrast}),Object.defineProperty(l,"prefersReducedMotion",{enumerable:!0,get:()=>o.prefersReducedMotion}),l.A11yButton=P,l.A11yCheckbox=L,l.A11yCheckboxGroup=N,l.A11yCombobox=D,l.A11yDialog=O,l.A11yInput=B,l.A11yListbox=K,l.A11yMenu=z,l.A11yOptgroup=M,l.A11yOption=F,l.A11yRadio=U,l.A11yRadioGroup=j,l.A11ySelect=R,l.A11ySwitch=T,l.A11yTabs=q,l.A11yTextarea=H,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),l}({},compa11yCore);
1742
+ `}setupEventListeners(){this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}updateVisual(){if(!this.shadowRoot)return;const e=this.shadowRoot.querySelector(".radio-dot");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"scale(1)":"scale(0)");const t=this.shadowRoot.querySelector(".radio-circle");t&&(this._checked?(t.style.background="var(--compa11y-radio-checked-bg, #0066cc)",t.style.borderColor="var(--compa11y-radio-checked-border, #0066cc)"):(t.style.background="var(--compa11y-radio-bg, white)",t.style.borderColor=""))}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"value":this._value=i||"";break;case"checked":this._checked=i!==null,this.setAttribute("aria-checked",String(this._checked)),this.updateVisual();break;case"disabled":this._disabled=i!==null,this._disabled?this.setAttribute("aria-disabled","true"):this.removeAttribute("aria-disabled");break;case"discoverable":i===null?this._discoverable=!0:i==="false"||i==="0"?this._discoverable=!1:this._discoverable=!0;break;case"label":case"hint":this.render();break}}}b("a11y-radio-group",Y),b("a11y-radio",G);class V extends u{constructor(){super(...arguments),this._toasts=[],this._counter=0,this._containerEl=null,this._maxToasts=5,this._handleClick=e=>{var a;const t=e.target,i=t.getAttribute("data-close-id");if(i){this.remove(i);return}const s=t.getAttribute("data-action-id");if(s){const r=this._toasts.find(h=>h.id===s);(a=r==null?void 0:r.action)==null||a.onClick(),this.remove(s)}}}static get observedAttributes(){return["position","duration","max-toasts","label"]}get position(){return this.getAttribute("position")||"bottom-right"}get duration(){const e=this.getAttribute("duration");return e?parseInt(e,10):5e3}get maxToasts(){const e=this.getAttribute("max-toasts");return e?parseInt(e,10):5}get label(){return this.getAttribute("label")||"Notifications"}setupAccessibility(){}render(){const e=this.attachShadow({mode:"open"});e.innerHTML=`
1743
+ <style>${me}</style>
1744
+ <div
1745
+ class="toast-container"
1746
+ role="region"
1747
+ aria-label="${this.label}"
1748
+ aria-live="polite"
1749
+ aria-relevant="additions removals"
1750
+ ></div>
1751
+ `,this._containerEl=e.querySelector(".toast-container")}setupEventListeners(){var e;(e=this._containerEl)==null||e.addEventListener("click",this._handleClick)}cleanupEventListeners(){var e;(e=this._containerEl)==null||e.removeEventListener("click",this._handleClick);for(const t of this._toasts)t.timerId&&clearTimeout(t.timerId);this._toasts=[]}onAttributeChange(e,t,i){e==="max-toasts"&&i&&(this._maxToasts=parseInt(i,10)),e==="label"&&this._containerEl&&this._containerEl.setAttribute("aria-label",i||"Notifications")}add(e){const t=`toast-${++this._counter}`,i=e.duration??this.duration,s={id:t,type:e.type||"info",title:e.title,description:e.description,duration:i,action:e.action,timerId:null,remaining:i,startTime:Date.now()};for(this._toasts.push(s);this._toasts.length>this._maxToasts;){const a=this._toasts.shift();a&&(a.timerId&&clearTimeout(a.timerId),this._removeElement(a.id))}return this._renderToast(s),this._startTimer(s),this.emit("a11y-toast-add",{id:t,...e}),t}remove(e){const t=this._toasts.findIndex(s=>s.id===e);if(t===-1)return;const i=this._toasts[t];i.timerId&&clearTimeout(i.timerId),this._toasts.splice(t,1),this._removeElement(e),this.emit("a11y-toast-remove",{id:e})}clear(){for(const e of this._toasts)e.timerId&&clearTimeout(e.timerId);this._toasts=[],this._containerEl&&(this._containerEl.innerHTML="")}_renderToast(e){if(!this._containerEl)return;const t=e.type==="error"||e.type==="warning",i=document.createElement("div");i.className="toast",i.setAttribute("data-toast-id",e.id),i.setAttribute("data-type",e.type),i.setAttribute("role",t?"alert":"status"),i.setAttribute("aria-atomic","true"),i.setAttribute("tabindex","0");let s='<div class="toast-content">';e.title&&(s+=`<div class="toast-title">${this._escapeHtml(e.title)}</div>`),e.description&&(s+=`<div class="toast-description">${this._escapeHtml(e.description)}</div>`),e.action&&(s+=`<button type="button" class="toast-action" data-action-id="${e.id}" tabindex="0">${this._escapeHtml(e.action.label)}</button>`),s+="</div>",s+=`<button type="button" class="toast-close" aria-label="Dismiss" data-close-id="${e.id}" tabindex="0">×</button>`,i.innerHTML=s,i.addEventListener("mouseenter",()=>this._pauseTimer(e)),i.addEventListener("mouseleave",()=>this._resumeTimer(e)),i.addEventListener("keydown",a=>{a.key==="Escape"&&this.remove(e.id)}),this._containerEl.appendChild(i)}_removeElement(e){var i;const t=(i=this._containerEl)==null?void 0:i.querySelector(`[data-toast-id="${e}"]`);t==null||t.remove()}_startTimer(e){e.duration!==0&&(e.startTime=Date.now(),e.timerId=setTimeout(()=>{this.remove(e.id)},e.remaining))}_pauseTimer(e){e.timerId&&(clearTimeout(e.timerId),e.timerId=null,e.remaining-=Date.now()-e.startTime)}_resumeTimer(e){this._startTimer(e)}_escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}}if(b("a11y-toast",V),typeof window<"u"){const d=()=>{o.initAnnouncer(),o.initFocusVisible()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d(),window.compa11y={A11yDialog:O,A11yMenu:D,A11yTabs:q,A11yCombobox:R,A11ySwitch:H,A11ySelect:B,A11yInput:P,A11yTextarea:M,A11yButton:F,A11yListbox:j,A11yOption:N,A11yOptgroup:K,A11yCheckbox:I,A11yCheckboxGroup:U,A11yRadioGroup:Y,A11yRadio:G,A11yToast:V,initAnnouncer:o.initAnnouncer,announce:o.announce,announcePolite:o.announcePolite,announceAssertive:o.announceAssertive,announceStatus:o.announceStatus,announceError:o.announceError,initFocusVisible:o.initFocusVisible,createFocusTrap:o.createFocusTrap,createFocusScope:o.createFocusScope,createRovingTabindex:o.createRovingTabindex,createKeyboardManager:o.createKeyboardManager,KeyboardPatterns:o.KeyboardPatterns,createTypeAhead:o.createTypeAhead,aria:o.aria,buildAriaProps:o.buildAriaProps,hasAccessibleName:o.hasAccessibleName,isBrowser:o.isBrowser,prefersReducedMotion:o.prefersReducedMotion,prefersHighContrast:o.prefersHighContrast,prefersDarkMode:o.prefersDarkMode}}return Object.defineProperty(l,"KeyboardPatterns",{enumerable:!0,get:()=>o.KeyboardPatterns}),Object.defineProperty(l,"announce",{enumerable:!0,get:()=>o.announce}),Object.defineProperty(l,"announceAssertive",{enumerable:!0,get:()=>o.announceAssertive}),Object.defineProperty(l,"announceError",{enumerable:!0,get:()=>o.announceError}),Object.defineProperty(l,"announcePolite",{enumerable:!0,get:()=>o.announcePolite}),Object.defineProperty(l,"announceStatus",{enumerable:!0,get:()=>o.announceStatus}),Object.defineProperty(l,"aria",{enumerable:!0,get:()=>o.aria}),Object.defineProperty(l,"buildAriaProps",{enumerable:!0,get:()=>o.buildAriaProps}),Object.defineProperty(l,"createFocusScope",{enumerable:!0,get:()=>o.createFocusScope}),Object.defineProperty(l,"createFocusTrap",{enumerable:!0,get:()=>o.createFocusTrap}),Object.defineProperty(l,"createKeyboardManager",{enumerable:!0,get:()=>o.createKeyboardManager}),Object.defineProperty(l,"createRovingTabindex",{enumerable:!0,get:()=>o.createRovingTabindex}),Object.defineProperty(l,"createTypeAhead",{enumerable:!0,get:()=>o.createTypeAhead}),Object.defineProperty(l,"hasAccessibleName",{enumerable:!0,get:()=>o.hasAccessibleName}),Object.defineProperty(l,"initAnnouncer",{enumerable:!0,get:()=>o.initAnnouncer}),Object.defineProperty(l,"initFocusVisible",{enumerable:!0,get:()=>o.initFocusVisible}),Object.defineProperty(l,"isBrowser",{enumerable:!0,get:()=>o.isBrowser}),Object.defineProperty(l,"prefersDarkMode",{enumerable:!0,get:()=>o.prefersDarkMode}),Object.defineProperty(l,"prefersHighContrast",{enumerable:!0,get:()=>o.prefersHighContrast}),Object.defineProperty(l,"prefersReducedMotion",{enumerable:!0,get:()=>o.prefersReducedMotion}),l.A11yButton=F,l.A11yCheckbox=I,l.A11yCheckboxGroup=U,l.A11yCombobox=R,l.A11yDialog=O,l.A11yInput=P,l.A11yListbox=j,l.A11yMenu=D,l.A11yOptgroup=K,l.A11yOption=N,l.A11yRadio=G,l.A11yRadioGroup=Y,l.A11ySelect=B,l.A11ySwitch=H,l.A11yTabs=q,l.A11yTextarea=M,l.A11yToast=V,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"}),l}({},compa11yCore);