@redvars/peacock 3.10.1 → 3.12.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 (325) 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/cb-divider.js +7 -6
  18. package/dist/cb-divider.js.map +1 -1
  19. package/dist/cb-group-base-D9gv7SDY.js +114 -0
  20. package/dist/cb-group-base-D9gv7SDY.js.map +1 -0
  21. package/dist/cb-group-base-DsX_2aFl.js +325 -0
  22. package/dist/cb-group-base-DsX_2aFl.js.map +1 -0
  23. package/dist/cb-group.js +96 -0
  24. package/dist/cb-group.js.map +1 -0
  25. package/dist/cb-rule.js +212 -0
  26. package/dist/cb-rule.js.map +1 -0
  27. package/dist/{chart-bar-CapLbc2e.js → chart-bar-D5dGFJfK.js} +2 -2
  28. package/dist/{chart-bar-CapLbc2e.js.map → chart-bar-D5dGFJfK.js.map} +1 -1
  29. package/dist/chart-bar.js +1 -1
  30. package/dist/chart-stacked-bar.js +1 -1
  31. package/dist/checkbox.js +78 -53
  32. package/dist/checkbox.js.map +1 -1
  33. package/dist/chip-set.js +52 -0
  34. package/dist/chip-set.js.map +1 -0
  35. package/dist/chip.js +8 -6
  36. package/dist/chip.js.map +1 -1
  37. package/dist/circular-progress.js +177 -0
  38. package/dist/circular-progress.js.map +1 -0
  39. package/dist/code-editor.js +129 -72
  40. package/dist/code-editor.js.map +1 -1
  41. package/dist/code-highlighter.js +2 -38
  42. package/dist/code-highlighter.js.map +1 -1
  43. package/dist/color-field.js +309 -0
  44. package/dist/color-field.js.map +1 -0
  45. package/dist/color-picker.js +26 -15
  46. package/dist/color-picker.js.map +1 -1
  47. package/dist/condition-builder.js +90 -35
  48. package/dist/condition-builder.js.map +1 -1
  49. package/dist/copy-to-clipboard-upGx-Ueo.js +39 -0
  50. package/dist/copy-to-clipboard-upGx-Ueo.js.map +1 -0
  51. package/dist/custom-elements-jsdocs.json +1140 -398
  52. package/dist/custom-elements.json +9065 -3989
  53. package/dist/date-picker.js +241 -0
  54. package/dist/date-picker.js.map +1 -0
  55. package/dist/{element-internals-2CMts_0M.js → delegate-py-Ets8N.js} +2 -43
  56. package/dist/delegate-py-Ets8N.js.map +1 -0
  57. package/dist/element-internals-QME0yEz4.js +43 -0
  58. package/dist/element-internals-QME0yEz4.js.map +1 -0
  59. package/dist/fab.js +51 -49
  60. package/dist/fab.js.map +1 -1
  61. package/dist/field.js +27 -0
  62. package/dist/field.js.map +1 -1
  63. package/dist/flow.js +5 -5
  64. package/dist/form-associated-Bhwwr6dT.js +162 -0
  65. package/dist/form-associated-Bhwwr6dT.js.map +1 -0
  66. package/dist/{form-associated-BXADnjOB.js → form-submitter-DPI4L6gj.js} +3 -159
  67. package/dist/form-submitter-DPI4L6gj.js.map +1 -0
  68. package/dist/html-editor.js +3 -1
  69. package/dist/html-editor.js.map +1 -1
  70. package/dist/icon-button.js +195 -156
  71. package/dist/icon-button.js.map +1 -1
  72. package/dist/image.js +2 -2
  73. package/dist/index.js +36 -11
  74. package/dist/index.js.map +1 -1
  75. package/dist/input.js +259 -0
  76. package/dist/input.js.map +1 -0
  77. package/dist/item.js +2 -1
  78. package/dist/item.js.map +1 -1
  79. package/dist/linear-progress.js +192 -0
  80. package/dist/linear-progress.js.map +1 -0
  81. package/dist/{list-AdO-PUq_.js → list-item.js} +12 -222
  82. package/dist/list-item.js.map +1 -0
  83. package/dist/list.js +225 -6
  84. package/dist/list.js.map +1 -1
  85. package/dist/loader-full.js +31 -8
  86. package/dist/loader-full.js.map +1 -1
  87. package/dist/loader.js +58 -25
  88. package/dist/loader.js.map +1 -1
  89. package/dist/markdown-editor.js +5 -3
  90. package/dist/markdown-editor.js.map +1 -1
  91. package/dist/menu-item.js +30 -30
  92. package/dist/navigation-bar-item.js +41 -0
  93. package/dist/navigation-bar-item.js.map +1 -0
  94. package/dist/navigation-bar.js +128 -0
  95. package/dist/navigation-bar.js.map +1 -0
  96. package/dist/navigation-drawer-item.js +236 -0
  97. package/dist/navigation-drawer-item.js.map +1 -0
  98. package/dist/navigation-drawer.js +293 -0
  99. package/dist/navigation-drawer.js.map +1 -0
  100. package/dist/navigation-rail.js +1 -1
  101. package/dist/number-field.js +280 -0
  102. package/dist/number-field.js.map +1 -0
  103. package/dist/pagination.js +1 -1
  104. package/dist/radio-group.js +209 -0
  105. package/dist/radio-group.js.map +1 -0
  106. package/dist/radio.js +47 -37
  107. package/dist/radio.js.map +1 -1
  108. package/dist/segmented-button-group.js +12 -0
  109. package/dist/segmented-button-group.js.map +1 -1
  110. package/dist/segmented-button.js +10 -6
  111. package/dist/segmented-button.js.map +1 -1
  112. package/dist/select.js +653 -0
  113. package/dist/select.js.map +1 -0
  114. package/dist/side-sheet.js +1 -1
  115. package/dist/sidebar-menu-item.js +273 -0
  116. package/dist/sidebar-menu-item.js.map +1 -0
  117. package/dist/sidebar-menu.js +193 -0
  118. package/dist/sidebar-menu.js.map +1 -0
  119. package/dist/sidebar-sub-menu.js +301 -0
  120. package/dist/sidebar-sub-menu.js.map +1 -0
  121. package/dist/slider.js +76 -24
  122. package/dist/slider.js.map +1 -1
  123. package/dist/snackbar.js +3 -3
  124. package/dist/snackbar.js.map +1 -1
  125. package/dist/split-button.js +2 -2
  126. package/dist/src/__internal/utils/size.d.ts +9 -0
  127. package/dist/src/button/ButtonTypes.d.ts +1 -1
  128. package/dist/src/checkbox/checkbox.d.ts +28 -22
  129. package/dist/src/chip/chip/chip.d.ts +3 -0
  130. package/dist/src/chip/tag/tag.d.ts +5 -1
  131. package/dist/src/code-editor/code-editor.d.ts +37 -10
  132. package/dist/src/color-field/color-field.d.ts +55 -0
  133. package/dist/src/color-field/index.d.ts +1 -0
  134. package/dist/src/color-picker/color-picker.d.ts +1 -1
  135. package/dist/src/condition-builder/cb-divider.d.ts +3 -1
  136. package/dist/src/condition-builder/cb-drag.d.ts +10 -0
  137. package/dist/src/condition-builder/cb-group-base.d.ts +59 -0
  138. package/dist/src/condition-builder/cb-group.d.ts +34 -0
  139. package/dist/src/condition-builder/cb-rule.d.ts +32 -0
  140. package/dist/src/condition-builder/cb-types.d.ts +13 -0
  141. package/dist/src/condition-builder/condition-builder.d.ts +35 -14
  142. package/dist/src/condition-builder/index.d.ts +3 -3
  143. package/dist/src/date-picker/date-picker.d.ts +0 -1
  144. package/dist/src/index.d.ts +6 -4
  145. package/dist/src/input/BaseInput.d.ts +21 -3
  146. package/dist/src/input/input.d.ts +15 -7
  147. package/dist/src/navigation-bar/index.d.ts +2 -0
  148. package/dist/src/navigation-bar/navigation-bar-item.d.ts +23 -0
  149. package/dist/src/navigation-bar/navigation-bar.d.ts +44 -0
  150. package/dist/src/navigation-drawer/index.d.ts +2 -0
  151. package/dist/src/navigation-drawer/navigation-drawer-item.d.ts +48 -0
  152. package/dist/src/navigation-drawer/navigation-drawer.d.ts +70 -0
  153. package/dist/src/number-field/number-field.d.ts +0 -1
  154. package/dist/src/radio/index.d.ts +1 -0
  155. package/dist/src/radio/radio-group.d.ts +50 -0
  156. package/dist/src/radio/radio.d.ts +18 -18
  157. package/dist/src/segmented-button/segmented-button-group.d.ts +5 -0
  158. package/dist/src/segmented-button/segmented-button.d.ts +2 -1
  159. package/dist/src/select/select.d.ts +6 -0
  160. package/dist/src/slider/slider.d.ts +14 -5
  161. package/dist/src/switch/switch.d.ts +22 -26
  162. package/dist/src/tabs/tabs.d.ts +3 -0
  163. package/dist/src/textarea/textarea.d.ts +0 -1
  164. package/dist/src/time-picker/time-picker.d.ts +0 -1
  165. package/dist/src/toolbar/toolbar.d.ts +7 -4
  166. package/dist/src/url-field/url-field.d.ts +0 -1
  167. package/dist/svg.js +5 -5
  168. package/dist/switch.js +413 -0
  169. package/dist/switch.js.map +1 -0
  170. package/dist/tab.js +2 -1
  171. package/dist/tab.js.map +1 -1
  172. package/dist/tabs.js +10 -8
  173. package/dist/tabs.js.map +1 -1
  174. package/dist/tag.js +349 -0
  175. package/dist/tag.js.map +1 -0
  176. package/dist/test/code-editor.test.d.ts +1 -0
  177. package/dist/test/color-field.test.d.ts +1 -0
  178. package/dist/test/color-picker.test.d.ts +1 -0
  179. package/dist/test/condition-builder.test.d.ts +1 -0
  180. package/dist/test/field.test.d.ts +1 -0
  181. package/dist/test/form-controls.test.d.ts +1 -0
  182. package/dist/test/icon.test.d.ts +1 -1
  183. package/dist/test/input.test.d.ts +1 -0
  184. package/dist/test/navigation.test.d.ts +1 -0
  185. package/dist/test/segmented-button.test.d.ts +1 -0
  186. package/dist/test/slider.test.d.ts +1 -0
  187. package/dist/textarea.js +237 -0
  188. package/dist/textarea.js.map +1 -0
  189. package/dist/time-picker.js +241 -0
  190. package/dist/time-picker.js.map +1 -0
  191. package/dist/toolbar.js +26 -9
  192. package/dist/toolbar.js.map +1 -1
  193. package/dist/tsconfig.tsbuildinfo +1 -1
  194. package/dist/url-field.js +298 -0
  195. package/dist/url-field.js.map +1 -0
  196. package/package.json +29 -8
  197. package/readme.md +2 -2
  198. package/scss/tokens.css +175 -18
  199. package/src/__internal/utils/size.ts +23 -0
  200. package/src/app-bar/app-bar.scss +4 -16
  201. package/src/bottom-sheet/bottom-sheet.scss +1 -1
  202. package/src/button/ButtonTypes.ts +2 -0
  203. package/src/button/button/button-base.scss +84 -84
  204. package/src/button/button/button-colors.scss +14 -2
  205. package/src/button/button/button-layers.scss +71 -71
  206. package/src/button/button/button-shapes.scss +2 -2
  207. package/src/button/button/button-sizes.scss +35 -35
  208. package/src/button/button/button.scss +1 -1
  209. package/src/button/button/button.ts +1 -2
  210. package/src/button/button-group/button-group.scss +5 -5
  211. package/src/button/fab/fab-sizes.scss +15 -15
  212. package/src/button/fab/fab.scss +32 -32
  213. package/src/button/icon-button/icon-button-sizes.scss +7 -7
  214. package/src/chart-bar/chart-bar.scss +1 -1
  215. package/src/checkbox/checkbox.scss +7 -6
  216. package/src/checkbox/checkbox.ts +92 -40
  217. package/src/chip/chip/chip.ts +8 -5
  218. package/src/chip/chip-set/chip-set.ts +2 -0
  219. package/src/chip/tag/tag-colors.scss +1 -1
  220. package/src/chip/tag/tag-sizes.scss +9 -0
  221. package/src/chip/tag/tag.scss +1 -1
  222. package/src/chip/tag/tag.ts +20 -9
  223. package/src/code-editor/code-editor.scss +8 -3
  224. package/src/code-editor/code-editor.ts +148 -79
  225. package/src/code-highlighter/code-highlighter.scss +1 -1
  226. package/src/color-field/color-field.scss +48 -0
  227. package/src/color-field/color-field.ts +239 -0
  228. package/src/color-field/index.ts +1 -0
  229. package/src/color-picker/color-picker.scss +33 -15
  230. package/src/color-picker/color-picker.ts +2 -1
  231. package/src/condition-builder/cb-divider.scss +4 -5
  232. package/src/condition-builder/cb-divider.ts +3 -1
  233. package/src/condition-builder/cb-drag.ts +35 -0
  234. package/src/condition-builder/cb-group-base.scss +97 -0
  235. package/src/condition-builder/cb-group-base.ts +335 -0
  236. package/src/condition-builder/cb-group.scss +21 -0
  237. package/src/condition-builder/cb-group.ts +72 -0
  238. package/src/condition-builder/cb-rule.scss +90 -0
  239. package/src/condition-builder/cb-rule.ts +129 -0
  240. package/src/condition-builder/cb-types.ts +16 -0
  241. package/src/condition-builder/condition-builder.scss +12 -9
  242. package/src/condition-builder/condition-builder.ts +77 -17
  243. package/src/condition-builder/index.ts +7 -3
  244. package/src/date-picker/date-picker.ts +2 -3
  245. package/src/field/field.scss +34 -0
  246. package/src/flow/flow.scss +5 -5
  247. package/src/image/image.scss +2 -2
  248. package/src/index.ts +14 -6
  249. package/src/input/BaseInput.ts +54 -4
  250. package/src/input/input.ts +104 -79
  251. package/src/list/list-item.ts +2 -0
  252. package/src/loader.ts +34 -19
  253. package/src/markdown-editor/markdown-editor.scss +2 -2
  254. package/src/menu/menu-item/menu-item.scss +30 -30
  255. package/src/navigation-bar/index.ts +2 -0
  256. package/src/navigation-bar/navigation-bar-item.ts +25 -0
  257. package/src/navigation-bar/navigation-bar.scss +27 -0
  258. package/src/navigation-bar/navigation-bar.ts +96 -0
  259. package/src/navigation-drawer/index.ts +2 -0
  260. package/src/navigation-drawer/navigation-drawer-item.scss +82 -0
  261. package/src/navigation-drawer/navigation-drawer-item.ts +133 -0
  262. package/src/navigation-drawer/navigation-drawer.scss +99 -0
  263. package/src/navigation-drawer/navigation-drawer.ts +196 -0
  264. package/src/navigation-rail/navigation-rail.scss +1 -1
  265. package/src/number-field/number-field.ts +2 -3
  266. package/src/pagination/pagination.scss +1 -1
  267. package/src/progress/circular-progress/circular-progress.ts +2 -0
  268. package/src/progress/linear-progress/linear-progress.ts +2 -0
  269. package/src/radio/index.ts +1 -0
  270. package/src/radio/radio-group.scss +39 -0
  271. package/src/radio/radio-group.ts +167 -0
  272. package/src/radio/radio.ts +74 -31
  273. package/src/segmented-button/segmented-button-group.ts +12 -0
  274. package/src/segmented-button/segmented-button.ts +12 -6
  275. package/src/select/select.ts +21 -1
  276. package/src/side-sheet/side-sheet.scss +1 -1
  277. package/src/sidebar-menu/sidebar-menu-item.scss +1 -1
  278. package/src/sidebar-menu/sidebar-menu-item.ts +2 -0
  279. package/src/sidebar-menu/sidebar-menu.ts +2 -0
  280. package/src/sidebar-menu/sidebar-sub-menu.scss +1 -1
  281. package/src/sidebar-menu/sidebar-sub-menu.ts +2 -0
  282. package/src/slider/slider.scss +3 -3
  283. package/src/slider/slider.ts +119 -31
  284. package/src/snackbar/snackbar.ts +3 -3
  285. package/src/split-button/split-button-colors.scss +2 -2
  286. package/src/svg/svg.scss +5 -5
  287. package/src/switch/switch.scss +0 -1
  288. package/src/switch/switch.ts +82 -47
  289. package/src/tabs/tab.scss +2 -1
  290. package/src/tabs/tabs.ts +14 -8
  291. package/src/textarea/textarea.ts +2 -3
  292. package/src/time-picker/time-picker.ts +2 -3
  293. package/src/toolbar/toolbar.scss +4 -4
  294. package/src/toolbar/toolbar.ts +12 -5
  295. package/src/url-field/url-field.ts +2 -3
  296. package/dist/BaseInput-CU1zZYKc.js +0 -27
  297. package/dist/BaseInput-CU1zZYKc.js.map +0 -1
  298. package/dist/brand-loader.js +0 -358
  299. package/dist/brand-loader.js.map +0 -1
  300. package/dist/cb-compound-expression.js +0 -133
  301. package/dist/cb-compound-expression.js.map +0 -1
  302. package/dist/cb-expression.js +0 -78
  303. package/dist/cb-expression.js.map +0 -1
  304. package/dist/cb-predicate.js +0 -141
  305. package/dist/cb-predicate.js.map +0 -1
  306. package/dist/element-internals-2CMts_0M.js.map +0 -1
  307. package/dist/form-associated-BXADnjOB.js.map +0 -1
  308. package/dist/list-AdO-PUq_.js.map +0 -1
  309. package/dist/select-DkyRqUTI.js +0 -3955
  310. package/dist/select-DkyRqUTI.js.map +0 -1
  311. package/dist/src/brand-loader/brand-loader.d.ts +0 -33
  312. package/dist/src/brand-loader/index.d.ts +0 -2
  313. package/dist/src/condition-builder/cb-compound-expression.d.ts +0 -30
  314. package/dist/src/condition-builder/cb-expression.d.ts +0 -30
  315. package/dist/src/condition-builder/cb-predicate.d.ts +0 -29
  316. package/src/brand-loader/brand-loader.scss +0 -270
  317. package/src/brand-loader/brand-loader.ts +0 -115
  318. package/src/brand-loader/index.ts +0 -2
  319. package/src/condition-builder/cb-compound-expression.scss +0 -41
  320. package/src/condition-builder/cb-compound-expression.ts +0 -79
  321. package/src/condition-builder/cb-expression.scss +0 -13
  322. package/src/condition-builder/cb-expression.ts +0 -48
  323. package/src/condition-builder/cb-predicate.scss +0 -35
  324. package/src/condition-builder/cb-predicate.ts +0 -101
  325. /package/dist/test/{brand-loader.test.d.ts → button.test.d.ts} +0 -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
+ }
@@ -224,7 +224,7 @@ export class Snackbar extends LitElement {
224
224
  </div>
225
225
 
226
226
  ${this.actionLabel
227
- ? html`<wc-button class="action" variant='text' size='small' @click=${this.handleActionClick}>
227
+ ? html`<wc-button class="action" variant='text' size='sm' @click=${this.handleActionClick}>
228
228
  ${this.actionLabel}
229
229
  </wc-button>`
230
230
  : nothing}
@@ -232,8 +232,8 @@ export class Snackbar extends LitElement {
232
232
  ${this.showCloseIcon
233
233
  ? html`<wc-icon-button
234
234
  class="close"
235
- variant='text'
236
- size='small'
235
+ variant='text'
236
+ size='sm'
237
237
  aria-label="Dismiss notification"
238
238
  @click=${this.handleCloseClick}
239
239
  >
@@ -37,7 +37,7 @@
37
37
  --filled-split-button-container-color: var(--color-on-surface);
38
38
  --filled-split-button-label-text-color: var(--color-surface);
39
39
 
40
- --tonal-split-button-container-color: var(--color-on-surface-container);
40
+ --tonal-split-button-container-color: var(--color-on-surface-variant);
41
41
  --tonal-split-button-label-text-color: var(--color-surface-container-high);
42
42
 
43
43
  --outlined-split-button-outline-color: var(--color-on-surface);
@@ -49,7 +49,7 @@
49
49
  --filled-split-button-label-text-color: var(--color-on-surface);
50
50
 
51
51
  --tonal-split-button-container-color: var(--color-surface-container-high);
52
- --tonal-split-button-label-text-color: var(--color-on-surface-container);
52
+ --tonal-split-button-label-text-color: var(--color-on-surface);
53
53
 
54
54
  --outlined-split-button-outline-color: var(--color-on-surface);
55
55
  --outlined-split-button-label-text-color: var(--color-on-surface);
package/src/svg/svg.scss CHANGED
@@ -46,7 +46,7 @@
46
46
  position: fixed;
47
47
  inset: 0;
48
48
  z-index: 9999;
49
- background: rgba(0, 0, 0, 0.85);
49
+ background: color-mix(in srgb, var(--color-scrim) 85%, transparent);
50
50
  align-items: center;
51
51
  justify-content: center;
52
52
  cursor: zoom-out;
@@ -62,14 +62,14 @@
62
62
  right: 1rem;
63
63
  background: transparent;
64
64
  border: none;
65
- color: #fff;
65
+ color: var(--color-white);
66
66
  font-size: 1.5rem;
67
67
  cursor: pointer;
68
68
  line-height: 1;
69
69
  padding: 0.25rem 0.5rem;
70
70
 
71
71
  &:focus-visible {
72
- outline: 2px solid #fff;
72
+ outline: 2px solid var(--color-white);
73
73
  outline-offset: 2px;
74
74
  }
75
75
  }
@@ -85,7 +85,7 @@
85
85
  svg {
86
86
  max-width: 90vw;
87
87
  max-height: 90vh;
88
- box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
89
- border-radius: 4px;
88
+ box-shadow: 0 8px 40px color-mix(in srgb, var(--color-shadow) 60%, transparent);
89
+ border-radius: var(--shape-corner-extra-small);
90
90
  }
91
91
  }
@@ -52,7 +52,6 @@
52
52
  justify-content: center;
53
53
  border-radius: var(--shape-corner-full);
54
54
  transition: all var(--duration-short2) var(--easing-standard);
55
- background: white;
56
55
  height: var(--switch-handle-radius);
57
56
  width: var(--switch-handle-radius);
58
57
  background: var(--switch-handle-color);
@@ -3,6 +3,13 @@ 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 {
7
+ type FormRestoreState,
8
+ type FormValue,
9
+ getFormState,
10
+ getFormValue,
11
+ } from '@/__internal/mixins/form-associated.js';
12
+ import IndividualComponent from '@/IndividualComponent.js';
6
13
 
7
14
  import styles from './switch.scss';
8
15
  import BaseInput from '../input/BaseInput.js';
@@ -15,6 +22,7 @@ import BaseInput from '../input/BaseInput.js';
15
22
  * @summary Captures boolean input with an on/off switch interaction.
16
23
  * @overview
17
24
  * <p>Toggles are used to enable or disable a single option. They provide immediate feedback about whether an option is active or inactive.</p>
25
+ * <p>The switch is form-associated: when <code>checked</code>, it submits <code>on</code> under its <code>name</code>.</p>
18
26
  *
19
27
  * @cssprop --switch-track-color: Color of the switch track when checked.
20
28
  * @cssprop --switch-track-off-color: Color of the switch track when unchecked.
@@ -23,27 +31,41 @@ import BaseInput from '../input/BaseInput.js';
23
31
  * @cssprop --switch-handle-radius: Size of the switch handle.
24
32
  * @cssprop --switch-handle-color: Color of the switch handle.
25
33
  *
26
- * @fires {CustomEvent} change - Dispatched when the switch value changes.
34
+ * @fires {CustomEvent} change - Dispatched when the switch is toggled. Detail: `{ checked, value, originalEvent }`.
27
35
  * @fires {CustomEvent} blur - Dispatched when the switch loses focus.
28
36
  * @fires {CustomEvent} focus - Dispatched when the switch receives focus.
29
37
  *
30
38
  * @example
31
39
  * ```html
32
- * <wc-switch value="true"></wc-switch>
40
+ * <wc-switch checked label="Wi-Fi"></wc-switch>
33
41
  * ```
34
42
  * @tags input, form
35
43
  */
44
+ @IndividualComponent
36
45
  export class Switch extends BaseInput {
46
+ // ── Static ───────────────────────────────────────────────────────────────
47
+
37
48
  static styles = [styles];
38
49
 
39
- @property({ type: Boolean })
40
- value: boolean = false;
50
+ // ── Properties ───────────────────────────────────────────────────────────
41
51
 
42
52
  /**
43
- * The input field name.
53
+ * Whether the switch is on.
44
54
  */
45
- @property({ type: String })
46
- name: string = '';
55
+ @property({ type: Boolean, reflect: true })
56
+ checked: boolean = false;
57
+
58
+ /**
59
+ * @deprecated Use `checked`. Kept as an alias of `checked`.
60
+ */
61
+ @property({ type: Boolean })
62
+ get value(): boolean {
63
+ return this.checked;
64
+ }
65
+
66
+ set value(value: boolean) {
67
+ this.checked = Boolean(value);
68
+ }
47
69
 
48
70
  /**
49
71
  * The switch label.
@@ -57,24 +79,6 @@ export class Switch extends BaseInput {
57
79
  @property({ type: Boolean })
58
80
  rounded: boolean = true;
59
81
 
60
- /**
61
- * If true, required icon is shown. Defaults to `false`.
62
- */
63
- @property({ type: Boolean, reflect: true })
64
- required: boolean = false;
65
-
66
- /**
67
- * If true, the toggle is readonly. Defaults to `false`.
68
- */
69
- @property({ type: Boolean, reflect: true })
70
- readonly: boolean = false;
71
-
72
- /**
73
- * If true, the user cannot interact with the toggle. Defaults to `false`.
74
- */
75
- @property({ type: Boolean, reflect: true })
76
- disabled: boolean = false;
77
-
78
82
  @property({ type: Boolean, reflect: true, attribute: 'with-icon' })
79
83
  withIcon: boolean = false;
80
84
 
@@ -84,6 +88,8 @@ export class Switch extends BaseInput {
84
88
  @property({ type: Object })
85
89
  configAria: Record<string, string> = {};
86
90
 
91
+ // ── State ────────────────────────────────────────────────────────────────
92
+
87
93
  @state()
88
94
  private hasFocus = false;
89
95
 
@@ -93,14 +99,17 @@ export class Switch extends BaseInput {
93
99
  @state()
94
100
  private slotHasContent = false;
95
101
 
102
+ // ── Queries ──────────────────────────────────────────────────────────────
103
+
96
104
  @query('.track')
97
105
  private trackElement?: HTMLElement;
98
106
 
99
- @query('.input-native')
100
- private nativeElement?: HTMLInputElement;
107
+ // ── Private fields ───────────────────────────────────────────────────────
101
108
 
102
109
  private tabindex?: string;
103
110
 
111
+ // ── Lifecycle ────────────────────────────────────────────────────────────
112
+
104
113
  connectedCallback() {
105
114
  super.connectedCallback();
106
115
  this.handleInitialAttributes();
@@ -118,6 +127,38 @@ export class Switch extends BaseInput {
118
127
  this.slotHasContent = this.hasChildNodes();
119
128
  }
120
129
 
130
+ // ── Public methods ───────────────────────────────────────────────────────
131
+
132
+ /**
133
+ * Sets focus on the toggle.
134
+ */
135
+ focus() {
136
+ this.trackElement?.focus();
137
+ }
138
+
139
+ /**
140
+ * Removes focus from the toggle.
141
+ */
142
+ blur() {
143
+ this.trackElement?.blur();
144
+ }
145
+
146
+ // ── Form association ─────────────────────────────────────────────────────
147
+
148
+ override [getFormValue](): FormValue | null {
149
+ return this.checked ? 'on' : null;
150
+ }
151
+
152
+ override [getFormState](): FormValue | null {
153
+ return String(this.checked);
154
+ }
155
+
156
+ override formStateRestoreCallback(state: FormRestoreState | null) {
157
+ this.checked = state === 'true';
158
+ }
159
+
160
+ // ── Private methods ──────────────────────────────────────────────────────
161
+
121
162
  private handleInitialAttributes() {
122
163
  if (this.hasAttribute('tabindex')) {
123
164
  this.tabindex = this.getAttribute('tabindex') || undefined;
@@ -158,10 +199,14 @@ export class Switch extends BaseInput {
158
199
 
159
200
  private clickHandler = (ev: MouseEvent | KeyboardEvent) => {
160
201
  if (!this.disabled && !this.readonly) {
161
- this.value = !this.value;
202
+ this.checked = !this.checked;
162
203
  this.dispatchEvent(
163
204
  new CustomEvent('change', {
164
- detail: { value: this.value, originalEvent: ev },
205
+ detail: {
206
+ checked: this.checked,
207
+ value: this.checked,
208
+ originalEvent: ev,
209
+ },
165
210
  bubbles: true,
166
211
  composed: true,
167
212
  }),
@@ -198,33 +243,23 @@ export class Switch extends BaseInput {
198
243
  }
199
244
  };
200
245
 
201
- /**
202
- * Sets focus on the toggle.
203
- */
204
- focus() {
205
- this.trackElement?.focus();
206
- }
207
-
208
- /**
209
- * Removes focus from the toggle.
210
- */
211
- blur() {
212
- this.trackElement?.blur();
213
- }
246
+ // ── Render helpers ───────────────────────────────────────────────────────
214
247
 
215
248
  __renderIcon() {
216
249
  if (this.withIcon) {
217
- if (this.value)
250
+ if (this.checked)
218
251
  return html`<wc-icon name="check" class="icon"></wc-icon>`;
219
252
  return html`<wc-icon name="close" class="icon"></wc-icon>`;
220
253
  }
221
254
  return nothing;
222
255
  }
223
256
 
257
+ // ── Render ───────────────────────────────────────────────────────────────
258
+
224
259
  render() {
225
260
  const cssClasses = {
226
261
  switch: true,
227
- 'state-checked': this.value,
262
+ 'state-checked': this.checked,
228
263
  'has-focus': this.hasFocus,
229
264
  active: this.isActive,
230
265
  disabled: this.disabled,
@@ -244,10 +279,10 @@ export class Switch extends BaseInput {
244
279
  @keydown=${this.keyDownHandler}
245
280
  @blur=${this.blurHandler}
246
281
  @focus=${this.focusHandler}
247
- role="checkbox"
282
+ role="switch"
248
283
  aria-disabled=${this.disabled}
249
284
  aria-required=${this.required}
250
- aria-checked=${this.value}
285
+ aria-checked=${this.checked}
251
286
  ${spread(this.configAria)}
252
287
  >
253
288
  <div class="handle">${this.__renderIcon()}</div>
@@ -257,7 +292,7 @@ export class Switch extends BaseInput {
257
292
  type="checkbox"
258
293
  class="input-native"
259
294
  name=${this.name}
260
- .checked=${this.value}
295
+ .checked=${this.checked}
261
296
  aria-hidden="true"
262
297
  ?required=${this.required}
263
298
  tabindex="-1"
package/src/tabs/tab.scss CHANGED
@@ -150,7 +150,8 @@
150
150
  --_container-shape-end-start: var(--shape-corner-small);
151
151
  --_container-shape-end-end: var(--shape-corner-small);
152
152
  --_active-indicator-color: var(--color-primary);
153
- --_active-indicator-shape: 3px 3px 0 0;
153
+ --_active-indicator-shape: var(--shape-corner-extra-small)
154
+ var(--shape-corner-extra-small) 0 0;
154
155
  --_active-indicator-height: 2px;
155
156
 
156
157
  .focus-ring {
package/src/tabs/tabs.ts CHANGED
@@ -13,6 +13,9 @@ import IndividualComponent from '@/IndividualComponent.js';
13
13
  * @overview
14
14
  * <p>Tabs holds the tab buttons and manages their layout.</p>
15
15
  *
16
+ * @fires {CustomEvent<{index: number, value: string}>} change - Dispatched when the user activates a tab.
17
+ * @fires {CustomEvent<{index: number, value: string}>} tab-click - Deprecated alias of `change`, fired alongside it.
18
+ *
16
19
  * @example
17
20
  * ```html
18
21
  * <wc-tabs>
@@ -176,14 +179,17 @@ export class Tabs extends LitElement {
176
179
  this.__animateIndicatorTransition(previousActiveTab, clickedTab);
177
180
  this.__lastActiveTab = clickedTab;
178
181
 
179
- this.dispatchEvent(new CustomEvent('tab-click', {
180
- bubbles: true,
181
- composed: true,
182
- detail: {
183
- index: clickedIndex,
184
- value: (clickedTab as Tab).value,
185
- },
186
- }));
182
+ const detail = {
183
+ index: clickedIndex,
184
+ value: (clickedTab as Tab).value,
185
+ };
186
+ this.dispatchEvent(
187
+ new CustomEvent('change', { bubbles: true, composed: true, detail }),
188
+ );
189
+ // Deprecated name, still what wc-tab-group listens for.
190
+ this.dispatchEvent(
191
+ new CustomEvent('tab-click', { bubbles: true, composed: true, detail }),
192
+ );
187
193
  };
188
194
 
189
195
  render() {
@@ -4,6 +4,7 @@ import { property, query, state } from 'lit/decorators.js';
4
4
  import { redispatchEvent } from '@/__internal/utils/dispatch-event-utils.js';
5
5
  import { spread } from '@/__internal/directive/spread.js';
6
6
 
7
+ import IndividualComponent from '@/IndividualComponent.js';
7
8
  import BaseInput from '../input/BaseInput.js';
8
9
  import styles from './textarea.scss';
9
10
 
@@ -19,15 +20,13 @@ import styles from './textarea.scss';
19
20
  * <wc-textarea label="Description" placeholder="Enter text"></wc-textarea>
20
21
  * ```
21
22
  */
23
+ @IndividualComponent
22
24
  export class Textarea extends BaseInput {
23
25
  static styles = [styles];
24
26
 
25
27
  @property({ type: String })
26
28
  value = '';
27
29
 
28
- @property({ type: String })
29
- name: string = '';
30
-
31
30
  @property({ type: String }) placeholder = '';
32
31
 
33
32
  @property({ type: String }) label = '';