@redvars/peacock 3.10.0 → 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 (284) 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 +8620 -4714
  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 +34 -4
  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/menu.js +1 -1
  81. package/dist/navigation-bar-item.js +41 -0
  82. package/dist/navigation-bar-item.js.map +1 -0
  83. package/dist/navigation-bar.js +128 -0
  84. package/dist/navigation-bar.js.map +1 -0
  85. package/dist/navigation-drawer-item.js +236 -0
  86. package/dist/navigation-drawer-item.js.map +1 -0
  87. package/dist/navigation-drawer.js +293 -0
  88. package/dist/navigation-drawer.js.map +1 -0
  89. package/dist/navigation-rail.js +1 -1
  90. package/dist/number-field.js +280 -0
  91. package/dist/number-field.js.map +1 -0
  92. package/dist/option.js +17 -0
  93. package/dist/option.js.map +1 -1
  94. package/dist/pagination.js +1 -1
  95. package/dist/radio-group.js +209 -0
  96. package/dist/radio-group.js.map +1 -0
  97. package/dist/radio.js +47 -37
  98. package/dist/radio.js.map +1 -1
  99. package/dist/segmented-button-group.js +12 -0
  100. package/dist/segmented-button-group.js.map +1 -1
  101. package/dist/segmented-button.js +10 -6
  102. package/dist/segmented-button.js.map +1 -1
  103. package/dist/select.js +653 -0
  104. package/dist/select.js.map +1 -0
  105. package/dist/side-sheet.js +1 -1
  106. package/dist/sidebar-menu-item.js +273 -0
  107. package/dist/sidebar-menu-item.js.map +1 -0
  108. package/dist/sidebar-menu.js +193 -0
  109. package/dist/sidebar-menu.js.map +1 -0
  110. package/dist/sidebar-sub-menu.js +301 -0
  111. package/dist/sidebar-sub-menu.js.map +1 -0
  112. package/dist/slider.js +76 -24
  113. package/dist/slider.js.map +1 -1
  114. package/dist/snackbar.js +3 -3
  115. package/dist/snackbar.js.map +1 -1
  116. package/dist/split-button.js +2 -2
  117. package/dist/src/__internal/utils/size.d.ts +9 -0
  118. package/dist/src/button/ButtonTypes.d.ts +1 -1
  119. package/dist/src/checkbox/checkbox.d.ts +28 -22
  120. package/dist/src/chip/chip/chip.d.ts +3 -0
  121. package/dist/src/chip/tag/tag.d.ts +5 -1
  122. package/dist/src/code-editor/code-editor.d.ts +37 -10
  123. package/dist/src/color-field/color-field.d.ts +55 -0
  124. package/dist/src/color-field/index.d.ts +1 -0
  125. package/dist/src/color-picker/color-picker.d.ts +1 -1
  126. package/dist/src/date-picker/date-picker.d.ts +0 -1
  127. package/dist/src/field/field.d.ts +2 -0
  128. package/dist/src/index.d.ts +4 -3
  129. package/dist/src/input/BaseInput.d.ts +21 -3
  130. package/dist/src/input/input.d.ts +15 -7
  131. package/dist/src/navigation-bar/index.d.ts +2 -0
  132. package/dist/src/navigation-bar/navigation-bar-item.d.ts +23 -0
  133. package/dist/src/navigation-bar/navigation-bar.d.ts +44 -0
  134. package/dist/src/navigation-drawer/index.d.ts +2 -0
  135. package/dist/src/navigation-drawer/navigation-drawer-item.d.ts +48 -0
  136. package/dist/src/navigation-drawer/navigation-drawer.d.ts +70 -0
  137. package/dist/src/number-field/number-field.d.ts +0 -1
  138. package/dist/src/radio/index.d.ts +1 -0
  139. package/dist/src/radio/radio-group.d.ts +50 -0
  140. package/dist/src/radio/radio.d.ts +18 -18
  141. package/dist/src/segmented-button/segmented-button-group.d.ts +5 -0
  142. package/dist/src/segmented-button/segmented-button.d.ts +2 -1
  143. package/dist/src/select/select.d.ts +7 -0
  144. package/dist/src/slider/slider.d.ts +14 -5
  145. package/dist/src/switch/switch.d.ts +22 -26
  146. package/dist/src/tabs/tabs.d.ts +3 -0
  147. package/dist/src/textarea/textarea.d.ts +0 -1
  148. package/dist/src/time-picker/time-picker.d.ts +0 -1
  149. package/dist/src/toolbar/toolbar.d.ts +7 -4
  150. package/dist/src/url-field/url-field.d.ts +0 -1
  151. package/dist/svg.js +5 -5
  152. package/dist/switch.js +413 -0
  153. package/dist/switch.js.map +1 -0
  154. package/dist/tab.js +2 -1
  155. package/dist/tab.js.map +1 -1
  156. package/dist/tabs.js +10 -8
  157. package/dist/tabs.js.map +1 -1
  158. package/dist/tag.js +349 -0
  159. package/dist/tag.js.map +1 -0
  160. package/dist/test/code-editor.test.d.ts +1 -0
  161. package/dist/test/color-field.test.d.ts +1 -0
  162. package/dist/test/color-picker.test.d.ts +1 -0
  163. package/dist/test/field.test.d.ts +1 -0
  164. package/dist/test/form-controls.test.d.ts +1 -0
  165. package/dist/test/icon.test.d.ts +1 -1
  166. package/dist/test/input.test.d.ts +1 -0
  167. package/dist/test/navigation.test.d.ts +1 -0
  168. package/dist/test/segmented-button.test.d.ts +1 -0
  169. package/dist/test/select.test.d.ts +1 -0
  170. package/dist/test/slider.test.d.ts +1 -0
  171. package/dist/textarea.js +237 -0
  172. package/dist/textarea.js.map +1 -0
  173. package/dist/time-picker.js +241 -0
  174. package/dist/time-picker.js.map +1 -0
  175. package/dist/toolbar.js +26 -9
  176. package/dist/toolbar.js.map +1 -1
  177. package/dist/tsconfig.tsbuildinfo +1 -1
  178. package/dist/url-field.js +298 -0
  179. package/dist/url-field.js.map +1 -0
  180. package/package.json +29 -8
  181. package/readme.md +2 -2
  182. package/scss/tokens.css +175 -18
  183. package/src/__internal/utils/size.ts +23 -0
  184. package/src/app-bar/app-bar.scss +4 -16
  185. package/src/bottom-sheet/bottom-sheet.scss +1 -1
  186. package/src/button/ButtonTypes.ts +2 -0
  187. package/src/button/button/button-base.scss +84 -84
  188. package/src/button/button/button-colors.scss +14 -2
  189. package/src/button/button/button-layers.scss +71 -71
  190. package/src/button/button/button-shapes.scss +2 -2
  191. package/src/button/button/button-sizes.scss +35 -35
  192. package/src/button/button/button.scss +1 -1
  193. package/src/button/button/button.ts +1 -2
  194. package/src/button/button-group/button-group.scss +5 -5
  195. package/src/button/fab/fab-sizes.scss +15 -15
  196. package/src/button/fab/fab.scss +32 -32
  197. package/src/button/icon-button/icon-button-sizes.scss +7 -7
  198. package/src/chart-bar/chart-bar.scss +1 -1
  199. package/src/checkbox/checkbox.scss +7 -6
  200. package/src/checkbox/checkbox.ts +92 -40
  201. package/src/chip/chip/chip.ts +8 -5
  202. package/src/chip/chip-set/chip-set.ts +2 -0
  203. package/src/chip/tag/tag-colors.scss +1 -1
  204. package/src/chip/tag/tag-sizes.scss +9 -0
  205. package/src/chip/tag/tag.scss +1 -1
  206. package/src/chip/tag/tag.ts +20 -9
  207. package/src/code-editor/code-editor.scss +8 -3
  208. package/src/code-editor/code-editor.ts +148 -79
  209. package/src/code-highlighter/code-highlighter.scss +1 -1
  210. package/src/color-field/color-field.scss +48 -0
  211. package/src/color-field/color-field.ts +239 -0
  212. package/src/color-field/index.ts +1 -0
  213. package/src/color-picker/color-picker.scss +33 -15
  214. package/src/color-picker/color-picker.ts +2 -1
  215. package/src/date-picker/date-picker.ts +2 -3
  216. package/src/field/field.scss +31 -0
  217. package/src/field/field.ts +5 -1
  218. package/src/flow/flow.scss +5 -5
  219. package/src/image/image.scss +2 -2
  220. package/src/index.ts +7 -3
  221. package/src/input/BaseInput.ts +54 -4
  222. package/src/input/input.ts +104 -79
  223. package/src/list/list-item.ts +2 -0
  224. package/src/loader.ts +28 -6
  225. package/src/markdown-editor/markdown-editor.scss +2 -2
  226. package/src/menu/menu/menu.scss +1 -1
  227. package/src/menu/menu-item/menu-item.scss +30 -30
  228. package/src/navigation-bar/index.ts +2 -0
  229. package/src/navigation-bar/navigation-bar-item.ts +25 -0
  230. package/src/navigation-bar/navigation-bar.scss +27 -0
  231. package/src/navigation-bar/navigation-bar.ts +96 -0
  232. package/src/navigation-drawer/index.ts +2 -0
  233. package/src/navigation-drawer/navigation-drawer-item.scss +82 -0
  234. package/src/navigation-drawer/navigation-drawer-item.ts +133 -0
  235. package/src/navigation-drawer/navigation-drawer.scss +99 -0
  236. package/src/navigation-drawer/navigation-drawer.ts +196 -0
  237. package/src/navigation-rail/navigation-rail.scss +1 -1
  238. package/src/number-field/number-field.ts +2 -3
  239. package/src/pagination/pagination.scss +1 -1
  240. package/src/progress/circular-progress/circular-progress.ts +2 -0
  241. package/src/progress/linear-progress/linear-progress.ts +2 -0
  242. package/src/radio/index.ts +1 -0
  243. package/src/radio/radio-group.scss +39 -0
  244. package/src/radio/radio-group.ts +167 -0
  245. package/src/radio/radio.ts +74 -31
  246. package/src/segmented-button/segmented-button-group.ts +12 -0
  247. package/src/segmented-button/segmented-button.ts +12 -6
  248. package/src/select/option.ts +17 -0
  249. package/src/select/select.ts +33 -8
  250. package/src/side-sheet/side-sheet.scss +1 -1
  251. package/src/sidebar-menu/sidebar-menu-item.scss +1 -1
  252. package/src/sidebar-menu/sidebar-menu-item.ts +2 -0
  253. package/src/sidebar-menu/sidebar-menu.ts +2 -0
  254. package/src/sidebar-menu/sidebar-sub-menu.scss +1 -1
  255. package/src/sidebar-menu/sidebar-sub-menu.ts +2 -0
  256. package/src/slider/slider.scss +3 -3
  257. package/src/slider/slider.ts +119 -31
  258. package/src/snackbar/snackbar.ts +3 -3
  259. package/src/split-button/split-button-colors.scss +2 -2
  260. package/src/svg/svg.scss +5 -5
  261. package/src/switch/switch.scss +0 -1
  262. package/src/switch/switch.ts +82 -47
  263. package/src/tabs/tab.scss +2 -1
  264. package/src/tabs/tabs.ts +14 -8
  265. package/src/textarea/textarea.ts +2 -3
  266. package/src/time-picker/time-picker.ts +2 -3
  267. package/src/toolbar/toolbar.scss +4 -4
  268. package/src/toolbar/toolbar.ts +12 -5
  269. package/src/url-field/url-field.ts +2 -3
  270. package/dist/BaseInput-CU1zZYKc.js +0 -27
  271. package/dist/BaseInput-CU1zZYKc.js.map +0 -1
  272. package/dist/brand-loader.js +0 -358
  273. package/dist/brand-loader.js.map +0 -1
  274. package/dist/element-internals-2CMts_0M.js.map +0 -1
  275. package/dist/form-associated-BXADnjOB.js.map +0 -1
  276. package/dist/list-AdO-PUq_.js.map +0 -1
  277. package/dist/select-CnnPbvpQ.js +0 -3955
  278. package/dist/select-CnnPbvpQ.js.map +0 -1
  279. package/dist/src/brand-loader/brand-loader.d.ts +0 -33
  280. package/dist/src/brand-loader/index.d.ts +0 -2
  281. package/src/brand-loader/brand-loader.scss +0 -270
  282. package/src/brand-loader/brand-loader.ts +0 -115
  283. package/src/brand-loader/index.ts +0 -2
  284. /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
  }),
@@ -24,10 +24,27 @@ export class SelectOptionElement extends LitElement {
24
24
  css`
25
25
  :host {
26
26
  display: contents;
27
+ --menu-item-backdrop-container-shape-start-start: none;
28
+ --menu-item-backdrop-container-shape-start-end: none;
29
+ --menu-item-backdrop-container-shape-end-start: none;
30
+ --menu-item-backdrop-container-shape-end-end: none;
31
+
32
+ --menu-item-backdrop-elevation-level-block-start: none;
33
+ --menu-item-backdrop-elevation-level-block-end: none;
27
34
  }
28
35
  :host([filtered]) {
29
36
  display: none;
30
37
  }
38
+ /* Forward the position styles wc-menu sets on this wrapper to the inner item */
39
+ wc-menu-item {
40
+ --menu-item-backdrop-container-shape-start-start: inherit;
41
+ --menu-item-backdrop-container-shape-start-end: inherit;
42
+ --menu-item-backdrop-container-shape-end-start: inherit;
43
+ --menu-item-backdrop-container-shape-end-end: inherit;
44
+
45
+ --menu-item-backdrop-elevation-level-block-start: inherit;
46
+ --menu-item-backdrop-elevation-level-block-end: inherit;
47
+ }
31
48
  `,
32
49
  ];
33
50
 
@@ -1,8 +1,14 @@
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';
11
+ import type { Field } from '../field/field.js';
6
12
  import type { Menu } from '../menu/menu/menu.js';
7
13
  import { SelectOptionElement } from './option.js';
8
14
 
@@ -25,6 +31,10 @@ export interface SelectOption {
25
31
  * - Client-side typeahead with `search="contains"`
26
32
  * - Server-side typeahead with `search="managed"`
27
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"`.
28
38
  *
29
39
  * @example
30
40
  * ```html
@@ -35,6 +45,7 @@ export interface SelectOption {
35
45
  * ```
36
46
  * @tags form
37
47
  */
48
+ @IndividualComponent
38
49
  export class Select extends BaseInput {
39
50
  static styles = [styles];
40
51
 
@@ -119,6 +130,9 @@ export class Select extends BaseInput {
119
130
  @query('.select-trigger')
120
131
  private _triggerEl?: HTMLElement;
121
132
 
133
+ @query('wc-field')
134
+ private _fieldEl?: Field;
135
+
122
136
  private get _menu(): Menu | null {
123
137
  return (this.renderRoot?.querySelector('wc-menu') as unknown as Menu) ?? null;
124
138
  }
@@ -134,6 +148,16 @@ export class Select extends BaseInput {
134
148
  this._triggerEl?.blur();
135
149
  }
136
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
+
137
161
  // ── Lifecycle ─────────────────────────────────────────────────────────────
138
162
 
139
163
  protected override updated(changedProperties: Map<string, unknown>) {
@@ -241,13 +265,14 @@ export class Select extends BaseInput {
241
265
  this._triggerEl?.focus();
242
266
  const menu = this._menu;
243
267
  if (menu && this._triggerEl) {
244
- menu.anchorElement = this._triggerEl;
245
- const triggerWidth = this._triggerEl.getBoundingClientRect().width;
246
- if (triggerWidth < 240) {
247
- menu.style.setProperty('--menu-width', '240px');
248
- } else {
249
- menu.style.setProperty('--menu-width', `${Math.ceil(triggerWidth)}px`);
250
- }
268
+ // Anchor to the field's bordered box so the menu lines up with its edge
269
+ // and is at least as wide as the field.
270
+ const anchor = this._fieldEl?.fieldBodyElement ?? this._triggerEl;
271
+ menu.anchorElement = anchor;
272
+ menu.style.setProperty(
273
+ '--menu-min-width',
274
+ `${Math.ceil(anchor.getBoundingClientRect().width)}px`,
275
+ );
251
276
  menu.show();
252
277
  }
253
278
  if (this.search) {
@@ -436,7 +461,7 @@ export class Select extends BaseInput {
436
461
  <wc-chip
437
462
  dismissible
438
463
  value=${val}
439
- @tag--dismiss=${(e: CustomEvent) =>
464
+ @dismiss=${(e: CustomEvent) =>
440
465
  this._handleChipDismiss(e, val)}
441
466
  >${this._getLabelForValue(val)}</wc-chip
442
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;