@webtides/element-library 0.4.0 → 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 (93) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/custom-elements.json +1543 -199
  3. package/package.json +1 -1
  4. package/src/components/app-frame/app-frame.changelog.md +14 -0
  5. package/src/components/app-frame/app-frame.js +14 -2
  6. package/src/components/app-frame/app-frame.readme.md +12 -3
  7. package/src/components/app-frame/app-frame.style.js +7 -0
  8. package/src/components/button/button.changelog.md +6 -0
  9. package/src/components/button/button.style.js +6 -1
  10. package/src/components/button-group/button-group.changelog.md +10 -0
  11. package/src/components/button-group/button-group.readme.md +2 -0
  12. package/src/components/button-group/button-group.style.js +6 -2
  13. package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +6 -0
  14. package/src/components/checkbox-group-field/checkbox-group-field.js +7 -2
  15. package/src/components/checkbox-group-field/checkbox-group-field.readme.md +23 -1
  16. package/src/components/combobox-field/combobox-field.changelog.md +6 -0
  17. package/src/components/combobox-field/combobox-field.readme.md +8 -0
  18. package/src/components/combobox-field/combobox-field.style.js +2 -0
  19. package/src/components/date-field/date-field.changelog.md +6 -0
  20. package/src/components/date-field/date-field.readme.md +10 -0
  21. package/src/components/date-field/date-field.style.js +8 -3
  22. package/src/components/description-list/description-list.changelog.md +17 -0
  23. package/src/components/description-list/description-list.js +7 -2
  24. package/src/components/description-list/description-list.readme.md +30 -4
  25. package/src/components/description-list/description-list.style.js +57 -28
  26. package/src/components/divider/divider.changelog.md +6 -0
  27. package/src/components/divider/divider.readme.md +1 -1
  28. package/src/components/divider/divider.style.js +6 -0
  29. package/src/components/file-field/file-field.changelog.md +8 -0
  30. package/src/components/file-field/file-field.js +135 -5
  31. package/src/components/file-field/file-field.readme.md +35 -6
  32. package/src/components/file-field/file-field.style.js +71 -0
  33. package/src/components/form-field/form-field.js +1 -1
  34. package/src/components/input-field/input-field.changelog.md +10 -0
  35. package/src/components/input-field/input-field.js +192 -14
  36. package/src/components/input-field/input-field.readme.md +88 -2
  37. package/src/components/input-field/input-field.style.js +2 -0
  38. package/src/components/list/list.changelog.md +6 -0
  39. package/src/components/list/list.js +2 -0
  40. package/src/components/list/list.readme.md +1 -0
  41. package/src/components/list-item/list-item.changelog.md +16 -0
  42. package/src/components/list-item/list-item.js +2 -0
  43. package/src/components/list-item/list-item.readme.md +19 -1
  44. package/src/components/list-item/list-item.style.js +23 -11
  45. package/src/components/menu/menu.changelog.md +17 -0
  46. package/src/components/menu/menu.js +293 -70
  47. package/src/components/menu/menu.readme.md +47 -6
  48. package/src/components/menu/menu.style.js +6 -2
  49. package/src/components/menu-item/menu-item.changelog.md +8 -0
  50. package/src/components/menu-item/menu-item.js +41 -3
  51. package/src/components/menu-item/menu-item.readme.md +45 -7
  52. package/src/components/menu-item/menu-item.style.js +30 -0
  53. package/src/components/otp-field/otp-field.changelog.md +6 -0
  54. package/src/components/otp-field/otp-field.readme.md +8 -0
  55. package/src/components/otp-field/otp-field.style.js +8 -3
  56. package/src/components/password-field/password-field.changelog.md +7 -0
  57. package/src/components/password-field/password-field.readme.md +11 -1
  58. package/src/components/password-field/password-field.style.js +2 -0
  59. package/src/components/popover/popover.changelog.md +6 -0
  60. package/src/components/popover/popover.style.js +1 -0
  61. package/src/components/radio-field/radio-field.changelog.md +6 -0
  62. package/src/components/radio-field/radio-field.js +7 -2
  63. package/src/components/radio-field/radio-field.readme.md +23 -1
  64. package/src/components/textarea-field/textarea-field.changelog.md +6 -0
  65. package/src/components/textarea-field/textarea-field.js +14 -1
  66. package/src/components/textarea-field/textarea-field.readme.md +23 -1
  67. package/src/styles/choice-group.style.js +26 -0
  68. package/src/styles/input-control.style.js +87 -0
  69. package/src/styles/native.css +100 -0
  70. package/src/utils/floating.js +15 -1
  71. package/src/utils/options.js +35 -0
  72. package/src/utils/text-entry-attributes.js +13 -0
  73. package/types/src/components/app-frame/app-frame.d.ts +7 -1
  74. package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +5 -2
  75. package/types/src/components/combobox-field/combobox-field.d.ts +10 -0
  76. package/types/src/components/date-field/date-field.d.ts +10 -0
  77. package/types/src/components/description-list/description-list.d.ts +7 -2
  78. package/types/src/components/file-field/file-field.d.ts +68 -3
  79. package/types/src/components/form-field/form-field.d.ts +1 -1
  80. package/types/src/components/input-field/input-field.d.ts +99 -0
  81. package/types/src/components/list/list.d.ts +2 -0
  82. package/types/src/components/list-item/list-item.d.ts +2 -0
  83. package/types/src/components/menu/menu.d.ts +105 -9
  84. package/types/src/components/menu-item/menu-item.d.ts +21 -0
  85. package/types/src/components/otp-field/otp-field.d.ts +10 -0
  86. package/types/src/components/password-field/password-field.d.ts +10 -0
  87. package/types/src/components/radio-field/radio-field.d.ts +5 -2
  88. package/types/src/components/textarea-field/textarea-field.d.ts +7 -0
  89. package/types/src/styles/input-control.style.d.ts +15 -0
  90. package/types/src/utils/floating.d.ts +11 -0
  91. package/types/src/utils/options.d.ts +17 -0
  92. package/types/src/utils/text-entry-attributes.d.ts +10 -0
  93. package/web-types.json +514 -24
@@ -1,18 +1,38 @@
1
1
  import { html, defineElement, classMap, when, optionalAttribute, spreadAttributes } from '@webtides/element-js';
2
2
  import FormField from '../form-field/form-field.js';
3
- import { shadowNativeTextEntryProperties, textEntryAttributes } from '../../utils/text-entry-attributes.js';
3
+ import {
4
+ lengthAttribute,
5
+ shadowNativeTextEntryProperties,
6
+ textEntryAttributes,
7
+ } from '../../utils/text-entry-attributes.js';
4
8
  import style from './input-field.style.js';
5
9
 
10
+ /** What is a control of its own in the content of the page: it has a name and a stop of the Tab key. */
11
+ const CONTROL = 'a[href], button, input, select, textarea, [tabindex], el-button, el-copy-button';
12
+
13
+ /** What takes the focus of a click itself. Asked of everything a click has passed, shadow roots included. */
14
+ const FOCUSABLE = 'a[href], button, input, select, textarea, summary, [tabindex], [contenteditable]';
15
+
6
16
  /**
7
17
  * Native `<input>` wrapper with label, help text, validation feedback (visual checkmark /
8
18
  * cross indicators) and ARIA wiring. Extends `FormField` and inherits its label / help /
9
19
  * error / required surface.
10
20
  *
21
+ * The page can put content at the start and at the end of the control: an element with
22
+ * `slot="start"` or `slot="end"` among the children of the field. The field has no shadow root,
23
+ * so these are no slots of the platform: the field takes the elements into its control when it
24
+ * renders. And `clearable` adds a button that empties the field.
25
+ *
11
26
  * @element el-input-field
12
27
  *
13
28
  * @fires {CustomEvent<string>} input-change - Fired when the input's value changes.
14
29
  * `detail` is the new value. Bubbles.
15
30
  *
31
+ * @slot start - Content at the start of the control, in front of the text: an icon, a text, a
32
+ * button. An element of the page with `slot="start"`.
33
+ * @slot end - Content at the end of the control, after the text: a unit, a button. An element of
34
+ * the page with `slot="end"`.
35
+ *
16
36
  * @property {string} type - Native `type` attribute of the underlying `<input>` (e.g.
17
37
  * `'text'`, `'email'`, `'password'`, `'tel'`, `'url'`).
18
38
  * @property {'small'|'medium'|'large'} size - Size of the control: its height, its padding and its
@@ -22,6 +42,15 @@ import style from './input-field.style.js';
22
42
  * @property {string | false} pattern - Regular expression used as the input's `pattern`
23
43
  * attribute. When `false` (the default), the `pattern` attribute is omitted entirely, so
24
44
  * the field applies no pattern constraint.
45
+ * @property {boolean} clearable - Whether the control has a button that empties it. The button
46
+ * shows while the field has a value and is not disabled. Default `false`.
47
+ * @property {string} clearLabel - The name of that button for assistive technology. Default
48
+ * `'Clear'`.
49
+ * @property {number | null} maxlength - Passed on to the control as `maxlength`: the browser takes
50
+ * no more characters than this while the user types. `null` (the default) leaves the attribute
51
+ * out.
52
+ * @property {number | null} minlength - Passed on as `minlength`: a text the user has typed that is
53
+ * shorter makes the field invalid. `null` (the default) leaves the attribute out.
25
54
  * @property {string | null} autocomplete - Passed on to the control as its `autocomplete`
26
55
  * attribute (e.g. `'email'`, `'current-password'`, `'one-time-code'`). `null` (the default)
27
56
  * leaves the attribute out. The same holds for the five properties below.
@@ -53,6 +82,10 @@ export default class InputField extends FormField {
53
82
  size: 'medium',
54
83
  placeholder: '',
55
84
  pattern: false,
85
+ clearable: false,
86
+ clearLabel: 'Clear',
87
+ maxlength: null,
88
+ minlength: null,
56
89
  autocomplete: null,
57
90
  inputmode: null,
58
91
  enterkeyhint: null,
@@ -62,6 +95,13 @@ export default class InputField extends FormField {
62
95
  };
63
96
  }
64
97
 
98
+ connectedCallback() {
99
+ // A server renders the template without the lifecycle: from here on the field is in a
100
+ // browser, and what the page has put into it are nodes the template takes in.
101
+ this._started = true;
102
+ super.connectedCallback();
103
+ }
104
+
65
105
  watch() {
66
106
  const watchers = super.watch();
67
107
  return {
@@ -75,6 +115,97 @@ export default class InputField extends FormField {
75
115
  };
76
116
  }
77
117
 
118
+ events() {
119
+ const events = super.events();
120
+ return {
121
+ ...events,
122
+ '.control': {
123
+ click: (event) => this._onControlClick(event),
124
+ },
125
+ '[data-clear]': {
126
+ click: () => this.clearInput(),
127
+ },
128
+ };
129
+ }
130
+
131
+ /**
132
+ * The elements the page has put into the field for the start or the end of its control:
133
+ * `<span slot="end">€</span>`. They are children of the field until it renders, and in
134
+ * their place in the control from then on, also in server-rendered markup. An element that
135
+ * comes later is taken in with the next render.
136
+ * @private
137
+ * @param {'start'|'end'} name
138
+ * @returns {Element[]}
139
+ */
140
+ _slotted(name) {
141
+ const placed = this._started ? this.querySelector(`:scope > .field > .control > .control-${name}`) : null;
142
+ return [
143
+ ...(placed ? placed.children : []),
144
+ ...[...this.children].filter((child) => child.getAttribute('slot') === name),
145
+ ];
146
+ }
147
+
148
+ /**
149
+ * The content for a place in the control. In a browser the elements of the page themselves:
150
+ * they are moved, not copied, and stay where they are with every render. On a server their
151
+ * markup, written as it is.
152
+ *
153
+ * That is what `unsafeHTML()` gives on a server. It is written out here because the directive
154
+ * gives nodes wherever there is a DOM, and a template that is turned into a string in a
155
+ * browser, as the tests of the server-rendered markup do, would lose them.
156
+ * @private
157
+ * @param {Element[]} elements
158
+ * @returns {Element[] | { __unsafeHTML: true, string: string }}
159
+ */
160
+ _content(elements) {
161
+ if (this._started) return elements;
162
+ return { __unsafeHTML: true, string: elements.map((element) => element.outerHTML).join('') };
163
+ }
164
+
165
+ /**
166
+ * Whether what the page has put at a place describes the value: a unit, a currency, the start
167
+ * of an address. A screen reader reads it with the input then. A control there, a button or
168
+ * a link, has a name and a stop of the Tab key itself, and is no description. An icon is none
169
+ * either: it has no text, and is hidden from assistive technology (`aria-hidden`).
170
+ * @private
171
+ * @param {Element[]} elements
172
+ * @returns {boolean}
173
+ */
174
+ _describes(elements) {
175
+ return (
176
+ elements.some((element) => element.textContent.trim() !== '') &&
177
+ !elements.some((element) => element.matches(CONTROL) || element.querySelector(CONTROL))
178
+ );
179
+ }
180
+
181
+ /**
182
+ * The description of the control: what the page has put at its start and at its end, then the
183
+ * messages of the field.
184
+ * @private
185
+ * @returns {string}
186
+ */
187
+ _describedBy() {
188
+ const { start = [], end = [] } = this._controlContent ?? {};
189
+ const ids = [];
190
+ if (this._describes(start)) ids.push(this._idOf('control-start'));
191
+ if (this._describes(end)) ids.push(this._idOf('control-end'));
192
+ return [...ids, super._describedBy()].join(' ');
193
+ }
194
+
195
+ /**
196
+ * A click on the control beside its input, on a text or an icon of the page, puts the focus
197
+ * into the input: to the eye all of it is the control. A control in the content, the button
198
+ * that clears the field and the input itself keep their click.
199
+ * @private
200
+ * @param {MouseEvent} event
201
+ */
202
+ _onControlClick(event) {
203
+ const path = event.composedPath();
204
+ const inside = path.slice(0, path.indexOf(event.currentTarget));
205
+ if (inside.some((node) => node instanceof Element && node.matches(FOCUSABLE))) return;
206
+ this.$refs.input.focus();
207
+ }
208
+
78
209
  /**
79
210
  * The pattern of the control. A field that extends this one can have a pattern of its own
80
211
  * where the page gives none (`OtpField`).
@@ -105,8 +236,13 @@ export default class InputField extends FormField {
105
236
  fieldTemplate() {
106
237
  const pattern = this._pattern();
107
238
  const { list = null, min = null, max = null, step = null } = this._controlAttributes();
239
+ const start = this._slotted('start');
240
+ const end = this._slotted('end');
241
+ const clearable = this.clearable === true || this.clearable === 'true' || this.clearable === '';
242
+ // The description of the input names the content, so it is found before the input.
243
+ this._controlContent = { start, end };
108
244
 
109
- return html`
245
+ const input = html`
110
246
  <input
111
247
  ref="input"
112
248
  id="${this._idOf('input')}"
@@ -121,23 +257,65 @@ export default class InputField extends FormField {
121
257
  min="${min}"
122
258
  max="${max}"
123
259
  step="${step}"
260
+ maxlength="${lengthAttribute(this.maxlength)}"
261
+ minlength="${lengthAttribute(this.minlength)}"
124
262
  ${spreadAttributes(textEntryAttributes(this))}
125
263
  aria-describedby="${this._describedBy()}"
126
264
  aria-invalid="${this.valid ? 'false' : 'true'}"
127
265
  aria-errormessage="${this._idOf('error-message')}"
128
266
  />
129
- ${when(
130
- this.touched,
131
- html`
132
- <div class="validity ${classMap({ 'is-valid': !!this.valid, 'is-invalid': !this.valid })}">
133
- ${when(
134
- this.valid,
135
- html` <span class="valid h-4 w-4">&checkmark;</span> `,
136
- html` <span class="invalid h-4 w-4" data-clear-input>&cross;</span> `,
137
- )}
138
- </div>
139
- `,
140
- )}
267
+ `;
268
+ const validity = when(
269
+ this.touched,
270
+ html`
271
+ <div class="validity ${classMap({ 'is-valid': !!this.valid, 'is-invalid': !this.valid })}">
272
+ ${when(
273
+ this.valid,
274
+ html` <span class="valid h-4 w-4">&checkmark;</span> `,
275
+ html` <span class="invalid h-4 w-4" data-clear-input>&cross;</span> `,
276
+ )}
277
+ </div>
278
+ `,
279
+ );
280
+
281
+ // A field without any of it is its input, as it was.
282
+ if (!start.length && !end.length && !clearable) return html`${input} ${validity}`;
283
+
284
+ // The button shows while there is something to clear, and has its place in the markup
285
+ // all the time. The mark of the validity stays beside the control.
286
+ const clears = clearable && String(this.value ?? '') !== '' && !this.disabled;
287
+ return html`
288
+ <div class="control">
289
+ <span
290
+ id="${this._idOf('control-start')}"
291
+ class="control-content control-start"
292
+ ?hidden="${!start.length}"
293
+ >${this._content(start)}</span
294
+ >
295
+ ${input}
296
+ <button
297
+ type="button"
298
+ class="control-clear"
299
+ data-clear
300
+ aria-label="${this.clearLabel}"
301
+ ?hidden="${!clears}"
302
+ >
303
+ <svg
304
+ viewBox="0 0 24 24"
305
+ fill="none"
306
+ stroke="currentColor"
307
+ stroke-width="2"
308
+ stroke-linecap="round"
309
+ aria-hidden="true"
310
+ >
311
+ <path d="M6 6l12 12M18 6L6 18"></path>
312
+ </svg>
313
+ </button>
314
+ <span id="${this._idOf('control-end')}" class="control-content control-end" ?hidden="${!end.length}"
315
+ >${this._content(end)}</span
316
+ >
317
+ </div>
318
+ ${validity}
141
319
  `;
142
320
  }
143
321
  }
@@ -40,6 +40,10 @@ import '@webtides/element-library/input-field/define';
40
40
  | `size` | `string` | `'medium'` | `small`, `medium` or `large`: the height, the padding and the font size of the control. Reflected. Shows once `styles/native.css` decorates the control. |
41
41
  | `placeholder` | `string` | `''` | Placeholder text displayed when the input is empty |
42
42
  | `pattern` | `string\|boolean` | `false` | Regular expression pattern for input validation. If false, allows any input |
43
+ | `clearable` | `boolean` | `false` | Whether the control has a button that empties it. The button shows while the field has a value and is not disabled |
44
+ | `clearLabel` | `string` | `'Clear'` | The name of that button for assistive technology |
45
+ | `maxlength` | `number` | `null` | Passed on to the control as `maxlength`: the browser takes no more characters than this while the user types |
46
+ | `minlength` | `number` | `null` | Passed on as `minlength`: a text the user has typed that is shorter makes the field invalid |
43
47
  | `autocomplete` | `string` | `null` | Passed on to the control as `autocomplete` (e.g. `email`, `current-password`, `one-time-code`) |
44
48
  | `inputmode` | `string` | `null` | Passed on as `inputmode`: the on-screen keyboard to show (e.g. `numeric`, `email`) |
45
49
  | `enterkeyhint` | `string` | `null` | Passed on as `enterkeyhint`: the label of the enter key on an on-screen keyboard (e.g. `next`, `send`) |
@@ -82,7 +86,65 @@ On a touch screen (`@media (any-pointer: coarse)`) the input is at least `--el-t
82
86
 
83
87
  #### Slots
84
88
 
85
- _None_ - The component generates its own input element internally
89
+ The field has no shadow root, so these are no slots of the platform: an element of the page with the `slot` attribute, among the children of the field, is taken into the control when the field renders. See [Content in the control](#content-in-the-control).
90
+
91
+ | Name | Description |
92
+ | ------- | ------------------------------------------------------------------------------------- |
93
+ | `start` | Content at the start of the control, in front of the text: an icon, a text, a button. |
94
+ | `end` | Content at the end of the control, after the text: a unit, a button. |
95
+
96
+ ## Content in the control
97
+
98
+ A search field with a magnifying glass, a price with its currency, an address that starts with `https://`, a key with a button that copies it: the page puts an element with `slot="start"` or `slot="end"` into the field, and the field takes it into its control.
99
+
100
+ ```html
101
+ <el-input-field name="q" label="Search" clearable="true">
102
+ <svg slot="start" aria-hidden="true">…</svg>
103
+ </el-input-field>
104
+
105
+ <el-input-field name="price" label="Price" inputmode="decimal">
106
+ <span slot="end">Euro</span>
107
+ </el-input-field>
108
+
109
+ <el-input-field name="site" label="Your site">
110
+ <span slot="start">https://</span>
111
+ </el-input-field>
112
+
113
+ <el-input-field name="key" label="Key" value="4f2a-91c7">
114
+ <el-copy-button slot="end" value="4f2a-91c7"></el-copy-button>
115
+ </el-input-field>
116
+ ```
117
+
118
+ - **In the control.** The content stands in a row with the input, the start in front of it and the end after it, and the text of the input does not run under it: the input is as wide as what is left. In a right-to-left page the start is at the right.
119
+ - **The elements of the page themselves.** The field moves them, it does not copy them: a listener of the page stays on its button, and the element is the same after every render. An element that comes later is taken in with the next render (`field.requestUpdate()`). A text needs an element around it (`<span slot="end">kg</span>`).
120
+ - **A click on a text or on an icon** puts the focus into the input: to the eye all of it is the control. **A button or a link** there keeps its click and is a stop of the Tab key of its own, after the input for one at the end.
121
+ - **A text is read with the input.** A unit or a currency is part of what the value means, so the input names the content as a part of its description (`aria-describedby`), in front of the help message: "Price, edit text, Euro". Write a text a screen reader can say, "Euro" before "€". **An icon is not**: give it `aria-hidden="true"`. Content with a control in it is no description either: the button has a name of its own.
122
+ - **The mark of a field that was touched** (✓ or ✗) keeps its place beside the control, and does not lie on the content at the end.
123
+ - **Server-rendered**, the content is in its place in the markup, and the element takes it over where it is.
124
+
125
+ #### With and without `styles/native.css`
126
+
127
+ The border of a native input cannot have anything inside of it. So the field renders a row around the input (`.control`), only while there is content for it or the field is `clearable`, and [`styles/native.css`](../../styles/native.css) makes that row the control: it has the border, the surface and the radius of an input, and the input inside of it has none. The focus ring is around all of it while the input has the focus, and not for a button in it, which has its own. The border of a field that is not valid is around all of it, and a disabled field fades as a whole. The row is as high as an input of its `size` alone.
128
+
129
+ Without that file the input keeps the border of the browser, as every control does, and the content stands beside it in the row.
130
+
131
+ #### The button that clears the field
132
+
133
+ `clearable="true"` adds a button at the end of the control, in front of the content at the end. It shows while the field has a value and is not disabled.
134
+
135
+ ```html
136
+ <el-input-field name="city" label="City" clearable="true" clear-label="Clear the city"></el-input-field>
137
+ ```
138
+
139
+ - It empties the value, `input-change` reports the empty value, and the focus is in the input after.
140
+ - It is a button with a name (`clear-label`, `Clear` by default: set it for other languages), and a stop of the Tab key after the input.
141
+ - On a touch screen it is at least `--el-touch-target` wide and high.
142
+
143
+ The fields that extend this one have both: [`el-combobox-field`](../combobox-field/combobox-field.readme.md), [`el-date-field`](../date-field/date-field.readme.md), [`el-otp-field`](../otp-field/otp-field.readme.md) and [`el-password-field`](../password-field/password-field.readme.md), which keeps its own button beside the control.
144
+
145
+ #### Not in this element
146
+
147
+ Two controls joined into one row: a select for the country code in front of a phone number, a button outside of the field that touches it. A select or a textarea with content in it.
86
148
 
87
149
  ## Keyboard and autofill hints
88
150
 
@@ -100,9 +162,33 @@ _None_ - The component generates its own input element internally
100
162
 
101
163
  Removing one of these attributes later leaves it empty (`autocomplete=""`) on the element and on the control, if it was there when the element started: element-js writes a removed attribute back empty. An empty value has the meaning of the default: on for `spellcheck` and `autocorrect`, the browser's own choice for the other four.
102
164
 
165
+ ## The length of the text
166
+
167
+ `maxlength` and `minlength` are passed on to the control, in server-rendered markup as well, and one that is not set is not rendered. The browser does the rest:
168
+
169
+ ```html
170
+ <el-input-field
171
+ name="name"
172
+ label="Name"
173
+ maxlength="100"
174
+ minlength="2"
175
+ error-message="At least 2 characters"
176
+ ></el-input-field>
177
+ ```
178
+
179
+ - **`maxlength`**: the control takes no more characters while the user types or pastes. Nothing is invalid for it: the text is never longer.
180
+ - **`minlength`**: a text the user has typed that is shorter makes the field invalid, the way `required` and `pattern` do: `valid` is `false`, the field shows its `error-message` once it was touched, and the form is not submitted.
181
+ - **Only what the user has typed is measured.** A browser does not hold a value against these limits that the page or the server has put into the control. A value from the server that is too long or too short is valid until the user changes it: the server checks what it gets.
182
+ - **An empty field is not too short.** `minlength` is for a text that is there. Add `required` for a field that has to be filled.
183
+ - **Say the limit.** The field shows no counter and no limit of its own: name it in `help-message`, and in `error-message` for the least length.
184
+
185
+ The fields that extend this one take both as well (`el-password-field`, `el-combobox-field`). An `el-otp-field` has `length` for its code, and a date has no length.
186
+
103
187
  ## Accessibility
104
188
 
105
189
  - Includes proper ARIA attributes (`aria-describedby`, `aria-invalid`, `aria-errormessage`)
190
+ - A text at the start or at the end of the control is part of the description of the input, an icon is not, and a button there is a control of its own
191
+ - The button that clears the field has a name (`clear-label`)
106
192
  - Links labels to inputs via `for` attribute
107
193
  - Supports screen reader only labels
108
194
  - Visual validity indicators (✓ for valid, × for invalid)
@@ -115,5 +201,5 @@ The component provides real-time validation feedback:
115
201
  - Validation state updates on focus, blur, and change events
116
202
  - Visual indicators appear after the field is touched
117
203
  - Error messages only display when field is touched and invalid
118
- - Supports HTML5 validation attributes (required, pattern, type)
204
+ - Supports HTML5 validation attributes (required, pattern, minlength, type)
119
205
  - Clicking the invalid indicator (×) clears the input
@@ -1,6 +1,7 @@
1
1
  import hostStyle from '../../styles/host.style.js';
2
2
  import formControlStyle from '../../styles/form-control.style.js';
3
3
  import sizeStyle from '../../styles/size.style.js';
4
+ import inputControlStyle from '../../styles/input-control.style.js';
4
5
 
5
6
  const css = String.raw;
6
7
 
@@ -48,5 +49,6 @@ export default [
48
49
  hostStyle('el-input-field'),
49
50
  formControlStyle('el-input-field'),
50
51
  sizeStyle('el-input-field'),
52
+ inputControlStyle('el-input-field'),
51
53
  style,
52
54
  ].join('\n');
@@ -12,6 +12,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.5.0] - 2026-11-27
16
+
17
+ ### Added
18
+
19
+ - `--el-list-gap` sets the gap between the start, the texts, the end and the control of a row. The rows read it, so it can be set on the list or for the page. ([#206](https://github.com/webtides/element-library/issues/206))
20
+
15
21
  ## [0.4.0] - 2026-11-27
16
22
 
17
23
  ### Added
@@ -19,6 +19,8 @@ import style from './list.style.js';
19
19
  * @cssproperty --el-list-padding-inline - The padding of a row at its start and its end. Unset, it
20
20
  * is `--el-space-4`, and `1rem` without a theme. Read by the rows, so it can be set on the list
21
21
  * or for the page.
22
+ * @cssproperty --el-list-gap - The gap between the start, the texts, the end and the control of a
23
+ * row. Unset, it is `--el-space-3`, and `0.75rem` without a theme. Read by the rows as well.
22
24
  *
23
25
  * @property {string} label - The name of the list for assistive technology. Unset, the list has
24
26
  * none.
@@ -71,6 +71,7 @@ _None._
71
71
  | Name | Default | Description |
72
72
  | --- | --- | --- |
73
73
  | `--el-list-padding-inline` | `--el-space-4` | The padding of a row at its start and its end. Read by the rows, so it can be set on the list or for the page. Without a theme it is `1rem`. |
74
+ | `--el-list-gap` | `--el-space-3` | The gap between the start, the texts, the end and the control of a row. Read by the rows as well. Without a theme it is `0.75rem`. See [the gaps of a row](../list-item/list-item.readme.md#the-gaps-of-a-row). |
74
75
 
75
76
  ## Where the texts begin
76
77
 
@@ -12,6 +12,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.5.0] - 2026-11-27
16
+
17
+ ### Added
18
+
19
+ - `--el-list-gap` sets the gap between the start, the texts, the end and the control of a row, on the list, on a row, or for the page. Unset, it is `--el-space-3` as before. ([#206](https://github.com/webtides/element-library/issues/206))
20
+
21
+ ### Changed
22
+
23
+ - A page that kept the end from shrinking itself (`el-list-item::part(end) { flex-shrink: 0 }`) does not need that rule any more. ([#207](https://github.com/webtides/element-library/issues/207))
24
+ - A page that gave the gap back itself, with a margin on what it slots into `start`, `end` and `action`, takes those rules out: a margin of the page adds to the gap now. ([#206](https://github.com/webtides/element-library/issues/206))
25
+
26
+ ### Fixed
27
+
28
+ - What is in `end` keeps its width beside a title or a description that is longer than the row. It shrank together with the texts, down to next to nothing: on a phone a date broke after every character and stood as a column of ten lines, and an icon shrank to a sliver, or left its place and was drawn in the padding of the row where the page kept it from shrinking. It takes the width it has now, up to half of the row, and breaks after that, as the readme said. The ends of all rows of a list end on one line. ([#207](https://github.com/webtides/element-library/issues/207))
29
+ - The gap beside what is in `start`, `end` and `action` holds on a page whose stylesheet takes the margin off every element (`* { margin: 0 }`, the reset of Tailwind CSS v4). The row gave the gap to what the page slots in, as a margin (`::slotted`), and a rule of the page wins over such a rule, whatever its specificity and its cascade layer: the icon touched the title. The gap is one of the parts of the row now, and the row takes nothing from the margin, the padding or the border of what is slotted. A row without a `start` has no gap there, and a list without one in any row has no first column, as before. ([#206](https://github.com/webtides/element-library/issues/206))
30
+
15
31
  ## [0.4.0] - 2026-11-27
16
32
 
17
33
  ### Added
@@ -33,6 +33,8 @@ import style from './list-item.style.js';
33
33
  *
34
34
  * @cssproperty --el-list-padding-inline - The padding of the row at its start and its end. Unset,
35
35
  * it is `--el-space-4`, and `1rem` without a theme.
36
+ * @cssproperty --el-list-gap - The gap between the start, the texts, the end and the control of
37
+ * the row. Unset, it is `--el-space-3`, and `0.75rem` without a theme.
36
38
  *
37
39
  * @property {string} href - The address the row leads to. Unset, the row is no link.
38
40
  * @property {string} target - Where to open the address (only with `href`).
@@ -80,6 +80,7 @@ _None._
80
80
  | Name | Default | Description |
81
81
  | --- | --- | --- |
82
82
  | `--el-list-padding-inline` | `--el-space-4` | The padding of the row at its start and its end. Set on the list, or for the page. Without a theme it is `1rem`. |
83
+ | `--el-list-gap` | `--el-space-3` | The gap between the start, the texts, the end and the control of the row. Set on the list, on a row, or for the page. Without a theme it is `0.75rem`. |
83
84
 
84
85
  ## A row that is a link
85
86
 
@@ -98,6 +99,21 @@ Both stand at the end of the row, `end` first.
98
99
 
99
100
  A control belongs into `action`. In `end` it would lie under the link of the row, and a click on it would follow the link. In a row without `href` the two only differ in their order and their colour.
100
101
 
102
+ ## The gaps of a row
103
+
104
+ Between what is in `start` and the texts is a gap, and one in front of what is in `end` and in `action`: `--el-space-3`, `0.75rem` without a theme. A part that nothing is slotted into has no gap and no width.
105
+
106
+ - **The gap belongs to the row**, not to what the page slots into it. The row takes nothing from the margin, the padding or the border of those elements, so a reset of the page that takes them off every element (`* { margin: 0 }`) changes nothing.
107
+ - **`--el-list-gap` sets it**, on the list, on a row, or for the page:
108
+
109
+ ```css
110
+ el-list {
111
+ --el-list-gap: 1rem;
112
+ }
113
+ ```
114
+
115
+ - **A margin of the page** on an element in `start`, `end` or `action` is not the gap: it adds to it.
116
+
101
117
  ## The current row
102
118
 
103
119
  `current` marks the row of the page the user is on, or the row that is chosen: the message that is open beside the list. A row with `href` gets `aria-current="page"` on its link, a row without gets `aria-current="true"`.
@@ -110,7 +126,9 @@ It is told apart by a tint of the text colour, by a bar at its start in the acce
110
126
 
111
127
  ## Long texts
112
128
 
113
- A title that is longer than the row breaks into more lines, and so does the line under it. A text without a space (an address, a word a user typed) breaks inside of the word: a row is never wider than its list. What is in `end` takes half of the row at most and breaks after that.
129
+ A title that is longer than the row breaks into more lines, and so does the line under it. A text without a space (an address, a word a user typed) breaks inside of the word: a row is never wider than its list.
130
+
131
+ What is in `end` keeps its width beside a long title: a date stays on one line, and an icon keeps its size and its place. So the ends of all rows of a list end on one line. It takes half of the row at most, and breaks after that.
114
132
 
115
133
  `truncate="true"` cuts the title and the line under it after one line, with an ellipsis. What is cut is not shown anywhere else; use it where the row leads to the whole text.
116
134
 
@@ -20,7 +20,7 @@ const style = css`
20
20
  one is in no grid of this list. */
21
21
  --_el-list-columns: initial;
22
22
  --_el-list-item-padding-inline: var(--el-list-padding-inline, var(--el-space-4, 1rem));
23
- --_el-list-item-gap: var(--el-space-3, 0.75rem);
23
+ --_el-list-item-gap: var(--el-list-gap, var(--el-space-3, 0.75rem));
24
24
 
25
25
  display: grid;
26
26
  grid-column: 1 / -1;
@@ -50,16 +50,30 @@ const style = css`
50
50
 
51
51
  /* ── Start ────────────────────────────────────────────────────────────── */
52
52
 
53
+ /*
54
+ * The gaps of a row are the gaps of its parts, not a margin of what the page slots into them:
55
+ * a rule of the page wins over a ::slotted rule, and a reset that takes the margin off every
56
+ * element would take the gaps with it.
57
+ *
58
+ * A part with a gap ends, or begins, with an empty box of its own. A gap is between two boxes:
59
+ * with something slotted there is one between it and that box, and with nothing slotted the box
60
+ * is alone, and the part has no width. So a row without a start has no gap at its start, and a
61
+ * list without a start in any row has no first column.
62
+ */
53
63
  .start {
54
64
  display: flex;
55
65
  align-items: center;
66
+ column-gap: var(--_el-list-item-gap);
67
+ }
68
+
69
+ .start::after,
70
+ .end::before,
71
+ .action::before {
72
+ content: '';
56
73
  }
57
74
 
58
- /* The gap to the texts comes with what is slotted, so a row without a start has none, and a
59
- list without a start in any row has no first column. A margin of the page wins over it. */
60
75
  ::slotted([slot='start']) {
61
76
  flex: none;
62
- margin-inline-end: var(--_el-list-item-gap);
63
77
  }
64
78
 
65
79
  /* ── Mark ─────────────────────────────────────────────────────────────── */
@@ -135,11 +149,13 @@ const style = css`
135
149
  /* ── End ──────────────────────────────────────────────────────────────── */
136
150
 
137
151
  /* A value, a count, a chevron: it takes the width it has, up to half of the row, and breaks
138
- after that. */
152
+ after that. It does not shrink with the texts: beside a long title a date would break after
153
+ every character, and an icon would leave its place. */
139
154
  .end {
140
155
  display: flex;
141
- flex: 0 1 auto;
156
+ flex: none;
142
157
  align-items: center;
158
+ column-gap: var(--_el-list-item-gap);
143
159
  min-width: 0;
144
160
  max-width: 50%;
145
161
  color: var(--el-color-fg-muted, inherit);
@@ -152,16 +168,12 @@ const style = css`
152
168
  display: flex;
153
169
  flex: none;
154
170
  align-items: center;
171
+ column-gap: var(--_el-list-item-gap);
155
172
  /* On top of the link of the row: a control here is a target of its own. */
156
173
  position: relative;
157
174
  z-index: 1;
158
175
  }
159
176
 
160
- ::slotted([slot='end']),
161
- ::slotted([slot='action']) {
162
- margin-inline-start: var(--_el-list-item-gap);
163
- }
164
-
165
177
  /* ── A row that is a link ─────────────────────────────────────────────── */
166
178
 
167
179
  /* The link is the title, and its target is the whole row: the box of the row, drawn by the
@@ -12,6 +12,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.5.0] - 2026-11-27
16
+
17
+ ### Changed
18
+
19
+ - A page that gave the room back itself, with a margin for an `el-divider` in a menu, takes that rule out: the margin adds to the room now. ([#206](https://github.com/webtides/element-library/issues/206))
20
+ - The panel is no part of a row of joined buttons: it stops the property that pulls a button over its neighbour there (`--_el-group-overlap`), as the ones for the corners and the line. ([#206](https://github.com/webtides/element-library/issues/206))
21
+
22
+ ### Fixed
23
+
24
+ - An `el-divider` between two entries has its room above and below on a page whose stylesheet takes the margin off every element (`* { margin: 0 }`, the reset of Tailwind CSS v4). The menu gave that room to the line as a margin (`::slotted`), and a rule of the page wins over such a rule: the line touched the entries. The menu names the room in a property that inherits now, and the line takes it in its own shadow root. ([#206](https://github.com/webtides/element-library/issues/206))
25
+ - An open menu keeps the keyboard wherever the focus is. `Escape` closes it and gives the focus back to what it was opened for, and the key does not reach the page behind; `ArrowDown` and `ArrowUp` bring the focus to its first and to its last entry; the Tab key closes it, and the focus moves on from where it is. The menu heard its keys on its panel alone: an open menu whose entries did not have the focus was left with no key, and `Escape` closed what was behind it. It hears them at the window now, for as long as it is open. ([#202](https://github.com/webtides/element-library/issues/202))
26
+ - A press on the heading of a group, on a line or on the padding of the panel leaves the focus on the entry that had it, and the arrow keys go on from there. The focus was nowhere in the page after such a press. Where no entry had the focus, the panel takes it itself: it has `tabindex="-1"`, and is no stop of the Tab key. ([#202](https://github.com/webtides/element-library/issues/202))
27
+ - A menu that is open at a point closes when what it was opened for scrolls away under it: the page, or a region around the row, also one in a shadow root the row is slotted into (the content of an `el-app-frame`). The menu stayed where it was, over another row and with the actions of the first one. The focus goes back to what the menu was opened for without scrolling to it, so the scroll goes on. A scroll inside of a long menu, and one of a region that does not move the row, leave the menu open, and a menu at an element follows the element as before. ([#204](https://github.com/webtides/element-library/issues/204))
28
+ - The button of a row closes the menu it has opened: a second press on the element the menu is open at closes it, and it stays closed, with the listener of the readme (`menu.showAt(button)` for a click) and nothing more. The press closed the menu when the pointer went down, as a press beside it, and the click of the same press opened it again: `menu-hide`, then `menu-show`, and a button that said `aria-expanded="true"` and could not collapse what it had expanded. The menu stays open now while the pointer is down on that element, and the `showAt()` that is called with the click closes it. A call with no press before it opens the menu as before. ([#203](https://github.com/webtides/element-library/issues/203))
29
+ - A menu that is opened with `showAt()` is where it was opened while its own element is out of view, below a long list for example. It was at its own element instead, off the screen: the element was placed once before it had taken its place from `showAt()`, and that placement, which had to try the other side, was done after the right one. The panel is placed once it is shown now, and one placement at a time.
30
+ - Entries that the page renders after the menu has opened, and entries whose element is defined after it, get the focus once they are there: the first one, or the last one where `ArrowUp` has opened the menu. The menu is placed again for its new size. The focus stayed where it was, and a menu at a point kept the place of an empty panel. ([#202](https://github.com/webtides/element-library/issues/202))
31
+
15
32
  ## [0.4.0] - 2026-11-27
16
33
 
17
34
  ### Added