@aceshooting/lyra-ui 2.0.0 → 2.1.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/README.md +87 -14
- package/custom-elements.json +11555 -5539
- package/dist/components/app-rail/app-rail-item.d.ts +30 -0
- package/dist/components/app-rail/app-rail-item.js +68 -0
- package/dist/components/app-rail/app-rail-item.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail-item.styles.js +65 -0
- package/dist/components/app-rail/app-rail.d.ts +21 -24
- package/dist/components/app-rail/app-rail.js +68 -132
- package/dist/components/app-rail/app-rail.styles.js +5 -2
- package/dist/components/attachment-chip/attachment-chip.d.ts +38 -11
- package/dist/components/attachment-chip/attachment-chip.js +73 -29
- package/dist/components/attachment-trigger/attachment-trigger.d.ts +13 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +13 -1
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +28 -6
- package/dist/components/chart/bar-chart.js +2 -18
- package/dist/components/chart/box-plot.d.ts +25 -1
- package/dist/components/chart/box-plot.js +136 -6
- package/dist/components/chart/box-plot.styles.js +13 -0
- package/dist/components/chart/bubble-chart.js +2 -18
- package/dist/components/chart/chart.d.ts +54 -10
- package/dist/components/chart/chart.js +182 -39
- package/dist/components/chart/doughnut-chart.js +2 -18
- package/dist/components/chart/histogram-bin.d.ts +5 -2
- package/dist/components/chart/histogram-bin.js +12 -4
- package/dist/components/chart/histogram.js +8 -16
- package/dist/components/chart/line-chart.js +2 -18
- package/dist/components/chart/lite-chart.d.ts +80 -3
- package/dist/components/chart/lite-chart.js +250 -53
- package/dist/components/chart/pie-chart.js +2 -18
- package/dist/components/chart/polar-area-chart.js +2 -18
- package/dist/components/chart/radar-chart.js +2 -18
- package/dist/components/chart/scatter-chart.js +2 -18
- package/dist/components/chat-composer/chat-composer.d.ts +42 -1
- package/dist/components/chat-composer/chat-composer.js +84 -3
- package/dist/components/chat-composer/chat-composer.styles.js +11 -1
- package/dist/components/chat-message/chat-message.d.ts +32 -4
- package/dist/components/chat-message/chat-message.js +57 -17
- package/dist/components/checkbox/checkbox.d.ts +66 -8
- package/dist/components/checkbox/checkbox.js +173 -50
- package/dist/components/checkbox/checkbox.styles.js +9 -2
- package/dist/components/chip/chip-group.js +8 -2
- package/dist/components/chip/chip.js +9 -2
- package/dist/components/citation-badge/citation-badge.js +21 -3
- package/dist/components/code-block/code-block.d.ts +38 -0
- package/dist/components/code-block/code-block.js +72 -7
- package/dist/components/code-block/code-loader.d.ts +44 -1
- package/dist/components/code-block/code-loader.js +63 -0
- package/dist/components/combobox/combobox.d.ts +46 -5
- package/dist/components/combobox/combobox.js +175 -35
- package/dist/components/combobox/combobox.styles.js +3 -3
- package/dist/components/context-meter/context-meter.js +17 -8
- package/dist/components/context-meter/context-meter.styles.js +0 -6
- package/dist/components/conversation-item/conversation-item.d.ts +13 -16
- package/dist/components/conversation-item/conversation-item.js +29 -20
- package/dist/components/date-picker/calendar-core.d.ts +24 -0
- package/dist/components/date-picker/calendar-core.js +51 -4
- package/dist/components/date-picker/date-input.d.ts +77 -10
- package/dist/components/date-picker/date-input.js +278 -73
- package/dist/components/date-picker/date-picker.d.ts +28 -4
- package/dist/components/date-picker/date-picker.js +95 -37
- package/dist/components/dialog/confirm.js +3 -6
- package/dist/components/dialog/dialog.d.ts +75 -31
- package/dist/components/dialog/dialog.js +147 -131
- package/dist/components/dialog/dialog.styles.js +46 -2
- package/dist/components/dock-panel/dock-panel.d.ts +8 -0
- package/dist/components/dock-panel/dock-panel.js +15 -1
- package/dist/components/dock-panel/dock-panel.styles.js +15 -1
- package/dist/components/document-preview/document-preview.d.ts +15 -7
- package/dist/components/document-preview/document-preview.js +29 -13
- package/dist/components/empty/empty.d.ts +1 -2
- package/dist/components/empty/empty.js +18 -12
- package/dist/components/empty/empty.styles.js +0 -3
- package/dist/components/export-button/export-button.d.ts +12 -0
- package/dist/components/export-button/export-button.js +33 -5
- package/dist/components/export-button/export-button.styles.js +5 -1
- package/dist/components/file-input/accept.js +2 -0
- package/dist/components/file-input/file-input.d.ts +10 -1
- package/dist/components/file-input/file-input.js +36 -5
- package/dist/components/flag/flag.d.ts +1 -1
- package/dist/components/flag/flag.js +15 -1
- package/dist/components/flag/flag.styles.js +1 -1
- package/dist/components/flag/language-map.d.ts +4 -1
- package/dist/components/flag/language-map.js +6 -3
- package/dist/components/gauge/gauge.d.ts +10 -1
- package/dist/components/gauge/gauge.js +28 -9
- package/dist/components/generation-status/generation-status.d.ts +13 -5
- package/dist/components/generation-status/generation-status.js +59 -5
- package/dist/components/graph/graph.d.ts +37 -3
- package/dist/components/graph/graph.js +132 -20
- package/dist/components/heatmap/calendar-grid.d.ts +15 -6
- package/dist/components/heatmap/calendar-grid.js +17 -6
- package/dist/components/heatmap/heatmap-scale.d.ts +5 -1
- package/dist/components/heatmap/heatmap-scale.js +8 -2
- package/dist/components/heatmap/heatmap.d.ts +166 -25
- package/dist/components/heatmap/heatmap.js +372 -89
- package/dist/components/json-viewer/json-viewer.d.ts +22 -5
- package/dist/components/json-viewer/json-viewer.js +115 -37
- package/dist/components/json-viewer/json-viewer.styles.js +2 -1
- package/dist/components/kbd/kbd.js +24 -7
- package/dist/components/live-region/live-region.d.ts +10 -1
- package/dist/components/live-region/live-region.js +42 -6
- package/dist/components/map/map.d.ts +24 -1
- package/dist/components/map/map.js +89 -24
- package/dist/components/markdown/markdown-loader.d.ts +24 -0
- package/dist/components/markdown/markdown-loader.js +35 -1
- package/dist/components/markdown/markdown.d.ts +46 -8
- package/dist/components/markdown/markdown.js +136 -31
- package/dist/components/markdown/markdown.styles.js +7 -1
- package/dist/components/media-card/media-card.d.ts +25 -17
- package/dist/components/media-card/media-card.js +43 -65
- package/dist/components/mention-popover/mention-popover.d.ts +4 -1
- package/dist/components/mention-popover/mention-popover.js +23 -5
- package/dist/components/menu/menu-item.d.ts +32 -3
- package/dist/components/menu/menu-item.js +94 -7
- package/dist/components/menu/menu-item.styles.js +8 -0
- package/dist/components/menu/menu.d.ts +25 -1
- package/dist/components/menu/menu.js +99 -3
- package/dist/components/menu/menu.styles.js +3 -2
- package/dist/components/model-select/model-select.d.ts +48 -3
- package/dist/components/model-select/model-select.js +120 -22
- package/dist/components/model-select/model-select.styles.js +17 -3
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +25 -1
- package/dist/components/model-settings-panel/model-settings-panel.js +65 -1
- package/dist/components/playback/playback.d.ts +6 -2
- package/dist/components/playback/playback.js +72 -29
- package/dist/components/playback/playback.styles.js +6 -1
- package/dist/components/responsive-panel/responsive-panel.d.ts +29 -16
- package/dist/components/responsive-panel/responsive-panel.js +130 -132
- package/dist/components/responsive-panel/responsive-panel.styles.js +1 -1
- package/dist/components/result-card/result-card.d.ts +8 -2
- package/dist/components/result-card/result-card.js +9 -3
- package/dist/components/result-card/result-card.styles.js +0 -1
- package/dist/components/select/select.d.ts +59 -20
- package/dist/components/select/select.js +125 -43
- package/dist/components/skeleton/skeleton.d.ts +3 -0
- package/dist/components/skeleton/skeleton.js +7 -1
- package/dist/components/skeleton/skeleton.styles.js +5 -4
- package/dist/components/slider/slider.d.ts +57 -5
- package/dist/components/slider/slider.js +195 -80
- package/dist/components/source-card/source-card.d.ts +17 -5
- package/dist/components/source-card/source-card.js +55 -8
- package/dist/components/source-card/source-card.styles.js +1 -1
- package/dist/components/source-list/source-list.js +9 -1
- package/dist/components/sparkline/sparkline.js +34 -10
- package/dist/components/split/split.d.ts +141 -14
- package/dist/components/split/split.js +357 -52
- package/dist/components/split/split.styles.js +18 -1
- package/dist/components/stat/stat.d.ts +10 -4
- package/dist/components/stat/stat.js +46 -11
- package/dist/components/stream-status/stream-status.d.ts +27 -11
- package/dist/components/stream-status/stream-status.js +95 -13
- package/dist/components/streaming-text/streaming-text.d.ts +9 -3
- package/dist/components/streaming-text/streaming-text.js +25 -10
- package/dist/components/streaming-text/streaming-text.styles.js +3 -2
- package/dist/components/switch/switch.d.ts +52 -7
- package/dist/components/switch/switch.js +111 -40
- package/dist/components/switch/switch.styles.js +1 -1
- package/dist/components/table/table.d.ts +18 -3
- package/dist/components/table/table.js +88 -20
- package/dist/components/tabs/tabs.d.ts +23 -0
- package/dist/components/tabs/tabs.js +76 -12
- package/dist/components/tabs/tabs.styles.js +11 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +3 -1
- package/dist/components/thinking-panel/thinking-panel.js +34 -9
- package/dist/components/thinking-panel/thinking-panel.styles.js +6 -0
- package/dist/components/time-range/time-range.d.ts +59 -2
- package/dist/components/time-range/time-range.js +163 -67
- package/dist/components/toast/toast-item.d.ts +12 -3
- package/dist/components/toast/toast-item.js +90 -53
- package/dist/components/toast/toast-item.styles.js +59 -28
- package/dist/components/toast/toast.js +17 -5
- package/dist/components/toast/toaster.js +10 -1
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +11 -10
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +50 -124
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.js +1 -1
- package/dist/components/tool-call-chip/tool-call-chip.d.ts +18 -2
- package/dist/components/tool-call-chip/tool-call-chip.js +86 -25
- package/dist/components/tool-param-form/tool-param-form.d.ts +89 -28
- package/dist/components/tool-param-form/tool-param-form.js +350 -106
- package/dist/components/tool-result-dialog/tool-result-dialog.d.ts +27 -7
- package/dist/components/tool-result-dialog/tool-result-dialog.js +80 -115
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.js +1 -1
- package/dist/components/tool-result-view/registry.d.ts +0 -8
- package/dist/components/tool-result-view/registry.js +7 -2
- package/dist/components/tool-result-view/tool-result-view.d.ts +6 -3
- package/dist/components/tool-result-view/tool-result-view.js +18 -4
- package/dist/components/tool-select-dialog/tool-select-dialog.d.ts +11 -11
- package/dist/components/tool-select-dialog/tool-select-dialog.js +44 -133
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.js +13 -4
- package/dist/components/tree/tree-node.d.ts +4 -1
- package/dist/components/tree/tree-node.js +4 -1
- package/dist/components/tree/tree.d.ts +17 -8
- package/dist/components/tree/tree.js +21 -20
- package/dist/components/typing-indicator/typing-indicator.d.ts +12 -2
- package/dist/components/typing-indicator/typing-indicator.js +16 -4
- package/dist/components/typing-indicator/typing-indicator.styles.js +2 -2
- package/dist/components/virtual-list/virtual-list.d.ts +56 -19
- package/dist/components/virtual-list/virtual-list.js +184 -38
- package/dist/components/virtual-list/virtual-list.styles.js +12 -0
- package/dist/components/widget/widget.d.ts +5 -4
- package/dist/components/widget/widget.js +54 -120
- package/dist/components/widget/widget.styles.js +8 -2
- package/dist/components/word-cloud/word-cloud-layout.d.ts +7 -0
- package/dist/components/word-cloud/word-cloud-layout.js +20 -6
- package/dist/components/word-cloud/word-cloud.d.ts +22 -2
- package/dist/components/word-cloud/word-cloud.js +45 -6
- package/dist/components/word-cloud/word-cloud.styles.js +13 -1
- package/dist/internal/anchored-validity.d.ts +1 -0
- package/dist/internal/anchored-validity.js +86 -0
- package/dist/internal/form-associated.d.ts +7 -0
- package/dist/internal/form-associated.js +43 -4
- package/dist/internal/numbers.d.ts +12 -0
- package/dist/internal/numbers.js +26 -0
- package/dist/internal/overlay-manager.d.ts +51 -0
- package/dist/internal/overlay-manager.js +523 -0
- package/dist/internal/positioner.js +27 -3
- package/dist/internal/safe-url.d.ts +12 -0
- package/dist/internal/safe-url.js +41 -0
- package/dist/internal/tokens.styles.js +17 -11
- package/dist/lyra.d.ts +5 -2
- package/dist/lyra.js +3 -1
- package/llms-full.txt +970 -426
- package/llms.txt +5 -4
- package/package.json +19 -2
|
@@ -8,9 +8,21 @@ import { html } from 'lit';
|
|
|
8
8
|
import { property, query, state } from 'lit/decorators.js';
|
|
9
9
|
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
10
|
import { defineElement } from '../../internal/prefix.js';
|
|
11
|
+
import { nextId, srOnly } from '../../internal/a11y.js';
|
|
11
12
|
import { loadChartJs } from './chart-loader.js';
|
|
12
13
|
import { styles } from './box-plot.styles.js';
|
|
13
14
|
import '../skeleton/skeleton.js';
|
|
15
|
+
// Defensive JS-side fallbacks for themeColors() below, mirroring the
|
|
16
|
+
// light-mode default of each `--lyra-chart-*` token's own fallback chain
|
|
17
|
+
// (see box-plot.styles.ts) — only reached if getComputedStyle somehow can't
|
|
18
|
+
// resolve the custom property at all (e.g. host detached from the document).
|
|
19
|
+
// Same values as chart.ts's own fallbacks, since both default to the same
|
|
20
|
+
// semantic tokens.
|
|
21
|
+
const FALLBACK_GRID_COLOR = '#8a8a90';
|
|
22
|
+
const FALLBACK_TICK_COLOR = '#6b7280';
|
|
23
|
+
const FALLBACK_LEGEND_COLOR = '#1a1a1a';
|
|
24
|
+
const FALLBACK_TOOLTIP_BG = '#fff';
|
|
25
|
+
const FALLBACK_TOOLTIP_TEXT = '#1a1a1a';
|
|
14
26
|
let boxPlotPlugin;
|
|
15
27
|
/**
|
|
16
28
|
* Lazily loads `@sgratzl/chartjs-chart-boxplot` and registers its controller
|
|
@@ -40,7 +52,11 @@ function loadBoxPlotPlugin() {
|
|
|
40
52
|
* Awesome's chart set — useful for summarizing distributions.
|
|
41
53
|
*
|
|
42
54
|
* @customElement lyra-box-plot
|
|
43
|
-
* @csspart base
|
|
55
|
+
* @csspart base - The chart wrapper.
|
|
56
|
+
* @csspart canvas - The box-plot canvas.
|
|
57
|
+
* @csspart description - The accessible box-plot summary.
|
|
58
|
+
* @csspart data-table - The optional generated or slotted data table.
|
|
59
|
+
* @slot data-table - An optional consumer-provided accessible table alternative.
|
|
44
60
|
*/
|
|
45
61
|
export class LyraBoxPlot extends LyraElement {
|
|
46
62
|
constructor() {
|
|
@@ -51,17 +67,34 @@ export class LyraBoxPlot extends LyraElement {
|
|
|
51
67
|
this.height = '280px';
|
|
52
68
|
this.yLabel = '';
|
|
53
69
|
this.beginAtZero = true;
|
|
70
|
+
/** Accessible name applied to the canvas. Falls back to the box labels. */
|
|
71
|
+
this.accessibleLabel = '';
|
|
72
|
+
/** Accessible description for the canvas. When unset, a five-number summary is generated. */
|
|
73
|
+
this.accessibleDescription = '';
|
|
74
|
+
/** Makes the generated data table visible; it remains screen-reader available when false. */
|
|
75
|
+
this.showDataTable = false;
|
|
54
76
|
/**
|
|
55
77
|
* True until the lazy-loaded `chart.js` + `@sgratzl/chartjs-chart-boxplot`
|
|
56
78
|
* peer dependencies have settled (success or failure) — mirrors
|
|
57
79
|
* `LyraChart`'s `loading` state.
|
|
58
80
|
*/
|
|
59
81
|
this.loading = true;
|
|
82
|
+
this.visible = true;
|
|
83
|
+
this.descriptionId = nextId('box-plot-description');
|
|
60
84
|
}
|
|
61
|
-
static { this.styles = [LyraElement.styles, styles]; }
|
|
85
|
+
static { this.styles = [LyraElement.styles, styles, srOnly]; }
|
|
62
86
|
connectedCallback() {
|
|
63
87
|
super.connectedCallback();
|
|
64
88
|
void loadBoxPlotPlugin().then((boxMod) => this.onBoxPlotPluginLoaded(boxMod));
|
|
89
|
+
if (typeof IntersectionObserver !== 'undefined') {
|
|
90
|
+
this.intersectionObserver = new IntersectionObserver((entries) => {
|
|
91
|
+
const wasVisible = this.visible;
|
|
92
|
+
this.visible = entries[0]?.isIntersecting ?? true;
|
|
93
|
+
if (this.visible && !wasVisible)
|
|
94
|
+
this.draw();
|
|
95
|
+
});
|
|
96
|
+
this.intersectionObserver.observe(this);
|
|
97
|
+
}
|
|
65
98
|
}
|
|
66
99
|
// Split out from `connectedCallback()` so the partial-peer-dependency-
|
|
67
100
|
// failure path (chart.js loads fine, `@sgratzl/chartjs-chart-boxplot`
|
|
@@ -91,6 +124,7 @@ export class LyraBoxPlot extends LyraElement {
|
|
|
91
124
|
super.disconnectedCallback();
|
|
92
125
|
this.chart?.destroy();
|
|
93
126
|
this.chart = undefined;
|
|
127
|
+
this.intersectionObserver?.disconnect();
|
|
94
128
|
}
|
|
95
129
|
updated(changed) {
|
|
96
130
|
if (this.loading)
|
|
@@ -105,9 +139,35 @@ export class LyraBoxPlot extends LyraElement {
|
|
|
105
139
|
if (changed.has('height')) {
|
|
106
140
|
this.style.setProperty('--lyra-chart-height', this.height);
|
|
107
141
|
}
|
|
142
|
+
if (this.loading)
|
|
143
|
+
return;
|
|
144
|
+
if (!this.visible)
|
|
145
|
+
return; // becoming visible again triggers its own draw() via the observer above
|
|
146
|
+
const contentChanged = ['labels', 'boxes', 'legend', 'height', 'yLabel', 'beginAtZero', 'loading'].some((name) => changed.has(name));
|
|
147
|
+
if (!contentChanged)
|
|
148
|
+
return;
|
|
108
149
|
this.draw();
|
|
109
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolves the `--lyra-chart-*` theme tokens (declared in
|
|
153
|
+
* `box-plot.styles.ts`, each layered over an existing semantic token) via
|
|
154
|
+
* `getComputedStyle`. Chart.js renders to canvas, not the DOM, so it can't
|
|
155
|
+
* consume CSS `var()` directly — same constraint `chart.ts`'s
|
|
156
|
+
* `themeColors()` documents — so this is called fresh from `buildConfig()`
|
|
157
|
+
* on every draw rather than cached.
|
|
158
|
+
*/
|
|
159
|
+
themeColors() {
|
|
160
|
+
const cs = getComputedStyle(this);
|
|
161
|
+
return {
|
|
162
|
+
grid: cs.getPropertyValue('--lyra-chart-grid-color').trim() || FALLBACK_GRID_COLOR,
|
|
163
|
+
tick: cs.getPropertyValue('--lyra-chart-tick-color').trim() || FALLBACK_TICK_COLOR,
|
|
164
|
+
legend: cs.getPropertyValue('--lyra-chart-legend-color').trim() || FALLBACK_LEGEND_COLOR,
|
|
165
|
+
tooltipBg: cs.getPropertyValue('--lyra-chart-tooltip-bg').trim() || FALLBACK_TOOLTIP_BG,
|
|
166
|
+
tooltipText: cs.getPropertyValue('--lyra-chart-tooltip-text').trim() || FALLBACK_TOOLTIP_TEXT,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
110
169
|
buildConfig() {
|
|
170
|
+
const theme = this.themeColors();
|
|
111
171
|
return {
|
|
112
172
|
// boxplot isn't in chart.js's static ChartType union — same cast the seed uses.
|
|
113
173
|
type: 'boxplot',
|
|
@@ -123,8 +183,15 @@ export class LyraBoxPlot extends LyraElement {
|
|
|
123
183
|
options: {
|
|
124
184
|
responsive: true,
|
|
125
185
|
maintainAspectRatio: false,
|
|
126
|
-
plugins: { legend: { display: this.legend } },
|
|
127
|
-
scales: {
|
|
186
|
+
plugins: { legend: { display: this.legend, labels: { color: theme.legend } } },
|
|
187
|
+
scales: {
|
|
188
|
+
y: {
|
|
189
|
+
beginAtZero: this.beginAtZero,
|
|
190
|
+
title: { display: !!this.yLabel, text: this.yLabel },
|
|
191
|
+
ticks: { color: theme.tick },
|
|
192
|
+
grid: { color: theme.grid },
|
|
193
|
+
},
|
|
194
|
+
},
|
|
128
195
|
},
|
|
129
196
|
};
|
|
130
197
|
}
|
|
@@ -148,6 +215,51 @@ export class LyraBoxPlot extends LyraElement {
|
|
|
148
215
|
}
|
|
149
216
|
this.chart = new this.chartJsModule.Chart(this.canvasEl, config);
|
|
150
217
|
}
|
|
218
|
+
boxPlotDescription() {
|
|
219
|
+
if (this.accessibleDescription)
|
|
220
|
+
return this.accessibleDescription;
|
|
221
|
+
const summaries = this.boxes.map((series) => {
|
|
222
|
+
if (!series.data.length)
|
|
223
|
+
return `${series.label}: no data`;
|
|
224
|
+
const medians = series.data.map((point) => point.median);
|
|
225
|
+
const first = medians[0];
|
|
226
|
+
const last = medians[medians.length - 1];
|
|
227
|
+
const trend = last > first ? 'increasing' : last < first ? 'decreasing' : 'flat';
|
|
228
|
+
return `${series.label}: ${series.data.length} distributions, median range ${Math.min(...medians)} to ${Math.max(...medians)}, ${trend} median trend`;
|
|
229
|
+
});
|
|
230
|
+
return `Box plot${summaries.length ? `. ${summaries.join('. ')}` : ' with no data'}.`;
|
|
231
|
+
}
|
|
232
|
+
renderDataTable() {
|
|
233
|
+
return html `
|
|
234
|
+
<table class=${this.showDataTable ? '' : 'sr-only'}>
|
|
235
|
+
<caption>${this.accessibleLabel || 'Box plot data'}</caption>
|
|
236
|
+
<thead>
|
|
237
|
+
<tr>
|
|
238
|
+
<th scope="col">Category</th>
|
|
239
|
+
<th scope="col">Series</th>
|
|
240
|
+
<th scope="col">Min</th>
|
|
241
|
+
<th scope="col">Q1</th>
|
|
242
|
+
<th scope="col">Median</th>
|
|
243
|
+
<th scope="col">Q3</th>
|
|
244
|
+
<th scope="col">Max</th>
|
|
245
|
+
</tr>
|
|
246
|
+
</thead>
|
|
247
|
+
<tbody>
|
|
248
|
+
${this.boxes.flatMap((series) => series.data.map((point, index) => html `
|
|
249
|
+
<tr>
|
|
250
|
+
<th scope="row">${this.labels[index] ?? `Point ${index + 1}`}</th>
|
|
251
|
+
<td>${series.label}</td>
|
|
252
|
+
<td>${point.min}</td>
|
|
253
|
+
<td>${point.q1}</td>
|
|
254
|
+
<td>${point.median}</td>
|
|
255
|
+
<td>${point.q3}</td>
|
|
256
|
+
<td>${point.max}</td>
|
|
257
|
+
</tr>
|
|
258
|
+
`))}
|
|
259
|
+
</tbody>
|
|
260
|
+
</table>
|
|
261
|
+
`;
|
|
262
|
+
}
|
|
151
263
|
render() {
|
|
152
264
|
if (this.loading) {
|
|
153
265
|
return html `
|
|
@@ -156,10 +268,16 @@ export class LyraBoxPlot extends LyraElement {
|
|
|
156
268
|
</div>
|
|
157
269
|
`;
|
|
158
270
|
}
|
|
159
|
-
const label = this.boxes.map((b) => b.label).join(', ') || 'Box plot';
|
|
271
|
+
const label = this.accessibleLabel || this.boxes.map((b) => b.label).join(', ') || 'Box plot';
|
|
272
|
+
const description = this.boxPlotDescription();
|
|
160
273
|
return html `
|
|
161
274
|
<div part="base">
|
|
162
|
-
<canvas part="canvas" role="img" aria-label=${label}></canvas>
|
|
275
|
+
<canvas part="canvas" role="img" aria-label=${label} aria-describedby=${this.descriptionId}></canvas>
|
|
276
|
+
<p part="description" id=${this.descriptionId} class="sr-only">${description}</p>
|
|
277
|
+
<div part="data-table">
|
|
278
|
+
<slot name="data-table"></slot>
|
|
279
|
+
${this.renderDataTable()}
|
|
280
|
+
</div>
|
|
163
281
|
</div>
|
|
164
282
|
`;
|
|
165
283
|
}
|
|
@@ -182,9 +300,21 @@ __decorate([
|
|
|
182
300
|
__decorate([
|
|
183
301
|
property({ type: Boolean, attribute: 'begin-at-zero' })
|
|
184
302
|
], LyraBoxPlot.prototype, "beginAtZero", void 0);
|
|
303
|
+
__decorate([
|
|
304
|
+
property({ attribute: 'accessible-label' })
|
|
305
|
+
], LyraBoxPlot.prototype, "accessibleLabel", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
property({ attribute: 'accessible-description' })
|
|
308
|
+
], LyraBoxPlot.prototype, "accessibleDescription", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
property({ type: Boolean, attribute: 'show-data-table' })
|
|
311
|
+
], LyraBoxPlot.prototype, "showDataTable", void 0);
|
|
185
312
|
__decorate([
|
|
186
313
|
state()
|
|
187
314
|
], LyraBoxPlot.prototype, "loading", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
state()
|
|
317
|
+
], LyraBoxPlot.prototype, "visible", void 0);
|
|
188
318
|
__decorate([
|
|
189
319
|
query('canvas')
|
|
190
320
|
], LyraBoxPlot.prototype, "canvasEl", void 0);
|
|
@@ -9,6 +9,19 @@ export const styles = css `
|
|
|
9
9
|
display: block;
|
|
10
10
|
position: relative;
|
|
11
11
|
block-size: var(--lyra-chart-height, 280px);
|
|
12
|
+
/* Same theme tokens as chart.styles.ts's :host — Chart.js renders to
|
|
13
|
+
canvas, not the DOM, so it can't consume CSS var() directly;
|
|
14
|
+
box-plot.ts's themeColors() resolves these once per draw() via
|
|
15
|
+
getComputedStyle, mirroring chart.ts. Each is its own token (rather
|
|
16
|
+
than reusing the semantic ones directly) so a host can retheme just
|
|
17
|
+
the chart's grid/ticks/legend/tooltip without affecting unrelated
|
|
18
|
+
text/border/surface colors elsewhere in the component, while still
|
|
19
|
+
defaulting to those semantic tokens. */
|
|
20
|
+
--lyra-chart-grid-color: var(--lyra-color-border);
|
|
21
|
+
--lyra-chart-tick-color: var(--lyra-color-text-quiet);
|
|
22
|
+
--lyra-chart-legend-color: var(--lyra-color-text);
|
|
23
|
+
--lyra-chart-tooltip-bg: var(--lyra-color-surface);
|
|
24
|
+
--lyra-chart-tooltip-text: var(--lyra-color-text);
|
|
12
25
|
}
|
|
13
26
|
[part='base'] {
|
|
14
27
|
position: relative;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LyraChart } from './chart.js';
|
|
1
|
+
import { LyraChart, lockChartType } from './chart.js';
|
|
2
2
|
import { defineElement } from '../../internal/prefix.js';
|
|
3
3
|
/**
|
|
4
4
|
* `<lyra-bubble-chart>` — `<lyra-chart>` with `type` locked to `"bubble"`. Feed
|
|
@@ -11,21 +11,5 @@ import { defineElement } from '../../internal/prefix.js';
|
|
|
11
11
|
*/
|
|
12
12
|
export class LyraBubbleChart extends LyraChart {
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
// default value — `LyraChart` declares it as a plain (decorator-managed)
|
|
16
|
-
// class field, and TypeScript forbids a subclass from re-declaring a base
|
|
17
|
-
// field as a getter/setter pair via ordinary class syntax (TS2611) — so the
|
|
18
|
-
// accessor pair is installed directly on the prototype instead, which is
|
|
19
|
-
// runtime-equivalent (same shadowing semantics as a class-syntax override)
|
|
20
|
-
// without tripping that check.
|
|
21
|
-
Object.defineProperty(LyraBubbleChart.prototype, 'type', {
|
|
22
|
-
configurable: true,
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get() {
|
|
25
|
-
return 'bubble';
|
|
26
|
-
},
|
|
27
|
-
set(_v) {
|
|
28
|
-
/* locked to 'bubble'; direct writes are ignored */
|
|
29
|
-
},
|
|
30
|
-
});
|
|
14
|
+
lockChartType(LyraBubbleChart, 'bubble');
|
|
31
15
|
defineElement('bubble-chart', LyraBubbleChart);
|
|
@@ -45,7 +45,12 @@ export type LyraChartType = 'line' | 'bar' | 'scatter' | 'pie' | 'doughnut' | 'r
|
|
|
45
45
|
* intersect-only — see `handlePointClick()`) a data point/segment.
|
|
46
46
|
* `detail: { datasetIndex: number, index: number, label: string |
|
|
47
47
|
* undefined, value: unknown }`.
|
|
48
|
-
* @csspart base
|
|
48
|
+
* @csspart base - The chart wrapper.
|
|
49
|
+
* @csspart canvas - The Chart.js canvas.
|
|
50
|
+
* @csspart reset-zoom-button - The reset-zoom control when zoom is active.
|
|
51
|
+
* @csspart description - The accessible chart summary.
|
|
52
|
+
* @csspart data-table - The optional generated or slotted data table.
|
|
53
|
+
* @slot data-table - An optional consumer-provided accessible table alternative.
|
|
49
54
|
*/
|
|
50
55
|
export declare class LyraChart extends LyraElement {
|
|
51
56
|
static styles: import("lit").CSSResultGroup[];
|
|
@@ -60,6 +65,12 @@ export declare class LyraChart extends LyraElement {
|
|
|
60
65
|
yLabel: string;
|
|
61
66
|
y2Label: string;
|
|
62
67
|
beginAtZero: boolean;
|
|
68
|
+
/** Accessible name applied to the canvas. Falls back to the dataset labels. */
|
|
69
|
+
accessibleLabel: string;
|
|
70
|
+
/** Accessible description for the canvas. When unset, a concise data/trend summary is generated. */
|
|
71
|
+
accessibleDescription: string;
|
|
72
|
+
/** Makes the generated data table visible; it remains screen-reader available when false. */
|
|
73
|
+
showDataTable: boolean;
|
|
63
74
|
/** Sets `options.indexAxis = 'y'`, Chart.js's own mechanism for horizontal bars (also applies to line/area types). */
|
|
64
75
|
horizontal: boolean;
|
|
65
76
|
/** Stacks the `x`/`y`(/`y2`) scale entries `buildScales()` returns; only meaningful for `bar` and `line` types. */
|
|
@@ -78,14 +89,29 @@ export declare class LyraChart extends LyraElement {
|
|
|
78
89
|
private zoomed;
|
|
79
90
|
private visible;
|
|
80
91
|
private intersectionObserver?;
|
|
81
|
-
private lastSignature;
|
|
82
92
|
private canvasEl?;
|
|
83
93
|
private chart?;
|
|
84
94
|
private chartJsModule?;
|
|
85
95
|
private builtType?;
|
|
86
96
|
private suppressZoomComplete;
|
|
97
|
+
private descriptionId;
|
|
87
98
|
connectedCallback(): void;
|
|
88
99
|
disconnectedCallback(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Resets a stale `zoomed` flag before the render pass that's about to call
|
|
102
|
+
* `draw()`: a `type` (or `config.type` override) change that lands on a
|
|
103
|
+
* *different* effective Chart.js type makes `draw()` destroy the old
|
|
104
|
+
* `Chart` instance and construct a brand-new one, which was never zoomed —
|
|
105
|
+
* without this, `render()`'s reset-zoom-button stays visible for an
|
|
106
|
+
* instance that has no zoom/pan state left to reset. Computed here (before
|
|
107
|
+
* render), not in `updated()`/`draw()`, because setting `zoomed` — a
|
|
108
|
+
* reactive `@state` property — from `updated()` would schedule a second,
|
|
109
|
+
* redundant update pass; `willUpdate()` runs before this cycle's render is
|
|
110
|
+
* considered complete, so the same set just folds into the render already
|
|
111
|
+
* in progress. Same rationale as `toast-item.ts`'s `willUpdate()`-vs-
|
|
112
|
+
* `updated()` split.
|
|
113
|
+
*/
|
|
114
|
+
protected willUpdate(): void;
|
|
89
115
|
protected updated(changed: PropertyValues): void;
|
|
90
116
|
private seriesToDataset;
|
|
91
117
|
/**
|
|
@@ -97,14 +123,6 @@ export declare class LyraChart extends LyraElement {
|
|
|
97
123
|
* is called fresh from `buildConfig()` on every draw rather than cached.
|
|
98
124
|
*/
|
|
99
125
|
private themeColors;
|
|
100
|
-
/**
|
|
101
|
-
* A content-affecting-properties fingerprint used by `updated()` to skip a
|
|
102
|
-
* redundant `draw()` when neither visibility nor any of these properties
|
|
103
|
-
* actually changed since the last draw (e.g. an unrelated property/state
|
|
104
|
-
* update, or `requestUpdate()` with nothing changed). Mirrors
|
|
105
|
-
* `lite-chart.ts`'s `computeSignature()`.
|
|
106
|
-
*/
|
|
107
|
-
private computeSignature;
|
|
108
126
|
/**
|
|
109
127
|
* Builds `options.scales` for the effective chart type: no scale at all for
|
|
110
128
|
* pie/doughnut (a proportional-area chart has no axis), the single radial
|
|
@@ -129,6 +147,15 @@ export declare class LyraChart extends LyraElement {
|
|
|
129
147
|
* chart type (bar/line/pie/doughnut/etc.), not just bars.
|
|
130
148
|
*/
|
|
131
149
|
private handlePointClick;
|
|
150
|
+
/**
|
|
151
|
+
* `config.type` (if set) overrides the attribute `type` post-merge — this
|
|
152
|
+
* is the one place that resolution logic lives, shared by `buildConfig()`
|
|
153
|
+
* (which needs it to build scales/interaction for the right type) and
|
|
154
|
+
* `willUpdate()` (which needs it to detect a type change against the last
|
|
155
|
+
* *actually built* type, `this.builtType`, before the render pass that
|
|
156
|
+
* would rebuild the `Chart` instance).
|
|
157
|
+
*/
|
|
158
|
+
private effectiveType;
|
|
132
159
|
private buildConfig;
|
|
133
160
|
private draw;
|
|
134
161
|
/** Reset any active zoom/pan back to the original view. */
|
|
@@ -143,6 +170,9 @@ export declare class LyraChart extends LyraElement {
|
|
|
143
170
|
* update loop has nothing of its own to trigger `draw()` on.
|
|
144
171
|
*/
|
|
145
172
|
refreshTheme(): void;
|
|
173
|
+
private seriesValues;
|
|
174
|
+
private chartDescription;
|
|
175
|
+
private renderDataTable;
|
|
146
176
|
render(): TemplateResult;
|
|
147
177
|
}
|
|
148
178
|
declare global {
|
|
@@ -150,3 +180,17 @@ declare global {
|
|
|
150
180
|
'lyra-chart': LyraChart;
|
|
151
181
|
}
|
|
152
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Installs a read-only `type` accessor pair on a `LyraChart` subclass's
|
|
185
|
+
* prototype, locking it to `value` — assigning `.type` afterwards (attribute
|
|
186
|
+
* or property) is silently ignored. `LyraChart` declares `type` as a plain
|
|
187
|
+
* (decorator-managed) class field, and TypeScript forbids a subclass from
|
|
188
|
+
* re-declaring a base field as a getter/setter pair via ordinary class
|
|
189
|
+
* syntax (TS2611), so the accessor pair is installed directly on the
|
|
190
|
+
* prototype instead, which is runtime-equivalent (same shadowing semantics
|
|
191
|
+
* as a class-syntax override) without tripping that check. Shared by every
|
|
192
|
+
* `lyra-*-chart` subclass (bar/line/pie/doughnut/scatter/bubble/radar/
|
|
193
|
+
* polarArea) plus `lyra-histogram`, replacing what used to be an identical
|
|
194
|
+
* ~16-line `Object.defineProperty` block copy-pasted into each file.
|
|
195
|
+
*/
|
|
196
|
+
export declare function lockChartType(ctor: Function, value: string): void;
|