@redvars/peacock 3.15.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 +2278 -677
- package/dist/custom-elements.json +13962 -3690
- 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/pagination.js +408 -110
- package/dist/pagination.js.map +1 -1
- 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/pagination/page-items.d.ts +14 -0
- package/dist/src/pagination/pagination.d.ts +46 -7
- package/dist/src/snackbar/snackbar.d.ts +13 -1
- package/dist/src/table/table.d.ts +125 -27
- package/dist/src/toolbar/toolbar.d.ts +56 -51
- package/dist/table.js +1007 -338
- 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/test/pagination.test.d.ts +1 -0
- package/dist/test/table.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/pagination/page-items.ts +50 -0
- package/src/pagination/pagination.scss +159 -44
- package/src/pagination/pagination.ts +275 -74
- 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 +337 -109
- package/src/table/table.ts +812 -272
- 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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG path for a rectangle with its own radius per corner, in the order top-left, top-right,
|
|
3
|
+
* bottom-right, bottom-left. Every path has the same commands, so d3 can tween between any two.
|
|
4
|
+
*/
|
|
5
|
+
export function roundedRectPath(
|
|
6
|
+
x: number,
|
|
7
|
+
y: number,
|
|
8
|
+
width: number,
|
|
9
|
+
height: number,
|
|
10
|
+
radii: [number, number, number, number],
|
|
11
|
+
): string {
|
|
12
|
+
const w = Math.max(width, 0);
|
|
13
|
+
const h = Math.max(height, 0);
|
|
14
|
+
const limit = Math.min(w / 2, h / 2);
|
|
15
|
+
const [tl, tr, br, bl] = radii.map(r => Math.max(Math.min(r, limit), 0));
|
|
16
|
+
return [
|
|
17
|
+
`M${x + tl},${y}`,
|
|
18
|
+
`H${x + w - tr}`,
|
|
19
|
+
`A${tr},${tr} 0 0 1 ${x + w},${y + tr}`,
|
|
20
|
+
`V${y + h - br}`,
|
|
21
|
+
`A${br},${br} 0 0 1 ${x + w - br},${y + h}`,
|
|
22
|
+
`H${x + bl}`,
|
|
23
|
+
`A${bl},${bl} 0 0 1 ${x},${y + h - bl}`,
|
|
24
|
+
`V${y + tl}`,
|
|
25
|
+
`A${tl},${tl} 0 0 1 ${x + tl},${y}`,
|
|
26
|
+
'Z',
|
|
27
|
+
].join('');
|
|
28
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** One series in a bar, line or area chart, keyed by the data field that holds its values. */
|
|
2
|
+
export type ChartSeriesConfig = {
|
|
3
|
+
/** Display name in the legend and tooltip. Defaults to the key. */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Any CSS color. Defaults to the next `--color-chart-n` token. */
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** Maps a data field to how its series is shown, for example `{ desktop: { label: 'Desktop' } }`. */
|
|
10
|
+
export type ChartConfig = Record<string, ChartSeriesConfig>;
|
|
11
|
+
|
|
12
|
+
/** One row of cartesian chart data: the category field (`index`) plus a number per series. */
|
|
13
|
+
export type ChartDatum = Record<string, unknown>;
|
|
14
|
+
|
|
15
|
+
/** Formats a value for tooltips, value labels and axis ticks. */
|
|
16
|
+
export type ChartValueFormatter = (value: number) => string;
|
|
17
|
+
|
|
18
|
+
/** A series resolved from config: key, label and color. */
|
|
19
|
+
export type ChartSeries = {
|
|
20
|
+
key: string;
|
|
21
|
+
label: string;
|
|
22
|
+
color: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** A row in the tooltip. */
|
|
26
|
+
export type ChartTooltipRow = {
|
|
27
|
+
key: string;
|
|
28
|
+
label: string;
|
|
29
|
+
color: string;
|
|
30
|
+
value: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** What the tooltip shows and where. Coordinates are relative to the plot element. */
|
|
34
|
+
export type ChartTooltipModel = {
|
|
35
|
+
title: string;
|
|
36
|
+
rows: ChartTooltipRow[];
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Detail of the `chart-select` event. */
|
|
42
|
+
export type ChartSelectDetail = {
|
|
43
|
+
/** Index of the selected category or slice in `data`. */
|
|
44
|
+
index: number;
|
|
45
|
+
/** Series key, when a single series was selected. */
|
|
46
|
+
series?: string;
|
|
47
|
+
/** The selected data row. */
|
|
48
|
+
datum: unknown;
|
|
49
|
+
};
|
package/src/card/card-content.ts
CHANGED
|
@@ -5,21 +5,24 @@ import IndividualComponent from '../IndividualComponent.js';
|
|
|
5
5
|
* @label Card Content
|
|
6
6
|
* @tag wc-card-content
|
|
7
7
|
* @rawTag card-content
|
|
8
|
+
* @summary A padded block inside a card. A card can hold several, next to edge-to-edge media.
|
|
8
9
|
*
|
|
9
|
-
* @cssprop --card-content-padding -
|
|
10
|
-
*
|
|
11
|
-
* ```
|
|
10
|
+
* @cssprop --card-content-padding - Padding on all sides. Defaults to 1rem.
|
|
12
11
|
*/
|
|
13
12
|
@IndividualComponent
|
|
14
13
|
export class CardContent extends LitElement {
|
|
14
|
+
// ── Static ────────────────────────────────────────────────────────────────
|
|
15
|
+
|
|
15
16
|
static styles = css`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
:host {
|
|
18
|
+
display: block;
|
|
19
|
+
padding: var(--card-content-padding, 1rem);
|
|
20
|
+
}
|
|
20
21
|
`;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
// ── Render ────────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
render() {
|
|
23
26
|
return html`<slot></slot>`;
|
|
24
|
-
|
|
27
|
+
}
|
|
25
28
|
}
|
package/src/card/card.scss
CHANGED
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
overflow: hidden;
|
|
58
58
|
padding: var(--card-padding);
|
|
59
59
|
|
|
60
|
-
border: 1px solid transparent; /* Fixes overflow issues with border */
|
|
61
60
|
border-start-start-radius: var(--_container-shape-start-start);
|
|
62
61
|
border-start-end-radius: var(--_container-shape-start-end);
|
|
63
62
|
border-end-start-radius: var(--_container-shape-end-start);
|
|
@@ -148,10 +147,13 @@
|
|
|
148
147
|
corner-shape: var(--_container-corner-shape-variant);
|
|
149
148
|
}
|
|
150
149
|
|
|
151
|
-
|
|
150
|
+
/*
|
|
151
|
+
Actionable and link cards. A disabled one with a disabled-reason stays
|
|
152
|
+
focusable, so it keeps the focus ring; only enabled ones get the ripple.
|
|
153
|
+
*/
|
|
154
|
+
:host([actionable]),
|
|
152
155
|
:host([href]) {
|
|
153
|
-
.focus-ring
|
|
154
|
-
.ripple {
|
|
156
|
+
.focus-ring {
|
|
155
157
|
display: block;
|
|
156
158
|
}
|
|
157
159
|
|
|
@@ -160,59 +162,66 @@
|
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
|
|
165
|
+
:host([actionable]:not([disabled])),
|
|
166
|
+
:host([href]:not([disabled])) {
|
|
167
|
+
.ripple {
|
|
168
|
+
display: block;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
Variants. Hover and press states apply to enabled actionable and link cards
|
|
174
|
+
only, so a static card never suggests it can be clicked.
|
|
175
|
+
*/
|
|
163
176
|
:host([variant='elevated']) {
|
|
164
177
|
--_container-color: var(--elevated-card-container-color);
|
|
165
178
|
--_label-text-color: var(--elevated-card-label-text-color);
|
|
166
179
|
--_container-elevation-level: 1;
|
|
167
180
|
--_container-state-color: var(--_label-text-color);
|
|
181
|
+
}
|
|
168
182
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
&:active:not([disabled]) {
|
|
175
|
-
--_container-elevation-level: 1;
|
|
176
|
-
--_container-state-opacity: 0.12;
|
|
177
|
-
}
|
|
183
|
+
:host([variant='elevated'][actionable]:not([disabled]):hover),
|
|
184
|
+
:host([variant='elevated'][href]:not([disabled]):hover) {
|
|
185
|
+
--_container-elevation-level: 2;
|
|
186
|
+
--_container-state-opacity: 0.08;
|
|
187
|
+
}
|
|
178
188
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
:host([variant='elevated'][actionable]:not([disabled]):active),
|
|
190
|
+
:host([variant='elevated'][href]:not([disabled]):active) {
|
|
191
|
+
--_container-elevation-level: 1;
|
|
192
|
+
--_container-state-opacity: 0.12;
|
|
193
|
+
}
|
|
184
194
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
:host([variant='elevated'][disabled]) {
|
|
196
|
+
--_container-color: var(--color-on-surface);
|
|
197
|
+
--_container-opacity: 0.1;
|
|
198
|
+
--_label-text-color: var(--color-on-surface);
|
|
199
|
+
--_label-text-opacity: 0.38;
|
|
189
200
|
}
|
|
190
201
|
|
|
191
202
|
:host([variant='filled']) {
|
|
192
203
|
--_container-color: var(--filled-card-container-color);
|
|
193
204
|
--_label-text-color: var(--filled-card-label-text-color);
|
|
194
205
|
--_container-state-color: var(--_label-text-color);
|
|
206
|
+
}
|
|
195
207
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
&:active:not([disabled]) {
|
|
202
|
-
--_container-elevation-level: 0;
|
|
203
|
-
--_container-state-opacity: 0.1;
|
|
204
|
-
}
|
|
208
|
+
:host([variant='filled'][actionable]:not([disabled]):hover),
|
|
209
|
+
:host([variant='filled'][href]:not([disabled]):hover) {
|
|
210
|
+
--_container-elevation-level: 1;
|
|
211
|
+
--_container-state-opacity: 0.08;
|
|
212
|
+
}
|
|
205
213
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
214
|
+
:host([variant='filled'][actionable]:not([disabled]):active),
|
|
215
|
+
:host([variant='filled'][href]:not([disabled]):active) {
|
|
216
|
+
--_container-elevation-level: 0;
|
|
217
|
+
--_container-state-opacity: 0.1;
|
|
218
|
+
}
|
|
211
219
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
220
|
+
:host([variant='filled'][disabled]) {
|
|
221
|
+
--_container-color: var(--color-on-surface);
|
|
222
|
+
--_container-opacity: 0.1;
|
|
223
|
+
--_label-text-color: var(--color-on-surface);
|
|
224
|
+
--_label-text-opacity: 0.38;
|
|
216
225
|
}
|
|
217
226
|
|
|
218
227
|
:host([variant='outlined']) {
|
|
@@ -225,22 +234,25 @@
|
|
|
225
234
|
display: block;
|
|
226
235
|
}
|
|
227
236
|
|
|
228
|
-
|
|
229
|
-
|
|
237
|
+
/* Keep content, such as edge-to-edge media, from covering the outline. */
|
|
238
|
+
.card-content {
|
|
239
|
+
border: var(--_outline-width) solid transparent;
|
|
230
240
|
}
|
|
241
|
+
}
|
|
231
242
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
243
|
+
:host([variant='outlined'][actionable]:not([disabled]):hover),
|
|
244
|
+
:host([variant='outlined'][href]:not([disabled]):hover) {
|
|
245
|
+
--_container-state-opacity: 0.08;
|
|
246
|
+
}
|
|
235
247
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
--_outline-opacity: 0.12;
|
|
248
|
+
:host([variant='outlined'][actionable]:not([disabled]):active),
|
|
249
|
+
:host([variant='outlined'][href]:not([disabled]):active) {
|
|
250
|
+
--_container-state-opacity: 0.12;
|
|
251
|
+
}
|
|
241
252
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
253
|
+
:host([variant='outlined'][disabled]) {
|
|
254
|
+
--_outline-color: var(--color-on-surface);
|
|
255
|
+
--_label-text-color: var(--color-on-surface);
|
|
256
|
+
--_label-text-opacity: 0.38;
|
|
257
|
+
--_outline-opacity: 0.12;
|
|
246
258
|
}
|
package/src/card/card.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { LitElement, 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
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
5
|
import {
|
|
5
6
|
dispatchActivationClick,
|
|
6
7
|
isActivationClick,
|
|
@@ -15,66 +16,89 @@ import NativeHyperlinkMixin from '@/__internal/mixins/NativeHyperlinkMixin.js';
|
|
|
15
16
|
|
|
16
17
|
type CardVariant = 'elevated' | 'filled' | 'outlined';
|
|
17
18
|
|
|
19
|
+
const DISABLED_REASON_ID = 'disabled-reason';
|
|
20
|
+
|
|
18
21
|
/**
|
|
19
22
|
* @label Card
|
|
20
23
|
* @tag wc-card
|
|
21
24
|
* @rawTag card
|
|
22
|
-
* @summary A card
|
|
23
|
-
* @cssprop --card-
|
|
24
|
-
* @cssprop --card-
|
|
25
|
-
* @cssprop --card-gap - Gap between
|
|
25
|
+
* @summary A surface that groups content and actions about one subject. Set `actionable` to make the whole card a button, or `href` to make it a link.
|
|
26
|
+
* @cssprop --card-container-shape - Corner radius of the card. Defaults to `--shape-corner-large`.
|
|
27
|
+
* @cssprop --card-padding - Padding inside the card, around its children. Defaults to 0; `wc-card-content` adds its own padding.
|
|
28
|
+
* @cssprop --card-gap - Gap between the card's children. Defaults to 0.
|
|
26
29
|
*
|
|
27
30
|
* @example
|
|
28
31
|
* ```html
|
|
29
|
-
* <wc-card variant="outlined"
|
|
32
|
+
* <wc-card variant="outlined">
|
|
30
33
|
* <wc-card-content>
|
|
31
|
-
* <h3 class="text-
|
|
32
|
-
* <p class="text-body">
|
|
34
|
+
* <h3 class="text-title-large">Title</h3>
|
|
35
|
+
* <p class="text-body-medium">Supporting text</p>
|
|
33
36
|
* </wc-card-content>
|
|
34
37
|
* </wc-card>
|
|
35
38
|
* ```
|
|
36
39
|
*/
|
|
37
40
|
@IndividualComponent
|
|
38
41
|
export class Card extends NativeHyperlinkMixin(LitElement) {
|
|
42
|
+
// ── Static ────────────────────────────────────────────────────────────────
|
|
43
|
+
|
|
39
44
|
static styles = [styles, colorStyles];
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
// ── Properties ────────────────────────────────────────────────────────────
|
|
42
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Visual style of the card: `elevated` (a raised surface with a shadow), `filled` (a tonal surface)
|
|
50
|
+
* or `outlined` (a bordered surface). Defaults to `elevated`.
|
|
51
|
+
*/
|
|
43
52
|
@property({ type: String, reflect: true })
|
|
44
53
|
variant: CardVariant = 'elevated';
|
|
45
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Dims the card and makes its content inert. An actionable or link card also stops responding
|
|
57
|
+
* to clicks and leaves the tab order, unless `disabled-reason` is set.
|
|
58
|
+
*/
|
|
46
59
|
@property({ type: Boolean, reflect: true })
|
|
47
60
|
disabled: boolean = false;
|
|
48
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Makes the whole card a single button that fires `click`. Its content becomes inert, so don't
|
|
64
|
+
* put buttons or links inside an actionable card.
|
|
65
|
+
*/
|
|
49
66
|
@property({ type: Boolean, reflect: true })
|
|
50
67
|
actionable: boolean = false;
|
|
51
68
|
|
|
52
69
|
/**
|
|
53
|
-
*
|
|
70
|
+
* Why an actionable or link card is disabled. The card stays focusable and screen readers read
|
|
71
|
+
* the reason with it.
|
|
54
72
|
*/
|
|
55
73
|
@property({ attribute: 'disabled-reason' })
|
|
56
74
|
disabledReason: string = '';
|
|
57
75
|
|
|
58
76
|
/**
|
|
59
|
-
*
|
|
77
|
+
* Delay in milliseconds for throttling activation of an actionable or link card. When unset
|
|
78
|
+
* (default), no throttle is applied.
|
|
60
79
|
*/
|
|
61
|
-
@property(
|
|
80
|
+
@property({ type: Number, attribute: 'throttle-delay' })
|
|
81
|
+
throttleDelay?: number;
|
|
62
82
|
|
|
63
|
-
/**
|
|
64
|
-
* States
|
|
65
|
-
*/
|
|
83
|
+
/** Whether the default slot holds meaningful content. */
|
|
66
84
|
@state()
|
|
67
85
|
private slotHasContent = false;
|
|
68
86
|
|
|
87
|
+
// ── Queries ───────────────────────────────────────────────────────────────
|
|
88
|
+
|
|
69
89
|
@query('.card') readonly cardElement!: HTMLElement | null;
|
|
70
90
|
|
|
71
|
-
|
|
91
|
+
// ── Constructor ───────────────────────────────────────────────────────────
|
|
72
92
|
|
|
73
93
|
constructor() {
|
|
74
94
|
super();
|
|
75
|
-
|
|
95
|
+
// Look the handler up on every click, so the throttled version set in
|
|
96
|
+
// firstUpdated() is the one that runs.
|
|
97
|
+
this.addEventListener('click', event => this.__handleClick(event));
|
|
76
98
|
}
|
|
77
99
|
|
|
100
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
78
102
|
override firstUpdated() {
|
|
79
103
|
if (typeof this.throttleDelay === 'number') {
|
|
80
104
|
this.__dispatchClickWithThrottle = throttle(
|
|
@@ -86,26 +110,28 @@ export class Card extends NativeHyperlinkMixin(LitElement) {
|
|
|
86
110
|
this.renderRoot.querySelector('slot'),
|
|
87
111
|
hasContent => {
|
|
88
112
|
this.slotHasContent = hasContent;
|
|
89
|
-
this.requestUpdate();
|
|
90
113
|
},
|
|
91
114
|
);
|
|
92
115
|
}
|
|
93
116
|
|
|
94
|
-
|
|
95
|
-
event => {
|
|
96
|
-
this.__dispatchClick(event);
|
|
97
|
-
};
|
|
117
|
+
// ── Private methods ───────────────────────────────────────────────────────
|
|
98
118
|
|
|
99
|
-
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
// prevent the default action.
|
|
103
|
-
if (this.disabled && this.href) {
|
|
119
|
+
__handleClick(event: MouseEvent | KeyboardEvent) {
|
|
120
|
+
// A disabled card never activates, and consumer click listeners on it never run.
|
|
121
|
+
if (this.disabled) {
|
|
104
122
|
event.stopImmediatePropagation();
|
|
105
123
|
event.preventDefault();
|
|
106
124
|
return;
|
|
107
125
|
}
|
|
126
|
+
this.__dispatchClickWithThrottle(event);
|
|
127
|
+
}
|
|
108
128
|
|
|
129
|
+
__dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =
|
|
130
|
+
event => {
|
|
131
|
+
this.__dispatchClick(event);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
__dispatchClick = (event: MouseEvent | KeyboardEvent) => {
|
|
109
135
|
if (!isActivationClick(event) || !this.cardElement) {
|
|
110
136
|
return;
|
|
111
137
|
}
|
|
@@ -114,90 +140,100 @@ export class Card extends NativeHyperlinkMixin(LitElement) {
|
|
|
114
140
|
dispatchActivationClick(this.cardElement);
|
|
115
141
|
};
|
|
116
142
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
: nothing;
|
|
143
|
+
/** True when a disabled interactive card should stay focusable to expose its reason. */
|
|
144
|
+
__isSoftDisabled() {
|
|
145
|
+
return this.disabled && !!this.disabledReason;
|
|
121
146
|
}
|
|
122
147
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (disabledReasonID)
|
|
126
|
-
return html`<div
|
|
127
|
-
id="disabled-reason-${this.#id}"
|
|
128
|
-
role="tooltip"
|
|
129
|
-
aria-label=${this.disabledReason}
|
|
130
|
-
class="screen-reader-only"
|
|
131
|
-
>
|
|
132
|
-
${this.disabledReason}
|
|
133
|
-
</div>`;
|
|
134
|
-
return nothing;
|
|
148
|
+
__getDisabledReasonID() {
|
|
149
|
+
return this.__isSoftDisabled() ? DISABLED_REASON_ID : undefined;
|
|
135
150
|
}
|
|
136
151
|
|
|
137
|
-
|
|
138
|
-
const isLinkElement = isLink(this);
|
|
139
|
-
const disableSlotTabbing = this.actionable || isLinkElement;
|
|
152
|
+
// ── Render helpers ────────────────────────────────────────────────────────
|
|
140
153
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
154
|
+
renderDisabledReason() {
|
|
155
|
+
if (!this.__isSoftDisabled()) return nothing;
|
|
156
|
+
return html`<div
|
|
157
|
+
id=${DISABLED_REASON_ID}
|
|
158
|
+
role="tooltip"
|
|
159
|
+
aria-label=${this.disabledReason}
|
|
160
|
+
class="screen-reader-only"
|
|
161
|
+
>
|
|
162
|
+
${this.disabledReason}
|
|
163
|
+
</div>`;
|
|
150
164
|
}
|
|
151
165
|
|
|
152
|
-
renderCardElement(isLinkElement: boolean
|
|
166
|
+
renderCardElement(isLinkElement: boolean) {
|
|
167
|
+
const interactive = this.actionable || isLinkElement;
|
|
153
168
|
const cssClasses = {
|
|
154
169
|
card: true,
|
|
155
170
|
'card-element': true,
|
|
156
171
|
[`variant-${this.variant}`]: true,
|
|
157
|
-
actionable:
|
|
172
|
+
actionable: interactive && !this.disabled,
|
|
158
173
|
disabled: this.disabled,
|
|
159
174
|
'has-content': this.slotHasContent,
|
|
160
175
|
};
|
|
176
|
+
const inertContent = interactive || this.disabled;
|
|
161
177
|
|
|
162
|
-
if (!
|
|
178
|
+
if (!interactive) {
|
|
163
179
|
return html`<div class=${classMap(cssClasses)} id="card">
|
|
164
|
-
${this.renderCardContent(
|
|
180
|
+
${this.renderCardContent(inertContent)}
|
|
165
181
|
</div>`;
|
|
166
182
|
}
|
|
167
183
|
|
|
184
|
+
const softDisabled = this.__isSoftDisabled();
|
|
185
|
+
const removedFromTabOrder = this.disabled && !softDisabled;
|
|
186
|
+
|
|
168
187
|
if (!isLinkElement) {
|
|
169
188
|
return html`<button
|
|
170
189
|
class=${classMap(cssClasses)}
|
|
171
190
|
id="card"
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
aria-disabled=${
|
|
175
|
-
?disabled=${
|
|
191
|
+
type="button"
|
|
192
|
+
aria-describedby=${ifDefined(this.__getDisabledReasonID())}
|
|
193
|
+
aria-disabled=${ifDefined(this.disabled ? 'true' : undefined)}
|
|
194
|
+
?disabled=${removedFromTabOrder}
|
|
176
195
|
>
|
|
177
|
-
${this.renderCardContent(
|
|
196
|
+
${this.renderCardContent(inertContent)} ${this.renderDisabledReason()}
|
|
178
197
|
</button>`;
|
|
179
198
|
}
|
|
199
|
+
|
|
180
200
|
return html`<a
|
|
181
201
|
class=${classMap(cssClasses)}
|
|
182
202
|
id="card"
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
203
|
+
href=${ifDefined(this.disabled ? undefined : this.href)}
|
|
204
|
+
target=${ifDefined(this.disabled ? undefined : this.target)}
|
|
205
|
+
rel=${ifDefined(this.disabled ? undefined : this.rel)}
|
|
206
|
+
download=${ifDefined(this.disabled ? undefined : this.download)}
|
|
207
|
+
role=${ifDefined(this.disabled ? 'link' : undefined)}
|
|
208
|
+
tabindex=${removedFromTabOrder ? '-1' : '0'}
|
|
209
|
+
aria-describedby=${ifDefined(this.__getDisabledReasonID())}
|
|
210
|
+
aria-disabled=${ifDefined(this.disabled ? 'true' : undefined)}
|
|
189
211
|
>
|
|
190
|
-
${this.renderCardContent(
|
|
212
|
+
${this.renderCardContent(inertContent)} ${this.renderDisabledReason()}
|
|
191
213
|
</a>`;
|
|
192
214
|
}
|
|
193
215
|
|
|
194
|
-
renderCardContent(
|
|
216
|
+
renderCardContent(inertContent: boolean) {
|
|
195
217
|
return html`
|
|
196
218
|
<div class="card-content">
|
|
197
|
-
<div class="slot-container" ?inert=${
|
|
219
|
+
<div class="slot-container" ?inert=${inertContent}>
|
|
198
220
|
<slot></slot>
|
|
199
221
|
</div>
|
|
200
222
|
</div>
|
|
201
223
|
`;
|
|
202
224
|
}
|
|
225
|
+
|
|
226
|
+
// ── Render ────────────────────────────────────────────────────────────────
|
|
227
|
+
|
|
228
|
+
render() {
|
|
229
|
+
return html`
|
|
230
|
+
<wc-focus-ring class="focus-ring" for="card"></wc-focus-ring>
|
|
231
|
+
<wc-elevation class="elevation"></wc-elevation>
|
|
232
|
+
<div class="background"></div>
|
|
233
|
+
<div class="outline"></div>
|
|
234
|
+
<wc-ripple class="ripple" for="card"></wc-ripple>
|
|
235
|
+
|
|
236
|
+
${this.renderCardElement(isLink(this))}
|
|
237
|
+
`;
|
|
238
|
+
}
|
|
203
239
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { property } from 'lit/decorators.js';
|
|
2
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
3
|
+
import { ChartLine } from '../chart-line/chart-line.js';
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
ChartConfig,
|
|
7
|
+
ChartDatum,
|
|
8
|
+
ChartSelectDetail,
|
|
9
|
+
ChartSeriesConfig,
|
|
10
|
+
ChartValueFormatter,
|
|
11
|
+
} from '../__internal/chart/types.js';
|
|
12
|
+
export type { ChartCurve } from '../chart-line/chart-line.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @label Area Chart
|
|
16
|
+
* @tag wc-chart-area
|
|
17
|
+
* @rawTag chart-area
|
|
18
|
+
* @summary A line chart with the area under each line filled, optionally stacked to show parts of a total over time.
|
|
19
|
+
* @tags charts
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```html
|
|
23
|
+
* <wc-chart-area index="month" stacked label="Visitors by month"></wc-chart-area>
|
|
24
|
+
* <script>
|
|
25
|
+
* const chart = document.querySelector('wc-chart-area');
|
|
26
|
+
* chart.config = {
|
|
27
|
+
* desktop: { label: 'Desktop' },
|
|
28
|
+
* mobile: { label: 'Mobile' },
|
|
29
|
+
* };
|
|
30
|
+
* chart.data = [
|
|
31
|
+
* { month: 'January', desktop: 186, mobile: 80 },
|
|
32
|
+
* { month: 'February', desktop: 305, mobile: 200 },
|
|
33
|
+
* { month: 'March', desktop: 237, mobile: 120 },
|
|
34
|
+
* ];
|
|
35
|
+
* </script>
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @slot empty - Shown when there is no data. Defaults to "No data".
|
|
39
|
+
*
|
|
40
|
+
* @fires chart-select - A category was clicked or chosen with Enter. `detail` holds `index` and `datum`.
|
|
41
|
+
*
|
|
42
|
+
* @csspart container - The outer wrapper.
|
|
43
|
+
* @csspart plot - The focusable plot area holding the SVG.
|
|
44
|
+
* @csspart tooltip - The tooltip.
|
|
45
|
+
* @csspart legend - The legend.
|
|
46
|
+
*
|
|
47
|
+
* @cssprop --color-chart-1 - Color of the first series; series cycle through `--color-chart-1` to `--color-chart-8`.
|
|
48
|
+
* @cssprop --chart-line-width - Stroke width of the lines. Defaults to `2px`.
|
|
49
|
+
* @cssprop --chart-grid-color - Gridline and baseline color. Defaults to `--color-outline-variant`.
|
|
50
|
+
* @cssprop --chart-axis-color - Axis label color. Defaults to `--color-on-surface-variant`.
|
|
51
|
+
* @cssprop --chart-dim-opacity - Opacity of series that are not highlighted. Defaults to `0.4`.
|
|
52
|
+
*/
|
|
53
|
+
@IndividualComponent
|
|
54
|
+
export class ChartArea extends ChartLine {
|
|
55
|
+
// ── Properties
|
|
56
|
+
|
|
57
|
+
/** Stacks the series on each other so the top line shows the total. */
|
|
58
|
+
@property({ type: Boolean, reflect: true }) stacked: boolean = false;
|
|
59
|
+
|
|
60
|
+
// ── Constructor
|
|
61
|
+
|
|
62
|
+
constructor() {
|
|
63
|
+
super();
|
|
64
|
+
this.filled = true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ── Private methods
|
|
68
|
+
|
|
69
|
+
protected drawProperties(): string[] {
|
|
70
|
+
return [...super.drawProperties(), 'stacked'];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
protected isStacked(): boolean {
|
|
74
|
+
return this.stacked;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare global {
|
|
79
|
+
interface HTMLElementTagNameMap {
|
|
80
|
+
'wc-chart-area': ChartArea;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChartArea } from './chart-area.js';
|