@redvars/peacock 3.3.3 → 3.5.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/IndividualComponent-DUINtMGK.js +67 -0
- package/dist/IndividualComponent-DUINtMGK.js.map +1 -0
- package/dist/assets/images/empty-state/no-document.svg +11 -12
- package/dist/assets/images/empty-state/page.svg +15 -9
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/banner.js +202 -0
- package/dist/banner.js.map +1 -0
- package/dist/bottom-sheet.js +238 -0
- package/dist/bottom-sheet.js.map +1 -0
- package/dist/{button-ClzS8JLq.js → button-DMN1dPAg.js} +358 -218
- package/dist/button-DMN1dPAg.js.map +1 -0
- package/dist/button-group-CX9CUUXk.js +435 -0
- package/dist/button-group-CX9CUUXk.js.map +1 -0
- package/dist/button-group.js +11 -6
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +10 -5
- package/dist/button.js.map +1 -1
- package/dist/card-content.js +29 -0
- package/dist/card-content.js.map +1 -0
- package/dist/card.js +428 -44
- package/dist/card.js.map +1 -1
- package/dist/{chart-bar-DbnXQgvS.js → chart-bar-cn6rrna-.js} +2 -2
- package/dist/{chart-bar-DbnXQgvS.js.map → chart-bar-cn6rrna-.js.map} +1 -1
- package/dist/chart-bar.js +5 -4
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-doughnut.js +2 -1
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-pie.js +2 -1
- package/dist/chart-pie.js.map +1 -1
- package/dist/chart-stacked-bar.js +5 -4
- package/dist/chart-stacked-bar.js.map +1 -1
- package/dist/{class-map-59YGWLnx.js → class-map-YU7g0o3B.js} +4 -10
- package/dist/class-map-YU7g0o3B.js.map +1 -0
- package/dist/clock.js +2 -1
- package/dist/clock.js.map +1 -1
- package/dist/code-editor.js +8 -6
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +6 -4
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +6270 -5026
- package/dist/custom-elements.json +5763 -2049
- package/dist/directive-ZPhl09Yt.js +9 -0
- package/dist/directive-ZPhl09Yt.js.map +1 -0
- package/dist/dispatch-event-utils-CuEqjlPT.js +127 -0
- package/dist/dispatch-event-utils-CuEqjlPT.js.map +1 -0
- package/dist/fab-C5Nzxk0E.js +497 -0
- package/dist/fab-C5Nzxk0E.js.map +1 -0
- package/dist/fab.js +11 -0
- package/dist/fab.js.map +1 -0
- package/dist/index.js +24 -12
- package/dist/index.js.map +1 -1
- package/dist/{observe-theme-change-pALI5fmV.js → is-dark-mode-DicqGkCJ.js} +8 -3
- package/dist/is-dark-mode-DicqGkCJ.js.map +1 -0
- package/dist/notification.js +417 -0
- package/dist/notification.js.map +1 -0
- package/dist/number-counter.js +4 -3
- package/dist/number-counter.js.map +1 -1
- package/dist/observe-slot-change-BGJfgg2E.js +31 -0
- package/dist/observe-slot-change-BGJfgg2E.js.map +1 -0
- package/dist/peacock-loader.js +59 -10
- package/dist/peacock-loader.js.map +1 -1
- package/dist/property-1psGvXOq.js +10 -0
- package/dist/property-1psGvXOq.js.map +1 -0
- package/dist/search.js +452 -0
- package/dist/search.js.map +1 -0
- package/dist/{radio-b70_Ie9n.js → select-4pl4XBj7.js} +2439 -521
- package/dist/select-4pl4XBj7.js.map +1 -0
- package/dist/side-sheet.js +186 -0
- package/dist/side-sheet.js.map +1 -0
- package/dist/spread-B5cgadZl.js +32 -0
- package/dist/spread-B5cgadZl.js.map +1 -0
- package/dist/src/__base_element/BaseHyperlink.d.ts +20 -0
- package/dist/src/__utils/cache-fetch.d.ts +1 -0
- package/dist/src/__utils/is-dark-mode.d.ts +1 -0
- package/dist/src/__utils/is-in-viewport.d.ts +1 -0
- package/dist/src/__utils/observe-slot-change.d.ts +1 -0
- package/dist/src/__utils/sanitize-svg.d.ts +1 -0
- package/dist/src/__utils/throttle.d.ts +4 -0
- package/dist/src/accordion/accordion-item.d.ts +33 -9
- package/dist/src/accordion/accordion.d.ts +21 -5
- package/dist/src/banner/banner.d.ts +47 -0
- package/dist/src/banner/index.d.ts +1 -0
- package/dist/src/bottom-sheet/bottom-sheet.d.ts +42 -0
- package/dist/src/bottom-sheet/index.d.ts +1 -0
- package/dist/src/button/BaseButton.d.ts +7 -13
- package/dist/src/button/button/button.d.ts +4 -0
- package/dist/src/button/button-group/button-group.d.ts +32 -3
- package/dist/src/button/icon-button/icon-button.d.ts +4 -0
- package/dist/src/card/card-content.d.ts +15 -0
- package/dist/src/card/card.d.ts +37 -3
- package/dist/src/card/index.d.ts +1 -0
- package/dist/src/container/container.d.ts +1 -1
- package/dist/src/empty-state/empty-state.d.ts +1 -1
- package/dist/src/fab/fab.d.ts +111 -0
- package/dist/src/fab/index.d.ts +1 -0
- package/dist/src/focus-ring/focus-ring.d.ts +4 -1
- package/dist/src/index.d.ts +11 -1
- package/dist/src/link/link.d.ts +3 -10
- package/dist/src/menu/menu/menu.d.ts +4 -2
- package/dist/src/menu/menu-item/menu-item.d.ts +0 -1
- package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -0
- package/dist/src/notification/index.d.ts +1 -0
- package/dist/src/notification/notification.d.ts +69 -0
- package/dist/src/pagination/pagination.d.ts +8 -1
- package/dist/src/ripple/ripple.d.ts +19 -3
- package/dist/src/search/index.d.ts +1 -0
- package/dist/src/search/search.d.ts +76 -0
- package/dist/src/segmented-button/index.d.ts +2 -0
- package/dist/src/segmented-button/segmented-button-group.d.ts +46 -0
- package/dist/src/segmented-button/segmented-button.d.ts +65 -0
- package/dist/src/select/index.d.ts +3 -0
- package/dist/src/select/option.d.ts +55 -0
- package/dist/src/select/select.d.ts +114 -0
- package/dist/src/side-sheet/index.d.ts +1 -0
- package/dist/src/side-sheet/side-sheet.d.ts +41 -0
- package/dist/src/slider/slider.d.ts +4 -0
- package/dist/src/snackbar/snackbar.d.ts +14 -1
- package/dist/src/tabs/tab-group.d.ts +0 -1
- package/dist/src/tabs/tab.d.ts +8 -2
- package/dist/src/tabs/tabs.d.ts +13 -1
- package/dist/src/toolbar/index.d.ts +1 -0
- package/dist/src/toolbar/toolbar.d.ts +86 -0
- package/dist/state-DwbEjqVk.js +10 -0
- package/dist/state-DwbEjqVk.js.map +1 -0
- package/dist/{style-map-DcB52w-l.js → style-map-DVmWOuYy.js} +3 -3
- package/dist/{style-map-DcB52w-l.js.map → style-map-DVmWOuYy.js.map} +1 -1
- package/dist/test/search.test.d.ts +1 -0
- package/dist/test/toolbar.test.d.ts +1 -0
- package/dist/throttle-C7ZAPqtu.js +24 -0
- package/dist/throttle-C7ZAPqtu.js.map +1 -0
- package/dist/toolbar.js +306 -0
- package/dist/toolbar.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{unsafe-html-C2r3PyzF.js → unsafe-html-BsGUjx94.js} +3 -3
- package/dist/{unsafe-html-C2r3PyzF.js.map → unsafe-html-BsGUjx94.js.map} +1 -1
- package/package.json +1 -1
- package/readme.md +2 -2
- package/scss/styles.scss +4 -0
- package/src/__base_element/BaseHyperlink.ts +42 -0
- package/src/__base_element/README.md +19 -0
- package/src/__utils/cache-fetch.ts +65 -0
- package/src/{utils → __utils}/dispatch-event-utils.ts +1 -0
- package/src/__utils/is-dark-mode.ts +3 -0
- package/src/__utils/is-in-viewport.ts +6 -0
- package/src/__utils/observe-slot-change.ts +38 -0
- package/src/__utils/sanitize-svg.ts +27 -0
- package/src/__utils/throttle.ts +27 -0
- package/src/accordion/accordion-item.scss +136 -65
- package/src/accordion/accordion-item.ts +117 -44
- package/src/accordion/accordion.scss +24 -5
- package/src/accordion/accordion.ts +29 -23
- package/src/accordion/demo/index.html +74 -35
- package/src/banner/banner.scss +87 -0
- package/src/banner/banner.ts +107 -0
- package/src/banner/index.ts +1 -0
- package/src/bottom-sheet/bottom-sheet.scss +88 -0
- package/src/bottom-sheet/bottom-sheet.ts +135 -0
- package/src/bottom-sheet/index.ts +1 -0
- package/src/button/BaseButton.ts +26 -30
- package/src/button/button/button-colors.scss +90 -19
- package/src/button/button/button-sizes.scss +39 -19
- package/src/button/button/button.scss +117 -116
- package/src/button/button/button.ts +29 -6
- package/src/button/button-group/button-group.scss +25 -22
- package/src/button/button-group/button-group.ts +122 -5
- package/src/button/icon-button/icon-button-sizes.scss +35 -15
- package/src/button/icon-button/icon-button.ts +25 -12
- package/src/card/card-colors.scss +10 -0
- package/src/card/card-content.ts +26 -0
- package/src/card/card.scss +221 -41
- package/src/card/card.ts +251 -8
- package/src/card/index.ts +1 -0
- package/src/chart-bar/chart-bar.ts +1 -1
- package/src/chart-bar/chart-stacked-bar.ts +3 -1
- package/src/chart-doughnut/chart-doughnut.ts +1 -1
- package/src/chart-pie/chart-pie.ts +1 -1
- package/src/checkbox/checkbox.ts +1 -1
- package/src/clock/clock.ts +1 -1
- package/src/code-editor/code-editor.ts +5 -5
- package/src/code-highlighter/code-highlighter.ts +2 -2
- package/src/container/container.ts +1 -1
- package/src/date-picker/date-picker.ts +5 -2
- package/src/divider/divider.ts +3 -1
- package/src/empty-state/empty-state.scss +9 -3
- package/src/empty-state/empty-state.ts +2 -2
- package/src/fab/fab-colors.scss +49 -0
- package/src/fab/fab-sizes.scss +47 -0
- package/src/fab/fab.scss +137 -0
- package/src/fab/fab.ts +285 -0
- package/src/fab/index.ts +1 -0
- package/src/field/field.ts +3 -1
- package/src/focus-ring/focus-ring.ts +37 -19
- package/src/icon/datasource.ts +1 -1
- package/src/icon/icon.ts +3 -1
- package/src/image/image.ts +3 -2
- package/src/index.ts +12 -1
- package/src/input/input.ts +5 -2
- package/src/link/link.ts +2 -15
- package/src/menu/menu/menu.scss +31 -3
- package/src/menu/menu/menu.ts +30 -6
- package/src/menu/menu-item/menu-item.scss +1 -0
- package/src/menu/menu-item/menu-item.ts +1 -9
- package/src/menu/sub-menu/sub-menu.ts +1 -0
- package/src/notification/index.ts +1 -0
- package/src/notification/notification.scss +201 -0
- package/src/notification/notification.ts +206 -0
- package/src/number-counter/number-counter.ts +3 -1
- package/src/number-field/number-field.ts +4 -2
- package/src/pagination/pagination.scss +33 -24
- package/src/pagination/pagination.ts +113 -60
- package/src/peacock-loader.ts +48 -0
- package/src/radio/radio.ts +3 -1
- package/src/ripple/ripple.ts +19 -3
- package/src/search/index.ts +1 -0
- package/src/search/search-colors.scss +14 -0
- package/src/search/search.scss +204 -0
- package/src/search/search.ts +240 -0
- package/src/segmented-button/index.ts +2 -0
- package/src/segmented-button/segmented-button-group.scss +21 -0
- package/src/segmented-button/segmented-button-group.ts +110 -0
- package/src/segmented-button/segmented-button.scss +115 -0
- package/src/segmented-button/segmented-button.ts +175 -0
- package/src/select/index.ts +3 -0
- package/src/select/option.ts +109 -0
- package/src/select/select.scss +125 -0
- package/src/select/select.ts +520 -0
- package/src/side-sheet/index.ts +1 -0
- package/src/side-sheet/side-sheet.scss +79 -0
- package/src/side-sheet/side-sheet.ts +100 -0
- package/src/slider/slider.scss +19 -1
- package/src/slider/slider.ts +30 -19
- package/src/snackbar/snackbar.scss +62 -31
- package/src/snackbar/snackbar.ts +92 -12
- package/src/switch/switch.ts +3 -1
- package/src/table/table.ts +3 -1
- package/src/tabs/demo/index.html +90 -0
- package/src/tabs/tab-group.ts +0 -3
- package/src/tabs/tab.scss +237 -25
- package/src/tabs/tab.ts +91 -14
- package/src/tabs/tabs.scss +37 -3
- package/src/tabs/tabs.ts +118 -2
- package/src/textarea/textarea.ts +4 -2
- package/src/time-picker/time-picker.ts +4 -2
- package/src/toolbar/index.ts +1 -0
- package/src/toolbar/toolbar-colors.scss +16 -0
- package/src/toolbar/toolbar.scss +165 -0
- package/src/toolbar/toolbar.ts +137 -0
- package/dist/IndividualComponent-Dt5xirYG.js +0 -73
- package/dist/IndividualComponent-Dt5xirYG.js.map +0 -1
- package/dist/button-ClzS8JLq.js.map +0 -1
- package/dist/button-group-BMS5WvaF.js +0 -292
- package/dist/button-group-BMS5WvaF.js.map +0 -1
- package/dist/chart-donut.js +0 -309
- package/dist/chart-donut.js.map +0 -1
- package/dist/class-map-59YGWLnx.js.map +0 -1
- package/dist/directive-Cuw6h7YA.js +0 -9
- package/dist/directive-Cuw6h7YA.js.map +0 -1
- package/dist/dispatch-event-utils-B4odODQf.js +0 -277
- package/dist/dispatch-event-utils-B4odODQf.js.map +0 -1
- package/dist/observe-theme-change-pALI5fmV.js.map +0 -1
- package/dist/radio-b70_Ie9n.js.map +0 -1
- package/dist/src/chart-donut/chart-donut.d.ts +0 -53
- package/dist/src/chart-donut/index.d.ts +0 -1
- package/dist/src/styleMixins.css.d.ts +0 -9
- package/dist/src/utils.d.ts +0 -9
- package/src/chart-donut/chart-donut.scss +0 -37
- package/src/chart-donut/chart-donut.ts +0 -287
- package/src/chart-donut/demo/index.html +0 -51
- package/src/chart-donut/index.ts +0 -1
- package/src/styleMixins.css.ts +0 -55
- package/src/utils.ts +0 -193
- /package/dist/src/{spread.d.ts → __directive/spread.d.ts} +0 -0
- /package/dist/src/{utils → __utils}/copy-to-clipboard.d.ts +0 -0
- /package/dist/src/{utils → __utils}/dispatch-event-utils.d.ts +0 -0
- /package/dist/src/{utils → __utils}/observe-theme-change.d.ts +0 -0
- /package/dist/test/{card.test.d.ts → banner.test.d.ts} +0 -0
- /package/src/{spread.ts → __directive/spread.ts} +0 -0
- /package/src/{utils → __utils}/copy-to-clipboard.ts +0 -0
- /package/src/{utils → __utils}/observe-theme-change.ts +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
|
|
5
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
6
|
+
import styles from './banner.scss';
|
|
7
|
+
|
|
8
|
+
type BannerVariant = 'note' | 'info' | 'success' | 'warning' | 'error';
|
|
9
|
+
|
|
10
|
+
const VARIANT_LABELS: Record<BannerVariant, string> = {
|
|
11
|
+
note: 'Note',
|
|
12
|
+
info: 'Info',
|
|
13
|
+
success: 'Success',
|
|
14
|
+
warning: 'Warning',
|
|
15
|
+
error: 'Error',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const VARIANT_ICONS: Record<BannerVariant, string> = {
|
|
19
|
+
note: 'star',
|
|
20
|
+
info: 'info',
|
|
21
|
+
success: 'check_circle',
|
|
22
|
+
warning: 'warning',
|
|
23
|
+
error: 'error',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @label Banner
|
|
28
|
+
* @tag wc-banner
|
|
29
|
+
* @rawTag banner
|
|
30
|
+
* @summary Banners show short, prominent contextual messages with optional icon and description.
|
|
31
|
+
*
|
|
32
|
+
* @cssprop --banner-container-color - Background color of the banner container.
|
|
33
|
+
* @cssprop --banner-label-text-color - Label text color.
|
|
34
|
+
* @cssprop --banner-description-text-color - Description text color.
|
|
35
|
+
* @cssprop --banner-icon-color - Icon color.
|
|
36
|
+
* @cssprop --banner-border-radius - Border radius of the banner surface.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```html
|
|
40
|
+
* <wc-banner variant="note" description="Use semantic roles that preserve a 3:1 contrast ratio."></wc-banner>
|
|
41
|
+
* ```
|
|
42
|
+
* @tags display, feedback
|
|
43
|
+
*/
|
|
44
|
+
@IndividualComponent
|
|
45
|
+
export class Banner extends LitElement {
|
|
46
|
+
static styles = [styles];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Visual intent of the banner.
|
|
50
|
+
*/
|
|
51
|
+
@property({ type: String, reflect: true })
|
|
52
|
+
variant: BannerVariant = 'note';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Optional explicit label text. Falls back to a variant-based label.
|
|
56
|
+
*/
|
|
57
|
+
@property({ type: String })
|
|
58
|
+
label?: string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Optional explicit icon name. Falls back to a variant-based icon.
|
|
62
|
+
*/
|
|
63
|
+
@property({ type: String })
|
|
64
|
+
icon?: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Optional description text when a default slot is not provided.
|
|
68
|
+
*/
|
|
69
|
+
@property({ type: String })
|
|
70
|
+
description = '';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* When true, label and description are rendered on a single line.
|
|
74
|
+
*/
|
|
75
|
+
@property({ type: Boolean, reflect: true })
|
|
76
|
+
inline = false;
|
|
77
|
+
|
|
78
|
+
private get resolvedLabel() {
|
|
79
|
+
return this.label || VARIANT_LABELS[this.variant];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private get resolvedIcon() {
|
|
83
|
+
return this.icon || VARIANT_ICONS[this.variant];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
render() {
|
|
87
|
+
return html`
|
|
88
|
+
<div class=${classMap({ 'banner': true, [this.variant]: true })} role="status" aria-live="polite">
|
|
89
|
+
<div class="banner-icon" aria-hidden="true">
|
|
90
|
+
<slot name="icon">
|
|
91
|
+
<wc-icon name=${this.resolvedIcon}></wc-icon>
|
|
92
|
+
</slot>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<div class=${classMap({ 'banner-content': true, [this.variant]: true, inline: this.inline })}>
|
|
96
|
+
<div class="banner-label">
|
|
97
|
+
<slot name="label">${this.resolvedLabel}:</slot>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div class="banner-description">
|
|
101
|
+
<slot>${this.description || nothing}</slot>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Banner } from './banner.js';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
@use "../../scss/mixin";
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: contents;
|
|
7
|
+
|
|
8
|
+
--bottom-sheet-container-color: var(--color-surface-container-low, #f7f2fa);
|
|
9
|
+
--bottom-sheet-scrim-color: rgba(0, 0, 0, 0.32);
|
|
10
|
+
--bottom-sheet-shape: var(--shape-corner-extra-large, 28px);
|
|
11
|
+
--bottom-sheet-max-height: 90dvh;
|
|
12
|
+
--bottom-sheet-handle-color: var(--color-on-surface-variant, #49454f);
|
|
13
|
+
--bottom-sheet-transition-duration: var(--duration-medium2, 300ms);
|
|
14
|
+
--bottom-sheet-transition-easing: var(--easing-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.scrim {
|
|
18
|
+
inset: 0;
|
|
19
|
+
position: fixed;
|
|
20
|
+
background-color: var(--bottom-sheet-scrim-color);
|
|
21
|
+
opacity: 0;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
transition:
|
|
24
|
+
opacity var(--bottom-sheet-transition-duration) var(--bottom-sheet-transition-easing);
|
|
25
|
+
z-index: 1000;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.scrim.visible {
|
|
29
|
+
opacity: 1;
|
|
30
|
+
pointer-events: auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sheet {
|
|
34
|
+
background-color: var(--bottom-sheet-container-color);
|
|
35
|
+
border-radius: var(--bottom-sheet-shape) var(--bottom-sheet-shape) 0 0;
|
|
36
|
+
bottom: 0;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
left: 0;
|
|
40
|
+
max-height: var(--bottom-sheet-max-height);
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
position: fixed;
|
|
43
|
+
right: 0;
|
|
44
|
+
transform: translateY(100%);
|
|
45
|
+
transition:
|
|
46
|
+
transform var(--bottom-sheet-transition-duration) var(--bottom-sheet-transition-easing);
|
|
47
|
+
will-change: transform;
|
|
48
|
+
z-index: 1001;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.sheet.variant-standard {
|
|
52
|
+
position: relative;
|
|
53
|
+
z-index: 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.sheet.open {
|
|
57
|
+
transform: translateY(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.sheet.dragging {
|
|
61
|
+
transition: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.handle-area {
|
|
65
|
+
cursor: grab;
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
padding: var(--spacing-100, 0.5rem) var(--spacing-200, 1rem);
|
|
69
|
+
touch-action: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.handle-area:active {
|
|
73
|
+
cursor: grabbing;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.handle {
|
|
77
|
+
background-color: var(--bottom-sheet-handle-color);
|
|
78
|
+
border-radius: var(--shape-corner-full, 9999px);
|
|
79
|
+
height: 4px;
|
|
80
|
+
opacity: 0.4;
|
|
81
|
+
width: 2rem;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.content {
|
|
85
|
+
flex: 1 1 auto;
|
|
86
|
+
overflow-y: auto;
|
|
87
|
+
padding: var(--spacing-100, 0.5rem) var(--spacing-300, 1.5rem) var(--spacing-300, 1.5rem);
|
|
88
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
|
+
import { property, state } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import IndividualComponent from '../IndividualComponent.js';
|
|
5
|
+
import styles from './bottom-sheet.scss';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @label Bottom Sheet
|
|
9
|
+
* @tag wc-bottom-sheet
|
|
10
|
+
* @rawTag bottom-sheet
|
|
11
|
+
* @summary Bottom sheets slide up from the bottom of the screen to reveal additional content. Supports standard and modal variants per Material Design 3.
|
|
12
|
+
*
|
|
13
|
+
* @cssprop --bottom-sheet-container-color - Background color of the sheet container.
|
|
14
|
+
* @cssprop --bottom-sheet-scrim-color - Color of the modal scrim overlay.
|
|
15
|
+
* @cssprop --bottom-sheet-shape - Corner radius of the top edge.
|
|
16
|
+
* @cssprop --bottom-sheet-max-height - Maximum height of the sheet.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```html
|
|
20
|
+
* Bottom Sheet
|
|
21
|
+
* ```
|
|
22
|
+
* @tags navigation, overlay
|
|
23
|
+
*/
|
|
24
|
+
@IndividualComponent
|
|
25
|
+
export class BottomSheet extends LitElement {
|
|
26
|
+
static styles = [styles];
|
|
27
|
+
|
|
28
|
+
/** Whether the sheet is visible. */
|
|
29
|
+
@property({ type: Boolean, reflect: true }) open = false;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sheet variant.
|
|
33
|
+
* - `"standard"`: Coexists with page content; no scrim.
|
|
34
|
+
* - `"modal"`: Overlays page content with a scrim backdrop.
|
|
35
|
+
*/
|
|
36
|
+
@property({ type: String, reflect: true }) variant: 'standard' | 'modal' =
|
|
37
|
+
'modal';
|
|
38
|
+
|
|
39
|
+
/** Whether to show the drag handle. */
|
|
40
|
+
@property({ type: Boolean, attribute: 'show-handle' }) showHandle = true;
|
|
41
|
+
|
|
42
|
+
@state() private _dragging = false;
|
|
43
|
+
@state() private _dragStartY = 0;
|
|
44
|
+
@state() private _dragOffsetY = 0;
|
|
45
|
+
|
|
46
|
+
show() {
|
|
47
|
+
this.open = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
hide() {
|
|
51
|
+
this._close('programmatic');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private _close(reason: string) {
|
|
55
|
+
if (!this.open) return;
|
|
56
|
+
this.open = false;
|
|
57
|
+
this.dispatchEvent(
|
|
58
|
+
new CustomEvent('bottom-sheet-close', {
|
|
59
|
+
detail: { reason },
|
|
60
|
+
bubbles: true,
|
|
61
|
+
composed: true,
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private _handleScrimClick() {
|
|
67
|
+
if (this.variant === 'modal') {
|
|
68
|
+
this._close('scrim');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private _handleDragStart(e: PointerEvent) {
|
|
73
|
+
this._dragging = true;
|
|
74
|
+
this._dragStartY = e.clientY;
|
|
75
|
+
this._dragOffsetY = 0;
|
|
76
|
+
(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private _handleDragMove(e: PointerEvent) {
|
|
80
|
+
if (!this._dragging) return;
|
|
81
|
+
const delta = e.clientY - this._dragStartY;
|
|
82
|
+
this._dragOffsetY = Math.max(0, delta);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private _handleDragEnd() {
|
|
86
|
+
if (!this._dragging) return;
|
|
87
|
+
this._dragging = false;
|
|
88
|
+
if (this._dragOffsetY > 80) {
|
|
89
|
+
this._close('drag');
|
|
90
|
+
}
|
|
91
|
+
this._dragOffsetY = 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
render() {
|
|
95
|
+
const translateY = this._dragging ? `${this._dragOffsetY}px` : undefined;
|
|
96
|
+
|
|
97
|
+
return html`
|
|
98
|
+
${this.variant === 'modal'
|
|
99
|
+
? html`<div
|
|
100
|
+
class=${classMap({ scrim: true, visible: this.open })}
|
|
101
|
+
@click=${this._handleScrimClick}
|
|
102
|
+
></div>`
|
|
103
|
+
: nothing}
|
|
104
|
+
|
|
105
|
+
<div
|
|
106
|
+
class=${classMap({
|
|
107
|
+
sheet: true,
|
|
108
|
+
open: this.open,
|
|
109
|
+
dragging: this._dragging,
|
|
110
|
+
[`variant-${this.variant}`]: true,
|
|
111
|
+
})}
|
|
112
|
+
style=${translateY ? `transform: translateY(${translateY})` : ''}
|
|
113
|
+
role="dialog"
|
|
114
|
+
aria-modal=${this.variant === 'modal' ? 'true' : 'false'}
|
|
115
|
+
aria-hidden=${!this.open ? 'true' : 'false'}
|
|
116
|
+
>
|
|
117
|
+
${this.showHandle
|
|
118
|
+
? html`<div
|
|
119
|
+
class="handle-area"
|
|
120
|
+
@pointerdown=${this._handleDragStart}
|
|
121
|
+
@pointermove=${this._handleDragMove}
|
|
122
|
+
@pointerup=${this._handleDragEnd}
|
|
123
|
+
@pointercancel=${this._handleDragEnd}
|
|
124
|
+
>
|
|
125
|
+
<div class="handle"></div>
|
|
126
|
+
</div>`
|
|
127
|
+
: nothing}
|
|
128
|
+
|
|
129
|
+
<div class="content">
|
|
130
|
+
<slot></slot>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BottomSheet } from './bottom-sheet.js';
|
package/src/button/BaseButton.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { html, LitElement, nothing } from 'lit';
|
|
2
2
|
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
-
import { dispatchActivationClick, isActivationClick } from '../
|
|
3
|
+
import { dispatchActivationClick, isActivationClick } from '../__utils/dispatch-event-utils.js';
|
|
4
|
+
import BaseHyperlink from '@/__base_element/BaseHyperlink.js';
|
|
4
5
|
|
|
5
|
-
export class BaseButton extends LitElement {
|
|
6
|
-
|
|
6
|
+
export class BaseButton extends BaseHyperlink(LitElement) {
|
|
7
|
+
protected static readonly DISABLED_REASON_ID = 'disabled-reason';
|
|
7
8
|
|
|
8
9
|
@property({ type: String }) htmlType: 'button' | 'submit' | 'reset' =
|
|
9
10
|
'button';
|
|
@@ -40,14 +41,14 @@ export class BaseButton extends LitElement {
|
|
|
40
41
|
| 'success'
|
|
41
42
|
| 'danger'
|
|
42
43
|
| 'warning'
|
|
43
|
-
| '
|
|
44
|
-
| '
|
|
44
|
+
| 'surface'
|
|
45
|
+
| 'on-surface' = 'primary';
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Button size.
|
|
48
49
|
* Possible values are `"sm"`, `"md"`, `"lg"`. Defaults to `"md"`.
|
|
49
50
|
*/
|
|
50
|
-
@property() size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'sm';
|
|
51
|
+
@property({ reflect: true }) size: 'xs' | 'sm' | 'md' | 'lg' | 'xl' = 'sm';
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
54
|
* If true, the user cannot interact with the button. Defaults to `false`.
|
|
@@ -55,12 +56,12 @@ export class BaseButton extends LitElement {
|
|
|
55
56
|
@property({ type: Boolean, reflect: true })
|
|
56
57
|
disabled: boolean = false;
|
|
57
58
|
|
|
58
|
-
@property() skeleton: boolean = false;
|
|
59
|
+
@property({ type: Boolean, reflect: true }) skeleton: boolean = false;
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* If true, the user cannot interact with the button and the button is visually styled as disabled. But the button is still focusable. Defaults to `false`.
|
|
62
63
|
*/
|
|
63
|
-
@property({ reflect: true, attribute: 'soft-disabled' })
|
|
64
|
+
@property({ type: Boolean, reflect: true, attribute: 'soft-disabled' })
|
|
64
65
|
softDisabled: boolean = false;
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -68,21 +69,16 @@ export class BaseButton extends LitElement {
|
|
|
68
69
|
*/
|
|
69
70
|
@property({ attribute: 'disabled-reason' })
|
|
70
71
|
disabledReason: string = '';
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Hyperlink to navigate to on click.
|
|
74
|
-
*/
|
|
75
|
-
@property({ reflect: true }) href?: string;
|
|
72
|
+
|
|
76
73
|
|
|
77
74
|
@property({ reflect: true })
|
|
78
75
|
configAria?: { [key: string]: any };
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
@property() target: string = '_self';
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@property({ type: Boolean, reflect: true }) toggle: boolean = false;
|
|
84
80
|
|
|
85
|
-
@property() selected: boolean = false;
|
|
81
|
+
@property({ type: Boolean, reflect: true }) selected: boolean = false;
|
|
86
82
|
|
|
87
83
|
/**
|
|
88
84
|
* Sets the delay for throttle in milliseconds. Defaults to 200 milliseconds.
|
|
@@ -134,10 +130,6 @@ export class BaseButton extends LitElement {
|
|
|
134
130
|
}
|
|
135
131
|
};
|
|
136
132
|
|
|
137
|
-
__isLink() {
|
|
138
|
-
return !!this.href;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
133
|
__dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =
|
|
142
134
|
event => {
|
|
143
135
|
this.__dispatchClick(event);
|
|
@@ -157,6 +149,10 @@ export class BaseButton extends LitElement {
|
|
|
157
149
|
return;
|
|
158
150
|
}
|
|
159
151
|
|
|
152
|
+
if (this.toggle) {
|
|
153
|
+
this.selected = !this.selected;
|
|
154
|
+
}
|
|
155
|
+
|
|
160
156
|
this.focus();
|
|
161
157
|
dispatchActivationClick(this.buttonElement);
|
|
162
158
|
};
|
|
@@ -166,8 +162,8 @@ export class BaseButton extends LitElement {
|
|
|
166
162
|
this.color = 'primary';
|
|
167
163
|
this.variant = 'filled';
|
|
168
164
|
} else if (this.type === 'secondary') {
|
|
169
|
-
this.color = '
|
|
170
|
-
this.variant = '
|
|
165
|
+
this.color = 'surface';
|
|
166
|
+
this.variant = 'filled';
|
|
171
167
|
} else if (this.type === 'tertiary') {
|
|
172
168
|
this.color = 'primary';
|
|
173
169
|
this.variant = 'text';
|
|
@@ -177,22 +173,22 @@ export class BaseButton extends LitElement {
|
|
|
177
173
|
}
|
|
178
174
|
}
|
|
179
175
|
|
|
180
|
-
|
|
176
|
+
protected get __disabledReasonID(): string | undefined {
|
|
181
177
|
return this.disabled && this.disabledReason
|
|
182
|
-
?
|
|
183
|
-
:
|
|
178
|
+
? BaseButton.DISABLED_REASON_ID
|
|
179
|
+
: undefined;
|
|
184
180
|
}
|
|
185
181
|
|
|
186
182
|
__renderDisabledReason() {
|
|
187
|
-
const disabledReasonID = this.
|
|
183
|
+
const disabledReasonID = this.__disabledReasonID;
|
|
188
184
|
if (disabledReasonID)
|
|
189
185
|
return html`<div
|
|
190
|
-
id
|
|
186
|
+
id=${disabledReasonID}
|
|
191
187
|
role="tooltip"
|
|
192
188
|
aria-label=${this.disabledReason}
|
|
193
189
|
class="screen-reader-only"
|
|
194
190
|
>
|
|
195
|
-
{this.disabledReason}
|
|
191
|
+
${this.disabledReason}
|
|
196
192
|
</div>`;
|
|
197
193
|
return nothing;
|
|
198
194
|
}
|
|
@@ -18,36 +18,107 @@
|
|
|
18
18
|
--neo-button-label-text-color: var(--color-on-#{$color});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
@mixin _button-color-toggle-unselected($color) {
|
|
22
|
+
|
|
23
|
+
--filled-button-container-color: var(--color-surface-container);
|
|
24
|
+
--filled-button-label-text-color: var(--color-surface-container-variant);
|
|
25
|
+
|
|
26
|
+
--tonal-button-container-color: var(--color-#{$color}-container);
|
|
27
|
+
--tonal-button-label-text-color: var(--color-on-#{$color}-container);
|
|
28
|
+
|
|
29
|
+
--elevated-button-container-color: var(--color-surface-container-low);
|
|
30
|
+
--elevated-button-label-text-color: var(--color-#{$color});
|
|
31
|
+
|
|
32
|
+
--outlined-button-outline-color: var(--color-#{$color});
|
|
33
|
+
--outlined-button-label-text-color: var(--color-#{$color});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@mixin _button-color-toggle-selected($color) {
|
|
37
|
+
|
|
38
|
+
--filled-button-container-color: var(--color-#{$color});
|
|
39
|
+
--filled-button-label-text-color: var(--color-on-#{$color});
|
|
40
|
+
|
|
41
|
+
--tonal-button-container-color: var(--color-#{$color});
|
|
42
|
+
--tonal-button-label-text-color: var(--color-on-#{$color});
|
|
43
|
+
|
|
44
|
+
--elevated-button-container-color: var(--color-#{$color});
|
|
45
|
+
--elevated-button-label-text-color: var(--color-on-#{$color});
|
|
46
|
+
|
|
47
|
+
--outlined-button-outline-color: var(--color-inverse-surface);
|
|
48
|
+
--outlined-button-label-text-color: var(--color-inverse-on-surface);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host([color=primary]:not([toggle])) {
|
|
22
52
|
@include _button-color(primary);
|
|
23
53
|
}
|
|
24
54
|
|
|
25
|
-
:host([color=
|
|
55
|
+
:host([color=primary][toggle][selected]) {
|
|
56
|
+
@include _button-color-toggle-selected(primary);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:host([color=primary][toggle]:not([selected])) {
|
|
60
|
+
@include _button-color-toggle-unselected(primary);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:host([color=secondary]:not([toggle])) {
|
|
26
64
|
@include _button-color(secondary);
|
|
27
65
|
}
|
|
28
66
|
|
|
29
|
-
:host([color=
|
|
67
|
+
:host([color=secondary][toggle][selected]) {
|
|
68
|
+
@include _button-color-toggle-selected(secondary);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([color=secondary][toggle]:not([selected])) {
|
|
72
|
+
@include _button-color-toggle-unselected(secondary);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:host([color=tertiary]:not([toggle])) {
|
|
30
76
|
@include _button-color(tertiary);
|
|
31
77
|
}
|
|
32
78
|
|
|
33
|
-
:host([color=
|
|
79
|
+
:host([color=tertiary][toggle][selected]) {
|
|
80
|
+
@include _button-color-toggle-selected(tertiary);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host([color=tertiary][toggle]:not([selected])) {
|
|
84
|
+
@include _button-color-toggle-unselected(tertiary);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:host([color=success]:not([toggle])) {
|
|
34
88
|
@include _button-color(success);
|
|
35
89
|
}
|
|
36
90
|
|
|
37
|
-
:host([color=
|
|
91
|
+
:host([color=success][toggle][selected]) {
|
|
92
|
+
@include _button-color-toggle-selected(success);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:host([color=success][toggle]:not([selected])) {
|
|
96
|
+
@include _button-color-toggle-unselected(success);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
:host([color=danger]:not([toggle])) {
|
|
38
101
|
@include _button-color(error);
|
|
39
102
|
}
|
|
40
103
|
|
|
104
|
+
:host([color=danger][toggle][selected]) {
|
|
105
|
+
@include _button-color-toggle-selected(error);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
:host([color=danger][toggle]:not([selected])) {
|
|
109
|
+
@include _button-color-toggle-unselected(error);
|
|
110
|
+
}
|
|
111
|
+
|
|
41
112
|
|
|
42
|
-
:host([color=
|
|
113
|
+
:host([color=on-surface]) {
|
|
43
114
|
--filled-button-container-color: var(--color-on-surface);
|
|
44
115
|
--filled-button-label-text-color: var(--color-surface);
|
|
45
116
|
|
|
46
|
-
--tonal-button-container-color: var(--color-surface-container);
|
|
47
|
-
--tonal-button-label-text-color: var(--color-
|
|
117
|
+
--tonal-button-container-color: var(--color-on-surface-container);
|
|
118
|
+
--tonal-button-label-text-color: var(--color-surface-container-high);
|
|
48
119
|
|
|
49
|
-
--elevated-button-container-color: var(--color-surface
|
|
50
|
-
--elevated-button-label-text-color: var(--color-
|
|
120
|
+
--elevated-button-container-color: var(--color-on-surface);
|
|
121
|
+
--elevated-button-label-text-color: var(--color-surface);
|
|
51
122
|
|
|
52
123
|
--outlined-button-outline-color: var(--color-on-surface);
|
|
53
124
|
--outlined-button-label-text-color: var(--color-on-surface);
|
|
@@ -58,20 +129,20 @@
|
|
|
58
129
|
--neo-button-label-text-color: var(--color-surface);
|
|
59
130
|
}
|
|
60
131
|
|
|
61
|
-
:host([color=
|
|
62
|
-
--filled-button-container-color: var(--color-surface);
|
|
132
|
+
:host([color=surface]) {
|
|
133
|
+
--filled-button-container-color: var(--color-surface-container-high);
|
|
63
134
|
--filled-button-label-text-color: var(--color-on-surface);
|
|
64
135
|
|
|
65
|
-
--tonal-button-container-color: var(--color-
|
|
66
|
-
--tonal-button-label-text-color: var(--color-surface-container);
|
|
136
|
+
--tonal-button-container-color: var(--color-surface-container-high);
|
|
137
|
+
--tonal-button-label-text-color: var(--color-on-surface-container);
|
|
67
138
|
|
|
68
|
-
--elevated-button-container-color: var(--color-surface
|
|
69
|
-
--elevated-button-label-text-color: var(--color-
|
|
139
|
+
--elevated-button-container-color: var(--color-surface);
|
|
140
|
+
--elevated-button-label-text-color: var(--color-on-surface);
|
|
70
141
|
|
|
71
|
-
--outlined-button-outline-color: var(--color-surface);
|
|
72
|
-
--outlined-button-label-text-color: var(--color-surface);
|
|
142
|
+
--outlined-button-outline-color: var(--color-on-surface);
|
|
143
|
+
--outlined-button-label-text-color: var(--color-on-surface);
|
|
73
144
|
|
|
74
|
-
--text-button-label-text-color: var(--color-surface);
|
|
145
|
+
--text-button-label-text-color: var(--color-on-surface);
|
|
75
146
|
|
|
76
147
|
--neo-button-container-color: var(--color-surface);
|
|
77
148
|
--neo-button-label-text-color: var(--color-on-surface);
|