@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
@@ -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 = '';
@@ -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 './time-picker.scss';
9
10
 
@@ -19,15 +20,13 @@ import styles from './time-picker.scss';
19
20
  * <wc-time-picker label="Time" placeholder="Select a time"></wc-time-picker>
20
21
  * ```
21
22
  */
23
+ @IndividualComponent
22
24
  export class TimePicker 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 = '';
@@ -81,20 +81,20 @@
81
81
  }
82
82
 
83
83
  /* Size variants */
84
- &.size-small {
84
+ &.size-sm {
85
85
  --toolbar-height: 5rem;
86
86
  }
87
87
 
88
- &.size-medium {
88
+ &.size-md {
89
89
  --toolbar-height: 6rem;
90
90
  }
91
91
 
92
- &.size-large {
92
+ &.size-lg {
93
93
  --toolbar-height: 7rem;
94
94
  }
95
95
 
96
96
  &.elevated {
97
- --toolbar-shadow: var(--elevation-shadow-level-3, 0 4px 8px rgba(0, 0, 0, 0.15));
97
+ --toolbar-shadow: var(--elevation-level3);
98
98
  }
99
99
  }
100
100
 
@@ -2,6 +2,11 @@
2
2
  import { property } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import IndividualComponent from '@/IndividualComponent.js';
5
+ import {
6
+ type LegacySize,
7
+ normalizeSize,
8
+ type Size,
9
+ } from '@/__internal/utils/size.js';
5
10
  import styles from './toolbar.scss';
6
11
  import colorStyles from './toolbar-colors.scss';
7
12
 
@@ -83,12 +88,14 @@ export class Toolbar extends LitElement {
83
88
 
84
89
  /**
85
90
  * Size of the docked toolbar.
86
- * - `"small"`: 80dp height (default).
87
- * - `"medium"`: 96dp height.
88
- * - `"large"`: 112dp height.
91
+ * - `"sm"`: 80dp height (default).
92
+ * - `"md"`: 96dp height.
93
+ * - `"lg"`: 112dp height.
94
+ *
95
+ * The long names `"small"`, `"medium"` and `"large"` still work but are deprecated.
89
96
  */
90
97
  @property({ type: String, reflect: true })
91
- size: 'small' | 'medium' | 'large' = 'small';
98
+ size: Size | LegacySize = 'sm';
92
99
 
93
100
  /**
94
101
  * Whether the toolbar is visually elevated (adds a shadow).
@@ -101,7 +108,7 @@ export class Toolbar extends LitElement {
101
108
  toolbar: true,
102
109
  [`variant-${this.variant}`]: true,
103
110
  [`orientation-${this.orientation}`]: true,
104
- [`size-${this.size}`]: true,
111
+ [`size-${normalizeSize(this.size, 'sm')}`]: true,
105
112
  elevated: this.elevated,
106
113
  };
107
114
 
@@ -3,6 +3,7 @@ import { property, query, state } from 'lit/decorators.js';
3
3
 
4
4
  import { redispatchEvent } from '@/__internal/utils/dispatch-event-utils.js';
5
5
 
6
+ import IndividualComponent from '@/IndividualComponent.js';
6
7
  import BaseInput from '../input/BaseInput.js';
7
8
  import styles from './url-field.scss';
8
9
 
@@ -21,15 +22,13 @@ import styles from './url-field.scss';
21
22
  * ```
22
23
  * @tags form
23
24
  */
25
+ @IndividualComponent
24
26
  export class UrlField extends BaseInput {
25
27
  static styles = [styles];
26
28
 
27
29
  @property({ type: String })
28
30
  value: string = '';
29
31
 
30
- @property({ type: String })
31
- name: string = '';
32
-
33
32
  @property({ type: String })
34
33
  placeholder: string = '';
35
34
 
@@ -1,27 +0,0 @@
1
- import { _ as __decorate, a as i } from './IndividualComponent-Bdwyrvd6.js';
2
- import { n } from './property-B49QQ8pS.js';
3
-
4
- class BaseInput extends i {
5
- constructor() {
6
- super(...arguments);
7
- this.disabled = false;
8
- this.readonly = false;
9
- this.required = false;
10
- this.skeleton = false;
11
- }
12
- }
13
- __decorate([
14
- n({ type: Boolean, reflect: true })
15
- ], BaseInput.prototype, "disabled", void 0);
16
- __decorate([
17
- n({ type: Boolean, reflect: true })
18
- ], BaseInput.prototype, "readonly", void 0);
19
- __decorate([
20
- n({ type: Boolean, reflect: true })
21
- ], BaseInput.prototype, "required", void 0);
22
- __decorate([
23
- n({ type: Boolean, reflect: true })
24
- ], BaseInput.prototype, "skeleton", void 0);
25
-
26
- export { BaseInput as B };
27
- //# sourceMappingURL=BaseInput-CU1zZYKc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseInput-CU1zZYKc.js","sources":["../../src/input/BaseInput.ts"],"sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nexport default abstract class BaseInput extends LitElement {\n value?: any;\n\n @property({ type: Boolean, reflect: true })\n disabled: boolean = false;\n\n @property({ type: Boolean, reflect: true })\n readonly: boolean = false;\n\n @property({ type: Boolean, reflect: true })\n required: boolean = false;\n\n @property({ type: Boolean, reflect: true })\n skeleton = false;\n}\n"],"names":["LitElement","property"],"mappings":";;;AAGc,MAAgB,SAAU,SAAQA,CAAU,CAAA;AAA1D,IAAA,WAAA,GAAA;;QAIE,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGzB,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGzB,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGzB,IAAA,CAAA,QAAQ,GAAG,KAAK;IAClB;AAAC;AAVC,UAAA,CAAA;IADCC,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACzB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;;;;"}