@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/dist/snackbar.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { i, _ as __decorate, I as IndividualComponent, a as i$1, A, b } from './IndividualComponent-Bdwyrvd6.js';
|
|
2
2
|
import { n } from './property-B49QQ8pS.js';
|
|
3
3
|
import { r } from './state-DkTK9EGF.js';
|
|
4
|
-
import { e } from './
|
|
4
|
+
import { e } from './query-CHb9Ft_d.js';
|
|
5
|
+
import { e as e$1 } from './class-map-DG7CA1et.js';
|
|
6
|
+
import './base-Cl6v8-BZ.js';
|
|
5
7
|
import './directive-ZPhl09Yt.js';
|
|
6
8
|
|
|
7
9
|
var css_248z = i`* {
|
|
@@ -38,13 +40,7 @@ var css_248z = i`* {
|
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
:host {
|
|
41
|
-
display:
|
|
42
|
-
inset-block-end: calc(var(--snackbar-offset-bottom, 1rem) + env(safe-area-inset-bottom, 0px));
|
|
43
|
-
inset-inline: var(--snackbar-offset-inline, 1rem);
|
|
44
|
-
justify-content: center;
|
|
45
|
-
pointer-events: none;
|
|
46
|
-
position: fixed;
|
|
47
|
-
z-index: var(--snackbar-z-index, 1000);
|
|
43
|
+
display: contents;
|
|
48
44
|
--snackbar-container-color: var(--color-inverse-surface);
|
|
49
45
|
--snackbar-label-text-color: var(--color-inverse-on-surface);
|
|
50
46
|
--snackbar-action-text-color: var(--color-inverse-primary);
|
|
@@ -52,6 +48,23 @@ var css_248z = i`* {
|
|
|
52
48
|
--snackbar-border-radius: var(--shape-corner-extra-small);
|
|
53
49
|
}
|
|
54
50
|
|
|
51
|
+
.layer {
|
|
52
|
+
background: transparent;
|
|
53
|
+
border: 0;
|
|
54
|
+
color: inherit;
|
|
55
|
+
display: flex;
|
|
56
|
+
height: auto;
|
|
57
|
+
inset: auto var(--snackbar-offset-inline, 1rem) calc(var(--snackbar-offset-bottom, 1rem) + env(safe-area-inset-bottom, 0px));
|
|
58
|
+
justify-content: center;
|
|
59
|
+
margin: 0;
|
|
60
|
+
overflow: visible;
|
|
61
|
+
padding: 0;
|
|
62
|
+
pointer-events: none;
|
|
63
|
+
position: fixed;
|
|
64
|
+
width: auto;
|
|
65
|
+
z-index: var(--snackbar-z-index, 1000);
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
.snackbar {
|
|
56
69
|
font-family: var(--typography-body-medium-font-family) !important;
|
|
57
70
|
font-size: var(--typography-body-medium-font-size) !important;
|
|
@@ -106,9 +119,11 @@ var css_248z = i`* {
|
|
|
106
119
|
}
|
|
107
120
|
|
|
108
121
|
:host([preview]) {
|
|
122
|
+
display: flex;
|
|
123
|
+
}
|
|
124
|
+
:host([preview]) .layer {
|
|
109
125
|
position: relative;
|
|
110
|
-
inset
|
|
111
|
-
inset-block-end: unset;
|
|
126
|
+
inset: auto;
|
|
112
127
|
}
|
|
113
128
|
:host([preview]) .snackbar {
|
|
114
129
|
display: inline-flex;
|
|
@@ -122,6 +137,11 @@ var Snackbar_1;
|
|
|
122
137
|
* @rawTag snackbar
|
|
123
138
|
* @summary Snackbars provide brief messages about app processes at the bottom of the screen.
|
|
124
139
|
*
|
|
140
|
+
* @overview
|
|
141
|
+
* <p>An open snackbar is shown as a manual popover, so it renders in the browser's top layer, above sticky
|
|
142
|
+
* headers, app bars and open modals whatever their <code>z-index</code>. Opening it again while it is
|
|
143
|
+
* visible brings it back in front of anything opened since.</p>
|
|
144
|
+
*
|
|
125
145
|
* @cssprop --snackbar-container-color - Container color for the snackbar.
|
|
126
146
|
* @cssprop --snackbar-label-text-color - Label text color for the snackbar.
|
|
127
147
|
* @cssprop --snackbar-action-text-color - Action text color.
|
|
@@ -129,7 +149,7 @@ var Snackbar_1;
|
|
|
129
149
|
* @cssprop --snackbar-border-radius - Border radius of the snackbar surface.
|
|
130
150
|
* @cssprop --snackbar-offset-inline - Inline offset from viewport edges.
|
|
131
151
|
* @cssprop --snackbar-offset-bottom - Bottom offset from viewport edge.
|
|
132
|
-
* @cssprop --snackbar-z-index - Stacking order for the snackbar.
|
|
152
|
+
* @cssprop --snackbar-z-index - Stacking order for the snackbar in browsers without the Popover API.
|
|
133
153
|
*
|
|
134
154
|
* @example
|
|
135
155
|
* ```html
|
|
@@ -176,9 +196,13 @@ let Snackbar = Snackbar_1 = class Snackbar extends i$1 {
|
|
|
176
196
|
document.removeEventListener(Snackbar_1.GLOBAL_OPEN_EVENT, this.handleGlobalSnackbarOpen);
|
|
177
197
|
this.clearExitTimer();
|
|
178
198
|
this.clearTimer();
|
|
199
|
+
this.syncLayer();
|
|
179
200
|
super.disconnectedCallback();
|
|
180
201
|
}
|
|
181
202
|
updated(changedProperties) {
|
|
203
|
+
if (changedProperties.has('open') || changedProperties.has('preview')) {
|
|
204
|
+
this.syncLayer();
|
|
205
|
+
}
|
|
182
206
|
if (changedProperties.has('open')) {
|
|
183
207
|
if (this.open) {
|
|
184
208
|
document.dispatchEvent(new CustomEvent(Snackbar_1.GLOBAL_OPEN_EVENT, {
|
|
@@ -196,6 +220,8 @@ let Snackbar = Snackbar_1 = class Snackbar extends i$1 {
|
|
|
196
220
|
this.open = true;
|
|
197
221
|
return;
|
|
198
222
|
}
|
|
223
|
+
// Already open: move it back to the top of the top layer, above anything opened since.
|
|
224
|
+
this.syncLayer(true);
|
|
199
225
|
this.scheduleAutoHide();
|
|
200
226
|
}
|
|
201
227
|
hide() {
|
|
@@ -252,6 +278,26 @@ let Snackbar = Snackbar_1 = class Snackbar extends i$1 {
|
|
|
252
278
|
this.completeDismiss();
|
|
253
279
|
}
|
|
254
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Shows the layer in the top layer while the snackbar is open, and hides it otherwise.
|
|
283
|
+
* With `raise`, an already showing layer is shown again so it moves above newer top-layer elements.
|
|
284
|
+
*/
|
|
285
|
+
syncLayer(raise = false) {
|
|
286
|
+
const { layer } = this;
|
|
287
|
+
if (!layer ||
|
|
288
|
+
typeof layer.showPopover !== 'function' ||
|
|
289
|
+
!layer.hasAttribute('popover')) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const shouldShow = this.open && !this.preview && this.isConnected;
|
|
293
|
+
const showing = layer.matches(':popover-open');
|
|
294
|
+
if (showing && (!shouldShow || raise)) {
|
|
295
|
+
layer.hidePopover();
|
|
296
|
+
}
|
|
297
|
+
if (shouldShow && (!showing || raise)) {
|
|
298
|
+
layer.showPopover();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
255
301
|
scheduleAutoHide() {
|
|
256
302
|
this.clearTimer();
|
|
257
303
|
if (!this.open || this.duration <= 0) {
|
|
@@ -264,39 +310,45 @@ let Snackbar = Snackbar_1 = class Snackbar extends i$1 {
|
|
|
264
310
|
render() {
|
|
265
311
|
const liveRole = this.actionLabel || this.showCloseIcon ? 'alert' : 'status';
|
|
266
312
|
return b `
|
|
267
|
-
<div
|
|
268
|
-
|
|
313
|
+
<div class="layer" popover=${this.preview ? A : 'manual'}>
|
|
314
|
+
<div
|
|
315
|
+
class=${e$1({
|
|
269
316
|
snackbar: true,
|
|
270
317
|
open: !this.preview && this.open,
|
|
271
318
|
preview: this.preview,
|
|
272
319
|
dismissing: this.dismissing,
|
|
273
320
|
multiline: this.multiline,
|
|
274
321
|
})}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
322
|
+
role=${liveRole}
|
|
323
|
+
aria-live="polite"
|
|
324
|
+
@animationend=${this.handleAnimationEnd}
|
|
325
|
+
>
|
|
326
|
+
<div class="label">
|
|
327
|
+
<slot>${this.message}</slot>
|
|
328
|
+
</div>
|
|
282
329
|
|
|
283
|
-
|
|
284
|
-
? b `<wc-button
|
|
285
|
-
|
|
286
|
-
|
|
330
|
+
${this.actionLabel
|
|
331
|
+
? b `<wc-button
|
|
332
|
+
class="action"
|
|
333
|
+
variant="text"
|
|
334
|
+
size="sm"
|
|
335
|
+
@click=${this.handleActionClick}
|
|
336
|
+
>
|
|
337
|
+
${this.actionLabel}
|
|
338
|
+
</wc-button>`
|
|
287
339
|
: A}
|
|
288
|
-
|
|
289
|
-
${this.showCloseIcon
|
|
340
|
+
${this.showCloseIcon
|
|
290
341
|
? b `<wc-icon-button
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
342
|
+
class="close"
|
|
343
|
+
variant="text"
|
|
344
|
+
size="sm"
|
|
345
|
+
aria-label="Dismiss notification"
|
|
346
|
+
@click=${this.handleCloseClick}
|
|
347
|
+
>
|
|
348
|
+
<wc-icon name="close"></wc-icon>
|
|
349
|
+
</wc-icon-button>`
|
|
299
350
|
: A}
|
|
351
|
+
</div>
|
|
300
352
|
</div>
|
|
301
353
|
`;
|
|
302
354
|
}
|
|
@@ -328,6 +380,9 @@ __decorate([
|
|
|
328
380
|
__decorate([
|
|
329
381
|
r()
|
|
330
382
|
], Snackbar.prototype, "dismissing", void 0);
|
|
383
|
+
__decorate([
|
|
384
|
+
e('.layer')
|
|
385
|
+
], Snackbar.prototype, "layer", void 0);
|
|
331
386
|
Snackbar = Snackbar_1 = __decorate([
|
|
332
387
|
IndividualComponent
|
|
333
388
|
], Snackbar);
|
package/dist/snackbar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snackbar.js","sources":["../../src/snackbar/snackbar.ts"],"sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport styles from './snackbar.scss';\nimport IndividualComponent from '@/IndividualComponent.js';\n\ntype SnackbarCloseReason = 'timeout' | 'dismiss' | 'action' | 'programmatic';\n\n/**\n * @label Snackbar\n * @tag wc-snackbar\n * @rawTag snackbar\n * @summary Snackbars provide brief messages about app processes at the bottom of the screen.\n *\n * @cssprop --snackbar-container-color - Container color for the snackbar.\n * @cssprop --snackbar-label-text-color - Label text color for the snackbar.\n * @cssprop --snackbar-action-text-color - Action text color.\n * @cssprop --snackbar-close-icon-color - Close icon color.\n * @cssprop --snackbar-border-radius - Border radius of the snackbar surface.\n * @cssprop --snackbar-offset-inline - Inline offset from viewport edges.\n * @cssprop --snackbar-offset-bottom - Bottom offset from viewport edge.\n * @cssprop --snackbar-z-index - Stacking order for the snackbar.\n *\n * @example\n * ```html\n * <wc-snackbar preview message=\"Message archived\" action-label=\"Undo\"></wc-snackbar>\n * ```\n * @tags display, feedback\n */\n@IndividualComponent\nexport class Snackbar extends LitElement {\n static styles = [styles];\n\n private static readonly GLOBAL_OPEN_EVENT = 'wc-snackbar-will-open';\n\n private static readonly EXIT_ANIMATION_MS = 180;\n\n /** Whether the snackbar is currently visible. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** The message text to display. Can also be provided via the default slot. */\n @property({ type: String }) message = '';\n\n /** Label for the optional action button. When empty, no action button is rendered. */\n @property({ type: String, attribute: 'action-label' }) actionLabel = '';\n\n /** When true, a dismiss icon button is shown on the trailing end. */\n @property({ type: Boolean, attribute: 'show-close-icon' })\n showCloseIcon = false;\n\n /** Auto-hide duration in milliseconds. Set to `0` to disable auto-hide. */\n @property({ type: Number }) duration = 4000;\n\n /** When true, the snackbar content is allowed to wrap to multiple lines. */\n @property({ type: Boolean, reflect: true }) multiline = false;\n\n /** When true, renders the snackbar in a static preview state (always visible, no animation). */\n @property({ type: Boolean, reflect: true }) preview = false;\n\n /** True while the exit animation is running before the snackbar fully closes. */\n @state() private dismissing = false;\n\n // ── Private fields ────────────────────────────────────────────────────────\n\n /** Timer handle for the auto-hide timeout. */\n private hideTimer: ReturnType<typeof setTimeout> | null = null;\n\n /** Timer handle for the exit animation duration timeout. */\n private exitTimer: ReturnType<typeof setTimeout> | null = null;\n\n private readonly handleGlobalSnackbarOpen = (\n event: Event,\n ) => {\n const { source } = (event as CustomEvent<{ source?: Snackbar }>).detail;\n if (source && source !== this) {\n this.hide();\n }\n };\n\n connectedCallback() {\n super.connectedCallback();\n document.addEventListener(\n Snackbar.GLOBAL_OPEN_EVENT,\n this.handleGlobalSnackbarOpen,\n );\n }\n\n disconnectedCallback() {\n document.removeEventListener(\n Snackbar.GLOBAL_OPEN_EVENT,\n this.handleGlobalSnackbarOpen,\n );\n this.clearExitTimer();\n this.clearTimer();\n super.disconnectedCallback();\n }\n\n protected updated(changedProperties: Map<string, unknown>) {\n if (changedProperties.has('open')) {\n if (this.open) {\n document.dispatchEvent(\n new CustomEvent(Snackbar.GLOBAL_OPEN_EVENT, {\n detail: { source: this },\n }),\n );\n }\n\n this.scheduleAutoHide();\n }\n }\n\n // ── Public methods ────────────────────────────────────────────────────────\n\n show() {\n this.dismissing = false;\n this.clearExitTimer();\n if (!this.open) {\n this.open = true;\n return;\n }\n\n this.scheduleAutoHide();\n }\n\n hide() {\n this.close('programmatic');\n }\n\n private close(reason: SnackbarCloseReason) {\n if (!this.open || this.dismissing) {\n return;\n }\n\n this.clearTimer();\n this.dismissing = true;\n this.clearExitTimer();\n this.exitTimer = setTimeout(() => {\n this.completeDismiss();\n }, Snackbar.EXIT_ANIMATION_MS);\n\n this.dispatchEvent(\n new CustomEvent('snackbar-close', {\n detail: { reason },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private completeDismiss() {\n this.clearExitTimer();\n this.dismissing = false;\n this.open = false;\n }\n\n private dispatchActionEvent() {\n this.dispatchEvent(\n new CustomEvent('snackbar-action', {\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private handleActionClick() {\n this.dispatchActionEvent();\n this.close('action');\n }\n\n private handleCloseClick() {\n this.close('dismiss');\n }\n\n private clearTimer() {\n if (this.hideTimer !== null) {\n clearTimeout(this.hideTimer);\n this.hideTimer = null;\n }\n }\n\n private clearExitTimer() {\n if (this.exitTimer !== null) {\n clearTimeout(this.exitTimer);\n this.exitTimer = null;\n }\n }\n\n private handleAnimationEnd(event: AnimationEvent) {\n if (event.animationName === 'snackbar-exit' && this.dismissing) {\n this.completeDismiss();\n }\n }\n\n private scheduleAutoHide() {\n this.clearTimer();\n if (!this.open || this.duration <= 0) {\n return;\n }\n\n this.hideTimer = setTimeout(() => {\n this.close('timeout');\n }, this.duration);\n }\n\n render() {\n const liveRole =\n this.actionLabel || this.showCloseIcon ? 'alert' : 'status';\n\n return html`\n <div\n class=${classMap({\n snackbar: true,\n open: !this.preview && this.open,\n preview: this.preview,\n dismissing: this.dismissing,\n multiline: this.multiline,\n })}\n role=${liveRole}\n aria-live=\"polite\"\n @animationend=${this.handleAnimationEnd}\n >\n <div class=\"label\">\n <slot>${this.message}</slot>\n </div>\n\n ${this.actionLabel\n ? html`<wc-button class=\"action\" variant='text' size='sm' @click=${this.handleActionClick}>\n ${this.actionLabel}\n </wc-button>`\n : nothing}\n\n ${this.showCloseIcon\n ? html`<wc-icon-button\n class=\"close\"\n variant='text'\n size='sm'\n aria-label=\"Dismiss notification\"\n @click=${this.handleCloseClick}\n >\n <wc-icon name=\"close\"></wc-icon>\n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nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport styles from './snackbar.scss';\nimport IndividualComponent from '@/IndividualComponent.js';\n\ntype SnackbarCloseReason = 'timeout' | 'dismiss' | 'action' | 'programmatic';\n\n/**\n * @label Snackbar\n * @tag wc-snackbar\n * @rawTag snackbar\n * @summary Snackbars provide brief messages about app processes at the bottom of the screen.\n *\n * @overview\n * <p>An open snackbar is shown as a manual popover, so it renders in the browser's top layer, above sticky\n * headers, app bars and open modals whatever their <code>z-index</code>. Opening it again while it is\n * visible brings it back in front of anything opened since.</p>\n *\n * @cssprop --snackbar-container-color - Container color for the snackbar.\n * @cssprop --snackbar-label-text-color - Label text color for the snackbar.\n * @cssprop --snackbar-action-text-color - Action text color.\n * @cssprop --snackbar-close-icon-color - Close icon color.\n * @cssprop --snackbar-border-radius - Border radius of the snackbar surface.\n * @cssprop --snackbar-offset-inline - Inline offset from viewport edges.\n * @cssprop --snackbar-offset-bottom - Bottom offset from viewport edge.\n * @cssprop --snackbar-z-index - Stacking order for the snackbar in browsers without the Popover API.\n *\n * @example\n * ```html\n * <wc-snackbar preview message=\"Message archived\" action-label=\"Undo\"></wc-snackbar>\n * ```\n * @tags display, feedback\n */\n@IndividualComponent\nexport class Snackbar extends LitElement {\n static styles = [styles];\n\n private static readonly GLOBAL_OPEN_EVENT = 'wc-snackbar-will-open';\n\n private static readonly EXIT_ANIMATION_MS = 180;\n\n /** Whether the snackbar is currently visible. */\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** The message text to display. Can also be provided via the default slot. */\n @property({ type: String }) message = '';\n\n /** Label for the optional action button. When empty, no action button is rendered. */\n @property({ type: String, attribute: 'action-label' }) actionLabel = '';\n\n /** When true, a dismiss icon button is shown on the trailing end. */\n @property({ type: Boolean, attribute: 'show-close-icon' })\n showCloseIcon = false;\n\n /** Auto-hide duration in milliseconds. Set to `0` to disable auto-hide. */\n @property({ type: Number }) duration = 4000;\n\n /** When true, the snackbar content is allowed to wrap to multiple lines. */\n @property({ type: Boolean, reflect: true }) multiline = false;\n\n /** When true, renders the snackbar in a static preview state (always visible, no animation). */\n @property({ type: Boolean, reflect: true }) preview = false;\n\n /** True while the exit animation is running before the snackbar fully closes. */\n @state() private dismissing = false;\n\n /** The positioned layer that is shown in the top layer as a popover. */\n @query('.layer') private layer?: HTMLElement;\n\n // ── Private fields ────────────────────────────────────────────────────────\n\n /** Timer handle for the auto-hide timeout. */\n private hideTimer: ReturnType<typeof setTimeout> | null = null;\n\n /** Timer handle for the exit animation duration timeout. */\n private exitTimer: ReturnType<typeof setTimeout> | null = null;\n\n private readonly handleGlobalSnackbarOpen = (event: Event) => {\n const { source } = (event as CustomEvent<{ source?: Snackbar }>).detail;\n if (source && source !== this) {\n this.hide();\n }\n };\n\n connectedCallback() {\n super.connectedCallback();\n document.addEventListener(\n Snackbar.GLOBAL_OPEN_EVENT,\n this.handleGlobalSnackbarOpen,\n );\n }\n\n disconnectedCallback() {\n document.removeEventListener(\n Snackbar.GLOBAL_OPEN_EVENT,\n this.handleGlobalSnackbarOpen,\n );\n this.clearExitTimer();\n this.clearTimer();\n this.syncLayer();\n super.disconnectedCallback();\n }\n\n protected updated(changedProperties: Map<string, unknown>) {\n if (changedProperties.has('open') || changedProperties.has('preview')) {\n this.syncLayer();\n }\n\n if (changedProperties.has('open')) {\n if (this.open) {\n document.dispatchEvent(\n new CustomEvent(Snackbar.GLOBAL_OPEN_EVENT, {\n detail: { source: this },\n }),\n );\n }\n\n this.scheduleAutoHide();\n }\n }\n\n // ── Public methods ────────────────────────────────────────────────────────\n\n show() {\n this.dismissing = false;\n this.clearExitTimer();\n if (!this.open) {\n this.open = true;\n return;\n }\n\n // Already open: move it back to the top of the top layer, above anything opened since.\n this.syncLayer(true);\n this.scheduleAutoHide();\n }\n\n hide() {\n this.close('programmatic');\n }\n\n private close(reason: SnackbarCloseReason) {\n if (!this.open || this.dismissing) {\n return;\n }\n\n this.clearTimer();\n this.dismissing = true;\n this.clearExitTimer();\n this.exitTimer = setTimeout(() => {\n this.completeDismiss();\n }, Snackbar.EXIT_ANIMATION_MS);\n\n this.dispatchEvent(\n new CustomEvent('snackbar-close', {\n detail: { reason },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private completeDismiss() {\n this.clearExitTimer();\n this.dismissing = false;\n this.open = false;\n }\n\n private dispatchActionEvent() {\n this.dispatchEvent(\n new CustomEvent('snackbar-action', {\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private handleActionClick() {\n this.dispatchActionEvent();\n this.close('action');\n }\n\n private handleCloseClick() {\n this.close('dismiss');\n }\n\n private clearTimer() {\n if (this.hideTimer !== null) {\n clearTimeout(this.hideTimer);\n this.hideTimer = null;\n }\n }\n\n private clearExitTimer() {\n if (this.exitTimer !== null) {\n clearTimeout(this.exitTimer);\n this.exitTimer = null;\n }\n }\n\n private handleAnimationEnd(event: AnimationEvent) {\n if (event.animationName === 'snackbar-exit' && this.dismissing) {\n this.completeDismiss();\n }\n }\n\n /**\n * Shows the layer in the top layer while the snackbar is open, and hides it otherwise.\n * With `raise`, an already showing layer is shown again so it moves above newer top-layer elements.\n */\n private syncLayer(raise = false) {\n const { layer } = this;\n if (\n !layer ||\n typeof layer.showPopover !== 'function' ||\n !layer.hasAttribute('popover')\n ) {\n return;\n }\n\n const shouldShow = this.open && !this.preview && this.isConnected;\n const showing = layer.matches(':popover-open');\n if (showing && (!shouldShow || raise)) {\n layer.hidePopover();\n }\n if (shouldShow && (!showing || raise)) {\n layer.showPopover();\n }\n }\n\n private scheduleAutoHide() {\n this.clearTimer();\n if (!this.open || this.duration <= 0) {\n return;\n }\n\n this.hideTimer = setTimeout(() => {\n this.close('timeout');\n }, this.duration);\n }\n\n render() {\n const liveRole =\n this.actionLabel || this.showCloseIcon ? 'alert' : 'status';\n\n return html`\n <div class=\"layer\" popover=${this.preview ? nothing : 'manual'}>\n <div\n class=${classMap({\n snackbar: true,\n open: !this.preview && this.open,\n preview: this.preview,\n dismissing: this.dismissing,\n multiline: this.multiline,\n })}\n role=${liveRole}\n aria-live=\"polite\"\n @animationend=${this.handleAnimationEnd}\n >\n <div class=\"label\">\n <slot>${this.message}</slot>\n </div>\n\n ${this.actionLabel\n ? html`<wc-button\n class=\"action\"\n variant=\"text\"\n size=\"sm\"\n @click=${this.handleActionClick}\n >\n ${this.actionLabel}\n </wc-button>`\n : nothing}\n ${this.showCloseIcon\n ? html`<wc-icon-button\n class=\"close\"\n variant=\"text\"\n size=\"sm\"\n aria-label=\"Dismiss notification\"\n @click=${this.handleCloseClick}\n >\n <wc-icon name=\"close\"></wc-icon>\n </wc-icon-button>`\n : nothing}\n </div>\n </div>\n `;\n }\n}\n"],"names":["LitElement","html","nothing","classMap","styles","property","state","query"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AAEI,IAAM,QAAQ,GAAA,UAAA,GAAd,MAAM,QAAS,SAAQA,GAAU,CAAA;AAAjC,IAAA,WAAA,GAAA;;;QAQuC,IAAA,CAAA,IAAI,GAAG,KAAK;;QAG5B,IAAA,CAAA,OAAO,GAAG,EAAE;;QAGe,IAAA,CAAA,WAAW,GAAG,EAAE;;QAIvE,IAAA,CAAA,aAAa,GAAG,KAAK;;QAGO,IAAA,CAAA,QAAQ,GAAG,IAAI;;QAGC,IAAA,CAAA,SAAS,GAAG,KAAK;;QAGjB,IAAA,CAAA,OAAO,GAAG,KAAK;;QAG1C,IAAA,CAAA,UAAU,GAAG,KAAK;;;QAQ3B,IAAA,CAAA,SAAS,GAAyC,IAAI;;QAGtD,IAAA,CAAA,SAAS,GAAyC,IAAI;AAE7C,QAAA,IAAA,CAAA,wBAAwB,GAAG,CAAC,KAAY,KAAI;AAC3D,YAA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,EAAA,OAAA,EAAA,MAAA,CAAA;AAjClC,QAAQ,GAAA,UAAA,GAAA,UAAA,CAAA;IADpB;AACY,CAAA,EAAA,QAAQ,CA6PpB;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ScaleBand, ScaleLinear, ScalePoint, Selection } from 'd3';
|
|
2
|
+
import { ChartBase } from './chart-base.js';
|
|
3
|
+
import type { ChartConfig, ChartDatum, ChartSelectDetail, ChartSeries, ChartTooltipModel } from './types.js';
|
|
4
|
+
export type ChartOrientation = 'vertical' | 'horizontal';
|
|
5
|
+
/** Plot margins and inner size, in SVG pixels. */
|
|
6
|
+
export type CartesianLayout = {
|
|
7
|
+
left: number;
|
|
8
|
+
top: number;
|
|
9
|
+
right: number;
|
|
10
|
+
bottom: number;
|
|
11
|
+
innerWidth: number;
|
|
12
|
+
innerHeight: number;
|
|
13
|
+
};
|
|
14
|
+
type CategoryScale = ScaleBand<string> | ScalePoint<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Base for charts with a category axis and a value axis (bar, line, area). Data is an array of
|
|
17
|
+
* rows; `index` names the category field and `config` names the series fields.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class CartesianChart extends ChartBase {
|
|
20
|
+
/** Rows to plot. Each row holds the category field (`index`) and a number per series. */
|
|
21
|
+
data: ChartDatum[];
|
|
22
|
+
/** Series to plot, keyed by data field, with optional label and color. Defaults to every numeric field. */
|
|
23
|
+
config: ChartConfig;
|
|
24
|
+
/** Data field that holds the category label, for example `month`. */
|
|
25
|
+
index: string;
|
|
26
|
+
/** Hides the gridlines. */
|
|
27
|
+
hideGrid: boolean;
|
|
28
|
+
/** Hides the category axis labels. */
|
|
29
|
+
hideCategoryAxis: boolean;
|
|
30
|
+
/** Hides the value axis labels. */
|
|
31
|
+
hideValueAxis: boolean;
|
|
32
|
+
/** Current plot layout, set by `computeLayout()`. */
|
|
33
|
+
protected layout: CartesianLayout;
|
|
34
|
+
/** Which axis carries the categories. */
|
|
35
|
+
protected orientation: ChartOrientation;
|
|
36
|
+
/** Category centers along the category axis, in inner plot coordinates. */
|
|
37
|
+
protected centers: number[];
|
|
38
|
+
/** Width of one category slot along the category axis. */
|
|
39
|
+
protected step: number;
|
|
40
|
+
/** Tooltip anchor per category, in plot element coordinates. */
|
|
41
|
+
protected anchors: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}[];
|
|
45
|
+
/** Whether the cursor is a band (bars) or a line (line, area). */
|
|
46
|
+
protected cursorKind: 'band' | 'line';
|
|
47
|
+
protected drawProperties(): string[];
|
|
48
|
+
protected hasData(): boolean;
|
|
49
|
+
protected getSeries(): ChartSeries[];
|
|
50
|
+
protected getItemCount(): number;
|
|
51
|
+
protected itemAtPoint(x: number, y: number): number;
|
|
52
|
+
protected getTooltip(index: number): ChartTooltipModel | undefined;
|
|
53
|
+
protected getSelectDetail(index: number): ChartSelectDetail;
|
|
54
|
+
protected drawHighlight(): void;
|
|
55
|
+
protected renderSvgContent(): import("lit-html").TemplateResult<2>;
|
|
56
|
+
protected renderTable(): import("lit-html").TemplateResult<1>;
|
|
57
|
+
/** Series keys from `config`, or every numeric field of the first row except `index`. */
|
|
58
|
+
protected seriesKeys(): string[];
|
|
59
|
+
/** Series not switched off in the legend. */
|
|
60
|
+
protected visibleSeries(): ChartSeries[];
|
|
61
|
+
/** A row's value for a series, 0 when missing. */
|
|
62
|
+
protected seriesValue(datum: ChartDatum, key: string): number;
|
|
63
|
+
/** Category label of a row. */
|
|
64
|
+
protected categoryLabel(index: number): string;
|
|
65
|
+
/** Category domain: row positions, so repeated labels stay distinct. */
|
|
66
|
+
protected categoryDomain(): string[];
|
|
67
|
+
/** The `.plot-area` group, or undefined before the SVG renders. */
|
|
68
|
+
protected plotArea(): Selection<SVGGElement, unknown, null, undefined> | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Sets `layout` from the value scale's ticks and the category labels. Call before setting the
|
|
71
|
+
* scales' ranges. `valueLabelSpace` reserves room for value labels at the end of the marks.
|
|
72
|
+
*/
|
|
73
|
+
protected computeLayout(valueScale: ScaleLinear<number, number>, valueLabelSpace?: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Draws gridlines, the zero baseline and both axes' labels, and records category centers.
|
|
76
|
+
* The scales must already have their ranges set from `layout`.
|
|
77
|
+
*/
|
|
78
|
+
protected drawFrame(categoryScale: CategoryScale, valueScale: ScaleLinear<number, number>): void;
|
|
79
|
+
}
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { LitElement, nothing, PropertyValues, SVGTemplateResult, TemplateResult } from 'lit';
|
|
2
|
+
import { BaseType, Selection } from 'd3';
|
|
3
|
+
import type { ChartSelectDetail, ChartSeries, ChartTooltipModel, ChartValueFormatter } from './types.js';
|
|
4
|
+
/** Number of `--color-chart-n` tokens series cycle through. */
|
|
5
|
+
export declare const CHART_PALETTE_SIZE = 8;
|
|
6
|
+
/** The palette color for the series or slice at `index`. */
|
|
7
|
+
export declare function chartColor(index: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Shared behaviour for every Peacock chart: container sizing, palette, value formatting,
|
|
10
|
+
* tooltip, legend, keyboard navigation, the accessible data table, and loading and empty states.
|
|
11
|
+
* Subclasses draw the marks with d3 into the SVG returned by `renderSvgContent()`.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class ChartBase extends LitElement {
|
|
14
|
+
/** Height of the plot in pixels. The width follows the container. */
|
|
15
|
+
height: number;
|
|
16
|
+
/** Accessible name of the chart, read by screen readers. */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Shows a skeleton while data loads. */
|
|
19
|
+
loading: boolean;
|
|
20
|
+
/** Shows the legend even for a single series. */
|
|
21
|
+
showLegend: boolean;
|
|
22
|
+
/** Hides the legend. */
|
|
23
|
+
hideLegend: boolean;
|
|
24
|
+
/** Hides the tooltip. */
|
|
25
|
+
hideTooltip: boolean;
|
|
26
|
+
/** Turns off enter and update animations. They are also off when the user prefers reduced motion. */
|
|
27
|
+
disableAnimation: boolean;
|
|
28
|
+
/** Formats values in tooltips, value labels and axis ticks. Defaults to the locale number format, compact on axes. */
|
|
29
|
+
valueFormatter?: ChartValueFormatter;
|
|
30
|
+
/** Keys of series or slices switched off in the legend. */
|
|
31
|
+
protected hiddenKeys: Set<string>;
|
|
32
|
+
/** Index of the hovered or focused category or slice, -1 for none. */
|
|
33
|
+
protected activeIndex: number;
|
|
34
|
+
/** Key of the series highlighted from the legend. */
|
|
35
|
+
protected activeSeries?: string;
|
|
36
|
+
/** Pointer position the tooltip follows; undefined places it at the item's anchor. */
|
|
37
|
+
protected pointer?: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
/** Width of the plot, measured from the container. */
|
|
42
|
+
protected plotWidth: number;
|
|
43
|
+
/** Text for the polite live region, set during keyboard navigation. */
|
|
44
|
+
private announcement;
|
|
45
|
+
protected svgElement?: SVGSVGElement;
|
|
46
|
+
protected plotElement?: HTMLElement;
|
|
47
|
+
/** Watches the host width. */
|
|
48
|
+
private resizeObserver?;
|
|
49
|
+
/** Whether the marks have been drawn once. */
|
|
50
|
+
private hasDrawn;
|
|
51
|
+
connectedCallback(): void;
|
|
52
|
+
disconnectedCallback(): void;
|
|
53
|
+
updated(changed: PropertyValues): void;
|
|
54
|
+
/** True when there is something to plot. */
|
|
55
|
+
protected abstract hasData(): boolean;
|
|
56
|
+
/** Every series or slice, including hidden ones, in legend order. */
|
|
57
|
+
protected abstract getSeries(): ChartSeries[];
|
|
58
|
+
/** Number of categories or slices keyboard navigation moves through. */
|
|
59
|
+
protected abstract getItemCount(): number;
|
|
60
|
+
/** Draws the marks; `animate` is false for resizes and when motion is off. */
|
|
61
|
+
protected abstract draw(animate: boolean): void;
|
|
62
|
+
/** Applies hover and focus state (dimming, cursor, active dots) without redrawing. */
|
|
63
|
+
protected abstract drawHighlight(): void;
|
|
64
|
+
/** The item under a point in plot coordinates. */
|
|
65
|
+
protected abstract itemAtPoint(x: number, y: number): number;
|
|
66
|
+
/** Tooltip content and default anchor for an item. */
|
|
67
|
+
protected abstract getTooltip(index: number): ChartTooltipModel | undefined;
|
|
68
|
+
/** Detail of `chart-select` for an item. */
|
|
69
|
+
protected abstract getSelectDetail(index: number): ChartSelectDetail;
|
|
70
|
+
/** The static SVG layers d3 draws into. */
|
|
71
|
+
protected abstract renderSvgContent(): SVGTemplateResult;
|
|
72
|
+
/** Rows of the visually hidden data table. */
|
|
73
|
+
protected abstract renderTable(): TemplateResult;
|
|
74
|
+
/** Property names that trigger a redraw when they change. */
|
|
75
|
+
protected drawProperties(): string[];
|
|
76
|
+
/** Whether the legend shows. */
|
|
77
|
+
protected legendVisible(): boolean;
|
|
78
|
+
/** Width and height of the SVG. */
|
|
79
|
+
protected svgSize(): {
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
};
|
|
83
|
+
/** Motion duration in ms, 0 when animation is off. */
|
|
84
|
+
protected motionEnabled(): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Returns a transition of `selection` when `animate` is true, else the selection itself, so
|
|
87
|
+
* callers set end values once. Transitions share the attr/style API used here.
|
|
88
|
+
*/
|
|
89
|
+
protected motion<E extends BaseType, D>(selection: Selection<E, D, BaseType, unknown>, animate: boolean): Selection<E, D, BaseType, unknown>;
|
|
90
|
+
/** Formats a value for tooltips and value labels. */
|
|
91
|
+
protected formatValue(value: number): string;
|
|
92
|
+
/** Formats an axis tick. */
|
|
93
|
+
protected formatTick(value: number): string;
|
|
94
|
+
/** Whether a series or slice is switched off in the legend. */
|
|
95
|
+
protected isHidden(key: string): boolean;
|
|
96
|
+
/** Extra content layered over the plot, such as the doughnut centre. */
|
|
97
|
+
protected renderOverlay(): TemplateResult | typeof nothing;
|
|
98
|
+
/** Skeleton shown while `loading`. */
|
|
99
|
+
protected renderSkeleton(): TemplateResult;
|
|
100
|
+
private pointFromEvent;
|
|
101
|
+
private handlePointerMove;
|
|
102
|
+
private handlePointerLeave;
|
|
103
|
+
private handleClick;
|
|
104
|
+
private handleKeyDown;
|
|
105
|
+
private handleBlur;
|
|
106
|
+
private announce;
|
|
107
|
+
private select;
|
|
108
|
+
private toggleSeries;
|
|
109
|
+
private renderTooltip;
|
|
110
|
+
private renderLegend;
|
|
111
|
+
private renderPlot;
|
|
112
|
+
render(): TemplateResult<1>;
|
|
113
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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 declare function roundedRectPath(x: number, y: number, width: number, height: number, radii: [number, number, number, number]): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
/** Maps a data field to how its series is shown, for example `{ desktop: { label: 'Desktop' } }`. */
|
|
9
|
+
export type ChartConfig = Record<string, ChartSeriesConfig>;
|
|
10
|
+
/** One row of cartesian chart data: the category field (`index`) plus a number per series. */
|
|
11
|
+
export type ChartDatum = Record<string, unknown>;
|
|
12
|
+
/** Formats a value for tooltips, value labels and axis ticks. */
|
|
13
|
+
export type ChartValueFormatter = (value: number) => string;
|
|
14
|
+
/** A series resolved from config: key, label and color. */
|
|
15
|
+
export type ChartSeries = {
|
|
16
|
+
key: string;
|
|
17
|
+
label: string;
|
|
18
|
+
color: string;
|
|
19
|
+
};
|
|
20
|
+
/** A row in the tooltip. */
|
|
21
|
+
export type ChartTooltipRow = {
|
|
22
|
+
key: string;
|
|
23
|
+
label: string;
|
|
24
|
+
color: string;
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
/** What the tooltip shows and where. Coordinates are relative to the plot element. */
|
|
28
|
+
export type ChartTooltipModel = {
|
|
29
|
+
title: string;
|
|
30
|
+
rows: ChartTooltipRow[];
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
};
|
|
34
|
+
/** Detail of the `chart-select` event. */
|
|
35
|
+
export type ChartSelectDetail = {
|
|
36
|
+
/** Index of the selected category or slice in `data`. */
|
|
37
|
+
index: number;
|
|
38
|
+
/** Series key, when a single series was selected. */
|
|
39
|
+
series?: string;
|
|
40
|
+
/** The selected data row. */
|
|
41
|
+
datum: unknown;
|
|
42
|
+
};
|
|
@@ -3,10 +3,9 @@ import { LitElement } from 'lit';
|
|
|
3
3
|
* @label Card Content
|
|
4
4
|
* @tag wc-card-content
|
|
5
5
|
* @rawTag card-content
|
|
6
|
+
* @summary A padded block inside a card. A card can hold several, next to edge-to-edge media.
|
|
6
7
|
*
|
|
7
|
-
* @cssprop --card-content-padding -
|
|
8
|
-
*
|
|
9
|
-
* ```
|
|
8
|
+
* @cssprop --card-content-padding - Padding on all sides. Defaults to 1rem.
|
|
10
9
|
*/
|
|
11
10
|
export declare class CardContent extends LitElement {
|
|
12
11
|
static styles: import("lit").CSSResult;
|
package/dist/src/card/card.d.ts
CHANGED
|
@@ -5,48 +5,62 @@ declare const Card_base: typeof LitElement & import("../__internal/mixins/MixinC
|
|
|
5
5
|
* @label Card
|
|
6
6
|
* @tag wc-card
|
|
7
7
|
* @rawTag card
|
|
8
|
-
* @summary A card
|
|
9
|
-
* @cssprop --card-
|
|
10
|
-
* @cssprop --card-
|
|
11
|
-
* @cssprop --card-gap - Gap between
|
|
8
|
+
* @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.
|
|
9
|
+
* @cssprop --card-container-shape - Corner radius of the card. Defaults to `--shape-corner-large`.
|
|
10
|
+
* @cssprop --card-padding - Padding inside the card, around its children. Defaults to 0; `wc-card-content` adds its own padding.
|
|
11
|
+
* @cssprop --card-gap - Gap between the card's children. Defaults to 0.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```html
|
|
15
|
-
* <wc-card variant="outlined"
|
|
15
|
+
* <wc-card variant="outlined">
|
|
16
16
|
* <wc-card-content>
|
|
17
|
-
* <h3 class="text-
|
|
18
|
-
* <p class="text-body">
|
|
17
|
+
* <h3 class="text-title-large">Title</h3>
|
|
18
|
+
* <p class="text-body-medium">Supporting text</p>
|
|
19
19
|
* </wc-card-content>
|
|
20
20
|
* </wc-card>
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export declare class Card extends Card_base {
|
|
24
|
-
#private;
|
|
25
24
|
static styles: import("lit").CSSResultGroup[];
|
|
25
|
+
/**
|
|
26
|
+
* Visual style of the card: `elevated` (a raised surface with a shadow), `filled` (a tonal surface)
|
|
27
|
+
* or `outlined` (a bordered surface). Defaults to `elevated`.
|
|
28
|
+
*/
|
|
26
29
|
variant: CardVariant;
|
|
30
|
+
/**
|
|
31
|
+
* Dims the card and makes its content inert. An actionable or link card also stops responding
|
|
32
|
+
* to clicks and leaves the tab order, unless `disabled-reason` is set.
|
|
33
|
+
*/
|
|
27
34
|
disabled: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Makes the whole card a single button that fires `click`. Its content becomes inert, so don't
|
|
37
|
+
* put buttons or links inside an actionable card.
|
|
38
|
+
*/
|
|
28
39
|
actionable: boolean;
|
|
29
40
|
/**
|
|
30
|
-
*
|
|
41
|
+
* Why an actionable or link card is disabled. The card stays focusable and screen readers read
|
|
42
|
+
* the reason with it.
|
|
31
43
|
*/
|
|
32
44
|
disabledReason: string;
|
|
33
45
|
/**
|
|
34
|
-
*
|
|
46
|
+
* Delay in milliseconds for throttling activation of an actionable or link card. When unset
|
|
47
|
+
* (default), no throttle is applied.
|
|
35
48
|
*/
|
|
36
49
|
throttleDelay?: number;
|
|
37
|
-
/**
|
|
38
|
-
* States
|
|
39
|
-
*/
|
|
50
|
+
/** Whether the default slot holds meaningful content. */
|
|
40
51
|
private slotHasContent;
|
|
41
52
|
readonly cardElement: HTMLElement | null;
|
|
42
53
|
constructor();
|
|
43
54
|
firstUpdated(): void;
|
|
55
|
+
__handleClick(event: MouseEvent | KeyboardEvent): void;
|
|
44
56
|
__dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void;
|
|
45
57
|
__dispatchClick: (event: MouseEvent | KeyboardEvent) => void;
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
/** True when a disabled interactive card should stay focusable to expose its reason. */
|
|
59
|
+
__isSoftDisabled(): boolean;
|
|
60
|
+
__getDisabledReasonID(): "disabled-reason" | undefined;
|
|
61
|
+
renderDisabledReason(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
62
|
+
renderCardElement(isLinkElement: boolean): import("lit-html").TemplateResult<1>;
|
|
63
|
+
renderCardContent(inertContent: boolean): import("lit-html").TemplateResult<1>;
|
|
48
64
|
render(): import("lit-html").TemplateResult<1>;
|
|
49
|
-
renderCardElement(isLinkElement: boolean, disableSlotTabbing: boolean): import("lit-html").TemplateResult<1>;
|
|
50
|
-
renderCardContent(disableSlotTabbing: boolean): import("lit-html").TemplateResult<1>;
|
|
51
65
|
}
|
|
52
66
|
export {};
|