@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* @label FAB Menu Item
|
|
4
|
+
* @tag wc-fab-menu-item
|
|
5
|
+
* @rawTag fab-menu-item
|
|
6
|
+
* @summary One action in a `wc-fab-menu`: a pill with an icon and a label.
|
|
7
|
+
* @overview
|
|
8
|
+
* <p>Use inside <code>wc-fab-menu</code>. The default slot holds the label and <code>icon</code>
|
|
9
|
+
* names the leading icon. Listen for <code>click</code> to run the action; the menu closes
|
|
10
|
+
* itself.</p>
|
|
11
|
+
* @tags controls
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```html
|
|
15
|
+
* <wc-fab-menu-item icon="edit">Note</wc-fab-menu-item>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class FabMenuItem extends LitElement {
|
|
19
|
+
static styles: import("lit").CSSResultGroup[];
|
|
20
|
+
/** @nocollapse */ static shadowRootOptions: ShadowRootInit;
|
|
21
|
+
/** Name of the leading icon. */
|
|
22
|
+
icon?: string;
|
|
23
|
+
/** Disables the item. */
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
/** Set by the menu: whether the item is shown. */
|
|
26
|
+
shown: boolean;
|
|
27
|
+
/** Set by the menu: its color set. */
|
|
28
|
+
color: 'primary' | 'secondary' | 'tertiary';
|
|
29
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { FabMenuItem } from './fab-menu-item.js';
|
|
3
|
+
/**
|
|
4
|
+
* @label FAB Menu
|
|
5
|
+
* @tag wc-fab-menu
|
|
6
|
+
* @rawTag fab-menu
|
|
7
|
+
* @summary A floating action button that opens into a short list of related actions.
|
|
8
|
+
* @overview
|
|
9
|
+
* <p>The M3 Expressive FAB menu. Put two to six <code>wc-fab-menu-item</code> elements inside.
|
|
10
|
+
* Pressing the FAB morphs it into a round close button and springs the items in, nearest first.
|
|
11
|
+
* Choosing an item, pressing Escape or clicking outside closes the menu.</p>
|
|
12
|
+
* <p><code>icon</code> sets the FAB's icon (<code>add</code> by default) and <code>label</code> its
|
|
13
|
+
* accessible name. <code>color</code> picks the color set: <code>primary</code> (default),
|
|
14
|
+
* <code>secondary</code> or <code>tertiary</code>. Items line up at the end of the FAB, or at its
|
|
15
|
+
* start with <code>align="start"</code>.</p>
|
|
16
|
+
* <p>The FAB is a button with <code>aria-expanded</code>. When the menu opens from the keyboard,
|
|
17
|
+
* focus moves to the first item; closing returns it to the FAB.</p>
|
|
18
|
+
* @tags controls
|
|
19
|
+
*
|
|
20
|
+
* @fires {CustomEvent<{open: boolean}>} toggle - Dispatched when the menu opens or closes.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```html
|
|
24
|
+
* <wc-fab-menu label="Create">
|
|
25
|
+
* <wc-fab-menu-item icon="edit">Note</wc-fab-menu-item>
|
|
26
|
+
* <wc-fab-menu-item icon="checklist">List</wc-fab-menu-item>
|
|
27
|
+
* <wc-fab-menu-item icon="image">Image</wc-fab-menu-item>
|
|
28
|
+
* </wc-fab-menu>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class FabMenu extends LitElement {
|
|
32
|
+
static styles: import("lit").CSSResultGroup[];
|
|
33
|
+
static Item: typeof FabMenuItem;
|
|
34
|
+
/** Whether the menu is open. */
|
|
35
|
+
open: boolean;
|
|
36
|
+
/** Icon of the closed FAB. */
|
|
37
|
+
icon: string;
|
|
38
|
+
/** Accessible name of the FAB. Defaults to "Open menu". */
|
|
39
|
+
label?: string;
|
|
40
|
+
/** Color set of the FAB and the items. */
|
|
41
|
+
color: 'primary' | 'secondary' | 'tertiary';
|
|
42
|
+
/** Which edge the items line up with. */
|
|
43
|
+
align: 'start' | 'end';
|
|
44
|
+
private _fab?;
|
|
45
|
+
private readonly _i18n;
|
|
46
|
+
private readonly _listId;
|
|
47
|
+
/** Whether the last open came from the keyboard, so focus moves into the list. */
|
|
48
|
+
private _openedByKeyboard;
|
|
49
|
+
disconnectedCallback(): void;
|
|
50
|
+
/** Opens the menu. */
|
|
51
|
+
show(): void;
|
|
52
|
+
/** Closes the menu. */
|
|
53
|
+
hide(): void;
|
|
54
|
+
private _items;
|
|
55
|
+
private _setOpen;
|
|
56
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
57
|
+
/** Tells each item whether it is shown, its stagger delay, and the color set. */
|
|
58
|
+
private _syncItems;
|
|
59
|
+
private _onOutside;
|
|
60
|
+
private _onFabClick;
|
|
61
|
+
private _onKeyDown;
|
|
62
|
+
private _onItemClick;
|
|
63
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
64
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export { default as ButtonGroup } from './button/button-group/button-group.js';
|
|
|
10
10
|
export { SegmentedButton } from './segmented-button/segmented-button.js';
|
|
11
11
|
export { SegmentedButtonGroup } from './segmented-button/segmented-button-group.js';
|
|
12
12
|
export { SplitButton } from './split-button/split-button.js';
|
|
13
|
+
export { FabMenu } from './fab-menu/fab-menu.js';
|
|
14
|
+
export { FabMenuItem } from './fab-menu/fab-menu-item.js';
|
|
13
15
|
export { DropdownButton } from './dropdown-button/dropdown-button.js';
|
|
14
16
|
export { Divider } from './divider/divider.js';
|
|
15
17
|
export { Elevation } from './elevation/elevation.js';
|
|
@@ -29,6 +31,7 @@ export { NotificationManager } from './notification-manager/notification-manager
|
|
|
29
31
|
export { Tag } from './chip/tag/tag.js';
|
|
30
32
|
export { LinearProgress } from './progress/linear-progress/linear-progress.js';
|
|
31
33
|
export { CircularProgress } from './progress/circular-progress/circular-progress.js';
|
|
34
|
+
export { LoadingIndicator } from './loading-indicator/loading-indicator.js';
|
|
32
35
|
export { Skeleton } from './skeleton/skeleton.js';
|
|
33
36
|
export { Field } from './field/field.js';
|
|
34
37
|
export { Input } from './input/input.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LoadingIndicator } from './loading-indicator.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const LoadingIndicator_base: import("../__internal/mixins/mixin.js").MixinReturn<typeof LitElement>;
|
|
3
|
+
/**
|
|
4
|
+
* @label Loading Indicator
|
|
5
|
+
* @tag wc-loading-indicator
|
|
6
|
+
* @rawTag loading-indicator
|
|
7
|
+
* @summary An expressive spinner that morphs between rounded shapes while it turns, for short waits of unknown length.
|
|
8
|
+
* @overview
|
|
9
|
+
* <p>Use it for waits of a few seconds whose length is unknown, such as loading a page or
|
|
10
|
+
* refreshing content. For longer work, or when progress is known, use
|
|
11
|
+
* <code>wc-circular-progress</code> or <code>wc-linear-progress</code>.</p>
|
|
12
|
+
* <p><code>contained</code> draws it on a round container, for use over content such as
|
|
13
|
+
* pull-to-refresh. Set the size with <code>--loading-indicator-size</code> (48px by default).</p>
|
|
14
|
+
* <p>It is named "Loading" unless an <code>aria-label</code> on the element names it. With
|
|
15
|
+
* reduced motion it morphs more slowly and turns at a slow, steady speed.</p>
|
|
16
|
+
* @tags display
|
|
17
|
+
*
|
|
18
|
+
* @cssprop --loading-indicator-size - Width and height. Defaults to 3rem.
|
|
19
|
+
* @cssprop --loading-indicator-color - Shape color. Defaults to var(--color-primary), or var(--color-on-primary-container) when contained.
|
|
20
|
+
* @cssprop --loading-indicator-container-color - Container color when `contained`. Defaults to var(--color-primary-container).
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```html
|
|
24
|
+
* <wc-loading-indicator></wc-loading-indicator>
|
|
25
|
+
* <wc-loading-indicator contained></wc-loading-indicator>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class LoadingIndicator extends LoadingIndicator_base {
|
|
29
|
+
static styles: import("lit").CSSResultGroup[];
|
|
30
|
+
/** Draws the indicator on a round container. */
|
|
31
|
+
contained: boolean;
|
|
32
|
+
private _shape?;
|
|
33
|
+
private readonly _i18n;
|
|
34
|
+
private _frame;
|
|
35
|
+
private _start;
|
|
36
|
+
connectedCallback(): void;
|
|
37
|
+
disconnectedCallback(): void;
|
|
38
|
+
private _tick;
|
|
39
|
+
/** Draws the frame `elapsed` ms after the indicator appeared. */
|
|
40
|
+
private _draw;
|
|
41
|
+
firstUpdated(): void;
|
|
42
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes wc-loading-indicator morphs through, after the M3 Expressive loading indicator:
|
|
3
|
+
* soft burst, 9-sided cookie, pentagon, pill, sunny, 4-sided cookie and oval.
|
|
4
|
+
*
|
|
5
|
+
* Every shape is a polar function sampled at the same angles, so morphing is a per-point blend
|
|
6
|
+
* of radii. Radii are normalised so each shape's furthest point is 1.
|
|
7
|
+
*/
|
|
8
|
+
/** Points per shape. Enough to look smooth at large sizes, cheap enough to blend every frame. */
|
|
9
|
+
export declare const SHAPE_POINTS = 180;
|
|
10
|
+
/** Every shape as normalised radii, in the order they morph. */
|
|
11
|
+
export declare const SHAPE_RADII: readonly Float32Array[];
|
|
12
|
+
/**
|
|
13
|
+
* For each shape, the turn (in samples) that best lines the next shape up with it, so matching
|
|
14
|
+
* lobes travel the shortest way during the morph. `PAIR_OFFSETS[i]` is for shape i to shape i + 1.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PAIR_OFFSETS: readonly number[];
|
|
17
|
+
/**
|
|
18
|
+
* An SVG path for a shape on its way from `from` to `to`: a per-point blend of radii, so the
|
|
19
|
+
* outline stays a recognisable shape the whole way through.
|
|
20
|
+
*
|
|
21
|
+
* @param from Radii of the shape being left.
|
|
22
|
+
* @param to Radii of the shape being reached.
|
|
23
|
+
* @param progress 0 at `from`, 1 at `to`.
|
|
24
|
+
* @param size Radius in viewBox units of a point whose normalised radius is 1.
|
|
25
|
+
* @param center Centre of the shape in viewBox units.
|
|
26
|
+
* @param offset Samples to turn `to` by before blending (see PAIR_OFFSETS). At 1 the path is
|
|
27
|
+
* `to` turned back by `offset` samples, which the caller makes up with its rotation.
|
|
28
|
+
*/
|
|
29
|
+
export declare function blendPath(from: Float32Array, to: Float32Array, progress: number, size: number, center: number, offset?: number): string;
|
|
@@ -9,7 +9,9 @@ import { ProgressBase } from '../progress-base.js';
|
|
|
9
9
|
* range. The visible <code>label</code> names the indicator through
|
|
10
10
|
* <code>aria-labelledby</code>; without one, an <code>aria-label</code> on the element names it,
|
|
11
11
|
* else it is named "Loading". With
|
|
12
|
-
* <code>indeterminate</code> it spins, for a wait of unknown length
|
|
12
|
+
* <code>indeterminate</code> it spins, for a wait of unknown length. <code>wavy</code> draws the
|
|
13
|
+
* indicator as a rippling ring, the M3 Expressive style; for short waits also consider
|
|
14
|
+
* <code>wc-loading-indicator</code>.</p>
|
|
13
15
|
* @tags display
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
@@ -8,7 +8,8 @@ import { ProgressBase } from '../progress-base.js';
|
|
|
8
8
|
* <p><code>value</code> runs from 0 to <code>max</code> (default 100) and is clamped into that
|
|
9
9
|
* range. The visible <code>label</code> names the bar through <code>aria-labelledby</code>; without
|
|
10
10
|
* one, an <code>aria-label</code> on the element names it, else it is named "Loading". Use <code>indeterminate</code> when the amount of work is not
|
|
11
|
-
* known
|
|
11
|
+
* known. <code>wavy</code> draws the filled part as a moving wave, the M3 Expressive style; it
|
|
12
|
+
* flattens once the task is complete.</p>
|
|
12
13
|
* @tags display
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
@@ -21,6 +21,11 @@ export declare class ProgressBase extends ProgressBase_base {
|
|
|
21
21
|
helperText?: string;
|
|
22
22
|
/** Lays out the label and the indicator on one line instead of stacking them. */
|
|
23
23
|
inline: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Draws the active indicator as a wave, the M3 Expressive style. The wave flattens out once the
|
|
26
|
+
* task is complete, and stops moving with reduced motion.
|
|
27
|
+
*/
|
|
28
|
+
wavy: boolean;
|
|
24
29
|
/** Peacock's strings, for the fallback accessible name. */
|
|
25
30
|
protected readonly i18n: I18nController;
|
|
26
31
|
/** The bar's name without a visible `label`: the host's `aria-label`, else "Loading". */
|
|
@@ -29,6 +34,8 @@ export declare class ProgressBase extends ProgressBase_base {
|
|
|
29
34
|
protected get __max(): number;
|
|
30
35
|
/** `value` clamped into `0`–`max`; 0 when unset. */
|
|
31
36
|
protected get __clampedValue(): number;
|
|
37
|
+
/** Whether a determinate task has reached `max`. */
|
|
38
|
+
protected get __complete(): boolean;
|
|
32
39
|
/** The clamped value as a percentage of `max`. */
|
|
33
40
|
__getPercentageValue(): number;
|
|
34
41
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormRestoreState } from '../__internal/mixins/form-associated.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ScaleSize } from '../__internal/utils/size.js';
|
|
3
3
|
import InputBase, { type ControlValidity } from '../__internal/input-base.js';
|
|
4
4
|
/** Where the slider shows its value: on the thumb while it is used, after the track, or not. */
|
|
5
5
|
export type SliderValueLabel = 'thumb' | 'end' | 'none';
|
|
@@ -19,6 +19,8 @@ export type SliderValueLabel = 'thumb' | 'end' | 'none';
|
|
|
19
19
|
* <code>v => `${v}%`</code>.</p>
|
|
20
20
|
* <p><code>required</code> does not apply: a slider always has a value. <code>readonly</code> keeps
|
|
21
21
|
* it focusable but its value cannot change.</p>
|
|
22
|
+
* <p>The look follows Material 3 Expressive: a thick track split around a slim handle, a stop
|
|
23
|
+
* dot at the end, five <code>size</code>s, and an optional <code>icon</code> inside the track.</p>
|
|
22
24
|
* <p>Keyboard: the arrows move one step (ten with Shift), Page Up and Page Down move ten steps,
|
|
23
25
|
* Home and End go to <code>min</code> and <code>max</code>.</p>
|
|
24
26
|
*
|
|
@@ -58,8 +60,16 @@ export declare class Slider extends InputBase {
|
|
|
58
60
|
error: boolean;
|
|
59
61
|
/** Error message shown below the slider while `error` is set; replaces the help text. */
|
|
60
62
|
errorText: string;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Size of the track and handle, from the M3 Expressive scale: `xs` (16px track, the default),
|
|
65
|
+
* `sm` (24px), `md` (40px), `lg` (56px) or `xl` (96px).
|
|
66
|
+
*/
|
|
67
|
+
size: ScaleSize;
|
|
68
|
+
/**
|
|
69
|
+
* Name of an icon shown inside the track, at its start (`md` and larger). It sits on the active
|
|
70
|
+
* part while it fits there, else just after the handle.
|
|
71
|
+
*/
|
|
72
|
+
icon?: string;
|
|
63
73
|
/**
|
|
64
74
|
* Where the value shows: `thumb` (on the thumb while it is used; the default), `end` (after the
|
|
65
75
|
* track) or `none`.
|
|
@@ -69,6 +79,9 @@ export declare class Slider extends InputBase {
|
|
|
69
79
|
valueText?: (value: number) => string;
|
|
70
80
|
/** True while the user is actively dragging the thumb. */
|
|
71
81
|
private isDragging;
|
|
82
|
+
/** Width of the track in px, for placing the inset icon. */
|
|
83
|
+
private trackWidth;
|
|
84
|
+
private resizeObserver?;
|
|
72
85
|
private container;
|
|
73
86
|
private thumbElement;
|
|
74
87
|
/** The value set by the consumer or the person; `undefined` means the midpoint. */
|
|
@@ -79,6 +92,8 @@ export declare class Slider extends InputBase {
|
|
|
79
92
|
/** Peacock's strings for the thumb label. */
|
|
80
93
|
private readonly i18n;
|
|
81
94
|
connectedCallback(): void;
|
|
95
|
+
firstUpdated(): void;
|
|
96
|
+
disconnectedCallback(): void;
|
|
82
97
|
focus(): void;
|
|
83
98
|
blur(): void;
|
|
84
99
|
formResetCallback(): void;
|
|
@@ -103,5 +118,10 @@ export declare class Slider extends InputBase {
|
|
|
103
118
|
private handleKeyDown;
|
|
104
119
|
/** A suggestion for a slider is a number. */
|
|
105
120
|
protected writeSuggestionValue(value: unknown): void;
|
|
121
|
+
/**
|
|
122
|
+
* The inset icon: on the active part of the track while it fits there, else on the inactive part
|
|
123
|
+
* just after the handle. Shown from `md` up, where the track is tall enough.
|
|
124
|
+
*/
|
|
125
|
+
private renderIcon;
|
|
106
126
|
render(): import("lit-html").TemplateResult<1>;
|
|
107
127
|
}
|
|
@@ -20,12 +20,17 @@ import { LitElement } from 'lit';
|
|
|
20
20
|
* disabled or hidden, the next enabled action (else the previous one) takes it over. Give the
|
|
21
21
|
* toolbar an <code>aria-label</code>.</p>
|
|
22
22
|
*
|
|
23
|
+
* <p>With <code>hide-on-scroll</code>, a floating toolbar slides away while the page scrolls down
|
|
24
|
+
* and comes back as soon as it scrolls up, the M3 Expressive behavior for a toolbar docked over
|
|
25
|
+
* long content. It stays while focus is inside it.</p>
|
|
26
|
+
*
|
|
23
27
|
* @cssprop --toolbar-container-color - Background color of the toolbar.
|
|
24
28
|
* @cssprop --toolbar-container-shape - Border radius of the floating toolbar.
|
|
25
29
|
* @cssprop --toolbar-padding - Padding of the floating toolbar.
|
|
26
30
|
* @cssprop --toolbar-gap - Gap between toolbar actions.
|
|
27
31
|
* @cssprop --toolbar-icon-color - Color of icons inside the toolbar.
|
|
28
32
|
* @cssprop --toolbar-content-color - Color of text inside the toolbar.
|
|
33
|
+
* @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.
|
|
29
34
|
* @cssprop --toolbar-wrap - `wrap` lets actions flow onto more lines when the toolbar is narrow. Defaults to `nowrap`.
|
|
30
35
|
*
|
|
31
36
|
* @example
|
|
@@ -73,10 +78,22 @@ export declare class Toolbar extends LitElement {
|
|
|
73
78
|
* (Left/Right for horizontal, Up/Down for vertical).
|
|
74
79
|
*/
|
|
75
80
|
orientation: 'horizontal' | 'vertical';
|
|
81
|
+
/**
|
|
82
|
+
* Color scheme of a floating toolbar: `standard` (surface container, the default) or `vibrant`
|
|
83
|
+
* (primary container), the M3 Expressive scheme for a toolbar that should stand out.
|
|
84
|
+
*/
|
|
85
|
+
color: 'standard' | 'vibrant';
|
|
76
86
|
/**
|
|
77
87
|
* Raises the floating toolbar to a higher elevation. Has no effect on the flat variant.
|
|
78
88
|
*/
|
|
79
89
|
elevated: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Slides the toolbar away while the page, or any scroll container in it, scrolls down, and back
|
|
92
|
+
* when it scrolls up. A horizontal toolbar moves down, a vertical one towards the end edge.
|
|
93
|
+
*/
|
|
94
|
+
hideOnScroll: boolean;
|
|
95
|
+
/** Whether `hide-on-scroll` has slid the toolbar away. */
|
|
96
|
+
private scrolledAway;
|
|
80
97
|
/** The toolbar's single tab stop, moved with the arrow keys along its orientation. */
|
|
81
98
|
private readonly roving;
|
|
82
99
|
/**
|
|
@@ -84,6 +101,8 @@ export declare class Toolbar extends LitElement {
|
|
|
84
101
|
* to the next enabled action instead of leaving the toolbar out of the Tab order.
|
|
85
102
|
*/
|
|
86
103
|
private readonly __actionStateObserver;
|
|
104
|
+
/** Last scroll offset seen per scroll container, and where the current run of scrolling began. */
|
|
105
|
+
private readonly __scrollOffsets;
|
|
87
106
|
connectedCallback(): void;
|
|
88
107
|
disconnectedCallback(): void;
|
|
89
108
|
updated(changed: Map<string, unknown>): void;
|
|
@@ -93,5 +112,6 @@ export declare class Toolbar extends LitElement {
|
|
|
93
112
|
*/
|
|
94
113
|
private __getItems;
|
|
95
114
|
private __handleSlotChange;
|
|
115
|
+
private __handleScroll;
|
|
96
116
|
render(): import("lit-html").TemplateResult<1>;
|
|
97
117
|
}
|
package/dist/step.js
CHANGED
|
@@ -100,7 +100,7 @@ var css_248z = i`* {
|
|
|
100
100
|
background: var(--color-on-surface);
|
|
101
101
|
opacity: 0;
|
|
102
102
|
pointer-events: none;
|
|
103
|
-
transition: opacity var(--duration
|
|
103
|
+
transition: opacity var(--motion-spring-fast-effects-duration) var(--motion-spring-fast-effects-easing);
|
|
104
104
|
}
|
|
105
105
|
.step.clickable:hover::before {
|
|
106
106
|
opacity: 0.08;
|
package/dist/switch.js
CHANGED
|
@@ -91,7 +91,7 @@ var css_248z = i`* {
|
|
|
91
91
|
border-radius: var(--shape-corner-full);
|
|
92
92
|
cursor: pointer;
|
|
93
93
|
display: flex;
|
|
94
|
-
transition: background-color var(--duration
|
|
94
|
+
transition: background-color var(--motion-spring-fast-effects-duration) var(--motion-spring-fast-effects-easing), border-color var(--motion-spring-fast-effects-duration) var(--motion-spring-fast-effects-easing);
|
|
95
95
|
align-items: center;
|
|
96
96
|
width: var(--_container-width);
|
|
97
97
|
height: var(--_container-height);
|
|
@@ -102,7 +102,7 @@ var css_248z = i`* {
|
|
|
102
102
|
align-items: center;
|
|
103
103
|
justify-content: center;
|
|
104
104
|
border-radius: var(--shape-corner-full);
|
|
105
|
-
transition:
|
|
105
|
+
transition: margin-inline-start var(--motion-spring-fast-spatial-duration) var(--motion-spring-fast-spatial-easing), width var(--motion-spring-fast-spatial-duration) var(--motion-spring-fast-spatial-easing), height var(--motion-spring-fast-spatial-duration) var(--motion-spring-fast-spatial-easing), background-color var(--motion-spring-fast-effects-duration) var(--motion-spring-fast-effects-easing);
|
|
106
106
|
height: var(--switch-handle-radius);
|
|
107
107
|
width: var(--switch-handle-radius);
|
|
108
108
|
background: var(--switch-handle-color);
|
|
@@ -150,6 +150,9 @@ var css_248z = i`* {
|
|
|
150
150
|
--switch-handle-radius: 22px;
|
|
151
151
|
--switch-handle-color: var(--color-surface-container-lowest);
|
|
152
152
|
}
|
|
153
|
+
.switch.active:not(.disabled, .readonly) {
|
|
154
|
+
--switch-handle-radius: 26px;
|
|
155
|
+
}
|
|
153
156
|
|
|
154
157
|
.switch.readonly {
|
|
155
158
|
cursor: default;
|
package/dist/switch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sources":["../../src/switch/switch.ts"],"sourcesContent":["import { html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport '@/__internal/agent/toggle-surface.js';\nimport type { AgentToggleChangeEvent } from '@/__internal/agent/toggle-surface.js';\nimport { spread } from '@/__internal/directive/spread.js';\nimport { peacockString } from '@/__internal/i18n/strings.js';\nimport ToggleBase from '@/__internal/toggle-base.js';\n\nimport styles from './switch.scss';\n\n/**\n * @label Switch\n * @tag wc-switch\n * @rawTag switch\n *\n * @summary An on and off switch for a single setting, such as turning notifications on.\n * @overview\n * <p>The switch is form-associated: when <code>checked</code>, it submits its <code>value</code>\n * (<code>on</code> by default) under its <code>name</code>. With <code>required</code> it blocks form\n * submission until it is on.</p>\n *\n * @cssprop --switch-track-color: Color of the switch track when checked.\n * @cssprop --switch-track-off-color: Color of the switch track when unchecked.\n * @cssprop --switch-width: Width of the switch track.\n * @cssprop --switch-height: Height of the switch track.\n * @cssprop --switch-handle-radius: Size of the switch handle.\n * @cssprop --switch-handle-color: Color of the switch handle.\n *\n * @fires {CustomEvent<{checked: boolean, value: string, originalEvent?: Event}>} change - Dispatched when the switch is toggled.\n *\n * @example\n * ```html\n * <wc-switch checked label=\"Wi-Fi\"></wc-switch>\n * ```\n * @tags input, form\n */\nexport class Switch extends ToggleBase {\n // ── Static ───────────────────────────────────────────────────────────────\n\n static styles = [styles];\n\n // ── Properties ───────────────────────────────────────────────────────────\n // `name`, `disabled`, `required`, `readonly`, `label`, `checked`, `value` and `configAria` are\n // inherited.\n\n /**\n * If true, the toggle has rounded corners. Defaults to `true`.\n */\n @property({ type: Boolean })\n rounded: boolean = true;\n\n /** Shows a check icon in the handle when on and a close icon when off. */\n @property({ type: Boolean, reflect: true, attribute: 'with-icon' })\n withIcon: boolean = false;\n\n // ── Protected methods ────────────────────────────────────────────────────\n\n protected override valueMissingText(): string {\n return peacockString('valueMissingCheckbox');\n }\n\n // ── Private methods ──────────────────────────────────────────────────────\n\n private keyDownHandler = (event: KeyboardEvent) => {\n if (event.key === ' ') {\n event.preventDefault();\n this.isActive = true;\n this.toggleChecked(event);\n }\n };\n\n private clickHandler = (event: MouseEvent) => {\n this.toggleChecked(event);\n };\n\n // ── Render helpers ───────────────────────────────────────────────────────\n\n private renderIcon() {\n if (!this.withIcon) return nothing;\n return this.checked\n ? html`<wc-icon name=\"check\" class=\"icon\"></wc-icon>`\n : html`<wc-icon name=\"close\" class=\"icon\"></wc-icon>`;\n }\n\n /** An agent's change, applied as a click would be; disabled and read-only switches refuse it. */\n private _handleAgentChange(event: AgentToggleChangeEvent) {\n event.stopPropagation();\n if (!this.applyAgentChange(event.detail.value)) event.preventDefault();\n }\n\n // ── Render ───────────────────────────────────────────────────────────────\n\n render() {\n const cssClasses = {\n switch: true,\n 'state-checked': this.checked,\n 'has-focus': this.hasFocus,\n active: this.isActive,\n disabled: this.disabled,\n readonly: this.readonly,\n required: this.required,\n rounded: this.rounded,\n 'has-content': this.slotHasContent,\n };\n\n return html`\n <label class=${classMap(cssClasses)}>\n <agent-switch\n .checked=${!!this.checked}\n .disabled=${this.disabled || !this.agentAvailable}\n .readOnly=${this.readonly}\n .required=${this.required}\n @checkedchange=${this._handleAgentChange}\n >\n <div\n class=\"track container\"\n role=\"switch\"\n aria-checked=${String(this.checked)}\n @mousedown=${this.handleMouseDown}\n @keydown=${this.keyDownHandler}\n @focus=${this.handleFocusChange}\n @blur=${this.handleFocusChange}\n ${spread({\n ...this.controlAttributes(),\n // Named for the agent bridge (ADR-030004): its name comes from the label or slotted text.\n 'aria-label': this.label || this.textContent?.trim() || undefined,\n })}\n >\n <div class=\"handle\">${this.renderIcon()}</div>\n </div>\n </agent-switch>\n\n <input\n type=\"checkbox\"\n class=\"input-native\"\n .checked=${this.checked}\n aria-hidden=\"true\"\n tabindex=\"-1\"\n @click=${this.clickHandler}\n />\n\n ${this.renderLabel()}\n </label>\n `;\n }\n}\n"],"names":["nothing","html","classMap","styles","property"],"mappings":"
|
|
1
|
+
{"version":3,"file":"switch.js","sources":["../../src/switch/switch.ts"],"sourcesContent":["import { html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport '@/__internal/agent/toggle-surface.js';\nimport type { AgentToggleChangeEvent } from '@/__internal/agent/toggle-surface.js';\nimport { spread } from '@/__internal/directive/spread.js';\nimport { peacockString } from '@/__internal/i18n/strings.js';\nimport ToggleBase from '@/__internal/toggle-base.js';\n\nimport styles from './switch.scss';\n\n/**\n * @label Switch\n * @tag wc-switch\n * @rawTag switch\n *\n * @summary An on and off switch for a single setting, such as turning notifications on.\n * @overview\n * <p>The switch is form-associated: when <code>checked</code>, it submits its <code>value</code>\n * (<code>on</code> by default) under its <code>name</code>. With <code>required</code> it blocks form\n * submission until it is on.</p>\n *\n * @cssprop --switch-track-color: Color of the switch track when checked.\n * @cssprop --switch-track-off-color: Color of the switch track when unchecked.\n * @cssprop --switch-width: Width of the switch track.\n * @cssprop --switch-height: Height of the switch track.\n * @cssprop --switch-handle-radius: Size of the switch handle.\n * @cssprop --switch-handle-color: Color of the switch handle.\n *\n * @fires {CustomEvent<{checked: boolean, value: string, originalEvent?: Event}>} change - Dispatched when the switch is toggled.\n *\n * @example\n * ```html\n * <wc-switch checked label=\"Wi-Fi\"></wc-switch>\n * ```\n * @tags input, form\n */\nexport class Switch extends ToggleBase {\n // ── Static ───────────────────────────────────────────────────────────────\n\n static styles = [styles];\n\n // ── Properties ───────────────────────────────────────────────────────────\n // `name`, `disabled`, `required`, `readonly`, `label`, `checked`, `value` and `configAria` are\n // inherited.\n\n /**\n * If true, the toggle has rounded corners. Defaults to `true`.\n */\n @property({ type: Boolean })\n rounded: boolean = true;\n\n /** Shows a check icon in the handle when on and a close icon when off. */\n @property({ type: Boolean, reflect: true, attribute: 'with-icon' })\n withIcon: boolean = false;\n\n // ── Protected methods ────────────────────────────────────────────────────\n\n protected override valueMissingText(): string {\n return peacockString('valueMissingCheckbox');\n }\n\n // ── Private methods ──────────────────────────────────────────────────────\n\n private keyDownHandler = (event: KeyboardEvent) => {\n if (event.key === ' ') {\n event.preventDefault();\n this.isActive = true;\n this.toggleChecked(event);\n }\n };\n\n private clickHandler = (event: MouseEvent) => {\n this.toggleChecked(event);\n };\n\n // ── Render helpers ───────────────────────────────────────────────────────\n\n private renderIcon() {\n if (!this.withIcon) return nothing;\n return this.checked\n ? html`<wc-icon name=\"check\" class=\"icon\"></wc-icon>`\n : html`<wc-icon name=\"close\" class=\"icon\"></wc-icon>`;\n }\n\n /** An agent's change, applied as a click would be; disabled and read-only switches refuse it. */\n private _handleAgentChange(event: AgentToggleChangeEvent) {\n event.stopPropagation();\n if (!this.applyAgentChange(event.detail.value)) event.preventDefault();\n }\n\n // ── Render ───────────────────────────────────────────────────────────────\n\n render() {\n const cssClasses = {\n switch: true,\n 'state-checked': this.checked,\n 'has-focus': this.hasFocus,\n active: this.isActive,\n disabled: this.disabled,\n readonly: this.readonly,\n required: this.required,\n rounded: this.rounded,\n 'has-content': this.slotHasContent,\n };\n\n return html`\n <label class=${classMap(cssClasses)}>\n <agent-switch\n .checked=${!!this.checked}\n .disabled=${this.disabled || !this.agentAvailable}\n .readOnly=${this.readonly}\n .required=${this.required}\n @checkedchange=${this._handleAgentChange}\n >\n <div\n class=\"track container\"\n role=\"switch\"\n aria-checked=${String(this.checked)}\n @mousedown=${this.handleMouseDown}\n @keydown=${this.keyDownHandler}\n @focus=${this.handleFocusChange}\n @blur=${this.handleFocusChange}\n ${spread({\n ...this.controlAttributes(),\n // Named for the agent bridge (ADR-030004): its name comes from the label or slotted text.\n 'aria-label': this.label || this.textContent?.trim() || undefined,\n })}\n >\n <div class=\"handle\">${this.renderIcon()}</div>\n </div>\n </agent-switch>\n\n <input\n type=\"checkbox\"\n class=\"input-native\"\n .checked=${this.checked}\n aria-hidden=\"true\"\n tabindex=\"-1\"\n @click=${this.clickHandler}\n />\n\n ${this.renderLabel()}\n </label>\n `;\n }\n}\n"],"names":["nothing","html","classMap","styles","property"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACG,MAAO,MAAO,SAAQ,UAAU,CAAA;AAAtC,IAAA,WAAA,GAAA;;;;;;AASE;;AAEG;QAEH,IAAA,CAAA,OAAO,GAAY,IAAI;;QAIvB,IAAA,CAAA,QAAQ,GAAY,KAAK;;AAUjB,QAAA,IAAA,CAAA,cAAc,GAAG,CAAC,KAAoB,KAAI;AAChD,YAAA,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,EAAE;gBACrB,KAAK,CAAC,cAAc,EAAE;AACtB,gBAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACpB,gBAAA,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;YAC3B;AACF,QAAA,CAAC;AAEO,QAAA,IAAA,CAAA,YAAY,GAAG,CAAC,KA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AAA,EAAA,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;AACtB,uBAAA,EAAA,IAAI,CAAC,eAAe;AACtB,qBAAA,EAAA,IAAI,CAAC,cAAc;AACrB,mBAAA,EAAA,IAAI,CAAC,iBAAiB;AACvB,kBAAA,EAAA,IAAI,CAAC,iBAAiB;AAC5B,YAAA,EAAA,MAAM,CAAC;YACP,GAAG,IAAI,CAAC,iBAAiB,EAAE;;AAE3B,YAAA,YAAY,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,SAAS;SAClE,CAAC;;kCAEoB,IAAI,CAAC,UAAU,EAAE,CAAA;;;;;;;AAO9B,mBAAA,EAAA,IAAI,CAAC,OAAO;;;AAGd,iBAAA,EAAA,IAAI,CAAC,YAAY;;;UAG1B,IAAI,CAAC,WAAW,EAAE;;KAEvB;IACH;;AAzGO,MAAA,CAAA,MAAM,GAAG,CAACC,QAAM,CAAC;AAUxB,UAAA,CAAA;AADC,IAAAC,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;AACH,CAAA,EAAA,MAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAIxB,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;AACxC,CAAA,EAAA,MAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;;;;"}
|
package/dist/tab-group.js
CHANGED
|
@@ -182,9 +182,20 @@ class TabGroup extends i$1 {
|
|
|
182
182
|
tab.classList.toggle('previous-tab', index >= 0 && i === index - 1);
|
|
183
183
|
tab.classList.toggle('next-tab', index >= 0 && i === index + 1);
|
|
184
184
|
});
|
|
185
|
-
this.getTabPanels()
|
|
185
|
+
const panels = this.getTabPanels();
|
|
186
|
+
const shown = panels.findIndex(panel => panel.active);
|
|
187
|
+
panels.forEach((panel, i) => {
|
|
188
|
+
const active = keyed ? panel.getAttribute('value') === key : i === index;
|
|
189
|
+
// M3 Expressive: a newly shown panel slides in from the side it sits on relative to the
|
|
190
|
+
// panel it replaces. The first panel shown does not move.
|
|
191
|
+
if (active && !panel.active && shown >= 0) {
|
|
192
|
+
panel.setAttribute('data-enter', i > shown ? 'end' : 'start');
|
|
193
|
+
}
|
|
194
|
+
else if (!active) {
|
|
195
|
+
panel.removeAttribute('data-enter');
|
|
196
|
+
}
|
|
186
197
|
// eslint-disable-next-line no-param-reassign
|
|
187
|
-
panel.active =
|
|
198
|
+
panel.active = active;
|
|
188
199
|
});
|
|
189
200
|
}
|
|
190
201
|
/** Links each tab and its panel, and makes sure one tab is selected. */
|
package/dist/tab-group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-group.js","sources":["../../src/tabs/tab-group.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport styles from './tab-group.scss';\nimport { Tabs, type TabsChangeDetail } from './tabs.js';\nimport { TabPanel } from './tab-panel.js';\nimport type { Tab } from './tab.js';\n\n/** The key that links a tab to its panel: the tab's `value`. */\nfunction tabKey(tab: HTMLElement): string | null {\n return tab.getAttribute('value') || (tab as Tab).value || null;\n}\n\n/** Gives `element` an id if it has none, so ARIA attributes can point at it. */\nfunction ensureId(element: HTMLElement, prefix: string): string {\n if (!element.id) {\n // eslint-disable-next-line no-param-reassign\n element.id = `${prefix}-${crypto.randomUUID()}`;\n }\n return element.id;\n}\n\n/**\n * @label Tab Group\n * @tag wc-tab-group\n * @rawTag tab-group\n *\n * @summary Pairs a row of tabs with their panels and shows the panel of the selected tab.\n * @overview\n * <p>Tabs and panels are matched by <code>value</code> (<code><wc-tab value=\"billing\"></code> shows\n * <code><wc-tab-panel value=\"billing\"></code>), or by position when no tab has a value.</p>\n * <p>The group wires the tabs pattern: each panel is labelled by its tab, and each tab points at\n * its panel. Tabs and panels added later are wired too. When the <code>wc-tabs</code> is\n * <code>managed</code>, the group leaves the selection to the consumer.</p>\n *\n * @example\n * ```html\n * <wc-tab-group>\n * <wc-tabs aria-label=\"Sections\">\n * <wc-tab selected>Tab 1</wc-tab>\n * <wc-tab>Tab 2</wc-tab>\n * </wc-tabs>\n *\n * <wc-tab-panel>Panel 1</wc-tab-panel>\n * <wc-tab-panel>Panel 2</wc-tab-panel>\n * </wc-tab-group>\n * ```\n * @tags navigation\n */\nexport class TabGroup extends LitElement {\n // ── Static\n\n static styles = [styles];\n\n static Tabs = Tabs;\n\n static TabPanel = TabPanel;\n\n // ── Private fields\n\n /** Re-wires when tabs or panels are added or removed, including tabs inside `wc-tabs`. */\n private readonly __observer = new MutationObserver(records => {\n const relevant = records.some(\n record =>\n record.target === this ||\n (record.target instanceof Element &&\n record.target.localName === 'wc-tabs'),\n );\n if (relevant) this.__sync();\n });\n\n // ── Lifecycle\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('change', this.__handleChange);\n this.__observer.observe(this, { childList: true, subtree: true });\n }\n\n disconnectedCallback() {\n this.removeEventListener('change', this.__handleChange);\n this.__observer.disconnect();\n super.disconnectedCallback();\n }\n\n firstUpdated() {\n this.__sync();\n }\n\n // ── Public\n\n /** Selects the tab whose key (`value`) is `target`, and shows its panel. */\n selectTab(target: string) {\n const index = this.getTabs().findIndex(tab => tabKey(tab) === target);\n this.__select(index, target);\n }\n\n /** Selects the tab at `index`, and shows the panel at the same position. */\n selectTabByIndex(index: number) {\n this.__select(index, null);\n }\n\n // ── Private\n\n private getTabs(): Tab[] {\n return Array.from(this.querySelectorAll<Tab>(':scope > wc-tabs wc-tab'));\n }\n\n private getTabPanels(): TabPanel[] {\n return Array.from(this.querySelectorAll<TabPanel>(':scope > wc-tab-panel'));\n }\n\n private getTabList(): Tabs | null {\n return this.querySelector<Tabs>(':scope > wc-tabs');\n }\n\n private tabsHaveKey(): boolean {\n return this.getTabs().some(tab => tabKey(tab) !== null);\n }\n\n /** The panel for the tab at `index`: by key when tabs have keys, else by position. */\n private __panelFor(tab: Tab, index: number, keyed: boolean) {\n const panels = this.getTabPanels();\n if (!keyed) return panels[index] ?? null;\n const key = tabKey(tab);\n return key === null\n ? null\n : (panels.find(panel => panel.getAttribute('value') === key) ?? null);\n }\n\n private __select(index: number, key: string | null) {\n const tabs = this.getTabs();\n const keyed = key !== null;\n tabs.forEach((tab, i) => {\n /* eslint-disable no-param-reassign */\n tab.selected = i === index;\n /* eslint-enable no-param-reassign */\n tab.classList.toggle('previous-tab', index >= 0 && i === index - 1);\n tab.classList.toggle('next-tab', index >= 0 && i === index + 1);\n });\n\n this.getTabPanels().forEach((panel, i) => {\n // eslint-disable-next-line no-param-reassign\n panel.active = keyed ? panel.getAttribute('value') === key : i === index;\n });\n }\n\n /** Links each tab and its panel, and makes sure one tab is selected. */\n private __sync() {\n const tabs = this.getTabs();\n const keyed = this.tabsHaveKey();\n\n tabs.forEach((tab, index) => {\n const panel = this.__panelFor(tab, index, keyed);\n // eslint-disable-next-line no-param-reassign\n tab.panel = panel;\n if (panel) {\n panel.setAttribute('aria-labelledby', ensureId(tab, 'wc-tab'));\n ensureId(panel, 'wc-tab-panel');\n }\n });\n\n const selected = tabs.findIndex(tab => tab.selected);\n const index = selected >= 0 ? selected : 0;\n if (tabs.length === 0) return;\n if (keyed) {\n const key = tabKey(tabs[index]);\n if (key !== null) this.__select(index, key);\n } else {\n this.__select(index, null);\n }\n }\n\n private __handleChange = (event: Event) => {\n // Only the group's own tab list; a `change` from a field inside a panel is not a tab change.\n const tabList = this.getTabList();\n if (!tabList || event.target !== tabList || tabList.managed) return;\n const { detail } = event as CustomEvent<TabsChangeDetail>;\n const tab = this.getTabs()[detail.index];\n const key = tab ? tabKey(tab) : null;\n if (key !== null && this.tabsHaveKey()) this.selectTab(key);\n else this.selectTabByIndex(detail.index);\n };\n\n // ── Render\n\n render() {\n return html`<slot @slotchange=${() => this.__sync()}></slot>`;\n }\n}\n"],"names":["LitElement","html","styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;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KAAK,EAAE,IAAI,CAAC;QAC5B;IACF;;IAeA,MAAM,GAAA;QACJ,OAAOC,CAAI,CAAA,CAAA,kBAAA,EAAqB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA,QAAA,CAAU;IAC/D;;AAxIO,QAAA,CAAA,MAAM,GAAG,CAACC,QAAM,CAAC;AAEjB,QAAA,CAAA,IAAI,GAAG,IAAH;AAEJ,QAAA,CAAA,QAAQ,GAAG,QAAH;;;;"}
|
|
1
|
+
{"version":3,"file":"tab-group.js","sources":["../../src/tabs/tab-group.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport styles from './tab-group.scss';\nimport { Tabs, type TabsChangeDetail } from './tabs.js';\nimport { TabPanel } from './tab-panel.js';\nimport type { Tab } from './tab.js';\n\n/** The key that links a tab to its panel: the tab's `value`. */\nfunction tabKey(tab: HTMLElement): string | null {\n return tab.getAttribute('value') || (tab as Tab).value || null;\n}\n\n/** Gives `element` an id if it has none, so ARIA attributes can point at it. */\nfunction ensureId(element: HTMLElement, prefix: string): string {\n if (!element.id) {\n // eslint-disable-next-line no-param-reassign\n element.id = `${prefix}-${crypto.randomUUID()}`;\n }\n return element.id;\n}\n\n/**\n * @label Tab Group\n * @tag wc-tab-group\n * @rawTag tab-group\n *\n * @summary Pairs a row of tabs with their panels and shows the panel of the selected tab.\n * @overview\n * <p>Tabs and panels are matched by <code>value</code> (<code><wc-tab value=\"billing\"></code> shows\n * <code><wc-tab-panel value=\"billing\"></code>), or by position when no tab has a value.</p>\n * <p>The group wires the tabs pattern: each panel is labelled by its tab, and each tab points at\n * its panel. Tabs and panels added later are wired too. When the <code>wc-tabs</code> is\n * <code>managed</code>, the group leaves the selection to the consumer.</p>\n *\n * @example\n * ```html\n * <wc-tab-group>\n * <wc-tabs aria-label=\"Sections\">\n * <wc-tab selected>Tab 1</wc-tab>\n * <wc-tab>Tab 2</wc-tab>\n * </wc-tabs>\n *\n * <wc-tab-panel>Panel 1</wc-tab-panel>\n * <wc-tab-panel>Panel 2</wc-tab-panel>\n * </wc-tab-group>\n * ```\n * @tags navigation\n */\nexport class TabGroup extends LitElement {\n // ── Static\n\n static styles = [styles];\n\n static Tabs = Tabs;\n\n static TabPanel = TabPanel;\n\n // ── Private fields\n\n /** Re-wires when tabs or panels are added or removed, including tabs inside `wc-tabs`. */\n private readonly __observer = new MutationObserver(records => {\n const relevant = records.some(\n record =>\n record.target === this ||\n (record.target instanceof Element &&\n record.target.localName === 'wc-tabs'),\n );\n if (relevant) this.__sync();\n });\n\n // ── Lifecycle\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('change', this.__handleChange);\n this.__observer.observe(this, { childList: true, subtree: true });\n }\n\n disconnectedCallback() {\n this.removeEventListener('change', this.__handleChange);\n this.__observer.disconnect();\n super.disconnectedCallback();\n }\n\n firstUpdated() {\n this.__sync();\n }\n\n // ── Public\n\n /** Selects the tab whose key (`value`) is `target`, and shows its panel. */\n selectTab(target: string) {\n const index = this.getTabs().findIndex(tab => tabKey(tab) === target);\n this.__select(index, target);\n }\n\n /** Selects the tab at `index`, and shows the panel at the same position. */\n selectTabByIndex(index: number) {\n this.__select(index, null);\n }\n\n // ── Private\n\n private getTabs(): Tab[] {\n return Array.from(this.querySelectorAll<Tab>(':scope > wc-tabs wc-tab'));\n }\n\n private getTabPanels(): TabPanel[] {\n return Array.from(this.querySelectorAll<TabPanel>(':scope > wc-tab-panel'));\n }\n\n private getTabList(): Tabs | null {\n return this.querySelector<Tabs>(':scope > wc-tabs');\n }\n\n private tabsHaveKey(): boolean {\n return this.getTabs().some(tab => tabKey(tab) !== null);\n }\n\n /** The panel for the tab at `index`: by key when tabs have keys, else by position. */\n private __panelFor(tab: Tab, index: number, keyed: boolean) {\n const panels = this.getTabPanels();\n if (!keyed) return panels[index] ?? null;\n const key = tabKey(tab);\n return key === null\n ? null\n : (panels.find(panel => panel.getAttribute('value') === key) ?? null);\n }\n\n private __select(index: number, key: string | null) {\n const tabs = this.getTabs();\n const keyed = key !== null;\n tabs.forEach((tab, i) => {\n /* eslint-disable no-param-reassign */\n tab.selected = i === index;\n /* eslint-enable no-param-reassign */\n tab.classList.toggle('previous-tab', index >= 0 && i === index - 1);\n tab.classList.toggle('next-tab', index >= 0 && i === index + 1);\n });\n\n const panels = this.getTabPanels();\n const shown = panels.findIndex(panel => panel.active);\n panels.forEach((panel, i) => {\n const active = keyed ? panel.getAttribute('value') === key : i === index;\n // M3 Expressive: a newly shown panel slides in from the side it sits on relative to the\n // panel it replaces. The first panel shown does not move.\n if (active && !panel.active && shown >= 0) {\n panel.setAttribute('data-enter', i > shown ? 'end' : 'start');\n } else if (!active) {\n panel.removeAttribute('data-enter');\n }\n // eslint-disable-next-line no-param-reassign\n panel.active = active;\n });\n }\n\n /** Links each tab and its panel, and makes sure one tab is selected. */\n private __sync() {\n const tabs = this.getTabs();\n const keyed = this.tabsHaveKey();\n\n tabs.forEach((tab, index) => {\n const panel = this.__panelFor(tab, index, keyed);\n // eslint-disable-next-line no-param-reassign\n tab.panel = panel;\n if (panel) {\n panel.setAttribute('aria-labelledby', ensureId(tab, 'wc-tab'));\n ensureId(panel, 'wc-tab-panel');\n }\n });\n\n const selected = tabs.findIndex(tab => tab.selected);\n const index = selected >= 0 ? selected : 0;\n if (tabs.length === 0) return;\n if (keyed) {\n const key = tabKey(tabs[index]);\n if (key !== null) this.__select(index, key);\n } else {\n this.__select(index, null);\n }\n }\n\n private __handleChange = (event: Event) => {\n // Only the group's own tab list; a `change` from a field inside a panel is not a tab change.\n const tabList = this.getTabList();\n if (!tabList || event.target !== tabList || tabList.managed) return;\n const { detail } = event as CustomEvent<TabsChangeDetail>;\n const tab = this.getTabs()[detail.index];\n const key = tab ? tabKey(tab) : null;\n if (key !== null && this.tabsHaveKey()) this.selectTab(key);\n else this.selectTabByIndex(detail.index);\n };\n\n // ── Render\n\n render() {\n return html`<slot @slotchange=${() => this.__sync()}></slot>`;\n }\n}\n"],"names":["LitElement","html","styles"],"mappings":";;;;;;;;;;;;;;;;;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AM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC;AACpD,QAAA,MAAM,KAAK,GAAG,QAAQ,IAAI,CAAC,GAAG,QAAQ,GAAG,CAAC;AAC1C,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE;QACvB,IAAI,KAAK,EAAE;YACT,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,GAAG,KAAK,IAAI;AAAE,gBAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC;QAC7C;aAAO;AACL,YAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;QAC5B;IACF;;IAeA,MAAM,GAAA;QACJ,OAAOC,CAAI,CAAA,CAAA,kBAAA,EAAqB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA,QAAA,CAAU;IAC/D;;AAlJO,QAAA,CAAA,MAAM,GAAG,CAACC,QAAM,CAAC;AAEjB,QAAA,CAAA,IAAI,GAAG,IAAH;AAEJ,QAAA,CAAA,QAAQ,GAAG,QAAH;;;;"}
|
package/dist/tab-panel.js
CHANGED
|
@@ -43,6 +43,32 @@ var css_248z = i`* {
|
|
|
43
43
|
|
|
44
44
|
:host([active]) {
|
|
45
45
|
display: block;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@keyframes tab-panel-enter {
|
|
49
|
+
from {
|
|
50
|
+
translate: var(--_tab-panel-enter-offset) 0;
|
|
51
|
+
opacity: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
:host([active][data-enter]) {
|
|
55
|
+
--_tab-panel-enter-offset: 2rem;
|
|
56
|
+
animation-name: tab-panel-enter;
|
|
57
|
+
animation-duration: var(--motion-spring-default-spatial-duration);
|
|
58
|
+
animation-timing-function: var(--motion-spring-default-spatial-easing);
|
|
59
|
+
animation-fill-mode: backwards;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
:host([active][data-enter=start]) {
|
|
63
|
+
--_tab-panel-enter-offset: -2rem;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host([active][data-enter=end]:dir(rtl)) {
|
|
67
|
+
--_tab-panel-enter-offset: -2rem;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:host([active][data-enter=start]:dir(rtl)) {
|
|
71
|
+
--_tab-panel-enter-offset: 2rem;
|
|
46
72
|
}`;
|
|
47
73
|
|
|
48
74
|
/**
|
package/dist/tab-panel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-panel.js","sources":["../../src/tabs/tab-panel.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport styles from './tab-panel.scss';\n\n/**\n * @label Tab Panel\n * @tag wc-tab-panel\n * @rawTag tab-panel\n *\n * @summary The content of one tab, shown while that tab is selected.\n * @overview\n * <p>The panel has <code>role=\"tabpanel\"</code>;\n * inside a <code>wc-tab-group</code> it is labelled by its tab (<code>aria-labelledby</code>) and\n * shown while that tab is selected. It is focusable, so keyboard users reach the content right\n * after the tab list.</p>\n *\n * @example\n * ```html\n * <wc-tab-panel>Content for this tab</wc-tab-panel>\n * ```\n * @tags navigation\n */\nexport class TabPanel extends LitElement {\n // ── Static\n\n static styles = [styles];\n\n // ── Properties\n\n /** Links the panel to the `wc-tab` with the same `value`. */\n @property({ reflect: true }) value?: string;\n\n /** Whether the panel is shown; set by `wc-tab-group` from the selected tab. */\n @property({ type: Boolean, reflect: true }) active = false;\n\n // ── Lifecycle\n\n override connectedCallback() {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'tabpanel');\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n }\n\n // ── Render\n\n render() {\n return html`<slot></slot>`;\n }\n}\n"],"names":["LitElement","html","styles","property"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tab-panel.js","sources":["../../src/tabs/tab-panel.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport styles from './tab-panel.scss';\n\n/**\n * @label Tab Panel\n * @tag wc-tab-panel\n * @rawTag tab-panel\n *\n * @summary The content of one tab, shown while that tab is selected.\n * @overview\n * <p>The panel has <code>role=\"tabpanel\"</code>;\n * inside a <code>wc-tab-group</code> it is labelled by its tab (<code>aria-labelledby</code>) and\n * shown while that tab is selected. It is focusable, so keyboard users reach the content right\n * after the tab list.</p>\n *\n * @example\n * ```html\n * <wc-tab-panel>Content for this tab</wc-tab-panel>\n * ```\n * @tags navigation\n */\nexport class TabPanel extends LitElement {\n // ── Static\n\n static styles = [styles];\n\n // ── Properties\n\n /** Links the panel to the `wc-tab` with the same `value`. */\n @property({ reflect: true }) value?: string;\n\n /** Whether the panel is shown; set by `wc-tab-group` from the selected tab. */\n @property({ type: Boolean, reflect: true }) active = false;\n\n // ── Lifecycle\n\n override connectedCallback() {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'tabpanel');\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n }\n\n // ── Render\n\n render() {\n return html`<slot></slot>`;\n }\n}\n"],"names":["LitElement","html","styles","property"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;;;;;;;;;;;;AAiBG;AACG,MAAO,QAAS,SAAQA,GAAU,CAAA;AAAxC,IAAA,WAAA,GAAA;;;;QAW8C,IAAA,CAAA,MAAM,GAAG,KAAK;IAe5D;;IAXW,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;AACzB,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;AAAE,YAAA,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC;AACrE,QAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;AAAE,YAAA,IAAI,CAAC,QAAQ,GAAG,CAAC;IACvD;;IAIA,MAAM,GAAA;QACJ,OAAOC,CAAI,CAAA,CAAA,aAAA,CAAe;IAC5B;;AAtBO,QAAA,CAAA,MAAM,GAAG,CAACC,QAAM,CAAC;AAKK,UAAA,CAAA;AAA5B,IAAAC,CAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;AAAiB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;AAGA,UAAA,CAAA;IAA3CA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAAiB,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;;;;"}
|