@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
@@ -10,12 +10,20 @@ import style from './menu-item.style.js';
10
10
  * Choosing an entry is a click on it: listen for `click` on the entry, or for `menu-select` on the
11
11
  * menu, which names the entry and its `value`.
12
12
  *
13
+ * An entry can set something instead of doing something. With `type="checkbox"` it is on or off
14
+ * (`role="menuitemcheckbox"`), with `type="radio"` it is one of several of which one is chosen
15
+ * (`role="menuitemradio"`), and `checked` is its state, which it says (`aria-checked`) and shows
16
+ * with a mark in front of its text. The page sets `checked`: the entry does not change it when
17
+ * it is chosen.
18
+ *
13
19
  * @element el-menu-item
14
20
  *
15
21
  * @slot - The text of the entry.
16
22
  * @slot icon - An icon in front of the text: a decoration, the text is the name.
17
23
  *
18
24
  * @csspart base - The entry: a `<button>`, or an `<a>` with `href`.
25
+ * @csspart mark - The place of the mark of an entry with a `type`: a check, or a dot. It is
26
+ * there while the entry is not checked as well.
19
27
  * @csspart icon - The place of the icon.
20
28
  * @csspart label - The text of the entry.
21
29
  *
@@ -27,6 +35,11 @@ import style from './menu-item.style.js';
27
35
  * `'delete'`. Default `''`.
28
36
  * @property {boolean} disabled - Whether the entry cannot be chosen. The keyboard still gets to
29
37
  * it. Default `false`.
38
+ * @property {'normal'|'checkbox'|'radio'} type - What the entry is: an action or a link
39
+ * (`'normal'`), an entry that is on or off (`'checkbox'`), or one of several of which one is
40
+ * chosen (`'radio'`). Default `'normal'`.
41
+ * @property {boolean} checked - Whether an entry with the `type` `checkbox` is on, or one with
42
+ * the `type` `radio` is the chosen one. The page sets it. Default `false`.
30
43
  * @property {'neutral'|'brand'|'success'|'warning'|'danger'} variant - The variant of the entry:
31
44
  * `danger` for something that cannot be undone. Default `'neutral'`. Reflected to the `variant`
32
45
  * attribute.
@@ -48,6 +61,8 @@ export default class MenuItem extends TemplateElement {
48
61
  rel: 'noreferrer noopener',
49
62
  value: '',
50
63
  disabled: false,
64
+ type: 'normal',
65
+ checked: false,
51
66
  variant: 'neutral',
52
67
  };
53
68
  }
@@ -84,10 +99,31 @@ export default class MenuItem extends TemplateElement {
84
99
  return this.disabled === true || this.disabled === 'true' || this.disabled === '';
85
100
  }
86
101
 
102
+ /**
103
+ * Whether the entry is checked: `checked` is there as an attribute without a value, or true.
104
+ * @private
105
+ * @returns {boolean}
106
+ */
107
+ _checked() {
108
+ return this.checked === true || this.checked === 'true' || this.checked === '';
109
+ }
110
+
87
111
  template() {
88
112
  const disabled = this._disabled();
89
- const classes = classMap({ item: true, 'item--disabled': disabled });
113
+ // An entry with a type says its state, also while it is off and while it is disabled.
114
+ const checkable = this.type === 'checkbox' || this.type === 'radio';
115
+ const role = checkable ? `menuitem${this.type}` : 'menuitem';
116
+ const checked = checkable ? String(this._checked()) : null;
117
+ const classes = classMap({
118
+ item: true,
119
+ 'item--disabled': disabled,
120
+ 'item--checkbox': this.type === 'checkbox',
121
+ 'item--radio': this.type === 'radio',
122
+ });
123
+ // The mark is drawn by the stylesheet, from the state the control says. Its place is
124
+ // there for every entry with a type, so a text does not move when its entry is checked.
90
125
  const content = html`
126
+ <span part="mark" class="mark" aria-hidden="true" ?hidden="${!checkable}"></span>
91
127
  <span part="icon" class="icon" ?hidden="${!hasSlotted(this, 'icon')}"><slot name="icon"></slot></span>
92
128
  <span part="label" class="label"><slot></slot></span>
93
129
  `;
@@ -100,7 +136,8 @@ export default class MenuItem extends TemplateElement {
100
136
  <a
101
137
  part="base"
102
138
  class="${classes}"
103
- role="menuitem"
139
+ role="${role}"
140
+ aria-checked="${checked}"
104
141
  tabindex="-1"
105
142
  href="${this.href}"
106
143
  target="${this.target || null}"
@@ -115,7 +152,8 @@ export default class MenuItem extends TemplateElement {
115
152
  part="base"
116
153
  class="${classes}"
117
154
  type="button"
118
- role="menuitem"
155
+ role="${role}"
156
+ aria-checked="${checked}"
119
157
  tabindex="-1"
120
158
  aria-disabled="${disabled ? 'true' : null}"
121
159
  >
@@ -1,6 +1,6 @@
1
1
  # Menu Item
2
2
 
3
- `menu-item` is one entry of an [`el-menu`](../menu/menu.readme.md): an action, or a link with an address.
3
+ `menu-item` is one entry of an [`el-menu`](../menu/menu.readme.md): an action, or a link with an address. Or an entry that sets something: one that is on or off, or the chosen one of several.
4
4
 
5
5
  ## How to use
6
6
 
@@ -40,6 +40,8 @@ import '@webtides/element-library/menu-item/define';
40
40
  | `rel` | `string` | `'noreferrer noopener'` | `rel` attribute for the link, written when `target` is set. |
41
41
  | `value` | `string` | `''` | What the entry stands for, for the listener of `menu-select`. |
42
42
  | `disabled` | `boolean` | `false` | Whether the entry cannot be chosen. The keyboard still gets to it. |
43
+ | `type` | `string` | `'normal'` | `normal`, an action or a link; `checkbox`, an entry that is on or off; `radio`, one of several of which one is chosen. |
44
+ | `checked` | `boolean` | `false` | Whether an entry with the `type` `checkbox` is on, or one with the `type` `radio` is the chosen one. The page sets it. |
43
45
  | `variant` | `string` | `'neutral'` | `neutral`, `brand`, `success`, `warning` or `danger`: `danger` for something that cannot be undone. Reflected. |
44
46
 
45
47
  #### Methods
@@ -61,11 +63,12 @@ _None of its own._ A choice is a `click` on the entry, and `menu-select` on its
61
63
 
62
64
  #### CSS Parts
63
65
 
64
- | Name | Description |
65
- | ------- | ------------------------------------------------- |
66
- | `base` | The entry: a `<button>`, or an `<a>` with `href`. |
67
- | `icon` | The place of the icon. |
68
- | `label` | The text of the entry. |
66
+ | Name | Description |
67
+ | --- | --- |
68
+ | `base` | The entry: a `<button>`, or an `<a>` with `href`. |
69
+ | `mark` | The place of the mark of an entry with a `type`: a check, or a dot. It is there while the entry is not checked as well. |
70
+ | `icon` | The place of the icon. |
71
+ | `label` | The text of the entry. |
69
72
 
70
73
  #### CSS Custom Properties
71
74
 
@@ -79,6 +82,41 @@ Without `href` the entry is a button, and choosing it is a click the page acts o
79
82
 
80
83
  `disabled="true"` takes the entry out of what can be chosen. It says so to assistive technology (`aria-disabled="true"`), fires no click, and a link has no address while it is disabled. The arrow keys still stop at it: a screen reader user learns that the action is there and not available now.
81
84
 
85
+ ## An entry that is checked
86
+
87
+ An entry can set something instead of doing something: the view a list is shown in, whether the archived rows are in it. `type` says which kind it is, and `checked` its state.
88
+
89
+ ```html
90
+ <el-menu>
91
+ <el-button slot="trigger">View</el-button>
92
+ <el-menu-group label="Layout">
93
+ <el-menu-item type="radio" value="list" checked="true">List</el-menu-item>
94
+ <el-menu-item type="radio" value="grid">Grid</el-menu-item>
95
+ </el-menu-group>
96
+ <el-menu-group>
97
+ <el-menu-item type="checkbox" value="archived">Show archived</el-menu-item>
98
+ </el-menu-group>
99
+ </el-menu>
100
+ ```
101
+
102
+ - **`type="checkbox"`** is an entry that is on or off (`role="menuitemcheckbox"`). **`type="radio"`** is one of several of which one is chosen (`role="menuitemradio"`): put the ones that belong together into an [`el-menu-group`](../menu-group/menu-group.readme.md).
103
+ - **`checked`** is the state. The entry says it to assistive technology (`aria-checked`), also while it is off and while it is disabled.
104
+ - **The page sets the state.** The entry does not change `checked` when it is chosen: the menu can be the answer of a server, and the server says what is chosen. Set it in the listener of `menu-select`, for the entry and, among radios, for the others:
105
+
106
+ ```js
107
+ menu.addEventListener('menu-select', ({ detail: { item } }) => {
108
+ if (item.type === 'radio') {
109
+ for (const other of item.parentElement.querySelectorAll('el-menu-item')) other.checked = other === item;
110
+ } else if (item.type === 'checkbox') {
111
+ item.checked = !item.checked;
112
+ }
113
+ });
114
+ ```
115
+
116
+ - **The mark** is in front of the text, and in front of the icon: a check for an entry that is on, a dot for the chosen one. Its place is there while the entry is not checked as well, so the text does not move when the state changes, and the texts of the entries of a group begin on one line. An entry without a `type` has no such place: in a menu that has both kinds, keep the checked ones in a group of their own.
117
+ - **Where the user forces colours** the mark has the colour of the text: the check is text, the dot is drawn with a border.
118
+ - **Choosing** such an entry is the same as for every entry: a click, `menu-select`, and the menu closes.
119
+
82
120
  ## A danger
83
121
 
84
122
  `variant="danger"` shows the entry in the colour of a danger, for an action that cannot be undone. The colour alone does not say so to everyone: name the action for what it does ("Delete"), and ask before it is done where it matters.
@@ -89,6 +127,6 @@ What is in the `icon` slot stands in front of the text. It is a decoration: give
89
127
 
90
128
  ## Accessibility
91
129
 
92
- - A menu item (`role="menuitem"`), which is no stop of the Tab key: its menu moves the focus to it.
130
+ - A menu item (`role="menuitem"`), which is no stop of the Tab key: its menu moves the focus to it. With a `type` it is a `menuitemcheckbox` or a `menuitemradio`, which says its state (`aria-checked`). The mark is hidden from assistive technology: the state is said, not drawn.
93
131
  - The focus of the keyboard shows as a ring inside of the entry and a tint, the pointer as a tint.
94
132
  - On a touch screen the entry is at least `--el-touch-target` high. Without the token nothing changes.
@@ -38,6 +38,36 @@ const style = css`
38
38
  justify-content: center;
39
39
  }
40
40
 
41
+ /* The place of the mark of an entry that is on or off, or one of several. It is as wide
42
+ while the entry is not checked, so the text of an entry does not move when it is, and the
43
+ texts of the entries of a group begin on one line. */
44
+ .mark {
45
+ display: inline-grid;
46
+ flex: none;
47
+ place-items: center;
48
+ inline-size: 1em;
49
+ block-size: 1em;
50
+ line-height: 1;
51
+ }
52
+
53
+ .mark[hidden] {
54
+ display: none;
55
+ }
56
+
57
+ /* On: a check, the sign in the box of a checkbox field. It is text, which shows where the
58
+ user forces colours. */
59
+ .item--checkbox[aria-checked='true'] .mark::before {
60
+ content: '\2713';
61
+ }
62
+
63
+ /* The chosen one of several: a dot. It is drawn with a border and has no size of its own: a
64
+ background is taken away where the user forces colours, a border stays. */
65
+ .item--radio[aria-checked='true'] .mark::before {
66
+ content: '';
67
+ border: 0.2em solid currentColor;
68
+ border-radius: 50%;
69
+ }
70
+
41
71
  /* One line as a rule. A text that is longer than the menu is wide wraps: an action that is
42
72
  cut off cannot be read. */
43
73
  .label {
@@ -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
+ - Takes content of the page into its control, an element with `slot="start"` or `slot="end"`, and has the button that empties it (`clearable`, `clear-label`), as `el-input-field`, which it extends. ([#168](https://github.com/webtides/element-library/issues/168))
20
+
15
21
  ## [0.3.0] - 2026-11-17
16
22
 
17
23
  ### Added
@@ -103,6 +103,14 @@ The label, the help message, the control and the error message stack in a column
103
103
 
104
104
  On a touch screen (`@media (any-pointer: coarse)`) the control and the clear cross are at least `--el-touch-target` high. Without that token, and on a fine pointer, the sizes stay as they are.
105
105
 
106
+ ## Content in the control
107
+
108
+ As [`el-input-field`](../input-field/input-field.readme.md#content-in-the-control), which this field extends, it takes an element of the page with `slot="start"` or `slot="end"` into its control, and `clearable="true"` adds a button that empties it (`clear-label` is its name).
109
+
110
+ ```html
111
+ <el-otp-field name="code" label="Code"><span slot="start">G-</span></el-otp-field>
112
+ ```
113
+
106
114
  ## Accessibility
107
115
 
108
116
  - One native text input, named by the label (`<label for>`). A screen reader reads the code as one value, and the user moves in it as in any text.
@@ -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,6 +49,10 @@ const style = css`
48
49
  }
49
50
  `;
50
51
 
51
- export default [hostStyle('el-otp-field'), formControlStyle('el-otp-field'), sizeStyle('el-otp-field'), style].join(
52
- '\n',
53
- );
52
+ export default [
53
+ hostStyle('el-otp-field'),
54
+ formControlStyle('el-otp-field'),
55
+ sizeStyle('el-otp-field'),
56
+ inputControlStyle('el-otp-field'),
57
+ style,
58
+ ].join('\n');
@@ -12,6 +12,13 @@ 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
+ - Takes content of the page into its control, an element with `slot="start"` or `slot="end"`, and has the button that empties it (`clearable`, `clear-label`), as `el-input-field`, which it extends. Its own button, the one that shows the password, stays beside the control. ([#168](https://github.com/webtides/element-library/issues/168))
20
+ - `maxlength` and `minlength` are passed on to the input, as in `el-input-field`: a password that is typed shorter than `minlength` makes the field invalid, with its `error-message`. ([#190](https://github.com/webtides/element-library/issues/190))
21
+
15
22
  ## [0.3.0] - 2026-11-17
16
23
 
17
24
  ### Added
@@ -29,7 +29,7 @@ import '@webtides/element-library/password-field/define';
29
29
 
30
30
  #### Properties/Attributes
31
31
 
32
- Inherits all of `input-field`'s properties (`name`, `value`, `size`, `placeholder`, `required`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `pattern`, `valid`, `touched`, and the keyboard and autofill hints `autocomplete`, `inputmode`, `enterkeyhint`, `autocapitalize`, `autocorrect`, `spellcheck`) and adds:
32
+ Inherits all of `input-field`'s properties (`name`, `value`, `size`, `placeholder`, `required`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `pattern`, `maxlength`, `minlength`, `valid`, `touched`, and the keyboard and autofill hints `autocomplete`, `inputmode`, `enterkeyhint`, `autocapitalize`, `autocorrect`, `spellcheck`) and adds:
33
33
 
34
34
  | Name | Type | Default | Description |
35
35
  | --- | --- | --- | --- |
@@ -62,6 +62,16 @@ The label, the help message, the control and the error message stack in a column
62
62
 
63
63
  On a touch screen (`@media (any-pointer: coarse)`) the reveal button is at least `--el-touch-target` wide and high, the input at least that high, and the clear cross of an invalid field at least that wide and high. Without that token, and on a fine pointer, the sizes stay as they are.
64
64
 
65
+ ## Content in the control
66
+
67
+ As [`el-input-field`](../input-field/input-field.readme.md#content-in-the-control), which this field extends, it takes an element of the page with `slot="start"` or `slot="end"` into its control, and `clearable="true"` adds a button that empties it (`clear-label` is its name).
68
+
69
+ ```html
70
+ <el-password-field name="password" label="Password" minlength="12"><span slot="end">min. 12</span></el-password-field>
71
+ ```
72
+
73
+ The button that shows the password is not part of the control: it stands after it, as it does without content.
74
+
65
75
  ## Accessibility
66
76
 
67
77
  - The reveal button is a real `<button>` with an `aria-label` that flips between "Show password" and "Hide password", and an `aria-pressed` state, so its purpose and state are announced. Set `show-label` and `hide-label` to translate the two labels.
@@ -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
 
@@ -81,5 +82,6 @@ export default [
81
82
  hostStyle('el-password-field'),
82
83
  formControlStyle('el-password-field'),
83
84
  sizeStyle('el-password-field'),
85
+ inputControlStyle('el-password-field'),
84
86
  style,
85
87
  ].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
+ ### Changed
18
+
19
+ - 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))
20
+
15
21
  ## [0.3.0] - 2026-11-17
16
22
 
17
23
  ### Added
@@ -35,6 +35,7 @@ const style = css`
35
35
  --_el-group-radius-start: initial;
36
36
  --_el-group-radius-end: initial;
37
37
  --_el-group-divider: initial;
38
+ --_el-group-overlap: initial;
38
39
  }
39
40
  `;
40
41
 
@@ -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
+ - An option can show something in front of its label: `color` is a colour that is drawn as a dot, `icon` the address of an SVG symbol, as an option of `el-segmented-field` has it. Things a user knows by their colour, tags or calendars, are found by it where they are chosen. Both are decorations, hidden from assistive technology: the label stays the name of the option. They are part of the option, so they work for options as an attribute and as a property, and are in server-rendered markup. The dot keeps its colour where the user forces colours. ([#198](https://github.com/webtides/element-library/issues/198))
20
+
15
21
  ## [0.3.0] - 2026-11-17
16
22
 
17
23
  ### Changed
@@ -1,6 +1,7 @@
1
1
  import { html, defineElement } from '@webtides/element-js';
2
2
  import FormField from '../form-field/form-field.js';
3
3
  import { focusLeft } from '../../utils/focus.js';
4
+ import { optionStartTemplate } from '../../utils/options.js';
4
5
  import style from './radio-field.style.js';
5
6
 
6
7
  /**
@@ -18,9 +19,12 @@ import style from './radio-field.style.js';
18
19
  * because of it. Inherits `valid` and `invalid` from `FormField`.
19
20
  *
20
21
  * @property {string | null} value - The selected option's value.
21
- * @property {Array<string | { value: string, label?: string, disabled?: boolean }>} options -
22
+ * @property {Array<string | { value: string, label?: string, disabled?: boolean, color?: string, icon?: string }>} options -
22
23
  * Options to render. Accepts plain strings (`['Yes', 'No']`) or option objects
23
- * (`[{ value, label, disabled? }]`). Strings are used as both value and label.
24
+ * (`[{ value, label, disabled? }]`). Strings are used as both value and label. An object can
25
+ * name a `color`, which is drawn as a dot in front of the label, and an `icon`, the address of
26
+ * an SVG symbol (`'#tag'`, `'/icons.svg#tag'`), which is drawn there as well. Both are
27
+ * decorations: the label stays the name of the option.
24
28
  */
25
29
  export default class RadioField extends FormField {
26
30
  constructor(options) {
@@ -151,6 +155,7 @@ export default class RadioField extends FormField {
151
155
  aria-describedby="${this._describedBy()}"
152
156
  />
153
157
  <span class="radio-indicator" aria-hidden="true"></span>
158
+ ${optionStartTemplate(option)}
154
159
  <span class="option-label">${label}</span>
155
160
  </label>
156
161
  `;
@@ -36,6 +36,28 @@ field.options = [
36
36
  ];
37
37
  ```
38
38
 
39
+ #### A colour or an icon in front of the label
40
+
41
+ Tags with a colour, calendars, categories with an icon: things a user knows by their colour are found by it where they are chosen. An option can name a `color`, which is drawn as a dot in front of its label, and an `icon`, the address of an SVG symbol, which is drawn there as well:
42
+
43
+ ```html
44
+ <svg width="0" height="0" style="position:absolute" aria-hidden="true">
45
+ <symbol id="icon-archive" viewBox="0 0 24 24">…</symbol>
46
+ </svg>
47
+
48
+ <el-radio-field
49
+ name="tags"
50
+ label="Calendar"
51
+ options='[{"value":"work","label":"Work","color":"#c81e1e"},{"value":"home","label":"Home","color":"#1e5fc8"},{"value":"archive","label":"Archive","icon":"#icon-archive"}]'
52
+ ></el-radio-field>
53
+ ```
54
+
55
+ - **`color`** is any colour of CSS. The dot has it where the user forces colours as well: it is the colour of a thing of the page, as the colour of a picture is.
56
+ - **`icon`** is the address of an SVG symbol: one of the page (`#icon-archive`) or of a file (`/icons.svg#archive`), as an option of [`el-segmented-field`](../segmented-field/segmented-field.readme.md) has it. The icon has the colour of the text and is 1.25em wide and high. An option with both shows the dot first.
57
+ - **Both are decorations.** They are hidden from assistive technology, and the label stays the name of the option: say in the label what the colour says to the eye.
58
+ - **As an attribute and as a property**, and in server-rendered markup: they are part of the option, as its label is.
59
+ - An option that names neither has nothing in front of its label, and a click on the dot or on the icon checks the option, as a click on its label does.
60
+
39
61
  ## API
40
62
 
41
63
  #### Properties/Attributes
@@ -45,7 +67,7 @@ Inherits all of `form-field`'s properties (`name`, `value`, `required`, `disable
45
67
  | Name | Type | Default | Description |
46
68
  | --- | --- | --- | --- |
47
69
  | `value` | `string \| null` | `null` | The selected option's value. |
48
- | `options` | `Array<string \| { value: string, label?: string, disabled?: boolean }>` | `[]` | Options to render. Strings are used as both value and label; objects allow a separate label/disabled. |
70
+ | `options` | `Array<string \| { value: string, label?: string, disabled?: boolean, color?: string, icon?: string }>` | `[]` | Options to render. Strings are used as both value and label; objects allow a separate label/disabled, and a `color` or an `icon` in front of the label. |
49
71
 
50
72
  #### Events
51
73
 
@@ -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
+ - `maxlength` and `minlength` are passed on to the native `<textarea>`, in server-rendered markup as well, and one that is not set is not rendered. The control takes no more characters than `maxlength` while the user types, and a typed text that is shorter than `minlength` makes the field invalid the way `required` does, with its `error-message`. Set on the element they did nothing before. ([#190](https://github.com/webtides/element-library/issues/190))
20
+
15
21
  ## [0.3.0] - 2026-11-17
16
22
 
17
23
  ### Added
@@ -1,6 +1,10 @@
1
1
  import { html, defineElement, classMap, 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 './textarea-field.style.js';
5
9
 
6
10
  /**
@@ -16,6 +20,11 @@ import style from './textarea-field.style.js';
16
20
  * @property {string} placeholder - Placeholder text shown while the textarea is empty.
17
21
  * @property {number} rows - Number of visible text rows. Forwarded to the underlying
18
22
  * `<textarea>`'s `rows` attribute.
23
+ * @property {number | null} maxlength - Passed on to the control as `maxlength`: the browser takes
24
+ * no more characters than this while the user types. `null` (the default) leaves the attribute
25
+ * out.
26
+ * @property {number | null} minlength - Passed on as `minlength`: a text the user has typed that is
27
+ * shorter makes the field invalid. `null` (the default) leaves the attribute out.
19
28
  * @property {string | null} autocomplete - Passed on to the control as its `autocomplete`
20
29
  * attribute (e.g. `'email'`, `'current-password'`, `'one-time-code'`). `null` (the default)
21
30
  * leaves the attribute out. The same holds for the five properties below.
@@ -39,6 +48,8 @@ export default class TextareaField extends FormField {
39
48
  ...super.properties(),
40
49
  placeholder: '',
41
50
  rows: 3,
51
+ maxlength: null,
52
+ minlength: null,
42
53
  autocomplete: null,
43
54
  inputmode: null,
44
55
  enterkeyhint: null,
@@ -90,6 +101,8 @@ export default class TextareaField extends FormField {
90
101
  placeholder="${this.placeholder}"
91
102
  ?required="${this.required}"
92
103
  ?disabled="${this.disabled}"
104
+ maxlength="${lengthAttribute(this.maxlength)}"
105
+ minlength="${lengthAttribute(this.minlength)}"
93
106
  ${spreadAttributes(textEntryAttributes(this))}
94
107
  aria-describedby="${this._describedBy()}"
95
108
  aria-invalid="${this.valid ? 'false' : 'true'}"
@@ -41,6 +41,8 @@ import '@webtides/element-library/textarea-field/define';
41
41
  | `value` | `string` | `null` | The current text content of the textarea field |
42
42
  | `placeholder` | `string` | `''` | Placeholder text displayed when the textarea is empty |
43
43
  | `rows` | `number` | `3` | The number of visible text rows in the textarea |
44
+ | `maxlength` | `number` | `null` | Passed on to the control as `maxlength`: the browser takes no more characters than this while the user types |
45
+ | `minlength` | `number` | `null` | Passed on as `minlength`: a text the user has typed that is shorter makes the field invalid |
44
46
  | `autocomplete` | `string` | `null` | Passed on to the control as `autocomplete` (e.g. `email`, `current-password`, `one-time-code`) |
45
47
  | `inputmode` | `string` | `null` | Passed on as `inputmode`: the on-screen keyboard to show (e.g. `numeric`, `email`) |
46
48
  | `enterkeyhint` | `string` | `null` | Passed on as `enterkeyhint`: the label of the enter key on an on-screen keyboard (e.g. `next`, `send`) |
@@ -118,6 +120,26 @@ The value is rendered as the content of the `<textarea>`. A server-rendered fiel
118
120
 
119
121
  A line break at the very start of the value is missing until the element has started: the HTML parser drops a line break that directly follows `<textarea>`.
120
122
 
123
+ ## The length of the text
124
+
125
+ `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:
126
+
127
+ ```html
128
+ <el-textarea-field
129
+ name="notes"
130
+ label="Notes"
131
+ maxlength="2000"
132
+ minlength="10"
133
+ error-message="At least 10 characters"
134
+ ></el-textarea-field>
135
+ ```
136
+
137
+ - **`maxlength`**: the control takes no more characters while the user types or pastes. Nothing is invalid for it: the text is never longer.
138
+ - **`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.
139
+ - **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.
140
+ - **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.
141
+ - **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.
142
+
121
143
  ## Validation
122
144
 
123
145
  The component provides real-time validation feedback:
@@ -125,7 +147,7 @@ The component provides real-time validation feedback:
125
147
  - Validation state updates on focus, on blur and with every change of the text
126
148
  - Visual indicators (checkmark for valid, cross for invalid) appear beside the textarea after the field is touched
127
149
  - Error messages only display when field is touched and invalid
128
- - Supports HTML5 validation attributes (required, disabled)
150
+ - Supports HTML5 validation attributes (required, minlength, disabled)
129
151
  - Clicking the invalid indicator (×) clears the textarea content
130
152
  - Tab key (keyCode 9) doesn't trigger change events to avoid false validation during navigation (inherited from `form-field`)
131
153
 
@@ -82,6 +82,32 @@ export default function choiceGroupStyle(host = ':host') {
82
82
  opacity: 0.5;
83
83
  }
84
84
 
85
+ /* What an option shows in front of its label: a colour, an icon. */
86
+ ${field} .option-start {
87
+ display: inline-flex;
88
+ flex: none;
89
+ align-items: center;
90
+ gap: var(--el-space-1, 0.25em);
91
+ }
92
+
93
+ /* The colour an option names, as a dot. It is the colour of a thing of the page, a tag or
94
+ a calendar, and what a user finds the option by: it stays where the user forces
95
+ colours, as the colour of a picture does. */
96
+ ${field} .option-color {
97
+ inline-size: 0.75em;
98
+ block-size: 0.75em;
99
+ border-radius: 50%;
100
+ background: var(--_el-option-color);
101
+ forced-color-adjust: none;
102
+ }
103
+
104
+ /* An icon has the colour of the text, as the icon of a segment has. */
105
+ ${field} .option-icon {
106
+ inline-size: 1.25em;
107
+ block-size: 1.25em;
108
+ fill: currentColor;
109
+ }
110
+
85
111
  /* Touch screens: the label of an option is its hit area and at least --el-touch-target
86
112
  in both directions. Without the token the sizes stay as they are. */
87
113
  @media (any-pointer: coarse) {