@compa11y/web 0.1.9 → 0.1.11
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 +705 -133
- package/dist/compa11y.js +1642 -311
- 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/popover.d.ts +52 -0
- package/dist/components/table.d.ts +78 -0
- package/dist/components/text.d.ts +16 -0
- package/dist/index.d.ts +7 -1
- package/dist/utils/styles.d.ts +5 -0
- package/package.json +2 -2
package/dist/compa11y.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { generateId as
|
|
2
|
-
import { KeyboardPatterns as
|
|
3
|
-
class
|
|
1
|
+
import { generateId as kt, announce as v, announcePolite as f, createTypeAhead as O, announceAssertive as R, createComponentWarnings as $, prefersDarkMode as wt, prefersHighContrast as St, prefersReducedMotion as Lt, isBrowser as $t, hasAccessibleName as It, buildAriaProps as Ct, aria as Tt, KeyboardPatterns as zt, createKeyboardManager as Dt, createRovingTabindex as qt, createFocusScope as Ot, createFocusTrap as Rt, initFocusVisible as B, announceError as Ht, announceStatus as Bt, initAnnouncer as M } from "@compa11y/core";
|
|
2
|
+
import { KeyboardPatterns as ke, announce as we, announceAssertive as Se, announceError as Le, announcePolite as $e, announceStatus as Ie, aria as Ce, buildAriaProps as Te, createFocusScope as ze, createFocusTrap as De, createKeyboardManager as qe, createRovingTabindex as Oe, createTypeAhead as Re, hasAccessibleName as He, initAnnouncer as Be, initFocusVisible as Me, isBrowser as Ke, prefersDarkMode as Fe, prefersHighContrast as Pe, prefersReducedMotion as Ne } from "@compa11y/core";
|
|
3
|
+
class u extends HTMLElement {
|
|
4
4
|
constructor() {
|
|
5
|
-
super(), this._internals = null, this._id =
|
|
5
|
+
super(), this._internals = null, this._id = kt(this.tagName.toLowerCase().replace("a11y-", "")), "attachInternals" in this && (this._internals = this.attachInternals());
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Standard observed attributes
|
|
@@ -74,10 +74,10 @@ class h extends HTMLElement {
|
|
|
74
74
|
return (i == null ? void 0 : i.assignedElements()) ?? [];
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
customElements.get(
|
|
77
|
+
function b(l, t) {
|
|
78
|
+
customElements.get(l) || customElements.define(l, t);
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const V = `
|
|
81
81
|
position: absolute;
|
|
82
82
|
width: 1px;
|
|
83
83
|
height: 1px;
|
|
@@ -87,7 +87,7 @@ const F = `
|
|
|
87
87
|
clip: rect(0, 0, 0, 0);
|
|
88
88
|
white-space: nowrap;
|
|
89
89
|
border: 0;
|
|
90
|
-
`,
|
|
90
|
+
`, z = `
|
|
91
91
|
appearance: none;
|
|
92
92
|
background: none;
|
|
93
93
|
border: none;
|
|
@@ -96,13 +96,13 @@ const F = `
|
|
|
96
96
|
font: inherit;
|
|
97
97
|
color: inherit;
|
|
98
98
|
cursor: pointer;
|
|
99
|
-
`,
|
|
99
|
+
`, G = `
|
|
100
100
|
:host(:focus-visible),
|
|
101
101
|
:focus-visible {
|
|
102
102
|
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
103
103
|
outline-offset: 2px;
|
|
104
104
|
}
|
|
105
|
-
`,
|
|
105
|
+
`, g = `
|
|
106
106
|
:host {
|
|
107
107
|
display: block;
|
|
108
108
|
box-sizing: border-box;
|
|
@@ -118,9 +118,9 @@ const F = `
|
|
|
118
118
|
box-sizing: inherit;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
${
|
|
122
|
-
`,
|
|
123
|
-
${
|
|
121
|
+
${G}
|
|
122
|
+
`, Mt = `
|
|
123
|
+
${g}
|
|
124
124
|
|
|
125
125
|
:host {
|
|
126
126
|
position: fixed;
|
|
@@ -158,8 +158,8 @@ const F = `
|
|
|
158
158
|
margin: 0 0 1rem 0;
|
|
159
159
|
color: var(--compa11y-dialog-description-color, #666);
|
|
160
160
|
}
|
|
161
|
-
`,
|
|
162
|
-
${
|
|
161
|
+
`, Kt = `
|
|
162
|
+
${g}
|
|
163
163
|
|
|
164
164
|
:host {
|
|
165
165
|
position: relative;
|
|
@@ -210,8 +210,8 @@ const F = `
|
|
|
210
210
|
margin: 0.25rem 0;
|
|
211
211
|
background: var(--compa11y-menu-separator-color, #e0e0e0);
|
|
212
212
|
}
|
|
213
|
-
`,
|
|
214
|
-
${
|
|
213
|
+
`, Ft = `
|
|
214
|
+
${g}
|
|
215
215
|
|
|
216
216
|
.tablist {
|
|
217
217
|
display: flex;
|
|
@@ -226,7 +226,7 @@ const F = `
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
::slotted([role="tab"]) {
|
|
229
|
-
${
|
|
229
|
+
${z}
|
|
230
230
|
padding: var(--compa11y-tab-padding, 0.75rem 1rem);
|
|
231
231
|
border-bottom: 2px solid transparent;
|
|
232
232
|
margin-bottom: -1px;
|
|
@@ -256,8 +256,8 @@ const F = `
|
|
|
256
256
|
::slotted([role="tabpanel"][hidden]) {
|
|
257
257
|
display: none;
|
|
258
258
|
}
|
|
259
|
-
`,
|
|
260
|
-
${
|
|
259
|
+
`, Pt = `
|
|
260
|
+
${g}
|
|
261
261
|
|
|
262
262
|
:host {
|
|
263
263
|
display: inline-block;
|
|
@@ -315,7 +315,7 @@ const F = `
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
.clear-button {
|
|
318
|
-
${
|
|
318
|
+
${z}
|
|
319
319
|
position: absolute;
|
|
320
320
|
right: 1.5rem;
|
|
321
321
|
width: 1.25rem;
|
|
@@ -397,8 +397,8 @@ const F = `
|
|
|
397
397
|
.options-source {
|
|
398
398
|
display: none;
|
|
399
399
|
}
|
|
400
|
-
`,
|
|
401
|
-
${
|
|
400
|
+
`, Nt = `
|
|
401
|
+
${g}
|
|
402
402
|
|
|
403
403
|
:host {
|
|
404
404
|
display: inline-block;
|
|
@@ -527,8 +527,8 @@ const F = `
|
|
|
527
527
|
.options-source {
|
|
528
528
|
display: none;
|
|
529
529
|
}
|
|
530
|
-
`,
|
|
531
|
-
${
|
|
530
|
+
`, jt = `
|
|
531
|
+
${g}
|
|
532
532
|
|
|
533
533
|
:host {
|
|
534
534
|
display: inline-block;
|
|
@@ -631,8 +631,8 @@ const F = `
|
|
|
631
631
|
opacity: 0.5;
|
|
632
632
|
cursor: not-allowed;
|
|
633
633
|
}
|
|
634
|
-
`,
|
|
635
|
-
${
|
|
634
|
+
`, Yt = `
|
|
635
|
+
${g}
|
|
636
636
|
|
|
637
637
|
:host {
|
|
638
638
|
display: block;
|
|
@@ -710,8 +710,8 @@ const F = `
|
|
|
710
710
|
color: var(--compa11y-input-error-color, #ef4444);
|
|
711
711
|
font-size: var(--compa11y-input-error-size, 0.8125rem);
|
|
712
712
|
}
|
|
713
|
-
`,
|
|
714
|
-
${
|
|
713
|
+
`, Vt = `
|
|
714
|
+
${g}
|
|
715
715
|
|
|
716
716
|
:host {
|
|
717
717
|
display: block;
|
|
@@ -791,8 +791,8 @@ const F = `
|
|
|
791
791
|
color: var(--compa11y-textarea-error-color, #ef4444);
|
|
792
792
|
font-size: var(--compa11y-textarea-error-size, 0.8125rem);
|
|
793
793
|
}
|
|
794
|
-
`,
|
|
795
|
-
${
|
|
794
|
+
`, Gt = `
|
|
795
|
+
${g}
|
|
796
796
|
|
|
797
797
|
:host {
|
|
798
798
|
display: inline-block;
|
|
@@ -906,8 +906,8 @@ const F = `
|
|
|
906
906
|
border-radius: 50%;
|
|
907
907
|
animation: compa11y-spin 0.6s linear infinite;
|
|
908
908
|
}
|
|
909
|
-
`,
|
|
910
|
-
${
|
|
909
|
+
`, Ut = `
|
|
910
|
+
${g}
|
|
911
911
|
|
|
912
912
|
:host {
|
|
913
913
|
display: block;
|
|
@@ -940,8 +940,8 @@ const F = `
|
|
|
940
940
|
max-height: none;
|
|
941
941
|
overflow-y: visible;
|
|
942
942
|
}
|
|
943
|
-
`,
|
|
944
|
-
${
|
|
943
|
+
`, Xt = `
|
|
944
|
+
${g}
|
|
945
945
|
|
|
946
946
|
:host {
|
|
947
947
|
display: block;
|
|
@@ -989,8 +989,8 @@ const F = `
|
|
|
989
989
|
:host([aria-selected="true"]) .check-mark {
|
|
990
990
|
visibility: visible;
|
|
991
991
|
}
|
|
992
|
-
`,
|
|
993
|
-
${
|
|
992
|
+
`, Wt = `
|
|
993
|
+
${g}
|
|
994
994
|
|
|
995
995
|
:host {
|
|
996
996
|
display: block;
|
|
@@ -1008,8 +1008,8 @@ const F = `
|
|
|
1008
1008
|
:host([disabled]) {
|
|
1009
1009
|
opacity: 0.5;
|
|
1010
1010
|
}
|
|
1011
|
-
`,
|
|
1012
|
-
${
|
|
1011
|
+
`, Jt = `
|
|
1012
|
+
${g}
|
|
1013
1013
|
|
|
1014
1014
|
:host {
|
|
1015
1015
|
display: inline-block;
|
|
@@ -1171,8 +1171,8 @@ const F = `
|
|
|
1171
1171
|
color: HighlightText;
|
|
1172
1172
|
}
|
|
1173
1173
|
}
|
|
1174
|
-
`,
|
|
1175
|
-
${
|
|
1174
|
+
`, Qt = `
|
|
1175
|
+
${g}
|
|
1176
1176
|
|
|
1177
1177
|
:host {
|
|
1178
1178
|
display: block;
|
|
@@ -1213,8 +1213,8 @@ const F = `
|
|
|
1213
1213
|
:host([disabled]) {
|
|
1214
1214
|
opacity: 0.5;
|
|
1215
1215
|
}
|
|
1216
|
-
`,
|
|
1217
|
-
${
|
|
1216
|
+
`, Zt = `
|
|
1217
|
+
${g}
|
|
1218
1218
|
|
|
1219
1219
|
:host {
|
|
1220
1220
|
display: block;
|
|
@@ -1266,8 +1266,8 @@ const F = `
|
|
|
1266
1266
|
:host([disabled]) {
|
|
1267
1267
|
opacity: 0.5;
|
|
1268
1268
|
}
|
|
1269
|
-
`,
|
|
1270
|
-
${
|
|
1269
|
+
`, te = `
|
|
1270
|
+
${g}
|
|
1271
1271
|
|
|
1272
1272
|
:host {
|
|
1273
1273
|
display: inline-block;
|
|
@@ -1386,8 +1386,8 @@ const F = `
|
|
|
1386
1386
|
background: HighlightText;
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
1389
|
-
`,
|
|
1390
|
-
${
|
|
1389
|
+
`, ee = `
|
|
1390
|
+
${g}
|
|
1391
1391
|
|
|
1392
1392
|
:host {
|
|
1393
1393
|
position: fixed;
|
|
@@ -1455,7 +1455,7 @@ const F = `
|
|
|
1455
1455
|
}
|
|
1456
1456
|
|
|
1457
1457
|
.toast-close {
|
|
1458
|
-
${
|
|
1458
|
+
${z}
|
|
1459
1459
|
flex-shrink: 0;
|
|
1460
1460
|
width: 1.5rem;
|
|
1461
1461
|
height: 1.5rem;
|
|
@@ -1479,7 +1479,7 @@ const F = `
|
|
|
1479
1479
|
}
|
|
1480
1480
|
|
|
1481
1481
|
.toast-action {
|
|
1482
|
-
${
|
|
1482
|
+
${z}
|
|
1483
1483
|
margin-top: 0.375rem;
|
|
1484
1484
|
font-size: var(--compa11y-toast-action-size, 0.8125rem);
|
|
1485
1485
|
font-weight: 500;
|
|
@@ -1495,15 +1495,258 @@ const F = `
|
|
|
1495
1495
|
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
1496
1496
|
outline-offset: 2px;
|
|
1497
1497
|
}
|
|
1498
|
-
`,
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1498
|
+
`, ie = `
|
|
1499
|
+
a11y-accordion {
|
|
1500
|
+
display: block;
|
|
1501
|
+
border: 1px solid var(--compa11y-accordion-border-color, #e0e0e0);
|
|
1502
|
+
border-radius: var(--compa11y-accordion-radius, 6px);
|
|
1503
|
+
overflow: hidden;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
a11y-accordion h1,
|
|
1507
|
+
a11y-accordion h2,
|
|
1508
|
+
a11y-accordion h3,
|
|
1509
|
+
a11y-accordion h4,
|
|
1510
|
+
a11y-accordion h5,
|
|
1511
|
+
a11y-accordion h6 {
|
|
1512
|
+
margin: 0;
|
|
1513
|
+
font-size: inherit;
|
|
1514
|
+
font-weight: inherit;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
a11y-accordion [data-accordion-trigger] {
|
|
1518
|
+
appearance: none;
|
|
1519
|
+
-webkit-appearance: none;
|
|
1520
|
+
background: var(--compa11y-accordion-trigger-bg, #ffffff);
|
|
1521
|
+
border: none;
|
|
1522
|
+
border-bottom: 1px solid var(--compa11y-accordion-border-color, #e0e0e0);
|
|
1523
|
+
padding: var(--compa11y-accordion-trigger-padding, 1rem);
|
|
1524
|
+
font: inherit;
|
|
1525
|
+
font-size: 1rem;
|
|
1526
|
+
font-weight: 500;
|
|
1527
|
+
color: var(--compa11y-accordion-trigger-color, #1a1a1a);
|
|
1528
|
+
width: 100%;
|
|
1529
|
+
text-align: left;
|
|
1530
|
+
cursor: pointer;
|
|
1531
|
+
display: flex;
|
|
1532
|
+
align-items: center;
|
|
1533
|
+
justify-content: space-between;
|
|
1534
|
+
gap: 0.5rem;
|
|
1535
|
+
transition: background 0.15s ease;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
a11y-accordion [data-accordion-trigger]:hover {
|
|
1539
|
+
background: var(--compa11y-accordion-trigger-hover-bg, #f9f9f9);
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
a11y-accordion [data-accordion-trigger]:focus-visible {
|
|
1543
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
1544
|
+
outline-offset: -2px;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
a11y-accordion [data-accordion-trigger][aria-disabled="true"],
|
|
1548
|
+
a11y-accordion [data-accordion-trigger]:disabled {
|
|
1549
|
+
opacity: 0.5;
|
|
1550
|
+
cursor: not-allowed;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
a11y-accordion [data-accordion-trigger]::after {
|
|
1554
|
+
content: '';
|
|
1555
|
+
flex-shrink: 0;
|
|
1556
|
+
width: 0.5rem;
|
|
1557
|
+
height: 0.5rem;
|
|
1558
|
+
border-right: 2px solid currentColor;
|
|
1559
|
+
border-bottom: 2px solid currentColor;
|
|
1560
|
+
transform: rotate(45deg) translateY(-2px);
|
|
1561
|
+
transition: transform 0.2s ease;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
a11y-accordion [data-accordion-trigger][aria-expanded="true"]::after {
|
|
1565
|
+
transform: rotate(-135deg) translateY(-2px);
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
a11y-accordion [data-accordion-panel] {
|
|
1569
|
+
padding: var(--compa11y-accordion-content-padding, 1rem);
|
|
1570
|
+
background: var(--compa11y-accordion-content-bg, #ffffff);
|
|
1571
|
+
border-bottom: 1px solid var(--compa11y-accordion-border-color, #e0e0e0);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
a11y-accordion [data-accordion-panel][hidden] {
|
|
1575
|
+
display: none;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
a11y-accordion > *:last-child [data-accordion-trigger],
|
|
1579
|
+
a11y-accordion > [data-accordion-panel]:last-child {
|
|
1580
|
+
border-bottom: none;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1584
|
+
a11y-accordion [data-accordion-trigger],
|
|
1585
|
+
a11y-accordion [data-accordion-trigger]::after {
|
|
1586
|
+
transition: none;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
@media (forced-colors: active) {
|
|
1591
|
+
a11y-accordion {
|
|
1592
|
+
border: 2px solid ButtonText;
|
|
1593
|
+
}
|
|
1594
|
+
a11y-accordion [data-accordion-trigger] {
|
|
1595
|
+
border-bottom: 1px solid ButtonText;
|
|
1596
|
+
forced-color-adjust: none;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
`, se = `
|
|
1600
|
+
/* ── Host ── */
|
|
1601
|
+
a11y-table {
|
|
1602
|
+
display: block;
|
|
1603
|
+
overflow-x: auto;
|
|
1604
|
+
-webkit-overflow-scrolling: touch;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
/* ── Table element ── */
|
|
1608
|
+
a11y-table table {
|
|
1609
|
+
border-collapse: collapse;
|
|
1610
|
+
width: 100%;
|
|
1611
|
+
font-size: 0.9375rem;
|
|
1612
|
+
color: var(--compa11y-table-color, #1a1a1a);
|
|
1613
|
+
background: var(--compa11y-table-bg, #ffffff);
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
/* ── Caption ── */
|
|
1617
|
+
a11y-table caption {
|
|
1618
|
+
caption-side: top;
|
|
1619
|
+
text-align: left;
|
|
1620
|
+
font-weight: 600;
|
|
1621
|
+
font-size: 1rem;
|
|
1622
|
+
padding-bottom: 0.5rem;
|
|
1623
|
+
color: var(--compa11y-table-caption-color, #1a1a1a);
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
/* ── Header cells ── */
|
|
1627
|
+
a11y-table th {
|
|
1628
|
+
text-align: left;
|
|
1629
|
+
font-weight: 600;
|
|
1630
|
+
padding: var(--compa11y-table-cell-padding, 0.625rem 0.875rem);
|
|
1631
|
+
background: var(--compa11y-table-head-bg, #f5f5f5);
|
|
1632
|
+
border-bottom: 2px solid var(--compa11y-table-border-color, #d0d0d0);
|
|
1633
|
+
white-space: nowrap;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
/* ── Data cells ── */
|
|
1637
|
+
a11y-table td {
|
|
1638
|
+
padding: var(--compa11y-table-cell-padding, 0.625rem 0.875rem);
|
|
1639
|
+
border-bottom: 1px solid var(--compa11y-table-border-color, #e8e8e8);
|
|
1640
|
+
vertical-align: top;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
/* ── Row hover ── */
|
|
1644
|
+
a11y-table tbody tr:hover {
|
|
1645
|
+
background: var(--compa11y-table-row-hover-bg, #fafafa);
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
/* ── Selected row ── */
|
|
1649
|
+
a11y-table tr[aria-selected="true"] {
|
|
1650
|
+
background: var(--compa11y-table-selected-bg, #e8f0fe);
|
|
1651
|
+
}
|
|
1652
|
+
a11y-table tr[aria-selected="true"]:hover {
|
|
1653
|
+
background: var(--compa11y-table-selected-hover-bg, #dde7fd);
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
/* ── Sort button ── */
|
|
1657
|
+
a11y-table [data-sort-btn] {
|
|
1658
|
+
appearance: none;
|
|
1659
|
+
-webkit-appearance: none;
|
|
1660
|
+
background: none;
|
|
1661
|
+
border: none;
|
|
1662
|
+
padding: 0;
|
|
1663
|
+
margin: 0;
|
|
1664
|
+
font: inherit;
|
|
1665
|
+
color: inherit;
|
|
1666
|
+
cursor: pointer;
|
|
1667
|
+
display: inline-flex;
|
|
1668
|
+
align-items: center;
|
|
1669
|
+
gap: 0.375em;
|
|
1670
|
+
text-align: left;
|
|
1671
|
+
width: 100%;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
a11y-table [data-sort-btn]:focus-visible {
|
|
1675
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
1676
|
+
outline-offset: 2px;
|
|
1677
|
+
border-radius: 2px;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
a11y-table [data-sort-icon] {
|
|
1681
|
+
font-size: 0.75em;
|
|
1682
|
+
opacity: 0.6;
|
|
1683
|
+
flex-shrink: 0;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
/* ── Select checkboxes ── */
|
|
1687
|
+
a11y-table [data-select-cb] {
|
|
1688
|
+
cursor: pointer;
|
|
1689
|
+
width: 1rem;
|
|
1690
|
+
height: 1rem;
|
|
1691
|
+
}
|
|
1692
|
+
a11y-table [data-select-cb]:focus-visible {
|
|
1693
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
1694
|
+
outline-offset: 2px;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
/* ── Empty / Loading cells ── */
|
|
1698
|
+
a11y-table [data-empty-cell],
|
|
1699
|
+
a11y-table [data-loading-cell] {
|
|
1700
|
+
text-align: center;
|
|
1701
|
+
padding: 2rem 1rem;
|
|
1702
|
+
color: var(--compa11y-table-muted-color, #6b6b6b);
|
|
1703
|
+
font-style: italic;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
/* ── Footer ── */
|
|
1707
|
+
a11y-table tfoot td,
|
|
1708
|
+
a11y-table tfoot th {
|
|
1709
|
+
background: var(--compa11y-table-foot-bg, #f5f5f5);
|
|
1710
|
+
border-top: 2px solid var(--compa11y-table-border-color, #d0d0d0);
|
|
1711
|
+
border-bottom: none;
|
|
1712
|
+
font-weight: 600;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
/* ── Reduced motion ── */
|
|
1716
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1717
|
+
a11y-table tr,
|
|
1718
|
+
a11y-table td,
|
|
1719
|
+
a11y-table th {
|
|
1720
|
+
transition: none;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
/* ── Windows High Contrast ── */
|
|
1725
|
+
@media (forced-colors: active) {
|
|
1726
|
+
a11y-table table {
|
|
1727
|
+
border: 1px solid ButtonText;
|
|
1728
|
+
forced-color-adjust: none;
|
|
1729
|
+
}
|
|
1730
|
+
a11y-table th,
|
|
1731
|
+
a11y-table td {
|
|
1732
|
+
border: 1px solid ButtonText;
|
|
1733
|
+
}
|
|
1734
|
+
a11y-table tr[aria-selected="true"] {
|
|
1735
|
+
outline: 2px solid Highlight;
|
|
1736
|
+
}
|
|
1737
|
+
a11y-table [data-sort-btn]:focus-visible {
|
|
1738
|
+
outline: 2px solid Highlight;
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
`, K = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1742
|
+
let L = 0, U = "";
|
|
1743
|
+
function ae() {
|
|
1744
|
+
L === 0 && (U = document.body.style.overflow, document.body.style.overflow = "hidden"), L++;
|
|
1502
1745
|
}
|
|
1503
|
-
function
|
|
1504
|
-
L--, L <= 0 && (L = 0, document.body.style.overflow =
|
|
1746
|
+
function re() {
|
|
1747
|
+
L--, L <= 0 && (L = 0, document.body.style.overflow = U);
|
|
1505
1748
|
}
|
|
1506
|
-
class
|
|
1749
|
+
class X extends u {
|
|
1507
1750
|
constructor() {
|
|
1508
1751
|
super(...arguments), this._open = !1, this._previouslyFocused = null, this._triggerElement = null, this.handleTriggerClick = () => {
|
|
1509
1752
|
this.open = !0;
|
|
@@ -1522,13 +1765,13 @@ class j extends h {
|
|
|
1522
1765
|
if (i.length === 0) return;
|
|
1523
1766
|
const s = ((e = this.shadowRoot) == null ? void 0 : e.activeElement) || document.activeElement;
|
|
1524
1767
|
let a = i.findIndex(
|
|
1525
|
-
(
|
|
1768
|
+
(n) => n === s
|
|
1526
1769
|
);
|
|
1527
1770
|
a === -1 && (a = t.shiftKey ? 0 : i.length - 1);
|
|
1528
1771
|
let r;
|
|
1529
1772
|
t.shiftKey ? r = a === 0 ? i.length - 1 : a - 1 : r = a === i.length - 1 ? 0 : a + 1;
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1773
|
+
const o = i[r];
|
|
1774
|
+
o && o.focus();
|
|
1532
1775
|
}
|
|
1533
1776
|
}
|
|
1534
1777
|
};
|
|
@@ -1548,7 +1791,7 @@ class j extends h {
|
|
|
1548
1791
|
render() {
|
|
1549
1792
|
const t = this.attachShadow({ mode: "open" }), e = `${this._id}-title`, i = `${this._id}-desc`;
|
|
1550
1793
|
t.innerHTML = `
|
|
1551
|
-
<style>${
|
|
1794
|
+
<style>${Mt}</style>
|
|
1552
1795
|
<div class="overlay" part="overlay"></div>
|
|
1553
1796
|
<div
|
|
1554
1797
|
class="dialog"
|
|
@@ -1604,7 +1847,7 @@ class j extends h {
|
|
|
1604
1847
|
*/
|
|
1605
1848
|
getFocusableElements() {
|
|
1606
1849
|
const t = [];
|
|
1607
|
-
return this.querySelectorAll(
|
|
1850
|
+
return this.querySelectorAll(K).forEach((i) => t.push(i)), this.shadowRoot && this.shadowRoot.querySelectorAll(K).forEach((s) => {
|
|
1608
1851
|
s.classList.contains("overlay") || t.push(s);
|
|
1609
1852
|
}), t;
|
|
1610
1853
|
}
|
|
@@ -1612,11 +1855,11 @@ class j extends h {
|
|
|
1612
1855
|
this._previouslyFocused = document.activeElement, this.style.display = "flex", requestAnimationFrame(() => {
|
|
1613
1856
|
const e = this.getFocusableElements()[0];
|
|
1614
1857
|
e && e.focus();
|
|
1615
|
-
}),
|
|
1858
|
+
}), ae(), v("Dialog opened", { politeness: "polite" }), this.emit("a11y-dialog-open");
|
|
1616
1859
|
}
|
|
1617
1860
|
hideDialog() {
|
|
1618
1861
|
var t;
|
|
1619
|
-
this.style.display = "none",
|
|
1862
|
+
this.style.display = "none", re(), (t = this._previouslyFocused) == null || t.focus(), this._previouslyFocused = null, v("Dialog closed", { politeness: "polite" }), this.emit("a11y-dialog-close");
|
|
1620
1863
|
}
|
|
1621
1864
|
/**
|
|
1622
1865
|
* Programmatic open
|
|
@@ -1631,8 +1874,8 @@ class j extends h {
|
|
|
1631
1874
|
this.open = !1;
|
|
1632
1875
|
}
|
|
1633
1876
|
}
|
|
1634
|
-
|
|
1635
|
-
class
|
|
1877
|
+
b("a11y-dialog", X);
|
|
1878
|
+
class W extends u {
|
|
1636
1879
|
constructor() {
|
|
1637
1880
|
super(...arguments), this._open = !1, this._highlightedIndex = -1, this._menuItems = [], this._triggerEl = null, this._triggerSlotEl = null, this._defaultSlotEl = null, this.updateMenuItems = () => {
|
|
1638
1881
|
this._menuItems = Array.from(
|
|
@@ -1722,7 +1965,7 @@ class Y extends h {
|
|
|
1722
1965
|
render() {
|
|
1723
1966
|
const t = this.attachShadow({ mode: "open" });
|
|
1724
1967
|
t.innerHTML = `
|
|
1725
|
-
<style>${
|
|
1968
|
+
<style>${Kt}</style>
|
|
1726
1969
|
<slot name="trigger"></slot>
|
|
1727
1970
|
<div
|
|
1728
1971
|
class="menu-content"
|
|
@@ -1797,8 +2040,8 @@ class Y extends h {
|
|
|
1797
2040
|
this.open = !this._open;
|
|
1798
2041
|
}
|
|
1799
2042
|
}
|
|
1800
|
-
|
|
1801
|
-
class
|
|
2043
|
+
b("a11y-menu", W);
|
|
2044
|
+
class J extends u {
|
|
1802
2045
|
constructor() {
|
|
1803
2046
|
super(...arguments), this._tabs = [], this._panels = [], this._selectedIndex = 0, this._focusedIndex = 0, this._tabSlotEl = null, this._panelSlotEl = null, this._defaultSlotEl = null, this.updateTabsAndPanels = () => {
|
|
1804
2047
|
this._tabs = Array.from(
|
|
@@ -1816,7 +2059,7 @@ class U extends h {
|
|
|
1816
2059
|
i !== -1 && e.getAttribute("aria-disabled") !== "true" && (this._focusedIndex = i, this.selectTab(i));
|
|
1817
2060
|
}
|
|
1818
2061
|
}, this.handleKeyDown = (t) => {
|
|
1819
|
-
var
|
|
2062
|
+
var o;
|
|
1820
2063
|
if (t.target.getAttribute("role") !== "tab") return;
|
|
1821
2064
|
const i = this.orientation === "horizontal", s = i ? "ArrowRight" : "ArrowDown", a = i ? "ArrowLeft" : "ArrowUp";
|
|
1822
2065
|
let r = this._focusedIndex;
|
|
@@ -1840,7 +2083,7 @@ class U extends h {
|
|
|
1840
2083
|
default:
|
|
1841
2084
|
return;
|
|
1842
2085
|
}
|
|
1843
|
-
this._focusedIndex = r, (
|
|
2086
|
+
this._focusedIndex = r, (o = this._tabs[r]) == null || o.focus(), this.activationMode === "automatic" && this.selectTab(r);
|
|
1844
2087
|
};
|
|
1845
2088
|
}
|
|
1846
2089
|
static get observedAttributes() {
|
|
@@ -1864,7 +2107,7 @@ class U extends h {
|
|
|
1864
2107
|
render() {
|
|
1865
2108
|
const t = this.attachShadow({ mode: "open" });
|
|
1866
2109
|
t.innerHTML = `
|
|
1867
|
-
<style>${
|
|
2110
|
+
<style>${Ft}</style>
|
|
1868
2111
|
<div class="tablist" role="tablist" aria-orientation="${this.orientation}" part="tablist">
|
|
1869
2112
|
<slot name="tab"></slot>
|
|
1870
2113
|
</div>
|
|
@@ -1930,8 +2173,8 @@ class U extends h {
|
|
|
1930
2173
|
);
|
|
1931
2174
|
}
|
|
1932
2175
|
}
|
|
1933
|
-
|
|
1934
|
-
class
|
|
2176
|
+
b("a11y-tabs", J);
|
|
2177
|
+
class Q extends u {
|
|
1935
2178
|
constructor() {
|
|
1936
2179
|
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 = () => {
|
|
1937
2180
|
const t = Array.from(this.querySelectorAll("option"));
|
|
@@ -2023,7 +2266,7 @@ class V extends h {
|
|
|
2023
2266
|
render() {
|
|
2024
2267
|
const t = this.attachShadow({ mode: "open" }), e = `${this._id}-input`, i = `${this._id}-listbox`, s = this.getAttribute("placeholder") || "Search...", a = this.hasAttribute("clearable");
|
|
2025
2268
|
t.innerHTML = `
|
|
2026
|
-
<style>${
|
|
2269
|
+
<style>${Pt}</style>
|
|
2027
2270
|
<div class="combobox-wrapper" part="wrapper">
|
|
2028
2271
|
<div class="input-wrapper" part="input-wrapper">
|
|
2029
2272
|
<input
|
|
@@ -2066,11 +2309,11 @@ class V extends h {
|
|
|
2066
2309
|
`, this._inputElement = t.querySelector("input"), this._listboxElement = t.querySelector(".listbox");
|
|
2067
2310
|
}
|
|
2068
2311
|
setupEventListeners() {
|
|
2069
|
-
var i, s, a, r,
|
|
2312
|
+
var i, s, a, r, o, n;
|
|
2070
2313
|
(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);
|
|
2071
|
-
const t = (
|
|
2314
|
+
const t = (o = this.shadowRoot) == null ? void 0 : o.querySelector(".clear-button");
|
|
2072
2315
|
t == null || t.addEventListener("click", this.handleClear), document.addEventListener("mousedown", this.handleOutsideClick);
|
|
2073
|
-
const e = (
|
|
2316
|
+
const e = (n = this.shadowRoot) == null ? void 0 : n.querySelector("slot");
|
|
2074
2317
|
e == null || e.addEventListener("slotchange", this.updateOptions), this.updateOptions();
|
|
2075
2318
|
}
|
|
2076
2319
|
cleanupEventListeners() {
|
|
@@ -2156,8 +2399,8 @@ class V extends h {
|
|
|
2156
2399
|
this.handleClear();
|
|
2157
2400
|
}
|
|
2158
2401
|
}
|
|
2159
|
-
|
|
2160
|
-
class
|
|
2402
|
+
b("a11y-combobox", Q);
|
|
2403
|
+
class Z extends u {
|
|
2161
2404
|
constructor() {
|
|
2162
2405
|
super(...arguments), this._checked = !1, this._button = null, this._label = null, this.handleClick = () => {
|
|
2163
2406
|
this.toggle();
|
|
@@ -2219,7 +2462,7 @@ class G extends h {
|
|
|
2219
2462
|
render() {
|
|
2220
2463
|
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}"` : "";
|
|
2221
2464
|
t.innerHTML = `
|
|
2222
|
-
<style>${
|
|
2465
|
+
<style>${jt}</style>
|
|
2223
2466
|
<div class="switch-wrapper size-${this.size}" part="wrapper">
|
|
2224
2467
|
<button
|
|
2225
2468
|
type="button"
|
|
@@ -2290,7 +2533,7 @@ class G extends h {
|
|
|
2290
2533
|
if (this.disabled) return;
|
|
2291
2534
|
this.checked = !this.checked;
|
|
2292
2535
|
const t = this.label || this.getAttribute("aria-label") || "Switch";
|
|
2293
|
-
|
|
2536
|
+
f(`${t} ${this.checked ? "on" : "off"}`);
|
|
2294
2537
|
}
|
|
2295
2538
|
/**
|
|
2296
2539
|
* Public method to open/close programmatically
|
|
@@ -2299,8 +2542,8 @@ class G extends h {
|
|
|
2299
2542
|
this.checked = t;
|
|
2300
2543
|
}
|
|
2301
2544
|
}
|
|
2302
|
-
|
|
2303
|
-
class
|
|
2545
|
+
b("a11y-switch", Z);
|
|
2546
|
+
class tt extends u {
|
|
2304
2547
|
constructor() {
|
|
2305
2548
|
super(...arguments), this._open = !1, this._highlightedIndex = -1, this._options = [], this._selectedValue = null, this._triggerElement = null, this._listboxElement = null, this._typeAhead = null, this.updateOptions = () => {
|
|
2306
2549
|
const t = Array.from(this.querySelectorAll("option"));
|
|
@@ -2309,7 +2552,7 @@ class X extends h {
|
|
|
2309
2552
|
label: e.textContent || "",
|
|
2310
2553
|
disabled: e.hasAttribute("disabled"),
|
|
2311
2554
|
element: e
|
|
2312
|
-
})), this._typeAhead =
|
|
2555
|
+
})), this._typeAhead = O(
|
|
2313
2556
|
this._options.map((e) => e.label),
|
|
2314
2557
|
{ timeout: 500 }
|
|
2315
2558
|
), this.renderOptions(), this.updateTriggerText();
|
|
@@ -2400,7 +2643,7 @@ class X extends h {
|
|
|
2400
2643
|
render() {
|
|
2401
2644
|
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") || "";
|
|
2402
2645
|
t.innerHTML = `
|
|
2403
|
-
<style>${
|
|
2646
|
+
<style>${Nt}</style>
|
|
2404
2647
|
<div class="select-wrapper" part="wrapper">
|
|
2405
2648
|
<button
|
|
2406
2649
|
id="${e}"
|
|
@@ -2551,8 +2794,8 @@ class X extends h {
|
|
|
2551
2794
|
this.open = !1;
|
|
2552
2795
|
}
|
|
2553
2796
|
}
|
|
2554
|
-
|
|
2555
|
-
class
|
|
2797
|
+
b("a11y-select", tt);
|
|
2798
|
+
class et extends u {
|
|
2556
2799
|
constructor() {
|
|
2557
2800
|
super(...arguments), this._value = "", this._inputEl = null, this._labelEl = null, this._hintEl = null, this._errorEl = null, this.handleInput = (t) => {
|
|
2558
2801
|
const e = t.target;
|
|
@@ -2632,41 +2875,41 @@ class W extends h {
|
|
|
2632
2875
|
));
|
|
2633
2876
|
}
|
|
2634
2877
|
render() {
|
|
2635
|
-
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") || "",
|
|
2636
|
-
|
|
2637
|
-
const
|
|
2878
|
+
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") || "", d = this.getAttribute("type") || "text", c = this.getAttribute("placeholder") || "", h = this.getAttribute("name") || "", p = this.getAttribute("autocomplete") || "", m = this.getAttribute("maxlength"), _ = this.getAttribute("minlength"), y = this.getAttribute("pattern"), w = this.getAttribute("inputmode"), I = this.getAttribute("aria-label") || "", C = this.getAttribute("aria-labelledby") || "", T = this.disabled, A = this.readOnly, x = this.required, E = !!n, k = [];
|
|
2879
|
+
o && k.push(s), E && k.push(a);
|
|
2880
|
+
const D = k.length ? `aria-describedby="${k.join(" ")}"` : "", S = !r && I ? `aria-label="${I}"` : "", Et = !r && C ? `aria-labelledby="${C}"` : r ? `aria-labelledby="${i}"` : "";
|
|
2638
2881
|
this.setAttribute("data-error", E ? "true" : "false"), t.innerHTML = `
|
|
2639
|
-
<style>${
|
|
2882
|
+
<style>${Yt}</style>
|
|
2640
2883
|
<div class="input-wrapper" part="wrapper">
|
|
2641
2884
|
${r ? `<label id="${i}" for="${e}" class="input-label" part="label">
|
|
2642
|
-
${r}${
|
|
2885
|
+
${r}${x ? '<span class="input-required" aria-hidden="true" part="required">*</span>' : ""}
|
|
2643
2886
|
</label>` : ""}
|
|
2644
2887
|
<input
|
|
2645
2888
|
id="${e}"
|
|
2646
|
-
type="${
|
|
2889
|
+
type="${d}"
|
|
2647
2890
|
value="${this._value}"
|
|
2648
2891
|
${c ? `placeholder="${c}"` : ""}
|
|
2649
|
-
${
|
|
2650
|
-
${
|
|
2651
|
-
${
|
|
2892
|
+
${h ? `name="${h}"` : ""}
|
|
2893
|
+
${p ? `autocomplete="${p}"` : ""}
|
|
2894
|
+
${m ? `maxlength="${m}"` : ""}
|
|
2652
2895
|
${_ ? `minlength="${_}"` : ""}
|
|
2653
|
-
${
|
|
2896
|
+
${y ? `pattern="${y}"` : ""}
|
|
2654
2897
|
${w ? `inputmode="${w}"` : ""}
|
|
2655
|
-
${
|
|
2656
|
-
${
|
|
2657
|
-
${
|
|
2898
|
+
${S}
|
|
2899
|
+
${Et}
|
|
2900
|
+
${D}
|
|
2658
2901
|
${E ? 'aria-invalid="true"' : ""}
|
|
2659
|
-
${
|
|
2660
|
-
${
|
|
2661
|
-
${
|
|
2902
|
+
${x ? 'aria-required="true"' : ""}
|
|
2903
|
+
${T ? "disabled" : ""}
|
|
2904
|
+
${A ? "readonly" : ""}
|
|
2662
2905
|
part="field"
|
|
2663
2906
|
/>
|
|
2664
|
-
${
|
|
2665
|
-
${E ? `<div id="${a}" class="input-error" role="alert" part="error">${
|
|
2907
|
+
${o ? `<div id="${s}" class="input-hint" part="hint">${o}</div>` : ""}
|
|
2908
|
+
${E ? `<div id="${a}" class="input-error" role="alert" part="error">${n}</div>` : ""}
|
|
2666
2909
|
</div>
|
|
2667
2910
|
`, this._inputEl = t.querySelector("input"), this._labelEl = t.querySelector("label"), this._hintEl = t.querySelector(".input-hint"), this._errorEl = t.querySelector(".input-error");
|
|
2668
|
-
const
|
|
2669
|
-
|
|
2911
|
+
const q = this.getAttribute("value");
|
|
2912
|
+
q && this._inputEl && (this._value = q, this._inputEl.value = q);
|
|
2670
2913
|
}
|
|
2671
2914
|
setupEventListeners() {
|
|
2672
2915
|
var t, e, i, s;
|
|
@@ -2740,7 +2983,7 @@ class W extends h {
|
|
|
2740
2983
|
const s = `${this._id}-error`, a = document.createElement("div");
|
|
2741
2984
|
a.id = s, a.className = "input-error", a.setAttribute("role", "alert"), a.setAttribute("part", "error"), a.textContent = t;
|
|
2742
2985
|
const r = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".input-wrapper");
|
|
2743
|
-
r == null || r.appendChild(a), this._errorEl = a,
|
|
2986
|
+
r == null || r.appendChild(a), this._errorEl = a, R(t);
|
|
2744
2987
|
}
|
|
2745
2988
|
this.updateAriaDescribedBy();
|
|
2746
2989
|
} else
|
|
@@ -2793,8 +3036,8 @@ class W extends h {
|
|
|
2793
3036
|
(t = this._inputEl) == null || t.select();
|
|
2794
3037
|
}
|
|
2795
3038
|
}
|
|
2796
|
-
|
|
2797
|
-
class
|
|
3039
|
+
b("a11y-input", et);
|
|
3040
|
+
class it extends u {
|
|
2798
3041
|
constructor() {
|
|
2799
3042
|
super(...arguments), this._value = "", this._textareaEl = null, this._labelEl = null, this._hintEl = null, this._errorEl = null, this.handleInput = (t) => {
|
|
2800
3043
|
const e = t.target;
|
|
@@ -2873,38 +3116,38 @@ class J extends h {
|
|
|
2873
3116
|
));
|
|
2874
3117
|
}
|
|
2875
3118
|
render() {
|
|
2876
|
-
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") || "",
|
|
2877
|
-
|
|
2878
|
-
const E =
|
|
2879
|
-
this.setAttribute("data-error",
|
|
2880
|
-
<style>${
|
|
3119
|
+
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") || "", d = this.getAttribute("rows") || "3", c = this.getAttribute("placeholder") || "", h = this.getAttribute("name") || "", p = this.getAttribute("autocomplete") || "", m = this.getAttribute("maxlength"), _ = this.getAttribute("minlength"), y = this.getAttribute("aria-label") || "", w = this.getAttribute("aria-labelledby") || "", I = this.disabled, C = this.readOnly, T = this.required, A = !!n, x = [];
|
|
3120
|
+
o && x.push(s), A && x.push(a);
|
|
3121
|
+
const E = x.length ? `aria-describedby="${x.join(" ")}"` : "", k = !r && y ? `aria-label="${y}"` : "", D = !r && w ? `aria-labelledby="${w}"` : r ? `aria-labelledby="${i}"` : "";
|
|
3122
|
+
this.setAttribute("data-error", A ? "true" : "false"), t.innerHTML = `
|
|
3123
|
+
<style>${Vt}</style>
|
|
2881
3124
|
<div class="textarea-wrapper" part="wrapper">
|
|
2882
3125
|
${r ? `<label id="${i}" for="${e}" class="textarea-label" part="label">
|
|
2883
|
-
${r}${
|
|
3126
|
+
${r}${T ? '<span class="textarea-required" aria-hidden="true" part="required">*</span>' : ""}
|
|
2884
3127
|
</label>` : ""}
|
|
2885
3128
|
<textarea
|
|
2886
3129
|
id="${e}"
|
|
2887
|
-
rows="${
|
|
3130
|
+
rows="${d}"
|
|
2888
3131
|
${c ? `placeholder="${c}"` : ""}
|
|
2889
|
-
${
|
|
2890
|
-
${
|
|
2891
|
-
${
|
|
3132
|
+
${h ? `name="${h}"` : ""}
|
|
3133
|
+
${p ? `autocomplete="${p}"` : ""}
|
|
3134
|
+
${m ? `maxlength="${m}"` : ""}
|
|
2892
3135
|
${_ ? `minlength="${_}"` : ""}
|
|
2893
|
-
${
|
|
2894
|
-
${
|
|
3136
|
+
${k}
|
|
3137
|
+
${D}
|
|
2895
3138
|
${E}
|
|
2896
|
-
${
|
|
2897
|
-
${
|
|
2898
|
-
${
|
|
2899
|
-
${
|
|
3139
|
+
${A ? 'aria-invalid="true"' : ""}
|
|
3140
|
+
${T ? 'aria-required="true"' : ""}
|
|
3141
|
+
${I ? "disabled" : ""}
|
|
3142
|
+
${C ? "readonly" : ""}
|
|
2900
3143
|
part="field"
|
|
2901
3144
|
>${this._value}</textarea>
|
|
2902
|
-
${
|
|
2903
|
-
${
|
|
3145
|
+
${o ? `<div id="${s}" class="textarea-hint" part="hint">${o}</div>` : ""}
|
|
3146
|
+
${A ? `<div id="${a}" class="textarea-error" role="alert" part="error">${n}</div>` : ""}
|
|
2904
3147
|
</div>
|
|
2905
3148
|
`, this._textareaEl = t.querySelector("textarea"), this._labelEl = t.querySelector("label"), this._hintEl = t.querySelector(".textarea-hint"), this._errorEl = t.querySelector(".textarea-error");
|
|
2906
|
-
const
|
|
2907
|
-
|
|
3149
|
+
const S = this.getAttribute("value");
|
|
3150
|
+
S && this._textareaEl && (this._value = S, this._textareaEl.value = S);
|
|
2908
3151
|
}
|
|
2909
3152
|
setupEventListeners() {
|
|
2910
3153
|
var t, e, i, s;
|
|
@@ -2975,7 +3218,7 @@ class J extends h {
|
|
|
2975
3218
|
const s = `${this._id}-error`, a = document.createElement("div");
|
|
2976
3219
|
a.id = s, a.className = "textarea-error", a.setAttribute("role", "alert"), a.setAttribute("part", "error"), a.textContent = t;
|
|
2977
3220
|
const r = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".textarea-wrapper");
|
|
2978
|
-
r == null || r.appendChild(a), this._errorEl = a,
|
|
3221
|
+
r == null || r.appendChild(a), this._errorEl = a, R(t);
|
|
2979
3222
|
}
|
|
2980
3223
|
this.updateAriaDescribedBy();
|
|
2981
3224
|
} else
|
|
@@ -3028,8 +3271,8 @@ class J extends h {
|
|
|
3028
3271
|
(t = this._textareaEl) == null || t.select();
|
|
3029
3272
|
}
|
|
3030
3273
|
}
|
|
3031
|
-
|
|
3032
|
-
class
|
|
3274
|
+
b("a11y-textarea", it);
|
|
3275
|
+
class st extends u {
|
|
3033
3276
|
constructor() {
|
|
3034
3277
|
super(...arguments), this._buttonEl = null, this.handleClick = (t) => {
|
|
3035
3278
|
if (this.disabled || this.loading) {
|
|
@@ -3094,18 +3337,18 @@ class Q extends h {
|
|
|
3094
3337
|
));
|
|
3095
3338
|
}
|
|
3096
3339
|
render() {
|
|
3097
|
-
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,
|
|
3340
|
+
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, d = r || n, c = r && !o;
|
|
3098
3341
|
t.innerHTML = `
|
|
3099
|
-
<style>${
|
|
3342
|
+
<style>${Gt}</style>
|
|
3100
3343
|
<button
|
|
3101
3344
|
class="variant-${e} size-${i}"
|
|
3102
3345
|
type="${s}"
|
|
3103
3346
|
${c ? "disabled" : ""}
|
|
3104
|
-
${
|
|
3105
|
-
${
|
|
3347
|
+
${d ? 'aria-disabled="true"' : ""}
|
|
3348
|
+
${n ? 'aria-busy="true"' : ""}
|
|
3106
3349
|
${a ? `aria-label="${a}"` : ""}
|
|
3107
3350
|
part="button"
|
|
3108
|
-
>${
|
|
3351
|
+
>${n ? '<span class="button-spinner" aria-hidden="true" part="spinner"></span>' : ""}<slot></slot></button>
|
|
3109
3352
|
`, this._buttonEl = t.querySelector("button");
|
|
3110
3353
|
}
|
|
3111
3354
|
setupEventListeners() {
|
|
@@ -3185,8 +3428,8 @@ class Q extends h {
|
|
|
3185
3428
|
(t = this._buttonEl) == null || t.click();
|
|
3186
3429
|
}
|
|
3187
3430
|
}
|
|
3188
|
-
|
|
3189
|
-
class
|
|
3431
|
+
b("a11y-button", st);
|
|
3432
|
+
class at extends u {
|
|
3190
3433
|
constructor() {
|
|
3191
3434
|
super(...arguments), this._label = "", this._disabled = !1;
|
|
3192
3435
|
}
|
|
@@ -3213,7 +3456,7 @@ class Z extends h {
|
|
|
3213
3456
|
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
3214
3457
|
const t = `${this._id}-label`;
|
|
3215
3458
|
this.shadowRoot.innerHTML = `
|
|
3216
|
-
<style>${
|
|
3459
|
+
<style>${Wt}</style>
|
|
3217
3460
|
<div class="optgroup-wrapper" part="group">
|
|
3218
3461
|
<div class="optgroup-label" part="label" id="${t}" role="presentation">
|
|
3219
3462
|
${this._label}
|
|
@@ -3244,7 +3487,7 @@ class Z extends h {
|
|
|
3244
3487
|
}
|
|
3245
3488
|
}
|
|
3246
3489
|
}
|
|
3247
|
-
class
|
|
3490
|
+
class rt extends u {
|
|
3248
3491
|
constructor() {
|
|
3249
3492
|
super(...arguments), this._value = "", this._disabled = !1, this._selected = !1, this._discoverable = !0, this.handleClick = (t) => {
|
|
3250
3493
|
if (this.effectivelyDisabled) {
|
|
@@ -3304,7 +3547,7 @@ class tt extends h {
|
|
|
3304
3547
|
}
|
|
3305
3548
|
render() {
|
|
3306
3549
|
this.shadowRoot || this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
|
|
3307
|
-
<style>${
|
|
3550
|
+
<style>${Xt}</style>
|
|
3308
3551
|
<div class="option-wrapper" part="option">
|
|
3309
3552
|
<span class="option-content" part="content"><slot></slot></span>
|
|
3310
3553
|
<span class="check-mark" part="check" aria-hidden="true">✓</span>
|
|
@@ -3331,7 +3574,7 @@ class tt extends h {
|
|
|
3331
3574
|
}
|
|
3332
3575
|
}
|
|
3333
3576
|
}
|
|
3334
|
-
class
|
|
3577
|
+
class ot extends u {
|
|
3335
3578
|
constructor() {
|
|
3336
3579
|
super(...arguments), this._value = null, this._values = /* @__PURE__ */ new Set(), this._multiple = !1, this._disabled = !1, this._discoverable = !0, this._orientation = "vertical", this._focusedIndex = -1, this._typeAhead = null, this.handleFocus = () => {
|
|
3337
3580
|
if (this._focusedIndex >= 0) return;
|
|
@@ -3355,12 +3598,12 @@ class et extends h {
|
|
|
3355
3598
|
if (this._disabled) return;
|
|
3356
3599
|
const e = (r = t.detail) == null ? void 0 : r.value;
|
|
3357
3600
|
if (e === void 0) return;
|
|
3358
|
-
const i = this.getAllOptions(), s = i.find((
|
|
3601
|
+
const i = this.getAllOptions(), s = i.find((o) => o.value === e);
|
|
3359
3602
|
if (!s) return;
|
|
3360
3603
|
const a = i.indexOf(s);
|
|
3361
3604
|
this._focusedIndex = a, this.updateFocusHighlight(), this.selectOption(s), this.focus();
|
|
3362
3605
|
}, this.handleKeyDown = (t) => {
|
|
3363
|
-
var a, r,
|
|
3606
|
+
var a, r, o;
|
|
3364
3607
|
if (this._disabled && !this._discoverable) return;
|
|
3365
3608
|
const e = this.getAllOptions();
|
|
3366
3609
|
if (e.length === 0) return;
|
|
@@ -3387,15 +3630,15 @@ class et extends h {
|
|
|
3387
3630
|
break;
|
|
3388
3631
|
default:
|
|
3389
3632
|
if (t.key.length === 1 && !t.ctrlKey && !t.altKey && !t.metaKey) {
|
|
3390
|
-
const
|
|
3391
|
-
if (
|
|
3392
|
-
const
|
|
3633
|
+
const n = (a = this._typeAhead) == null ? void 0 : a.type(t.key);
|
|
3634
|
+
if (n) {
|
|
3635
|
+
const d = e.findIndex(
|
|
3393
3636
|
(c) => {
|
|
3394
|
-
var
|
|
3395
|
-
return (((
|
|
3637
|
+
var h;
|
|
3638
|
+
return (((h = c.textContent) == null ? void 0 : h.trim()) || "") === n && !c.effectivelyDisabled;
|
|
3396
3639
|
}
|
|
3397
3640
|
);
|
|
3398
|
-
|
|
3641
|
+
d >= 0 && (i = d, s = !0);
|
|
3399
3642
|
}
|
|
3400
3643
|
}
|
|
3401
3644
|
break;
|
|
@@ -3416,27 +3659,27 @@ class et extends h {
|
|
|
3416
3659
|
break;
|
|
3417
3660
|
default:
|
|
3418
3661
|
if (t.key.length === 1 && !t.ctrlKey && !t.altKey && !t.metaKey) {
|
|
3419
|
-
const
|
|
3420
|
-
if (
|
|
3421
|
-
const
|
|
3662
|
+
const n = (r = this._typeAhead) == null ? void 0 : r.type(t.key);
|
|
3663
|
+
if (n) {
|
|
3664
|
+
const d = e.findIndex(
|
|
3422
3665
|
(c) => {
|
|
3423
|
-
var
|
|
3424
|
-
return (((
|
|
3666
|
+
var h;
|
|
3667
|
+
return (((h = c.textContent) == null ? void 0 : h.trim()) || "") === n && !c.effectivelyDisabled;
|
|
3425
3668
|
}
|
|
3426
3669
|
);
|
|
3427
|
-
|
|
3670
|
+
d >= 0 && (i = d, s = !0);
|
|
3428
3671
|
}
|
|
3429
3672
|
}
|
|
3430
3673
|
break;
|
|
3431
3674
|
}
|
|
3432
3675
|
if (s && (t.preventDefault(), t.stopPropagation()), i !== null && i >= 0) {
|
|
3433
3676
|
this._focusedIndex = i, this.updateFocusHighlight();
|
|
3434
|
-
const
|
|
3435
|
-
if (!this._multiple &&
|
|
3436
|
-
this.selectSingle(
|
|
3437
|
-
else if (
|
|
3438
|
-
const
|
|
3439
|
-
|
|
3677
|
+
const n = e[i];
|
|
3678
|
+
if (!this._multiple && n)
|
|
3679
|
+
this.selectSingle(n);
|
|
3680
|
+
else if (n) {
|
|
3681
|
+
const d = ((o = n.textContent) == null ? void 0 : o.trim()) || n.value, c = this._values.has(n.value);
|
|
3682
|
+
f(`${d}${c ? ", selected" : ""}`);
|
|
3440
3683
|
}
|
|
3441
3684
|
}
|
|
3442
3685
|
};
|
|
@@ -3506,7 +3749,7 @@ class et extends h {
|
|
|
3506
3749
|
}
|
|
3507
3750
|
render() {
|
|
3508
3751
|
this.shadowRoot || this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
|
|
3509
|
-
<style>${
|
|
3752
|
+
<style>${Ut}</style>
|
|
3510
3753
|
<div class="listbox-wrapper" part="wrapper">
|
|
3511
3754
|
<slot></slot>
|
|
3512
3755
|
</div>
|
|
@@ -3577,31 +3820,31 @@ class et extends h {
|
|
|
3577
3820
|
const e = this._value;
|
|
3578
3821
|
if (this._value = t.value, this.setAttribute("value", t.value), this.syncOptionStates(), e !== this._value) {
|
|
3579
3822
|
const s = ((i = t.textContent) == null ? void 0 : i.trim()) || t.value;
|
|
3580
|
-
this.emit("change", { value: this._value, label: s }), this.emit("a11y-listbox-change", { value: this._value, label: s }),
|
|
3823
|
+
this.emit("change", { value: this._value, label: s }), this.emit("a11y-listbox-change", { value: this._value, label: s }), f(`${s} selected`);
|
|
3581
3824
|
}
|
|
3582
3825
|
}
|
|
3583
3826
|
toggleOptionSelection(t) {
|
|
3584
3827
|
var s;
|
|
3585
3828
|
if (t.effectivelyDisabled || this._disabled) return;
|
|
3586
3829
|
const e = ((s = t.textContent) == null ? void 0 : s.trim()) || t.value;
|
|
3587
|
-
this._values.has(t.value) ? (this._values.delete(t.value), t.selected = !1,
|
|
3830
|
+
this._values.has(t.value) ? (this._values.delete(t.value), t.selected = !1, f(`${e} deselected`)) : (this._values.add(t.value), t.selected = !0, f(`${e} selected`));
|
|
3588
3831
|
const i = Array.from(this._values);
|
|
3589
3832
|
this.setAttribute("value", i.join(",")), this.emit("change", { value: i }), this.emit("a11y-listbox-change", { value: i });
|
|
3590
3833
|
}
|
|
3591
3834
|
selectRange(t, e) {
|
|
3592
3835
|
const i = this.getAllOptions(), s = Math.min(t, e), a = Math.max(t, e);
|
|
3593
|
-
for (let
|
|
3594
|
-
const
|
|
3595
|
-
|
|
3836
|
+
for (let o = s; o <= a; o++) {
|
|
3837
|
+
const n = i[o];
|
|
3838
|
+
n && !n.effectivelyDisabled && (this._values.add(n.value), n.selected = !0);
|
|
3596
3839
|
}
|
|
3597
3840
|
const r = Array.from(this._values);
|
|
3598
|
-
this.setAttribute("value", r.join(",")), this.emit("change", { value: r }), this.emit("a11y-listbox-change", { value: r }),
|
|
3841
|
+
this.setAttribute("value", r.join(",")), this.emit("change", { value: r }), this.emit("a11y-listbox-change", { value: r }), f(`${a - s + 1} items selected`);
|
|
3599
3842
|
}
|
|
3600
3843
|
toggleSelectAll() {
|
|
3601
3844
|
const t = this.getEnabledOptions();
|
|
3602
|
-
t.every((s) => this._values.has(s.value)) ? (this._values.clear(), this.getAllOptions().forEach((s) => s.selected = !1),
|
|
3845
|
+
t.every((s) => this._values.has(s.value)) ? (this._values.clear(), this.getAllOptions().forEach((s) => s.selected = !1), f("All deselected")) : (t.forEach((s) => {
|
|
3603
3846
|
this._values.add(s.value), s.selected = !0;
|
|
3604
|
-
}),
|
|
3847
|
+
}), f("All selected"));
|
|
3605
3848
|
const i = Array.from(this._values);
|
|
3606
3849
|
this.setAttribute("value", i.join(",")), this.emit("change", { value: i }), this.emit("a11y-listbox-change", { value: i });
|
|
3607
3850
|
}
|
|
@@ -3613,7 +3856,7 @@ class et extends h {
|
|
|
3613
3856
|
return ((i = e.textContent) == null ? void 0 : i.trim()) || "";
|
|
3614
3857
|
}
|
|
3615
3858
|
);
|
|
3616
|
-
this._typeAhead =
|
|
3859
|
+
this._typeAhead = O(t, { timeout: 500 });
|
|
3617
3860
|
}
|
|
3618
3861
|
// ===== Attribute Changes =====
|
|
3619
3862
|
onAttributeChange(t, e, i) {
|
|
@@ -3638,21 +3881,21 @@ class et extends h {
|
|
|
3638
3881
|
}
|
|
3639
3882
|
}
|
|
3640
3883
|
}
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
const
|
|
3884
|
+
b("a11y-optgroup", at);
|
|
3885
|
+
b("a11y-option", rt);
|
|
3886
|
+
b("a11y-listbox", ot);
|
|
3887
|
+
const oe = `<svg class="checkbox-check" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
|
3645
3888
|
<path d="M2.5 6L5 8.5L9.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3646
|
-
</svg>`,
|
|
3889
|
+
</svg>`, ne = `<svg class="checkbox-dash" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
|
3647
3890
|
<path d="M3 6H9" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
3648
3891
|
</svg>`;
|
|
3649
|
-
class
|
|
3892
|
+
class H extends u {
|
|
3650
3893
|
constructor() {
|
|
3651
3894
|
super(...arguments), this._checked = !1, this._indeterminate = !1, this._input = null, this.handleChange = () => {
|
|
3652
3895
|
if (!this._input) return;
|
|
3653
3896
|
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 });
|
|
3654
3897
|
const t = this.label || this.getAttribute("aria-label") || "Checkbox";
|
|
3655
|
-
|
|
3898
|
+
f(`${t} ${this._checked ? "checked" : "unchecked"}`);
|
|
3656
3899
|
};
|
|
3657
3900
|
}
|
|
3658
3901
|
static get observedAttributes() {
|
|
@@ -3763,11 +4006,11 @@ class R extends h {
|
|
|
3763
4006
|
);
|
|
3764
4007
|
}
|
|
3765
4008
|
render() {
|
|
3766
|
-
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,
|
|
3767
|
-
|
|
3768
|
-
const
|
|
4009
|
+
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, d = this.getAttribute("aria-label"), c = this.getAttribute("name") || "", h = this.getAttribute("aria-describedby") || "", p = [];
|
|
4010
|
+
h && p.push(h), o && p.push(s), n && p.push(a);
|
|
4011
|
+
const m = p.length ? `aria-describedby="${p.join(" ")}"` : "", _ = !r && d ? `aria-label="${d}"` : "";
|
|
3769
4012
|
t.innerHTML = `
|
|
3770
|
-
<style>${
|
|
4013
|
+
<style>${Jt}</style>
|
|
3771
4014
|
<div class="checkbox-wrapper size-${this.size}" part="wrapper">
|
|
3772
4015
|
<div class="checkbox-control">
|
|
3773
4016
|
<input
|
|
@@ -3779,20 +4022,20 @@ class R extends h {
|
|
|
3779
4022
|
${this._checked ? "checked" : ""}
|
|
3780
4023
|
${this.disabled ? "disabled" : ""}
|
|
3781
4024
|
${this.required ? 'required aria-required="true"' : ""}
|
|
3782
|
-
${
|
|
4025
|
+
${m}
|
|
3783
4026
|
${_}
|
|
3784
|
-
${
|
|
4027
|
+
${n ? 'aria-invalid="true"' : ""}
|
|
3785
4028
|
part="input"
|
|
3786
4029
|
/>
|
|
3787
4030
|
<div class="checkbox-indicator" part="indicator" aria-hidden="true">
|
|
3788
|
-
${
|
|
3789
|
-
${
|
|
4031
|
+
${oe}
|
|
4032
|
+
${ne}
|
|
3790
4033
|
</div>
|
|
3791
4034
|
</div>
|
|
3792
|
-
${r ||
|
|
4035
|
+
${r || o || n ? `<div class="checkbox-content">
|
|
3793
4036
|
${r ? `<label for="${e}" id="${i}" class="checkbox-label" part="label">${this.label}${this.required ? '<span class="checkbox-required" aria-hidden="true">*</span>' : ""}</label>` : ""}
|
|
3794
|
-
${
|
|
3795
|
-
${
|
|
4037
|
+
${o ? `<div id="${s}" class="checkbox-hint" part="hint">${this.hint}</div>` : ""}
|
|
4038
|
+
${n ? `<div id="${a}" class="checkbox-error" role="alert" part="error">${this.error}</div>` : ""}
|
|
3796
4039
|
</div>` : ""}
|
|
3797
4040
|
</div>
|
|
3798
4041
|
`, this._input = t.querySelector("input"), this._input && this._indeterminate && (this._input.indeterminate = !0);
|
|
@@ -3857,7 +4100,7 @@ class R extends h {
|
|
|
3857
4100
|
if (this.disabled) return;
|
|
3858
4101
|
this._indeterminate ? (this.indeterminate = !1, this.checked = !0) : this.checked = !this.checked;
|
|
3859
4102
|
const t = this.label || this.getAttribute("aria-label") || "Checkbox";
|
|
3860
|
-
|
|
4103
|
+
f(`${t} ${this.checked ? "checked" : "unchecked"}`);
|
|
3861
4104
|
}
|
|
3862
4105
|
/**
|
|
3863
4106
|
* Set checked state programmatically
|
|
@@ -3866,11 +4109,11 @@ class R extends h {
|
|
|
3866
4109
|
this.checked = t;
|
|
3867
4110
|
}
|
|
3868
4111
|
}
|
|
3869
|
-
class
|
|
4112
|
+
class nt extends u {
|
|
3870
4113
|
constructor() {
|
|
3871
4114
|
super(...arguments), this._value = [], this.handleChildChange = (t) => {
|
|
3872
4115
|
const e = t.target;
|
|
3873
|
-
if (!(e instanceof
|
|
4116
|
+
if (!(e instanceof H) || e === this) return;
|
|
3874
4117
|
const i = e.value;
|
|
3875
4118
|
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 }));
|
|
3876
4119
|
};
|
|
@@ -3940,7 +4183,7 @@ class it extends h {
|
|
|
3940
4183
|
render() {
|
|
3941
4184
|
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");
|
|
3942
4185
|
t.innerHTML = `
|
|
3943
|
-
<style>${
|
|
4186
|
+
<style>${Qt}</style>
|
|
3944
4187
|
<fieldset
|
|
3945
4188
|
part="fieldset"
|
|
3946
4189
|
${a ? `aria-label="${a}"` : ""}
|
|
@@ -4006,9 +4249,9 @@ class it extends h {
|
|
|
4006
4249
|
t && (this.disabled ? t.setAttribute("disabled", "") : t.removeAttribute("disabled"));
|
|
4007
4250
|
}
|
|
4008
4251
|
}
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
class
|
|
4252
|
+
b("a11y-checkbox", H);
|
|
4253
|
+
b("a11y-checkbox-group", nt);
|
|
4254
|
+
class lt extends u {
|
|
4012
4255
|
constructor() {
|
|
4013
4256
|
super(...arguments), this._value = "", this._disabled = !1, this._discoverable = !0, this._orientation = "vertical", this._required = !1, this._name = "", this.handleRadioSelect = (t) => {
|
|
4014
4257
|
var i;
|
|
@@ -4047,7 +4290,7 @@ class st extends h {
|
|
|
4047
4290
|
if (a && a.value !== this._value) {
|
|
4048
4291
|
this.selectRadio(a.value);
|
|
4049
4292
|
const r = a.getAttribute("label") || a.value;
|
|
4050
|
-
|
|
4293
|
+
f(`${r} selected`);
|
|
4051
4294
|
}
|
|
4052
4295
|
}
|
|
4053
4296
|
return;
|
|
@@ -4060,7 +4303,7 @@ class st extends h {
|
|
|
4060
4303
|
if (a) {
|
|
4061
4304
|
this.selectRadio(a.value), a.focus();
|
|
4062
4305
|
const r = a.getAttribute("label") || a.value;
|
|
4063
|
-
|
|
4306
|
+
f(`${r} selected`);
|
|
4064
4307
|
}
|
|
4065
4308
|
}
|
|
4066
4309
|
};
|
|
@@ -4132,9 +4375,9 @@ class st extends h {
|
|
|
4132
4375
|
}
|
|
4133
4376
|
render() {
|
|
4134
4377
|
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
4135
|
-
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` : "",
|
|
4136
|
-
|
|
4137
|
-
<style>${
|
|
4378
|
+
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(" ");
|
|
4379
|
+
o ? this.setAttribute("aria-describedby", o) : this.removeAttribute("aria-describedby"), t.innerHTML = `
|
|
4380
|
+
<style>${Zt}</style>
|
|
4138
4381
|
<fieldset part="fieldset">
|
|
4139
4382
|
${e ? `<legend part="legend">${e}${this._required ? '<span class="radio-group-required" aria-hidden="true"> *</span>' : ""}</legend>` : ""}
|
|
4140
4383
|
<div class="radio-group-items" part="items">
|
|
@@ -4213,7 +4456,7 @@ class st extends h {
|
|
|
4213
4456
|
}
|
|
4214
4457
|
}
|
|
4215
4458
|
}
|
|
4216
|
-
class
|
|
4459
|
+
class dt extends u {
|
|
4217
4460
|
constructor() {
|
|
4218
4461
|
super(...arguments), this._value = "", this._checked = !1, this._disabled = !1, this._discoverable = !0, this.handleClick = (t) => {
|
|
4219
4462
|
if (this._disabled) {
|
|
@@ -4228,7 +4471,7 @@ class at extends h {
|
|
|
4228
4471
|
})
|
|
4229
4472
|
);
|
|
4230
4473
|
const e = this.getAttribute("label") || this._value;
|
|
4231
|
-
|
|
4474
|
+
f(`${e} selected`);
|
|
4232
4475
|
}, this.handleKeyDown = (t) => {
|
|
4233
4476
|
if (!this._disabled && t.key === "Enter") {
|
|
4234
4477
|
t.preventDefault(), this.dispatchEvent(
|
|
@@ -4239,7 +4482,7 @@ class at extends h {
|
|
|
4239
4482
|
})
|
|
4240
4483
|
);
|
|
4241
4484
|
const e = this.getAttribute("label") || this._value;
|
|
4242
|
-
|
|
4485
|
+
f(`${e} selected`);
|
|
4243
4486
|
}
|
|
4244
4487
|
};
|
|
4245
4488
|
}
|
|
@@ -4284,7 +4527,7 @@ class at extends h {
|
|
|
4284
4527
|
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
4285
4528
|
const t = this.shadowRoot, e = this.getAttribute("label") || "", i = this.getAttribute("hint") || "", s = e ? `${this._id}-label` : "", a = i ? `${this._id}-hint` : "";
|
|
4286
4529
|
s && this.setAttribute("aria-labelledby", s), a && this.setAttribute("aria-describedby", a), t.innerHTML = `
|
|
4287
|
-
<style>${
|
|
4530
|
+
<style>${te}</style>
|
|
4288
4531
|
<div class="radio-wrapper" part="wrapper">
|
|
4289
4532
|
<div class="radio-control" part="control">
|
|
4290
4533
|
<input
|
|
@@ -4345,9 +4588,9 @@ class at extends h {
|
|
|
4345
4588
|
}
|
|
4346
4589
|
}
|
|
4347
4590
|
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
class
|
|
4591
|
+
b("a11y-radio-group", lt);
|
|
4592
|
+
b("a11y-radio", dt);
|
|
4593
|
+
class ht extends u {
|
|
4351
4594
|
constructor() {
|
|
4352
4595
|
super(...arguments), this._toasts = [], this._counter = 0, this._containerEl = null, this._maxToasts = 5, this._handleClick = (t) => {
|
|
4353
4596
|
var a;
|
|
@@ -4358,7 +4601,7 @@ class rt extends h {
|
|
|
4358
4601
|
}
|
|
4359
4602
|
const s = e.getAttribute("data-action-id");
|
|
4360
4603
|
if (s) {
|
|
4361
|
-
const r = this._toasts.find((
|
|
4604
|
+
const r = this._toasts.find((o) => o.id === s);
|
|
4362
4605
|
(a = r == null ? void 0 : r.action) == null || a.onClick(), this.removeToast(s);
|
|
4363
4606
|
}
|
|
4364
4607
|
};
|
|
@@ -4385,7 +4628,7 @@ class rt extends h {
|
|
|
4385
4628
|
render() {
|
|
4386
4629
|
const t = this.attachShadow({ mode: "open" });
|
|
4387
4630
|
t.innerHTML = `
|
|
4388
|
-
<style>${
|
|
4631
|
+
<style>${ee}</style>
|
|
4389
4632
|
<div
|
|
4390
4633
|
class="toast-container"
|
|
4391
4634
|
role="region"
|
|
@@ -4485,8 +4728,8 @@ class rt extends h {
|
|
|
4485
4728
|
return e.textContent = t, e.innerHTML;
|
|
4486
4729
|
}
|
|
4487
4730
|
}
|
|
4488
|
-
|
|
4489
|
-
class
|
|
4731
|
+
b("a11y-toast", ht);
|
|
4732
|
+
class ct extends u {
|
|
4490
4733
|
static get observedAttributes() {
|
|
4491
4734
|
return ["focusable"];
|
|
4492
4735
|
}
|
|
@@ -4496,7 +4739,7 @@ class ot extends h {
|
|
|
4496
4739
|
this.shadowRoot || this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
|
|
4497
4740
|
<style>
|
|
4498
4741
|
:host {
|
|
4499
|
-
${
|
|
4742
|
+
${V}
|
|
4500
4743
|
}
|
|
4501
4744
|
|
|
4502
4745
|
:host([hidden]) {
|
|
@@ -4524,9 +4767,9 @@ class ot extends h {
|
|
|
4524
4767
|
cleanupEventListeners() {
|
|
4525
4768
|
}
|
|
4526
4769
|
}
|
|
4527
|
-
|
|
4528
|
-
const
|
|
4529
|
-
class
|
|
4770
|
+
b("a11y-visually-hidden", ct);
|
|
4771
|
+
const le = $("SkipLink");
|
|
4772
|
+
class ut extends u {
|
|
4530
4773
|
constructor() {
|
|
4531
4774
|
super(...arguments), this.handleClick = (t) => {
|
|
4532
4775
|
const e = this.getAttribute("target") || "#main-content", i = document.querySelector(e);
|
|
@@ -4537,7 +4780,7 @@ class lt extends h {
|
|
|
4537
4780
|
return ["target", "label"];
|
|
4538
4781
|
}
|
|
4539
4782
|
setupAccessibility() {
|
|
4540
|
-
this.getAttribute("target") ||
|
|
4783
|
+
this.getAttribute("target") || le.warning(
|
|
4541
4784
|
'Missing "target" attribute. Provide a CSS selector (e.g. target="#main-content") pointing to the skip destination.'
|
|
4542
4785
|
);
|
|
4543
4786
|
}
|
|
@@ -4555,7 +4798,7 @@ class lt extends h {
|
|
|
4555
4798
|
}
|
|
4556
4799
|
|
|
4557
4800
|
.skip-link {
|
|
4558
|
-
${
|
|
4801
|
+
${V}
|
|
4559
4802
|
display: inline-block;
|
|
4560
4803
|
text-decoration: none;
|
|
4561
4804
|
}
|
|
@@ -4605,8 +4848,8 @@ class lt extends h {
|
|
|
4605
4848
|
(t === "target" || t === "label") && this.render();
|
|
4606
4849
|
}
|
|
4607
4850
|
}
|
|
4608
|
-
|
|
4609
|
-
const
|
|
4851
|
+
b("a11y-skip-link", ut);
|
|
4852
|
+
const de = $("Alert"), he = `
|
|
4610
4853
|
:host {
|
|
4611
4854
|
display: block;
|
|
4612
4855
|
box-sizing: border-box;
|
|
@@ -4731,7 +4974,7 @@ const Gt = N("Alert"), Xt = `
|
|
|
4731
4974
|
outline: 2px solid Highlight;
|
|
4732
4975
|
}
|
|
4733
4976
|
}
|
|
4734
|
-
`,
|
|
4977
|
+
`, F = {
|
|
4735
4978
|
info: "ℹ️",
|
|
4736
4979
|
// ℹ️
|
|
4737
4980
|
success: "✅",
|
|
@@ -4741,7 +4984,7 @@ const Gt = N("Alert"), Xt = `
|
|
|
4741
4984
|
error: "❌"
|
|
4742
4985
|
// ❌
|
|
4743
4986
|
};
|
|
4744
|
-
class
|
|
4987
|
+
class bt extends u {
|
|
4745
4988
|
constructor() {
|
|
4746
4989
|
super(...arguments), this._closeButton = null, this.handleDismiss = () => {
|
|
4747
4990
|
this.emit("dismiss", { type: this.alertType }), this.remove();
|
|
@@ -4764,15 +5007,15 @@ class nt extends h {
|
|
|
4764
5007
|
}
|
|
4765
5008
|
setupAccessibility() {
|
|
4766
5009
|
const t = ["info", "success", "warning", "error"], e = this.getAttribute("type");
|
|
4767
|
-
e && !t.includes(e) &&
|
|
5010
|
+
e && !t.includes(e) && de.warning(
|
|
4768
5011
|
`Invalid type="${e}". Use one of: ${t.join(", ")}.`
|
|
4769
5012
|
);
|
|
4770
5013
|
}
|
|
4771
5014
|
render() {
|
|
4772
5015
|
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
4773
|
-
const t = this.getAttribute("title"), e = this.hasAttribute("dismissible"), i =
|
|
5016
|
+
const t = this.getAttribute("title"), e = this.hasAttribute("dismissible"), i = F[this.alertType] || F.info;
|
|
4774
5017
|
this.shadowRoot.innerHTML = `
|
|
4775
|
-
<style>${
|
|
5018
|
+
<style>${he}</style>
|
|
4776
5019
|
<div
|
|
4777
5020
|
class="alert"
|
|
4778
5021
|
role="${this.alertRole}"
|
|
@@ -4813,99 +5056,1187 @@ class nt extends h {
|
|
|
4813
5056
|
this.handleDismiss();
|
|
4814
5057
|
}
|
|
4815
5058
|
}
|
|
4816
|
-
|
|
5059
|
+
b("a11y-alert", bt);
|
|
5060
|
+
const ce = `
|
|
5061
|
+
:host {
|
|
5062
|
+
display: inline;
|
|
5063
|
+
}
|
|
5064
|
+
|
|
5065
|
+
:host([hidden]) {
|
|
5066
|
+
display: none !important;
|
|
5067
|
+
}
|
|
5068
|
+
|
|
5069
|
+
a {
|
|
5070
|
+
color: var(--compa11y-link-color, #0066cc);
|
|
5071
|
+
text-decoration: var(--compa11y-link-underline, underline);
|
|
5072
|
+
cursor: pointer;
|
|
5073
|
+
border-radius: 2px;
|
|
5074
|
+
}
|
|
5075
|
+
|
|
5076
|
+
a:hover {
|
|
5077
|
+
color: var(--compa11y-link-color-hover, #004499);
|
|
5078
|
+
}
|
|
5079
|
+
|
|
5080
|
+
a:visited {
|
|
5081
|
+
color: var(--compa11y-link-color-visited, #551a8b);
|
|
5082
|
+
}
|
|
5083
|
+
|
|
5084
|
+
a:focus-visible {
|
|
5085
|
+
outline: 2px solid var(--compa11y-focus-color, #0066cc);
|
|
5086
|
+
outline-offset: 2px;
|
|
5087
|
+
}
|
|
5088
|
+
|
|
5089
|
+
/* Disabled state */
|
|
5090
|
+
:host([disabled]) a {
|
|
5091
|
+
color: var(--compa11y-link-color-disabled, #999);
|
|
5092
|
+
cursor: not-allowed;
|
|
5093
|
+
pointer-events: none;
|
|
5094
|
+
text-decoration: none;
|
|
5095
|
+
}
|
|
5096
|
+
|
|
5097
|
+
/* External link indicator */
|
|
5098
|
+
.external-icon {
|
|
5099
|
+
display: inline-block;
|
|
5100
|
+
width: 0.75em;
|
|
5101
|
+
height: 0.75em;
|
|
5102
|
+
margin-left: 0.25em;
|
|
5103
|
+
vertical-align: baseline;
|
|
5104
|
+
}
|
|
5105
|
+
|
|
5106
|
+
/* Forced colors / high contrast mode */
|
|
5107
|
+
@media (forced-colors: active) {
|
|
5108
|
+
a {
|
|
5109
|
+
forced-color-adjust: none;
|
|
5110
|
+
color: LinkText;
|
|
5111
|
+
}
|
|
5112
|
+
|
|
5113
|
+
a:visited {
|
|
5114
|
+
color: VisitedText;
|
|
5115
|
+
}
|
|
5116
|
+
|
|
5117
|
+
a:focus-visible {
|
|
5118
|
+
outline: 2px solid Highlight;
|
|
5119
|
+
}
|
|
5120
|
+
|
|
5121
|
+
:host([disabled]) a {
|
|
5122
|
+
color: GrayText;
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
`;
|
|
5126
|
+
class pt extends u {
|
|
5127
|
+
static get observedAttributes() {
|
|
5128
|
+
return ["href", "external", "current", "disabled"];
|
|
5129
|
+
}
|
|
5130
|
+
setupAccessibility() {
|
|
5131
|
+
}
|
|
5132
|
+
render() {
|
|
5133
|
+
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
5134
|
+
const t = this.getAttribute("href") || "", e = this.hasAttribute("external"), i = this.getAttribute("current"), s = this.hasAttribute("disabled"), a = [];
|
|
5135
|
+
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}"`);
|
|
5136
|
+
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">
|
|
5137
|
+
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
|
|
5138
|
+
<polyline points="15 3 21 3 21 9"/>
|
|
5139
|
+
<line x1="10" y1="14" x2="21" y2="3"/>
|
|
5140
|
+
</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>' : "";
|
|
5141
|
+
this.shadowRoot.innerHTML = `
|
|
5142
|
+
<style>${ce}</style>
|
|
5143
|
+
<a ${a.join(" ")} part="link">
|
|
5144
|
+
<slot></slot>${r}${o}
|
|
5145
|
+
</a>
|
|
5146
|
+
`;
|
|
5147
|
+
}
|
|
5148
|
+
onAttributeChange(t, e, i) {
|
|
5149
|
+
["href", "external", "current", "disabled"].includes(t) && this.render();
|
|
5150
|
+
}
|
|
5151
|
+
}
|
|
5152
|
+
b("a11y-link", pt);
|
|
5153
|
+
const gt = `
|
|
5154
|
+
:host {
|
|
5155
|
+
display: block;
|
|
5156
|
+
}
|
|
5157
|
+
|
|
5158
|
+
:host([hidden]) {
|
|
5159
|
+
display: none !important;
|
|
5160
|
+
}
|
|
5161
|
+
|
|
5162
|
+
:host([as="span"]) {
|
|
5163
|
+
display: inline;
|
|
5164
|
+
}
|
|
5165
|
+
|
|
5166
|
+
*,
|
|
5167
|
+
*::before,
|
|
5168
|
+
*::after {
|
|
5169
|
+
box-sizing: border-box;
|
|
5170
|
+
}
|
|
5171
|
+
|
|
5172
|
+
/* Size scale */
|
|
5173
|
+
.size-xs { font-size: var(--compa11y-text-size-xs, 0.75rem); line-height: 1.5; }
|
|
5174
|
+
.size-sm { font-size: var(--compa11y-text-size-sm, 0.875rem); line-height: 1.5; }
|
|
5175
|
+
.size-md { font-size: var(--compa11y-text-size-md, 1rem); line-height: 1.5; }
|
|
5176
|
+
.size-lg { font-size: var(--compa11y-text-size-lg, 1.125rem); line-height: 1.5; }
|
|
5177
|
+
.size-xl { font-size: var(--compa11y-text-size-xl, 1.25rem); line-height: 1.4; }
|
|
5178
|
+
.size-2xl { font-size: var(--compa11y-text-size-2xl, 1.5rem); line-height: 1.3; }
|
|
5179
|
+
.size-3xl { font-size: var(--compa11y-text-size-3xl, 1.875rem); line-height: 1.25; }
|
|
5180
|
+
|
|
5181
|
+
/* Color variants */
|
|
5182
|
+
.color-default { color: var(--compa11y-text-color, inherit); }
|
|
5183
|
+
.color-muted { color: var(--compa11y-text-color-muted, #666); }
|
|
5184
|
+
.color-accent { color: var(--compa11y-text-color-accent, #0066cc); }
|
|
5185
|
+
.color-error { color: var(--compa11y-text-color-error, #dc2626); }
|
|
5186
|
+
.color-success { color: var(--compa11y-text-color-success, #16a34a); }
|
|
5187
|
+
.color-warning { color: var(--compa11y-text-color-warning, #d97706); }
|
|
5188
|
+
|
|
5189
|
+
/* Weight */
|
|
5190
|
+
.weight-normal { font-weight: 400; }
|
|
5191
|
+
.weight-medium { font-weight: 500; }
|
|
5192
|
+
.weight-semibold { font-weight: 600; }
|
|
5193
|
+
.weight-bold { font-weight: 700; }
|
|
5194
|
+
|
|
5195
|
+
/* Alignment */
|
|
5196
|
+
.align-left { text-align: left; }
|
|
5197
|
+
.align-center { text-align: center; }
|
|
5198
|
+
.align-right { text-align: right; }
|
|
5199
|
+
|
|
5200
|
+
/* Truncation */
|
|
5201
|
+
.truncate {
|
|
5202
|
+
overflow: hidden;
|
|
5203
|
+
text-overflow: ellipsis;
|
|
5204
|
+
white-space: nowrap;
|
|
5205
|
+
}
|
|
5206
|
+
|
|
5207
|
+
/* Forced colors */
|
|
5208
|
+
@media (forced-colors: active) {
|
|
5209
|
+
.color-muted,
|
|
5210
|
+
.color-accent,
|
|
5211
|
+
.color-error,
|
|
5212
|
+
.color-success,
|
|
5213
|
+
.color-warning {
|
|
5214
|
+
color: CanvasText;
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5217
|
+
`, ue = `
|
|
5218
|
+
${gt}
|
|
5219
|
+
|
|
5220
|
+
h1, h2, h3, h4, h5, h6 {
|
|
5221
|
+
margin: 0;
|
|
5222
|
+
font-family: var(--compa11y-heading-font-family, inherit);
|
|
5223
|
+
}
|
|
5224
|
+
|
|
5225
|
+
/* Default heading sizes (when no size attr) */
|
|
5226
|
+
h1 { font-size: var(--compa11y-heading-1-size, 2.25rem); line-height: 1.2; font-weight: 700; }
|
|
5227
|
+
h2 { font-size: var(--compa11y-heading-2-size, 1.875rem); line-height: 1.25; font-weight: 700; }
|
|
5228
|
+
h3 { font-size: var(--compa11y-heading-3-size, 1.5rem); line-height: 1.3; font-weight: 600; }
|
|
5229
|
+
h4 { font-size: var(--compa11y-heading-4-size, 1.25rem); line-height: 1.35; font-weight: 600; }
|
|
5230
|
+
h5 { font-size: var(--compa11y-heading-5-size, 1.125rem); line-height: 1.4; font-weight: 600; }
|
|
5231
|
+
h6 { font-size: var(--compa11y-heading-6-size, 1rem); line-height: 1.5; font-weight: 600; }
|
|
5232
|
+
`, be = `
|
|
5233
|
+
${gt}
|
|
5234
|
+
|
|
5235
|
+
p, span, div, label {
|
|
5236
|
+
margin: 0;
|
|
5237
|
+
font-family: var(--compa11y-text-font-family, inherit);
|
|
5238
|
+
}
|
|
5239
|
+
`;
|
|
5240
|
+
function mt(l, t) {
|
|
5241
|
+
const e = [], i = l.getAttribute("size"), s = l.getAttribute("color") || "default", a = l.getAttribute("weight"), r = l.getAttribute("align"), o = l.hasAttribute("truncate");
|
|
5242
|
+
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(" ");
|
|
5243
|
+
}
|
|
5244
|
+
class ft extends u {
|
|
5245
|
+
static get observedAttributes() {
|
|
5246
|
+
return ["level", "size", "color", "weight", "align", "truncate"];
|
|
5247
|
+
}
|
|
5248
|
+
get headingLevel() {
|
|
5249
|
+
const t = parseInt(this.getAttribute("level") || "2", 10);
|
|
5250
|
+
return t >= 1 && t <= 6 ? t : 2;
|
|
5251
|
+
}
|
|
5252
|
+
setupAccessibility() {
|
|
5253
|
+
}
|
|
5254
|
+
render() {
|
|
5255
|
+
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
5256
|
+
const t = `h${this.headingLevel}`, e = mt(this), i = this.getAttribute("size") ? `size-${this.getAttribute("size")}` : "", s = e;
|
|
5257
|
+
this.shadowRoot.innerHTML = `
|
|
5258
|
+
<style>${ue}</style>
|
|
5259
|
+
<${t} class="${s}" part="heading">
|
|
5260
|
+
<slot></slot>
|
|
5261
|
+
</${t}>
|
|
5262
|
+
`;
|
|
5263
|
+
}
|
|
5264
|
+
onAttributeChange() {
|
|
5265
|
+
this.render();
|
|
5266
|
+
}
|
|
5267
|
+
}
|
|
5268
|
+
class vt extends u {
|
|
5269
|
+
static get observedAttributes() {
|
|
5270
|
+
return ["as", "size", "color", "weight", "align", "truncate"];
|
|
5271
|
+
}
|
|
5272
|
+
get tagName_() {
|
|
5273
|
+
const t = this.getAttribute("as");
|
|
5274
|
+
return t && ["p", "span", "div", "label"].includes(t) ? t : "p";
|
|
5275
|
+
}
|
|
5276
|
+
setupAccessibility() {
|
|
5277
|
+
}
|
|
5278
|
+
render() {
|
|
5279
|
+
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
5280
|
+
const t = this.tagName_, e = mt(this, "md");
|
|
5281
|
+
this.shadowRoot.innerHTML = `
|
|
5282
|
+
<style>${be}</style>
|
|
5283
|
+
<${t} class="${e}" part="text">
|
|
5284
|
+
<slot></slot>
|
|
5285
|
+
</${t}>
|
|
5286
|
+
`;
|
|
5287
|
+
}
|
|
5288
|
+
onAttributeChange() {
|
|
5289
|
+
this.render();
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5292
|
+
b("a11y-heading", ft);
|
|
5293
|
+
b("a11y-text", vt);
|
|
5294
|
+
const pe = `
|
|
5295
|
+
:host {
|
|
5296
|
+
display: block;
|
|
5297
|
+
box-sizing: border-box;
|
|
5298
|
+
}
|
|
5299
|
+
|
|
5300
|
+
:host([hidden]) {
|
|
5301
|
+
display: none !important;
|
|
5302
|
+
}
|
|
5303
|
+
|
|
5304
|
+
*,
|
|
5305
|
+
*::before,
|
|
5306
|
+
*::after {
|
|
5307
|
+
box-sizing: inherit;
|
|
5308
|
+
}
|
|
5309
|
+
|
|
5310
|
+
.field-wrapper {
|
|
5311
|
+
display: flex;
|
|
5312
|
+
flex-direction: column;
|
|
5313
|
+
gap: var(--compa11y-field-gap, 0.25rem);
|
|
5314
|
+
}
|
|
5315
|
+
|
|
5316
|
+
.field-label {
|
|
5317
|
+
display: block;
|
|
5318
|
+
color: var(--compa11y-field-label-color, inherit);
|
|
5319
|
+
font-size: var(--compa11y-field-label-size, 0.875rem);
|
|
5320
|
+
font-weight: var(--compa11y-field-label-weight, 500);
|
|
5321
|
+
}
|
|
5322
|
+
|
|
5323
|
+
:host([disabled]) .field-label {
|
|
5324
|
+
color: var(--compa11y-field-disabled-color, #999);
|
|
5325
|
+
}
|
|
5326
|
+
|
|
5327
|
+
.field-required {
|
|
5328
|
+
color: var(--compa11y-field-required-color, #ef4444);
|
|
5329
|
+
margin-left: 0.125rem;
|
|
5330
|
+
}
|
|
5331
|
+
|
|
5332
|
+
.field-hint {
|
|
5333
|
+
color: var(--compa11y-field-hint-color, #666);
|
|
5334
|
+
font-size: var(--compa11y-field-hint-size, 0.8125rem);
|
|
5335
|
+
}
|
|
5336
|
+
|
|
5337
|
+
.field-error {
|
|
5338
|
+
color: var(--compa11y-field-error-color, #ef4444);
|
|
5339
|
+
font-size: var(--compa11y-field-error-size, 0.8125rem);
|
|
5340
|
+
}
|
|
5341
|
+
|
|
5342
|
+
/* Forced colors */
|
|
5343
|
+
@media (forced-colors: active) {
|
|
5344
|
+
.field-label {
|
|
5345
|
+
color: CanvasText;
|
|
5346
|
+
}
|
|
5347
|
+
|
|
5348
|
+
:host([disabled]) .field-label {
|
|
5349
|
+
color: GrayText;
|
|
5350
|
+
}
|
|
5351
|
+
|
|
5352
|
+
.field-error {
|
|
5353
|
+
color: LinkText;
|
|
5354
|
+
}
|
|
5355
|
+
}
|
|
5356
|
+
`;
|
|
5357
|
+
class yt extends u {
|
|
5358
|
+
static get observedAttributes() {
|
|
5359
|
+
return ["label", "hint", "error", "required", "disabled"];
|
|
5360
|
+
}
|
|
5361
|
+
setupAccessibility() {
|
|
5362
|
+
var t;
|
|
5363
|
+
typeof process < "u" && ((t = process.env) == null ? void 0 : t.NODE_ENV) !== "production" && (this.hasAttribute("label") || console.warn(
|
|
5364
|
+
`[compa11y/FormField] FormField has no label. Add label="..." attribute.
|
|
5365
|
+
💡 Suggestion: <a11y-form-field label="Email">...</a11y-form-field>`
|
|
5366
|
+
));
|
|
5367
|
+
}
|
|
5368
|
+
render() {
|
|
5369
|
+
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
5370
|
+
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`;
|
|
5371
|
+
this.setAttribute("data-error", a ? "true" : "false"), this.shadowRoot.innerHTML = `
|
|
5372
|
+
<style>${pe}</style>
|
|
5373
|
+
<div class="field-wrapper" part="wrapper">
|
|
5374
|
+
${t ? `<label
|
|
5375
|
+
class="field-label"
|
|
5376
|
+
id="${r}"
|
|
5377
|
+
part="label"
|
|
5378
|
+
>${t}${s ? '<span class="field-required" aria-hidden="true" part="required">*</span>' : ""}</label>` : ""}
|
|
5379
|
+
<slot></slot>
|
|
5380
|
+
${e ? `<div class="field-hint" id="${o}" part="hint">${e}</div>` : ""}
|
|
5381
|
+
${a ? `<div class="field-error" id="${n}" role="alert" part="error">${i}</div>` : ""}
|
|
5382
|
+
</div>
|
|
5383
|
+
`, this.wireControl();
|
|
5384
|
+
}
|
|
5385
|
+
setupEventListeners() {
|
|
5386
|
+
var e;
|
|
5387
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("slot");
|
|
5388
|
+
t == null || t.addEventListener("slotchange", () => this.wireControl());
|
|
5389
|
+
}
|
|
5390
|
+
cleanupEventListeners() {
|
|
5391
|
+
var e;
|
|
5392
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("slot");
|
|
5393
|
+
t == null || t.removeEventListener("slotchange", () => this.wireControl());
|
|
5394
|
+
}
|
|
5395
|
+
/**
|
|
5396
|
+
* Find the first focusable control in the slot and wire ARIA attributes.
|
|
5397
|
+
*/
|
|
5398
|
+
wireControl() {
|
|
5399
|
+
var _;
|
|
5400
|
+
const t = (_ = this.shadowRoot) == null ? void 0 : _.querySelector("slot");
|
|
5401
|
+
if (!t) return;
|
|
5402
|
+
const e = t.assignedElements({ flatten: !0 }), i = e.find(
|
|
5403
|
+
(y) => y instanceof HTMLInputElement || y instanceof HTMLSelectElement || y instanceof HTMLTextAreaElement || y.hasAttribute("role") || y.hasAttribute("tabindex")
|
|
5404
|
+
) || e[0];
|
|
5405
|
+
if (!i) return;
|
|
5406
|
+
const s = this.getAttribute("label") || "", a = this.getAttribute("hint") || "", r = this.getAttribute("error") || "", o = this.hasAttribute("required"), n = this.hasAttribute("disabled"), d = !!r, c = `${this._id}-label`, h = `${this._id}-hint`, p = `${this._id}-error`;
|
|
5407
|
+
s && !i.hasAttribute("aria-label") && i.setAttribute("aria-labelledby", c);
|
|
5408
|
+
const m = [];
|
|
5409
|
+
a && m.push(h), d && m.push(p), m.length ? i.setAttribute("aria-describedby", m.join(" ")) : i.removeAttribute("aria-describedby"), d ? 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"));
|
|
5410
|
+
}
|
|
5411
|
+
onAttributeChange(t, e, i) {
|
|
5412
|
+
["label", "hint", "error", "required", "disabled"].includes(t) && (this.render(), this.setupEventListeners());
|
|
5413
|
+
}
|
|
5414
|
+
}
|
|
5415
|
+
b("a11y-form-field", yt);
|
|
5416
|
+
const P = $("Popover");
|
|
5417
|
+
function ge(l, t, e, i) {
|
|
5418
|
+
const s = window.innerWidth, a = window.innerHeight, r = t.offsetWidth, o = t.offsetHeight, n = e.indexOf("-"), d = n === -1 ? e : e.slice(0, n), c = n === -1 ? "center" : e.slice(n + 1);
|
|
5419
|
+
let h = 0, p = 0;
|
|
5420
|
+
switch (d) {
|
|
5421
|
+
case "top":
|
|
5422
|
+
h = l.top - o - i;
|
|
5423
|
+
break;
|
|
5424
|
+
case "bottom":
|
|
5425
|
+
h = l.bottom + i;
|
|
5426
|
+
break;
|
|
5427
|
+
case "left":
|
|
5428
|
+
p = l.left - r - i;
|
|
5429
|
+
break;
|
|
5430
|
+
case "right":
|
|
5431
|
+
p = l.right + i;
|
|
5432
|
+
break;
|
|
5433
|
+
}
|
|
5434
|
+
if (d === "top" || d === "bottom")
|
|
5435
|
+
switch (c) {
|
|
5436
|
+
case "start":
|
|
5437
|
+
p = l.left;
|
|
5438
|
+
break;
|
|
5439
|
+
case "end":
|
|
5440
|
+
p = l.right - r;
|
|
5441
|
+
break;
|
|
5442
|
+
default:
|
|
5443
|
+
p = l.left + (l.width - r) / 2;
|
|
5444
|
+
}
|
|
5445
|
+
else
|
|
5446
|
+
switch (c) {
|
|
5447
|
+
case "start":
|
|
5448
|
+
h = l.top;
|
|
5449
|
+
break;
|
|
5450
|
+
case "end":
|
|
5451
|
+
h = l.bottom - o;
|
|
5452
|
+
break;
|
|
5453
|
+
default:
|
|
5454
|
+
h = l.top + (l.height - o) / 2;
|
|
5455
|
+
}
|
|
5456
|
+
d === "bottom" && h + o > a && l.top - o - i > 0 ? h = l.top - o - i : d === "top" && h < 0 && l.bottom + i + o < a ? h = l.bottom + i : d === "right" && p + r > s && l.left - r - i > 0 ? p = l.left - r - i : d === "left" && p < 0 && l.right + i + r < s && (p = l.right + i);
|
|
5457
|
+
const m = 8;
|
|
5458
|
+
return p = Math.max(m, Math.min(p, s - r - m)), h = Math.max(m, Math.min(h, a - o - m)), { top: h, left: p };
|
|
5459
|
+
}
|
|
5460
|
+
const me = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), details > summary', fe = `
|
|
5461
|
+
:host {
|
|
5462
|
+
display: inline-block;
|
|
5463
|
+
}
|
|
5464
|
+
|
|
5465
|
+
:host([hidden]) {
|
|
5466
|
+
display: none !important;
|
|
5467
|
+
}
|
|
5468
|
+
|
|
5469
|
+
*,
|
|
5470
|
+
*::before,
|
|
5471
|
+
*::after {
|
|
5472
|
+
box-sizing: border-box;
|
|
5473
|
+
}
|
|
5474
|
+
|
|
5475
|
+
.popover-content {
|
|
5476
|
+
position: fixed;
|
|
5477
|
+
z-index: var(--compa11y-popover-z-index, 1000);
|
|
5478
|
+
background: var(--compa11y-popover-bg, #fff);
|
|
5479
|
+
color: var(--compa11y-popover-color, inherit);
|
|
5480
|
+
border: var(--compa11y-popover-border, 1px solid rgba(0, 0, 0, 0.15));
|
|
5481
|
+
border-radius: var(--compa11y-popover-radius, 0.375rem);
|
|
5482
|
+
box-shadow: var(--compa11y-popover-shadow, 0 4px 16px rgba(0, 0, 0, 0.12));
|
|
5483
|
+
padding: var(--compa11y-popover-padding, 1rem);
|
|
5484
|
+
max-width: var(--compa11y-popover-max-width, 320px);
|
|
5485
|
+
min-width: 100px;
|
|
5486
|
+
outline: none;
|
|
5487
|
+
transition: opacity 0.15s ease, transform 0.15s ease;
|
|
5488
|
+
opacity: 0;
|
|
5489
|
+
transform: scale(0.96) translateY(-2px);
|
|
5490
|
+
}
|
|
5491
|
+
|
|
5492
|
+
.popover-content[data-open="true"] {
|
|
5493
|
+
opacity: 1;
|
|
5494
|
+
transform: scale(1) translateY(0);
|
|
5495
|
+
}
|
|
5496
|
+
|
|
5497
|
+
.popover-content[hidden] {
|
|
5498
|
+
display: none !important;
|
|
5499
|
+
}
|
|
5500
|
+
|
|
5501
|
+
@media (prefers-reduced-motion: reduce) {
|
|
5502
|
+
.popover-content {
|
|
5503
|
+
transition: none;
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
|
|
5507
|
+
${G}
|
|
5508
|
+
|
|
5509
|
+
@media (forced-colors: active) {
|
|
5510
|
+
.popover-content {
|
|
5511
|
+
border: 2px solid ButtonText;
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5514
|
+
`;
|
|
5515
|
+
class _t extends u {
|
|
5516
|
+
constructor() {
|
|
5517
|
+
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._focusOrigin = null, this._weMovedFocus = !1, this._onTriggerSlotChange = () => {
|
|
5518
|
+
const t = `${this._id}-content`;
|
|
5519
|
+
this._wireTrigger(t);
|
|
5520
|
+
}, this._onOutsidePointerDown = (t) => {
|
|
5521
|
+
t.composedPath().includes(this) || (this.open = !1);
|
|
5522
|
+
}, this._onDocumentKeyDown = (t) => {
|
|
5523
|
+
t.key === "Escape" && (t.stopPropagation(), this.open = !1);
|
|
5524
|
+
}, this._onScrollOrResize = () => {
|
|
5525
|
+
this._open && this._updatePosition();
|
|
5526
|
+
}, this._onTriggerClick = () => {
|
|
5527
|
+
this._disabled || (this.open = !this._open);
|
|
5528
|
+
}, this._onTriggerKeyDown = (t) => {
|
|
5529
|
+
this._disabled || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.open = !this._open);
|
|
5530
|
+
};
|
|
5531
|
+
}
|
|
5532
|
+
static get observedAttributes() {
|
|
5533
|
+
return [
|
|
5534
|
+
"open",
|
|
5535
|
+
"placement",
|
|
5536
|
+
"offset",
|
|
5537
|
+
"disabled",
|
|
5538
|
+
"haspopup",
|
|
5539
|
+
"content-role",
|
|
5540
|
+
"content-label",
|
|
5541
|
+
"focus-policy"
|
|
5542
|
+
];
|
|
5543
|
+
}
|
|
5544
|
+
// ─── Public API ────────────────────────────────────────────────────────────
|
|
5545
|
+
get open() {
|
|
5546
|
+
return this._open;
|
|
5547
|
+
}
|
|
5548
|
+
set open(t) {
|
|
5549
|
+
this._open !== t && (this._open = t, this.toggleAttribute("open", t), t ? this._show() : this._hide());
|
|
5550
|
+
}
|
|
5551
|
+
get disabled() {
|
|
5552
|
+
return this._disabled;
|
|
5553
|
+
}
|
|
5554
|
+
set disabled(t) {
|
|
5555
|
+
this._disabled = t, this.toggleAttribute("disabled", t), this._updateTriggerDisabled();
|
|
5556
|
+
}
|
|
5557
|
+
// ─── Lifecycle ─────────────────────────────────────────────────────────────
|
|
5558
|
+
setupAccessibility() {
|
|
5559
|
+
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";
|
|
5560
|
+
}
|
|
5561
|
+
render() {
|
|
5562
|
+
this.shadowRoot || this.attachShadow({ mode: "open" });
|
|
5563
|
+
const t = `${this._id}-content`, e = this._contentLabel ? `aria-label="${this._contentLabel}"` : "";
|
|
5564
|
+
this.shadowRoot.innerHTML = `
|
|
5565
|
+
<style>${fe}</style>
|
|
5566
|
+
<slot name="trigger" part="trigger-slot"></slot>
|
|
5567
|
+
<div
|
|
5568
|
+
class="popover-content"
|
|
5569
|
+
id="${t}"
|
|
5570
|
+
part="content"
|
|
5571
|
+
role="${this._contentRole}"
|
|
5572
|
+
aria-modal="false"
|
|
5573
|
+
tabindex="-1"
|
|
5574
|
+
${e}
|
|
5575
|
+
${this._open ? 'data-open="true"' : ""}
|
|
5576
|
+
${this._open ? "" : "hidden"}
|
|
5577
|
+
>
|
|
5578
|
+
<slot></slot>
|
|
5579
|
+
</div>
|
|
5580
|
+
`, this._contentEl = this.shadowRoot.querySelector(".popover-content"), this._wireTrigger(t), this._open && requestAnimationFrame(() => this._updatePosition());
|
|
5581
|
+
}
|
|
5582
|
+
setupEventListeners() {
|
|
5583
|
+
var e;
|
|
5584
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector('slot[name="trigger"]');
|
|
5585
|
+
t == null || t.addEventListener("slotchange", this._onTriggerSlotChange);
|
|
5586
|
+
}
|
|
5587
|
+
cleanupEventListeners() {
|
|
5588
|
+
var e;
|
|
5589
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector('slot[name="trigger"]');
|
|
5590
|
+
t == null || t.removeEventListener("slotchange", this._onTriggerSlotChange), this._removeGlobalListeners(), this._detachTriggerListeners();
|
|
5591
|
+
}
|
|
5592
|
+
onAttributeChange(t, e, i) {
|
|
5593
|
+
var s, a, r;
|
|
5594
|
+
switch (t) {
|
|
5595
|
+
case "open":
|
|
5596
|
+
this.open = i !== null;
|
|
5597
|
+
break;
|
|
5598
|
+
case "placement":
|
|
5599
|
+
this._placement = i || "bottom", this._open && this._updatePosition();
|
|
5600
|
+
break;
|
|
5601
|
+
case "offset":
|
|
5602
|
+
this._offset = parseInt(i || "8", 10), this._open && this._updatePosition();
|
|
5603
|
+
break;
|
|
5604
|
+
case "disabled":
|
|
5605
|
+
this._disabled = i !== null, this._updateTriggerDisabled();
|
|
5606
|
+
break;
|
|
5607
|
+
case "haspopup":
|
|
5608
|
+
this._haspopup = i || "dialog", this._updateTriggerAria();
|
|
5609
|
+
break;
|
|
5610
|
+
case "content-role":
|
|
5611
|
+
this._contentRole = i || "dialog", (s = this._contentEl) == null || s.setAttribute("role", this._contentRole);
|
|
5612
|
+
break;
|
|
5613
|
+
case "content-label":
|
|
5614
|
+
this._contentLabel = i || "", this._contentLabel ? (a = this._contentEl) == null || a.setAttribute("aria-label", this._contentLabel) : (r = this._contentEl) == null || r.removeAttribute("aria-label");
|
|
5615
|
+
break;
|
|
5616
|
+
case "focus-policy":
|
|
5617
|
+
this._focusPolicy = i || "first";
|
|
5618
|
+
break;
|
|
5619
|
+
}
|
|
5620
|
+
}
|
|
5621
|
+
// ─── Trigger Wiring ────────────────────────────────────────────────────────
|
|
5622
|
+
_wireTrigger(t) {
|
|
5623
|
+
var a, r;
|
|
5624
|
+
const e = (a = this.shadowRoot) == null ? void 0 : a.querySelector('slot[name="trigger"]');
|
|
5625
|
+
if (!e) return;
|
|
5626
|
+
const s = e.assignedElements({ flatten: !0 })[0] || null;
|
|
5627
|
+
typeof process < "u" && ((r = process.env) == null ? void 0 : r.NODE_ENV) !== "production" && (s || P.warning(
|
|
5628
|
+
'Popover has no trigger. Add an element to the "trigger" slot.',
|
|
5629
|
+
'<a11y-popover><button slot="trigger">Open</button>...</a11y-popover>'
|
|
5630
|
+
)), this._detachTriggerListeners(), this._triggerEl = s, s && (this._updateTriggerAria(t), this._updateTriggerDisabled(), s.addEventListener("click", this._onTriggerClick), s.addEventListener("keydown", this._onTriggerKeyDown));
|
|
5631
|
+
}
|
|
5632
|
+
/** Update ARIA attributes on the trigger without re-wiring listeners. */
|
|
5633
|
+
_updateTriggerAria(t) {
|
|
5634
|
+
const e = this._triggerEl;
|
|
5635
|
+
if (!e) return;
|
|
5636
|
+
const i = t || `${this._id}-content`;
|
|
5637
|
+
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");
|
|
5638
|
+
}
|
|
5639
|
+
/** Apply disabled state to the trigger element. */
|
|
5640
|
+
_updateTriggerDisabled() {
|
|
5641
|
+
const t = this._triggerEl;
|
|
5642
|
+
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")));
|
|
5643
|
+
}
|
|
5644
|
+
_detachTriggerListeners() {
|
|
5645
|
+
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"));
|
|
5646
|
+
}
|
|
5647
|
+
// ─── Open / Close ──────────────────────────────────────────────────────────
|
|
5648
|
+
_show() {
|
|
5649
|
+
var t;
|
|
5650
|
+
this._contentEl && (this._focusOrigin = document.activeElement, this._contentEl.removeAttribute("hidden"), this._updateTriggerAria(), this._updatePosition(), requestAnimationFrame(() => {
|
|
5651
|
+
var e;
|
|
5652
|
+
(e = this._contentEl) == null || e.setAttribute("data-open", "true");
|
|
5653
|
+
}), typeof process < "u" && ((t = process.env) == null ? void 0 : t.NODE_ENV) !== "production" && requestAnimationFrame(() => {
|
|
5654
|
+
const e = this._contentEl;
|
|
5655
|
+
if (!e) return;
|
|
5656
|
+
const i = e.hasAttribute("aria-label") || e.hasAttribute("aria-labelledby"), s = !!e.querySelector('h1, h2, h3, h4, h5, h6, [role="heading"]');
|
|
5657
|
+
!i && !s && P.warning(
|
|
5658
|
+
'Popover content has no accessible name. Add content-label="..." on <a11y-popover>, or place a heading inside the content.',
|
|
5659
|
+
'Example: <a11y-popover content-label="Filter options">...</a11y-popover>'
|
|
5660
|
+
);
|
|
5661
|
+
}), requestAnimationFrame(() => {
|
|
5662
|
+
const e = this._focusPolicy;
|
|
5663
|
+
if (e === "none") return;
|
|
5664
|
+
const i = this._contentEl;
|
|
5665
|
+
if (!i) return;
|
|
5666
|
+
let s = null;
|
|
5667
|
+
e === "first" && (s = i.querySelector(me)), s || (s = i), this._weMovedFocus = !0, s.focus();
|
|
5668
|
+
}), this._addGlobalListeners(), this.emit("a11y-popover-open"));
|
|
5669
|
+
}
|
|
5670
|
+
_hide() {
|
|
5671
|
+
var s;
|
|
5672
|
+
if (!this._contentEl) return;
|
|
5673
|
+
this._contentEl.removeAttribute("data-open"), this._updateTriggerAria();
|
|
5674
|
+
const t = () => {
|
|
5675
|
+
var a, r;
|
|
5676
|
+
(a = this._contentEl) == null || a.setAttribute("hidden", ""), (r = this._contentEl) == null || r.removeEventListener("transitionend", t);
|
|
5677
|
+
};
|
|
5678
|
+
getComputedStyle(this._contentEl).transitionDuration !== "0s" ? (this._contentEl.addEventListener("transitionend", t), setTimeout(t, 200)) : this._contentEl.setAttribute("hidden", ""), this._removeGlobalListeners();
|
|
5679
|
+
const i = this._weMovedFocus || this._contentEl.contains(document.activeElement);
|
|
5680
|
+
this._weMovedFocus = !1, this._focusOrigin = null, i && ((s = this._triggerEl) == null || s.focus()), this.emit("a11y-popover-close");
|
|
5681
|
+
}
|
|
5682
|
+
// ─── Positioning ───────────────────────────────────────────────────────────
|
|
5683
|
+
_updatePosition() {
|
|
5684
|
+
if (!this._triggerEl || !this._contentEl || !this._open) return;
|
|
5685
|
+
const t = this._triggerEl.getBoundingClientRect(), { top: e, left: i } = ge(
|
|
5686
|
+
t,
|
|
5687
|
+
this._contentEl,
|
|
5688
|
+
this._placement,
|
|
5689
|
+
this._offset
|
|
5690
|
+
);
|
|
5691
|
+
this._contentEl.style.top = `${e}px`, this._contentEl.style.left = `${i}px`;
|
|
5692
|
+
}
|
|
5693
|
+
// ─── Global Dismiss Listeners ──────────────────────────────────────────────
|
|
5694
|
+
_addGlobalListeners() {
|
|
5695
|
+
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 });
|
|
5696
|
+
}
|
|
5697
|
+
_removeGlobalListeners() {
|
|
5698
|
+
document.removeEventListener("pointerdown", this._onOutsidePointerDown, !0), document.removeEventListener("keydown", this._onDocumentKeyDown, !0), window.removeEventListener("scroll", this._onScrollOrResize, !0), window.removeEventListener("resize", this._onScrollOrResize);
|
|
5699
|
+
}
|
|
5700
|
+
}
|
|
5701
|
+
b("a11y-popover", _t);
|
|
5702
|
+
const ve = $("A11yAccordion");
|
|
5703
|
+
let N = !1;
|
|
5704
|
+
function ye() {
|
|
5705
|
+
if (N || typeof document > "u") return;
|
|
5706
|
+
N = !0;
|
|
5707
|
+
const l = document.createElement("style");
|
|
5708
|
+
l.setAttribute("data-compa11y-accordion", ""), l.textContent = ie, document.head.appendChild(l);
|
|
5709
|
+
}
|
|
5710
|
+
class xt extends u {
|
|
5711
|
+
constructor() {
|
|
5712
|
+
super(...arguments), this._triggers = [], this._panels = [], this._openItems = /* @__PURE__ */ new Set(), this._defaultSlotEl = null, this.updateItems = () => {
|
|
5713
|
+
this._triggers = Array.from(
|
|
5714
|
+
this.querySelectorAll("[data-accordion-trigger]")
|
|
5715
|
+
), this._panels = Array.from(
|
|
5716
|
+
this.querySelectorAll("[data-accordion-panel]")
|
|
5717
|
+
), this._triggers.forEach((t, e) => {
|
|
5718
|
+
const i = this._panels[e], s = t.id || `${this._id}-trigger-${e}`, a = (i == null ? void 0 : i.id) || `${this._id}-panel-${e}`;
|
|
5719
|
+
t.id = s, t.getAttribute("aria-controls") || t.setAttribute("aria-controls", a);
|
|
5720
|
+
const r = this._openItems.has(e);
|
|
5721
|
+
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), ve.checks.accessibleLabel(
|
|
5722
|
+
t,
|
|
5723
|
+
`a11y-accordion trigger[${e}]`
|
|
5724
|
+
);
|
|
5725
|
+
});
|
|
5726
|
+
}, this.handleClick = (t) => {
|
|
5727
|
+
const i = t.target.closest(
|
|
5728
|
+
"[data-accordion-trigger]"
|
|
5729
|
+
);
|
|
5730
|
+
if (!i || i.hasAttribute("disabled") || i.getAttribute("aria-disabled") === "true") return;
|
|
5731
|
+
const a = this._triggers.indexOf(i);
|
|
5732
|
+
a !== -1 && this.toggleItem(a);
|
|
5733
|
+
}, this.handleKeyDown = (t) => {
|
|
5734
|
+
var o, n, d, c;
|
|
5735
|
+
const i = t.target.closest(
|
|
5736
|
+
"[data-accordion-trigger]"
|
|
5737
|
+
);
|
|
5738
|
+
if (!i || this._triggers.indexOf(i) === -1) return;
|
|
5739
|
+
const a = this._triggers.filter(
|
|
5740
|
+
(h) => !h.hasAttribute("disabled") && h.getAttribute("aria-disabled") !== "true"
|
|
5741
|
+
), r = a.indexOf(i);
|
|
5742
|
+
if (r !== -1)
|
|
5743
|
+
switch (t.key) {
|
|
5744
|
+
case "ArrowDown":
|
|
5745
|
+
t.preventDefault(), (o = a[(r + 1) % a.length]) == null || o.focus();
|
|
5746
|
+
break;
|
|
5747
|
+
case "ArrowUp":
|
|
5748
|
+
t.preventDefault(), (n = a[(r - 1 + a.length) % a.length]) == null || n.focus();
|
|
5749
|
+
break;
|
|
5750
|
+
case "Home":
|
|
5751
|
+
t.preventDefault(), (d = a[0]) == null || d.focus();
|
|
5752
|
+
break;
|
|
5753
|
+
case "End":
|
|
5754
|
+
t.preventDefault(), (c = a[a.length - 1]) == null || c.focus();
|
|
5755
|
+
break;
|
|
5756
|
+
}
|
|
5757
|
+
};
|
|
5758
|
+
}
|
|
5759
|
+
static get observedAttributes() {
|
|
5760
|
+
return ["type", "collapsible"];
|
|
5761
|
+
}
|
|
5762
|
+
/** Whether one or multiple items can be open at once. @default 'single' */
|
|
5763
|
+
get type() {
|
|
5764
|
+
return this.getAttribute("type") || "single";
|
|
5765
|
+
}
|
|
5766
|
+
/** Whether the open item can be collapsed in single mode. */
|
|
5767
|
+
get collapsible() {
|
|
5768
|
+
return this.hasAttribute("collapsible");
|
|
5769
|
+
}
|
|
5770
|
+
setupAccessibility() {
|
|
5771
|
+
ye(), this.updateItems();
|
|
5772
|
+
}
|
|
5773
|
+
render() {
|
|
5774
|
+
this.shadowRoot || this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
|
|
5775
|
+
<style>
|
|
5776
|
+
${g}
|
|
5777
|
+
:host {
|
|
5778
|
+
display: block;
|
|
5779
|
+
}
|
|
5780
|
+
</style>
|
|
5781
|
+
<slot></slot>
|
|
5782
|
+
`;
|
|
5783
|
+
}
|
|
5784
|
+
setupEventListeners() {
|
|
5785
|
+
var t, e;
|
|
5786
|
+
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);
|
|
5787
|
+
}
|
|
5788
|
+
cleanupEventListeners() {
|
|
5789
|
+
var t;
|
|
5790
|
+
this.removeEventListener("click", this.handleClick), this.removeEventListener("keydown", this.handleKeyDown), (t = this._defaultSlotEl) == null || t.removeEventListener(
|
|
5791
|
+
"slotchange",
|
|
5792
|
+
this.updateItems
|
|
5793
|
+
);
|
|
5794
|
+
}
|
|
5795
|
+
onAttributeChange(t, e, i) {
|
|
5796
|
+
t === "type" && (this._openItems.clear(), this.syncState());
|
|
5797
|
+
}
|
|
5798
|
+
toggleItem(t) {
|
|
5799
|
+
var n, d;
|
|
5800
|
+
const e = this._openItems.has(t), i = [];
|
|
5801
|
+
this.type === "single" ? e && this.collapsible ? i.push(t) : e || this._openItems.forEach((c) => i.push(c)) : e && i.push(t);
|
|
5802
|
+
const s = document.activeElement, a = i.find((c) => {
|
|
5803
|
+
const h = this._panels[c];
|
|
5804
|
+
return h && h.contains(s);
|
|
5805
|
+
});
|
|
5806
|
+
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(() => {
|
|
5807
|
+
var c;
|
|
5808
|
+
(c = this._triggers[a]) == null || c.focus();
|
|
5809
|
+
});
|
|
5810
|
+
const r = this._openItems.has(t), o = ((d = (n = this._triggers[t]) == null ? void 0 : n.textContent) == null ? void 0 : d.trim()) || "Section";
|
|
5811
|
+
v(`${o} ${r ? "expanded" : "collapsed"}`), this.emit("a11y-accordion-change", {
|
|
5812
|
+
index: t,
|
|
5813
|
+
expanded: r,
|
|
5814
|
+
trigger: this._triggers[t],
|
|
5815
|
+
panel: this._panels[t]
|
|
5816
|
+
});
|
|
5817
|
+
}
|
|
5818
|
+
syncState() {
|
|
5819
|
+
this._triggers.forEach((t, e) => {
|
|
5820
|
+
const i = this._panels[e], s = this._openItems.has(e);
|
|
5821
|
+
t.setAttribute("aria-expanded", String(s)), i && (i.hidden = !s);
|
|
5822
|
+
});
|
|
5823
|
+
}
|
|
5824
|
+
/** Open an item by index */
|
|
5825
|
+
open(t) {
|
|
5826
|
+
this.type === "single" && this._openItems.clear(), this._openItems.add(t), this.syncState();
|
|
5827
|
+
}
|
|
5828
|
+
/** Close an item by index */
|
|
5829
|
+
close(t) {
|
|
5830
|
+
this._openItems.delete(t), this.syncState();
|
|
5831
|
+
}
|
|
5832
|
+
/** Toggle an item by index */
|
|
5833
|
+
toggle(t) {
|
|
5834
|
+
this.toggleItem(t);
|
|
5835
|
+
}
|
|
5836
|
+
}
|
|
5837
|
+
b("a11y-accordion", xt);
|
|
5838
|
+
const j = $("A11yTable");
|
|
5839
|
+
let Y = !1;
|
|
5840
|
+
function _e() {
|
|
5841
|
+
if (Y || typeof document > "u") return;
|
|
5842
|
+
Y = !0;
|
|
5843
|
+
const l = document.createElement("style");
|
|
5844
|
+
l.setAttribute("data-compa11y-table", ""), l.textContent = se, document.head.appendChild(l);
|
|
5845
|
+
}
|
|
5846
|
+
class At extends u {
|
|
5847
|
+
constructor() {
|
|
5848
|
+
super(...arguments), this._columns = [], this._rows = [], this._sortKey = null, this._sortDirection = "none", this._selectedRows = /* @__PURE__ */ new Set(), this._tableEl = null, this.handleClick = (t) => {
|
|
5849
|
+
const i = t.target.closest("[data-sort-btn]");
|
|
5850
|
+
if (i) {
|
|
5851
|
+
const s = i.dataset.sortKey;
|
|
5852
|
+
if (s) {
|
|
5853
|
+
this.sort(s);
|
|
5854
|
+
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}`;
|
|
5855
|
+
v(`${r} ${o}`), this.emit("a11y-table-sort", {
|
|
5856
|
+
sortKey: this._sortKey,
|
|
5857
|
+
sortDirection: this._sortDirection
|
|
5858
|
+
});
|
|
5859
|
+
}
|
|
5860
|
+
}
|
|
5861
|
+
}, this.handleChange = (t) => {
|
|
5862
|
+
const e = t.target;
|
|
5863
|
+
if (!(!e || e.type !== "checkbox")) {
|
|
5864
|
+
if ("selectAll" in e.dataset) {
|
|
5865
|
+
e.checked ? this.selectAll() : this.deselectAll();
|
|
5866
|
+
const i = this._selectedRows.size;
|
|
5867
|
+
v(
|
|
5868
|
+
i === 0 ? "Selection cleared" : `All ${i} rows selected`
|
|
5869
|
+
);
|
|
5870
|
+
return;
|
|
5871
|
+
}
|
|
5872
|
+
if ("selectRow" in e.dataset) {
|
|
5873
|
+
const i = e.dataset.rowId ?? "";
|
|
5874
|
+
if (!i) return;
|
|
5875
|
+
e.checked ? this._selectedRows.add(i) : this._selectedRows.delete(i), this.syncSelectionState(), this.emitSelectEvent();
|
|
5876
|
+
const s = this._selectedRows.size;
|
|
5877
|
+
v(
|
|
5878
|
+
s === 0 ? "Selection cleared" : `${s} row${s === 1 ? "" : "s"} selected`
|
|
5879
|
+
);
|
|
5880
|
+
}
|
|
5881
|
+
}
|
|
5882
|
+
};
|
|
5883
|
+
}
|
|
5884
|
+
static get observedAttributes() {
|
|
5885
|
+
return ["caption", "sort-key", "sort-direction", "selectable", "loading", "empty-message"];
|
|
5886
|
+
}
|
|
5887
|
+
// ── Attribute-backed getters ──────────────────────────────────────────────
|
|
5888
|
+
get caption() {
|
|
5889
|
+
return this.getAttribute("caption") || "";
|
|
5890
|
+
}
|
|
5891
|
+
set caption(t) {
|
|
5892
|
+
this.setAttribute("caption", t);
|
|
5893
|
+
}
|
|
5894
|
+
get selectable() {
|
|
5895
|
+
return this.hasAttribute("selectable");
|
|
5896
|
+
}
|
|
5897
|
+
get loading() {
|
|
5898
|
+
return this.hasAttribute("loading");
|
|
5899
|
+
}
|
|
5900
|
+
get emptyMessage() {
|
|
5901
|
+
return this.getAttribute("empty-message") || "No results found";
|
|
5902
|
+
}
|
|
5903
|
+
// ── Property-backed sort state ────────────────────────────────────────────
|
|
5904
|
+
get sortKey() {
|
|
5905
|
+
return this._sortKey;
|
|
5906
|
+
}
|
|
5907
|
+
set sortKey(t) {
|
|
5908
|
+
this._sortKey = t, this.rerenderTable();
|
|
5909
|
+
}
|
|
5910
|
+
get sortDirection() {
|
|
5911
|
+
return this._sortDirection;
|
|
5912
|
+
}
|
|
5913
|
+
set sortDirection(t) {
|
|
5914
|
+
this._sortDirection = t, this.rerenderTable();
|
|
5915
|
+
}
|
|
5916
|
+
// ── Data properties ───────────────────────────────────────────────────────
|
|
5917
|
+
get columns() {
|
|
5918
|
+
return this._columns;
|
|
5919
|
+
}
|
|
5920
|
+
set columns(t) {
|
|
5921
|
+
this._columns = t, this.rerenderTable();
|
|
5922
|
+
}
|
|
5923
|
+
get rows() {
|
|
5924
|
+
return this._rows;
|
|
5925
|
+
}
|
|
5926
|
+
set rows(t) {
|
|
5927
|
+
this._rows = t, this.rerenderTable();
|
|
5928
|
+
}
|
|
5929
|
+
get selectedRows() {
|
|
5930
|
+
return Array.from(this._selectedRows);
|
|
5931
|
+
}
|
|
5932
|
+
set selectedRows(t) {
|
|
5933
|
+
this._selectedRows = new Set(t), this.syncSelectionState();
|
|
5934
|
+
}
|
|
5935
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
5936
|
+
/**
|
|
5937
|
+
* Re-apply JS properties that were set before the element was upgraded.
|
|
5938
|
+
*
|
|
5939
|
+
* When a custom element is used before its class is registered (e.g. inline
|
|
5940
|
+
* script sets `el.columns = [...]` before the module loads), the value lands
|
|
5941
|
+
* as a plain "own" property on the HTMLElement, shadowing the class
|
|
5942
|
+
* getter/setter. This method detects that, removes the own property, and
|
|
5943
|
+
* re-routes the value through the real setter so private fields are updated.
|
|
5944
|
+
*/
|
|
5945
|
+
upgradeProperty(t) {
|
|
5946
|
+
if (Object.prototype.hasOwnProperty.call(this, t)) {
|
|
5947
|
+
const e = this[t];
|
|
5948
|
+
delete this[t], this[t] = e;
|
|
5949
|
+
}
|
|
5950
|
+
}
|
|
5951
|
+
setupAccessibility() {
|
|
5952
|
+
_e(), this.upgradeProperty("columns"), this.upgradeProperty("rows"), this.upgradeProperty("selectedRows"), this.upgradeProperty("sortKey"), this.upgradeProperty("sortDirection");
|
|
5953
|
+
const t = this.getAttribute("sort-key");
|
|
5954
|
+
t && (this._sortKey = t);
|
|
5955
|
+
const e = this.getAttribute("sort-direction");
|
|
5956
|
+
e && (this._sortDirection = e), !this.caption && !this.getAttribute("aria-label") && !this.getAttribute("aria-labelledby") && j.warning(
|
|
5957
|
+
"a11y-table must have an accessible name. Provide a caption attribute, aria-label, or aria-labelledby."
|
|
5958
|
+
);
|
|
5959
|
+
}
|
|
5960
|
+
render() {
|
|
5961
|
+
this.shadowRoot || this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
|
|
5962
|
+
<style>
|
|
5963
|
+
${g}
|
|
5964
|
+
:host { display: block; overflow-x: auto; }
|
|
5965
|
+
</style>
|
|
5966
|
+
<slot></slot>
|
|
5967
|
+
`, this._tableEl || (this._tableEl = document.createElement("table"), this.appendChild(this._tableEl)), this.renderTable();
|
|
5968
|
+
}
|
|
5969
|
+
setupEventListeners() {
|
|
5970
|
+
this.addEventListener("click", this.handleClick), this.addEventListener("change", this.handleChange);
|
|
5971
|
+
}
|
|
5972
|
+
cleanupEventListeners() {
|
|
5973
|
+
this.removeEventListener("click", this.handleClick), this.removeEventListener("change", this.handleChange);
|
|
5974
|
+
}
|
|
5975
|
+
onAttributeChange(t, e, i) {
|
|
5976
|
+
switch (t) {
|
|
5977
|
+
case "caption":
|
|
5978
|
+
case "empty-message":
|
|
5979
|
+
this.rerenderTable();
|
|
5980
|
+
break;
|
|
5981
|
+
case "sort-key":
|
|
5982
|
+
this._sortKey = i, this.rerenderTable();
|
|
5983
|
+
break;
|
|
5984
|
+
case "sort-direction":
|
|
5985
|
+
this._sortDirection = i || "none", this.rerenderTable();
|
|
5986
|
+
break;
|
|
5987
|
+
case "selectable":
|
|
5988
|
+
case "loading":
|
|
5989
|
+
this.rerenderTable();
|
|
5990
|
+
break;
|
|
5991
|
+
}
|
|
5992
|
+
}
|
|
5993
|
+
// ── Public API ────────────────────────────────────────────────────────────
|
|
5994
|
+
/** Sort the table by a column key, cycling direction automatically */
|
|
5995
|
+
sort(t, e) {
|
|
5996
|
+
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();
|
|
5997
|
+
}
|
|
5998
|
+
selectRow(t) {
|
|
5999
|
+
this._selectedRows.add(t), this.syncSelectionState(), this.emitSelectEvent();
|
|
6000
|
+
}
|
|
6001
|
+
deselectRow(t) {
|
|
6002
|
+
this._selectedRows.delete(t), this.syncSelectionState(), this.emitSelectEvent();
|
|
6003
|
+
}
|
|
6004
|
+
selectAll() {
|
|
6005
|
+
for (const t of this._rows) {
|
|
6006
|
+
const e = String(t.id ?? "");
|
|
6007
|
+
e && this._selectedRows.add(e);
|
|
6008
|
+
}
|
|
6009
|
+
this.syncSelectionState(), this.emitSelectEvent();
|
|
6010
|
+
}
|
|
6011
|
+
deselectAll() {
|
|
6012
|
+
this._selectedRows.clear(), this.syncSelectionState(), this.emitSelectEvent();
|
|
6013
|
+
}
|
|
6014
|
+
// ── Rendering ─────────────────────────────────────────────────────────────
|
|
6015
|
+
/**
|
|
6016
|
+
* Preserve focus on a sort button across full re-renders.
|
|
6017
|
+
* We save the sort-key of the focused sort button, re-render, then
|
|
6018
|
+
* move focus back to the newly rendered sort button.
|
|
6019
|
+
*/
|
|
6020
|
+
rerenderTable() {
|
|
6021
|
+
if (!this._tableEl) return;
|
|
6022
|
+
const t = document.activeElement, e = (t == null ? void 0 : t.dataset.sortKey) ?? null, i = this._tableEl.contains(t);
|
|
6023
|
+
this.renderTable(), i && e && requestAnimationFrame(() => {
|
|
6024
|
+
var a;
|
|
6025
|
+
const s = (a = this._tableEl) == null ? void 0 : a.querySelector(
|
|
6026
|
+
`[data-sort-key="${e}"]`
|
|
6027
|
+
);
|
|
6028
|
+
s == null || s.focus();
|
|
6029
|
+
});
|
|
6030
|
+
}
|
|
6031
|
+
renderTable() {
|
|
6032
|
+
if (!this._tableEl) return;
|
|
6033
|
+
const t = this._tableEl;
|
|
6034
|
+
this.loading ? this.setAttribute("aria-busy", "true") : this.removeAttribute("aria-busy");
|
|
6035
|
+
let e = t.querySelector("caption");
|
|
6036
|
+
this.caption ? (e || (e = document.createElement("caption"), t.prepend(e)), e.textContent = this.caption) : e && e.remove();
|
|
6037
|
+
let i = t.querySelector("thead");
|
|
6038
|
+
i || (i = document.createElement("thead"), t.appendChild(i)), this.renderThead(i);
|
|
6039
|
+
let s = t.querySelector("tbody");
|
|
6040
|
+
s || (s = document.createElement("tbody"), t.appendChild(s)), this.renderTbody(s);
|
|
6041
|
+
}
|
|
6042
|
+
renderThead(t) {
|
|
6043
|
+
t.innerHTML = "";
|
|
6044
|
+
const e = document.createElement("tr");
|
|
6045
|
+
if (this.selectable) {
|
|
6046
|
+
const i = document.createElement("th");
|
|
6047
|
+
i.scope = "col", i.style.width = "2.5rem";
|
|
6048
|
+
const s = this._rows.map((d) => String(d.id ?? "")).filter(Boolean), a = s.filter(
|
|
6049
|
+
(d) => this._selectedRows.has(d)
|
|
6050
|
+
).length, r = s.length > 0 && a === s.length, o = a > 0 && a < s.length, n = document.createElement("input");
|
|
6051
|
+
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);
|
|
6052
|
+
}
|
|
6053
|
+
for (const i of this._columns) {
|
|
6054
|
+
const s = document.createElement("th");
|
|
6055
|
+
if (s.scope = "col", i.align && (s.style.textAlign = i.align), i.sortable) {
|
|
6056
|
+
const a = this._sortKey === i.key, r = a ? this._sortDirection : "none";
|
|
6057
|
+
s.setAttribute("aria-sort", r);
|
|
6058
|
+
const o = document.createElement("button");
|
|
6059
|
+
o.type = "button", o.setAttribute("data-sort-btn", ""), o.setAttribute("data-sort-key", i.key);
|
|
6060
|
+
const n = document.createElement("span");
|
|
6061
|
+
n.textContent = i.label;
|
|
6062
|
+
const d = document.createElement("span");
|
|
6063
|
+
d.setAttribute("aria-hidden", "true"), d.setAttribute("data-sort-icon", ""), d.textContent = a && r === "ascending" ? "↑" : a && r === "descending" ? "↓" : "↕", o.appendChild(n), o.appendChild(d), s.appendChild(o);
|
|
6064
|
+
} else
|
|
6065
|
+
s.textContent = i.label;
|
|
6066
|
+
e.appendChild(s);
|
|
6067
|
+
}
|
|
6068
|
+
t.appendChild(e);
|
|
6069
|
+
}
|
|
6070
|
+
renderTbody(t) {
|
|
6071
|
+
if (t.innerHTML = "", this.loading) {
|
|
6072
|
+
const e = document.createElement("tr");
|
|
6073
|
+
e.setAttribute("aria-busy", "true");
|
|
6074
|
+
const i = document.createElement("td");
|
|
6075
|
+
i.setAttribute("data-loading-cell", ""), i.colSpan = this._columns.length + (this.selectable ? 1 : 0), i.textContent = "Loading…", e.appendChild(i), t.appendChild(e);
|
|
6076
|
+
return;
|
|
6077
|
+
}
|
|
6078
|
+
if (this._rows.length === 0) {
|
|
6079
|
+
const e = document.createElement("tr"), i = document.createElement("td");
|
|
6080
|
+
i.setAttribute("data-empty-cell", ""), i.colSpan = this._columns.length + (this.selectable ? 1 : 0), i.textContent = this.emptyMessage, e.appendChild(i), t.appendChild(e);
|
|
6081
|
+
return;
|
|
6082
|
+
}
|
|
6083
|
+
this.selectable && this._rows.some((i) => !i.id) && j.warning(
|
|
6084
|
+
'a11y-table: When selectable is enabled, each row object must have an "id" field.'
|
|
6085
|
+
);
|
|
6086
|
+
for (const e of this._rows) {
|
|
6087
|
+
const i = String(e.id ?? ""), s = i ? this._selectedRows.has(i) : !1, a = document.createElement("tr");
|
|
6088
|
+
if (i && this.selectable && a.setAttribute("aria-selected", String(s)), this.selectable) {
|
|
6089
|
+
const r = document.createElement("td");
|
|
6090
|
+
r.style.width = "2.5rem";
|
|
6091
|
+
const o = document.createElement("input");
|
|
6092
|
+
o.type = "checkbox", o.dataset.rowId = i, o.dataset.selectRow = "", o.setAttribute("data-select-cb", ""), o.checked = s;
|
|
6093
|
+
const n = this._columns[0], d = n ? String(e[n.key] ?? i) : i;
|
|
6094
|
+
o.setAttribute("aria-label", `Select ${d}`), r.appendChild(o), a.appendChild(r);
|
|
6095
|
+
}
|
|
6096
|
+
for (const r of this._columns) {
|
|
6097
|
+
const o = e[r.key], n = o == null ? "" : String(o);
|
|
6098
|
+
if (r.rowHeader) {
|
|
6099
|
+
const d = document.createElement("th");
|
|
6100
|
+
d.scope = "row", r.align && (d.style.textAlign = r.align), d.textContent = n, a.appendChild(d);
|
|
6101
|
+
} else {
|
|
6102
|
+
const d = document.createElement("td");
|
|
6103
|
+
r.align && (d.style.textAlign = r.align), d.textContent = n, a.appendChild(d);
|
|
6104
|
+
}
|
|
6105
|
+
}
|
|
6106
|
+
t.appendChild(a);
|
|
6107
|
+
}
|
|
6108
|
+
}
|
|
6109
|
+
/** Re-sync selection state without full re-render (preserves focus) */
|
|
6110
|
+
syncSelectionState() {
|
|
6111
|
+
if (!this._tableEl) return;
|
|
6112
|
+
const t = this._tableEl.querySelectorAll("tbody tr");
|
|
6113
|
+
for (const i of Array.from(t)) {
|
|
6114
|
+
const s = i.querySelector("[data-select-row]");
|
|
6115
|
+
if (!s) continue;
|
|
6116
|
+
const a = s.dataset.rowId ?? "", r = this._selectedRows.has(a);
|
|
6117
|
+
i.setAttribute("aria-selected", String(r)), s.checked = r;
|
|
6118
|
+
}
|
|
6119
|
+
const e = this._tableEl.querySelector("[data-select-all]");
|
|
6120
|
+
if (e) {
|
|
6121
|
+
const i = this._rows.map((a) => String(a.id ?? "")).filter(Boolean), s = i.filter(
|
|
6122
|
+
(a) => this._selectedRows.has(a)
|
|
6123
|
+
).length;
|
|
6124
|
+
e.checked = i.length > 0 && s === i.length, e.indeterminate = s > 0 && s < i.length;
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6127
|
+
emitSelectEvent() {
|
|
6128
|
+
this.emit("a11y-table-select", {
|
|
6129
|
+
selectedRows: Array.from(this._selectedRows)
|
|
6130
|
+
});
|
|
6131
|
+
}
|
|
6132
|
+
}
|
|
6133
|
+
b("a11y-table", At);
|
|
4817
6134
|
if (typeof window < "u") {
|
|
4818
|
-
const
|
|
4819
|
-
|
|
6135
|
+
const l = () => {
|
|
6136
|
+
M(), B();
|
|
4820
6137
|
};
|
|
4821
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
6138
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", l) : l(), window.compa11y = {
|
|
4822
6139
|
// Components (classes)
|
|
4823
|
-
A11yDialog:
|
|
4824
|
-
A11yMenu:
|
|
4825
|
-
A11yTabs:
|
|
4826
|
-
A11yCombobox:
|
|
4827
|
-
A11ySwitch:
|
|
4828
|
-
A11ySelect:
|
|
4829
|
-
A11yInput:
|
|
4830
|
-
A11yTextarea:
|
|
4831
|
-
A11yButton:
|
|
4832
|
-
A11yListbox:
|
|
4833
|
-
A11yOption:
|
|
4834
|
-
A11yOptgroup:
|
|
4835
|
-
A11yCheckbox:
|
|
4836
|
-
A11yCheckboxGroup:
|
|
4837
|
-
A11yRadioGroup:
|
|
4838
|
-
A11yRadio:
|
|
4839
|
-
A11yToast:
|
|
4840
|
-
A11yVisuallyHidden:
|
|
4841
|
-
A11ySkipLink:
|
|
4842
|
-
A11yAlert:
|
|
6140
|
+
A11yDialog: X,
|
|
6141
|
+
A11yMenu: W,
|
|
6142
|
+
A11yTabs: J,
|
|
6143
|
+
A11yCombobox: Q,
|
|
6144
|
+
A11ySwitch: Z,
|
|
6145
|
+
A11ySelect: tt,
|
|
6146
|
+
A11yInput: et,
|
|
6147
|
+
A11yTextarea: it,
|
|
6148
|
+
A11yButton: st,
|
|
6149
|
+
A11yListbox: ot,
|
|
6150
|
+
A11yOption: rt,
|
|
6151
|
+
A11yOptgroup: at,
|
|
6152
|
+
A11yCheckbox: H,
|
|
6153
|
+
A11yCheckboxGroup: nt,
|
|
6154
|
+
A11yRadioGroup: lt,
|
|
6155
|
+
A11yRadio: dt,
|
|
6156
|
+
A11yToast: ht,
|
|
6157
|
+
A11yVisuallyHidden: ct,
|
|
6158
|
+
A11ySkipLink: ut,
|
|
6159
|
+
A11yAlert: bt,
|
|
6160
|
+
A11yLink: pt,
|
|
6161
|
+
A11yHeading: ft,
|
|
6162
|
+
A11yText: vt,
|
|
6163
|
+
A11yFormField: yt,
|
|
6164
|
+
A11yPopover: _t,
|
|
6165
|
+
A11yAccordion: xt,
|
|
6166
|
+
A11yTable: At,
|
|
4843
6167
|
// Announcer utilities
|
|
4844
|
-
initAnnouncer:
|
|
6168
|
+
initAnnouncer: M,
|
|
4845
6169
|
announce: v,
|
|
4846
|
-
announcePolite:
|
|
4847
|
-
announceAssertive:
|
|
4848
|
-
announceStatus:
|
|
4849
|
-
announceError:
|
|
6170
|
+
announcePolite: f,
|
|
6171
|
+
announceAssertive: R,
|
|
6172
|
+
announceStatus: Bt,
|
|
6173
|
+
announceError: Ht,
|
|
4850
6174
|
// Focus utilities
|
|
4851
|
-
initFocusVisible:
|
|
4852
|
-
createFocusTrap:
|
|
4853
|
-
createFocusScope:
|
|
4854
|
-
createRovingTabindex:
|
|
6175
|
+
initFocusVisible: B,
|
|
6176
|
+
createFocusTrap: Rt,
|
|
6177
|
+
createFocusScope: Ot,
|
|
6178
|
+
createRovingTabindex: qt,
|
|
4855
6179
|
// Keyboard utilities
|
|
4856
|
-
createKeyboardManager:
|
|
4857
|
-
KeyboardPatterns:
|
|
4858
|
-
createTypeAhead:
|
|
6180
|
+
createKeyboardManager: Dt,
|
|
6181
|
+
KeyboardPatterns: zt,
|
|
6182
|
+
createTypeAhead: O,
|
|
4859
6183
|
// ARIA utilities
|
|
4860
|
-
aria:
|
|
4861
|
-
buildAriaProps:
|
|
4862
|
-
hasAccessibleName:
|
|
6184
|
+
aria: Tt,
|
|
6185
|
+
buildAriaProps: Ct,
|
|
6186
|
+
hasAccessibleName: It,
|
|
4863
6187
|
// Platform detection
|
|
4864
|
-
isBrowser:
|
|
4865
|
-
prefersReducedMotion:
|
|
4866
|
-
prefersHighContrast:
|
|
4867
|
-
prefersDarkMode:
|
|
6188
|
+
isBrowser: $t,
|
|
6189
|
+
prefersReducedMotion: Lt,
|
|
6190
|
+
prefersHighContrast: St,
|
|
6191
|
+
prefersDarkMode: wt
|
|
4868
6192
|
};
|
|
4869
6193
|
}
|
|
4870
6194
|
export {
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
6195
|
+
xt as A11yAccordion,
|
|
6196
|
+
bt as A11yAlert,
|
|
6197
|
+
st as A11yButton,
|
|
6198
|
+
H as A11yCheckbox,
|
|
6199
|
+
nt as A11yCheckboxGroup,
|
|
6200
|
+
Q as A11yCombobox,
|
|
6201
|
+
X as A11yDialog,
|
|
6202
|
+
yt as A11yFormField,
|
|
6203
|
+
ft as A11yHeading,
|
|
6204
|
+
et as A11yInput,
|
|
6205
|
+
pt as A11yLink,
|
|
6206
|
+
ot as A11yListbox,
|
|
6207
|
+
W as A11yMenu,
|
|
6208
|
+
at as A11yOptgroup,
|
|
6209
|
+
rt as A11yOption,
|
|
6210
|
+
_t as A11yPopover,
|
|
6211
|
+
dt as A11yRadio,
|
|
6212
|
+
lt as A11yRadioGroup,
|
|
6213
|
+
tt as A11ySelect,
|
|
6214
|
+
ut as A11ySkipLink,
|
|
6215
|
+
Z as A11ySwitch,
|
|
6216
|
+
At as A11yTable,
|
|
6217
|
+
J as A11yTabs,
|
|
6218
|
+
vt as A11yText,
|
|
6219
|
+
it as A11yTextarea,
|
|
6220
|
+
ht as A11yToast,
|
|
6221
|
+
ct as A11yVisuallyHidden,
|
|
6222
|
+
ke as KeyboardPatterns,
|
|
6223
|
+
we as announce,
|
|
6224
|
+
Se as announceAssertive,
|
|
6225
|
+
Le as announceError,
|
|
6226
|
+
$e as announcePolite,
|
|
6227
|
+
Ie as announceStatus,
|
|
6228
|
+
Ce as aria,
|
|
6229
|
+
Te as buildAriaProps,
|
|
6230
|
+
ze as createFocusScope,
|
|
6231
|
+
De as createFocusTrap,
|
|
6232
|
+
qe as createKeyboardManager,
|
|
6233
|
+
Oe as createRovingTabindex,
|
|
6234
|
+
Re as createTypeAhead,
|
|
6235
|
+
He as hasAccessibleName,
|
|
6236
|
+
Be as initAnnouncer,
|
|
6237
|
+
Me as initFocusVisible,
|
|
6238
|
+
Ke as isBrowser,
|
|
6239
|
+
Fe as prefersDarkMode,
|
|
6240
|
+
Pe as prefersHighContrast,
|
|
6241
|
+
Ne as prefersReducedMotion
|
|
4911
6242
|
};
|