@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,193 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+ import sizeStyle from '../../styles/size.style.js';
3
+ import formControlStyle from '../../styles/form-control.style.js';
4
+ import choiceGroupStyle from '../../styles/choice-group.style.js';
5
+
6
+ const css = String.raw;
7
+
8
+ /**
9
+ * The fieldset as the column of the field, the option as the hit area of its radio and the hidden
10
+ * native radio are the shared module `choice-group`. Here: the options as a row of joined buttons,
11
+ * and the segment that is drawn in the place of a radio.
12
+ */
13
+ const style = css`
14
+ el-segmented-field {
15
+ /* A row as wide as its options, and never wider than its place: the options share the
16
+ width then, and a label that does not fit breaks into lines. */
17
+ .options {
18
+ display: flex;
19
+ align-self: flex-start;
20
+ max-width: 100%;
21
+
22
+ /* The size of the options: the one of the field, from the size module. */
23
+ --_el-segment-height: var(--_el-size-height);
24
+ --_el-segment-padding-block: var(--_el-size-padding-block);
25
+ --_el-segment-padding-inline: var(--_el-size-padding-inline);
26
+ --_el-segment-font-size: var(--_el-size-font-size);
27
+ }
28
+
29
+ /* A container that gives its controls one size, a toolbar, says so in properties that are
30
+ inherited (see sizeContextStyle()). The field reads them while the page has not set a
31
+ size on the field itself: the template marks the row then. Outside of such a container
32
+ they are not set, and the size is the one of the field. */
33
+ .options--inherit-size {
34
+ --_el-segment-height: var(--_el-context-size-height, var(--_el-size-height));
35
+ --_el-segment-padding-block: var(--_el-context-size-padding-block, var(--_el-size-padding-block));
36
+ --_el-segment-padding-inline: var(--_el-context-size-padding-inline, var(--_el-size-padding-inline));
37
+ --_el-segment-font-size: var(--_el-context-size-font-size, var(--_el-size-font-size));
38
+ }
39
+
40
+ /* The label is the hit area. It has no gap and no room of its own: the segment fills it,
41
+ on a touch screen up to the least size of a target as well. */
42
+ .option {
43
+ position: relative;
44
+ flex: 0 1 auto;
45
+ align-items: stretch;
46
+ gap: 0;
47
+ min-width: 0;
48
+ }
49
+
50
+ /* Touch screens: an option may share the width of a narrow row, and still is no narrower
51
+ than a target. The shared module says the same for every option of a field; the rule
52
+ above, for the row, would take it back. */
53
+ @media (any-pointer: coarse) {
54
+ .option {
55
+ min-width: var(--el-touch-target, 0px);
56
+ }
57
+ }
58
+
59
+ /* ── Segment ──────────────────────────────────────────────────────── */
60
+
61
+ /* An outlined button of the size of the field. The fallbacks render a usable control
62
+ without a theme: a border in the text colour of the page. */
63
+ .segment {
64
+ --_el-segment-radius: var(--el-radius-md, 4px);
65
+
66
+ position: relative;
67
+ display: flex;
68
+ flex: 1 1 auto;
69
+ align-items: center;
70
+ justify-content: center;
71
+ gap: var(--el-space-2, 0.5em);
72
+ /* The height of the size counts from the border, as on el-button. The field renders
73
+ into the page, where nothing has said so. */
74
+ box-sizing: border-box;
75
+ min-width: 0;
76
+ min-height: var(--_el-segment-height);
77
+ padding: var(--_el-segment-padding-block) var(--_el-segment-padding-inline);
78
+ border: var(--el-border-width, 1px) solid var(--el-color-border, currentColor);
79
+ color: var(--el-color-fg, inherit);
80
+ font-family: var(--el-font-family, inherit);
81
+ font-size: var(--_el-segment-font-size);
82
+ font-weight: 600;
83
+ line-height: var(--el-line-height, 1.5);
84
+ text-align: center;
85
+ overflow-wrap: anywhere;
86
+ user-select: none;
87
+ transition: background var(--el-duration-md, 0s) var(--el-ease, linear);
88
+ }
89
+
90
+ /* Only the outer corners of the row are round. The properties follow the reading
91
+ direction, so the start of the row is at the right in a text that runs from right to
92
+ left. */
93
+ .option:first-child .segment {
94
+ border-start-start-radius: var(--_el-segment-radius);
95
+ border-end-start-radius: var(--_el-segment-radius);
96
+ }
97
+
98
+ .option:last-child .segment {
99
+ border-start-end-radius: var(--_el-segment-radius);
100
+ border-end-end-radius: var(--_el-segment-radius);
101
+ }
102
+
103
+ /* With a neighbour in front: the border at the start lies on the border at the end of
104
+ that neighbour, so the two share one line. */
105
+ .option:not(:first-child) {
106
+ margin-inline-start: calc(-1 * var(--el-border-width, 1px));
107
+ }
108
+
109
+ /* The option with the focus lies over its neighbours, which would cover a part of its
110
+ focus ring otherwise. */
111
+ .option:has(input:focus-visible) {
112
+ z-index: 1;
113
+ }
114
+
115
+ /* ── States ───────────────────────────────────────────────────────── */
116
+
117
+ /* A tint of the text colour, which shows on every background. Hover only where the
118
+ pointer can hover: a touch screen leaves :hover on the option that was tapped last. */
119
+ @media (hover: hover) {
120
+ .option:hover input:not(:disabled):not(:checked) + .segment {
121
+ background: color-mix(in srgb, currentColor 12%, transparent);
122
+ }
123
+ }
124
+
125
+ .option:active input:not(:disabled):not(:checked) + .segment {
126
+ background: color-mix(in srgb, currentColor 24%, transparent);
127
+ }
128
+
129
+ /* The chosen option, as a pressed el-button: a tint of the text colour and a ring inside
130
+ of the edge. The ring is a shape and a border, so it tells the option apart without a
131
+ colour, and forced colours keep it. It has the corners of its segment. */
132
+ input:checked + .segment {
133
+ background: color-mix(in srgb, currentColor 16%, transparent);
134
+ }
135
+
136
+ input:checked + .segment::before {
137
+ content: '';
138
+ position: absolute;
139
+ inset: 0;
140
+ border: 0.125rem solid currentColor;
141
+ border-radius: inherit;
142
+ pointer-events: none;
143
+ }
144
+
145
+ /* Forced colours leave the ring as the only mark: it is wider there. */
146
+ @media (forced-colors: active) {
147
+ input:checked + .segment::before {
148
+ border-width: 0.1875rem;
149
+ }
150
+ }
151
+
152
+ /* ── A label that is not shown ────────────────────────────────────── */
153
+
154
+ /* label-screen-reader-only gives the legend the class sr-only. The field hides it itself,
155
+ so a field in a toolbar has a name and no label, on a page without such a class too. */
156
+ legend.sr-only {
157
+ position: absolute;
158
+ width: 1px;
159
+ height: 1px;
160
+ margin: 0;
161
+ overflow: hidden;
162
+ clip-path: inset(50%);
163
+ white-space: nowrap;
164
+ }
165
+
166
+ /* ── Icon ─────────────────────────────────────────────────────────── */
167
+
168
+ .segment-icon {
169
+ flex: none;
170
+ width: 1.25em;
171
+ height: 1.25em;
172
+ fill: currentColor;
173
+ }
174
+
175
+ /* The name of an option that shows an icon: for assistive technology alone. */
176
+ .segment-name {
177
+ position: absolute;
178
+ width: 1px;
179
+ height: 1px;
180
+ overflow: hidden;
181
+ clip-path: inset(50%);
182
+ white-space: nowrap;
183
+ }
184
+ }
185
+ `;
186
+
187
+ export default [
188
+ hostStyle('el-segmented-field'),
189
+ sizeStyle('el-segmented-field'),
190
+ formControlStyle('el-segmented-field'),
191
+ choiceGroupStyle('el-segmented-field'),
192
+ style,
193
+ ].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-splitter`: the edge between two panes that are beside each other, which the user drags to set the width of one of them. It is the control and sizes nothing itself, as a range does: `value` is the width in pixels, between `min` and `max`, and the layout around it takes it from the events. ([#182](https://github.com/webtides/element-library/issues/182))
20
+ - Dragged with a mouse, a finger and a pen. While it is dragged no text is selected, a finger does not scroll the page, and the edge keeps following the pointer over an `iframe`: it captures the pointer and covers the viewport for that time. `:state(dragging)` matches while it is dragged.
21
+ - A stop of the Tab key: the arrow keys move the edge by `step` pixels (`16` by default), `Home` and `End` take it to the least and to the greatest width. To assistive technology it is a separator with a value (`role="separator"`, `aria-valuenow`, `aria-valuemin`, `aria-valuemax`) and with the name of what it sizes (`label`).
22
+ - `splitter-resize` tells of every width while the user changes it, `splitter-resize-end` of the one that stays: when the pointer lets go, and with every key. A width the page sets tells of nothing.
23
+ - `placement` is the edge of its pane the splitter is: `end` (the default, the pane is in front of it) or `start` (the pane is after it). The direction of the drag and of the arrow keys follows it, and the reading direction.
24
+ - The edge is thin, a line from `--el-color-border` and `--el-border-width` (`--el-splitter-line-width` sets another width), and takes the pointer in a wider area around it: `--el-space-2` wide, and at least `--el-touch-target` on a touch screen. Under the pointer, while it is dragged and with the keyboard focus the line is a mark in `--el-color-accent`, and the focus has a ring. The line is a border, which stays where the user forces colours and is there without a theme then.
@@ -0,0 +1,3 @@
1
+ import { define } from './splitter.js';
2
+
3
+ define();
@@ -0,0 +1,4 @@
1
+ export default {
2
+ RESIZE: 'splitter-resize',
3
+ RESIZE_END: 'splitter-resize-end',
4
+ };
@@ -0,0 +1,237 @@
1
+ import { TemplateElement, defineElement, html } from '@webtides/element-js';
2
+ import style from './splitter.style.js';
3
+ import Events from './splitter.events.js';
4
+
5
+ /**
6
+ * The edge between two panes that are beside each other, which the user drags to set the width of
7
+ * one of them: with a mouse, a finger or a pen, and with the arrow keys. To assistive technology
8
+ * it is a separator with a value, the width in pixels, and with the name of what it sizes.
9
+ *
10
+ * The splitter is the control and sizes nothing itself, as a range does: it has a `value` between
11
+ * `min` and `max`, and tells of every change. The layout around it takes the value. An
12
+ * `el-app-frame` renders one at the edge of its navigation and of its aside (`resizable`); a page
13
+ * with two panes of its own writes one between them and sets the width of the pane from the
14
+ * event.
15
+ *
16
+ * @element el-splitter
17
+ *
18
+ * @fires {CustomEvent<{ value: number }>} splitter-resize - Fired with every change the user
19
+ * makes: while the edge is dragged, and with every key. The new width is in `detail.value`.
20
+ * @fires {CustomEvent<{ value: number }>} splitter-resize-end - Fired once the user has set a
21
+ * width: when the pointer lets go of the edge, and with every key. The width to keep is in
22
+ * `detail.value`.
23
+ *
24
+ * @csspart base - The separator: what takes the pointer and the focus. It is wider than the line.
25
+ * @csspart line - The line that shows, and the mark it becomes under the pointer and with the
26
+ * focus.
27
+ *
28
+ * @cssproperty --el-splitter-line-width - The width of the line. Default `--el-border-width`.
29
+ *
30
+ * @cssstate dragging - Set while a pointer drags the edge.
31
+ *
32
+ * @property {number} value - The width of the pane the splitter sizes, in pixels. Default `0`.
33
+ * @property {number} min - The least width. Default `0`.
34
+ * @property {number} max - The greatest width. Default `100`.
35
+ * @property {number} step - How far an arrow key moves the edge, in pixels. Default `16`.
36
+ * @property {string} label - The name of what the splitter sizes, for assistive technology.
37
+ * Default `''`.
38
+ * @property {'start'|'end'} placement - The edge of its pane the splitter is. `end`: the pane is
39
+ * in front of it, and grows when the edge moves away from the start. `start`: the pane is after
40
+ * it. Default `'end'`.
41
+ */
42
+ export default class Splitter extends TemplateElement {
43
+ /**
44
+ * The drag that is going on: the pointer, where it took the edge, the width then, and the
45
+ * direction in which the width grows.
46
+ * @private
47
+ * @type {{ pointerId: number, x: number, value: number, sign: number } | undefined}
48
+ */
49
+ _drag = undefined;
50
+
51
+ constructor() {
52
+ super({ styles: [style], shadowRender: true });
53
+ }
54
+
55
+ properties() {
56
+ return {
57
+ value: 0,
58
+ min: 0,
59
+ max: 100,
60
+ step: 16,
61
+ label: '',
62
+ placement: 'end',
63
+ };
64
+ }
65
+
66
+ events() {
67
+ return {
68
+ "[part~='base']": {
69
+ pointerdown: (event) => this._onPointerDown(event),
70
+ pointermove: (event) => this._onPointerMove(event),
71
+ pointerup: (event) => this._onPointerEnd(event),
72
+ pointercancel: (event) => this._onPointerEnd(event),
73
+ // The capture of a finger starts on what it touched, the line, and moves to the
74
+ // separator: only the separator losing it is the end of a drag.
75
+ lostpointercapture: (event) => {
76
+ if (event.target === event.currentTarget) this._onPointerEnd(event);
77
+ },
78
+ keydown: (event) => this._onKeyDown(event),
79
+ },
80
+ };
81
+ }
82
+
83
+ disconnected() {
84
+ this._drag = undefined;
85
+ this._internals.states.delete('dragging');
86
+ }
87
+
88
+ /**
89
+ * A width between the least and the greatest one, in whole pixels.
90
+ * @private
91
+ * @param {number} value
92
+ * @returns {number}
93
+ */
94
+ _clamp(value) {
95
+ const min = Number(this.min) || 0;
96
+ const max = Math.max(min, Number(this.max) || 0);
97
+ return Math.round(Math.min(max, Math.max(min, Number(value) || 0)));
98
+ }
99
+
100
+ /**
101
+ * The direction in which the width grows: 1 where it grows as the edge moves to the right.
102
+ * The pane is in front of the edge or after it, and the page runs from the left or from the
103
+ * right.
104
+ * @private
105
+ * @returns {number}
106
+ */
107
+ _sign() {
108
+ const rtl = getComputedStyle(this).direction === 'rtl';
109
+ return (rtl ? -1 : 1) * (this.placement === 'start' ? -1 : 1);
110
+ }
111
+
112
+ /**
113
+ * Takes a width from the user and tells of it. A width that is the same as before is none.
114
+ * @private
115
+ * @param {number} value
116
+ * @returns {boolean} Whether the width has changed.
117
+ */
118
+ _resize(value) {
119
+ const next = this._clamp(value);
120
+ if (next === this._clamp(this.value)) return false;
121
+ this.value = next;
122
+ this.dispatch(Events.RESIZE, { value: next });
123
+ return true;
124
+ }
125
+
126
+ /**
127
+ * The edge follows the pointer that took it, wherever that goes. The separator captures the
128
+ * pointer, so a move outside of the window still arrives here. A page in the page takes a pen
129
+ * that is over it all the same: while the edge is dragged, the separator covers the viewport
130
+ * (see the stylesheet), and the pointer is over nothing else.
131
+ * @private
132
+ * @param {PointerEvent} event
133
+ */
134
+ _onPointerDown(event) {
135
+ if (event.button !== 0) return;
136
+ // A drag whose end never arrived is over when the next one starts.
137
+ this._endDrag();
138
+
139
+ try {
140
+ event.currentTarget.setPointerCapture(event.pointerId);
141
+ } catch {
142
+ // A pointer that is gone again cannot be captured. The drag ends with the next one.
143
+ }
144
+ this._drag = {
145
+ pointerId: event.pointerId,
146
+ x: event.clientX,
147
+ value: this._clamp(this.value),
148
+ sign: this._sign(),
149
+ };
150
+ this._internals.states.add('dragging');
151
+ }
152
+
153
+ /**
154
+ * @private
155
+ * @param {PointerEvent} event
156
+ */
157
+ _onPointerMove(event) {
158
+ const drag = this._drag;
159
+ if (!drag || event.pointerId !== drag.pointerId) return;
160
+
161
+ this._resize(drag.value + drag.sign * (event.clientX - drag.x));
162
+ }
163
+
164
+ /**
165
+ * The pointer has let go, or the system has taken it away: the width stays as it is now.
166
+ * @private
167
+ * @param {PointerEvent} event
168
+ */
169
+ _onPointerEnd(event) {
170
+ if (event.pointerId === this._drag?.pointerId) this._endDrag();
171
+ }
172
+
173
+ /**
174
+ * Ends the drag that is going on, and tells of the width that stays if it is another one than
175
+ * before the drag.
176
+ * @private
177
+ */
178
+ _endDrag() {
179
+ const drag = this._drag;
180
+ if (!drag) return;
181
+
182
+ this._drag = undefined;
183
+ this._internals.states.delete('dragging');
184
+ const value = this._clamp(this.value);
185
+ if (value !== drag.value) this.dispatch(Events.RESIZE_END, { value });
186
+ }
187
+
188
+ /**
189
+ * The arrow keys move the edge a step, in the direction of the arrow. `Home` and `End` take
190
+ * it to the least and to the greatest width.
191
+ * @private
192
+ * @param {KeyboardEvent} event
193
+ */
194
+ _onKeyDown(event) {
195
+ if (event.altKey || event.ctrlKey || event.metaKey) return;
196
+
197
+ const value = this._clamp(this.value);
198
+ const step = Math.abs(Number(this.step)) || 1;
199
+ const to = {
200
+ ArrowRight: value + this._sign() * step,
201
+ ArrowLeft: value - this._sign() * step,
202
+ Home: Number(this.min) || 0,
203
+ End: Number(this.max) || 0,
204
+ }[event.key];
205
+ if (to === undefined) return;
206
+
207
+ // The key is the one of the splitter: the page does not scroll with it.
208
+ event.preventDefault();
209
+ if (this._resize(to)) this.dispatch(Events.RESIZE_END, { value: this._clamp(this.value) });
210
+ }
211
+
212
+ template() {
213
+ const min = Number(this.min) || 0;
214
+
215
+ return html`
216
+ <div
217
+ part="base"
218
+ class="splitter"
219
+ role="separator"
220
+ tabindex="0"
221
+ aria-orientation="vertical"
222
+ aria-label="${this.label || null}"
223
+ aria-valuenow="${this._clamp(this.value)}"
224
+ aria-valuemin="${min}"
225
+ aria-valuemax="${Math.max(min, Number(this.max) || 0)}"
226
+ >
227
+ <span part="line" class="line"></span>
228
+ </div>
229
+ `;
230
+ }
231
+ }
232
+
233
+ export function define() {
234
+ defineElement('el-splitter', Splitter);
235
+ }
236
+
237
+ export { Events };
@@ -0,0 +1,164 @@
1
+ # Splitter
2
+
3
+ `splitter` is the edge between two panes that are beside each other, which the user drags to set the width of one of them: more room for long names in a list, or less of it for more of what is chosen from the list. It is dragged with a mouse, a finger or a pen, and moved with the arrow keys.
4
+
5
+ The splitter is the control and sizes nothing itself, as a range does: it has a `value` between `min` and `max`, the width in pixels, and tells of every change. The layout around it takes the value. An [`el-app-frame`](../app-frame/app-frame.readme.md) has one at the edge of its navigation and of its aside (`resizable`); a page with two panes of its own writes one between them.
6
+
7
+ ## How to use
8
+
9
+ #### Install
10
+
11
+ ```sh
12
+ npm i --save @webtides/element-library
13
+ ```
14
+
15
+ #### Use
16
+
17
+ ```js
18
+ import '@webtides/element-library/splitter/define';
19
+ ```
20
+
21
+ ```html
22
+ <div class="panes" style="--list: 320px">
23
+ <el-list label="Messages">…</el-list>
24
+ <el-splitter label="Messages" value="320" min="200" max="480"></el-splitter>
25
+ <article>…</article>
26
+ </div>
27
+ ```
28
+
29
+ ```css
30
+ .panes {
31
+ display: grid;
32
+ grid-template-columns: var(--list) auto minmax(0, 1fr);
33
+ }
34
+ ```
35
+
36
+ ```js
37
+ const panes = document.querySelector('.panes');
38
+
39
+ panes.addEventListener('splitter-resize', (event) => {
40
+ panes.style.setProperty('--list', `${event.detail.value}px`);
41
+ });
42
+ panes.addEventListener('splitter-resize-end', (event) => {
43
+ localStorage.setItem('list', event.detail.value);
44
+ });
45
+ ```
46
+
47
+ ## API
48
+
49
+ #### Properties/Attributes
50
+
51
+ | Name | Type | Default | Description |
52
+ | --- | --- | --- | --- |
53
+ | `value` | `number` | `0` | The width of the pane the splitter sizes, in pixels. |
54
+ | `min` | `number` | `0` | The least width. |
55
+ | `max` | `number` | `100` | The greatest width. |
56
+ | `step` | `number` | `16` | How far an arrow key moves the edge, in pixels. |
57
+ | `label` | `string` | `''` | The name of what the splitter sizes, for assistive technology. |
58
+ | `placement` | `'start' \| 'end'` | `'end'` | The edge of its pane the splitter is. `end`: the pane is in front of it. `start`: the pane is after it. |
59
+
60
+ #### Methods
61
+
62
+ _None._
63
+
64
+ #### Events
65
+
66
+ | Name | Detail | Description |
67
+ | --- | --- | --- |
68
+ | `splitter-resize` | `{ value: number }` | Fired with every change the user makes: while the edge is dragged, and with every key. |
69
+ | `splitter-resize-end` | `{ value: number }` | Fired once the user has set a width: when the pointer lets go of the edge, and with every key. The width to keep. |
70
+
71
+ #### Slots
72
+
73
+ _None._
74
+
75
+ #### CSS Parts
76
+
77
+ | Name | Description |
78
+ | ------ | ---------------------------------------------------------------------------------- |
79
+ | `base` | The separator: what takes the pointer and the focus. It is wider than the line. |
80
+ | `line` | The line that shows, and the mark it becomes under the pointer and with the focus. |
81
+
82
+ #### CSS Custom Properties
83
+
84
+ | Name | Default | Description |
85
+ | --- | --- | --- |
86
+ | `--el-splitter-line-width` | `--el-border-width` | The width of the line. `0px` for an edge that lies on a line the layout draws itself. |
87
+
88
+ Reads `--el-color-border` and `--el-border-width` for its line, `--el-color-accent` for the mark, `--el-focus-ring-width` and `--el-color-focus-ring` for the focus ring, `--el-space-2` for the width of what takes the pointer, `--el-duration-md` and `--el-ease` for the way from the line to the mark, and `--el-touch-target` on a touch screen.
89
+
90
+ #### States
91
+
92
+ | Name | Description |
93
+ | ---------- | ----------------------------------- |
94
+ | `dragging` | Set while a pointer drags the edge. |
95
+
96
+ ## The value, and who takes it
97
+
98
+ The splitter has the width of one pane as its `value`, in pixels. It does not know the pane and writes nothing onto it.
99
+
100
+ - The page gives the width it starts with, and the least and the greatest one: `value`, `min`, `max`. A value outside of the two is said as the nearer of them.
101
+ - While the user changes the width, `splitter-resize` tells of every one. The page sets it on its layout, a custom property of a grid for example. A page that is slow to do so loses nothing: the edge follows the pointer, not the layout.
102
+ - `splitter-resize-end` tells of the width that stays. That is the moment to keep it, in the storage of the browser or on the server.
103
+ - A width the page sets on the splitter (`value`) tells of nothing.
104
+
105
+ The splitter is as wide as its line and as high as the row it is in: a flex row or a grid row stretches it. It sizes a width. Two panes above each other are not what it is for.
106
+
107
+ ## Which pane it sizes
108
+
109
+ `placement` says at which edge of its pane the splitter is. That decides in which direction the width grows.
110
+
111
+ ```html
112
+ <!-- The pane is in front of the splitter: a list at the start. -->
113
+ <el-list>…</el-list>
114
+ <el-splitter label="Messages" …></el-splitter>
115
+ <article>…</article>
116
+
117
+ <!-- The pane is after it: details at the end. -->
118
+ <article>…</article>
119
+ <el-splitter placement="start" label="Details" …></el-splitter>
120
+ <aside>…</aside>
121
+ ```
122
+
123
+ In a right-to-left page start and end are the other way around, and so are the drag and the arrow keys.
124
+
125
+ ## Keeping a width
126
+
127
+ A server-rendered page that has kept a width writes it in two places: on its layout, and as the `value` of the splitter. Nothing jumps then: the layout has the width before the script has run, and the splitter says the same one when it starts.
128
+
129
+ ```html
130
+ <div class="panes" style="--list: 280px">
131
+ …
132
+ <el-splitter label="Messages" value="280" min="200" max="480"></el-splitter>
133
+ …
134
+ </div>
135
+ ```
136
+
137
+ ## Pointer
138
+
139
+ - The edge is a thin line. It takes the pointer in a wider area around it, which lies over the panes at both sides: `--el-space-2` wide, and at least `--el-touch-target` on a touch screen.
140
+ - While the edge is dragged, no text is selected and a finger does not scroll the page.
141
+ - The edge keeps following the pointer wherever it goes. It captures the pointer, and it covers the viewport while it is dragged: a page in the page (an `iframe`) under the pointer would take a pen away from it.
142
+ - Only the main button of a mouse takes the edge.
143
+
144
+ ## Keyboard
145
+
146
+ | Key | What it does |
147
+ | -------------------------- | -------------------------------------------------------------- |
148
+ | `Tab` | The edge is a stop of the Tab key. |
149
+ | `ArrowLeft` / `ArrowRight` | Move the edge by `step` pixels, in the direction of the arrow. |
150
+ | `Home` | The least width. |
151
+ | `End` | The greatest width. |
152
+
153
+ Every key is a width that stays: it fires `splitter-resize` and `splitter-resize-end`.
154
+
155
+ ## Server-side rendering
156
+
157
+ The splitter renders on a server with `@webtides/element-js-ssr-renderer`: the separator with its name and its value is in the markup, and the line looks the same before and after the element takes over. It moves once the script has run.
158
+
159
+ ## Accessibility
160
+
161
+ - A separator that takes the focus (`role="separator"` with `tabindex="0"`), with `aria-orientation="vertical"`, the width as `aria-valuenow` and the limits as `aria-valuemin` and `aria-valuemax`.
162
+ - `label` is its name: what it sizes ("Messages"), not what it is.
163
+ - The keyboard focus shows as a ring around what takes the pointer, and the line is the mark it is under the pointer.
164
+ - The line is a border: it stays where the user forces colours, and it is there without a theme then. Without a theme and without forced colours the line has no width, and shows as a mark under the pointer and with the focus.