@redvars/peacock 4.7.0 → 4.8.1

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 (300) hide show
  1. package/dist/accordion-item.js +4 -4
  2. package/dist/app-bar.js +1 -1
  3. package/dist/app-shell.js +2 -2
  4. package/dist/assets/styles.css +1 -1
  5. package/dist/assets/styles.css.map +1 -1
  6. package/dist/assets/theme.d.ts +2 -0
  7. package/dist/assets/theme.js +49 -29
  8. package/dist/assets/tokens.css +1 -1
  9. package/dist/assets/tokens.css.map +1 -1
  10. package/dist/bottom-sheet.js +3 -3
  11. package/dist/breadcrumb-item.js +1 -1
  12. package/dist/button-group.js +79 -0
  13. package/dist/button-group.js.map +1 -1
  14. package/dist/button.js +26 -25
  15. package/dist/button.js.map +1 -1
  16. package/dist/calendar-column-view.js +3 -3
  17. package/dist/calendar-month-view.js +3 -3
  18. package/dist/calendar-timeline.js +3 -3
  19. package/dist/card.js +2 -1
  20. package/dist/card.js.map +1 -1
  21. package/dist/carousel.js +182 -7
  22. package/dist/carousel.js.map +1 -1
  23. package/dist/{cartesian-chart-C8qKDXo8.js → cartesian-chart-UW1CYKRS.js} +2 -2
  24. package/dist/{cartesian-chart-C8qKDXo8.js.map → cartesian-chart-UW1CYKRS.js.map} +1 -1
  25. package/dist/cb-group.js +1 -1
  26. package/dist/chart-area.js +2 -2
  27. package/dist/chart-bar.js +2 -2
  28. package/dist/{chart-base-BpQMZZsw.js → chart-base-D5ujPGcl.js} +3 -3
  29. package/dist/{chart-base-BpQMZZsw.js.map → chart-base-D5ujPGcl.js.map} +1 -1
  30. package/dist/chart-doughnut.js +1 -1
  31. package/dist/chart-line.js +2 -2
  32. package/dist/chart-pie.js +2 -2
  33. package/dist/checkbox.js +7 -6
  34. package/dist/checkbox.js.map +1 -1
  35. package/dist/chip.js +34 -8
  36. package/dist/chip.js.map +1 -1
  37. package/dist/circular-progress.js +46 -15
  38. package/dist/circular-progress.js.map +1 -1
  39. package/dist/code-highlighter.js +1 -1
  40. package/dist/color-picker.js +1 -1
  41. package/dist/command-palette.js +2 -2
  42. package/dist/comment-composer.js +5 -5
  43. package/dist/condition-builder.js +1 -1
  44. package/dist/{condition-group-base-NcvOY-Zv.js → condition-group-base-DS76sprm.js} +2 -2
  45. package/dist/{condition-group-base-NcvOY-Zv.js.map → condition-group-base-DS76sprm.js.map} +1 -1
  46. package/dist/confirm-dialog.js +2 -2
  47. package/dist/custom-elements-jsdocs.json +302 -10
  48. package/dist/custom-elements.json +1209 -16
  49. package/dist/date-picker.js +51 -1
  50. package/dist/date-picker.js.map +1 -1
  51. package/dist/dependency-map.js +2 -2
  52. package/dist/{diagram-hv7hCgzx.js → diagram-DFO-X7yq.js} +2 -2
  53. package/dist/{diagram-hv7hCgzx.js.map → diagram-DFO-X7yq.js.map} +1 -1
  54. package/dist/diagram.js +1 -1
  55. package/dist/discussion.js +3 -3
  56. package/dist/{document-editor-CZBlz3ai.js → document-editor-W4pXGCEL.js} +19 -7
  57. package/dist/document-editor-W4pXGCEL.js.map +1 -0
  58. package/dist/document-editor.js +3 -3
  59. package/dist/dropdown-button.js +1 -1
  60. package/dist/erd.js +4 -4
  61. package/dist/fab-menu-item.js +189 -0
  62. package/dist/fab-menu-item.js.map +1 -0
  63. package/dist/fab-menu.js +329 -0
  64. package/dist/fab-menu.js.map +1 -0
  65. package/dist/fab.js +28 -17
  66. package/dist/fab.js.map +1 -1
  67. package/dist/field.js +1 -1
  68. package/dist/file-upload.js +1 -1
  69. package/dist/flow.js +1 -1
  70. package/dist/haptics-CAaQ2E-9.js +29 -0
  71. package/dist/haptics-CAaQ2E-9.js.map +1 -0
  72. package/dist/hover-card.js +5 -3
  73. package/dist/hover-card.js.map +1 -1
  74. package/dist/html-editor.js +4 -4
  75. package/dist/icon-button.js +26 -25
  76. package/dist/icon-button.js.map +1 -1
  77. package/dist/{index-DK3fREuj.js → index-BBxpsqx8.js} +4 -4
  78. package/dist/{index-DK3fREuj.js.map → index-BBxpsqx8.js.map} +1 -1
  79. package/dist/{index-CTEt3LtO.js → index-CDtKB0In.js} +4 -4
  80. package/dist/{index-CTEt3LtO.js.map → index-CDtKB0In.js.map} +1 -1
  81. package/dist/{index-Bag4vtx-.js → index-Tb0ky27z.js} +3 -3
  82. package/dist/{index-Bag4vtx-.js.map → index-Tb0ky27z.js.map} +1 -1
  83. package/dist/index.js +17 -13
  84. package/dist/index.js.map +1 -1
  85. package/dist/{indicator-navigation-item-BG0TrdDE.js → indicator-navigation-item-aZsm-RpR.js} +17 -5
  86. package/dist/{indicator-navigation-item-BG0TrdDE.js.map → indicator-navigation-item-aZsm-RpR.js.map} +1 -1
  87. package/dist/inline-edit.js +1 -1
  88. package/dist/json-viewer.js +1 -1
  89. package/dist/linear-progress.js +51 -4
  90. package/dist/linear-progress.js.map +1 -1
  91. package/dist/link-button.js +26 -25
  92. package/dist/link-button.js.map +1 -1
  93. package/dist/loader-full.js +10 -6
  94. package/dist/loader-full.js.map +1 -1
  95. package/dist/loader.js +19 -6
  96. package/dist/loader.js.map +1 -1
  97. package/dist/loading-indicator.js +301 -0
  98. package/dist/loading-indicator.js.map +1 -0
  99. package/dist/markdown-editor.js +4 -4
  100. package/dist/mention-input.js +1 -1
  101. package/dist/menu.js +8 -6
  102. package/dist/menu.js.map +1 -1
  103. package/dist/{modal-Dds0rXAG.js → modal-ClWCCbxD.js} +7 -5
  104. package/dist/{modal-Dds0rXAG.js.map → modal-ClWCCbxD.js.map} +1 -1
  105. package/dist/modal.js +14 -3
  106. package/dist/modal.js.map +1 -1
  107. package/dist/navigation-bar-item.js +1 -1
  108. package/dist/navigation-bar.js +1 -1
  109. package/dist/navigation-drawer-group.js +1 -1
  110. package/dist/navigation-drawer.js +1 -1
  111. package/dist/navigation-rail-item.js +1 -1
  112. package/dist/navigation-rail.js +1 -1
  113. package/dist/notification-center.js +1 -1
  114. package/dist/number-counter.js +1 -1
  115. package/dist/{overlay-controller-BOk-kfil.js → overlay-controller-iVaiUqos.js} +20 -10
  116. package/dist/{overlay-controller-BOk-kfil.js.map → overlay-controller-iVaiUqos.js.map} +1 -1
  117. package/dist/pagination.js +1 -1
  118. package/dist/popover-content.js +4 -2
  119. package/dist/popover-content.js.map +1 -1
  120. package/dist/popover.js +1 -1
  121. package/dist/{progress-base-BhJK__VP.js → progress-base-BeLu9-Tq.js} +13 -1
  122. package/dist/progress-base-BeLu9-Tq.js.map +1 -0
  123. package/dist/prompt-input.js +5 -5
  124. package/dist/radio.js +6 -4
  125. package/dist/radio.js.map +1 -1
  126. package/dist/resizable-panels.js +1 -1
  127. package/dist/{rich-text-input-base-SrsPvc-j.js → rich-text-input-base-BCmnkpuV.js} +2 -2
  128. package/dist/{rich-text-input-base-SrsPvc-j.js.map → rich-text-input-base-BCmnkpuV.js.map} +1 -1
  129. package/dist/scroll-area.js +1 -1
  130. package/dist/search.js +1 -1
  131. package/dist/segmented-button.js +7 -2
  132. package/dist/segmented-button.js.map +1 -1
  133. package/dist/select.js +1 -1
  134. package/dist/side-sheet.js +3 -3
  135. package/dist/site-header.js +3 -3
  136. package/dist/site-nav-menu.js +1 -1
  137. package/dist/{slash-controller-DwL0nkqv.js → slash-controller-BFhzSjiR.js} +2 -2
  138. package/dist/{slash-controller-DwL0nkqv.js.map → slash-controller-BFhzSjiR.js.map} +1 -1
  139. package/dist/slider.js +169 -69
  140. package/dist/slider.js.map +1 -1
  141. package/dist/snackbar.js +2 -2
  142. package/dist/sparkline.js +2 -2
  143. package/dist/split-button.js +1 -1
  144. package/dist/src/__internal/utils/haptics.d.ts +7 -0
  145. package/dist/src/button/button-group/button-group.d.ts +12 -0
  146. package/dist/src/button/fab/fab.d.ts +1 -0
  147. package/dist/src/carousel/carousel.d.ts +22 -0
  148. package/dist/src/chip/chip/chip.d.ts +4 -0
  149. package/dist/src/date-picker/date-picker.d.ts +6 -1
  150. package/dist/src/document-editor/document-editor.d.ts +2 -0
  151. package/dist/src/fab-menu/fab-menu-item.d.ts +30 -0
  152. package/dist/src/fab-menu/fab-menu.d.ts +64 -0
  153. package/dist/src/fab-menu/index.d.ts +2 -0
  154. package/dist/src/index.d.ts +3 -0
  155. package/dist/src/loading-indicator/index.d.ts +1 -0
  156. package/dist/src/loading-indicator/loading-indicator.d.ts +44 -0
  157. package/dist/src/loading-indicator/shapes.d.ts +29 -0
  158. package/dist/src/modal/modal.d.ts +4 -0
  159. package/dist/src/progress/circular-progress/circular-progress.d.ts +3 -1
  160. package/dist/src/progress/linear-progress/linear-progress.d.ts +2 -1
  161. package/dist/src/progress/progress-base.d.ts +7 -0
  162. package/dist/src/slider/slider.d.ts +23 -3
  163. package/dist/src/toolbar/toolbar.d.ts +20 -0
  164. package/dist/step.js +1 -1
  165. package/dist/switch.js +7 -3
  166. package/dist/switch.js.map +1 -1
  167. package/dist/tab-group.js +13 -2
  168. package/dist/tab-group.js.map +1 -1
  169. package/dist/tab-panel.js +26 -0
  170. package/dist/tab-panel.js.map +1 -1
  171. package/dist/tab.js +23 -5
  172. package/dist/tab.js.map +1 -1
  173. package/dist/table.js +4 -4
  174. package/dist/tag.js +2 -1
  175. package/dist/tag.js.map +1 -1
  176. package/dist/test/button-group-press.test.d.ts +1 -0
  177. package/dist/test/fab-menu.test.d.ts +1 -0
  178. package/dist/test/haptics.test.d.ts +1 -0
  179. package/dist/test/loading-indicator.test.d.ts +1 -0
  180. package/dist/{toggle-base-DP3PSXbf.js → toggle-base-CVO9YntI.js} +3 -1
  181. package/dist/toggle-base-CVO9YntI.js.map +1 -0
  182. package/dist/toolbar.js +102 -0
  183. package/dist/toolbar.js.map +1 -1
  184. package/dist/tooltip.js +5 -2
  185. package/dist/tooltip.js.map +1 -1
  186. package/dist/tour.js +3 -3
  187. package/dist/tree-chart.js +3 -3
  188. package/dist/tree-item.js +1 -1
  189. package/dist/tsconfig.tsbuildinfo +1 -1
  190. package/dist/{video-DgtGGvrk.js → video-DSQ07o3h.js} +2 -2
  191. package/dist/{video-DgtGGvrk.js.map → video-DSQ07o3h.js.map} +1 -1
  192. package/dist/video.js +1 -1
  193. package/dist/workflow.js +5 -5
  194. package/package.json +1 -1
  195. package/scss/tokens.css +364 -0
  196. package/src/__internal/chart/chart-base.scss +4 -2
  197. package/src/__internal/controllers/overlay-controller.ts +19 -9
  198. package/src/__internal/rich-text/editor-chrome.scss +2 -1
  199. package/src/__internal/toggle-base.ts +2 -0
  200. package/src/__internal/utils/haptics.ts +32 -0
  201. package/src/accordion/accordion-item.scss +10 -6
  202. package/src/app-bar/app-bar.scss +2 -1
  203. package/src/app-shell/app-shell.scss +2 -2
  204. package/src/bottom-sheet/bottom-sheet.scss +4 -2
  205. package/src/breadcrumb/breadcrumb-item/breadcrumb-item.scss +4 -2
  206. package/src/button/button/button-base.scss +14 -12
  207. package/src/button/button/button-layers.scss +27 -5
  208. package/src/button/button-group/button-group.scss +6 -0
  209. package/src/button/button-group/button-group.ts +105 -0
  210. package/src/button/fab/fab-sizes.scss +2 -0
  211. package/src/button/fab/fab.scss +32 -17
  212. package/src/button/fab/fab.ts +1 -0
  213. package/src/calendar/calendar-column-view.scss +3 -3
  214. package/src/calendar/calendar-month-view.scss +3 -3
  215. package/src/calendar-timeline/calendar-timeline.scss +6 -3
  216. package/src/card/card.scss +2 -1
  217. package/src/carousel/carousel.scss +71 -2
  218. package/src/carousel/carousel.ts +159 -7
  219. package/src/chart-pie/chart-pie.scss +4 -2
  220. package/src/checkbox/checkbox.scss +13 -7
  221. package/src/chip/chip/chip.scss +41 -8
  222. package/src/chip/chip/chip.ts +4 -0
  223. package/src/chip/tag/tag.scss +2 -1
  224. package/src/code-highlighter/code-highlighter.scss +2 -1
  225. package/src/color-picker/color-picker.scss +1 -1
  226. package/src/comment-composer/comment-composer.scss +2 -1
  227. package/src/components.manifest.json +21 -0
  228. package/src/condition-builder/condition-group-base.scss +1 -1
  229. package/src/date-picker/date-picker.scss +27 -0
  230. package/src/date-picker/date-picker.ts +27 -1
  231. package/src/dependency-map/dependency-map.scss +4 -2
  232. package/src/diagram/diagram.scss +2 -1
  233. package/src/document-editor/document-editor.scss +1 -1
  234. package/src/document-editor/document-editor.ts +17 -0
  235. package/src/dropdown-button/dropdown-button.scss +2 -1
  236. package/src/erd/erd.scss +8 -4
  237. package/src/fab-menu/fab-menu-item.scss +99 -0
  238. package/src/fab-menu/fab-menu-item.ts +58 -0
  239. package/src/fab-menu/fab-menu.scss +119 -0
  240. package/src/fab-menu/fab-menu.ts +195 -0
  241. package/src/fab-menu/index.ts +2 -0
  242. package/src/field/field.scss +1 -1
  243. package/src/file-upload/file-upload.scss +2 -2
  244. package/src/hover-card/hover-card.scss +9 -2
  245. package/src/index.ts +3 -0
  246. package/src/inline-edit/inline-edit.scss +2 -2
  247. package/src/json-viewer/json-viewer.scss +2 -1
  248. package/src/loader.ts +12 -0
  249. package/src/loading-indicator/index.ts +1 -0
  250. package/src/loading-indicator/loading-indicator.scss +52 -0
  251. package/src/loading-indicator/loading-indicator.ts +164 -0
  252. package/src/loading-indicator/shapes.ts +104 -0
  253. package/src/menu/menu/menu.scss +10 -6
  254. package/src/modal/modal.scss +8 -4
  255. package/src/modal/modal.ts +14 -1
  256. package/src/navigation-drawer/navigation-drawer-group.scss +2 -2
  257. package/src/navigation-drawer/navigation-drawer.scss +3 -2
  258. package/src/navigation-rail/navigation-rail-item.scss +27 -5
  259. package/src/number-counter/number-counter.scss +1 -1
  260. package/src/pagination/pagination.scss +2 -1
  261. package/src/popover/popover-content.scss +7 -2
  262. package/src/progress/circular-progress/circular-progress.scss +3 -2
  263. package/src/progress/circular-progress/circular-progress.ts +43 -12
  264. package/src/progress/linear-progress/linear-progress.scss +70 -2
  265. package/src/progress/linear-progress/linear-progress.ts +4 -1
  266. package/src/progress/progress-base.ts +11 -0
  267. package/src/prompt-input/prompt-input.scss +2 -1
  268. package/src/radio/radio.scss +8 -4
  269. package/src/radio/radio.ts +2 -0
  270. package/src/resizable-panels/resizable-panels.scss +2 -1
  271. package/src/scroll-area/scroll-area.scss +2 -1
  272. package/src/search/search.scss +2 -1
  273. package/src/segmented-button/segmented-button.scss +8 -3
  274. package/src/select/select.scss +2 -1
  275. package/src/side-sheet/side-sheet.scss +4 -2
  276. package/src/site-header/site-header.scss +4 -4
  277. package/src/site-header/site-nav-menu.scss +2 -2
  278. package/src/slider/slider.scss +127 -64
  279. package/src/slider/slider.ts +80 -10
  280. package/src/snackbar/snackbar.scss +5 -2
  281. package/src/sparkline/sparkline.scss +6 -3
  282. package/src/split-button/split-button.scss +4 -2
  283. package/src/stepper/step.scss +2 -1
  284. package/src/switch/switch.scss +21 -2
  285. package/src/table/table.scss +8 -4
  286. package/src/tabs/tab-group.ts +12 -2
  287. package/src/tabs/tab-panel.scss +31 -0
  288. package/src/tabs/tab.scss +28 -17
  289. package/src/toolbar/toolbar-colors.scss +11 -0
  290. package/src/toolbar/toolbar.scss +28 -0
  291. package/src/toolbar/toolbar.ts +74 -1
  292. package/src/tooltip/tooltip.scss +9 -3
  293. package/src/tour/tour.scss +2 -2
  294. package/src/tree/tree-item.scss +2 -1
  295. package/src/tree-chart/tree-chart.scss +3 -3
  296. package/src/video/video.scss +2 -1
  297. package/src/workflow/workflow.scss +5 -5
  298. package/dist/document-editor-CZBlz3ai.js.map +0 -1
  299. package/dist/progress-base-BhJK__VP.js.map +0 -1
  300. package/dist/toggle-base-DP3PSXbf.js.map +0 -1
@@ -3,13 +3,20 @@ import { property, state, query } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { styleMap } from 'lit/directives/style-map.js';
5
5
  import type { FormRestoreState } from '@/__internal/mixins/form-associated.js';
6
- import type { Size } from '@/__internal/utils/size.js';
6
+ import type { ScaleSize } from '@/__internal/utils/size.js';
7
7
  import InputBase, { type ControlValidity } from '@/__internal/input-base.js';
8
8
  import sliderStyles from './slider.scss';
9
9
  import { I18nController } from '@/__internal/i18n/i18n-controller.js';
10
+ import { haptic } from '../__internal/utils/haptics.js';
10
11
 
11
12
  let sliderCount = 0;
12
13
 
14
+ /** Handle half-width plus the gap on each side of it, in px (matches `--_handle-space`). */
15
+ const HANDLE_SPACE_PX = 8;
16
+
17
+ /** Room the inset icon needs on the active track: icon plus inset on both sides, in px. */
18
+ const ICON_ROOM = { md: 40, lg: 48, xl: 64 } as const;
19
+
13
20
  /** Where the slider shows its value: on the thumb while it is used, after the track, or not. */
14
21
  export type SliderValueLabel = 'thumb' | 'end' | 'none';
15
22
 
@@ -29,6 +36,8 @@ export type SliderValueLabel = 'thumb' | 'end' | 'none';
29
36
  * <code>v =&gt; `${v}%`</code>.</p>
30
37
  * <p><code>required</code> does not apply: a slider always has a value. <code>readonly</code> keeps
31
38
  * it focusable but its value cannot change.</p>
39
+ * <p>The look follows Material 3 Expressive: a thick track split around a slim handle, a stop
40
+ * dot at the end, five <code>size</code>s, and an optional <code>icon</code> inside the track.</p>
32
41
  * <p>Keyboard: the arrows move one step (ten with Shift), Page Up and Page Down move ten steps,
33
42
  * Home and End go to <code>min</code> and <code>max</code>.</p>
34
43
  *
@@ -93,8 +102,17 @@ export class Slider extends InputBase {
93
102
  /** Error message shown below the slider while `error` is set; replaces the help text. */
94
103
  @property({ type: String, attribute: 'error-text' }) errorText = '';
95
104
 
96
- /** Size of the track and thumb: `sm` (default), `md` or `lg`. */
97
- @property({ type: String, reflect: true }) size: Size = 'sm';
105
+ /**
106
+ * Size of the track and handle, from the M3 Expressive scale: `xs` (16px track, the default),
107
+ * `sm` (24px), `md` (40px), `lg` (56px) or `xl` (96px).
108
+ */
109
+ @property({ type: String, reflect: true }) size: ScaleSize = 'xs';
110
+
111
+ /**
112
+ * Name of an icon shown inside the track, at its start (`md` and larger). It sits on the active
113
+ * part while it fits there, else just after the handle.
114
+ */
115
+ @property({ type: String }) icon?: string;
98
116
 
99
117
  /**
100
118
  * Where the value shows: `thumb` (on the thumb while it is used; the default), `end` (after the
@@ -112,6 +130,11 @@ export class Slider extends InputBase {
112
130
  /** True while the user is actively dragging the thumb. */
113
131
  @state() private isDragging = false;
114
132
 
133
+ /** Width of the track in px, for placing the inset icon. */
134
+ @state() private trackWidth = 0;
135
+
136
+ private resizeObserver?: ResizeObserver;
137
+
115
138
  // ── Queries ──────────────────────────────────────────────────────────────
116
139
 
117
140
  @query('.slider-container') private container!: HTMLElement;
@@ -138,6 +161,19 @@ export class Slider extends InputBase {
138
161
  super.connectedCallback();
139
162
  }
140
163
 
164
+ override firstUpdated() {
165
+ this.resizeObserver = new ResizeObserver(([entry]) => {
166
+ this.trackWidth = entry.contentRect.width;
167
+ });
168
+ this.resizeObserver.observe(this.container);
169
+ }
170
+
171
+ override disconnectedCallback() {
172
+ super.disconnectedCallback();
173
+ this.resizeObserver?.disconnect();
174
+ this.resizeObserver = undefined;
175
+ }
176
+
141
177
  // ── Public methods ───────────────────────────────────────────────────────
142
178
 
143
179
  override focus() {
@@ -220,7 +256,11 @@ export class Slider extends InputBase {
220
256
  const oldValue = this.value;
221
257
  this.value = Math.max(this.min, Math.min(this.max, steppedValue));
222
258
 
223
- if (oldValue !== this.value) this.emit('input');
259
+ if (oldValue !== this.value) {
260
+ // A tick per step on a stepped slider; a near-continuous one stays quiet.
261
+ if ((this.max - this.min) / this.step <= 20) haptic('tick');
262
+ this.emit('input');
263
+ }
224
264
  }
225
265
 
226
266
  private onMouseDown(e: MouseEvent | TouchEvent) {
@@ -319,6 +359,27 @@ export class Slider extends InputBase {
319
359
 
320
360
  // ── Render ───────────────────────────────────────────────────────────────
321
361
 
362
+ /**
363
+ * The inset icon: on the active part of the track while it fits there, else on the inactive part
364
+ * just after the handle. Shown from `md` up, where the track is tall enough.
365
+ */
366
+ private renderIcon(percentage: number) {
367
+ if (!this.icon || !['md', 'lg', 'xl'].includes(this.size)) return nothing;
368
+ const iconSpace = ICON_ROOM[this.size as 'md' | 'lg' | 'xl'];
369
+ const activeWidth = (percentage / 100) * this.trackWidth - HANDLE_SPACE_PX;
370
+ const onActive = activeWidth >= iconSpace;
371
+ return html`<wc-icon
372
+ class=${classMap({ 'track-icon': true, 'on-active': onActive })}
373
+ name=${this.icon}
374
+ aria-hidden="true"
375
+ style=${styleMap({
376
+ left: onActive
377
+ ? 'var(--_icon-inset)'
378
+ : `calc(${percentage}% + var(--_handle-space) + var(--_icon-inset))`,
379
+ })}
380
+ ></wc-icon>`;
381
+ }
382
+
322
383
  render() {
323
384
  const { value } = this;
324
385
  const range = this.max - this.min;
@@ -352,12 +413,21 @@ export class Slider extends InputBase {
352
413
  @mousedown=${this.onMouseDown}
353
414
  @touchstart=${this.onMouseDown}
354
415
  >
355
- <div class="track">
356
- <div
357
- class="track-active"
358
- style=${styleMap({ width: `${percentage}%` })}
359
- ></div>
416
+ <div
417
+ class="track track-active"
418
+ style=${styleMap({
419
+ width: `max(0px, calc(${percentage}% - var(--_handle-space)))`,
420
+ })}
421
+ ></div>
422
+ <div
423
+ class="track track-inactive"
424
+ style=${styleMap({
425
+ left: `calc(${percentage}% + var(--_handle-space))`,
426
+ })}
427
+ >
428
+ ${percentage < 100 ? html`<span class="stop"></span>` : nothing}
360
429
  </div>
430
+ ${this.renderIcon(percentage)}
361
431
 
362
432
  <div
363
433
  class="thumb"
@@ -374,7 +444,7 @@ export class Slider extends InputBase {
374
444
  aria-readonly=${this.readonly ? 'true' : nothing}
375
445
  aria-invalid=${invalid ? 'true' : nothing}
376
446
  style=${styleMap({
377
- left: `calc(${percentage}% - var(--thumb-half))`,
447
+ left: `calc(${percentage}% - var(--_handle-width) / 2)`,
378
448
  })}
379
449
  @keydown=${this.handleKeyDown}
380
450
  >
@@ -73,13 +73,16 @@
73
73
  }
74
74
 
75
75
  .snackbar.open {
76
- animation: snackbar-enter var(--duration-medium1, 300ms) var(--easing-standard, cubic-bezier(0.2, 0, 0, 1)) both;
76
+ // M3 Expressive: it rises in on the default spatial spring and fades out without overshoot.
77
+ animation: snackbar-enter var(--motion-spring-default-spatial-duration, 300ms)
78
+ var(--motion-spring-default-spatial-easing, cubic-bezier(0.2, 0, 0, 1)) both;
77
79
  display: inline-flex;
78
80
  pointer-events: auto;
79
81
  }
80
82
 
81
83
  .snackbar.open.dismissing {
82
- animation: snackbar-exit var(--duration-short2, 150ms) var(--easing-standard, cubic-bezier(0.2, 0, 0, 1)) forwards;
84
+ animation: snackbar-exit var(--motion-spring-fast-effects-duration, 150ms)
85
+ var(--motion-spring-fast-effects-easing, cubic-bezier(0.2, 0, 0, 1)) forwards;
83
86
  pointer-events: none;
84
87
  }
85
88
 
@@ -73,13 +73,16 @@
73
73
  @media (prefers-reduced-motion: no-preference) {
74
74
  .line,
75
75
  .area {
76
- transition: d var(--duration-medium, 250ms) var(--easing-standard, ease);
76
+ transition: d var(--motion-spring-default-effects-duration)
77
+ var(--motion-spring-default-effects-easing);
77
78
  }
78
79
 
79
80
  .bar {
80
81
  transition:
81
- y var(--duration-medium, 250ms) var(--easing-standard, ease),
82
- height var(--duration-medium, 250ms) var(--easing-standard, ease);
82
+ y var(--motion-spring-default-effects-duration)
83
+ var(--motion-spring-default-effects-easing),
84
+ height var(--motion-spring-default-effects-duration)
85
+ var(--motion-spring-default-effects-easing);
83
86
  }
84
87
  }
85
88
 
@@ -67,8 +67,10 @@
67
67
  );
68
68
  translate: var(--_optical-offset) 0;
69
69
  transition:
70
- transform 200ms var(--easing-standard),
71
- translate 200ms var(--easing-standard);
70
+ transform var(--motion-spring-fast-spatial-duration)
71
+ var(--motion-spring-fast-spatial-easing),
72
+ translate var(--motion-spring-fast-spatial-duration)
73
+ var(--motion-spring-fast-spatial-easing);
72
74
  }
73
75
 
74
76
  :host(:dir(rtl)) .dropdown-icon {
@@ -56,7 +56,8 @@
56
56
  background: var(--color-on-surface);
57
57
  opacity: 0;
58
58
  pointer-events: none;
59
- transition: opacity var(--duration-short4) var(--easing-standard);
59
+ transition: opacity var(--motion-spring-fast-effects-duration)
60
+ var(--motion-spring-fast-effects-easing);
60
61
  }
61
62
 
62
63
  &:hover::before {
@@ -39,7 +39,11 @@
39
39
  border-radius: var(--shape-corner-full);
40
40
  cursor: pointer;
41
41
  display: flex;
42
- transition: background-color var(--duration-short2) var(--easing-standard);
42
+ transition:
43
+ background-color var(--motion-spring-fast-effects-duration)
44
+ var(--motion-spring-fast-effects-easing),
45
+ border-color var(--motion-spring-fast-effects-duration)
46
+ var(--motion-spring-fast-effects-easing);
43
47
  align-items: center;
44
48
 
45
49
  width: var(--_container-width);
@@ -51,7 +55,17 @@
51
55
  align-items: center;
52
56
  justify-content: center;
53
57
  border-radius: var(--shape-corner-full);
54
- transition: all var(--duration-short2) var(--easing-standard);
58
+ // The handle slides and grows on the fast spatial spring, so it
59
+ // overshoots a little when toggled or pressed.
60
+ transition:
61
+ margin-inline-start var(--motion-spring-fast-spatial-duration)
62
+ var(--motion-spring-fast-spatial-easing),
63
+ width var(--motion-spring-fast-spatial-duration)
64
+ var(--motion-spring-fast-spatial-easing),
65
+ height var(--motion-spring-fast-spatial-duration)
66
+ var(--motion-spring-fast-spatial-easing),
67
+ background-color var(--motion-spring-fast-effects-duration)
68
+ var(--motion-spring-fast-effects-easing);
55
69
  height: var(--switch-handle-radius);
56
70
  width: var(--switch-handle-radius);
57
71
  background: var(--switch-handle-color);
@@ -113,6 +127,11 @@
113
127
  --switch-handle-radius: 22px;
114
128
  --switch-handle-color: var(--color-surface-container-lowest);
115
129
  }
130
+
131
+ // Pressing grows the handle, in both states.
132
+ &.active:not(.disabled, .readonly) {
133
+ --switch-handle-radius: 26px;
134
+ }
116
135
  }
117
136
 
118
137
  .switch.readonly {
@@ -177,7 +177,8 @@
177
177
  wc-icon {
178
178
  --icon-size: 1.25rem;
179
179
  font-size: 1.25rem;
180
- transition: transform var(--duration-short4, 200ms) ease;
180
+ transition: transform var(--motion-spring-fast-spatial-duration)
181
+ var(--motion-spring-fast-spatial-easing);
181
182
  }
182
183
 
183
184
  &[aria-expanded='true'] wc-icon {
@@ -459,7 +460,8 @@
459
460
  --icon-size: 1.125rem;
460
461
  font-size: 1.125rem;
461
462
  opacity: 0;
462
- transition: opacity var(--duration-short2, 100ms) ease;
463
+ transition: opacity var(--motion-spring-fast-effects-duration)
464
+ var(--motion-spring-fast-effects-easing);
463
465
 
464
466
  .sort-button:hover &,
465
467
  .sort-button:focus-visible & {
@@ -505,7 +507,8 @@
505
507
  inset-inline-end: 0;
506
508
  inline-size: 2px;
507
509
  background: var(--table-border-color);
508
- transition: background var(--duration-short2, 100ms) ease;
510
+ transition: background var(--motion-spring-fast-effects-duration)
511
+ var(--motion-spring-fast-effects-easing);
509
512
  }
510
513
 
511
514
  &:hover::after,
@@ -667,7 +670,8 @@
667
670
  );
668
671
  pointer-events: none;
669
672
  opacity: 0;
670
- transition: opacity var(--duration-short4, 200ms) ease;
673
+ transition: opacity var(--motion-spring-fast-effects-duration)
674
+ var(--motion-spring-fast-effects-easing);
671
675
  }
672
676
 
673
677
  .pinned-group-start::after {
@@ -137,9 +137,19 @@ export class TabGroup extends LitElement {
137
137
  tab.classList.toggle('next-tab', index >= 0 && i === index + 1);
138
138
  });
139
139
 
140
- this.getTabPanels().forEach((panel, i) => {
140
+ const panels = this.getTabPanels();
141
+ const shown = panels.findIndex(panel => panel.active);
142
+ panels.forEach((panel, i) => {
143
+ const active = keyed ? panel.getAttribute('value') === key : i === index;
144
+ // M3 Expressive: a newly shown panel slides in from the side it sits on relative to the
145
+ // panel it replaces. The first panel shown does not move.
146
+ if (active && !panel.active && shown >= 0) {
147
+ panel.setAttribute('data-enter', i > shown ? 'end' : 'start');
148
+ } else if (!active) {
149
+ panel.removeAttribute('data-enter');
150
+ }
141
151
  // eslint-disable-next-line no-param-reassign
142
- panel.active = keyed ? panel.getAttribute('value') === key : i === index;
152
+ panel.active = active;
143
153
  });
144
154
  }
145
155
 
@@ -10,3 +10,34 @@
10
10
  :host([active]) {
11
11
  display: block;
12
12
  }
13
+
14
+ // M3 Expressive: when the selected tab changes, the new panel slides in from the side of the tab
15
+ // that was picked (`data-enter`, set by wc-tab-group) on the default spatial spring and fades in
16
+ // on the effects spring. The spring tokens drop the movement for reduced motion.
17
+ @keyframes tab-panel-enter {
18
+ from {
19
+ translate: var(--_tab-panel-enter-offset) 0;
20
+ opacity: 0;
21
+ }
22
+ }
23
+
24
+ :host([active][data-enter]) {
25
+ --_tab-panel-enter-offset: 2rem;
26
+
27
+ animation-name: tab-panel-enter;
28
+ animation-duration: var(--motion-spring-default-spatial-duration);
29
+ animation-timing-function: var(--motion-spring-default-spatial-easing);
30
+ animation-fill-mode: backwards;
31
+ }
32
+
33
+ :host([active][data-enter='start']) {
34
+ --_tab-panel-enter-offset: -2rem;
35
+ }
36
+
37
+ :host([active][data-enter='end']:dir(rtl)) {
38
+ --_tab-panel-enter-offset: -2rem;
39
+ }
40
+
41
+ :host([active][data-enter='start']:dir(rtl)) {
42
+ --_tab-panel-enter-offset: 2rem;
43
+ }
package/src/tabs/tab.scss CHANGED
@@ -41,8 +41,10 @@
41
41
  color: var(--_label-text-color);
42
42
  opacity: var(--_label-text-opacity, 1);
43
43
  transition:
44
- color var(--duration-short4) var(--easing-standard),
45
- opacity var(--duration-short4) var(--easing-standard);
44
+ color var(--motion-spring-fast-effects-duration)
45
+ var(--motion-spring-fast-effects-easing),
46
+ opacity var(--motion-spring-fast-effects-duration)
47
+ var(--motion-spring-fast-effects-easing);
46
48
  --icon-size: var(--tab-icon-size, var(--_tab-icon-size));
47
49
  --icon-color: var(--_label-text-color);
48
50
 
@@ -69,8 +71,10 @@
69
71
  inset: auto 0px 0px;
70
72
  opacity: 0;
71
73
  transition:
72
- transform var(--duration-medium2) var(--easing-standard),
73
- opacity var(--duration-short4) var(--easing-standard);
74
+ transform var(--motion-spring-default-spatial-duration)
75
+ var(--motion-spring-default-spatial-easing),
76
+ opacity var(--motion-spring-fast-effects-duration)
77
+ var(--motion-spring-fast-effects-easing);
74
78
  will-change: transform, opacity;
75
79
  }
76
80
 
@@ -83,9 +87,12 @@
83
87
  transform: scaleX(0.6);
84
88
  transform-origin: center center;
85
89
  transition:
86
- transform var(--duration-medium2) var(--easing-standard),
87
- opacity var(--duration-short4) var(--easing-standard),
88
- background-color var(--duration-short4) var(--easing-standard);
90
+ transform var(--motion-spring-default-spatial-duration)
91
+ var(--motion-spring-default-spatial-easing),
92
+ opacity var(--motion-spring-fast-effects-duration)
93
+ var(--motion-spring-fast-effects-easing),
94
+ background-color var(--motion-spring-fast-effects-duration)
95
+ var(--motion-spring-fast-effects-easing);
89
96
  will-change: transform, opacity;
90
97
  }
91
98
 
@@ -106,11 +113,15 @@
106
113
  */
107
114
  .focus-ring {
108
115
  z-index: 2;
109
- --focus-ring-container-shape-start-start: var(--_container-shape-start-start);
116
+ --focus-ring-container-shape-start-start: var(
117
+ --_container-shape-start-start
118
+ );
110
119
  --focus-ring-container-shape-start-end: var(--_container-shape-start-end);
111
120
  --focus-ring-container-shape-end-start: var(--_container-shape-end-start);
112
121
  --focus-ring-container-shape-end-end: var(--_container-shape-end-end);
113
- --focus-ring-container-shape-variant: var(--_container-corner-shape-variant);
122
+ --focus-ring-container-shape-variant: var(
123
+ --_container-corner-shape-variant
124
+ );
114
125
  }
115
126
 
116
127
  .ripple {
@@ -134,8 +145,6 @@
134
145
  }
135
146
  }
136
147
 
137
-
138
-
139
148
  :host-context([variant='primary']) .tab {
140
149
  --_container-padding: 1rem;
141
150
  --_tab-icon-size: 1.5rem;
@@ -158,9 +167,7 @@
158
167
  inset: 3px 3px 4px 3px;
159
168
  }
160
169
 
161
-
162
170
  .tab-content {
163
-
164
171
  flex-direction: column;
165
172
 
166
173
  .icon-section {
@@ -180,10 +187,11 @@
180
187
  }
181
188
  }
182
189
 
183
-
184
-
185
-
186
190
  &.active {
191
+ // M3 Expressive: the active label is emphasized.
192
+ .tab-content {
193
+ @include mixin.get-typography('title-small-emphasized');
194
+ }
187
195
 
188
196
  .indicator {
189
197
  opacity: 1;
@@ -244,8 +252,11 @@
244
252
  }
245
253
  }
246
254
 
247
-
248
255
  &.active {
256
+ // M3 Expressive: the active label is emphasized.
257
+ .tab-content {
258
+ @include mixin.get-typography('title-small-emphasized');
259
+ }
249
260
 
250
261
  .indicator {
251
262
  opacity: 1;
@@ -13,3 +13,14 @@
13
13
  :host([variant='flat']) {
14
14
  --toolbar-container-color: transparent;
15
15
  }
16
+
17
+ /* Vibrant: the M3 Expressive scheme for a toolbar that should stand out. */
18
+ :host([color='vibrant']) {
19
+ --toolbar-container-color: var(--color-primary-container);
20
+ --toolbar-content-color: var(--color-on-primary-container);
21
+ --toolbar-icon-color: var(--color-on-primary-container);
22
+ }
23
+
24
+ :host([color='vibrant']) ::slotted(*) {
25
+ --text-button-label-text-color: var(--color-on-primary-container);
26
+ }
@@ -94,3 +94,31 @@
94
94
  .toolbar.variant-flat {
95
95
  padding: 0;
96
96
  }
97
+
98
+ /* ---- Hide on scroll (M3 Expressive) ---- */
99
+
100
+ :host([hide-on-scroll]) .toolbar {
101
+ transition:
102
+ translate var(--motion-spring-default-spatial-duration)
103
+ var(--motion-spring-default-spatial-easing),
104
+ opacity var(--motion-spring-default-effects-duration)
105
+ var(--motion-spring-default-effects-easing),
106
+ visibility 0s;
107
+ }
108
+
109
+ .toolbar.scrolled-away {
110
+ translate: 0 var(--toolbar-hide-distance, 150%);
111
+ opacity: 0;
112
+ visibility: hidden;
113
+ pointer-events: none;
114
+ // Hide once the slide has finished; show again at once.
115
+ transition-delay: 0s, 0s, var(--motion-spring-default-spatial-duration);
116
+
117
+ &.orientation-vertical {
118
+ translate: var(--toolbar-hide-distance, 150%) 0;
119
+ }
120
+
121
+ &.orientation-vertical:dir(rtl) {
122
+ translate: calc(-1 * var(--toolbar-hide-distance, 150%)) 0;
123
+ }
124
+ }
@@ -1,10 +1,13 @@
1
1
  import { LitElement, html, nothing } from 'lit';
2
- import { property } from 'lit/decorators.js';
2
+ import { property, state } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { RovingFocusController } from '@/__internal/controllers/roving-focus-controller.js';
5
5
  import styles from './toolbar.scss';
6
6
  import colorStyles from './toolbar-colors.scss';
7
7
 
8
+ /** How far the page must scroll in one direction before a `hide-on-scroll` toolbar reacts, in pixels. */
9
+ const SCROLL_THRESHOLD = 8;
10
+
8
11
  /** Slotted elements that separate groups and never take focus. */
9
12
  const SEPARATOR_SELECTOR = 'wc-divider, hr, [role="separator"]';
10
13
 
@@ -29,12 +32,17 @@ const SEPARATOR_SELECTOR = 'wc-divider, hr, [role="separator"]';
29
32
  * disabled or hidden, the next enabled action (else the previous one) takes it over. Give the
30
33
  * toolbar an <code>aria-label</code>.</p>
31
34
  *
35
+ * <p>With <code>hide-on-scroll</code>, a floating toolbar slides away while the page scrolls down
36
+ * and comes back as soon as it scrolls up, the M3 Expressive behavior for a toolbar docked over
37
+ * long content. It stays while focus is inside it.</p>
38
+ *
32
39
  * @cssprop --toolbar-container-color - Background color of the toolbar.
33
40
  * @cssprop --toolbar-container-shape - Border radius of the floating toolbar.
34
41
  * @cssprop --toolbar-padding - Padding of the floating toolbar.
35
42
  * @cssprop --toolbar-gap - Gap between toolbar actions.
36
43
  * @cssprop --toolbar-icon-color - Color of icons inside the toolbar.
37
44
  * @cssprop --toolbar-content-color - Color of text inside the toolbar.
45
+ * @cssprop --toolbar-hide-distance - How far a `hide-on-scroll` toolbar travels as it slides away. Defaults to 150% of its size; set it to clear a gap below a docked toolbar.
38
46
  * @cssprop --toolbar-wrap - `wrap` lets actions flow onto more lines when the toolbar is narrow. Defaults to `nowrap`.
39
47
  *
40
48
  * @example
@@ -90,12 +98,31 @@ export class Toolbar extends LitElement {
90
98
  @property({ type: String, reflect: true })
91
99
  orientation: 'horizontal' | 'vertical' = 'horizontal';
92
100
 
101
+ /**
102
+ * Color scheme of a floating toolbar: `standard` (surface container, the default) or `vibrant`
103
+ * (primary container), the M3 Expressive scheme for a toolbar that should stand out.
104
+ */
105
+ @property({ type: String, reflect: true })
106
+ color: 'standard' | 'vibrant' = 'standard';
107
+
93
108
  /**
94
109
  * Raises the floating toolbar to a higher elevation. Has no effect on the flat variant.
95
110
  */
96
111
  @property({ type: Boolean, reflect: true })
97
112
  elevated: boolean = false;
98
113
 
114
+ /**
115
+ * Slides the toolbar away while the page, or any scroll container in it, scrolls down, and back
116
+ * when it scrolls up. A horizontal toolbar moves down, a vertical one towards the end edge.
117
+ */
118
+ @property({ type: Boolean, attribute: 'hide-on-scroll', reflect: true })
119
+ hideOnScroll = false;
120
+
121
+ // ── State
122
+
123
+ /** Whether `hide-on-scroll` has slid the toolbar away. */
124
+ @state() private scrolledAway = false;
125
+
99
126
  // ── Private fields
100
127
 
101
128
  /** The toolbar's single tab stop, moved with the arrow keys along its orientation. */
@@ -112,6 +139,12 @@ export class Toolbar extends LitElement {
112
139
  this.roving.sync();
113
140
  });
114
141
 
142
+ /** Last scroll offset seen per scroll container, and where the current run of scrolling began. */
143
+ private readonly __scrollOffsets = new WeakMap<
144
+ EventTarget,
145
+ { last: number; anchor: number }
146
+ >();
147
+
115
148
  // ── Lifecycle
116
149
 
117
150
  override connectedCallback() {
@@ -128,12 +161,25 @@ export class Toolbar extends LitElement {
128
161
  override disconnectedCallback() {
129
162
  super.disconnectedCallback();
130
163
  this.__actionStateObserver.disconnect();
164
+ document.removeEventListener('scroll', this.__handleScroll, true);
131
165
  }
132
166
 
133
167
  override updated(changed: Map<string, unknown>) {
134
168
  if (changed.has('orientation')) {
135
169
  this.setAttribute('aria-orientation', this.orientation);
136
170
  }
171
+ if (changed.has('hideOnScroll')) {
172
+ // Capture catches scrolls of any container on the page, not only the document.
173
+ if (this.hideOnScroll) {
174
+ document.addEventListener('scroll', this.__handleScroll, {
175
+ capture: true,
176
+ passive: true,
177
+ });
178
+ } else {
179
+ document.removeEventListener('scroll', this.__handleScroll, true);
180
+ this.scrolledAway = false;
181
+ }
182
+ }
137
183
  }
138
184
 
139
185
  // ── Private methods
@@ -157,6 +203,32 @@ export class Toolbar extends LitElement {
157
203
  this.roving.sync();
158
204
  };
159
205
 
206
+ private __handleScroll = (event: Event) => {
207
+ const target = event.target as Element | Document;
208
+ // A scroll inside the toolbar itself, such as a wrapped overflow, is not page scrolling.
209
+ if (target instanceof Node && this.contains(target)) return;
210
+ const offset =
211
+ target instanceof Document
212
+ ? (target.scrollingElement?.scrollTop ?? 0)
213
+ : target.scrollTop;
214
+ // Before the first event there is no earlier offset: count from the top.
215
+ const seen = this.__scrollOffsets.get(target) ?? { last: 0, anchor: 0 };
216
+ // Start a new run whenever the direction flips, so a small reversal brings the toolbar back.
217
+ const down = offset > seen.last;
218
+ if (down !== seen.anchor < seen.last || offset === seen.last) {
219
+ seen.anchor = seen.last;
220
+ }
221
+ seen.last = offset;
222
+ this.__scrollOffsets.set(target, seen);
223
+
224
+ const travelled = offset - seen.anchor;
225
+ if (travelled > SCROLL_THRESHOLD && !this.matches(':focus-within')) {
226
+ this.scrolledAway = true;
227
+ } else if (travelled < -SCROLL_THRESHOLD || offset <= 0) {
228
+ this.scrolledAway = false;
229
+ }
230
+ };
231
+
160
232
  // ── Render
161
233
 
162
234
  override render() {
@@ -166,6 +238,7 @@ export class Toolbar extends LitElement {
166
238
  [`variant-${this.variant}`]: true,
167
239
  [`orientation-${this.orientation}`]: true,
168
240
  elevated: floating && this.elevated,
241
+ 'scrolled-away': this.hideOnScroll && this.scrolledAway,
169
242
  };
170
243
 
171
244
  return html`