@ids-group-ltd/ids-design-system 0.13.1 → 0.13.3
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/CHANGELOG.md +626 -0
- package/components.md +17 -9
- package/docs/agent/INDEX.md +1 -1
- package/docs/agent/charts/ds-column-chart.md +3 -2
- package/docs/agent/charts/ds-line-chart.md +2 -1
- package/docs/agent/feedback/ds-bar.md +13 -0
- package/docs/agent/forms/ds-button.md +1 -1
- package/docs/agent/forms/ds-icon-button.md +1 -1
- package/docs/agent/surfaces/ds-card.md +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar-chart.mjs +81 -13
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar.mjs +95 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-bar.mjs.map +1 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-button.mjs +3 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-button.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-legend.mjs +47 -5
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-legend.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-tooltip.mjs +198 -50
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart-tooltip.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart.mjs +973 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-chart.mjs.map +1 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-column-chart.mjs +172 -111
- package/fesm2022/ids-group-ltd-ids-design-system-components-column-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-donut-chart.mjs +86 -15
- package/fesm2022/ids-group-ltd-ids-design-system-components-donut-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-funnel-chart.mjs +87 -12
- package/fesm2022/ids-group-ltd-ids-design-system-components-funnel-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-line-chart.mjs +193 -98
- package/fesm2022/ids-group-ltd-ids-design-system-components-line-chart.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components.mjs +233 -33
- package/fesm2022/ids-group-ltd-ids-design-system-components.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-core.mjs +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-core.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system.mjs +2 -1
- package/fesm2022/ids-group-ltd-ids-design-system.mjs.map +1 -1
- package/migrations/0.13.2.json +269 -0
- package/migrations/0.13.3.json +211 -0
- package/package.json +17 -9
- package/styles/_chart-frame.scss +117 -10
- package/styles/_chart-interactive.scss +12 -3
- package/styles/_overlay-motion.scss +7 -6
- package/styles/_tokens-charts.scss +29 -5
- package/styles/_tokens.scss +1 -1
- package/types/ids-group-ltd-ids-design-system-components-bar-chart.d.ts +68 -5
- package/types/ids-group-ltd-ids-design-system-components-bar.d.ts +63 -0
- package/types/ids-group-ltd-ids-design-system-components-button.d.ts +3 -2
- package/types/ids-group-ltd-ids-design-system-components-chart-legend.d.ts +25 -2
- package/types/ids-group-ltd-ids-design-system-components-chart-tooltip.d.ts +21 -4
- package/types/ids-group-ltd-ids-design-system-components-chart.d.ts +543 -0
- package/types/ids-group-ltd-ids-design-system-components-column-chart.d.ts +125 -37
- package/types/ids-group-ltd-ids-design-system-components-donut-chart.d.ts +43 -4
- package/types/ids-group-ltd-ids-design-system-components-funnel-chart.d.ts +52 -4
- package/types/ids-group-ltd-ids-design-system-components-line-chart.d.ts +90 -23
- package/types/ids-group-ltd-ids-design-system-components.d.ts +91 -16
- package/types/ids-group-ltd-ids-design-system-core.d.ts +73 -6
- package/types/ids-group-ltd-ids-design-system.d.ts +7 -6
- package/docs/agent/feedback/ds-progress.md +0 -7
- package/fesm2022/ids-group-ltd-ids-design-system-components-progress.mjs +0 -41
- package/fesm2022/ids-group-ltd-ids-design-system-components-progress.mjs.map +0 -1
- package/types/ids-group-ltd-ids-design-system-components-progress.d.ts +0 -22
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, model, booleanAttribute, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
2
|
+
import { input, model, booleanAttribute, computed, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import { nextControlId } from '@ids-group-ltd/ids-design-system/components';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The key beside a chart, and — when `toggleable` — the control that hides a series.
|
|
@@ -14,8 +15,17 @@ class ChartLegendComponent {
|
|
|
14
15
|
/** Ids of the hidden items. Two-way, so a page can drive it from a URL parameter and so
|
|
15
16
|
* cross-chart filtering later is this same mechanism. */
|
|
16
17
|
hidden = model([], ...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
|
|
17
|
-
/** Offers the
|
|
18
|
+
/** Offers the control. Off leaves the legend a plain key. */
|
|
18
19
|
toggleable = input(false, { ...(ngDevMode ? { debugName: "toggleable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
20
|
+
/** What a control does. `'isolate'` shows one series and hides the rest, which is the question a
|
|
21
|
+
* reader of a crowded chart actually asks — "show me only this" takes one action instead of one
|
|
22
|
+
* per series. `'toggle'` hides one and leaves the rest, for taking a dominant series out so the
|
|
23
|
+
* others can be read at a usable scale.
|
|
24
|
+
*
|
|
25
|
+
* The two are different controls, not two styles of one: isolate is a single choice among many,
|
|
26
|
+
* so it renders as a radio group with an "All" option, and toggle renders as checkboxes. That is
|
|
27
|
+
* what gives each the keyboard and screen-reader behaviour it should have. */
|
|
28
|
+
mode = input('isolate', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
|
|
19
29
|
/** The item under the pointer or holding focus, which is what the chart dims from. */
|
|
20
30
|
highlighted = model(null, ...(ngDevMode ? [{ debugName: "highlighted" }] : /* istanbul ignore next */ []));
|
|
21
31
|
isHidden(id) {
|
|
@@ -27,13 +37,45 @@ class ChartLegendComponent {
|
|
|
27
37
|
? hidden.filter((entry) => entry !== id)
|
|
28
38
|
: [...hidden, id]);
|
|
29
39
|
}
|
|
40
|
+
/** Radio groups are scoped by NAME across the whole document, so a shared name would make every
|
|
41
|
+
* legend on a page one group: choosing a series in one chart would clear the choice in all the
|
|
42
|
+
* others, and only the last one rendered would show a selection at all. */
|
|
43
|
+
groupName = nextControlId('ds-chart-legend');
|
|
44
|
+
/** Which radio is on: an item's id, or the two ends of the range. Always one of them, so the
|
|
45
|
+
* group is never a set of empty circles with nothing chosen — a radio group with no selection
|
|
46
|
+
* reads as broken, and the reader cannot tell "everything" from "not decided yet".
|
|
47
|
+
*
|
|
48
|
+
* A partial set left over from `'toggle'` — some hidden, more than one visible — is not a state
|
|
49
|
+
* isolate can express, so it settles on `'all'` and the next choice makes it true. */
|
|
50
|
+
isolated = computed(() => {
|
|
51
|
+
const items = this.items();
|
|
52
|
+
const visible = items.filter((item) => !this.isHidden(item.id));
|
|
53
|
+
if (visible.length === 0 && items.length > 0) {
|
|
54
|
+
return 'none';
|
|
55
|
+
}
|
|
56
|
+
if (visible.length === 1) {
|
|
57
|
+
return visible[0].id;
|
|
58
|
+
}
|
|
59
|
+
return 'all';
|
|
60
|
+
}, ...(ngDevMode ? [{ debugName: "isolated" }] : /* istanbul ignore next */ []));
|
|
61
|
+
isolate(id) {
|
|
62
|
+
this.hidden.set(this.items()
|
|
63
|
+
.filter((item) => item.id !== id)
|
|
64
|
+
.map((item) => item.id));
|
|
65
|
+
}
|
|
66
|
+
showAll() {
|
|
67
|
+
this.hidden.set([]);
|
|
68
|
+
}
|
|
69
|
+
hideAll() {
|
|
70
|
+
this.hidden.set(this.items().map((item) => item.id));
|
|
71
|
+
}
|
|
30
72
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChartLegendComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
31
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ChartLegendComponent, isStandalone: true, selector: "ds-chart-legend", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, hidden: { classPropertyName: "hidden", publicName: "hidden", isSignal: true, isRequired: false, transformFunction: null }, toggleable: { classPropertyName: "toggleable", publicName: "toggleable", isSignal: true, isRequired: false, transformFunction: null }, highlighted: { classPropertyName: "highlighted", publicName: "highlighted", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hidden: "hiddenChange", highlighted: "highlightedChange" }, ngImport: i0, template: "<ul class=\"legend\">\n @for (item of items(); track item.id) {\n <li\n class=\"legend-item\"\n [class.is-hidden]=\"isHidden(item.id)\"\n (pointerenter)=\"highlighted.set(item.id)\"\n (pointerleave)=\"highlighted.set(null)\">\n @if (toggleable()) {\n <label class=\"legend-toggle\">\n <input\n type=\"checkbox\"\n class=\"legend-check\"\n animate.enter=\"mark-enter\"\n [checked]=\"!isHidden(item.id)\"\n [style.--ds-checkbox-selected-bg-color]=\"item.color\"\n [style.--ds-checkbox-selected-border-color]=\"item.color\"\n (change)=\"toggle(item.id)\"\n (focus)=\"highlighted.set(item.id)\"\n (blur)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n </label>\n } @else {\n <span\n class=\"legend-swatch\"\n animate.enter=\"mark-enter\"\n aria-hidden=\"true\"\n [style.background]=\"item.color\">\n </span>\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n }\n </li>\n }\n</ul>\n", styles: ["@charset \"UTF-8\";@keyframes ds-chart-mark-grow-y{0%{opacity:0;transform:scaleY(0)}}@keyframes ds-chart-mark-grow-x{0%{opacity:0;transform:scaleX(0)}}@keyframes ds-chart-mark-fade-in{0%{opacity:0}}@keyframes ds-chart-mark-exit{to{opacity:0}}.legend-swatch.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-swatch.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}.legend-check.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-check.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}:host{display:block}.legend{display:flex;flex-wrap:wrap;gap:var(--space-2) var(--space-4);margin:var(--space-3) 0 0;padding:0;list-style:none}.legend-item{display:inline-flex;gap:var(--space-2);align-items:center;color:var(--text-secondary);font-size:var(--font-size-xs)}.legend-toggle{display:inline-flex;gap:var(--space-2);align-items:center;cursor:pointer}.legend-check{appearance:none;width:var(--_checkbox-glyph, var(--check-size));height:var(--_checkbox-glyph, var(--check-size));border:var(--check-bw) solid var(--_checkbox-border, var(--ds-checkbox-border-color, var(--border-strong)));background:var(--_checkbox-bg, var(--ds-checkbox-bg-color, var(--surface-default)));cursor:pointer;display:inline-grid;place-items:center;vertical-align:middle;flex-shrink:0;margin:0;border-radius:var(--_checkbox-radius, var(--ds-checkbox-radius, var(--ds-radius-inner)));transition:background-color var(--duration-fast) var(--ease-standard),border-color var(--duration-fast) var(--ease-standard)}.legend-check:hover:not(:disabled){border-color:var(--_checkbox-hover-border, var(--ds-checkbox-hover-border-color, var(--accent)))}.legend-check:active:not(:disabled,[disabled],.is-disabled){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.legend-check:disabled{background:var(--surface-disabled);border-color:var(--border-disabled);cursor:not-allowed}.legend-check{color:var(--icon-on-primary)}.legend-check:after{content:\"\";--_check-mark-enter-duration: var(--ds-check-mark-enter-duration, var(--ds-motion-check-enter-duration));--_check-mark-enter-easing: var(--ds-check-mark-enter-easing, var(--ds-motion-check-enter-easing));--_check-mark-exit-duration: var(--ds-check-mark-exit-duration, var(--ds-motion-check-exit-duration));--_check-mark-exit-easing: var(--ds-check-mark-exit-easing, var(--ds-motion-check-exit-easing));width:var(--check-tick-size);height:var(--check-tick-size);transform:scale(.6);opacity:0;transform-origin:center;transition:transform var(--_check-mark-exit-duration) var(--_check-mark-exit-easing),opacity var(--_check-mark-exit-duration) var(--_check-mark-exit-easing);background-color:currentcolor}@media(forced-colors:active){.legend-check:after{background-color:CanvasText}}.legend-check:after{-webkit-mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat;mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat}.legend-check:checked{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-check:checked:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing)}.legend-check:indeterminate{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-check:indeterminate:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing);width:var(--check-indet-w);height:var(--check-indet-h);border-radius:var(--ds-radius-inner);-webkit-mask:none;mask:none}.legend-swatch{flex:none;inline-size:var(--space-2-5);block-size:var(--space-2-5);border-radius:var(--radius-pill)}.legend-label{transition:color var(--ds-motion-chart-state-duration) var(--ds-motion-chart-state-easing)}.legend-item.is-hidden .legend-label{color:var(--text-disabled)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
73
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ChartLegendComponent, isStandalone: true, selector: "ds-chart-legend", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, hidden: { classPropertyName: "hidden", publicName: "hidden", isSignal: true, isRequired: false, transformFunction: null }, toggleable: { classPropertyName: "toggleable", publicName: "toggleable", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, highlighted: { classPropertyName: "highlighted", publicName: "highlighted", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { hidden: "hiddenChange", highlighted: "highlightedChange" }, ngImport: i0, template: "<ul class=\"legend\">\n @if (toggleable() && mode() === 'isolate') {\n <li class=\"legend-item\">\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === 'all'\"\n (change)=\"showAll()\"\n (focus)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n All\n </span>\n </label>\n </li>\n }\n\n @for (item of items(); track item.id) {\n <li\n class=\"legend-item\"\n [class.is-hidden]=\"isHidden(item.id)\"\n (pointerenter)=\"highlighted.set(item.id)\"\n (pointerleave)=\"highlighted.set(null)\">\n @if (toggleable() && mode() === 'isolate') {\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n animate.enter=\"mark-enter\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === item.id\"\n [style.--ds-checkbox-selected-bg-color]=\"item.color\"\n [style.--ds-checkbox-selected-border-color]=\"item.color\"\n (change)=\"isolate(item.id)\"\n (focus)=\"highlighted.set(item.id)\"\n (blur)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n </label>\n } @else if (toggleable()) {\n <label class=\"legend-toggle\">\n <input\n type=\"checkbox\"\n class=\"legend-check\"\n animate.enter=\"mark-enter\"\n [checked]=\"!isHidden(item.id)\"\n [style.--ds-checkbox-selected-bg-color]=\"item.color\"\n [style.--ds-checkbox-selected-border-color]=\"item.color\"\n (change)=\"toggle(item.id)\"\n (focus)=\"highlighted.set(item.id)\"\n (blur)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n </label>\n } @else {\n <span\n class=\"legend-swatch\"\n animate.enter=\"mark-enter\"\n aria-hidden=\"true\"\n [style.background]=\"item.color\">\n </span>\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n }\n </li>\n }\n\n @if (toggleable() && mode() === 'isolate') {\n <li class=\"legend-item\">\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === 'none'\"\n (change)=\"hideAll()\"\n (focus)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n None\n </span>\n </label>\n </li>\n }\n</ul>\n", styles: ["@charset \"UTF-8\";@keyframes ds-chart-mark-grow-y{0%{opacity:0;transform:scaleY(0)}}@keyframes ds-chart-mark-grow-x{0%{opacity:0;transform:scaleX(0)}}@keyframes ds-chart-mark-fade-in{0%{opacity:0}}@keyframes ds-chart-mark-exit{to{opacity:0}}.legend-swatch.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-swatch.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}.legend-check.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-check.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}.legend-radio.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-radio.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}:host{display:block}.legend{display:flex;flex-wrap:wrap;gap:var(--space-2) var(--space-4);margin:var(--space-3) 0 0;padding:0;list-style:none}.legend-item{display:inline-flex;gap:var(--space-2);align-items:center;color:var(--text-secondary);font-size:var(--font-size-xs)}.legend-toggle{display:inline-flex;gap:var(--space-2);align-items:center;cursor:pointer}.legend-check{appearance:none;width:var(--_checkbox-glyph, var(--check-size));height:var(--_checkbox-glyph, var(--check-size));border:var(--check-bw) solid var(--_checkbox-border, var(--ds-checkbox-border-color, var(--border-strong)));background:var(--_checkbox-bg, var(--ds-checkbox-bg-color, var(--surface-default)));cursor:pointer;display:inline-grid;place-items:center;vertical-align:middle;flex-shrink:0;margin:0;border-radius:var(--_checkbox-radius, var(--ds-checkbox-radius, var(--ds-radius-inner)));transition:background-color var(--duration-fast) var(--ease-standard),border-color var(--duration-fast) var(--ease-standard)}.legend-check:hover:not(:disabled){border-color:var(--_checkbox-hover-border, var(--ds-checkbox-hover-border-color, var(--accent)))}.legend-check:active:not(:disabled,[disabled],.is-disabled){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.legend-check:disabled{background:var(--surface-disabled);border-color:var(--border-disabled);cursor:not-allowed}.legend-check{color:var(--icon-on-primary)}.legend-check:after{content:\"\";--_check-mark-enter-duration: var(--ds-check-mark-enter-duration, var(--ds-motion-check-enter-duration));--_check-mark-enter-easing: var(--ds-check-mark-enter-easing, var(--ds-motion-check-enter-easing));--_check-mark-exit-duration: var(--ds-check-mark-exit-duration, var(--ds-motion-check-exit-duration));--_check-mark-exit-easing: var(--ds-check-mark-exit-easing, var(--ds-motion-check-exit-easing));width:var(--check-tick-size);height:var(--check-tick-size);transform:scale(.6);opacity:0;transform-origin:center;transition:transform var(--_check-mark-exit-duration) var(--_check-mark-exit-easing),opacity var(--_check-mark-exit-duration) var(--_check-mark-exit-easing);background-color:currentcolor}@media(forced-colors:active){.legend-check:after{background-color:CanvasText}}.legend-check:after{-webkit-mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat;mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat}.legend-check:checked{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-check:checked:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing)}.legend-check:indeterminate{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-check:indeterminate:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing);width:var(--check-indet-w);height:var(--check-indet-h);border-radius:var(--ds-radius-inner);-webkit-mask:none;mask:none}.legend-radio{appearance:none;width:var(--_checkbox-glyph, var(--check-size));height:var(--_checkbox-glyph, var(--check-size));border:var(--check-bw) solid var(--_checkbox-border, var(--ds-checkbox-border-color, var(--border-strong)));background:var(--_checkbox-bg, var(--ds-checkbox-bg-color, var(--surface-default)));cursor:pointer;display:inline-grid;place-items:center;vertical-align:middle;flex-shrink:0;margin:0;border-radius:var(--_checkbox-radius, var(--ds-checkbox-radius, var(--ds-radius-inner)));transition:background-color var(--duration-fast) var(--ease-standard),border-color var(--duration-fast) var(--ease-standard)}.legend-radio:hover:not(:disabled){border-color:var(--_checkbox-hover-border, var(--ds-checkbox-hover-border-color, var(--accent)))}.legend-radio:active:not(:disabled,[disabled],.is-disabled){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.legend-radio:disabled{background:var(--surface-disabled);border-color:var(--border-disabled);cursor:not-allowed}.legend-radio{color:var(--icon-on-primary)}.legend-radio:after{content:\"\";--_check-mark-enter-duration: var(--ds-check-mark-enter-duration, var(--ds-motion-check-enter-duration));--_check-mark-enter-easing: var(--ds-check-mark-enter-easing, var(--ds-motion-check-enter-easing));--_check-mark-exit-duration: var(--ds-check-mark-exit-duration, var(--ds-motion-check-exit-duration));--_check-mark-exit-easing: var(--ds-check-mark-exit-easing, var(--ds-motion-check-exit-easing));width:var(--check-tick-size);height:var(--check-tick-size);transform:scale(.6);opacity:0;transform-origin:center;transition:transform var(--_check-mark-exit-duration) var(--_check-mark-exit-easing),opacity var(--_check-mark-exit-duration) var(--_check-mark-exit-easing);background-color:currentcolor}@media(forced-colors:active){.legend-radio:after{background-color:CanvasText}}.legend-radio:after{-webkit-mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat;mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat}.legend-radio:checked{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-radio:checked:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing)}.legend-radio:indeterminate{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-radio:indeterminate:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing);width:var(--check-indet-w);height:var(--check-indet-h);border-radius:var(--ds-radius-inner);-webkit-mask:none;mask:none}.legend-radio{border-radius:var(--radius-pill)}.legend-swatch{flex:none;inline-size:var(--space-2-5);block-size:var(--space-2-5);border-radius:var(--radius-pill)}.legend-label{transition:color var(--ds-motion-chart-state-duration) var(--ds-motion-chart-state-easing)}.legend-item.is-hidden .legend-label{color:var(--text-disabled)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
32
74
|
}
|
|
33
75
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChartLegendComponent, decorators: [{
|
|
34
76
|
type: Component,
|
|
35
|
-
args: [{ selector: 'ds-chart-legend', standalone: true, encapsulation: ViewEncapsulation.Emulated, changeDetection: ChangeDetectionStrategy.OnPush, template: "<ul class=\"legend\">\n @for (item of items(); track item.id) {\n <li\n class=\"legend-item\"\n [class.is-hidden]=\"isHidden(item.id)\"\n (pointerenter)=\"highlighted.set(item.id)\"\n (pointerleave)=\"highlighted.set(null)\">\n @if (toggleable()) {\n <label class=\"legend-toggle\">\n <input\n type=\"checkbox\"\n class=\"legend-check\"\n animate.enter=\"mark-enter\"\n [checked]=\"!isHidden(item.id)\"\n [style.--ds-checkbox-selected-bg-color]=\"item.color\"\n [style.--ds-checkbox-selected-border-color]=\"item.color\"\n (change)=\"toggle(item.id)\"\n (focus)=\"highlighted.set(item.id)\"\n (blur)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n </label>\n } @else {\n <span\n class=\"legend-swatch\"\n animate.enter=\"mark-enter\"\n aria-hidden=\"true\"\n [style.background]=\"item.color\">\n </span>\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n }\n </li>\n }\n</ul>\n", styles: ["@charset \"UTF-8\";@keyframes ds-chart-mark-grow-y{0%{opacity:0;transform:scaleY(0)}}@keyframes ds-chart-mark-grow-x{0%{opacity:0;transform:scaleX(0)}}@keyframes ds-chart-mark-fade-in{0%{opacity:0}}@keyframes ds-chart-mark-exit{to{opacity:0}}.legend-swatch.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-swatch.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}.legend-check.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-check.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}:host{display:block}.legend{display:flex;flex-wrap:wrap;gap:var(--space-2) var(--space-4);margin:var(--space-3) 0 0;padding:0;list-style:none}.legend-item{display:inline-flex;gap:var(--space-2);align-items:center;color:var(--text-secondary);font-size:var(--font-size-xs)}.legend-toggle{display:inline-flex;gap:var(--space-2);align-items:center;cursor:pointer}.legend-check{appearance:none;width:var(--_checkbox-glyph, var(--check-size));height:var(--_checkbox-glyph, var(--check-size));border:var(--check-bw) solid var(--_checkbox-border, var(--ds-checkbox-border-color, var(--border-strong)));background:var(--_checkbox-bg, var(--ds-checkbox-bg-color, var(--surface-default)));cursor:pointer;display:inline-grid;place-items:center;vertical-align:middle;flex-shrink:0;margin:0;border-radius:var(--_checkbox-radius, var(--ds-checkbox-radius, var(--ds-radius-inner)));transition:background-color var(--duration-fast) var(--ease-standard),border-color var(--duration-fast) var(--ease-standard)}.legend-check:hover:not(:disabled){border-color:var(--_checkbox-hover-border, var(--ds-checkbox-hover-border-color, var(--accent)))}.legend-check:active:not(:disabled,[disabled],.is-disabled){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.legend-check:disabled{background:var(--surface-disabled);border-color:var(--border-disabled);cursor:not-allowed}.legend-check{color:var(--icon-on-primary)}.legend-check:after{content:\"\";--_check-mark-enter-duration: var(--ds-check-mark-enter-duration, var(--ds-motion-check-enter-duration));--_check-mark-enter-easing: var(--ds-check-mark-enter-easing, var(--ds-motion-check-enter-easing));--_check-mark-exit-duration: var(--ds-check-mark-exit-duration, var(--ds-motion-check-exit-duration));--_check-mark-exit-easing: var(--ds-check-mark-exit-easing, var(--ds-motion-check-exit-easing));width:var(--check-tick-size);height:var(--check-tick-size);transform:scale(.6);opacity:0;transform-origin:center;transition:transform var(--_check-mark-exit-duration) var(--_check-mark-exit-easing),opacity var(--_check-mark-exit-duration) var(--_check-mark-exit-easing);background-color:currentcolor}@media(forced-colors:active){.legend-check:after{background-color:CanvasText}}.legend-check:after{-webkit-mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat;mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat}.legend-check:checked{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-check:checked:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing)}.legend-check:indeterminate{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-check:indeterminate:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing);width:var(--check-indet-w);height:var(--check-indet-h);border-radius:var(--ds-radius-inner);-webkit-mask:none;mask:none}.legend-swatch{flex:none;inline-size:var(--space-2-5);block-size:var(--space-2-5);border-radius:var(--radius-pill)}.legend-label{transition:color var(--ds-motion-chart-state-duration) var(--ds-motion-chart-state-easing)}.legend-item.is-hidden .legend-label{color:var(--text-disabled)}\n"] }]
|
|
36
|
-
}], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: true }] }], hidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "hidden", required: false }] }, { type: i0.Output, args: ["hiddenChange"] }], toggleable: [{ type: i0.Input, args: [{ isSignal: true, alias: "toggleable", required: false }] }], highlighted: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlighted", required: false }] }, { type: i0.Output, args: ["highlightedChange"] }] } });
|
|
77
|
+
args: [{ selector: 'ds-chart-legend', standalone: true, encapsulation: ViewEncapsulation.Emulated, changeDetection: ChangeDetectionStrategy.OnPush, template: "<ul class=\"legend\">\n @if (toggleable() && mode() === 'isolate') {\n <li class=\"legend-item\">\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === 'all'\"\n (change)=\"showAll()\"\n (focus)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n All\n </span>\n </label>\n </li>\n }\n\n @for (item of items(); track item.id) {\n <li\n class=\"legend-item\"\n [class.is-hidden]=\"isHidden(item.id)\"\n (pointerenter)=\"highlighted.set(item.id)\"\n (pointerleave)=\"highlighted.set(null)\">\n @if (toggleable() && mode() === 'isolate') {\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n animate.enter=\"mark-enter\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === item.id\"\n [style.--ds-checkbox-selected-bg-color]=\"item.color\"\n [style.--ds-checkbox-selected-border-color]=\"item.color\"\n (change)=\"isolate(item.id)\"\n (focus)=\"highlighted.set(item.id)\"\n (blur)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n </label>\n } @else if (toggleable()) {\n <label class=\"legend-toggle\">\n <input\n type=\"checkbox\"\n class=\"legend-check\"\n animate.enter=\"mark-enter\"\n [checked]=\"!isHidden(item.id)\"\n [style.--ds-checkbox-selected-bg-color]=\"item.color\"\n [style.--ds-checkbox-selected-border-color]=\"item.color\"\n (change)=\"toggle(item.id)\"\n (focus)=\"highlighted.set(item.id)\"\n (blur)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n </label>\n } @else {\n <span\n class=\"legend-swatch\"\n animate.enter=\"mark-enter\"\n aria-hidden=\"true\"\n [style.background]=\"item.color\">\n </span>\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n }\n </li>\n }\n\n @if (toggleable() && mode() === 'isolate') {\n <li class=\"legend-item\">\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === 'none'\"\n (change)=\"hideAll()\"\n (focus)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n None\n </span>\n </label>\n </li>\n }\n</ul>\n", styles: ["@charset \"UTF-8\";@keyframes ds-chart-mark-grow-y{0%{opacity:0;transform:scaleY(0)}}@keyframes ds-chart-mark-grow-x{0%{opacity:0;transform:scaleX(0)}}@keyframes ds-chart-mark-fade-in{0%{opacity:0}}@keyframes ds-chart-mark-exit{to{opacity:0}}.legend-swatch.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-swatch.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}.legend-check.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-check.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}.legend-radio.mark-enter{animation:ds-chart-mark-fade-in var(--ds-motion-chart-mark-enter-duration) var(--ds-motion-chart-mark-enter-easing) calc(var(--ds-motion-chart-mark-exit-duration) + var(--_chart-mark-stagger, 0ms)) both}.legend-radio.mark-leave{animation:ds-chart-mark-exit var(--ds-motion-chart-mark-exit-duration) var(--ds-motion-chart-mark-exit-easing) both}:host{display:block}.legend{display:flex;flex-wrap:wrap;gap:var(--space-2) var(--space-4);margin:var(--space-3) 0 0;padding:0;list-style:none}.legend-item{display:inline-flex;gap:var(--space-2);align-items:center;color:var(--text-secondary);font-size:var(--font-size-xs)}.legend-toggle{display:inline-flex;gap:var(--space-2);align-items:center;cursor:pointer}.legend-check{appearance:none;width:var(--_checkbox-glyph, var(--check-size));height:var(--_checkbox-glyph, var(--check-size));border:var(--check-bw) solid var(--_checkbox-border, var(--ds-checkbox-border-color, var(--border-strong)));background:var(--_checkbox-bg, var(--ds-checkbox-bg-color, var(--surface-default)));cursor:pointer;display:inline-grid;place-items:center;vertical-align:middle;flex-shrink:0;margin:0;border-radius:var(--_checkbox-radius, var(--ds-checkbox-radius, var(--ds-radius-inner)));transition:background-color var(--duration-fast) var(--ease-standard),border-color var(--duration-fast) var(--ease-standard)}.legend-check:hover:not(:disabled){border-color:var(--_checkbox-hover-border, var(--ds-checkbox-hover-border-color, var(--accent)))}.legend-check:active:not(:disabled,[disabled],.is-disabled){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.legend-check:disabled{background:var(--surface-disabled);border-color:var(--border-disabled);cursor:not-allowed}.legend-check{color:var(--icon-on-primary)}.legend-check:after{content:\"\";--_check-mark-enter-duration: var(--ds-check-mark-enter-duration, var(--ds-motion-check-enter-duration));--_check-mark-enter-easing: var(--ds-check-mark-enter-easing, var(--ds-motion-check-enter-easing));--_check-mark-exit-duration: var(--ds-check-mark-exit-duration, var(--ds-motion-check-exit-duration));--_check-mark-exit-easing: var(--ds-check-mark-exit-easing, var(--ds-motion-check-exit-easing));width:var(--check-tick-size);height:var(--check-tick-size);transform:scale(.6);opacity:0;transform-origin:center;transition:transform var(--_check-mark-exit-duration) var(--_check-mark-exit-easing),opacity var(--_check-mark-exit-duration) var(--_check-mark-exit-easing);background-color:currentcolor}@media(forced-colors:active){.legend-check:after{background-color:CanvasText}}.legend-check:after{-webkit-mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat;mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat}.legend-check:checked{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-check:checked:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing)}.legend-check:indeterminate{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-check:indeterminate:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing);width:var(--check-indet-w);height:var(--check-indet-h);border-radius:var(--ds-radius-inner);-webkit-mask:none;mask:none}.legend-radio{appearance:none;width:var(--_checkbox-glyph, var(--check-size));height:var(--_checkbox-glyph, var(--check-size));border:var(--check-bw) solid var(--_checkbox-border, var(--ds-checkbox-border-color, var(--border-strong)));background:var(--_checkbox-bg, var(--ds-checkbox-bg-color, var(--surface-default)));cursor:pointer;display:inline-grid;place-items:center;vertical-align:middle;flex-shrink:0;margin:0;border-radius:var(--_checkbox-radius, var(--ds-checkbox-radius, var(--ds-radius-inner)));transition:background-color var(--duration-fast) var(--ease-standard),border-color var(--duration-fast) var(--ease-standard)}.legend-radio:hover:not(:disabled){border-color:var(--_checkbox-hover-border, var(--ds-checkbox-hover-border-color, var(--accent)))}.legend-radio:active:not(:disabled,[disabled],.is-disabled){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.legend-radio:disabled{background:var(--surface-disabled);border-color:var(--border-disabled);cursor:not-allowed}.legend-radio{color:var(--icon-on-primary)}.legend-radio:after{content:\"\";--_check-mark-enter-duration: var(--ds-check-mark-enter-duration, var(--ds-motion-check-enter-duration));--_check-mark-enter-easing: var(--ds-check-mark-enter-easing, var(--ds-motion-check-enter-easing));--_check-mark-exit-duration: var(--ds-check-mark-exit-duration, var(--ds-motion-check-exit-duration));--_check-mark-exit-easing: var(--ds-check-mark-exit-easing, var(--ds-motion-check-exit-easing));width:var(--check-tick-size);height:var(--check-tick-size);transform:scale(.6);opacity:0;transform-origin:center;transition:transform var(--_check-mark-exit-duration) var(--_check-mark-exit-easing),opacity var(--_check-mark-exit-duration) var(--_check-mark-exit-easing);background-color:currentcolor}@media(forced-colors:active){.legend-radio:after{background-color:CanvasText}}.legend-radio:after{-webkit-mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat;mask:url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2 6.5l2.5 2.5L10 3.5' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\") center/contain no-repeat}.legend-radio:checked{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-radio:checked:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing)}.legend-radio:indeterminate{background:var(--_checkbox-selected-bg, var(--ds-checkbox-selected-bg-color, var(--accent)));border-color:var(--_checkbox-selected-border, var(--ds-checkbox-selected-border-color, var(--accent)))}.legend-radio:indeterminate:after{transform:scale(1);opacity:1;transition:transform var(--_check-mark-enter-duration) var(--_check-mark-enter-easing),opacity var(--_check-mark-enter-duration) var(--_check-mark-enter-easing);width:var(--check-indet-w);height:var(--check-indet-h);border-radius:var(--ds-radius-inner);-webkit-mask:none;mask:none}.legend-radio{border-radius:var(--radius-pill)}.legend-swatch{flex:none;inline-size:var(--space-2-5);block-size:var(--space-2-5);border-radius:var(--radius-pill)}.legend-label{transition:color var(--ds-motion-chart-state-duration) var(--ds-motion-chart-state-easing)}.legend-item.is-hidden .legend-label{color:var(--text-disabled)}\n"] }]
|
|
78
|
+
}], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: true }] }], hidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "hidden", required: false }] }, { type: i0.Output, args: ["hiddenChange"] }], toggleable: [{ type: i0.Input, args: [{ isSignal: true, alias: "toggleable", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], highlighted: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlighted", required: false }] }, { type: i0.Output, args: ["highlightedChange"] }] } });
|
|
37
79
|
|
|
38
80
|
/**
|
|
39
81
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ids-group-ltd-ids-design-system-components-chart-legend.mjs","sources":["../../../src/lib/components/chart-legend/chart-legend.component.ts","../../../src/lib/components/chart-legend/chart-legend.component.html","../../../src/lib/components/chart-legend/ids-group-ltd-ids-design-system-components-chart-legend.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ViewEncapsulation,\n booleanAttribute,\n input,\n model,\n} from '@angular/core';\nimport type { ChartLegendItem } from './chart-legend.types';\n\n/**\n * The key beside a chart, and — when `toggleable` — the control that hides a series.\n *\n * Ordinary DOM, never inside the `<svg>`: an item is a real `<input type=\"checkbox\">`, which is\n * what makes the toggle keyboard-operable and correctly announced without inventing a role.\n *\n * @internal\n */\n@Component({\n selector: 'ds-chart-legend',\n standalone: true,\n templateUrl: './chart-legend.component.html',\n styleUrl: './chart-legend.component.scss',\n encapsulation: ViewEncapsulation.Emulated,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ChartLegendComponent {\n readonly items = input.required<readonly ChartLegendItem[]>();\n\n /** Ids of the hidden items. Two-way, so a page can drive it from a URL parameter and so\n * cross-chart filtering later is this same mechanism. */\n readonly hidden = model<readonly string[]>([]);\n\n /** Offers the
|
|
1
|
+
{"version":3,"file":"ids-group-ltd-ids-design-system-components-chart-legend.mjs","sources":["../../../src/lib/components/chart-legend/chart-legend.component.ts","../../../src/lib/components/chart-legend/chart-legend.component.html","../../../src/lib/components/chart-legend/ids-group-ltd-ids-design-system-components-chart-legend.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n computed,\n ViewEncapsulation,\n booleanAttribute,\n input,\n model,\n} from '@angular/core';\nimport { nextControlId } from '@ids-group-ltd/ids-design-system/components';\nimport type { ChartLegendItem } from './chart-legend.types';\n\n/**\n * The key beside a chart, and — when `toggleable` — the control that hides a series.\n *\n * Ordinary DOM, never inside the `<svg>`: an item is a real `<input type=\"checkbox\">`, which is\n * what makes the toggle keyboard-operable and correctly announced without inventing a role.\n *\n * @internal\n */\n@Component({\n selector: 'ds-chart-legend',\n standalone: true,\n templateUrl: './chart-legend.component.html',\n styleUrl: './chart-legend.component.scss',\n encapsulation: ViewEncapsulation.Emulated,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ChartLegendComponent {\n readonly items = input.required<readonly ChartLegendItem[]>();\n\n /** Ids of the hidden items. Two-way, so a page can drive it from a URL parameter and so\n * cross-chart filtering later is this same mechanism. */\n readonly hidden = model<readonly string[]>([]);\n\n /** Offers the control. Off leaves the legend a plain key. */\n readonly toggleable = input(false, { transform: booleanAttribute });\n\n /** What a control does. `'isolate'` shows one series and hides the rest, which is the question a\n * reader of a crowded chart actually asks — \"show me only this\" takes one action instead of one\n * per series. `'toggle'` hides one and leaves the rest, for taking a dominant series out so the\n * others can be read at a usable scale.\n *\n * The two are different controls, not two styles of one: isolate is a single choice among many,\n * so it renders as a radio group with an \"All\" option, and toggle renders as checkboxes. That is\n * what gives each the keyboard and screen-reader behaviour it should have. */\n readonly mode = input<'toggle' | 'isolate'>('isolate');\n\n /** The item under the pointer or holding focus, which is what the chart dims from. */\n readonly highlighted = model<string | null>(null);\n\n protected isHidden(id: string): boolean {\n return this.hidden().includes(id);\n }\n\n protected toggle(id: string): void {\n const hidden = this.hidden();\n\n this.hidden.set(\n hidden.includes(id)\n ? hidden.filter((entry) => entry !== id)\n : [...hidden, id],\n );\n }\n\n /** Radio groups are scoped by NAME across the whole document, so a shared name would make every\n * legend on a page one group: choosing a series in one chart would clear the choice in all the\n * others, and only the last one rendered would show a selection at all. */\n protected readonly groupName = nextControlId('ds-chart-legend');\n\n /** Which radio is on: an item's id, or the two ends of the range. Always one of them, so the\n * group is never a set of empty circles with nothing chosen — a radio group with no selection\n * reads as broken, and the reader cannot tell \"everything\" from \"not decided yet\".\n *\n * A partial set left over from `'toggle'` — some hidden, more than one visible — is not a state\n * isolate can express, so it settles on `'all'` and the next choice makes it true. */\n protected readonly isolated = computed(() => {\n const items = this.items();\n const visible = items.filter((item) => !this.isHidden(item.id));\n if (visible.length === 0 && items.length > 0) {\n return 'none';\n }\n if (visible.length === 1) {\n return visible[0].id;\n }\n\n return 'all';\n });\n\n protected isolate(id: string): void {\n this.hidden.set(\n this.items()\n .filter((item) => item.id !== id)\n .map((item) => item.id),\n );\n }\n\n protected showAll(): void {\n this.hidden.set([]);\n }\n\n protected hideAll(): void {\n this.hidden.set(this.items().map((item) => item.id));\n }\n}\n","<ul class=\"legend\">\n @if (toggleable() && mode() === 'isolate') {\n <li class=\"legend-item\">\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === 'all'\"\n (change)=\"showAll()\"\n (focus)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n All\n </span>\n </label>\n </li>\n }\n\n @for (item of items(); track item.id) {\n <li\n class=\"legend-item\"\n [class.is-hidden]=\"isHidden(item.id)\"\n (pointerenter)=\"highlighted.set(item.id)\"\n (pointerleave)=\"highlighted.set(null)\">\n @if (toggleable() && mode() === 'isolate') {\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n animate.enter=\"mark-enter\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === item.id\"\n [style.--ds-checkbox-selected-bg-color]=\"item.color\"\n [style.--ds-checkbox-selected-border-color]=\"item.color\"\n (change)=\"isolate(item.id)\"\n (focus)=\"highlighted.set(item.id)\"\n (blur)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n </label>\n } @else if (toggleable()) {\n <label class=\"legend-toggle\">\n <input\n type=\"checkbox\"\n class=\"legend-check\"\n animate.enter=\"mark-enter\"\n [checked]=\"!isHidden(item.id)\"\n [style.--ds-checkbox-selected-bg-color]=\"item.color\"\n [style.--ds-checkbox-selected-border-color]=\"item.color\"\n (change)=\"toggle(item.id)\"\n (focus)=\"highlighted.set(item.id)\"\n (blur)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n </label>\n } @else {\n <span\n class=\"legend-swatch\"\n animate.enter=\"mark-enter\"\n aria-hidden=\"true\"\n [style.background]=\"item.color\">\n </span>\n\n <span class=\"legend-label\">\n {{ item.label }}\n </span>\n }\n </li>\n }\n\n @if (toggleable() && mode() === 'isolate') {\n <li class=\"legend-item\">\n <label class=\"legend-toggle\">\n <input\n type=\"radio\"\n class=\"legend-radio\"\n [attr.name]=\"groupName\"\n [checked]=\"isolated() === 'none'\"\n (change)=\"hideAll()\"\n (focus)=\"highlighted.set(null)\" />\n\n <span class=\"legend-label\">\n None\n </span>\n </label>\n </li>\n }\n</ul>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAYA;;;;;;;AAOG;MASU,oBAAoB,CAAA;AACtB,IAAA,KAAK,GAAG,KAAK,CAAC,QAAQ,2EAA8B;AAE7D;AAC0D;AACjD,IAAA,MAAM,GAAG,KAAK,CAAoB,EAAE,6EAAC;;IAGrC,UAAU,GAAG,KAAK,CAAC,KAAK,kFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAEnE;;;;;;;AAO+E;AACtE,IAAA,IAAI,GAAG,KAAK,CAAuB,SAAS,2EAAC;;AAG7C,IAAA,WAAW,GAAG,KAAK,CAAgB,IAAI,kFAAC;AAEvC,IAAA,QAAQ,CAAC,EAAU,EAAA;QAC3B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC;AAEU,IAAA,MAAM,CAAC,EAAU,EAAA;AACzB,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE;QAE5B,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,MAAM,CAAC,QAAQ,CAAC,EAAE;AAChB,cAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,KAAK,EAAE;cACrC,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC,CACpB;IACH;AAEA;;AAE4E;AACzD,IAAA,SAAS,GAAG,aAAa,CAAC,iBAAiB,CAAC;AAE/D;;;;;AAKuF;AACpE,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAK;AAC1C,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE;QAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/D,QAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;AAC5C,YAAA,OAAO,MAAM;QACf;AACA,QAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AACxB,YAAA,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;QACtB;AAEA,QAAA,OAAO,KAAK;AACd,IAAA,CAAC,+EAAC;AAEQ,IAAA,OAAO,CAAC,EAAU,EAAA;QAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,IAAI,CAAC,KAAK;aACP,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE;aAC/B,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,CAC1B;IACH;IAEU,OAAO,GAAA;AACf,QAAA,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IACrB;IAEU,OAAO,GAAA;QACf,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;IACtD;wGA3EW,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAApB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,oBAAoB,sxBC5BjC,+xFA6FA,EAAA,MAAA,EAAA,CAAA,msRAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FDjEa,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBARhC,SAAS;+BACE,iBAAiB,EAAA,UAAA,EACf,IAAI,EAAA,aAAA,EAGD,iBAAiB,CAAC,QAAQ,EAAA,eAAA,EACxB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,+xFAAA,EAAA,MAAA,EAAA,CAAA,msRAAA,CAAA,EAAA;;;AE1BjD;;AAEG;;;;"}
|
|
@@ -23,28 +23,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImpo
|
|
|
23
23
|
}, encapsulation: ViewEncapsulation.Emulated, changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (template(); as projected) {\n <ng-container\n [ngTemplateOutlet]=\"projected\"\n [ngTemplateOutletContext]=\"{ $implicit: context() }\" />\n} @else {\n @if (context().category) {\n <p class=\"category\">\n {{ context().category }}\n </p>\n }\n\n <ul class=\"entries\">\n @for (entry of context().entries; track entry.label) {\n <li class=\"entry\">\n <span\n class=\"swatch\"\n [style.background]=\"entry.color\">\n </span>\n\n <span class=\"label\">\n {{ entry.label }}\n </span>\n\n <span class=\"value\">\n {{ entry.formatted }}\n </span>\n\n @if (entry.detail) {\n <span class=\"detail\">\n {{ entry.detail }}\n </span>\n }\n </li>\n }\n </ul>\n}\n", styles: [":host{--_chart-tooltip-bg-color: var(--ds-chart-tooltip-bg-color);--_chart-tooltip-text-color: var(--ds-chart-tooltip-text-color);--_chart-tooltip-border-color: var(--ds-chart-tooltip-border-color);display:block;background:var(--_chart-tooltip-bg-color);color:var(--_chart-tooltip-text-color);border:var(--border-width-default) solid var(--_chart-tooltip-border-color);border-radius:var(--ds-radius-control);box-shadow:var(--ds-elevation-overlay);padding:var(--space-2) var(--space-2-5);max-width:var(--tooltip-maxw);z-index:var(--layer-tooltip);font:var(--font-weight-regular) var(--font-size-xs)/var(--line-height-base) var(--font-sans);pointer-events:none}.category{margin:0 0 var(--space-1-5);font-weight:var(--font-weight-medium)}.entries{display:grid;gap:var(--space-1);margin:0;padding:0;list-style:none}.entry{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:var(--space-2)}.detail{grid-column:2/-1;margin-block-start:calc(var(--space-1) * -1);color:var(--_chart-tooltip-text-color);opacity:.7;font-size:var(--font-size-2xs)}.swatch{inline-size:var(--space-2);block-size:var(--space-2);border-radius:var(--radius-pill)}.value{font-variant-numeric:tabular-nums;font-weight:var(--font-weight-medium)}\n"] }]
|
|
24
24
|
}], propDecorators: { context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: true }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }] } });
|
|
25
25
|
|
|
26
|
-
const POINTER_GAP_PX =
|
|
26
|
+
const POINTER_GAP_PX = 6;
|
|
27
27
|
// A fingertip covers roughly 40 CSS px, so a touch-opened panel has to clear the tap
|
|
28
28
|
// point by more than a pointer-opened one does.
|
|
29
29
|
const TOUCH_GAP_PX = 48;
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
|
|
30
|
+
// Four fallbacks are what make the panel flip out of a small dashboard card rather than be
|
|
31
|
+
// clipped by it. Above first, except while a mark is HELD: the Unpin control sits at the plot's
|
|
32
|
+
// top edge, and a panel that opens upward from a mark in the upper half lands on top of it. The
|
|
33
|
+
// panel is portaled to the body, so no z-index can lift the control over it — an app layout that
|
|
34
|
+
// isolates its own stacking context traps the chart's chrome below the overlay whatever number it
|
|
35
|
+
// carries.
|
|
36
|
+
function positionsFor(gap, preferBelow) {
|
|
37
|
+
const above = {
|
|
38
|
+
originX: 'center',
|
|
39
|
+
originY: 'top',
|
|
40
|
+
overlayX: 'center',
|
|
41
|
+
overlayY: 'bottom',
|
|
42
|
+
offsetY: -gap,
|
|
43
|
+
};
|
|
44
|
+
const below = {
|
|
45
|
+
originX: 'center',
|
|
46
|
+
originY: 'bottom',
|
|
47
|
+
overlayX: 'center',
|
|
48
|
+
overlayY: 'top',
|
|
49
|
+
offsetY: gap,
|
|
50
|
+
};
|
|
33
51
|
return [
|
|
34
|
-
|
|
35
|
-
originX: 'center',
|
|
36
|
-
originY: 'top',
|
|
37
|
-
overlayX: 'center',
|
|
38
|
-
overlayY: 'bottom',
|
|
39
|
-
offsetY: -gap,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
originX: 'center',
|
|
43
|
-
originY: 'bottom',
|
|
44
|
-
overlayX: 'center',
|
|
45
|
-
overlayY: 'top',
|
|
46
|
-
offsetY: gap,
|
|
47
|
-
},
|
|
52
|
+
...(preferBelow ? [below, above] : [above, below]),
|
|
48
53
|
{
|
|
49
54
|
originX: 'end',
|
|
50
55
|
originY: 'center',
|
|
@@ -74,9 +79,18 @@ class ChartTooltipDirective {
|
|
|
74
79
|
dsChartTooltip = input(null, ...(ngDevMode ? [{ debugName: "dsChartTooltip" }] : /* istanbul ignore next */ []));
|
|
75
80
|
dsChartTooltipOrigin = input(null, ...(ngDevMode ? [{ debugName: "dsChartTooltipOrigin" }] : /* istanbul ignore next */ []));
|
|
76
81
|
dsChartTooltipTemplate = input(null, ...(ngDevMode ? [{ debugName: "dsChartTooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
82
|
+
/** Extra clearance between the mark and the panel, on top of the pointer default. A chart that
|
|
83
|
+
* prints something ABOVE its mark — a column with its value on top — needs the panel to clear
|
|
84
|
+
* that text as well as the mark, or the two overlap. Ignored for touch, where the gap is already
|
|
85
|
+
* sized for a fingertip. */
|
|
86
|
+
dsChartTooltipExtraGap = input(0, ...(ngDevMode ? [{ debugName: "dsChartTooltipExtraGap" }] : /* istanbul ignore next */ []));
|
|
87
|
+
/** Opens the panel BELOW the mark first. A chart sets it while a mark is held, so the panel
|
|
88
|
+
* leaves the plot's top edge — and the Unpin control that lives there — alone. */
|
|
89
|
+
dsChartTooltipPreferBelow = input(false, ...(ngDevMode ? [{ debugName: "dsChartTooltipPreferBelow" }] : /* istanbul ignore next */ []));
|
|
77
90
|
overlayRef = null;
|
|
78
91
|
panelRef = null;
|
|
79
|
-
|
|
92
|
+
detachScrollReposition = null;
|
|
93
|
+
detachEscape = null;
|
|
80
94
|
constructor() {
|
|
81
95
|
effect(() => {
|
|
82
96
|
const context = this.dsChartTooltip();
|
|
@@ -100,11 +114,11 @@ class ChartTooltipDirective {
|
|
|
100
114
|
});
|
|
101
115
|
this.panelRef = this.overlayRef.attach(new ComponentPortal(ChartTooltipPanelComponent, this.viewContainerRef));
|
|
102
116
|
// CDK's reposition strategy watches `window` and registered `cdkScrollable`s only, so it
|
|
103
|
-
// misses an app's own `overflow: auto` container
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
this.
|
|
117
|
+
// misses an app's own `overflow: auto` container. Moved rather than closed: a PINNED mark
|
|
118
|
+
// stops answering pointer moves, so a close here would be permanent, leaving the pin glyph
|
|
119
|
+
// and the Unpin control standing over a reading that is gone.
|
|
120
|
+
this.detachScrollReposition = closeOnScroll(this.overlayRef, () => this.overlayRef?.updatePosition());
|
|
121
|
+
this.detachEscape = this.closeOnEscape();
|
|
108
122
|
}
|
|
109
123
|
else {
|
|
110
124
|
this.overlayRef.updatePositionStrategy(this.strategyFor(origin));
|
|
@@ -113,23 +127,43 @@ class ChartTooltipDirective {
|
|
|
113
127
|
this.panelRef?.setInput('template', this.dsChartTooltipTemplate());
|
|
114
128
|
}
|
|
115
129
|
strategyFor(origin) {
|
|
116
|
-
const gap = coarsePointer()
|
|
130
|
+
const gap = coarsePointer()
|
|
131
|
+
? TOUCH_GAP_PX
|
|
132
|
+
: POINTER_GAP_PX + this.dsChartTooltipExtraGap();
|
|
117
133
|
return this.overlay
|
|
118
134
|
.position()
|
|
119
135
|
.flexibleConnectedTo(origin)
|
|
120
136
|
.withFlexibleDimensions(false)
|
|
121
137
|
.withPush(true)
|
|
122
|
-
.withPositions(positionsFor(gap));
|
|
138
|
+
.withPositions(positionsFor(gap, this.dsChartTooltipPreferBelow()));
|
|
139
|
+
}
|
|
140
|
+
// WCAG 1.4.13 wants the panel dismissable WITHOUT moving the pointer or the focus, which rules
|
|
141
|
+
// out "move off the mark". Nothing re-opens it afterwards: the effect re-runs on a CHANGE to the
|
|
142
|
+
// context or the origin, and neither changes while the pointer rests where it already is — so the
|
|
143
|
+
// reader keeps the screen they cleared until they visit another mark.
|
|
144
|
+
closeOnEscape() {
|
|
145
|
+
if (typeof document === 'undefined') {
|
|
146
|
+
return () => undefined;
|
|
147
|
+
}
|
|
148
|
+
const onKeydown = (event) => {
|
|
149
|
+
if (event.key === 'Escape') {
|
|
150
|
+
this.close();
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
document.addEventListener('keydown', onKeydown, true);
|
|
154
|
+
return () => document.removeEventListener('keydown', onKeydown, true);
|
|
123
155
|
}
|
|
124
156
|
close() {
|
|
125
|
-
this.
|
|
126
|
-
this.
|
|
157
|
+
this.detachEscape?.();
|
|
158
|
+
this.detachEscape = null;
|
|
159
|
+
this.detachScrollReposition?.();
|
|
160
|
+
this.detachScrollReposition = null;
|
|
127
161
|
this.overlayRef?.dispose();
|
|
128
162
|
this.overlayRef = null;
|
|
129
163
|
this.panelRef = null;
|
|
130
164
|
}
|
|
131
165
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChartTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
132
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.22", type: ChartTooltipDirective, isStandalone: true, selector: "[dsChartTooltip]", inputs: { dsChartTooltip: { classPropertyName: "dsChartTooltip", publicName: "dsChartTooltip", isSignal: true, isRequired: false, transformFunction: null }, dsChartTooltipOrigin: { classPropertyName: "dsChartTooltipOrigin", publicName: "dsChartTooltipOrigin", isSignal: true, isRequired: false, transformFunction: null }, dsChartTooltipTemplate: { classPropertyName: "dsChartTooltipTemplate", publicName: "dsChartTooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
166
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.22", type: ChartTooltipDirective, isStandalone: true, selector: "[dsChartTooltip]", inputs: { dsChartTooltip: { classPropertyName: "dsChartTooltip", publicName: "dsChartTooltip", isSignal: true, isRequired: false, transformFunction: null }, dsChartTooltipOrigin: { classPropertyName: "dsChartTooltipOrigin", publicName: "dsChartTooltipOrigin", isSignal: true, isRequired: false, transformFunction: null }, dsChartTooltipTemplate: { classPropertyName: "dsChartTooltipTemplate", publicName: "dsChartTooltipTemplate", isSignal: true, isRequired: false, transformFunction: null }, dsChartTooltipExtraGap: { classPropertyName: "dsChartTooltipExtraGap", publicName: "dsChartTooltipExtraGap", isSignal: true, isRequired: false, transformFunction: null }, dsChartTooltipPreferBelow: { classPropertyName: "dsChartTooltipPreferBelow", publicName: "dsChartTooltipPreferBelow", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
133
167
|
}
|
|
134
168
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ChartTooltipDirective, decorators: [{
|
|
135
169
|
type: Directive,
|
|
@@ -137,7 +171,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImpo
|
|
|
137
171
|
selector: '[dsChartTooltip]',
|
|
138
172
|
standalone: true,
|
|
139
173
|
}]
|
|
140
|
-
}], ctorParameters: () => [], propDecorators: { dsChartTooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "dsChartTooltip", required: false }] }], dsChartTooltipOrigin: [{ type: i0.Input, args: [{ isSignal: true, alias: "dsChartTooltipOrigin", required: false }] }], dsChartTooltipTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "dsChartTooltipTemplate", required: false }] }] } });
|
|
174
|
+
}], ctorParameters: () => [], propDecorators: { dsChartTooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "dsChartTooltip", required: false }] }], dsChartTooltipOrigin: [{ type: i0.Input, args: [{ isSignal: true, alias: "dsChartTooltipOrigin", required: false }] }], dsChartTooltipTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "dsChartTooltipTemplate", required: false }] }], dsChartTooltipExtraGap: [{ type: i0.Input, args: [{ isSignal: true, alias: "dsChartTooltipExtraGap", required: false }] }], dsChartTooltipPreferBelow: [{ type: i0.Input, args: [{ isSignal: true, alias: "dsChartTooltipPreferBelow", required: false }] }] } });
|
|
141
175
|
function coarsePointer() {
|
|
142
176
|
return (typeof window !== 'undefined' &&
|
|
143
177
|
window.matchMedia('(pointer: coarse)').matches);
|
|
@@ -154,52 +188,166 @@ function coarsePointer() {
|
|
|
154
188
|
*
|
|
155
189
|
* @internal
|
|
156
190
|
*/
|
|
157
|
-
function chartActiveMark() {
|
|
191
|
+
function chartActiveMark(lingerMs = () => 0) {
|
|
158
192
|
const index = signal(-1, ...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
159
193
|
const origin = signal(null, ...(ngDevMode ? [{ debugName: "origin" }] : /* istanbul ignore next */ []));
|
|
160
|
-
|
|
194
|
+
// One flag for two ways of arriving at the same state: a tap, which has no hover to hold the
|
|
195
|
+
// panel open, and a deliberate click under `pinOnClick`. Both release the same way.
|
|
196
|
+
const pinned = signal(false, ...(ngDevMode ? [{ debugName: "pinned" }] : /* istanbul ignore next */ []));
|
|
197
|
+
let pendingClear = null;
|
|
198
|
+
// The element that OWNS the handlers, which is not always the tooltip anchor: a column anchors
|
|
199
|
+
// its panel to the bar while the whole cell answers the pointer. A press is "outside" only when
|
|
200
|
+
// it misses this, or a click on the cell beside the bar would release the pin and immediately
|
|
201
|
+
// re-take it, leaving the pin looking stuck.
|
|
202
|
+
let host = null;
|
|
161
203
|
const clear = () => {
|
|
162
|
-
|
|
204
|
+
pinned.set(false);
|
|
205
|
+
host = null;
|
|
206
|
+
cancelPendingClear();
|
|
163
207
|
index.set(-1);
|
|
164
208
|
origin.set(null);
|
|
165
209
|
document.removeEventListener('pointerdown', release, true);
|
|
210
|
+
document.removeEventListener('keydown', releaseOnEscape, true);
|
|
211
|
+
document.removeEventListener('pointerover', trackPointer, true);
|
|
212
|
+
};
|
|
213
|
+
// The tooltip anchors to the MARK, not to the box that catches the pointer: a column's cell is
|
|
214
|
+
// the full plot height, so anchoring to it opens the panel at the top of the chart rather than
|
|
215
|
+
// over the column it is about. A selector is resolved INSIDE the box; a legend item's mark is not
|
|
216
|
+
// inside it, so that caller passes the element.
|
|
217
|
+
const aim = (at, event, anchor) => {
|
|
218
|
+
const target = event.currentTarget;
|
|
219
|
+
if (target instanceof Element) {
|
|
220
|
+
host = target;
|
|
221
|
+
const mark = typeof anchor === 'string' ? target.querySelector(anchor) : anchor;
|
|
222
|
+
origin.set(mark ?? target);
|
|
223
|
+
}
|
|
224
|
+
index.set(at);
|
|
225
|
+
};
|
|
226
|
+
const hold = () => {
|
|
227
|
+
pinned.set(true);
|
|
228
|
+
cancelPendingClear();
|
|
229
|
+
document.addEventListener('pointerdown', release, true);
|
|
230
|
+
document.addEventListener('keydown', releaseOnEscape, true);
|
|
231
|
+
};
|
|
232
|
+
// Escape releases the mark as well as the panel. Without this the panel would go and the dimming
|
|
233
|
+
// it caused would stay, leaving the chart in a state with nothing on screen explaining it.
|
|
234
|
+
const releaseOnEscape = (event) => {
|
|
235
|
+
if (event.key === 'Escape') {
|
|
236
|
+
clear();
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const cancelPendingClear = () => {
|
|
240
|
+
if (pendingClear !== null) {
|
|
241
|
+
clearTimeout(pendingClear);
|
|
242
|
+
pendingClear = null;
|
|
243
|
+
}
|
|
166
244
|
};
|
|
245
|
+
const scheduleClear = () => {
|
|
246
|
+
cancelPendingClear();
|
|
247
|
+
pendingClear = setTimeout(() => {
|
|
248
|
+
pendingClear = null;
|
|
249
|
+
index.set(-1);
|
|
250
|
+
origin.set(null);
|
|
251
|
+
document.removeEventListener('pointerover', trackPointer, true);
|
|
252
|
+
}, Math.max(lingerMs(), 0));
|
|
253
|
+
};
|
|
254
|
+
// One listener answers both halves of "is the pointer on the panel": `pointerover` fires on every
|
|
255
|
+
// element the pointer crosses, so arriving on the panel cancels the clear and leaving it for
|
|
256
|
+
// anything that is not the mark schedules a new one. Without the second half a panel the pointer
|
|
257
|
+
// once touched would never close, because the mark's own `pointerleave` has already fired.
|
|
258
|
+
const trackPointer = (event) => {
|
|
259
|
+
if (!(event.target instanceof Element)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (pinned() || event.target.closest('.ds-chart-tooltip-pane')) {
|
|
263
|
+
cancelPendingClear();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
// Against the HOST, not the anchor: a legend item and the arc its panel points at are disjoint
|
|
267
|
+
// elements, so testing the anchor would clear the panel the moment the pointer moved inside the
|
|
268
|
+
// legend item that opened it.
|
|
269
|
+
if (!host || !host.contains(event.target)) {
|
|
270
|
+
scheduleClear();
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
// The chart the aimed mark belongs to. Every chart puts its plot in one `<figure>`, so this is
|
|
274
|
+
// what tells "pressed another mark of the same chart" apart from "pressed away".
|
|
275
|
+
const chartOf = (element) => element ? element.closest('figure') : null;
|
|
167
276
|
const release = (event) => {
|
|
168
|
-
|
|
169
|
-
|
|
277
|
+
if (!(event.target instanceof Element)) {
|
|
278
|
+
clear();
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (host && host.contains(event.target)) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
// Hopping the pin from one mark to the next must not pass through "nothing is pinned". This
|
|
285
|
+
// handler runs on `pointerdown`, the re-aim on the `click` after it, so clearing here would
|
|
286
|
+
// unmount the Unpin control and the pinned styling for a frame and mount them again — a
|
|
287
|
+
// flicker on every hop. The press is a re-aim when it lands on another mark of the same chart.
|
|
288
|
+
const pressedMark = event.target.closest('[data-mark-index]');
|
|
289
|
+
if (pressedMark && chartOf(pressedMark) === chartOf(host)) {
|
|
170
290
|
return;
|
|
171
291
|
}
|
|
172
292
|
clear();
|
|
173
293
|
};
|
|
174
294
|
if (typeof document !== 'undefined') {
|
|
175
|
-
inject(DestroyRef).onDestroy(() =>
|
|
295
|
+
inject(DestroyRef).onDestroy(() => {
|
|
296
|
+
cancelPendingClear();
|
|
297
|
+
document.removeEventListener('pointerdown', release, true);
|
|
298
|
+
document.removeEventListener('pointerover', trackPointer, true);
|
|
299
|
+
});
|
|
176
300
|
}
|
|
177
301
|
return {
|
|
178
302
|
index: index.asReadonly(),
|
|
179
303
|
origin: origin.asReadonly(),
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
304
|
+
pinned: pinned.asReadonly(),
|
|
305
|
+
enter(at, event, anchor) {
|
|
306
|
+
// A pin HOLDS. Without this the next mark the pointer crossed took the active slot straight
|
|
307
|
+
// back, so pinning appeared to work and then followed the pointer anyway — the one thing a
|
|
308
|
+
// pin exists not to do. It is released by Escape, or by a press outside the pinned mark.
|
|
309
|
+
if (pinned()) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
aim(at, event, anchor);
|
|
313
|
+
cancelPendingClear();
|
|
314
|
+
if (typeof document !== 'undefined') {
|
|
315
|
+
document.addEventListener('pointerover', trackPointer, true);
|
|
188
316
|
}
|
|
189
|
-
index.set(at);
|
|
190
317
|
if (typeof document !== 'undefined' &&
|
|
191
318
|
event instanceof PointerEvent &&
|
|
192
319
|
event.pointerType === 'touch') {
|
|
193
|
-
|
|
194
|
-
document.addEventListener('pointerdown', release, true);
|
|
320
|
+
hold();
|
|
195
321
|
}
|
|
196
322
|
},
|
|
197
323
|
leave() {
|
|
198
|
-
if (
|
|
324
|
+
if (pinned()) {
|
|
199
325
|
return;
|
|
200
326
|
}
|
|
201
|
-
|
|
202
|
-
|
|
327
|
+
scheduleClear();
|
|
328
|
+
},
|
|
329
|
+
release() {
|
|
330
|
+
if (typeof document !== 'undefined') {
|
|
331
|
+
clear();
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
pin(at, event, anchor) {
|
|
335
|
+
if (typeof document === 'undefined') {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
// The same gesture that set the pin clears it. A press on a DIFFERENT mark has already gone
|
|
339
|
+
// through `release` by the time the click lands, so this only ever sees a fresh mark or the
|
|
340
|
+
// pinned one.
|
|
341
|
+
if (pinned() && index() === at) {
|
|
342
|
+
clear();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
// Re-aiming while already pinned keeps `pinned` true throughout, so nothing that renders on
|
|
346
|
+
// it — the Unpin control, the held mark's styling — unmounts between the two marks.
|
|
347
|
+
aim(at, event, anchor);
|
|
348
|
+
if (!pinned()) {
|
|
349
|
+
hold();
|
|
350
|
+
}
|
|
203
351
|
},
|
|
204
352
|
};
|
|
205
353
|
}
|