@redvars/peacock 3.4.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseButton-DuASuVth.js +219 -0
- package/dist/BaseButton-DuASuVth.js.map +1 -0
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js +65 -0
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js.map +1 -0
- package/dist/assets/components.css +1 -1
- package/dist/assets/components.css.map +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/banner.js +187 -0
- package/dist/banner.js.map +1 -0
- package/dist/bottom-sheet.js +2 -2
- package/dist/{button-COYCtuA8.js → button-DouvOfEU.js} +92 -283
- package/dist/button-DouvOfEU.js.map +1 -0
- package/dist/{button-group-DsXquZQn.js → button-group-CEdMwvJJ.js} +72 -48
- package/dist/button-group-CEdMwvJJ.js.map +1 -0
- package/dist/button-group.js +8 -5
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +7 -4
- package/dist/button.js.map +1 -1
- package/dist/card.js +29 -74
- package/dist/card.js.map +1 -1
- package/dist/chart-bar.js +2 -2
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-doughnut.js +2 -2
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-pie.js +2 -2
- package/dist/chart-pie.js.map +1 -1
- package/dist/chart-stacked-bar.js +2 -2
- package/dist/chart-stacked-bar.js.map +1 -1
- package/dist/{class-map-3TAnCMAX.js → class-map-YU7g0o3B.js} +2 -2
- package/dist/{class-map-3TAnCMAX.js.map → class-map-YU7g0o3B.js.map} +1 -1
- package/dist/clock.js.map +1 -1
- package/dist/code-editor.js +4 -4
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +5 -4
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +6627 -3477
- package/dist/custom-elements.json +10954 -7810
- 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.js +423 -0
- package/dist/fab.js.map +1 -0
- package/dist/index.js +17 -9
- package/dist/index.js.map +1 -1
- package/dist/{observe-theme-change-DKAIv5BB.js → is-dark-mode-DicqGkCJ.js} +6 -2
- package/dist/is-dark-mode-DicqGkCJ.js.map +1 -0
- package/dist/{select-C3XAzenC.js → navigation-rail-Lxetd5-Z.js} +2426 -898
- package/dist/navigation-rail-Lxetd5-Z.js.map +1 -0
- package/dist/notification.js +418 -0
- package/dist/notification.js.map +1 -0
- package/dist/number-counter.js +2 -2
- 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 +48 -13
- package/dist/peacock-loader.js.map +1 -1
- package/dist/search.js +456 -0
- package/dist/search.js.map +1 -0
- package/dist/side-sheet.js +2 -2
- package/dist/src/__mixins/BaseButtonMixin.d.ts +20 -0
- package/dist/src/__mixins/BaseHyperlinkMixin.d.ts +18 -0
- package/dist/src/__mixins/MixinConstructor.d.ts +1 -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 +43 -0
- package/dist/src/banner/index.d.ts +1 -0
- package/dist/src/button/BaseButton.d.ts +7 -57
- package/dist/src/button/button/button.d.ts +32 -3
- package/dist/src/button/button-group/button-group.d.ts +4 -4
- package/dist/src/button/icon-button/icon-button.d.ts +33 -8
- package/dist/src/card/card.d.ts +4 -15
- package/dist/src/empty-state/empty-state.d.ts +1 -1
- package/dist/src/fab/fab.d.ts +80 -0
- package/dist/src/fab/index.d.ts +1 -0
- package/dist/src/focus-ring/focus-ring.d.ts +11 -5
- package/dist/src/index.d.ts +8 -1
- package/dist/src/link/link.d.ts +3 -10
- package/dist/src/menu/menu/menu.d.ts +3 -2
- package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -0
- package/dist/src/navigation-rail/index.d.ts +2 -0
- package/dist/src/navigation-rail/navigation-rail-item.d.ts +55 -0
- package/dist/src/navigation-rail/navigation-rail.d.ts +71 -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/search/index.d.ts +1 -0
- package/dist/src/search/search.d.ts +76 -0
- package/dist/src/select/select.d.ts +3 -5
- package/dist/src/sidebar-menu/index.d.ts +3 -0
- package/dist/src/sidebar-menu/sidebar-menu-item.d.ts +58 -0
- package/dist/src/sidebar-menu/sidebar-menu.d.ts +38 -0
- package/dist/src/sidebar-menu/sidebar-sub-menu.d.ts +35 -0
- package/dist/src/slider/slider.d.ts +4 -0
- package/dist/src/snackbar/snackbar.d.ts +14 -1
- package/dist/src/toolbar/index.d.ts +1 -0
- package/dist/src/toolbar/toolbar.d.ts +86 -0
- package/dist/src/tooltip/tooltip.d.ts +3 -0
- package/dist/src/url-field/index.d.ts +1 -0
- package/dist/src/url-field/url-field.d.ts +48 -0
- package/dist/{style-map-CRFEoCEg.js → style-map-DVmWOuYy.js} +2 -2
- package/dist/{style-map-CRFEoCEg.js.map → style-map-DVmWOuYy.js.map} +1 -1
- package/dist/test/banner.test.d.ts +1 -0
- package/dist/test/search.test.d.ts +1 -0
- package/dist/test/sidebar-menu.test.d.ts +1 -0
- package/dist/test/toolbar.test.d.ts +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-D3GHRaGQ.js → unsafe-html-BsGUjx94.js} +2 -2
- package/dist/{unsafe-html-D3GHRaGQ.js.map → unsafe-html-BsGUjx94.js.map} +1 -1
- package/package.json +1 -1
- package/readme.md +73 -65
- package/scss/mixin.scss +16 -0
- package/scss/styles.scss +4 -0
- package/src/__mixins/BaseButtonMixin.ts +83 -0
- package/src/__mixins/BaseHyperlinkMixin.ts +68 -0
- package/src/__mixins/MixinConstructor.ts +1 -0
- package/src/__mixins/README.md +19 -0
- package/src/__utils/cache-fetch.ts +65 -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 +83 -0
- package/src/banner/banner.ts +101 -0
- package/src/banner/index.ts +1 -0
- package/src/button/BaseButton.ts +13 -115
- package/src/button/button/button-colors.scss +14 -14
- package/src/button/button/button-sizes.scss +4 -2
- package/src/button/button/button.ts +80 -26
- package/src/button/button-group/button-group.ts +5 -5
- package/src/button/icon-button/icon-button.ts +79 -44
- package/src/card/card.ts +50 -100
- package/src/chart-bar/chart-bar.ts +10 -15
- package/src/chart-bar/chart-stacked-bar.ts +15 -19
- package/src/chart-doughnut/chart-doughnut.ts +24 -28
- package/src/chart-pie/chart-pie.ts +20 -24
- package/src/checkbox/checkbox.scss +17 -34
- package/src/checkbox/checkbox.ts +4 -2
- package/src/clock/clock.ts +1 -1
- package/src/code-editor/code-editor.ts +4 -4
- package/src/code-highlighter/code-highlighter.scss +1 -0
- package/src/code-highlighter/code-highlighter.ts +3 -3
- package/src/date-picker/date-picker.ts +6 -3
- package/src/divider/divider.ts +3 -1
- package/src/elevation/elevation.scss +5 -5
- package/src/empty-state/empty-state.scss +7 -9
- package/src/empty-state/empty-state.ts +1 -1
- 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 +214 -0
- package/src/fab/index.ts +1 -0
- package/src/field/field.ts +3 -1
- package/src/focus-ring/focus-ring.ts +47 -40
- 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 +8 -1
- package/src/input/input.ts +8 -3
- package/src/link/link.ts +2 -15
- package/src/menu/menu/menu.scss +7 -0
- package/src/menu/menu/menu.ts +7 -4
- package/src/menu/menu-item/menu-item.ts +3 -1
- package/src/menu/sub-menu/sub-menu.ts +1 -0
- package/src/navigation-rail/index.ts +2 -0
- package/src/navigation-rail/navigation-rail-item.scss +216 -0
- package/src/navigation-rail/navigation-rail-item.ts +223 -0
- package/src/navigation-rail/navigation-rail.scss +72 -0
- package/src/navigation-rail/navigation-rail.ts +149 -0
- package/src/notification/index.ts +1 -0
- package/src/notification/notification.scss +201 -0
- package/src/notification/notification.ts +207 -0
- package/src/number-counter/number-counter.ts +3 -1
- package/src/number-field/number-field.ts +10 -6
- package/src/pagination/pagination.scss +33 -24
- package/src/pagination/pagination.ts +115 -60
- package/src/peacock-loader.ts +42 -5
- package/src/radio/radio.ts +3 -1
- 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 +244 -0
- package/src/select/option.ts +1 -1
- package/src/select/select.scss +5 -0
- package/src/select/select.ts +71 -37
- package/src/sidebar-menu/demo/index.html +68 -0
- package/src/sidebar-menu/index.ts +3 -0
- package/src/sidebar-menu/sidebar-menu-item.scss +102 -0
- package/src/sidebar-menu/sidebar-menu-item.ts +151 -0
- package/src/{tree-view/tree-view.scss → sidebar-menu/sidebar-menu.scss} +1 -1
- package/src/sidebar-menu/sidebar-menu.ts +182 -0
- package/src/sidebar-menu/sidebar-sub-menu.scss +130 -0
- package/src/sidebar-menu/sidebar-sub-menu.ts +160 -0
- package/src/skeleton/skeleton.scss +18 -24
- package/src/slider/slider.scss +19 -0
- package/src/slider/slider.ts +30 -19
- package/src/snackbar/snackbar.scss +62 -31
- package/src/snackbar/snackbar.ts +91 -11
- package/src/switch/switch.ts +3 -1
- package/src/table/table.ts +3 -1
- package/src/tabs/tab.ts +10 -6
- package/src/text/text.css-component.scss +7 -1
- package/src/textarea/textarea.ts +4 -2
- package/src/time-picker/time-picker.ts +5 -3
- 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/src/tooltip/tooltip.ts +24 -0
- package/src/url-field/index.ts +1 -0
- package/src/url-field/url-field.scss +50 -0
- package/src/url-field/url-field.ts +239 -0
- package/dist/button-COYCtuA8.js.map +0 -1
- package/dist/button-group-DsXquZQn.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-DKAIv5BB.js.map +0 -1
- package/dist/select-C3XAzenC.js.map +0 -1
- package/dist/src/styleMixins.css.d.ts +0 -9
- package/dist/src/tree-view/index.d.ts +0 -2
- package/dist/src/tree-view/tree-node.d.ts +0 -69
- package/dist/src/tree-view/tree-view.d.ts +0 -40
- package/dist/src/tree-view/wc-tree-view.d.ts +0 -6
- package/dist/src/utils.d.ts +0 -9
- package/dist/test/tree-view.test.d.ts +0 -1
- package/src/styleMixins.css.ts +0 -55
- package/src/tree-view/demo/index.html +0 -57
- package/src/tree-view/index.ts +0 -2
- package/src/tree-view/tree-node.scss +0 -101
- package/src/tree-view/tree-node.ts +0 -268
- package/src/tree-view/tree-view.ts +0 -182
- package/src/tree-view/wc-tree-view.ts +0 -9
- 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/src/{spread.ts → __directive/spread.ts} +0 -0
- /package/src/{utils → __utils}/copy-to-clipboard.ts +0 -0
- /package/src/{utils → __utils}/dispatch-event-utils.ts +0 -0
- /package/src/{utils → __utils}/observe-theme-change.ts +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
height: 100%;
|
|
8
|
+
width: var(--nav-rail-width, 5rem); /* 80dp */
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.rail {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: center;
|
|
16
|
+
height: 100%;
|
|
17
|
+
width: 100%;
|
|
18
|
+
border-radius: inherit;
|
|
19
|
+
background-color: var(--nav-rail-container-color, var(--color-surface));
|
|
20
|
+
padding-block: var(--nav-rail-padding-block, 0.75rem); /* 12dp */
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
|
|
23
|
+
.header {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
align-items: center;
|
|
27
|
+
width: 100%;
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
|
|
30
|
+
&:empty {
|
|
31
|
+
display: none;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
wc-divider {
|
|
36
|
+
width: calc(100% - 1rem);
|
|
37
|
+
margin-block: 0.5rem;
|
|
38
|
+
flex-shrink: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.items {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: center;
|
|
45
|
+
width: 100%;
|
|
46
|
+
gap: 0.75rem; /* 12dp between items */
|
|
47
|
+
flex: 1;
|
|
48
|
+
|
|
49
|
+
::slotted(wc-navigation-rail-item) {
|
|
50
|
+
width: 100%;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* Alignment variants */
|
|
55
|
+
&.align-top {
|
|
56
|
+
.items {
|
|
57
|
+
justify-content: flex-start;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&.align-center {
|
|
62
|
+
.items {
|
|
63
|
+
justify-content: center;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&.align-bottom {
|
|
68
|
+
.items {
|
|
69
|
+
justify-content: flex-end;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { html, LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import styles from './navigation-rail.scss';
|
|
5
|
+
import { NavigationRailItem } from './navigation-rail-item.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @label Navigation Rail
|
|
9
|
+
* @tag wc-navigation-rail
|
|
10
|
+
* @rawTag navigation-rail
|
|
11
|
+
*
|
|
12
|
+
* @summary A vertical side navigation for medium-sized screens, following Material Design 3 specs.
|
|
13
|
+
* @overview
|
|
14
|
+
* <p>Navigation rail provides access to primary destinations in an app using icons—with or without labels—on a vertical rail.</p>
|
|
15
|
+
* <p>Use navigation rail on medium-sized screens (tablets) with 3–7 destinations.</p>
|
|
16
|
+
*
|
|
17
|
+
* @cssprop --nav-rail-width - Width of the rail container. Defaults to 5rem (80dp).
|
|
18
|
+
* @cssprop --nav-rail-container-color - Background color of the rail. Defaults to surface color.
|
|
19
|
+
* @cssprop --nav-rail-indicator-color - Color of the active indicator. Defaults to secondary-container.
|
|
20
|
+
* @cssprop --nav-rail-indicator-shape - Shape (border-radius) of the active indicator. Defaults to full (pill).
|
|
21
|
+
* @cssprop --nav-rail-indicator-width - Width of the active indicator. Defaults to 3.5rem (56dp).
|
|
22
|
+
* @cssprop --nav-rail-indicator-height - Height of the active indicator. Defaults to 2rem (32dp).
|
|
23
|
+
* @cssprop --nav-rail-inactive-icon-color - Color of inactive icons. Defaults to on-surface-variant.
|
|
24
|
+
* @cssprop --nav-rail-active-icon-color - Color of active icons. Defaults to on-secondary-container.
|
|
25
|
+
* @cssprop --nav-rail-inactive-label-color - Color of inactive labels. Defaults to on-surface-variant.
|
|
26
|
+
* @cssprop --nav-rail-active-label-color - Color of active labels. Defaults to on-surface.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```html
|
|
30
|
+
* <wc-navigation-rail>
|
|
31
|
+
* <wc-navigation-rail-item active>
|
|
32
|
+
* <wc-icon slot="icon">home</wc-icon>
|
|
33
|
+
* Home
|
|
34
|
+
* </wc-navigation-rail-item>
|
|
35
|
+
* <wc-navigation-rail-item>
|
|
36
|
+
* <wc-icon slot="icon">search</wc-icon>
|
|
37
|
+
* Search
|
|
38
|
+
* </wc-navigation-rail-item>
|
|
39
|
+
* <wc-navigation-rail-item>
|
|
40
|
+
* <wc-icon slot="icon">settings</wc-icon>
|
|
41
|
+
* Settings
|
|
42
|
+
* </wc-navigation-rail-item>
|
|
43
|
+
* </wc-navigation-rail>
|
|
44
|
+
* ```
|
|
45
|
+
* @tags navigation
|
|
46
|
+
*/
|
|
47
|
+
export class NavigationRail extends LitElement {
|
|
48
|
+
static styles = [styles];
|
|
49
|
+
|
|
50
|
+
static Item = NavigationRailItem;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Vertical alignment of items within the rail.
|
|
54
|
+
* - `"top"`: Items align to the top.
|
|
55
|
+
* - `"center"`: Items are centered (default).
|
|
56
|
+
* - `"bottom"`: Items align to the bottom.
|
|
57
|
+
*/
|
|
58
|
+
@property({ reflect: true }) alignment: 'top' | 'center' | 'bottom' = 'center';
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Display mode of the navigation rail.
|
|
62
|
+
* - `"expanded"`: shows labels.
|
|
63
|
+
* - `"collapsed"`: hides labels.
|
|
64
|
+
*/
|
|
65
|
+
@property({ reflect: true }) mode: 'expanded' | 'collapsed' = 'expanded';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Whether to show a divider between the header and items sections.
|
|
69
|
+
*/
|
|
70
|
+
@property({ type: Boolean, attribute: 'show-divider' }) showDivider = false;
|
|
71
|
+
|
|
72
|
+
connectedCallback() {
|
|
73
|
+
super.connectedCallback();
|
|
74
|
+
this.addEventListener('click', this._handleItemClick);
|
|
75
|
+
this.setAttribute('role', 'navigation');
|
|
76
|
+
this.setAttribute('aria-label', this.getAttribute('aria-label') ?? 'Main navigation');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
disconnectedCallback() {
|
|
80
|
+
this.removeEventListener('click', this._handleItemClick);
|
|
81
|
+
super.disconnectedCallback();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
protected override firstUpdated() {
|
|
85
|
+
this._syncItemMode();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
protected override updated(changedProperties: PropertyValues<this>) {
|
|
89
|
+
if (changedProperties.has('mode')) {
|
|
90
|
+
this._syncItemMode();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private _handleItemClick = (event: Event) => {
|
|
95
|
+
const target = event.target as HTMLElement;
|
|
96
|
+
const item = target.closest('wc-navigation-rail-item') as NavigationRailItem | null;
|
|
97
|
+
|
|
98
|
+
if (!item || item.disabled) return;
|
|
99
|
+
|
|
100
|
+
// Deactivate all items and activate the clicked one
|
|
101
|
+
for (const railItem of this._getItems()) {
|
|
102
|
+
railItem.active = railItem === item;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.dispatchEvent(
|
|
106
|
+
new CustomEvent('nav-change', {
|
|
107
|
+
detail: {
|
|
108
|
+
value: item.value,
|
|
109
|
+
item,
|
|
110
|
+
},
|
|
111
|
+
bubbles: true,
|
|
112
|
+
composed: true,
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
private _getItems(): NavigationRailItem[] {
|
|
118
|
+
return Array.from(
|
|
119
|
+
this.querySelectorAll('wc-navigation-rail-item'),
|
|
120
|
+
) as NavigationRailItem[];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private _syncItemMode = () => {
|
|
124
|
+
const isCollapsed = this.mode === 'collapsed';
|
|
125
|
+
for (const railItem of this._getItems()) {
|
|
126
|
+
railItem.collapsed = isCollapsed;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
render() {
|
|
131
|
+
const cssClasses = {
|
|
132
|
+
rail: true,
|
|
133
|
+
[`align-${this.alignment}`]: true,
|
|
134
|
+
[`mode-${this.mode}`]: true,
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return html`
|
|
138
|
+
<div class=${classMap(cssClasses)}>
|
|
139
|
+
<div class="header">
|
|
140
|
+
<slot name="header"></slot>
|
|
141
|
+
</div>
|
|
142
|
+
${this.showDivider ? html`<wc-divider></wc-divider>` : ''}
|
|
143
|
+
<nav class="items" role="presentation">
|
|
144
|
+
<slot @slotchange=${this._syncItemMode}></slot>
|
|
145
|
+
</nav>
|
|
146
|
+
</div>
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Notification } from './notification.js';
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
--notification-container-color: var(--color-primary-container);
|
|
7
|
+
--notification-text-color: var(--color-on-primary-container);
|
|
8
|
+
--notification-leading-icon-color: var(--color-on-primary-container);
|
|
9
|
+
--notification-accent-color: var(--color-primary);
|
|
10
|
+
--notification-border-radius: var(--shape-corner-medium);
|
|
11
|
+
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host(:not([inline])) {
|
|
16
|
+
width: min(100%, 28rem);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.notification {
|
|
20
|
+
align-items: flex-start;
|
|
21
|
+
background: var(--notification-container-color);
|
|
22
|
+
border-inline-start: 4px solid var(--notification-accent-color);
|
|
23
|
+
border-radius: var(--notification-border-radius);
|
|
24
|
+
color: var(--notification-text-color);
|
|
25
|
+
display: grid;
|
|
26
|
+
gap: var(--spacing-100);
|
|
27
|
+
grid-template-columns: auto 1fr auto;
|
|
28
|
+
padding: var(--spacing-150) var(--spacing-100) var(--spacing-150) var(--spacing-150);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.state-icon {
|
|
32
|
+
align-items: center;
|
|
33
|
+
color: var(--notification-leading-icon-color);
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
min-height: 2rem;
|
|
37
|
+
|
|
38
|
+
--icon-size: 1.25rem;
|
|
39
|
+
--icon-color: var(--notification-leading-icon-color);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.content {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
gap: var(--spacing-100);
|
|
46
|
+
min-width: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.content-text {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
gap: var(--spacing-025);
|
|
53
|
+
min-width: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.title {
|
|
57
|
+
@include mixin.get-typography(label-large);
|
|
58
|
+
color: var(--notification-text-color);
|
|
59
|
+
overflow-wrap: anywhere;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.subtitle {
|
|
63
|
+
@include mixin.get-typography(body-medium);
|
|
64
|
+
color: var(--notification-text-color);
|
|
65
|
+
opacity: 0.88;
|
|
66
|
+
overflow-wrap: anywhere;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.title ::slotted(*),
|
|
70
|
+
.subtitle ::slotted(*) {
|
|
71
|
+
margin: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.actions {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
gap: var(--spacing-100);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.action {
|
|
80
|
+
--outlined-button-label-text-color: var(--notification-text-color);
|
|
81
|
+
--outlined-button-outline-color: color-mix(in srgb, var(--notification-text-color) 40%, transparent);
|
|
82
|
+
--text-button-label-text-color: var(--notification-text-color);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.close-button-container {
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.close-button {
|
|
90
|
+
--text-button-label-text-color: var(--notification-text-color);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.notification.inline {
|
|
94
|
+
align-items: center;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.notification.inline .content {
|
|
98
|
+
align-items: center;
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: row;
|
|
101
|
+
gap: var(--spacing-150);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.notification.inline .content-text {
|
|
105
|
+
display: inline;
|
|
106
|
+
flex: 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.notification.inline .title,
|
|
110
|
+
.notification.inline .subtitle,
|
|
111
|
+
.notification.inline .title ::slotted(*),
|
|
112
|
+
.notification.inline .subtitle ::slotted(*) {
|
|
113
|
+
display: inline;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.notification:not(.has-subtitle) {
|
|
117
|
+
align-items: center;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.notification:not(.has-subtitle) .content {
|
|
121
|
+
gap: 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.notification.variant-info {
|
|
125
|
+
--notification-container-color: var(--color-primary-container);
|
|
126
|
+
--notification-text-color: var(--color-on-primary-container);
|
|
127
|
+
--notification-leading-icon-color: var(--color-on-primary-container);
|
|
128
|
+
--notification-accent-color: var(--color-primary);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.notification.variant-success {
|
|
132
|
+
--notification-container-color: var(--color-success-container);
|
|
133
|
+
--notification-text-color: var(--color-on-success-container);
|
|
134
|
+
--notification-leading-icon-color: var(--color-on-success-container);
|
|
135
|
+
--notification-accent-color: var(--color-success);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.notification.variant-warning {
|
|
139
|
+
--notification-container-color: var(--color-warning-container);
|
|
140
|
+
--notification-text-color: var(--color-on-warning-container);
|
|
141
|
+
--notification-leading-icon-color: var(--color-on-warning-container);
|
|
142
|
+
--notification-accent-color: var(--color-warning);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.notification.variant-error {
|
|
146
|
+
--notification-container-color: var(--color-error-container);
|
|
147
|
+
--notification-text-color: var(--color-on-error-container);
|
|
148
|
+
--notification-leading-icon-color: var(--color-on-error-container);
|
|
149
|
+
--notification-accent-color: var(--color-error);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.notification.high-contrast {
|
|
153
|
+
--notification-container-color: var(--color-inverse-surface);
|
|
154
|
+
--notification-text-color: var(--color-inverse-on-surface);
|
|
155
|
+
--notification-leading-icon-color: var(--color-inverse-on-surface);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.notification.high-contrast.variant-info {
|
|
159
|
+
--notification-accent-color: var(--color-primary);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.notification.high-contrast.variant-success {
|
|
163
|
+
--notification-accent-color: var(--color-success);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.notification.high-contrast.variant-warning {
|
|
167
|
+
--notification-accent-color: var(--color-warning);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.notification.high-contrast.variant-error {
|
|
171
|
+
--notification-accent-color: var(--color-error);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@media (max-width: 640px) {
|
|
175
|
+
:host(:not([inline])) {
|
|
176
|
+
width: 100%;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.notification.inline {
|
|
180
|
+
align-items: flex-start;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.notification.inline .content {
|
|
184
|
+
align-items: flex-start;
|
|
185
|
+
flex-direction: column;
|
|
186
|
+
gap: var(--spacing-100);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.notification.inline .content-text {
|
|
190
|
+
display: flex;
|
|
191
|
+
flex-direction: column;
|
|
192
|
+
gap: var(--spacing-025);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.notification.inline .title,
|
|
196
|
+
.notification.inline .subtitle,
|
|
197
|
+
.notification.inline .title ::slotted(*),
|
|
198
|
+
.notification.inline .subtitle ::slotted(*) {
|
|
199
|
+
display: initial;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
|
|
5
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
6
|
+
import styles from './notification.scss';
|
|
7
|
+
|
|
8
|
+
type NotificationVariant = 'success' | 'error' | 'info' | 'warning';
|
|
9
|
+
|
|
10
|
+
const VARIANT_LABELS: Record<NotificationVariant, string> = {
|
|
11
|
+
success: 'Success',
|
|
12
|
+
error: 'Error',
|
|
13
|
+
info: 'Information',
|
|
14
|
+
warning: 'Warning',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const VARIANT_ICONS: Record<NotificationVariant, string> = {
|
|
18
|
+
success: 'check_circle',
|
|
19
|
+
error: 'error',
|
|
20
|
+
info: 'info',
|
|
21
|
+
warning: 'warning',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @label Notification
|
|
26
|
+
* @tag wc-notification
|
|
27
|
+
* @rawTag notification
|
|
28
|
+
* @summary Notifications communicate contextual status, errors, warnings, and success messages.
|
|
29
|
+
*
|
|
30
|
+
* @cssprop --notification-container-color - Surface color for the notification container.
|
|
31
|
+
* @cssprop --notification-text-color - Label and supporting text color.
|
|
32
|
+
* @cssprop --notification-leading-icon-color - Leading state icon color.
|
|
33
|
+
* @cssprop --notification-accent-color - Start border color for status emphasis.
|
|
34
|
+
* @cssprop --notification-border-radius - Border radius of the notification container.
|
|
35
|
+
*
|
|
36
|
+
* @fires {CustomEvent} notification-dismiss - Fired when the notification is dismissed.
|
|
37
|
+
* @fires {CustomEvent} notification-action-click - Fired when the action button is clicked.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```html
|
|
41
|
+
* <wc-notification variant="success" action="Undo" dismissible>
|
|
42
|
+
* <span slot="title">Record saved</span>
|
|
43
|
+
* </wc-notification>
|
|
44
|
+
* ```
|
|
45
|
+
* @tags display, feedback
|
|
46
|
+
*/
|
|
47
|
+
@IndividualComponent
|
|
48
|
+
export class Notification extends LitElement {
|
|
49
|
+
static styles = [styles];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* If true, content and actions are laid out in a single row.
|
|
53
|
+
*/
|
|
54
|
+
@property({ type: Boolean, reflect: true }) inline = false;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The visual variant of the notification.
|
|
58
|
+
*/
|
|
59
|
+
@property({ type: String, reflect: true })
|
|
60
|
+
variant: NotificationVariant = 'info';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Enables a high contrast appearance.
|
|
64
|
+
*/
|
|
65
|
+
@property({ type: Boolean, reflect: true, attribute: 'high-contrast' })
|
|
66
|
+
highContrast = false;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* If true, renders a dismiss icon button.
|
|
70
|
+
*/
|
|
71
|
+
@property({ type: Boolean, reflect: true }) dismissible = false;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Action label text. When provided, an action button is shown.
|
|
75
|
+
*/
|
|
76
|
+
@property({ type: String }) action = '';
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* If true, the host controls visibility when dismissed.
|
|
80
|
+
*/
|
|
81
|
+
@property({ type: Boolean, reflect: true }) managed = false;
|
|
82
|
+
|
|
83
|
+
@state() private isHidden = false;
|
|
84
|
+
|
|
85
|
+
@state() private hasSubtitle = false;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Programmatically reveals the notification.
|
|
89
|
+
*/
|
|
90
|
+
show() {
|
|
91
|
+
this.isHidden = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Programmatically dismisses the notification.
|
|
96
|
+
*/
|
|
97
|
+
dismiss() {
|
|
98
|
+
this.hideAndEmitDismiss('programmatic');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private get variantIcon() {
|
|
102
|
+
return VARIANT_ICONS[this.variant];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private get variantLabel() {
|
|
106
|
+
return VARIANT_LABELS[this.variant];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private emitActionClick() {
|
|
110
|
+
this.dispatchEvent(
|
|
111
|
+
new CustomEvent('notification-action-click', {
|
|
112
|
+
bubbles: true,
|
|
113
|
+
composed: true,
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private hideAndEmitDismiss(reason: 'dismiss' | 'programmatic') {
|
|
119
|
+
if (!this.managed) {
|
|
120
|
+
this.isHidden = true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.dispatchEvent(
|
|
124
|
+
new CustomEvent('notification-dismiss', {
|
|
125
|
+
detail: { reason },
|
|
126
|
+
bubbles: true,
|
|
127
|
+
composed: true,
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private handleSubtitleSlotChange(event: Event) {
|
|
133
|
+
const slot = event.target as HTMLSlotElement;
|
|
134
|
+
this.hasSubtitle = slot
|
|
135
|
+
.assignedNodes({ flatten: true })
|
|
136
|
+
.some(node => node.textContent?.trim());
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
render() {
|
|
140
|
+
if (this.isHidden) {
|
|
141
|
+
return nothing;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return html`
|
|
145
|
+
<div
|
|
146
|
+
class=${classMap({
|
|
147
|
+
notification: true,
|
|
148
|
+
inline: this.inline,
|
|
149
|
+
'high-contrast': this.highContrast,
|
|
150
|
+
'has-subtitle': this.hasSubtitle,
|
|
151
|
+
[`variant-${this.variant}`]: true,
|
|
152
|
+
})}
|
|
153
|
+
role="alert"
|
|
154
|
+
aria-live="polite"
|
|
155
|
+
aria-label=${this.variantLabel}
|
|
156
|
+
>
|
|
157
|
+
<div class="state-icon" aria-hidden="true">
|
|
158
|
+
<slot name="icon">
|
|
159
|
+
<wc-icon name=${this.variantIcon}></wc-icon>
|
|
160
|
+
</slot>
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
<div class="content">
|
|
164
|
+
<div class="content-text">
|
|
165
|
+
<div class="title">
|
|
166
|
+
<slot name="title"></slot>
|
|
167
|
+
<slot></slot>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<div class="subtitle">
|
|
171
|
+
<slot name="subtitle" @slotchange=${this.handleSubtitleSlotChange}></slot>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
${this.action
|
|
176
|
+
? html`<div class="actions">
|
|
177
|
+
<wc-button
|
|
178
|
+
class="action"
|
|
179
|
+
size="sm"
|
|
180
|
+
variant=${this.inline ? 'text' : 'outlined'}
|
|
181
|
+
@click=${this.emitActionClick}
|
|
182
|
+
>
|
|
183
|
+
${this.action}
|
|
184
|
+
</wc-button>
|
|
185
|
+
</div>`
|
|
186
|
+
: nothing}
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
${this.dismissible
|
|
190
|
+
? html`<div class="close-button-container">
|
|
191
|
+
<wc-icon-button
|
|
192
|
+
class="close-button"
|
|
193
|
+
variant="text"
|
|
194
|
+
size="sm"
|
|
195
|
+
aria-label="Close notification"
|
|
196
|
+
@click=${() => {
|
|
197
|
+
this.hideAndEmitDismiss('dismiss');
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
<wc-icon name="close"></wc-icon>
|
|
201
|
+
</wc-icon-button>
|
|
202
|
+
</div>`
|
|
203
|
+
: nothing}
|
|
204
|
+
</div>
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { html, LitElement, nothing } from 'lit';
|
|
2
2
|
import { property } from 'lit/decorators.js';
|
|
3
3
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
6
|
+
|
|
5
7
|
import styles from './number-counter.scss';
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { html, nothing } from 'lit';
|
|
2
2
|
import { property, query, state } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { redispatchEvent } from '@/__utils/dispatch-event-utils.js';
|
|
6
|
+
import { spread } from '@/__directive/spread.js';
|
|
7
|
+
|
|
5
8
|
import BaseInput from '../input/BaseInput.js';
|
|
6
9
|
import styles from './number-field.scss';
|
|
7
|
-
import { spread } from '../spread.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @label Number Field
|
|
@@ -168,11 +170,12 @@ export class NumberField extends BaseInput {
|
|
|
168
170
|
${this.stepper && !this.disabled
|
|
169
171
|
? html`<wc-icon-button
|
|
170
172
|
class="stepper"
|
|
171
|
-
name="remove"
|
|
172
173
|
variant="text"
|
|
173
174
|
slot="field-start"
|
|
174
175
|
@click=${this.stepDown}
|
|
175
|
-
|
|
176
|
+
>
|
|
177
|
+
<wc-icon name="remove"></wc-icon>
|
|
178
|
+
</wc-icon-button>`
|
|
176
179
|
: nothing}
|
|
177
180
|
|
|
178
181
|
<slot name="start" slot="field-start"></slot>
|
|
@@ -204,10 +207,11 @@ export class NumberField extends BaseInput {
|
|
|
204
207
|
? html`<wc-icon-button
|
|
205
208
|
class="stepper"
|
|
206
209
|
variant="text"
|
|
207
|
-
name="add"
|
|
208
210
|
slot="field-end"
|
|
209
211
|
@click=${this.stepUp}
|
|
210
|
-
|
|
212
|
+
>
|
|
213
|
+
<wc-icon name="add"></wc-icon>
|
|
214
|
+
</wc-icon-button>`
|
|
211
215
|
: nothing}
|
|
212
216
|
</wc-field>
|
|
213
217
|
`;
|