@compa11y/web 0.1.9 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compa11y.iife.js +1006 -174
- package/dist/compa11y.js +2199 -306
- package/dist/components/accordion.d.ts +30 -0
- package/dist/components/form-field.d.ts +14 -0
- package/dist/components/link.d.ts +8 -0
- package/dist/components/pagination.d.ts +45 -0
- package/dist/components/popover.d.ts +47 -0
- package/dist/components/table.d.ts +78 -0
- package/dist/components/text.d.ts +16 -0
- package/dist/index.d.ts +8 -1
- package/dist/utils/styles.d.ts +9 -0
- package/package.json +2 -2
package/dist/compa11y.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var compa11y=function(l
|
|
1
|
+
var compa11y=function(h,l){"use strict";class p extends HTMLElement{constructor(){super(),this._internals=null,this._id=l.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(t,e,i){e!==i&&this.onAttributeChange(t,e,i)}setupEventListeners(){}cleanupEventListeners(){}onAttributeChange(t,e,i){}emit(t,e){return this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:!0}))}getSlot(t){var e;return((e=this.shadowRoot)==null?void 0:e.querySelector(`slot[name="${t}"]`))??null}getSlottedElements(t){var s;const e=t?`slot[name="${t}"]`:"slot:not([name])",i=(s=this.shadowRoot)==null?void 0:s.querySelector(e);return(i==null?void 0:i.assignedElements())??[]}}function g(d,t){customElements.get(d)||customElements.define(d,t)}const lt=`
|
|
2
2
|
position: absolute;
|
|
3
3
|
width: 1px;
|
|
4
4
|
height: 1px;
|
|
@@ -8,7 +8,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
8
8
|
clip: rect(0, 0, 0, 0);
|
|
9
9
|
white-space: nowrap;
|
|
10
10
|
border: 0;
|
|
11
|
-
`,
|
|
11
|
+
`,L=`
|
|
12
12
|
appearance: none;
|
|
13
13
|
background: none;
|
|
14
14
|
border: none;
|
|
@@ -17,7 +17,13 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
17
17
|
font: inherit;
|
|
18
18
|
color: inherit;
|
|
19
19
|
cursor: pointer;
|
|
20
|
-
`,
|
|
20
|
+
`,dt=`
|
|
21
|
+
:host(:focus-visible),
|
|
22
|
+
:focus-visible {
|
|
23
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
24
|
+
outline-offset: 2px;
|
|
25
|
+
}
|
|
26
|
+
`,f=`
|
|
21
27
|
:host {
|
|
22
28
|
display: block;
|
|
23
29
|
box-sizing: border-box;
|
|
@@ -33,15 +39,9 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
33
39
|
box-sizing: inherit;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
40
|
-
outline-offset: 2px;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
`,ae=`
|
|
44
|
-
${p}
|
|
42
|
+
${dt}
|
|
43
|
+
`,yt=`
|
|
44
|
+
${f}
|
|
45
45
|
|
|
46
46
|
:host {
|
|
47
47
|
position: fixed;
|
|
@@ -79,8 +79,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
79
79
|
margin: 0 0 1rem 0;
|
|
80
80
|
color: var(--compa11y-dialog-description-color, #666);
|
|
81
81
|
}
|
|
82
|
-
`,
|
|
83
|
-
${
|
|
82
|
+
`,_t=`
|
|
83
|
+
${f}
|
|
84
84
|
|
|
85
85
|
:host {
|
|
86
86
|
position: relative;
|
|
@@ -131,8 +131,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
131
131
|
margin: 0.25rem 0;
|
|
132
132
|
background: var(--compa11y-menu-separator-color, #e0e0e0);
|
|
133
133
|
}
|
|
134
|
-
`,
|
|
135
|
-
${
|
|
134
|
+
`,xt=`
|
|
135
|
+
${f}
|
|
136
136
|
|
|
137
137
|
.tablist {
|
|
138
138
|
display: flex;
|
|
@@ -147,7 +147,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
::slotted([role="tab"]) {
|
|
150
|
-
${
|
|
150
|
+
${L}
|
|
151
151
|
padding: var(--compa11y-tab-padding, 0.75rem 1rem);
|
|
152
152
|
border-bottom: 2px solid transparent;
|
|
153
153
|
margin-bottom: -1px;
|
|
@@ -177,8 +177,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
177
177
|
::slotted([role="tabpanel"][hidden]) {
|
|
178
178
|
display: none;
|
|
179
179
|
}
|
|
180
|
-
`,
|
|
181
|
-
${
|
|
180
|
+
`,At=`
|
|
181
|
+
${f}
|
|
182
182
|
|
|
183
183
|
:host {
|
|
184
184
|
display: inline-block;
|
|
@@ -236,7 +236,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
.clear-button {
|
|
239
|
-
${
|
|
239
|
+
${L}
|
|
240
240
|
position: absolute;
|
|
241
241
|
right: 1.5rem;
|
|
242
242
|
width: 1.25rem;
|
|
@@ -318,8 +318,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
318
318
|
.options-source {
|
|
319
319
|
display: none;
|
|
320
320
|
}
|
|
321
|
-
`,
|
|
322
|
-
${
|
|
321
|
+
`,Et=`
|
|
322
|
+
${f}
|
|
323
323
|
|
|
324
324
|
:host {
|
|
325
325
|
display: inline-block;
|
|
@@ -448,8 +448,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
448
448
|
.options-source {
|
|
449
449
|
display: none;
|
|
450
450
|
}
|
|
451
|
-
`,
|
|
452
|
-
${
|
|
451
|
+
`,kt=`
|
|
452
|
+
${f}
|
|
453
453
|
|
|
454
454
|
:host {
|
|
455
455
|
display: inline-block;
|
|
@@ -552,8 +552,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
552
552
|
opacity: 0.5;
|
|
553
553
|
cursor: not-allowed;
|
|
554
554
|
}
|
|
555
|
-
`,
|
|
556
|
-
${
|
|
555
|
+
`,wt=`
|
|
556
|
+
${f}
|
|
557
557
|
|
|
558
558
|
:host {
|
|
559
559
|
display: block;
|
|
@@ -631,8 +631,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
631
631
|
color: var(--compa11y-input-error-color, #ef4444);
|
|
632
632
|
font-size: var(--compa11y-input-error-size, 0.8125rem);
|
|
633
633
|
}
|
|
634
|
-
`,
|
|
635
|
-
${
|
|
634
|
+
`,St=`
|
|
635
|
+
${f}
|
|
636
636
|
|
|
637
637
|
:host {
|
|
638
638
|
display: block;
|
|
@@ -712,8 +712,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
712
712
|
color: var(--compa11y-textarea-error-color, #ef4444);
|
|
713
713
|
font-size: var(--compa11y-textarea-error-size, 0.8125rem);
|
|
714
714
|
}
|
|
715
|
-
|
|
716
|
-
${
|
|
715
|
+
`,$t=`
|
|
716
|
+
${f}
|
|
717
717
|
|
|
718
718
|
:host {
|
|
719
719
|
display: inline-block;
|
|
@@ -827,8 +827,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
827
827
|
border-radius: 50%;
|
|
828
828
|
animation: compa11y-spin 0.6s linear infinite;
|
|
829
829
|
}
|
|
830
|
-
`,
|
|
831
|
-
${
|
|
830
|
+
`,Lt=`
|
|
831
|
+
${f}
|
|
832
832
|
|
|
833
833
|
:host {
|
|
834
834
|
display: block;
|
|
@@ -861,8 +861,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
861
861
|
max-height: none;
|
|
862
862
|
overflow-y: visible;
|
|
863
863
|
}
|
|
864
|
-
`,
|
|
865
|
-
${
|
|
864
|
+
`,It=`
|
|
865
|
+
${f}
|
|
866
866
|
|
|
867
867
|
:host {
|
|
868
868
|
display: block;
|
|
@@ -910,8 +910,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
910
910
|
:host([aria-selected="true"]) .check-mark {
|
|
911
911
|
visibility: visible;
|
|
912
912
|
}
|
|
913
|
-
`,
|
|
914
|
-
${
|
|
913
|
+
`,Tt=`
|
|
914
|
+
${f}
|
|
915
915
|
|
|
916
916
|
:host {
|
|
917
917
|
display: block;
|
|
@@ -929,8 +929,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
929
929
|
:host([disabled]) {
|
|
930
930
|
opacity: 0.5;
|
|
931
931
|
}
|
|
932
|
-
`,
|
|
933
|
-
${
|
|
932
|
+
`,Ct=`
|
|
933
|
+
${f}
|
|
934
934
|
|
|
935
935
|
:host {
|
|
936
936
|
display: inline-block;
|
|
@@ -1092,8 +1092,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1092
1092
|
color: HighlightText;
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
|
-
`,
|
|
1096
|
-
${
|
|
1095
|
+
`,zt=`
|
|
1096
|
+
${f}
|
|
1097
1097
|
|
|
1098
1098
|
:host {
|
|
1099
1099
|
display: block;
|
|
@@ -1134,8 +1134,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1134
1134
|
:host([disabled]) {
|
|
1135
1135
|
opacity: 0.5;
|
|
1136
1136
|
}
|
|
1137
|
-
`,
|
|
1138
|
-
${
|
|
1137
|
+
`,Dt=`
|
|
1138
|
+
${f}
|
|
1139
1139
|
|
|
1140
1140
|
:host {
|
|
1141
1141
|
display: block;
|
|
@@ -1187,8 +1187,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1187
1187
|
:host([disabled]) {
|
|
1188
1188
|
opacity: 0.5;
|
|
1189
1189
|
}
|
|
1190
|
-
`,
|
|
1191
|
-
${
|
|
1190
|
+
`,qt=`
|
|
1191
|
+
${f}
|
|
1192
1192
|
|
|
1193
1193
|
:host {
|
|
1194
1194
|
display: inline-block;
|
|
@@ -1307,8 +1307,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1307
1307
|
background: HighlightText;
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
1310
|
-
`,
|
|
1311
|
-
${
|
|
1310
|
+
`,Ot=`
|
|
1311
|
+
${f}
|
|
1312
1312
|
|
|
1313
1313
|
:host {
|
|
1314
1314
|
position: fixed;
|
|
@@ -1376,7 +1376,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1376
1376
|
}
|
|
1377
1377
|
|
|
1378
1378
|
.toast-close {
|
|
1379
|
-
${
|
|
1379
|
+
${L}
|
|
1380
1380
|
flex-shrink: 0;
|
|
1381
1381
|
width: 1.5rem;
|
|
1382
1382
|
height: 1.5rem;
|
|
@@ -1400,7 +1400,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1400
1400
|
}
|
|
1401
1401
|
|
|
1402
1402
|
.toast-action {
|
|
1403
|
-
${
|
|
1403
|
+
${L}
|
|
1404
1404
|
margin-top: 0.375rem;
|
|
1405
1405
|
font-size: var(--compa11y-toast-action-size, 0.8125rem);
|
|
1406
1406
|
font-weight: 500;
|
|
@@ -1416,18 +1416,433 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1416
1416
|
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
1417
1417
|
outline-offset: 2px;
|
|
1418
1418
|
}
|
|
1419
|
-
`,
|
|
1420
|
-
|
|
1419
|
+
`,Rt=`
|
|
1420
|
+
a11y-accordion {
|
|
1421
|
+
display: block;
|
|
1422
|
+
border: 1px solid var(--compa11y-accordion-border-color, #e0e0e0);
|
|
1423
|
+
border-radius: var(--compa11y-accordion-radius, 6px);
|
|
1424
|
+
overflow: hidden;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
a11y-accordion h1,
|
|
1428
|
+
a11y-accordion h2,
|
|
1429
|
+
a11y-accordion h3,
|
|
1430
|
+
a11y-accordion h4,
|
|
1431
|
+
a11y-accordion h5,
|
|
1432
|
+
a11y-accordion h6 {
|
|
1433
|
+
margin: 0;
|
|
1434
|
+
font-size: inherit;
|
|
1435
|
+
font-weight: inherit;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
a11y-accordion [data-accordion-trigger] {
|
|
1439
|
+
appearance: none;
|
|
1440
|
+
-webkit-appearance: none;
|
|
1441
|
+
background: var(--compa11y-accordion-trigger-bg, #ffffff);
|
|
1442
|
+
border: none;
|
|
1443
|
+
border-bottom: 1px solid var(--compa11y-accordion-border-color, #e0e0e0);
|
|
1444
|
+
padding: var(--compa11y-accordion-trigger-padding, 1rem);
|
|
1445
|
+
font: inherit;
|
|
1446
|
+
font-size: 1rem;
|
|
1447
|
+
font-weight: 500;
|
|
1448
|
+
color: var(--compa11y-accordion-trigger-color, #1a1a1a);
|
|
1449
|
+
width: 100%;
|
|
1450
|
+
text-align: left;
|
|
1451
|
+
cursor: pointer;
|
|
1452
|
+
display: flex;
|
|
1453
|
+
align-items: center;
|
|
1454
|
+
justify-content: space-between;
|
|
1455
|
+
gap: 0.5rem;
|
|
1456
|
+
transition: background 0.15s ease;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
a11y-accordion [data-accordion-trigger]:hover {
|
|
1460
|
+
background: var(--compa11y-accordion-trigger-hover-bg, #f9f9f9);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
a11y-accordion [data-accordion-trigger]:focus-visible {
|
|
1464
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
1465
|
+
outline-offset: -2px;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
a11y-accordion [data-accordion-trigger][aria-disabled="true"],
|
|
1469
|
+
a11y-accordion [data-accordion-trigger]:disabled {
|
|
1470
|
+
opacity: 0.5;
|
|
1471
|
+
cursor: not-allowed;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
a11y-accordion [data-accordion-trigger]::after {
|
|
1475
|
+
content: '';
|
|
1476
|
+
flex-shrink: 0;
|
|
1477
|
+
width: 0.5rem;
|
|
1478
|
+
height: 0.5rem;
|
|
1479
|
+
border-right: 2px solid currentColor;
|
|
1480
|
+
border-bottom: 2px solid currentColor;
|
|
1481
|
+
transform: rotate(45deg) translateY(-2px);
|
|
1482
|
+
transition: transform 0.2s ease;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
a11y-accordion [data-accordion-trigger][aria-expanded="true"]::after {
|
|
1486
|
+
transform: rotate(-135deg) translateY(-2px);
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
a11y-accordion [data-accordion-panel] {
|
|
1490
|
+
padding: var(--compa11y-accordion-content-padding, 1rem);
|
|
1491
|
+
background: var(--compa11y-accordion-content-bg, #ffffff);
|
|
1492
|
+
border-bottom: 1px solid var(--compa11y-accordion-border-color, #e0e0e0);
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
a11y-accordion [data-accordion-panel][hidden] {
|
|
1496
|
+
display: none;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
a11y-accordion > *:last-child [data-accordion-trigger],
|
|
1500
|
+
a11y-accordion > [data-accordion-panel]:last-child {
|
|
1501
|
+
border-bottom: none;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1505
|
+
a11y-accordion [data-accordion-trigger],
|
|
1506
|
+
a11y-accordion [data-accordion-trigger]::after {
|
|
1507
|
+
transition: none;
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
@media (forced-colors: active) {
|
|
1512
|
+
a11y-accordion {
|
|
1513
|
+
border: 2px solid ButtonText;
|
|
1514
|
+
}
|
|
1515
|
+
a11y-accordion [data-accordion-trigger] {
|
|
1516
|
+
border-bottom: 1px solid ButtonText;
|
|
1517
|
+
forced-color-adjust: none;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
`,Pt=`
|
|
1521
|
+
/* ── Host ── */
|
|
1522
|
+
a11y-table {
|
|
1523
|
+
display: block;
|
|
1524
|
+
overflow-x: auto;
|
|
1525
|
+
-webkit-overflow-scrolling: touch;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/* ── Table element ── */
|
|
1529
|
+
a11y-table table {
|
|
1530
|
+
border-collapse: collapse;
|
|
1531
|
+
width: 100%;
|
|
1532
|
+
font-size: 0.9375rem;
|
|
1533
|
+
color: var(--compa11y-table-color, #1a1a1a);
|
|
1534
|
+
background: var(--compa11y-table-bg, #ffffff);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
/* ── Caption ── */
|
|
1538
|
+
a11y-table caption {
|
|
1539
|
+
caption-side: top;
|
|
1540
|
+
text-align: left;
|
|
1541
|
+
font-weight: 600;
|
|
1542
|
+
font-size: 1rem;
|
|
1543
|
+
padding-bottom: 0.5rem;
|
|
1544
|
+
color: var(--compa11y-table-caption-color, #1a1a1a);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/* ── Header cells ── */
|
|
1548
|
+
a11y-table th {
|
|
1549
|
+
text-align: left;
|
|
1550
|
+
font-weight: 600;
|
|
1551
|
+
padding: var(--compa11y-table-cell-padding, 0.625rem 0.875rem);
|
|
1552
|
+
background: var(--compa11y-table-head-bg, #f5f5f5);
|
|
1553
|
+
border-bottom: 2px solid var(--compa11y-table-border-color, #d0d0d0);
|
|
1554
|
+
white-space: nowrap;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
/* ── Data cells ── */
|
|
1558
|
+
a11y-table td {
|
|
1559
|
+
padding: var(--compa11y-table-cell-padding, 0.625rem 0.875rem);
|
|
1560
|
+
border-bottom: 1px solid var(--compa11y-table-border-color, #e8e8e8);
|
|
1561
|
+
vertical-align: top;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
/* ── Row hover ── */
|
|
1565
|
+
a11y-table tbody tr:hover {
|
|
1566
|
+
background: var(--compa11y-table-row-hover-bg, #fafafa);
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/* ── Selected row ── */
|
|
1570
|
+
a11y-table tr[aria-selected="true"] {
|
|
1571
|
+
background: var(--compa11y-table-selected-bg, #e8f0fe);
|
|
1572
|
+
}
|
|
1573
|
+
a11y-table tr[aria-selected="true"]:hover {
|
|
1574
|
+
background: var(--compa11y-table-selected-hover-bg, #dde7fd);
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
/* ── Sort button ── */
|
|
1578
|
+
a11y-table [data-sort-btn] {
|
|
1579
|
+
appearance: none;
|
|
1580
|
+
-webkit-appearance: none;
|
|
1581
|
+
background: none;
|
|
1582
|
+
border: none;
|
|
1583
|
+
padding: 0;
|
|
1584
|
+
margin: 0;
|
|
1585
|
+
font: inherit;
|
|
1586
|
+
color: inherit;
|
|
1587
|
+
cursor: pointer;
|
|
1588
|
+
display: inline-flex;
|
|
1589
|
+
align-items: center;
|
|
1590
|
+
gap: 0.375em;
|
|
1591
|
+
text-align: left;
|
|
1592
|
+
width: 100%;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
a11y-table [data-sort-btn]:focus-visible {
|
|
1596
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
1597
|
+
outline-offset: 2px;
|
|
1598
|
+
border-radius: 2px;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
a11y-table [data-sort-icon] {
|
|
1602
|
+
font-size: 0.75em;
|
|
1603
|
+
opacity: 0.6;
|
|
1604
|
+
flex-shrink: 0;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
/* ── Select checkboxes ── */
|
|
1608
|
+
a11y-table [data-select-cb] {
|
|
1609
|
+
cursor: pointer;
|
|
1610
|
+
width: 1rem;
|
|
1611
|
+
height: 1rem;
|
|
1612
|
+
}
|
|
1613
|
+
a11y-table [data-select-cb]:focus-visible {
|
|
1614
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
1615
|
+
outline-offset: 2px;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
/* ── Empty / Loading cells ── */
|
|
1619
|
+
a11y-table [data-empty-cell],
|
|
1620
|
+
a11y-table [data-loading-cell] {
|
|
1621
|
+
text-align: center;
|
|
1622
|
+
padding: 2rem 1rem;
|
|
1623
|
+
color: var(--compa11y-table-muted-color, #6b6b6b);
|
|
1624
|
+
font-style: italic;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
/* ── Footer ── */
|
|
1628
|
+
a11y-table tfoot td,
|
|
1629
|
+
a11y-table tfoot th {
|
|
1630
|
+
background: var(--compa11y-table-foot-bg, #f5f5f5);
|
|
1631
|
+
border-top: 2px solid var(--compa11y-table-border-color, #d0d0d0);
|
|
1632
|
+
border-bottom: none;
|
|
1633
|
+
font-weight: 600;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
/* ── Reduced motion ── */
|
|
1637
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1638
|
+
a11y-table tr,
|
|
1639
|
+
a11y-table td,
|
|
1640
|
+
a11y-table th {
|
|
1641
|
+
transition: none;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
/* ── Windows High Contrast ── */
|
|
1646
|
+
@media (forced-colors: active) {
|
|
1647
|
+
a11y-table table {
|
|
1648
|
+
border: 1px solid ButtonText;
|
|
1649
|
+
forced-color-adjust: none;
|
|
1650
|
+
}
|
|
1651
|
+
a11y-table th,
|
|
1652
|
+
a11y-table td {
|
|
1653
|
+
border: 1px solid ButtonText;
|
|
1654
|
+
}
|
|
1655
|
+
a11y-table tr[aria-selected="true"] {
|
|
1656
|
+
outline: 2px solid Highlight;
|
|
1657
|
+
}
|
|
1658
|
+
a11y-table [data-sort-btn]:focus-visible {
|
|
1659
|
+
outline: 2px solid Highlight;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
`,Ht=`
|
|
1663
|
+
${f}
|
|
1664
|
+
|
|
1665
|
+
:host {
|
|
1666
|
+
display: block;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
/* Visually hidden — live region always in DOM */
|
|
1670
|
+
.sr-only {
|
|
1671
|
+
position: absolute;
|
|
1672
|
+
width: 1px;
|
|
1673
|
+
height: 1px;
|
|
1674
|
+
padding: 0;
|
|
1675
|
+
margin: -1px;
|
|
1676
|
+
overflow: hidden;
|
|
1677
|
+
clip: rect(0, 0, 0, 0);
|
|
1678
|
+
white-space: nowrap;
|
|
1679
|
+
border: 0;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
nav {
|
|
1683
|
+
display: flex;
|
|
1684
|
+
flex-wrap: wrap;
|
|
1685
|
+
align-items: center;
|
|
1686
|
+
gap: var(--compa11y-pagination-gap, 0.5rem);
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
ul {
|
|
1690
|
+
display: flex;
|
|
1691
|
+
flex-wrap: wrap;
|
|
1692
|
+
align-items: center;
|
|
1693
|
+
gap: var(--compa11y-pagination-btn-gap, 2px);
|
|
1694
|
+
list-style: none;
|
|
1695
|
+
padding: 0;
|
|
1696
|
+
margin: 0;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
[data-compa11y-pagination-btn] {
|
|
1700
|
+
display: inline-flex;
|
|
1701
|
+
align-items: center;
|
|
1702
|
+
justify-content: center;
|
|
1703
|
+
min-width: var(--compa11y-pagination-btn-size, 44px);
|
|
1704
|
+
min-height: var(--compa11y-pagination-btn-size, 44px);
|
|
1705
|
+
padding: var(--compa11y-pagination-btn-padding, 0.25rem 0.5rem);
|
|
1706
|
+
border: var(--compa11y-pagination-btn-border, 1px solid #d1d5db);
|
|
1707
|
+
border-radius: var(--compa11y-pagination-btn-radius, 4px);
|
|
1708
|
+
background: var(--compa11y-pagination-btn-bg, transparent);
|
|
1709
|
+
color: var(--compa11y-pagination-btn-color, inherit);
|
|
1710
|
+
font: inherit;
|
|
1711
|
+
cursor: pointer;
|
|
1712
|
+
user-select: none;
|
|
1713
|
+
transition: background 0.15s ease, border-color 0.15s ease;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
[data-compa11y-pagination-btn]:not([disabled]):hover {
|
|
1717
|
+
background: var(--compa11y-pagination-btn-hover-bg, #f3f4f6);
|
|
1718
|
+
border-color: var(--compa11y-pagination-btn-hover-border, #9ca3af);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
[data-compa11y-pagination-btn]:focus-visible {
|
|
1722
|
+
outline: var(--compa11y-focus-width, 2px) solid
|
|
1723
|
+
var(--compa11y-focus-color, #0066cc);
|
|
1724
|
+
outline-offset: 2px;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
[data-compa11y-pagination-btn][disabled] {
|
|
1728
|
+
opacity: 0.4;
|
|
1729
|
+
cursor: not-allowed;
|
|
1730
|
+
pointer-events: none;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
/* Current page — background + border so color is not the only indicator */
|
|
1734
|
+
[data-compa11y-pagination-page][data-current="true"] {
|
|
1735
|
+
background: var(--compa11y-pagination-current-bg, #0066cc);
|
|
1736
|
+
color: var(--compa11y-pagination-current-color, #fff);
|
|
1737
|
+
border-color: var(--compa11y-pagination-current-bg, #0066cc);
|
|
1738
|
+
font-weight: 600;
|
|
1739
|
+
text-decoration: underline;
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
[aria-hidden="true"] span {
|
|
1743
|
+
display: inline-flex;
|
|
1744
|
+
align-items: center;
|
|
1745
|
+
justify-content: center;
|
|
1746
|
+
min-width: var(--compa11y-pagination-btn-size, 44px);
|
|
1747
|
+
min-height: var(--compa11y-pagination-btn-size, 44px);
|
|
1748
|
+
color: var(--compa11y-pagination-ellipsis-color, #9ca3af);
|
|
1749
|
+
user-select: none;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
/* Rows-per-page selector */
|
|
1753
|
+
.page-size-wrapper {
|
|
1754
|
+
display: flex;
|
|
1755
|
+
align-items: center;
|
|
1756
|
+
gap: 0.5rem;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
.page-size-wrapper label {
|
|
1760
|
+
white-space: nowrap;
|
|
1761
|
+
font-size: 0.875rem;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
[data-compa11y-pagination-pagesize] {
|
|
1765
|
+
padding: 0.25rem 0.5rem;
|
|
1766
|
+
border: 1px solid #d1d5db;
|
|
1767
|
+
border-radius: 4px;
|
|
1768
|
+
font: inherit;
|
|
1769
|
+
font-size: 0.875rem;
|
|
1770
|
+
background: var(--compa11y-pagination-select-bg, #fff);
|
|
1771
|
+
cursor: pointer;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
[data-compa11y-pagination-pagesize]:focus-visible {
|
|
1775
|
+
outline: var(--compa11y-focus-width, 2px) solid
|
|
1776
|
+
var(--compa11y-focus-color, #0066cc);
|
|
1777
|
+
outline-offset: 2px;
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
/* Jump-to-page input */
|
|
1781
|
+
.jump-wrapper {
|
|
1782
|
+
display: flex;
|
|
1783
|
+
align-items: center;
|
|
1784
|
+
gap: 0.5rem;
|
|
1785
|
+
flex-wrap: wrap;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
.jump-wrapper label {
|
|
1789
|
+
white-space: nowrap;
|
|
1790
|
+
font-size: 0.875rem;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
[data-compa11y-pagination-jump] {
|
|
1794
|
+
width: 5rem;
|
|
1795
|
+
padding: 0.25rem 0.5rem;
|
|
1796
|
+
border: 1px solid #d1d5db;
|
|
1797
|
+
border-radius: 4px;
|
|
1798
|
+
font: inherit;
|
|
1799
|
+
font-size: 0.875rem;
|
|
1800
|
+
background: var(--compa11y-pagination-input-bg, #fff);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
[data-compa11y-pagination-jump]:focus-visible {
|
|
1804
|
+
outline: var(--compa11y-focus-width, 2px) solid
|
|
1805
|
+
var(--compa11y-focus-color, #0066cc);
|
|
1806
|
+
outline-offset: 2px;
|
|
1807
|
+
border-color: var(--compa11y-focus-color, #0066cc);
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
[data-compa11y-pagination-error] {
|
|
1811
|
+
color: var(--compa11y-pagination-error-color, #dc2626);
|
|
1812
|
+
font-size: 0.75rem;
|
|
1813
|
+
width: 100%;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/* Reduced motion */
|
|
1817
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1818
|
+
[data-compa11y-pagination-btn] {
|
|
1819
|
+
transition: none !important;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
/* Forced colours / high contrast */
|
|
1824
|
+
@media (forced-colors: active) {
|
|
1825
|
+
[data-compa11y-pagination-page][data-current="true"] {
|
|
1826
|
+
border: 2px solid ButtonText;
|
|
1827
|
+
forced-color-adjust: none;
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
[data-compa11y-pagination-btn]:focus-visible {
|
|
1831
|
+
outline: 2px solid Highlight;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
`,ct='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';let w=0,ht="";function Mt(){w===0&&(ht=document.body.style.overflow,document.body.style.overflow="hidden"),w++}function Bt(){w--,w<=0&&(w=0,document.body.style.overflow=ht)}class D extends p{constructor(){super(...arguments),this._open=!1,this._previouslyFocused=null,this._triggerElement=null,this.handleTriggerClick=()=>{this.open=!0},this.handleClose=()=>{this.open=!1},this.handleKeyDown=t=>{var e;if(this._open){if(t.key==="Escape"){this.getAttribute("close-on-escape")!=="false"&&(t.preventDefault(),this.handleClose());return}if(t.key==="Tab"){t.preventDefault();const i=this.getFocusableElements();if(i.length===0)return;const s=((e=this.shadowRoot)==null?void 0:e.activeElement)||document.activeElement;let a=i.findIndex(n=>n===s);a===-1&&(a=t.shiftKey?0:i.length-1);let r;t.shiftKey?r=a===0?i.length-1:a-1:r=a===i.length-1?0:a+1;const o=i[r];o&&o.focus()}}}}static get observedAttributes(){return["open","trigger","close-on-outside-click","close-on-escape"]}get open(){return this._open}set open(t){const e=this._open;this._open=t,t!==e&&(t?this.showDialog():this.hideDialog()),this.toggleAttribute("open",t)}setupAccessibility(){}render(){const t=this.attachShadow({mode:"open"}),e=`${this._id}-title`,i=`${this._id}-desc`;t.innerHTML=`
|
|
1835
|
+
<style>${yt}</style>
|
|
1421
1836
|
<div class="overlay" part="overlay"></div>
|
|
1422
1837
|
<div
|
|
1423
1838
|
class="dialog"
|
|
1424
1839
|
role="dialog"
|
|
1425
1840
|
aria-modal="true"
|
|
1426
|
-
aria-labelledby="${
|
|
1841
|
+
aria-labelledby="${e}"
|
|
1427
1842
|
aria-describedby="${i}"
|
|
1428
1843
|
part="dialog"
|
|
1429
1844
|
>
|
|
1430
|
-
<div id="${
|
|
1845
|
+
<div id="${e}" part="title">
|
|
1431
1846
|
<slot name="title"></slot>
|
|
1432
1847
|
</div>
|
|
1433
1848
|
<div id="${i}" part="description">
|
|
@@ -1440,8 +1855,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1440
1855
|
<slot name="actions"></slot>
|
|
1441
1856
|
</div>
|
|
1442
1857
|
</div>
|
|
1443
|
-
`,this._open||(this.style.display="none")}setupEventListeners(){var i;const
|
|
1444
|
-
<style>${
|
|
1858
|
+
`,this._open||(this.style.display="none")}setupEventListeners(){var i;const t=this.getAttribute("trigger");if(t){const s=()=>{this._triggerElement=document.querySelector(t),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 e=(i=this.shadowRoot)==null?void 0:i.querySelector(".overlay");this.getAttribute("close-on-outside-click")!=="false"&&(e==null||e.addEventListener("click",this.handleClose)),this.addEventListener("keydown",this.handleKeyDown)}cleanupEventListeners(){var t;(t=this._triggerElement)==null||t.removeEventListener("click",this.handleTriggerClick),this.removeEventListener("keydown",this.handleKeyDown)}onAttributeChange(t,e,i){t==="open"&&(this.open=i!==null)}getFocusableElements(){const t=[];return this.querySelectorAll(ct).forEach(i=>t.push(i)),this.shadowRoot&&this.shadowRoot.querySelectorAll(ct).forEach(s=>{s.classList.contains("overlay")||t.push(s)}),t}showDialog(){this._previouslyFocused=document.activeElement,this.style.display="flex",requestAnimationFrame(()=>{const e=this.getFocusableElements()[0];e&&e.focus()}),Mt(),l.announce("Dialog opened",{politeness:"polite"}),this.emit("a11y-dialog-open")}hideDialog(){var t;this.style.display="none",Bt(),(t=this._previouslyFocused)==null||t.focus(),this._previouslyFocused=null,l.announce("Dialog closed",{politeness:"polite"}),this.emit("a11y-dialog-close")}show(){this.open=!0}close(){this.open=!1}}g("a11y-dialog",D);class q extends p{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((t,e)=>{t.id=t.id||`${this._id}-item-${e}`,t.setAttribute("tabindex","-1")})},this._lastClickTime=0,this.handleTriggerClick=()=>{const t=Date.now();t-this._lastClickTime<50||(this._lastClickTime=t,this.toggle())},this.handleTriggerKeyDown=t=>{switch(t.key){case"Enter":case" ":t.preventDefault(),this.toggle(),this._open&&this.highlightItem(0);break;case"ArrowDown":t.preventDefault(),this._open||this.show(),this.highlightItem(0);break;case"ArrowUp":t.preventDefault(),this._open||this.show(),this.highlightItem(this._menuItems.length-1);break}},this.handleMenuKeyDown=t=>{if(!this._open)return;const e=t.target;if(!(!e.hasAttribute("role")||e.getAttribute("role")!=="menuitem"))switch(t.key){case"ArrowDown":t.preventDefault(),this.highlightItem((this._highlightedIndex+1)%this._menuItems.length);break;case"ArrowUp":t.preventDefault(),this.highlightItem((this._highlightedIndex-1+this._menuItems.length)%this._menuItems.length);break;case"Home":t.preventDefault(),this.highlightItem(0);break;case"End":t.preventDefault(),this.highlightItem(this._menuItems.length-1);break;case"Enter":case" ":t.preventDefault(),this.selectItem(this._highlightedIndex);break;case"Escape":t.preventDefault(),this.close();break;case"Tab":this.close();break}},this.handleItemClick=t=>{const e=t.target;if(e.getAttribute("role")==="menuitem"&&e.getAttribute("aria-disabled")!=="true"){const i=this._menuItems.indexOf(e);this.selectItem(i)}},this.handleMouseOver=t=>{const e=t.target;if(e.getAttribute("role")==="menuitem"){const i=this._menuItems.indexOf(e);i!==-1&&this.highlightItem(i,!1)}},this.handleOutsideClick=t=>{if(!this._open)return;t.composedPath().includes(this)||this.close()}}static get observedAttributes(){return["open"]}get open(){return this._open}set open(t){const e=this._open;this._open=t,t!==e&&this.updateMenuVisibility(),this.toggleAttribute("open",t)}setupAccessibility(){const t=this.querySelector('[slot="trigger"]');t&&(t.setAttribute("aria-haspopup","menu"),t.setAttribute("aria-expanded",String(this._open)),t.id=t.id||`${this._id}-trigger`,t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"))}render(){const t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
1859
|
+
<style>${_t}</style>
|
|
1445
1860
|
<slot name="trigger"></slot>
|
|
1446
1861
|
<div
|
|
1447
1862
|
class="menu-content"
|
|
@@ -1453,8 +1868,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1453
1868
|
>
|
|
1454
1869
|
<slot></slot>
|
|
1455
1870
|
</div>
|
|
1456
|
-
`}setupEventListeners(){var e,
|
|
1457
|
-
<style>${
|
|
1871
|
+
`}setupEventListeners(){var t,e,i,s,a,r;this._triggerEl=this.querySelector('[slot="trigger"]'),(t=this._triggerEl)==null||t.addEventListener("click",this.handleTriggerClick),(e=this._triggerEl)==null||e.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 t,e,i,s;(t=this._triggerEl)==null||t.removeEventListener("click",this.handleTriggerClick),(e=this._triggerEl)==null||e.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(t,e,i){t==="open"&&(this.open=i!==null)}highlightItem(t,e=!0){var s;if(this._highlightedIndex>=0){const a=this._menuItems[this._highlightedIndex];a==null||a.removeAttribute("data-highlighted")}this._highlightedIndex=t;const i=this._menuItems[t];if(i){i.setAttribute("data-highlighted","true"),e&&i.focus();const a=(s=this.shadowRoot)==null?void 0:s.querySelector('[role="menu"]');a==null||a.setAttribute("aria-activedescendant",i.id)}}selectItem(t){const e=this._menuItems[t];e&&(this.emit("a11y-menu-select",{item:e,index:t}),e.click()),this.close()}updateMenuVisibility(){var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector(".menu-content"),e=this.querySelector('[slot="trigger"]');this._open?(t==null||t.removeAttribute("hidden"),e==null||e.setAttribute("aria-expanded","true"),this.updateMenuItems(),this.emit("a11y-menu-open")):(t==null||t.setAttribute("hidden",""),e==null||e.setAttribute("aria-expanded","false"),this._highlightedIndex=-1,this._menuItems.forEach(s=>{s.removeAttribute("data-highlighted")}),e==null||e.focus(),this.emit("a11y-menu-close"))}show(){this.open=!0}close(){this.open=!1}toggle(){this.open=!this._open}}g("a11y-menu",q);class O extends p{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((t,e)=>{const i=this._panels[e],s=t.id||`${this._id}-tab-${e}`,a=(i==null?void 0:i.id)||`${this._id}-panel-${e}`;t.id=s,t.setAttribute("aria-controls",a),t.setAttribute("tabindex",e===this._selectedIndex?"0":"-1"),t.setAttribute("aria-selected",String(e===this._selectedIndex)),t.hasAttribute("slot")||t.setAttribute("slot","tab"),i&&(i.id=a,i.setAttribute("aria-labelledby",s),i.setAttribute("tabindex","0"),i.hidden=e!==this._selectedIndex,i.hasAttribute("slot")||i.setAttribute("slot","panel"))}),this.updateSelection()},this.handleClick=t=>{const e=t.target;if(e.getAttribute("role")==="tab"){const i=this._tabs.indexOf(e);i!==-1&&e.getAttribute("aria-disabled")!=="true"&&(this._focusedIndex=i,this.selectTab(i))}},this.handleKeyDown=t=>{var o;if(t.target.getAttribute("role")!=="tab")return;const i=this.orientation==="horizontal",s=i?"ArrowRight":"ArrowDown",a=i?"ArrowLeft":"ArrowUp";let r=this._focusedIndex;switch(t.key){case s:t.preventDefault(),r=(this._focusedIndex+1)%this._tabs.length;break;case a:t.preventDefault(),r=(this._focusedIndex-1+this._tabs.length)%this._tabs.length;break;case"Home":t.preventDefault(),r=0;break;case"End":t.preventDefault(),r=this._tabs.length-1;break;case"Enter":case" ":t.preventDefault(),this.selectTab(this._focusedIndex);return;default:return}this._focusedIndex=r,(o=this._tabs[r])==null||o.focus(),this.activationMode==="automatic"&&this.selectTab(r)}}static get observedAttributes(){return["orientation","activation-mode","selected-index"]}get selectedIndex(){return this._selectedIndex}set selectedIndex(t){t>=0&&t<this._tabs.length&&(this._selectedIndex=t,this.updateSelection())}get orientation(){return this.getAttribute("orientation")||"horizontal"}get activationMode(){return this.getAttribute("activation-mode")||"automatic"}setupAccessibility(){this.updateTabsAndPanels()}render(){const t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
1872
|
+
<style>${xt}</style>
|
|
1458
1873
|
<div class="tablist" role="tablist" aria-orientation="${this.orientation}" part="tablist">
|
|
1459
1874
|
<slot name="tab"></slot>
|
|
1460
1875
|
</div>
|
|
@@ -1462,12 +1877,12 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1462
1877
|
<slot name="panel"></slot>
|
|
1463
1878
|
</div>
|
|
1464
1879
|
<slot></slot>
|
|
1465
|
-
`}setupEventListeners(){var e,
|
|
1466
|
-
<style>${
|
|
1880
|
+
`}setupEventListeners(){var t,e,i,s,a,r;this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this._tabSlotEl=((t=this.shadowRoot)==null?void 0:t.querySelector('slot[name="tab"]'))??null,this._panelSlotEl=((e=this.shadowRoot)==null?void 0:e.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 t,e,i;this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown),(t=this._tabSlotEl)==null||t.removeEventListener("slotchange",this.updateTabsAndPanels),(e=this._panelSlotEl)==null||e.removeEventListener("slotchange",this.updateTabsAndPanels),(i=this._defaultSlotEl)==null||i.removeEventListener("slotchange",this.updateTabsAndPanels)}onAttributeChange(t,e,i){var s;if(t==="orientation"){const a=(s=this.shadowRoot)==null?void 0:s.querySelector('[role="tablist"]');a==null||a.setAttribute("aria-orientation",i||"horizontal")}t==="selected-index"&&i&&(this.selectedIndex=parseInt(i,10))}selectTab(t){const e=this._selectedIndex;if(this._selectedIndex=t,this._focusedIndex=t,this.updateSelection(),e!==t){const i=this._tabs[t];l.announce(`${(i==null?void 0:i.textContent)||"Tab"} selected`),this.emit("a11y-tabs-change",{index:t,tab:this._tabs[t],panel:this._panels[t]})}}updateSelection(){this._tabs.forEach((t,e)=>{const i=e===this._selectedIndex;t.setAttribute("aria-selected",String(i)),t.setAttribute("tabindex",i?"0":"-1")}),this._panels.forEach((t,e)=>{t.hidden=e!==this._selectedIndex})}select(t){this.selectTab(t)}next(){this.selectTab((this._selectedIndex+1)%this._tabs.length)}previous(){this.selectTab((this._selectedIndex-1+this._tabs.length)%this._tabs.length)}}g("a11y-tabs",O);class R extends p{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 t=Array.from(this.querySelectorAll("option"));this._options=t.map(e=>({value:e.getAttribute("value")||e.textContent||"",label:e.textContent||"",disabled:e.hasAttribute("disabled"),element:e})),this._filteredOptions=[...this._options],this.renderOptions()},this.handleInput=t=>{const e=t.target;this._inputValue=e.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;l.announce(s===0?"No results":`${s} result${s===1?"":"s"} available`)},this.handleFocus=()=>{this.open=!0},this.handleBlur=()=>{setTimeout(()=>{var t;(t=this.shadowRoot)!=null&&t.activeElement||(this.open=!1)},150)},this.handleKeyDown=t=>{switch(t.key){case"ArrowDown":t.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":t.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(t.preventDefault(),this._open&&this._highlightedIndex>=0){const e=this._filteredOptions[this._highlightedIndex];e&&!e.disabled&&this.selectOption(e)}break;case"Escape":t.preventDefault(),this.open=!1,this._highlightedIndex=-1;break;case"Home":this._open&&(t.preventDefault(),this._highlightedIndex=0,this.updateHighlight());break;case"End":this._open&&(t.preventDefault(),this._highlightedIndex=this._filteredOptions.length-1,this.updateHighlight());break;case"Tab":this._open&&(this.open=!1,this._highlightedIndex=-1);break}},this.handleOptionClick=t=>{const e=t.currentTarget,i=parseInt(e.dataset.index||"0",10),s=this._filteredOptions[i];s&&!s.disabled&&this.selectOption(s)},this.handleOptionHover=t=>{const e=t.currentTarget,i=parseInt(e.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=t=>{if(!this._open)return;t.composedPath().includes(this)||(this.open=!1)}}static get observedAttributes(){return["open","value","placeholder","disabled","clearable"]}get open(){return this._open}set open(t){const e=this._open;this._open=t,t!==e&&this.updateListboxVisibility(),this.toggleAttribute("open",t)}get value(){return this._selectedValue}set value(t){this._selectedValue=t;const e=this._options.find(i=>i.value===t);e&&(this._inputValue=e.label,this._inputElement&&(this._inputElement.value=e.label)),this.setAttribute("value",t||"")}setupAccessibility(){}render(){const t=this.attachShadow({mode:"open"}),e=`${this._id}-input`,i=`${this._id}-listbox`,s=this.getAttribute("placeholder")||"Search...",a=this.hasAttribute("clearable");t.innerHTML=`
|
|
1881
|
+
<style>${At}</style>
|
|
1467
1882
|
<div class="combobox-wrapper" part="wrapper">
|
|
1468
1883
|
<div class="input-wrapper" part="input-wrapper">
|
|
1469
1884
|
<input
|
|
1470
|
-
id="${
|
|
1885
|
+
id="${e}"
|
|
1471
1886
|
type="text"
|
|
1472
1887
|
role="combobox"
|
|
1473
1888
|
autocomplete="off"
|
|
@@ -1493,7 +1908,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1493
1908
|
<ul
|
|
1494
1909
|
id="${i}"
|
|
1495
1910
|
role="listbox"
|
|
1496
|
-
aria-labelledby="${
|
|
1911
|
+
aria-labelledby="${e}"
|
|
1497
1912
|
class="listbox"
|
|
1498
1913
|
tabindex="-1"
|
|
1499
1914
|
hidden
|
|
@@ -1503,20 +1918,20 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1503
1918
|
<div class="options-source" hidden>
|
|
1504
1919
|
<slot></slot>
|
|
1505
1920
|
</div>
|
|
1506
|
-
`,this._inputElement=
|
|
1921
|
+
`,this._inputElement=t.querySelector("input"),this._listboxElement=t.querySelector(".listbox")}setupEventListeners(){var i,s,a,r,o,n;(i=this._inputElement)==null||i.addEventListener("input",this.handleInput),(s=this._inputElement)==null||s.addEventListener("focus",this.handleFocus),(a=this._inputElement)==null||a.addEventListener("blur",this.handleBlur),(r=this._inputElement)==null||r.addEventListener("keydown",this.handleKeyDown);const t=(o=this.shadowRoot)==null?void 0:o.querySelector(".clear-button");t==null||t.addEventListener("click",this.handleClear),document.addEventListener("mousedown",this.handleOutsideClick);const e=(n=this.shadowRoot)==null?void 0:n.querySelector("slot");e==null||e.addEventListener("slotchange",this.updateOptions),this.updateOptions()}cleanupEventListeners(){document.removeEventListener("mousedown",this.handleOutsideClick)}onAttributeChange(t,e,i){t==="open"&&(this.open=i!==null),t==="value"&&(this.value=i),t==="disabled"&&this._inputElement&&(this._inputElement.disabled=i!==null),t==="placeholder"&&this._inputElement&&(this._inputElement.placeholder=i||"Search...")}renderOptions(){this._listboxElement&&(this._listboxElement.innerHTML=this._filteredOptions.length===0?'<li role="presentation" class="empty-message" part="empty">No results found</li>':this._filteredOptions.map((t,e)=>`
|
|
1507
1922
|
<li
|
|
1508
|
-
id="${this._id}-option-${
|
|
1923
|
+
id="${this._id}-option-${e}"
|
|
1509
1924
|
role="option"
|
|
1510
|
-
aria-selected="${this._selectedValue===
|
|
1511
|
-
aria-disabled="${
|
|
1512
|
-
data-value="${
|
|
1513
|
-
data-index="${
|
|
1925
|
+
aria-selected="${this._selectedValue===t.value}"
|
|
1926
|
+
aria-disabled="${t.disabled}"
|
|
1927
|
+
data-value="${t.value}"
|
|
1928
|
+
data-index="${e}"
|
|
1514
1929
|
part="option"
|
|
1515
|
-
${
|
|
1516
|
-
>${
|
|
1517
|
-
`).join(""),this._listboxElement.querySelectorAll('[role="option"]').forEach(
|
|
1518
|
-
💡 Suggestion: <a11y-switch label="Enable feature"></a11y-switch>`)}render(){const
|
|
1519
|
-
<style>${
|
|
1930
|
+
${t.disabled?'class="disabled"':""}
|
|
1931
|
+
>${t.label}</li>
|
|
1932
|
+
`).join(""),this._listboxElement.querySelectorAll('[role="option"]').forEach(t=>{t.addEventListener("click",this.handleOptionClick),t.addEventListener("mouseenter",this.handleOptionHover)}))}selectOption(t){this._selectedValue=t.value,this._inputValue=t.label,this._inputElement&&(this._inputElement.value=t.label),this.open=!1,this._highlightedIndex=-1,this.renderOptions(),this.updateClearButton(),l.announce(`${t.label} selected`),this.emit("a11y-combobox-select",{value:t.value,label:t.label}),this.emit("a11y-combobox-change",{value:t.value,label:t.label})}updateHighlight(){var t,e,i,s;if((t=this._listboxElement)==null||t.querySelectorAll('[role="option"]').forEach((a,r)=>{a.classList.toggle("highlighted",r===this._highlightedIndex)}),this._highlightedIndex>=0){const a=`${this._id}-option-${this._highlightedIndex}`;(e=this._inputElement)==null||e.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 t=this._inputElement.getBoundingClientRect(),e=window.innerHeight,i=Math.min(this._listboxElement.scrollHeight,200),s=e-t.bottom,a=t.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 e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector(".clear-button");t&&(t.hidden=!this._inputValue)}show(){this.open=!0}close(){this.open=!1}clear(){this.handleClear()}}g("a11y-combobox",R);class P extends p{constructor(){super(...arguments),this._checked=!1,this._button=null,this._label=null,this.handleClick=()=>{this.toggle()},this.handleKeyDown=t=>{this.disabled||(t.key===" "||t.key==="Enter")&&(t.preventDefault(),this.toggle())},this.handleLabelClick=()=>{var t;this.disabled||(this.toggle(),(t=this._button)==null||t.focus())}}static get observedAttributes(){return["checked","disabled","label","size","aria-label"]}get checked(){return this._checked}set checked(t){const e=this._checked;this._checked=t,this.toggleAttribute("checked",t),t!==e&&(this.updateVisualState(),this.emit("change",{checked:t}))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t),this.updateDisabledState()}get label(){return this.getAttribute("label")||""}set label(t){t?this.setAttribute("label",t):this.removeAttribute("label")}get size(){const t=this.getAttribute("size");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}setupAccessibility(){var t;this.getAttribute("role"),typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)!=="production"&&!this.label&&!this.getAttribute("aria-label")&&console.warn(`[compa11y/Switch] Switch has no accessible label. Add label="..." or aria-label="..." attribute.
|
|
1933
|
+
💡 Suggestion: <a11y-switch label="Enable feature"></a11y-switch>`)}render(){const t=this.attachShadow({mode:"open"}),e=`${this._id}-label`,i=!!this.label,s=this.getAttribute("aria-label"),a=i?"":s?`aria-label="${s}"`:"",r=i?`aria-labelledby="${e}"`:"";t.innerHTML=`
|
|
1934
|
+
<style>${kt}</style>
|
|
1520
1935
|
<div class="switch-wrapper size-${this.size}" part="wrapper">
|
|
1521
1936
|
<button
|
|
1522
1937
|
type="button"
|
|
@@ -1531,13 +1946,13 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1531
1946
|
>
|
|
1532
1947
|
<span class="switch-thumb" part="thumb" aria-hidden="true"></span>
|
|
1533
1948
|
</button>
|
|
1534
|
-
${i?`<label id="${
|
|
1949
|
+
${i?`<label id="${e}" class="switch-label ${this.disabled?"disabled":""}" part="label">${this.label}</label>`:""}
|
|
1535
1950
|
</div>
|
|
1536
|
-
`,this._button=
|
|
1537
|
-
<style>${
|
|
1951
|
+
`,this._button=t.querySelector("button"),this._label=t.querySelector("label")}setupEventListeners(){var t,e,i;(t=this._button)==null||t.addEventListener("click",this.handleClick),(e=this._button)==null||e.addEventListener("keydown",this.handleKeyDown),(i=this._label)==null||i.addEventListener("click",this.handleLabelClick)}cleanupEventListeners(){var t,e,i;(t=this._button)==null||t.removeEventListener("click",this.handleClick),(e=this._button)==null||e.removeEventListener("keydown",this.handleKeyDown),(i=this._label)==null||i.removeEventListener("click",this.handleLabelClick)}onAttributeChange(t,e,i){switch(t){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 e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector(".switch-wrapper");t&&(t.classList.remove("size-sm","size-md","size-lg"),t.classList.add(`size-${this.size}`))}toggle(){if(this.disabled)return;this.checked=!this.checked;const t=this.label||this.getAttribute("aria-label")||"Switch";l.announcePolite(`${t} ${this.checked?"on":"off"}`)}setChecked(t){this.checked=t}}g("a11y-switch",P);class H extends p{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 t=Array.from(this.querySelectorAll("option"));this._options=t.map(e=>({value:e.getAttribute("value")||e.textContent||"",label:e.textContent||"",disabled:e.hasAttribute("disabled"),element:e})),this._typeAhead=l.createTypeAhead(this._options.map(e=>e.label),{timeout:500}),this.renderOptions(),this.updateTriggerText()},this.handleTriggerClick=()=>{var t;(t=this._triggerElement)!=null&&t.disabled||(this._open?(this.open=!1,this._highlightedIndex=-1):this.openAndHighlight())},this.handleKeyDown=t=>{var e;switch(t.key){case"ArrowDown":t.preventDefault(),this._open?this.highlightNext():this.openAndHighlight();break;case"ArrowUp":t.preventDefault(),this._open?this.highlightPrevious():this.openAndHighlight(!0);break;case"Enter":if(t.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(t.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":t.preventDefault(),this._open&&(this.open=!1,this._highlightedIndex=-1);break;case"Home":this._open&&(t.preventDefault(),this._highlightedIndex=this.findFirstEnabled(),this.updateHighlight());break;case"End":this._open&&(t.preventDefault(),this._highlightedIndex=this.findLastEnabled(),this.updateHighlight());break;case"Tab":this._open&&(this.open=!1,this._highlightedIndex=-1);break;default:if(t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey){const i=(e=this._typeAhead)==null?void 0:e.type(t.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 t;(t=this.shadowRoot)!=null&&t.activeElement||(this.open=!1,this._highlightedIndex=-1)},150)},this.handleListboxMouseDown=t=>{t.preventDefault()},this.handleOptionClick=t=>{const e=t.currentTarget,i=parseInt(e.dataset.index||"0",10),s=this._options[i];s&&!s.disabled&&this.selectOption(s)},this.handleOptionHover=t=>{const e=t.currentTarget,i=parseInt(e.dataset.index||"0",10),s=this._options[i];s&&!s.disabled&&(this._highlightedIndex=i,this.updateHighlight())},this.handleOutsideClick=t=>{if(!this._open)return;t.composedPath().includes(this)||(this.open=!1,this._highlightedIndex=-1)}}static get observedAttributes(){return["open","value","placeholder","disabled"]}get open(){return this._open}set open(t){const e=this._open;this._open=t,t!==e&&this.updateListboxVisibility(),this.toggleAttribute("open",t)}get value(){return this._selectedValue}set value(t){this._selectedValue=t,this.updateTriggerText(),this.setAttribute("value",t||"")}setupAccessibility(){}render(){const t=this.attachShadow({mode:"open"}),e=`${this._id}-trigger`,i=`${this._id}-listbox`,s=this.getAttribute("placeholder")||"Select an option...",a=this.getAttribute("aria-label")||"",r=this.getAttribute("aria-labelledby")||"";t.innerHTML=`
|
|
1952
|
+
<style>${Et}</style>
|
|
1538
1953
|
<div class="select-wrapper" part="wrapper">
|
|
1539
1954
|
<button
|
|
1540
|
-
id="${
|
|
1955
|
+
id="${e}"
|
|
1541
1956
|
type="button"
|
|
1542
1957
|
role="combobox"
|
|
1543
1958
|
aria-expanded="false"
|
|
@@ -1554,7 +1969,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1554
1969
|
<ul
|
|
1555
1970
|
id="${i}"
|
|
1556
1971
|
role="listbox"
|
|
1557
|
-
aria-labelledby="${
|
|
1972
|
+
aria-labelledby="${e}"
|
|
1558
1973
|
class="listbox"
|
|
1559
1974
|
tabindex="-1"
|
|
1560
1975
|
hidden
|
|
@@ -1564,172 +1979,172 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1564
1979
|
<div class="options-source" hidden>
|
|
1565
1980
|
<slot></slot>
|
|
1566
1981
|
</div>
|
|
1567
|
-
`,this._triggerElement=
|
|
1982
|
+
`,this._triggerElement=t.querySelector(".select-trigger"),this._listboxElement=t.querySelector(".listbox")}setupEventListeners(){var e,i,s,a,r;(e=this._triggerElement)==null||e.addEventListener("click",this.handleTriggerClick),(i=this._triggerElement)==null||i.addEventListener("keydown",this.handleKeyDown),(s=this._triggerElement)==null||s.addEventListener("blur",this.handleBlur),(a=this._listboxElement)==null||a.addEventListener("mousedown",this.handleListboxMouseDown),document.addEventListener("mousedown",this.handleOutsideClick);const t=(r=this.shadowRoot)==null?void 0:r.querySelector("slot");t==null||t.addEventListener("slotchange",this.updateOptions),this.updateOptions()}cleanupEventListeners(){document.removeEventListener("mousedown",this.handleOutsideClick)}onAttributeChange(t,e,i){t==="open"&&(this.open=i!==null),t==="value"&&(this.value=i),t==="disabled"&&this._triggerElement&&(this._triggerElement.disabled=i!==null),t==="placeholder"&&this.updateTriggerText()}renderOptions(){this._listboxElement&&(this._listboxElement.innerHTML=this._options.map((t,e)=>`
|
|
1568
1983
|
<li
|
|
1569
|
-
id="${this._id}-option-${
|
|
1984
|
+
id="${this._id}-option-${e}"
|
|
1570
1985
|
role="option"
|
|
1571
|
-
aria-selected="${this._selectedValue===
|
|
1572
|
-
aria-disabled="${
|
|
1573
|
-
data-value="${
|
|
1574
|
-
data-index="${
|
|
1986
|
+
aria-selected="${this._selectedValue===t.value}"
|
|
1987
|
+
aria-disabled="${t.disabled}"
|
|
1988
|
+
data-value="${t.value}"
|
|
1989
|
+
data-index="${e}"
|
|
1575
1990
|
part="option"
|
|
1576
|
-
${
|
|
1991
|
+
${t.disabled?'class="disabled"':""}
|
|
1577
1992
|
>
|
|
1578
|
-
<span class="option-text">${
|
|
1579
|
-
${this._selectedValue===
|
|
1993
|
+
<span class="option-text">${t.label}</span>
|
|
1994
|
+
${this._selectedValue===t.value?'<span class="check-mark" aria-hidden="true">✓</span>':""}
|
|
1580
1995
|
</li>
|
|
1581
|
-
`).join(""),this._listboxElement.querySelectorAll('[role="option"]').forEach(
|
|
1582
|
-
💡 Suggestion: <a11y-input label="Full Name"></a11y-input>`))}render(){const
|
|
1583
|
-
<style>${
|
|
1996
|
+
`).join(""),this._listboxElement.querySelectorAll('[role="option"]').forEach(t=>{t.addEventListener("click",this.handleOptionClick),t.addEventListener("mouseenter",this.handleOptionHover)}))}openAndHighlight(t=!1){this.open=!0;const e=this._options.findIndex(i=>i.value===this._selectedValue);e>=0?this._highlightedIndex=e:this._highlightedIndex=t?this.findLastEnabled():this.findFirstEnabled(),this.updateHighlight(),l.announce(`${this._options.length} option${this._options.length===1?"":"s"} available`)}selectOption(t){this._selectedValue=t.value,this.updateTriggerText(),this.open=!1,this._highlightedIndex=-1,this.renderOptions(),l.announce(`${t.label} selected`),this.emit("a11y-select-change",{value:t.value,label:t.label}),this.emit("change",{value:t.value,label:t.label})}updateTriggerText(){var s;const t=(s=this.shadowRoot)==null?void 0:s.querySelector(".select-value");if(!t)return;const e=this._options.find(a=>a.value===this._selectedValue),i=this.getAttribute("placeholder")||"Select an option...";e?(t.textContent=e.label,t.classList.remove("placeholder")):(t.textContent=i,t.classList.add("placeholder"))}highlightNext(){const t=this.findNextEnabled(this._highlightedIndex,1);t>=0&&(this._highlightedIndex=t,this.updateHighlight())}highlightPrevious(){const t=this.findNextEnabled(this._highlightedIndex,-1);t>=0&&(this._highlightedIndex=t,this.updateHighlight())}findNextEnabled(t,e){var r;const i=this._options.length;let s=t+e;s<0&&(s=i-1),s>=i&&(s=0);const a=s;for(;(r=this._options[s])!=null&&r.disabled;)if(s+=e,s<0&&(s=i-1),s>=i&&(s=0),s===a)return-1;return s}findFirstEnabled(){return this._options.findIndex(t=>!t.disabled)}findLastEnabled(){var t;for(let e=this._options.length-1;e>=0;e--)if(!((t=this._options[e])!=null&&t.disabled))return e;return-1}updateHighlight(){var t,e,i,s;if((t=this._listboxElement)==null||t.querySelectorAll('[role="option"]').forEach((a,r)=>{a.classList.toggle("highlighted",r===this._highlightedIndex)}),this._highlightedIndex>=0){const a=`${this._id}-option-${this._highlightedIndex}`;(e=this._triggerElement)==null||e.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 t=this._triggerElement.getBoundingClientRect(),e=window.innerHeight,i=Math.min(this._listboxElement.scrollHeight,200),s=e-t.bottom,a=t.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}}g("a11y-select",H);class M extends p{constructor(){super(...arguments),this._value="",this._inputEl=null,this._labelEl=null,this._hintEl=null,this._errorEl=null,this.handleInput=t=>{const e=t.target;this._value=e.value,this.emit("input",{value:this._value})},this.handleChange=t=>{const e=t.target;this._value=e.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(t){const e=this._value;this._value=t,this._inputEl&&this._inputEl.value!==t&&(this._inputEl.value=t),t!==e&&this.setAttribute("value",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t)}get readOnly(){return this.hasAttribute("readonly")}set readOnly(t){this.toggleAttribute("readonly",t)}get required(){return this.hasAttribute("required")}set required(t){this.toggleAttribute("required",t)}get error(){return this.getAttribute("error")||""}set error(t){t?this.setAttribute("error",t):this.removeAttribute("error")}setupAccessibility(){var t;typeof process<"u"&&((t=process.env)==null?void 0:t.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.
|
|
1997
|
+
💡 Suggestion: <a11y-input label="Full Name"></a11y-input>`))}render(){const t=this.attachShadow({mode:"open"}),e=`${this._id}-field`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=this.getAttribute("label")||"",o=this.getAttribute("hint")||"",n=this.getAttribute("error")||"",c=this.getAttribute("type")||"text",b=this.getAttribute("placeholder")||"",u=this.getAttribute("name")||"",m=this.getAttribute("autocomplete")||"",v=this.getAttribute("maxlength"),_=this.getAttribute("minlength"),y=this.getAttribute("pattern"),S=this.getAttribute("inputmode"),T=this.getAttribute("aria-label")||"",C=this.getAttribute("aria-labelledby")||"",z=this.disabled,A=this.readOnly,x=this.required,E=!!n,k=[];o&&k.push(s),E&&k.push(a);const ot=k.length?`aria-describedby="${k.join(" ")}"`:"",$=!r&&T?`aria-label="${T}"`:"",ae=!r&&C?`aria-labelledby="${C}"`:r?`aria-labelledby="${i}"`:"";this.setAttribute("data-error",E?"true":"false"),t.innerHTML=`
|
|
1998
|
+
<style>${wt}</style>
|
|
1584
1999
|
<div class="input-wrapper" part="wrapper">
|
|
1585
|
-
${r?`<label id="${i}" for="${
|
|
1586
|
-
${r}${
|
|
2000
|
+
${r?`<label id="${i}" for="${e}" class="input-label" part="label">
|
|
2001
|
+
${r}${x?'<span class="input-required" aria-hidden="true" part="required">*</span>':""}
|
|
1587
2002
|
</label>`:""}
|
|
1588
2003
|
<input
|
|
1589
|
-
id="${
|
|
1590
|
-
type="${
|
|
2004
|
+
id="${e}"
|
|
2005
|
+
type="${c}"
|
|
1591
2006
|
value="${this._value}"
|
|
1592
2007
|
${b?`placeholder="${b}"`:""}
|
|
1593
|
-
${
|
|
1594
|
-
${
|
|
1595
|
-
${
|
|
1596
|
-
${
|
|
1597
|
-
${
|
|
1598
|
-
${
|
|
1599
|
-
${
|
|
1600
|
-
${
|
|
1601
|
-
${
|
|
1602
|
-
${
|
|
1603
|
-
${
|
|
2008
|
+
${u?`name="${u}"`:""}
|
|
2009
|
+
${m?`autocomplete="${m}"`:""}
|
|
2010
|
+
${v?`maxlength="${v}"`:""}
|
|
2011
|
+
${_?`minlength="${_}"`:""}
|
|
2012
|
+
${y?`pattern="${y}"`:""}
|
|
2013
|
+
${S?`inputmode="${S}"`:""}
|
|
2014
|
+
${$}
|
|
2015
|
+
${ae}
|
|
2016
|
+
${ot}
|
|
2017
|
+
${E?'aria-invalid="true"':""}
|
|
2018
|
+
${x?'aria-required="true"':""}
|
|
1604
2019
|
${z?"disabled":""}
|
|
1605
|
-
${
|
|
2020
|
+
${A?"readonly":""}
|
|
1606
2021
|
part="field"
|
|
1607
2022
|
/>
|
|
1608
|
-
${
|
|
1609
|
-
${
|
|
2023
|
+
${o?`<div id="${s}" class="input-hint" part="hint">${o}</div>`:""}
|
|
2024
|
+
${E?`<div id="${a}" class="input-error" role="alert" part="error">${n}</div>`:""}
|
|
1610
2025
|
</div>
|
|
1611
|
-
`,this._inputEl=
|
|
1612
|
-
💡 Suggestion: <a11y-textarea label="Description"></a11y-textarea>`))}render(){const
|
|
1613
|
-
<style>${
|
|
2026
|
+
`,this._inputEl=t.querySelector("input"),this._labelEl=t.querySelector("label"),this._hintEl=t.querySelector(".input-hint"),this._errorEl=t.querySelector(".input-error");const nt=this.getAttribute("value");nt&&this._inputEl&&(this._value=nt,this._inputEl.value=nt)}setupEventListeners(){var t,e,i,s;(t=this._inputEl)==null||t.addEventListener("input",this.handleInput),(e=this._inputEl)==null||e.addEventListener("change",this.handleChange),(i=this._inputEl)==null||i.addEventListener("focus",this.handleFocus),(s=this._inputEl)==null||s.addEventListener("blur",this.handleBlur)}cleanupEventListeners(){var t,e,i,s;(t=this._inputEl)==null||t.removeEventListener("input",this.handleInput),(e=this._inputEl)==null||e.removeEventListener("change",this.handleChange),(i=this._inputEl)==null||i.removeEventListener("focus",this.handleFocus),(s=this._inputEl)==null||s.removeEventListener("blur",this.handleBlur)}onAttributeChange(t,e,i){switch(t){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(t){var i;const e=!!t;if(this.setAttribute("data-error",e?"true":"false"),this._inputEl&&(e?this._inputEl.setAttribute("aria-invalid","true"):this._inputEl.removeAttribute("aria-invalid")),e){if(this._errorEl)this._errorEl.textContent=t;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=t;const r=(i=this.shadowRoot)==null?void 0:i.querySelector(".input-wrapper");r==null||r.appendChild(a),this._errorEl=a,l.announceAssertive(t)}this.updateAriaDescribedBy()}else this._errorEl&&(this._errorEl.remove(),this._errorEl=null),this.updateAriaDescribedBy()}updateHint(t){var e;if(t)if(this._hintEl)this._hintEl.textContent=t;else{const i=`${this._id}-hint`,s=document.createElement("div");s.id=i,s.className="input-hint",s.setAttribute("part","hint"),s.textContent=t;const a=(e=this.shadowRoot)==null?void 0:e.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 t=[];this._hintEl&&t.push(this._hintEl.id),this._errorEl&&t.push(this._errorEl.id),t.length>0?this._inputEl.setAttribute("aria-describedby",t.join(" ")):this._inputEl.removeAttribute("aria-describedby")}updateRequiredIndicator(t){if(!this._labelEl)return;const e=this._labelEl.querySelector(".input-required");if(t&&!e){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!t&&e&&e.remove()}focus(){var t;(t=this._inputEl)==null||t.focus()}blur(){var t;(t=this._inputEl)==null||t.blur()}select(){var t;(t=this._inputEl)==null||t.select()}}g("a11y-input",M);class B extends p{constructor(){super(...arguments),this._value="",this._textareaEl=null,this._labelEl=null,this._hintEl=null,this._errorEl=null,this.handleInput=t=>{const e=t.target;this._value=e.value,this.emit("input",{value:this._value})},this.handleChange=t=>{const e=t.target;this._value=e.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(t){const e=this._value;this._value=t,this._textareaEl&&this._textareaEl.value!==t&&(this._textareaEl.value=t),t!==e&&this.setAttribute("value",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t)}get readOnly(){return this.hasAttribute("readonly")}set readOnly(t){this.toggleAttribute("readonly",t)}get required(){return this.hasAttribute("required")}set required(t){this.toggleAttribute("required",t)}get error(){return this.getAttribute("error")||""}set error(t){t?this.setAttribute("error",t):this.removeAttribute("error")}setupAccessibility(){var t;typeof process<"u"&&((t=process.env)==null?void 0:t.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.
|
|
2027
|
+
💡 Suggestion: <a11y-textarea label="Description"></a11y-textarea>`))}render(){const t=this.attachShadow({mode:"open"}),e=`${this._id}-field`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=this.getAttribute("label")||"",o=this.getAttribute("hint")||"",n=this.getAttribute("error")||"",c=this.getAttribute("rows")||"3",b=this.getAttribute("placeholder")||"",u=this.getAttribute("name")||"",m=this.getAttribute("autocomplete")||"",v=this.getAttribute("maxlength"),_=this.getAttribute("minlength"),y=this.getAttribute("aria-label")||"",S=this.getAttribute("aria-labelledby")||"",T=this.disabled,C=this.readOnly,z=this.required,A=!!n,x=[];o&&x.push(s),A&&x.push(a);const E=x.length?`aria-describedby="${x.join(" ")}"`:"",k=!r&&y?`aria-label="${y}"`:"",ot=!r&&S?`aria-labelledby="${S}"`:r?`aria-labelledby="${i}"`:"";this.setAttribute("data-error",A?"true":"false"),t.innerHTML=`
|
|
2028
|
+
<style>${St}</style>
|
|
1614
2029
|
<div class="textarea-wrapper" part="wrapper">
|
|
1615
|
-
${r?`<label id="${i}" for="${
|
|
2030
|
+
${r?`<label id="${i}" for="${e}" class="textarea-label" part="label">
|
|
1616
2031
|
${r}${z?'<span class="textarea-required" aria-hidden="true" part="required">*</span>':""}
|
|
1617
2032
|
</label>`:""}
|
|
1618
2033
|
<textarea
|
|
1619
|
-
id="${
|
|
1620
|
-
rows="${
|
|
2034
|
+
id="${e}"
|
|
2035
|
+
rows="${c}"
|
|
1621
2036
|
${b?`placeholder="${b}"`:""}
|
|
1622
|
-
${
|
|
1623
|
-
${
|
|
1624
|
-
${
|
|
1625
|
-
${
|
|
2037
|
+
${u?`name="${u}"`:""}
|
|
2038
|
+
${m?`autocomplete="${m}"`:""}
|
|
2039
|
+
${v?`maxlength="${v}"`:""}
|
|
2040
|
+
${_?`minlength="${_}"`:""}
|
|
2041
|
+
${k}
|
|
2042
|
+
${ot}
|
|
1626
2043
|
${E}
|
|
1627
|
-
${
|
|
1628
|
-
${A}
|
|
1629
|
-
${x?'aria-invalid="true"':""}
|
|
2044
|
+
${A?'aria-invalid="true"':""}
|
|
1630
2045
|
${z?'aria-required="true"':""}
|
|
1631
|
-
${
|
|
1632
|
-
${
|
|
2046
|
+
${T?"disabled":""}
|
|
2047
|
+
${C?"readonly":""}
|
|
1633
2048
|
part="field"
|
|
1634
2049
|
>${this._value}</textarea>
|
|
1635
|
-
${
|
|
1636
|
-
${
|
|
2050
|
+
${o?`<div id="${s}" class="textarea-hint" part="hint">${o}</div>`:""}
|
|
2051
|
+
${A?`<div id="${a}" class="textarea-error" role="alert" part="error">${n}</div>`:""}
|
|
1637
2052
|
</div>
|
|
1638
|
-
`,this._textareaEl=
|
|
1639
|
-
💡 Suggestion: <a11y-button>Click me</a11y-button>`))}render(){const
|
|
1640
|
-
<style>${
|
|
2053
|
+
`,this._textareaEl=t.querySelector("textarea"),this._labelEl=t.querySelector("label"),this._hintEl=t.querySelector(".textarea-hint"),this._errorEl=t.querySelector(".textarea-error");const $=this.getAttribute("value");$&&this._textareaEl&&(this._value=$,this._textareaEl.value=$)}setupEventListeners(){var t,e,i,s;(t=this._textareaEl)==null||t.addEventListener("input",this.handleInput),(e=this._textareaEl)==null||e.addEventListener("change",this.handleChange),(i=this._textareaEl)==null||i.addEventListener("focus",this.handleFocus),(s=this._textareaEl)==null||s.addEventListener("blur",this.handleBlur)}cleanupEventListeners(){var t,e,i,s;(t=this._textareaEl)==null||t.removeEventListener("input",this.handleInput),(e=this._textareaEl)==null||e.removeEventListener("change",this.handleChange),(i=this._textareaEl)==null||i.removeEventListener("focus",this.handleFocus),(s=this._textareaEl)==null||s.removeEventListener("blur",this.handleBlur)}onAttributeChange(t,e,i){switch(t){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(t){var i;const e=!!t;if(this.setAttribute("data-error",e?"true":"false"),this._textareaEl&&(e?this._textareaEl.setAttribute("aria-invalid","true"):this._textareaEl.removeAttribute("aria-invalid")),e){if(this._errorEl)this._errorEl.textContent=t;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=t;const r=(i=this.shadowRoot)==null?void 0:i.querySelector(".textarea-wrapper");r==null||r.appendChild(a),this._errorEl=a,l.announceAssertive(t)}this.updateAriaDescribedBy()}else this._errorEl&&(this._errorEl.remove(),this._errorEl=null),this.updateAriaDescribedBy()}updateHint(t){var e;if(t)if(this._hintEl)this._hintEl.textContent=t;else{const i=`${this._id}-hint`,s=document.createElement("div");s.id=i,s.className="textarea-hint",s.setAttribute("part","hint"),s.textContent=t;const a=(e=this.shadowRoot)==null?void 0:e.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 t=[];this._hintEl&&t.push(this._hintEl.id),this._errorEl&&t.push(this._errorEl.id),t.length>0?this._textareaEl.setAttribute("aria-describedby",t.join(" ")):this._textareaEl.removeAttribute("aria-describedby")}updateRequiredIndicator(t){if(!this._labelEl)return;const e=this._labelEl.querySelector(".textarea-required");if(t&&!e){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!t&&e&&e.remove()}focus(){var t;(t=this._textareaEl)==null||t.focus()}blur(){var t;(t=this._textareaEl)==null||t.blur()}select(){var t;(t=this._textareaEl)==null||t.select()}}g("a11y-textarea",B);class F extends p{constructor(){super(...arguments),this._buttonEl=null,this.handleClick=t=>{if(this.disabled||this.loading){t.preventDefault(),t.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(t){this.toggleAttribute("disabled",t)}get discoverable(){return this.hasAttribute("discoverable")}set discoverable(t){this.toggleAttribute("discoverable",t)}get loading(){return this.hasAttribute("loading")}set loading(t){this.toggleAttribute("loading",t)}get variant(){return this.getAttribute("variant")||"secondary"}set variant(t){this.setAttribute("variant",t)}get size(){return this.getAttribute("size")||"md"}set size(t){this.setAttribute("size",t)}setupAccessibility(){var t,e;typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)!=="production"&&((e=this.textContent)!=null&&e.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.
|
|
2054
|
+
💡 Suggestion: <a11y-button>Click me</a11y-button>`))}render(){const t=this.attachShadow({mode:"open"}),e=this.variant,i=this.size,s=this.getAttribute("type")||"button",a=this.getAttribute("aria-label")||"",r=this.disabled,o=this.discoverable,n=this.loading,c=r||n,b=r&&!o;t.innerHTML=`
|
|
2055
|
+
<style>${$t}</style>
|
|
1641
2056
|
<button
|
|
1642
|
-
class="variant-${
|
|
2057
|
+
class="variant-${e} size-${i}"
|
|
1643
2058
|
type="${s}"
|
|
1644
2059
|
${b?"disabled":""}
|
|
1645
|
-
${
|
|
2060
|
+
${c?'aria-disabled="true"':""}
|
|
1646
2061
|
${n?'aria-busy="true"':""}
|
|
1647
2062
|
${a?`aria-label="${a}"`:""}
|
|
1648
2063
|
part="button"
|
|
1649
2064
|
>${n?'<span class="button-spinner" aria-hidden="true" part="spinner"></span>':""}<slot></slot></button>
|
|
1650
|
-
`,this._buttonEl=
|
|
1651
|
-
<style>${
|
|
2065
|
+
`,this._buttonEl=t.querySelector("button")}setupEventListeners(){var t;(t=this._buttonEl)==null||t.addEventListener("click",this.handleClick)}cleanupEventListeners(){var t;(t=this._buttonEl)==null||t.removeEventListener("click",this.handleClick)}onAttributeChange(t,e,i){switch(t){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 t=this.disabled,e=this.discoverable,i=this.loading,s=t&&!e,a=t||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 e=document.createElement("span");e.className="button-spinner",e.setAttribute("aria-hidden","true"),e.setAttribute("part","spinner"),this._buttonEl.insertBefore(e,this._buttonEl.firstChild)}}else{this._buttonEl.removeAttribute("aria-busy");const e=this._buttonEl.querySelector(".button-spinner");e==null||e.remove(),this.updateDisabledState()}}focus(){var t;(t=this._buttonEl)==null||t.focus()}blur(){var t;(t=this._buttonEl)==null||t.blur()}click(){var t;(t=this._buttonEl)==null||t.click()}}g("a11y-button",F);class K extends p{constructor(){super(...arguments),this._label="",this._disabled=!1}static get observedAttributes(){return["label","disabled"]}get label(){return this._label}set label(t){this._label=t,this.setAttribute("label",t),this.updateLabel()}get disabled(){return this._disabled}set disabled(t){const e=!!t;this._disabled!==e&&(this._disabled=e,e?(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 t=`${this._id}-label`;this.shadowRoot.innerHTML=`
|
|
2066
|
+
<style>${Tt}</style>
|
|
1652
2067
|
<div class="optgroup-wrapper" part="group">
|
|
1653
|
-
<div class="optgroup-label" part="label" id="${
|
|
2068
|
+
<div class="optgroup-label" part="label" id="${t}" role="presentation">
|
|
1654
2069
|
${this._label}
|
|
1655
2070
|
</div>
|
|
1656
2071
|
<div class="optgroup-options" part="options" role="none">
|
|
1657
2072
|
<slot></slot>
|
|
1658
2073
|
</div>
|
|
1659
2074
|
</div>
|
|
1660
|
-
`,this.setAttribute("aria-labelledby",
|
|
1661
|
-
<style>${
|
|
2075
|
+
`,this.setAttribute("aria-labelledby",t)}setupEventListeners(){}cleanupEventListeners(){}updateLabel(){var e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector(".optgroup-label");t&&(t.textContent=this._label)}onAttributeChange(t,e,i){switch(t){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 j extends p{constructor(){super(...arguments),this._value="",this._disabled=!1,this._selected=!1,this._discoverable=!0,this.handleClick=t=>{if(this.effectivelyDisabled){t.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(t){this._value=t,this.setAttribute("value",t)}get disabled(){return this._disabled}set disabled(t){const e=!!t;this._disabled!==e&&(this._disabled=e,e?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get selected(){return this._selected}set selected(t){const e=!!t;this._selected!==e&&(this._selected=e,this.setAttribute("aria-selected",String(e)))}get discoverable(){return this._discoverable}set discoverable(t){this._discoverable=!!t}get effectivelyDisabled(){if(this._disabled)return!0;const t=this.closest("a11y-optgroup");return(t==null?void 0:t.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 t=this.getAttribute("discoverable");(t==="false"||t==="0")&&(this._discoverable=!1)}render(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
|
|
2076
|
+
<style>${It}</style>
|
|
1662
2077
|
<div class="option-wrapper" part="option">
|
|
1663
2078
|
<span class="option-content" part="content"><slot></slot></span>
|
|
1664
2079
|
<span class="check-mark" part="check" aria-hidden="true">✓</span>
|
|
1665
2080
|
</div>
|
|
1666
|
-
`}setupEventListeners(){this.addEventListener("click",this.handleClick)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick)}onAttributeChange(e,
|
|
1667
|
-
<style>${
|
|
2081
|
+
`}setupEventListeners(){this.addEventListener("click",this.handleClick)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick)}onAttributeChange(t,e,i){switch(t){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 N extends p{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 t=this.getAllOptions();if(!this._multiple&&this._value){const e=t.findIndex(i=>i.value===this._value);if(e>=0){this._focusedIndex=e,this.updateFocusHighlight();return}}else if(this._multiple&&this._values.size>0){const e=t.findIndex(i=>this._values.has(i.value));if(e>=0){this._focusedIndex=e,this.updateFocusHighlight();return}}this._focusedIndex=this.findFirstEnabled(),this.updateFocusHighlight()},this.handleOptionSelect=t=>{var r;if(this._disabled)return;const e=(r=t.detail)==null?void 0:r.value;if(e===void 0)return;const i=this.getAllOptions(),s=i.find(o=>o.value===e);if(!s)return;const a=i.indexOf(s);this._focusedIndex=a,this.updateFocusHighlight(),this.selectOption(s),this.focus()},this.handleKeyDown=t=>{var a,r,o;if(this._disabled&&!this._discoverable)return;const e=this.getAllOptions();if(e.length===0)return;let i=null,s=!1;if(this._multiple)switch(t.key){case"ArrowDown":t.shiftKey?(i=this.findNextEnabled(this._focusedIndex,1),i>=0&&this.toggleOptionSelection(e[i])):i=this.findNextEnabled(this._focusedIndex,1),s=!0;break;case"ArrowUp":t.shiftKey?(i=this.findNextEnabled(this._focusedIndex,-1),i>=0&&this.toggleOptionSelection(e[i])):i=this.findNextEnabled(this._focusedIndex,-1),s=!0;break;case" ":this._focusedIndex>=0&&e[this._focusedIndex]!=null&&this.toggleOptionSelection(e[this._focusedIndex]),s=!0;break;case"Home":t.ctrlKey&&t.shiftKey?(this.selectRange(this.findFirstEnabled(),this._focusedIndex),i=this.findFirstEnabled()):i=this.findFirstEnabled(),s=!0;break;case"End":t.ctrlKey&&t.shiftKey?(this.selectRange(this._focusedIndex,this.findLastEnabled()),i=this.findLastEnabled()):i=this.findLastEnabled(),s=!0;break;case"a":(t.ctrlKey||t.metaKey)&&(this.toggleSelectAll(),s=!0);break;default:if(t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey){const n=(a=this._typeAhead)==null?void 0:a.type(t.key);if(n){const c=e.findIndex(b=>{var u;return(((u=b.textContent)==null?void 0:u.trim())||"")===n&&!b.effectivelyDisabled});c>=0&&(i=c,s=!0)}}break}else switch(t.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(t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey){const n=(r=this._typeAhead)==null?void 0:r.type(t.key);if(n){const c=e.findIndex(b=>{var u;return(((u=b.textContent)==null?void 0:u.trim())||"")===n&&!b.effectivelyDisabled});c>=0&&(i=c,s=!0)}}break}if(s&&(t.preventDefault(),t.stopPropagation()),i!==null&&i>=0){this._focusedIndex=i,this.updateFocusHighlight();const n=e[i];if(!this._multiple&&n)this.selectSingle(n);else if(n){const c=((o=n.textContent)==null?void 0:o.trim())||n.value,b=this._values.has(n.value);l.announcePolite(`${c}${b?", 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(t){if(this._multiple){const e=Array.isArray(t)?t:String(t).split(",").filter(Boolean);this._values=new Set(e),this.setAttribute("value",e.join(","))}else{const e=Array.isArray(t)?t[0]||"":String(t);this._value=e,this.setAttribute("value",e)}this.syncOptionStates()}get multiple(){return this._multiple}set multiple(t){const e=!!t;this._multiple!==e&&(this._multiple=e,e?(this.setAttribute("multiple",""),this.setAttribute("aria-multiselectable","true")):(this.removeAttribute("multiple"),this.removeAttribute("aria-multiselectable")))}get disabled(){return this._disabled}set disabled(t){const e=!!t;this._disabled!==e&&(this._disabled=e,e?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get discoverable(){return this._discoverable}set discoverable(t){this._discoverable=!!t}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.setAttribute("orientation",t),this.setAttribute("aria-orientation",t)}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 e=this.getAttribute("orientation");(e==="horizontal"||e==="vertical")&&(this._orientation=e);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=`
|
|
2082
|
+
<style>${Lt}</style>
|
|
1668
2083
|
<div class="listbox-wrapper" part="wrapper">
|
|
1669
2084
|
<slot></slot>
|
|
1670
2085
|
</div>
|
|
1671
|
-
`}setupEventListeners(){var
|
|
2086
|
+
`}setupEventListeners(){var e;this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("focus",this.handleFocus),this.addEventListener("option-select",this.handleOptionSelect);const t=(e=this.shadowRoot)==null?void 0:e.querySelector("slot");t&&t.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(t=>!t.effectivelyDisabled)}getEnabledIndices(){const t=this.getAllOptions(),e=[];return t.forEach((i,s)=>{i.effectivelyDisabled||e.push(s)}),e}syncOptionStates(){this.getAllOptions().forEach(e=>{this._multiple?e.selected=this._values.has(e.value):e.selected=e.value===this._value})}updateFocusHighlight(){const t=this.getAllOptions();t.forEach((i,s)=>{s===this._focusedIndex?i.toggleAttribute("data-focused",!0):i.removeAttribute("data-focused")});const e=this._focusedIndex>=0?t[this._focusedIndex]:void 0;e?(this.setAttribute("aria-activedescendant",e.id),e.scrollIntoView({block:"nearest"})):this.removeAttribute("aria-activedescendant")}findNextEnabled(t,e){const i=this.getEnabledIndices();if(i.length===0)return-1;const s=i.indexOf(t);if(s===-1)return e===1?i[0]:i[i.length-1];const a=s+e;return a<0||a>=i.length?-1:i[a]}findFirstEnabled(){const t=this.getEnabledIndices();return t.length>0?t[0]:-1}findLastEnabled(){const t=this.getEnabledIndices();return t.length>0?t[t.length-1]:-1}selectOption(t){t.effectivelyDisabled||this._disabled||(this._multiple?this.toggleOptionSelection(t):this.selectSingle(t))}selectSingle(t){var i;const e=this._value;if(this._value=t.value,this.setAttribute("value",t.value),this.syncOptionStates(),e!==this._value){const s=((i=t.textContent)==null?void 0:i.trim())||t.value;this.emit("change",{value:this._value,label:s}),this.emit("a11y-listbox-change",{value:this._value,label:s}),l.announcePolite(`${s} selected`)}}toggleOptionSelection(t){var s;if(t.effectivelyDisabled||this._disabled)return;const e=((s=t.textContent)==null?void 0:s.trim())||t.value;this._values.has(t.value)?(this._values.delete(t.value),t.selected=!1,l.announcePolite(`${e} deselected`)):(this._values.add(t.value),t.selected=!0,l.announcePolite(`${e} 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(t,e){const i=this.getAllOptions(),s=Math.min(t,e),a=Math.max(t,e);for(let o=s;o<=a;o++){const n=i[o];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}),l.announcePolite(`${a-s+1} items selected`)}toggleSelectAll(){const t=this.getEnabledOptions();t.every(s=>this._values.has(s.value))?(this._values.clear(),this.getAllOptions().forEach(s=>s.selected=!1),l.announcePolite("All deselected")):(t.forEach(s=>{this._values.add(s.value),s.selected=!0}),l.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 t=this.getAllOptions().map(e=>{var i;return((i=e.textContent)==null?void 0:i.trim())||""});this._typeAhead=l.createTypeAhead(t,{timeout:500})}onAttributeChange(t,e,i){switch(t){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}}}g("a11y-optgroup",K),g("a11y-option",j),g("a11y-listbox",N);const Ft=`<svg class="checkbox-check" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
|
1672
2087
|
<path d="M2.5 6L5 8.5L9.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1673
|
-
</svg>`,
|
|
2088
|
+
</svg>`,Kt=`<svg class="checkbox-dash" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
|
1674
2089
|
<path d="M3 6H9" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
1675
|
-
</svg>`;class I extends
|
|
1676
|
-
💡 Suggestion: <a11y-checkbox label="Accept terms"></a11y-checkbox>`)}render(){const
|
|
1677
|
-
<style>${
|
|
2090
|
+
</svg>`;class I extends p{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 t=this.label||this.getAttribute("aria-label")||"Checkbox";l.announcePolite(`${t} ${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(t){const e=this._checked;this._checked=t,this.toggleAttribute("checked",t),t!==e&&(this.updateVisualState(),this.emit("change",{checked:t,value:this.value}))}get indeterminate(){return this._indeterminate}set indeterminate(t){const e=this._indeterminate;this._indeterminate=t,this.toggleAttribute("indeterminate",t),t!==e&&this.updateVisualState()}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t),this.updateDisabledState()}get value(){return this.getAttribute("value")||""}set value(t){t?this.setAttribute("value",t):this.removeAttribute("value")}get label(){return this.getAttribute("label")||""}set label(t){t?this.setAttribute("label",t):this.removeAttribute("label")}get hint(){return this.getAttribute("hint")||""}set hint(t){t?this.setAttribute("hint",t):this.removeAttribute("hint")}get error(){return this.getAttribute("error")||""}set error(t){t?this.setAttribute("error",t):this.removeAttribute("error")}get size(){const t=this.getAttribute("size");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get required(){return this.hasAttribute("required")}set required(t){this.toggleAttribute("required",t)}setupAccessibility(){var t;this._checked=this.hasAttribute("checked"),this._indeterminate=this.hasAttribute("indeterminate"),typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)!=="production"&&!this.label&&!this.getAttribute("aria-label")&&console.warn(`[compa11y/Checkbox] Checkbox has no accessible label. Add label="..." or aria-label="..." attribute.
|
|
2091
|
+
💡 Suggestion: <a11y-checkbox label="Accept terms"></a11y-checkbox>`)}render(){const t=this.attachShadow({mode:"open"}),e=`${this._id}-input`,i=`${this._id}-label`,s=`${this._id}-hint`,a=`${this._id}-error`,r=!!this.label,o=!!this.hint,n=!!this.error,c=this.getAttribute("aria-label"),b=this.getAttribute("name")||"",u=this.getAttribute("aria-describedby")||"",m=[];u&&m.push(u),o&&m.push(s),n&&m.push(a);const v=m.length?`aria-describedby="${m.join(" ")}"`:"",_=!r&&c?`aria-label="${c}"`:"";t.innerHTML=`
|
|
2092
|
+
<style>${Ct}</style>
|
|
1678
2093
|
<div class="checkbox-wrapper size-${this.size}" part="wrapper">
|
|
1679
2094
|
<div class="checkbox-control">
|
|
1680
2095
|
<input
|
|
1681
2096
|
type="checkbox"
|
|
1682
2097
|
class="checkbox-input"
|
|
1683
|
-
id="${
|
|
2098
|
+
id="${e}"
|
|
1684
2099
|
${b?`name="${b}"`:""}
|
|
1685
2100
|
${this.value?`value="${this.value}"`:""}
|
|
1686
2101
|
${this._checked?"checked":""}
|
|
1687
2102
|
${this.disabled?"disabled":""}
|
|
1688
2103
|
${this.required?'required aria-required="true"':""}
|
|
1689
|
-
${
|
|
1690
|
-
${
|
|
2104
|
+
${v}
|
|
2105
|
+
${_}
|
|
1691
2106
|
${n?'aria-invalid="true"':""}
|
|
1692
2107
|
part="input"
|
|
1693
2108
|
/>
|
|
1694
2109
|
<div class="checkbox-indicator" part="indicator" aria-hidden="true">
|
|
1695
|
-
${
|
|
1696
|
-
${
|
|
2110
|
+
${Ft}
|
|
2111
|
+
${Kt}
|
|
1697
2112
|
</div>
|
|
1698
2113
|
</div>
|
|
1699
|
-
${r||
|
|
1700
|
-
${r?`<label for="${
|
|
1701
|
-
${
|
|
2114
|
+
${r||o||n?`<div class="checkbox-content">
|
|
2115
|
+
${r?`<label for="${e}" id="${i}" class="checkbox-label" part="label">${this.label}${this.required?'<span class="checkbox-required" aria-hidden="true">*</span>':""}</label>`:""}
|
|
2116
|
+
${o?`<div id="${s}" class="checkbox-hint" part="hint">${this.hint}</div>`:""}
|
|
1702
2117
|
${n?`<div id="${a}" class="checkbox-error" role="alert" part="error">${this.error}</div>`:""}
|
|
1703
2118
|
</div>`:""}
|
|
1704
2119
|
</div>
|
|
1705
|
-
`,this._input=
|
|
1706
|
-
💡 Suggestion: <a11y-checkbox-group legend="Select options"></a11y-checkbox-group>`),this.initValueFromChildren()}render(){const
|
|
1707
|
-
<style>${
|
|
2120
|
+
`,this._input=t.querySelector("input"),this._input&&this._indeterminate&&(this._input.indeterminate=!0)}setupEventListeners(){var t;(t=this._input)==null||t.addEventListener("change",this.handleChange)}cleanupEventListeners(){var t;(t=this._input)==null||t.removeEventListener("change",this.handleChange)}onAttributeChange(t,e,i){switch(t){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 e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector(".checkbox-wrapper");t&&(t.classList.remove("size-sm","size-md","size-lg"),t.classList.add(`size-${this.size}`))}toggle(){if(this.disabled)return;this._indeterminate?(this.indeterminate=!1,this.checked=!0):this.checked=!this.checked;const t=this.label||this.getAttribute("aria-label")||"Checkbox";l.announcePolite(`${t} ${this.checked?"checked":"unchecked"}`)}setChecked(t){this.checked=t}}class Y extends p{constructor(){super(...arguments),this._value=[],this.handleChildChange=t=>{const e=t.target;if(!(e instanceof I)||e===this)return;const i=e.value;i&&(e.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(t){this._value=[...t],this.syncCheckboxStates()}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t),this.syncDisabledState()}get legend(){return this.getAttribute("legend")||""}set legend(t){t?this.setAttribute("legend",t):this.removeAttribute("legend")}get error(){return this.getAttribute("error")||""}set error(t){t?this.setAttribute("error",t):this.removeAttribute("error")}get orientation(){return this.getAttribute("orientation")==="horizontal"?"horizontal":"vertical"}set orientation(t){this.setAttribute("orientation",t)}setupAccessibility(){var t;typeof process<"u"&&((t=process.env)==null?void 0:t.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.
|
|
2121
|
+
💡 Suggestion: <a11y-checkbox-group legend="Select options"></a11y-checkbox-group>`),this.initValueFromChildren()}render(){const t=this.attachShadow({mode:"open"}),e=`${this._id}-error`,i=!!this.legend,s=!!this.error,a=this.getAttribute("aria-label"),r=this.getAttribute("aria-labelledby");t.innerHTML=`
|
|
2122
|
+
<style>${zt}</style>
|
|
1708
2123
|
<fieldset
|
|
1709
2124
|
part="fieldset"
|
|
1710
2125
|
${a?`aria-label="${a}"`:""}
|
|
1711
2126
|
${r?`aria-labelledby="${r}"`:""}
|
|
1712
|
-
${s?`aria-describedby="${
|
|
2127
|
+
${s?`aria-describedby="${e}"`:""}
|
|
1713
2128
|
${this.disabled?"disabled":""}
|
|
1714
2129
|
>
|
|
1715
2130
|
${i?`<legend part="legend">${this.legend}</legend>`:""}
|
|
1716
2131
|
<div class="checkbox-group-items" part="items">
|
|
1717
2132
|
<slot></slot>
|
|
1718
2133
|
</div>
|
|
1719
|
-
${s?`<div id="${
|
|
2134
|
+
${s?`<div id="${e}" class="checkbox-group-error" role="alert" part="error">${this.error}</div>`:""}
|
|
1720
2135
|
</fieldset>
|
|
1721
|
-
`}setupEventListeners(){this.addEventListener("change",this.handleChildChange)}cleanupEventListeners(){this.removeEventListener("change",this.handleChildChange)}onAttributeChange(e,
|
|
1722
|
-
<style>${
|
|
2136
|
+
`}setupEventListeners(){this.addEventListener("change",this.handleChildChange)}cleanupEventListeners(){this.removeEventListener("change",this.handleChildChange)}onAttributeChange(t,e,i){switch(t){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 t=this.querySelectorAll("a11y-checkbox"),e=[];t.forEach(i=>{i.hasAttribute("checked")&&i.getAttribute("value")&&e.push(i.getAttribute("value"))}),this._value=e})}syncCheckboxStates(){this.querySelectorAll("a11y-checkbox").forEach(e=>{const i=e.value;i&&(e.checked=this._value.includes(i))})}syncDisabledState(){var e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector("fieldset");t&&(this.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"))}}g("a11y-checkbox",I),g("a11y-checkbox-group",Y);class U extends p{constructor(){super(...arguments),this._value="",this._disabled=!1,this._discoverable=!0,this._orientation="vertical",this._required=!1,this._name="",this.handleRadioSelect=t=>{var i;if(this._disabled)return;const e=(i=t.detail)==null?void 0:i.value;e!==void 0&&this.selectRadio(e)},this.handleKeyDown=t=>{if(this._disabled)return;const e=this.getEnabledRadios();if(e.length===0)return;const i=e.findIndex(a=>a.value===this._value);let s=null;switch(t.key){case"ArrowDown":case"ArrowRight":s=i<0?0:(i+1)%e.length;break;case"ArrowUp":case"ArrowLeft":s=i<0?e.length-1:(i-1+e.length)%e.length;break;case"Home":s=0;break;case"End":s=e.length-1;break;case" ":t.preventDefault(),t.stopPropagation();{const a=e.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;l.announcePolite(`${r} selected`)}}return;default:return}if(s!==null){t.preventDefault(),t.stopPropagation();const a=e[s];if(a){this.selectRadio(a.value),a.focus();const r=a.getAttribute("label")||a.value;l.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(t){this._value!==t&&(this._value=t,this.setAttribute("value",t),this.syncRadioStates())}get disabled(){return this._disabled}set disabled(t){const e=!!t;this._disabled!==e&&(this._disabled=e,e?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")),this.syncRadioStates())}get discoverable(){return this._discoverable}set discoverable(t){this._discoverable=!!t}get required(){return this._required}set required(t){this._required=!!t,this._required?this.setAttribute("aria-required","true"):this.removeAttribute("aria-required")}get name(){return this._name}set name(t){this._name=t,this.setAttribute("name",t)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.setAttribute("orientation",t),this.setAttribute("aria-orientation",t)}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 e=this.getAttribute("value");e&&(this._value=e),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 t=this.shadowRoot,e=this.getAttribute("legend")||"",i=this.getAttribute("hint")||"",s=this.getAttribute("error")||"",a=i?`${this._id}-hint`:"",r=s?`${this._id}-error`:"",o=[a,r].filter(Boolean).join(" ");o?this.setAttribute("aria-describedby",o):this.removeAttribute("aria-describedby"),t.innerHTML=`
|
|
2137
|
+
<style>${Dt}</style>
|
|
1723
2138
|
<fieldset part="fieldset">
|
|
1724
|
-
${
|
|
2139
|
+
${e?`<legend part="legend">${e}${this._required?'<span class="radio-group-required" aria-hidden="true"> *</span>':""}</legend>`:""}
|
|
1725
2140
|
<div class="radio-group-items" part="items">
|
|
1726
2141
|
<slot></slot>
|
|
1727
2142
|
</div>
|
|
1728
2143
|
${i?`<div class="radio-group-hint" id="${a}" part="hint">${i}</div>`:""}
|
|
1729
2144
|
${s?`<div class="radio-group-error" id="${r}" part="error" role="alert">${s}</div>`:""}
|
|
1730
2145
|
</fieldset>
|
|
1731
|
-
`}setupEventListeners(){var
|
|
1732
|
-
<style>${
|
|
2146
|
+
`}setupEventListeners(){var e;this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("radio-select",this.handleRadioSelect);const t=(e=this.shadowRoot)==null?void 0:e.querySelector("slot");t&&t.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(t=>!t.disabled&&!this._disabled)}syncRadioStates(){const t=this.getRadios(),e=this.getEnabledRadios();t.forEach(i=>{const s=i.value===this._value;i.checked=s,s||!this._value&&e[0]===i?i.setAttribute("tabindex","0"):i.setAttribute("tabindex","-1")})}selectRadio(t){this._disabled||(this._value=t,this.setAttribute("value",t),this.syncRadioStates(),this.hasAttribute("aria-invalid")&&this.removeAttribute("aria-invalid"),this.emit("change",{value:t}),this.emit("a11y-radiogroup-change",{value:t}))}attributeChangedCallback(t,e,i){if(e!==i)switch(t){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 p{constructor(){super(...arguments),this._value="",this._checked=!1,this._disabled=!1,this._discoverable=!0,this.handleClick=t=>{if(this._disabled){t.preventDefault();return}this.dispatchEvent(new CustomEvent("radio-select",{detail:{value:this._value},bubbles:!0,composed:!0}));const e=this.getAttribute("label")||this._value;l.announcePolite(`${e} selected`)},this.handleKeyDown=t=>{if(!this._disabled&&t.key==="Enter"){t.preventDefault(),this.dispatchEvent(new CustomEvent("radio-select",{detail:{value:this._value},bubbles:!0,composed:!0}));const e=this.getAttribute("label")||this._value;l.announcePolite(`${e} selected`)}}}static get observedAttributes(){return["value","label","hint","disabled","discoverable","checked"]}get value(){return this._value}set value(t){this._value=t,this.setAttribute("value",t)}get checked(){return this._checked}set checked(t){const e=!!t;this._checked!==e&&(this._checked=e,e?this.setAttribute("checked",""):this.removeAttribute("checked"),this.setAttribute("aria-checked",String(e)),this.updateVisual())}get disabled(){return this._disabled}set disabled(t){const e=!!t;this._disabled!==e&&(this._disabled=e,e?(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true")):(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")))}get discoverable(){return this._discoverable}set discoverable(t){let e;typeof t=="string"?e=t!=="false"&&t!=="0":e=!!t,this._discoverable!==e&&(this._discoverable=e,e?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 t=this.getAttribute("discoverable");(t==="false"||t==="0")&&(this._discoverable=!1),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1")}render(){this.shadowRoot||this.attachShadow({mode:"open"});const t=this.shadowRoot,e=this.getAttribute("label")||"",i=this.getAttribute("hint")||"",s=e?`${this._id}-label`:"",a=i?`${this._id}-hint`:"";s&&this.setAttribute("aria-labelledby",s),a&&this.setAttribute("aria-describedby",a),t.innerHTML=`
|
|
2147
|
+
<style>${qt}</style>
|
|
1733
2148
|
<div class="radio-wrapper" part="wrapper">
|
|
1734
2149
|
<div class="radio-control" part="control">
|
|
1735
2150
|
<input
|
|
@@ -1743,14 +2158,14 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1743
2158
|
<div class="radio-dot" part="dot" aria-hidden="true"></div>
|
|
1744
2159
|
</div>
|
|
1745
2160
|
</div>
|
|
1746
|
-
${
|
|
1747
|
-
${
|
|
2161
|
+
${e||i?`<div class="radio-content">
|
|
2162
|
+
${e?`<span class="radio-label" id="${s}" part="label">${e}</span>`:""}
|
|
1748
2163
|
${i?`<span class="radio-hint" id="${a}" part="hint">${i}</span>`:""}
|
|
1749
2164
|
</div>`:""}
|
|
1750
2165
|
<slot></slot>
|
|
1751
2166
|
</div>
|
|
1752
|
-
`}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
|
|
1753
|
-
<style>${
|
|
2167
|
+
`}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 t=this.shadowRoot.querySelector(".radio-dot");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"scale(1)":"scale(0)");const e=this.shadowRoot.querySelector(".radio-circle");e&&(this._checked?(e.style.background="var(--compa11y-radio-checked-bg, #0066cc)",e.style.borderColor="var(--compa11y-radio-checked-border, #0066cc)"):(e.style.background="var(--compa11y-radio-bg, white)",e.style.borderColor=""))}attributeChangedCallback(t,e,i){if(e!==i)switch(t){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}}}g("a11y-radio-group",U),g("a11y-radio",G);class V extends p{constructor(){super(...arguments),this._toasts=[],this._counter=0,this._containerEl=null,this._maxToasts=5,this._handleClick=t=>{var a;const e=t.target,i=e.getAttribute("data-close-id");if(i){this.removeToast(i);return}const s=e.getAttribute("data-action-id");if(s){const r=this._toasts.find(o=>o.id===s);(a=r==null?void 0:r.action)==null||a.onClick(),this.removeToast(s)}}}static get observedAttributes(){return["position","duration","max-toasts","label"]}get position(){return this.getAttribute("position")||"bottom-right"}get duration(){const t=this.getAttribute("duration");return t?parseInt(t,10):5e3}get maxToasts(){const t=this.getAttribute("max-toasts");return t?parseInt(t,10):5}get label(){return this.getAttribute("label")||"Notifications"}setupAccessibility(){}render(){const t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
2168
|
+
<style>${Ot}</style>
|
|
1754
2169
|
<div
|
|
1755
2170
|
class="toast-container"
|
|
1756
2171
|
role="region"
|
|
@@ -1758,10 +2173,10 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1758
2173
|
aria-live="polite"
|
|
1759
2174
|
aria-relevant="additions removals"
|
|
1760
2175
|
></div>
|
|
1761
|
-
`,this._containerEl=
|
|
2176
|
+
`,this._containerEl=t.querySelector(".toast-container")}setupEventListeners(){var t;(t=this._containerEl)==null||t.addEventListener("click",this._handleClick)}cleanupEventListeners(){var t;(t=this._containerEl)==null||t.removeEventListener("click",this._handleClick);for(const e of this._toasts)e.timerId&&clearTimeout(e.timerId);this._toasts=[]}onAttributeChange(t,e,i){t==="max-toasts"&&i&&(this._maxToasts=parseInt(i,10)),t==="label"&&this._containerEl&&this._containerEl.setAttribute("aria-label",i||"Notifications")}add(t){const e=`toast-${++this._counter}`,i=t.duration??this.duration,s={id:e,type:t.type||"info",title:t.title,description:t.description,duration:i,action:t.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:e,...t}),e}removeToast(t){const e=this._toasts.findIndex(s=>s.id===t);if(e===-1)return;const i=this._toasts[e];i&&i.timerId&&clearTimeout(i.timerId),this._toasts.splice(e,1),this._removeElement(t),this.emit("a11y-toast-remove",{id:t})}clear(){for(const t of this._toasts)t.timerId&&clearTimeout(t.timerId);this._toasts=[],this._containerEl&&(this._containerEl.innerHTML="")}_renderToast(t){if(!this._containerEl)return;const e=t.type==="error"||t.type==="warning",i=document.createElement("div");i.className="toast",i.setAttribute("data-toast-id",t.id),i.setAttribute("data-type",t.type),i.setAttribute("role",e?"alert":"status"),i.setAttribute("aria-atomic","true"),i.setAttribute("tabindex","0");let s='<div class="toast-content">';t.title&&(s+=`<div class="toast-title">${this._escapeHtml(t.title)}</div>`),t.description&&(s+=`<div class="toast-description">${this._escapeHtml(t.description)}</div>`),t.action&&(s+=`<button type="button" class="toast-action" data-action-id="${t.id}" tabindex="0">${this._escapeHtml(t.action.label)}</button>`),s+="</div>",s+=`<button type="button" class="toast-close" aria-label="Dismiss" data-close-id="${t.id}" tabindex="0">×</button>`,i.innerHTML=s,i.addEventListener("mouseenter",()=>this._pauseTimer(t)),i.addEventListener("mouseleave",()=>this._resumeTimer(t)),i.addEventListener("keydown",a=>{a.key==="Escape"&&this.removeToast(t.id)}),this._containerEl.appendChild(i)}_removeElement(t){var i;const e=(i=this._containerEl)==null?void 0:i.querySelector(`[data-toast-id="${t}"]`);e==null||e.remove()}_startTimer(t){t.duration!==0&&(t.startTime=Date.now(),t.timerId=setTimeout(()=>{this.removeToast(t.id)},t.remaining))}_pauseTimer(t){t.timerId&&(clearTimeout(t.timerId),t.timerId=null,t.remaining-=Date.now()-t.startTime)}_resumeTimer(t){this._startTimer(t)}_escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}}g("a11y-toast",V);class W extends p{static get observedAttributes(){return["focusable"]}setupAccessibility(){}render(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
|
|
1762
2177
|
<style>
|
|
1763
2178
|
:host {
|
|
1764
|
-
${
|
|
2179
|
+
${lt}
|
|
1765
2180
|
}
|
|
1766
2181
|
|
|
1767
2182
|
:host([hidden]) {
|
|
@@ -1782,7 +2197,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1782
2197
|
}
|
|
1783
2198
|
</style>
|
|
1784
2199
|
<slot></slot>
|
|
1785
|
-
`}setupEventListeners(){}cleanupEventListeners(){}}
|
|
2200
|
+
`}setupEventListeners(){}cleanupEventListeners(){}}g("a11y-visually-hidden",W);const jt=l.createComponentWarnings("SkipLink");class X extends p{constructor(){super(...arguments),this.handleClick=t=>{const e=this.getAttribute("target")||"#main-content",i=document.querySelector(e);i&&(t.preventDefault(),!i.hasAttribute("tabindex")&&i.tabIndex<0&&i.setAttribute("tabindex","-1"),i.focus(),i.scrollIntoView({behavior:"smooth",block:"start"}))}}static get observedAttributes(){return["target","label"]}setupAccessibility(){this.getAttribute("target")||jt.warning('Missing "target" attribute. Provide a CSS selector (e.g. target="#main-content") pointing to the skip destination.')}render(){this.shadowRoot||this.attachShadow({mode:"open"});const t=this.getAttribute("target")||"#main-content",e=this.getAttribute("label");this.shadowRoot.innerHTML=`
|
|
1786
2201
|
<style>
|
|
1787
2202
|
:host {
|
|
1788
2203
|
display: block;
|
|
@@ -1793,7 +2208,7 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1793
2208
|
}
|
|
1794
2209
|
|
|
1795
2210
|
.skip-link {
|
|
1796
|
-
${
|
|
2211
|
+
${lt}
|
|
1797
2212
|
display: inline-block;
|
|
1798
2213
|
text-decoration: none;
|
|
1799
2214
|
}
|
|
@@ -1828,10 +2243,10 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1828
2243
|
}
|
|
1829
2244
|
}
|
|
1830
2245
|
</style>
|
|
1831
|
-
<a class="skip-link" href="${
|
|
1832
|
-
${
|
|
2246
|
+
<a class="skip-link" href="${t}" part="link">
|
|
2247
|
+
${e||"<slot>Skip to main content</slot>"}
|
|
1833
2248
|
</a>
|
|
1834
|
-
`}setupEventListeners(){this.addEventListener("click",this.handleClick)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick)}onAttributeChange(e,
|
|
2249
|
+
`}setupEventListeners(){this.addEventListener("click",this.handleClick)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick)}onAttributeChange(t,e,i){(t==="target"||t==="label")&&this.render()}}g("a11y-skip-link",X);const Nt=l.createComponentWarnings("Alert"),Yt=`
|
|
1835
2250
|
:host {
|
|
1836
2251
|
display: block;
|
|
1837
2252
|
box-sizing: border-box;
|
|
@@ -1956,8 +2371,8 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1956
2371
|
outline: 2px solid Highlight;
|
|
1957
2372
|
}
|
|
1958
2373
|
}
|
|
1959
|
-
`,
|
|
1960
|
-
<style>${
|
|
2374
|
+
`,ut={info:"ℹ️",success:"✅",warning:"⚠️",error:"❌"};class J extends p{constructor(){super(...arguments),this._closeButton=null,this.handleDismiss=()=>{this.emit("dismiss",{type:this.alertType}),this.remove()}}static get observedAttributes(){return["type","title","dismissible"]}get alertType(){return this.getAttribute("type")||"info"}get alertRole(){const t=this.alertType;return t==="error"||t==="warning"?"alert":"status"}setupAccessibility(){const t=["info","success","warning","error"],e=this.getAttribute("type");e&&!t.includes(e)&&Nt.warning(`Invalid type="${e}". Use one of: ${t.join(", ")}.`)}render(){this.shadowRoot||this.attachShadow({mode:"open"});const t=this.getAttribute("title"),e=this.hasAttribute("dismissible"),i=ut[this.alertType]||ut.info;this.shadowRoot.innerHTML=`
|
|
2375
|
+
<style>${Yt}</style>
|
|
1961
2376
|
<div
|
|
1962
2377
|
class="alert"
|
|
1963
2378
|
role="${this.alertRole}"
|
|
@@ -1966,16 +2381,433 @@ var compa11y=function(l,o){"use strict";class c extends HTMLElement{constructor(
|
|
|
1966
2381
|
>
|
|
1967
2382
|
<span class="alert-icon" part="icon" aria-hidden="true">${i}</span>
|
|
1968
2383
|
<div class="alert-content" part="content">
|
|
1969
|
-
${
|
|
2384
|
+
${t?`<div class="alert-title" part="title">${t}</div>`:""}
|
|
1970
2385
|
<div class="alert-description" part="description">
|
|
1971
2386
|
<slot></slot>
|
|
1972
2387
|
</div>
|
|
1973
2388
|
</div>
|
|
1974
|
-
${
|
|
2389
|
+
${e?`<button
|
|
1975
2390
|
class="alert-close"
|
|
1976
2391
|
part="close"
|
|
1977
2392
|
aria-label="Dismiss alert"
|
|
1978
2393
|
type="button"
|
|
1979
2394
|
>×</button>`:""}
|
|
1980
2395
|
</div>
|
|
1981
|
-
`,this._closeButton=this.shadowRoot.querySelector(".alert-close")}setupEventListeners(){var
|
|
2396
|
+
`,this._closeButton=this.shadowRoot.querySelector(".alert-close")}setupEventListeners(){var t;(t=this._closeButton)==null||t.addEventListener("click",this.handleDismiss)}cleanupEventListeners(){var t;(t=this._closeButton)==null||t.removeEventListener("click",this.handleDismiss)}onAttributeChange(t,e,i){(t==="type"||t==="title"||t==="dismissible")&&(this.render(),this.setupEventListeners())}dismiss(){this.handleDismiss()}}g("a11y-alert",J);const Ut=`
|
|
2397
|
+
:host {
|
|
2398
|
+
display: inline;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
:host([hidden]) {
|
|
2402
|
+
display: none !important;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
a {
|
|
2406
|
+
color: var(--compa11y-link-color, #0066cc);
|
|
2407
|
+
text-decoration: var(--compa11y-link-underline, underline);
|
|
2408
|
+
cursor: pointer;
|
|
2409
|
+
border-radius: 2px;
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
a:hover {
|
|
2413
|
+
color: var(--compa11y-link-color-hover, #004499);
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
a:visited {
|
|
2417
|
+
color: var(--compa11y-link-color-visited, #551a8b);
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
a:focus-visible {
|
|
2421
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
2422
|
+
outline-offset: 2px;
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
/* Disabled state */
|
|
2426
|
+
:host([disabled]) a {
|
|
2427
|
+
color: var(--compa11y-link-color-disabled, #999);
|
|
2428
|
+
cursor: not-allowed;
|
|
2429
|
+
pointer-events: none;
|
|
2430
|
+
text-decoration: none;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
/* External link indicator */
|
|
2434
|
+
.external-icon {
|
|
2435
|
+
display: inline-block;
|
|
2436
|
+
width: 0.75em;
|
|
2437
|
+
height: 0.75em;
|
|
2438
|
+
margin-left: 0.25em;
|
|
2439
|
+
vertical-align: baseline;
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
/* Forced colors / high contrast mode */
|
|
2443
|
+
@media (forced-colors: active) {
|
|
2444
|
+
a {
|
|
2445
|
+
forced-color-adjust: none;
|
|
2446
|
+
color: LinkText;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
a:visited {
|
|
2450
|
+
color: VisitedText;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
a:focus-visible {
|
|
2454
|
+
outline: 2px solid Highlight;
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
:host([disabled]) a {
|
|
2458
|
+
color: GrayText;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
`;class Q extends p{static get observedAttributes(){return["href","external","current","disabled"]}setupAccessibility(){}render(){this.shadowRoot||this.attachShadow({mode:"open"});const t=this.getAttribute("href")||"",e=this.hasAttribute("external"),i=this.getAttribute("current"),s=this.hasAttribute("disabled"),a=[];s?(a.push('role="link"'),a.push('aria-disabled="true"'),a.push('tabindex="-1"')):a.push(`href="${t}"`),e&&!s&&(a.push('target="_blank"'),a.push('rel="noopener noreferrer"')),i&&a.push(`aria-current="${i}"`);const r=e?`<svg class="external-icon" part="external-icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2462
|
+
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
|
|
2463
|
+
<polyline points="15 3 21 3 21 9"/>
|
|
2464
|
+
<line x1="10" y1="14" x2="21" y2="3"/>
|
|
2465
|
+
</svg>`:"",o=e?'<span class="sr-only" style="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;">(opens in new tab)</span>':"";this.shadowRoot.innerHTML=`
|
|
2466
|
+
<style>${Ut}</style>
|
|
2467
|
+
<a ${a.join(" ")} part="link">
|
|
2468
|
+
<slot></slot>${r}${o}
|
|
2469
|
+
</a>
|
|
2470
|
+
`}onAttributeChange(t,e,i){["href","external","current","disabled"].includes(t)&&this.render()}}g("a11y-link",Q);const bt=`
|
|
2471
|
+
:host {
|
|
2472
|
+
display: block;
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
:host([hidden]) {
|
|
2476
|
+
display: none !important;
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
:host([as="span"]) {
|
|
2480
|
+
display: inline;
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
*,
|
|
2484
|
+
*::before,
|
|
2485
|
+
*::after {
|
|
2486
|
+
box-sizing: border-box;
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
/* Size scale */
|
|
2490
|
+
.size-xs { font-size: var(--compa11y-text-size-xs, 0.75rem); line-height: 1.5; }
|
|
2491
|
+
.size-sm { font-size: var(--compa11y-text-size-sm, 0.875rem); line-height: 1.5; }
|
|
2492
|
+
.size-md { font-size: var(--compa11y-text-size-md, 1rem); line-height: 1.5; }
|
|
2493
|
+
.size-lg { font-size: var(--compa11y-text-size-lg, 1.125rem); line-height: 1.5; }
|
|
2494
|
+
.size-xl { font-size: var(--compa11y-text-size-xl, 1.25rem); line-height: 1.4; }
|
|
2495
|
+
.size-2xl { font-size: var(--compa11y-text-size-2xl, 1.5rem); line-height: 1.3; }
|
|
2496
|
+
.size-3xl { font-size: var(--compa11y-text-size-3xl, 1.875rem); line-height: 1.25; }
|
|
2497
|
+
|
|
2498
|
+
/* Color variants */
|
|
2499
|
+
.color-default { color: var(--compa11y-text-color, inherit); }
|
|
2500
|
+
.color-muted { color: var(--compa11y-text-color-muted, #666); }
|
|
2501
|
+
.color-accent { color: var(--compa11y-text-color-accent, #0066cc); }
|
|
2502
|
+
.color-error { color: var(--compa11y-text-color-error, #dc2626); }
|
|
2503
|
+
.color-success { color: var(--compa11y-text-color-success, #16a34a); }
|
|
2504
|
+
.color-warning { color: var(--compa11y-text-color-warning, #d97706); }
|
|
2505
|
+
|
|
2506
|
+
/* Weight */
|
|
2507
|
+
.weight-normal { font-weight: 400; }
|
|
2508
|
+
.weight-medium { font-weight: 500; }
|
|
2509
|
+
.weight-semibold { font-weight: 600; }
|
|
2510
|
+
.weight-bold { font-weight: 700; }
|
|
2511
|
+
|
|
2512
|
+
/* Alignment */
|
|
2513
|
+
.align-left { text-align: left; }
|
|
2514
|
+
.align-center { text-align: center; }
|
|
2515
|
+
.align-right { text-align: right; }
|
|
2516
|
+
|
|
2517
|
+
/* Truncation */
|
|
2518
|
+
.truncate {
|
|
2519
|
+
overflow: hidden;
|
|
2520
|
+
text-overflow: ellipsis;
|
|
2521
|
+
white-space: nowrap;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
/* Forced colors */
|
|
2525
|
+
@media (forced-colors: active) {
|
|
2526
|
+
.color-muted,
|
|
2527
|
+
.color-accent,
|
|
2528
|
+
.color-error,
|
|
2529
|
+
.color-success,
|
|
2530
|
+
.color-warning {
|
|
2531
|
+
color: CanvasText;
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
`,Gt=`
|
|
2535
|
+
${bt}
|
|
2536
|
+
|
|
2537
|
+
h1, h2, h3, h4, h5, h6 {
|
|
2538
|
+
margin: 0;
|
|
2539
|
+
font-family: var(--compa11y-heading-font-family, inherit);
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
/* Default heading sizes (when no size attr) */
|
|
2543
|
+
h1 { font-size: var(--compa11y-heading-1-size, 2.25rem); line-height: 1.2; font-weight: 700; }
|
|
2544
|
+
h2 { font-size: var(--compa11y-heading-2-size, 1.875rem); line-height: 1.25; font-weight: 700; }
|
|
2545
|
+
h3 { font-size: var(--compa11y-heading-3-size, 1.5rem); line-height: 1.3; font-weight: 600; }
|
|
2546
|
+
h4 { font-size: var(--compa11y-heading-4-size, 1.25rem); line-height: 1.35; font-weight: 600; }
|
|
2547
|
+
h5 { font-size: var(--compa11y-heading-5-size, 1.125rem); line-height: 1.4; font-weight: 600; }
|
|
2548
|
+
h6 { font-size: var(--compa11y-heading-6-size, 1rem); line-height: 1.5; font-weight: 600; }
|
|
2549
|
+
`,Vt=`
|
|
2550
|
+
${bt}
|
|
2551
|
+
|
|
2552
|
+
p, span, div, label {
|
|
2553
|
+
margin: 0;
|
|
2554
|
+
font-family: var(--compa11y-text-font-family, inherit);
|
|
2555
|
+
}
|
|
2556
|
+
`;function pt(d,t){const e=[],i=d.getAttribute("size"),s=d.getAttribute("color")||"default",a=d.getAttribute("weight"),r=d.getAttribute("align"),o=d.hasAttribute("truncate");return i?e.push(`size-${i}`):t&&e.push(`size-${t}`),e.push(`color-${s}`),a&&e.push(`weight-${a}`),r&&e.push(`align-${r}`),o&&e.push("truncate"),e.join(" ")}class Z extends p{static get observedAttributes(){return["level","size","color","weight","align","truncate"]}get headingLevel(){const t=parseInt(this.getAttribute("level")||"2",10);return t>=1&&t<=6?t:2}setupAccessibility(){}render(){this.shadowRoot||this.attachShadow({mode:"open"});const t=`h${this.headingLevel}`,e=pt(this),i=this.getAttribute("size")?`size-${this.getAttribute("size")}`:"",s=e;this.shadowRoot.innerHTML=`
|
|
2557
|
+
<style>${Gt}</style>
|
|
2558
|
+
<${t} class="${s}" part="heading">
|
|
2559
|
+
<slot></slot>
|
|
2560
|
+
</${t}>
|
|
2561
|
+
`}onAttributeChange(){this.render()}}class tt extends p{static get observedAttributes(){return["as","size","color","weight","align","truncate"]}get tagName_(){const t=this.getAttribute("as");return t&&["p","span","div","label"].includes(t)?t:"p"}setupAccessibility(){}render(){this.shadowRoot||this.attachShadow({mode:"open"});const t=this.tagName_,e=pt(this,"md");this.shadowRoot.innerHTML=`
|
|
2562
|
+
<style>${Vt}</style>
|
|
2563
|
+
<${t} class="${e}" part="text">
|
|
2564
|
+
<slot></slot>
|
|
2565
|
+
</${t}>
|
|
2566
|
+
`}onAttributeChange(){this.render()}}g("a11y-heading",Z),g("a11y-text",tt);const Wt=`
|
|
2567
|
+
:host {
|
|
2568
|
+
display: block;
|
|
2569
|
+
box-sizing: border-box;
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
:host([hidden]) {
|
|
2573
|
+
display: none !important;
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
*,
|
|
2577
|
+
*::before,
|
|
2578
|
+
*::after {
|
|
2579
|
+
box-sizing: inherit;
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
.field-wrapper {
|
|
2583
|
+
display: flex;
|
|
2584
|
+
flex-direction: column;
|
|
2585
|
+
gap: var(--compa11y-field-gap, 0.25rem);
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
.field-label {
|
|
2589
|
+
display: block;
|
|
2590
|
+
color: var(--compa11y-field-label-color, inherit);
|
|
2591
|
+
font-size: var(--compa11y-field-label-size, 0.875rem);
|
|
2592
|
+
font-weight: var(--compa11y-field-label-weight, 500);
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
:host([disabled]) .field-label {
|
|
2596
|
+
color: var(--compa11y-field-disabled-color, #999);
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
.field-required {
|
|
2600
|
+
color: var(--compa11y-field-required-color, #ef4444);
|
|
2601
|
+
margin-left: 0.125rem;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
.field-hint {
|
|
2605
|
+
color: var(--compa11y-field-hint-color, #666);
|
|
2606
|
+
font-size: var(--compa11y-field-hint-size, 0.8125rem);
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
.field-error {
|
|
2610
|
+
color: var(--compa11y-field-error-color, #ef4444);
|
|
2611
|
+
font-size: var(--compa11y-field-error-size, 0.8125rem);
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
/* Forced colors */
|
|
2615
|
+
@media (forced-colors: active) {
|
|
2616
|
+
.field-label {
|
|
2617
|
+
color: CanvasText;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
:host([disabled]) .field-label {
|
|
2621
|
+
color: GrayText;
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
.field-error {
|
|
2625
|
+
color: LinkText;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
`;class et extends p{static get observedAttributes(){return["label","hint","error","required","disabled"]}setupAccessibility(){var t;typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)!=="production"&&(this.hasAttribute("label")||console.warn(`[compa11y/FormField] FormField has no label. Add label="..." attribute.
|
|
2629
|
+
💡 Suggestion: <a11y-form-field label="Email">...</a11y-form-field>`))}render(){this.shadowRoot||this.attachShadow({mode:"open"});const t=this.getAttribute("label")||"",e=this.getAttribute("hint")||"",i=this.getAttribute("error")||"",s=this.hasAttribute("required"),a=!!i,r=`${this._id}-label`,o=`${this._id}-hint`,n=`${this._id}-error`;this.setAttribute("data-error",a?"true":"false"),this.shadowRoot.innerHTML=`
|
|
2630
|
+
<style>${Wt}</style>
|
|
2631
|
+
<div class="field-wrapper" part="wrapper">
|
|
2632
|
+
${t?`<label
|
|
2633
|
+
class="field-label"
|
|
2634
|
+
id="${r}"
|
|
2635
|
+
part="label"
|
|
2636
|
+
>${t}${s?'<span class="field-required" aria-hidden="true" part="required">*</span>':""}</label>`:""}
|
|
2637
|
+
<slot></slot>
|
|
2638
|
+
${e?`<div class="field-hint" id="${o}" part="hint">${e}</div>`:""}
|
|
2639
|
+
${a?`<div class="field-error" id="${n}" role="alert" part="error">${i}</div>`:""}
|
|
2640
|
+
</div>
|
|
2641
|
+
`,this.wireControl()}setupEventListeners(){var e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector("slot");t==null||t.addEventListener("slotchange",()=>this.wireControl())}cleanupEventListeners(){var e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector("slot");t==null||t.removeEventListener("slotchange",()=>this.wireControl())}wireControl(){var _;const t=(_=this.shadowRoot)==null?void 0:_.querySelector("slot");if(!t)return;const e=t.assignedElements({flatten:!0}),i=e.find(y=>y instanceof HTMLInputElement||y instanceof HTMLSelectElement||y instanceof HTMLTextAreaElement||y.hasAttribute("role")||y.hasAttribute("tabindex"))||e[0];if(!i)return;const s=this.getAttribute("label")||"",a=this.getAttribute("hint")||"",r=this.getAttribute("error")||"",o=this.hasAttribute("required"),n=this.hasAttribute("disabled"),c=!!r,b=`${this._id}-label`,u=`${this._id}-hint`,m=`${this._id}-error`;s&&!i.hasAttribute("aria-label")&&i.setAttribute("aria-labelledby",b);const v=[];a&&v.push(u),c&&v.push(m),v.length?i.setAttribute("aria-describedby",v.join(" ")):i.removeAttribute("aria-describedby"),c?i.setAttribute("aria-invalid","true"):i.removeAttribute("aria-invalid"),o?i.setAttribute("aria-required","true"):i.removeAttribute("aria-required"),n?("disabled"in i&&(i.disabled=!0),i.setAttribute("aria-disabled","true")):("disabled"in i&&(i.disabled=!1),i.removeAttribute("aria-disabled"))}onAttributeChange(t,e,i){["label","hint","error","required","disabled"].includes(t)&&(this.render(),this.setupEventListeners())}}g("a11y-form-field",et);const gt=l.createComponentWarnings("Popover");function Xt(d,t,e,i){const s=window.innerWidth,a=window.innerHeight,r=t.offsetWidth,o=t.offsetHeight,n=e.indexOf("-"),c=n===-1?e:e.slice(0,n),b=n===-1?"center":e.slice(n+1);let u=0,m=0;switch(c){case"top":u=d.top-o-i;break;case"bottom":u=d.bottom+i;break;case"left":m=d.left-r-i;break;case"right":m=d.right+i;break}if(c==="top"||c==="bottom")switch(b){case"start":m=d.left;break;case"end":m=d.right-r;break;default:m=d.left+(d.width-r)/2}else switch(b){case"start":u=d.top;break;case"end":u=d.bottom-o;break;default:u=d.top+(d.height-o)/2}c==="bottom"&&u+o>a&&d.top-o-i>0?u=d.top-o-i:c==="top"&&u<0&&d.bottom+i+o<a?u=d.bottom+i:c==="right"&&m+r>s&&d.left-r-i>0?m=d.left-r-i:c==="left"&&m<0&&d.right+i+r<s&&(m=d.right+i);const v=8;return m=Math.max(v,Math.min(m,s-r-v)),u=Math.max(v,Math.min(u,a-o-v)),{top:u,left:m}}const Jt='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), details > summary',Qt=`
|
|
2642
|
+
:host {
|
|
2643
|
+
display: inline-block;
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
:host([hidden]) {
|
|
2647
|
+
display: none !important;
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
*,
|
|
2651
|
+
*::before,
|
|
2652
|
+
*::after {
|
|
2653
|
+
box-sizing: border-box;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
.popover-content {
|
|
2657
|
+
position: fixed;
|
|
2658
|
+
z-index: var(--compa11y-popover-z-index, 1000);
|
|
2659
|
+
background: var(--compa11y-popover-bg, #fff);
|
|
2660
|
+
color: var(--compa11y-popover-color, inherit);
|
|
2661
|
+
border: var(--compa11y-popover-border, 1px solid rgba(0, 0, 0, 0.15));
|
|
2662
|
+
border-radius: var(--compa11y-popover-radius, 0.375rem);
|
|
2663
|
+
box-shadow: var(--compa11y-popover-shadow, 0 4px 16px rgba(0, 0, 0, 0.12));
|
|
2664
|
+
padding: var(--compa11y-popover-padding, 1rem);
|
|
2665
|
+
max-width: var(--compa11y-popover-max-width, 320px);
|
|
2666
|
+
min-width: 100px;
|
|
2667
|
+
outline: none;
|
|
2668
|
+
transition: opacity 0.15s ease, transform 0.15s ease;
|
|
2669
|
+
opacity: 0;
|
|
2670
|
+
transform: scale(0.96) translateY(-2px);
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
.popover-content[data-open="true"] {
|
|
2674
|
+
opacity: 1;
|
|
2675
|
+
transform: scale(1) translateY(0);
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
.popover-content[hidden] {
|
|
2679
|
+
display: none !important;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2683
|
+
.popover-content {
|
|
2684
|
+
transition: none;
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
${dt}
|
|
2689
|
+
|
|
2690
|
+
@media (forced-colors: active) {
|
|
2691
|
+
.popover-content {
|
|
2692
|
+
border: 2px solid ButtonText;
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
`;class it extends p{constructor(){super(...arguments),this._open=!1,this._placement="bottom",this._offset=8,this._disabled=!1,this._haspopup="dialog",this._contentRole="dialog",this._contentLabel="",this._focusPolicy="first",this._triggerEl=null,this._contentEl=null,this._weMovedFocus=!1,this._onTriggerSlotChange=()=>{const t=`${this._id}-content`;this._wireTrigger(t)},this._onOutsidePointerDown=t=>{t.composedPath().includes(this)||(this.open=!1)},this._onDocumentKeyDown=t=>{t.key==="Escape"&&(t.stopPropagation(),this.open=!1)},this._onScrollOrResize=()=>{this._open&&this._updatePosition()},this._onTriggerClick=()=>{this._disabled||(this.open=!this._open)},this._onTriggerKeyDown=t=>{this._disabled||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.open=!this._open)}}static get observedAttributes(){return["open","placement","offset","disabled","haspopup","content-role","content-label","focus-policy"]}get open(){return this._open}set open(t){this._open!==t&&(this._open=t,this.toggleAttribute("open",t),t?this._show():this._hide())}get disabled(){return this._disabled}set disabled(t){this._disabled=t,this.toggleAttribute("disabled",t),this._updateTriggerDisabled()}setupAccessibility(){this._open=this.hasAttribute("open"),this._placement=this.getAttribute("placement")||"bottom",this._offset=parseInt(this.getAttribute("offset")||"8",10),this._disabled=this.hasAttribute("disabled"),this._haspopup=this.getAttribute("haspopup")||"dialog",this._contentRole=this.getAttribute("content-role")||"dialog",this._contentLabel=this.getAttribute("content-label")||"",this._focusPolicy=this.getAttribute("focus-policy")||"first"}render(){this.shadowRoot||this.attachShadow({mode:"open"});const t=`${this._id}-content`,e=this._contentLabel?`aria-label="${this._contentLabel}"`:"";this.shadowRoot.innerHTML=`
|
|
2696
|
+
<style>${Qt}</style>
|
|
2697
|
+
<slot name="trigger" part="trigger-slot"></slot>
|
|
2698
|
+
<div
|
|
2699
|
+
class="popover-content"
|
|
2700
|
+
id="${t}"
|
|
2701
|
+
part="content"
|
|
2702
|
+
role="${this._contentRole}"
|
|
2703
|
+
aria-modal="false"
|
|
2704
|
+
tabindex="-1"
|
|
2705
|
+
${e}
|
|
2706
|
+
${this._open?'data-open="true"':""}
|
|
2707
|
+
${this._open?"":"hidden"}
|
|
2708
|
+
>
|
|
2709
|
+
<slot></slot>
|
|
2710
|
+
</div>
|
|
2711
|
+
`,this._contentEl=this.shadowRoot.querySelector(".popover-content"),this._wireTrigger(t),this._open&&requestAnimationFrame(()=>this._updatePosition())}setupEventListeners(){var e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector('slot[name="trigger"]');t==null||t.addEventListener("slotchange",this._onTriggerSlotChange)}cleanupEventListeners(){var e;const t=(e=this.shadowRoot)==null?void 0:e.querySelector('slot[name="trigger"]');t==null||t.removeEventListener("slotchange",this._onTriggerSlotChange),this._removeGlobalListeners(),this._detachTriggerListeners()}onAttributeChange(t,e,i){var s,a,r;switch(t){case"open":this.open=i!==null;break;case"placement":this._placement=i||"bottom",this._open&&this._updatePosition();break;case"offset":this._offset=parseInt(i||"8",10),this._open&&this._updatePosition();break;case"disabled":this._disabled=i!==null,this._updateTriggerDisabled();break;case"haspopup":this._haspopup=i||"dialog",this._updateTriggerAria();break;case"content-role":this._contentRole=i||"dialog",(s=this._contentEl)==null||s.setAttribute("role",this._contentRole);break;case"content-label":this._contentLabel=i||"",this._contentLabel?(a=this._contentEl)==null||a.setAttribute("aria-label",this._contentLabel):(r=this._contentEl)==null||r.removeAttribute("aria-label");break;case"focus-policy":this._focusPolicy=i||"first";break}}_wireTrigger(t){var a,r;const e=(a=this.shadowRoot)==null?void 0:a.querySelector('slot[name="trigger"]');if(!e)return;const s=e.assignedElements({flatten:!0})[0]||null;typeof process<"u"&&((r=process.env)==null?void 0:r.NODE_ENV)!=="production"&&(s||gt.warning('Popover has no trigger. Add an element to the "trigger" slot.','<a11y-popover><button slot="trigger">Open</button>...</a11y-popover>')),this._detachTriggerListeners(),this._triggerEl=s,s&&(this._updateTriggerAria(t),this._updateTriggerDisabled(),s.addEventListener("click",this._onTriggerClick),s.addEventListener("keydown",this._onTriggerKeyDown))}_updateTriggerAria(t){const e=this._triggerEl;if(!e)return;const i=t||`${this._id}-content`;this._haspopup&&this._haspopup!=="false"?e.setAttribute("aria-haspopup",this._haspopup):e.removeAttribute("aria-haspopup"),e.setAttribute("aria-expanded",String(this._open)),this._open?e.setAttribute("aria-controls",i):e.removeAttribute("aria-controls")}_updateTriggerDisabled(){const t=this._triggerEl;t&&(this._disabled?"disabled"in t?t.disabled=!0:(t.setAttribute("aria-disabled","true"),t.setAttribute("tabindex","-1")):"disabled"in t?t.disabled=!1:(t.removeAttribute("aria-disabled"),t.removeAttribute("tabindex")))}_detachTriggerListeners(){this._triggerEl&&(this._triggerEl.removeEventListener("click",this._onTriggerClick),this._triggerEl.removeEventListener("keydown",this._onTriggerKeyDown),this._triggerEl.removeAttribute("aria-haspopup"),this._triggerEl.removeAttribute("aria-expanded"),this._triggerEl.removeAttribute("aria-controls"))}_show(){var t;this._contentEl&&(this._contentEl.removeAttribute("hidden"),this._updateTriggerAria(),this._updatePosition(),requestAnimationFrame(()=>{var e;(e=this._contentEl)==null||e.setAttribute("data-open","true")}),typeof process<"u"&&((t=process.env)==null?void 0:t.NODE_ENV)!=="production"&&requestAnimationFrame(()=>{const e=this._contentEl;if(!e)return;const i=e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby"),s=!!e.querySelector('h1, h2, h3, h4, h5, h6, [role="heading"]');!i&&!s&>.warning('Popover content has no accessible name. Add content-label="..." on <a11y-popover>, or place a heading inside the content.','Example: <a11y-popover content-label="Filter options">...</a11y-popover>')}),requestAnimationFrame(()=>{const e=this._focusPolicy;if(e==="none")return;const i=this._contentEl;if(!i)return;let s=null;e==="first"&&(s=i.querySelector(Jt)),s||(s=i),this._weMovedFocus=!0,s.focus()}),this._addGlobalListeners(),this.emit("a11y-popover-open"))}_hide(){var s;if(!this._contentEl)return;this._contentEl.removeAttribute("data-open"),this._updateTriggerAria();const t=()=>{var a,r;(a=this._contentEl)==null||a.setAttribute("hidden",""),(r=this._contentEl)==null||r.removeEventListener("transitionend",t)};getComputedStyle(this._contentEl).transitionDuration!=="0s"?(this._contentEl.addEventListener("transitionend",t),setTimeout(t,200)):this._contentEl.setAttribute("hidden",""),this._removeGlobalListeners();const i=this._weMovedFocus||this._contentEl.contains(document.activeElement);this._weMovedFocus=!1,i&&((s=this._triggerEl)==null||s.focus()),this.emit("a11y-popover-close")}_updatePosition(){if(!this._triggerEl||!this._contentEl||!this._open)return;const t=this._triggerEl.getBoundingClientRect(),{top:e,left:i}=Xt(t,this._contentEl,this._placement,this._offset);this._contentEl.style.top=`${e}px`,this._contentEl.style.left=`${i}px`}_addGlobalListeners(){document.addEventListener("pointerdown",this._onOutsidePointerDown,!0),document.addEventListener("keydown",this._onDocumentKeyDown,!0),window.addEventListener("scroll",this._onScrollOrResize,{passive:!0,capture:!0}),window.addEventListener("resize",this._onScrollOrResize,{passive:!0})}_removeGlobalListeners(){document.removeEventListener("pointerdown",this._onOutsidePointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown,!0),window.removeEventListener("scroll",this._onScrollOrResize,!0),window.removeEventListener("resize",this._onScrollOrResize)}}g("a11y-popover",it);const Zt=l.createComponentWarnings("A11yAccordion");let mt=!1;function te(){if(mt||typeof document>"u")return;mt=!0;const d=document.createElement("style");d.setAttribute("data-compa11y-accordion",""),d.textContent=Rt,document.head.appendChild(d)}class st extends p{constructor(){super(...arguments),this._triggers=[],this._panels=[],this._openItems=new Set,this._defaultSlotEl=null,this.updateItems=()=>{this._triggers=Array.from(this.querySelectorAll("[data-accordion-trigger]")),this._panels=Array.from(this.querySelectorAll("[data-accordion-panel]")),this._triggers.forEach((t,e)=>{const i=this._panels[e],s=t.id||`${this._id}-trigger-${e}`,a=(i==null?void 0:i.id)||`${this._id}-panel-${e}`;t.id=s,t.getAttribute("aria-controls")||t.setAttribute("aria-controls",a);const r=this._openItems.has(e);t.setAttribute("aria-expanded",String(r)),i&&(i.id=a,i.getAttribute("role")||i.setAttribute("role","region"),i.getAttribute("aria-labelledby")||i.setAttribute("aria-labelledby",s),i.hidden=!r),Zt.checks.accessibleLabel(t,`a11y-accordion trigger[${e}]`)})},this.handleClick=t=>{const i=t.target.closest("[data-accordion-trigger]");if(!i||i.hasAttribute("disabled")||i.getAttribute("aria-disabled")==="true")return;const a=this._triggers.indexOf(i);a!==-1&&this.toggleItem(a)},this.handleKeyDown=t=>{var o,n,c,b;const i=t.target.closest("[data-accordion-trigger]");if(!i||this._triggers.indexOf(i)===-1)return;const a=this._triggers.filter(u=>!u.hasAttribute("disabled")&&u.getAttribute("aria-disabled")!=="true"),r=a.indexOf(i);if(r!==-1)switch(t.key){case"ArrowDown":t.preventDefault(),(o=a[(r+1)%a.length])==null||o.focus();break;case"ArrowUp":t.preventDefault(),(n=a[(r-1+a.length)%a.length])==null||n.focus();break;case"Home":t.preventDefault(),(c=a[0])==null||c.focus();break;case"End":t.preventDefault(),(b=a[a.length-1])==null||b.focus();break}}}static get observedAttributes(){return["type","collapsible"]}get type(){return this.getAttribute("type")||"single"}get collapsible(){return this.hasAttribute("collapsible")}setupAccessibility(){te(),this.updateItems()}render(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
|
|
2712
|
+
<style>
|
|
2713
|
+
${f}
|
|
2714
|
+
:host {
|
|
2715
|
+
display: block;
|
|
2716
|
+
}
|
|
2717
|
+
</style>
|
|
2718
|
+
<slot></slot>
|
|
2719
|
+
`}setupEventListeners(){var t,e;this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this._defaultSlotEl=((t=this.shadowRoot)==null?void 0:t.querySelector("slot"))??null,(e=this._defaultSlotEl)==null||e.addEventListener("slotchange",this.updateItems)}cleanupEventListeners(){var t;this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown),(t=this._defaultSlotEl)==null||t.removeEventListener("slotchange",this.updateItems)}onAttributeChange(t,e,i){t==="type"&&(this._openItems.clear(),this.syncState())}toggleItem(t){var n,c;const e=this._openItems.has(t),i=[];this.type==="single"?e&&this.collapsible?i.push(t):e||this._openItems.forEach(b=>i.push(b)):e&&i.push(t);const s=document.activeElement,a=i.find(b=>{const u=this._panels[b];return u&&u.contains(s)});this.type==="single"?e?this.collapsible&&this._openItems.delete(t):(this._openItems.clear(),this._openItems.add(t)):e?this._openItems.delete(t):this._openItems.add(t),this.syncState(),a!==void 0&&requestAnimationFrame(()=>{var b;(b=this._triggers[a])==null||b.focus()});const r=this._openItems.has(t),o=((c=(n=this._triggers[t])==null?void 0:n.textContent)==null?void 0:c.trim())||"Section";l.announce(`${o} ${r?"expanded":"collapsed"}`),this.emit("a11y-accordion-change",{index:t,expanded:r,trigger:this._triggers[t],panel:this._panels[t]})}syncState(){this._triggers.forEach((t,e)=>{const i=this._panels[e],s=this._openItems.has(e);t.setAttribute("aria-expanded",String(s)),i&&(i.hidden=!s)})}open(t){this.type==="single"&&this._openItems.clear(),this._openItems.add(t),this.syncState()}close(t){this._openItems.delete(t),this.syncState()}toggle(t){this.toggleItem(t)}}g("a11y-accordion",st);const ft=l.createComponentWarnings("A11yTable");let vt=!1;function ee(){if(vt||typeof document>"u")return;vt=!0;const d=document.createElement("style");d.setAttribute("data-compa11y-table",""),d.textContent=Pt,document.head.appendChild(d)}class at extends p{constructor(){super(...arguments),this._columns=[],this._rows=[],this._sortKey=null,this._sortDirection="none",this._selectedRows=new Set,this._tableEl=null,this.handleClick=t=>{const i=t.target.closest("[data-sort-btn]");if(i){const s=i.dataset.sortKey;if(s){this.sort(s);const a=this._columns.find(n=>n.key===s),r=(a==null?void 0:a.label)??s,o=this._sortDirection==="none"?"sort cleared":`sorted ${this._sortDirection}`;l.announce(`${r} ${o}`),this.emit("a11y-table-sort",{sortKey:this._sortKey,sortDirection:this._sortDirection})}}},this.handleChange=t=>{const e=t.target;if(!(!e||e.type!=="checkbox")){if("selectAll"in e.dataset){e.checked?this.selectAll():this.deselectAll();const i=this._selectedRows.size;l.announce(i===0?"Selection cleared":`All ${i} rows selected`);return}if("selectRow"in e.dataset){const i=e.dataset.rowId??"";if(!i)return;e.checked?this._selectedRows.add(i):this._selectedRows.delete(i),this.syncSelectionState(),this.emitSelectEvent();const s=this._selectedRows.size;l.announce(s===0?"Selection cleared":`${s} row${s===1?"":"s"} selected`)}}}}static get observedAttributes(){return["caption","sort-key","sort-direction","selectable","loading","empty-message"]}get caption(){return this.getAttribute("caption")||""}set caption(t){this.setAttribute("caption",t)}get selectable(){return this.hasAttribute("selectable")}get loading(){return this.hasAttribute("loading")}get emptyMessage(){return this.getAttribute("empty-message")||"No results found"}get sortKey(){return this._sortKey}set sortKey(t){this._sortKey=t,this.rerenderTable()}get sortDirection(){return this._sortDirection}set sortDirection(t){this._sortDirection=t,this.rerenderTable()}get columns(){return this._columns}set columns(t){this._columns=t,this.rerenderTable()}get rows(){return this._rows}set rows(t){this._rows=t,this.rerenderTable()}get selectedRows(){return Array.from(this._selectedRows)}set selectedRows(t){this._selectedRows=new Set(t),this.syncSelectionState()}upgradeProperty(t){if(Object.prototype.hasOwnProperty.call(this,t)){const e=this[t];delete this[t],this[t]=e}}setupAccessibility(){ee(),this.upgradeProperty("columns"),this.upgradeProperty("rows"),this.upgradeProperty("selectedRows"),this.upgradeProperty("sortKey"),this.upgradeProperty("sortDirection");const t=this.getAttribute("sort-key");t&&(this._sortKey=t);const e=this.getAttribute("sort-direction");e&&(this._sortDirection=e),!this.caption&&!this.getAttribute("aria-label")&&!this.getAttribute("aria-labelledby")&&ft.warning("a11y-table must have an accessible name. Provide a caption attribute, aria-label, or aria-labelledby.")}render(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=`
|
|
2720
|
+
<style>
|
|
2721
|
+
${f}
|
|
2722
|
+
:host { display: block; overflow-x: auto; }
|
|
2723
|
+
</style>
|
|
2724
|
+
<slot></slot>
|
|
2725
|
+
`,this._tableEl||(this._tableEl=document.createElement("table"),this.appendChild(this._tableEl)),this.renderTable()}setupEventListeners(){this.addEventListener("click",this.handleClick),this.addEventListener("change",this.handleChange)}cleanupEventListeners(){this.removeEventListener("click",this.handleClick),this.removeEventListener("change",this.handleChange)}onAttributeChange(t,e,i){switch(t){case"caption":case"empty-message":this.rerenderTable();break;case"sort-key":this._sortKey=i,this.rerenderTable();break;case"sort-direction":this._sortDirection=i||"none",this.rerenderTable();break;case"selectable":case"loading":this.rerenderTable();break}}sort(t,e){e?(this._sortKey=e==="none"?null:t,this._sortDirection=e):this._sortKey!==t?(this._sortKey=t,this._sortDirection="ascending"):this._sortDirection==="ascending"?this._sortDirection="descending":this._sortDirection==="descending"?(this._sortKey=null,this._sortDirection="none"):(this._sortKey=t,this._sortDirection="ascending"),this.rerenderTable()}selectRow(t){this._selectedRows.add(t),this.syncSelectionState(),this.emitSelectEvent()}deselectRow(t){this._selectedRows.delete(t),this.syncSelectionState(),this.emitSelectEvent()}selectAll(){for(const t of this._rows){const e=String(t.id??"");e&&this._selectedRows.add(e)}this.syncSelectionState(),this.emitSelectEvent()}deselectAll(){this._selectedRows.clear(),this.syncSelectionState(),this.emitSelectEvent()}rerenderTable(){if(!this._tableEl)return;const t=document.activeElement,e=(t==null?void 0:t.dataset.sortKey)??null,i=this._tableEl.contains(t);this.renderTable(),i&&e&&requestAnimationFrame(()=>{var a;const s=(a=this._tableEl)==null?void 0:a.querySelector(`[data-sort-key="${e}"]`);s==null||s.focus()})}renderTable(){if(!this._tableEl)return;const t=this._tableEl;this.loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");let e=t.querySelector("caption");this.caption?(e||(e=document.createElement("caption"),t.prepend(e)),e.textContent=this.caption):e&&e.remove();let i=t.querySelector("thead");i||(i=document.createElement("thead"),t.appendChild(i)),this.renderThead(i);let s=t.querySelector("tbody");s||(s=document.createElement("tbody"),t.appendChild(s)),this.renderTbody(s)}renderThead(t){t.innerHTML="";const e=document.createElement("tr");if(this.selectable){const i=document.createElement("th");i.scope="col",i.style.width="2.5rem";const s=this._rows.map(c=>String(c.id??"")).filter(Boolean),a=s.filter(c=>this._selectedRows.has(c)).length,r=s.length>0&&a===s.length,o=a>0&&a<s.length,n=document.createElement("input");n.type="checkbox",n.dataset.selectAll="",n.setAttribute("data-select-cb",""),n.setAttribute("aria-label","Select all rows"),n.checked=r,n.indeterminate=o,i.appendChild(n),e.appendChild(i)}for(const i of this._columns){const s=document.createElement("th");if(s.scope="col",i.align&&(s.style.textAlign=i.align),i.sortable){const a=this._sortKey===i.key,r=a?this._sortDirection:"none";s.setAttribute("aria-sort",r);const o=document.createElement("button");o.type="button",o.setAttribute("data-sort-btn",""),o.setAttribute("data-sort-key",i.key);const n=document.createElement("span");n.textContent=i.label;const c=document.createElement("span");c.setAttribute("aria-hidden","true"),c.setAttribute("data-sort-icon",""),c.textContent=a&&r==="ascending"?"↑":a&&r==="descending"?"↓":"↕",o.appendChild(n),o.appendChild(c),s.appendChild(o)}else s.textContent=i.label;e.appendChild(s)}t.appendChild(e)}renderTbody(t){if(t.innerHTML="",this.loading){const e=document.createElement("tr");e.setAttribute("aria-busy","true");const i=document.createElement("td");i.setAttribute("data-loading-cell",""),i.colSpan=this._columns.length+(this.selectable?1:0),i.textContent="Loading…",e.appendChild(i),t.appendChild(e);return}if(this._rows.length===0){const e=document.createElement("tr"),i=document.createElement("td");i.setAttribute("data-empty-cell",""),i.colSpan=this._columns.length+(this.selectable?1:0),i.textContent=this.emptyMessage,e.appendChild(i),t.appendChild(e);return}this.selectable&&this._rows.some(i=>!i.id)&&ft.warning('a11y-table: When selectable is enabled, each row object must have an "id" field.');for(const e of this._rows){const i=String(e.id??""),s=i?this._selectedRows.has(i):!1,a=document.createElement("tr");if(i&&this.selectable&&a.setAttribute("aria-selected",String(s)),this.selectable){const r=document.createElement("td");r.style.width="2.5rem";const o=document.createElement("input");o.type="checkbox",o.dataset.rowId=i,o.dataset.selectRow="",o.setAttribute("data-select-cb",""),o.checked=s;const n=this._columns[0],c=n?String(e[n.key]??i):i;o.setAttribute("aria-label",`Select ${c}`),r.appendChild(o),a.appendChild(r)}for(const r of this._columns){const o=e[r.key],n=o==null?"":String(o);if(r.rowHeader){const c=document.createElement("th");c.scope="row",r.align&&(c.style.textAlign=r.align),c.textContent=n,a.appendChild(c)}else{const c=document.createElement("td");r.align&&(c.style.textAlign=r.align),c.textContent=n,a.appendChild(c)}}t.appendChild(a)}}syncSelectionState(){if(!this._tableEl)return;const t=this._tableEl.querySelectorAll("tbody tr");for(const i of Array.from(t)){const s=i.querySelector("[data-select-row]");if(!s)continue;const a=s.dataset.rowId??"",r=this._selectedRows.has(a);i.setAttribute("aria-selected",String(r)),s.checked=r}const e=this._tableEl.querySelector("[data-select-all]");if(e){const i=this._rows.map(a=>String(a.id??"")).filter(Boolean),s=i.filter(a=>this._selectedRows.has(a)).length;e.checked=i.length>0&&s===i.length,e.indeterminate=s>0&&s<i.length}}emitSelectEvent(){this.emit("a11y-table-select",{selectedRows:Array.from(this._selectedRows)})}}g("a11y-table",at);const ie=l.createComponentWarnings("Pagination");function se(d,t,e,i){if(t<=0)return[];if(t===1)return[1];const s=new Set;for(let o=1;o<=Math.min(i,t);o++)s.add(o);for(let o=Math.max(t-i+1,1);o<=t;o++)s.add(o);for(let o=Math.max(d-e,1);o<=Math.min(d+e,t);o++)s.add(o);const a=Array.from(s).sort((o,n)=>o-n),r=[];for(let o=0;o<a.length;o++){const n=a[o],c=a[o-1];if(n!==void 0){if(c!==void 0){const b=n-c;if(b===2)r.push(c+1);else if(b>2){const u=(c+n)/2;r.push(u<d?"ellipsis-start":"ellipsis-end")}}r.push(n)}}return r}class rt extends p{constructor(){super(...arguments),this._currentPage=1,this._totalPages=1,this._totalItems=null,this._pageSize=25,this._siblingCount=1,this._boundaryCount=1,this._showFirstLast=!1,this._showPageSize=!1,this._showJumpTo=!1,this._disabled=!1,this._pageSizeOptions=[10,25,50],this._handleClick=t=>{const e=t.target.closest("button[data-action]");if(!e||e.disabled)return;switch(e.dataset.action){case"first":this._goToPage(1,"first");break;case"prev":this._goToPage(this._currentPage-1,"prev");break;case"page":{const s=parseInt(e.dataset.page??"",10);isNaN(s)||this._goToPage(s,"page");break}case"next":this._goToPage(this._currentPage+1,"next");break;case"last":this._goToPage(this._totalPages,"last");break}},this._handleChange=t=>{const e=t.target;if(!e.matches("[data-compa11y-pagination-pagesize]"))return;const i=parseInt(e.value,10);this._pageSize=i,this._recomputeTotalPages(),this._currentPage=1,this._syncUI(),this._totalItems!=null?l.announcePolite(`Showing 1–${Math.min(i,this._totalItems)} of ${this._totalItems}`):l.announcePolite(`Page 1 of ${this._totalPages}`),this.emit("page-change",{page:1}),this.emit("page-size-change",{pageSize:i})},this._handleKeyDown=t=>{var r;const e=t.target;if(!e.matches("[data-compa11y-pagination-jump]")||t.key!=="Enter")return;const i=e,s=parseInt(i.value,10),a=(r=this.shadowRoot)==null?void 0:r.querySelector("[data-compa11y-pagination-error]");if(isNaN(s)||s<1||s>this._totalPages){a&&(a.textContent=`Enter a page between 1 and ${this._totalPages}`,a.style.display="",i.setAttribute("aria-describedby",`${this._id}-jump-error`));return}a&&(a.textContent="",a.style.display="none",i.removeAttribute("aria-describedby")),this._goToPage(s,"page"),i.value=""}}static get observedAttributes(){return["current-page","total-pages","total-items","page-size","page-size-options","show-first-last","show-page-size","show-jump-to","sibling-count","boundary-count","disabled","aria-label"]}get currentPage(){return this._currentPage}set currentPage(t){const e=Math.max(1,Math.min(t,this._totalPages));e!==this._currentPage&&(this._currentPage=e,this._syncUI())}get totalPages(){return this._totalPages}set totalPages(t){this._totalPages=Math.max(1,t),this._syncUI()}setupAccessibility(){this._readAttributes()}render(){const t=this.attachShadow({mode:"open"});t.innerHTML=`
|
|
2726
|
+
<style>${Ht}</style>
|
|
2727
|
+
<nav part="nav" data-compa11y-pagination>
|
|
2728
|
+
<div
|
|
2729
|
+
class="sr-only"
|
|
2730
|
+
role="status"
|
|
2731
|
+
aria-live="polite"
|
|
2732
|
+
aria-atomic="true"
|
|
2733
|
+
part="live-region"
|
|
2734
|
+
></div>
|
|
2735
|
+
<ul part="list"></ul>
|
|
2736
|
+
<div class="extras" part="extras"></div>
|
|
2737
|
+
</nav>
|
|
2738
|
+
`,this._syncUI()}setupEventListeners(){const t=this.shadowRoot;t==null||t.addEventListener("click",this._handleClick),t==null||t.addEventListener("change",this._handleChange),t==null||t.addEventListener("keydown",this._handleKeyDown)}cleanupEventListeners(){const t=this.shadowRoot;t==null||t.removeEventListener("click",this._handleClick),t==null||t.removeEventListener("change",this._handleChange),t==null||t.removeEventListener("keydown",this._handleKeyDown)}onAttributeChange(t,e,i){var s;switch(t){case"current-page":this._currentPage=Math.max(1,Math.min(parseInt(i??"1",10),this._totalPages));break;case"total-pages":this._totalPages=Math.max(1,parseInt(i??"1",10));break;case"total-items":this._totalItems=i!=null?parseInt(i,10):null,this._recomputeTotalPages();break;case"page-size":this._pageSize=Math.max(1,parseInt(i??"25",10)),this._recomputeTotalPages();break;case"page-size-options":i&&(this._pageSizeOptions=i.split(",").map(a=>parseInt(a.trim(),10)).filter(a=>!isNaN(a)&&a>0));break;case"show-first-last":this._showFirstLast=i!==null;break;case"show-page-size":this._showPageSize=i!==null;break;case"show-jump-to":this._showJumpTo=i!==null;break;case"sibling-count":this._siblingCount=Math.max(0,parseInt(i??"1",10));break;case"boundary-count":this._boundaryCount=Math.max(0,parseInt(i??"1",10));break;case"disabled":this._disabled=i!==null;break;case"aria-label":{const a=(s=this.shadowRoot)==null?void 0:s.querySelector("nav");a&&a.setAttribute("aria-label",i??"Pagination");return}}this._syncUI()}_readAttributes(){const t=i=>this.getAttribute(i);this._currentPage=Math.max(1,parseInt(t("current-page")??"1",10)),this._totalPages=Math.max(1,parseInt(t("total-pages")??"1",10)),this._totalItems=t("total-items")!=null?parseInt(t("total-items"),10):null,this._pageSize=Math.max(1,parseInt(t("page-size")??"25",10)),this._siblingCount=Math.max(0,parseInt(t("sibling-count")??"1",10)),this._boundaryCount=Math.max(0,parseInt(t("boundary-count")??"1",10)),this._showFirstLast=this.hasAttribute("show-first-last"),this._showPageSize=this.hasAttribute("show-page-size"),this._showJumpTo=this.hasAttribute("show-jump-to"),this._disabled=this.hasAttribute("disabled");const e=t("page-size-options");e&&(this._pageSizeOptions=e.split(",").map(i=>parseInt(i.trim(),10)).filter(i=>!isNaN(i)&&i>0)),this._recomputeTotalPages(),this._devWarnings()}_recomputeTotalPages(){this._totalItems!=null&&(this._totalPages=Math.max(1,Math.ceil(this._totalItems/this._pageSize)))}_devWarnings(){this.hasAttribute("total-pages")||this.hasAttribute("total-items")||ie.error("Either total-pages or total-items attribute is required.",'Add total-pages="n" or total-items="n" to <a11y-pagination>.')}_ariaLabel(){return this.getAttribute("aria-label")??"Pagination"}_announce(t){var i;const e=(i=this.shadowRoot)==null?void 0:i.querySelector('[role="status"]');e&&(e.textContent=t,setTimeout(()=>{e.textContent=""},1e3))}_goToPage(t,e){if(!(t<1||t>this._totalPages||t===this._currentPage)){if(this._currentPage=t,this._syncUI(),e!==void 0){const i=e;requestAnimationFrame(()=>this._restoreFocus(i,t))}this._announce(`Page ${t} of ${this._totalPages}`),this.emit("page-change",{page:t})}}_restoreFocus(t,e){if(!this.shadowRoot)return;let i=null;t==="page"?i=this.shadowRoot.querySelector(`button[data-page="${e}"]`):(i=this.shadowRoot.querySelector(`button[data-action="${t}"]`),i&&i.disabled&&(t==="prev"||t==="first"?i=this.shadowRoot.querySelector('button[data-action="next"]:not([disabled])')??this.shadowRoot.querySelector('button[data-action="last"]:not([disabled])'):i=this.shadowRoot.querySelector('button[data-action="prev"]:not([disabled])')??this.shadowRoot.querySelector('button[data-action="first"]:not([disabled])'))),i==null||i.focus()}_syncUI(){if(!this.shadowRoot)return;const t=this.shadowRoot.querySelector("nav");t&&t.setAttribute("aria-label",this._ariaLabel()),this._renderList(),this._renderExtras()}_renderList(){var o;const t=(o=this.shadowRoot)==null?void 0:o.querySelector("ul");if(!t)return;const e=this._currentPage<=1,i=this._currentPage>=this._totalPages,s=this._disabled,a=[];this._showFirstLast&&a.push(`<li>
|
|
2739
|
+
<button
|
|
2740
|
+
type="button"
|
|
2741
|
+
aria-label="First page"
|
|
2742
|
+
data-compa11y-pagination-btn
|
|
2743
|
+
data-action="first"
|
|
2744
|
+
${e||s?"disabled":""}
|
|
2745
|
+
part="btn btn-first"
|
|
2746
|
+
>«</button>
|
|
2747
|
+
</li>`),a.push(`<li>
|
|
2748
|
+
<button
|
|
2749
|
+
type="button"
|
|
2750
|
+
aria-label="Previous page"
|
|
2751
|
+
data-compa11y-pagination-btn
|
|
2752
|
+
data-action="prev"
|
|
2753
|
+
${e||s?"disabled":""}
|
|
2754
|
+
part="btn btn-prev"
|
|
2755
|
+
>‹</button>
|
|
2756
|
+
</li>`);const r=se(this._currentPage,this._totalPages,this._siblingCount,this._boundaryCount);for(const n of r){if(n==="ellipsis-start"||n==="ellipsis-end"){a.push('<li aria-hidden="true" part="ellipsis"><span>…</span></li>');continue}const c=n===this._currentPage;a.push(`<li>
|
|
2757
|
+
<button
|
|
2758
|
+
type="button"
|
|
2759
|
+
aria-label="Page ${n}"
|
|
2760
|
+
${c?'aria-current="page"':""}
|
|
2761
|
+
${s?"disabled":""}
|
|
2762
|
+
data-compa11y-pagination-btn
|
|
2763
|
+
data-compa11y-pagination-page
|
|
2764
|
+
data-current="${c}"
|
|
2765
|
+
data-action="page"
|
|
2766
|
+
data-page="${n}"
|
|
2767
|
+
part="btn btn-page${c?" btn-current":""}"
|
|
2768
|
+
>${n}</button>
|
|
2769
|
+
</li>`)}a.push(`<li>
|
|
2770
|
+
<button
|
|
2771
|
+
type="button"
|
|
2772
|
+
aria-label="Next page"
|
|
2773
|
+
data-compa11y-pagination-btn
|
|
2774
|
+
data-action="next"
|
|
2775
|
+
${i||s?"disabled":""}
|
|
2776
|
+
part="btn btn-next"
|
|
2777
|
+
>›</button>
|
|
2778
|
+
</li>`),this._showFirstLast&&a.push(`<li>
|
|
2779
|
+
<button
|
|
2780
|
+
type="button"
|
|
2781
|
+
aria-label="Last page"
|
|
2782
|
+
data-compa11y-pagination-btn
|
|
2783
|
+
data-action="last"
|
|
2784
|
+
${i||s?"disabled":""}
|
|
2785
|
+
part="btn btn-last"
|
|
2786
|
+
>»</button>
|
|
2787
|
+
</li>`),t.innerHTML=a.join("")}_renderExtras(){var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector(".extras");if(!t)return;const e=[];if(this._showPageSize){const s=this._pageSizeOptions.map(a=>`<option value="${a}"${a===this._pageSize?" selected":""}>${a}</option>`).join("");e.push(`<div class="page-size-wrapper" part="page-size-wrapper">
|
|
2788
|
+
<label for="${this._id}-pagesize">Rows per page</label>
|
|
2789
|
+
<select
|
|
2790
|
+
id="${this._id}-pagesize"
|
|
2791
|
+
data-compa11y-pagination-pagesize
|
|
2792
|
+
${this._disabled?"disabled":""}
|
|
2793
|
+
part="page-size-select"
|
|
2794
|
+
>${s}</select>
|
|
2795
|
+
</div>`)}this._showJumpTo&&e.push(`<div class="jump-wrapper" part="jump-wrapper">
|
|
2796
|
+
<label for="${this._id}-jump">Go to page</label>
|
|
2797
|
+
<input
|
|
2798
|
+
id="${this._id}-jump"
|
|
2799
|
+
type="number"
|
|
2800
|
+
min="1"
|
|
2801
|
+
max="${this._totalPages}"
|
|
2802
|
+
data-compa11y-pagination-jump
|
|
2803
|
+
${this._disabled?"disabled":""}
|
|
2804
|
+
part="jump-input"
|
|
2805
|
+
/>
|
|
2806
|
+
<span
|
|
2807
|
+
id="${this._id}-jump-error"
|
|
2808
|
+
role="alert"
|
|
2809
|
+
data-compa11y-pagination-error
|
|
2810
|
+
part="jump-error"
|
|
2811
|
+
style="display:none"
|
|
2812
|
+
></span>
|
|
2813
|
+
</div>`),t.innerHTML=e.join("")}goTo(t){this._goToPage(t)}next(){this._goToPage(this._currentPage+1)}previous(){this._goToPage(this._currentPage-1)}}if(g("a11y-pagination",rt),typeof window<"u"){const d=()=>{l.initAnnouncer(),l.initFocusVisible()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d(),window.compa11y={A11yDialog:D,A11yMenu:q,A11yTabs:O,A11yCombobox:R,A11ySwitch:P,A11ySelect:H,A11yInput:M,A11yTextarea:B,A11yButton:F,A11yListbox:N,A11yOption:j,A11yOptgroup:K,A11yCheckbox:I,A11yCheckboxGroup:Y,A11yRadioGroup:U,A11yRadio:G,A11yToast:V,A11yVisuallyHidden:W,A11ySkipLink:X,A11yAlert:J,A11yLink:Q,A11yHeading:Z,A11yText:tt,A11yFormField:et,A11yPopover:it,A11yAccordion:st,A11yTable:at,A11yPagination:rt,initAnnouncer:l.initAnnouncer,announce:l.announce,announcePolite:l.announcePolite,announceAssertive:l.announceAssertive,announceStatus:l.announceStatus,announceError:l.announceError,initFocusVisible:l.initFocusVisible,createFocusTrap:l.createFocusTrap,createFocusScope:l.createFocusScope,createRovingTabindex:l.createRovingTabindex,createKeyboardManager:l.createKeyboardManager,KeyboardPatterns:l.KeyboardPatterns,createTypeAhead:l.createTypeAhead,aria:l.aria,buildAriaProps:l.buildAriaProps,hasAccessibleName:l.hasAccessibleName,isBrowser:l.isBrowser,prefersReducedMotion:l.prefersReducedMotion,prefersHighContrast:l.prefersHighContrast,prefersDarkMode:l.prefersDarkMode}}return Object.defineProperty(h,"KeyboardPatterns",{enumerable:!0,get:()=>l.KeyboardPatterns}),Object.defineProperty(h,"announce",{enumerable:!0,get:()=>l.announce}),Object.defineProperty(h,"announceAssertive",{enumerable:!0,get:()=>l.announceAssertive}),Object.defineProperty(h,"announceError",{enumerable:!0,get:()=>l.announceError}),Object.defineProperty(h,"announcePolite",{enumerable:!0,get:()=>l.announcePolite}),Object.defineProperty(h,"announceStatus",{enumerable:!0,get:()=>l.announceStatus}),Object.defineProperty(h,"aria",{enumerable:!0,get:()=>l.aria}),Object.defineProperty(h,"buildAriaProps",{enumerable:!0,get:()=>l.buildAriaProps}),Object.defineProperty(h,"createFocusScope",{enumerable:!0,get:()=>l.createFocusScope}),Object.defineProperty(h,"createFocusTrap",{enumerable:!0,get:()=>l.createFocusTrap}),Object.defineProperty(h,"createKeyboardManager",{enumerable:!0,get:()=>l.createKeyboardManager}),Object.defineProperty(h,"createRovingTabindex",{enumerable:!0,get:()=>l.createRovingTabindex}),Object.defineProperty(h,"createTypeAhead",{enumerable:!0,get:()=>l.createTypeAhead}),Object.defineProperty(h,"hasAccessibleName",{enumerable:!0,get:()=>l.hasAccessibleName}),Object.defineProperty(h,"initAnnouncer",{enumerable:!0,get:()=>l.initAnnouncer}),Object.defineProperty(h,"initFocusVisible",{enumerable:!0,get:()=>l.initFocusVisible}),Object.defineProperty(h,"isBrowser",{enumerable:!0,get:()=>l.isBrowser}),Object.defineProperty(h,"prefersDarkMode",{enumerable:!0,get:()=>l.prefersDarkMode}),Object.defineProperty(h,"prefersHighContrast",{enumerable:!0,get:()=>l.prefersHighContrast}),Object.defineProperty(h,"prefersReducedMotion",{enumerable:!0,get:()=>l.prefersReducedMotion}),h.A11yAccordion=st,h.A11yAlert=J,h.A11yButton=F,h.A11yCheckbox=I,h.A11yCheckboxGroup=Y,h.A11yCombobox=R,h.A11yDialog=D,h.A11yFormField=et,h.A11yHeading=Z,h.A11yInput=M,h.A11yLink=Q,h.A11yListbox=N,h.A11yMenu=q,h.A11yOptgroup=K,h.A11yOption=j,h.A11yPagination=rt,h.A11yPopover=it,h.A11yRadio=G,h.A11yRadioGroup=U,h.A11ySelect=H,h.A11ySkipLink=X,h.A11ySwitch=P,h.A11yTable=at,h.A11yTabs=O,h.A11yText=tt,h.A11yTextarea=B,h.A11yToast=V,h.A11yVisuallyHidden=W,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),h}({},compa11yCore);
|