@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.
Files changed (252) hide show
  1. package/CHANGELOG.md +300 -0
  2. package/README.md +72 -56
  3. package/all.js +16 -0
  4. package/catalog.js +17 -1
  5. package/custom-elements.json +15912 -10065
  6. package/package.json +1 -1
  7. package/src/components/accordion/accordion.changelog.md +11 -0
  8. package/src/components/accordion/accordion.js +15 -3
  9. package/src/components/accordion/accordion.readme.md +27 -1
  10. package/src/components/accordion/accordion.style.js +19 -0
  11. package/src/components/app-bar/app-bar.changelog.md +24 -0
  12. package/src/components/app-bar/app-bar.define.js +3 -0
  13. package/src/components/app-bar/app-bar.js +91 -0
  14. package/src/components/app-bar/app-bar.readme.md +130 -0
  15. package/src/components/app-bar/app-bar.style.js +103 -0
  16. package/src/components/app-frame/app-frame.changelog.md +59 -0
  17. package/src/components/app-frame/app-frame.define.js +3 -0
  18. package/src/components/app-frame/app-frame.events.js +6 -0
  19. package/src/components/app-frame/app-frame.js +1085 -0
  20. package/src/components/app-frame/app-frame.readme.md +425 -0
  21. package/src/components/app-frame/app-frame.style.js +534 -0
  22. package/src/components/button/button.changelog.md +21 -0
  23. package/src/components/button/button.events.js +3 -0
  24. package/src/components/button/button.js +145 -3
  25. package/src/components/button/button.readme.md +72 -4
  26. package/src/components/button/button.style.js +167 -8
  27. package/src/components/button-group/button-group.changelog.md +10 -0
  28. package/src/components/button-group/button-group.readme.md +2 -0
  29. package/src/components/button-group/button-group.style.js +6 -2
  30. package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +6 -0
  31. package/src/components/checkbox-group-field/checkbox-group-field.js +7 -2
  32. package/src/components/checkbox-group-field/checkbox-group-field.readme.md +23 -1
  33. package/src/components/combobox-field/combobox-field.changelog.md +6 -0
  34. package/src/components/combobox-field/combobox-field.readme.md +8 -0
  35. package/src/components/combobox-field/combobox-field.style.js +2 -0
  36. package/src/components/date-field/date-field.changelog.md +6 -0
  37. package/src/components/date-field/date-field.readme.md +10 -0
  38. package/src/components/date-field/date-field.style.js +8 -3
  39. package/src/components/description-list/description-list.changelog.md +42 -0
  40. package/src/components/description-list/description-list.define.js +3 -0
  41. package/src/components/description-list/description-list.js +49 -0
  42. package/src/components/description-list/description-list.readme.md +161 -0
  43. package/src/components/description-list/description-list.style.js +169 -0
  44. package/src/components/dialog/dialog.changelog.md +7 -0
  45. package/src/components/dialog/dialog.readme.md +5 -0
  46. package/src/components/dialog/dialog.style.js +17 -2
  47. package/src/components/divider/divider.changelog.md +6 -0
  48. package/src/components/divider/divider.readme.md +1 -1
  49. package/src/components/divider/divider.style.js +6 -0
  50. package/src/components/drawer/drawer.changelog.md +7 -0
  51. package/src/components/drawer/drawer.readme.md +7 -6
  52. package/src/components/drawer/drawer.style.js +35 -2
  53. package/src/components/dropdown/dropdown.readme.md +6 -1
  54. package/src/components/file-field/file-field.changelog.md +8 -0
  55. package/src/components/file-field/file-field.js +135 -5
  56. package/src/components/file-field/file-field.readme.md +35 -6
  57. package/src/components/file-field/file-field.style.js +71 -0
  58. package/src/components/form-field/form-field.js +1 -1
  59. package/src/components/input-field/input-field.changelog.md +10 -0
  60. package/src/components/input-field/input-field.js +192 -14
  61. package/src/components/input-field/input-field.readme.md +88 -2
  62. package/src/components/input-field/input-field.style.js +2 -0
  63. package/src/components/list/list.changelog.md +30 -0
  64. package/src/components/list/list.define.js +3 -0
  65. package/src/components/list/list.js +68 -0
  66. package/src/components/list/list.readme.md +123 -0
  67. package/src/components/list/list.style.js +56 -0
  68. package/src/components/list-item/list-item.changelog.md +40 -0
  69. package/src/components/list-item/list-item.define.js +3 -0
  70. package/src/components/list-item/list-item.js +130 -0
  71. package/src/components/list-item/list-item.readme.md +144 -0
  72. package/src/components/list-item/list-item.style.js +246 -0
  73. package/src/components/menu/menu.changelog.md +44 -0
  74. package/src/components/menu/menu.define.js +3 -0
  75. package/src/components/menu/menu.events.js +5 -0
  76. package/src/components/menu/menu.js +793 -0
  77. package/src/components/menu/menu.readme.md +313 -0
  78. package/src/components/menu/menu.style.js +59 -0
  79. package/src/components/menu-group/menu-group.changelog.md +20 -0
  80. package/src/components/menu-group/menu-group.define.js +3 -0
  81. package/src/components/menu-group/menu-group.js +44 -0
  82. package/src/components/menu-group/menu-group.readme.md +74 -0
  83. package/src/components/menu-group/menu-group.style.js +38 -0
  84. package/src/components/menu-item/menu-item.changelog.md +32 -0
  85. package/src/components/menu-item/menu-item.define.js +3 -0
  86. package/src/components/menu-item/menu-item.js +168 -0
  87. package/src/components/menu-item/menu-item.readme.md +132 -0
  88. package/src/components/menu-item/menu-item.style.js +117 -0
  89. package/src/components/nav/nav.changelog.md +35 -0
  90. package/src/components/nav/nav.define.js +3 -0
  91. package/src/components/nav/nav.js +212 -0
  92. package/src/components/nav/nav.readme.md +248 -0
  93. package/src/components/nav/nav.style.js +269 -0
  94. package/src/components/nav-item/nav-item.changelog.md +25 -0
  95. package/src/components/nav-item/nav-item.define.js +3 -0
  96. package/src/components/nav-item/nav-item.js +75 -0
  97. package/src/components/nav-item/nav-item.readme.md +111 -0
  98. package/src/components/nav-item/nav-item.style.js +159 -0
  99. package/src/components/otp-field/otp-field.changelog.md +6 -0
  100. package/src/components/otp-field/otp-field.readme.md +8 -0
  101. package/src/components/otp-field/otp-field.style.js +8 -3
  102. package/src/components/pagination/pagination.changelog.md +8 -0
  103. package/src/components/pagination/pagination.js +123 -49
  104. package/src/components/pagination/pagination.readme.md +24 -6
  105. package/src/components/pagination/pagination.style.js +11 -1
  106. package/src/components/password-field/password-field.changelog.md +7 -0
  107. package/src/components/password-field/password-field.readme.md +11 -1
  108. package/src/components/password-field/password-field.style.js +2 -0
  109. package/src/components/popover/popover.changelog.md +6 -0
  110. package/src/components/popover/popover.style.js +1 -0
  111. package/src/components/radio-field/radio-field.changelog.md +6 -0
  112. package/src/components/radio-field/radio-field.js +7 -2
  113. package/src/components/radio-field/radio-field.readme.md +23 -1
  114. package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
  115. package/src/components/scroll-to-top/scroll-to-top.js +16 -12
  116. package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
  117. package/src/components/segmented-field/segmented-field.changelog.md +27 -0
  118. package/src/components/segmented-field/segmented-field.define.js +3 -0
  119. package/src/components/segmented-field/segmented-field.js +175 -0
  120. package/src/components/segmented-field/segmented-field.readme.md +140 -0
  121. package/src/components/segmented-field/segmented-field.style.js +193 -0
  122. package/src/components/splitter/splitter.changelog.md +24 -0
  123. package/src/components/splitter/splitter.define.js +3 -0
  124. package/src/components/splitter/splitter.events.js +4 -0
  125. package/src/components/splitter/splitter.js +237 -0
  126. package/src/components/splitter/splitter.readme.md +164 -0
  127. package/src/components/splitter/splitter.style.js +100 -0
  128. package/src/components/status-bar/status-bar.changelog.md +25 -0
  129. package/src/components/status-bar/status-bar.define.js +3 -0
  130. package/src/components/status-bar/status-bar.js +74 -0
  131. package/src/components/status-bar/status-bar.readme.md +139 -0
  132. package/src/components/status-bar/status-bar.style.js +122 -0
  133. package/src/components/tab-group/tab-group.changelog.md +7 -0
  134. package/src/components/tab-group/tab-group.js +30 -9
  135. package/src/components/tab-group/tab-group.readme.md +14 -0
  136. package/src/components/textarea-field/textarea-field.changelog.md +6 -0
  137. package/src/components/textarea-field/textarea-field.js +14 -1
  138. package/src/components/textarea-field/textarea-field.readme.md +23 -1
  139. package/src/components/toast/toast.changelog.md +6 -0
  140. package/src/components/toast/toast.readme.md +5 -3
  141. package/src/components/toast/toast.style.js +22 -6
  142. package/src/components/toolbar/toolbar.changelog.md +24 -0
  143. package/src/components/toolbar/toolbar.define.js +3 -0
  144. package/src/components/toolbar/toolbar.js +233 -0
  145. package/src/components/toolbar/toolbar.readme.md +156 -0
  146. package/src/components/toolbar/toolbar.style.js +49 -0
  147. package/src/components/tooltip/tooltip.changelog.md +11 -0
  148. package/src/components/tooltip/tooltip.js +51 -4
  149. package/src/components/tooltip/tooltip.readme.md +26 -1
  150. package/src/components/tree/tree.changelog.md +23 -0
  151. package/src/components/tree/tree.define.js +3 -0
  152. package/src/components/tree/tree.js +138 -0
  153. package/src/components/tree/tree.readme.md +119 -0
  154. package/src/components/tree/tree.style.js +16 -0
  155. package/src/components/tree-item/tree-item.changelog.md +23 -0
  156. package/src/components/tree-item/tree-item.define.js +3 -0
  157. package/src/components/tree-item/tree-item.events.js +3 -0
  158. package/src/components/tree-item/tree-item.js +246 -0
  159. package/src/components/tree-item/tree-item.readme.md +128 -0
  160. package/src/components/tree-item/tree-item.style.js +226 -0
  161. package/src/styles/appearance.style.js +47 -0
  162. package/src/styles/choice-group.style.js +27 -1
  163. package/src/styles/input-control.style.js +87 -0
  164. package/src/styles/modal.style.js +14 -1
  165. package/src/styles/native.css +100 -0
  166. package/src/styles/size.style.js +41 -0
  167. package/src/utils/floating.js +15 -1
  168. package/src/utils/focus.js +69 -0
  169. package/src/utils/options.js +35 -0
  170. package/src/utils/scroll.js +24 -0
  171. package/src/utils/text-entry-attributes.js +13 -0
  172. package/types/all.d.ts +16 -0
  173. package/types/src/components/accordion/accordion.d.ts +3 -1
  174. package/types/src/components/app-bar/app-bar.d.ts +43 -0
  175. package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
  176. package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
  177. package/types/src/components/app-frame/app-frame.d.ts +497 -0
  178. package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
  179. package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
  180. package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
  181. package/types/src/components/button/button.d.ts +61 -0
  182. package/types/src/components/button/button.events.d.ts +4 -0
  183. package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +5 -2
  184. package/types/src/components/combobox-field/combobox-field.d.ts +10 -0
  185. package/types/src/components/date-field/date-field.d.ts +10 -0
  186. package/types/src/components/description-list/description-list.d.ts +34 -0
  187. package/types/src/components/description-list/description-list.define.d.ts +1 -0
  188. package/types/src/components/description-list/description-list.style.d.ts +2 -0
  189. package/types/src/components/file-field/file-field.d.ts +68 -3
  190. package/types/src/components/form-field/form-field.d.ts +1 -1
  191. package/types/src/components/input-field/input-field.d.ts +99 -0
  192. package/types/src/components/list/list.d.ts +41 -0
  193. package/types/src/components/list/list.define.d.ts +1 -0
  194. package/types/src/components/list/list.style.d.ts +2 -0
  195. package/types/src/components/list-item/list-item.d.ts +64 -0
  196. package/types/src/components/list-item/list-item.define.d.ts +1 -0
  197. package/types/src/components/list-item/list-item.style.d.ts +2 -0
  198. package/types/src/components/menu/menu.d.ts +362 -0
  199. package/types/src/components/menu/menu.define.d.ts +1 -0
  200. package/types/src/components/menu/menu.events.d.ts +6 -0
  201. package/types/src/components/menu/menu.style.d.ts +2 -0
  202. package/types/src/components/menu-group/menu-group.d.ts +24 -0
  203. package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
  204. package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
  205. package/types/src/components/menu-item/menu-item.d.ts +80 -0
  206. package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
  207. package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
  208. package/types/src/components/nav/nav.d.ts +103 -0
  209. package/types/src/components/nav/nav.define.d.ts +1 -0
  210. package/types/src/components/nav/nav.style.d.ts +2 -0
  211. package/types/src/components/nav-item/nav-item.d.ts +39 -0
  212. package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
  213. package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
  214. package/types/src/components/otp-field/otp-field.d.ts +10 -0
  215. package/types/src/components/pagination/pagination.d.ts +31 -2
  216. package/types/src/components/password-field/password-field.d.ts +10 -0
  217. package/types/src/components/radio-field/radio-field.d.ts +5 -2
  218. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
  219. package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
  220. package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
  221. package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
  222. package/types/src/components/splitter/splitter.d.ts +127 -0
  223. package/types/src/components/splitter/splitter.define.d.ts +1 -0
  224. package/types/src/components/splitter/splitter.events.d.ts +5 -0
  225. package/types/src/components/splitter/splitter.style.d.ts +2 -0
  226. package/types/src/components/status-bar/status-bar.d.ts +44 -0
  227. package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
  228. package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
  229. package/types/src/components/tab-group/tab-group.d.ts +17 -0
  230. package/types/src/components/textarea-field/textarea-field.d.ts +7 -0
  231. package/types/src/components/toolbar/toolbar.d.ts +96 -0
  232. package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
  233. package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
  234. package/types/src/components/tooltip/tooltip.d.ts +26 -0
  235. package/types/src/components/tree/tree.d.ts +62 -0
  236. package/types/src/components/tree/tree.define.d.ts +1 -0
  237. package/types/src/components/tree/tree.style.d.ts +2 -0
  238. package/types/src/components/tree-item/tree-item.d.ts +106 -0
  239. package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
  240. package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
  241. package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
  242. package/types/src/styles/appearance.style.d.ts +31 -0
  243. package/types/src/styles/choice-group.style.d.ts +1 -1
  244. package/types/src/styles/input-control.style.d.ts +15 -0
  245. package/types/src/styles/modal.style.d.ts +5 -0
  246. package/types/src/styles/size.style.d.ts +24 -0
  247. package/types/src/utils/floating.d.ts +11 -0
  248. package/types/src/utils/focus.d.ts +25 -0
  249. package/types/src/utils/options.d.ts +17 -0
  250. package/types/src/utils/scroll.d.ts +11 -0
  251. package/types/src/utils/text-entry-attributes.d.ts +10 -0
  252. package/web-types.json +2935 -308
@@ -0,0 +1,313 @@
1
+ # Menu
2
+
3
+ `menu` is a menu button: a button that opens a list of actions. "Edit, Duplicate, Delete" for a row of a table, the account in a header, "More" at the end of a toolbar. The button is what the page puts into the `trigger` slot, and the actions are [`el-menu-item`](../menu-item/menu-item.readme.md) elements.
4
+
5
+ A screen reader announces it as a menu, the keyboard moves through its entries, and its panel floats: it is in the top layer of the browser, so nothing clips it and it moves nothing on the page.
6
+
7
+ ## How to use
8
+
9
+ #### Install
10
+
11
+ ```sh
12
+ npm i --save @webtides/element-library
13
+ ```
14
+
15
+ #### Use
16
+
17
+ ```js
18
+ import '@webtides/element-library/menu/define';
19
+ import '@webtides/element-library/menu-item/define';
20
+ ```
21
+
22
+ ```html
23
+ <el-menu>
24
+ <el-button slot="trigger" caret="true">More</el-button>
25
+ <el-menu-item value="edit">Edit</el-menu-item>
26
+ <el-menu-item value="duplicate">Duplicate</el-menu-item>
27
+ <el-menu-item value="delete" variant="danger">Delete</el-menu-item>
28
+ </el-menu>
29
+ ```
30
+
31
+ ```js
32
+ document.querySelector('el-menu').addEventListener('menu-select', (event) => {
33
+ console.log(event.detail.value); // 'edit'
34
+ });
35
+ ```
36
+
37
+ > Boolean attributes are passed as strings (`open="true"`), matching the rest of the library.
38
+
39
+ ## API
40
+
41
+ #### Properties/Attributes
42
+
43
+ | Name | Type | Default | Description |
44
+ | --- | --- | --- | --- |
45
+ | `open` | `boolean` | `false` | Whether the menu is shown. Reflected to the `open` attribute. |
46
+ | `label` | `string` | `''` | The name of the menu for assistive technology. Without one the menu has the name of its button. |
47
+ | `placement` | `string` | `'bottom-start'` | The side of the button the menu is placed at: `top`, `bottom`, `left` or `right`, each also with `-start` or `-end`. |
48
+ | `distance` | `number` | `4` | The gap between the button and the menu, in pixels. |
49
+
50
+ #### Methods
51
+
52
+ | Name | Description |
53
+ | --- | --- |
54
+ | `show()` | Opens the menu, with the focus on its first entry. |
55
+ | `hide()` | Closes the menu. |
56
+ | `toggle()` | Opens the menu when it is closed, and closes it when open. |
57
+ | `showAt(place, opener?)` | Opens the menu somewhere else than at its own button: at an element of the page, or at a point `{ x, y }` of the viewport. `opener` is what it is opened for. Called with the click of a press on the element the menu is open at, it closes the menu. |
58
+
59
+ #### Read-only properties
60
+
61
+ | Name | Type | Description |
62
+ | --- | --- | --- |
63
+ | `opener` | `Element \| undefined` | What the menu is open for: the row or the button of `showAt()`, or its own button. Nothing while it is closed. |
64
+
65
+ #### Events
66
+
67
+ | Name | Detail | Description |
68
+ | --- | --- | --- |
69
+ | `menu-select` | `{ item: HTMLElement, value: string, opener: Element }` | Fired when the user has chosen an entry: the `el-menu-item`, its `value`, and what the menu was opened for. The menu closes after it. |
70
+ | `menu-show` | | Fired when the menu has opened. |
71
+ | `menu-hide` | | Fired when the menu has closed. |
72
+
73
+ #### Slots
74
+
75
+ | Name | Description |
76
+ | --- | --- |
77
+ | (default) | The entries: `el-menu-item` elements, in `el-menu-group` elements where they are divided into groups. An `el-divider` is a line between two of them. |
78
+ | `trigger` | The button that opens the menu. A menu that is opened with `showAt()` alone needs none. |
79
+
80
+ #### CSS Parts
81
+
82
+ | Name | Description |
83
+ | --------- | ------------------------------------------------------------------------------------ |
84
+ | `trigger` | Forwarded onto the `trigger` slot. |
85
+ | `panel` | The floating panel, which is the menu: background, border, radius, elevation, width. |
86
+
87
+ #### CSS States
88
+
89
+ | Name | Description |
90
+ | ------ | -------------------------------------------------------------- |
91
+ | `open` | Set while the menu is shown. Style with `el-menu:state(open)`. |
92
+
93
+ #### CSS Custom Properties
94
+
95
+ | Name | Default | Description |
96
+ | --------------------- | ------- | ------------------------------- |
97
+ | `--el-menu-min-width` | `10rem` | The least width of the menu. |
98
+ | `--el-menu-max-width` | `20rem` | The greatest width of the menu. |
99
+
100
+ Reads `--el-color-bg` and `--el-color-fg` for its surface and its text (the colours of the system without a theme: a floating surface has to be readable over the page), `--el-color-border` and `--el-border-width` for its border, `--el-radius-lg`, `--el-shadow-lg`, `--el-space-1` for its padding and `--el-font-size-sm` for its text.
101
+
102
+ ## The button
103
+
104
+ Any button goes into the `trigger` slot: an `el-button`, or a native `<button>`. The menu writes two attributes onto it, which say to assistive technology what it does:
105
+
106
+ - `aria-haspopup="menu"`: it opens a menu.
107
+ - `aria-expanded`: whether the menu is open.
108
+
109
+ An `el-button` passes both on to the control inside of it. A button that shows an icon alone needs a name (`aria-label`), which is the name of the menu as well:
110
+
111
+ ```html
112
+ <el-menu>
113
+ <el-button slot="trigger" circle="true" aria-label="Actions for the invoice">
114
+ <svg aria-hidden="true">…</svg>
115
+ </el-button>
116
+ …
117
+ </el-menu>
118
+ ```
119
+
120
+ ## Keyboard
121
+
122
+ | Key | On the button | In the menu |
123
+ | ---------------- | ---------------------------------------- | ------------------------------------------------ |
124
+ | `Enter`, `Space` | Opens the menu, focus on the first entry | Chooses the entry |
125
+ | `ArrowDown` | Opens the menu, focus on the first entry | The next entry, from the last one to the first |
126
+ | `ArrowUp` | Opens the menu, focus on the last entry | The entry before, from the first one to the last |
127
+ | `Home`, `End` | | The first entry, the last entry |
128
+ | A letter | | The next entry that starts with it |
129
+ | `Escape` | | Closes the menu, focus back on the button |
130
+ | `Tab` | Moves on | Closes the menu, and the focus moves on |
131
+
132
+ The entries are no stops of the Tab key: the menu is one, through its button, and moves the focus itself. An entry that is disabled is reached by the arrow keys, so a screen reader finds it, and cannot be chosen.
133
+
134
+ #### While the focus is not on an entry
135
+
136
+ An open menu keeps the keyboard wherever the focus is: after a press beside the entries, on a row whose finger has just been lifted, before the entries are there. It hears the keys at the window for as long as it is open, before the page does.
137
+
138
+ - **`Escape` closes the menu from anywhere**, and the focus goes back to its button, or to what the menu was opened for. The key does not reach the page behind: a dialog around the menu stays open. Only a listener in the capture phase of the window that was there before the menu opened hears it first.
139
+ - **`ArrowDown` and `ArrowUp` bring the focus into the menu** from anywhere in the page, to its first and to its last entry.
140
+ - **The Tab key closes the menu from anywhere**, and the focus moves on from where it is.
141
+ - **Every other key is the one of the page** while the focus is not in the menu. A page with shortcuts of single letters asks itself whether a menu is open (`menu.open`).
142
+ - **A press beside the entries**, on the heading of a group, on a line or on the padding of the panel, leaves the focus on the entry that had it, and the arrow keys go on from there. Where no entry had it, the panel takes the focus of the press itself: it has `tabindex="-1"`, and is no stop of the Tab key.
143
+
144
+ ## Choosing an entry
145
+
146
+ Choosing is a click on an entry, with the pointer, `Enter` or `Space`. The menu fires `menu-select` and closes, and the focus is on the button again.
147
+
148
+ - `detail.item` is the `el-menu-item`, `detail.value` its `value`.
149
+ - The click is a click on the entry as well, for a listener there.
150
+ - An entry with `href` is a link: the browser follows it, and the menu closes.
151
+ - A click beside the menu closes it and chooses nothing.
152
+
153
+ ## Groups
154
+
155
+ Entries that belong together go into an [`el-menu-group`](../menu-group/menu-group.readme.md), which has a line over it and a heading where it has a `label`. An [`el-divider`](../divider/divider.readme.md) is a line alone, with `--el-space-1` above and below it. That room is the menu's, not a margin of the element: a reset of the page that takes the margin off every element changes nothing.
156
+
157
+ ```html
158
+ <el-menu>
159
+ <el-button slot="trigger">File</el-button>
160
+ <el-menu-item value="open">Open</el-menu-item>
161
+ <el-menu-group label="Share">
162
+ <el-menu-item value="mail">Mail</el-menu-item>
163
+ <el-menu-item value="link">Copy link</el-menu-item>
164
+ </el-menu-group>
165
+ <el-menu-group>
166
+ <el-menu-item value="delete" variant="danger">Delete</el-menu-item>
167
+ </el-menu-group>
168
+ </el-menu>
169
+ ```
170
+
171
+ ## Entries that are checked
172
+
173
+ An [`el-menu-item`](../menu-item/menu-item.readme.md) with `type="checkbox"` is on or off, one with `type="radio"` is the chosen one of several, and `checked` is the state. The entry says the state and shows it with a mark in front of its text.
174
+
175
+ ```html
176
+ <el-menu-group label="Layout">
177
+ <el-menu-item type="radio" value="list" checked="true">List</el-menu-item>
178
+ <el-menu-item type="radio" value="grid">Grid</el-menu-item>
179
+ </el-menu-group>
180
+ ```
181
+
182
+ Choosing such an entry is a choice as every other: `menu-select`, and the menu closes. The menu changes no state: the page sets `checked` in its listener, or renders the menu again with the answer of a server.
183
+
184
+ ## The panel
185
+
186
+ - **In the top layer.** The panel is a native popover: an element around the menu that clips (`overflow: hidden`) does not cut it off, and no `z-index` is needed. It takes no room on the page.
187
+ - **At its button.** `placement` names the side, `bottom-start` by default: below the button and in line with the start of it, which is the right edge in a right-to-left page. Without room at that side the menu goes to the opposite one, and it is pushed back along the edge of the viewport where it would leave it. It follows the button when the page scrolls.
188
+ - **As wide as its entries**, between `--el-menu-min-width` and `--el-menu-max-width`. A text that is longer wraps.
189
+ - **A long menu scrolls** in what the browser shows.
190
+ - **One at a time.** A menu that opens closes another one that is open.
191
+ - **A press beside it closes it**, when the pointer goes down. Its own button, and the element it was opened at with `showAt()`, are not beside it: they close it with their click. The panel is a popover the menu opens and closes itself (`popover="manual"`): one the platform closes would be gone when the finger of a long press is lifted.
192
+
193
+ Its place comes from [Floating UI](https://floating-ui.com), which the element imports (`@floating-ui/dom`).
194
+
195
+ ## One menu for many rows
196
+
197
+ A dense list has the same actions for every row: mark as read, rename, move, delete. One `el-menu` serves all of them. It has no button of its own, and the page opens it where it is needed with `showAt()`:
198
+
199
+ ```html
200
+ <ul id="notes">
201
+ <li data-id="12" tabindex="0">
202
+ Release notes
203
+ <el-button circle="true" appearance="plain" aria-haspopup="menu" aria-label="Actions for Release notes">
204
+ <svg aria-hidden="true">…</svg>
205
+ </el-button>
206
+ </li>
207
+ …
208
+ </ul>
209
+
210
+ <el-menu id="actions" label="Actions">
211
+ <el-menu-item value="read">Mark as read</el-menu-item>
212
+ <el-menu-item value="rename">Rename</el-menu-item>
213
+ <el-menu-item value="delete" variant="danger">Delete</el-menu-item>
214
+ </el-menu>
215
+ ```
216
+
217
+ ```js
218
+ const list = document.querySelector('#notes');
219
+ const menu = document.querySelector('#actions');
220
+
221
+ // A right click on a row: the menu opens where the pointer is.
222
+ list.addEventListener('contextmenu', (event) => {
223
+ const row = event.target.closest('li');
224
+ if (!row) return;
225
+ event.preventDefault();
226
+ menu.showAt({ x: event.clientX, y: event.clientY }, row);
227
+ });
228
+
229
+ // The button of a row: the same menu, at the button.
230
+ list.addEventListener('click', (event) => {
231
+ const button = event.target.closest('[aria-haspopup="menu"]');
232
+ if (button) menu.showAt(button);
233
+ });
234
+
235
+ menu.addEventListener('menu-select', (event) => {
236
+ const row = event.detail.opener.closest('li');
237
+ act(event.detail.value, row.dataset.id);
238
+ });
239
+ ```
240
+
241
+ - **`showAt({ x, y }, opener)`** opens the menu at a point of the viewport, the `clientX` and `clientY` of an event. The corner of the menu is at the point, as the menu of the system is, and the menu stays inside of the viewport.
242
+ - **`showAt(element)`** opens it at an element, placed as at its own button (`placement`, `distance`). It follows the element when the page scrolls.
243
+ - **A menu at a point closes when what it was opened for scrolls away under it**: the page, or a region around the row, the list in a column of an `el-app-frame`. A point does not move with the row, and the menu would be left over another one. The focus goes back to the row without scrolling to it, so the scroll goes on. A scroll inside of a long menu leaves it open, and so does one of a region that does not move the row. A menu that was opened for nothing (`showAt({ x, y })` alone) closes for every scroll of the page beside it.
244
+ - **The opener** is what the menu is opened for: the second argument, or the element it is placed at. It is `menu.opener` while the menu is open and `detail.opener` of `menu-select`, and it gets the focus back when the menu closes after a choice or `Escape`. A row that should get the focus back has to be able to take it (`tabindex`).
245
+ - **A second press on the button of a row closes the menu**, with the listener above and nothing more. While the pointer is down on the element the menu is open at, the menu stays open, and the `showAt()` the page calls with the click of that press closes it. The button says `aria-expanded="false"` after. A call of `showAt()` with no press before it, from a script or for `Enter` on the button, opens the menu.
246
+ - **An open menu moves** when `showAt()` is called again, for a right click on another row. It tells of both: `menu-hide` for the row it has left, `menu-show` for the one it is open for.
247
+ - **The roles and the keys** are the ones of the menu: the focus is on the first entry, the arrow keys move through the entries, `Escape` closes.
248
+ - **Nothing in the menu of the right click alone.** A right click and a long press are found by a user who knows them. The button of the row offers the same entries to everybody else, and to the keyboard.
249
+ - **The button of a row** says that it opens a menu: write `aria-haspopup="menu"` onto it. The menu tells such a button whether it is open for it (`aria-expanded`), and takes its name while it has no `label` of its own. A row is no control, and nothing is written onto it.
250
+ - **A menu with a button of its own** can be opened with `showAt()` as well. Its button does not say that the menu is open while it is open elsewhere.
251
+
252
+ #### A long press
253
+
254
+ A browser on Android fires `contextmenu` for a long press, and the listener above is all it takes. Safari on iOS does not: there the page finds the long press itself, a finger that stays down for half a second without moving, and calls `showAt()` while the finger is still down. The menu stays open when the finger is lifted.
255
+
256
+ ```js
257
+ let timer;
258
+ list.addEventListener('pointerdown', (event) => {
259
+ if (event.pointerType !== 'touch') return;
260
+ const row = event.target.closest('li');
261
+ timer = setTimeout(() => menu.showAt({ x: event.clientX, y: event.clientY }, row), 500);
262
+ });
263
+ for (const type of ['pointerup', 'pointercancel', 'pointermove']) {
264
+ list.addEventListener(type, () => clearTimeout(timer));
265
+ }
266
+ ```
267
+
268
+ A long press on a text selects it in Safari, and the selection takes the finger away from the page. Keep the text of a row from being selected for that:
269
+
270
+ ```css
271
+ #notes li {
272
+ -webkit-user-select: none;
273
+ user-select: none;
274
+ -webkit-touch-callout: none;
275
+ }
276
+ ```
277
+
278
+ ## Entries that come later
279
+
280
+ The page can render the entries when the menu is asked for, as the answer of a server, and an autoloader can define `el-menu-item` when it first sees one. The menu is open then before an entry can take the focus, and the focus stays where it was.
281
+
282
+ ```js
283
+ menu.addEventListener('menu-show', async () => {
284
+ const actions = await load(menu.opener);
285
+ menu.replaceChildren(...actions.map(entry));
286
+ });
287
+ ```
288
+
289
+ - **The focus goes to the first entry once the entries are there**: when they have come into the menu, and when their element is defined. To the last one where `ArrowUp` has opened the menu. Not where the user has put the focus into the menu by then.
290
+ - **The menu is placed again**: it has another size with its entries, and stays inside of the viewport.
291
+ - **Until then the keys work as above**: `Escape` closes the menu.
292
+
293
+ ## Not in this element
294
+
295
+ - A menu in a menu (a submenu).
296
+ - A menu that stays open after a choice.
297
+ - A menu bar.
298
+
299
+ For a panel in the flow of the page there is [`el-dropdown`](../dropdown/dropdown.readme.md), and for a floating panel with any content [`el-popover`](../popover/popover.readme.md).
300
+
301
+ ## Server-side rendering
302
+
303
+ The menu and its entries render on a server with `@webtides/element-js-ssr-renderer`. Before the script has run the menu is its button: the panel is a popover that is closed, and takes no room. A menu without a button, for the rows of a list, takes no room at all. The roles of the menu and of its entries, the links and the entries that are disabled are in the markup. The script adds what the button says (`aria-haspopup`, `aria-expanded`), the opening and the keyboard. A button does nothing before that.
304
+
305
+ ## Accessibility
306
+
307
+ - The panel has `role="menu"`, with the name of `label` or the one of its button. The entries have `role="menuitem"`, or `menuitemcheckbox` and `menuitemradio` with their state (`aria-checked`), the groups `role="group"` with their heading as their name.
308
+ - The button says that it opens a menu and whether the menu is open.
309
+ - The focus is on an entry while the menu is open, and goes back to the button, or to what the menu was opened for, when the menu closes after a choice or `Escape`.
310
+ - The keys of the menu work wherever the focus is while the menu is open: `Escape` closes it, the arrow keys bring the focus into it.
311
+ - The entry that has the focus of the keyboard has a ring inside of it, which shows where the user forces colours.
312
+ - On a touch screen every entry is at least `--el-touch-target` high.
313
+ - Without a theme the menu has the colours of the system, and reads in a light and in a dark scheme.
@@ -0,0 +1,59 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ const style = css`
6
+ :host {
7
+ display: inline-block;
8
+ }
9
+
10
+ [part~='panel'] {
11
+ /* The platform centres a popover in the viewport and gives it a look of its own. The panel
12
+ is placed at the button instead: the script sets left and top, in the coordinates of the
13
+ viewport. Whether it is shown stays with the platform, so there is no display here. */
14
+ position: fixed;
15
+ inset: auto;
16
+ top: 0;
17
+ left: 0;
18
+ margin: 0;
19
+ box-sizing: border-box;
20
+ inline-size: max-content;
21
+ min-inline-size: var(--el-menu-min-width, 10rem);
22
+ max-inline-size: min(var(--el-menu-max-width, 20rem), calc(100vw - 1rem));
23
+ /* A long menu scrolls in what the browser shows, and is never higher. */
24
+ max-block-size: calc(100vh - 1rem);
25
+ max-block-size: calc(100dvh - 1rem);
26
+ overflow-y: auto;
27
+ overscroll-behavior: contain;
28
+ padding: var(--el-space-1, 0.25rem);
29
+ /* System colours as the headless fallback: a floating surface has to be readable over the
30
+ page, so transparent is no option here. */
31
+ background: var(--el-color-bg, Canvas);
32
+ color: var(--el-color-fg, CanvasText);
33
+ border: var(--el-border-width, 1px) solid var(--el-color-border, currentColor);
34
+ border-radius: var(--el-radius-lg, 0);
35
+ box-shadow: var(--el-shadow-lg, none);
36
+ /* The text of the page around the button is not the text of a menu: a menu in a heading
37
+ is no heading. */
38
+ font-size: var(--el-font-size-sm, 0.875rem);
39
+ font-weight: var(--el-font-weight-normal, 400);
40
+ line-height: 1.25;
41
+ text-align: start;
42
+ /* A menu can stand in a row of joined buttons (el-button-group), which joins its button
43
+ with properties that inherit. What is in the panel is not part of that row. */
44
+ --_el-group-radius-start: initial;
45
+ --_el-group-radius-end: initial;
46
+ --_el-group-divider: initial;
47
+ --_el-group-overlap: initial;
48
+ }
49
+
50
+ /* A line between two entries, which the page puts there. The menu names the room above and
51
+ below it, in a property that inherits, and the line takes that room in its own shadow root.
52
+ A margin of the slotted element would be gone on a page that takes the margin off every
53
+ element: a rule of the page wins over a ::slotted rule. */
54
+ ::slotted(el-divider) {
55
+ --_el-context-divider-space: var(--el-space-1, 0.25rem);
56
+ }
57
+ `;
58
+
59
+ export default [hostStyle(), style].join('\n');
@@ -0,0 +1,20 @@
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-menu-group`: a group of entries in an `el-menu`. A group to assistive technology (`role="group"`), with `label` as its heading and its name. The heading the eye sees is not read a second time. ([#167](https://github.com/webtides/element-library/issues/167))
20
+ - A line divides a group from what is before it in the menu. A group that is the first thing in its menu has none. Where the user forces colours the line is there without a theme as well.
@@ -0,0 +1,3 @@
1
+ import { define } from './menu-group.js';
2
+
3
+ define();
@@ -0,0 +1,44 @@
1
+ import { TemplateElement, defineElement, html } from '@webtides/element-js';
2
+ import style from './menu-group.style.js';
3
+
4
+ /**
5
+ * A group of entries in an `el-menu`, with a heading where it has a `label`. A group to assistive
6
+ * technology (`role="group"`), which has the heading as its name. A line divides it from what is
7
+ * before it in the menu.
8
+ *
9
+ * @element el-menu-group
10
+ *
11
+ * @slot - The entries of the group: `el-menu-item` elements.
12
+ *
13
+ * @csspart base - The group, with the line over it.
14
+ * @csspart label - The heading of the group.
15
+ *
16
+ * @property {string} label - The heading of the group, and its name for assistive technology.
17
+ * Default `''`.
18
+ */
19
+ export default class MenuGroup extends TemplateElement {
20
+ constructor() {
21
+ super({ styles: [style], shadowRender: true });
22
+ }
23
+
24
+ properties() {
25
+ return {
26
+ label: '',
27
+ };
28
+ }
29
+
30
+ template() {
31
+ // The group has the text as its name, so the heading the eye sees is not read a second
32
+ // time. A plain binding leaves the name out while there is none.
33
+ return html`
34
+ <div part="base" class="group" role="group" aria-label="${this.label || null}">
35
+ <div part="label" class="label" aria-hidden="true" ?hidden="${!this.label}">${this.label}</div>
36
+ <slot></slot>
37
+ </div>
38
+ `;
39
+ }
40
+ }
41
+
42
+ export function define() {
43
+ defineElement('el-menu-group', MenuGroup);
44
+ }
@@ -0,0 +1,74 @@
1
+ # Menu Group
2
+
3
+ `menu-group` is a group of entries in an [`el-menu`](../menu/menu.readme.md): the entries that belong together, under a heading where the group has one.
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/menu/define';
17
+ import '@webtides/element-library/menu-group/define';
18
+ import '@webtides/element-library/menu-item/define';
19
+ ```
20
+
21
+ ```html
22
+ <el-menu>
23
+ <el-button slot="trigger">File</el-button>
24
+ <el-menu-item value="open">Open</el-menu-item>
25
+ <el-menu-group label="Share">
26
+ <el-menu-item value="mail">Mail</el-menu-item>
27
+ <el-menu-item value="link">Copy link</el-menu-item>
28
+ </el-menu-group>
29
+ </el-menu>
30
+ ```
31
+
32
+ ## API
33
+
34
+ #### Properties/Attributes
35
+
36
+ | Name | Type | Default | Description |
37
+ | ------- | -------- | ------- | ---------------------------------------------------------------- |
38
+ | `label` | `string` | `''` | The heading of the group, and its name for assistive technology. |
39
+
40
+ #### Methods
41
+
42
+ _None._
43
+
44
+ #### Events
45
+
46
+ _None._
47
+
48
+ #### Slots
49
+
50
+ | Name | Description |
51
+ | --------- | -------------------------------------------------- |
52
+ | (default) | The entries of the group: `el-menu-item` elements. |
53
+
54
+ #### CSS Parts
55
+
56
+ | Name | Description |
57
+ | ------- | --------------------------------- |
58
+ | `base` | The group, with the line over it. |
59
+ | `label` | The heading of the group. |
60
+
61
+ #### CSS Custom Properties
62
+
63
+ Reads `--el-color-border` and `--el-border-width` for the line, `--el-space-1`, `--el-space-2` and `--el-space-3` for the room around it and the heading, and `--el-color-fg-muted` and `--el-font-size-xs` for the heading.
64
+
65
+ ## The line
66
+
67
+ A group has a line over it, which divides it from what is before it in the menu. A group that is the first thing in its menu has none. Entries that follow a group without a group of their own have no line over them: put them into a group, or an [`el-divider`](../divider/divider.readme.md) between.
68
+
69
+ ## Accessibility
70
+
71
+ - A group (`role="group"`) with `label` as its name. A screen reader says the name when the focus enters the group.
72
+ - The heading the eye sees is hidden from assistive technology, so it is not read a second time.
73
+ - The arrow keys move through the entries of all groups as through one row.
74
+ - Where the user forces colours the line is there without a theme as well.
@@ -0,0 +1,38 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ const style = css`
6
+ :host {
7
+ display: block;
8
+ /* Where the user forces colours the line is there without a theme as well: nothing else
9
+ tells two groups apart. */
10
+ --_el-menu-group-line-width: var(--el-border-width, 1px);
11
+ }
12
+
13
+ @media (forced-colors: active) {
14
+ :host {
15
+ --_el-menu-group-line-width: max(var(--el-border-width, 0px), 1px);
16
+ }
17
+ }
18
+
19
+ /* A line over the group, with a little room on both sides of it. Not over a group that is
20
+ the first thing in its menu: the button of the menu is a child of it as well, in a slot of
21
+ its own, and is not counted. */
22
+ :host(:not(:nth-child(1 of :not([slot])))) .group {
23
+ margin-block-start: var(--el-space-1, 0.25rem);
24
+ padding-block-start: var(--el-space-1, 0.25rem);
25
+ border-block-start: var(--_el-menu-group-line-width) solid var(--el-color-border, currentColor);
26
+ }
27
+
28
+ /* The heading starts where the entries start. */
29
+ .label {
30
+ padding: var(--el-space-2, 0.5rem) var(--el-space-3, 0.75rem) var(--el-space-1, 0.25rem);
31
+ color: var(--el-color-fg-muted, inherit);
32
+ font-size: var(--el-font-size-xs, 0.75rem);
33
+ font-weight: var(--el-font-weight-semibold, 600);
34
+ line-height: 1.2;
35
+ }
36
+ `;
37
+
38
+ export default [hostStyle(), style].join('\n');
@@ -0,0 +1,32 @@
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.5.0] - 2026-11-27
16
+
17
+ ### Added
18
+
19
+ - `type`: an entry that sets something instead of doing something. With `type="checkbox"` it is on or off (`role="menuitemcheckbox"`), with `type="radio"` it is one of several of which one is chosen (`role="menuitemradio"`). `checked` is its state, which it says (`aria-checked`), also while it is off and while it is disabled. A page could put a mark into the `icon` slot before, and a screen reader heard nothing of it: the role of an entry is inside of its shadow root. ([#205](https://github.com/webtides/element-library/issues/205))
20
+ - The state shows as a mark in front of the text, a check or a dot, in the new part `mark`. Its place is there while the entry is not checked as well, so the text does not move when the state changes. Where the user forces colours the mark has the colour of the text: the check is text, the dot is drawn with a border. ([#205](https://github.com/webtides/element-library/issues/205))
21
+ - The page sets the state: the entry does not change `checked` when it is chosen, and the menu fires `menu-select` and closes as for every entry. The state is in the server-rendered markup. ([#205](https://github.com/webtides/element-library/issues/205))
22
+
23
+ ## [0.4.0] - 2026-11-27
24
+
25
+ ### Added
26
+
27
+ - Initial `el-menu-item`: one entry of an `el-menu`. A `<button>` with `role="menuitem"`, or a link with `href`, `target` and `rel`. It is out of the order of the Tab key: the menu moves the focus to it. ([#167](https://github.com/webtides/element-library/issues/167))
28
+ - `value` is what the entry stands for, for the listener of `menu-select`. Choosing an entry is a click on it, which the page can hear on the entry as well.
29
+ - `disabled`: the entry cannot be chosen. It says so (`aria-disabled`), fires no click, and the keyboard still gets to it. A link that is disabled has no address.
30
+ - The `icon` slot takes an icon in front of the text, and takes no room while it is empty.
31
+ - `variant` (reflected): `danger` shows an entry for something that cannot be undone in the colour of a danger, from the shared variants.
32
+ - The entry under the pointer and the one with the focus of the keyboard have a tint of the text colour, and the focus a ring inside of the entry, which is what shows where the user forces colours. On a touch screen an entry is at least `--el-touch-target` high.
@@ -0,0 +1,3 @@
1
+ import { define } from './menu-item.js';
2
+
3
+ define();