@redvars/peacock 3.10.1 → 3.11.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 (276) hide show
  1. package/dist/BaseInput-CV0pZgSb.js +58 -0
  2. package/dist/BaseInput-CV0pZgSb.js.map +1 -0
  3. package/dist/app-bar.js +16 -16
  4. package/dist/assets/styles.css +1 -1
  5. package/dist/assets/styles.css.map +1 -1
  6. package/dist/assets/theme.d.ts +66 -0
  7. package/dist/assets/theme.js +134 -0
  8. package/dist/assets/tokens.css +1 -1
  9. package/dist/assets/tokens.css.map +1 -1
  10. package/dist/base-progress-CLZTRveO.js +33 -0
  11. package/dist/base-progress-CLZTRveO.js.map +1 -0
  12. package/dist/bottom-sheet.js +1 -1
  13. package/dist/button-group.js +9 -7
  14. package/dist/button-group.js.map +1 -1
  15. package/dist/button.js +225 -187
  16. package/dist/button.js.map +1 -1
  17. package/dist/{chart-bar-CapLbc2e.js → chart-bar-D5dGFJfK.js} +2 -2
  18. package/dist/{chart-bar-CapLbc2e.js.map → chart-bar-D5dGFJfK.js.map} +1 -1
  19. package/dist/chart-bar.js +1 -1
  20. package/dist/chart-stacked-bar.js +1 -1
  21. package/dist/checkbox.js +78 -53
  22. package/dist/checkbox.js.map +1 -1
  23. package/dist/chip-set.js +52 -0
  24. package/dist/chip-set.js.map +1 -0
  25. package/dist/chip.js +8 -6
  26. package/dist/chip.js.map +1 -1
  27. package/dist/circular-progress.js +177 -0
  28. package/dist/circular-progress.js.map +1 -0
  29. package/dist/code-editor.js +129 -72
  30. package/dist/code-editor.js.map +1 -1
  31. package/dist/code-highlighter.js +2 -38
  32. package/dist/code-highlighter.js.map +1 -1
  33. package/dist/color-field.js +309 -0
  34. package/dist/color-field.js.map +1 -0
  35. package/dist/color-picker.js +26 -15
  36. package/dist/color-picker.js.map +1 -1
  37. package/dist/copy-to-clipboard-upGx-Ueo.js +39 -0
  38. package/dist/copy-to-clipboard-upGx-Ueo.js.map +1 -0
  39. package/dist/custom-elements-jsdocs.json +1044 -382
  40. package/dist/custom-elements.json +8615 -4726
  41. package/dist/date-picker.js +241 -0
  42. package/dist/date-picker.js.map +1 -0
  43. package/dist/{element-internals-2CMts_0M.js → delegate-py-Ets8N.js} +2 -43
  44. package/dist/delegate-py-Ets8N.js.map +1 -0
  45. package/dist/element-internals-QME0yEz4.js +43 -0
  46. package/dist/element-internals-QME0yEz4.js.map +1 -0
  47. package/dist/fab.js +51 -49
  48. package/dist/fab.js.map +1 -1
  49. package/dist/field.js +25 -0
  50. package/dist/field.js.map +1 -1
  51. package/dist/flow.js +5 -5
  52. package/dist/form-associated-Bhwwr6dT.js +162 -0
  53. package/dist/form-associated-Bhwwr6dT.js.map +1 -0
  54. package/dist/{form-associated-BXADnjOB.js → form-submitter-DPI4L6gj.js} +3 -159
  55. package/dist/form-submitter-DPI4L6gj.js.map +1 -0
  56. package/dist/html-editor.js +3 -1
  57. package/dist/html-editor.js.map +1 -1
  58. package/dist/icon-button.js +195 -156
  59. package/dist/icon-button.js.map +1 -1
  60. package/dist/image.js +2 -2
  61. package/dist/index.js +32 -8
  62. package/dist/index.js.map +1 -1
  63. package/dist/input.js +259 -0
  64. package/dist/input.js.map +1 -0
  65. package/dist/item.js +2 -1
  66. package/dist/item.js.map +1 -1
  67. package/dist/linear-progress.js +192 -0
  68. package/dist/linear-progress.js.map +1 -0
  69. package/dist/{list-AdO-PUq_.js → list-item.js} +12 -222
  70. package/dist/list-item.js.map +1 -0
  71. package/dist/list.js +225 -6
  72. package/dist/list.js.map +1 -1
  73. package/dist/loader-full.js +31 -8
  74. package/dist/loader-full.js.map +1 -1
  75. package/dist/loader.js +52 -12
  76. package/dist/loader.js.map +1 -1
  77. package/dist/markdown-editor.js +5 -3
  78. package/dist/markdown-editor.js.map +1 -1
  79. package/dist/menu-item.js +30 -30
  80. package/dist/navigation-bar-item.js +41 -0
  81. package/dist/navigation-bar-item.js.map +1 -0
  82. package/dist/navigation-bar.js +128 -0
  83. package/dist/navigation-bar.js.map +1 -0
  84. package/dist/navigation-drawer-item.js +236 -0
  85. package/dist/navigation-drawer-item.js.map +1 -0
  86. package/dist/navigation-drawer.js +293 -0
  87. package/dist/navigation-drawer.js.map +1 -0
  88. package/dist/navigation-rail.js +1 -1
  89. package/dist/number-field.js +280 -0
  90. package/dist/number-field.js.map +1 -0
  91. package/dist/pagination.js +1 -1
  92. package/dist/radio-group.js +209 -0
  93. package/dist/radio-group.js.map +1 -0
  94. package/dist/radio.js +47 -37
  95. package/dist/radio.js.map +1 -1
  96. package/dist/segmented-button-group.js +12 -0
  97. package/dist/segmented-button-group.js.map +1 -1
  98. package/dist/segmented-button.js +10 -6
  99. package/dist/segmented-button.js.map +1 -1
  100. package/dist/select.js +653 -0
  101. package/dist/select.js.map +1 -0
  102. package/dist/side-sheet.js +1 -1
  103. package/dist/sidebar-menu-item.js +273 -0
  104. package/dist/sidebar-menu-item.js.map +1 -0
  105. package/dist/sidebar-menu.js +193 -0
  106. package/dist/sidebar-menu.js.map +1 -0
  107. package/dist/sidebar-sub-menu.js +301 -0
  108. package/dist/sidebar-sub-menu.js.map +1 -0
  109. package/dist/slider.js +76 -24
  110. package/dist/slider.js.map +1 -1
  111. package/dist/snackbar.js +3 -3
  112. package/dist/snackbar.js.map +1 -1
  113. package/dist/split-button.js +2 -2
  114. package/dist/src/__internal/utils/size.d.ts +9 -0
  115. package/dist/src/button/ButtonTypes.d.ts +1 -1
  116. package/dist/src/checkbox/checkbox.d.ts +28 -22
  117. package/dist/src/chip/chip/chip.d.ts +3 -0
  118. package/dist/src/chip/tag/tag.d.ts +5 -1
  119. package/dist/src/code-editor/code-editor.d.ts +37 -10
  120. package/dist/src/color-field/color-field.d.ts +55 -0
  121. package/dist/src/color-field/index.d.ts +1 -0
  122. package/dist/src/color-picker/color-picker.d.ts +1 -1
  123. package/dist/src/date-picker/date-picker.d.ts +0 -1
  124. package/dist/src/index.d.ts +4 -3
  125. package/dist/src/input/BaseInput.d.ts +21 -3
  126. package/dist/src/input/input.d.ts +15 -7
  127. package/dist/src/navigation-bar/index.d.ts +2 -0
  128. package/dist/src/navigation-bar/navigation-bar-item.d.ts +23 -0
  129. package/dist/src/navigation-bar/navigation-bar.d.ts +44 -0
  130. package/dist/src/navigation-drawer/index.d.ts +2 -0
  131. package/dist/src/navigation-drawer/navigation-drawer-item.d.ts +48 -0
  132. package/dist/src/navigation-drawer/navigation-drawer.d.ts +70 -0
  133. package/dist/src/number-field/number-field.d.ts +0 -1
  134. package/dist/src/radio/index.d.ts +1 -0
  135. package/dist/src/radio/radio-group.d.ts +50 -0
  136. package/dist/src/radio/radio.d.ts +18 -18
  137. package/dist/src/segmented-button/segmented-button-group.d.ts +5 -0
  138. package/dist/src/segmented-button/segmented-button.d.ts +2 -1
  139. package/dist/src/select/select.d.ts +6 -0
  140. package/dist/src/slider/slider.d.ts +14 -5
  141. package/dist/src/switch/switch.d.ts +22 -26
  142. package/dist/src/tabs/tabs.d.ts +3 -0
  143. package/dist/src/textarea/textarea.d.ts +0 -1
  144. package/dist/src/time-picker/time-picker.d.ts +0 -1
  145. package/dist/src/toolbar/toolbar.d.ts +7 -4
  146. package/dist/src/url-field/url-field.d.ts +0 -1
  147. package/dist/svg.js +5 -5
  148. package/dist/switch.js +413 -0
  149. package/dist/switch.js.map +1 -0
  150. package/dist/tab.js +2 -1
  151. package/dist/tab.js.map +1 -1
  152. package/dist/tabs.js +10 -8
  153. package/dist/tabs.js.map +1 -1
  154. package/dist/tag.js +349 -0
  155. package/dist/tag.js.map +1 -0
  156. package/dist/test/code-editor.test.d.ts +1 -0
  157. package/dist/test/color-field.test.d.ts +1 -0
  158. package/dist/test/color-picker.test.d.ts +1 -0
  159. package/dist/test/field.test.d.ts +1 -0
  160. package/dist/test/form-controls.test.d.ts +1 -0
  161. package/dist/test/icon.test.d.ts +1 -1
  162. package/dist/test/input.test.d.ts +1 -0
  163. package/dist/test/navigation.test.d.ts +1 -0
  164. package/dist/test/segmented-button.test.d.ts +1 -0
  165. package/dist/test/slider.test.d.ts +1 -0
  166. package/dist/textarea.js +237 -0
  167. package/dist/textarea.js.map +1 -0
  168. package/dist/time-picker.js +241 -0
  169. package/dist/time-picker.js.map +1 -0
  170. package/dist/toolbar.js +26 -9
  171. package/dist/toolbar.js.map +1 -1
  172. package/dist/tsconfig.tsbuildinfo +1 -1
  173. package/dist/url-field.js +298 -0
  174. package/dist/url-field.js.map +1 -0
  175. package/package.json +29 -8
  176. package/readme.md +2 -2
  177. package/scss/tokens.css +175 -18
  178. package/src/__internal/utils/size.ts +23 -0
  179. package/src/app-bar/app-bar.scss +4 -16
  180. package/src/bottom-sheet/bottom-sheet.scss +1 -1
  181. package/src/button/ButtonTypes.ts +2 -0
  182. package/src/button/button/button-base.scss +84 -84
  183. package/src/button/button/button-colors.scss +14 -2
  184. package/src/button/button/button-layers.scss +71 -71
  185. package/src/button/button/button-shapes.scss +2 -2
  186. package/src/button/button/button-sizes.scss +35 -35
  187. package/src/button/button/button.scss +1 -1
  188. package/src/button/button/button.ts +1 -2
  189. package/src/button/button-group/button-group.scss +5 -5
  190. package/src/button/fab/fab-sizes.scss +15 -15
  191. package/src/button/fab/fab.scss +32 -32
  192. package/src/button/icon-button/icon-button-sizes.scss +7 -7
  193. package/src/chart-bar/chart-bar.scss +1 -1
  194. package/src/checkbox/checkbox.scss +7 -6
  195. package/src/checkbox/checkbox.ts +92 -40
  196. package/src/chip/chip/chip.ts +8 -5
  197. package/src/chip/chip-set/chip-set.ts +2 -0
  198. package/src/chip/tag/tag-colors.scss +1 -1
  199. package/src/chip/tag/tag-sizes.scss +9 -0
  200. package/src/chip/tag/tag.scss +1 -1
  201. package/src/chip/tag/tag.ts +20 -9
  202. package/src/code-editor/code-editor.scss +8 -3
  203. package/src/code-editor/code-editor.ts +148 -79
  204. package/src/code-highlighter/code-highlighter.scss +1 -1
  205. package/src/color-field/color-field.scss +48 -0
  206. package/src/color-field/color-field.ts +239 -0
  207. package/src/color-field/index.ts +1 -0
  208. package/src/color-picker/color-picker.scss +33 -15
  209. package/src/color-picker/color-picker.ts +2 -1
  210. package/src/date-picker/date-picker.ts +2 -3
  211. package/src/field/field.scss +31 -0
  212. package/src/flow/flow.scss +5 -5
  213. package/src/image/image.scss +2 -2
  214. package/src/index.ts +7 -3
  215. package/src/input/BaseInput.ts +54 -4
  216. package/src/input/input.ts +104 -79
  217. package/src/list/list-item.ts +2 -0
  218. package/src/loader.ts +28 -6
  219. package/src/markdown-editor/markdown-editor.scss +2 -2
  220. package/src/menu/menu-item/menu-item.scss +30 -30
  221. package/src/navigation-bar/index.ts +2 -0
  222. package/src/navigation-bar/navigation-bar-item.ts +25 -0
  223. package/src/navigation-bar/navigation-bar.scss +27 -0
  224. package/src/navigation-bar/navigation-bar.ts +96 -0
  225. package/src/navigation-drawer/index.ts +2 -0
  226. package/src/navigation-drawer/navigation-drawer-item.scss +82 -0
  227. package/src/navigation-drawer/navigation-drawer-item.ts +133 -0
  228. package/src/navigation-drawer/navigation-drawer.scss +99 -0
  229. package/src/navigation-drawer/navigation-drawer.ts +196 -0
  230. package/src/navigation-rail/navigation-rail.scss +1 -1
  231. package/src/number-field/number-field.ts +2 -3
  232. package/src/pagination/pagination.scss +1 -1
  233. package/src/progress/circular-progress/circular-progress.ts +2 -0
  234. package/src/progress/linear-progress/linear-progress.ts +2 -0
  235. package/src/radio/index.ts +1 -0
  236. package/src/radio/radio-group.scss +39 -0
  237. package/src/radio/radio-group.ts +167 -0
  238. package/src/radio/radio.ts +74 -31
  239. package/src/segmented-button/segmented-button-group.ts +12 -0
  240. package/src/segmented-button/segmented-button.ts +12 -6
  241. package/src/select/select.ts +21 -1
  242. package/src/side-sheet/side-sheet.scss +1 -1
  243. package/src/sidebar-menu/sidebar-menu-item.scss +1 -1
  244. package/src/sidebar-menu/sidebar-menu-item.ts +2 -0
  245. package/src/sidebar-menu/sidebar-menu.ts +2 -0
  246. package/src/sidebar-menu/sidebar-sub-menu.scss +1 -1
  247. package/src/sidebar-menu/sidebar-sub-menu.ts +2 -0
  248. package/src/slider/slider.scss +3 -3
  249. package/src/slider/slider.ts +119 -31
  250. package/src/snackbar/snackbar.ts +3 -3
  251. package/src/split-button/split-button-colors.scss +2 -2
  252. package/src/svg/svg.scss +5 -5
  253. package/src/switch/switch.scss +0 -1
  254. package/src/switch/switch.ts +82 -47
  255. package/src/tabs/tab.scss +2 -1
  256. package/src/tabs/tabs.ts +14 -8
  257. package/src/textarea/textarea.ts +2 -3
  258. package/src/time-picker/time-picker.ts +2 -3
  259. package/src/toolbar/toolbar.scss +4 -4
  260. package/src/toolbar/toolbar.ts +12 -5
  261. package/src/url-field/url-field.ts +2 -3
  262. package/dist/BaseInput-CU1zZYKc.js +0 -27
  263. package/dist/BaseInput-CU1zZYKc.js.map +0 -1
  264. package/dist/brand-loader.js +0 -358
  265. package/dist/brand-loader.js.map +0 -1
  266. package/dist/element-internals-2CMts_0M.js.map +0 -1
  267. package/dist/form-associated-BXADnjOB.js.map +0 -1
  268. package/dist/list-AdO-PUq_.js.map +0 -1
  269. package/dist/select-DkyRqUTI.js +0 -3955
  270. package/dist/select-DkyRqUTI.js.map +0 -1
  271. package/dist/src/brand-loader/brand-loader.d.ts +0 -33
  272. package/dist/src/brand-loader/index.d.ts +0 -2
  273. package/src/brand-loader/brand-loader.scss +0 -270
  274. package/src/brand-loader/brand-loader.ts +0 -115
  275. package/src/brand-loader/index.ts +0 -2
  276. /package/dist/test/{brand-loader.test.d.ts → button.test.d.ts} +0 -0
@@ -3,6 +3,14 @@ import { property, query, state } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
 
5
5
  import { spread } from '@/__internal/directive/spread.js';
6
+ import { mixinElementInternals } from '@/__internal/mixins/element-internals.js';
7
+ import {
8
+ type FormRestoreState,
9
+ type FormValue,
10
+ getFormState,
11
+ getFormValue,
12
+ mixinFormAssociated,
13
+ } from '@/__internal/mixins/form-associated.js';
6
14
 
7
15
  import styles from './radio.scss';
8
16
  import IndividualComponent from '@/IndividualComponent.js';
@@ -14,6 +22,9 @@ import IndividualComponent from '@/IndividualComponent.js';
14
22
  * @summary Allows selection of a single option from a set.
15
23
  * @overview
16
24
  * <p>Radio buttons follow the specifications with clear focus, hover, and selected states.</p>
25
+ * <p>Radios that share a <code>name</code> form a group. Wrap them in <code>wc-radio-group</code> to get a
26
+ * group label and a single <code>change</code> event for the whole set.</p>
27
+ * <p>The radio is form-associated: the checked radio submits its <code>value</code> under its <code>name</code>.</p>
17
28
  *
18
29
  * @cssprop --radio-size: Size of the outer radio circle.
19
30
  * @cssprop --radio-dot-size: Size of the inner dot when selected.
@@ -35,17 +46,19 @@ import IndividualComponent from '@/IndividualComponent.js';
35
46
  type RadioDirection = 1 | -1;
36
47
 
37
48
  @IndividualComponent
38
- export class Radio extends LitElement {
49
+ export class Radio extends mixinFormAssociated(
50
+ mixinElementInternals(LitElement),
51
+ ) {
52
+ // ── Static ───────────────────────────────────────────────────────────────
53
+
39
54
  private static readonly DIRECTION_NEXT: RadioDirection = 1;
55
+
40
56
  private static readonly DIRECTION_PREVIOUS: RadioDirection = -1;
41
57
 
42
58
  static styles = [styles];
43
59
 
44
- /**
45
- * The input field name for grouping radios.
46
- */
47
- @property({ type: String })
48
- name: string = '';
60
+ // ── Properties ───────────────────────────────────────────────────────────
61
+ // `name` (which groups radios) and `disabled` come from mixinFormAssociated.
49
62
 
50
63
  /**
51
64
  * The submitted value when this radio is selected.
@@ -77,18 +90,14 @@ export class Radio extends LitElement {
77
90
  @property({ type: Boolean, reflect: true })
78
91
  readonly: boolean = false;
79
92
 
80
- /**
81
- * If true, the user cannot interact with the radio. Defaults to `false`.
82
- */
83
- @property({ type: Boolean, reflect: true })
84
- disabled: boolean = false;
85
-
86
93
  /**
87
94
  * Configuration object for aria attributes.
88
95
  */
89
96
  @property({ type: Object })
90
97
  configAria: Record<string, string> = {};
91
98
 
99
+ // ── State ────────────────────────────────────────────────────────────────
100
+
92
101
  /** True while the radio container has keyboard focus. */
93
102
  @state()
94
103
  private hasFocus = false;
@@ -105,19 +114,24 @@ export class Radio extends LitElement {
105
114
  @state()
106
115
  private isGroupFocusTarget = false;
107
116
 
117
+ // ── Queries ──────────────────────────────────────────────────────────────
118
+
108
119
  @query('.container')
109
120
  private containerElement?: HTMLElement;
110
121
 
111
- @query('.input-native')
112
- private nativeElement?: HTMLInputElement;
113
-
114
- // ── Private fields ────────────────────────────────────────────────────────
122
+ // ── Private fields ───────────────────────────────────────────────────────
115
123
 
116
124
  /** Captured `tabindex` attribute value forwarded to the inner container. */
117
125
  private tabindex?: number;
118
126
 
127
+ /** `checked` when first connected; `form.reset()` returns to it. */
128
+ private defaultChecked?: boolean;
129
+
130
+ // ── Lifecycle ────────────────────────────────────────────────────────────
131
+
119
132
  connectedCallback() {
120
133
  super.connectedCallback();
134
+ this.defaultChecked ??= this.checked;
121
135
  this.handleInitialAttributes();
122
136
  window.addEventListener('mouseup', this.windowMouseUp);
123
137
  window.addEventListener('keyup', this.windowKeyUp);
@@ -148,6 +162,42 @@ export class Radio extends LitElement {
148
162
  }
149
163
  }
150
164
 
165
+ // ── Public methods ───────────────────────────────────────────────────────
166
+
167
+ /**
168
+ * Sets focus on the radio.
169
+ */
170
+ focus() {
171
+ this.containerElement?.focus();
172
+ }
173
+
174
+ /**
175
+ * Removes focus from the radio.
176
+ */
177
+ blur() {
178
+ this.containerElement?.blur();
179
+ }
180
+
181
+ // ── Form association ─────────────────────────────────────────────────────
182
+
183
+ override [getFormValue](): FormValue | null {
184
+ return this.checked ? this.value || 'on' : null;
185
+ }
186
+
187
+ override [getFormState](): FormValue | null {
188
+ return String(this.checked);
189
+ }
190
+
191
+ formResetCallback() {
192
+ this.checked = this.defaultChecked ?? false;
193
+ }
194
+
195
+ formStateRestoreCallback(state: FormRestoreState | null) {
196
+ this.checked = state === 'true';
197
+ }
198
+
199
+ // ── Private methods ──────────────────────────────────────────────────────
200
+
151
201
  private handleInitialAttributes() {
152
202
  if (this.hasAttribute('tabindex')) {
153
203
  const attrValue = this.getAttribute('tabindex');
@@ -256,9 +306,14 @@ export class Radio extends LitElement {
256
306
 
257
307
  private getGroupRadios(): Radio[] {
258
308
  if (!this.name) return [this];
259
- const scopeRoot = this.closest('form') ?? document;
309
+ // A radio group or form scopes the name; otherwise the radio's own tree (document or the
310
+ // shadow root it was rendered into).
311
+ const scopeRoot = (this.closest('wc-radio-group, form') ??
312
+ this.getRootNode()) as ParentNode;
260
313
  return Array.from(
261
- scopeRoot.querySelectorAll<Radio>(`wc-radio[name="${this.name}"]`),
314
+ scopeRoot.querySelectorAll<Radio>(
315
+ `wc-radio[name="${CSS.escape(this.name)}"]`,
316
+ ),
262
317
  );
263
318
  }
264
319
 
@@ -300,19 +355,7 @@ export class Radio extends LitElement {
300
355
  target.containerElement?.focus();
301
356
  }
302
357
 
303
- /**
304
- * Sets focus on the radio.
305
- */
306
- focus() {
307
- this.containerElement?.focus();
308
- }
309
-
310
- /**
311
- * Removes focus from the radio.
312
- */
313
- blur() {
314
- this.containerElement?.blur();
315
- }
358
+ // ── Render ───────────────────────────────────────────────────────────────
316
359
 
317
360
  render() {
318
361
  const cssClasses = {
@@ -55,6 +55,7 @@ export class SegmentedButtonGroup extends LitElement {
55
55
  'segmented-button--change',
56
56
  this._onSegmentChange as EventListener,
57
57
  );
58
+ this.addEventListener('change', this._stopSegmentChange, { capture: true });
58
59
  }
59
60
 
60
61
  disconnectedCallback() {
@@ -63,8 +64,19 @@ export class SegmentedButtonGroup extends LitElement {
63
64
  'segmented-button--change',
64
65
  this._onSegmentChange as EventListener,
65
66
  );
67
+ this.removeEventListener('change', this._stopSegmentChange, {
68
+ capture: true,
69
+ });
66
70
  }
67
71
 
72
+ /**
73
+ * Swallows a segment's own `change` on the way down (capture phase), so listeners on the group
74
+ * and above see only the group's `change`, one per selection.
75
+ */
76
+ private _stopSegmentChange = (ev: Event) => {
77
+ if (ev.target !== this) ev.stopPropagation();
78
+ };
79
+
68
80
  private _getSegments(): SegmentedButton[] {
69
81
  return Array.from(
70
82
  this.querySelectorAll<SegmentedButton>('wc-segmented-button'),
@@ -19,7 +19,8 @@ import IndividualComponent from '@/IndividualComponent.js';
19
19
  * @cssprop --segmented-button-outline-color: Outline / border color.
20
20
  * @cssprop --segmented-button-disabled-opacity: Opacity when the segment is disabled.
21
21
  *
22
- * @fires {CustomEvent} segmented-button--change - Dispatched when the selected state changes.
22
+ * @fires {CustomEvent} change - Dispatched when the segment is activated. Detail: `{ value, selected, originalEvent }`, where `selected` is the requested state. Inside a `wc-segmented-button-group` the group swallows it and fires its own `change` instead.
23
+ * @fires {CustomEvent} segmented-button--change - Deprecated alias of `change`, fired alongside it.
23
24
  *
24
25
  * @example
25
26
  * ```html
@@ -102,13 +103,18 @@ export class SegmentedButton extends LitElement {
102
103
 
103
104
  private _toggle(ev: MouseEvent | KeyboardEvent) {
104
105
  if (this.disabled) return;
106
+ const detail = {
107
+ value: this.value || this.textContent?.trim(),
108
+ selected: !this.selected,
109
+ originalEvent: ev,
110
+ };
111
+ this.dispatchEvent(
112
+ new CustomEvent('change', { detail, bubbles: true, composed: true }),
113
+ );
114
+ // Deprecated name, still what wc-segmented-button-group listens for.
105
115
  this.dispatchEvent(
106
116
  new CustomEvent('segmented-button--change', {
107
- detail: {
108
- value: this.value || this.textContent?.trim(),
109
- selected: !this.selected,
110
- originalEvent: ev,
111
- },
117
+ detail,
112
118
  bubbles: true,
113
119
  composed: true,
114
120
  }),
@@ -1,6 +1,11 @@
1
1
  import { html, nothing } from 'lit';
2
2
  import { property, query, state } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
+ import {
5
+ type FormValue,
6
+ getFormValue,
7
+ } from '@/__internal/mixins/form-associated.js';
8
+ import IndividualComponent from '@/IndividualComponent.js';
4
9
  import BaseInput from '../input/BaseInput.js';
5
10
  import styles from './select.scss';
6
11
  import type { Field } from '../field/field.js';
@@ -26,6 +31,10 @@ export interface SelectOption {
26
31
  * - Client-side typeahead with `search="contains"`
27
32
  * - Server-side typeahead with `search="managed"`
28
33
  * - Multi-select chips display
34
+ * - Form-associated: submits the value under `name` (one entry per value with `multiple`)
35
+ *
36
+ * @fires {CustomEvent<{value: string}>} change - Dispatched when the selection changes.
37
+ * @fires {CustomEvent<{value: string}>} select-search - Dispatched as the user types when `search="managed"`.
29
38
  *
30
39
  * @example
31
40
  * ```html
@@ -36,6 +45,7 @@ export interface SelectOption {
36
45
  * ```
37
46
  * @tags form
38
47
  */
48
+ @IndividualComponent
39
49
  export class Select extends BaseInput {
40
50
  static styles = [styles];
41
51
 
@@ -138,6 +148,16 @@ export class Select extends BaseInput {
138
148
  this._triggerEl?.blur();
139
149
  }
140
150
 
151
+ // ── Form association ──────────────────────────────────────────────────────
152
+
153
+ override [getFormValue](): FormValue | null {
154
+ if (!this.multiple) return this.value;
155
+ // One entry per selected value, like a native <select multiple>.
156
+ const data = new FormData();
157
+ for (const value of this._selectedValues) data.append(this.name, value);
158
+ return data;
159
+ }
160
+
141
161
  // ── Lifecycle ─────────────────────────────────────────────────────────────
142
162
 
143
163
  protected override updated(changedProperties: Map<string, unknown>) {
@@ -441,7 +461,7 @@ export class Select extends BaseInput {
441
461
  <wc-chip
442
462
  dismissible
443
463
  value=${val}
444
- @tag--dismiss=${(e: CustomEvent) =>
464
+ @dismiss=${(e: CustomEvent) =>
445
465
  this._handleChipDismiss(e, val)}
446
466
  >${this._getLabelForValue(val)}</wc-chip
447
467
  >
@@ -6,7 +6,7 @@
6
6
  display: contents;
7
7
 
8
8
  --side-sheet-container-color: var(--color-surface-container-low, #f7f2fa);
9
- --side-sheet-scrim-color: rgba(0, 0, 0, 0.32);
9
+ --side-sheet-scrim-color: color-mix(in srgb, var(--color-scrim) 32%, transparent);
10
10
  --side-sheet-shape: var(--shape-corner-extra-large, 28px);
11
11
  --side-sheet-width: 360px;
12
12
  --side-sheet-transition-duration: var(--duration-medium2, 300ms);
@@ -8,7 +8,7 @@
8
8
  // M3 sidebar menu item sizing
9
9
  --sidebar-menu-item-height: 3rem;
10
10
  --sidebar-menu-item-icon-size: 1.25rem;
11
- --sidebar-menu-item-border-radius: var(--global-shape-corner-full, 9999px);
11
+ --sidebar-menu-item-border-radius: var(--shape-corner-full, 9999px);
12
12
 
13
13
  // M3 color tokens
14
14
  --sidebar-menu-item-label-color: var(--color-on-surface);
@@ -1,4 +1,5 @@
1
1
  import { html, LitElement } from 'lit';
2
+ import IndividualComponent from '@/IndividualComponent.js';
2
3
  import { property, query } from 'lit/decorators.js';
3
4
  import { classMap } from 'lit/directives/class-map.js';
4
5
  import styles from './sidebar-menu-item.scss';
@@ -19,6 +20,7 @@ import styles from './sidebar-menu-item.scss';
19
20
  * ```
20
21
  * @tags navigation
21
22
  */
23
+ @IndividualComponent
22
24
  export class SidebarMenuItem extends LitElement {
23
25
  static styles = [styles];
24
26
 
@@ -1,4 +1,5 @@
1
1
  import { html, LitElement } from 'lit';
2
+ import IndividualComponent from '@/IndividualComponent.js';
2
3
  import { property } from 'lit/decorators.js';
3
4
  import styles from './sidebar-menu.scss';
4
5
  import { SidebarMenuItem } from './sidebar-menu-item.js';
@@ -23,6 +24,7 @@ type SidebarNode = SidebarMenuItem | SidebarSubMenu;
23
24
  * ```
24
25
  * @tags navigation
25
26
  */
27
+ @IndividualComponent
26
28
  export class SidebarMenu extends LitElement {
27
29
  static styles = [styles];
28
30
 
@@ -6,7 +6,7 @@
6
6
  display: block;
7
7
 
8
8
  --sidebar-menu-item-height: 3rem;
9
- --sidebar-menu-item-border-radius: var(--global-shape-corner-full, 9999px);
9
+ --sidebar-menu-item-border-radius: var(--shape-corner-full, 9999px);
10
10
  --sidebar-menu-item-label-color: var(--color-on-surface);
11
11
  --sidebar-menu-item-icon-color: var(--color-on-surface-variant);
12
12
  --sidebar-menu-item-selected-background: var(--color-secondary-container);
@@ -1,4 +1,5 @@
1
1
  import { html, LitElement } from 'lit';
2
+ import IndividualComponent from '@/IndividualComponent.js';
2
3
  import { property, query } from 'lit/decorators.js';
3
4
  import { classMap } from 'lit/directives/class-map.js';
4
5
  import { styleMap } from 'lit/directives/style-map.js';
@@ -18,6 +19,7 @@ import styles from './sidebar-sub-menu.scss';
18
19
  * ```
19
20
  * @tags navigation
20
21
  */
22
+ @IndividualComponent
21
23
  export class SidebarSubMenu extends LitElement {
22
24
  static styles = [styles];
23
25
 
@@ -73,7 +73,7 @@
73
73
  height: var(--_thumb-size);
74
74
  background-color: var(--_thumb-color);
75
75
  border-radius: 50%;
76
- box-shadow: var(--md-sys-elevation-1);
76
+ box-shadow: var(--elevation-level1);
77
77
  outline: none;
78
78
  cursor: grab;
79
79
  transition: left 0.05s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.2s ease;
@@ -103,7 +103,7 @@
103
103
  &:focus-visible::before { opacity: 0.12; }
104
104
  &:active {
105
105
  cursor: grabbing;
106
- box-shadow: var(--md-sys-elevation-5);
106
+ box-shadow: var(--elevation-level5);
107
107
  }
108
108
 
109
109
  // Disable transition while dragging
@@ -120,7 +120,7 @@
120
120
  padding: 4px 8px;
121
121
  background-color: var(--_label-color);
122
122
  color: var(--_label-text-color);
123
- border-radius: 4px;
123
+ border-radius: var(--shape-corner-extra-small);
124
124
  font-size: 12px;
125
125
  white-space: nowrap;
126
126
  opacity: 0;
@@ -1,6 +1,13 @@
1
1
  import { LitElement, html } from 'lit';
2
2
  import { property, state, query } from 'lit/decorators.js';
3
3
  import { styleMap } from 'lit/directives/style-map.js';
4
+ import { mixinElementInternals } from '@/__internal/mixins/element-internals.js';
5
+ import {
6
+ type FormRestoreState,
7
+ type FormValue,
8
+ getFormValue,
9
+ mixinFormAssociated,
10
+ } from '@/__internal/mixins/form-associated.js';
4
11
  import sliderStyles from './slider.scss';
5
12
  import IndividualComponent from '@/IndividualComponent.js';
6
13
 
@@ -10,6 +17,9 @@ import IndividualComponent from '@/IndividualComponent.js';
10
17
  * @rawTag slider
11
18
  *
12
19
  * @summary Sliders allow users to make selections from a range of values.
20
+ * @overview
21
+ * <p>The slider is form-associated: its <code>value</code> is submitted under its <code>name</code>,
22
+ * and <code>form.reset()</code> restores the starting value.</p>
13
23
  *
14
24
  * @fires {CustomEvent} input - Dispatched when the slider value changes during interaction.
15
25
  * @fires {CustomEvent} change - Dispatched when the slider interaction ends.
@@ -18,11 +28,19 @@ import IndividualComponent from '@/IndividualComponent.js';
18
28
  * ```html
19
29
  * <wc-slider min="0" max="100" value="50"></wc-slider>
20
30
  * ```
31
+ * @tags input, form
21
32
  */
22
33
  @IndividualComponent
23
- export class Slider extends LitElement {
34
+ export class Slider extends mixinFormAssociated(
35
+ mixinElementInternals(LitElement),
36
+ ) {
37
+ // ── Static ───────────────────────────────────────────────────────────────
38
+
24
39
  static styles = [sliderStyles];
25
40
 
41
+ // ── Properties ───────────────────────────────────────────────────────────
42
+ // `name` and `disabled` come from mixinFormAssociated.
43
+
26
44
  /**
27
45
  * The minimum value of the slider.
28
46
  */
@@ -43,11 +61,6 @@ export class Slider extends LitElement {
43
61
  */
44
62
  @property({ type: Number }) step = 1;
45
63
 
46
- /**
47
- * Whether the slider is disabled.
48
- */
49
- @property({ type: Boolean, reflect: true }) disabled = false;
50
-
51
64
  /**
52
65
  * Whether to show labels on the slider.
53
66
  */
@@ -58,46 +71,90 @@ export class Slider extends LitElement {
58
71
  */
59
72
  @property({ type: Boolean, attribute: 'show-value' }) showValue = false;
60
73
 
74
+ // ── State ────────────────────────────────────────────────────────────────
75
+
61
76
  /** True while the user is actively dragging the thumb. */
62
77
  @state() private isDragging = false;
63
78
 
79
+ // ── Queries ──────────────────────────────────────────────────────────────
80
+
64
81
  @query('.slider-container') private container!: HTMLElement;
65
82
 
66
83
  @query('.thumb') private thumbElement!: HTMLElement;
67
84
 
85
+ // ── Private fields ───────────────────────────────────────────────────────
86
+
87
+ /** `value` when first connected; `form.reset()` returns to it. */
88
+ private defaultValue?: number;
89
+
90
+ // ── Lifecycle ────────────────────────────────────────────────────────────
91
+
92
+ override connectedCallback() {
93
+ super.connectedCallback();
94
+ this.defaultValue ??= this.value;
95
+ }
96
+
97
+ // ── Form association ─────────────────────────────────────────────────────
98
+
99
+ override [getFormValue](): FormValue | null {
100
+ return String(this.value);
101
+ }
102
+
103
+ formResetCallback() {
104
+ this.value = this.defaultValue ?? this.value;
105
+ }
106
+
107
+ formStateRestoreCallback(state: FormRestoreState | null) {
108
+ const restored = Number(state);
109
+ if (typeof state === 'string' && !Number.isNaN(restored)) {
110
+ this.value = restored;
111
+ }
112
+ }
113
+
114
+ // ── Private methods ──────────────────────────────────────────────────────
115
+
68
116
  private handleInput(event: MouseEvent | TouchEvent) {
69
117
  if (this.disabled) return;
70
-
118
+
71
119
  const rect = this.container.getBoundingClientRect();
72
- const clientX = 'touches' in event ? event.touches[0].clientX : (event as MouseEvent).clientX;
73
-
120
+ const clientX =
121
+ 'touches' in event
122
+ ? event.touches[0].clientX
123
+ : (event as MouseEvent).clientX;
124
+
74
125
  // Calculate percentage relative to track width
75
126
  let percentage = (clientX - rect.left) / rect.width;
76
127
  percentage = Math.max(0, Math.min(1, percentage));
77
-
128
+
78
129
  const rawValue = this.min + percentage * (this.max - this.min);
79
130
  const steppedValue = Math.round(rawValue / this.step) * this.step;
80
-
131
+
81
132
  const oldValue = this.value;
82
133
  this.value = Math.max(this.min, Math.min(this.max, steppedValue));
83
134
 
84
135
  if (oldValue !== this.value) {
85
- this.dispatchEvent(new CustomEvent('input', { detail: { value: this.value }, bubbles: true, composed: true }));
136
+ this.dispatchEvent(
137
+ new CustomEvent('input', {
138
+ detail: { value: this.value },
139
+ bubbles: true,
140
+ composed: true,
141
+ }),
142
+ );
86
143
  }
87
144
  }
88
145
 
89
146
  private onMouseDown(e: MouseEvent | TouchEvent) {
90
147
  if (this.disabled) return;
91
-
148
+
92
149
  e.preventDefault();
93
150
  this.isDragging = true;
94
-
151
+
95
152
  // Add dragging class for CSS state
96
153
  this.container.classList.add('dragging');
97
154
  this.thumbElement.classList.add('dragging');
98
-
155
+
99
156
  this.handleInput(e);
100
-
157
+
101
158
  window.addEventListener('mousemove', this.onMouseMove);
102
159
  window.addEventListener('mouseup', this.onMouseUp);
103
160
  window.addEventListener('touchmove', this.onMouseMove, { passive: false });
@@ -114,13 +171,19 @@ export class Slider extends LitElement {
114
171
 
115
172
  private onMouseUp = () => {
116
173
  if (!this.isDragging) return;
117
-
174
+
118
175
  this.isDragging = false;
119
176
  this.container.classList.remove('dragging');
120
177
  this.thumbElement.classList.remove('dragging');
121
-
122
- this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value }, bubbles: true, composed: true }));
123
-
178
+
179
+ this.dispatchEvent(
180
+ new CustomEvent('change', {
181
+ detail: { value: this.value },
182
+ bubbles: true,
183
+ composed: true,
184
+ }),
185
+ );
186
+
124
187
  window.removeEventListener('mousemove', this.onMouseMove);
125
188
  window.removeEventListener('mouseup', this.onMouseUp);
126
189
  window.removeEventListener('touchmove', this.onMouseMove);
@@ -130,7 +193,7 @@ export class Slider extends LitElement {
130
193
 
131
194
  private handleKeyDown(e: KeyboardEvent) {
132
195
  if (this.disabled) return;
133
-
196
+
134
197
  const increment = e.shiftKey ? this.step * 10 : this.step;
135
198
  let newValue = this.value;
136
199
 
@@ -150,27 +213,44 @@ export class Slider extends LitElement {
150
213
 
151
214
  if (newValue !== this.value) {
152
215
  this.value = newValue;
153
- this.dispatchEvent(new CustomEvent('input', { detail: { value: this.value }, bubbles: true, composed: true }));
154
- this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value }, bubbles: true, composed: true }));
216
+ this.dispatchEvent(
217
+ new CustomEvent('input', {
218
+ detail: { value: this.value },
219
+ bubbles: true,
220
+ composed: true,
221
+ }),
222
+ );
223
+ this.dispatchEvent(
224
+ new CustomEvent('change', {
225
+ detail: { value: this.value },
226
+ bubbles: true,
227
+ composed: true,
228
+ }),
229
+ );
155
230
  }
156
231
  }
157
232
 
233
+ // ── Render ───────────────────────────────────────────────────────────────
234
+
158
235
  render() {
159
236
  const percentage = ((this.value - this.min) / (this.max - this.min)) * 100;
160
237
 
161
238
  return html`
162
239
  <div class="slider ${this.showValue ? 'with-value' : ''}">
163
- <div
240
+ <div
164
241
  class="slider-container ${this.disabled ? 'disabled' : ''}"
165
242
  @mousedown=${this.onMouseDown}
166
243
  @touchstart=${this.onMouseDown}
167
244
  >
168
245
  <div class="track">
169
- <div class="track-active" style=${styleMap({ width: `${percentage}%` })}></div>
246
+ <div
247
+ class="track-active"
248
+ style=${styleMap({ width: `${percentage}%` })}
249
+ ></div>
170
250
  </div>
171
251
 
172
- <div
173
- class="thumb"
252
+ <div
253
+ class="thumb"
174
254
  role="slider"
175
255
  aria-label="Slider"
176
256
  tabindex="${this.disabled ? -1 : 0}"
@@ -178,15 +258,23 @@ export class Slider extends LitElement {
178
258
  aria-valuemax=${this.max}
179
259
  aria-valuenow=${this.value}
180
260
  aria-disabled=${this.disabled}
181
- style=${styleMap({ left: `calc(${percentage}% - var(--thumb-half))` })}
261
+ style=${styleMap({
262
+ left: `calc(${percentage}% - var(--thumb-half))`,
263
+ })}
182
264
  @keydown=${this.handleKeyDown}
183
265
  >
184
- ${this.labeled ? html`<div class="value-label">${this.value}</div>` : ''}
266
+ ${this.labeled
267
+ ? html`<div class="value-label">${this.value}</div>`
268
+ : ''}
185
269
  </div>
186
270
  </div>
187
271
 
188
- ${this.showValue ? html`<output class="value-display" aria-live="polite">${this.value}</output>` : ''}
272
+ ${this.showValue
273
+ ? html`<output class="value-display" aria-live="polite"
274
+ >${this.value}</output
275
+ >`
276
+ : ''}
189
277
  </div>
190
278
  `;
191
279
  }
192
- }
280
+ }