@redvars/peacock 3.10.0 → 3.11.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/BaseInput-CV0pZgSb.js +58 -0
- package/dist/BaseInput-CV0pZgSb.js.map +1 -0
- package/dist/app-bar.js +16 -16
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/assets/theme.d.ts +66 -0
- package/dist/assets/theme.js +134 -0
- package/dist/assets/tokens.css +1 -1
- package/dist/assets/tokens.css.map +1 -1
- package/dist/base-progress-CLZTRveO.js +33 -0
- package/dist/base-progress-CLZTRveO.js.map +1 -0
- package/dist/bottom-sheet.js +1 -1
- package/dist/button-group.js +9 -7
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +225 -187
- package/dist/button.js.map +1 -1
- package/dist/{chart-bar-CapLbc2e.js → chart-bar-D5dGFJfK.js} +2 -2
- package/dist/{chart-bar-CapLbc2e.js.map → chart-bar-D5dGFJfK.js.map} +1 -1
- package/dist/chart-bar.js +1 -1
- package/dist/chart-stacked-bar.js +1 -1
- package/dist/checkbox.js +78 -53
- package/dist/checkbox.js.map +1 -1
- package/dist/chip-set.js +52 -0
- package/dist/chip-set.js.map +1 -0
- package/dist/chip.js +8 -6
- package/dist/chip.js.map +1 -1
- package/dist/circular-progress.js +177 -0
- package/dist/circular-progress.js.map +1 -0
- package/dist/code-editor.js +129 -72
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +2 -38
- package/dist/code-highlighter.js.map +1 -1
- package/dist/color-field.js +309 -0
- package/dist/color-field.js.map +1 -0
- package/dist/color-picker.js +26 -15
- package/dist/color-picker.js.map +1 -1
- package/dist/copy-to-clipboard-upGx-Ueo.js +39 -0
- package/dist/copy-to-clipboard-upGx-Ueo.js.map +1 -0
- package/dist/custom-elements-jsdocs.json +1044 -382
- package/dist/custom-elements.json +8620 -4714
- package/dist/date-picker.js +241 -0
- package/dist/date-picker.js.map +1 -0
- package/dist/{element-internals-2CMts_0M.js → delegate-py-Ets8N.js} +2 -43
- package/dist/delegate-py-Ets8N.js.map +1 -0
- package/dist/element-internals-QME0yEz4.js +43 -0
- package/dist/element-internals-QME0yEz4.js.map +1 -0
- package/dist/fab.js +51 -49
- package/dist/fab.js.map +1 -1
- package/dist/field.js +34 -4
- package/dist/field.js.map +1 -1
- package/dist/flow.js +5 -5
- package/dist/form-associated-Bhwwr6dT.js +162 -0
- package/dist/form-associated-Bhwwr6dT.js.map +1 -0
- package/dist/{form-associated-BXADnjOB.js → form-submitter-DPI4L6gj.js} +3 -159
- package/dist/form-submitter-DPI4L6gj.js.map +1 -0
- package/dist/html-editor.js +3 -1
- package/dist/html-editor.js.map +1 -1
- package/dist/icon-button.js +195 -156
- package/dist/icon-button.js.map +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +32 -8
- package/dist/index.js.map +1 -1
- package/dist/input.js +259 -0
- package/dist/input.js.map +1 -0
- package/dist/item.js +2 -1
- package/dist/item.js.map +1 -1
- package/dist/linear-progress.js +192 -0
- package/dist/linear-progress.js.map +1 -0
- package/dist/{list-AdO-PUq_.js → list-item.js} +12 -222
- package/dist/list-item.js.map +1 -0
- package/dist/list.js +225 -6
- package/dist/list.js.map +1 -1
- package/dist/loader-full.js +31 -8
- package/dist/loader-full.js.map +1 -1
- package/dist/loader.js +52 -12
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +5 -3
- package/dist/markdown-editor.js.map +1 -1
- package/dist/menu-item.js +30 -30
- package/dist/menu.js +1 -1
- package/dist/navigation-bar-item.js +41 -0
- package/dist/navigation-bar-item.js.map +1 -0
- package/dist/navigation-bar.js +128 -0
- package/dist/navigation-bar.js.map +1 -0
- package/dist/navigation-drawer-item.js +236 -0
- package/dist/navigation-drawer-item.js.map +1 -0
- package/dist/navigation-drawer.js +293 -0
- package/dist/navigation-drawer.js.map +1 -0
- package/dist/navigation-rail.js +1 -1
- package/dist/number-field.js +280 -0
- package/dist/number-field.js.map +1 -0
- package/dist/option.js +17 -0
- package/dist/option.js.map +1 -1
- package/dist/pagination.js +1 -1
- package/dist/radio-group.js +209 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/radio.js +47 -37
- package/dist/radio.js.map +1 -1
- package/dist/segmented-button-group.js +12 -0
- package/dist/segmented-button-group.js.map +1 -1
- package/dist/segmented-button.js +10 -6
- package/dist/segmented-button.js.map +1 -1
- package/dist/select.js +653 -0
- package/dist/select.js.map +1 -0
- package/dist/side-sheet.js +1 -1
- package/dist/sidebar-menu-item.js +273 -0
- package/dist/sidebar-menu-item.js.map +1 -0
- package/dist/sidebar-menu.js +193 -0
- package/dist/sidebar-menu.js.map +1 -0
- package/dist/sidebar-sub-menu.js +301 -0
- package/dist/sidebar-sub-menu.js.map +1 -0
- package/dist/slider.js +76 -24
- package/dist/slider.js.map +1 -1
- package/dist/snackbar.js +3 -3
- package/dist/snackbar.js.map +1 -1
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/utils/size.d.ts +9 -0
- package/dist/src/button/ButtonTypes.d.ts +1 -1
- package/dist/src/checkbox/checkbox.d.ts +28 -22
- package/dist/src/chip/chip/chip.d.ts +3 -0
- package/dist/src/chip/tag/tag.d.ts +5 -1
- package/dist/src/code-editor/code-editor.d.ts +37 -10
- package/dist/src/color-field/color-field.d.ts +55 -0
- package/dist/src/color-field/index.d.ts +1 -0
- package/dist/src/color-picker/color-picker.d.ts +1 -1
- package/dist/src/date-picker/date-picker.d.ts +0 -1
- package/dist/src/field/field.d.ts +2 -0
- package/dist/src/index.d.ts +4 -3
- package/dist/src/input/BaseInput.d.ts +21 -3
- package/dist/src/input/input.d.ts +15 -7
- package/dist/src/navigation-bar/index.d.ts +2 -0
- package/dist/src/navigation-bar/navigation-bar-item.d.ts +23 -0
- package/dist/src/navigation-bar/navigation-bar.d.ts +44 -0
- package/dist/src/navigation-drawer/index.d.ts +2 -0
- package/dist/src/navigation-drawer/navigation-drawer-item.d.ts +48 -0
- package/dist/src/navigation-drawer/navigation-drawer.d.ts +70 -0
- package/dist/src/number-field/number-field.d.ts +0 -1
- package/dist/src/radio/index.d.ts +1 -0
- package/dist/src/radio/radio-group.d.ts +50 -0
- package/dist/src/radio/radio.d.ts +18 -18
- package/dist/src/segmented-button/segmented-button-group.d.ts +5 -0
- package/dist/src/segmented-button/segmented-button.d.ts +2 -1
- package/dist/src/select/select.d.ts +7 -0
- package/dist/src/slider/slider.d.ts +14 -5
- package/dist/src/switch/switch.d.ts +22 -26
- package/dist/src/tabs/tabs.d.ts +3 -0
- package/dist/src/textarea/textarea.d.ts +0 -1
- package/dist/src/time-picker/time-picker.d.ts +0 -1
- package/dist/src/toolbar/toolbar.d.ts +7 -4
- package/dist/src/url-field/url-field.d.ts +0 -1
- package/dist/svg.js +5 -5
- package/dist/switch.js +413 -0
- package/dist/switch.js.map +1 -0
- package/dist/tab.js +2 -1
- package/dist/tab.js.map +1 -1
- package/dist/tabs.js +10 -8
- package/dist/tabs.js.map +1 -1
- package/dist/tag.js +349 -0
- package/dist/tag.js.map +1 -0
- package/dist/test/code-editor.test.d.ts +1 -0
- package/dist/test/color-field.test.d.ts +1 -0
- package/dist/test/color-picker.test.d.ts +1 -0
- package/dist/test/field.test.d.ts +1 -0
- package/dist/test/form-controls.test.d.ts +1 -0
- package/dist/test/icon.test.d.ts +1 -1
- package/dist/test/input.test.d.ts +1 -0
- package/dist/test/navigation.test.d.ts +1 -0
- package/dist/test/segmented-button.test.d.ts +1 -0
- package/dist/test/select.test.d.ts +1 -0
- package/dist/test/slider.test.d.ts +1 -0
- package/dist/textarea.js +237 -0
- package/dist/textarea.js.map +1 -0
- package/dist/time-picker.js +241 -0
- package/dist/time-picker.js.map +1 -0
- package/dist/toolbar.js +26 -9
- package/dist/toolbar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/url-field.js +298 -0
- package/dist/url-field.js.map +1 -0
- package/package.json +29 -8
- package/readme.md +2 -2
- package/scss/tokens.css +175 -18
- package/src/__internal/utils/size.ts +23 -0
- package/src/app-bar/app-bar.scss +4 -16
- package/src/bottom-sheet/bottom-sheet.scss +1 -1
- package/src/button/ButtonTypes.ts +2 -0
- package/src/button/button/button-base.scss +84 -84
- package/src/button/button/button-colors.scss +14 -2
- package/src/button/button/button-layers.scss +71 -71
- package/src/button/button/button-shapes.scss +2 -2
- package/src/button/button/button-sizes.scss +35 -35
- package/src/button/button/button.scss +1 -1
- package/src/button/button/button.ts +1 -2
- package/src/button/button-group/button-group.scss +5 -5
- package/src/button/fab/fab-sizes.scss +15 -15
- package/src/button/fab/fab.scss +32 -32
- package/src/button/icon-button/icon-button-sizes.scss +7 -7
- package/src/chart-bar/chart-bar.scss +1 -1
- package/src/checkbox/checkbox.scss +7 -6
- package/src/checkbox/checkbox.ts +92 -40
- package/src/chip/chip/chip.ts +8 -5
- package/src/chip/chip-set/chip-set.ts +2 -0
- package/src/chip/tag/tag-colors.scss +1 -1
- package/src/chip/tag/tag-sizes.scss +9 -0
- package/src/chip/tag/tag.scss +1 -1
- package/src/chip/tag/tag.ts +20 -9
- package/src/code-editor/code-editor.scss +8 -3
- package/src/code-editor/code-editor.ts +148 -79
- package/src/code-highlighter/code-highlighter.scss +1 -1
- package/src/color-field/color-field.scss +48 -0
- package/src/color-field/color-field.ts +239 -0
- package/src/color-field/index.ts +1 -0
- package/src/color-picker/color-picker.scss +33 -15
- package/src/color-picker/color-picker.ts +2 -1
- package/src/date-picker/date-picker.ts +2 -3
- package/src/field/field.scss +31 -0
- package/src/field/field.ts +5 -1
- package/src/flow/flow.scss +5 -5
- package/src/image/image.scss +2 -2
- package/src/index.ts +7 -3
- package/src/input/BaseInput.ts +54 -4
- package/src/input/input.ts +104 -79
- package/src/list/list-item.ts +2 -0
- package/src/loader.ts +28 -6
- package/src/markdown-editor/markdown-editor.scss +2 -2
- package/src/menu/menu/menu.scss +1 -1
- package/src/menu/menu-item/menu-item.scss +30 -30
- package/src/navigation-bar/index.ts +2 -0
- package/src/navigation-bar/navigation-bar-item.ts +25 -0
- package/src/navigation-bar/navigation-bar.scss +27 -0
- package/src/navigation-bar/navigation-bar.ts +96 -0
- package/src/navigation-drawer/index.ts +2 -0
- package/src/navigation-drawer/navigation-drawer-item.scss +82 -0
- package/src/navigation-drawer/navigation-drawer-item.ts +133 -0
- package/src/navigation-drawer/navigation-drawer.scss +99 -0
- package/src/navigation-drawer/navigation-drawer.ts +196 -0
- package/src/navigation-rail/navigation-rail.scss +1 -1
- package/src/number-field/number-field.ts +2 -3
- package/src/pagination/pagination.scss +1 -1
- package/src/progress/circular-progress/circular-progress.ts +2 -0
- package/src/progress/linear-progress/linear-progress.ts +2 -0
- package/src/radio/index.ts +1 -0
- package/src/radio/radio-group.scss +39 -0
- package/src/radio/radio-group.ts +167 -0
- package/src/radio/radio.ts +74 -31
- package/src/segmented-button/segmented-button-group.ts +12 -0
- package/src/segmented-button/segmented-button.ts +12 -6
- package/src/select/option.ts +17 -0
- package/src/select/select.ts +33 -8
- package/src/side-sheet/side-sheet.scss +1 -1
- package/src/sidebar-menu/sidebar-menu-item.scss +1 -1
- package/src/sidebar-menu/sidebar-menu-item.ts +2 -0
- package/src/sidebar-menu/sidebar-menu.ts +2 -0
- package/src/sidebar-menu/sidebar-sub-menu.scss +1 -1
- package/src/sidebar-menu/sidebar-sub-menu.ts +2 -0
- package/src/slider/slider.scss +3 -3
- package/src/slider/slider.ts +119 -31
- package/src/snackbar/snackbar.ts +3 -3
- package/src/split-button/split-button-colors.scss +2 -2
- package/src/svg/svg.scss +5 -5
- package/src/switch/switch.scss +0 -1
- package/src/switch/switch.ts +82 -47
- package/src/tabs/tab.scss +2 -1
- package/src/tabs/tabs.ts +14 -8
- package/src/textarea/textarea.ts +2 -3
- package/src/time-picker/time-picker.ts +2 -3
- package/src/toolbar/toolbar.scss +4 -4
- package/src/toolbar/toolbar.ts +12 -5
- package/src/url-field/url-field.ts +2 -3
- package/dist/BaseInput-CU1zZYKc.js +0 -27
- package/dist/BaseInput-CU1zZYKc.js.map +0 -1
- package/dist/brand-loader.js +0 -358
- package/dist/brand-loader.js.map +0 -1
- package/dist/element-internals-2CMts_0M.js.map +0 -1
- package/dist/form-associated-BXADnjOB.js.map +0 -1
- package/dist/list-AdO-PUq_.js.map +0 -1
- package/dist/select-CnnPbvpQ.js +0 -3955
- package/dist/select-CnnPbvpQ.js.map +0 -1
- package/dist/src/brand-loader/brand-loader.d.ts +0 -33
- package/dist/src/brand-loader/index.d.ts +0 -2
- package/src/brand-loader/brand-loader.scss +0 -270
- package/src/brand-loader/brand-loader.ts +0 -115
- package/src/brand-loader/index.ts +0 -2
- /package/dist/test/{brand-loader.test.d.ts → button.test.d.ts} +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
--_width: var(--navigation-drawer-width, 22.5rem); // 360dp
|
|
8
|
+
--_container-color: var(
|
|
9
|
+
--navigation-drawer-container-color,
|
|
10
|
+
var(--color-surface-container-low)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host([variant='standard']) {
|
|
15
|
+
height: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
:host([variant='standard']:not([open])) {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.drawer {
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
background-color: var(--_container-color);
|
|
25
|
+
color: var(--color-on-surface-variant);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.standard {
|
|
29
|
+
width: var(--_width);
|
|
30
|
+
height: 100%;
|
|
31
|
+
overflow-y: auto;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.modal {
|
|
35
|
+
position: fixed;
|
|
36
|
+
inset-block: 0;
|
|
37
|
+
inset-inline-start: 0;
|
|
38
|
+
inset-inline-end: auto;
|
|
39
|
+
width: min(var(--_width), calc(100vw - 3.5rem));
|
|
40
|
+
max-width: none;
|
|
41
|
+
height: 100dvh;
|
|
42
|
+
max-height: none;
|
|
43
|
+
margin: 0;
|
|
44
|
+
padding: 0;
|
|
45
|
+
border: none;
|
|
46
|
+
border-start-end-radius: var(--shape-corner-large);
|
|
47
|
+
border-end-end-radius: var(--shape-corner-large);
|
|
48
|
+
box-shadow: var(--elevation-level1);
|
|
49
|
+
overflow-y: auto;
|
|
50
|
+
|
|
51
|
+
&[open] {
|
|
52
|
+
animation: slide-in var(--duration-medium2, 300ms)
|
|
53
|
+
var(--easing-emphasized-decelerate, ease-out);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&::backdrop {
|
|
57
|
+
background: color-mix(in srgb, var(--color-scrim, black) 32%, transparent);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@keyframes slide-in {
|
|
62
|
+
from {
|
|
63
|
+
transform: translateX(-100%);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:host(:dir(rtl)) .modal[open] {
|
|
68
|
+
animation-name: slide-in-rtl;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@keyframes slide-in-rtl {
|
|
72
|
+
from {
|
|
73
|
+
transform: translateX(100%);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.container {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
min-height: 100%;
|
|
81
|
+
padding: var(--spacing-150);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.headline {
|
|
85
|
+
@include mixin.get-typography(title-small);
|
|
86
|
+
color: var(--color-on-surface-variant);
|
|
87
|
+
padding: var(--spacing-200) var(--spacing-200) var(--spacing-150);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.items {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@media (prefers-reduced-motion: reduce) {
|
|
96
|
+
.modal[open] {
|
|
97
|
+
animation: none;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { html, LitElement, nothing, PropertyValues } from 'lit';
|
|
2
|
+
import { property, query } from 'lit/decorators.js';
|
|
3
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
4
|
+
import { NavigationDrawerItem } from './navigation-drawer-item.js';
|
|
5
|
+
import styles from './navigation-drawer.scss';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @label Navigation Drawer
|
|
9
|
+
* @tag wc-navigation-drawer
|
|
10
|
+
* @rawTag navigation-drawer
|
|
11
|
+
*
|
|
12
|
+
* @summary A side panel listing an app's destinations.
|
|
13
|
+
* @overview
|
|
14
|
+
* <p>Navigation drawer holds <code>wc-navigation-drawer-item</code> destinations. Clicking an item makes
|
|
15
|
+
* it the active one and fires <code>change</code>.</p>
|
|
16
|
+
* <ul>
|
|
17
|
+
* <li><code>variant="standard"</code> (default) sits in the page layout, next to the content.</li>
|
|
18
|
+
* <li><code>variant="modal"</code> opens over the page with a scrim. It traps focus, closes on Escape,
|
|
19
|
+
* on a scrim click and after an item is chosen.</li>
|
|
20
|
+
* </ul>
|
|
21
|
+
* <p>Both variants show only while <code>open</code> is set.</p>
|
|
22
|
+
*
|
|
23
|
+
* @slot - The drawer items. Other content, such as `wc-divider` or section titles, works too.
|
|
24
|
+
* @slot header - Content above the items, after the headline.
|
|
25
|
+
*
|
|
26
|
+
* @fires {CustomEvent<{value: string | undefined, index: number, item: NavigationDrawerItem}>} change - Dispatched when the user activates an item.
|
|
27
|
+
* @fires {CustomEvent} open - Dispatched when the drawer opens.
|
|
28
|
+
* @fires {CustomEvent} close - Dispatched when the drawer closes.
|
|
29
|
+
*
|
|
30
|
+
* @cssprop --navigation-drawer-width - Width of the drawer. Defaults to 22.5rem (360dp).
|
|
31
|
+
* @cssprop --navigation-drawer-container-color - Background of the drawer. Defaults to `--color-surface-container-low`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```html
|
|
35
|
+
* <wc-navigation-drawer open headline="Mail">
|
|
36
|
+
* <wc-navigation-drawer-item active badge="24">
|
|
37
|
+
* <wc-icon slot="icon" name="inbox"></wc-icon>
|
|
38
|
+
* Inbox
|
|
39
|
+
* </wc-navigation-drawer-item>
|
|
40
|
+
* <wc-navigation-drawer-item>
|
|
41
|
+
* <wc-icon slot="icon" name="send"></wc-icon>
|
|
42
|
+
* Sent
|
|
43
|
+
* </wc-navigation-drawer-item>
|
|
44
|
+
* </wc-navigation-drawer>
|
|
45
|
+
* ```
|
|
46
|
+
* @tags navigation
|
|
47
|
+
*/
|
|
48
|
+
@IndividualComponent
|
|
49
|
+
export class NavigationDrawer extends LitElement {
|
|
50
|
+
// ── Static ───────────────────────────────────────────────────────────────
|
|
51
|
+
|
|
52
|
+
static styles = [styles];
|
|
53
|
+
|
|
54
|
+
static Item = NavigationDrawerItem;
|
|
55
|
+
|
|
56
|
+
// ── Properties ───────────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
/** Whether the drawer is shown. */
|
|
59
|
+
@property({ type: Boolean, reflect: true }) open = false;
|
|
60
|
+
|
|
61
|
+
/** `"standard"` sits in the layout; `"modal"` opens over the page with a scrim. */
|
|
62
|
+
@property({ reflect: true }) variant: 'standard' | 'modal' = 'standard';
|
|
63
|
+
|
|
64
|
+
/** Title shown at the top of the drawer. */
|
|
65
|
+
@property() headline = '';
|
|
66
|
+
|
|
67
|
+
// ── Queries ──────────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
@query('dialog') private dialogElement?: HTMLDialogElement;
|
|
70
|
+
|
|
71
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
72
|
+
|
|
73
|
+
override connectedCallback() {
|
|
74
|
+
super.connectedCallback();
|
|
75
|
+
this.addEventListener('click', this.handleItemClick);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
override disconnectedCallback() {
|
|
79
|
+
this.removeEventListener('click', this.handleItemClick);
|
|
80
|
+
super.disconnectedCallback();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected override updated(changed: PropertyValues<this>) {
|
|
84
|
+
if (changed.has('open') || changed.has('variant')) {
|
|
85
|
+
this.syncDialog();
|
|
86
|
+
}
|
|
87
|
+
// Skip the first render: `open` set in markup is not a user action.
|
|
88
|
+
if (changed.has('open') && changed.get('open') !== undefined) {
|
|
89
|
+
this.dispatchEvent(
|
|
90
|
+
new CustomEvent(this.open ? 'open' : 'close', {
|
|
91
|
+
bubbles: true,
|
|
92
|
+
composed: true,
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ── Public methods ───────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
/** Opens the drawer. */
|
|
101
|
+
show() {
|
|
102
|
+
this.open = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Closes the drawer. */
|
|
106
|
+
close() {
|
|
107
|
+
this.open = false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ── Private methods ──────────────────────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
private getItems(): NavigationDrawerItem[] {
|
|
113
|
+
return Array.from(
|
|
114
|
+
this.querySelectorAll<NavigationDrawerItem>('wc-navigation-drawer-item'),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private syncDialog() {
|
|
119
|
+
const dialog = this.dialogElement;
|
|
120
|
+
if (!dialog) return;
|
|
121
|
+
if (this.open && !dialog.open) {
|
|
122
|
+
dialog.showModal();
|
|
123
|
+
const items = this.getItems();
|
|
124
|
+
(items.find(item => item.active) ?? items[0])?.focus();
|
|
125
|
+
} else if (!this.open && dialog.open) {
|
|
126
|
+
dialog.close();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private handleItemClick = (event: Event) => {
|
|
131
|
+
const item = (event.target as Element).closest?.(
|
|
132
|
+
'wc-navigation-drawer-item',
|
|
133
|
+
) as NavigationDrawerItem | null;
|
|
134
|
+
if (!item || item.disabled) return;
|
|
135
|
+
|
|
136
|
+
const items = this.getItems();
|
|
137
|
+
for (const drawerItem of items) {
|
|
138
|
+
drawerItem.active = drawerItem === item;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.dispatchEvent(
|
|
142
|
+
new CustomEvent('change', {
|
|
143
|
+
detail: { value: item.value, index: items.indexOf(item), item },
|
|
144
|
+
bubbles: true,
|
|
145
|
+
composed: true,
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
if (this.variant === 'modal') this.close();
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** Escape: close through `open` so the property stays the source of truth. */
|
|
153
|
+
private handleCancel(event: Event) {
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
this.close();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** A click that lands on the dialog itself, not its content, is a scrim click. */
|
|
159
|
+
private handleDialogClick(event: MouseEvent) {
|
|
160
|
+
if (event.target === this.dialogElement) this.close();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ── Render helpers ───────────────────────────────────────────────────────
|
|
164
|
+
|
|
165
|
+
private renderContent() {
|
|
166
|
+
return html`
|
|
167
|
+
<div class="container" part="container">
|
|
168
|
+
${this.headline
|
|
169
|
+
? html`<div class="headline">${this.headline}</div>`
|
|
170
|
+
: nothing}
|
|
171
|
+
<slot name="header"></slot>
|
|
172
|
+
<nav class="items" aria-label=${this.headline || 'Navigation'}>
|
|
173
|
+
<slot></slot>
|
|
174
|
+
</nav>
|
|
175
|
+
</div>
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
180
|
+
|
|
181
|
+
render() {
|
|
182
|
+
if (this.variant === 'modal') {
|
|
183
|
+
return html`<dialog
|
|
184
|
+
class="drawer modal"
|
|
185
|
+
@cancel=${this.handleCancel}
|
|
186
|
+
@click=${this.handleDialogClick}
|
|
187
|
+
>
|
|
188
|
+
${this.renderContent()}
|
|
189
|
+
</dialog>`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return html`<div class="drawer standard" ?hidden=${!this.open}>
|
|
193
|
+
${this.renderContent()}
|
|
194
|
+
</div>`;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -5,6 +5,7 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
|
5
5
|
import { redispatchEvent } from '@/__internal/utils/dispatch-event-utils.js';
|
|
6
6
|
import { spread } from '@/__internal/directive/spread.js';
|
|
7
7
|
|
|
8
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
8
9
|
import BaseInput from '../input/BaseInput.js';
|
|
9
10
|
import styles from './number-field.scss';
|
|
10
11
|
|
|
@@ -20,6 +21,7 @@ import styles from './number-field.scss';
|
|
|
20
21
|
* <wc-number-field label="Age" placeholder="Enter your age"></wc-number-field>
|
|
21
22
|
* ```
|
|
22
23
|
*/
|
|
24
|
+
@IndividualComponent
|
|
23
25
|
export class NumberField extends BaseInput {
|
|
24
26
|
static styles = [styles];
|
|
25
27
|
|
|
@@ -28,9 +30,6 @@ export class NumberField extends BaseInput {
|
|
|
28
30
|
@property({ type: Number })
|
|
29
31
|
value?: number;
|
|
30
32
|
|
|
31
|
-
@property({ type: String })
|
|
32
|
-
name: string = '';
|
|
33
|
-
|
|
34
33
|
@property({ type: String })
|
|
35
34
|
placeholder = '';
|
|
36
35
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
2
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
3
4
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
4
5
|
import styles from './circular-progress.scss';
|
|
@@ -16,6 +17,7 @@ import { BaseProgress } from '../base-progress.js';
|
|
|
16
17
|
* <wc-circular-progress value="30"></wc-circular-progress>
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
20
|
+
@IndividualComponent
|
|
19
21
|
export class CircularProgress extends BaseProgress {
|
|
20
22
|
// Lit components use static styles for better performance
|
|
21
23
|
static styles = [styles];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
2
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
3
4
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
4
5
|
import styles from './linear-progress.scss';
|
|
@@ -16,6 +17,7 @@ import { BaseProgress } from '../base-progress.js';
|
|
|
16
17
|
* <wc-linear-progress value="30" style="width:10rem"></wc-linear-progress>
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
20
|
+
@IndividualComponent
|
|
19
21
|
export class LinearProgress extends BaseProgress {
|
|
20
22
|
// Lit components use static styles for better performance
|
|
21
23
|
static styles = [styles];
|
package/src/radio/index.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.radio-group {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: var(--spacing-100);
|
|
13
|
+
|
|
14
|
+
.label {
|
|
15
|
+
@include mixin.get-typography(body-small);
|
|
16
|
+
color: var(--color-on-surface-variant);
|
|
17
|
+
|
|
18
|
+
.required {
|
|
19
|
+
color: var(--color-error);
|
|
20
|
+
padding-inline-start: var(--spacing-025);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.radios {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
gap: var(--radio-group-gap, var(--spacing-100));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.orientation-horizontal .radios {
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
gap: var(--radio-group-gap, var(--spacing-300));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&.disabled .label {
|
|
37
|
+
opacity: 0.38;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { html, LitElement, nothing, PropertyValues } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
|
+
import type { Radio } from './radio.js';
|
|
6
|
+
import styles from './radio-group.scss';
|
|
7
|
+
|
|
8
|
+
let radioGroupCount = 0;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @label Radio Group
|
|
12
|
+
* @tag wc-radio-group
|
|
13
|
+
* @rawTag radio-group
|
|
14
|
+
* @summary Groups radios under one label, one name and one value.
|
|
15
|
+
* @overview
|
|
16
|
+
* <p>Radio group gives its <code>wc-radio</code> children a shared <code>name</code> (its own, or a
|
|
17
|
+
* generated one), so only one can be checked. Its <code>value</code> is the value of the checked radio,
|
|
18
|
+
* and setting it checks the matching radio.</p>
|
|
19
|
+
* <p>The radios stay form-associated, so the group submits once, through the checked radio.</p>
|
|
20
|
+
*
|
|
21
|
+
* @fires {CustomEvent<{value: string}>} change - Dispatched when the user checks a different radio. The group swallows the radios' own `change` events.
|
|
22
|
+
*
|
|
23
|
+
* @cssprop --radio-group-gap - Space between radios. Defaults to `--spacing-100`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```html
|
|
27
|
+
* <wc-radio-group label="Size" name="size" value="md">
|
|
28
|
+
* <wc-radio value="sm" label="Small"></wc-radio>
|
|
29
|
+
* <wc-radio value="md" label="Medium"></wc-radio>
|
|
30
|
+
* <wc-radio value="lg" label="Large"></wc-radio>
|
|
31
|
+
* </wc-radio-group>
|
|
32
|
+
* ```
|
|
33
|
+
* @tags input, form
|
|
34
|
+
*/
|
|
35
|
+
@IndividualComponent
|
|
36
|
+
export class RadioGroup extends LitElement {
|
|
37
|
+
// ── Static ───────────────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
static styles = [styles];
|
|
40
|
+
|
|
41
|
+
// ── Properties ───────────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
/** Name given to every radio in the group, and submitted with forms. Generated when empty. */
|
|
44
|
+
@property({ type: String, reflect: true })
|
|
45
|
+
name: string = '';
|
|
46
|
+
|
|
47
|
+
/** Value of the checked radio. Setting it checks the radio with that value. */
|
|
48
|
+
@property({ type: String })
|
|
49
|
+
value: string = '';
|
|
50
|
+
|
|
51
|
+
/** Group label, shown above the radios and used as the accessible name. */
|
|
52
|
+
@property({ type: String })
|
|
53
|
+
label: string = '';
|
|
54
|
+
|
|
55
|
+
/** Lays the radios out in a column (default) or a row. */
|
|
56
|
+
@property({ type: String, reflect: true })
|
|
57
|
+
orientation: 'vertical' | 'horizontal' = 'vertical';
|
|
58
|
+
|
|
59
|
+
/** Disables every radio in the group. */
|
|
60
|
+
@property({ type: Boolean, reflect: true })
|
|
61
|
+
disabled: boolean = false;
|
|
62
|
+
|
|
63
|
+
/** Marks the group as required. */
|
|
64
|
+
@property({ type: Boolean, reflect: true })
|
|
65
|
+
required: boolean = false;
|
|
66
|
+
|
|
67
|
+
// ── Private fields ───────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
private readonly generatedName = `wc-radio-group-${(radioGroupCount += 1)}`;
|
|
70
|
+
|
|
71
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
72
|
+
|
|
73
|
+
override connectedCallback() {
|
|
74
|
+
super.connectedCallback();
|
|
75
|
+
this.addEventListener('change', this.handleRadioChange, { capture: true });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
override disconnectedCallback() {
|
|
79
|
+
this.removeEventListener('change', this.handleRadioChange, {
|
|
80
|
+
capture: true,
|
|
81
|
+
});
|
|
82
|
+
super.disconnectedCallback();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected override updated(changed: PropertyValues<this>) {
|
|
86
|
+
if (
|
|
87
|
+
changed.has('name') ||
|
|
88
|
+
changed.has('value') ||
|
|
89
|
+
changed.has('disabled')
|
|
90
|
+
) {
|
|
91
|
+
this.syncRadios();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ── Private methods ──────────────────────────────────────────────────────
|
|
96
|
+
|
|
97
|
+
private getRadios(): Radio[] {
|
|
98
|
+
return Array.from(this.querySelectorAll<Radio>('wc-radio'));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Pushes the group's name, value and disabled state down to its radios. */
|
|
102
|
+
private syncRadios = () => {
|
|
103
|
+
const radios = this.getRadios();
|
|
104
|
+
const name = this.name || this.generatedName;
|
|
105
|
+
|
|
106
|
+
for (const radio of radios) {
|
|
107
|
+
if (radio.name !== name) radio.name = name;
|
|
108
|
+
if (this.disabled) radio.disabled = true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (this.value) {
|
|
112
|
+
for (const radio of radios) radio.checked = radio.value === this.value;
|
|
113
|
+
} else {
|
|
114
|
+
// No value set: adopt the radio that was checked in markup.
|
|
115
|
+
this.value = radios.find(radio => radio.checked)?.value ?? '';
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
private handleRadioChange = (event: Event) => {
|
|
120
|
+
if (event.target === this) return;
|
|
121
|
+
const radio = (event.target as Element).closest?.(
|
|
122
|
+
'wc-radio',
|
|
123
|
+
) as Radio | null;
|
|
124
|
+
if (!radio) return;
|
|
125
|
+
|
|
126
|
+
// Capture phase: swallow the radio's `change` so listeners on the group and above see one
|
|
127
|
+
// `change`, the group's.
|
|
128
|
+
event.stopPropagation();
|
|
129
|
+
this.value = radio.value;
|
|
130
|
+
this.dispatchEvent(
|
|
131
|
+
new CustomEvent('change', {
|
|
132
|
+
detail: { value: this.value },
|
|
133
|
+
bubbles: true,
|
|
134
|
+
composed: true,
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
140
|
+
|
|
141
|
+
render() {
|
|
142
|
+
return html`
|
|
143
|
+
<div
|
|
144
|
+
class=${classMap({
|
|
145
|
+
'radio-group': true,
|
|
146
|
+
[`orientation-${this.orientation}`]: true,
|
|
147
|
+
disabled: this.disabled,
|
|
148
|
+
})}
|
|
149
|
+
role="radiogroup"
|
|
150
|
+
aria-label=${this.label || nothing}
|
|
151
|
+
aria-required=${this.required ? 'true' : nothing}
|
|
152
|
+
aria-disabled=${this.disabled ? 'true' : nothing}
|
|
153
|
+
>
|
|
154
|
+
${this.label
|
|
155
|
+
? html`<div class="label" aria-hidden="true">
|
|
156
|
+
${this.label}${this.required
|
|
157
|
+
? html`<span class="required">*</span>`
|
|
158
|
+
: nothing}
|
|
159
|
+
</div>`
|
|
160
|
+
: nothing}
|
|
161
|
+
<div class="radios">
|
|
162
|
+
<slot @slotchange=${this.syncRadios}></slot>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
`;
|
|
166
|
+
}
|
|
167
|
+
}
|