@webtides/element-library 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/CHANGELOG.md +208 -0
  2. package/README.md +72 -56
  3. package/all.js +16 -0
  4. package/catalog.js +17 -1
  5. package/custom-elements.json +14731 -10193
  6. package/package.json +1 -1
  7. package/src/components/accordion/accordion.changelog.md +11 -0
  8. package/src/components/accordion/accordion.js +15 -3
  9. package/src/components/accordion/accordion.readme.md +27 -1
  10. package/src/components/accordion/accordion.style.js +19 -0
  11. package/src/components/app-bar/app-bar.changelog.md +24 -0
  12. package/src/components/app-bar/app-bar.define.js +3 -0
  13. package/src/components/app-bar/app-bar.js +91 -0
  14. package/src/components/app-bar/app-bar.readme.md +130 -0
  15. package/src/components/app-bar/app-bar.style.js +103 -0
  16. package/src/components/app-frame/app-frame.changelog.md +45 -0
  17. package/src/components/app-frame/app-frame.define.js +3 -0
  18. package/src/components/app-frame/app-frame.events.js +6 -0
  19. package/src/components/app-frame/app-frame.js +1073 -0
  20. package/src/components/app-frame/app-frame.readme.md +416 -0
  21. package/src/components/app-frame/app-frame.style.js +527 -0
  22. package/src/components/button/button.changelog.md +25 -0
  23. package/src/components/button/button.events.js +3 -0
  24. package/src/components/button/button.js +209 -14
  25. package/src/components/button/button.readme.md +82 -6
  26. package/src/components/button/button.style.js +161 -7
  27. package/src/components/checkbox-field/checkbox-field.changelog.md +6 -0
  28. package/src/components/checkbox-field/checkbox-field.js +7 -1
  29. package/src/components/description-list/description-list.changelog.md +25 -0
  30. package/src/components/description-list/description-list.define.js +3 -0
  31. package/src/components/description-list/description-list.js +44 -0
  32. package/src/components/description-list/description-list.readme.md +135 -0
  33. package/src/components/description-list/description-list.style.js +140 -0
  34. package/src/components/dialog/dialog.changelog.md +7 -0
  35. package/src/components/dialog/dialog.readme.md +5 -0
  36. package/src/components/dialog/dialog.style.js +17 -2
  37. package/src/components/drawer/drawer.changelog.md +7 -0
  38. package/src/components/drawer/drawer.readme.md +7 -6
  39. package/src/components/drawer/drawer.style.js +35 -2
  40. package/src/components/dropdown/dropdown.readme.md +6 -1
  41. package/src/components/list/list.changelog.md +24 -0
  42. package/src/components/list/list.define.js +3 -0
  43. package/src/components/list/list.js +66 -0
  44. package/src/components/list/list.readme.md +122 -0
  45. package/src/components/list/list.style.js +56 -0
  46. package/src/components/list-item/list-item.changelog.md +24 -0
  47. package/src/components/list-item/list-item.define.js +3 -0
  48. package/src/components/list-item/list-item.js +128 -0
  49. package/src/components/list-item/list-item.readme.md +126 -0
  50. package/src/components/list-item/list-item.style.js +234 -0
  51. package/src/components/menu/menu.changelog.md +27 -0
  52. package/src/components/menu/menu.define.js +3 -0
  53. package/src/components/menu/menu.events.js +5 -0
  54. package/src/components/menu/menu.js +570 -0
  55. package/src/components/menu/menu.readme.md +272 -0
  56. package/src/components/menu/menu.style.js +55 -0
  57. package/src/components/menu-group/menu-group.changelog.md +20 -0
  58. package/src/components/menu-group/menu-group.define.js +3 -0
  59. package/src/components/menu-group/menu-group.js +44 -0
  60. package/src/components/menu-group/menu-group.readme.md +74 -0
  61. package/src/components/menu-group/menu-group.style.js +38 -0
  62. package/src/components/menu-item/menu-item.changelog.md +24 -0
  63. package/src/components/menu-item/menu-item.define.js +3 -0
  64. package/src/components/menu-item/menu-item.js +130 -0
  65. package/src/components/menu-item/menu-item.readme.md +94 -0
  66. package/src/components/menu-item/menu-item.style.js +87 -0
  67. package/src/components/nav/nav.changelog.md +35 -0
  68. package/src/components/nav/nav.define.js +3 -0
  69. package/src/components/nav/nav.js +212 -0
  70. package/src/components/nav/nav.readme.md +248 -0
  71. package/src/components/nav/nav.style.js +269 -0
  72. package/src/components/nav-item/nav-item.changelog.md +25 -0
  73. package/src/components/nav-item/nav-item.define.js +3 -0
  74. package/src/components/nav-item/nav-item.js +75 -0
  75. package/src/components/nav-item/nav-item.readme.md +111 -0
  76. package/src/components/nav-item/nav-item.style.js +159 -0
  77. package/src/components/pagination/pagination.changelog.md +8 -0
  78. package/src/components/pagination/pagination.js +123 -49
  79. package/src/components/pagination/pagination.readme.md +24 -6
  80. package/src/components/pagination/pagination.style.js +11 -1
  81. package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
  82. package/src/components/scroll-to-top/scroll-to-top.js +16 -12
  83. package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
  84. package/src/components/segmented-field/segmented-field.changelog.md +27 -0
  85. package/src/components/segmented-field/segmented-field.define.js +3 -0
  86. package/src/components/segmented-field/segmented-field.js +175 -0
  87. package/src/components/segmented-field/segmented-field.readme.md +140 -0
  88. package/src/components/segmented-field/segmented-field.style.js +193 -0
  89. package/src/components/splitter/splitter.changelog.md +24 -0
  90. package/src/components/splitter/splitter.define.js +3 -0
  91. package/src/components/splitter/splitter.events.js +4 -0
  92. package/src/components/splitter/splitter.js +237 -0
  93. package/src/components/splitter/splitter.readme.md +164 -0
  94. package/src/components/splitter/splitter.style.js +100 -0
  95. package/src/components/status-bar/status-bar.changelog.md +25 -0
  96. package/src/components/status-bar/status-bar.define.js +3 -0
  97. package/src/components/status-bar/status-bar.js +74 -0
  98. package/src/components/status-bar/status-bar.readme.md +139 -0
  99. package/src/components/status-bar/status-bar.style.js +122 -0
  100. package/src/components/switch-field/switch-field.changelog.md +6 -0
  101. package/src/components/switch-field/switch-field.js +7 -1
  102. package/src/components/tab-group/tab-group.changelog.md +7 -0
  103. package/src/components/tab-group/tab-group.js +30 -9
  104. package/src/components/tab-group/tab-group.readme.md +14 -0
  105. package/src/components/toast/toast.changelog.md +6 -0
  106. package/src/components/toast/toast.readme.md +5 -3
  107. package/src/components/toast/toast.style.js +22 -6
  108. package/src/components/toolbar/toolbar.changelog.md +24 -0
  109. package/src/components/toolbar/toolbar.define.js +3 -0
  110. package/src/components/toolbar/toolbar.js +233 -0
  111. package/src/components/toolbar/toolbar.readme.md +156 -0
  112. package/src/components/toolbar/toolbar.style.js +49 -0
  113. package/src/components/tooltip/tooltip.changelog.md +11 -0
  114. package/src/components/tooltip/tooltip.js +51 -4
  115. package/src/components/tooltip/tooltip.readme.md +26 -1
  116. package/src/components/tree/tree.changelog.md +23 -0
  117. package/src/components/tree/tree.define.js +3 -0
  118. package/src/components/tree/tree.js +138 -0
  119. package/src/components/tree/tree.readme.md +119 -0
  120. package/src/components/tree/tree.style.js +16 -0
  121. package/src/components/tree-item/tree-item.changelog.md +23 -0
  122. package/src/components/tree-item/tree-item.define.js +3 -0
  123. package/src/components/tree-item/tree-item.events.js +3 -0
  124. package/src/components/tree-item/tree-item.js +246 -0
  125. package/src/components/tree-item/tree-item.readme.md +128 -0
  126. package/src/components/tree-item/tree-item.style.js +226 -0
  127. package/src/styles/appearance.style.js +47 -0
  128. package/src/styles/choice-group.style.js +1 -1
  129. package/src/styles/modal.style.js +14 -1
  130. package/src/styles/size.style.js +41 -0
  131. package/src/utils/focus.js +69 -0
  132. package/src/utils/scroll.js +24 -0
  133. package/types/all.d.ts +16 -0
  134. package/types/src/components/accordion/accordion.d.ts +3 -1
  135. package/types/src/components/app-bar/app-bar.d.ts +43 -0
  136. package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
  137. package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
  138. package/types/src/components/app-frame/app-frame.d.ts +491 -0
  139. package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
  140. package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
  141. package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
  142. package/types/src/components/button/button.d.ts +97 -7
  143. package/types/src/components/button/button.events.d.ts +4 -0
  144. package/types/src/components/description-list/description-list.d.ts +29 -0
  145. package/types/src/components/description-list/description-list.define.d.ts +1 -0
  146. package/types/src/components/description-list/description-list.style.d.ts +2 -0
  147. package/types/src/components/list/list.d.ts +39 -0
  148. package/types/src/components/list/list.define.d.ts +1 -0
  149. package/types/src/components/list/list.style.d.ts +2 -0
  150. package/types/src/components/list-item/list-item.d.ts +62 -0
  151. package/types/src/components/list-item/list-item.define.d.ts +1 -0
  152. package/types/src/components/list-item/list-item.style.d.ts +2 -0
  153. package/types/src/components/menu/menu.d.ts +266 -0
  154. package/types/src/components/menu/menu.define.d.ts +1 -0
  155. package/types/src/components/menu/menu.events.d.ts +6 -0
  156. package/types/src/components/menu/menu.style.d.ts +2 -0
  157. package/types/src/components/menu-group/menu-group.d.ts +24 -0
  158. package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
  159. package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
  160. package/types/src/components/menu-item/menu-item.d.ts +59 -0
  161. package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
  162. package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
  163. package/types/src/components/nav/nav.d.ts +103 -0
  164. package/types/src/components/nav/nav.define.d.ts +1 -0
  165. package/types/src/components/nav/nav.style.d.ts +2 -0
  166. package/types/src/components/nav-item/nav-item.d.ts +39 -0
  167. package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
  168. package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
  169. package/types/src/components/pagination/pagination.d.ts +31 -2
  170. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
  171. package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
  172. package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
  173. package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
  174. package/types/src/components/splitter/splitter.d.ts +127 -0
  175. package/types/src/components/splitter/splitter.define.d.ts +1 -0
  176. package/types/src/components/splitter/splitter.events.d.ts +5 -0
  177. package/types/src/components/splitter/splitter.style.d.ts +2 -0
  178. package/types/src/components/status-bar/status-bar.d.ts +44 -0
  179. package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
  180. package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
  181. package/types/src/components/tab-group/tab-group.d.ts +17 -0
  182. package/types/src/components/toolbar/toolbar.d.ts +96 -0
  183. package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
  184. package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
  185. package/types/src/components/tooltip/tooltip.d.ts +26 -0
  186. package/types/src/components/tree/tree.d.ts +62 -0
  187. package/types/src/components/tree/tree.define.d.ts +1 -0
  188. package/types/src/components/tree/tree.style.d.ts +2 -0
  189. package/types/src/components/tree-item/tree-item.d.ts +106 -0
  190. package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
  191. package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
  192. package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
  193. package/types/src/styles/appearance.style.d.ts +31 -0
  194. package/types/src/styles/choice-group.style.d.ts +1 -1
  195. package/types/src/styles/modal.style.d.ts +5 -0
  196. package/types/src/styles/size.style.d.ts +24 -0
  197. package/types/src/utils/focus.d.ts +25 -0
  198. package/types/src/utils/scroll.d.ts +11 -0
  199. package/web-types.json +2530 -393
@@ -1,4 +1,5 @@
1
1
  import { TemplateElement } from '@webtides/element-js';
2
+ import Events from './button.events.js';
2
3
  /**
3
4
  * A themeable button that renders a native `<button>` — or an `<a>` when `href` is set — and
4
5
  * decorates it with the `--el-*` design tokens. Speaks the library's shared vocabulary: a semantic
@@ -11,15 +12,28 @@ import { TemplateElement } from '@webtides/element-js';
11
12
  * `aria-controls` as references to the elements they name.
12
13
  *
13
14
  * The element is form-associated: a `<fieldset disabled>` around it disables it, and it is listed in
14
- * the `elements` of its form. A button of the type `submit` keeps a hidden native
15
- * `<button type="submit">` in its content, which is what the form is submitted with: it is the
16
- * `submitter` of the `submit` event, its `name` and `value` are in the data of the form, and Enter in
17
- * a field of the form finds it. The attributes `form`, `formaction`, `formenctype`, `formmethod`,
18
- * `formnovalidate` and `formtarget` of the element do what they do on a native button. A `click`
19
- * listener of the page that calls `preventDefault()` keeps the button from submitting or resetting.
15
+ * the `elements` of its form. A button of the type `submit` submits its form with a hidden native
16
+ * `<button type="submit">` in its content: it is the `submitter` of the `submit` event, its `name`
17
+ * and `value` are in the data of the form, and Enter in a field of the form finds it. The element
18
+ * makes that button when the form is first submitted with it, by a click or by Enter in a field.
19
+ * Until then its content is what the page wrote, so a framework can hydrate a server-rendered
20
+ * button, also when the element has started before the framework does. The attributes `form`,
21
+ * `formaction`, `formenctype`, `formmethod`, `formnovalidate` and `formtarget` of the element do
22
+ * what they do on a native button. A `click` listener of the page that calls `preventDefault()`
23
+ * keeps the button from submitting or resetting.
24
+ *
25
+ * In a container that gives its controls a size and an appearance, an `el-toolbar`, the button
26
+ * takes them from it, while the page has not set `size` or `appearance` on the button itself.
27
+ *
28
+ * With `toggle` the button stays pressed: a click flips `pressed`, the control says so to assistive
29
+ * technology (`aria-pressed`), and the button shows it. A `click` listener of the page that calls
30
+ * `preventDefault()` keeps the button from flipping, as it keeps it from submitting.
20
31
  *
21
32
  * @element el-button
22
33
  *
34
+ * @fires {CustomEvent<{ pressed: boolean }>} button-toggle - Fired when a click has flipped a
35
+ * toggle button. `detail.pressed` is the new state. Not fired when `pressed` is set from a script.
36
+ *
23
37
  * @slot - The button's label.
24
38
  * @slot prefix - A presentational prefix icon or similar element.
25
39
  * @slot suffix - A presentational suffix icon or similar element.
@@ -44,6 +58,10 @@ import { TemplateElement } from '@webtides/element-js';
44
58
  * @property {boolean} loading - Shows a spinner and blocks interaction.
45
59
  * @property {boolean} disabled - Disables the button. Reflected to the `disabled` attribute, which is
46
60
  * there while the button is disabled and gone while it is not.
61
+ * @property {boolean} toggle - The button is a toggle button: it stays pressed. A click flips
62
+ * `pressed`, and the control has `aria-pressed`. Ignored when `href` is set. Default `false`.
63
+ * @property {boolean} pressed - Whether a toggle button is pressed. Reflected to the `pressed`
64
+ * attribute of a toggle button. Without `toggle` it does nothing. Default `false`.
47
65
  * @property {'button'|'submit'|'reset'} type - Behaviour when activated. `submit` / `reset` act on
48
66
  * the form of the button: the nearest ancestor `<form>`, or the one its `form` attribute names.
49
67
  * Ignored when `href` is set. Default `'button'`.
@@ -57,6 +75,7 @@ import { TemplateElement } from '@webtides/element-js';
57
75
  */
58
76
  export default class Button extends TemplateElement {
59
77
  disabled: boolean;
78
+ pressed: boolean;
60
79
  /**
61
80
  * The platform tells a form-associated element when a `<fieldset disabled>` around it disables
62
81
  * it, and resolves its `form` attribute.
@@ -69,6 +88,23 @@ export default class Button extends TemplateElement {
69
88
  * @type {HTMLButtonElement | undefined}
70
89
  */
71
90
  private _submitter;
91
+ /**
92
+ * Where the element listens for Enter in a field of its form, see `afterUpdate()`.
93
+ * @private
94
+ * @type {Node | undefined}
95
+ */
96
+ private _keydownRoot;
97
+ /**
98
+ * Which of `size` and `appearance` the page has set on the button itself, see `_isOwn()`.
99
+ * @private
100
+ * @type {Set<string> | undefined}
101
+ */
102
+ private _ownLook;
103
+ /**
104
+ * Whether the button is writing a property to its attribute right now, see `reflectProperty()`.
105
+ * @private
106
+ */
107
+ private _reflecting;
72
108
  constructor();
73
109
  properties(): {
74
110
  variant: string;
@@ -79,6 +115,8 @@ export default class Button extends TemplateElement {
79
115
  caret: boolean;
80
116
  loading: boolean;
81
117
  disabled: boolean;
118
+ toggle: boolean;
119
+ pressed: boolean;
82
120
  type: string;
83
121
  name: string;
84
122
  value: string;
@@ -87,8 +125,31 @@ export default class Button extends TemplateElement {
87
125
  rel: string;
88
126
  download: string;
89
127
  };
128
+ connectedCallback(): void;
129
+ /**
130
+ * Whether the page has given the button a `size` or an `appearance` of its own. A button
131
+ * without one takes it from a container that gives one to its controls, a toolbar. The
132
+ * template marks the control with the answer, and the stylesheet reads the mark.
133
+ *
134
+ * On the server no attribute has been written by the element: the ones that are there are
135
+ * the ones of the page.
136
+ * @private
137
+ * @param {'size' | 'appearance'} name
138
+ * @returns {boolean}
139
+ */
140
+ private _isOwn;
90
141
  /** Whether the button renders as a link rather than a native button. */
91
142
  get isLink(): boolean;
143
+ /**
144
+ * Whether the button is a toggle button: one that stays pressed. A link leads somewhere, it
145
+ * has no state to stay in.
146
+ */
147
+ get isToggle(): boolean;
148
+ watch(): {
149
+ toggle: () => void;
150
+ size: () => Set<string>;
151
+ appearance: () => Set<string>;
152
+ };
92
153
  /**
93
154
  * An ARIA attribute of the element, or one it shares with a native submit button, was set,
94
155
  * changed or removed. They are no properties of the component: the template and the submit
@@ -115,7 +176,28 @@ export default class Button extends TemplateElement {
115
176
  property: string;
116
177
  newValue: unknown;
117
178
  }): void;
179
+ /**
180
+ * `pressed` is the attribute of a toggle button: `"true"` or `"false"`, so that the page can
181
+ * read the state and select by it. On a button that is no toggle the attribute says nothing,
182
+ * and the element does not write it there.
183
+ * @private
184
+ * @param {unknown} pressed
185
+ */
186
+ private _reflectPressed;
118
187
  afterUpdate(): void;
188
+ disconnected(): void;
189
+ /**
190
+ * Enter in a field of the form submits the form with its first submit button, and without one
191
+ * only a form with a single field. The browser looks for that button once every listener has
192
+ * had the key, so the native submit button of the element is made here, if it is not there yet.
193
+ *
194
+ * Only for a key the browser may submit with: Enter in an `<input>` or a `<select>` of the
195
+ * form, and not while a text is being composed. Enter in a `<textarea>` is a line break, and
196
+ * leaves the content of the element as it is.
197
+ * @private
198
+ * @param {KeyboardEvent} event
199
+ */
200
+ private _onRootKeydown;
119
201
  /** Focuses the underlying control. */
120
202
  focus(options: any): void;
121
203
  /** Removes focus from the underlying control. */
@@ -162,8 +244,15 @@ export default class Button extends TemplateElement {
162
244
  * button has. It is disabled while the element is disabled or loading, which keeps Enter from
163
245
  * submitting as well. One that is in the content already is taken: written by the page, for a
164
246
  * form that is submitted with Enter before the script has run, or copied with the element.
247
+ *
248
+ * The element makes the button only when the form is about to be submitted with it (`create`):
249
+ * with a click, or with Enter in a field. A render does not. The content of the element is what
250
+ * the page wrote until then: a framework that hydrates a server-rendered page after the element
251
+ * has started finds the children it rendered, and no other.
165
252
  * @private
166
- * @returns {HTMLButtonElement | null} The submit button, or `null` for a button of another type.
253
+ * @param {boolean} [create] - Whether to make the button when there is none.
254
+ * @returns {HTMLButtonElement | null} The submit button, or `null`: for a button of another
255
+ * type, and while there is none and none was asked for.
167
256
  */
168
257
  private _syncSubmitter;
169
258
  /**
@@ -186,3 +275,4 @@ export default class Button extends TemplateElement {
186
275
  template(): any;
187
276
  }
188
277
  export declare function define(): void;
278
+ export { Events };
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ TOGGLE: string;
3
+ };
4
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import { TemplateElement } from '@webtides/element-js';
2
+ /**
3
+ * Rows of a name and its value, for a settings page or the page of an entry: the address, the
4
+ * plan, the day it was created. The element is the native `<dl>`; the page writes the names as
5
+ * `<dt>` and the values as `<dd>` into it, as it would into a `<dl>`.
6
+ *
7
+ * In a narrow place a name stands above its value. From a width of 30rem, which the list measures
8
+ * on itself, the two stand side by side, and the values of all rows begin on one line. A row can
9
+ * end in an action: a `<dd data-action>` with a link or a button in it.
10
+ *
11
+ * Pure presentation: the list runs no script of its own, so a server-rendered list is complete
12
+ * before the element takes over.
13
+ *
14
+ * @element el-description-list
15
+ *
16
+ * @slot - The rows: for each one a `<dt>` with the name, a `<dd>` with the value (or several),
17
+ * and, to end the row in an action, a `<dd data-action>` with a link or a button.
18
+ *
19
+ * @csspart base - The `<dl>`.
20
+ *
21
+ * @cssproperty --el-description-list-term-width - The width of the column of the names while
22
+ * names and values stand side by side. Unset, the column is as wide as the longest name, and
23
+ * 40% of the list at most.
24
+ */
25
+ export default class DescriptionList extends TemplateElement {
26
+ constructor();
27
+ template(): any;
28
+ }
29
+ export declare function define(): void;
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;
@@ -0,0 +1,39 @@
1
+ import { TemplateElement } from '@webtides/element-js';
2
+ /**
3
+ * A list of rows: messages, articles, files, the entries of a settings page. The list is the
4
+ * surface and the list for assistive technology; every `el-list-item` slotted into it is one row.
5
+ * It gives its rows one density, one line between two of them and one place where their texts
6
+ * begin, whatever stands at the start of a row.
7
+ *
8
+ * Pure presentation: the list runs no script of its own, so a server-rendered list is complete
9
+ * before the element takes over.
10
+ *
11
+ * @element el-list
12
+ *
13
+ * @slot - The rows: `el-list-item` elements.
14
+ *
15
+ * @csspart base - The list (`role="list"`) and its surface.
16
+ *
17
+ * @cssproperty --el-list-padding-inline - The padding of a row at its start and its end. Unset, it
18
+ * is `--el-space-4`, and `1rem` without a theme. Read by the rows, so it can be set on the list
19
+ * or for the page.
20
+ *
21
+ * @property {string} label - The name of the list for assistive technology. Unset, the list has
22
+ * none.
23
+ * @property {'default'|'compact'} density - How much room a row has above and below its texts.
24
+ * Default `'default'`. Reflected to the `density` attribute.
25
+ * @property {'plain'|'outlined'|'filled'} appearance - How the surface is painted: not at all, so
26
+ * the list reaches from edge to edge of its place, or as a card with the background of the page
27
+ * or a muted fill, a border and round corners. Default `'plain'`. Reflected to the `appearance`
28
+ * attribute.
29
+ */
30
+ export default class List extends TemplateElement {
31
+ constructor();
32
+ properties(): {
33
+ label: string;
34
+ density: string;
35
+ appearance: string;
36
+ };
37
+ template(): any;
38
+ }
39
+ export declare function define(): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;
@@ -0,0 +1,62 @@
1
+ import { TemplateElement } from '@webtides/element-js';
2
+ /**
3
+ * One row of an `el-list`. It has the parts a row has everywhere: something at the start (an icon,
4
+ * an avatar), a title, a line under it, something at the end (a value, a count, a chevron), and a
5
+ * control of its own after that.
6
+ *
7
+ * With `href` the row is a link as a whole: the title is the link, and its target is the whole
8
+ * row. What is slotted into `action` stays a target of its own.
9
+ *
10
+ * Pure presentation: the row runs no script of its own.
11
+ *
12
+ * @element el-list-item
13
+ *
14
+ * @slot - The title of the row.
15
+ * @slot description - The line under the title.
16
+ * @slot start - What stands in front of the texts: an icon, an avatar. The texts of all rows of a
17
+ * list begin after the widest start.
18
+ * @slot end - What stands at the end of the row and belongs to it: a value, a count, a chevron. In
19
+ * a row that is a link it is part of the target of the link.
20
+ * @slot action - A control at the very end: a button, a switch, a menu. In a row that is a link it
21
+ * lies on top of the link and is a target of its own.
22
+ *
23
+ * @csspart base - The row: an item of the list.
24
+ * @csspart mark - The dot of `mark`, in the padding at the start of the row.
25
+ * @csspart start - The region of the `start` slot.
26
+ * @csspart text - The title and the line under it.
27
+ * @csspart title - The title: an `<a>` with `href`, a `<span>` without.
28
+ * @csspart description - The region of the `description` slot.
29
+ * @csspart end - The region of the `end` slot.
30
+ * @csspart action - The region of the `action` slot.
31
+ *
32
+ * @cssproperty --el-list-padding-inline - The padding of the row at its start and its end. Unset,
33
+ * it is `--el-space-4`, and `1rem` without a theme.
34
+ *
35
+ * @property {string} href - The address the row leads to. Unset, the row is no link.
36
+ * @property {string} target - Where to open the address (only with `href`).
37
+ * @property {string} rel - `rel` attribute for the link, written when `target` is set. Default
38
+ * `'noreferrer noopener'`.
39
+ * @property {boolean} current - The row is the current or the chosen one: it gets `aria-current`
40
+ * (`"page"` on the link of a row with `href`, `"true"` on a row without), a bar at its start
41
+ * and a heavier title. Default `false`.
42
+ * @property {string} mark - Marks the row with a dot in the padding at its start, which does not
43
+ * move the texts: an unread message, for example. The text is what assistive technology reads
44
+ * in front of the title ("Unread"). Unset, the row has no mark.
45
+ * @property {boolean} truncate - Cuts the title and the line under it after one line, with an
46
+ * ellipsis. Unset, a long text breaks into more lines. Default `false`.
47
+ */
48
+ export default class ListItem extends TemplateElement {
49
+ constructor();
50
+ properties(): {
51
+ href: string;
52
+ target: string;
53
+ rel: string;
54
+ current: boolean;
55
+ mark: string;
56
+ truncate: boolean;
57
+ };
58
+ /** @private */
59
+ private titleTemplate;
60
+ template(): any;
61
+ }
62
+ export declare function define(): void;
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;
@@ -0,0 +1,266 @@
1
+ import { TemplateElement } from '@webtides/element-js';
2
+ import Events from './menu.events.js';
3
+ /**
4
+ * A menu button: a button that opens a list of actions. "Edit, Duplicate, Delete" for a row of a
5
+ * table, the account in a header, "More" at the end of a toolbar. The button is what the page
6
+ * puts into the `trigger` slot, the actions are `el-menu-item` elements.
7
+ *
8
+ * To assistive technology it is a menu (`role="menu"`) of menu items, and the button says that it
9
+ * opens one and whether it is open. The keyboard moves through the entries with the arrow keys,
10
+ * `Home`, `End` and the first letter of an entry. `Escape` closes the menu and gives the focus
11
+ * back to the button, the Tab key closes it and moves on.
12
+ *
13
+ * The panel is a native popover: it is in the top layer, so nothing clips it and it moves nothing
14
+ * on the page. It is placed at the button, at the side that `placement` names, on the other side
15
+ * without room there, and never outside of the viewport. A press beside it closes it.
16
+ *
17
+ * Choosing an entry closes the menu and fires `menu-select`.
18
+ *
19
+ * One menu can serve many things, the rows of a list: `showAt()` opens it at a point of the
20
+ * viewport, for a right click or a long press, or at an element of the page, a button of a row.
21
+ * What it was opened for is the `opener`, which gets the focus back and which `menu-select`
22
+ * names.
23
+ *
24
+ * @element el-menu
25
+ *
26
+ * @fires {CustomEvent} menu-show - Fired when the menu has opened.
27
+ * @fires {CustomEvent} menu-hide - Fired when the menu has closed.
28
+ * @fires {CustomEvent<{ item: HTMLElement, value: string, opener: Element | undefined }>} menu-select -
29
+ * Fired when the user has chosen an entry: the `el-menu-item` is in `detail.item`, its `value`
30
+ * in `detail.value`, and what the menu was opened for in `detail.opener`. The menu closes after
31
+ * it.
32
+ *
33
+ * @slot - The entries: `el-menu-item` elements, in `el-menu-group` elements where they are
34
+ * divided into groups. An `el-divider` is a line between two of them.
35
+ * @slot trigger - The button that opens the menu. It gets `aria-haspopup="menu"` and
36
+ * `aria-expanded`.
37
+ *
38
+ * @csspart trigger - Forwarded onto the `trigger` slot.
39
+ * @csspart panel - The floating panel, which is the menu (`role="menu"`): background, border,
40
+ * radius, elevation, width.
41
+ *
42
+ * @cssstate open - Set while the menu is shown.
43
+ *
44
+ * @property {boolean} open - Whether the menu is shown. Reflected to the `open` attribute.
45
+ * @property {string} label - The name of the menu for assistive technology. Without one the menu
46
+ * has the name of its button.
47
+ * @property {'top'|'top-start'|'top-end'|'bottom'|'bottom-start'|'bottom-end'|'left'|'left-start'|'left-end'|'right'|'right-start'|'right-end'} placement -
48
+ * The side of the button the menu is placed at, and with `-start` or `-end` the edge of the
49
+ * button it is aligned with. Without room there, the menu goes to the opposite side. Default
50
+ * `'bottom-start'`.
51
+ * @property {number} distance - The gap between the button and the menu, in pixels. Default `4`.
52
+ */
53
+ export default class Menu extends TemplateElement {
54
+ open: any;
55
+ _openAtPointerDown: any;
56
+ _stopAutoUpdate: () => void;
57
+ /**
58
+ * Which entry gets the focus when the menu opens: the first one, or the last one for
59
+ * `ArrowUp` on the button.
60
+ * @private
61
+ * @type {'first'|'last'}
62
+ */
63
+ private _enterAt;
64
+ /**
65
+ * Whether the focus goes back to the button when the menu closes. It does after a choice and
66
+ * after `Escape`, and not where the user has moved it on.
67
+ * @private
68
+ */
69
+ private _restoreFocus;
70
+ /**
71
+ * Where the menu is placed while it is open somewhere else than at its own button: an element
72
+ * of the page, or a point of the viewport.
73
+ * @private
74
+ * @type {Element | { x: number, y: number } | undefined}
75
+ */
76
+ private _place;
77
+ /**
78
+ * What the menu was opened for with `showAt()`.
79
+ * @private
80
+ * @type {Element | undefined}
81
+ */
82
+ private _opener;
83
+ /**
84
+ * The button of the page that was told that the menu is open.
85
+ * @private
86
+ * @type {Element | undefined}
87
+ */
88
+ private _expanded;
89
+ /**
90
+ * Where the menu opens next, and what for: what `showAt()` was given. It is taken when the
91
+ * menu opens, which is after the element has rendered.
92
+ * @private
93
+ * @type {{ place: Element | { x: number, y: number }, opener: Element | undefined } | undefined}
94
+ */
95
+ private _next;
96
+ /**
97
+ * Whether the Tab key was pressed in the menu, and the focus is about to leave it.
98
+ * @private
99
+ */
100
+ private _leaving;
101
+ /**
102
+ * A pointer that goes down beside the open menu closes it. The panel is a popover the menu
103
+ * opens and closes itself (`popover="manual"`): the platform would close one of its own
104
+ * (`auto`) when the pointer that opened it is let go, the finger after a long press.
105
+ * @private
106
+ * @param {PointerEvent} event
107
+ */
108
+ private _onPressOutside;
109
+ constructor();
110
+ properties(): {
111
+ open: boolean;
112
+ label: string;
113
+ placement: string;
114
+ distance: number;
115
+ };
116
+ connected(): void;
117
+ disconnected(): void;
118
+ afterUpdate(): void;
119
+ watch(): {
120
+ open: (open: any) => void;
121
+ };
122
+ events(): {
123
+ '[data-trigger]': {
124
+ pointerdown: () => void;
125
+ click: (event: any) => void;
126
+ keydown: (event: any) => void;
127
+ slotchange: () => void;
128
+ };
129
+ "[part~='panel']": {
130
+ keydown: (event: any) => void;
131
+ click: (event: any) => void;
132
+ focusout: (event: any) => void;
133
+ };
134
+ };
135
+ /**
136
+ * Opens the menu, with the focus on its first entry.
137
+ * @returns {void}
138
+ */
139
+ show(): void;
140
+ /**
141
+ * Opens the menu somewhere else than at its own button: one menu for the rows of a list.
142
+ *
143
+ * At a point of the viewport, from a `contextmenu` event or a long press: the corner of the
144
+ * menu is at the point, and the menu stays inside of the viewport. Or at an element of the
145
+ * page, the button of a row: the menu is placed at it as at its own button.
146
+ *
147
+ * `opener` is what the menu is opened for. It gets the focus back when the menu closes, and
148
+ * `menu-select` names it (`detail.opener`). Without one it is the element the menu is placed
149
+ * at.
150
+ * @param {Element | { x: number, y: number }} place - The element, or the point in the
151
+ * coordinates of the viewport (`clientX`, `clientY`).
152
+ * @param {Element} [opener] - The row or the button the menu is opened for.
153
+ * @returns {void}
154
+ */
155
+ showAt(place: Element | {
156
+ x: number;
157
+ y: number;
158
+ }, opener?: Element): void;
159
+ /**
160
+ * Closes the menu.
161
+ * @returns {void}
162
+ */
163
+ hide(): void;
164
+ /**
165
+ * What the menu is open for: the row or the button it was opened for with `showAt()`, or its
166
+ * own button. Nothing while it is closed.
167
+ * @returns {Element | undefined}
168
+ */
169
+ get opener(): Element | undefined;
170
+ /**
171
+ * Opens the menu when it is closed, and closes it when it is open.
172
+ * @returns {void}
173
+ */
174
+ toggle(): void;
175
+ /**
176
+ * The button of the menu: what is in the `trigger` slot.
177
+ * @private
178
+ * @returns {HTMLElement | undefined}
179
+ */
180
+ private _trigger;
181
+ /**
182
+ * The entries the user can reach, in the order of the page. An entry that is disabled is one
183
+ * of them: the keyboard gets to it, so a screen reader finds it, and it cannot be chosen.
184
+ * @private
185
+ * @returns {HTMLElement[]}
186
+ */
187
+ private _items;
188
+ /**
189
+ * The text of an entry, without its icon: what a letter of the keyboard is compared with.
190
+ * @private
191
+ * @param {Element} item
192
+ * @returns {string}
193
+ */
194
+ private _textOf;
195
+ /**
196
+ * The button says that it opens a menu, and whether the menu is open. An `el-button` passes
197
+ * both on to the control inside of it.
198
+ * @private
199
+ */
200
+ private _syncTrigger;
201
+ /**
202
+ * Whether the focus is on an entry of the menu.
203
+ * @private
204
+ * @returns {boolean}
205
+ */
206
+ private _hasFocusInPanel;
207
+ /**
208
+ * The arrow keys on the button open the menu: down at its first entry, up at its last one.
209
+ * `Enter` and `Space` are a click of the button.
210
+ * @private
211
+ * @param {KeyboardEvent} event
212
+ */
213
+ private _onTriggerKeyDown;
214
+ /**
215
+ * The keys of a menu, while the focus is on one of its entries.
216
+ * @private
217
+ * @param {KeyboardEvent} event
218
+ */
219
+ private _onKeyDown;
220
+ /**
221
+ * A click in the panel: the user has chosen the entry it is on, unless that one is disabled.
222
+ * @private
223
+ * @param {MouseEvent} event
224
+ */
225
+ private _onClick;
226
+ /**
227
+ * The focus has left the menu with the Tab key, which closes it and moves on. The focus is
228
+ * where the user has put it, and stays there.
229
+ *
230
+ * Only the key closes it this way. A pointer that goes down beside the menu closes it by
231
+ * itself, and the finger of a long press gives the focus to the row it is on when it is
232
+ * lifted: the menu it has just opened stays open.
233
+ * @private
234
+ * @param {FocusEvent} event
235
+ */
236
+ private _onFocusOut;
237
+ /**
238
+ * Puts the focus on the entry the menu is entered at.
239
+ * @private
240
+ */
241
+ private _focusEntry;
242
+ /** @private */
243
+ private _applyOpen;
244
+ /** @private */
245
+ private _applyClose;
246
+ /**
247
+ * What the panel is placed at: its own button, the element of `showAt()`, or its point. A
248
+ * point is an element for the placing that has no size and does not move.
249
+ * @private
250
+ * @returns {Element | { getBoundingClientRect: () => DOMRect }}
251
+ */
252
+ private _anchor;
253
+ /**
254
+ * Places the panel now, and again whenever the button moves: on scroll, on resize, when the
255
+ * button or the panel changes its size.
256
+ * @private
257
+ */
258
+ private _startPositioning;
259
+ /** @private */
260
+ private _stopPositioning;
261
+ /** @private */
262
+ private _position;
263
+ template(): any;
264
+ }
265
+ export declare function define(): void;
266
+ export { Events };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ SHOW: string;
3
+ HIDE: string;
4
+ SELECT: string;
5
+ };
6
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import { TemplateElement } from '@webtides/element-js';
2
+ /**
3
+ * A group of entries in an `el-menu`, with a heading where it has a `label`. A group to assistive
4
+ * technology (`role="group"`), which has the heading as its name. A line divides it from what is
5
+ * before it in the menu.
6
+ *
7
+ * @element el-menu-group
8
+ *
9
+ * @slot - The entries of the group: `el-menu-item` elements.
10
+ *
11
+ * @csspart base - The group, with the line over it.
12
+ * @csspart label - The heading of the group.
13
+ *
14
+ * @property {string} label - The heading of the group, and its name for assistive technology.
15
+ * Default `''`.
16
+ */
17
+ export default class MenuGroup extends TemplateElement {
18
+ constructor();
19
+ properties(): {
20
+ label: string;
21
+ };
22
+ template(): any;
23
+ }
24
+ export declare function define(): void;
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;