@webtides/element-library 0.3.0 → 0.4.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 (199) hide show
  1. package/CHANGELOG.md +208 -0
  2. package/README.md +72 -56
  3. package/all.js +16 -0
  4. package/catalog.js +17 -1
  5. package/custom-elements.json +14731 -10193
  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 +45 -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 +1073 -0
  20. package/src/components/app-frame/app-frame.readme.md +416 -0
  21. package/src/components/app-frame/app-frame.style.js +527 -0
  22. package/src/components/button/button.changelog.md +25 -0
  23. package/src/components/button/button.events.js +3 -0
  24. package/src/components/button/button.js +209 -14
  25. package/src/components/button/button.readme.md +82 -6
  26. package/src/components/button/button.style.js +161 -7
  27. package/src/components/checkbox-field/checkbox-field.changelog.md +6 -0
  28. package/src/components/checkbox-field/checkbox-field.js +7 -1
  29. package/src/components/description-list/description-list.changelog.md +25 -0
  30. package/src/components/description-list/description-list.define.js +3 -0
  31. package/src/components/description-list/description-list.js +44 -0
  32. package/src/components/description-list/description-list.readme.md +135 -0
  33. package/src/components/description-list/description-list.style.js +140 -0
  34. package/src/components/dialog/dialog.changelog.md +7 -0
  35. package/src/components/dialog/dialog.readme.md +5 -0
  36. package/src/components/dialog/dialog.style.js +17 -2
  37. package/src/components/drawer/drawer.changelog.md +7 -0
  38. package/src/components/drawer/drawer.readme.md +7 -6
  39. package/src/components/drawer/drawer.style.js +35 -2
  40. package/src/components/dropdown/dropdown.readme.md +6 -1
  41. package/src/components/list/list.changelog.md +24 -0
  42. package/src/components/list/list.define.js +3 -0
  43. package/src/components/list/list.js +66 -0
  44. package/src/components/list/list.readme.md +122 -0
  45. package/src/components/list/list.style.js +56 -0
  46. package/src/components/list-item/list-item.changelog.md +24 -0
  47. package/src/components/list-item/list-item.define.js +3 -0
  48. package/src/components/list-item/list-item.js +128 -0
  49. package/src/components/list-item/list-item.readme.md +126 -0
  50. package/src/components/list-item/list-item.style.js +234 -0
  51. package/src/components/menu/menu.changelog.md +27 -0
  52. package/src/components/menu/menu.define.js +3 -0
  53. package/src/components/menu/menu.events.js +5 -0
  54. package/src/components/menu/menu.js +570 -0
  55. package/src/components/menu/menu.readme.md +272 -0
  56. package/src/components/menu/menu.style.js +55 -0
  57. package/src/components/menu-group/menu-group.changelog.md +20 -0
  58. package/src/components/menu-group/menu-group.define.js +3 -0
  59. package/src/components/menu-group/menu-group.js +44 -0
  60. package/src/components/menu-group/menu-group.readme.md +74 -0
  61. package/src/components/menu-group/menu-group.style.js +38 -0
  62. package/src/components/menu-item/menu-item.changelog.md +24 -0
  63. package/src/components/menu-item/menu-item.define.js +3 -0
  64. package/src/components/menu-item/menu-item.js +130 -0
  65. package/src/components/menu-item/menu-item.readme.md +94 -0
  66. package/src/components/menu-item/menu-item.style.js +87 -0
  67. package/src/components/nav/nav.changelog.md +35 -0
  68. package/src/components/nav/nav.define.js +3 -0
  69. package/src/components/nav/nav.js +212 -0
  70. package/src/components/nav/nav.readme.md +248 -0
  71. package/src/components/nav/nav.style.js +269 -0
  72. package/src/components/nav-item/nav-item.changelog.md +25 -0
  73. package/src/components/nav-item/nav-item.define.js +3 -0
  74. package/src/components/nav-item/nav-item.js +75 -0
  75. package/src/components/nav-item/nav-item.readme.md +111 -0
  76. package/src/components/nav-item/nav-item.style.js +159 -0
  77. package/src/components/pagination/pagination.changelog.md +8 -0
  78. package/src/components/pagination/pagination.js +123 -49
  79. package/src/components/pagination/pagination.readme.md +24 -6
  80. package/src/components/pagination/pagination.style.js +11 -1
  81. package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
  82. package/src/components/scroll-to-top/scroll-to-top.js +16 -12
  83. package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
  84. package/src/components/segmented-field/segmented-field.changelog.md +27 -0
  85. package/src/components/segmented-field/segmented-field.define.js +3 -0
  86. package/src/components/segmented-field/segmented-field.js +175 -0
  87. package/src/components/segmented-field/segmented-field.readme.md +140 -0
  88. package/src/components/segmented-field/segmented-field.style.js +193 -0
  89. package/src/components/splitter/splitter.changelog.md +24 -0
  90. package/src/components/splitter/splitter.define.js +3 -0
  91. package/src/components/splitter/splitter.events.js +4 -0
  92. package/src/components/splitter/splitter.js +237 -0
  93. package/src/components/splitter/splitter.readme.md +164 -0
  94. package/src/components/splitter/splitter.style.js +100 -0
  95. package/src/components/status-bar/status-bar.changelog.md +25 -0
  96. package/src/components/status-bar/status-bar.define.js +3 -0
  97. package/src/components/status-bar/status-bar.js +74 -0
  98. package/src/components/status-bar/status-bar.readme.md +139 -0
  99. package/src/components/status-bar/status-bar.style.js +122 -0
  100. package/src/components/switch-field/switch-field.changelog.md +6 -0
  101. package/src/components/switch-field/switch-field.js +7 -1
  102. package/src/components/tab-group/tab-group.changelog.md +7 -0
  103. package/src/components/tab-group/tab-group.js +30 -9
  104. package/src/components/tab-group/tab-group.readme.md +14 -0
  105. package/src/components/toast/toast.changelog.md +6 -0
  106. package/src/components/toast/toast.readme.md +5 -3
  107. package/src/components/toast/toast.style.js +22 -6
  108. package/src/components/toolbar/toolbar.changelog.md +24 -0
  109. package/src/components/toolbar/toolbar.define.js +3 -0
  110. package/src/components/toolbar/toolbar.js +233 -0
  111. package/src/components/toolbar/toolbar.readme.md +156 -0
  112. package/src/components/toolbar/toolbar.style.js +49 -0
  113. package/src/components/tooltip/tooltip.changelog.md +11 -0
  114. package/src/components/tooltip/tooltip.js +51 -4
  115. package/src/components/tooltip/tooltip.readme.md +26 -1
  116. package/src/components/tree/tree.changelog.md +23 -0
  117. package/src/components/tree/tree.define.js +3 -0
  118. package/src/components/tree/tree.js +138 -0
  119. package/src/components/tree/tree.readme.md +119 -0
  120. package/src/components/tree/tree.style.js +16 -0
  121. package/src/components/tree-item/tree-item.changelog.md +23 -0
  122. package/src/components/tree-item/tree-item.define.js +3 -0
  123. package/src/components/tree-item/tree-item.events.js +3 -0
  124. package/src/components/tree-item/tree-item.js +246 -0
  125. package/src/components/tree-item/tree-item.readme.md +128 -0
  126. package/src/components/tree-item/tree-item.style.js +226 -0
  127. package/src/styles/appearance.style.js +47 -0
  128. package/src/styles/choice-group.style.js +1 -1
  129. package/src/styles/modal.style.js +14 -1
  130. package/src/styles/size.style.js +41 -0
  131. package/src/utils/focus.js +69 -0
  132. package/src/utils/scroll.js +24 -0
  133. package/types/all.d.ts +16 -0
  134. package/types/src/components/accordion/accordion.d.ts +3 -1
  135. package/types/src/components/app-bar/app-bar.d.ts +43 -0
  136. package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
  137. package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
  138. package/types/src/components/app-frame/app-frame.d.ts +491 -0
  139. package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
  140. package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
  141. package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
  142. package/types/src/components/button/button.d.ts +97 -7
  143. package/types/src/components/button/button.events.d.ts +4 -0
  144. package/types/src/components/description-list/description-list.d.ts +29 -0
  145. package/types/src/components/description-list/description-list.define.d.ts +1 -0
  146. package/types/src/components/description-list/description-list.style.d.ts +2 -0
  147. package/types/src/components/list/list.d.ts +39 -0
  148. package/types/src/components/list/list.define.d.ts +1 -0
  149. package/types/src/components/list/list.style.d.ts +2 -0
  150. package/types/src/components/list-item/list-item.d.ts +62 -0
  151. package/types/src/components/list-item/list-item.define.d.ts +1 -0
  152. package/types/src/components/list-item/list-item.style.d.ts +2 -0
  153. package/types/src/components/menu/menu.d.ts +266 -0
  154. package/types/src/components/menu/menu.define.d.ts +1 -0
  155. package/types/src/components/menu/menu.events.d.ts +6 -0
  156. package/types/src/components/menu/menu.style.d.ts +2 -0
  157. package/types/src/components/menu-group/menu-group.d.ts +24 -0
  158. package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
  159. package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
  160. package/types/src/components/menu-item/menu-item.d.ts +59 -0
  161. package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
  162. package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
  163. package/types/src/components/nav/nav.d.ts +103 -0
  164. package/types/src/components/nav/nav.define.d.ts +1 -0
  165. package/types/src/components/nav/nav.style.d.ts +2 -0
  166. package/types/src/components/nav-item/nav-item.d.ts +39 -0
  167. package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
  168. package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
  169. package/types/src/components/pagination/pagination.d.ts +31 -2
  170. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
  171. package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
  172. package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
  173. package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
  174. package/types/src/components/splitter/splitter.d.ts +127 -0
  175. package/types/src/components/splitter/splitter.define.d.ts +1 -0
  176. package/types/src/components/splitter/splitter.events.d.ts +5 -0
  177. package/types/src/components/splitter/splitter.style.d.ts +2 -0
  178. package/types/src/components/status-bar/status-bar.d.ts +44 -0
  179. package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
  180. package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
  181. package/types/src/components/tab-group/tab-group.d.ts +17 -0
  182. package/types/src/components/toolbar/toolbar.d.ts +96 -0
  183. package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
  184. package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
  185. package/types/src/components/tooltip/tooltip.d.ts +26 -0
  186. package/types/src/components/tree/tree.d.ts +62 -0
  187. package/types/src/components/tree/tree.define.d.ts +1 -0
  188. package/types/src/components/tree/tree.style.d.ts +2 -0
  189. package/types/src/components/tree-item/tree-item.d.ts +106 -0
  190. package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
  191. package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
  192. package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
  193. package/types/src/styles/appearance.style.d.ts +31 -0
  194. package/types/src/styles/choice-group.style.d.ts +1 -1
  195. package/types/src/styles/modal.style.d.ts +5 -0
  196. package/types/src/styles/size.style.d.ts +24 -0
  197. package/types/src/utils/focus.d.ts +25 -0
  198. package/types/src/utils/scroll.d.ts +11 -0
  199. package/web-types.json +2530 -393
@@ -12,6 +12,13 @@ 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`), the header of a drawer was under the status bar and its footer under the home indicator. The surface still reaches the three edges it lies against, and its header, its body and its footer keep clear of that room now. The size the page gives is the one of what is in the drawer, and the room is on top. Elsewhere nothing changes. ([#183](https://github.com/webtides/element-library/issues/183))
20
+ - What is in a drawer and would keep the edges of the screen clear itself (an `el-app-bar`, an `el-nav`) is told that the surface does so, and adds no room of its own.
21
+
15
22
  ## [0.3.0] - 2026-11-17
16
23
 
17
24
  ### Added
@@ -134,13 +134,14 @@ On a touch screen (`@media (any-pointer: coarse)`) the close button is at least
134
134
 
135
135
  The drawer is never wider or higher than the viewport. On a narrow screen a drawer at the start or the end covers the page, and the close button is the way back.
136
136
 
137
- A page that reaches under the notch and the home indicator of a phone (`viewport-fit=cover`) keeps the content of the drawer clear of them itself:
137
+ ## On a phone
138
138
 
139
- ```css
140
- el-drawer::part(base) {
141
- padding-block-end: env(safe-area-inset-bottom);
142
- }
143
- ```
139
+ 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 system takes room at the edges of the screen. The surface of the drawer reaches the three edges it lies against, and its header, its body and its footer keep clear of that room: the header starts below the status bar, the footer ends above the home indicator.
140
+
141
+ - The room is padding of the surface (`::part(base)`), on the edges the drawer lies against and not on the one that faces the page.
142
+ - `--el-drawer-size` is the size of what is in the drawer. The room of the screen is on top of it.
143
+ - What is in a drawer and keeps the edges of the screen clear when it is alone, an [`el-app-bar`](../app-bar/app-bar.readme.md) or an [`el-nav`](../nav/nav.readme.md), is told that the drawer does so, and adds no room of its own.
144
+ - Without `viewport-fit=cover`, and on a desktop, the room is nothing and the drawer is as before.
144
145
 
145
146
  ## Opening and closing
146
147
 
@@ -10,9 +10,27 @@ const border = 'var(--el-border-width, 0)';
10
10
  *
11
11
  * The first rule is the drawer at the end of the line, which is also what a placement that is none
12
12
  * of the four gets. The other placements change what differs.
13
+ *
14
+ * On a phone the system takes room at the edges of the screen, where the page reaches under them
15
+ * (viewport-fit=cover): the notch, the rounded corners, the home indicator. The surface of the
16
+ * drawer reaches the three edges it lies against, and its header, its body and its footer stay
17
+ * clear of that room: it is padding of the surface, which the modal module reads. The size the
18
+ * page gives a drawer is the one of what is in it, and the room is on top. Elsewhere the room is
19
+ * nothing.
13
20
  */
14
21
  const style = css`
15
22
  dialog {
23
+ /* The room of the system at the edges of the screen, by the direction of the text. */
24
+ --_el-drawer-screen-top: env(safe-area-inset-top, 0px);
25
+ --_el-drawer-screen-bottom: env(safe-area-inset-bottom, 0px);
26
+ --_el-drawer-screen-start: env(safe-area-inset-left, 0px);
27
+ --_el-drawer-screen-end: env(safe-area-inset-right, 0px);
28
+ /* The edges the drawer lies against: all but the one that faces the page. */
29
+ --_el-modal-inset-block-start: var(--_el-drawer-screen-top);
30
+ --_el-modal-inset-block-end: var(--_el-drawer-screen-bottom);
31
+ --_el-modal-inset-inline-start: 0px;
32
+ --_el-modal-inset-inline-end: var(--_el-drawer-screen-end);
33
+
16
34
  /* The direction the end of a line is in: 1 for the right, -1 for the left. */
17
35
  --_el-drawer-end: 1;
18
36
  /* How far the drawer is out of the viewport before it is shown. */
@@ -28,7 +46,9 @@ const style = css`
28
46
  margin: 0;
29
47
  max-inline-size: 100%;
30
48
  max-block-size: 100%;
31
- inline-size: var(--el-drawer-size, 25rem);
49
+ inline-size: calc(
50
+ var(--el-drawer-size, 25rem) + var(--_el-modal-inset-inline-start) + var(--_el-modal-inset-inline-end)
51
+ );
32
52
  /* From edge to edge: the browser gives a dialog the height of its content. */
33
53
  block-size: auto;
34
54
 
@@ -46,9 +66,13 @@ const style = css`
46
66
  \`:dir(rtl)\` for an element inside the shadow root. */
47
67
  :host(:dir(rtl)) dialog {
48
68
  --_el-drawer-end: -1;
69
+ --_el-drawer-screen-start: env(safe-area-inset-right, 0px);
70
+ --_el-drawer-screen-end: env(safe-area-inset-left, 0px);
49
71
  }
50
72
 
51
73
  :host([placement='start']) dialog {
74
+ --_el-modal-inset-inline-start: var(--_el-drawer-screen-start);
75
+ --_el-modal-inset-inline-end: 0px;
52
76
  --_el-drawer-x: calc(-100% * var(--_el-drawer-end));
53
77
  inset-inline: 0 auto;
54
78
  border-inline-width: 0 ${border};
@@ -58,14 +82,22 @@ const style = css`
58
82
  /* Across the viewport, and as high as the content unless a size is given. */
59
83
  :host([placement='top']) dialog,
60
84
  :host([placement='bottom']) dialog {
85
+ --_el-modal-inset-inline-start: var(--_el-drawer-screen-start);
86
+ --_el-modal-inset-inline-end: var(--_el-drawer-screen-end);
87
+ /* The size of the page and the room of the system on top of it. Without a size the
88
+ property is not valid, and the drawer is as high as its content. */
89
+ --_el-drawer-block-size: calc(
90
+ var(--el-drawer-size) + var(--_el-modal-inset-block-start) + var(--_el-modal-inset-block-end)
91
+ );
61
92
  --_el-drawer-x: 0;
62
93
  inset-inline: 0;
63
94
  inline-size: auto;
64
- block-size: var(--el-drawer-size, auto);
95
+ block-size: var(--_el-drawer-block-size, auto);
65
96
  border-inline-width: 0;
66
97
  }
67
98
 
68
99
  :host([placement='top']) dialog {
100
+ --_el-modal-inset-block-end: 0px;
69
101
  --_el-drawer-y: -100%;
70
102
  inset-block-end: auto;
71
103
  border-block-end-width: ${border};
@@ -73,6 +105,7 @@ const style = css`
73
105
  }
74
106
 
75
107
  :host([placement='bottom']) dialog {
108
+ --_el-modal-inset-block-start: 0px;
76
109
  --_el-drawer-y: 100%;
77
110
  inset-block-start: auto;
78
111
  border-block-start-width: ${border};
@@ -1,6 +1,11 @@
1
1
  # Dropdown
2
2
 
3
- `dropdown` is a component that creates a toggleable dropdown menu with trigger and content slots. It handles click-outside and escape key interactions to automatically close the dropdown when the user clicks outside or presses the Escape key.
3
+ `dropdown` is a component that shows and hides a panel for a trigger, with trigger and content slots. It closes when the user clicks outside or presses the Escape key.
4
+
5
+ The panel is in the flow of the page: it takes room below its trigger, and what follows moves down. That is what the dropdown is for, a part of the page that opens in its place. For the two things it is often taken for, there are elements of their own:
6
+
7
+ - **A menu of actions** behind a button is an [`el-menu`](../menu/menu.readme.md): entries with roles, the keyboard through them, and a panel that floats.
8
+ - **A panel that floats** next to its anchor, with any content, is an [`el-popover`](../popover/popover.readme.md).
4
9
 
5
10
  ## How to use
6
11
 
@@ -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-list`: a list of rows, for messages, articles, files or the entries of a settings page. It is the list for assistive technology (`role="list"`, named by `label`), and every `el-list-item` slotted into it is an item of that list. ([#192](https://github.com/webtides/element-library/issues/192))
20
+ - The texts of all rows begin on one line, after the widest start of the list: the list has a column for the start and one for the rest, and a row takes them over (`subgrid`). A list without a start in any row has no first column.
21
+ - `density` (`'default'` or `'compact'`): `--el-space-3` or `--el-space-2` above and below the texts of a row.
22
+ - `appearance`: `'plain'` (the default) has no surface and reaches from edge to edge of its place; `'outlined'` and `'filled'` are the surfaces of `el-card`. Between two rows is a line in `--el-color-border`. Without a theme the list paints nothing.
23
+ - `--el-list-padding-inline` is the padding of a row at its start and its end, `--el-space-4` unset. With `0` a list in the body of an `el-card` has its rows on the line of the other content.
24
+ - The list runs no script: a server-rendered list is complete without JavaScript, and looks the same before and after the element takes over.
@@ -0,0 +1,3 @@
1
+ import { define } from './list.js';
2
+
3
+ define();
@@ -0,0 +1,66 @@
1
+ import { TemplateElement, defineElement, html, spreadAttributes } from '@webtides/element-js';
2
+ import style from './list.style.js';
3
+
4
+ /**
5
+ * A list of rows: messages, articles, files, the entries of a settings page. The list is the
6
+ * surface and the list for assistive technology; every `el-list-item` slotted into it is one row.
7
+ * It gives its rows one density, one line between two of them and one place where their texts
8
+ * begin, whatever stands at the start of a row.
9
+ *
10
+ * Pure presentation: the list runs no script of its own, so a server-rendered list is complete
11
+ * before the element takes over.
12
+ *
13
+ * @element el-list
14
+ *
15
+ * @slot - The rows: `el-list-item` elements.
16
+ *
17
+ * @csspart base - The list (`role="list"`) and its surface.
18
+ *
19
+ * @cssproperty --el-list-padding-inline - The padding of a row at its start and its end. Unset, it
20
+ * is `--el-space-4`, and `1rem` without a theme. Read by the rows, so it can be set on the list
21
+ * or for the page.
22
+ *
23
+ * @property {string} label - The name of the list for assistive technology. Unset, the list has
24
+ * none.
25
+ * @property {'default'|'compact'} density - How much room a row has above and below its texts.
26
+ * Default `'default'`. Reflected to the `density` attribute.
27
+ * @property {'plain'|'outlined'|'filled'} appearance - How the surface is painted: not at all, so
28
+ * the list reaches from edge to edge of its place, or as a card with the background of the page
29
+ * or a muted fill, a border and round corners. Default `'plain'`. Reflected to the `appearance`
30
+ * attribute.
31
+ */
32
+ export default class List extends TemplateElement {
33
+ constructor() {
34
+ super({
35
+ styles: [style],
36
+ shadowRender: true,
37
+ // The stylesheet selects the host by these attributes.
38
+ propertyOptions: {
39
+ density: { reflect: true },
40
+ appearance: { reflect: true },
41
+ },
42
+ });
43
+ }
44
+
45
+ properties() {
46
+ return {
47
+ label: '',
48
+ density: 'default',
49
+ appearance: 'plain',
50
+ };
51
+ }
52
+
53
+ template() {
54
+ // The role is inside of the shadow root, not on the element: it is part of the
55
+ // server-rendered markup that way, and needs no script.
56
+ return html`
57
+ <div part="base" class="list" role="list" ${spreadAttributes({ 'aria-label': this.label || undefined })}>
58
+ <slot></slot>
59
+ </div>
60
+ `;
61
+ }
62
+ }
63
+
64
+ export function define() {
65
+ defineElement('el-list', List);
66
+ }
@@ -0,0 +1,122 @@
1
+ # List
2
+
3
+ `list` is a list of rows: messages, articles, files, the entries of a settings page. The list is the surface and the list for assistive technology; every [`el-list-item`](../list-item/list-item.readme.md) in it is one row. It gives its rows one density, one line between two of them, and one place where their texts begin.
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/list/define';
17
+ import '@webtides/element-library/list-item/define';
18
+ ```
19
+
20
+ ```html
21
+ <el-list label="Messages">
22
+ <el-list-item href="/messages/1" mark="Unread">
23
+ <el-avatar slot="start" initials="AL" label="Ada Lovelace"></el-avatar>
24
+ Ada Lovelace
25
+ <span slot="description">The notes on the engine are ready for you.</span>
26
+ <time slot="end" datetime="09:12">09:12</time>
27
+ </el-list-item>
28
+ <el-list-item href="/messages/2" current="true">
29
+ <el-avatar slot="start" initials="GH" label="Grace Hopper"></el-avatar>
30
+ Grace Hopper
31
+ <span slot="description">Found it. A moth, in relay 70.</span>
32
+ <time slot="end" datetime="08:40">08:40</time>
33
+ </el-list-item>
34
+ </el-list>
35
+ ```
36
+
37
+ > Boolean attributes are passed as strings (`current="true"`), matching the rest of the library.
38
+
39
+ ## API
40
+
41
+ #### Properties/Attributes
42
+
43
+ | Name | Type | Default | Description |
44
+ | --- | --- | --- | --- |
45
+ | `label` | `string` | `''` | The name of the list for assistive technology. Unset, the list has none. |
46
+ | `density` | `'default' \| 'compact'` | `'default'` | How much room a row has above and below its texts. Reflected to the `density` attribute. |
47
+ | `appearance` | `'plain' \| 'outlined' \| 'filled'` | `'plain'` | How the surface is painted: not at all, or as a card with the background of the page or a muted fill. Reflected to the `appearance` attribute. |
48
+
49
+ #### Methods
50
+
51
+ _None._
52
+
53
+ #### Events
54
+
55
+ _None._
56
+
57
+ #### Slots
58
+
59
+ | Name | Description |
60
+ | --------- | ---------------------------------- |
61
+ | (default) | The rows: `el-list-item` elements. |
62
+
63
+ #### CSS Parts
64
+
65
+ | Name | Description |
66
+ | ------ | ----------------------------------------- |
67
+ | `base` | The list (`role="list"`) and its surface. |
68
+
69
+ #### CSS Custom Properties
70
+
71
+ | Name | Default | Description |
72
+ | --- | --- | --- |
73
+ | `--el-list-padding-inline` | `--el-space-4` | The padding of a row at its start and its end. Read by the rows, so it can be set on the list or for the page. Without a theme it is `1rem`. |
74
+
75
+ ## Where the texts begin
76
+
77
+ What stands at the start of a row differs: an avatar in one row, a small icon in the next, nothing in a third. The texts of all rows of a list begin on one line all the same, after the widest start of the list. The list has two columns, the start and the rest, and every row takes them over (`subgrid`). A list in which no row has a start has no first column: its texts begin at the padding of the row.
78
+
79
+ A `mark` of a row (an unread message) is a dot in that padding. It moves nothing.
80
+
81
+ ## Density
82
+
83
+ `density="compact"` gives a row less room above and below its texts: `--el-space-2` in the place of `--el-space-3`, `0.5rem` in the place of `0.75rem` without a theme. Nothing else changes: the texts, the gap and the padding at the sides are the same.
84
+
85
+ On a touch screen (`@media (any-pointer: coarse)`) a row that is a link is at least `--el-touch-target` high in either density. A row that is no target stays as compact as it is.
86
+
87
+ ## From edge to edge, and as a card
88
+
89
+ - `appearance="plain"`, the default: no surface. The list is as wide as its place, and a line reaches from one edge of it to the other. That is the list of a phone screen, or of a column that is one.
90
+ - `appearance="outlined"`: the surface of an `el-card`, with the background of the page, a border, round corners and the shadow of the theme.
91
+ - `appearance="filled"`: the same with the muted fill.
92
+
93
+ Between two rows is a line in `--el-color-border`, `--el-border-width` wide. Without a theme the list is headless: no line, no border, no fill.
94
+
95
+ A list in the body of an `el-card` has the padding of the card around it. `--el-list-padding-inline: 0` puts its rows on the line of the other content of the card:
96
+
97
+ ```html
98
+ <el-card>
99
+ <strong slot="header">Folders</strong>
100
+ <el-list label="Folders" style="--el-list-padding-inline: 0">
101
+ <el-list-item href="/inbox">Inbox <span slot="end">12</span></el-list-item>
102
+ <el-list-item href="/drafts">Drafts <span slot="end">2</span></el-list-item>
103
+ </el-list>
104
+ </el-card>
105
+ ```
106
+
107
+ The `hidden` attribute hides the list, and a row.
108
+
109
+ ## Accessibility
110
+
111
+ - The list has `role="list"`, and every row is an item of it: a screen reader says how many rows the list has and where its user is in it.
112
+ - `label` names the list. A screen reader reads the name when its user enters the list; without it the list has none. A list of links that is the navigation of a page belongs into a `<nav>` of the page.
113
+ - The list has no keyboard model of its own. The Tab key goes from one link or control to the next, in the order of the rows.
114
+
115
+ ## Server-side rendering
116
+
117
+ The list, its name and the rows are part of the server-rendered markup (Declarative Shadow DOM), with their links. The list runs no script: it looks the same before and after its JavaScript has loaded, its links work before that, and without JavaScript.
118
+
119
+ ## What it is not
120
+
121
+ - No choice of several rows, no reordering by dragging, no swipe actions and no virtual scrolling.
122
+ - No groups with headings. Write a heading and a list after it for each group.
@@ -0,0 +1,56 @@
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
+
9
+ /* What the rows read. The density is the room above and below the texts of a row. */
10
+ --_el-list-padding-block: var(--el-space-3, 0.75rem);
11
+ }
12
+
13
+ :host([density='compact']) {
14
+ --_el-list-padding-block: var(--el-space-2, 0.5rem);
15
+ }
16
+
17
+ /*
18
+ * Two columns for every row: what stands at the start, and the rest. A row takes them over
19
+ * (subgrid), so the first column is as wide as the widest start of the list, and the texts of
20
+ * all rows begin on one line. Without a start in any row the column has no width.
21
+ *
22
+ * The rows are told on themselves, not through the host: a property of the host would reach
23
+ * everything inside of the list, a row of another list in the content of a row as well.
24
+ */
25
+ .list {
26
+ display: grid;
27
+ grid-template-columns: auto minmax(0, 1fr);
28
+ font-family: var(--el-font-family, inherit);
29
+ line-height: var(--el-line-height, inherit);
30
+ }
31
+
32
+ ::slotted(*) {
33
+ --_el-list-columns: subgrid;
34
+ }
35
+
36
+ /* ── Surface ──────────────────────────────────────────────────────────── */
37
+
38
+ /* A card: the surface of el-card. It is headless without a theme, every token falls back to a
39
+ value that paints nothing. The corners clip the fill of a row under the pointer; the focus
40
+ ring of a row is inside of the row, so it is not cut. */
41
+ :host([appearance='outlined']) .list,
42
+ :host([appearance='filled']) .list {
43
+ overflow: hidden;
44
+ background: var(--el-color-bg, transparent);
45
+ color: var(--el-color-fg, inherit);
46
+ border: var(--el-border-width, 0) solid var(--el-color-border, transparent);
47
+ border-radius: var(--el-radius-lg, 0);
48
+ box-shadow: var(--el-shadow-md, none);
49
+ }
50
+
51
+ :host([appearance='filled']) .list {
52
+ background: var(--el-color-bg-muted, transparent);
53
+ }
54
+ `;
55
+
56
+ export default [hostStyle(), style].join('\n');
@@ -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-list-item`: one row of an `el-list`, an item of its list (`role="listitem"`). It has a start (`start` slot), a title (default slot), a line under it (`description`), an end (`end`) and a control of its own (`action`). ([#192](https://github.com/webtides/element-library/issues/192))
20
+ - With `href` the row is a link as a whole: the title is a native link (`target` is passed on, `rel` is written with it), and its target is the whole row. A control in `action` lies on top of the link and stays a target of its own. On a touch screen a row that is a link is at least `--el-touch-target` high.
21
+ - `current` marks the current or the chosen row: `aria-current` (`"page"` on the link, `"true"` on a row without one), a tint, a bar at the start in the accent colour and a heavier title. The bar is a border, so it stays where the user forces colours.
22
+ - `mark` draws a dot in the padding at the start of the row, which does not move the texts. Its text is read in front of the title and is part of the name of the link (`mark="Unread"`).
23
+ - A long title breaks into more lines, inside of a word where it has to, so a text a user typed cannot widen the page. `truncate` cuts the title and the line under it after one line.
24
+ - The row runs no script: its link works before the element takes over, and without JavaScript in server-rendered markup.
@@ -0,0 +1,3 @@
1
+ import { define } from './list-item.js';
2
+
3
+ define();
@@ -0,0 +1,128 @@
1
+ import { TemplateElement, defineElement, html, classMap, spreadAttributes } from '@webtides/element-js';
2
+ import style from './list-item.style.js';
3
+
4
+ /**
5
+ * One row of an `el-list`. It has the parts a row has everywhere: something at the start (an icon,
6
+ * an avatar), a title, a line under it, something at the end (a value, a count, a chevron), and a
7
+ * control of its own after that.
8
+ *
9
+ * With `href` the row is a link as a whole: the title is the link, and its target is the whole
10
+ * row. What is slotted into `action` stays a target of its own.
11
+ *
12
+ * Pure presentation: the row runs no script of its own.
13
+ *
14
+ * @element el-list-item
15
+ *
16
+ * @slot - The title of the row.
17
+ * @slot description - The line under the title.
18
+ * @slot start - What stands in front of the texts: an icon, an avatar. The texts of all rows of a
19
+ * list begin after the widest start.
20
+ * @slot end - What stands at the end of the row and belongs to it: a value, a count, a chevron. In
21
+ * a row that is a link it is part of the target of the link.
22
+ * @slot action - A control at the very end: a button, a switch, a menu. In a row that is a link it
23
+ * lies on top of the link and is a target of its own.
24
+ *
25
+ * @csspart base - The row: an item of the list.
26
+ * @csspart mark - The dot of `mark`, in the padding at the start of the row.
27
+ * @csspart start - The region of the `start` slot.
28
+ * @csspart text - The title and the line under it.
29
+ * @csspart title - The title: an `<a>` with `href`, a `<span>` without.
30
+ * @csspart description - The region of the `description` slot.
31
+ * @csspart end - The region of the `end` slot.
32
+ * @csspart action - The region of the `action` slot.
33
+ *
34
+ * @cssproperty --el-list-padding-inline - The padding of the row at its start and its end. Unset,
35
+ * it is `--el-space-4`, and `1rem` without a theme.
36
+ *
37
+ * @property {string} href - The address the row leads to. Unset, the row is no link.
38
+ * @property {string} target - Where to open the address (only with `href`).
39
+ * @property {string} rel - `rel` attribute for the link, written when `target` is set. Default
40
+ * `'noreferrer noopener'`.
41
+ * @property {boolean} current - The row is the current or the chosen one: it gets `aria-current`
42
+ * (`"page"` on the link of a row with `href`, `"true"` on a row without), a bar at its start
43
+ * and a heavier title. Default `false`.
44
+ * @property {string} mark - Marks the row with a dot in the padding at its start, which does not
45
+ * move the texts: an unread message, for example. The text is what assistive technology reads
46
+ * in front of the title ("Unread"). Unset, the row has no mark.
47
+ * @property {boolean} truncate - Cuts the title and the line under it after one line, with an
48
+ * ellipsis. Unset, a long text breaks into more lines. Default `false`.
49
+ */
50
+ export default class ListItem extends TemplateElement {
51
+ constructor() {
52
+ super({
53
+ styles: [style],
54
+ shadowRender: true,
55
+ });
56
+ }
57
+
58
+ properties() {
59
+ return {
60
+ href: '',
61
+ target: '',
62
+ rel: 'noreferrer noopener',
63
+ current: false,
64
+ mark: '',
65
+ truncate: false,
66
+ };
67
+ }
68
+
69
+ /** @private */
70
+ titleTemplate() {
71
+ // Read in front of the title, and part of the name of the link: a list of links says
72
+ // which of them are marked. The space keeps the two words apart in that name.
73
+ const mark = this.mark ? html`<span class="mark-text">${this.mark} </span>` : '';
74
+
75
+ if (!this.href) {
76
+ return html`<span part="title" class="title">${mark}<slot></slot></span>`;
77
+ }
78
+
79
+ return html`
80
+ <a
81
+ part="title"
82
+ class="title"
83
+ href="${this.href}"
84
+ ${spreadAttributes({
85
+ target: this.target || undefined,
86
+ rel: this.target ? this.rel : undefined,
87
+ 'aria-current': this.current ? 'page' : undefined,
88
+ })}
89
+ >${mark}<slot></slot
90
+ ></a>
91
+ `;
92
+ }
93
+
94
+ template() {
95
+ const classes = {
96
+ item: true,
97
+ 'item--link': !!this.href,
98
+ 'item--current': !!this.current,
99
+ 'item--truncate': !!this.truncate,
100
+ };
101
+
102
+ // The role of a row is inside of the shadow root, not on the element: it is part of the
103
+ // server-rendered markup that way, and needs no script.
104
+ return html`
105
+ <div
106
+ part="base"
107
+ class="${classMap(classes)}"
108
+ role="listitem"
109
+ ${spreadAttributes({ 'aria-current': this.current && !this.href ? 'true' : undefined })}
110
+ >
111
+ ${this.mark ? html`<span part="mark" class="mark" aria-hidden="true"></span>` : ''}
112
+ <span part="start" class="start"><slot name="start"></slot></span>
113
+ <span class="body">
114
+ <span part="text" class="text">
115
+ ${this.titleTemplate()}
116
+ <span part="description" class="description"><slot name="description"></slot></span>
117
+ </span>
118
+ <span part="end" class="end"><slot name="end"></slot></span>
119
+ <span part="action" class="action"><slot name="action"></slot></span>
120
+ </span>
121
+ </div>
122
+ `;
123
+ }
124
+ }
125
+
126
+ export function define() {
127
+ defineElement('el-list-item', ListItem);
128
+ }