@webtides/element-library 0.3.1 → 0.5.0
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/CHANGELOG.md +300 -0
- package/README.md +72 -56
- package/all.js +16 -0
- package/catalog.js +17 -1
- package/custom-elements.json +15912 -10065
- package/package.json +1 -1
- package/src/components/accordion/accordion.changelog.md +11 -0
- package/src/components/accordion/accordion.js +15 -3
- package/src/components/accordion/accordion.readme.md +27 -1
- package/src/components/accordion/accordion.style.js +19 -0
- package/src/components/app-bar/app-bar.changelog.md +24 -0
- package/src/components/app-bar/app-bar.define.js +3 -0
- package/src/components/app-bar/app-bar.js +91 -0
- package/src/components/app-bar/app-bar.readme.md +130 -0
- package/src/components/app-bar/app-bar.style.js +103 -0
- package/src/components/app-frame/app-frame.changelog.md +59 -0
- package/src/components/app-frame/app-frame.define.js +3 -0
- package/src/components/app-frame/app-frame.events.js +6 -0
- package/src/components/app-frame/app-frame.js +1085 -0
- package/src/components/app-frame/app-frame.readme.md +425 -0
- package/src/components/app-frame/app-frame.style.js +534 -0
- package/src/components/button/button.changelog.md +21 -0
- package/src/components/button/button.events.js +3 -0
- package/src/components/button/button.js +145 -3
- package/src/components/button/button.readme.md +72 -4
- package/src/components/button/button.style.js +167 -8
- package/src/components/button-group/button-group.changelog.md +10 -0
- package/src/components/button-group/button-group.readme.md +2 -0
- package/src/components/button-group/button-group.style.js +6 -2
- package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +6 -0
- package/src/components/checkbox-group-field/checkbox-group-field.js +7 -2
- package/src/components/checkbox-group-field/checkbox-group-field.readme.md +23 -1
- package/src/components/combobox-field/combobox-field.changelog.md +6 -0
- package/src/components/combobox-field/combobox-field.readme.md +8 -0
- package/src/components/combobox-field/combobox-field.style.js +2 -0
- package/src/components/date-field/date-field.changelog.md +6 -0
- package/src/components/date-field/date-field.readme.md +10 -0
- package/src/components/date-field/date-field.style.js +8 -3
- package/src/components/description-list/description-list.changelog.md +42 -0
- package/src/components/description-list/description-list.define.js +3 -0
- package/src/components/description-list/description-list.js +49 -0
- package/src/components/description-list/description-list.readme.md +161 -0
- package/src/components/description-list/description-list.style.js +169 -0
- package/src/components/dialog/dialog.changelog.md +7 -0
- package/src/components/dialog/dialog.readme.md +5 -0
- package/src/components/dialog/dialog.style.js +17 -2
- package/src/components/divider/divider.changelog.md +6 -0
- package/src/components/divider/divider.readme.md +1 -1
- package/src/components/divider/divider.style.js +6 -0
- package/src/components/drawer/drawer.changelog.md +7 -0
- package/src/components/drawer/drawer.readme.md +7 -6
- package/src/components/drawer/drawer.style.js +35 -2
- package/src/components/dropdown/dropdown.readme.md +6 -1
- package/src/components/file-field/file-field.changelog.md +8 -0
- package/src/components/file-field/file-field.js +135 -5
- package/src/components/file-field/file-field.readme.md +35 -6
- package/src/components/file-field/file-field.style.js +71 -0
- package/src/components/form-field/form-field.js +1 -1
- package/src/components/input-field/input-field.changelog.md +10 -0
- package/src/components/input-field/input-field.js +192 -14
- package/src/components/input-field/input-field.readme.md +88 -2
- package/src/components/input-field/input-field.style.js +2 -0
- package/src/components/list/list.changelog.md +30 -0
- package/src/components/list/list.define.js +3 -0
- package/src/components/list/list.js +68 -0
- package/src/components/list/list.readme.md +123 -0
- package/src/components/list/list.style.js +56 -0
- package/src/components/list-item/list-item.changelog.md +40 -0
- package/src/components/list-item/list-item.define.js +3 -0
- package/src/components/list-item/list-item.js +130 -0
- package/src/components/list-item/list-item.readme.md +144 -0
- package/src/components/list-item/list-item.style.js +246 -0
- package/src/components/menu/menu.changelog.md +44 -0
- package/src/components/menu/menu.define.js +3 -0
- package/src/components/menu/menu.events.js +5 -0
- package/src/components/menu/menu.js +793 -0
- package/src/components/menu/menu.readme.md +313 -0
- package/src/components/menu/menu.style.js +59 -0
- package/src/components/menu-group/menu-group.changelog.md +20 -0
- package/src/components/menu-group/menu-group.define.js +3 -0
- package/src/components/menu-group/menu-group.js +44 -0
- package/src/components/menu-group/menu-group.readme.md +74 -0
- package/src/components/menu-group/menu-group.style.js +38 -0
- package/src/components/menu-item/menu-item.changelog.md +32 -0
- package/src/components/menu-item/menu-item.define.js +3 -0
- package/src/components/menu-item/menu-item.js +168 -0
- package/src/components/menu-item/menu-item.readme.md +132 -0
- package/src/components/menu-item/menu-item.style.js +117 -0
- package/src/components/nav/nav.changelog.md +35 -0
- package/src/components/nav/nav.define.js +3 -0
- package/src/components/nav/nav.js +212 -0
- package/src/components/nav/nav.readme.md +248 -0
- package/src/components/nav/nav.style.js +269 -0
- package/src/components/nav-item/nav-item.changelog.md +25 -0
- package/src/components/nav-item/nav-item.define.js +3 -0
- package/src/components/nav-item/nav-item.js +75 -0
- package/src/components/nav-item/nav-item.readme.md +111 -0
- package/src/components/nav-item/nav-item.style.js +159 -0
- package/src/components/otp-field/otp-field.changelog.md +6 -0
- package/src/components/otp-field/otp-field.readme.md +8 -0
- package/src/components/otp-field/otp-field.style.js +8 -3
- package/src/components/pagination/pagination.changelog.md +8 -0
- package/src/components/pagination/pagination.js +123 -49
- package/src/components/pagination/pagination.readme.md +24 -6
- package/src/components/pagination/pagination.style.js +11 -1
- package/src/components/password-field/password-field.changelog.md +7 -0
- package/src/components/password-field/password-field.readme.md +11 -1
- package/src/components/password-field/password-field.style.js +2 -0
- package/src/components/popover/popover.changelog.md +6 -0
- package/src/components/popover/popover.style.js +1 -0
- package/src/components/radio-field/radio-field.changelog.md +6 -0
- package/src/components/radio-field/radio-field.js +7 -2
- package/src/components/radio-field/radio-field.readme.md +23 -1
- package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
- package/src/components/scroll-to-top/scroll-to-top.js +16 -12
- package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
- package/src/components/segmented-field/segmented-field.changelog.md +27 -0
- package/src/components/segmented-field/segmented-field.define.js +3 -0
- package/src/components/segmented-field/segmented-field.js +175 -0
- package/src/components/segmented-field/segmented-field.readme.md +140 -0
- package/src/components/segmented-field/segmented-field.style.js +193 -0
- package/src/components/splitter/splitter.changelog.md +24 -0
- package/src/components/splitter/splitter.define.js +3 -0
- package/src/components/splitter/splitter.events.js +4 -0
- package/src/components/splitter/splitter.js +237 -0
- package/src/components/splitter/splitter.readme.md +164 -0
- package/src/components/splitter/splitter.style.js +100 -0
- package/src/components/status-bar/status-bar.changelog.md +25 -0
- package/src/components/status-bar/status-bar.define.js +3 -0
- package/src/components/status-bar/status-bar.js +74 -0
- package/src/components/status-bar/status-bar.readme.md +139 -0
- package/src/components/status-bar/status-bar.style.js +122 -0
- package/src/components/tab-group/tab-group.changelog.md +7 -0
- package/src/components/tab-group/tab-group.js +30 -9
- package/src/components/tab-group/tab-group.readme.md +14 -0
- package/src/components/textarea-field/textarea-field.changelog.md +6 -0
- package/src/components/textarea-field/textarea-field.js +14 -1
- package/src/components/textarea-field/textarea-field.readme.md +23 -1
- package/src/components/toast/toast.changelog.md +6 -0
- package/src/components/toast/toast.readme.md +5 -3
- package/src/components/toast/toast.style.js +22 -6
- package/src/components/toolbar/toolbar.changelog.md +24 -0
- package/src/components/toolbar/toolbar.define.js +3 -0
- package/src/components/toolbar/toolbar.js +233 -0
- package/src/components/toolbar/toolbar.readme.md +156 -0
- package/src/components/toolbar/toolbar.style.js +49 -0
- package/src/components/tooltip/tooltip.changelog.md +11 -0
- package/src/components/tooltip/tooltip.js +51 -4
- package/src/components/tooltip/tooltip.readme.md +26 -1
- package/src/components/tree/tree.changelog.md +23 -0
- package/src/components/tree/tree.define.js +3 -0
- package/src/components/tree/tree.js +138 -0
- package/src/components/tree/tree.readme.md +119 -0
- package/src/components/tree/tree.style.js +16 -0
- package/src/components/tree-item/tree-item.changelog.md +23 -0
- package/src/components/tree-item/tree-item.define.js +3 -0
- package/src/components/tree-item/tree-item.events.js +3 -0
- package/src/components/tree-item/tree-item.js +246 -0
- package/src/components/tree-item/tree-item.readme.md +128 -0
- package/src/components/tree-item/tree-item.style.js +226 -0
- package/src/styles/appearance.style.js +47 -0
- package/src/styles/choice-group.style.js +27 -1
- package/src/styles/input-control.style.js +87 -0
- package/src/styles/modal.style.js +14 -1
- package/src/styles/native.css +100 -0
- package/src/styles/size.style.js +41 -0
- package/src/utils/floating.js +15 -1
- package/src/utils/focus.js +69 -0
- package/src/utils/options.js +35 -0
- package/src/utils/scroll.js +24 -0
- package/src/utils/text-entry-attributes.js +13 -0
- package/types/all.d.ts +16 -0
- package/types/src/components/accordion/accordion.d.ts +3 -1
- package/types/src/components/app-bar/app-bar.d.ts +43 -0
- package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
- package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
- package/types/src/components/app-frame/app-frame.d.ts +497 -0
- package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
- package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
- package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
- package/types/src/components/button/button.d.ts +61 -0
- package/types/src/components/button/button.events.d.ts +4 -0
- package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +5 -2
- package/types/src/components/combobox-field/combobox-field.d.ts +10 -0
- package/types/src/components/date-field/date-field.d.ts +10 -0
- package/types/src/components/description-list/description-list.d.ts +34 -0
- package/types/src/components/description-list/description-list.define.d.ts +1 -0
- package/types/src/components/description-list/description-list.style.d.ts +2 -0
- package/types/src/components/file-field/file-field.d.ts +68 -3
- package/types/src/components/form-field/form-field.d.ts +1 -1
- package/types/src/components/input-field/input-field.d.ts +99 -0
- package/types/src/components/list/list.d.ts +41 -0
- package/types/src/components/list/list.define.d.ts +1 -0
- package/types/src/components/list/list.style.d.ts +2 -0
- package/types/src/components/list-item/list-item.d.ts +64 -0
- package/types/src/components/list-item/list-item.define.d.ts +1 -0
- package/types/src/components/list-item/list-item.style.d.ts +2 -0
- package/types/src/components/menu/menu.d.ts +362 -0
- package/types/src/components/menu/menu.define.d.ts +1 -0
- package/types/src/components/menu/menu.events.d.ts +6 -0
- package/types/src/components/menu/menu.style.d.ts +2 -0
- package/types/src/components/menu-group/menu-group.d.ts +24 -0
- package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
- package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
- package/types/src/components/menu-item/menu-item.d.ts +80 -0
- package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
- package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
- package/types/src/components/nav/nav.d.ts +103 -0
- package/types/src/components/nav/nav.define.d.ts +1 -0
- package/types/src/components/nav/nav.style.d.ts +2 -0
- package/types/src/components/nav-item/nav-item.d.ts +39 -0
- package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
- package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
- package/types/src/components/otp-field/otp-field.d.ts +10 -0
- package/types/src/components/pagination/pagination.d.ts +31 -2
- package/types/src/components/password-field/password-field.d.ts +10 -0
- package/types/src/components/radio-field/radio-field.d.ts +5 -2
- package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
- package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
- package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
- package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
- package/types/src/components/splitter/splitter.d.ts +127 -0
- package/types/src/components/splitter/splitter.define.d.ts +1 -0
- package/types/src/components/splitter/splitter.events.d.ts +5 -0
- package/types/src/components/splitter/splitter.style.d.ts +2 -0
- package/types/src/components/status-bar/status-bar.d.ts +44 -0
- package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
- package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
- package/types/src/components/tab-group/tab-group.d.ts +17 -0
- package/types/src/components/textarea-field/textarea-field.d.ts +7 -0
- package/types/src/components/toolbar/toolbar.d.ts +96 -0
- package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
- package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
- package/types/src/components/tooltip/tooltip.d.ts +26 -0
- package/types/src/components/tree/tree.d.ts +62 -0
- package/types/src/components/tree/tree.define.d.ts +1 -0
- package/types/src/components/tree/tree.style.d.ts +2 -0
- package/types/src/components/tree-item/tree-item.d.ts +106 -0
- package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
- package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
- package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
- package/types/src/styles/appearance.style.d.ts +31 -0
- package/types/src/styles/choice-group.style.d.ts +1 -1
- package/types/src/styles/input-control.style.d.ts +15 -0
- package/types/src/styles/modal.style.d.ts +5 -0
- package/types/src/styles/size.style.d.ts +24 -0
- package/types/src/utils/floating.d.ts +11 -0
- package/types/src/utils/focus.d.ts +25 -0
- package/types/src/utils/options.d.ts +17 -0
- package/types/src/utils/scroll.d.ts +11 -0
- package/types/src/utils/text-entry-attributes.d.ts +10 -0
- package/web-types.json +2935 -308
|
@@ -41,6 +41,8 @@ import '@webtides/element-library/textarea-field/define';
|
|
|
41
41
|
| `value` | `string` | `null` | The current text content of the textarea field |
|
|
42
42
|
| `placeholder` | `string` | `''` | Placeholder text displayed when the textarea is empty |
|
|
43
43
|
| `rows` | `number` | `3` | The number of visible text rows in the textarea |
|
|
44
|
+
| `maxlength` | `number` | `null` | Passed on to the control as `maxlength`: the browser takes no more characters than this while the user types |
|
|
45
|
+
| `minlength` | `number` | `null` | Passed on as `minlength`: a text the user has typed that is shorter makes the field invalid |
|
|
44
46
|
| `autocomplete` | `string` | `null` | Passed on to the control as `autocomplete` (e.g. `email`, `current-password`, `one-time-code`) |
|
|
45
47
|
| `inputmode` | `string` | `null` | Passed on as `inputmode`: the on-screen keyboard to show (e.g. `numeric`, `email`) |
|
|
46
48
|
| `enterkeyhint` | `string` | `null` | Passed on as `enterkeyhint`: the label of the enter key on an on-screen keyboard (e.g. `next`, `send`) |
|
|
@@ -118,6 +120,26 @@ The value is rendered as the content of the `<textarea>`. A server-rendered fiel
|
|
|
118
120
|
|
|
119
121
|
A line break at the very start of the value is missing until the element has started: the HTML parser drops a line break that directly follows `<textarea>`.
|
|
120
122
|
|
|
123
|
+
## The length of the text
|
|
124
|
+
|
|
125
|
+
`maxlength` and `minlength` are passed on to the control, in server-rendered markup as well, and one that is not set is not rendered. The browser does the rest:
|
|
126
|
+
|
|
127
|
+
```html
|
|
128
|
+
<el-textarea-field
|
|
129
|
+
name="notes"
|
|
130
|
+
label="Notes"
|
|
131
|
+
maxlength="2000"
|
|
132
|
+
minlength="10"
|
|
133
|
+
error-message="At least 10 characters"
|
|
134
|
+
></el-textarea-field>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- **`maxlength`**: the control takes no more characters while the user types or pastes. Nothing is invalid for it: the text is never longer.
|
|
138
|
+
- **`minlength`**: a text the user has typed that is shorter makes the field invalid, the way `required` and `pattern` do: `valid` is `false`, the field shows its `error-message` once it was touched, and the form is not submitted.
|
|
139
|
+
- **Only what the user has typed is measured.** A browser does not hold a value against these limits that the page or the server has put into the control. A value from the server that is too long or too short is valid until the user changes it: the server checks what it gets.
|
|
140
|
+
- **An empty field is not too short.** `minlength` is for a text that is there. Add `required` for a field that has to be filled.
|
|
141
|
+
- **Say the limit.** The field shows no counter and no limit of its own: name it in `help-message`, and in `error-message` for the least length.
|
|
142
|
+
|
|
121
143
|
## Validation
|
|
122
144
|
|
|
123
145
|
The component provides real-time validation feedback:
|
|
@@ -125,7 +147,7 @@ The component provides real-time validation feedback:
|
|
|
125
147
|
- Validation state updates on focus, on blur and with every change of the text
|
|
126
148
|
- Visual indicators (checkmark for valid, cross for invalid) appear beside the textarea after the field is touched
|
|
127
149
|
- Error messages only display when field is touched and invalid
|
|
128
|
-
- Supports HTML5 validation attributes (required, disabled)
|
|
150
|
+
- Supports HTML5 validation attributes (required, minlength, disabled)
|
|
129
151
|
- Clicking the invalid indicator (×) clears the textarea content
|
|
130
152
|
- Tab key (keyCode 9) doesn't trigger change events to avoid false validation during navigation (inherited from `form-field`)
|
|
131
153
|
|
|
@@ -12,6 +12,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
12
12
|
|
|
13
13
|
## Unreleased
|
|
14
14
|
|
|
15
|
+
## [0.4.0] - 2026-11-27
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- On a phone whose page reaches under the notch and the home indicator (`viewport-fit=cover`), a toast could lie under them. The distance of the stack from an edge (`--el-toast-inset`) is on top of the room the system takes there now, and the stack is no wider than what is between the two sides. Elsewhere nothing changes. ([#183](https://github.com/webtides/element-library/issues/183))
|
|
20
|
+
|
|
15
21
|
## [0.3.0] - 2026-11-17
|
|
16
22
|
|
|
17
23
|
### Added
|
|
@@ -80,9 +80,9 @@ _None of its own._ A toast fires the events of a notification (`notification-sho
|
|
|
80
80
|
|
|
81
81
|
#### CSS Custom Properties
|
|
82
82
|
|
|
83
|
-
| Name
|
|
84
|
-
|
|
|
85
|
-
| `--el-toast-inset` | The distance of the stack from the edges of the viewport. Unset, it is `--el-space-4`. |
|
|
83
|
+
| Name | Description |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `--el-toast-inset` | The distance of the stack from the edges of the viewport, on top of the room the system takes there on a phone. Unset, it is `--el-space-4`. |
|
|
86
86
|
|
|
87
87
|
Reads the standard library design tokens `--el-space-4` and `--el-space-2` (the gap between two toasts). The look of a toast is the look of `el-notification`.
|
|
88
88
|
|
|
@@ -138,6 +138,8 @@ The first toast is at the edge, the next ones follow towards the middle of the v
|
|
|
138
138
|
|
|
139
139
|
The region lets the pointer through: what is beside and between the toasts can be clicked.
|
|
140
140
|
|
|
141
|
+
Where a page reaches under the notch and the home indicator of a phone (`viewport-fit=cover` in its viewport, or a web app on the home screen), the distance is on top of the room the system takes at that edge of the screen: a toast at the top is below the status bar, one at the bottom above the home indicator. Without it, and on a desktop, that room is nothing.
|
|
142
|
+
|
|
141
143
|
## More toasts than places
|
|
142
144
|
|
|
143
145
|
With `max` the region shows no more than that many toasts at once. A toast beyond that waits, in the order the toasts came, and is shown when a place is free: when a toast before it is gone, not when it starts to leave.
|
|
@@ -8,14 +8,23 @@ const style = css`
|
|
|
8
8
|
bar) goes. Before the script has run it is a fixed box in the same place. */
|
|
9
9
|
:host {
|
|
10
10
|
--_el-toast-inset: var(--el-toast-inset, var(--el-space-4, 1rem));
|
|
11
|
+
/*
|
|
12
|
+
* The distance from an edge of the viewport is on top of the room the system takes there
|
|
13
|
+
* on a phone: the notch, the rounded corners, the home indicator. Nothing where the page
|
|
14
|
+
* does not reach under them (no viewport-fit=cover), and on a desktop.
|
|
15
|
+
*/
|
|
16
|
+
--_el-toast-top: calc(var(--_el-toast-inset) + env(safe-area-inset-top, 0px));
|
|
17
|
+
--_el-toast-bottom: calc(var(--_el-toast-inset) + env(safe-area-inset-bottom, 0px));
|
|
18
|
+
--_el-toast-start: calc(var(--_el-toast-inset) + env(safe-area-inset-left, 0px));
|
|
19
|
+
--_el-toast-end: calc(var(--_el-toast-inset) + env(safe-area-inset-right, 0px));
|
|
11
20
|
|
|
12
21
|
position: fixed;
|
|
13
22
|
inset: auto;
|
|
14
23
|
/* The default, top-end. */
|
|
15
|
-
top: var(--_el-toast-
|
|
16
|
-
inset-inline-end: var(--_el-toast-
|
|
24
|
+
top: var(--_el-toast-top);
|
|
25
|
+
inset-inline-end: var(--_el-toast-end);
|
|
17
26
|
/* Never wider than the viewport between the two distances. */
|
|
18
|
-
max-width: calc(100% -
|
|
27
|
+
max-width: calc(100% - var(--_el-toast-start) - var(--_el-toast-end));
|
|
19
28
|
padding: 0;
|
|
20
29
|
border: 0;
|
|
21
30
|
background: none;
|
|
@@ -25,14 +34,21 @@ const style = css`
|
|
|
25
34
|
pointer-events: none;
|
|
26
35
|
}
|
|
27
36
|
|
|
37
|
+
/* Asked of the host: the sides of the screen are left and right, start and end follow the
|
|
38
|
+
direction of the text. */
|
|
39
|
+
:host(:dir(rtl)) {
|
|
40
|
+
--_el-toast-start: calc(var(--_el-toast-inset) + env(safe-area-inset-right, 0px));
|
|
41
|
+
--_el-toast-end: calc(var(--_el-toast-inset) + env(safe-area-inset-left, 0px));
|
|
42
|
+
}
|
|
43
|
+
|
|
28
44
|
:host([placement^='bottom']) {
|
|
29
45
|
top: auto;
|
|
30
|
-
bottom: var(--_el-toast-
|
|
46
|
+
bottom: var(--_el-toast-bottom);
|
|
31
47
|
}
|
|
32
48
|
|
|
33
49
|
:host([placement$='-start']) {
|
|
34
50
|
inset-inline-end: auto;
|
|
35
|
-
inset-inline-start: var(--_el-toast-
|
|
51
|
+
inset-inline-start: var(--_el-toast-start);
|
|
36
52
|
}
|
|
37
53
|
|
|
38
54
|
/* In the middle: the box reaches from one side to the other, and the stack puts the toasts
|
|
@@ -40,7 +56,7 @@ const style = css`
|
|
|
40
56
|
takes them from the host. */
|
|
41
57
|
:host([placement='top']),
|
|
42
58
|
:host([placement='bottom']) {
|
|
43
|
-
inset-inline: var(--_el-toast-
|
|
59
|
+
inset-inline: var(--_el-toast-start) var(--_el-toast-end);
|
|
44
60
|
width: auto;
|
|
45
61
|
}
|
|
46
62
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
When your PR touches this component, add an entry under Unreleased and
|
|
9
|
+
mirror it (prefixed with the component name) in root CHANGELOG.md.
|
|
10
|
+
Uncomment headings as needed.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
## Unreleased
|
|
14
|
+
|
|
15
|
+
## [0.4.0] - 2026-11-27
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial `el-toolbar`: the row of controls over a list or a view. A toolbar for assistive technology (`role="toolbar"`, named by `label`), with what the page writes into it as its controls: `el-button`, `el-button-group`, `el-segmented-field`, and `el-divider` between two groups. ([#194](https://github.com/webtides/element-library/issues/194))
|
|
20
|
+
- `size` and `appearance` are the size and the appearance of the controls that have none of their own: of every `el-button` in the toolbar, also inside of a group, and `size` of an `el-segmented-field`. A toolbar that names none has controls of the medium size and plain buttons. A control that names its own keeps it, the defaults included. The toolbar does not write to its controls: it says both in CSS properties that are inherited.
|
|
21
|
+
- The controls stand in a row with a gap of `--el-space-2`. What is slotted into `end` stands at the end; start and end follow the reading direction. A toolbar with more controls than its width takes breaks into a second line.
|
|
22
|
+
- One stop of the Tab key, as the WAI-ARIA toolbar pattern says: the arrow keys move the focus between the controls and around the ends, Home and End go to the first and the last one, and Tab leaves the toolbar and comes back to the control that had the focus last. The options of an `el-segmented-field` are controls of the toolbar: the left and right arrow keys go through them, Space and the up and down keys choose. In a control that takes text the keys belong to that control.
|
|
23
|
+
- An `el-button` with an `aria-label`, a button with an icon alone, shows that name as a tooltip, for the pointer and for the focus of the keyboard. The tooltips are `el-tooltip` elements in the shadow root of the toolbar (`::part(tooltip)`); the toolbar imports the tooltip, and with it `@floating-ui/dom`.
|
|
24
|
+
- The look is the stylesheets alone: a server-rendered toolbar does not change when the elements take over. The script adds the keyboard and the tooltips.
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { TemplateElement, defineElement, html, spreadAttributes } from '@webtides/element-js';
|
|
2
|
+
import { define as defineTooltip } from '../tooltip/tooltip.js';
|
|
3
|
+
import { activeElement, focusableElements } from '../../utils/focus.js';
|
|
4
|
+
import { hasSlotted } from '../../utils/slots.js';
|
|
5
|
+
import style from './toolbar.style.js';
|
|
6
|
+
|
|
7
|
+
/** A control that takes text: there the left and right arrow keys, Home and End move the caret. */
|
|
8
|
+
const TEXT_ENTRY =
|
|
9
|
+
'textarea, select, [contenteditable=""], [contenteditable="true"], input:not([type="radio"], [type="checkbox"], [type="button"], [type="submit"], [type="reset"], [type="range"], [type="color"], [type="file"], [type="image"])';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A toolbar: the row of controls over a list or a view. It gives them one size and one
|
|
13
|
+
* appearance, lays them out with a gap, in lines where they do not fit into one, and with a group
|
|
14
|
+
* at the end, and makes them one stop of the Tab key: the arrow keys move between them.
|
|
15
|
+
*
|
|
16
|
+
* The controls are what the page writes into it: `el-button` (also as a toggle, and with an icon
|
|
17
|
+
* alone), `el-button-group`, `el-segmented-field`, and `el-divider` between two groups.
|
|
18
|
+
*
|
|
19
|
+
* The look is the stylesheet alone, so a server-rendered toolbar does not change when the element
|
|
20
|
+
* takes over. The script adds the keyboard, and the tooltips of the buttons with an icon alone.
|
|
21
|
+
*
|
|
22
|
+
* @element el-toolbar
|
|
23
|
+
*
|
|
24
|
+
* @slot - The controls of the toolbar, and `el-divider` elements between two groups of them.
|
|
25
|
+
* @slot end - The controls at the end of the toolbar.
|
|
26
|
+
*
|
|
27
|
+
* @csspart base - The toolbar (`role="toolbar"`): the row of the controls.
|
|
28
|
+
* @csspart end - The group at the end.
|
|
29
|
+
* @csspart tooltip - The tooltip of a button with an icon alone: an `el-tooltip`.
|
|
30
|
+
*
|
|
31
|
+
* @property {string} label - The name of the toolbar for assistive technology, "Formatting".
|
|
32
|
+
* Unset, the toolbar has none.
|
|
33
|
+
* @property {'small'|'medium'|'large'} size - The size of the controls that have none of their
|
|
34
|
+
* own. Default `'medium'`. Reflected to the `size` attribute.
|
|
35
|
+
* @property {'filled'|'outlined'|'plain'} appearance - The appearance of the buttons that have
|
|
36
|
+
* none of their own. Default `'plain'`. Reflected to the `appearance` attribute.
|
|
37
|
+
*/
|
|
38
|
+
export default class Toolbar extends TemplateElement {
|
|
39
|
+
/**
|
|
40
|
+
* The control that had the focus last: where the Tab key comes back to.
|
|
41
|
+
* @private
|
|
42
|
+
* @type {HTMLElement | undefined}
|
|
43
|
+
*/
|
|
44
|
+
_current = undefined;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether the toolbar has started in a browser, see `connected()`.
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
_started = false;
|
|
51
|
+
|
|
52
|
+
constructor() {
|
|
53
|
+
super({
|
|
54
|
+
styles: [style],
|
|
55
|
+
shadowRender: true,
|
|
56
|
+
// The tooltips are made for the buttons with a name of their own: one that comes or
|
|
57
|
+
// goes, also inside of a group, and a name that changes, ask for a new render.
|
|
58
|
+
// The filter names the attributes of the toolbar itself as well: element-js hears of
|
|
59
|
+
// them through the same observer.
|
|
60
|
+
mutationObserverOptions: {
|
|
61
|
+
childList: true,
|
|
62
|
+
subtree: true,
|
|
63
|
+
attributeFilter: ['aria-label', 'label', 'size', 'appearance'],
|
|
64
|
+
},
|
|
65
|
+
// The stylesheet selects the host by these attributes.
|
|
66
|
+
propertyOptions: {
|
|
67
|
+
size: { reflect: true },
|
|
68
|
+
appearance: { reflect: true },
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
properties() {
|
|
74
|
+
return {
|
|
75
|
+
label: '',
|
|
76
|
+
size: 'medium',
|
|
77
|
+
appearance: 'plain',
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
connected() {
|
|
82
|
+
// The tooltips come with the script: a server renders none, and the first render in the
|
|
83
|
+
// browser is the markup of the server.
|
|
84
|
+
this._started = true;
|
|
85
|
+
this.requestUpdate();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
events() {
|
|
89
|
+
return {
|
|
90
|
+
this: {
|
|
91
|
+
keydown: (event) => this._onKeydown(event),
|
|
92
|
+
focusin: (event) => this._onFocusIn(event),
|
|
93
|
+
},
|
|
94
|
+
// A template element does not render again when a child comes, goes or changes its
|
|
95
|
+
// `slot` attribute. The slot tells of all three, and the event bubbles to the base.
|
|
96
|
+
"[part~='base']": {
|
|
97
|
+
slotchange: () => this.requestUpdate(),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The controls of the toolbar that the user can move the focus to, in their order: the ones
|
|
104
|
+
* at the end last, as they are shown.
|
|
105
|
+
* @private
|
|
106
|
+
* @returns {HTMLElement[]}
|
|
107
|
+
*/
|
|
108
|
+
_controls() {
|
|
109
|
+
const controls = focusableElements(this);
|
|
110
|
+
const atEnd = (control) => {
|
|
111
|
+
let element = control;
|
|
112
|
+
// Out of the shadow root of a component, up to the child of the toolbar.
|
|
113
|
+
while (element && element.parentNode !== this) element = element.parentNode?.host ?? element.parentNode;
|
|
114
|
+
return element?.getAttribute?.('slot') === 'end';
|
|
115
|
+
};
|
|
116
|
+
return [...controls.filter((control) => !atEnd(control)), ...controls.filter(atEnd)];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The arrow keys move the focus from control to control and around the ends, Home and End go
|
|
121
|
+
* to the first and the last one. The Tab key leaves the toolbar.
|
|
122
|
+
* @private
|
|
123
|
+
* @param {KeyboardEvent} event
|
|
124
|
+
*/
|
|
125
|
+
_onKeydown(event) {
|
|
126
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.isComposing) return;
|
|
127
|
+
|
|
128
|
+
const controls = this._controls();
|
|
129
|
+
const current = activeElement();
|
|
130
|
+
const index = controls.indexOf(current);
|
|
131
|
+
if (index === -1) return;
|
|
132
|
+
|
|
133
|
+
if (event.key === 'Tab') {
|
|
134
|
+
this._letTabLeave(controls, current);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// In a control that takes text the keys move the caret.
|
|
139
|
+
if (current.matches(TEXT_ENTRY)) return;
|
|
140
|
+
|
|
141
|
+
const backwards = getComputedStyle(this).direction === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
|
|
142
|
+
const forwards = backwards === 'ArrowLeft' ? 'ArrowRight' : 'ArrowLeft';
|
|
143
|
+
const targets = {
|
|
144
|
+
[backwards]: () => controls[(index - 1 + controls.length) % controls.length],
|
|
145
|
+
[forwards]: () => controls[(index + 1) % controls.length],
|
|
146
|
+
Home: () => controls[0],
|
|
147
|
+
End: () => controls[controls.length - 1],
|
|
148
|
+
};
|
|
149
|
+
if (!Object.hasOwn(targets, event.key)) return;
|
|
150
|
+
|
|
151
|
+
// The keys would scroll the page, and move the choice of a group of radios: in a toolbar
|
|
152
|
+
// they move the focus, and Space chooses.
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
targets[event.key]().focus();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Lets the Tab key leave the toolbar: the browser takes the key once every listener has had
|
|
159
|
+
* it, and goes to the next stop. Until then the other controls of the toolbar are none.
|
|
160
|
+
* @private
|
|
161
|
+
* @param {HTMLElement[]} controls
|
|
162
|
+
* @param {Element} current
|
|
163
|
+
*/
|
|
164
|
+
_letTabLeave(controls, current) {
|
|
165
|
+
const others = controls.filter((control) => control !== current && !control.inert);
|
|
166
|
+
for (const control of others) control.inert = true;
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
for (const control of others) control.inert = false;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The Tab key comes into the toolbar at the control that had the focus last, and at the first
|
|
174
|
+
* one before any had it. A pointer puts the focus where it is pressed.
|
|
175
|
+
* @private
|
|
176
|
+
* @param {FocusEvent} event
|
|
177
|
+
*/
|
|
178
|
+
_onFocusIn(event) {
|
|
179
|
+
const entered = activeElement();
|
|
180
|
+
const controls = this._controls();
|
|
181
|
+
if (!controls.includes(entered)) return;
|
|
182
|
+
|
|
183
|
+
const cameFromOutside = !event.relatedTarget || !this.contains(event.relatedTarget);
|
|
184
|
+
const remembered = controls.includes(this._current) ? this._current : controls[0];
|
|
185
|
+
if (cameFromOutside && entered !== remembered && entered.matches(':focus-visible')) {
|
|
186
|
+
remembered.focus();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this._current = entered;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The buttons that show an icon alone: they have a name of their own for assistive technology
|
|
194
|
+
* (`aria-label`), which their content does not show. None before the toolbar has started: on
|
|
195
|
+
* a server there is no pointer to show a tooltip to.
|
|
196
|
+
* @private
|
|
197
|
+
* @returns {Element[]}
|
|
198
|
+
*/
|
|
199
|
+
_namedButtons() {
|
|
200
|
+
if (!this._started) return [];
|
|
201
|
+
return [...this.querySelectorAll('el-button[aria-label]')].filter((button) =>
|
|
202
|
+
button.getAttribute('aria-label'),
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
template() {
|
|
207
|
+
// The role is inside of the shadow root, not on the element: it is part of the
|
|
208
|
+
// server-rendered markup that way, and needs no script.
|
|
209
|
+
return html`
|
|
210
|
+
<div
|
|
211
|
+
part="base"
|
|
212
|
+
class="toolbar"
|
|
213
|
+
role="toolbar"
|
|
214
|
+
${spreadAttributes({ 'aria-label': this.label || undefined })}
|
|
215
|
+
>
|
|
216
|
+
<slot></slot>
|
|
217
|
+
<div part="end" class="end" ?hidden="${!hasSlotted(this, 'end')}"><slot name="end"></slot></div>
|
|
218
|
+
</div>
|
|
219
|
+
${this._namedButtons().map(
|
|
220
|
+
(button) =>
|
|
221
|
+
html`<el-tooltip part="tooltip" type="label" placement="bottom" .anchor="${button}"
|
|
222
|
+
>${button.getAttribute('aria-label')}</el-tooltip
|
|
223
|
+
>`,
|
|
224
|
+
)}
|
|
225
|
+
`;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function define() {
|
|
230
|
+
// The tooltips of the buttons with an icon alone.
|
|
231
|
+
defineTooltip();
|
|
232
|
+
defineElement('el-toolbar', Toolbar);
|
|
233
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Toolbar
|
|
2
|
+
|
|
3
|
+
`toolbar` is the row of controls over a list or a view: reply, archive, a toggle, a choice of the layout. It gives its controls one size and one appearance, lays them out with a gap and a group at the end, and makes them one stop of the Tab key, with the arrow keys between them.
|
|
4
|
+
|
|
5
|
+
## How to use
|
|
6
|
+
|
|
7
|
+
#### Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i --save @webtides/element-library
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### Use
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import '@webtides/element-library/toolbar/define';
|
|
17
|
+
import '@webtides/element-library/button/define';
|
|
18
|
+
import '@webtides/element-library/divider/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<el-toolbar label="Message" size="small">
|
|
23
|
+
<el-button circle="true" aria-label="Reply"><svg aria-hidden="true">…</svg></el-button>
|
|
24
|
+
<el-button circle="true" aria-label="Forward"><svg aria-hidden="true">…</svg></el-button>
|
|
25
|
+
<el-divider orientation="vertical"></el-divider>
|
|
26
|
+
<el-button toggle="true" circle="true" aria-label="Starred"><svg aria-hidden="true">…</svg></el-button>
|
|
27
|
+
<el-segmented-field
|
|
28
|
+
name="view"
|
|
29
|
+
label="View"
|
|
30
|
+
label-screen-reader-only="true"
|
|
31
|
+
value="list"
|
|
32
|
+
options='[{"value":"list","label":"List"},{"value":"board","label":"Board"}]'
|
|
33
|
+
></el-segmented-field>
|
|
34
|
+
<el-button slot="end" variant="brand" appearance="filled">Send</el-button>
|
|
35
|
+
</el-toolbar>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
> Boolean attributes are passed as strings (`circle="true"`), matching the rest of the library.
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
#### Properties/Attributes
|
|
43
|
+
|
|
44
|
+
| Name | Type | Default | Description |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| `label` | `string` | `''` | The name of the toolbar for assistive technology. Unset, the toolbar has none. |
|
|
47
|
+
| `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | The size of the controls that have none of their own. Reflected to the `size` attribute. |
|
|
48
|
+
| `appearance` | `'filled' \| 'outlined' \| 'plain'` | `'plain'` | The appearance of the buttons that have none of their own. Reflected to the `appearance` attribute. |
|
|
49
|
+
|
|
50
|
+
#### Methods
|
|
51
|
+
|
|
52
|
+
_None._
|
|
53
|
+
|
|
54
|
+
#### Events
|
|
55
|
+
|
|
56
|
+
_None._
|
|
57
|
+
|
|
58
|
+
#### Slots
|
|
59
|
+
|
|
60
|
+
| Name | Description |
|
|
61
|
+
| --------- | -------------------------------------------------------------------------- |
|
|
62
|
+
| (default) | The controls of the toolbar, and `el-divider` elements between two groups. |
|
|
63
|
+
| `end` | The controls at the end of the toolbar. |
|
|
64
|
+
|
|
65
|
+
#### CSS Parts
|
|
66
|
+
|
|
67
|
+
| Name | Description |
|
|
68
|
+
| --------- | ------------------------------------------------------------ |
|
|
69
|
+
| `base` | The toolbar (`role="toolbar"`): the row of the controls. |
|
|
70
|
+
| `end` | The group at the end. |
|
|
71
|
+
| `tooltip` | The tooltip of a button with an icon alone: an `el-tooltip`. |
|
|
72
|
+
|
|
73
|
+
#### CSS Custom Properties
|
|
74
|
+
|
|
75
|
+
Reads `--el-space-2` for the gap between two controls (`0.5rem` without a theme). The controls read the tokens they read anywhere.
|
|
76
|
+
|
|
77
|
+
## One size and one appearance
|
|
78
|
+
|
|
79
|
+
`size` and `appearance` of the toolbar are the size and the appearance of its controls: of every `el-button` in it, also inside of an `el-button-group` or as the anchor of an `el-popover`, and `size` of an `el-segmented-field` as well. A toolbar without the attributes has controls of the medium size and plain buttons.
|
|
80
|
+
|
|
81
|
+
A control that names its own keeps it. That goes for the defaults as well: `appearance="filled"` on a button keeps the button filled in a plain toolbar, and `size="medium"` keeps it medium in a small one.
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<el-toolbar label="Message" size="small">
|
|
85
|
+
<el-button>Reply</el-button>
|
|
86
|
+
<!-- small, plain -->
|
|
87
|
+
<el-button variant="brand" appearance="filled">Send</el-button>
|
|
88
|
+
<!-- small, filled -->
|
|
89
|
+
</el-toolbar>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
How it works, and what follows from it:
|
|
93
|
+
|
|
94
|
+
- The toolbar does not write to its controls. It says its size and its appearance in CSS properties that are inherited, and a control reads them in its own stylesheet. The `size` and the `appearance` attribute of a button in a toolbar still say `medium` and `filled`, the defaults: a selector like `el-button[appearance='plain']` does not match it.
|
|
95
|
+
- A control counts as having its own when the page wrote the attribute, when a script set the property before the control was connected, or when either changes later. Setting a property to the value it already has changes nothing: to keep a default after the control is connected, write the attribute.
|
|
96
|
+
- A plain button of a toolbar answers to the pointer with a tint of its text colour, as an outlined button does. A button with `appearance="plain"` of its own is underlined under the pointer, as outside of a toolbar.
|
|
97
|
+
- Other controls of the library keep their own size in a toolbar.
|
|
98
|
+
|
|
99
|
+
## Groups
|
|
100
|
+
|
|
101
|
+
- An `el-divider` with `orientation="vertical"` stands between two groups of controls. It is a separator to assistive technology, and the arrow keys pass it.
|
|
102
|
+
- An [`el-button-group`](../button-group/button-group.readme.md) is a group of buttons that touch, with a name of its own.
|
|
103
|
+
- What is slotted into `end` stands at the end of the toolbar: all the room that is left is in front of it.
|
|
104
|
+
|
|
105
|
+
Start and end follow the reading direction: in a text that runs from right to left the first control is at the right, and the group at the end at the left.
|
|
106
|
+
|
|
107
|
+
## A button with an icon alone
|
|
108
|
+
|
|
109
|
+
Such a button is an `el-button` with `circle="true"`, which makes it as wide as it is high, and an `aria-label`, which is its name.
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<el-button circle="true" aria-label="Archive"><svg aria-hidden="true">…</svg></el-button>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The toolbar shows that name as a tooltip, for the pointer and for the focus of the keyboard: every `el-button` with an `aria-label` in the toolbar gets one, below the button. The tooltip is for the eye. A screen reader has the name already and does not read it twice.
|
|
116
|
+
|
|
117
|
+
The tooltips come with the script of the toolbar. They are `el-tooltip` elements in its shadow root (`::part(tooltip)`), so nothing is added to what the page wrote into the toolbar. The toolbar imports the tooltip, and with it `@floating-ui/dom`.
|
|
118
|
+
|
|
119
|
+
## More controls than the width takes
|
|
120
|
+
|
|
121
|
+
The toolbar breaks into a second line where its controls do not fit into one. Every control stays in reach of the pointer and of the arrow keys, and the toolbar is never wider than its place. The group at the end still ends the toolbar, in a line of its own if it has to.
|
|
122
|
+
|
|
123
|
+
## Keyboard
|
|
124
|
+
|
|
125
|
+
The toolbar is one stop of the Tab key, as the WAI-ARIA toolbar pattern says.
|
|
126
|
+
|
|
127
|
+
| Key | What it does |
|
|
128
|
+
| --- | --- |
|
|
129
|
+
| Tab | Moves the focus into the toolbar: to the control that had it last, or to the first one. From inside, it leaves the toolbar. |
|
|
130
|
+
| Right arrow, left arrow | Moves the focus to the next and the previous control, and around the ends. The other way round in a text that runs from right to left. |
|
|
131
|
+
| Home, End | Moves the focus to the first and the last control. |
|
|
132
|
+
|
|
133
|
+
- Disabled controls are passed.
|
|
134
|
+
- The options of an `el-segmented-field` are controls of the toolbar: the left and right arrow keys go through them without choosing. Space chooses the option with the focus, and the up and down arrow keys move the choice, as in a group of radios outside of a toolbar.
|
|
135
|
+
- In a control that takes text (an input, a select) the arrow keys, Home and End belong to that control. The Tab key leaves the toolbar from there as well.
|
|
136
|
+
- A click puts the focus where the pointer is.
|
|
137
|
+
|
|
138
|
+
Before the script has run, every control is a stop of the Tab key.
|
|
139
|
+
|
|
140
|
+
## Accessibility
|
|
141
|
+
|
|
142
|
+
- The toolbar has `role="toolbar"`. Give it a `label`: a screen reader reads it when its user enters the toolbar, and a page with two toolbars needs it to tell them apart.
|
|
143
|
+
- Use a toolbar for three controls or more. Two buttons beside each other need none.
|
|
144
|
+
- On a touch screen (`@media (any-pointer: coarse)`) every `el-button` and every option of an `el-segmented-field` is at least `--el-touch-target` high and wide, in a small toolbar as well.
|
|
145
|
+
- An `el-segmented-field` in a toolbar needs a `label` as every field does. `label-screen-reader-only="true"` keeps it as the name of the group and does not show it.
|
|
146
|
+
|
|
147
|
+
## Server-side rendering
|
|
148
|
+
|
|
149
|
+
The toolbar, its name and its layout are part of the server-rendered markup (Declarative Shadow DOM), and the size and the appearance of the controls are their stylesheets reading the toolbar. A server-rendered toolbar looks the same before and after the elements take over. The script adds the keyboard and the tooltips.
|
|
150
|
+
|
|
151
|
+
The `hidden` attribute hides the toolbar.
|
|
152
|
+
|
|
153
|
+
## What it is not
|
|
154
|
+
|
|
155
|
+
- No toolbar the user arranges, and no formatting toolbar of an editor for rich text.
|
|
156
|
+
- No menu for the controls that do not fit: they go into a second line.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import hostStyle from '../../styles/host.style.js';
|
|
2
|
+
import { sizeContextStyle } from '../../styles/size.style.js';
|
|
3
|
+
import { appearanceContextStyle } from '../../styles/appearance.style.js';
|
|
4
|
+
|
|
5
|
+
const css = String.raw;
|
|
6
|
+
|
|
7
|
+
const style = css`
|
|
8
|
+
:host {
|
|
9
|
+
display: block;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* A row with a gap, which breaks into a second line where its controls do not fit: every
|
|
13
|
+
control stays in reach, and the toolbar is never wider than its place. The gaps follow the
|
|
14
|
+
reading direction, as the order of the controls does. */
|
|
15
|
+
.toolbar {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-wrap: wrap;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: var(--el-space-2, 0.5rem);
|
|
20
|
+
min-width: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* The group at the end: all the room that is left is in front of it. In a line of its own it
|
|
24
|
+
still stands at the end. */
|
|
25
|
+
.end {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: var(--el-space-2, 0.5rem);
|
|
30
|
+
margin-inline-start: auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* The tooltips of the buttons with an icon alone take no room. A tooltip hides itself while
|
|
34
|
+
it is closed, but with a stylesheet it only has once it has rendered: for a frame its text
|
|
35
|
+
would be a line under the toolbar. */
|
|
36
|
+
el-tooltip:not(:popover-open) {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* A divider between two groups is as high as a control, not as the whole row of a toolbar
|
|
41
|
+
that has broken into lines. */
|
|
42
|
+
::slotted(el-divider) {
|
|
43
|
+
align-self: center;
|
|
44
|
+
height: 1.5em;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
// Plain is the appearance of a toolbar that names none.
|
|
49
|
+
export default [hostStyle(), sizeContextStyle(), appearanceContextStyle(':host', 'plain'), style].join('\n');
|
|
@@ -12,6 +12,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
12
12
|
|
|
13
13
|
## Unreleased
|
|
14
14
|
|
|
15
|
+
## [0.4.0] - 2026-11-27
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `anchor`: the anchor as an element, for one that an id cannot name: an element in another tree than the tooltip, the light DOM of a component whose shadow root the tooltip is in. A property only, and it comes before `for`. ([#194](https://github.com/webtides/element-library/issues/194))
|
|
20
|
+
- `type` (`'description'` by default, or `'label'`): a tooltip of the type `label` shows the name its anchor already has, of a button with an icon alone for example. It does not describe the anchor (`aria-describedby` is not written) and is hidden from assistive technology, which would read the name twice. ([#194](https://github.com/webtides/element-library/issues/194))
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- In Safari a tooltip could stay shown after its anchor had lost the pointer or the focus: `open` was `false`, and the tooltip was still there. The tooltip read its own state back (`states.has('open')`) to know whether there was something to close, and WebKit forgets what was added to the states of an element a moment later, while `:state(open)` still matches. The tooltip keeps a field of its own now.
|
|
25
|
+
|
|
15
26
|
## [0.3.0] - 2026-11-17
|
|
16
27
|
|
|
17
28
|
### Added
|