@webtides/element-library 0.3.1 → 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 (195) hide show
  1. package/CHANGELOG.md +193 -0
  2. package/README.md +72 -56
  3. package/all.js +16 -0
  4. package/catalog.js +17 -1
  5. package/custom-elements.json +14723 -10220
  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 +15 -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 +161 -7
  27. package/src/components/description-list/description-list.changelog.md +25 -0
  28. package/src/components/description-list/description-list.define.js +3 -0
  29. package/src/components/description-list/description-list.js +44 -0
  30. package/src/components/description-list/description-list.readme.md +135 -0
  31. package/src/components/description-list/description-list.style.js +140 -0
  32. package/src/components/dialog/dialog.changelog.md +7 -0
  33. package/src/components/dialog/dialog.readme.md +5 -0
  34. package/src/components/dialog/dialog.style.js +17 -2
  35. package/src/components/drawer/drawer.changelog.md +7 -0
  36. package/src/components/drawer/drawer.readme.md +7 -6
  37. package/src/components/drawer/drawer.style.js +35 -2
  38. package/src/components/dropdown/dropdown.readme.md +6 -1
  39. package/src/components/list/list.changelog.md +24 -0
  40. package/src/components/list/list.define.js +3 -0
  41. package/src/components/list/list.js +66 -0
  42. package/src/components/list/list.readme.md +122 -0
  43. package/src/components/list/list.style.js +56 -0
  44. package/src/components/list-item/list-item.changelog.md +24 -0
  45. package/src/components/list-item/list-item.define.js +3 -0
  46. package/src/components/list-item/list-item.js +128 -0
  47. package/src/components/list-item/list-item.readme.md +126 -0
  48. package/src/components/list-item/list-item.style.js +234 -0
  49. package/src/components/menu/menu.changelog.md +27 -0
  50. package/src/components/menu/menu.define.js +3 -0
  51. package/src/components/menu/menu.events.js +5 -0
  52. package/src/components/menu/menu.js +570 -0
  53. package/src/components/menu/menu.readme.md +272 -0
  54. package/src/components/menu/menu.style.js +55 -0
  55. package/src/components/menu-group/menu-group.changelog.md +20 -0
  56. package/src/components/menu-group/menu-group.define.js +3 -0
  57. package/src/components/menu-group/menu-group.js +44 -0
  58. package/src/components/menu-group/menu-group.readme.md +74 -0
  59. package/src/components/menu-group/menu-group.style.js +38 -0
  60. package/src/components/menu-item/menu-item.changelog.md +24 -0
  61. package/src/components/menu-item/menu-item.define.js +3 -0
  62. package/src/components/menu-item/menu-item.js +130 -0
  63. package/src/components/menu-item/menu-item.readme.md +94 -0
  64. package/src/components/menu-item/menu-item.style.js +87 -0
  65. package/src/components/nav/nav.changelog.md +35 -0
  66. package/src/components/nav/nav.define.js +3 -0
  67. package/src/components/nav/nav.js +212 -0
  68. package/src/components/nav/nav.readme.md +248 -0
  69. package/src/components/nav/nav.style.js +269 -0
  70. package/src/components/nav-item/nav-item.changelog.md +25 -0
  71. package/src/components/nav-item/nav-item.define.js +3 -0
  72. package/src/components/nav-item/nav-item.js +75 -0
  73. package/src/components/nav-item/nav-item.readme.md +111 -0
  74. package/src/components/nav-item/nav-item.style.js +159 -0
  75. package/src/components/pagination/pagination.changelog.md +8 -0
  76. package/src/components/pagination/pagination.js +123 -49
  77. package/src/components/pagination/pagination.readme.md +24 -6
  78. package/src/components/pagination/pagination.style.js +11 -1
  79. package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
  80. package/src/components/scroll-to-top/scroll-to-top.js +16 -12
  81. package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
  82. package/src/components/segmented-field/segmented-field.changelog.md +27 -0
  83. package/src/components/segmented-field/segmented-field.define.js +3 -0
  84. package/src/components/segmented-field/segmented-field.js +175 -0
  85. package/src/components/segmented-field/segmented-field.readme.md +140 -0
  86. package/src/components/segmented-field/segmented-field.style.js +193 -0
  87. package/src/components/splitter/splitter.changelog.md +24 -0
  88. package/src/components/splitter/splitter.define.js +3 -0
  89. package/src/components/splitter/splitter.events.js +4 -0
  90. package/src/components/splitter/splitter.js +237 -0
  91. package/src/components/splitter/splitter.readme.md +164 -0
  92. package/src/components/splitter/splitter.style.js +100 -0
  93. package/src/components/status-bar/status-bar.changelog.md +25 -0
  94. package/src/components/status-bar/status-bar.define.js +3 -0
  95. package/src/components/status-bar/status-bar.js +74 -0
  96. package/src/components/status-bar/status-bar.readme.md +139 -0
  97. package/src/components/status-bar/status-bar.style.js +122 -0
  98. package/src/components/tab-group/tab-group.changelog.md +7 -0
  99. package/src/components/tab-group/tab-group.js +30 -9
  100. package/src/components/tab-group/tab-group.readme.md +14 -0
  101. package/src/components/toast/toast.changelog.md +6 -0
  102. package/src/components/toast/toast.readme.md +5 -3
  103. package/src/components/toast/toast.style.js +22 -6
  104. package/src/components/toolbar/toolbar.changelog.md +24 -0
  105. package/src/components/toolbar/toolbar.define.js +3 -0
  106. package/src/components/toolbar/toolbar.js +233 -0
  107. package/src/components/toolbar/toolbar.readme.md +156 -0
  108. package/src/components/toolbar/toolbar.style.js +49 -0
  109. package/src/components/tooltip/tooltip.changelog.md +11 -0
  110. package/src/components/tooltip/tooltip.js +51 -4
  111. package/src/components/tooltip/tooltip.readme.md +26 -1
  112. package/src/components/tree/tree.changelog.md +23 -0
  113. package/src/components/tree/tree.define.js +3 -0
  114. package/src/components/tree/tree.js +138 -0
  115. package/src/components/tree/tree.readme.md +119 -0
  116. package/src/components/tree/tree.style.js +16 -0
  117. package/src/components/tree-item/tree-item.changelog.md +23 -0
  118. package/src/components/tree-item/tree-item.define.js +3 -0
  119. package/src/components/tree-item/tree-item.events.js +3 -0
  120. package/src/components/tree-item/tree-item.js +246 -0
  121. package/src/components/tree-item/tree-item.readme.md +128 -0
  122. package/src/components/tree-item/tree-item.style.js +226 -0
  123. package/src/styles/appearance.style.js +47 -0
  124. package/src/styles/choice-group.style.js +1 -1
  125. package/src/styles/modal.style.js +14 -1
  126. package/src/styles/size.style.js +41 -0
  127. package/src/utils/focus.js +69 -0
  128. package/src/utils/scroll.js +24 -0
  129. package/types/all.d.ts +16 -0
  130. package/types/src/components/accordion/accordion.d.ts +3 -1
  131. package/types/src/components/app-bar/app-bar.d.ts +43 -0
  132. package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
  133. package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
  134. package/types/src/components/app-frame/app-frame.d.ts +491 -0
  135. package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
  136. package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
  137. package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
  138. package/types/src/components/button/button.d.ts +61 -0
  139. package/types/src/components/button/button.events.d.ts +4 -0
  140. package/types/src/components/description-list/description-list.d.ts +29 -0
  141. package/types/src/components/description-list/description-list.define.d.ts +1 -0
  142. package/types/src/components/description-list/description-list.style.d.ts +2 -0
  143. package/types/src/components/list/list.d.ts +39 -0
  144. package/types/src/components/list/list.define.d.ts +1 -0
  145. package/types/src/components/list/list.style.d.ts +2 -0
  146. package/types/src/components/list-item/list-item.d.ts +62 -0
  147. package/types/src/components/list-item/list-item.define.d.ts +1 -0
  148. package/types/src/components/list-item/list-item.style.d.ts +2 -0
  149. package/types/src/components/menu/menu.d.ts +266 -0
  150. package/types/src/components/menu/menu.define.d.ts +1 -0
  151. package/types/src/components/menu/menu.events.d.ts +6 -0
  152. package/types/src/components/menu/menu.style.d.ts +2 -0
  153. package/types/src/components/menu-group/menu-group.d.ts +24 -0
  154. package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
  155. package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
  156. package/types/src/components/menu-item/menu-item.d.ts +59 -0
  157. package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
  158. package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
  159. package/types/src/components/nav/nav.d.ts +103 -0
  160. package/types/src/components/nav/nav.define.d.ts +1 -0
  161. package/types/src/components/nav/nav.style.d.ts +2 -0
  162. package/types/src/components/nav-item/nav-item.d.ts +39 -0
  163. package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
  164. package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
  165. package/types/src/components/pagination/pagination.d.ts +31 -2
  166. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
  167. package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
  168. package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
  169. package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
  170. package/types/src/components/splitter/splitter.d.ts +127 -0
  171. package/types/src/components/splitter/splitter.define.d.ts +1 -0
  172. package/types/src/components/splitter/splitter.events.d.ts +5 -0
  173. package/types/src/components/splitter/splitter.style.d.ts +2 -0
  174. package/types/src/components/status-bar/status-bar.d.ts +44 -0
  175. package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
  176. package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
  177. package/types/src/components/tab-group/tab-group.d.ts +17 -0
  178. package/types/src/components/toolbar/toolbar.d.ts +96 -0
  179. package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
  180. package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
  181. package/types/src/components/tooltip/tooltip.d.ts +26 -0
  182. package/types/src/components/tree/tree.d.ts +62 -0
  183. package/types/src/components/tree/tree.define.d.ts +1 -0
  184. package/types/src/components/tree/tree.style.d.ts +2 -0
  185. package/types/src/components/tree-item/tree-item.d.ts +106 -0
  186. package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
  187. package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
  188. package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
  189. package/types/src/styles/appearance.style.d.ts +31 -0
  190. package/types/src/styles/choice-group.style.d.ts +1 -1
  191. package/types/src/styles/modal.style.d.ts +5 -0
  192. package/types/src/styles/size.style.d.ts +24 -0
  193. package/types/src/utils/focus.d.ts +25 -0
  194. package/types/src/utils/scroll.d.ts +11 -0
  195. package/web-types.json +2530 -393
@@ -0,0 +1,128 @@
1
+ # TreeItem
2
+
3
+ `tree-item` is one entry of an [`el-tree`](../tree/tree.readme.md), and the entries below it. It has the parts of a row of a list: an icon at the start, its name, a count at the end. With `href` the name is a link. An entry with entries below it opens and closes.
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/tree/define';
17
+ import '@webtides/element-library/tree-item/define';
18
+ ```
19
+
20
+ ```html
21
+ <el-tree label="Folders">
22
+ <el-tree-item label="Inbox" href="/inbox" open="true">
23
+ <el-svg-use slot="start" name="folder" aria-hidden="true"></el-svg-use>
24
+ <span slot="end">12</span>
25
+
26
+ <el-tree-item label="Work" href="/inbox/work" current="true"></el-tree-item>
27
+ <el-tree-item label="Private" href="/inbox/private"></el-tree-item>
28
+ </el-tree-item>
29
+ </el-tree>
30
+ ```
31
+
32
+ The entries below an entry are the `el-tree-item` elements the page writes into it, to any depth.
33
+
34
+ > Boolean attributes are passed as strings (`open="true"`), matching the rest of the library.
35
+
36
+ ## API
37
+
38
+ #### Properties/Attributes
39
+
40
+ | Name | Type | Default | Description |
41
+ | --- | --- | --- | --- |
42
+ | `label` | `string` | `''` | The name of the entry. |
43
+ | `href` | `string` | `''` | The address the entry leads to. Unset, the entry is no link. |
44
+ | `target` | `string` | `''` | Where to open the address (only with `href`). |
45
+ | `rel` | `string` | `'noreferrer noopener'` | `rel` attribute for the link, written when `target` is set. |
46
+ | `current` | `boolean` | `false` | The entry is the one of the page the user is on. |
47
+ | `open` | `boolean` | `false` | Whether the entries below this one are shown. Reflected to the `open` attribute, which the stylesheet reads. |
48
+
49
+ `hasItems` (read only) says whether the entry has entries below it.
50
+
51
+ #### Methods
52
+
53
+ | Name | Description |
54
+ | --- | --- |
55
+ | `toggle(open?)` | Opens or closes the entry, as its button does, and fires `tree-item-toggle`. Without an argument it goes to the other state. An entry without entries below it stays as it is. |
56
+
57
+ #### Events
58
+
59
+ | Name | Detail | Description |
60
+ | --- | --- | --- |
61
+ | `tree-item-toggle` | `{ open: boolean }` | Fired when the user has opened or closed the entry, with its button or with the arrow keys. Not fired when `open` is set from a script. It bubbles, through the entries above and the tree: look at `event.target`. |
62
+
63
+ #### Slots
64
+
65
+ | Name | Description |
66
+ | --- | --- |
67
+ | (default) | The entries below this one: `el-tree-item` elements. |
68
+ | `label` | The name of the entry. Takes precedence over the `label` attribute. |
69
+ | `start` | What stands in front of the name: an icon. |
70
+ | `end` | What stands at the end of the row: a count. In an entry that is a link it is part of the target of the link. |
71
+
72
+ #### CSS Parts
73
+
74
+ | Name | Description |
75
+ | --- | --- |
76
+ | `base` | The entry: an item of the list it is in. |
77
+ | `row` | The row of the entry: its button, its start, its name and its end. |
78
+ | `toggle` | The button that opens and closes the entries below, on an entry that is a link and has such entries. |
79
+ | `start` | The region of the `start` slot. |
80
+ | `label` | The name: an `<a>` with `href`; without, a `<button>` when the entry has entries below it, and a `<span>` when it has none. |
81
+ | `end` | The region of the `end` slot. |
82
+ | `children` | The list of the entries below (`role="list"`). |
83
+
84
+ #### CSS Custom Properties
85
+
86
+ | Name | Default | Description |
87
+ | --- | --- | --- |
88
+ | `--el-tree-indent` | `--el-space-4` | How far the entries below stand in from this one. Set on the tree, or for the page. Without a theme it is `1rem`. |
89
+
90
+ Reads the design tokens of the library: `--el-space-1` and `--el-space-2` for the room in a row, `--el-color-fg` and `--el-color-fg-muted` for the name and the count, `--el-color-accent` for the bar of the current entry, `--el-radius-md` for the corners of a row, `--el-focus-ring-*` for the focus ring.
91
+
92
+ ## The row
93
+
94
+ A row is as wide as the tree on every level: the fill of the row under the pointer, and of the current entry, reaches from edge to edge, and what stands in the row is moved in by the level. Every row has the place of the button of a branch, with or without entries below, so the names of a level begin on one line.
95
+
96
+ A name that is longer than the tree breaks into more lines, inside of a word where it has to.
97
+
98
+ ## A link, a branch, a name
99
+
100
+ - **With `href`** the name is a native link, and its target is the whole row: the start, the name, the end and the room around them. An entry that also has entries below it gets a button in front of the name, which opens and closes them. The button lies on top of the link and is a target of its own.
101
+ - **Without `href`, with entries below**, the entry is a button as a whole: a click anywhere on its row opens and closes it. That is a category that leads nowhere itself.
102
+ - **Without `href` and without entries below**, the entry is a text.
103
+
104
+ ## Opening and closing
105
+
106
+ `open="true"` shows the entries below. The stylesheet of the entry reads that attribute, so a server-rendered entry is open or closed from the first paint. The button of a branch, the arrow keys of the tree and `toggle()` change it and fire `tree-item-toggle`; setting `open` from a script changes it and fires nothing.
107
+
108
+ An entry without entries below it has no button and no state: `open` does nothing there. When entries come later, the button comes with them.
109
+
110
+ ## The current entry
111
+
112
+ `current` marks the entry of the page the user is on. With `href` its link gets `aria-current="page"`, without it the name gets `aria-current="true"`.
113
+
114
+ 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 name. 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.
115
+
116
+ The tree does not open the branches above the current entry. Render them open.
117
+
118
+ ## Accessibility
119
+
120
+ - The entry has `role="listitem"`, and the entries below it are in a list of their own (`role="list"`).
121
+ - The button of a branch is named by the name of its entry (`aria-labelledby`), says whether the branch is open (`aria-expanded`) and which list it opens (`aria-controls`).
122
+ - An icon in `start` that only repeats the name should be hidden from assistive technology (`aria-hidden="true"`).
123
+ - For the keyboard, see [`el-tree`](../tree/tree.readme.md#keyboard).
124
+ - On a touch screen (`@media (any-pointer: coarse)`) a row that is a target is at least `--el-touch-target` high, and the button of a branch is that wide and high.
125
+
126
+ ## Server-side rendering
127
+
128
+ The entry, its link, its button and the list below it are part of the server-rendered markup (Declarative Shadow DOM). Whether the entry has entries below it is asked of its children, which a server knows as well. Its links work before the script has run; opening and closing needs the script.
@@ -0,0 +1,226 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ const style = css`
6
+ /*
7
+ * How far in the entry stands. An entry takes what the list it is in hands down, and hands
8
+ * down one step more to the list below it. The two have different names: a property cannot be
9
+ * counted up from its own inherited value.
10
+ */
11
+ :host {
12
+ display: block;
13
+ --_el-tree-indent: var(--_el-tree-indent-below, 0px);
14
+ }
15
+
16
+ .children {
17
+ --_el-tree-indent-below: calc(var(--_el-tree-indent) + var(--el-tree-indent, var(--el-space-4, 1rem)));
18
+ }
19
+
20
+ /* Closed unless the host is open. The rule reads the attribute of the host, which is all there
21
+ is before the element starts: a server-rendered tree shows its open branches, and no other,
22
+ from the first paint. */
23
+ :host(:not([open='true'])) .children {
24
+ display: none;
25
+ }
26
+
27
+ /* ── Row ──────────────────────────────────────────────────────────────── */
28
+
29
+ /* As wide as the tree, on every level: the fill of a row under the pointer and of the current
30
+ row reaches from edge to edge, and what stands in the row is moved in. */
31
+ .row {
32
+ --_el-tree-row-padding: var(--el-space-2, 0.5rem);
33
+ --_el-tree-toggle-size: 1.5rem;
34
+
35
+ display: flex;
36
+ align-items: center;
37
+ gap: var(--el-space-1, 0.25rem);
38
+ /* The link of an entry is as large as this box, and the button that opens the entry lies
39
+ on top of it. Both stay inside of the row. */
40
+ position: relative;
41
+ isolation: isolate;
42
+ min-width: 0;
43
+ padding-block: var(--el-space-1, 0.25rem);
44
+ padding-inline: calc(var(--_el-tree-row-padding) + var(--_el-tree-indent)) var(--_el-tree-row-padding);
45
+ border-radius: var(--el-radius-md, 0);
46
+ color: var(--el-color-fg, inherit);
47
+ font-family: var(--el-font-family, inherit);
48
+ font-size: var(--el-font-size-md, inherit);
49
+ line-height: var(--el-line-height, inherit);
50
+ transition: background var(--el-duration-md, 0s) var(--el-ease, linear);
51
+ }
52
+
53
+ /* ── Button of a branch ───────────────────────────────────────────────── */
54
+
55
+ /* Every row has the place of the button, with or without entries below: the names of a level
56
+ begin on one line. */
57
+ .toggle,
58
+ .toggle-place {
59
+ display: inline-flex;
60
+ flex: none;
61
+ align-items: center;
62
+ justify-content: center;
63
+ width: var(--_el-tree-toggle-size);
64
+ height: var(--_el-tree-toggle-size);
65
+ color: var(--el-color-fg-muted, inherit);
66
+ }
67
+
68
+ .toggle {
69
+ /* On top of the link of the row: a target of its own. */
70
+ position: relative;
71
+ z-index: 1;
72
+ margin: 0;
73
+ padding: 0;
74
+ border: none;
75
+ border-radius: var(--el-radius-sm, 2px);
76
+ background: transparent;
77
+ font: inherit;
78
+ cursor: pointer;
79
+ }
80
+
81
+ @media (hover: hover) {
82
+ .toggle:hover {
83
+ background: color-mix(in srgb, currentColor 16%, transparent);
84
+ }
85
+ }
86
+
87
+ .toggle:focus-visible {
88
+ outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
89
+ outline-offset: calc(-1 * var(--el-focus-ring-width, 2px));
90
+ }
91
+
92
+ /* It points along the reading direction while the entry is closed, and down while it is open. */
93
+ .chevron {
94
+ width: 1em;
95
+ height: 1em;
96
+ transition: rotate var(--el-duration-md, 0s) var(--el-ease, linear);
97
+ }
98
+
99
+ :host(:dir(rtl)) .chevron {
100
+ scale: -1 1;
101
+ }
102
+
103
+ :host([open='true']) .chevron {
104
+ rotate: 90deg;
105
+ }
106
+
107
+ :host([open='true']:dir(rtl)) .chevron {
108
+ rotate: -90deg;
109
+ }
110
+
111
+ /* ── Start, name, end ─────────────────────────────────────────────────── */
112
+
113
+ .start {
114
+ display: inline-flex;
115
+ flex: none;
116
+ align-items: center;
117
+ }
118
+
119
+ /* A name a user typed cannot widen the tree: it breaks, inside of a word where it has to. */
120
+ .label {
121
+ flex: 1 1 auto;
122
+ min-width: 0;
123
+ margin: 0;
124
+ padding: 0;
125
+ border: none;
126
+ background: none;
127
+ color: inherit;
128
+ font: inherit;
129
+ text-align: start;
130
+ text-decoration: none;
131
+ overflow-wrap: anywhere;
132
+ }
133
+
134
+ button.label {
135
+ cursor: pointer;
136
+ }
137
+
138
+ /* A count: quieter than the name. */
139
+ .end {
140
+ display: inline-flex;
141
+ flex: none;
142
+ align-items: center;
143
+ color: var(--el-color-fg-muted, inherit);
144
+ font-size: var(--el-font-size-sm, 0.875em);
145
+ }
146
+
147
+ /* ── A row that leads somewhere, or opens ─────────────────────────────── */
148
+
149
+ /* The target of the link, and of a name that is a button, is the whole row: the box of the
150
+ row, drawn by the name. It lies on the start and the end, and under the button of a branch
151
+ that is a link. */
152
+ a.label::after,
153
+ button.label::after {
154
+ content: '';
155
+ position: absolute;
156
+ inset: 0;
157
+ border-radius: inherit;
158
+ }
159
+
160
+ .row:has(a.label, button.label) {
161
+ cursor: pointer;
162
+ }
163
+
164
+ /* A tint of the text colour, which shows on every background. Hover only where the pointer
165
+ can hover: a touch screen leaves :hover on the row that was tapped last. */
166
+ @media (hover: hover) {
167
+ .row:has(.label:is(a, button):hover) {
168
+ background: color-mix(in srgb, currentColor 8%, transparent);
169
+ }
170
+ }
171
+
172
+ .row:has(.label:is(a, button):active) {
173
+ background: color-mix(in srgb, currentColor 16%, transparent);
174
+ }
175
+
176
+ /* The ring of a theme, and without one a ring in the colour of the text. It is drawn around
177
+ the row and inside of it. */
178
+ .label:focus-visible {
179
+ outline: none;
180
+ }
181
+
182
+ .label:focus-visible::after {
183
+ outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
184
+ outline-offset: calc(-1 * var(--el-focus-ring-width, 2px));
185
+ }
186
+
187
+ /* ── The current entry ────────────────────────────────────────────────── */
188
+
189
+ /* A fill, a bar at the start and a heavier name. The bar and the weight tell the entry apart
190
+ without a colour; the bar is a border, which forced colours keep. */
191
+ .row--current {
192
+ background: color-mix(in srgb, currentColor 8%, transparent);
193
+ }
194
+
195
+ .row--current::before {
196
+ content: '';
197
+ position: absolute;
198
+ inset-block: 0;
199
+ inset-inline-start: 0;
200
+ border-inline-start: 0.1875rem solid var(--el-color-accent, currentColor);
201
+ border-start-start-radius: inherit;
202
+ border-end-start-radius: inherit;
203
+ pointer-events: none;
204
+ }
205
+
206
+ .row--current .label {
207
+ font-weight: var(--el-font-weight-semibold, 600);
208
+ }
209
+
210
+ /* ── Touch screens ────────────────────────────────────────────────────── */
211
+
212
+ /* On a coarse pointer a row that is a target is at least --el-touch-target high, and so is the
213
+ button of a branch, in both directions. Without the token the sizes stay as they are. */
214
+ @media (any-pointer: coarse) {
215
+ .row:has(a.label, button.label) {
216
+ min-height: var(--el-touch-target, auto);
217
+ }
218
+
219
+ .toggle {
220
+ min-width: var(--el-touch-target, var(--_el-tree-toggle-size));
221
+ min-height: var(--el-touch-target, var(--_el-tree-toggle-size));
222
+ }
223
+ }
224
+ `;
225
+
226
+ export default [hostStyle(), style].join('\n');
@@ -40,3 +40,50 @@ export default function appearanceStyle(surface, host = ':host') {
40
40
  }
41
41
  `;
42
42
  }
43
+
44
+ /**
45
+ * The appearance a container gives to the controls inside of it: a toolbar with
46
+ * `appearance="plain"` has plain buttons. The container declares `appearance` as a reflected
47
+ * property and composes this module; it sets one of two properties on the host, which are
48
+ * inherited at any depth and into shadow roots:
49
+ *
50
+ * - `--_el-context-appearance-outlined`
51
+ * - `--_el-context-appearance-plain`
52
+ *
53
+ * Each is a switch: it is set to nothing, or it is not set. A stylesheet cannot ask for the value
54
+ * of a property, so the control puts the switch in front of a value in a property of its own,
55
+ * which is valid only where the switch is set, and falls back from one to the next:
56
+ *
57
+ * --_el-button-if-plain: var(--_el-context-appearance-plain) transparent;
58
+ * background: var(--_el-button-if-plain, var(--_el-variant-fill));
59
+ *
60
+ * Outside of a container none of the switches is set, and the control paints what it painted
61
+ * before, with the same values. As with the size, the control only does so while the page has not
62
+ * given it an appearance of its own, and marks that from its template.
63
+ *
64
+ * `filled` sets nothing: it is the appearance a control has anyway.
65
+ *
66
+ * The appearance a container has without the attribute is given as `byDefault`. The rule for it
67
+ * selects a host that has no `appearance` attribute as well: element-js writes the default onto
68
+ * the element when it starts, and in server-rendered markup it is not there yet.
69
+ * @param {string} [host] - `':host'` (the default), or the tag of a component without a shadow root.
70
+ * @param {'filled'|'outlined'|'plain'} [byDefault] - The appearance of a container without the
71
+ * attribute. Default `'filled'`.
72
+ * @returns {string}
73
+ */
74
+ export function appearanceContextStyle(host = ':host', byDefault = 'filled') {
75
+ const selectorOf = (appearance) =>
76
+ [`[appearance='${appearance}']`, ...(appearance === byDefault ? [':not([appearance])'] : [])]
77
+ .map((condition) => hostSelector(host, condition))
78
+ .join(',\n ');
79
+
80
+ return css`
81
+ ${selectorOf('outlined')} {
82
+ --_el-context-appearance-outlined: ;
83
+ }
84
+
85
+ ${selectorOf('plain')} {
86
+ --_el-context-appearance-plain: ;
87
+ }
88
+ `;
89
+ }
@@ -5,7 +5,7 @@ const css = String.raw;
5
5
  /**
6
6
  * A group of choices in a field: a fieldset with a legend that holds the options, each of them a
7
7
  * label around a native radio or checkbox (`el-radio-field`, `el-checkbox-group-field`,
8
- * `el-rating-field`).
8
+ * `el-rating-field`, `el-segmented-field`).
9
9
  *
10
10
  * - The fieldset is the column of the field. It loses the border and the padding of the browser
11
11
  * and stacks the legend, the help message, the options and the error message: all of them are
@@ -15,6 +15,11 @@ const css = String.raw;
15
15
  * are different properties from the ones set here, so the order of the two stylesheets does not
16
16
  * decide anything.
17
17
  *
18
+ * A surface that reaches an edge of the screen keeps what is in it clear of the notch and the home
19
+ * indicator of a phone: the component says how much room each side needs
20
+ * (`--_el-modal-inset-block-start`, `-block-end`, `-inline-start`, `-inline-end`), and that room
21
+ * is the padding of the surface here.
22
+ *
18
23
  * The module takes no host: a dialog with slots needs a shadow root, and the host of one is
19
24
  * `:host`.
20
25
  * @returns {string}
@@ -30,7 +35,15 @@ export default function modalStyle() {
30
35
  * every visual token falls back to a null-ish value so an unthemed surface imposes nothing.
31
36
  */
32
37
  dialog {
33
- padding: 0;
38
+ /* The surface keeps the room of the screen itself. What is in it and would ask the
39
+ screen when it is alone (an el-app-bar, an el-nav) has nothing to keep clear of. */
40
+ --_el-context-inset-block-start: 0px;
41
+ --_el-context-inset-block-end: 0px;
42
+ --_el-context-inset-inline-start: 0px;
43
+ --_el-context-inset-inline-end: 0px;
44
+
45
+ padding-block: var(--_el-modal-inset-block-start, 0px) var(--_el-modal-inset-block-end, 0px);
46
+ padding-inline: var(--_el-modal-inset-inline-start, 0px) var(--_el-modal-inset-inline-end, 0px);
34
47
  background: var(--el-color-bg, transparent);
35
48
  color: var(--el-color-fg, inherit);
36
49
  box-shadow: var(--el-shadow-lg, none);
@@ -46,3 +46,44 @@ export default function sizeStyle(host = ':host') {
46
46
  }
47
47
  `;
48
48
  }
49
+
50
+ /**
51
+ * The size a container gives to the controls inside of it: a toolbar with `size="small"` has small
52
+ * controls. The container declares `size` as a reflected property and composes this module; it
53
+ * sets properties on the host that are inherited, at any depth and into shadow roots:
54
+ *
55
+ * - `--_el-context-size-height`, `--_el-context-size-padding-block`,
56
+ * `--_el-context-size-padding-inline`, `--_el-context-size-font-size`
57
+ *
58
+ * They are what `sizeStyle()` resolves a size to, under other names: a control declares the
59
+ * `--_el-size-` properties on its own host, so an inherited value of the same name would never
60
+ * reach it. A control that takes its size from a container reads the context first and its own
61
+ * size after it, on the element that it paints:
62
+ *
63
+ * min-height: var(--_el-context-size-height, var(--_el-size-height));
64
+ *
65
+ * It does so only while the page has not given it a size of its own. The stylesheet cannot ask
66
+ * that: element-js writes the default onto the element. So the control marks the element it paints
67
+ * from its template (`button--inherit-size` of `el-button`).
68
+ *
69
+ * `medium` sets nothing: it is the size a control has anyway.
70
+ * @param {string} [host] - `':host'` (the default), or the tag of a component without a shadow root.
71
+ * @returns {string}
72
+ */
73
+ export function sizeContextStyle(host = ':host') {
74
+ return css`
75
+ ${hostSelector(host, "[size='small']")} {
76
+ --_el-context-size-height: calc(var(--el-control-height, 2.5rem) * 0.8);
77
+ --_el-context-size-padding-block: var(--el-space-1, 0.25em);
78
+ --_el-context-size-padding-inline: var(--el-space-3, 0.75em);
79
+ --_el-context-size-font-size: var(--el-font-size-sm, 0.875rem);
80
+ }
81
+
82
+ ${hostSelector(host, "[size='large']")} {
83
+ --_el-context-size-height: calc(var(--el-control-height, 2.5rem) * 1.25);
84
+ --_el-context-size-padding-block: var(--el-space-3, 0.75em);
85
+ --_el-context-size-padding-inline: var(--el-space-5, 1.5em);
86
+ --_el-context-size-font-size: calc(var(--el-font-size-md, 1rem) * 1.125);
87
+ }
88
+ `;
89
+ }
@@ -16,3 +16,72 @@
16
16
  export function focusLeft(group, event) {
17
17
  return !(group.contains(event.relatedTarget) || group.matches(':active'));
18
18
  }
19
+
20
+ /** What takes the focus by its tag or its attributes. Whether it does right now is asked of each one. */
21
+ const FOCUSABLE =
22
+ 'a[href], button, input:not([type="hidden"]), select, textarea, summary, [tabindex], [contenteditable=""], [contenteditable="true"]';
23
+
24
+ /**
25
+ * The element that has the focus, also when it is inside of a shadow root: `document.activeElement`
26
+ * stops at the element whose shadow root the focus is in.
27
+ * @returns {Element | null}
28
+ */
29
+ export function activeElement() {
30
+ let active = document.activeElement;
31
+ while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
32
+ return active;
33
+ }
34
+
35
+ /**
36
+ * The elements inside of `root` that the user can move the focus to, in the order of the document:
37
+ * the controls of the page, and the ones inside of the shadow roots of custom elements, the
38
+ * `<button>` of an `el-button` for example. Left out are controls that are disabled, inert, not
39
+ * shown or taken out of the tab order (`tabindex="-1"`).
40
+ *
41
+ * Each radio of a group is one of them, also the ones that are not checked: the Tab key stops at
42
+ * a group once, the arrow keys of a toolbar at every radio.
43
+ * @param {Element} root
44
+ * @returns {HTMLElement[]}
45
+ */
46
+ export function focusableElements(root) {
47
+ const found = [];
48
+ const visit = (parent) => {
49
+ for (const element of parent.children) {
50
+ if (element.matches(FOCUSABLE) && takesFocus(element)) found.push(element);
51
+ // The controls of a component first, then what the page has put into it.
52
+ if (element.shadowRoot) visit(element.shadowRoot);
53
+ visit(element);
54
+ }
55
+ };
56
+ visit(root);
57
+ return found;
58
+ }
59
+
60
+ /**
61
+ * Whether the user can move the focus to `root` or to an element inside of it, the ones in shadow
62
+ * roots included. It stops at the first one it finds, which `focusableElements()` does not.
63
+ * @param {Element} root
64
+ * @returns {boolean}
65
+ */
66
+ export function containsFocusable(root) {
67
+ const visit = (parent) => {
68
+ for (const element of parent.children) {
69
+ if (element.matches(FOCUSABLE) && takesFocus(element)) return true;
70
+ if (element.shadowRoot && visit(element.shadowRoot)) return true;
71
+ if (visit(element)) return true;
72
+ }
73
+ return false;
74
+ };
75
+ return (root.matches(FOCUSABLE) && takesFocus(root)) || visit(root);
76
+ }
77
+
78
+ /**
79
+ * @param {HTMLElement} element
80
+ * @returns {boolean}
81
+ */
82
+ function takesFocus(element) {
83
+ if (element.matches(':disabled') || element.getAttribute('tabindex') === '-1') return false;
84
+ if (element.closest('[inert]')) return false;
85
+ // Not rendered, or hidden: by itself, or by something around it.
86
+ return element.checkVisibility?.({ visibilityProperty: true }) ?? element.getClientRects().length > 0;
87
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The element that scrolls what an element is in, up and down: the nearest one around it that has
3
+ * more content than height and an overflow that scrolls. `null` where that is the document, which
4
+ * the window scrolls.
5
+ *
6
+ * The way up goes through slots and out of shadow roots: an element in the content of an
7
+ * `el-app-frame` is scrolled by a region in the shadow root of the frame.
8
+ * @param {Element} element
9
+ * @returns {HTMLElement | null}
10
+ */
11
+ export function scrollContainer(element) {
12
+ let node = element.assignedSlot ?? element.parentNode ?? element.host;
13
+
14
+ while (node) {
15
+ if (node instanceof Element && node !== document.documentElement && node !== document.body) {
16
+ const { overflowY } = getComputedStyle(node);
17
+ const scrolls = overflowY === 'auto' || overflowY === 'scroll';
18
+ if (scrolls && node.scrollHeight > node.clientHeight) return node;
19
+ }
20
+ node = node.assignedSlot ?? node.parentNode ?? node.host;
21
+ }
22
+
23
+ return null;
24
+ }
package/types/all.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import './src/components/accordion/accordion.define.js';
2
2
  import './src/components/accordion-group/accordion-group.define.js';
3
3
  import './src/components/amount-field/amount-field.define.js';
4
+ import './src/components/app-bar/app-bar.define.js';
5
+ import './src/components/app-frame/app-frame.define.js';
4
6
  import './src/components/avatar/avatar.define.js';
5
7
  import './src/components/badge/badge.define.js';
6
8
  import './src/components/breadcrumb/breadcrumb.define.js';
@@ -15,6 +17,7 @@ import './src/components/color-field/color-field.define.js';
15
17
  import './src/components/combobox-field/combobox-field.define.js';
16
18
  import './src/components/copy-button/copy-button.define.js';
17
19
  import './src/components/date-field/date-field.define.js';
20
+ import './src/components/description-list/description-list.define.js';
18
21
  import './src/components/dialog/dialog.define.js';
19
22
  import './src/components/divider/divider.define.js';
20
23
  import './src/components/drawer/drawer.define.js';
@@ -24,6 +27,13 @@ import './src/components/file-field/file-field.define.js';
24
27
  import './src/components/form-field/form-field.define.js';
25
28
  import './src/components/input-field/input-field.define.js';
26
29
  import './src/components/lazy-src/lazy-src.define.js';
30
+ import './src/components/list/list.define.js';
31
+ import './src/components/list-item/list-item.define.js';
32
+ import './src/components/menu/menu.define.js';
33
+ import './src/components/menu-group/menu-group.define.js';
34
+ import './src/components/menu-item/menu-item.define.js';
35
+ import './src/components/nav/nav.define.js';
36
+ import './src/components/nav-item/nav-item.define.js';
27
37
  import './src/components/notification/notification.define.js';
28
38
  import './src/components/otp-field/otp-field.define.js';
29
39
  import './src/components/pagination/pagination.define.js';
@@ -36,10 +46,13 @@ import './src/components/range-field/range-field.define.js';
36
46
  import './src/components/rating-field/rating-field.define.js';
37
47
  import './src/components/scroll-to/scroll-to.define.js';
38
48
  import './src/components/scroll-to-top/scroll-to-top.define.js';
49
+ import './src/components/segmented-field/segmented-field.define.js';
39
50
  import './src/components/select-field/select-field.define.js';
40
51
  import './src/components/skeleton/skeleton.define.js';
41
52
  import './src/components/slider/slider.define.js';
42
53
  import './src/components/spinner/spinner.define.js';
54
+ import './src/components/splitter/splitter.define.js';
55
+ import './src/components/status-bar/status-bar.define.js';
43
56
  import './src/components/sticky/sticky.define.js';
44
57
  import './src/components/svg-use/svg-use.define.js';
45
58
  import './src/components/switch-field/switch-field.define.js';
@@ -50,5 +63,8 @@ import './src/components/tag/tag.define.js';
50
63
  import './src/components/tag-field/tag-field.define.js';
51
64
  import './src/components/textarea-field/textarea-field.define.js';
52
65
  import './src/components/toast/toast.define.js';
66
+ import './src/components/toolbar/toolbar.define.js';
53
67
  import './src/components/tooltip/tooltip.define.js';
54
68
  import './src/components/transition-classes/transition-classes.define.js';
69
+ import './src/components/tree/tree.define.js';
70
+ import './src/components/tree-item/tree-item.define.js';
@@ -22,7 +22,9 @@ import Events from './accordion.events.js';
22
22
  * `el-accordion:state(open)` from outside.
23
23
  *
24
24
  * @property {boolean} open - Controls whether the accordion is expanded (`true`) or collapsed
25
- * (`false`). Reflected to the `open` attribute.
25
+ * (`false`). Reflected to the `open` attribute. The stylesheet of the element reads that
26
+ * attribute: an accordion without `open="true"` shows its header alone, before the element
27
+ * starts as well.
26
28
  */
27
29
  export default class Accordion extends TemplateElement {
28
30
  open: any;