@redvars/peacock 4.7.0 → 4.8.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.
- package/dist/accordion-item.js +4 -4
- package/dist/app-bar.js +1 -1
- package/dist/app-shell.js +2 -2
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/assets/theme.d.ts +2 -0
- package/dist/assets/theme.js +49 -29
- package/dist/assets/tokens.css +1 -1
- package/dist/assets/tokens.css.map +1 -1
- package/dist/bottom-sheet.js +3 -3
- package/dist/breadcrumb-item.js +1 -1
- package/dist/button-group.js +79 -0
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +26 -25
- package/dist/button.js.map +1 -1
- package/dist/calendar-column-view.js +3 -3
- package/dist/calendar-month-view.js +3 -3
- package/dist/calendar-timeline.js +3 -3
- package/dist/card.js +2 -1
- package/dist/card.js.map +1 -1
- package/dist/carousel.js +182 -7
- package/dist/carousel.js.map +1 -1
- package/dist/{cartesian-chart-C8qKDXo8.js → cartesian-chart-UW1CYKRS.js} +2 -2
- package/dist/{cartesian-chart-C8qKDXo8.js.map → cartesian-chart-UW1CYKRS.js.map} +1 -1
- package/dist/cb-group.js +1 -1
- package/dist/chart-area.js +2 -2
- package/dist/chart-bar.js +2 -2
- package/dist/{chart-base-BpQMZZsw.js → chart-base-D5ujPGcl.js} +3 -3
- package/dist/{chart-base-BpQMZZsw.js.map → chart-base-D5ujPGcl.js.map} +1 -1
- package/dist/chart-doughnut.js +1 -1
- package/dist/chart-line.js +2 -2
- package/dist/chart-pie.js +2 -2
- package/dist/checkbox.js +5 -5
- package/dist/chip.js +34 -8
- package/dist/chip.js.map +1 -1
- package/dist/circular-progress.js +46 -15
- package/dist/circular-progress.js.map +1 -1
- package/dist/code-highlighter.js +1 -1
- package/dist/color-picker.js +1 -1
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +5 -5
- package/dist/condition-builder.js +1 -1
- package/dist/{condition-group-base-NcvOY-Zv.js → condition-group-base-DS76sprm.js} +2 -2
- package/dist/{condition-group-base-NcvOY-Zv.js.map → condition-group-base-DS76sprm.js.map} +1 -1
- package/dist/confirm-dialog.js +2 -2
- package/dist/custom-elements-jsdocs.json +302 -10
- package/dist/custom-elements.json +1128 -16
- package/dist/dependency-map.js +2 -2
- package/dist/{diagram-hv7hCgzx.js → diagram-DFO-X7yq.js} +2 -2
- package/dist/{diagram-hv7hCgzx.js.map → diagram-DFO-X7yq.js.map} +1 -1
- package/dist/diagram.js +1 -1
- package/dist/discussion.js +3 -3
- package/dist/{document-editor-CZBlz3ai.js → document-editor-CSS-wACs.js} +7 -7
- package/dist/{document-editor-CZBlz3ai.js.map → document-editor-CSS-wACs.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/dropdown-button.js +1 -1
- package/dist/erd.js +4 -4
- package/dist/fab-menu-item.js +189 -0
- package/dist/fab-menu-item.js.map +1 -0
- package/dist/fab-menu.js +326 -0
- package/dist/fab-menu.js.map +1 -0
- package/dist/fab.js +28 -17
- package/dist/fab.js.map +1 -1
- package/dist/field.js +1 -1
- package/dist/file-upload.js +1 -1
- package/dist/flow.js +1 -1
- package/dist/hover-card.js +5 -3
- package/dist/hover-card.js.map +1 -1
- package/dist/html-editor.js +4 -4
- package/dist/icon-button.js +26 -25
- package/dist/icon-button.js.map +1 -1
- package/dist/{index-DK3fREuj.js → index-BBxpsqx8.js} +4 -4
- package/dist/{index-DK3fREuj.js.map → index-BBxpsqx8.js.map} +1 -1
- package/dist/{index-CTEt3LtO.js → index-CDtKB0In.js} +4 -4
- package/dist/{index-CTEt3LtO.js.map → index-CDtKB0In.js.map} +1 -1
- package/dist/{index-Bag4vtx-.js → index-Tb0ky27z.js} +3 -3
- package/dist/{index-Bag4vtx-.js.map → index-Tb0ky27z.js.map} +1 -1
- package/dist/index.js +15 -12
- package/dist/index.js.map +1 -1
- package/dist/{indicator-navigation-item-BG0TrdDE.js → indicator-navigation-item-aZsm-RpR.js} +17 -5
- package/dist/{indicator-navigation-item-BG0TrdDE.js.map → indicator-navigation-item-aZsm-RpR.js.map} +1 -1
- package/dist/inline-edit.js +1 -1
- package/dist/json-viewer.js +1 -1
- package/dist/linear-progress.js +51 -4
- package/dist/linear-progress.js.map +1 -1
- package/dist/link-button.js +26 -25
- package/dist/link-button.js.map +1 -1
- package/dist/loader-full.js +8 -5
- package/dist/loader-full.js.map +1 -1
- package/dist/loader.js +17 -5
- package/dist/loader.js.map +1 -1
- package/dist/loading-indicator.js +301 -0
- package/dist/loading-indicator.js.map +1 -0
- package/dist/markdown-editor.js +4 -4
- package/dist/mention-input.js +1 -1
- package/dist/menu.js +8 -6
- package/dist/menu.js.map +1 -1
- package/dist/{modal-Dds0rXAG.js → modal-ClWCCbxD.js} +7 -5
- package/dist/{modal-Dds0rXAG.js.map → modal-ClWCCbxD.js.map} +1 -1
- package/dist/modal.js +2 -2
- package/dist/navigation-bar-item.js +1 -1
- package/dist/navigation-bar.js +1 -1
- package/dist/navigation-drawer-group.js +1 -1
- package/dist/navigation-drawer.js +1 -1
- package/dist/navigation-rail-item.js +1 -1
- package/dist/navigation-rail.js +1 -1
- package/dist/notification-center.js +1 -1
- package/dist/number-counter.js +1 -1
- package/dist/{overlay-controller-BOk-kfil.js → overlay-controller-iVaiUqos.js} +20 -10
- package/dist/{overlay-controller-BOk-kfil.js.map → overlay-controller-iVaiUqos.js.map} +1 -1
- package/dist/pagination.js +1 -1
- package/dist/popover-content.js +4 -2
- package/dist/popover-content.js.map +1 -1
- package/dist/popover.js +1 -1
- package/dist/{progress-base-BhJK__VP.js → progress-base-BeLu9-Tq.js} +13 -1
- package/dist/progress-base-BeLu9-Tq.js.map +1 -0
- package/dist/prompt-input.js +5 -5
- package/dist/radio.js +3 -3
- package/dist/resizable-panels.js +1 -1
- package/dist/{rich-text-input-base-SrsPvc-j.js → rich-text-input-base-BCmnkpuV.js} +2 -2
- package/dist/{rich-text-input-base-SrsPvc-j.js.map → rich-text-input-base-BCmnkpuV.js.map} +1 -1
- package/dist/scroll-area.js +1 -1
- package/dist/search.js +1 -1
- package/dist/segmented-button.js +7 -2
- package/dist/segmented-button.js.map +1 -1
- package/dist/select.js +1 -1
- package/dist/side-sheet.js +3 -3
- package/dist/site-header.js +3 -3
- package/dist/site-nav-menu.js +1 -1
- package/dist/{slash-controller-DwL0nkqv.js → slash-controller-BFhzSjiR.js} +2 -2
- package/dist/{slash-controller-DwL0nkqv.js.map → slash-controller-BFhzSjiR.js.map} +1 -1
- package/dist/slider.js +163 -68
- package/dist/slider.js.map +1 -1
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +1 -1
- package/dist/src/button/button-group/button-group.d.ts +12 -0
- package/dist/src/button/fab/fab.d.ts +1 -0
- package/dist/src/carousel/carousel.d.ts +22 -0
- package/dist/src/chip/chip/chip.d.ts +4 -0
- package/dist/src/fab-menu/fab-menu-item.d.ts +30 -0
- package/dist/src/fab-menu/fab-menu.d.ts +64 -0
- package/dist/src/fab-menu/index.d.ts +2 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/loading-indicator/index.d.ts +1 -0
- package/dist/src/loading-indicator/loading-indicator.d.ts +44 -0
- package/dist/src/loading-indicator/shapes.d.ts +29 -0
- package/dist/src/progress/circular-progress/circular-progress.d.ts +3 -1
- package/dist/src/progress/linear-progress/linear-progress.d.ts +2 -1
- package/dist/src/progress/progress-base.d.ts +7 -0
- package/dist/src/slider/slider.d.ts +23 -3
- package/dist/src/toolbar/toolbar.d.ts +20 -0
- package/dist/step.js +1 -1
- package/dist/switch.js +5 -2
- package/dist/switch.js.map +1 -1
- package/dist/tab-group.js +13 -2
- package/dist/tab-group.js.map +1 -1
- package/dist/tab-panel.js +26 -0
- package/dist/tab-panel.js.map +1 -1
- package/dist/tab.js +23 -5
- package/dist/tab.js.map +1 -1
- package/dist/table.js +4 -4
- package/dist/tag.js +2 -1
- package/dist/tag.js.map +1 -1
- package/dist/test/button-group-press.test.d.ts +1 -0
- package/dist/test/fab-menu.test.d.ts +1 -0
- package/dist/test/loading-indicator.test.d.ts +1 -0
- package/dist/toolbar.js +102 -0
- package/dist/toolbar.js.map +1 -1
- package/dist/tooltip.js +5 -2
- package/dist/tooltip.js.map +1 -1
- package/dist/tour.js +3 -3
- package/dist/tree-chart.js +3 -3
- package/dist/tree-item.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{video-DgtGGvrk.js → video-DSQ07o3h.js} +2 -2
- package/dist/{video-DgtGGvrk.js.map → video-DSQ07o3h.js.map} +1 -1
- package/dist/video.js +1 -1
- package/dist/workflow.js +5 -5
- package/package.json +1 -1
- package/scss/tokens.css +364 -0
- package/src/__internal/chart/chart-base.scss +4 -2
- package/src/__internal/controllers/overlay-controller.ts +19 -9
- package/src/__internal/rich-text/editor-chrome.scss +2 -1
- package/src/accordion/accordion-item.scss +10 -6
- package/src/app-bar/app-bar.scss +2 -1
- package/src/app-shell/app-shell.scss +2 -2
- package/src/bottom-sheet/bottom-sheet.scss +4 -2
- package/src/breadcrumb/breadcrumb-item/breadcrumb-item.scss +4 -2
- package/src/button/button/button-base.scss +14 -12
- package/src/button/button/button-layers.scss +27 -5
- package/src/button/button-group/button-group.scss +6 -0
- package/src/button/button-group/button-group.ts +105 -0
- package/src/button/fab/fab-sizes.scss +2 -0
- package/src/button/fab/fab.scss +32 -17
- package/src/button/fab/fab.ts +1 -0
- package/src/calendar/calendar-column-view.scss +3 -3
- package/src/calendar/calendar-month-view.scss +3 -3
- package/src/calendar-timeline/calendar-timeline.scss +6 -3
- package/src/card/card.scss +2 -1
- package/src/carousel/carousel.scss +71 -2
- package/src/carousel/carousel.ts +159 -7
- package/src/chart-pie/chart-pie.scss +4 -2
- package/src/checkbox/checkbox.scss +13 -7
- package/src/chip/chip/chip.scss +41 -8
- package/src/chip/chip/chip.ts +4 -0
- package/src/chip/tag/tag.scss +2 -1
- package/src/code-highlighter/code-highlighter.scss +2 -1
- package/src/color-picker/color-picker.scss +1 -1
- package/src/comment-composer/comment-composer.scss +2 -1
- package/src/components.manifest.json +21 -0
- package/src/condition-builder/condition-group-base.scss +1 -1
- package/src/dependency-map/dependency-map.scss +4 -2
- package/src/diagram/diagram.scss +2 -1
- package/src/document-editor/document-editor.scss +1 -1
- package/src/dropdown-button/dropdown-button.scss +2 -1
- package/src/erd/erd.scss +8 -4
- package/src/fab-menu/fab-menu-item.scss +99 -0
- package/src/fab-menu/fab-menu-item.ts +58 -0
- package/src/fab-menu/fab-menu.scss +119 -0
- package/src/fab-menu/fab-menu.ts +193 -0
- package/src/fab-menu/index.ts +2 -0
- package/src/field/field.scss +1 -1
- package/src/file-upload/file-upload.scss +2 -2
- package/src/hover-card/hover-card.scss +9 -2
- package/src/index.ts +3 -0
- package/src/inline-edit/inline-edit.scss +2 -2
- package/src/json-viewer/json-viewer.scss +2 -1
- package/src/loader.ts +12 -0
- package/src/loading-indicator/index.ts +1 -0
- package/src/loading-indicator/loading-indicator.scss +52 -0
- package/src/loading-indicator/loading-indicator.ts +164 -0
- package/src/loading-indicator/shapes.ts +104 -0
- package/src/menu/menu/menu.scss +10 -6
- package/src/modal/modal.scss +8 -4
- package/src/navigation-drawer/navigation-drawer-group.scss +2 -2
- package/src/navigation-drawer/navigation-drawer.scss +3 -2
- package/src/navigation-rail/navigation-rail-item.scss +27 -5
- package/src/number-counter/number-counter.scss +1 -1
- package/src/pagination/pagination.scss +2 -1
- package/src/popover/popover-content.scss +7 -2
- package/src/progress/circular-progress/circular-progress.scss +3 -2
- package/src/progress/circular-progress/circular-progress.ts +43 -12
- package/src/progress/linear-progress/linear-progress.scss +70 -2
- package/src/progress/linear-progress/linear-progress.ts +4 -1
- package/src/progress/progress-base.ts +11 -0
- package/src/prompt-input/prompt-input.scss +2 -1
- package/src/radio/radio.scss +8 -4
- package/src/resizable-panels/resizable-panels.scss +2 -1
- package/src/scroll-area/scroll-area.scss +2 -1
- package/src/search/search.scss +2 -1
- package/src/segmented-button/segmented-button.scss +8 -3
- package/src/select/select.scss +2 -1
- package/src/side-sheet/side-sheet.scss +4 -2
- package/src/site-header/site-header.scss +4 -4
- package/src/site-header/site-nav-menu.scss +2 -2
- package/src/slider/slider.scss +127 -64
- package/src/slider/slider.ts +74 -9
- package/src/snackbar/snackbar.scss +5 -2
- package/src/sparkline/sparkline.scss +6 -3
- package/src/split-button/split-button.scss +4 -2
- package/src/stepper/step.scss +2 -1
- package/src/switch/switch.scss +21 -2
- package/src/table/table.scss +8 -4
- package/src/tabs/tab-group.ts +12 -2
- package/src/tabs/tab-panel.scss +31 -0
- package/src/tabs/tab.scss +28 -17
- package/src/toolbar/toolbar-colors.scss +11 -0
- package/src/toolbar/toolbar.scss +28 -0
- package/src/toolbar/toolbar.ts +74 -1
- package/src/tooltip/tooltip.scss +9 -3
- package/src/tour/tour.scss +2 -2
- package/src/tree/tree-item.scss +2 -1
- package/src/tree-chart/tree-chart.scss +3 -3
- package/src/video/video.scss +2 -1
- package/src/workflow/workflow.scss +5 -5
- package/dist/progress-base-BhJK__VP.js.map +0 -1
package/src/slider/slider.ts
CHANGED
|
@@ -3,13 +3,19 @@ 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 {
|
|
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
10
|
|
|
11
11
|
let sliderCount = 0;
|
|
12
12
|
|
|
13
|
+
/** Handle half-width plus the gap on each side of it, in px (matches `--_handle-space`). */
|
|
14
|
+
const HANDLE_SPACE_PX = 8;
|
|
15
|
+
|
|
16
|
+
/** Room the inset icon needs on the active track: icon plus inset on both sides, in px. */
|
|
17
|
+
const ICON_ROOM = { md: 40, lg: 48, xl: 64 } as const;
|
|
18
|
+
|
|
13
19
|
/** Where the slider shows its value: on the thumb while it is used, after the track, or not. */
|
|
14
20
|
export type SliderValueLabel = 'thumb' | 'end' | 'none';
|
|
15
21
|
|
|
@@ -29,6 +35,8 @@ export type SliderValueLabel = 'thumb' | 'end' | 'none';
|
|
|
29
35
|
* <code>v => `${v}%`</code>.</p>
|
|
30
36
|
* <p><code>required</code> does not apply: a slider always has a value. <code>readonly</code> keeps
|
|
31
37
|
* it focusable but its value cannot change.</p>
|
|
38
|
+
* <p>The look follows Material 3 Expressive: a thick track split around a slim handle, a stop
|
|
39
|
+
* dot at the end, five <code>size</code>s, and an optional <code>icon</code> inside the track.</p>
|
|
32
40
|
* <p>Keyboard: the arrows move one step (ten with Shift), Page Up and Page Down move ten steps,
|
|
33
41
|
* Home and End go to <code>min</code> and <code>max</code>.</p>
|
|
34
42
|
*
|
|
@@ -93,8 +101,17 @@ export class Slider extends InputBase {
|
|
|
93
101
|
/** Error message shown below the slider while `error` is set; replaces the help text. */
|
|
94
102
|
@property({ type: String, attribute: 'error-text' }) errorText = '';
|
|
95
103
|
|
|
96
|
-
/**
|
|
97
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Size of the track and handle, from the M3 Expressive scale: `xs` (16px track, the default),
|
|
106
|
+
* `sm` (24px), `md` (40px), `lg` (56px) or `xl` (96px).
|
|
107
|
+
*/
|
|
108
|
+
@property({ type: String, reflect: true }) size: ScaleSize = 'xs';
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Name of an icon shown inside the track, at its start (`md` and larger). It sits on the active
|
|
112
|
+
* part while it fits there, else just after the handle.
|
|
113
|
+
*/
|
|
114
|
+
@property({ type: String }) icon?: string;
|
|
98
115
|
|
|
99
116
|
/**
|
|
100
117
|
* Where the value shows: `thumb` (on the thumb while it is used; the default), `end` (after the
|
|
@@ -112,6 +129,11 @@ export class Slider extends InputBase {
|
|
|
112
129
|
/** True while the user is actively dragging the thumb. */
|
|
113
130
|
@state() private isDragging = false;
|
|
114
131
|
|
|
132
|
+
/** Width of the track in px, for placing the inset icon. */
|
|
133
|
+
@state() private trackWidth = 0;
|
|
134
|
+
|
|
135
|
+
private resizeObserver?: ResizeObserver;
|
|
136
|
+
|
|
115
137
|
// ── Queries ──────────────────────────────────────────────────────────────
|
|
116
138
|
|
|
117
139
|
@query('.slider-container') private container!: HTMLElement;
|
|
@@ -138,6 +160,19 @@ export class Slider extends InputBase {
|
|
|
138
160
|
super.connectedCallback();
|
|
139
161
|
}
|
|
140
162
|
|
|
163
|
+
override firstUpdated() {
|
|
164
|
+
this.resizeObserver = new ResizeObserver(([entry]) => {
|
|
165
|
+
this.trackWidth = entry.contentRect.width;
|
|
166
|
+
});
|
|
167
|
+
this.resizeObserver.observe(this.container);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
override disconnectedCallback() {
|
|
171
|
+
super.disconnectedCallback();
|
|
172
|
+
this.resizeObserver?.disconnect();
|
|
173
|
+
this.resizeObserver = undefined;
|
|
174
|
+
}
|
|
175
|
+
|
|
141
176
|
// ── Public methods ───────────────────────────────────────────────────────
|
|
142
177
|
|
|
143
178
|
override focus() {
|
|
@@ -319,6 +354,27 @@ export class Slider extends InputBase {
|
|
|
319
354
|
|
|
320
355
|
// ── Render ───────────────────────────────────────────────────────────────
|
|
321
356
|
|
|
357
|
+
/**
|
|
358
|
+
* The inset icon: on the active part of the track while it fits there, else on the inactive part
|
|
359
|
+
* just after the handle. Shown from `md` up, where the track is tall enough.
|
|
360
|
+
*/
|
|
361
|
+
private renderIcon(percentage: number) {
|
|
362
|
+
if (!this.icon || !['md', 'lg', 'xl'].includes(this.size)) return nothing;
|
|
363
|
+
const iconSpace = ICON_ROOM[this.size as 'md' | 'lg' | 'xl'];
|
|
364
|
+
const activeWidth = (percentage / 100) * this.trackWidth - HANDLE_SPACE_PX;
|
|
365
|
+
const onActive = activeWidth >= iconSpace;
|
|
366
|
+
return html`<wc-icon
|
|
367
|
+
class=${classMap({ 'track-icon': true, 'on-active': onActive })}
|
|
368
|
+
name=${this.icon}
|
|
369
|
+
aria-hidden="true"
|
|
370
|
+
style=${styleMap({
|
|
371
|
+
left: onActive
|
|
372
|
+
? 'var(--_icon-inset)'
|
|
373
|
+
: `calc(${percentage}% + var(--_handle-space) + var(--_icon-inset))`,
|
|
374
|
+
})}
|
|
375
|
+
></wc-icon>`;
|
|
376
|
+
}
|
|
377
|
+
|
|
322
378
|
render() {
|
|
323
379
|
const { value } = this;
|
|
324
380
|
const range = this.max - this.min;
|
|
@@ -352,12 +408,21 @@ export class Slider extends InputBase {
|
|
|
352
408
|
@mousedown=${this.onMouseDown}
|
|
353
409
|
@touchstart=${this.onMouseDown}
|
|
354
410
|
>
|
|
355
|
-
<div
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
411
|
+
<div
|
|
412
|
+
class="track track-active"
|
|
413
|
+
style=${styleMap({
|
|
414
|
+
width: `max(0px, calc(${percentage}% - var(--_handle-space)))`,
|
|
415
|
+
})}
|
|
416
|
+
></div>
|
|
417
|
+
<div
|
|
418
|
+
class="track track-inactive"
|
|
419
|
+
style=${styleMap({
|
|
420
|
+
left: `calc(${percentage}% + var(--_handle-space))`,
|
|
421
|
+
})}
|
|
422
|
+
>
|
|
423
|
+
${percentage < 100 ? html`<span class="stop"></span>` : nothing}
|
|
360
424
|
</div>
|
|
425
|
+
${this.renderIcon(percentage)}
|
|
361
426
|
|
|
362
427
|
<div
|
|
363
428
|
class="thumb"
|
|
@@ -374,7 +439,7 @@ export class Slider extends InputBase {
|
|
|
374
439
|
aria-readonly=${this.readonly ? 'true' : nothing}
|
|
375
440
|
aria-invalid=${invalid ? 'true' : nothing}
|
|
376
441
|
style=${styleMap({
|
|
377
|
-
left: `calc(${percentage}% - var(--
|
|
442
|
+
left: `calc(${percentage}% - var(--_handle-width) / 2)`,
|
|
378
443
|
})}
|
|
379
444
|
@keydown=${this.handleKeyDown}
|
|
380
445
|
>
|
|
@@ -73,13 +73,16 @@
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
.snackbar.open {
|
|
76
|
-
|
|
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(--
|
|
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(--
|
|
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(--
|
|
82
|
-
|
|
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
|
|
71
|
-
|
|
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 {
|
package/src/stepper/step.scss
CHANGED
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
background: var(--color-on-surface);
|
|
57
57
|
opacity: 0;
|
|
58
58
|
pointer-events: none;
|
|
59
|
-
transition: opacity var(--
|
|
59
|
+
transition: opacity var(--motion-spring-fast-effects-duration)
|
|
60
|
+
var(--motion-spring-fast-effects-easing);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
&:hover::before {
|
package/src/switch/switch.scss
CHANGED
|
@@ -39,7 +39,11 @@
|
|
|
39
39
|
border-radius: var(--shape-corner-full);
|
|
40
40
|
cursor: pointer;
|
|
41
41
|
display: flex;
|
|
42
|
-
transition:
|
|
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
|
-
|
|
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 {
|
package/src/table/table.scss
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
package/src/tabs/tab-group.ts
CHANGED
|
@@ -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()
|
|
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 =
|
|
152
|
+
panel.active = active;
|
|
143
153
|
});
|
|
144
154
|
}
|
|
145
155
|
|
package/src/tabs/tab-panel.scss
CHANGED
|
@@ -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(--
|
|
45
|
-
|
|
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(--
|
|
73
|
-
|
|
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(--
|
|
87
|
-
|
|
88
|
-
|
|
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(
|
|
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(
|
|
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
|
+
}
|
package/src/toolbar/toolbar.scss
CHANGED
|
@@ -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
|
+
}
|
package/src/toolbar/toolbar.ts
CHANGED
|
@@ -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`
|
package/src/tooltip/tooltip.scss
CHANGED
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
transform: scale(0);
|
|
23
23
|
opacity: 0;
|
|
24
24
|
|
|
25
|
-
--_tooltip-duration: var(--duration
|
|
25
|
+
--_tooltip-duration: var(--motion-spring-fast-effects-duration, 0.1s);
|
|
26
|
+
--_tooltip-easing: var(--motion-spring-fast-effects-easing, ease-in-out);
|
|
26
27
|
|
|
27
28
|
/* `allow-discrete` keeps the tooltip in the top layer while it fades out. */
|
|
28
29
|
transition:
|
|
29
|
-
transform var(--_tooltip-duration)
|
|
30
|
-
opacity var(--_tooltip-duration)
|
|
30
|
+
transform var(--_tooltip-duration) var(--_tooltip-easing),
|
|
31
|
+
opacity var(--_tooltip-duration) var(--_tooltip-easing),
|
|
31
32
|
display var(--_tooltip-duration) allow-discrete,
|
|
32
33
|
overlay var(--_tooltip-duration) allow-discrete;
|
|
33
34
|
}
|
|
@@ -36,6 +37,11 @@
|
|
|
36
37
|
pointer-events: auto;
|
|
37
38
|
transform: none;
|
|
38
39
|
opacity: 1;
|
|
40
|
+
// M3 Expressive: it pops in on the fast spatial spring and fades out without overshoot.
|
|
41
|
+
transition-duration: var(--motion-spring-fast-spatial-duration, 0.1s),
|
|
42
|
+
var(--_tooltip-duration);
|
|
43
|
+
transition-timing-function: var(--motion-spring-fast-spatial-easing, ease-out),
|
|
44
|
+
var(--_tooltip-easing);
|
|
39
45
|
|
|
40
46
|
@starting-style {
|
|
41
47
|
transform: scale(0);
|