@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,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,40 @@
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
+ - `--el-list-gap` sets the gap between the start, the texts, the end and the control of a row, on the list, on a row, or for the page. Unset, it is `--el-space-3` as before. ([#206](https://github.com/webtides/element-library/issues/206))
20
+
21
+ ### Changed
22
+
23
+ - A page that kept the end from shrinking itself (`el-list-item::part(end) { flex-shrink: 0 }`) does not need that rule any more. ([#207](https://github.com/webtides/element-library/issues/207))
24
+ - A page that gave the gap back itself, with a margin on what it slots into `start`, `end` and `action`, takes those rules out: a margin of the page adds to the gap now. ([#206](https://github.com/webtides/element-library/issues/206))
25
+
26
+ ### Fixed
27
+
28
+ - What is in `end` keeps its width beside a title or a description that is longer than the row. It shrank together with the texts, down to next to nothing: on a phone a date broke after every character and stood as a column of ten lines, and an icon shrank to a sliver, or left its place and was drawn in the padding of the row where the page kept it from shrinking. It takes the width it has now, up to half of the row, and breaks after that, as the readme said. The ends of all rows of a list end on one line. ([#207](https://github.com/webtides/element-library/issues/207))
29
+ - The gap beside what is in `start`, `end` and `action` holds on a page whose stylesheet takes the margin off every element (`* { margin: 0 }`, the reset of Tailwind CSS v4). The row gave the gap to what the page slots in, as a margin (`::slotted`), and a rule of the page wins over such a rule, whatever its specificity and its cascade layer: the icon touched the title. The gap is one of the parts of the row now, and the row takes nothing from the margin, the padding or the border of what is slotted. A row without a `start` has no gap there, and a list without one in any row has no first column, as before. ([#206](https://github.com/webtides/element-library/issues/206))
30
+
31
+ ## [0.4.0] - 2026-11-27
32
+
33
+ ### Added
34
+
35
+ - 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))
36
+ - 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.
37
+ - `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.
38
+ - `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"`).
39
+ - 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.
40
+ - 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,130 @@
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
+ * @cssproperty --el-list-gap - The gap between the start, the texts, the end and the control of
37
+ * the row. Unset, it is `--el-space-3`, and `0.75rem` without a theme.
38
+ *
39
+ * @property {string} href - The address the row leads to. Unset, the row is no link.
40
+ * @property {string} target - Where to open the address (only with `href`).
41
+ * @property {string} rel - `rel` attribute for the link, written when `target` is set. Default
42
+ * `'noreferrer noopener'`.
43
+ * @property {boolean} current - The row is the current or the chosen one: it gets `aria-current`
44
+ * (`"page"` on the link of a row with `href`, `"true"` on a row without), a bar at its start
45
+ * and a heavier title. Default `false`.
46
+ * @property {string} mark - Marks the row with a dot in the padding at its start, which does not
47
+ * move the texts: an unread message, for example. The text is what assistive technology reads
48
+ * in front of the title ("Unread"). Unset, the row has no mark.
49
+ * @property {boolean} truncate - Cuts the title and the line under it after one line, with an
50
+ * ellipsis. Unset, a long text breaks into more lines. Default `false`.
51
+ */
52
+ export default class ListItem extends TemplateElement {
53
+ constructor() {
54
+ super({
55
+ styles: [style],
56
+ shadowRender: true,
57
+ });
58
+ }
59
+
60
+ properties() {
61
+ return {
62
+ href: '',
63
+ target: '',
64
+ rel: 'noreferrer noopener',
65
+ current: false,
66
+ mark: '',
67
+ truncate: false,
68
+ };
69
+ }
70
+
71
+ /** @private */
72
+ titleTemplate() {
73
+ // Read in front of the title, and part of the name of the link: a list of links says
74
+ // which of them are marked. The space keeps the two words apart in that name.
75
+ const mark = this.mark ? html`<span class="mark-text">${this.mark} </span>` : '';
76
+
77
+ if (!this.href) {
78
+ return html`<span part="title" class="title">${mark}<slot></slot></span>`;
79
+ }
80
+
81
+ return html`
82
+ <a
83
+ part="title"
84
+ class="title"
85
+ href="${this.href}"
86
+ ${spreadAttributes({
87
+ target: this.target || undefined,
88
+ rel: this.target ? this.rel : undefined,
89
+ 'aria-current': this.current ? 'page' : undefined,
90
+ })}
91
+ >${mark}<slot></slot
92
+ ></a>
93
+ `;
94
+ }
95
+
96
+ template() {
97
+ const classes = {
98
+ item: true,
99
+ 'item--link': !!this.href,
100
+ 'item--current': !!this.current,
101
+ 'item--truncate': !!this.truncate,
102
+ };
103
+
104
+ // The role of a row is inside of the shadow root, not on the element: it is part of the
105
+ // server-rendered markup that way, and needs no script.
106
+ return html`
107
+ <div
108
+ part="base"
109
+ class="${classMap(classes)}"
110
+ role="listitem"
111
+ ${spreadAttributes({ 'aria-current': this.current && !this.href ? 'true' : undefined })}
112
+ >
113
+ ${this.mark ? html`<span part="mark" class="mark" aria-hidden="true"></span>` : ''}
114
+ <span part="start" class="start"><slot name="start"></slot></span>
115
+ <span class="body">
116
+ <span part="text" class="text">
117
+ ${this.titleTemplate()}
118
+ <span part="description" class="description"><slot name="description"></slot></span>
119
+ </span>
120
+ <span part="end" class="end"><slot name="end"></slot></span>
121
+ <span part="action" class="action"><slot name="action"></slot></span>
122
+ </span>
123
+ </div>
124
+ `;
125
+ }
126
+ }
127
+
128
+ export function define() {
129
+ defineElement('el-list-item', ListItem);
130
+ }
@@ -0,0 +1,144 @@
1
+ # ListItem
2
+
3
+ `list-item` is one row of an [`el-list`](../list/list.readme.md). It has the parts a row has everywhere: something at the start, a title, a line under it, something at the end, and a control of its own after that. With `href` the row is a link as a whole.
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="Files">
22
+ <el-list-item href="/files/notes.pdf">
23
+ <el-svg-use slot="start" name="file"></el-svg-use>
24
+ notes.pdf
25
+ <span slot="description">240 KB</span>
26
+ <el-badge slot="end" pill="true">3</el-badge>
27
+ <el-button slot="action" size="small" appearance="plain" aria-label="Remove notes.pdf">✕</el-button>
28
+ </el-list-item>
29
+ </el-list>
30
+ ```
31
+
32
+ > Boolean attributes are passed as strings (`current="true"`), matching the rest of the library.
33
+
34
+ ## API
35
+
36
+ #### Properties/Attributes
37
+
38
+ | Name | Type | Default | Description |
39
+ | --- | --- | --- | --- |
40
+ | `href` | `string` | `''` | The address the row leads to. Unset, the row is no link. |
41
+ | `target` | `string` | `''` | Where to open the address (only with `href`). |
42
+ | `rel` | `string` | `'noreferrer noopener'` | `rel` attribute for the link, written when `target` is set. |
43
+ | `current` | `boolean` | `false` | The row is the current or the chosen one: it gets `aria-current`, a bar at its start and a heavier title. |
44
+ | `mark` | `string` | `''` | Marks the row with a dot in the padding at its start. The text is read in front of the title. Unset, the row has no mark. |
45
+ | `truncate` | `boolean` | `false` | Cuts the title and the line under it after one line, with an ellipsis. |
46
+
47
+ #### Methods
48
+
49
+ _None._
50
+
51
+ #### Events
52
+
53
+ _None._
54
+
55
+ #### Slots
56
+
57
+ | Name | Description |
58
+ | --- | --- |
59
+ | (default) | The title of the row. |
60
+ | `description` | The line under the title. |
61
+ | `start` | What stands in front of the texts: an icon, an avatar. |
62
+ | `end` | What stands at the end of the row and belongs to it: a value, a count, a chevron. In a row that is a link it is part of the target of the link. |
63
+ | `action` | A control at the very end: a button, a switch, a menu. In a row that is a link it lies on top of the link and is a target of its own. |
64
+
65
+ #### CSS Parts
66
+
67
+ | Name | Description |
68
+ | ------------- | ---------------------------------------------------- |
69
+ | `base` | The row: an item of the list. |
70
+ | `mark` | The dot of `mark`, in the padding at the start. |
71
+ | `start` | The region of the `start` slot. |
72
+ | `text` | The title and the line under it. |
73
+ | `title` | The title: an `<a>` with `href`, a `<span>` without. |
74
+ | `description` | The region of the `description` slot. |
75
+ | `end` | The region of the `end` slot. |
76
+ | `action` | The region of the `action` slot. |
77
+
78
+ #### CSS Custom Properties
79
+
80
+ | Name | Default | Description |
81
+ | --- | --- | --- |
82
+ | `--el-list-padding-inline` | `--el-space-4` | The padding of the row at its start and its end. Set on the list, or for the page. Without a theme it is `1rem`. |
83
+ | `--el-list-gap` | `--el-space-3` | The gap between the start, the texts, the end and the control of the row. Set on the list, on a row, or for the page. Without a theme it is `0.75rem`. |
84
+
85
+ ## A row that is a link
86
+
87
+ With `href` the title is a native link, and the target of that link is the whole row: the padding, the start, the texts and the end. A click anywhere on the row follows the link, and it is a real link there: the context menu, a middle click and "open in a new tab" work as on any link. The name of the link is the title alone; the line under it and the end are text beside it.
88
+
89
+ The link takes the keyboard focus once, and its focus ring is drawn around the row, inside of it.
90
+
91
+ On a touch screen (`@media (any-pointer: coarse)`) a row that is a link is at least `--el-touch-target` high.
92
+
93
+ ## `end` and `action`
94
+
95
+ Both stand at the end of the row, `end` first.
96
+
97
+ - **`end`** is for what belongs to the row: a value, a count, a time, a chevron. In a row that is a link, a click on it follows the link.
98
+ - **`action`** is for a control: a button, a switch, a menu. It lies on top of the link and is a target of its own, with a place of its own in the tab order after the link.
99
+
100
+ A control belongs into `action`. In `end` it would lie under the link of the row, and a click on it would follow the link. In a row without `href` the two only differ in their order and their colour.
101
+
102
+ ## The gaps of a row
103
+
104
+ Between what is in `start` and the texts is a gap, and one in front of what is in `end` and in `action`: `--el-space-3`, `0.75rem` without a theme. A part that nothing is slotted into has no gap and no width.
105
+
106
+ - **The gap belongs to the row**, not to what the page slots into it. The row takes nothing from the margin, the padding or the border of those elements, so a reset of the page that takes them off every element (`* { margin: 0 }`) changes nothing.
107
+ - **`--el-list-gap` sets it**, on the list, on a row, or for the page:
108
+
109
+ ```css
110
+ el-list {
111
+ --el-list-gap: 1rem;
112
+ }
113
+ ```
114
+
115
+ - **A margin of the page** on an element in `start`, `end` or `action` is not the gap: it adds to it.
116
+
117
+ ## The current row
118
+
119
+ `current` marks the row of the page the user is on, or the row that is chosen: the message that is open beside the list. A row with `href` gets `aria-current="page"` on its link, a row without gets `aria-current="true"`.
120
+
121
+ It is told apart by a tint of the text colour, by a bar at its start in the accent colour and by a heavier title. The bar and the weight do not depend on a colour: where the user forces colours, the bar is drawn in a colour of the system.
122
+
123
+ ## A mark
124
+
125
+ `mark="Unread"` draws a dot in the padding at the start of the row, in the accent colour. It is out of the flow: a row with a mark has its start and its texts where a row without one has them. The text of the attribute is for assistive technology: it is read in front of the title, and it is part of the name of the link ("Unread Ada Lovelace"). Write it in the language of the page.
126
+
127
+ ## Long texts
128
+
129
+ A title that is longer than the row breaks into more lines, and so does the line under it. A text without a space (an address, a word a user typed) breaks inside of the word: a row is never wider than its list.
130
+
131
+ What is in `end` keeps its width beside a long title: a date stays on one line, and an icon keeps its size and its place. So the ends of all rows of a list end on one line. It takes half of the row at most, and breaks after that.
132
+
133
+ `truncate="true"` cuts the title and the line under it after one line, with an ellipsis. What is cut is not shown anywhere else; use it where the row leads to the whole text.
134
+
135
+ ## Accessibility
136
+
137
+ - The row has `role="listitem"`. Use it in an `el-list`, which is the list.
138
+ - A row with `href` holds one link, named by the title. The texts beside it are read with the row.
139
+ - An icon or an avatar in `start` that only repeats the title should be hidden from assistive technology (`aria-hidden="true"`), or have a name that adds something.
140
+ - A control in `action` needs a name that says which row it acts on ("Remove notes.pdf"), because a screen reader user may reach it without the row.
141
+
142
+ ## Server-side rendering
143
+
144
+ The row, its link and its parts are part of the server-rendered markup (Declarative Shadow DOM). The row runs no script: it looks the same before and after its JavaScript has loaded, and its link works before that.
@@ -0,0 +1,246 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ const style = css`
6
+ /*
7
+ * A row of the grid of its list: it spans the two columns and takes them over, so its start is
8
+ * in the first one and its texts begin where the texts of the other rows do. A row that is in
9
+ * no list has two columns of its own.
10
+ */
11
+ :host {
12
+ display: grid;
13
+ grid-column: 1 / -1;
14
+ grid-template-columns: var(--_el-list-columns, auto minmax(0, 1fr));
15
+ min-width: 0;
16
+ }
17
+
18
+ .item {
19
+ /* What the list tells its rows ends here: a row of another list in the content of this
20
+ one is in no grid of this list. */
21
+ --_el-list-columns: initial;
22
+ --_el-list-item-padding-inline: var(--el-list-padding-inline, var(--el-space-4, 1rem));
23
+ --_el-list-item-gap: var(--el-list-gap, var(--el-space-3, 0.75rem));
24
+
25
+ display: grid;
26
+ grid-column: 1 / -1;
27
+ grid-template-columns: subgrid;
28
+ align-items: center;
29
+ /* The link of a row is as large as this box, and the control at its end lies on top of
30
+ the link. Both stay inside of the row. */
31
+ position: relative;
32
+ isolation: isolate;
33
+ min-width: 0;
34
+ padding: var(--_el-list-padding-block, var(--el-space-3, 0.75rem)) var(--_el-list-item-padding-inline);
35
+ color: var(--el-color-fg, inherit);
36
+ font-family: var(--el-font-family, inherit);
37
+ font-size: var(--el-font-size-md, inherit);
38
+ line-height: var(--el-line-height, inherit);
39
+ transition: background var(--el-duration-md, 0s) var(--el-ease, linear);
40
+ /* The line between two rows. Without a theme it has no width. It is drawn inside of the
41
+ shadow root: a reset of the page that takes the border off every element reaches the
42
+ host, and wins there. */
43
+ border-block-start: var(--el-border-width, 0) solid var(--el-color-border, transparent);
44
+ }
45
+
46
+ /* Nothing stands above the first row. */
47
+ :host(:first-of-type) .item {
48
+ border-block-start: none;
49
+ }
50
+
51
+ /* ── Start ────────────────────────────────────────────────────────────── */
52
+
53
+ /*
54
+ * The gaps of a row are the gaps of its parts, not a margin of what the page slots into them:
55
+ * a rule of the page wins over a ::slotted rule, and a reset that takes the margin off every
56
+ * element would take the gaps with it.
57
+ *
58
+ * A part with a gap ends, or begins, with an empty box of its own. A gap is between two boxes:
59
+ * with something slotted there is one between it and that box, and with nothing slotted the box
60
+ * is alone, and the part has no width. So a row without a start has no gap at its start, and a
61
+ * list without a start in any row has no first column.
62
+ */
63
+ .start {
64
+ display: flex;
65
+ align-items: center;
66
+ column-gap: var(--_el-list-item-gap);
67
+ }
68
+
69
+ .start::after,
70
+ .end::before,
71
+ .action::before {
72
+ content: '';
73
+ }
74
+
75
+ ::slotted([slot='start']) {
76
+ flex: none;
77
+ }
78
+
79
+ /* ── Mark ─────────────────────────────────────────────────────────────── */
80
+
81
+ /* A dot in the middle of the padding at the start of the row. It is out of the flow, so a row
82
+ with a mark has its start and its texts where a row without one has them. A border draws
83
+ it: forced colours take a background away. */
84
+ .mark {
85
+ position: absolute;
86
+ inset-block-start: 50%;
87
+ inset-inline-start: calc(var(--_el-list-item-padding-inline) / 2);
88
+ translate: -50% -50%;
89
+ width: 0;
90
+ height: 0;
91
+ border: 0.25rem solid var(--el-color-accent, currentColor);
92
+ border-radius: 50%;
93
+ pointer-events: none;
94
+ }
95
+
96
+ :host(:dir(rtl)) .mark {
97
+ translate: 50% -50%;
98
+ }
99
+
100
+ /* The text of the mark is for assistive technology alone. */
101
+ .mark-text {
102
+ position: absolute;
103
+ width: 1px;
104
+ height: 1px;
105
+ overflow: hidden;
106
+ clip-path: inset(50%);
107
+ white-space: nowrap;
108
+ }
109
+
110
+ /* ── Texts ────────────────────────────────────────────────────────────── */
111
+
112
+ .body {
113
+ grid-column: 2;
114
+ display: flex;
115
+ align-items: center;
116
+ min-width: 0;
117
+ }
118
+
119
+ /* A text a user typed cannot widen the row: it breaks, inside of a word where it has to. */
120
+ .text {
121
+ display: flex;
122
+ flex: 1 1 auto;
123
+ flex-direction: column;
124
+ min-width: 0;
125
+ overflow-wrap: anywhere;
126
+ }
127
+
128
+ .title {
129
+ display: block;
130
+ min-width: 0;
131
+ color: inherit;
132
+ text-decoration: none;
133
+ }
134
+
135
+ .description {
136
+ display: block;
137
+ min-width: 0;
138
+ color: var(--el-color-fg-muted, inherit);
139
+ font-size: var(--el-font-size-sm, 0.875em);
140
+ }
141
+
142
+ .item--truncate .title,
143
+ .item--truncate .description {
144
+ overflow: hidden;
145
+ text-overflow: ellipsis;
146
+ white-space: nowrap;
147
+ }
148
+
149
+ /* ── End ──────────────────────────────────────────────────────────────── */
150
+
151
+ /* A value, a count, a chevron: it takes the width it has, up to half of the row, and breaks
152
+ after that. It does not shrink with the texts: beside a long title a date would break after
153
+ every character, and an icon would leave its place. */
154
+ .end {
155
+ display: flex;
156
+ flex: none;
157
+ align-items: center;
158
+ column-gap: var(--_el-list-item-gap);
159
+ min-width: 0;
160
+ max-width: 50%;
161
+ color: var(--el-color-fg-muted, inherit);
162
+ font-size: var(--el-font-size-sm, 0.875em);
163
+ overflow-wrap: anywhere;
164
+ text-align: end;
165
+ }
166
+
167
+ .action {
168
+ display: flex;
169
+ flex: none;
170
+ align-items: center;
171
+ column-gap: var(--_el-list-item-gap);
172
+ /* On top of the link of the row: a control here is a target of its own. */
173
+ position: relative;
174
+ z-index: 1;
175
+ }
176
+
177
+ /* ── A row that is a link ─────────────────────────────────────────────── */
178
+
179
+ /* The link is the title, and its target is the whole row: the box of the row, drawn by the
180
+ link. It lies on the start, the texts and the end, and under the control at the very end. */
181
+ a.title::after {
182
+ content: '';
183
+ position: absolute;
184
+ inset: 0;
185
+ }
186
+
187
+ .item--link {
188
+ cursor: pointer;
189
+ }
190
+
191
+ /* A tint of the text colour, which shows on every background. Hover only where the pointer
192
+ can hover: a touch screen leaves :hover on the row that was tapped last. */
193
+ @media (hover: hover) {
194
+ .item--link:has(a.title:hover) {
195
+ background: color-mix(in srgb, currentColor 8%, transparent);
196
+ }
197
+ }
198
+
199
+ .item--link:has(a.title:active) {
200
+ background: color-mix(in srgb, currentColor 16%, transparent);
201
+ }
202
+
203
+ /* The ring of a theme, and without one a ring in the colour of the text. It is drawn around
204
+ the row and inside of it: a list with round corners clips what is outside. */
205
+ a.title:focus-visible {
206
+ outline: none;
207
+ }
208
+
209
+ a.title:focus-visible::after {
210
+ outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
211
+ outline-offset: calc(-1 * var(--el-focus-ring-width, 2px));
212
+ }
213
+
214
+ /* ── The current row ──────────────────────────────────────────────────── */
215
+
216
+ /* A fill, a bar at the start and a heavier title. The bar and the weight tell the row apart
217
+ without a colour; the bar is a border, which forced colours keep. */
218
+ .item--current {
219
+ background: color-mix(in srgb, currentColor 8%, transparent);
220
+ }
221
+
222
+ .item--current::before {
223
+ content: '';
224
+ position: absolute;
225
+ inset-block: 0;
226
+ inset-inline-start: 0;
227
+ border-inline-start: 0.1875rem solid var(--el-color-accent, currentColor);
228
+ pointer-events: none;
229
+ }
230
+
231
+ .item--current .title {
232
+ font-weight: var(--el-font-weight-semibold, 600);
233
+ }
234
+
235
+ /* ── Touch screens ────────────────────────────────────────────────────── */
236
+
237
+ /* On a coarse pointer a row that is a link is at least --el-touch-target high. Without the
238
+ token the sizes stay as they are. */
239
+ @media (any-pointer: coarse) {
240
+ .item--link {
241
+ min-height: var(--el-touch-target, auto);
242
+ }
243
+ }
244
+ `;
245
+
246
+ export default [hostStyle(), style].join('\n');