@redvars/peacock 3.16.0 → 3.17.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/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/assets/theme.js +19 -19
- package/dist/assets/tokens.css +1 -1
- package/dist/assets/tokens.css.map +1 -1
- package/dist/card-content.js +8 -7
- package/dist/card-content.js.map +1 -1
- package/dist/card.js +142 -98
- package/dist/card.js.map +1 -1
- package/dist/{chart-bar-D5dGFJfK.js → cartesian-chart-DgE4USyC.js} +529 -312
- package/dist/cartesian-chart-DgE4USyC.js.map +1 -0
- package/dist/chart-area.js +78 -0
- package/dist/chart-area.js.map +1 -0
- package/dist/chart-bar.js +283 -213
- package/dist/chart-bar.js.map +1 -1
- package/dist/{transform-DSwFSqzD.js → chart-base-C2qRMF48.js} +771 -102
- package/dist/chart-base-C2qRMF48.js.map +1 -0
- package/dist/chart-doughnut.js +55 -287
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-line.js +626 -0
- package/dist/chart-line.js.map +1 -0
- package/dist/chart-pie.js +637 -195
- package/dist/chart-pie.js.map +1 -1
- package/dist/code-editor.js +704 -131
- package/dist/code-editor.js.map +1 -1
- package/dist/code-group.js +188 -0
- package/dist/code-group.js.map +1 -0
- package/dist/code-highlighter.js +895 -257
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +1675 -222
- package/dist/custom-elements.json +13351 -3970
- package/dist/image.js +5 -1
- package/dist/image.js.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/loader-full.js +1 -1
- package/dist/loader.js +9 -3
- package/dist/loader.js.map +1 -1
- package/dist/{is-dark-mode-DOcaw4Yq.js → observe-theme-change-DCifz1uv.js} +2 -6
- package/dist/observe-theme-change-DCifz1uv.js.map +1 -0
- package/dist/path-CJ0Arqcy.js +166 -0
- package/dist/path-CJ0Arqcy.js.map +1 -0
- package/dist/snackbar.js +89 -34
- package/dist/snackbar.js.map +1 -1
- package/dist/src/__internal/chart/cartesian-chart.d.ts +80 -0
- package/dist/src/__internal/chart/chart-base.d.ts +113 -0
- package/dist/src/__internal/chart/paths.d.ts +5 -0
- package/dist/src/__internal/chart/types.d.ts +42 -0
- package/dist/src/card/card-content.d.ts +2 -3
- package/dist/src/card/card.d.ts +31 -17
- package/dist/src/chart-area/chart-area.d.ts +54 -0
- package/dist/src/chart-area/index.d.ts +1 -0
- package/dist/src/chart-bar/chart-bar.d.ts +44 -33
- package/dist/src/chart-bar/index.d.ts +0 -1
- package/dist/src/chart-doughnut/chart-doughnut.d.ts +33 -39
- package/dist/src/chart-line/chart-line.d.ts +69 -0
- package/dist/src/chart-line/index.d.ts +1 -0
- package/dist/src/chart-pie/chart-pie.d.ts +63 -28
- package/dist/src/code-editor/code-editor.d.ts +52 -13
- package/dist/src/code-editor/editor-theme.d.ts +60 -0
- package/dist/src/code-highlighter/code-group.d.ts +52 -0
- package/dist/src/code-highlighter/code-highlighter.d.ts +122 -15
- package/dist/src/code-highlighter/index.d.ts +1 -0
- package/dist/src/code-highlighter/line-ranges.d.ts +24 -0
- package/dist/src/code-highlighter/local.d.ts +4 -1
- package/dist/src/code-highlighter/token-colors.d.ts +8 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/snackbar/snackbar.d.ts +13 -1
- package/dist/src/toolbar/toolbar.d.ts +56 -51
- package/dist/table.js +9 -4
- package/dist/table.js.map +1 -1
- package/dist/test/chart.test.d.ts +1 -0
- package/dist/test/code-highlighter.test.d.ts +1 -0
- package/dist/token-colors-0TFHWbcq.js +81 -0
- package/dist/token-colors-0TFHWbcq.js.map +1 -0
- package/dist/toolbar.js +195 -184
- package/dist/toolbar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/readme.md +7 -6
- package/scss/_code-block.scss +139 -0
- package/scss/tokens.css +24 -0
- package/src/__internal/chart/cartesian-chart.ts +404 -0
- package/src/__internal/chart/chart-base.scss +252 -0
- package/src/__internal/chart/chart-base.ts +474 -0
- package/src/__internal/chart/paths.ts +28 -0
- package/src/__internal/chart/types.ts +49 -0
- package/src/card/card-content.ts +12 -9
- package/src/card/card.scss +66 -54
- package/src/card/card.ts +109 -73
- package/src/chart-area/chart-area.ts +82 -0
- package/src/chart-area/index.ts +1 -0
- package/src/chart-bar/chart-bar.ts +336 -250
- package/src/chart-bar/index.ts +0 -1
- package/src/chart-doughnut/chart-doughnut.ts +62 -262
- package/src/chart-doughnut/demo/index.html +14 -22
- package/src/chart-line/chart-line.scss +25 -0
- package/src/chart-line/chart-line.ts +346 -0
- package/src/chart-line/index.ts +1 -0
- package/src/chart-pie/chart-pie.scss +35 -16
- package/src/chart-pie/chart-pie.ts +282 -188
- package/src/chart-pie/demo/index.html +13 -21
- package/src/code-editor/code-editor.scss +132 -36
- package/src/code-editor/code-editor.ts +308 -88
- package/src/code-editor/demo/index.html +39 -12
- package/src/code-editor/editor-theme.ts +213 -0
- package/src/code-highlighter/code-group.scss +34 -0
- package/src/code-highlighter/code-group.ts +173 -0
- package/src/code-highlighter/code-highlighter.scss +226 -111
- package/src/code-highlighter/code-highlighter.ts +554 -199
- package/src/code-highlighter/demo/index.html +68 -4
- package/src/code-highlighter/index.ts +1 -0
- package/src/code-highlighter/line-ranges.ts +81 -0
- package/src/code-highlighter/local.ts +9 -3
- package/src/code-highlighter/token-colors.ts +42 -0
- package/src/index.ts +4 -2
- package/src/loader.ts +8 -2
- package/src/snackbar/demo/index.html +39 -4
- package/src/snackbar/snackbar.scss +27 -10
- package/src/snackbar/snackbar.ts +80 -37
- package/src/table/table.scss +7 -1
- package/src/table/table.ts +4 -3
- package/src/toolbar/toolbar-colors.scss +6 -7
- package/src/toolbar/toolbar.scss +35 -106
- package/src/toolbar/toolbar.ts +180 -80
- package/dist/array-D5vjT2Xm.js +0 -14
- package/dist/array-D5vjT2Xm.js.map +0 -1
- package/dist/chart-bar-D5dGFJfK.js.map +0 -1
- package/dist/chart-stacked-bar.js +0 -403
- package/dist/chart-stacked-bar.js.map +0 -1
- package/dist/copy-to-clipboard-upGx-Ueo.js +0 -39
- package/dist/copy-to-clipboard-upGx-Ueo.js.map +0 -1
- package/dist/is-dark-mode-DOcaw4Yq.js.map +0 -1
- package/dist/pie-Dz0IDiPt.js +0 -537
- package/dist/pie-Dz0IDiPt.js.map +0 -1
- package/dist/pierre-dark-DFWl0m-C.js +0 -4
- package/dist/pierre-dark-DFWl0m-C.js.map +0 -1
- package/dist/pierre-light-BEkAPImt.js +0 -4
- package/dist/pierre-light-BEkAPImt.js.map +0 -1
- package/dist/src/chart-bar/chart-stacked-bar.d.ts +0 -78
- package/dist/src/code-highlighter/constants.d.ts +0 -1
- package/dist/transform-DSwFSqzD.js.map +0 -1
- package/src/chart-bar/chart-bar.scss +0 -58
- package/src/chart-bar/chart-stacked-bar.ts +0 -398
- package/src/chart-doughnut/chart-donut.scss +0 -37
- package/src/code-highlighter/constants.ts +0 -117
- /package/dist/test/{chart-bar.test.d.ts → card.test.d.ts} +0 -0
package/src/toolbar/toolbar.scss
CHANGED
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
@include mixin.base-styles;
|
|
4
4
|
|
|
5
5
|
:host {
|
|
6
|
-
display: block;
|
|
6
|
+
display: inline-block;
|
|
7
|
+
vertical-align: middle;
|
|
7
8
|
--toolbar-container-shape: var(--shape-corner-full);
|
|
8
|
-
--toolbar-
|
|
9
|
-
--toolbar-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
--toolbar-padding: 0.5rem;
|
|
10
|
+
--toolbar-gap: 0.25rem;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([orientation='vertical']) {
|
|
14
|
+
vertical-align: top;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/* ---- Shared toolbar base ---- */
|
|
@@ -17,15 +19,9 @@
|
|
|
17
19
|
.toolbar {
|
|
18
20
|
position: relative;
|
|
19
21
|
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
gap: var(--toolbar-gap);
|
|
22
|
-
padding-inline: var(--toolbar-padding-inline);
|
|
23
|
-
min-height: var(--toolbar-height);
|
|
24
|
-
width: 100%;
|
|
25
22
|
box-sizing: border-box;
|
|
26
|
-
color: var(--_toolbar-
|
|
23
|
+
color: var(--_toolbar-content-color);
|
|
27
24
|
--icon-color: var(--_toolbar-icon-color);
|
|
28
|
-
box-shadow: var(--toolbar-shadow);
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
.toolbar-content {
|
|
@@ -33,6 +29,7 @@
|
|
|
33
29
|
z-index: 1;
|
|
34
30
|
display: flex;
|
|
35
31
|
align-items: center;
|
|
32
|
+
gap: var(--toolbar-gap);
|
|
36
33
|
min-width: 0;
|
|
37
34
|
}
|
|
38
35
|
|
|
@@ -44,70 +41,36 @@
|
|
|
44
41
|
z-index: 0;
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
width: 100%;
|
|
51
|
-
padding-inline: var(--toolbar-padding-inline);
|
|
52
|
-
padding-block-start: 0.5rem;
|
|
53
|
-
padding-block-end: calc(0.5rem + env(safe-area-inset-bottom, 0px));
|
|
54
|
-
|
|
55
|
-
.background {
|
|
56
|
-
border-radius: var(--toolbar-docked-container-shape);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.toolbar-content {
|
|
60
|
-
width: 100%;
|
|
61
|
-
justify-content: space-between;
|
|
62
|
-
gap: var(--toolbar-gap);
|
|
63
|
-
overflow-x: auto;
|
|
64
|
-
overflow-y: hidden;
|
|
65
|
-
scrollbar-width: none;
|
|
66
|
-
|
|
67
|
-
&::-webkit-scrollbar {
|
|
68
|
-
display: none;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
::slotted(*) {
|
|
73
|
-
position: relative;
|
|
74
|
-
z-index: 1;
|
|
75
|
-
flex-shrink: 0;
|
|
76
|
-
}
|
|
44
|
+
::slotted(*) {
|
|
45
|
+
flex-shrink: 0;
|
|
46
|
+
}
|
|
77
47
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
48
|
+
::slotted(wc-icon-button) {
|
|
49
|
+
--button-container-shape: var(--shape-corner-full);
|
|
50
|
+
--button-container-shape-variant: round;
|
|
51
|
+
}
|
|
82
52
|
|
|
83
|
-
|
|
84
|
-
&.size-sm {
|
|
85
|
-
--toolbar-height: 5rem;
|
|
86
|
-
}
|
|
53
|
+
/* ---- Orientation ---- */
|
|
87
54
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
55
|
+
.orientation-horizontal .toolbar-content {
|
|
56
|
+
flex-direction: row;
|
|
57
|
+
}
|
|
91
58
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
59
|
+
.orientation-vertical .toolbar-content {
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
}
|
|
95
62
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
63
|
+
/* Dividers separate groups of actions: a short line across the toolbar's direction. */
|
|
64
|
+
::slotted(wc-divider) {
|
|
65
|
+
align-self: stretch;
|
|
66
|
+
--divider-spacing: 0.25rem;
|
|
99
67
|
}
|
|
100
68
|
|
|
101
69
|
/* ---- Floating variant ---- */
|
|
102
70
|
|
|
103
71
|
.toolbar.variant-floating {
|
|
104
|
-
|
|
105
|
-
|
|
72
|
+
padding: var(--toolbar-padding);
|
|
106
73
|
border-radius: var(--toolbar-container-shape);
|
|
107
|
-
width: auto;
|
|
108
|
-
display: inline-flex;
|
|
109
|
-
padding: 0.75rem;
|
|
110
|
-
gap: 0.5rem;
|
|
111
74
|
|
|
112
75
|
.elevation {
|
|
113
76
|
--elevation-level: 3;
|
|
@@ -119,47 +82,13 @@
|
|
|
119
82
|
border-radius: var(--toolbar-container-shape);
|
|
120
83
|
}
|
|
121
84
|
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
gap: 0.5rem;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
::slotted(*) {
|
|
128
|
-
position: relative;
|
|
129
|
-
z-index: 1;
|
|
85
|
+
&.elevated .elevation {
|
|
86
|
+
--elevation-level: 4;
|
|
130
87
|
}
|
|
88
|
+
}
|
|
131
89
|
|
|
132
|
-
|
|
133
|
-
--button-container-shape: var(--shape-corner-full);
|
|
134
|
-
--button-container-shape-variant: round;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
&.orientation-horizontal {
|
|
138
|
-
min-height: auto;
|
|
139
|
-
padding-block: 0.5rem;
|
|
140
|
-
padding-inline: 0.75rem;
|
|
141
|
-
|
|
142
|
-
.toolbar-content {
|
|
143
|
-
flex-direction: row;
|
|
144
|
-
align-items: center;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
&.orientation-vertical {
|
|
149
|
-
min-height: auto;
|
|
150
|
-
width: auto;
|
|
151
|
-
padding-block: 0.75rem;
|
|
152
|
-
padding-inline: 0.5rem;
|
|
153
|
-
|
|
154
|
-
.toolbar-content {
|
|
155
|
-
flex-direction: column;
|
|
156
|
-
align-items: center;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
90
|
+
/* ---- Flat variant ---- */
|
|
159
91
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
--elevation-level: 4;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
92
|
+
.toolbar.variant-flat {
|
|
93
|
+
padding: 0;
|
|
165
94
|
}
|
package/src/toolbar/toolbar.ts
CHANGED
|
@@ -1,142 +1,242 @@
|
|
|
1
|
-
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
2
|
import { property } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
|
-
import {
|
|
6
|
-
type LegacySize,
|
|
7
|
-
normalizeSize,
|
|
8
|
-
type Size,
|
|
9
|
-
} from '@/__internal/utils/size.js';
|
|
10
5
|
import styles from './toolbar.scss';
|
|
11
6
|
import colorStyles from './toolbar-colors.scss';
|
|
12
7
|
|
|
8
|
+
/** Slotted elements that separate groups and never take focus. */
|
|
9
|
+
const SEPARATOR_SELECTOR = 'wc-divider, hr, [role="separator"]';
|
|
10
|
+
|
|
13
11
|
/**
|
|
14
12
|
* @label Toolbar
|
|
15
13
|
* @tag wc-toolbar
|
|
16
14
|
* @rawTag toolbar
|
|
17
15
|
*
|
|
18
|
-
* @summary A
|
|
16
|
+
* @summary A group of related actions, such as editor formatting controls.
|
|
19
17
|
* @overview
|
|
20
|
-
* <p>The toolbar
|
|
21
|
-
*
|
|
22
|
-
* variant
|
|
18
|
+
* <p>The toolbar groups related actions into one control. The <code>floating</code> variant
|
|
19
|
+
* (default) is an elevated pill that sits over content, such as a canvas or a selection. The
|
|
20
|
+
* <code>flat</code> variant has no container of its own, for embedding in existing chrome like a
|
|
21
|
+
* card or editor header. Both variants lay their actions out horizontally or vertically.</p>
|
|
22
|
+
*
|
|
23
|
+
* <p>Render actions directly as children. Use a <code>wc-divider</code> to separate groups of
|
|
24
|
+
* actions; in a horizontal toolbar give it the <code>vertical</code> attribute.</p>
|
|
23
25
|
*
|
|
24
|
-
* <p>
|
|
25
|
-
*
|
|
26
|
-
* and
|
|
26
|
+
* <p>The toolbar follows the WAI-ARIA toolbar pattern: it is a single tab stop, and the arrow
|
|
27
|
+
* keys along its orientation move focus between actions (Home and End jump to the first and last).
|
|
28
|
+
* Disabled actions and dividers are skipped. Give the toolbar an <code>aria-label</code>.</p>
|
|
27
29
|
*
|
|
28
30
|
* @cssprop --toolbar-container-color - Background color of the toolbar.
|
|
29
|
-
* @cssprop --toolbar-container-shape - Border radius of the
|
|
30
|
-
* @cssprop --toolbar-
|
|
31
|
-
* @cssprop --toolbar-
|
|
32
|
-
* @cssprop --toolbar-
|
|
33
|
-
* @cssprop --toolbar-
|
|
34
|
-
* @cssprop --toolbar-title-color - Color of the title (default slot) text.
|
|
35
|
-
* @cssprop --toolbar-shadow - Box-shadow of the toolbar.
|
|
31
|
+
* @cssprop --toolbar-container-shape - Border radius of the floating toolbar.
|
|
32
|
+
* @cssprop --toolbar-padding - Padding of the floating toolbar.
|
|
33
|
+
* @cssprop --toolbar-gap - Gap between toolbar actions.
|
|
34
|
+
* @cssprop --toolbar-icon-color - Color of icons inside the toolbar.
|
|
35
|
+
* @cssprop --toolbar-content-color - Color of text inside the toolbar.
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
38
|
* ```html
|
|
39
|
-
* <!--
|
|
40
|
-
* <wc-toolbar>
|
|
41
|
-
* <wc-icon-button variant="text" color="surface"><wc-icon name="
|
|
42
|
-
* <wc-icon-button variant="
|
|
43
|
-
* <wc-
|
|
44
|
-
* <wc-icon-button variant="
|
|
39
|
+
* <!-- Floating toolbar -->
|
|
40
|
+
* <wc-toolbar aria-label="Formatting">
|
|
41
|
+
* <wc-icon-button variant="text" color="surface" aria-label="Undo"><wc-icon name="undo"></wc-icon></wc-icon-button>
|
|
42
|
+
* <wc-icon-button variant="text" color="surface" aria-label="Redo"><wc-icon name="redo"></wc-icon></wc-icon-button>
|
|
43
|
+
* <wc-divider vertical></wc-divider>
|
|
44
|
+
* <wc-icon-button variant="tonal" aria-label="Bold"><wc-icon name="format_bold"></wc-icon></wc-icon-button>
|
|
45
|
+
* <wc-icon-button variant="text" color="surface" aria-label="Italic"><wc-icon name="format_italic"></wc-icon></wc-icon-button>
|
|
45
46
|
* </wc-toolbar>
|
|
46
47
|
* ```
|
|
47
48
|
*
|
|
48
49
|
* @example
|
|
49
50
|
* ```html
|
|
50
|
-
* <!--
|
|
51
|
-
* <wc-toolbar
|
|
52
|
-
* <wc-icon-button variant="tonal"><wc-icon name="
|
|
53
|
-
* <wc-icon-button variant="text"><wc-icon name="
|
|
54
|
-
* <wc-icon-button variant="text"><wc-icon name="
|
|
51
|
+
* <!-- Vertical floating toolbar -->
|
|
52
|
+
* <wc-toolbar orientation="vertical" aria-label="Tools">
|
|
53
|
+
* <wc-icon-button variant="tonal" aria-label="Select"><wc-icon name="arrow_selector_tool"></wc-icon></wc-icon-button>
|
|
54
|
+
* <wc-icon-button variant="text" color="surface" aria-label="Draw"><wc-icon name="draw"></wc-icon></wc-icon-button>
|
|
55
|
+
* <wc-icon-button variant="text" color="surface" aria-label="Text"><wc-icon name="text_fields"></wc-icon></wc-icon-button>
|
|
55
56
|
* </wc-toolbar>
|
|
56
57
|
* ```
|
|
57
58
|
*
|
|
58
59
|
* @example
|
|
59
60
|
* ```html
|
|
60
|
-
* <!--
|
|
61
|
-
* <wc-toolbar variant="
|
|
62
|
-
* <wc-icon-button variant="
|
|
63
|
-
* <wc-icon-button variant="text"><wc-icon name="
|
|
64
|
-
* <wc-icon-button variant="text"><wc-icon name="favorite"></wc-icon></wc-icon-button>
|
|
61
|
+
* <!-- Flat toolbar inside existing chrome -->
|
|
62
|
+
* <wc-toolbar variant="flat" aria-label="Row actions">
|
|
63
|
+
* <wc-icon-button variant="text" color="surface" aria-label="Edit"><wc-icon name="edit"></wc-icon></wc-icon-button>
|
|
64
|
+
* <wc-icon-button variant="text" color="surface" aria-label="Delete"><wc-icon name="delete"></wc-icon></wc-icon-button>
|
|
65
65
|
* </wc-toolbar>
|
|
66
66
|
* ```
|
|
67
|
-
* @tags display
|
|
67
|
+
* @tags display
|
|
68
68
|
*/
|
|
69
69
|
@IndividualComponent
|
|
70
70
|
export class Toolbar extends LitElement {
|
|
71
|
+
// ── Static
|
|
71
72
|
static styles = [styles, colorStyles];
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
* Visual and layout variant of the toolbar.
|
|
75
|
-
* - `"docked"`: A full-width bar attached to the edge of the screen (default).
|
|
76
|
-
* - `"floating"`: A detached pill-shaped toolbar that floats over content.
|
|
77
|
-
*/
|
|
78
|
-
@property({ type: String, reflect: true })
|
|
79
|
-
variant: 'docked' | 'floating' = 'docked';
|
|
74
|
+
// ── Properties
|
|
80
75
|
|
|
81
76
|
/**
|
|
82
|
-
*
|
|
83
|
-
* - `"
|
|
84
|
-
* - `"
|
|
77
|
+
* Visual variant of the toolbar.
|
|
78
|
+
* - `"floating"`: An elevated pill that floats over content (default).
|
|
79
|
+
* - `"flat"`: No container, fill or elevation; for embedding in existing chrome.
|
|
85
80
|
*/
|
|
86
81
|
@property({ type: String, reflect: true })
|
|
87
|
-
|
|
82
|
+
variant: 'floating' | 'flat' = 'floating';
|
|
88
83
|
|
|
89
84
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* - `"md"`: 96dp height.
|
|
93
|
-
* - `"lg"`: 112dp height.
|
|
94
|
-
*
|
|
95
|
-
* The long names `"small"`, `"medium"` and `"large"` still work but are deprecated.
|
|
85
|
+
* Orientation of the toolbar. It sets the layout direction and the arrow keys that move focus
|
|
86
|
+
* (Left/Right for horizontal, Up/Down for vertical).
|
|
96
87
|
*/
|
|
97
88
|
@property({ type: String, reflect: true })
|
|
98
|
-
|
|
89
|
+
orientation: 'horizontal' | 'vertical' = 'horizontal';
|
|
99
90
|
|
|
100
91
|
/**
|
|
101
|
-
*
|
|
92
|
+
* Raises the floating toolbar to a higher elevation. Has no effect on the flat variant.
|
|
102
93
|
*/
|
|
103
94
|
@property({ type: Boolean, reflect: true })
|
|
104
95
|
elevated: boolean = false;
|
|
105
96
|
|
|
106
|
-
|
|
107
|
-
const cssClasses = {
|
|
108
|
-
toolbar: true,
|
|
109
|
-
[`variant-${this.variant}`]: true,
|
|
110
|
-
[`orientation-${this.orientation}`]: true,
|
|
111
|
-
[`size-${normalizeSize(this.size, 'sm')}`]: true,
|
|
112
|
-
elevated: this.elevated,
|
|
113
|
-
};
|
|
97
|
+
// ── Private fields
|
|
114
98
|
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
/** The item that holds the toolbar's single tab stop. */
|
|
100
|
+
private __activeItem: HTMLElement | null = null;
|
|
101
|
+
|
|
102
|
+
// ── Lifecycle
|
|
103
|
+
|
|
104
|
+
override connectedCallback() {
|
|
105
|
+
super.connectedCallback();
|
|
106
|
+
// The role lives on the host so the host's aria-label names the toolbar.
|
|
107
|
+
this.setAttribute('role', 'toolbar');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
override firstUpdated() {
|
|
111
|
+
this.__syncTabStops();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
override updated(changed: Map<string, unknown>) {
|
|
115
|
+
if (changed.has('orientation')) {
|
|
116
|
+
this.setAttribute('aria-orientation', this.orientation);
|
|
117
117
|
}
|
|
118
|
+
}
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
// ── Private methods
|
|
121
|
+
|
|
122
|
+
/** Actions that can take focus, in slot order. */
|
|
123
|
+
private __getItems(): HTMLElement[] {
|
|
124
|
+
const slot = this.shadowRoot?.querySelector('slot');
|
|
125
|
+
if (!slot) return [];
|
|
126
|
+
return slot
|
|
127
|
+
.assignedElements({ flatten: true })
|
|
128
|
+
.filter(
|
|
129
|
+
(el): el is HTMLElement =>
|
|
130
|
+
el instanceof HTMLElement &&
|
|
131
|
+
!el.matches(SEPARATOR_SELECTOR) &&
|
|
132
|
+
!el.hasAttribute('disabled') &&
|
|
133
|
+
el.getAttribute('aria-disabled') !== 'true' &&
|
|
134
|
+
!el.hidden,
|
|
135
|
+
);
|
|
120
136
|
}
|
|
121
137
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
/** Gives the active item `tabindex="0"` and every other item `tabindex="-1"`. */
|
|
139
|
+
private __syncTabStops() {
|
|
140
|
+
const items = this.__getItems();
|
|
141
|
+
if (!this.__activeItem || !items.includes(this.__activeItem)) {
|
|
142
|
+
this.__activeItem = items[0] ?? null;
|
|
143
|
+
}
|
|
144
|
+
for (const item of items) {
|
|
145
|
+
item.tabIndex = item === this.__activeItem ? 0 : -1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Makes `item` the tab stop and focuses it. */
|
|
150
|
+
private __focusItem(item: HTMLElement) {
|
|
151
|
+
this.__activeItem = item;
|
|
152
|
+
this.__syncTabStops();
|
|
153
|
+
item.focus();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Finds the toolbar item an event came from. */
|
|
157
|
+
private __itemFromEvent(event: Event, items: HTMLElement[]) {
|
|
158
|
+
return (
|
|
159
|
+
event
|
|
160
|
+
.composedPath()
|
|
161
|
+
.find((node): node is HTMLElement =>
|
|
162
|
+
items.includes(node as HTMLElement),
|
|
163
|
+
) ?? null
|
|
164
|
+
);
|
|
131
165
|
}
|
|
132
166
|
|
|
133
|
-
private
|
|
167
|
+
private __handleSlotChange = () => {
|
|
168
|
+
this.__syncTabStops();
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
private __handleFocusIn = (event: FocusEvent) => {
|
|
172
|
+
const item = this.__itemFromEvent(event, this.__getItems());
|
|
173
|
+
if (item && item !== this.__activeItem) {
|
|
174
|
+
this.__activeItem = item;
|
|
175
|
+
this.__syncTabStops();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
private __handleKeyDown = (event: KeyboardEvent) => {
|
|
180
|
+
const items = this.__getItems();
|
|
181
|
+
if (items.length === 0) return;
|
|
182
|
+
|
|
183
|
+
const current = this.__itemFromEvent(event, items);
|
|
184
|
+
if (!current) return;
|
|
185
|
+
|
|
186
|
+
const index = items.indexOf(current);
|
|
187
|
+
let nextKey = 'ArrowDown';
|
|
188
|
+
let prevKey = 'ArrowUp';
|
|
189
|
+
if (this.orientation === 'horizontal') {
|
|
190
|
+
const rtl = getComputedStyle(this).direction === 'rtl';
|
|
191
|
+
nextKey = rtl ? 'ArrowLeft' : 'ArrowRight';
|
|
192
|
+
prevKey = rtl ? 'ArrowRight' : 'ArrowLeft';
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
let target: HTMLElement | undefined;
|
|
196
|
+
switch (event.key) {
|
|
197
|
+
case nextKey:
|
|
198
|
+
target = items[(index + 1) % items.length];
|
|
199
|
+
break;
|
|
200
|
+
case prevKey:
|
|
201
|
+
target = items[(index - 1 + items.length) % items.length];
|
|
202
|
+
break;
|
|
203
|
+
case 'Home':
|
|
204
|
+
[target] = items;
|
|
205
|
+
break;
|
|
206
|
+
case 'End':
|
|
207
|
+
target = items[items.length - 1];
|
|
208
|
+
break;
|
|
209
|
+
default:
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
if (target) this.__focusItem(target);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// ── Render
|
|
218
|
+
|
|
219
|
+
override render() {
|
|
220
|
+
const floating = this.variant === 'floating';
|
|
221
|
+
const cssClasses = {
|
|
222
|
+
toolbar: true,
|
|
223
|
+
[`variant-${this.variant}`]: true,
|
|
224
|
+
[`orientation-${this.orientation}`]: true,
|
|
225
|
+
elevated: floating && this.elevated,
|
|
226
|
+
};
|
|
227
|
+
|
|
134
228
|
return html`
|
|
135
|
-
<div
|
|
136
|
-
|
|
229
|
+
<div
|
|
230
|
+
class=${classMap(cssClasses)}
|
|
231
|
+
@keydown=${this.__handleKeyDown}
|
|
232
|
+
@focusin=${this.__handleFocusIn}
|
|
233
|
+
>
|
|
234
|
+
${floating
|
|
235
|
+
? html`<wc-elevation class="elevation"></wc-elevation>`
|
|
236
|
+
: nothing}
|
|
137
237
|
<div class="background"></div>
|
|
138
238
|
<div class="toolbar-content">
|
|
139
|
-
<slot></slot>
|
|
239
|
+
<slot @slotchange=${this.__handleSlotChange}></slot>
|
|
140
240
|
</div>
|
|
141
241
|
</div>
|
|
142
242
|
`;
|
package/dist/array-D5vjT2Xm.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function constant(x) {
|
|
2
|
-
return function constant() {
|
|
3
|
-
return x;
|
|
4
|
-
};
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function array(x) {
|
|
8
|
-
return typeof x === "object" && "length" in x
|
|
9
|
-
? x // Array, TypedArray, NodeList, array-like
|
|
10
|
-
: Array.from(x); // Map, Set, iterable, string, or anything else
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { array as a, constant as c };
|
|
14
|
-
//# sourceMappingURL=array-D5vjT2Xm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-D5vjT2Xm.js","sources":["../node_modules/d3-shape/src/constant.js","../node_modules/d3-shape/src/array.js"],"sourcesContent":["export default function(x) {\n return function constant() {\n return x;\n };\n}\n","export var slice = Array.prototype.slice;\n\nexport default function(x) {\n return typeof x === \"object\" && \"length\" in x\n ? x // Array, TypedArray, NodeList, array-like\n : Array.from(x); // Map, Set, iterable, string, or anything else\n}\n"],"names":[],"mappings":"AAAe,iBAAQ,CAAC,CAAC,EAAE;AAC3B,EAAE,OAAO,SAAS,QAAQ,GAAG;AAC7B,IAAI,OAAO,CAAC;AACZ,EAAE,CAAC;AACH;;ACFe,cAAQ,CAAC,CAAC,EAAE;AAC3B,EAAE,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,QAAQ,IAAI;AAC9C,MAAM,CAAC;AACP,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB;;;;","x_google_ignoreList":[0,1]}
|