a11y-elements 0.7.0 → 1.0.1
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/README.md +112 -72
- package/dist/a11y.css +28 -1
- package/dist/browser/all.js +43 -43
- package/dist/browser/{chunk-XWWLU5PH.js → chunk-23IEROGQ.js} +6 -5
- package/dist/browser/chunk-23IEROGQ.js.map +1 -0
- package/dist/browser/{chunk-PTU2DM52.js → chunk-4V5TTMP4.js} +18 -9
- package/dist/browser/chunk-4V5TTMP4.js.map +1 -0
- package/dist/browser/chunk-6AIK32FI.js +115 -0
- package/dist/browser/chunk-6AIK32FI.js.map +1 -0
- package/dist/browser/{chunk-QT3RDF3H.js → chunk-6AJBXOCZ.js} +6 -5
- package/dist/browser/chunk-6AJBXOCZ.js.map +1 -0
- package/dist/browser/{chunk-K24OBXOZ.js → chunk-6JAOKGVI.js} +11 -8
- package/dist/browser/chunk-6JAOKGVI.js.map +1 -0
- package/dist/browser/{chunk-4JFOUSU7.js → chunk-6NOUML5M.js} +17 -12
- package/dist/browser/chunk-6NOUML5M.js.map +1 -0
- package/dist/browser/{chunk-VZZ6PGGW.js → chunk-7CL7TH7I.js} +3 -3
- package/dist/browser/{chunk-S3G36NHT.js → chunk-7GCUNMAO.js} +30 -6
- package/dist/browser/chunk-7GCUNMAO.js.map +1 -0
- package/dist/browser/{chunk-O6WGSOHI.js → chunk-7YZP3GGZ.js} +4 -4
- package/dist/browser/{chunk-HF2UHDNK.js → chunk-AHF64455.js} +3 -3
- package/dist/browser/{chunk-ANCRYRXA.js → chunk-CJJN2J7X.js} +17 -16
- package/dist/browser/chunk-CJJN2J7X.js.map +1 -0
- package/dist/browser/{chunk-GJIJX2MO.js → chunk-D6ES5GYW.js} +3 -3
- package/dist/browser/{chunk-BLDP54O5.js → chunk-DCFJ364K.js} +3 -3
- package/dist/browser/{chunk-XNWCI66X.js → chunk-ED3UMYMY.js} +55 -6
- package/dist/browser/chunk-ED3UMYMY.js.map +1 -0
- package/dist/browser/{chunk-X3FGPMOG.js → chunk-EMXZKQ32.js} +14 -11
- package/dist/browser/chunk-EMXZKQ32.js.map +1 -0
- package/dist/browser/{chunk-73Y3YTSE.js → chunk-F5VLI6QP.js} +15 -9
- package/dist/browser/chunk-F5VLI6QP.js.map +1 -0
- package/dist/browser/{chunk-R3ESHCSH.js → chunk-FNILKXCO.js} +55 -29
- package/dist/browser/chunk-FNILKXCO.js.map +1 -0
- package/dist/browser/{chunk-6G3UL7FH.js → chunk-GA3VPLST.js} +3 -3
- package/dist/browser/chunk-GJIRWFLA.js +147 -0
- package/dist/browser/chunk-GJIRWFLA.js.map +1 -0
- package/dist/browser/{chunk-5SFYIGMT.js → chunk-GKCQ6PNB.js} +3 -3
- package/dist/browser/{chunk-DFQ4O2RT.js → chunk-HG7FJAXE.js} +15 -8
- package/dist/browser/chunk-HG7FJAXE.js.map +1 -0
- package/dist/browser/{chunk-EOI2JDNP.js → chunk-IHMGZOLZ.js} +12 -9
- package/dist/browser/chunk-IHMGZOLZ.js.map +1 -0
- package/dist/browser/{chunk-NEQKRAIP.js → chunk-ISUDKKRI.js} +4 -3
- package/dist/browser/chunk-ISUDKKRI.js.map +1 -0
- package/dist/browser/{chunk-IP2X2FJW.js → chunk-JFZTJO7H.js} +10 -7
- package/dist/browser/chunk-JFZTJO7H.js.map +1 -0
- package/dist/browser/{chunk-CKFVCVMO.js → chunk-JTFESZPQ.js} +16 -14
- package/dist/browser/chunk-JTFESZPQ.js.map +1 -0
- package/dist/browser/{chunk-PWR4UC47.js → chunk-KVUJT6BC.js} +59 -22
- package/dist/browser/chunk-KVUJT6BC.js.map +1 -0
- package/dist/browser/{chunk-H23YF56K.js → chunk-LIZBBXUV.js} +4 -4
- package/dist/browser/{chunk-K4P65IHJ.js → chunk-LVKKZ4XP.js} +27 -26
- package/dist/browser/chunk-LVKKZ4XP.js.map +1 -0
- package/dist/browser/{chunk-GEGVADVM.js → chunk-MIBUA46B.js} +11 -6
- package/dist/browser/chunk-MIBUA46B.js.map +1 -0
- package/dist/browser/{chunk-2E2MNSPU.js → chunk-MKDICSZ3.js} +6 -6
- package/dist/browser/{chunk-F47DDMFE.js → chunk-MNWKDM3I.js} +22 -2
- package/dist/browser/chunk-MNWKDM3I.js.map +1 -0
- package/dist/browser/{chunk-F4AVN6JZ.js → chunk-NBWKCBIZ.js} +2 -2
- package/dist/browser/{chunk-6AYXOLXI.js → chunk-NJSZSBR5.js} +7 -6
- package/dist/browser/chunk-NJSZSBR5.js.map +1 -0
- package/dist/browser/{chunk-JZJW3GXR.js → chunk-NLRXEMHB.js} +32 -19
- package/dist/browser/chunk-NLRXEMHB.js.map +1 -0
- package/dist/browser/{chunk-IAXHGJ62.js → chunk-NT7DOWM7.js} +3 -3
- package/dist/browser/{chunk-DO53LTZ7.js → chunk-O235WSRL.js} +40 -12
- package/dist/browser/chunk-O235WSRL.js.map +1 -0
- package/dist/browser/{chunk-3IYYFR25.js → chunk-ORDVOV7E.js} +11 -6
- package/dist/browser/chunk-ORDVOV7E.js.map +1 -0
- package/dist/browser/{chunk-GFNWEW7C.js → chunk-P42G35OU.js} +11 -7
- package/dist/browser/chunk-P42G35OU.js.map +1 -0
- package/dist/browser/{chunk-4KU26VOY.js → chunk-Q4TMA3P7.js} +6 -2
- package/dist/browser/chunk-Q4TMA3P7.js.map +1 -0
- package/dist/browser/{chunk-7NNZKO4M.js → chunk-SRWD5UK6.js} +2 -2
- package/dist/browser/{chunk-VAMC6L65.js → chunk-TPVVWXTY.js} +12 -7
- package/dist/browser/chunk-TPVVWXTY.js.map +1 -0
- package/dist/browser/{chunk-P22R5WMV.js → chunk-UFLTXMN2.js} +7 -6
- package/dist/browser/chunk-UFLTXMN2.js.map +1 -0
- package/dist/browser/{chunk-ACNPSWNA.js → chunk-WDPW7UKG.js} +6 -5
- package/dist/browser/chunk-WDPW7UKG.js.map +1 -0
- package/dist/browser/components/anchor/define.js +3 -3
- package/dist/browser/components/avatar/define.js +3 -3
- package/dist/browser/components/card-link/define.js +4 -4
- package/dist/browser/components/checkbox/define.js +3 -3
- package/dist/browser/components/checkbox-group/define.js +3 -3
- package/dist/browser/components/file-input/define.js +5 -5
- package/dist/browser/components/focusable/define.js +2 -2
- package/dist/browser/components/input/define.js +5 -5
- package/dist/browser/components/label/define.js +3 -3
- package/dist/browser/components/picture/define.js +3 -3
- package/dist/browser/components/progress/define.js +4 -4
- package/dist/browser/components/radio-group/define.js +3 -3
- package/dist/browser/components/select/define.js +3 -3
- package/dist/browser/components/skeleton/define.js +3 -3
- package/dist/browser/components/spinner/define.js +3 -3
- package/dist/browser/components/switch/define.js +3 -3
- package/dist/browser/components/tabs/define.js +4 -4
- package/dist/browser/components/textarea/define.js +5 -5
- package/dist/browser/components/visually-hidden/define.js +2 -2
- package/dist/browser/overlays/blocking-loader/define.js +7 -7
- package/dist/browser/overlays/context-menu/define.js +8 -8
- package/dist/browser/overlays/drawer/define.js +8 -8
- package/dist/browser/overlays/dropdown/define.js +9 -9
- package/dist/browser/overlays/emergency-dialog/define.js +8 -8
- package/dist/browser/overlays/floating/define.js +6 -6
- package/dist/browser/overlays/modal/define.js +9 -9
- package/dist/browser/overlays/notification-banner/define.js +5 -5
- package/dist/browser/overlays/popover/define.js +8 -8
- package/dist/browser/overlays/snackbar/define.js +5 -5
- package/dist/browser/overlays/tooltip/define.js +8 -8
- package/dist/components/anchor/anchor.element.d.ts +2 -0
- package/dist/components/anchor/anchor.element.js +12 -6
- package/dist/components/anchor/anchor.element.js.map +1 -1
- package/dist/components/card-link/card-link.element.js +2 -1
- package/dist/components/card-link/card-link.element.js.map +1 -1
- package/dist/components/checkbox/checkbox.element.d.ts +2 -0
- package/dist/components/checkbox/checkbox.element.js +11 -3
- package/dist/components/checkbox/checkbox.element.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.element.js +17 -9
- package/dist/components/checkbox-group/checkbox-group.element.js.map +1 -1
- package/dist/components/file-input/file-input.element.js +13 -12
- package/dist/components/file-input/file-input.element.js.map +1 -1
- package/dist/components/focusable/focusable.element.js +5 -1
- package/dist/components/focusable/focusable.element.js.map +1 -1
- package/dist/components/label/label.element.js +2 -1
- package/dist/components/label/label.element.js.map +1 -1
- package/dist/components/picture/picture.element.js +12 -5
- package/dist/components/picture/picture.element.js.map +1 -1
- package/dist/components/progress/progress.element.d.ts +2 -0
- package/dist/components/progress/progress.element.js +8 -2
- package/dist/components/progress/progress.element.js.map +1 -1
- package/dist/components/radio-group/radio-group.element.js +9 -3
- package/dist/components/radio-group/radio-group.element.js.map +1 -1
- package/dist/components/select/select.element.js +3 -2
- package/dist/components/select/select.element.js.map +1 -1
- package/dist/components/switch/switch.element.js +3 -2
- package/dist/components/switch/switch.element.js.map +1 -1
- package/dist/components/tabs/tabs.element.d.ts +2 -0
- package/dist/components/tabs/tabs.element.js +13 -3
- package/dist/components/tabs/tabs.element.js.map +1 -1
- package/dist/core/a11y-element.d.ts +1 -0
- package/dist/core/a11y-element.js +5 -3
- package/dist/core/a11y-element.js.map +1 -1
- package/dist/core/a11y-field-element.js +3 -1
- package/dist/core/a11y-field-element.js.map +1 -1
- package/dist/core/a11y-overlay-element.js +10 -6
- package/dist/core/a11y-overlay-element.js.map +1 -1
- package/dist/core/builtin.d.ts +9 -0
- package/dist/core/builtin.js +17 -0
- package/dist/core/builtin.js.map +1 -0
- package/dist/core/dom.js +6 -4
- package/dist/core/dom.js.map +1 -1
- package/dist/core/field.js +5 -4
- package/dist/core/field.js.map +1 -1
- package/dist/core/focus-trap.d.ts +13 -1
- package/dist/core/focus-trap.js +71 -33
- package/dist/core/focus-trap.js.map +1 -1
- package/dist/core/ids.js +2 -1
- package/dist/core/ids.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/overlay-registry.d.ts +25 -3
- package/dist/core/overlay-registry.js +105 -22
- package/dist/core/overlay-registry.js.map +1 -1
- package/dist/core/safe-dom.d.ts +20 -0
- package/dist/core/safe-dom.js +55 -0
- package/dist/core/safe-dom.js.map +1 -0
- package/dist/core/sanitize.d.ts +1 -7
- package/dist/core/sanitize.js +81 -16
- package/dist/core/sanitize.js.map +1 -1
- package/dist/core/strings.js +3 -2
- package/dist/core/strings.js.map +1 -1
- package/dist/core/template.d.ts +3 -1
- package/dist/core/template.js +5 -3
- package/dist/core/template.js.map +1 -1
- package/dist/core/transition.d.ts +8 -2
- package/dist/core/transition.js +34 -4
- package/dist/core/transition.js.map +1 -1
- package/dist/overlays/context-menu/context-menu.element.js +2 -1
- package/dist/overlays/context-menu/context-menu.element.js.map +1 -1
- package/dist/overlays/core/a11y-anchored-overlay-element.js +33 -15
- package/dist/overlays/core/a11y-anchored-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-menu-overlay-element.d.ts +9 -0
- package/dist/overlays/core/a11y-menu-overlay-element.js +40 -9
- package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-modal-overlay-element.js +10 -7
- package/dist/overlays/core/a11y-modal-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-passive-overlay-element.d.ts +18 -1
- package/dist/overlays/core/a11y-passive-overlay-element.js +39 -2
- package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
- package/dist/overlays/dropdown/dropdown.element.d.ts +1 -0
- package/dist/overlays/dropdown/dropdown.element.js +9 -2
- package/dist/overlays/dropdown/dropdown.element.js.map +1 -1
- package/dist/overlays/floating/floating.element.js +22 -21
- package/dist/overlays/floating/floating.element.js.map +1 -1
- package/dist/overlays/modal/confirm-dialog.js +7 -3
- package/dist/overlays/modal/confirm-dialog.js.map +1 -1
- package/dist/overlays/notification-banner/define.js +4 -3
- package/dist/overlays/notification-banner/define.js.map +1 -1
- package/dist/overlays/notification-banner/notification-banner.element.d.ts +4 -4
- package/dist/overlays/notification-banner/notification-banner.element.js +14 -8
- package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
- package/dist/overlays/snackbar/define.js +4 -3
- package/dist/overlays/snackbar/define.js.map +1 -1
- package/dist/overlays/snackbar/snackbar.element.d.ts +18 -0
- package/dist/overlays/snackbar/snackbar.element.js +52 -6
- package/dist/overlays/snackbar/snackbar.element.js.map +1 -1
- package/package.json +2 -1
- package/dist/browser/chunk-23I2KVFV.js +0 -85
- package/dist/browser/chunk-23I2KVFV.js.map +0 -1
- package/dist/browser/chunk-3IYYFR25.js.map +0 -1
- package/dist/browser/chunk-4JFOUSU7.js.map +0 -1
- package/dist/browser/chunk-4KU26VOY.js.map +0 -1
- package/dist/browser/chunk-6AYXOLXI.js.map +0 -1
- package/dist/browser/chunk-73Y3YTSE.js.map +0 -1
- package/dist/browser/chunk-ACNPSWNA.js.map +0 -1
- package/dist/browser/chunk-ANCRYRXA.js.map +0 -1
- package/dist/browser/chunk-CKFVCVMO.js.map +0 -1
- package/dist/browser/chunk-DFQ4O2RT.js.map +0 -1
- package/dist/browser/chunk-DO53LTZ7.js.map +0 -1
- package/dist/browser/chunk-EOI2JDNP.js.map +0 -1
- package/dist/browser/chunk-F47DDMFE.js.map +0 -1
- package/dist/browser/chunk-GEGVADVM.js.map +0 -1
- package/dist/browser/chunk-GFNWEW7C.js.map +0 -1
- package/dist/browser/chunk-HMJBQAFR.js +0 -80
- package/dist/browser/chunk-HMJBQAFR.js.map +0 -1
- package/dist/browser/chunk-IP2X2FJW.js.map +0 -1
- package/dist/browser/chunk-JZJW3GXR.js.map +0 -1
- package/dist/browser/chunk-K24OBXOZ.js.map +0 -1
- package/dist/browser/chunk-K4P65IHJ.js.map +0 -1
- package/dist/browser/chunk-NEQKRAIP.js.map +0 -1
- package/dist/browser/chunk-P22R5WMV.js.map +0 -1
- package/dist/browser/chunk-PTU2DM52.js.map +0 -1
- package/dist/browser/chunk-PWR4UC47.js.map +0 -1
- package/dist/browser/chunk-QT3RDF3H.js.map +0 -1
- package/dist/browser/chunk-R3ESHCSH.js.map +0 -1
- package/dist/browser/chunk-S3G36NHT.js.map +0 -1
- package/dist/browser/chunk-VAMC6L65.js.map +0 -1
- package/dist/browser/chunk-X3FGPMOG.js.map +0 -1
- package/dist/browser/chunk-XNWCI66X.js.map +0 -1
- package/dist/browser/chunk-XWWLU5PH.js.map +0 -1
- /package/dist/browser/{chunk-VZZ6PGGW.js.map → chunk-7CL7TH7I.js.map} +0 -0
- /package/dist/browser/{chunk-O6WGSOHI.js.map → chunk-7YZP3GGZ.js.map} +0 -0
- /package/dist/browser/{chunk-HF2UHDNK.js.map → chunk-AHF64455.js.map} +0 -0
- /package/dist/browser/{chunk-GJIJX2MO.js.map → chunk-D6ES5GYW.js.map} +0 -0
- /package/dist/browser/{chunk-BLDP54O5.js.map → chunk-DCFJ364K.js.map} +0 -0
- /package/dist/browser/{chunk-6G3UL7FH.js.map → chunk-GA3VPLST.js.map} +0 -0
- /package/dist/browser/{chunk-5SFYIGMT.js.map → chunk-GKCQ6PNB.js.map} +0 -0
- /package/dist/browser/{chunk-H23YF56K.js.map → chunk-LIZBBXUV.js.map} +0 -0
- /package/dist/browser/{chunk-2E2MNSPU.js.map → chunk-MKDICSZ3.js.map} +0 -0
- /package/dist/browser/{chunk-F4AVN6JZ.js.map → chunk-NBWKCBIZ.js.map} +0 -0
- /package/dist/browser/{chunk-IAXHGJ62.js.map → chunk-NT7DOWM7.js.map} +0 -0
- /package/dist/browser/{chunk-7NNZKO4M.js.map → chunk-SRWD5UK6.js.map} +0 -0
package/README.md
CHANGED
|
@@ -2,9 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
Framework-agnostic accessibility Custom Elements (Web Components). A behavior layer, not a themed UI kit.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- See a [demo of the components](https://nutin.dev/a11y-elements/elements)
|
|
6
|
+
- See a [demo of the overlays](https://nutin.dev/a11y-elements/overlays)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## Elements
|
|
9
|
+
|
|
10
|
+
### Accessibility components
|
|
11
|
+
|
|
12
|
+
- [`<a11y-anchor>`](#a11y-anchor)
|
|
13
|
+
- [`<a11y-avatar>`](#a11y-avatar)
|
|
14
|
+
- [`<a11y-card-link>`](#a11y-card-link)
|
|
15
|
+
- [`<a11y-checkbox>`](#a11y-checkbox)
|
|
16
|
+
- [`<a11y-checkbox-group>`](#a11y-checkbox-group)
|
|
17
|
+
- [`<a11y-file-input>`](#a11y-file-input)
|
|
18
|
+
- [`<a11y-focusable>`](#a11y-focusable)
|
|
19
|
+
- [`<a11y-input>`](#a11y-input)
|
|
20
|
+
- [`<a11y-label>`](#a11y-label)
|
|
21
|
+
- [`<a11y-picture>`](#a11y-picture)
|
|
22
|
+
- [`<a11y-progress>`](#a11y-progress)
|
|
23
|
+
- [`<a11y-radio-group>`](#a11y-radio-group)
|
|
24
|
+
- [`<a11y-select>`](#a11y-select)
|
|
25
|
+
- [`<a11y-skeleton>`](#a11y-skeleton)
|
|
26
|
+
- [`<a11y-spinner>`](#a11y-spinner)
|
|
27
|
+
- [`<a11y-switch>`](#a11y-switch)
|
|
28
|
+
- [`<a11y-tabs>`](#a11y-tabs)
|
|
29
|
+
- [`<a11y-textarea>`](#a11y-textarea)
|
|
30
|
+
- [`<a11y-visually-hidden>`](#a11y-visually-hidden)
|
|
31
|
+
|
|
32
|
+
### Overlays
|
|
33
|
+
|
|
34
|
+
Behavior shared by overlays is described once, in [Common to all overlays](#common-to-all-overlays).
|
|
35
|
+
|
|
36
|
+
- [`<a11y-blocking-loader>`](#a11y-blocking-loader)
|
|
37
|
+
- [`<a11y-context-menu>`](#a11y-context-menu)
|
|
38
|
+
- [`<a11y-drawer>`](#a11y-drawer)
|
|
39
|
+
- [`<a11y-dropdown>`](#a11y-dropdown)
|
|
40
|
+
- [`<a11y-emergency-dialog>`](#a11y-emergency-dialog)
|
|
41
|
+
- [`<a11y-floating>`](#a11y-floating)
|
|
42
|
+
- [`<a11y-modal>`](#a11y-modal)
|
|
43
|
+
- [`<a11y-notification-banner>`](#a11y-notification-banner)
|
|
44
|
+
- [`<a11y-popover>`](#a11y-popover)
|
|
45
|
+
- [`<a11y-snackbar>`](#a11y-snackbar)
|
|
46
|
+
- [`<a11y-tooltip>`](#a11y-toolti
|
|
47
|
+
|
|
48
|
+
### Import paths
|
|
49
|
+
|
|
50
|
+
Import paths follow the folder names: `a11y-elements/components/<name>` or `a11y-elements/overlays/<name>` (add `/element` for the class), and `dist/browser/<group>/<name>/define.js` for zero-build.
|
|
51
|
+
|
|
52
|
+
### Values
|
|
53
|
+
|
|
54
|
+
Elements that hold a value (checkbox, switch, select, radio-group, checkbox-group, input, textarea, file-input) share one contract, typed as `ValueElement<V>` in `a11y-elements/core`: `getValue()` reads it, `setValue(value)` writes it silently (no events, no `onChange`), and `onChange(value)` is called when the user changes it. The native controls inside stay the source of truth and the ones that submit.
|
|
55
|
+
|
|
56
|
+
### CSS attributes
|
|
57
|
+
|
|
58
|
+
Attributes that set a CSS variable (spinner `size`/`color`/…, avatar `size`, skeleton `width`/`height`) win over your own inline value for that variable only while they're set. See [Scope to one instance](#scope-to-one-instance).
|
|
8
59
|
|
|
9
60
|
## Usage
|
|
10
61
|
|
|
@@ -70,7 +121,7 @@ setStrings({
|
|
|
70
121
|
| `navigatedTo` | `Navigated to {name}` | `<a11y-anchor>` jump announcement (`{name}` is the target's name) | `navigated-label` |
|
|
71
122
|
| `closeDialog` | `Close dialog` | the × button of `<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`, an expandable `<a11y-floating>`'s panel | `close-label` |
|
|
72
123
|
| `confirm` / `cancel` | `OK` / `Cancel` | the buttons of `confirmDialog()` | `confirmLabel` / `cancelLabel` |
|
|
73
|
-
| `dismiss` | `Dismiss` | the × button of each `<a11y-notification-banner>` item and of a `dismissible` `<a11y-floating>` | `dismiss-label` |
|
|
124
|
+
| `dismiss` | `Dismiss` | the × button of each `<a11y-notification-banner>` item, of each `<a11y-snackbar>` toast, and of a `dismissible` `<a11y-floating>` | `dismiss-label` |
|
|
74
125
|
| `loading` | `Loading` | `<a11y-spinner>`, `<a11y-blocking-loader>` | `label` / `message` |
|
|
75
126
|
| `progress` | `Progress` | `<a11y-progress>` without a label | `label` / `aria-label` |
|
|
76
127
|
| `avatar` | `Avatar` | `<a11y-avatar>` with no `alt` or `initials` | `alt` / `initials` |
|
|
@@ -92,25 +143,9 @@ setStrings({
|
|
|
92
143
|
* Elements already on the page update right away, so calling it again on a language switch is enough.
|
|
93
144
|
* `resetStrings()` restores the English defaults.
|
|
94
145
|
|
|
95
|
-
##
|
|
96
|
-
|
|
97
|
-
Each section shows an example, the element's own attributes/properties/methods, and its CSS variables (collapsed).
|
|
98
|
-
|
|
99
|
-
Behavior shared by overlays is described once, in [Common to all overlays](#common-to-all-overlays).
|
|
146
|
+
## Accessibility components
|
|
100
147
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
**Overlays:** [`<a11y-blocking-loader>`](#a11y-blocking-loader) · [`<a11y-context-menu>`](#a11y-context-menu) · [`<a11y-drawer>`](#a11y-drawer) · [`<a11y-dropdown>`](#a11y-dropdown) · [`<a11y-emergency-dialog>`](#a11y-emergency-dialog) · [`<a11y-floating>`](#a11y-floating) · [`<a11y-modal>`](#a11y-modal) · [`<a11y-notification-banner>`](#a11y-notification-banner) · [`<a11y-popover>`](#a11y-popover) · [`<a11y-snackbar>`](#a11y-snackbar) · [`<a11y-tooltip>`](#a11y-tooltip)
|
|
104
|
-
|
|
105
|
-
Import paths follow the folder names: `a11y-elements/components/<name>` or `a11y-elements/overlays/<name>` (add `/element` for the class), and `dist/browser/<group>/<name>/define.js` for zero-build.
|
|
106
|
-
|
|
107
|
-
Elements that hold a value (checkbox, switch, select, radio-group, checkbox-group, input, textarea, file-input) share one contract, typed as `ValueElement<V>` in `a11y-elements/core`: `getValue()` reads it, `setValue(value)` writes it silently (no events, no `onChange`), and `onChange(value)` is called when the user changes it. The native controls inside stay the source of truth and the ones that submit.
|
|
108
|
-
|
|
109
|
-
Attributes that set a CSS variable (spinner `size`/`color`/…, avatar `size`, skeleton `width`/`height`) win over your own inline value for that variable only while they're set. See [Scope to one instance](#scope-to-one-instance).
|
|
110
|
-
|
|
111
|
-
### Accessibility components
|
|
112
|
-
|
|
113
|
-
#### `a11y-anchor`
|
|
148
|
+
### `a11y-anchor`
|
|
114
149
|
|
|
115
150
|
Enhances a real `<a href>`:
|
|
116
151
|
|
|
@@ -131,7 +166,7 @@ Both strings can be [translated](#translating-built-in-strings).
|
|
|
131
166
|
|
|
132
167
|
No CSS variables of its own: style the `<a>` directly.
|
|
133
168
|
|
|
134
|
-
|
|
169
|
+
### `a11y-avatar`
|
|
135
170
|
|
|
136
171
|
An avatar image with an initials fallback. When the image is missing or fails to load, the initials show instead and the element gets `role="img"` with an `aria-label`.
|
|
137
172
|
|
|
@@ -167,7 +202,7 @@ The initials are set in Arial rather than the page font, so they fit the circle
|
|
|
167
202
|
|
|
168
203
|
</details>
|
|
169
204
|
|
|
170
|
-
|
|
205
|
+
### `a11y-card-link`
|
|
171
206
|
|
|
172
207
|
Makes a whole card go to one page through a real `<a href>` inside it (usually around the title). The link stays the card's only tab stop and its accessible name, so screen readers announce a link named by the title, Enter follows it, Space scrolls the page, and middle-click, "Open in new tab" and "Copy link address" work on it.
|
|
173
208
|
|
|
@@ -205,7 +240,7 @@ The whole card is outlined while its link has keyboard focus (`:has(:focus-visib
|
|
|
205
240
|
|
|
206
241
|
</details>
|
|
207
242
|
|
|
208
|
-
|
|
243
|
+
### `a11y-checkbox`
|
|
209
244
|
|
|
210
245
|
Wraps a real `<input type="checkbox">` in a `<label>` with a visible label text. The input stays yours: `name`, `checked`, `disabled`, `required` are plain HTML attributes on it.
|
|
211
246
|
|
|
@@ -255,7 +290,7 @@ checkbox.onChange = (checked) => console.log('accepted:', checked);
|
|
|
255
290
|
|
|
256
291
|
</details>
|
|
257
292
|
|
|
258
|
-
|
|
293
|
+
### `a11y-checkbox-group`
|
|
259
294
|
|
|
260
295
|
Wraps your checkboxes in a `<fieldset>` with a `<legend>`, styled like `<a11y-checkbox>`. Add `select-all` for a "Select all" checkbox: it's checked when every option is, partly checked when some are, and checks or unchecks them all. It has no `name`, so it's never submitted, and disabled options keep their own state.
|
|
261
296
|
|
|
@@ -304,7 +339,7 @@ Options use the `--a11y-checkbox-*` variables above.
|
|
|
304
339
|
|
|
305
340
|
</details>
|
|
306
341
|
|
|
307
|
-
|
|
342
|
+
### `a11y-file-input`
|
|
308
343
|
|
|
309
344
|
A file picker built from a real `<input type="file">`, with the same parts as [`a11y-input`](#a11y-input). Files can be browsed for or dropped onto the element. It only picks files: the input keeps its `name` and submits them with the form, or you read `getValue()` and upload them yourself.
|
|
310
345
|
|
|
@@ -390,9 +425,9 @@ The hint and error use the [shared field variables](#a11y-input).
|
|
|
390
425
|
|
|
391
426
|
</details>
|
|
392
427
|
|
|
393
|
-
|
|
428
|
+
### `a11y-focusable`
|
|
394
429
|
|
|
395
|
-
Makes a non-button element behave like a button: `role="button"`, `tabindex="0"
|
|
430
|
+
Makes a non-button element behave like a button: `role="button"`, `tabindex="0"` (unless you set your own), and Enter/Space on the element itself fire a real `click`, so one `click` listener covers mouse and keyboard. Keys pressed in a control nested inside are left to that control, and nothing fires while `aria-disabled="true"`. Prefer a real `<button>` whenever you can.
|
|
396
431
|
|
|
397
432
|
It's for **actions**. Cards that go to another page should use [`<a11y-card-link>`](#a11y-card-link) or a plain `<a href>`: a button role, Space activation and no `href` mislead screen-reader users and break "Open in new tab".
|
|
398
433
|
|
|
@@ -408,7 +443,7 @@ It's for **actions**. Cards that go to another page should use [`<a11y-card-link
|
|
|
408
443
|
|
|
409
444
|
No CSS variables.
|
|
410
445
|
|
|
411
|
-
|
|
446
|
+
### `a11y-input`
|
|
412
447
|
|
|
413
448
|
A text field built from a real `<input>` and optional parts, wired together for you:
|
|
414
449
|
|
|
@@ -541,7 +576,7 @@ Shared by the parts of every field:
|
|
|
541
576
|
|
|
542
577
|
</details>
|
|
543
578
|
|
|
544
|
-
|
|
579
|
+
#### Building your own field: `bindField()`
|
|
545
580
|
|
|
546
581
|
The same wiring, without the custom elements: `bindField()` takes the control and its parts as any elements you like, for example from a framework component. It's exported from `a11y-elements/core`, and from the input and textarea `define.js` bundles.
|
|
547
582
|
|
|
@@ -565,7 +600,7 @@ field.destroy(); // on unmount: removes its listeners and the ARIA it added
|
|
|
565
600
|
|
|
566
601
|
A real `<label>` is linked with `for`; any other element with `aria-labelledby`. Tokens you put in `aria-describedby` / `aria-labelledby` yourself are kept.
|
|
567
602
|
|
|
568
|
-
|
|
603
|
+
### `a11y-label`
|
|
569
604
|
|
|
570
605
|
Renders a real `<label class="a11y-label">` around its content. A custom element can't itself be a `<label>`, and only a real one gives click-to-focus and native naming. Inside `<a11y-input>` / `<a11y-textarea>` it's linked automatically; on its own, `for` is forwarded:
|
|
571
606
|
|
|
@@ -597,7 +632,7 @@ A `*` marks a required field. It's CSS only and hidden from screen readers, whic
|
|
|
597
632
|
|
|
598
633
|
</details>
|
|
599
634
|
|
|
600
|
-
|
|
635
|
+
### `a11y-picture`
|
|
601
636
|
|
|
602
637
|
Wraps a `<picture>`/`<img>` and optional `<figcaption>`, yours or generated from attributes, as `role="figure"`. An image with `alt=""` and no caption is treated as decorative and hidden from assistive tech (`aria-hidden="true"`).
|
|
603
638
|
|
|
@@ -666,7 +701,7 @@ The `PictureSource` and `PictureImage` types are exported with the element.
|
|
|
666
701
|
|
|
667
702
|
</details>
|
|
668
703
|
|
|
669
|
-
|
|
704
|
+
### `a11y-progress`
|
|
670
705
|
|
|
671
706
|
A labelled progress bar around a native `<progress>`. Without `value`, it shows an indeterminate animation.
|
|
672
707
|
|
|
@@ -676,8 +711,8 @@ A labelled progress bar around a native `<progress>`. Without `value`, it shows
|
|
|
676
711
|
|
|
677
712
|
| Name | Kind | Default | Description |
|
|
678
713
|
| --- | --- | --- | --- |
|
|
679
|
-
| `value` | attribute / property | — | Current value; absent means indeterminate. |
|
|
680
|
-
| `max` | attribute / property | `100` | Maximum value. |
|
|
714
|
+
| `value` | attribute / property | — | Current value; absent, empty or not a number means indeterminate. |
|
|
715
|
+
| `max` | attribute / property | `100` | Maximum value; `100` unless it's a positive number. |
|
|
681
716
|
| `label` | attribute | — | Visible label, used as the accessible name. |
|
|
682
717
|
| `aria-label` | attribute | `Progress` | Accessible name when there's no visible `label`. The default can be [translated](#translating-built-in-strings). |
|
|
683
718
|
|
|
@@ -699,7 +734,7 @@ A labelled progress bar around a native `<progress>`. Without `value`, it shows
|
|
|
699
734
|
|
|
700
735
|
</details>
|
|
701
736
|
|
|
702
|
-
|
|
737
|
+
### `a11y-radio-group`
|
|
703
738
|
|
|
704
739
|
Wraps your radios in a `<fieldset>` with a `<legend>`. Give every radio the same `name`; that's what makes them one native group.
|
|
705
740
|
|
|
@@ -747,7 +782,7 @@ Wraps your radios in a `<fieldset>` with a `<legend>`. Give every radio the same
|
|
|
747
782
|
|
|
748
783
|
</details>
|
|
749
784
|
|
|
750
|
-
|
|
785
|
+
### `a11y-select`
|
|
751
786
|
|
|
752
787
|
Wraps a real `<select>` in a `<label>` with a visible label text. Options and keyboard handling stay native.
|
|
753
788
|
|
|
@@ -797,7 +832,7 @@ The native `<select>` inside stays the source of truth: its `change` events and
|
|
|
797
832
|
|
|
798
833
|
</details>
|
|
799
834
|
|
|
800
|
-
|
|
835
|
+
### `a11y-skeleton`
|
|
801
836
|
|
|
802
837
|
A loading placeholder, hidden from assistive tech.
|
|
803
838
|
|
|
@@ -835,7 +870,7 @@ A loading placeholder, hidden from assistive tech.
|
|
|
835
870
|
|
|
836
871
|
</details>
|
|
837
872
|
|
|
838
|
-
|
|
873
|
+
### `a11y-spinner`
|
|
839
874
|
|
|
840
875
|
A loading spinner with `role="status"`. No JS needed beyond the define.
|
|
841
876
|
|
|
@@ -873,7 +908,7 @@ Size presets: add `a11y-spinner--sm`, `a11y-spinner--lg` or `a11y-spinner--xl` t
|
|
|
873
908
|
|
|
874
909
|
</details>
|
|
875
910
|
|
|
876
|
-
|
|
911
|
+
### `a11y-switch`
|
|
877
912
|
|
|
878
913
|
Like `<a11y-checkbox>`, but the input gets `role="switch"`.
|
|
879
914
|
|
|
@@ -918,7 +953,7 @@ Like `<a11y-checkbox>`, but the input gets `role="switch"`.
|
|
|
918
953
|
|
|
919
954
|
</details>
|
|
920
955
|
|
|
921
|
-
|
|
956
|
+
### `a11y-tabs`
|
|
922
957
|
|
|
923
958
|
Turns your own tab buttons and panels into the WAI-ARIA Tabs pattern (automatic activation). Tabs are the `[data-tab]` elements inside the `[data-tablist]` child, each one showing the `[data-panel]` with the same name.
|
|
924
959
|
|
|
@@ -973,7 +1008,7 @@ Turns your own tab buttons and panels into the WAI-ARIA Tabs pattern (automatic
|
|
|
973
1008
|
|
|
974
1009
|
</details>
|
|
975
1010
|
|
|
976
|
-
|
|
1011
|
+
### `a11y-textarea`
|
|
977
1012
|
|
|
978
1013
|
`<a11y-input>` for a real `<textarea>`: same parts, attributes, properties, validation and states.
|
|
979
1014
|
|
|
@@ -1002,7 +1037,7 @@ The same as [`a11y-input`](#a11y-input), prefixed `--a11y-textarea-` instead of
|
|
|
1002
1037
|
|
|
1003
1038
|
</details>
|
|
1004
1039
|
|
|
1005
|
-
|
|
1040
|
+
### `a11y-visually-hidden`
|
|
1006
1041
|
|
|
1007
1042
|
Content for screen readers only, hidden visually.
|
|
1008
1043
|
|
|
@@ -1015,9 +1050,9 @@ Content for screen readers only, hidden visually.
|
|
|
1015
1050
|
|
|
1016
1051
|
No attributes or CSS variables. The class `a11y-visually-hidden` is also usable on its own.
|
|
1017
1052
|
|
|
1018
|
-
|
|
1053
|
+
## Overlays
|
|
1019
1054
|
|
|
1020
|
-
|
|
1055
|
+
### Common to all overlays
|
|
1021
1056
|
|
|
1022
1057
|
* **Open/close** with the `open` attribute or property, or `show()` / `close()`.
|
|
1023
1058
|
* **Before the element is defined** (lazy-loaded bundles), setting `.open = true`, `onClose` or any other property works: it's applied once the element upgrades. `setAttribute('open', '')` works too.
|
|
@@ -1040,11 +1075,11 @@ No attributes or CSS variables. The class `a11y-visually-hidden` is also usable
|
|
|
1040
1075
|
* **Except `<a11y-floating>`**, which is visible by default and has no `open`: `dismissAllOverlays()` only collapses its expanded panel. See [`a11y-floating`](#a11y-floating).
|
|
1041
1076
|
* **Body mounting:** every overlay (including the snackbar and notification-banner regions) moves itself to `<body>` when connected, so a `position: fixed` layer isn't clipped by an ancestor. See [Overlays in a framework](#overlays-in-a-framework) below.
|
|
1042
1077
|
|
|
1043
|
-
|
|
1078
|
+
#### Overlays in a framework
|
|
1044
1079
|
|
|
1045
|
-
|
|
1080
|
+
##### Removing them is up to you.
|
|
1046
1081
|
|
|
1047
|
-
An overlay authored inside a component isn't inside that component's DOM any more, so when your framework removes the component's subtree (an unmount, a SPA navigation), the overlay stays in `<body>`, and the next render adds a second copy with the same `id`. Call `removeOverlaysWithin(host)` on unmount. It removes every overlay authored inside `host`, even after `host` has left the document, and returns how many it removed. It's exported from `a11y-elements/core` and from every overlay's `define.js`.
|
|
1082
|
+
An overlay authored inside a component isn't inside that component's DOM any more, so when your framework removes the component's subtree (an unmount, a SPA navigation), the overlay stays in `<body>`, and the next render adds a second copy with the same `id`. Call `removeOverlaysWithin(host)` on unmount. It removes every overlay authored inside `host`, and any overlay authored inside one of those (a tooltip in a modal), even after `host` has left the document, and returns how many it removed. It's exported from `a11y-elements/core` and from every overlay's `define.js`.
|
|
1048
1083
|
|
|
1049
1084
|
```js
|
|
1050
1085
|
import { removeOverlaysWithin } from 'a11y-elements/core';
|
|
@@ -1055,7 +1090,7 @@ onUnmount(() => removeOverlaysWithin(hostElement)); // your framework's unmount
|
|
|
1055
1090
|
|
|
1056
1091
|
Nothing is removed automatically, so subtrees your framework detaches and reattaches later (keep-alive caches, keyed moves) keep their overlays.
|
|
1057
1092
|
|
|
1058
|
-
|
|
1093
|
+
#### Don't reach overlay content through the host.
|
|
1059
1094
|
|
|
1060
1095
|
If the overlay's bundle is already loaded, `host.innerHTML = '…<a11y-modal>…'` upgrades the overlay and moves it to `<body>` during that same assignment, so a later `host.querySelectorAll(...)` finds nothing inside it.
|
|
1061
1096
|
|
|
@@ -1067,13 +1102,13 @@ If the bundle loads after rendering, the same query does find it, so the result
|
|
|
1067
1102
|
* bind events on the overlay element itself, or delegate from it;
|
|
1068
1103
|
* put final text into the markup before injecting it, rather than in a pass after rendering.
|
|
1069
1104
|
|
|
1070
|
-
|
|
1105
|
+
#### Bind overlay events yourself.
|
|
1071
1106
|
|
|
1072
1107
|
Framework template bindings (event directives, declarative listeners) usually run over the component's subtree after it's inserted. By then the overlay has already moved to `<body>`, so its bindings never attach. Get the overlay with `getElementById`, call `addEventListener` on it (or delegate from it) after each render, and remove the listener on unmount.
|
|
1073
1108
|
|
|
1074
1109
|
<a id="dialogs"></a>
|
|
1075
1110
|
|
|
1076
|
-
|
|
1111
|
+
#### Dialogs (`<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`)
|
|
1077
1112
|
|
|
1078
1113
|
They also share:
|
|
1079
1114
|
|
|
@@ -1096,7 +1131,7 @@ They also share:
|
|
|
1096
1131
|
|
|
1097
1132
|
<a id="anchored-overlays"></a>
|
|
1098
1133
|
|
|
1099
|
-
|
|
1134
|
+
#### Anchored overlays (`<a11y-popover>`, `<a11y-tooltip>`, `<a11y-dropdown>`, `<a11y-context-menu>`)
|
|
1100
1135
|
|
|
1101
1136
|
They are positioned next to an anchor. They flip to the opposite side when there isn't room, and close on a click outside or Escape.
|
|
1102
1137
|
|
|
@@ -1110,9 +1145,9 @@ They are positioned next to an anchor. They flip to the opposite side when there
|
|
|
1110
1145
|
|
|
1111
1146
|
<a id="menus"></a>
|
|
1112
1147
|
|
|
1113
|
-
|
|
1148
|
+
#### Menus (`<a11y-dropdown>`, `<a11y-context-menu>`)
|
|
1114
1149
|
|
|
1115
|
-
Items are your own children with `role="menuitem"`. Arrow keys, Home and End move between them, and Enter/Space fire a real `click`. The menu closes after an item is clicked or when focus leaves it. Mark an item `aria-disabled="true"` to skip it.
|
|
1150
|
+
Items are your own children with `role="menuitem"`. Arrow keys, Home and End move between them, and Enter/Space fire a real `click`. The menu closes after an item is clicked or when focus leaves it. Mark an item `aria-disabled="true"` (or, on a `<button>`, `disabled`) to skip it.
|
|
1116
1151
|
|
|
1117
1152
|
<details>
|
|
1118
1153
|
<summary>CSS variables shared by anchored overlays and menus</summary>
|
|
@@ -1129,7 +1164,7 @@ Items are your own children with `role="menuitem"`. Arrow keys, Home and End mov
|
|
|
1129
1164
|
|
|
1130
1165
|
</details>
|
|
1131
1166
|
|
|
1132
|
-
|
|
1167
|
+
### `a11y-blocking-loader`
|
|
1133
1168
|
|
|
1134
1169
|
A full-screen loading overlay that can't be dismissed. While open, the rest of the page is `inert` and focus moves onto the loader; both are restored on close. Contains an `<a11y-spinner>` (registered automatically).
|
|
1135
1170
|
|
|
@@ -1163,7 +1198,7 @@ See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `cl
|
|
|
1163
1198
|
|
|
1164
1199
|
</details>
|
|
1165
1200
|
|
|
1166
|
-
|
|
1201
|
+
### `a11y-context-menu`
|
|
1167
1202
|
|
|
1168
1203
|
A menu that opens at the pointer on right-click of a trigger element, replacing the browser's own menu there. See [Menus](#menus) and [Anchored overlays](#anchored-overlays).
|
|
1169
1204
|
|
|
@@ -1199,7 +1234,7 @@ Also takes the shared [anchored-overlay](#anchored-overlays) options `placement`
|
|
|
1199
1234
|
|
|
1200
1235
|
</details>
|
|
1201
1236
|
|
|
1202
|
-
|
|
1237
|
+
### `a11y-drawer`
|
|
1203
1238
|
|
|
1204
1239
|
A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dialogs](#dialogs)).
|
|
1205
1240
|
|
|
@@ -1236,7 +1271,7 @@ The close button uses the modal's `--a11y-modal-close-button-size` and `--a11y-m
|
|
|
1236
1271
|
|
|
1237
1272
|
</details>
|
|
1238
1273
|
|
|
1239
|
-
|
|
1274
|
+
### `a11y-dropdown`
|
|
1240
1275
|
|
|
1241
1276
|
A menu attached to a trigger button. The anchor is the trigger: clicking it toggles the menu, and it gets `aria-haspopup`, `aria-controls` and `aria-expanded`. See [Anchored overlays](#anchored-overlays) and [Menus](#menus).
|
|
1242
1277
|
|
|
@@ -1267,7 +1302,7 @@ No attributes of its own. It takes the shared [anchored-overlay](#anchored-overl
|
|
|
1267
1302
|
|
|
1268
1303
|
</details>
|
|
1269
1304
|
|
|
1270
|
-
|
|
1305
|
+
### `a11y-emergency-dialog`
|
|
1271
1306
|
|
|
1272
1307
|
A modal the user can't dismiss: no close button, no Escape, no backdrop click, whatever its attributes say. For things that must be resolved on purpose, e.g. "your session is about to expire". Close it from code.
|
|
1273
1308
|
|
|
@@ -1298,7 +1333,7 @@ From the shared [dialog](#dialogs) options, only `dialog-label` and `onClose` ap
|
|
|
1298
1333
|
|
|
1299
1334
|
</details>
|
|
1300
1335
|
|
|
1301
|
-
|
|
1336
|
+
### `a11y-floating`
|
|
1302
1337
|
|
|
1303
1338
|
Content pinned to a corner or edge of the viewport: a floating button that opens a drawer, an info bubble, a help launcher. It's visible by default: there's no `open` attribute. Hide it with `hidden` or `dismiss()`. Several in the same position stack instead of overlapping.
|
|
1304
1339
|
|
|
@@ -1381,7 +1416,7 @@ Offsets add the device's safe-area inset (`env(safe-area-inset-*)`). The stackin
|
|
|
1381
1416
|
|
|
1382
1417
|
</details>
|
|
1383
1418
|
|
|
1384
|
-
|
|
1419
|
+
### `a11y-modal`
|
|
1385
1420
|
|
|
1386
1421
|
A centered dialog. Your content is its children. See [Dialogs](#dialogs).
|
|
1387
1422
|
|
|
@@ -1414,9 +1449,9 @@ Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-lab
|
|
|
1414
1449
|
|
|
1415
1450
|
`.a11y-modal-buttons` is an optional footer-row class for your own buttons. It lays them out in a row, and gives plain `<button>`s a default look (padding, font size, hover colors). Those styles have zero specificity (`:where()`), so any class on your buttons overrides them. They also sit in the `a11y-elements` cascade layer, so any CSS of yours that isn't in a layer wins. If your own styles are layered (Tailwind's `@layer utilities`, for example), declare the order first so yours win: `@layer a11y-elements, base, components, utilities;`. With `danger: true`, `confirmDialog()`'s confirm button uses `--a11y-color-danger` for its text and hover background.
|
|
1416
1451
|
|
|
1417
|
-
|
|
1452
|
+
#### Confirmation dialogs: `confirmDialog()`
|
|
1418
1453
|
|
|
1419
|
-
`confirmDialog()` asks a yes/no question in a temporary modal, and resolves `true` only when the confirm button is pressed. Every other close (Cancel, Escape, the backdrop, ×, `dismissAllOverlays()`) resolves `false`. Focus starts on Cancel, so a stray Enter doesn't confirm. The modal is removed once closed.
|
|
1454
|
+
`confirmDialog()` asks a yes/no question in a temporary modal, and resolves `true` only when the confirm button is pressed. Every other close (Cancel, Escape, the backdrop, ×, `dismissAllOverlays()`) resolves `false`. Focus starts on Cancel, so a stray Enter doesn't confirm. The modal is removed once closed. It isn't authored inside any component, so `removeOverlaysWithin()` doesn't see it: on a SPA navigation, close it with `dismissAllOverlays()` (which resolves it `false`), or remove `a11y-modal.a11y-confirm` yourself.
|
|
1420
1455
|
|
|
1421
1456
|
```js
|
|
1422
1457
|
import { confirmDialog } from 'a11y-elements/overlays/modal';
|
|
@@ -1475,7 +1510,7 @@ modal.open = true;
|
|
|
1475
1510
|
|
|
1476
1511
|
</details>
|
|
1477
1512
|
|
|
1478
|
-
|
|
1513
|
+
### `a11y-notification-banner`
|
|
1479
1514
|
|
|
1480
1515
|
Full-width banners that stay until the user dismisses them (or you call `dismissAll()`). Place one region in the page, or skip it and use `showNotificationBanner()`, which finds or creates one.
|
|
1481
1516
|
|
|
@@ -1533,7 +1568,7 @@ Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared
|
|
|
1533
1568
|
|
|
1534
1569
|
</details>
|
|
1535
1570
|
|
|
1536
|
-
|
|
1571
|
+
### `a11y-popover`
|
|
1537
1572
|
|
|
1538
1573
|
Content attached to an anchor, opened from code. With `interactive` it's a `role="dialog"` that traps focus; without it, a `role="region"`. See [Anchored overlays](#anchored-overlays).
|
|
1539
1574
|
|
|
@@ -1575,9 +1610,9 @@ Also takes the shared [anchored-overlay](#anchored-overlays) options: `anchor` /
|
|
|
1575
1610
|
|
|
1576
1611
|
</details>
|
|
1577
1612
|
|
|
1578
|
-
|
|
1613
|
+
### `a11y-snackbar`
|
|
1579
1614
|
|
|
1580
|
-
Toast notifications that dismiss themselves: after 3 s by default, or 10 s when the toast has an action button. The countdown pauses while the toast is hovered or focused. Place one region in the page, or skip it and use `notify()`, which finds or creates one.
|
|
1615
|
+
Toast notifications that dismiss themselves: after 3 s by default, or 10 s when the toast has an action button. The countdown pauses while the toast is hovered or focused. A round × button in each toast's top-right corner dismisses it early (without running `onAction`). Place one region in the page, or skip it and use `notify()`, which finds or creates one.
|
|
1581
1616
|
|
|
1582
1617
|
```html
|
|
1583
1618
|
<a11y-snackbar max-stack="5"></a11y-snackbar>
|
|
@@ -1596,13 +1631,15 @@ notify(h('span', null, 'Saved. ', h('a', { href: '/files' }, 'View files'))); //
|
|
|
1596
1631
|
|
|
1597
1632
|
| Name | Kind | Default | Description |
|
|
1598
1633
|
| --- | --- | --- | --- |
|
|
1634
|
+
| `dismiss-label` | attribute | `Dismiss` | Accessible name of each toast's × button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
1599
1635
|
| `max-stack` | attribute | `3` | How many toasts show at once; the rest wait in a queue and show as earlier ones are dismissed. |
|
|
1600
1636
|
| `maxStack` | property | `3` | Same as `max-stack`. `setMaxStack(n)` is an alias. |
|
|
1601
1637
|
| `notify(message, options)` | method | — | Shows a toast (or queues it). |
|
|
1638
|
+
| `dismissAll()` | method | — | Removes every showing toast and drops queued ones, without running `onAction`. |
|
|
1602
1639
|
|
|
1603
|
-
It's a page region, not an open/close overlay: it fires no open/close events and `dismissAllOverlays()` leaves it alone. Like every overlay it moves itself to `<body>`; see [Overlays in a framework](#overlays-in-a-framework) for `removeOverlaysWithin()`.
|
|
1640
|
+
It's a page region, not an open/close overlay: it fires no open/close events and `dismissAllOverlays()` leaves it alone, so toasts outlive a SPA navigation while the region stays in the page. Call `dismissAll()` to clear them. Removing the region from the document (e.g. with `removeOverlaysWithin()`) drops its toasts, queued ones included, and cancels their timers; re-adding it starts empty. A toast enqueued while the region is detached waits until it's back in the page. Like every overlay it moves itself to `<body>`; see [Overlays in a framework](#overlays-in-a-framework) for `removeOverlaysWithin()`.
|
|
1604
1641
|
|
|
1605
|
-
A `message` is text: a string is inserted as text, never parsed. A DOM node (e.g. built with `h()` from `a11y-elements/core`) is inserted as is. For markup, pass `raw(markup)` from `a11y-elements/core`. It's sanitized against script injection (no scripts, `<style>`, event handlers or `javascript:` URLs). That's a basic XSS filter, not a full sanitizer like DOMPurify: forms, links, images and `style` attributes still pass, so untrusted markup can still look like your UI (phishing). Pass user data as text, or run it through DOMPurify first. `trustedRaw(markup)` skips that, for markup you wrote yourself. The same goes for `<a11y-notification-banner>`.
|
|
1642
|
+
A `message` is text: a string is inserted as text, never parsed. A DOM node (e.g. built with `h()` from `a11y-elements/core`) is inserted as is. For markup, pass `raw(markup)` from `a11y-elements/core`. It's sanitized against script injection (no scripts, `<style>`, event handlers or `javascript:` URLs). It also drops an `id` or `name` that would shadow a built-in of `document` or of a `<form>` (DOM clobbering: `name="createElement"`, `name="action"`, `id="body"`, …), or a name a form or image on the page already has. That's a basic XSS filter, not a full sanitizer like DOMPurify: forms, links, images and `style` attributes still pass, so untrusted markup can still look like your UI (phishing). Pass user data as text, or run it through DOMPurify first. `trustedRaw(markup)` skips that, for markup you wrote yourself. The same goes for `<a11y-notification-banner>`.
|
|
1606
1643
|
|
|
1607
1644
|
`notify()` options (method and convenience export):
|
|
1608
1645
|
|
|
@@ -1610,7 +1647,7 @@ A `message` is text: a string is inserted as text, never parsed. A DOM node (e.g
|
|
|
1610
1647
|
| --- | --- | --- |
|
|
1611
1648
|
| `type` | `info` | `info`, `success`, `warning` or `error` (`error` uses `role="alert"`). |
|
|
1612
1649
|
| `position` | `bottom` | `bottom` or `top`. |
|
|
1613
|
-
| `duration` | `3000` (`10000` with an action) | Time on screen, in ms, not counting hover/focus. |
|
|
1650
|
+
| `duration` | `3000` (`10000` with an action) | Time on screen, in ms, not counting hover/focus. `Infinity` keeps the toast until it's dismissed. |
|
|
1614
1651
|
| `actionText` / `onAction` | — | Adds an action button; clicking it dismisses the toast and runs `onAction`. |
|
|
1615
1652
|
| `maxStack` | — | Sets `max-stack` on the region (sticky for later toasts). |
|
|
1616
1653
|
|
|
@@ -1625,6 +1662,9 @@ Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared
|
|
|
1625
1662
|
| --- | --- |
|
|
1626
1663
|
| `--a11y-snackbar-animation-duration` | `0.3s` |
|
|
1627
1664
|
| `--a11y-snackbar-border-radius` | `0.5rem` |
|
|
1665
|
+
| `--a11y-snackbar-close-border-width` | `2px` |
|
|
1666
|
+
| `--a11y-snackbar-close-font-size` | `1rem` |
|
|
1667
|
+
| `--a11y-snackbar-close-size` | `1.5rem` |
|
|
1628
1668
|
| `--a11y-snackbar-container-width` | `350px` |
|
|
1629
1669
|
| `--a11y-snackbar-gap` | `1rem` |
|
|
1630
1670
|
| `--a11y-snackbar-offset` | `1rem` |
|
|
@@ -1636,7 +1676,7 @@ Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared
|
|
|
1636
1676
|
|
|
1637
1677
|
</details>
|
|
1638
1678
|
|
|
1639
|
-
|
|
1679
|
+
### `a11y-tooltip`
|
|
1640
1680
|
|
|
1641
1681
|
A short description shown on hover or focus of its anchor, which gets `aria-describedby`. It stays open while the pointer is over it, and Escape hides it. Never traps focus. See [Anchored overlays](#anchored-overlays).
|
|
1642
1682
|
|
|
@@ -1667,7 +1707,7 @@ Also takes the shared [anchored-overlay](#anchored-overlays) options: `anchor` /
|
|
|
1667
1707
|
|
|
1668
1708
|
</details>
|
|
1669
1709
|
|
|
1670
|
-
|
|
1710
|
+
## Shared tokens
|
|
1671
1711
|
|
|
1672
1712
|
Status colors and the z-index scale, defined on `:root` (in `overlays/core/overlay-variables.css`). Override them globally, or override a component's own token instead.
|
|
1673
1713
|
|
package/dist/a11y.css
CHANGED
|
@@ -1469,6 +1469,7 @@ a11y-floating.a11y-floating--scrolled-away {
|
|
|
1469
1469
|
top: var(--a11y-snackbar-offset, 1rem);
|
|
1470
1470
|
}
|
|
1471
1471
|
.a11y-snackbar {
|
|
1472
|
+
position: relative;
|
|
1472
1473
|
display: flex;
|
|
1473
1474
|
justify-content: center;
|
|
1474
1475
|
align-items: center;
|
|
@@ -1497,13 +1498,39 @@ a11y-floating.a11y-floating--scrolled-away {
|
|
|
1497
1498
|
background: var(--a11y-color-warning, #f9a825);
|
|
1498
1499
|
color: var(--a11y-color-text-on-warning, #111827);
|
|
1499
1500
|
}
|
|
1500
|
-
.a11y-
|
|
1501
|
+
.a11y-snackbar__action {
|
|
1501
1502
|
background: transparent;
|
|
1502
1503
|
border: none;
|
|
1503
1504
|
color: inherit;
|
|
1504
1505
|
font-weight: bold;
|
|
1505
1506
|
cursor: pointer;
|
|
1506
1507
|
}
|
|
1508
|
+
.a11y-snackbar__close {
|
|
1509
|
+
position: absolute;
|
|
1510
|
+
top: 0;
|
|
1511
|
+
right: 0;
|
|
1512
|
+
transform: translate(40%, -40%);
|
|
1513
|
+
display: flex;
|
|
1514
|
+
align-items: center;
|
|
1515
|
+
justify-content: center;
|
|
1516
|
+
box-sizing: border-box;
|
|
1517
|
+
width: var(--a11y-snackbar-close-size, 1.5rem);
|
|
1518
|
+
height: var(--a11y-snackbar-close-size, 1.5rem);
|
|
1519
|
+
padding: 0;
|
|
1520
|
+
border: var(--a11y-snackbar-close-border-width, 2px) solid currentColor;
|
|
1521
|
+
border-radius: 50%;
|
|
1522
|
+
background: inherit;
|
|
1523
|
+
color: inherit;
|
|
1524
|
+
font: inherit;
|
|
1525
|
+
font-size: var(--a11y-snackbar-close-font-size, 1rem);
|
|
1526
|
+
font-weight: bold;
|
|
1527
|
+
line-height: 1;
|
|
1528
|
+
cursor: pointer;
|
|
1529
|
+
}
|
|
1530
|
+
.a11y-snackbar__close:focus-visible {
|
|
1531
|
+
outline: 2px solid currentColor;
|
|
1532
|
+
outline-offset: 2px;
|
|
1533
|
+
}
|
|
1507
1534
|
@keyframes a11y-snackbar-fade-in {
|
|
1508
1535
|
from {
|
|
1509
1536
|
opacity: 0;
|