@masmarino/gabarit 0.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/ACCESSIBILITY.md +216 -0
- package/LICENSE +21 -0
- package/README.md +188 -0
- package/fesm2022/masmarino-gabarit.mjs +2398 -0
- package/fesm2022/masmarino-gabarit.mjs.map +1 -0
- package/package.json +49 -0
- package/src/lib/tokens/_palette.scss +58 -0
- package/src/lib/tokens/_semantic.scss +114 -0
- package/src/lib/tokens/_utilities.scss +145 -0
- package/src/lib/tokens/index.scss +3 -0
- package/types/masmarino-gabarit.d.ts +786 -0
|
@@ -0,0 +1,2398 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, inject, input, computed, ChangeDetectionStrategy, Component, signal, viewChild, HostListener, booleanAttribute, output, forwardRef, ElementRef, effect, contentChildren, viewChildren, InjectionToken, isDevMode, Injector, afterNextRender } from '@angular/core';
|
|
3
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
4
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
5
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
6
|
+
|
|
7
|
+
const GABARIT_VERSION = '0.1.0';
|
|
8
|
+
|
|
9
|
+
const BUILT_IN_ICONS = {
|
|
10
|
+
search: `<path d="m21 21-4.34-4.34" />
|
|
11
|
+
<circle cx="11" cy="11" r="8" />`,
|
|
12
|
+
x: `<path d="M18 6 6 18" />
|
|
13
|
+
<path d="m6 6 12 12" />`,
|
|
14
|
+
eye: `<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" />
|
|
15
|
+
<circle cx="12" cy="12" r="3" />`,
|
|
16
|
+
'eye-off': `<path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" />
|
|
17
|
+
<path d="M14.084 14.158a3 3 0 0 1-4.242-4.242" />
|
|
18
|
+
<path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" />
|
|
19
|
+
<path d="m2 2 20 20" />`,
|
|
20
|
+
'chevron-down': `<path d="m6 9 6 6 6-6" />`,
|
|
21
|
+
check: `<path d="M20 6 9 17l-5-5" />`,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
class IconRegistry {
|
|
25
|
+
icons = new Map(Object.entries(BUILT_IN_ICONS));
|
|
26
|
+
register(name, svgInnerMarkup) {
|
|
27
|
+
this.icons.set(name, svgInnerMarkup);
|
|
28
|
+
}
|
|
29
|
+
registerAll(icons) {
|
|
30
|
+
for (const [name, markup] of Object.entries(icons)) {
|
|
31
|
+
this.icons.set(name, markup);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
get(name) {
|
|
35
|
+
return this.icons.get(name) ?? null;
|
|
36
|
+
}
|
|
37
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: IconRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
38
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: IconRegistry, providedIn: 'root' });
|
|
39
|
+
}
|
|
40
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: IconRegistry, decorators: [{
|
|
41
|
+
type: Injectable,
|
|
42
|
+
args: [{ providedIn: 'root' }]
|
|
43
|
+
}] });
|
|
44
|
+
|
|
45
|
+
class Icon {
|
|
46
|
+
sanitizer = inject(DomSanitizer);
|
|
47
|
+
registry = inject(IconRegistry);
|
|
48
|
+
name = input.required(/* @ts-ignore */
|
|
49
|
+
...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
50
|
+
svgContent = computed(() => {
|
|
51
|
+
const markup = this.registry.get(this.name());
|
|
52
|
+
return markup ? this.sanitizer.bypassSecurityTrustHtml(markup) : null;
|
|
53
|
+
}, /* @ts-ignore */
|
|
54
|
+
...(ngDevMode ? [{ debugName: "svgContent" }] : /* istanbul ignore next */ []));
|
|
55
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Icon, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
56
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Icon, isStandalone: true, selector: "gbt-icon", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "attr.aria-hidden": "\"true\"" } }, ngImport: i0, template: `
|
|
57
|
+
@if (svgContent(); as content) {
|
|
58
|
+
<svg
|
|
59
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
+
viewBox="0 0 24 24"
|
|
61
|
+
fill="none"
|
|
62
|
+
stroke="currentColor"
|
|
63
|
+
stroke-width="2"
|
|
64
|
+
stroke-linecap="round"
|
|
65
|
+
stroke-linejoin="round"
|
|
66
|
+
aria-hidden="true"
|
|
67
|
+
[innerHTML]="content"
|
|
68
|
+
></svg>
|
|
69
|
+
}
|
|
70
|
+
`, isInline: true, styles: [":host{display:inline-flex;width:1.25em;height:1.25em}svg{width:100%;height:100%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
71
|
+
}
|
|
72
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Icon, decorators: [{
|
|
73
|
+
type: Component,
|
|
74
|
+
args: [{ selector: 'gbt-icon', standalone: true, template: `
|
|
75
|
+
@if (svgContent(); as content) {
|
|
76
|
+
<svg
|
|
77
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
78
|
+
viewBox="0 0 24 24"
|
|
79
|
+
fill="none"
|
|
80
|
+
stroke="currentColor"
|
|
81
|
+
stroke-width="2"
|
|
82
|
+
stroke-linecap="round"
|
|
83
|
+
stroke-linejoin="round"
|
|
84
|
+
aria-hidden="true"
|
|
85
|
+
[innerHTML]="content"
|
|
86
|
+
></svg>
|
|
87
|
+
}
|
|
88
|
+
`, host: {
|
|
89
|
+
'[attr.aria-hidden]': '"true"',
|
|
90
|
+
}, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:inline-flex;width:1.25em;height:1.25em}svg{width:100%;height:100%}\n"] }]
|
|
91
|
+
}], propDecorators: { name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: true }] }] } });
|
|
92
|
+
|
|
93
|
+
let nextId = 0;
|
|
94
|
+
class AppShell {
|
|
95
|
+
navLabel = input.required(/* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "navLabel" }] : /* istanbul ignore next */ []));
|
|
97
|
+
skipLabel = input.required(/* @ts-ignore */
|
|
98
|
+
...(ngDevMode ? [{ debugName: "skipLabel" }] : /* istanbul ignore next */ []));
|
|
99
|
+
openMenuLabel = input.required(/* @ts-ignore */
|
|
100
|
+
...(ngDevMode ? [{ debugName: "openMenuLabel" }] : /* istanbul ignore next */ []));
|
|
101
|
+
closeMenuLabel = input.required(/* @ts-ignore */
|
|
102
|
+
...(ngDevMode ? [{ debugName: "closeMenuLabel" }] : /* istanbul ignore next */ []));
|
|
103
|
+
id = ++nextId;
|
|
104
|
+
mainId = `gbt-app-shell-main-${this.id}`;
|
|
105
|
+
navId = `gbt-app-shell-nav-${this.id}`;
|
|
106
|
+
menuOpen = signal(false, /* @ts-ignore */
|
|
107
|
+
...(ngDevMode ? [{ debugName: "menuOpen" }] : /* istanbul ignore next */ []));
|
|
108
|
+
menuLabel = computed(() => this.menuOpen() ? this.closeMenuLabel() : this.openMenuLabel(), /* @ts-ignore */
|
|
109
|
+
...(ngDevMode ? [{ debugName: "menuLabel" }] : /* istanbul ignore next */ []));
|
|
110
|
+
toggleButton = viewChild('toggle', /* @ts-ignore */
|
|
111
|
+
...(ngDevMode ? [{ debugName: "toggleButton" }] : /* istanbul ignore next */ []));
|
|
112
|
+
nav = viewChild('nav', /* @ts-ignore */
|
|
113
|
+
...(ngDevMode ? [{ debugName: "nav" }] : /* istanbul ignore next */ []));
|
|
114
|
+
toggleMenu() {
|
|
115
|
+
if (this.menuOpen()) {
|
|
116
|
+
this.close();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.menuOpen.set(true);
|
|
120
|
+
queueMicrotask(() => this.nav()?.nativeElement.focus());
|
|
121
|
+
}
|
|
122
|
+
close() {
|
|
123
|
+
if (!this.menuOpen())
|
|
124
|
+
return;
|
|
125
|
+
this.menuOpen.set(false);
|
|
126
|
+
this.toggleButton()?.nativeElement.focus();
|
|
127
|
+
}
|
|
128
|
+
onEscape() {
|
|
129
|
+
this.close();
|
|
130
|
+
}
|
|
131
|
+
onNavKeydown(event) {
|
|
132
|
+
if (event.key !== 'Tab' || !this.menuOpen())
|
|
133
|
+
return;
|
|
134
|
+
const nav = this.nav()?.nativeElement;
|
|
135
|
+
if (!nav)
|
|
136
|
+
return;
|
|
137
|
+
const focusableElements = nav.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');
|
|
138
|
+
if (focusableElements.length === 0)
|
|
139
|
+
return;
|
|
140
|
+
const first = focusableElements[0];
|
|
141
|
+
const last = focusableElements[focusableElements.length - 1];
|
|
142
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
last.focus();
|
|
145
|
+
}
|
|
146
|
+
else if (!event.shiftKey && document.activeElement === last) {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
first.focus();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AppShell, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
152
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AppShell, isStandalone: true, selector: "gbt-app-shell", inputs: { navLabel: { classPropertyName: "navLabel", publicName: "navLabel", isSignal: true, isRequired: true, transformFunction: null }, skipLabel: { classPropertyName: "skipLabel", publicName: "skipLabel", isSignal: true, isRequired: true, transformFunction: null }, openMenuLabel: { classPropertyName: "openMenuLabel", publicName: "openMenuLabel", isSignal: true, isRequired: true, transformFunction: null }, closeMenuLabel: { classPropertyName: "closeMenuLabel", publicName: "closeMenuLabel", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "document:keydown.escape": "onEscape()" } }, viewQueries: [{ propertyName: "toggleButton", first: true, predicate: ["toggle"], descendants: true, isSignal: true }, { propertyName: "nav", first: true, predicate: ["nav"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"gbt-app-shell\">\n <a class=\"gbt-app-shell__skip\" [href]=\"'#' + mainId\">{{ skipLabel() }}</a>\n\n <nav\n #nav\n [id]=\"navId\"\n class=\"gbt-app-shell__nav\"\n [class.gbt-app-shell__nav--open]=\"menuOpen()\"\n [attr.aria-label]=\"navLabel()\"\n tabindex=\"-1\"\n (keydown)=\"onNavKeydown($event)\"\n >\n <div class=\"gbt-app-shell__brand\">\n <ng-content select=\"[shell-brand]\" />\n </div>\n <ng-content select=\"[shell-nav]\" />\n </nav>\n\n @if (menuOpen()) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <div class=\"gbt-app-shell__scrim\" (click)=\"close()\"></div>\n }\n\n <div class=\"gbt-app-shell__body\">\n <header class=\"gbt-app-shell__header\">\n <button\n #toggle\n type=\"button\"\n class=\"gbt-app-shell__toggle\"\n [attr.aria-expanded]=\"menuOpen()\"\n [attr.aria-controls]=\"navId\"\n [attr.aria-label]=\"menuLabel()\"\n (click)=\"toggleMenu()\"\n >\n <span class=\"gbt-app-shell__burger\" aria-hidden=\"true\"></span>\n </button>\n <ng-content select=\"[shell-header]\" />\n </header>\n\n <main [id]=\"mainId\" class=\"gbt-app-shell__content\" tabindex=\"-1\">\n <ng-content />\n </main>\n </div>\n</div>\n", styles: [":host{display:block}.gbt-app-shell{display:flex;min-height:100vh;background:var(--bg-panel)}.gbt-app-shell__skip{position:absolute;left:-9999px;top:0;z-index:1040;padding:.5rem .75rem;border-radius:var(--site-border-radius-sm);background:var(--primary);color:var(--text-on-primary);font-size:.875rem;text-decoration:none}.gbt-app-shell__skip:focus-visible{left:.5rem;top:.5rem;outline:2px solid var(--primary);outline-offset:2px}.gbt-app-shell__nav{display:flex;flex-direction:column;gap:.25rem;flex-shrink:0;box-sizing:border-box;width:220px;padding:1rem .75rem;background:var(--bg-panel);border-right:1px solid var(--border-color)}.gbt-app-shell__brand{margin-bottom:1rem}.gbt-app-shell__body{display:flex;flex-direction:column;flex:1;min-width:0}.gbt-app-shell__header{position:relative;z-index:1010;display:flex;align-items:center;gap:.75rem;padding:.75rem 1rem;border-bottom:1px solid var(--border-color)}.gbt-app-shell__toggle{display:none;flex-shrink:0;width:2.25rem;height:2.25rem;padding:0;border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);background:transparent;cursor:pointer}.gbt-app-shell__toggle:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-app-shell__burger{display:block;position:relative;width:1rem;height:2px;margin:0 auto;background:var(--text-primary)}.gbt-app-shell__burger:before,.gbt-app-shell__burger:after{content:\"\";position:absolute;left:0;width:100%;height:2px;background:var(--text-primary)}.gbt-app-shell__burger:before{top:-5px}.gbt-app-shell__burger:after{top:5px}.gbt-app-shell__content{flex:1;min-width:0;padding:1rem}.gbt-app-shell__content:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}@media(max-width:768px){.gbt-app-shell__toggle{display:block}.gbt-app-shell__nav{position:fixed;top:0;bottom:0;left:0;z-index:1030;transform:translate(-100%);transition:transform .16s ease-out}}@media(max-width:768px)and (prefers-reduced-motion:reduce){.gbt-app-shell__nav{transition:none}}@media(max-width:768px){.gbt-app-shell__nav--open{transform:translate(0)}.gbt-app-shell__scrim{position:fixed;inset:0;z-index:1020;background:#0006}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
153
|
+
}
|
|
154
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AppShell, decorators: [{
|
|
155
|
+
type: Component,
|
|
156
|
+
args: [{ selector: 'gbt-app-shell', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"gbt-app-shell\">\n <a class=\"gbt-app-shell__skip\" [href]=\"'#' + mainId\">{{ skipLabel() }}</a>\n\n <nav\n #nav\n [id]=\"navId\"\n class=\"gbt-app-shell__nav\"\n [class.gbt-app-shell__nav--open]=\"menuOpen()\"\n [attr.aria-label]=\"navLabel()\"\n tabindex=\"-1\"\n (keydown)=\"onNavKeydown($event)\"\n >\n <div class=\"gbt-app-shell__brand\">\n <ng-content select=\"[shell-brand]\" />\n </div>\n <ng-content select=\"[shell-nav]\" />\n </nav>\n\n @if (menuOpen()) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <div class=\"gbt-app-shell__scrim\" (click)=\"close()\"></div>\n }\n\n <div class=\"gbt-app-shell__body\">\n <header class=\"gbt-app-shell__header\">\n <button\n #toggle\n type=\"button\"\n class=\"gbt-app-shell__toggle\"\n [attr.aria-expanded]=\"menuOpen()\"\n [attr.aria-controls]=\"navId\"\n [attr.aria-label]=\"menuLabel()\"\n (click)=\"toggleMenu()\"\n >\n <span class=\"gbt-app-shell__burger\" aria-hidden=\"true\"></span>\n </button>\n <ng-content select=\"[shell-header]\" />\n </header>\n\n <main [id]=\"mainId\" class=\"gbt-app-shell__content\" tabindex=\"-1\">\n <ng-content />\n </main>\n </div>\n</div>\n", styles: [":host{display:block}.gbt-app-shell{display:flex;min-height:100vh;background:var(--bg-panel)}.gbt-app-shell__skip{position:absolute;left:-9999px;top:0;z-index:1040;padding:.5rem .75rem;border-radius:var(--site-border-radius-sm);background:var(--primary);color:var(--text-on-primary);font-size:.875rem;text-decoration:none}.gbt-app-shell__skip:focus-visible{left:.5rem;top:.5rem;outline:2px solid var(--primary);outline-offset:2px}.gbt-app-shell__nav{display:flex;flex-direction:column;gap:.25rem;flex-shrink:0;box-sizing:border-box;width:220px;padding:1rem .75rem;background:var(--bg-panel);border-right:1px solid var(--border-color)}.gbt-app-shell__brand{margin-bottom:1rem}.gbt-app-shell__body{display:flex;flex-direction:column;flex:1;min-width:0}.gbt-app-shell__header{position:relative;z-index:1010;display:flex;align-items:center;gap:.75rem;padding:.75rem 1rem;border-bottom:1px solid var(--border-color)}.gbt-app-shell__toggle{display:none;flex-shrink:0;width:2.25rem;height:2.25rem;padding:0;border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);background:transparent;cursor:pointer}.gbt-app-shell__toggle:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-app-shell__burger{display:block;position:relative;width:1rem;height:2px;margin:0 auto;background:var(--text-primary)}.gbt-app-shell__burger:before,.gbt-app-shell__burger:after{content:\"\";position:absolute;left:0;width:100%;height:2px;background:var(--text-primary)}.gbt-app-shell__burger:before{top:-5px}.gbt-app-shell__burger:after{top:5px}.gbt-app-shell__content{flex:1;min-width:0;padding:1rem}.gbt-app-shell__content:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}@media(max-width:768px){.gbt-app-shell__toggle{display:block}.gbt-app-shell__nav{position:fixed;top:0;bottom:0;left:0;z-index:1030;transform:translate(-100%);transition:transform .16s ease-out}}@media(max-width:768px)and (prefers-reduced-motion:reduce){.gbt-app-shell__nav{transition:none}}@media(max-width:768px){.gbt-app-shell__nav--open{transform:translate(0)}.gbt-app-shell__scrim{position:fixed;inset:0;z-index:1020;background:#0006}}\n"] }]
|
|
157
|
+
}], propDecorators: { navLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "navLabel", required: true }] }], skipLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "skipLabel", required: true }] }], openMenuLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "openMenuLabel", required: true }] }], closeMenuLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeMenuLabel", required: true }] }], toggleButton: [{ type: i0.ViewChild, args: ['toggle', { isSignal: true }] }], nav: [{ type: i0.ViewChild, args: ['nav', { isSignal: true }] }], onEscape: [{
|
|
158
|
+
type: HostListener,
|
|
159
|
+
args: ['document:keydown.escape']
|
|
160
|
+
}] } });
|
|
161
|
+
|
|
162
|
+
class Button {
|
|
163
|
+
variant = input('primary', /* @ts-ignore */
|
|
164
|
+
...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
165
|
+
size = input('medium', /* @ts-ignore */
|
|
166
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
167
|
+
type = input('button', /* @ts-ignore */
|
|
168
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
169
|
+
text = input('', /* @ts-ignore */
|
|
170
|
+
...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
|
|
171
|
+
iconName = input(null, /* @ts-ignore */
|
|
172
|
+
...(ngDevMode ? [{ debugName: "iconName" }] : /* istanbul ignore next */ []));
|
|
173
|
+
ariaLabel = input(null, /* @ts-ignore */
|
|
174
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
175
|
+
loading = input(false, { ...(ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
176
|
+
loadingLabel = input('Loading', /* @ts-ignore */
|
|
177
|
+
...(ngDevMode ? [{ debugName: "loadingLabel" }] : /* istanbul ignore next */ []));
|
|
178
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
179
|
+
clicked = output();
|
|
180
|
+
handleClick() {
|
|
181
|
+
if (!this.disabled() && !this.loading()) {
|
|
182
|
+
this.clicked.emit();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Button, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
186
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Button, isStandalone: true, selector: "gbt-button", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, iconName: { classPropertyName: "iconName", publicName: "iconName", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, loadingLabel: { classPropertyName: "loadingLabel", publicName: "loadingLabel", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { clicked: "clicked" }, ngImport: i0, template: "<button\n [type]=\"type()\"\n class=\"gbt-button gbt-button--{{ variant() }} gbt-button--{{ size() }}\"\n [disabled]=\"disabled() || loading()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-busy]=\"loading() ? 'true' : null\"\n (click)=\"handleClick()\"\n>\n @if (iconName()) {\n <gbt-icon [name]=\"iconName()!\" aria-hidden=\"true\" />\n }\n @if (loading()) {\n <span class=\"gbt-button__spinner\" aria-hidden=\"true\"></span>\n <span class=\"sr-only\">{{ loadingLabel() }}</span>\n }\n <span>{{ text() }}</span>\n</button>\n", styles: [":host{display:inline-block}.gbt-button{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;border:none;border-radius:var(--site-border-radius-sm);font-family:var(--font-family);font-weight:600;cursor:pointer;transition:background-color var(--site-transition-fast),opacity var(--site-transition-fast)}.gbt-button:disabled{cursor:not-allowed;opacity:.5}.gbt-button--small{padding:.375rem .75rem;font-size:.8125rem}.gbt-button--medium{padding:.5rem 1rem;font-size:.875rem}.gbt-button--large{padding:.75rem 1.5rem;font-size:1rem}.gbt-button--primary{background:var(--primary);color:var(--text-on-primary)}.gbt-button--primary:not(:disabled):hover{background:var(--primary-hover)}.gbt-button--secondary{background:var(--bg-panel);color:var(--text-primary);border:1px solid var(--border-color)}.gbt-button--secondary:not(:disabled):hover{background:var(--bg-hover)}.gbt-button--danger{background:var(--color-error-fill);color:var(--text-on-error)}.gbt-button--danger:not(:disabled):hover{background:var(--color-error-hover)}.gbt-button__spinner{width:1em;height:1em;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:gbt-button-spin .6s linear infinite}@media(prefers-reduced-motion:reduce){.gbt-button__spinner{animation:none}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}@keyframes gbt-button-spin{to{transform:rotate(360deg)}}\n"], dependencies: [{ kind: "component", type: Icon, selector: "gbt-icon", inputs: ["name"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
187
|
+
}
|
|
188
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Button, decorators: [{
|
|
189
|
+
type: Component,
|
|
190
|
+
args: [{ selector: 'gbt-button', standalone: true, imports: [Icon], changeDetection: ChangeDetectionStrategy.OnPush, template: "<button\n [type]=\"type()\"\n class=\"gbt-button gbt-button--{{ variant() }} gbt-button--{{ size() }}\"\n [disabled]=\"disabled() || loading()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-busy]=\"loading() ? 'true' : null\"\n (click)=\"handleClick()\"\n>\n @if (iconName()) {\n <gbt-icon [name]=\"iconName()!\" aria-hidden=\"true\" />\n }\n @if (loading()) {\n <span class=\"gbt-button__spinner\" aria-hidden=\"true\"></span>\n <span class=\"sr-only\">{{ loadingLabel() }}</span>\n }\n <span>{{ text() }}</span>\n</button>\n", styles: [":host{display:inline-block}.gbt-button{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;border:none;border-radius:var(--site-border-radius-sm);font-family:var(--font-family);font-weight:600;cursor:pointer;transition:background-color var(--site-transition-fast),opacity var(--site-transition-fast)}.gbt-button:disabled{cursor:not-allowed;opacity:.5}.gbt-button--small{padding:.375rem .75rem;font-size:.8125rem}.gbt-button--medium{padding:.5rem 1rem;font-size:.875rem}.gbt-button--large{padding:.75rem 1.5rem;font-size:1rem}.gbt-button--primary{background:var(--primary);color:var(--text-on-primary)}.gbt-button--primary:not(:disabled):hover{background:var(--primary-hover)}.gbt-button--secondary{background:var(--bg-panel);color:var(--text-primary);border:1px solid var(--border-color)}.gbt-button--secondary:not(:disabled):hover{background:var(--bg-hover)}.gbt-button--danger{background:var(--color-error-fill);color:var(--text-on-error)}.gbt-button--danger:not(:disabled):hover{background:var(--color-error-hover)}.gbt-button__spinner{width:1em;height:1em;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:gbt-button-spin .6s linear infinite}@media(prefers-reduced-motion:reduce){.gbt-button__spinner{animation:none}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}@keyframes gbt-button-spin{to{transform:rotate(360deg)}}\n"] }]
|
|
191
|
+
}], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], iconName: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconName", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], loadingLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingLabel", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], clicked: [{ type: i0.Output, args: ["clicked"] }] } });
|
|
192
|
+
|
|
193
|
+
class Card {
|
|
194
|
+
hoverable = input(false, { ...(ngDevMode ? { debugName: "hoverable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
195
|
+
heading = input('', /* @ts-ignore */
|
|
196
|
+
...(ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []));
|
|
197
|
+
icon = input('', /* @ts-ignore */
|
|
198
|
+
...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
199
|
+
headingLevel = input(2, /* @ts-ignore */
|
|
200
|
+
...(ngDevMode ? [{ debugName: "headingLevel" }] : /* istanbul ignore next */ []));
|
|
201
|
+
cardClass = computed(() => 'gbt-card' + (this.hoverable() ? ' gbt-card--hoverable' : ''), /* @ts-ignore */
|
|
202
|
+
...(ngDevMode ? [{ debugName: "cardClass" }] : /* istanbul ignore next */ []));
|
|
203
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Card, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
204
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Card, isStandalone: true, selector: "gbt-card", inputs: { hoverable: { classPropertyName: "hoverable", publicName: "hoverable", isSignal: true, isRequired: false, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, headingLevel: { classPropertyName: "headingLevel", publicName: "headingLevel", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div [class]=\"cardClass()\">\n @if (heading()) {\n <div class=\"gbt-card__header\">\n @switch (headingLevel()) {\n @case (1) {\n <h1 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h1>\n }\n @case (3) {\n <h3 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h3>\n }\n @case (4) {\n <h4 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h4>\n }\n @case (5) {\n <h5 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h5>\n }\n @case (6) {\n <h6 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h6>\n }\n @default {\n <h2 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h2>\n }\n }\n <ng-content select=\"[card-header-actions]\"></ng-content>\n </div>\n }\n <ng-content></ng-content>\n</div>\n<ng-template #headingContent>\n @if (icon()) {\n <gbt-icon [name]=\"icon()\" aria-hidden=\"true\" />\n }\n {{ heading() }}\n</ng-template>\n", styles: [":host{display:block}.gbt-card{background:var(--bg-principal);border-radius:var(--site-border-radius-lg);box-shadow:var(--site-shadow-sm);position:relative;overflow:hidden;transition:box-shadow .18s cubic-bezier(.4,0,.2,1);padding:1.25rem 1.5rem;font-size:.9rem;line-height:1.65;color:var(--text-secondary)}.gbt-card--hoverable{cursor:pointer;-webkit-user-select:none;user-select:none}.gbt-card--hoverable:hover{box-shadow:var(--site-shadow-lg)}.gbt-card__header{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:.75rem}.gbt-card__title{display:flex;align-items:center;gap:.5rem;font-size:1rem;font-weight:600;color:var(--text-primary);margin:0}\n"], dependencies: [{ kind: "component", type: Icon, selector: "gbt-icon", inputs: ["name"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
205
|
+
}
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Card, decorators: [{
|
|
207
|
+
type: Component,
|
|
208
|
+
args: [{ selector: 'gbt-card', standalone: true, imports: [Icon, NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [class]=\"cardClass()\">\n @if (heading()) {\n <div class=\"gbt-card__header\">\n @switch (headingLevel()) {\n @case (1) {\n <h1 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h1>\n }\n @case (3) {\n <h3 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h3>\n }\n @case (4) {\n <h4 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h4>\n }\n @case (5) {\n <h5 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h5>\n }\n @case (6) {\n <h6 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h6>\n }\n @default {\n <h2 class=\"gbt-card__title\"><ng-container *ngTemplateOutlet=\"headingContent\" /></h2>\n }\n }\n <ng-content select=\"[card-header-actions]\"></ng-content>\n </div>\n }\n <ng-content></ng-content>\n</div>\n<ng-template #headingContent>\n @if (icon()) {\n <gbt-icon [name]=\"icon()\" aria-hidden=\"true\" />\n }\n {{ heading() }}\n</ng-template>\n", styles: [":host{display:block}.gbt-card{background:var(--bg-principal);border-radius:var(--site-border-radius-lg);box-shadow:var(--site-shadow-sm);position:relative;overflow:hidden;transition:box-shadow .18s cubic-bezier(.4,0,.2,1);padding:1.25rem 1.5rem;font-size:.9rem;line-height:1.65;color:var(--text-secondary)}.gbt-card--hoverable{cursor:pointer;-webkit-user-select:none;user-select:none}.gbt-card--hoverable:hover{box-shadow:var(--site-shadow-lg)}.gbt-card__header{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:.75rem}.gbt-card__title{display:flex;align-items:center;gap:.5rem;font-size:1rem;font-weight:600;color:var(--text-primary);margin:0}\n"] }]
|
|
209
|
+
}], propDecorators: { hoverable: [{ type: i0.Input, args: [{ isSignal: true, alias: "hoverable", required: false }] }], heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], headingLevel: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingLevel", required: false }] }] } });
|
|
210
|
+
|
|
211
|
+
let nextInputId = 0;
|
|
212
|
+
class GbtInput {
|
|
213
|
+
id = input(`gbt-input-${++nextInputId}`, /* @ts-ignore */
|
|
214
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
215
|
+
label = input('', /* @ts-ignore */
|
|
216
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
217
|
+
type = input('text', /* @ts-ignore */
|
|
218
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
219
|
+
required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
220
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
221
|
+
placeholder = input('', /* @ts-ignore */
|
|
222
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
223
|
+
errorMessage = input(null, /* @ts-ignore */
|
|
224
|
+
...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
225
|
+
autocomplete = input('off', /* @ts-ignore */
|
|
226
|
+
...(ngDevMode ? [{ debugName: "autocomplete" }] : /* istanbul ignore next */ []));
|
|
227
|
+
showPasswordLabel = input('Show password', /* @ts-ignore */
|
|
228
|
+
...(ngDevMode ? [{ debugName: "showPasswordLabel" }] : /* istanbul ignore next */ []));
|
|
229
|
+
hidePasswordLabel = input('Hide password', /* @ts-ignore */
|
|
230
|
+
...(ngDevMode ? [{ debugName: "hidePasswordLabel" }] : /* istanbul ignore next */ []));
|
|
231
|
+
value = signal('', /* @ts-ignore */
|
|
232
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
233
|
+
passwordVisible = signal(false, /* @ts-ignore */
|
|
234
|
+
...(ngDevMode ? [{ debugName: "passwordVisible" }] : /* istanbul ignore next */ []));
|
|
235
|
+
effectiveType = computed(() => this.type() === 'password' && !this.passwordVisible() ? 'password' : 'text', /* @ts-ignore */
|
|
236
|
+
...(ngDevMode ? [{ debugName: "effectiveType" }] : /* istanbul ignore next */ []));
|
|
237
|
+
formDisabled = signal(false, /* @ts-ignore */
|
|
238
|
+
...(ngDevMode ? [{ debugName: "formDisabled" }] : /* istanbul ignore next */ []));
|
|
239
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled(), /* @ts-ignore */
|
|
240
|
+
...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
|
|
241
|
+
onChange = () => { };
|
|
242
|
+
onTouched = () => { };
|
|
243
|
+
writeValue(value) {
|
|
244
|
+
this.value.set(value ?? '');
|
|
245
|
+
}
|
|
246
|
+
registerOnChange(fn) {
|
|
247
|
+
this.onChange = fn;
|
|
248
|
+
}
|
|
249
|
+
registerOnTouched(fn) {
|
|
250
|
+
this.onTouched = fn;
|
|
251
|
+
}
|
|
252
|
+
setDisabledState(isDisabled) {
|
|
253
|
+
this.formDisabled.set(isDisabled);
|
|
254
|
+
}
|
|
255
|
+
onInput(event) {
|
|
256
|
+
const value = event.target.value;
|
|
257
|
+
this.value.set(value);
|
|
258
|
+
this.onChange(value);
|
|
259
|
+
}
|
|
260
|
+
onBlur() {
|
|
261
|
+
this.onTouched();
|
|
262
|
+
}
|
|
263
|
+
togglePasswordVisibility() {
|
|
264
|
+
this.passwordVisible.update((visible) => !visible);
|
|
265
|
+
}
|
|
266
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: GbtInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
267
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: GbtInput, isStandalone: true, selector: "gbt-input", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, autocomplete: { classPropertyName: "autocomplete", publicName: "autocomplete", isSignal: true, isRequired: false, transformFunction: null }, showPasswordLabel: { classPropertyName: "showPasswordLabel", publicName: "showPasswordLabel", isSignal: true, isRequired: false, transformFunction: null }, hidePasswordLabel: { classPropertyName: "hidePasswordLabel", publicName: "hidePasswordLabel", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
268
|
+
{
|
|
269
|
+
provide: NG_VALUE_ACCESSOR,
|
|
270
|
+
useExisting: forwardRef(() => GbtInput),
|
|
271
|
+
multi: true,
|
|
272
|
+
},
|
|
273
|
+
], ngImport: i0, template: "<div class=\"gbt-input\">\n @if (label()) {\n <label [for]=\"id()\">{{ label() }}{{ required() ? ' *' : '' }}</label>\n }\n <div class=\"gbt-input__wrapper\">\n <input\n [id]=\"id()\"\n [type]=\"effectiveType()\"\n [placeholder]=\"placeholder()\"\n [required]=\"required()\"\n [disabled]=\"isDisabled()\"\n [attr.autocomplete]=\"autocomplete()\"\n [value]=\"value()\"\n [attr.aria-invalid]=\"errorMessage() ? true : null\"\n [attr.aria-describedby]=\"errorMessage() ? id() + '-error' : null\"\n (input)=\"onInput($event)\"\n (blur)=\"onBlur()\"\n />\n @if (type() === 'password') {\n <button\n type=\"button\"\n class=\"gbt-input__toggle\"\n (click)=\"togglePasswordVisibility()\"\n [attr.aria-label]=\"passwordVisible() ? hidePasswordLabel() : showPasswordLabel()\"\n >\n <gbt-icon [name]=\"passwordVisible() ? 'eye-off' : 'eye'\" aria-hidden=\"true\" />\n </button>\n }\n </div>\n @if (errorMessage()) {\n <p [id]=\"id() + '-error'\" class=\"gbt-input__error\" role=\"alert\">{{ errorMessage() }}</p>\n }\n</div>\n", styles: [":host{display:block}.gbt-input{display:flex;flex-direction:column;gap:.375rem}.gbt-input label{font-size:.8125rem;font-weight:600;color:var(--text-secondary)}.gbt-input__wrapper{position:relative;display:flex;align-items:center}.gbt-input input{width:100%;padding:.5rem .75rem;font-family:var(--font-family);font-size:.875rem;color:var(--text-primary);background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);transition:border-color var(--site-transition-fast)}.gbt-input input:focus{outline:none;border-color:var(--primary)}.gbt-input input:focus-visible{outline:2px solid var(--primary);outline-offset:1px}.gbt-input input:disabled{background:var(--bg-panel);cursor:not-allowed}.gbt-input__toggle{position:absolute;right:.5rem;display:inline-flex;background:none;border:none;color:var(--text-discret);cursor:pointer}.gbt-input__toggle:before{content:\"\";position:absolute;inset:50% auto auto 50%;width:max(100%,24px);height:max(100%,24px);transform:translate(-50%,-50%)}.gbt-input__error{font-size:.75rem;color:var(--color-error-text)}\n"], dependencies: [{ kind: "component", type: Icon, selector: "gbt-icon", inputs: ["name"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
274
|
+
}
|
|
275
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: GbtInput, decorators: [{
|
|
276
|
+
type: Component,
|
|
277
|
+
args: [{ selector: 'gbt-input', standalone: true, imports: [Icon], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
278
|
+
{
|
|
279
|
+
provide: NG_VALUE_ACCESSOR,
|
|
280
|
+
useExisting: forwardRef(() => GbtInput),
|
|
281
|
+
multi: true,
|
|
282
|
+
},
|
|
283
|
+
], template: "<div class=\"gbt-input\">\n @if (label()) {\n <label [for]=\"id()\">{{ label() }}{{ required() ? ' *' : '' }}</label>\n }\n <div class=\"gbt-input__wrapper\">\n <input\n [id]=\"id()\"\n [type]=\"effectiveType()\"\n [placeholder]=\"placeholder()\"\n [required]=\"required()\"\n [disabled]=\"isDisabled()\"\n [attr.autocomplete]=\"autocomplete()\"\n [value]=\"value()\"\n [attr.aria-invalid]=\"errorMessage() ? true : null\"\n [attr.aria-describedby]=\"errorMessage() ? id() + '-error' : null\"\n (input)=\"onInput($event)\"\n (blur)=\"onBlur()\"\n />\n @if (type() === 'password') {\n <button\n type=\"button\"\n class=\"gbt-input__toggle\"\n (click)=\"togglePasswordVisibility()\"\n [attr.aria-label]=\"passwordVisible() ? hidePasswordLabel() : showPasswordLabel()\"\n >\n <gbt-icon [name]=\"passwordVisible() ? 'eye-off' : 'eye'\" aria-hidden=\"true\" />\n </button>\n }\n </div>\n @if (errorMessage()) {\n <p [id]=\"id() + '-error'\" class=\"gbt-input__error\" role=\"alert\">{{ errorMessage() }}</p>\n }\n</div>\n", styles: [":host{display:block}.gbt-input{display:flex;flex-direction:column;gap:.375rem}.gbt-input label{font-size:.8125rem;font-weight:600;color:var(--text-secondary)}.gbt-input__wrapper{position:relative;display:flex;align-items:center}.gbt-input input{width:100%;padding:.5rem .75rem;font-family:var(--font-family);font-size:.875rem;color:var(--text-primary);background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);transition:border-color var(--site-transition-fast)}.gbt-input input:focus{outline:none;border-color:var(--primary)}.gbt-input input:focus-visible{outline:2px solid var(--primary);outline-offset:1px}.gbt-input input:disabled{background:var(--bg-panel);cursor:not-allowed}.gbt-input__toggle{position:absolute;right:.5rem;display:inline-flex;background:none;border:none;color:var(--text-discret);cursor:pointer}.gbt-input__toggle:before{content:\"\";position:absolute;inset:50% auto auto 50%;width:max(100%,24px);height:max(100%,24px);transform:translate(-50%,-50%)}.gbt-input__error{font-size:.75rem;color:var(--color-error-text)}\n"] }]
|
|
284
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], autocomplete: [{ type: i0.Input, args: [{ isSignal: true, alias: "autocomplete", required: false }] }], showPasswordLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "showPasswordLabel", required: false }] }], hidePasswordLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "hidePasswordLabel", required: false }] }] } });
|
|
285
|
+
|
|
286
|
+
let nextCheckboxId = 0;
|
|
287
|
+
class Checkbox {
|
|
288
|
+
id = input(`gbt-checkbox-${++nextCheckboxId}`, /* @ts-ignore */
|
|
289
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
290
|
+
label = input('', /* @ts-ignore */
|
|
291
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
292
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
293
|
+
checked = signal(false, /* @ts-ignore */
|
|
294
|
+
...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
295
|
+
formDisabled = signal(false, /* @ts-ignore */
|
|
296
|
+
...(ngDevMode ? [{ debugName: "formDisabled" }] : /* istanbul ignore next */ []));
|
|
297
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled(), /* @ts-ignore */
|
|
298
|
+
...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
|
|
299
|
+
onChange = () => { };
|
|
300
|
+
onTouched = () => { };
|
|
301
|
+
writeValue(value) {
|
|
302
|
+
this.checked.set(!!value);
|
|
303
|
+
}
|
|
304
|
+
registerOnChange(fn) {
|
|
305
|
+
this.onChange = fn;
|
|
306
|
+
}
|
|
307
|
+
registerOnTouched(fn) {
|
|
308
|
+
this.onTouched = fn;
|
|
309
|
+
}
|
|
310
|
+
setDisabledState(isDisabled) {
|
|
311
|
+
this.formDisabled.set(isDisabled);
|
|
312
|
+
}
|
|
313
|
+
onToggle(event) {
|
|
314
|
+
const value = event.target.checked;
|
|
315
|
+
this.checked.set(value);
|
|
316
|
+
this.onChange(value);
|
|
317
|
+
this.onTouched();
|
|
318
|
+
}
|
|
319
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Checkbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
320
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.5", type: Checkbox, isStandalone: true, selector: "gbt-checkbox", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
321
|
+
{
|
|
322
|
+
provide: NG_VALUE_ACCESSOR,
|
|
323
|
+
useExisting: forwardRef(() => Checkbox),
|
|
324
|
+
multi: true,
|
|
325
|
+
},
|
|
326
|
+
], ngImport: i0, template: "<label class=\"gbt-checkbox\" [class.gbt-checkbox--disabled]=\"isDisabled()\">\n <input\n type=\"checkbox\"\n [id]=\"id()\"\n [checked]=\"checked()\"\n [disabled]=\"isDisabled()\"\n (change)=\"onToggle($event)\"\n />\n <span>{{ label() }}</span>\n</label>\n", styles: [".gbt-checkbox{position:relative;display:inline-flex;align-items:center;gap:.5rem;font-size:.875rem;color:var(--text-primary);cursor:pointer}.gbt-checkbox:before{content:\"\";position:absolute;inset:50% auto auto 50%;width:max(100%,24px);height:max(100%,24px);transform:translate(-50%,-50%)}.gbt-checkbox--disabled{cursor:not-allowed;opacity:.5}.gbt-checkbox input{width:1rem;height:1rem;accent-color:var(--primary)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
327
|
+
}
|
|
328
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Checkbox, decorators: [{
|
|
329
|
+
type: Component,
|
|
330
|
+
args: [{ selector: 'gbt-checkbox', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
331
|
+
{
|
|
332
|
+
provide: NG_VALUE_ACCESSOR,
|
|
333
|
+
useExisting: forwardRef(() => Checkbox),
|
|
334
|
+
multi: true,
|
|
335
|
+
},
|
|
336
|
+
], template: "<label class=\"gbt-checkbox\" [class.gbt-checkbox--disabled]=\"isDisabled()\">\n <input\n type=\"checkbox\"\n [id]=\"id()\"\n [checked]=\"checked()\"\n [disabled]=\"isDisabled()\"\n (change)=\"onToggle($event)\"\n />\n <span>{{ label() }}</span>\n</label>\n", styles: [".gbt-checkbox{position:relative;display:inline-flex;align-items:center;gap:.5rem;font-size:.875rem;color:var(--text-primary);cursor:pointer}.gbt-checkbox:before{content:\"\";position:absolute;inset:50% auto auto 50%;width:max(100%,24px);height:max(100%,24px);transform:translate(-50%,-50%)}.gbt-checkbox--disabled{cursor:not-allowed;opacity:.5}.gbt-checkbox input{width:1rem;height:1rem;accent-color:var(--primary)}\n"] }]
|
|
337
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
338
|
+
|
|
339
|
+
let nextSelectId = 0;
|
|
340
|
+
class Select {
|
|
341
|
+
elementRef = inject(ElementRef);
|
|
342
|
+
id = input(`gbt-select-${++nextSelectId}`, /* @ts-ignore */
|
|
343
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
344
|
+
label = input('', /* @ts-ignore */
|
|
345
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
346
|
+
options = input.required(/* @ts-ignore */
|
|
347
|
+
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
348
|
+
multiple = input(false, { ...(ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
349
|
+
placeholder = input('Select…', /* @ts-ignore */
|
|
350
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
351
|
+
disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
352
|
+
required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
353
|
+
errorMessage = input(null, /* @ts-ignore */
|
|
354
|
+
...(ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []));
|
|
355
|
+
selectedCountLabel = input((count) => `${count} selected`, /* @ts-ignore */
|
|
356
|
+
...(ngDevMode ? [{ debugName: "selectedCountLabel" }] : /* istanbul ignore next */ []));
|
|
357
|
+
open = signal(false, /* @ts-ignore */
|
|
358
|
+
...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
359
|
+
activeIndex = signal(-1, /* @ts-ignore */
|
|
360
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
361
|
+
selected = signal([], /* @ts-ignore */
|
|
362
|
+
...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
363
|
+
panelStyle = signal(null, /* @ts-ignore */
|
|
364
|
+
...(ngDevMode ? [{ debugName: "panelStyle" }] : /* istanbul ignore next */ []));
|
|
365
|
+
formDisabled = signal(false, /* @ts-ignore */
|
|
366
|
+
...(ngDevMode ? [{ debugName: "formDisabled" }] : /* istanbul ignore next */ []));
|
|
367
|
+
labelId = computed(() => `${this.id()}-label`, /* @ts-ignore */
|
|
368
|
+
...(ngDevMode ? [{ debugName: "labelId" }] : /* istanbul ignore next */ []));
|
|
369
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled(), /* @ts-ignore */
|
|
370
|
+
...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
|
|
371
|
+
onChange = () => { };
|
|
372
|
+
onTouched = () => { };
|
|
373
|
+
setDisabledState(isDisabled) {
|
|
374
|
+
this.formDisabled.set(isDisabled);
|
|
375
|
+
}
|
|
376
|
+
writeValue(value) {
|
|
377
|
+
if (this.multiple()) {
|
|
378
|
+
this.selected.set(Array.isArray(value) ? value : []);
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
this.selected.set(value === null || value === undefined ? [] : [value]);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
registerOnChange(fn) {
|
|
385
|
+
this.onChange = fn;
|
|
386
|
+
}
|
|
387
|
+
registerOnTouched(fn) {
|
|
388
|
+
this.onTouched = fn;
|
|
389
|
+
}
|
|
390
|
+
selectedOptions = computed(() => {
|
|
391
|
+
const selected = this.selected();
|
|
392
|
+
return this.options().filter((option) => selected.includes(option.value));
|
|
393
|
+
}, /* @ts-ignore */
|
|
394
|
+
...(ngDevMode ? [{ debugName: "selectedOptions" }] : /* istanbul ignore next */ []));
|
|
395
|
+
triggerLabel = computed(() => {
|
|
396
|
+
const opts = this.selectedOptions();
|
|
397
|
+
if (opts.length === 0) {
|
|
398
|
+
return this.placeholder();
|
|
399
|
+
}
|
|
400
|
+
if (this.multiple() && opts.length > 1) {
|
|
401
|
+
return this.selectedCountLabel()(opts.length);
|
|
402
|
+
}
|
|
403
|
+
return opts[0].label;
|
|
404
|
+
}, /* @ts-ignore */
|
|
405
|
+
...(ngDevMode ? [{ debugName: "triggerLabel" }] : /* istanbul ignore next */ []));
|
|
406
|
+
triggerIcon = computed(() => {
|
|
407
|
+
const opts = this.selectedOptions();
|
|
408
|
+
return opts.length === 1 ? opts[0].icon : undefined;
|
|
409
|
+
}, /* @ts-ignore */
|
|
410
|
+
...(ngDevMode ? [{ debugName: "triggerIcon" }] : /* istanbul ignore next */ []));
|
|
411
|
+
activeOptionId = computed(() => this.open() && this.activeIndex() >= 0 ? `${this.id()}-option-${this.activeIndex()}` : null, /* @ts-ignore */
|
|
412
|
+
...(ngDevMode ? [{ debugName: "activeOptionId" }] : /* istanbul ignore next */ []));
|
|
413
|
+
isSelected(value) {
|
|
414
|
+
return this.selected().includes(value);
|
|
415
|
+
}
|
|
416
|
+
toggleOpen() {
|
|
417
|
+
if (this.isDisabled()) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
this.open.update((value) => !value);
|
|
421
|
+
if (this.open()) {
|
|
422
|
+
this.activeIndex.set(Math.max(0, this.options().findIndex((o) => this.isSelected(o.value))));
|
|
423
|
+
this.updatePanelPosition();
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
this.onTouched();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
updatePanelPosition() {
|
|
430
|
+
if (!this.open()) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
const trigger = this.elementRef.nativeElement.querySelector('.gbt-select__trigger');
|
|
434
|
+
if (!trigger) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const rect = trigger.getBoundingClientRect();
|
|
438
|
+
this.panelStyle.set({
|
|
439
|
+
top: `${rect.bottom + 6}px`,
|
|
440
|
+
left: `${rect.left}px`,
|
|
441
|
+
width: `${rect.width}px`,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
selectOption(value) {
|
|
445
|
+
if (this.multiple()) {
|
|
446
|
+
const current = this.selected();
|
|
447
|
+
const next = current.includes(value)
|
|
448
|
+
? current.filter((v) => v !== value)
|
|
449
|
+
: [...current, value];
|
|
450
|
+
this.selected.set(next);
|
|
451
|
+
this.onChange(next);
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
this.selected.set([value]);
|
|
455
|
+
this.onChange(value);
|
|
456
|
+
this.open.set(false);
|
|
457
|
+
this.onTouched();
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
handleClickOutside(event) {
|
|
461
|
+
if (this.open() && !this.elementRef.nativeElement.contains(event.target)) {
|
|
462
|
+
this.open.set(false);
|
|
463
|
+
this.onTouched();
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
onKeydown(event) {
|
|
467
|
+
if (this.isDisabled()) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if (!this.open()) {
|
|
471
|
+
if (event.key === 'ArrowDown' || event.key === 'Enter' || event.key === ' ') {
|
|
472
|
+
event.preventDefault();
|
|
473
|
+
this.toggleOpen();
|
|
474
|
+
}
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const options = this.options();
|
|
478
|
+
switch (event.key) {
|
|
479
|
+
case 'Escape':
|
|
480
|
+
event.preventDefault();
|
|
481
|
+
event.stopPropagation();
|
|
482
|
+
this.open.set(false);
|
|
483
|
+
this.onTouched();
|
|
484
|
+
break;
|
|
485
|
+
case 'ArrowDown':
|
|
486
|
+
event.preventDefault();
|
|
487
|
+
this.activeIndex.update((i) => Math.min(i + 1, options.length - 1));
|
|
488
|
+
break;
|
|
489
|
+
case 'ArrowUp':
|
|
490
|
+
event.preventDefault();
|
|
491
|
+
this.activeIndex.update((i) => Math.max(i - 1, 0));
|
|
492
|
+
break;
|
|
493
|
+
case 'Enter':
|
|
494
|
+
case ' ': {
|
|
495
|
+
event.preventDefault();
|
|
496
|
+
const active = options[this.activeIndex()];
|
|
497
|
+
if (active) {
|
|
498
|
+
this.selectOption(active.value);
|
|
499
|
+
}
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Select, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
505
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Select, isStandalone: true, selector: "gbt-select", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, errorMessage: { classPropertyName: "errorMessage", publicName: "errorMessage", isSignal: true, isRequired: false, transformFunction: null }, selectedCountLabel: { classPropertyName: "selectedCountLabel", publicName: "selectedCountLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "document:click": "handleClickOutside($event)", "keydown": "onKeydown($event)", "window:scroll": "updatePanelPosition()", "window:resize": "updatePanelPosition()" } }, providers: [
|
|
506
|
+
{
|
|
507
|
+
provide: NG_VALUE_ACCESSOR,
|
|
508
|
+
useExisting: forwardRef(() => Select),
|
|
509
|
+
multi: true,
|
|
510
|
+
},
|
|
511
|
+
], ngImport: i0, template: "<div class=\"gbt-select\" [class.gbt-select--disabled]=\"isDisabled()\">\n @if (label()) {\n <label [id]=\"labelId()\" [for]=\"id()\" class=\"gbt-select__label\"\n >{{ label() }}{{ required() ? ' *' : '' }}</label\n >\n }\n\n <button\n type=\"button\"\n [id]=\"id()\"\n class=\"gbt-select__trigger\"\n [class.gbt-select__trigger--open]=\"open()\"\n [disabled]=\"isDisabled()\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"open() ? id() + '-listbox' : null\"\n [attr.aria-activedescendant]=\"activeOptionId()\"\n [attr.aria-labelledby]=\"label() ? labelId() + ' ' + id() : null\"\n [attr.aria-required]=\"required() ? true : null\"\n [attr.aria-invalid]=\"errorMessage() ? true : null\"\n [attr.aria-describedby]=\"errorMessage() ? id() + '-error' : null\"\n (click)=\"toggleOpen()\"\n >\n @if (triggerIcon(); as icon) {\n <gbt-icon [name]=\"icon\" class=\"gbt-select__trigger-icon\" aria-hidden=\"true\" />\n }\n <span\n class=\"gbt-select__trigger-label\"\n [class.gbt-select__trigger-label--placeholder]=\"selectedOptions().length === 0\"\n >\n {{ triggerLabel() }}\n </span>\n <gbt-icon name=\"chevron-down\" class=\"gbt-select__chevron\" aria-hidden=\"true\" />\n </button>\n @if (open() && panelStyle(); as style) {\n <ul\n [id]=\"id() + '-listbox'\"\n class=\"gbt-select__panel\"\n role=\"listbox\"\n [attr.aria-label]=\"label() || placeholder()\"\n [attr.aria-multiselectable]=\"multiple()\"\n [style.top]=\"style.top\"\n [style.left]=\"style.left\"\n [style.width]=\"style.width\"\n >\n @for (option of options(); track option.value; let i = $index) {\n <li role=\"presentation\">\n <button\n [id]=\"id() + '-option-' + i\"\n type=\"button\"\n role=\"option\"\n tabindex=\"-1\"\n class=\"gbt-select__option\"\n [class.gbt-select__option--selected]=\"isSelected(option.value)\"\n [class.gbt-select__option--active]=\"i === activeIndex()\"\n [attr.aria-selected]=\"isSelected(option.value)\"\n (click)=\"selectOption(option.value)\"\n (mouseenter)=\"activeIndex.set(i)\"\n >\n @if (option.icon) {\n <gbt-icon [name]=\"option.icon\" class=\"gbt-select__option-icon\" aria-hidden=\"true\" />\n }\n <span class=\"gbt-select__option-label\">{{ option.label }}</span>\n @if (isSelected(option.value)) {\n <gbt-icon name=\"check\" class=\"gbt-select__option-check\" aria-hidden=\"true\" />\n }\n </button>\n </li>\n }\n </ul>\n }\n @if (errorMessage()) {\n <p [id]=\"id() + '-error'\" class=\"gbt-select__error\" role=\"alert\">{{ errorMessage() }}</p>\n }\n</div>\n", styles: [":host{position:relative;display:inline-block;min-width:180px}.gbt-select{display:flex;flex-direction:column;gap:.375rem}.gbt-select--disabled{opacity:.5}.gbt-select__label{font-size:.8125rem;font-weight:600;color:var(--text-secondary)}.gbt-select__trigger{display:flex;align-items:center;gap:8px;width:100%;height:40px;padding:0 10px;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);color:var(--text-primary);font-size:14px;cursor:pointer;transition:border-color .15s cubic-bezier(.4,0,.2,1),box-shadow .15s cubic-bezier(.4,0,.2,1)}.gbt-select__trigger:hover:not(:disabled){border-color:var(--border-color)}.gbt-select__trigger--open{border-color:var(--primary);box-shadow:0 0 0 4px color-mix(in srgb,var(--primary) 12%,transparent)}.gbt-select__trigger:disabled{cursor:not-allowed}.gbt-select__trigger-icon{flex-shrink:0;color:var(--text-secondary)}.gbt-select__trigger-label{flex:1;min-width:0;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gbt-select__trigger-label--placeholder{color:var(--text-discret)}.gbt-select__chevron{flex-shrink:0;color:var(--text-secondary);transition:transform .2s cubic-bezier(.4,0,.2,1)}.gbt-select__trigger--open .gbt-select__chevron{transform:rotate(180deg)}.gbt-select__panel{position:fixed;z-index:1000;margin:0;padding:6px;list-style:none;max-height:280px;overflow-y:auto;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);box-shadow:var(--site-shadow-lg);animation:gbt-select-scale-in .15s cubic-bezier(.34,1.56,.64,1) both}.gbt-select__panel::-webkit-scrollbar{width:6px}.gbt-select__panel::-webkit-scrollbar-track{background:transparent}.gbt-select__panel::-webkit-scrollbar-thumb{background:var(--bg-hover);border-radius:3px}.gbt-select__option{display:flex;align-items:center;gap:8px;width:100%;padding:8px 10px;background:transparent;border:none;border-radius:8px;color:var(--text-primary);font-size:14px;text-align:left;cursor:pointer;transition:background .12s cubic-bezier(.4,0,.2,1)}.gbt-select__option:hover,.gbt-select__option--active{background:var(--bg-hover)}.gbt-select__option--selected{color:var(--primary);font-weight:600}.gbt-select__option-icon{flex-shrink:0;color:var(--text-secondary)}.gbt-select__option--selected .gbt-select__option-icon{color:var(--primary)}.gbt-select__option-label{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gbt-select__option-check{flex-shrink:0;color:var(--primary)}@keyframes gbt-select-scale-in{0%{opacity:0;transform:scale(.97) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.gbt-select__error{font-size:.75rem;color:var(--color-error-text)}@media(prefers-reduced-motion:reduce){.gbt-select__panel{animation:none}.gbt-select__chevron{transition:none}}\n"], dependencies: [{ kind: "component", type: Icon, selector: "gbt-icon", inputs: ["name"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
512
|
+
}
|
|
513
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Select, decorators: [{
|
|
514
|
+
type: Component,
|
|
515
|
+
args: [{ selector: 'gbt-select', standalone: true, imports: [Icon], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
516
|
+
'(document:click)': 'handleClickOutside($event)',
|
|
517
|
+
'(keydown)': 'onKeydown($event)',
|
|
518
|
+
'(window:scroll)': 'updatePanelPosition()',
|
|
519
|
+
'(window:resize)': 'updatePanelPosition()',
|
|
520
|
+
}, providers: [
|
|
521
|
+
{
|
|
522
|
+
provide: NG_VALUE_ACCESSOR,
|
|
523
|
+
useExisting: forwardRef(() => Select),
|
|
524
|
+
multi: true,
|
|
525
|
+
},
|
|
526
|
+
], template: "<div class=\"gbt-select\" [class.gbt-select--disabled]=\"isDisabled()\">\n @if (label()) {\n <label [id]=\"labelId()\" [for]=\"id()\" class=\"gbt-select__label\"\n >{{ label() }}{{ required() ? ' *' : '' }}</label\n >\n }\n\n <button\n type=\"button\"\n [id]=\"id()\"\n class=\"gbt-select__trigger\"\n [class.gbt-select__trigger--open]=\"open()\"\n [disabled]=\"isDisabled()\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"open() ? id() + '-listbox' : null\"\n [attr.aria-activedescendant]=\"activeOptionId()\"\n [attr.aria-labelledby]=\"label() ? labelId() + ' ' + id() : null\"\n [attr.aria-required]=\"required() ? true : null\"\n [attr.aria-invalid]=\"errorMessage() ? true : null\"\n [attr.aria-describedby]=\"errorMessage() ? id() + '-error' : null\"\n (click)=\"toggleOpen()\"\n >\n @if (triggerIcon(); as icon) {\n <gbt-icon [name]=\"icon\" class=\"gbt-select__trigger-icon\" aria-hidden=\"true\" />\n }\n <span\n class=\"gbt-select__trigger-label\"\n [class.gbt-select__trigger-label--placeholder]=\"selectedOptions().length === 0\"\n >\n {{ triggerLabel() }}\n </span>\n <gbt-icon name=\"chevron-down\" class=\"gbt-select__chevron\" aria-hidden=\"true\" />\n </button>\n @if (open() && panelStyle(); as style) {\n <ul\n [id]=\"id() + '-listbox'\"\n class=\"gbt-select__panel\"\n role=\"listbox\"\n [attr.aria-label]=\"label() || placeholder()\"\n [attr.aria-multiselectable]=\"multiple()\"\n [style.top]=\"style.top\"\n [style.left]=\"style.left\"\n [style.width]=\"style.width\"\n >\n @for (option of options(); track option.value; let i = $index) {\n <li role=\"presentation\">\n <button\n [id]=\"id() + '-option-' + i\"\n type=\"button\"\n role=\"option\"\n tabindex=\"-1\"\n class=\"gbt-select__option\"\n [class.gbt-select__option--selected]=\"isSelected(option.value)\"\n [class.gbt-select__option--active]=\"i === activeIndex()\"\n [attr.aria-selected]=\"isSelected(option.value)\"\n (click)=\"selectOption(option.value)\"\n (mouseenter)=\"activeIndex.set(i)\"\n >\n @if (option.icon) {\n <gbt-icon [name]=\"option.icon\" class=\"gbt-select__option-icon\" aria-hidden=\"true\" />\n }\n <span class=\"gbt-select__option-label\">{{ option.label }}</span>\n @if (isSelected(option.value)) {\n <gbt-icon name=\"check\" class=\"gbt-select__option-check\" aria-hidden=\"true\" />\n }\n </button>\n </li>\n }\n </ul>\n }\n @if (errorMessage()) {\n <p [id]=\"id() + '-error'\" class=\"gbt-select__error\" role=\"alert\">{{ errorMessage() }}</p>\n }\n</div>\n", styles: [":host{position:relative;display:inline-block;min-width:180px}.gbt-select{display:flex;flex-direction:column;gap:.375rem}.gbt-select--disabled{opacity:.5}.gbt-select__label{font-size:.8125rem;font-weight:600;color:var(--text-secondary)}.gbt-select__trigger{display:flex;align-items:center;gap:8px;width:100%;height:40px;padding:0 10px;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);color:var(--text-primary);font-size:14px;cursor:pointer;transition:border-color .15s cubic-bezier(.4,0,.2,1),box-shadow .15s cubic-bezier(.4,0,.2,1)}.gbt-select__trigger:hover:not(:disabled){border-color:var(--border-color)}.gbt-select__trigger--open{border-color:var(--primary);box-shadow:0 0 0 4px color-mix(in srgb,var(--primary) 12%,transparent)}.gbt-select__trigger:disabled{cursor:not-allowed}.gbt-select__trigger-icon{flex-shrink:0;color:var(--text-secondary)}.gbt-select__trigger-label{flex:1;min-width:0;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gbt-select__trigger-label--placeholder{color:var(--text-discret)}.gbt-select__chevron{flex-shrink:0;color:var(--text-secondary);transition:transform .2s cubic-bezier(.4,0,.2,1)}.gbt-select__trigger--open .gbt-select__chevron{transform:rotate(180deg)}.gbt-select__panel{position:fixed;z-index:1000;margin:0;padding:6px;list-style:none;max-height:280px;overflow-y:auto;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);box-shadow:var(--site-shadow-lg);animation:gbt-select-scale-in .15s cubic-bezier(.34,1.56,.64,1) both}.gbt-select__panel::-webkit-scrollbar{width:6px}.gbt-select__panel::-webkit-scrollbar-track{background:transparent}.gbt-select__panel::-webkit-scrollbar-thumb{background:var(--bg-hover);border-radius:3px}.gbt-select__option{display:flex;align-items:center;gap:8px;width:100%;padding:8px 10px;background:transparent;border:none;border-radius:8px;color:var(--text-primary);font-size:14px;text-align:left;cursor:pointer;transition:background .12s cubic-bezier(.4,0,.2,1)}.gbt-select__option:hover,.gbt-select__option--active{background:var(--bg-hover)}.gbt-select__option--selected{color:var(--primary);font-weight:600}.gbt-select__option-icon{flex-shrink:0;color:var(--text-secondary)}.gbt-select__option--selected .gbt-select__option-icon{color:var(--primary)}.gbt-select__option-label{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gbt-select__option-check{flex-shrink:0;color:var(--primary)}@keyframes gbt-select-scale-in{0%{opacity:0;transform:scale(.97) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}.gbt-select__error{font-size:.75rem;color:var(--color-error-text)}@media(prefers-reduced-motion:reduce){.gbt-select__panel{animation:none}.gbt-select__chevron{transition:none}}\n"] }]
|
|
527
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: true }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], errorMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessage", required: false }] }], selectedCountLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedCountLabel", required: false }] }] } });
|
|
528
|
+
|
|
529
|
+
class Modal {
|
|
530
|
+
isOpen = input.required(/* @ts-ignore */
|
|
531
|
+
...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
532
|
+
heading = input('', /* @ts-ignore */
|
|
533
|
+
...(ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []));
|
|
534
|
+
headingLevel = input(2, /* @ts-ignore */
|
|
535
|
+
...(ngDevMode ? [{ debugName: "headingLevel" }] : /* istanbul ignore next */ []));
|
|
536
|
+
closeLabel = input('Close', /* @ts-ignore */
|
|
537
|
+
...(ngDevMode ? [{ debugName: "closeLabel" }] : /* istanbul ignore next */ []));
|
|
538
|
+
closed = output();
|
|
539
|
+
dialog = viewChild('dialog', /* @ts-ignore */
|
|
540
|
+
...(ngDevMode ? [{ debugName: "dialog" }] : /* istanbul ignore next */ []));
|
|
541
|
+
previouslyFocused = null;
|
|
542
|
+
constructor() {
|
|
543
|
+
effect(() => {
|
|
544
|
+
if (this.isOpen()) {
|
|
545
|
+
this.previouslyFocused = document.activeElement;
|
|
546
|
+
queueMicrotask(() => this.dialog()?.nativeElement.focus());
|
|
547
|
+
}
|
|
548
|
+
else if (this.previouslyFocused) {
|
|
549
|
+
const target = this.previouslyFocused;
|
|
550
|
+
this.previouslyFocused = null;
|
|
551
|
+
target.focus();
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
ngOnDestroy() {
|
|
556
|
+
this.previouslyFocused?.focus();
|
|
557
|
+
}
|
|
558
|
+
onEscape() {
|
|
559
|
+
if (this.isOpen()) {
|
|
560
|
+
this.closed.emit();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
onBackdropClick(event) {
|
|
564
|
+
if (event.target === event.currentTarget) {
|
|
565
|
+
this.closed.emit();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
onDialogKeydown(event) {
|
|
569
|
+
if (event.key !== 'Tab') {
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const dialog = this.dialog()?.nativeElement;
|
|
573
|
+
if (!dialog) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
const focusable = dialog.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');
|
|
577
|
+
if (focusable.length === 0) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
const first = focusable[0];
|
|
581
|
+
const last = focusable[focusable.length - 1];
|
|
582
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
583
|
+
event.preventDefault();
|
|
584
|
+
last.focus();
|
|
585
|
+
}
|
|
586
|
+
else if (!event.shiftKey && document.activeElement === last) {
|
|
587
|
+
event.preventDefault();
|
|
588
|
+
first.focus();
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Modal, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
592
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Modal, isStandalone: true, selector: "gbt-modal", inputs: { isOpen: { classPropertyName: "isOpen", publicName: "isOpen", isSignal: true, isRequired: true, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, headingLevel: { classPropertyName: "headingLevel", publicName: "headingLevel", isSignal: true, isRequired: false, transformFunction: null }, closeLabel: { classPropertyName: "closeLabel", publicName: "closeLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed" }, host: { listeners: { "document:keydown.escape": "onEscape()" } }, viewQueries: [{ propertyName: "dialog", first: true, predicate: ["dialog"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (isOpen()) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <div class=\"gbt-modal__backdrop\" (click)=\"onBackdropClick($event)\">\n <div\n class=\"gbt-modal__dialog\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-label]=\"heading() || null\"\n tabindex=\"-1\"\n #dialog\n (keydown)=\"onDialogKeydown($event)\"\n >\n <header class=\"gbt-modal__header\">\n @switch (headingLevel()) {\n @case (1) {\n <h1 class=\"gbt-modal__title\">{{ heading() }}</h1>\n }\n @case (3) {\n <h3 class=\"gbt-modal__title\">{{ heading() }}</h3>\n }\n @case (4) {\n <h4 class=\"gbt-modal__title\">{{ heading() }}</h4>\n }\n @case (5) {\n <h5 class=\"gbt-modal__title\">{{ heading() }}</h5>\n }\n @case (6) {\n <h6 class=\"gbt-modal__title\">{{ heading() }}</h6>\n }\n @default {\n <h2 class=\"gbt-modal__title\">{{ heading() }}</h2>\n }\n }\n <button\n type=\"button\"\n class=\"gbt-modal__close\"\n (click)=\"closed.emit()\"\n [attr.aria-label]=\"closeLabel()\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n </header>\n <div class=\"gbt-modal__body\">\n <ng-content />\n </div>\n </div>\n </div>\n}\n", styles: [".gbt-modal__backdrop{position:fixed;inset:0;background:#0006;display:flex;align-items:center;justify-content:center;z-index:100}.gbt-modal__dialog{background:var(--bg-principal);border-radius:var(--site-border-radius);box-shadow:var(--site-shadow-lg);width:min(90vw,480px);max-height:90vh;overflow-y:auto}.gbt-modal__dialog:focus{outline:none}.gbt-modal__dialog:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-modal__header{display:flex;align-items:center;justify-content:space-between;padding:1rem 1.25rem;border-bottom:1px solid var(--border-color)}.gbt-modal__header .gbt-modal__title{font-size:1rem;font-weight:600;color:var(--text-primary);margin:0}.gbt-modal__close{position:relative;display:inline-flex;background:none;border:none;color:var(--text-discret);cursor:pointer}.gbt-modal__close:before{content:\"\";position:absolute;inset:50% auto auto 50%;width:max(100%,24px);height:max(100%,24px);transform:translate(-50%,-50%)}.gbt-modal__body{padding:1.25rem;display:flex;flex-direction:column;gap:1rem}.gbt-modal__body>form{display:flex;flex-direction:column;gap:1rem}\n"], dependencies: [{ kind: "component", type: Icon, selector: "gbt-icon", inputs: ["name"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
593
|
+
}
|
|
594
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Modal, decorators: [{
|
|
595
|
+
type: Component,
|
|
596
|
+
args: [{ selector: 'gbt-modal', standalone: true, imports: [Icon], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (isOpen()) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <div class=\"gbt-modal__backdrop\" (click)=\"onBackdropClick($event)\">\n <div\n class=\"gbt-modal__dialog\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-label]=\"heading() || null\"\n tabindex=\"-1\"\n #dialog\n (keydown)=\"onDialogKeydown($event)\"\n >\n <header class=\"gbt-modal__header\">\n @switch (headingLevel()) {\n @case (1) {\n <h1 class=\"gbt-modal__title\">{{ heading() }}</h1>\n }\n @case (3) {\n <h3 class=\"gbt-modal__title\">{{ heading() }}</h3>\n }\n @case (4) {\n <h4 class=\"gbt-modal__title\">{{ heading() }}</h4>\n }\n @case (5) {\n <h5 class=\"gbt-modal__title\">{{ heading() }}</h5>\n }\n @case (6) {\n <h6 class=\"gbt-modal__title\">{{ heading() }}</h6>\n }\n @default {\n <h2 class=\"gbt-modal__title\">{{ heading() }}</h2>\n }\n }\n <button\n type=\"button\"\n class=\"gbt-modal__close\"\n (click)=\"closed.emit()\"\n [attr.aria-label]=\"closeLabel()\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n </header>\n <div class=\"gbt-modal__body\">\n <ng-content />\n </div>\n </div>\n </div>\n}\n", styles: [".gbt-modal__backdrop{position:fixed;inset:0;background:#0006;display:flex;align-items:center;justify-content:center;z-index:100}.gbt-modal__dialog{background:var(--bg-principal);border-radius:var(--site-border-radius);box-shadow:var(--site-shadow-lg);width:min(90vw,480px);max-height:90vh;overflow-y:auto}.gbt-modal__dialog:focus{outline:none}.gbt-modal__dialog:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-modal__header{display:flex;align-items:center;justify-content:space-between;padding:1rem 1.25rem;border-bottom:1px solid var(--border-color)}.gbt-modal__header .gbt-modal__title{font-size:1rem;font-weight:600;color:var(--text-primary);margin:0}.gbt-modal__close{position:relative;display:inline-flex;background:none;border:none;color:var(--text-discret);cursor:pointer}.gbt-modal__close:before{content:\"\";position:absolute;inset:50% auto auto 50%;width:max(100%,24px);height:max(100%,24px);transform:translate(-50%,-50%)}.gbt-modal__body{padding:1.25rem;display:flex;flex-direction:column;gap:1rem}.gbt-modal__body>form{display:flex;flex-direction:column;gap:1rem}\n"] }]
|
|
597
|
+
}], ctorParameters: () => [], propDecorators: { isOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "isOpen", required: true }] }], heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], headingLevel: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingLevel", required: false }] }], closeLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeLabel", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }], dialog: [{ type: i0.ViewChild, args: ['dialog', { isSignal: true }] }], onEscape: [{
|
|
598
|
+
type: HostListener,
|
|
599
|
+
args: ['document:keydown.escape']
|
|
600
|
+
}] } });
|
|
601
|
+
|
|
602
|
+
class Table {
|
|
603
|
+
data = input.required(/* @ts-ignore */
|
|
604
|
+
...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
605
|
+
columns = input.required(/* @ts-ignore */
|
|
606
|
+
...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
607
|
+
trackBy = input(null, /* @ts-ignore */
|
|
608
|
+
...(ngDevMode ? [{ debugName: "trackBy" }] : /* istanbul ignore next */ []));
|
|
609
|
+
emptyMessage = input('No data', /* @ts-ignore */
|
|
610
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
611
|
+
caption = input.required(/* @ts-ignore */
|
|
612
|
+
...(ngDevMode ? [{ debugName: "caption" }] : /* istanbul ignore next */ []));
|
|
613
|
+
clickableRows = input(false, { ...(ngDevMode ? { debugName: "clickableRows" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
614
|
+
rowClick = output();
|
|
615
|
+
trackRow = (index, row) => {
|
|
616
|
+
const identify = this.trackBy();
|
|
617
|
+
return identify ? identify(row) : index;
|
|
618
|
+
};
|
|
619
|
+
onRowKeydown(event, row) {
|
|
620
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
621
|
+
event.preventDefault();
|
|
622
|
+
this.rowClick.emit(row);
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
cellValue(row, column) {
|
|
626
|
+
return column.format ? column.format(row) : row[column.key];
|
|
627
|
+
}
|
|
628
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Table, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
629
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Table, isStandalone: true, selector: "gbt-table", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: true, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: true, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, caption: { classPropertyName: "caption", publicName: "caption", isSignal: true, isRequired: true, transformFunction: null }, clickableRows: { classPropertyName: "clickableRows", publicName: "clickableRows", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { rowClick: "rowClick" }, ngImport: i0, template: "<table class=\"gbt-table\">\n <caption>\n {{\n caption()\n }}\n </caption>\n <thead>\n <tr>\n @for (column of columns(); track column.key) {\n <th scope=\"col\">{{ column.label }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of data(); track trackRow($index, row)) {\n <tr\n [class.gbt-table__row--clickable]=\"clickableRows()\"\n [attr.tabindex]=\"clickableRows() ? 0 : null\"\n (click)=\"clickableRows() && rowClick.emit(row)\"\n (keydown)=\"clickableRows() && onRowKeydown($event, row)\"\n >\n @for (column of columns(); track column.key) {\n <td>{{ cellValue(row, column) }}</td>\n }\n </tr>\n } @empty {\n <tr class=\"gbt-table__empty\">\n <td [attr.colspan]=\"columns().length\">{{ emptyMessage() }}</td>\n </tr>\n }\n </tbody>\n</table>\n", styles: [".gbt-table{width:100%;border-collapse:collapse;font-size:.875rem}.gbt-table caption{text-align:left;padding:0 0 .625rem;font-weight:600;color:var(--text-primary)}.gbt-table th{text-align:left;padding:.625rem .75rem;font-weight:600;color:var(--text-secondary);border-bottom:1px solid var(--border-color)}.gbt-table td{padding:.625rem .75rem;color:var(--text-primary);border-bottom:1px solid var(--border-color)}.gbt-table tbody tr{transition:background-color var(--site-transition-fast)}.gbt-table tbody tr.gbt-table__row--clickable{cursor:pointer}.gbt-table tbody tr.gbt-table__row--clickable:hover{background:var(--bg-hover)}.gbt-table tbody tr:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}.gbt-table__empty{cursor:default;text-align:center;color:var(--text-discret)}.gbt-table__empty:hover{background:none}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
630
|
+
}
|
|
631
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Table, decorators: [{
|
|
632
|
+
type: Component,
|
|
633
|
+
args: [{ selector: 'gbt-table', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<table class=\"gbt-table\">\n <caption>\n {{\n caption()\n }}\n </caption>\n <thead>\n <tr>\n @for (column of columns(); track column.key) {\n <th scope=\"col\">{{ column.label }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of data(); track trackRow($index, row)) {\n <tr\n [class.gbt-table__row--clickable]=\"clickableRows()\"\n [attr.tabindex]=\"clickableRows() ? 0 : null\"\n (click)=\"clickableRows() && rowClick.emit(row)\"\n (keydown)=\"clickableRows() && onRowKeydown($event, row)\"\n >\n @for (column of columns(); track column.key) {\n <td>{{ cellValue(row, column) }}</td>\n }\n </tr>\n } @empty {\n <tr class=\"gbt-table__empty\">\n <td [attr.colspan]=\"columns().length\">{{ emptyMessage() }}</td>\n </tr>\n }\n </tbody>\n</table>\n", styles: [".gbt-table{width:100%;border-collapse:collapse;font-size:.875rem}.gbt-table caption{text-align:left;padding:0 0 .625rem;font-weight:600;color:var(--text-primary)}.gbt-table th{text-align:left;padding:.625rem .75rem;font-weight:600;color:var(--text-secondary);border-bottom:1px solid var(--border-color)}.gbt-table td{padding:.625rem .75rem;color:var(--text-primary);border-bottom:1px solid var(--border-color)}.gbt-table tbody tr{transition:background-color var(--site-transition-fast)}.gbt-table tbody tr.gbt-table__row--clickable{cursor:pointer}.gbt-table tbody tr.gbt-table__row--clickable:hover{background:var(--bg-hover)}.gbt-table tbody tr:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}.gbt-table__empty{cursor:default;text-align:center;color:var(--text-discret)}.gbt-table__empty:hover{background:none}\n"] }]
|
|
634
|
+
}], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: true }] }], trackBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackBy", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], caption: [{ type: i0.Input, args: [{ isSignal: true, alias: "caption", required: true }] }], clickableRows: [{ type: i0.Input, args: [{ isSignal: true, alias: "clickableRows", required: false }] }], rowClick: [{ type: i0.Output, args: ["rowClick"] }] } });
|
|
635
|
+
|
|
636
|
+
let nextSearchBarId = 0;
|
|
637
|
+
class SearchBar {
|
|
638
|
+
elementRef = inject(ElementRef);
|
|
639
|
+
id = input(`gbt-search-bar-${++nextSearchBarId}`, /* @ts-ignore */
|
|
640
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
641
|
+
results = input(null, /* @ts-ignore */
|
|
642
|
+
...(ngDevMode ? [{ debugName: "results" }] : /* istanbul ignore next */ []));
|
|
643
|
+
groupedResults = input(null, /* @ts-ignore */
|
|
644
|
+
...(ngDevMode ? [{ debugName: "groupedResults" }] : /* istanbul ignore next */ []));
|
|
645
|
+
placeholder = input('Search…', /* @ts-ignore */
|
|
646
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
647
|
+
ariaLabel = input('', /* @ts-ignore */
|
|
648
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
649
|
+
displayFn = input((item) => String(item), /* @ts-ignore */
|
|
650
|
+
...(ngDevMode ? [{ debugName: "displayFn" }] : /* istanbul ignore next */ []));
|
|
651
|
+
itemTemplate = input(/* @ts-ignore */
|
|
652
|
+
...(ngDevMode ? [undefined, { debugName: "itemTemplate" }] : /* istanbul ignore next */ []));
|
|
653
|
+
keepQueryOnSelect = input(false, /* @ts-ignore */
|
|
654
|
+
...(ngDevMode ? [{ debugName: "keepQueryOnSelect" }] : /* istanbul ignore next */ []));
|
|
655
|
+
noResultsMessage = input('No results', /* @ts-ignore */
|
|
656
|
+
...(ngDevMode ? [{ debugName: "noResultsMessage" }] : /* istanbul ignore next */ []));
|
|
657
|
+
noResultsHint = input('Try a different search.', /* @ts-ignore */
|
|
658
|
+
...(ngDevMode ? [{ debugName: "noResultsHint" }] : /* istanbul ignore next */ []));
|
|
659
|
+
clearLabel = input('Clear search', /* @ts-ignore */
|
|
660
|
+
...(ngDevMode ? [{ debugName: "clearLabel" }] : /* istanbul ignore next */ []));
|
|
661
|
+
resultsAnnouncement = input((count) => `${count} result${count !== 1 ? 's' : ''}`, /* @ts-ignore */
|
|
662
|
+
...(ngDevMode ? [{ debugName: "resultsAnnouncement" }] : /* istanbul ignore next */ []));
|
|
663
|
+
navigateHint = input('Navigate', /* @ts-ignore */
|
|
664
|
+
...(ngDevMode ? [{ debugName: "navigateHint" }] : /* istanbul ignore next */ []));
|
|
665
|
+
selectHint = input('Select', /* @ts-ignore */
|
|
666
|
+
...(ngDevMode ? [{ debugName: "selectHint" }] : /* istanbul ignore next */ []));
|
|
667
|
+
closeHint = input('Close', /* @ts-ignore */
|
|
668
|
+
...(ngDevMode ? [{ debugName: "closeHint" }] : /* istanbul ignore next */ []));
|
|
669
|
+
queryChange = output();
|
|
670
|
+
itemSelected = output();
|
|
671
|
+
clear = output();
|
|
672
|
+
isFocused = signal(false, /* @ts-ignore */
|
|
673
|
+
...(ngDevMode ? [{ debugName: "isFocused" }] : /* istanbul ignore next */ []));
|
|
674
|
+
showResults = signal(false, /* @ts-ignore */
|
|
675
|
+
...(ngDevMode ? [{ debugName: "showResults" }] : /* istanbul ignore next */ []));
|
|
676
|
+
searchQuery = signal('', /* @ts-ignore */
|
|
677
|
+
...(ngDevMode ? [{ debugName: "searchQuery" }] : /* istanbul ignore next */ []));
|
|
678
|
+
activeIndex = signal(0, /* @ts-ignore */
|
|
679
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
680
|
+
searchInput = viewChild('searchInput', /* @ts-ignore */
|
|
681
|
+
...(ngDevMode ? [{ debugName: "searchInput" }] : /* istanbul ignore next */ []));
|
|
682
|
+
hasGroupedResultsInput = computed(() => !!this.groupedResults(), /* @ts-ignore */
|
|
683
|
+
...(ngDevMode ? [{ debugName: "hasGroupedResultsInput" }] : /* istanbul ignore next */ []));
|
|
684
|
+
allVisibleItems = computed(() => {
|
|
685
|
+
if (this.groupedResults()) {
|
|
686
|
+
return this.groupedResults().flatMap((category) => category.items);
|
|
687
|
+
}
|
|
688
|
+
return this.results() ?? [];
|
|
689
|
+
}, /* @ts-ignore */
|
|
690
|
+
...(ngDevMode ? [{ debugName: "allVisibleItems" }] : /* istanbul ignore next */ []));
|
|
691
|
+
showOverlay = computed(() => this.showResults(), /* @ts-ignore */
|
|
692
|
+
...(ngDevMode ? [{ debugName: "showOverlay" }] : /* istanbul ignore next */ []));
|
|
693
|
+
panelId = computed(() => `${this.id()}-panel`, /* @ts-ignore */
|
|
694
|
+
...(ngDevMode ? [{ debugName: "panelId" }] : /* istanbul ignore next */ []));
|
|
695
|
+
itemDomId(index) {
|
|
696
|
+
return `${this.id()}-item-${index}`;
|
|
697
|
+
}
|
|
698
|
+
indexedGroupedResults = computed(() => {
|
|
699
|
+
const grouped = this.groupedResults();
|
|
700
|
+
if (!grouped)
|
|
701
|
+
return null;
|
|
702
|
+
const format = this.displayFn();
|
|
703
|
+
let index = 0;
|
|
704
|
+
return grouped.map((category) => ({
|
|
705
|
+
...category,
|
|
706
|
+
indexedItems: category.items.map((item) => ({
|
|
707
|
+
item,
|
|
708
|
+
index: index++,
|
|
709
|
+
formatted: format(item),
|
|
710
|
+
})),
|
|
711
|
+
}));
|
|
712
|
+
}, /* @ts-ignore */
|
|
713
|
+
...(ngDevMode ? [{ debugName: "indexedGroupedResults" }] : /* istanbul ignore next */ []));
|
|
714
|
+
indexedResults = computed(() => {
|
|
715
|
+
const format = this.displayFn();
|
|
716
|
+
return (this.results() ?? []).map((item, index) => ({ item, index, formatted: format(item) }));
|
|
717
|
+
}, /* @ts-ignore */
|
|
718
|
+
...(ngDevMode ? [{ debugName: "indexedResults" }] : /* istanbul ignore next */ []));
|
|
719
|
+
activeItemDomId = computed(() => {
|
|
720
|
+
if (!this.showOverlay())
|
|
721
|
+
return null;
|
|
722
|
+
const idx = this.activeIndex();
|
|
723
|
+
return idx >= 0 && idx < this.allVisibleItems().length ? this.itemDomId(idx) : null;
|
|
724
|
+
}, /* @ts-ignore */
|
|
725
|
+
...(ngDevMode ? [{ debugName: "activeItemDomId" }] : /* istanbul ignore next */ []));
|
|
726
|
+
resultCount = computed(() => this.showOverlay() ? this.allVisibleItems().length : 0, /* @ts-ignore */
|
|
727
|
+
...(ngDevMode ? [{ debugName: "resultCount" }] : /* istanbul ignore next */ []));
|
|
728
|
+
hasGroupedResults = computed(() => this.hasGroupedResultsInput() && !!this.groupedResults()?.some((c) => c.items.length > 0), /* @ts-ignore */
|
|
729
|
+
...(ngDevMode ? [{ debugName: "hasGroupedResults" }] : /* istanbul ignore next */ []));
|
|
730
|
+
hasNoResults = computed(() => this.allVisibleItems().length === 0, /* @ts-ignore */
|
|
731
|
+
...(ngDevMode ? [{ debugName: "hasNoResults" }] : /* istanbul ignore next */ []));
|
|
732
|
+
onNavigationKeydown(event) {
|
|
733
|
+
if (!this.isFocused() || !this.showOverlay())
|
|
734
|
+
return;
|
|
735
|
+
if (event.key === 'Escape') {
|
|
736
|
+
event.preventDefault();
|
|
737
|
+
this.blurSearch();
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
const items = this.allVisibleItems();
|
|
741
|
+
if (items.length === 0)
|
|
742
|
+
return;
|
|
743
|
+
switch (event.key) {
|
|
744
|
+
case 'ArrowDown':
|
|
745
|
+
event.preventDefault();
|
|
746
|
+
this.activeIndex.update((i) => Math.min(i + 1, items.length - 1));
|
|
747
|
+
break;
|
|
748
|
+
case 'ArrowUp':
|
|
749
|
+
event.preventDefault();
|
|
750
|
+
this.activeIndex.update((i) => Math.max(i - 1, 0));
|
|
751
|
+
break;
|
|
752
|
+
case 'Enter': {
|
|
753
|
+
const active = items[this.activeIndex()];
|
|
754
|
+
if (!active)
|
|
755
|
+
break;
|
|
756
|
+
event.preventDefault();
|
|
757
|
+
this.onSelect(active);
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
handleClickOutside(event) {
|
|
763
|
+
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
764
|
+
this.showResults.set(false);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
focusSearch() {
|
|
768
|
+
this.searchInput()?.nativeElement.focus();
|
|
769
|
+
}
|
|
770
|
+
blurSearch() {
|
|
771
|
+
this.searchInput()?.nativeElement.blur();
|
|
772
|
+
this.showResults.set(false);
|
|
773
|
+
}
|
|
774
|
+
onFocus() {
|
|
775
|
+
this.isFocused.set(true);
|
|
776
|
+
if (this.searchQuery().length > 0)
|
|
777
|
+
this.showResults.set(true);
|
|
778
|
+
}
|
|
779
|
+
onBlur() {
|
|
780
|
+
this.isFocused.set(false);
|
|
781
|
+
setTimeout(() => {
|
|
782
|
+
if (!this.elementRef.nativeElement.contains(document.activeElement)) {
|
|
783
|
+
this.showResults.set(false);
|
|
784
|
+
}
|
|
785
|
+
}, 200);
|
|
786
|
+
}
|
|
787
|
+
onInput(event) {
|
|
788
|
+
const value = event.target.value;
|
|
789
|
+
this.searchQuery.set(value);
|
|
790
|
+
this.activeIndex.set(0);
|
|
791
|
+
this.showResults.set(value.length > 0);
|
|
792
|
+
this.queryChange.emit(value);
|
|
793
|
+
}
|
|
794
|
+
onClear() {
|
|
795
|
+
this.searchQuery.set('');
|
|
796
|
+
this.activeIndex.set(0);
|
|
797
|
+
this.showResults.set(false);
|
|
798
|
+
this.clear.emit();
|
|
799
|
+
this.focusSearch();
|
|
800
|
+
}
|
|
801
|
+
onSelect(item) {
|
|
802
|
+
this.itemSelected.emit(item);
|
|
803
|
+
this.showResults.set(false);
|
|
804
|
+
this.searchQuery.set(this.keepQueryOnSelect() ? this.displayFn()(item) : '');
|
|
805
|
+
}
|
|
806
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: SearchBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
807
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: SearchBar, isStandalone: true, selector: "gbt-search-bar", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, results: { classPropertyName: "results", publicName: "results", isSignal: true, isRequired: false, transformFunction: null }, groupedResults: { classPropertyName: "groupedResults", publicName: "groupedResults", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, displayFn: { classPropertyName: "displayFn", publicName: "displayFn", isSignal: true, isRequired: false, transformFunction: null }, itemTemplate: { classPropertyName: "itemTemplate", publicName: "itemTemplate", isSignal: true, isRequired: false, transformFunction: null }, keepQueryOnSelect: { classPropertyName: "keepQueryOnSelect", publicName: "keepQueryOnSelect", isSignal: true, isRequired: false, transformFunction: null }, noResultsMessage: { classPropertyName: "noResultsMessage", publicName: "noResultsMessage", isSignal: true, isRequired: false, transformFunction: null }, noResultsHint: { classPropertyName: "noResultsHint", publicName: "noResultsHint", isSignal: true, isRequired: false, transformFunction: null }, clearLabel: { classPropertyName: "clearLabel", publicName: "clearLabel", isSignal: true, isRequired: false, transformFunction: null }, resultsAnnouncement: { classPropertyName: "resultsAnnouncement", publicName: "resultsAnnouncement", isSignal: true, isRequired: false, transformFunction: null }, navigateHint: { classPropertyName: "navigateHint", publicName: "navigateHint", isSignal: true, isRequired: false, transformFunction: null }, selectHint: { classPropertyName: "selectHint", publicName: "selectHint", isSignal: true, isRequired: false, transformFunction: null }, closeHint: { classPropertyName: "closeHint", publicName: "closeHint", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { queryChange: "queryChange", itemSelected: "itemSelected", clear: "clear" }, host: { listeners: { "keydown": "onNavigationKeydown($event)", "document:click": "handleClickOutside($event)" } }, viewQueries: [{ propertyName: "searchInput", first: true, predicate: ["searchInput"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n<div class=\"gbt-sb-trigger\" [class.gbt-sb-trigger--open]=\"isFocused()\" (click)=\"focusSearch()\">\n <gbt-icon name=\"search\" class=\"gbt-sb-trigger__icon\" aria-hidden=\"true\" />\n <input\n #searchInput\n type=\"text\"\n role=\"combobox\"\n class=\"gbt-sb-trigger__input\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"ariaLabel() || placeholder()\"\n [value]=\"searchQuery()\"\n [attr.aria-expanded]=\"showOverlay()\"\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n [attr.aria-controls]=\"showOverlay() ? panelId() : null\"\n [attr.aria-activedescendant]=\"activeItemDomId()\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur()\"\n (input)=\"onInput($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n @if (searchQuery().length > 0) {\n <button\n type=\"button\"\n class=\"gbt-sb-trigger__clear\"\n (click)=\"onClear()\"\n [attr.aria-label]=\"clearLabel()\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n }\n</div>\n@if (showOverlay()) {\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">\n {{ resultsAnnouncement()(resultCount()) }}\n </div>\n}\n@if (showOverlay()) {\n <div class=\"gbt-sb-backdrop\" (click)=\"blurSearch()\" aria-hidden=\"true\"></div>\n <ng-template #footer>\n <div class=\"gbt-sb-footer\" aria-hidden=\"true\">\n <span class=\"gbt-sb-footer__hint\">\n <kbd class=\"gbt-sb-kbd gbt-sb-kbd--sm\">\u2191</kbd>\n <kbd class=\"gbt-sb-kbd gbt-sb-kbd--sm\">\u2193</kbd>\n {{ navigateHint() }}\n </span>\n <span class=\"gbt-sb-footer__hint\">\n <kbd class=\"gbt-sb-kbd gbt-sb-kbd--sm\">\u21B5</kbd>\n {{ selectHint() }}\n </span>\n <span class=\"gbt-sb-footer__hint\">\n <kbd class=\"gbt-sb-kbd gbt-sb-kbd--sm\">Esc</kbd>\n {{ closeHint() }}\n </span>\n </div>\n </ng-template>\n @if (hasNoResults()) {\n <div [id]=\"panelId()\" class=\"gbt-sb-panel\">\n <div class=\"gbt-sb-state\" role=\"status\">\n <gbt-icon name=\"search\" class=\"gbt-sb-state__icon\" aria-hidden=\"true\" />\n <span>{{ noResultsMessage() }}</span>\n <p class=\"gbt-sb-state__hint\">{{ noResultsHint() }}</p>\n </div>\n <ng-container [ngTemplateOutlet]=\"footer\"></ng-container>\n </div>\n } @else {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <div\n [id]=\"panelId()\"\n class=\"gbt-sb-panel\"\n role=\"listbox\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"$event.stopPropagation()\"\n >\n @if (hasGroupedResults()) {\n <div class=\"gbt-sb-list\">\n @for (category of indexedGroupedResults(); track category.label) {\n @if (category.items.length > 0) {\n <div class=\"gbt-sb-group-label\">\n @if (category.icon) {\n <gbt-icon [name]=\"category.icon\" aria-hidden=\"true\" />\n }\n {{ category.label }}\n <span class=\"gbt-sb-group-count\" aria-hidden=\"true\">{{\n category.items.length\n }}</span>\n </div>\n @for (entry of category.indexedItems; track entry.index) {\n <button\n type=\"button\"\n role=\"option\"\n tabindex=\"-1\"\n [id]=\"itemDomId(entry.index)\"\n class=\"gbt-sb-item\"\n [attr.aria-selected]=\"entry.index === activeIndex()\"\n [class.gbt-sb-item--active]=\"entry.index === activeIndex()\"\n (click)=\"onSelect(entry.item)\"\n (mouseenter)=\"activeIndex.set(entry.index)\"\n >\n @if (itemTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()!\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.item }\"\n ></ng-container>\n } @else {\n @if (category.icon) {\n <gbt-icon\n [name]=\"category.icon\"\n class=\"gbt-sb-item__icon\"\n aria-hidden=\"true\"\n />\n }\n <span class=\"gbt-sb-item__label\">{{ entry.formatted }}</span>\n }\n </button>\n }\n }\n }\n </div>\n } @else if (results() && results()!.length > 0) {\n <div class=\"gbt-sb-list\">\n @for (entry of indexedResults(); track entry.index) {\n <button\n type=\"button\"\n role=\"option\"\n tabindex=\"-1\"\n [id]=\"itemDomId(entry.index)\"\n class=\"gbt-sb-item\"\n [attr.aria-selected]=\"entry.index === activeIndex()\"\n [class.gbt-sb-item--active]=\"entry.index === activeIndex()\"\n (click)=\"onSelect(entry.item)\"\n (mouseenter)=\"activeIndex.set(entry.index)\"\n >\n @if (itemTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()!\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.item }\"\n ></ng-container>\n } @else {\n <span class=\"gbt-sb-item__label\">{{ entry.formatted }}</span>\n }\n </button>\n }\n </div>\n }\n\n <ng-container [ngTemplateOutlet]=\"footer\"></ng-container>\n </div>\n }\n}\n", styles: [":host{position:relative;display:block}.gbt-sb-trigger{position:relative;z-index:1000;box-sizing:border-box;display:flex;align-items:center;gap:8px;height:40px;width:340px;padding:0 12px;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:16px;transition:width .35s cubic-bezier(.34,1.56,.64,1),border-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s cubic-bezier(.4,0,.2,1);cursor:text}.gbt-sb-trigger--open{width:420px;border-color:var(--primary);box-shadow:0 0 0 4px color-mix(in srgb,var(--primary) 12%,transparent)}.gbt-sb-trigger__icon{flex-shrink:0;color:var(--text-secondary);transition:color .2s cubic-bezier(.4,0,.2,1),transform .3s cubic-bezier(.34,1.56,.64,1)}.gbt-sb-trigger--open .gbt-sb-trigger__icon{color:var(--primary);transform:scale(1.1) rotate(5deg)}.gbt-sb-trigger__input{flex:1;min-width:0;border:none;outline:none;background:transparent;color:var(--text-primary);font-size:14px;line-height:1.5}.gbt-sb-trigger__input::placeholder{color:var(--text-secondary)}.gbt-sb-trigger__input:focus-visible{outline:2px solid var(--primary);outline-offset:2px;border-radius:4px}.gbt-sb-trigger__clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;background:transparent;border:none;border-radius:6px;color:var(--text-secondary);cursor:pointer;transition:background .15s cubic-bezier(.4,0,.2,1),color .15s cubic-bezier(.4,0,.2,1)}.gbt-sb-trigger__clear:hover{background:var(--bg-hover);color:var(--text-primary)}.gbt-sb-trigger__clear:active{transform:scale(.9)}.gbt-sb-backdrop{position:fixed;inset:0;background:#0000004d;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);z-index:999;animation:gbt-search-bar-fade-in .2s cubic-bezier(.4,0,.2,1) both}.gbt-sb-panel{position:absolute;top:calc(100% + 8px);left:50%;transform:translate(-50%);width:420px;max-height:460px;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius);box-shadow:0 16px 48px #0000002e,0 4px 12px #00000014;overflow:hidden;display:flex;flex-direction:column;z-index:1001;animation:gbt-search-bar-scale-in .25s cubic-bezier(.34,1.56,.64,1) both}.gbt-sb-list{flex:1;overflow-y:auto;padding:6px;display:flex;flex-direction:column}.gbt-sb-list::-webkit-scrollbar{width:6px}.gbt-sb-list::-webkit-scrollbar-track{background:transparent}.gbt-sb-list::-webkit-scrollbar-thumb{background:var(--bg-hover);border-radius:3px}.gbt-sb-list::-webkit-scrollbar-thumb:hover{background:var(--border-color)}.gbt-sb-group-label{display:flex;align-items:center;gap:6px;padding:10px 10px 4px;color:var(--text-secondary);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px}.gbt-sb-group-count{margin-left:auto;padding:1px 7px;background:var(--bg-hover);border-radius:10px;font-size:11px;font-weight:600;color:var(--text-secondary)}.gbt-sb-item{display:flex;align-items:center;gap:10px;width:100%;padding:9px 10px;background:transparent;border:none;border-radius:8px;text-align:left;cursor:pointer;transition:background .12s cubic-bezier(.4,0,.2,1)}.gbt-sb-item:hover{background:var(--bg-hover)}.gbt-sb-item--active{background:color-mix(in srgb,var(--primary) 9%,transparent)}.gbt-sb-item__icon{flex-shrink:0;color:var(--text-secondary);transition:color .15s cubic-bezier(.4,0,.2,1)}.gbt-sb-item--active .gbt-sb-item__icon{color:var(--primary)}.gbt-sb-item__label{flex:1;font-size:14px;font-weight:500;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gbt-sb-state{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:48px 24px;gap:12px;text-align:center}.gbt-sb-state span{color:var(--text-primary);font-size:14px;font-weight:500}.gbt-sb-state__icon{color:var(--text-secondary);opacity:.4}.gbt-sb-state__hint{margin:0;color:var(--text-secondary);font-size:12px}.gbt-sb-kbd{display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:22px;padding:0 5px;background:var(--bg-hover);border:1px solid var(--border-color);border-bottom-width:2px;border-radius:5px;color:var(--text-secondary);font-size:11px;font-family:SF Mono,Monaco,Consolas,monospace;font-weight:500;line-height:1}.gbt-sb-kbd--sm{min-width:18px;height:18px;font-size:10px;border-radius:4px}.gbt-sb-footer{flex-shrink:0;display:flex;align-items:center;gap:16px;padding:8px 12px;border-top:1px solid var(--border-color);background:var(--bg-hover)}.gbt-sb-footer__hint{display:flex;align-items:center;gap:4px;color:var(--text-secondary);font-size:11px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@keyframes gbt-search-bar-fade-in{0%{opacity:0}to{opacity:1}}@keyframes gbt-search-bar-scale-in{0%{opacity:0;transform:translate(-50%) scale(.96) translateY(-6px)}to{opacity:1;transform:translate(-50%) scale(1) translateY(0)}}@media(prefers-reduced-motion:reduce){.gbt-sb-trigger{transition:border-color .15s,box-shadow .15s}.gbt-sb-trigger__icon{transition:color .15s;transform:none!important}.gbt-sb-trigger__clear{transition:none}.gbt-sb-trigger__clear:active{transform:none}.gbt-sb-backdrop,.gbt-sb-panel{animation:none}}@media screen and (max-width:800px){.gbt-sb-trigger,.gbt-sb-trigger--open{width:100%}.gbt-sb-panel{width:calc(100vw - 32px);max-height:360px}.gbt-sb-state{padding:32px 16px}}\n"], dependencies: [{ kind: "component", type: Icon, selector: "gbt-icon", inputs: ["name"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
808
|
+
}
|
|
809
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: SearchBar, decorators: [{
|
|
810
|
+
type: Component,
|
|
811
|
+
args: [{ selector: 'gbt-search-bar', standalone: true, imports: [Icon, NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
812
|
+
'(keydown)': 'onNavigationKeydown($event)',
|
|
813
|
+
'(document:click)': 'handleClickOutside($event)',
|
|
814
|
+
}, template: "<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n<div class=\"gbt-sb-trigger\" [class.gbt-sb-trigger--open]=\"isFocused()\" (click)=\"focusSearch()\">\n <gbt-icon name=\"search\" class=\"gbt-sb-trigger__icon\" aria-hidden=\"true\" />\n <input\n #searchInput\n type=\"text\"\n role=\"combobox\"\n class=\"gbt-sb-trigger__input\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"ariaLabel() || placeholder()\"\n [value]=\"searchQuery()\"\n [attr.aria-expanded]=\"showOverlay()\"\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n [attr.aria-controls]=\"showOverlay() ? panelId() : null\"\n [attr.aria-activedescendant]=\"activeItemDomId()\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur()\"\n (input)=\"onInput($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n @if (searchQuery().length > 0) {\n <button\n type=\"button\"\n class=\"gbt-sb-trigger__clear\"\n (click)=\"onClear()\"\n [attr.aria-label]=\"clearLabel()\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n }\n</div>\n@if (showOverlay()) {\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">\n {{ resultsAnnouncement()(resultCount()) }}\n </div>\n}\n@if (showOverlay()) {\n <div class=\"gbt-sb-backdrop\" (click)=\"blurSearch()\" aria-hidden=\"true\"></div>\n <ng-template #footer>\n <div class=\"gbt-sb-footer\" aria-hidden=\"true\">\n <span class=\"gbt-sb-footer__hint\">\n <kbd class=\"gbt-sb-kbd gbt-sb-kbd--sm\">\u2191</kbd>\n <kbd class=\"gbt-sb-kbd gbt-sb-kbd--sm\">\u2193</kbd>\n {{ navigateHint() }}\n </span>\n <span class=\"gbt-sb-footer__hint\">\n <kbd class=\"gbt-sb-kbd gbt-sb-kbd--sm\">\u21B5</kbd>\n {{ selectHint() }}\n </span>\n <span class=\"gbt-sb-footer__hint\">\n <kbd class=\"gbt-sb-kbd gbt-sb-kbd--sm\">Esc</kbd>\n {{ closeHint() }}\n </span>\n </div>\n </ng-template>\n @if (hasNoResults()) {\n <div [id]=\"panelId()\" class=\"gbt-sb-panel\">\n <div class=\"gbt-sb-state\" role=\"status\">\n <gbt-icon name=\"search\" class=\"gbt-sb-state__icon\" aria-hidden=\"true\" />\n <span>{{ noResultsMessage() }}</span>\n <p class=\"gbt-sb-state__hint\">{{ noResultsHint() }}</p>\n </div>\n <ng-container [ngTemplateOutlet]=\"footer\"></ng-container>\n </div>\n } @else {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <div\n [id]=\"panelId()\"\n class=\"gbt-sb-panel\"\n role=\"listbox\"\n (mousedown)=\"$event.preventDefault()\"\n (click)=\"$event.stopPropagation()\"\n >\n @if (hasGroupedResults()) {\n <div class=\"gbt-sb-list\">\n @for (category of indexedGroupedResults(); track category.label) {\n @if (category.items.length > 0) {\n <div class=\"gbt-sb-group-label\">\n @if (category.icon) {\n <gbt-icon [name]=\"category.icon\" aria-hidden=\"true\" />\n }\n {{ category.label }}\n <span class=\"gbt-sb-group-count\" aria-hidden=\"true\">{{\n category.items.length\n }}</span>\n </div>\n @for (entry of category.indexedItems; track entry.index) {\n <button\n type=\"button\"\n role=\"option\"\n tabindex=\"-1\"\n [id]=\"itemDomId(entry.index)\"\n class=\"gbt-sb-item\"\n [attr.aria-selected]=\"entry.index === activeIndex()\"\n [class.gbt-sb-item--active]=\"entry.index === activeIndex()\"\n (click)=\"onSelect(entry.item)\"\n (mouseenter)=\"activeIndex.set(entry.index)\"\n >\n @if (itemTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()!\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.item }\"\n ></ng-container>\n } @else {\n @if (category.icon) {\n <gbt-icon\n [name]=\"category.icon\"\n class=\"gbt-sb-item__icon\"\n aria-hidden=\"true\"\n />\n }\n <span class=\"gbt-sb-item__label\">{{ entry.formatted }}</span>\n }\n </button>\n }\n }\n }\n </div>\n } @else if (results() && results()!.length > 0) {\n <div class=\"gbt-sb-list\">\n @for (entry of indexedResults(); track entry.index) {\n <button\n type=\"button\"\n role=\"option\"\n tabindex=\"-1\"\n [id]=\"itemDomId(entry.index)\"\n class=\"gbt-sb-item\"\n [attr.aria-selected]=\"entry.index === activeIndex()\"\n [class.gbt-sb-item--active]=\"entry.index === activeIndex()\"\n (click)=\"onSelect(entry.item)\"\n (mouseenter)=\"activeIndex.set(entry.index)\"\n >\n @if (itemTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()!\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.item }\"\n ></ng-container>\n } @else {\n <span class=\"gbt-sb-item__label\">{{ entry.formatted }}</span>\n }\n </button>\n }\n </div>\n }\n\n <ng-container [ngTemplateOutlet]=\"footer\"></ng-container>\n </div>\n }\n}\n", styles: [":host{position:relative;display:block}.gbt-sb-trigger{position:relative;z-index:1000;box-sizing:border-box;display:flex;align-items:center;gap:8px;height:40px;width:340px;padding:0 12px;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:16px;transition:width .35s cubic-bezier(.34,1.56,.64,1),border-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s cubic-bezier(.4,0,.2,1);cursor:text}.gbt-sb-trigger--open{width:420px;border-color:var(--primary);box-shadow:0 0 0 4px color-mix(in srgb,var(--primary) 12%,transparent)}.gbt-sb-trigger__icon{flex-shrink:0;color:var(--text-secondary);transition:color .2s cubic-bezier(.4,0,.2,1),transform .3s cubic-bezier(.34,1.56,.64,1)}.gbt-sb-trigger--open .gbt-sb-trigger__icon{color:var(--primary);transform:scale(1.1) rotate(5deg)}.gbt-sb-trigger__input{flex:1;min-width:0;border:none;outline:none;background:transparent;color:var(--text-primary);font-size:14px;line-height:1.5}.gbt-sb-trigger__input::placeholder{color:var(--text-secondary)}.gbt-sb-trigger__input:focus-visible{outline:2px solid var(--primary);outline-offset:2px;border-radius:4px}.gbt-sb-trigger__clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;background:transparent;border:none;border-radius:6px;color:var(--text-secondary);cursor:pointer;transition:background .15s cubic-bezier(.4,0,.2,1),color .15s cubic-bezier(.4,0,.2,1)}.gbt-sb-trigger__clear:hover{background:var(--bg-hover);color:var(--text-primary)}.gbt-sb-trigger__clear:active{transform:scale(.9)}.gbt-sb-backdrop{position:fixed;inset:0;background:#0000004d;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);z-index:999;animation:gbt-search-bar-fade-in .2s cubic-bezier(.4,0,.2,1) both}.gbt-sb-panel{position:absolute;top:calc(100% + 8px);left:50%;transform:translate(-50%);width:420px;max-height:460px;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius);box-shadow:0 16px 48px #0000002e,0 4px 12px #00000014;overflow:hidden;display:flex;flex-direction:column;z-index:1001;animation:gbt-search-bar-scale-in .25s cubic-bezier(.34,1.56,.64,1) both}.gbt-sb-list{flex:1;overflow-y:auto;padding:6px;display:flex;flex-direction:column}.gbt-sb-list::-webkit-scrollbar{width:6px}.gbt-sb-list::-webkit-scrollbar-track{background:transparent}.gbt-sb-list::-webkit-scrollbar-thumb{background:var(--bg-hover);border-radius:3px}.gbt-sb-list::-webkit-scrollbar-thumb:hover{background:var(--border-color)}.gbt-sb-group-label{display:flex;align-items:center;gap:6px;padding:10px 10px 4px;color:var(--text-secondary);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.5px}.gbt-sb-group-count{margin-left:auto;padding:1px 7px;background:var(--bg-hover);border-radius:10px;font-size:11px;font-weight:600;color:var(--text-secondary)}.gbt-sb-item{display:flex;align-items:center;gap:10px;width:100%;padding:9px 10px;background:transparent;border:none;border-radius:8px;text-align:left;cursor:pointer;transition:background .12s cubic-bezier(.4,0,.2,1)}.gbt-sb-item:hover{background:var(--bg-hover)}.gbt-sb-item--active{background:color-mix(in srgb,var(--primary) 9%,transparent)}.gbt-sb-item__icon{flex-shrink:0;color:var(--text-secondary);transition:color .15s cubic-bezier(.4,0,.2,1)}.gbt-sb-item--active .gbt-sb-item__icon{color:var(--primary)}.gbt-sb-item__label{flex:1;font-size:14px;font-weight:500;color:var(--text-primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gbt-sb-state{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:48px 24px;gap:12px;text-align:center}.gbt-sb-state span{color:var(--text-primary);font-size:14px;font-weight:500}.gbt-sb-state__icon{color:var(--text-secondary);opacity:.4}.gbt-sb-state__hint{margin:0;color:var(--text-secondary);font-size:12px}.gbt-sb-kbd{display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:22px;padding:0 5px;background:var(--bg-hover);border:1px solid var(--border-color);border-bottom-width:2px;border-radius:5px;color:var(--text-secondary);font-size:11px;font-family:SF Mono,Monaco,Consolas,monospace;font-weight:500;line-height:1}.gbt-sb-kbd--sm{min-width:18px;height:18px;font-size:10px;border-radius:4px}.gbt-sb-footer{flex-shrink:0;display:flex;align-items:center;gap:16px;padding:8px 12px;border-top:1px solid var(--border-color);background:var(--bg-hover)}.gbt-sb-footer__hint{display:flex;align-items:center;gap:4px;color:var(--text-secondary);font-size:11px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@keyframes gbt-search-bar-fade-in{0%{opacity:0}to{opacity:1}}@keyframes gbt-search-bar-scale-in{0%{opacity:0;transform:translate(-50%) scale(.96) translateY(-6px)}to{opacity:1;transform:translate(-50%) scale(1) translateY(0)}}@media(prefers-reduced-motion:reduce){.gbt-sb-trigger{transition:border-color .15s,box-shadow .15s}.gbt-sb-trigger__icon{transition:color .15s;transform:none!important}.gbt-sb-trigger__clear{transition:none}.gbt-sb-trigger__clear:active{transform:none}.gbt-sb-backdrop,.gbt-sb-panel{animation:none}}@media screen and (max-width:800px){.gbt-sb-trigger,.gbt-sb-trigger--open{width:100%}.gbt-sb-panel{width:calc(100vw - 32px);max-height:360px}.gbt-sb-state{padding:32px 16px}}\n"] }]
|
|
815
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], results: [{ type: i0.Input, args: [{ isSignal: true, alias: "results", required: false }] }], groupedResults: [{ type: i0.Input, args: [{ isSignal: true, alias: "groupedResults", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], displayFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "displayFn", required: false }] }], itemTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemTemplate", required: false }] }], keepQueryOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "keepQueryOnSelect", required: false }] }], noResultsMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "noResultsMessage", required: false }] }], noResultsHint: [{ type: i0.Input, args: [{ isSignal: true, alias: "noResultsHint", required: false }] }], clearLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "clearLabel", required: false }] }], resultsAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "resultsAnnouncement", required: false }] }], navigateHint: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigateHint", required: false }] }], selectHint: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectHint", required: false }] }], closeHint: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeHint", required: false }] }], queryChange: [{ type: i0.Output, args: ["queryChange"] }], itemSelected: [{ type: i0.Output, args: ["itemSelected"] }], clear: [{ type: i0.Output, args: ["clear"] }], searchInput: [{ type: i0.ViewChild, args: ['searchInput', { isSignal: true }] }] } });
|
|
816
|
+
|
|
817
|
+
class Tab {
|
|
818
|
+
label = input.required(/* @ts-ignore */
|
|
819
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
820
|
+
active = signal(false, /* @ts-ignore */
|
|
821
|
+
...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
822
|
+
index = signal(0, /* @ts-ignore */
|
|
823
|
+
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
824
|
+
groupId = signal('', /* @ts-ignore */
|
|
825
|
+
...(ngDevMode ? [{ debugName: "groupId" }] : /* istanbul ignore next */ []));
|
|
826
|
+
setState(index, active, groupId) {
|
|
827
|
+
this.index.set(index);
|
|
828
|
+
this.active.set(active);
|
|
829
|
+
this.groupId.set(groupId);
|
|
830
|
+
}
|
|
831
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Tab, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
832
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.5", type: Tab, isStandalone: true, selector: "gbt-tab", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "tabpanel" }, properties: { "style.display": "active() ? null : 'none'", "id": "groupId() + '-panel-' + index()", "attr.aria-labelledby": "groupId() + '-trigger-' + index()" } }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
833
|
+
}
|
|
834
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Tab, decorators: [{
|
|
835
|
+
type: Component,
|
|
836
|
+
args: [{
|
|
837
|
+
selector: 'gbt-tab',
|
|
838
|
+
standalone: true,
|
|
839
|
+
imports: [],
|
|
840
|
+
template: `<ng-content></ng-content>`,
|
|
841
|
+
host: {
|
|
842
|
+
role: 'tabpanel',
|
|
843
|
+
'[style.display]': "active() ? null : 'none'",
|
|
844
|
+
'[id]': "groupId() + '-panel-' + index()",
|
|
845
|
+
'[attr.aria-labelledby]': "groupId() + '-trigger-' + index()",
|
|
846
|
+
},
|
|
847
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
848
|
+
}]
|
|
849
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }] } });
|
|
850
|
+
|
|
851
|
+
let nextTabsId = 0;
|
|
852
|
+
class Tabs {
|
|
853
|
+
id = input(`gbt-tabs-${++nextTabsId}`, /* @ts-ignore */
|
|
854
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
855
|
+
tabs = contentChildren(Tab, /* @ts-ignore */
|
|
856
|
+
...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
|
|
857
|
+
triggers = viewChildren('trigger', /* @ts-ignore */
|
|
858
|
+
...(ngDevMode ? [{ debugName: "triggers" }] : /* istanbul ignore next */ []));
|
|
859
|
+
activeIndex = signal(0, /* @ts-ignore */
|
|
860
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
861
|
+
constructor() {
|
|
862
|
+
effect(() => {
|
|
863
|
+
const tabs = this.tabs();
|
|
864
|
+
const active = this.activeIndex();
|
|
865
|
+
const groupId = this.id();
|
|
866
|
+
tabs.forEach((tab, i) => tab.setState(i, i === active, groupId));
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
select(index) {
|
|
870
|
+
this.activeIndex.set(index);
|
|
871
|
+
}
|
|
872
|
+
onKeydown(event, index) {
|
|
873
|
+
const count = this.tabs().length;
|
|
874
|
+
if (count === 0) {
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
let next = null;
|
|
878
|
+
if (event.key === 'ArrowRight') {
|
|
879
|
+
next = (index + 1) % count;
|
|
880
|
+
}
|
|
881
|
+
else if (event.key === 'ArrowLeft') {
|
|
882
|
+
next = (index - 1 + count) % count;
|
|
883
|
+
}
|
|
884
|
+
if (next === null) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
event.preventDefault();
|
|
888
|
+
this.select(next);
|
|
889
|
+
this.triggers()[next]?.nativeElement.focus();
|
|
890
|
+
}
|
|
891
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Tabs, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
892
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Tabs, isStandalone: true, selector: "gbt-tabs", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "tabs", predicate: Tab, isSignal: true }], viewQueries: [{ propertyName: "triggers", predicate: ["trigger"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"gbt-tabs\">\n <div class=\"gbt-tabs__list\" role=\"tablist\">\n @for (tab of tabs(); track tab; let i = $index) {\n <button\n #trigger\n type=\"button\"\n class=\"gbt-tabs__trigger\"\n [class.gbt-tabs__trigger--active]=\"activeIndex() === i\"\n role=\"tab\"\n [id]=\"id() + '-trigger-' + i\"\n [attr.aria-selected]=\"activeIndex() === i\"\n [attr.aria-controls]=\"id() + '-panel-' + i\"\n [tabIndex]=\"activeIndex() === i ? 0 : -1\"\n (click)=\"select(i)\"\n (keydown)=\"onKeydown($event, i)\"\n >\n {{ tab.label() }}\n </button>\n }\n </div>\n <div class=\"gbt-tabs__panels\">\n <ng-content></ng-content>\n </div>\n</div>\n", styles: [":host{display:block}.gbt-tabs{display:flex;flex-direction:column}.gbt-tabs__list{display:flex;gap:.5rem;border-bottom:1px solid var(--border-color);overflow-x:auto}.gbt-tabs__trigger{appearance:none;background:none;border:none;border-bottom:2px solid transparent;padding:.75rem 1rem;font-size:.9375rem;font-weight:500;color:var(--text-secondary);cursor:pointer;white-space:nowrap;transition:color var(--site-transition-fast),border-color var(--site-transition-fast)}.gbt-tabs__trigger:hover{color:var(--text-primary)}.gbt-tabs__trigger:focus-visible{outline:2px solid var(--primary);outline-offset:-2px;border-radius:var(--site-border-radius-sm)}.gbt-tabs__trigger--active{color:var(--primary);border-bottom-color:var(--primary)}.gbt-tabs__panels{padding-top:1rem;display:flex;flex-direction:column;gap:1rem}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
893
|
+
}
|
|
894
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Tabs, decorators: [{
|
|
895
|
+
type: Component,
|
|
896
|
+
args: [{ selector: 'gbt-tabs', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"gbt-tabs\">\n <div class=\"gbt-tabs__list\" role=\"tablist\">\n @for (tab of tabs(); track tab; let i = $index) {\n <button\n #trigger\n type=\"button\"\n class=\"gbt-tabs__trigger\"\n [class.gbt-tabs__trigger--active]=\"activeIndex() === i\"\n role=\"tab\"\n [id]=\"id() + '-trigger-' + i\"\n [attr.aria-selected]=\"activeIndex() === i\"\n [attr.aria-controls]=\"id() + '-panel-' + i\"\n [tabIndex]=\"activeIndex() === i ? 0 : -1\"\n (click)=\"select(i)\"\n (keydown)=\"onKeydown($event, i)\"\n >\n {{ tab.label() }}\n </button>\n }\n </div>\n <div class=\"gbt-tabs__panels\">\n <ng-content></ng-content>\n </div>\n</div>\n", styles: [":host{display:block}.gbt-tabs{display:flex;flex-direction:column}.gbt-tabs__list{display:flex;gap:.5rem;border-bottom:1px solid var(--border-color);overflow-x:auto}.gbt-tabs__trigger{appearance:none;background:none;border:none;border-bottom:2px solid transparent;padding:.75rem 1rem;font-size:.9375rem;font-weight:500;color:var(--text-secondary);cursor:pointer;white-space:nowrap;transition:color var(--site-transition-fast),border-color var(--site-transition-fast)}.gbt-tabs__trigger:hover{color:var(--text-primary)}.gbt-tabs__trigger:focus-visible{outline:2px solid var(--primary);outline-offset:-2px;border-radius:var(--site-border-radius-sm)}.gbt-tabs__trigger--active{color:var(--primary);border-bottom-color:var(--primary)}.gbt-tabs__panels{padding-top:1rem;display:flex;flex-direction:column;gap:1rem}\n"] }]
|
|
897
|
+
}], ctorParameters: () => [], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], tabs: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => Tab), { isSignal: true }] }], triggers: [{ type: i0.ViewChildren, args: ['trigger', { isSignal: true }] }] } });
|
|
898
|
+
|
|
899
|
+
function linearScale(domain, range) {
|
|
900
|
+
const [d0, d1] = domain;
|
|
901
|
+
const [r0, r1] = range;
|
|
902
|
+
const span = d1 - d0;
|
|
903
|
+
const ratio = span === 0 ? 0 : (r1 - r0) / span;
|
|
904
|
+
return {
|
|
905
|
+
domain,
|
|
906
|
+
range,
|
|
907
|
+
map: (value) => r0 + (value - d0) * ratio,
|
|
908
|
+
invert: (pixel) => (ratio === 0 ? d0 : d0 + (pixel - r0) / ratio),
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function timeScale(domain, range) {
|
|
912
|
+
const numeric = linearScale([domain[0].getTime(), domain[1].getTime()], range);
|
|
913
|
+
return {
|
|
914
|
+
domain,
|
|
915
|
+
range,
|
|
916
|
+
map: (value) => numeric.map(value.getTime()),
|
|
917
|
+
invert: (pixel) => new Date(numeric.invert(pixel)),
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
function bandScale(domain, range, padding = 0) {
|
|
921
|
+
const [r0, r1] = range;
|
|
922
|
+
const step = domain.length === 0 ? 0 : (r1 - r0) / domain.length;
|
|
923
|
+
const gutter = Math.min(Math.max(padding, 0), 1);
|
|
924
|
+
const bandwidth = step * (1 - gutter);
|
|
925
|
+
return {
|
|
926
|
+
domain,
|
|
927
|
+
range,
|
|
928
|
+
bandwidth,
|
|
929
|
+
map: (value) => {
|
|
930
|
+
const index = domain.indexOf(value);
|
|
931
|
+
return index === -1 ? Number.NaN : r0 + index * step;
|
|
932
|
+
},
|
|
933
|
+
invert: (pixel) => {
|
|
934
|
+
if (step === 0)
|
|
935
|
+
return null;
|
|
936
|
+
const index = Math.floor((pixel - r0) / step);
|
|
937
|
+
return index >= 0 && index < domain.length ? domain[index] : null;
|
|
938
|
+
},
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function niceTicks(min, max, count) {
|
|
943
|
+
if (!Number.isFinite(min) || !Number.isFinite(max))
|
|
944
|
+
return [];
|
|
945
|
+
if (min === max)
|
|
946
|
+
return [min];
|
|
947
|
+
if (max < min)
|
|
948
|
+
return niceTicks(max, min, count);
|
|
949
|
+
const rawStep = (max - min) / Math.max(1, count);
|
|
950
|
+
const magnitude = 10 ** Math.floor(Math.log10(rawStep));
|
|
951
|
+
const normalized = rawStep / magnitude;
|
|
952
|
+
const step = magnitude * (normalized <= 1 ? 1 : normalized <= 2 ? 2 : normalized <= 5 ? 5 : 10);
|
|
953
|
+
const first = Math.floor(min / step) * step;
|
|
954
|
+
const last = Math.ceil(max / step) * step;
|
|
955
|
+
const decimals = Math.max(0, -Math.floor(Math.log10(step)));
|
|
956
|
+
const ticks = [];
|
|
957
|
+
for (let value = first; value <= last + step / 1e9; value += step) {
|
|
958
|
+
ticks.push(Number(value.toFixed(decimals)));
|
|
959
|
+
}
|
|
960
|
+
return ticks;
|
|
961
|
+
}
|
|
962
|
+
const SECOND = 1000;
|
|
963
|
+
const MINUTE = 60 * SECOND;
|
|
964
|
+
const HOUR = 60 * MINUTE;
|
|
965
|
+
const DAY$1 = 24 * HOUR;
|
|
966
|
+
const STEPS = [
|
|
967
|
+
{ ms: SECOND, unit: 'second' },
|
|
968
|
+
{ ms: 5 * SECOND, unit: 'second' },
|
|
969
|
+
{ ms: 15 * SECOND, unit: 'second' },
|
|
970
|
+
{ ms: 30 * SECOND, unit: 'second' },
|
|
971
|
+
{ ms: MINUTE, unit: 'minute' },
|
|
972
|
+
{ ms: 5 * MINUTE, unit: 'minute' },
|
|
973
|
+
{ ms: 15 * MINUTE, unit: 'minute' },
|
|
974
|
+
{ ms: 30 * MINUTE, unit: 'minute' },
|
|
975
|
+
{ ms: HOUR, unit: 'hour' },
|
|
976
|
+
{ ms: 3 * HOUR, unit: 'hour' },
|
|
977
|
+
{ ms: 6 * HOUR, unit: 'hour' },
|
|
978
|
+
{ ms: 12 * HOUR, unit: 'hour' },
|
|
979
|
+
{ ms: DAY$1, unit: 'day' },
|
|
980
|
+
{ ms: 2 * DAY$1, unit: 'day' },
|
|
981
|
+
{ ms: 7 * DAY$1, unit: 'day' },
|
|
982
|
+
{ ms: 30 * DAY$1, unit: 'month', months: 1 },
|
|
983
|
+
{ ms: 90 * DAY$1, unit: 'month', months: 3 },
|
|
984
|
+
{ ms: 365 * DAY$1, unit: 'year', months: 12 },
|
|
985
|
+
];
|
|
986
|
+
const FORMATS = {
|
|
987
|
+
second: { hour: '2-digit', minute: '2-digit', second: '2-digit' },
|
|
988
|
+
minute: { hour: '2-digit', minute: '2-digit' },
|
|
989
|
+
hour: { hour: '2-digit', minute: '2-digit' },
|
|
990
|
+
day: { day: '2-digit', month: '2-digit' },
|
|
991
|
+
month: { month: 'short', year: 'numeric' },
|
|
992
|
+
year: { year: 'numeric' },
|
|
993
|
+
};
|
|
994
|
+
const MIN_PIXELS_PER_TICK = 60;
|
|
995
|
+
function timeTicks(start, end, pixelWidth) {
|
|
996
|
+
const span = end.getTime() - start.getTime();
|
|
997
|
+
const makeFormatter = (unit) => (date, locale) => new Intl.DateTimeFormat(locale, { ...FORMATS[unit], timeZone: 'UTC' }).format(date);
|
|
998
|
+
if (span <= 0) {
|
|
999
|
+
return { values: [start], unit: 'day', format: makeFormatter('day') };
|
|
1000
|
+
}
|
|
1001
|
+
const maxTicks = Math.max(2, Math.floor(pixelWidth / MIN_PIXELS_PER_TICK));
|
|
1002
|
+
const coarsest = STEPS[STEPS.length - 1];
|
|
1003
|
+
const chosen = STEPS.find((step) => span / step.ms + 1 <= maxTicks) ?? {
|
|
1004
|
+
...coarsest,
|
|
1005
|
+
months: coarsest.months * Math.max(1, Math.ceil((span / coarsest.ms + 1) / maxTicks)),
|
|
1006
|
+
};
|
|
1007
|
+
const values = [];
|
|
1008
|
+
if (chosen.months) {
|
|
1009
|
+
const step = chosen.months;
|
|
1010
|
+
const cursor = step >= 12
|
|
1011
|
+
? new Date(Date.UTC(Math.floor(start.getUTCFullYear() / (step / 12)) * (step / 12), 0, 1))
|
|
1012
|
+
: new Date(Date.UTC(start.getUTCFullYear(), Math.floor(start.getUTCMonth() / step) * step, 1));
|
|
1013
|
+
while (cursor.getTime() < start.getTime())
|
|
1014
|
+
cursor.setUTCMonth(cursor.getUTCMonth() + step);
|
|
1015
|
+
while (cursor.getTime() <= end.getTime()) {
|
|
1016
|
+
values.push(new Date(cursor));
|
|
1017
|
+
cursor.setUTCMonth(cursor.getUTCMonth() + step);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
else {
|
|
1021
|
+
const first = Math.ceil(start.getTime() / chosen.ms) * chosen.ms;
|
|
1022
|
+
for (let t = first; t <= end.getTime(); t += chosen.ms) {
|
|
1023
|
+
values.push(new Date(t));
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
if (values.length === 0)
|
|
1027
|
+
values.push(start);
|
|
1028
|
+
return { values, unit: chosen.unit, format: makeFormatter(chosen.unit) };
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
function formatNumber(value, locale, decimals) {
|
|
1032
|
+
return new Intl.NumberFormat(locale, {
|
|
1033
|
+
minimumFractionDigits: decimals,
|
|
1034
|
+
maximumFractionDigits: decimals,
|
|
1035
|
+
}).format(value);
|
|
1036
|
+
}
|
|
1037
|
+
function formatCompact(value, locale) {
|
|
1038
|
+
return new Intl.NumberFormat(locale, {
|
|
1039
|
+
notation: 'compact',
|
|
1040
|
+
maximumFractionDigits: 1,
|
|
1041
|
+
}).format(value);
|
|
1042
|
+
}
|
|
1043
|
+
function formatDuration(ms, locale) {
|
|
1044
|
+
if (ms < 1000)
|
|
1045
|
+
return `${formatNumber(Math.round(ms), locale)} ms`;
|
|
1046
|
+
const totalSeconds = Math.round(ms / 1000);
|
|
1047
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
1048
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
1049
|
+
const seconds = totalSeconds % 60;
|
|
1050
|
+
const num = (value) => formatNumber(value, locale);
|
|
1051
|
+
if (hours > 0)
|
|
1052
|
+
return minutes > 0 ? `${num(hours)} h ${num(minutes)} min` : `${num(hours)} h`;
|
|
1053
|
+
if (minutes > 0)
|
|
1054
|
+
return seconds > 0 ? `${num(minutes)} min ${num(seconds)} s` : `${num(minutes)} min`;
|
|
1055
|
+
return `${num(seconds)} s`;
|
|
1056
|
+
}
|
|
1057
|
+
function formatPercent(ratio, locale, decimals = 0) {
|
|
1058
|
+
return new Intl.NumberFormat(locale, {
|
|
1059
|
+
style: 'percent',
|
|
1060
|
+
minimumFractionDigits: decimals,
|
|
1061
|
+
maximumFractionDigits: decimals,
|
|
1062
|
+
}).format(ratio);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
const round = (n) => Number(n.toFixed(2));
|
|
1066
|
+
function linePath(points) {
|
|
1067
|
+
if (points.length === 0)
|
|
1068
|
+
return '';
|
|
1069
|
+
return points
|
|
1070
|
+
.map((point, index) => `${index === 0 ? 'M' : 'L'}${round(point.x)},${round(point.y)}`)
|
|
1071
|
+
.join('');
|
|
1072
|
+
}
|
|
1073
|
+
function areaPath(points, baseline) {
|
|
1074
|
+
if (points.length === 0)
|
|
1075
|
+
return '';
|
|
1076
|
+
const last = points[points.length - 1];
|
|
1077
|
+
const first = points[0];
|
|
1078
|
+
return `${linePath(points)}L${round(last.x)},${round(baseline)}L${round(first.x)},${round(baseline)}Z`;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
function nearestIndex(sorted, target) {
|
|
1082
|
+
if (sorted.length === 0)
|
|
1083
|
+
return -1;
|
|
1084
|
+
let low = 0;
|
|
1085
|
+
let high = sorted.length - 1;
|
|
1086
|
+
while (low < high) {
|
|
1087
|
+
const mid = (low + high) >> 1;
|
|
1088
|
+
if (sorted[mid] < target)
|
|
1089
|
+
low = mid + 1;
|
|
1090
|
+
else
|
|
1091
|
+
high = mid;
|
|
1092
|
+
}
|
|
1093
|
+
const previous = low - 1;
|
|
1094
|
+
if (previous < 0)
|
|
1095
|
+
return low;
|
|
1096
|
+
return target - sorted[previous] <= sorted[low] - target ? previous : low;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
const ESTIMATED_CHAR_WIDTH = 6.5;
|
|
1100
|
+
const LABEL_GAP = 8;
|
|
1101
|
+
function estimateLabelWidth(label) {
|
|
1102
|
+
return label.length * ESTIMATED_CHAR_WIDTH;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
const EMPTY_BOX = {
|
|
1106
|
+
width: 0,
|
|
1107
|
+
height: 0,
|
|
1108
|
+
margin: { top: 0, right: 0, bottom: 0, left: 0 },
|
|
1109
|
+
innerWidth: 0,
|
|
1110
|
+
innerHeight: 0,
|
|
1111
|
+
};
|
|
1112
|
+
const CHART_CONTEXT = new InjectionToken('gbt-chart-context');
|
|
1113
|
+
class ChartContext {
|
|
1114
|
+
_box = signal(EMPTY_BOX, /* @ts-ignore */
|
|
1115
|
+
...(ngDevMode ? [{ debugName: "_box" }] : /* istanbul ignore next */ []));
|
|
1116
|
+
_xSpec = signal({ kind: 'linear', domain: [0, 1] }, /* @ts-ignore */
|
|
1117
|
+
...(ngDevMode ? [{ debugName: "_xSpec" }] : /* istanbul ignore next */ []));
|
|
1118
|
+
_ySpec = signal({ kind: 'linear', domain: [0, 1] }, /* @ts-ignore */
|
|
1119
|
+
...(ngDevMode ? [{ debugName: "_ySpec" }] : /* istanbul ignore next */ []));
|
|
1120
|
+
_activeIndex = signal(null, /* @ts-ignore */
|
|
1121
|
+
...(ngDevMode ? [{ debugName: "_activeIndex" }] : /* istanbul ignore next */ []));
|
|
1122
|
+
_pointValues = signal([], /* @ts-ignore */
|
|
1123
|
+
...(ngDevMode ? [{ debugName: "_pointValues" }] : /* istanbul ignore next */ []));
|
|
1124
|
+
box = this._box.asReadonly();
|
|
1125
|
+
xSpec = this._xSpec.asReadonly();
|
|
1126
|
+
ySpec = this._ySpec.asReadonly();
|
|
1127
|
+
activeIndex = this._activeIndex.asReadonly();
|
|
1128
|
+
pointValues = this._pointValues.asReadonly();
|
|
1129
|
+
xScale = computed(() => {
|
|
1130
|
+
const spec = this._xSpec();
|
|
1131
|
+
const range = [0, this._box().innerWidth];
|
|
1132
|
+
if (spec.kind === 'time')
|
|
1133
|
+
return timeScale(spec.domain, range);
|
|
1134
|
+
if (spec.kind === 'band')
|
|
1135
|
+
return bandScale(spec.domain, range, spec.padding ?? 0);
|
|
1136
|
+
return linearScale(spec.domain, range);
|
|
1137
|
+
}, /* @ts-ignore */
|
|
1138
|
+
...(ngDevMode ? [{ debugName: "xScale" }] : /* istanbul ignore next */ []));
|
|
1139
|
+
yScale = computed(() => linearScale(this._ySpec().domain, [this._box().innerHeight, 0]), /* @ts-ignore */
|
|
1140
|
+
...(ngDevMode ? [{ debugName: "yScale" }] : /* istanbul ignore next */ []));
|
|
1141
|
+
pointPositions = computed(() => {
|
|
1142
|
+
const kind = this._xSpec().kind;
|
|
1143
|
+
const scale = this.xScale();
|
|
1144
|
+
return this._pointValues().map((value) => kind === 'band'
|
|
1145
|
+
? scale.map(value) + scale.bandwidth / 2
|
|
1146
|
+
: scale.map(value));
|
|
1147
|
+
}, /* @ts-ignore */
|
|
1148
|
+
...(ngDevMode ? [{ debugName: "pointPositions" }] : /* istanbul ignore next */ []));
|
|
1149
|
+
activePosition = computed(() => {
|
|
1150
|
+
const index = this._activeIndex();
|
|
1151
|
+
if (index === null)
|
|
1152
|
+
return null;
|
|
1153
|
+
return this.pointPositions()[index] ?? null;
|
|
1154
|
+
}, /* @ts-ignore */
|
|
1155
|
+
...(ngDevMode ? [{ debugName: "activePosition" }] : /* istanbul ignore next */ []));
|
|
1156
|
+
setPointValues(values) {
|
|
1157
|
+
this._pointValues.set(values);
|
|
1158
|
+
}
|
|
1159
|
+
setGeometry(box) {
|
|
1160
|
+
this._box.set(box);
|
|
1161
|
+
}
|
|
1162
|
+
setSpecs(x, y) {
|
|
1163
|
+
this._xSpec.set(x);
|
|
1164
|
+
this._ySpec.set(y);
|
|
1165
|
+
}
|
|
1166
|
+
setActiveIndex(index) {
|
|
1167
|
+
this._activeIndex.set(index);
|
|
1168
|
+
}
|
|
1169
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartContext, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1170
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartContext });
|
|
1171
|
+
}
|
|
1172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartContext, decorators: [{
|
|
1173
|
+
type: Injectable
|
|
1174
|
+
}] });
|
|
1175
|
+
|
|
1176
|
+
const DEFAULT_MARGIN = { top: 16, right: 8, bottom: 32, left: 48 };
|
|
1177
|
+
class ChartFrame {
|
|
1178
|
+
context = inject(ChartContext);
|
|
1179
|
+
label = input.required(/* @ts-ignore */
|
|
1180
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
1181
|
+
heading = input('', /* @ts-ignore */
|
|
1182
|
+
...(ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []));
|
|
1183
|
+
headingLevel = input(2, /* @ts-ignore */
|
|
1184
|
+
...(ngDevMode ? [{ debugName: "headingLevel" }] : /* istanbul ignore next */ []));
|
|
1185
|
+
headline = input('', /* @ts-ignore */
|
|
1186
|
+
...(ngDevMode ? [{ debugName: "headline" }] : /* istanbul ignore next */ []));
|
|
1187
|
+
trend = input('', /* @ts-ignore */
|
|
1188
|
+
...(ngDevMode ? [{ debugName: "trend" }] : /* istanbul ignore next */ []));
|
|
1189
|
+
x = input.required(/* @ts-ignore */
|
|
1190
|
+
...(ngDevMode ? [{ debugName: "x" }] : /* istanbul ignore next */ []));
|
|
1191
|
+
y = input.required(/* @ts-ignore */
|
|
1192
|
+
...(ngDevMode ? [{ debugName: "y" }] : /* istanbul ignore next */ []));
|
|
1193
|
+
margin = input({}, /* @ts-ignore */
|
|
1194
|
+
...(ngDevMode ? [{ debugName: "margin" }] : /* istanbul ignore next */ []));
|
|
1195
|
+
size = input(null, /* @ts-ignore */
|
|
1196
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1197
|
+
pointValues = input([], /* @ts-ignore */
|
|
1198
|
+
...(ngDevMode ? [{ debugName: "pointValues" }] : /* istanbul ignore next */ []));
|
|
1199
|
+
activeIndexChange = output();
|
|
1200
|
+
surface = viewChild.required('surface', /* @ts-ignore */
|
|
1201
|
+
...(ngDevMode ? [{ debugName: "surface" }] : /* istanbul ignore next */ []));
|
|
1202
|
+
measured = signal(null, /* @ts-ignore */
|
|
1203
|
+
...(ngDevMode ? [{ debugName: "measured" }] : /* istanbul ignore next */ []));
|
|
1204
|
+
ready = computed(() => this.context.box().innerWidth > 0, /* @ts-ignore */
|
|
1205
|
+
...(ngDevMode ? [{ debugName: "ready" }] : /* istanbul ignore next */ []));
|
|
1206
|
+
viewBox = computed(() => {
|
|
1207
|
+
const b = this.context.box();
|
|
1208
|
+
return `0 0 ${b.width} ${b.height}`;
|
|
1209
|
+
}, /* @ts-ignore */
|
|
1210
|
+
...(ngDevMode ? [{ debugName: "viewBox" }] : /* istanbul ignore next */ []));
|
|
1211
|
+
innerTransform = computed(() => {
|
|
1212
|
+
const m = this.context.box().margin;
|
|
1213
|
+
return `translate(${m.left},${m.top})`;
|
|
1214
|
+
}, /* @ts-ignore */
|
|
1215
|
+
...(ngDevMode ? [{ debugName: "innerTransform" }] : /* istanbul ignore next */ []));
|
|
1216
|
+
activePosition = computed(() => this.context.activePosition(), /* @ts-ignore */
|
|
1217
|
+
...(ngDevMode ? [{ debugName: "activePosition" }] : /* istanbul ignore next */ []));
|
|
1218
|
+
innerHeight = computed(() => this.context.box().innerHeight, /* @ts-ignore */
|
|
1219
|
+
...(ngDevMode ? [{ debugName: "innerHeight" }] : /* istanbul ignore next */ []));
|
|
1220
|
+
constructor() {
|
|
1221
|
+
effect(() => this.activeIndexChange.emit(this.context.activeIndex()));
|
|
1222
|
+
effect(() => {
|
|
1223
|
+
const margin = { ...DEFAULT_MARGIN, ...this.margin() };
|
|
1224
|
+
const size = this.size() ?? this.measured();
|
|
1225
|
+
const width = size?.width ?? 0;
|
|
1226
|
+
const height = size?.height ?? 0;
|
|
1227
|
+
this.context.setSpecs(this.x(), this.y());
|
|
1228
|
+
this.context.setPointValues(this.pointValues());
|
|
1229
|
+
this.context.setGeometry({
|
|
1230
|
+
width,
|
|
1231
|
+
height,
|
|
1232
|
+
margin,
|
|
1233
|
+
innerWidth: Math.max(0, width - margin.left - margin.right),
|
|
1234
|
+
innerHeight: Math.max(0, height - margin.top - margin.bottom),
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
effect((onCleanup) => {
|
|
1238
|
+
if (this.size() || typeof ResizeObserver === 'undefined')
|
|
1239
|
+
return;
|
|
1240
|
+
const element = this.surface().nativeElement;
|
|
1241
|
+
const observer = new ResizeObserver((entries) => {
|
|
1242
|
+
const rect = entries[0]?.contentRect;
|
|
1243
|
+
if (rect)
|
|
1244
|
+
this.measured.set({ width: rect.width, height: rect.height });
|
|
1245
|
+
});
|
|
1246
|
+
observer.observe(element);
|
|
1247
|
+
onCleanup(() => observer.disconnect());
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
onKeydown(event) {
|
|
1251
|
+
const count = this.pointValues().length;
|
|
1252
|
+
if (count === 0)
|
|
1253
|
+
return;
|
|
1254
|
+
const current = this.context.activeIndex();
|
|
1255
|
+
const last = count - 1;
|
|
1256
|
+
switch (event.key) {
|
|
1257
|
+
case 'ArrowRight':
|
|
1258
|
+
this.context.setActiveIndex(current === null ? 0 : Math.min(last, current + 1));
|
|
1259
|
+
break;
|
|
1260
|
+
case 'ArrowLeft':
|
|
1261
|
+
this.context.setActiveIndex(current === null ? last : Math.max(0, current - 1));
|
|
1262
|
+
break;
|
|
1263
|
+
case 'Home':
|
|
1264
|
+
this.context.setActiveIndex(0);
|
|
1265
|
+
break;
|
|
1266
|
+
case 'End':
|
|
1267
|
+
this.context.setActiveIndex(last);
|
|
1268
|
+
break;
|
|
1269
|
+
case 'Escape':
|
|
1270
|
+
this.context.setActiveIndex(null);
|
|
1271
|
+
break;
|
|
1272
|
+
default:
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
event.preventDefault();
|
|
1276
|
+
}
|
|
1277
|
+
onBlur() {
|
|
1278
|
+
this.context.setActiveIndex(null);
|
|
1279
|
+
}
|
|
1280
|
+
onPointerMove(event) {
|
|
1281
|
+
const positions = this.context.pointPositions();
|
|
1282
|
+
if (positions.length === 0)
|
|
1283
|
+
return;
|
|
1284
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
1285
|
+
const local = event.clientX - rect.left - this.context.box().margin.left;
|
|
1286
|
+
this.context.setActiveIndex(nearestIndex(positions, local));
|
|
1287
|
+
}
|
|
1288
|
+
onPointerLeave(event) {
|
|
1289
|
+
const surface = event.currentTarget;
|
|
1290
|
+
if (surface.ownerDocument.activeElement === surface)
|
|
1291
|
+
return;
|
|
1292
|
+
this.context.setActiveIndex(null);
|
|
1293
|
+
}
|
|
1294
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartFrame, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1295
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: ChartFrame, isStandalone: true, selector: "gbt-chart-frame", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, headingLevel: { classPropertyName: "headingLevel", publicName: "headingLevel", isSignal: true, isRequired: false, transformFunction: null }, headline: { classPropertyName: "headline", publicName: "headline", isSignal: true, isRequired: false, transformFunction: null }, trend: { classPropertyName: "trend", publicName: "trend", isSignal: true, isRequired: false, transformFunction: null }, x: { classPropertyName: "x", publicName: "x", isSignal: true, isRequired: true, transformFunction: null }, y: { classPropertyName: "y", publicName: "y", isSignal: true, isRequired: true, transformFunction: null }, margin: { classPropertyName: "margin", publicName: "margin", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, pointValues: { classPropertyName: "pointValues", publicName: "pointValues", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activeIndexChange: "activeIndexChange" }, providers: [ChartContext, { provide: CHART_CONTEXT, useExisting: ChartContext }], viewQueries: [{ propertyName: "surface", first: true, predicate: ["surface"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"gbt-chart-frame\">\n @if (heading()) {\n <div class=\"gbt-chart-frame__header\">\n @switch (headingLevel()) {\n @case (1) {\n <h1 class=\"gbt-chart-frame__title\">{{ heading() }}</h1>\n }\n @case (3) {\n <h3 class=\"gbt-chart-frame__title\">{{ heading() }}</h3>\n }\n @case (4) {\n <h4 class=\"gbt-chart-frame__title\">{{ heading() }}</h4>\n }\n @case (5) {\n <h5 class=\"gbt-chart-frame__title\">{{ heading() }}</h5>\n }\n @case (6) {\n <h6 class=\"gbt-chart-frame__title\">{{ heading() }}</h6>\n }\n @default {\n <h2 class=\"gbt-chart-frame__title\">{{ heading() }}</h2>\n }\n }\n @if (headline()) {\n <p class=\"gbt-chart-frame__headline\">{{ headline() }}</p>\n }\n @if (trend()) {\n <p class=\"gbt-chart-frame__trend\">{{ trend() }}</p>\n }\n </div>\n }\n\n <div\n #surface\n class=\"gbt-chart-frame__surface\"\n [attr.tabindex]=\"ready() && pointValues().length > 0 ? 0 : null\"\n [attr.role]=\"ready() ? 'group' : null\"\n [attr.aria-label]=\"ready() ? label() : null\"\n (keydown)=\"onKeydown($event)\"\n (blur)=\"onBlur()\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerleave)=\"onPointerLeave($event)\"\n >\n @if (ready()) {\n <svg\n class=\"gbt-chart-frame__svg\"\n [attr.viewBox]=\"viewBox()\"\n role=\"presentation\"\n focusable=\"false\"\n >\n <g [attr.transform]=\"innerTransform()\">\n <ng-content select=\"[gbtChartLayer]\" />\n @if (activePosition() !== null) {\n <line\n class=\"gbt-chart-frame__guide\"\n [attr.x1]=\"activePosition()\"\n [attr.x2]=\"activePosition()\"\n y1=\"0\"\n [attr.y2]=\"innerHeight()\"\n aria-hidden=\"true\"\n />\n }\n </g>\n </svg>\n <ng-content select=\"gbt-chart-tooltip\" />\n }\n </div>\n <ng-content select=\"gbt-chart-empty\" />\n <ng-content select=\"gbt-chart-table\" />\n</div>\n", styles: [":host{display:block}.gbt-chart-frame{position:relative;width:100%;height:100%;display:flex;flex-direction:column}.gbt-chart-frame__surface{flex:1;min-height:0;position:relative}.gbt-chart-frame__surface:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-chart-frame__svg{display:block;width:100%;height:100%}.gbt-chart-frame__guide{stroke:var(--border-color);stroke-width:1;pointer-events:none}.gbt-chart-frame__header{display:grid;grid-template-columns:1fr auto;align-items:baseline;column-gap:.75rem;margin-bottom:.5rem}.gbt-chart-frame__title{margin:0;font-size:.875rem;font-weight:600;color:var(--text-primary)}.gbt-chart-frame__headline{margin:0;grid-row:1;grid-column:2;font-size:1.375rem;font-weight:600;font-variant-numeric:tabular-nums;color:var(--text-primary)}.gbt-chart-frame__trend{margin:0;grid-column:2;justify-self:end;font-size:.6875rem;font-weight:600;color:var(--text-secondary)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1296
|
+
}
|
|
1297
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartFrame, decorators: [{
|
|
1298
|
+
type: Component,
|
|
1299
|
+
args: [{ selector: 'gbt-chart-frame', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, providers: [ChartContext, { provide: CHART_CONTEXT, useExisting: ChartContext }], template: "<div class=\"gbt-chart-frame\">\n @if (heading()) {\n <div class=\"gbt-chart-frame__header\">\n @switch (headingLevel()) {\n @case (1) {\n <h1 class=\"gbt-chart-frame__title\">{{ heading() }}</h1>\n }\n @case (3) {\n <h3 class=\"gbt-chart-frame__title\">{{ heading() }}</h3>\n }\n @case (4) {\n <h4 class=\"gbt-chart-frame__title\">{{ heading() }}</h4>\n }\n @case (5) {\n <h5 class=\"gbt-chart-frame__title\">{{ heading() }}</h5>\n }\n @case (6) {\n <h6 class=\"gbt-chart-frame__title\">{{ heading() }}</h6>\n }\n @default {\n <h2 class=\"gbt-chart-frame__title\">{{ heading() }}</h2>\n }\n }\n @if (headline()) {\n <p class=\"gbt-chart-frame__headline\">{{ headline() }}</p>\n }\n @if (trend()) {\n <p class=\"gbt-chart-frame__trend\">{{ trend() }}</p>\n }\n </div>\n }\n\n <div\n #surface\n class=\"gbt-chart-frame__surface\"\n [attr.tabindex]=\"ready() && pointValues().length > 0 ? 0 : null\"\n [attr.role]=\"ready() ? 'group' : null\"\n [attr.aria-label]=\"ready() ? label() : null\"\n (keydown)=\"onKeydown($event)\"\n (blur)=\"onBlur()\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerleave)=\"onPointerLeave($event)\"\n >\n @if (ready()) {\n <svg\n class=\"gbt-chart-frame__svg\"\n [attr.viewBox]=\"viewBox()\"\n role=\"presentation\"\n focusable=\"false\"\n >\n <g [attr.transform]=\"innerTransform()\">\n <ng-content select=\"[gbtChartLayer]\" />\n @if (activePosition() !== null) {\n <line\n class=\"gbt-chart-frame__guide\"\n [attr.x1]=\"activePosition()\"\n [attr.x2]=\"activePosition()\"\n y1=\"0\"\n [attr.y2]=\"innerHeight()\"\n aria-hidden=\"true\"\n />\n }\n </g>\n </svg>\n <ng-content select=\"gbt-chart-tooltip\" />\n }\n </div>\n <ng-content select=\"gbt-chart-empty\" />\n <ng-content select=\"gbt-chart-table\" />\n</div>\n", styles: [":host{display:block}.gbt-chart-frame{position:relative;width:100%;height:100%;display:flex;flex-direction:column}.gbt-chart-frame__surface{flex:1;min-height:0;position:relative}.gbt-chart-frame__surface:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-chart-frame__svg{display:block;width:100%;height:100%}.gbt-chart-frame__guide{stroke:var(--border-color);stroke-width:1;pointer-events:none}.gbt-chart-frame__header{display:grid;grid-template-columns:1fr auto;align-items:baseline;column-gap:.75rem;margin-bottom:.5rem}.gbt-chart-frame__title{margin:0;font-size:.875rem;font-weight:600;color:var(--text-primary)}.gbt-chart-frame__headline{margin:0;grid-row:1;grid-column:2;font-size:1.375rem;font-weight:600;font-variant-numeric:tabular-nums;color:var(--text-primary)}.gbt-chart-frame__trend{margin:0;grid-column:2;justify-self:end;font-size:.6875rem;font-weight:600;color:var(--text-secondary)}\n"] }]
|
|
1300
|
+
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], headingLevel: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingLevel", required: false }] }], headline: [{ type: i0.Input, args: [{ isSignal: true, alias: "headline", required: false }] }], trend: [{ type: i0.Input, args: [{ isSignal: true, alias: "trend", required: false }] }], x: [{ type: i0.Input, args: [{ isSignal: true, alias: "x", required: true }] }], y: [{ type: i0.Input, args: [{ isSignal: true, alias: "y", required: true }] }], margin: [{ type: i0.Input, args: [{ isSignal: true, alias: "margin", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], pointValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "pointValues", required: false }] }], activeIndexChange: [{ type: i0.Output, args: ["activeIndexChange"] }], surface: [{ type: i0.ViewChild, args: ['surface', { isSignal: true }] }] } });
|
|
1301
|
+
|
|
1302
|
+
class ChartAxis {
|
|
1303
|
+
context = inject(CHART_CONTEXT);
|
|
1304
|
+
axis = input.required(/* @ts-ignore */
|
|
1305
|
+
...(ngDevMode ? [{ debugName: "axis" }] : /* istanbul ignore next */ []));
|
|
1306
|
+
locale = input.required(/* @ts-ignore */
|
|
1307
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
1308
|
+
tickCount = input(5, /* @ts-ignore */
|
|
1309
|
+
...(ngDevMode ? [{ debugName: "tickCount" }] : /* istanbul ignore next */ []));
|
|
1310
|
+
format = input(null, /* @ts-ignore */
|
|
1311
|
+
...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
|
|
1312
|
+
grid = input(false, { ...(ngDevMode ? { debugName: "grid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
1313
|
+
groupTransform = computed(() => {
|
|
1314
|
+
const box = this.context.box();
|
|
1315
|
+
return this.axis() === 'x' ? `translate(0,${box.innerHeight})` : 'translate(0,0)';
|
|
1316
|
+
}, /* @ts-ignore */
|
|
1317
|
+
...(ngDevMode ? [{ debugName: "groupTransform" }] : /* istanbul ignore next */ []));
|
|
1318
|
+
ticks = computed(() => {
|
|
1319
|
+
if (this.axis() === 'y')
|
|
1320
|
+
return this.yTicks();
|
|
1321
|
+
const ticks = this.xTicks();
|
|
1322
|
+
if (this.context.xSpec().kind === 'band')
|
|
1323
|
+
return ticks;
|
|
1324
|
+
const last = ticks.length - 1;
|
|
1325
|
+
return ticks.map((tick, index) => ({
|
|
1326
|
+
...tick,
|
|
1327
|
+
anchor: index === 0 ? 'start' : index === last ? 'end' : 'middle',
|
|
1328
|
+
}));
|
|
1329
|
+
}, /* @ts-ignore */
|
|
1330
|
+
...(ngDevMode ? [{ debugName: "ticks" }] : /* istanbul ignore next */ []));
|
|
1331
|
+
gridLines = computed(() => {
|
|
1332
|
+
if (!this.grid() || this.axis() !== 'y')
|
|
1333
|
+
return [];
|
|
1334
|
+
return this.yTicks().map((tick) => tick.y - 4);
|
|
1335
|
+
}, /* @ts-ignore */
|
|
1336
|
+
...(ngDevMode ? [{ debugName: "gridLines" }] : /* istanbul ignore next */ []));
|
|
1337
|
+
innerWidth = computed(() => this.context.box().innerWidth, /* @ts-ignore */
|
|
1338
|
+
...(ngDevMode ? [{ debugName: "innerWidth" }] : /* istanbul ignore next */ []));
|
|
1339
|
+
yTicks() {
|
|
1340
|
+
const spec = this.context.ySpec();
|
|
1341
|
+
const scale = this.context.yScale();
|
|
1342
|
+
const custom = this.format();
|
|
1343
|
+
return niceTicks(spec.domain[0], spec.domain[1], this.tickCount()).map((value) => ({
|
|
1344
|
+
key: `y-${value}`,
|
|
1345
|
+
x: -8,
|
|
1346
|
+
y: scale.map(value) + 4,
|
|
1347
|
+
label: custom ? custom(value) : formatCompact(value, this.locale()),
|
|
1348
|
+
date: null,
|
|
1349
|
+
anchor: 'end',
|
|
1350
|
+
}));
|
|
1351
|
+
}
|
|
1352
|
+
xTicks() {
|
|
1353
|
+
const spec = this.context.xSpec();
|
|
1354
|
+
const box = this.context.box();
|
|
1355
|
+
const custom = this.format();
|
|
1356
|
+
if (spec.kind === 'band') {
|
|
1357
|
+
const scale = this.context.xScale();
|
|
1358
|
+
const labels = spec.domain.map((category) => (custom ? custom(category) : category));
|
|
1359
|
+
const step = spec.domain.length === 0 ? 0 : box.innerWidth / spec.domain.length;
|
|
1360
|
+
const widest = labels.reduce((large, label) => Math.max(large, estimateLabelWidth(label)), 0);
|
|
1361
|
+
const keepEvery = Math.max(1, Math.ceil((widest + LABEL_GAP) / Math.max(step, 1)));
|
|
1362
|
+
return spec.domain
|
|
1363
|
+
.map((category, index) => ({
|
|
1364
|
+
key: `x-${category}`,
|
|
1365
|
+
x: scale.map(category) + scale.bandwidth / 2,
|
|
1366
|
+
y: 20,
|
|
1367
|
+
label: labels[index],
|
|
1368
|
+
date: null,
|
|
1369
|
+
anchor: 'middle',
|
|
1370
|
+
}))
|
|
1371
|
+
.filter((_, index) => index % keepEvery === 0);
|
|
1372
|
+
}
|
|
1373
|
+
if (spec.kind === 'time') {
|
|
1374
|
+
const scale = this.context.xScale();
|
|
1375
|
+
const result = timeTicks(spec.domain[0], spec.domain[1], box.innerWidth);
|
|
1376
|
+
const fine = result.unit === 'hour' || result.unit === 'minute' || result.unit === 'second';
|
|
1377
|
+
const days = new Set(result.values.map((v) => v.toISOString().slice(0, 10)));
|
|
1378
|
+
const multiDay = days.size > 1;
|
|
1379
|
+
const seen = new Set();
|
|
1380
|
+
return result.values.map((value) => {
|
|
1381
|
+
const day = value.toISOString().slice(0, 10);
|
|
1382
|
+
const first = fine && multiDay && !seen.has(day);
|
|
1383
|
+
seen.add(day);
|
|
1384
|
+
return {
|
|
1385
|
+
key: `x-${value.getTime()}`,
|
|
1386
|
+
x: scale.map(value),
|
|
1387
|
+
y: first ? 14 : 20,
|
|
1388
|
+
label: custom ? custom(value) : result.format(value, this.locale()),
|
|
1389
|
+
date: first
|
|
1390
|
+
? new Intl.DateTimeFormat(this.locale(), {
|
|
1391
|
+
day: '2-digit',
|
|
1392
|
+
month: '2-digit',
|
|
1393
|
+
timeZone: 'UTC',
|
|
1394
|
+
}).format(value)
|
|
1395
|
+
: null,
|
|
1396
|
+
anchor: 'middle',
|
|
1397
|
+
};
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
const scale = this.context.xScale();
|
|
1401
|
+
return niceTicks(spec.domain[0], spec.domain[1], this.tickCount()).map((value) => ({
|
|
1402
|
+
key: `x-${value}`,
|
|
1403
|
+
x: scale.map(value),
|
|
1404
|
+
y: 20,
|
|
1405
|
+
label: custom ? custom(value) : formatCompact(value, this.locale()),
|
|
1406
|
+
date: null,
|
|
1407
|
+
anchor: 'middle',
|
|
1408
|
+
}));
|
|
1409
|
+
}
|
|
1410
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartAxis, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1411
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: ChartAxis, isStandalone: true, selector: "g[gbtChartAxis]", inputs: { axis: { classPropertyName: "axis", publicName: "axis", isSignal: true, isRequired: true, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: true, transformFunction: null }, tickCount: { classPropertyName: "tickCount", publicName: "tickCount", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-hidden": "true" }, properties: { "attr.transform": "groupTransform()", "attr.axis": "axis()" } }, ngImport: i0, template: "@for (y of gridLines(); track $index) {\n <svg:line\n class=\"gbt-chart-axis__grid\"\n x1=\"0\"\n [attr.x2]=\"innerWidth()\"\n [attr.y1]=\"y\"\n [attr.y2]=\"y\"\n />\n}\n@for (tick of ticks(); track tick.key) {\n <svg:text\n class=\"gbt-chart-axis__label\"\n [attr.x]=\"tick.x\"\n [attr.y]=\"tick.y\"\n [attr.text-anchor]=\"tick.anchor\"\n >\n @if (tick.date) {\n <svg:tspan [attr.x]=\"tick.x\" dy=\"0\">{{ tick.label }}</svg:tspan>\n <svg:tspan [attr.x]=\"tick.x\" dy=\"1.1em\">{{ tick.date }}</svg:tspan>\n } @else {\n {{ tick.label }}\n }\n </svg:text>\n}\n", styles: [".gbt-chart-axis__label{fill:var(--text-discret);font-size:.75rem;font-family:var(--font-family)}.gbt-chart-axis__grid{stroke:var(--border-color);stroke-width:1;opacity:.5}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1412
|
+
}
|
|
1413
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartAxis, decorators: [{
|
|
1414
|
+
type: Component,
|
|
1415
|
+
args: [{ selector: 'g[gbtChartAxis]', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1416
|
+
'[attr.transform]': 'groupTransform()',
|
|
1417
|
+
'[attr.axis]': 'axis()',
|
|
1418
|
+
'aria-hidden': 'true',
|
|
1419
|
+
}, template: "@for (y of gridLines(); track $index) {\n <svg:line\n class=\"gbt-chart-axis__grid\"\n x1=\"0\"\n [attr.x2]=\"innerWidth()\"\n [attr.y1]=\"y\"\n [attr.y2]=\"y\"\n />\n}\n@for (tick of ticks(); track tick.key) {\n <svg:text\n class=\"gbt-chart-axis__label\"\n [attr.x]=\"tick.x\"\n [attr.y]=\"tick.y\"\n [attr.text-anchor]=\"tick.anchor\"\n >\n @if (tick.date) {\n <svg:tspan [attr.x]=\"tick.x\" dy=\"0\">{{ tick.label }}</svg:tspan>\n <svg:tspan [attr.x]=\"tick.x\" dy=\"1.1em\">{{ tick.date }}</svg:tspan>\n } @else {\n {{ tick.label }}\n }\n </svg:text>\n}\n", styles: [".gbt-chart-axis__label{fill:var(--text-discret);font-size:.75rem;font-family:var(--font-family)}.gbt-chart-axis__grid{stroke:var(--border-color);stroke-width:1;opacity:.5}\n"] }]
|
|
1420
|
+
}], propDecorators: { axis: [{ type: i0.Input, args: [{ isSignal: true, alias: "axis", required: true }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: true }] }], tickCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "tickCount", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], grid: [{ type: i0.Input, args: [{ isSignal: true, alias: "grid", required: false }] }] } });
|
|
1421
|
+
|
|
1422
|
+
class ChartTooltip {
|
|
1423
|
+
context = inject(CHART_CONTEXT);
|
|
1424
|
+
points = input.required(/* @ts-ignore */
|
|
1425
|
+
...(ngDevMode ? [{ debugName: "points" }] : /* istanbul ignore next */ []));
|
|
1426
|
+
active = computed(() => {
|
|
1427
|
+
const index = this.context.activeIndex();
|
|
1428
|
+
if (index === null)
|
|
1429
|
+
return null;
|
|
1430
|
+
return this.points()[index] ?? null;
|
|
1431
|
+
}, /* @ts-ignore */
|
|
1432
|
+
...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
1433
|
+
left = computed(() => {
|
|
1434
|
+
const position = this.context.activePosition();
|
|
1435
|
+
if (position === null)
|
|
1436
|
+
return 0;
|
|
1437
|
+
return position + this.context.box().margin.left;
|
|
1438
|
+
}, /* @ts-ignore */
|
|
1439
|
+
...(ngDevMode ? [{ debugName: "left" }] : /* istanbul ignore next */ []));
|
|
1440
|
+
anchor = computed(() => {
|
|
1441
|
+
const index = this.context.activeIndex();
|
|
1442
|
+
if (index === null)
|
|
1443
|
+
return 'middle';
|
|
1444
|
+
const last = this.context.pointValues().length - 1;
|
|
1445
|
+
return index === 0 ? 'start' : index === last ? 'end' : 'middle';
|
|
1446
|
+
}, /* @ts-ignore */
|
|
1447
|
+
...(ngDevMode ? [{ debugName: "anchor" }] : /* istanbul ignore next */ []));
|
|
1448
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartTooltip, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1449
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: ChartTooltip, isStandalone: true, selector: "gbt-chart-tooltip", inputs: { points: { classPropertyName: "points", publicName: "points", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<div class=\"gbt-chart-tooltip\" role=\"status\" aria-live=\"polite\">\n @if (active(); as point) {\n <div class=\"gbt-chart-tooltip__panel\" [style.left.px]=\"left()\" [attr.data-anchor]=\"anchor()\">\n <p class=\"gbt-chart-tooltip__header\">{{ point.header }}</p>\n <ul class=\"gbt-chart-tooltip__rows\">\n @for (row of point.rows; track $index) {\n <li>\n <span\n class=\"gbt-chart-tooltip__swatch\"\n [attr.data-series]=\"row.series ?? null\"\n [attr.data-pattern]=\"row.pattern ?? 'solid'\"\n aria-hidden=\"true\"\n ></span>\n <span class=\"gbt-chart-tooltip__label\">{{ row.label }}</span>\n <span class=\"gbt-chart-tooltip__value\">{{ row.value }}</span>\n </li>\n }\n </ul>\n </div>\n }\n</div>\n", styles: [".gbt-chart-tooltip__panel{position:absolute;top:0;padding:.375rem .625rem;border:1px solid var(--border-color);border-radius:var(--site-border-radius);background:var(--bg-principal);color:var(--text-primary);font-size:.8125rem;pointer-events:none;white-space:nowrap}.gbt-chart-tooltip__panel[data-anchor=start]{transform:translate(0)}.gbt-chart-tooltip__panel[data-anchor=middle]{transform:translate(-50%)}.gbt-chart-tooltip__panel[data-anchor=end]{transform:translate(-100%)}.gbt-chart-tooltip__header{margin:0 0 .25rem;font-weight:600}.gbt-chart-tooltip__rows{margin:0;padding:0;list-style:none}.gbt-chart-tooltip__rows li{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:.5rem}.gbt-chart-tooltip__label{color:var(--text-secondary)}.gbt-chart-tooltip__value{font-variant-numeric:tabular-nums;font-weight:600}.gbt-chart-tooltip__swatch{width:10px;height:10px;border-radius:50%}.gbt-chart-tooltip__swatch[data-series=\"1\"]{background:var(--chart-series-1-base)}.gbt-chart-tooltip__swatch[data-series=\"2\"]{background:var(--chart-series-2-base)}.gbt-chart-tooltip__swatch[data-series=\"3\"]{background:var(--chart-series-3-base)}.gbt-chart-tooltip__swatch[data-pattern=dashed]{border-radius:2px}.gbt-chart-tooltip__swatch[data-pattern=dotted]{border-radius:50%;transform:scale(.7)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1450
|
+
}
|
|
1451
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartTooltip, decorators: [{
|
|
1452
|
+
type: Component,
|
|
1453
|
+
args: [{ selector: 'gbt-chart-tooltip', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"gbt-chart-tooltip\" role=\"status\" aria-live=\"polite\">\n @if (active(); as point) {\n <div class=\"gbt-chart-tooltip__panel\" [style.left.px]=\"left()\" [attr.data-anchor]=\"anchor()\">\n <p class=\"gbt-chart-tooltip__header\">{{ point.header }}</p>\n <ul class=\"gbt-chart-tooltip__rows\">\n @for (row of point.rows; track $index) {\n <li>\n <span\n class=\"gbt-chart-tooltip__swatch\"\n [attr.data-series]=\"row.series ?? null\"\n [attr.data-pattern]=\"row.pattern ?? 'solid'\"\n aria-hidden=\"true\"\n ></span>\n <span class=\"gbt-chart-tooltip__label\">{{ row.label }}</span>\n <span class=\"gbt-chart-tooltip__value\">{{ row.value }}</span>\n </li>\n }\n </ul>\n </div>\n }\n</div>\n", styles: [".gbt-chart-tooltip__panel{position:absolute;top:0;padding:.375rem .625rem;border:1px solid var(--border-color);border-radius:var(--site-border-radius);background:var(--bg-principal);color:var(--text-primary);font-size:.8125rem;pointer-events:none;white-space:nowrap}.gbt-chart-tooltip__panel[data-anchor=start]{transform:translate(0)}.gbt-chart-tooltip__panel[data-anchor=middle]{transform:translate(-50%)}.gbt-chart-tooltip__panel[data-anchor=end]{transform:translate(-100%)}.gbt-chart-tooltip__header{margin:0 0 .25rem;font-weight:600}.gbt-chart-tooltip__rows{margin:0;padding:0;list-style:none}.gbt-chart-tooltip__rows li{display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:.5rem}.gbt-chart-tooltip__label{color:var(--text-secondary)}.gbt-chart-tooltip__value{font-variant-numeric:tabular-nums;font-weight:600}.gbt-chart-tooltip__swatch{width:10px;height:10px;border-radius:50%}.gbt-chart-tooltip__swatch[data-series=\"1\"]{background:var(--chart-series-1-base)}.gbt-chart-tooltip__swatch[data-series=\"2\"]{background:var(--chart-series-2-base)}.gbt-chart-tooltip__swatch[data-series=\"3\"]{background:var(--chart-series-3-base)}.gbt-chart-tooltip__swatch[data-pattern=dashed]{border-radius:2px}.gbt-chart-tooltip__swatch[data-pattern=dotted]{border-radius:50%;transform:scale(.7)}\n"] }]
|
|
1454
|
+
}], propDecorators: { points: [{ type: i0.Input, args: [{ isSignal: true, alias: "points", required: true }] }] } });
|
|
1455
|
+
|
|
1456
|
+
const DASH_ARRAYS$1 = {
|
|
1457
|
+
solid: 'none',
|
|
1458
|
+
dashed: '6 3',
|
|
1459
|
+
dotted: '1 3',
|
|
1460
|
+
};
|
|
1461
|
+
class ChartLegend {
|
|
1462
|
+
entries = input.required(/* @ts-ignore */
|
|
1463
|
+
...(ngDevMode ? [{ debugName: "entries" }] : /* istanbul ignore next */ []));
|
|
1464
|
+
dashArray(pattern) {
|
|
1465
|
+
return DASH_ARRAYS$1[pattern ?? 'solid'];
|
|
1466
|
+
}
|
|
1467
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartLegend, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1468
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: ChartLegend, isStandalone: true, selector: "gbt-chart-legend", inputs: { entries: { classPropertyName: "entries", publicName: "entries", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<ul class=\"gbt-chart-legend\">\n @for (entry of entries(); track $index) {\n <li class=\"gbt-chart-legend__item\" [attr.data-pattern]=\"entry.pattern ?? 'solid'\">\n <svg class=\"gbt-chart-legend__swatch\" viewBox=\"0 0 24 8\" aria-hidden=\"true\" focusable=\"false\">\n <line\n class=\"gbt-chart-legend__line\"\n x1=\"0\"\n y1=\"4\"\n x2=\"24\"\n y2=\"4\"\n [attr.stroke-dasharray]=\"dashArray(entry.pattern)\"\n stroke-width=\"2\"\n />\n </svg>\n {{ entry.label }}\n @if (entry.value; as value) {\n <span class=\"gbt-chart-legend__value\">{{ value }}</span>\n }\n </li>\n }\n</ul>\n", styles: [".gbt-chart-legend{display:flex;flex-wrap:wrap;gap:.75rem 1.25rem;margin:0;padding:0;list-style:none;font-size:.8125rem;color:var(--text-secondary)}.gbt-chart-legend__item{display:inline-flex;align-items:center;gap:.375rem}.gbt-chart-legend__item:nth-child(3n+1) .gbt-chart-legend__line{stroke:var(--chart-series-1-base)}.gbt-chart-legend__item:nth-child(3n+2) .gbt-chart-legend__line{stroke:var(--chart-series-2-base)}.gbt-chart-legend__item:nth-child(3n+3) .gbt-chart-legend__line{stroke:var(--chart-series-3-base)}.gbt-chart-legend__swatch{width:1.5rem;height:.5rem;flex:none}.gbt-chart-legend__value{margin-left:.375rem;font-variant-numeric:tabular-nums;font-weight:600;color:var(--text-primary)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1469
|
+
}
|
|
1470
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartLegend, decorators: [{
|
|
1471
|
+
type: Component,
|
|
1472
|
+
args: [{ selector: 'gbt-chart-legend', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ul class=\"gbt-chart-legend\">\n @for (entry of entries(); track $index) {\n <li class=\"gbt-chart-legend__item\" [attr.data-pattern]=\"entry.pattern ?? 'solid'\">\n <svg class=\"gbt-chart-legend__swatch\" viewBox=\"0 0 24 8\" aria-hidden=\"true\" focusable=\"false\">\n <line\n class=\"gbt-chart-legend__line\"\n x1=\"0\"\n y1=\"4\"\n x2=\"24\"\n y2=\"4\"\n [attr.stroke-dasharray]=\"dashArray(entry.pattern)\"\n stroke-width=\"2\"\n />\n </svg>\n {{ entry.label }}\n @if (entry.value; as value) {\n <span class=\"gbt-chart-legend__value\">{{ value }}</span>\n }\n </li>\n }\n</ul>\n", styles: [".gbt-chart-legend{display:flex;flex-wrap:wrap;gap:.75rem 1.25rem;margin:0;padding:0;list-style:none;font-size:.8125rem;color:var(--text-secondary)}.gbt-chart-legend__item{display:inline-flex;align-items:center;gap:.375rem}.gbt-chart-legend__item:nth-child(3n+1) .gbt-chart-legend__line{stroke:var(--chart-series-1-base)}.gbt-chart-legend__item:nth-child(3n+2) .gbt-chart-legend__line{stroke:var(--chart-series-2-base)}.gbt-chart-legend__item:nth-child(3n+3) .gbt-chart-legend__line{stroke:var(--chart-series-3-base)}.gbt-chart-legend__swatch{width:1.5rem;height:.5rem;flex:none}.gbt-chart-legend__value{margin-left:.375rem;font-variant-numeric:tabular-nums;font-weight:600;color:var(--text-primary)}\n"] }]
|
|
1473
|
+
}], propDecorators: { entries: [{ type: i0.Input, args: [{ isSignal: true, alias: "entries", required: true }] }] } });
|
|
1474
|
+
|
|
1475
|
+
class ChartEmpty {
|
|
1476
|
+
message = input.required(/* @ts-ignore */
|
|
1477
|
+
...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
|
|
1478
|
+
actionLabel = input('', /* @ts-ignore */
|
|
1479
|
+
...(ngDevMode ? [{ debugName: "actionLabel" }] : /* istanbul ignore next */ []));
|
|
1480
|
+
action = output();
|
|
1481
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartEmpty, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1482
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: ChartEmpty, isStandalone: true, selector: "gbt-chart-empty", inputs: { message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: true, transformFunction: null }, actionLabel: { classPropertyName: "actionLabel", publicName: "actionLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { action: "action" }, ngImport: i0, template: "<div class=\"gbt-chart-empty\" role=\"status\">\n <p class=\"gbt-chart-empty__message\">{{ message() }}</p>\n @if (actionLabel()) {\n <button type=\"button\" class=\"gbt-chart-empty__action\" (click)=\"action.emit()\">\n {{ actionLabel() }}\n </button>\n }\n</div>\n", styles: [".gbt-chart-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.75rem;min-height:8rem;padding:1.5rem;color:var(--text-secondary);text-align:center}.gbt-chart-empty__message{margin:0;font-size:.875rem}.gbt-chart-empty__action{min-width:24px;min-height:24px;padding:.375rem .75rem;border:1px solid var(--border-color);border-radius:var(--site-border-radius);background:transparent;color:var(--primary);font:inherit;cursor:pointer}.gbt-chart-empty__action:hover{background:var(--bg-hover)}.gbt-chart-empty__action:focus-visible{outline:2px solid var(--primary);outline-offset:2px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1483
|
+
}
|
|
1484
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartEmpty, decorators: [{
|
|
1485
|
+
type: Component,
|
|
1486
|
+
args: [{ selector: 'gbt-chart-empty', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"gbt-chart-empty\" role=\"status\">\n <p class=\"gbt-chart-empty__message\">{{ message() }}</p>\n @if (actionLabel()) {\n <button type=\"button\" class=\"gbt-chart-empty__action\" (click)=\"action.emit()\">\n {{ actionLabel() }}\n </button>\n }\n</div>\n", styles: [".gbt-chart-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.75rem;min-height:8rem;padding:1.5rem;color:var(--text-secondary);text-align:center}.gbt-chart-empty__message{margin:0;font-size:.875rem}.gbt-chart-empty__action{min-width:24px;min-height:24px;padding:.375rem .75rem;border:1px solid var(--border-color);border-radius:var(--site-border-radius);background:transparent;color:var(--primary);font:inherit;cursor:pointer}.gbt-chart-empty__action:hover{background:var(--bg-hover)}.gbt-chart-empty__action:focus-visible{outline:2px solid var(--primary);outline-offset:2px}\n"] }]
|
|
1487
|
+
}], propDecorators: { message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: true }] }], actionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionLabel", required: false }] }], action: [{ type: i0.Output, args: ["action"] }] } });
|
|
1488
|
+
|
|
1489
|
+
class ChartTable {
|
|
1490
|
+
caption = input.required(/* @ts-ignore */
|
|
1491
|
+
...(ngDevMode ? [{ debugName: "caption" }] : /* istanbul ignore next */ []));
|
|
1492
|
+
columns = input.required(/* @ts-ignore */
|
|
1493
|
+
...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
1494
|
+
rows = input.required(/* @ts-ignore */
|
|
1495
|
+
...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
1496
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartTable, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1497
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: ChartTable, isStandalone: true, selector: "gbt-chart-table", inputs: { caption: { classPropertyName: "caption", publicName: "caption", isSignal: true, isRequired: true, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: true, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<div class=\"gbt-sr-only\">\n <table>\n <caption>\n {{\n caption()\n }}\n </caption>\n <thead>\n <tr>\n @for (column of columns(); track column) {\n <th scope=\"col\">{{ column }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of rows(); track $index) {\n <tr>\n @for (cell of row; track $index) {\n <td>{{ cell }}</td>\n }\n </tr>\n }\n </tbody>\n </table>\n</div>\n", styles: [".gbt-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1498
|
+
}
|
|
1499
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: ChartTable, decorators: [{
|
|
1500
|
+
type: Component,
|
|
1501
|
+
args: [{ selector: 'gbt-chart-table', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"gbt-sr-only\">\n <table>\n <caption>\n {{\n caption()\n }}\n </caption>\n <thead>\n <tr>\n @for (column of columns(); track column) {\n <th scope=\"col\">{{ column }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of rows(); track $index) {\n <tr>\n @for (cell of row; track $index) {\n <td>{{ cell }}</td>\n }\n </tr>\n }\n </tbody>\n </table>\n</div>\n", styles: [".gbt-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}\n"] }]
|
|
1502
|
+
}], propDecorators: { caption: [{ type: i0.Input, args: [{ isSignal: true, alias: "caption", required: true }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: true }] }], rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: true }] }] } });
|
|
1503
|
+
|
|
1504
|
+
const DASH_ARRAYS = {
|
|
1505
|
+
solid: 'none',
|
|
1506
|
+
dashed: '6 3',
|
|
1507
|
+
dotted: '1 3',
|
|
1508
|
+
};
|
|
1509
|
+
const DEFAULT_PATTERNS = [
|
|
1510
|
+
'solid',
|
|
1511
|
+
'dashed',
|
|
1512
|
+
'dotted',
|
|
1513
|
+
];
|
|
1514
|
+
class LineSeries {
|
|
1515
|
+
series = input.required(/* @ts-ignore */
|
|
1516
|
+
...(ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []));
|
|
1517
|
+
area = input(false, /* @ts-ignore */
|
|
1518
|
+
...(ngDevMode ? [{ debugName: "area" }] : /* istanbul ignore next */ []));
|
|
1519
|
+
context = inject(CHART_CONTEXT);
|
|
1520
|
+
renderedLines = computed(() => {
|
|
1521
|
+
const x = this.context.xScale();
|
|
1522
|
+
const y = this.context.yScale();
|
|
1523
|
+
const base = Math.min(Math.max(y.map(0), 0), this.context.box().innerHeight);
|
|
1524
|
+
return this.series().map((oneSeries, index) => {
|
|
1525
|
+
const points = oneSeries.points.map((p) => ({
|
|
1526
|
+
x: x.map(p.x),
|
|
1527
|
+
y: y.map(p.y),
|
|
1528
|
+
}));
|
|
1529
|
+
return {
|
|
1530
|
+
label: oneSeries.label,
|
|
1531
|
+
strokePath: linePath(points),
|
|
1532
|
+
fillPath: areaPath(points, base),
|
|
1533
|
+
colorIndex: (index % 3) + 1,
|
|
1534
|
+
dashArray: DASH_ARRAYS[oneSeries.pattern ?? DEFAULT_PATTERNS[index % DEFAULT_PATTERNS.length]],
|
|
1535
|
+
};
|
|
1536
|
+
});
|
|
1537
|
+
}, /* @ts-ignore */
|
|
1538
|
+
...(ngDevMode ? [{ debugName: "renderedLines" }] : /* istanbul ignore next */ []));
|
|
1539
|
+
activeDots = computed(() => {
|
|
1540
|
+
const activeIndex = this.context.activeIndex();
|
|
1541
|
+
if (activeIndex === null)
|
|
1542
|
+
return [];
|
|
1543
|
+
const activeXValue = this.context.pointValues()[activeIndex];
|
|
1544
|
+
if (activeXValue === undefined)
|
|
1545
|
+
return [];
|
|
1546
|
+
const key = activeXValue instanceof Date ? activeXValue.getTime() : activeXValue;
|
|
1547
|
+
const x = this.context.xScale();
|
|
1548
|
+
const y = this.context.yScale();
|
|
1549
|
+
const dots = [];
|
|
1550
|
+
this.series().forEach((oneSeries, seriesIndex) => {
|
|
1551
|
+
const point = oneSeries.points.find((p) => (p.x instanceof Date ? p.x.getTime() : p.x) === key);
|
|
1552
|
+
if (point === undefined)
|
|
1553
|
+
return;
|
|
1554
|
+
dots.push({
|
|
1555
|
+
x: x.map(point.x),
|
|
1556
|
+
y: y.map(point.y),
|
|
1557
|
+
colorIndex: (seriesIndex % 3) + 1,
|
|
1558
|
+
});
|
|
1559
|
+
});
|
|
1560
|
+
return dots;
|
|
1561
|
+
}, /* @ts-ignore */
|
|
1562
|
+
...(ngDevMode ? [{ debugName: "activeDots" }] : /* istanbul ignore next */ []));
|
|
1563
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: LineSeries, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1564
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: LineSeries, isStandalone: true, selector: "g[gbtLineSeries]", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null }, area: { classPropertyName: "area", publicName: "area", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-hidden": "true" } }, ngImport: i0, template: "@for (renderedLine of renderedLines(); track $index) {\n @if (area()) {\n <svg:path\n class=\"gbt-line-series__area\"\n [attr.d]=\"renderedLine.fillPath\"\n [attr.data-series]=\"renderedLine.colorIndex\"\n />\n }\n <svg:path\n class=\"gbt-line-series__line\"\n [attr.d]=\"renderedLine.strokePath\"\n [attr.data-series]=\"renderedLine.colorIndex\"\n [attr.stroke-dasharray]=\"renderedLine.dashArray\"\n />\n}\n@for (dot of activeDots(); track $index) {\n <svg:circle\n class=\"gbt-line-series__dot\"\n [attr.cx]=\"dot.x\"\n [attr.cy]=\"dot.y\"\n r=\"4\"\n [attr.data-series]=\"dot.colorIndex\"\n />\n}\n", styles: [".gbt-line-series__line{fill:none;stroke-width:2;stroke-linejoin:round;stroke-linecap:round}.gbt-line-series__line[data-series=\"1\"]{stroke:var(--chart-series-1-base)}.gbt-line-series__line[data-series=\"2\"]{stroke:var(--chart-series-2-base)}.gbt-line-series__line[data-series=\"3\"]{stroke:var(--chart-series-3-base)}.gbt-line-series__area{stroke:none;opacity:.15}.gbt-line-series__area[data-series=\"1\"]{fill:var(--chart-series-1-base)}.gbt-line-series__area[data-series=\"2\"]{fill:var(--chart-series-2-base)}.gbt-line-series__area[data-series=\"3\"]{fill:var(--chart-series-3-base)}.gbt-line-series__dot{stroke:var(--bg-principal);stroke-width:2;pointer-events:none}.gbt-line-series__dot[data-series=\"1\"]{fill:var(--chart-series-1-base)}.gbt-line-series__dot[data-series=\"2\"]{fill:var(--chart-series-2-base)}.gbt-line-series__dot[data-series=\"3\"]{fill:var(--chart-series-3-base)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1565
|
+
}
|
|
1566
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: LineSeries, decorators: [{
|
|
1567
|
+
type: Component,
|
|
1568
|
+
args: [{ selector: 'g[gbtLineSeries]', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, host: { 'aria-hidden': 'true' }, template: "@for (renderedLine of renderedLines(); track $index) {\n @if (area()) {\n <svg:path\n class=\"gbt-line-series__area\"\n [attr.d]=\"renderedLine.fillPath\"\n [attr.data-series]=\"renderedLine.colorIndex\"\n />\n }\n <svg:path\n class=\"gbt-line-series__line\"\n [attr.d]=\"renderedLine.strokePath\"\n [attr.data-series]=\"renderedLine.colorIndex\"\n [attr.stroke-dasharray]=\"renderedLine.dashArray\"\n />\n}\n@for (dot of activeDots(); track $index) {\n <svg:circle\n class=\"gbt-line-series__dot\"\n [attr.cx]=\"dot.x\"\n [attr.cy]=\"dot.y\"\n r=\"4\"\n [attr.data-series]=\"dot.colorIndex\"\n />\n}\n", styles: [".gbt-line-series__line{fill:none;stroke-width:2;stroke-linejoin:round;stroke-linecap:round}.gbt-line-series__line[data-series=\"1\"]{stroke:var(--chart-series-1-base)}.gbt-line-series__line[data-series=\"2\"]{stroke:var(--chart-series-2-base)}.gbt-line-series__line[data-series=\"3\"]{stroke:var(--chart-series-3-base)}.gbt-line-series__area{stroke:none;opacity:.15}.gbt-line-series__area[data-series=\"1\"]{fill:var(--chart-series-1-base)}.gbt-line-series__area[data-series=\"2\"]{fill:var(--chart-series-2-base)}.gbt-line-series__area[data-series=\"3\"]{fill:var(--chart-series-3-base)}.gbt-line-series__dot{stroke:var(--bg-principal);stroke-width:2;pointer-events:none}.gbt-line-series__dot[data-series=\"1\"]{fill:var(--chart-series-1-base)}.gbt-line-series__dot[data-series=\"2\"]{fill:var(--chart-series-2-base)}.gbt-line-series__dot[data-series=\"3\"]{fill:var(--chart-series-3-base)}\n"] }]
|
|
1569
|
+
}], propDecorators: { series: [{ type: i0.Input, args: [{ isSignal: true, alias: "series", required: true }] }], area: [{ type: i0.Input, args: [{ isSignal: true, alias: "area", required: false }] }] } });
|
|
1570
|
+
|
|
1571
|
+
const DAY = 86400000;
|
|
1572
|
+
function yDomain(series, includeZero) {
|
|
1573
|
+
const values = series.flatMap((s) => s.points.map((p) => p.y));
|
|
1574
|
+
if (values.length === 0)
|
|
1575
|
+
return [0, 1];
|
|
1576
|
+
let min = Math.min(...values);
|
|
1577
|
+
let max = Math.max(...values);
|
|
1578
|
+
if (includeZero) {
|
|
1579
|
+
min = Math.min(min, 0);
|
|
1580
|
+
max = Math.max(max, 0);
|
|
1581
|
+
}
|
|
1582
|
+
if (min === max)
|
|
1583
|
+
return [min, min + 1];
|
|
1584
|
+
return [min, max];
|
|
1585
|
+
}
|
|
1586
|
+
function numericXDomain(series) {
|
|
1587
|
+
const values = series.flatMap((s) => s.points.map((p) => p.x));
|
|
1588
|
+
if (values.length === 0)
|
|
1589
|
+
return [0, 1];
|
|
1590
|
+
const min = Math.min(...values);
|
|
1591
|
+
const max = Math.max(...values);
|
|
1592
|
+
return min === max ? [min, min + 1] : [min, max];
|
|
1593
|
+
}
|
|
1594
|
+
function timeXDomain(series) {
|
|
1595
|
+
const values = series.flatMap((s) => s.points.map((p) => p.x.getTime()));
|
|
1596
|
+
if (values.length === 0)
|
|
1597
|
+
return [new Date(-DAY), new Date(0)];
|
|
1598
|
+
const min = Math.min(...values);
|
|
1599
|
+
const max = Math.max(...values);
|
|
1600
|
+
return min === max ? [new Date(min), new Date(min + DAY)] : [new Date(min), new Date(max)];
|
|
1601
|
+
}
|
|
1602
|
+
function longestSeriesLength(series) {
|
|
1603
|
+
return series.reduce((longest, s) => Math.max(longest, s.points.length), 0);
|
|
1604
|
+
}
|
|
1605
|
+
function niceYDomain(series, includeZero, tickCount) {
|
|
1606
|
+
const [min, max] = yDomain(series, includeZero);
|
|
1607
|
+
const ticks = niceTicks(min, max, tickCount);
|
|
1608
|
+
if (ticks.length === 0)
|
|
1609
|
+
return [min, max];
|
|
1610
|
+
return [ticks[0], ticks[ticks.length - 1]];
|
|
1611
|
+
}
|
|
1612
|
+
function niceXDomain(series, tickCount) {
|
|
1613
|
+
const [min, max] = numericXDomain(series);
|
|
1614
|
+
const ticks = niceTicks(min, max, tickCount);
|
|
1615
|
+
if (ticks.length === 0)
|
|
1616
|
+
return [min, max];
|
|
1617
|
+
return [ticks[0], ticks[ticks.length - 1]];
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
const MAX_SERIES = 3;
|
|
1621
|
+
const ABSENT = '—';
|
|
1622
|
+
class LineChart {
|
|
1623
|
+
series = input.required(/* @ts-ignore */
|
|
1624
|
+
...(ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []));
|
|
1625
|
+
xKind = input.required(/* @ts-ignore */
|
|
1626
|
+
...(ngDevMode ? [{ debugName: "xKind" }] : /* istanbul ignore next */ []));
|
|
1627
|
+
locale = input.required(/* @ts-ignore */
|
|
1628
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
1629
|
+
label = input.required(/* @ts-ignore */
|
|
1630
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
1631
|
+
tableCaption = input.required(/* @ts-ignore */
|
|
1632
|
+
...(ngDevMode ? [{ debugName: "tableCaption" }] : /* istanbul ignore next */ []));
|
|
1633
|
+
xColumn = input.required(/* @ts-ignore */
|
|
1634
|
+
...(ngDevMode ? [{ debugName: "xColumn" }] : /* istanbul ignore next */ []));
|
|
1635
|
+
emptyMessage = input.required(/* @ts-ignore */
|
|
1636
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
1637
|
+
area = input(false, /* @ts-ignore */
|
|
1638
|
+
...(ngDevMode ? [{ debugName: "area" }] : /* istanbul ignore next */ []));
|
|
1639
|
+
yZero = input(true, /* @ts-ignore */
|
|
1640
|
+
...(ngDevMode ? [{ debugName: "yZero" }] : /* istanbul ignore next */ []));
|
|
1641
|
+
yTickCount = input(5, /* @ts-ignore */
|
|
1642
|
+
...(ngDevMode ? [{ debugName: "yTickCount" }] : /* istanbul ignore next */ []));
|
|
1643
|
+
xTickCount = input(5, /* @ts-ignore */
|
|
1644
|
+
...(ngDevMode ? [{ debugName: "xTickCount" }] : /* istanbul ignore next */ []));
|
|
1645
|
+
size = input(null, /* @ts-ignore */
|
|
1646
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1647
|
+
heading = input('', /* @ts-ignore */
|
|
1648
|
+
...(ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []));
|
|
1649
|
+
headingLevel = input(2, /* @ts-ignore */
|
|
1650
|
+
...(ngDevMode ? [{ debugName: "headingLevel" }] : /* istanbul ignore next */ []));
|
|
1651
|
+
headline = input('', /* @ts-ignore */
|
|
1652
|
+
...(ngDevMode ? [{ debugName: "headline" }] : /* istanbul ignore next */ []));
|
|
1653
|
+
trend = input('', /* @ts-ignore */
|
|
1654
|
+
...(ngDevMode ? [{ debugName: "trend" }] : /* istanbul ignore next */ []));
|
|
1655
|
+
activeIndex = signal(null, /* @ts-ignore */
|
|
1656
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
1657
|
+
hasData = computed(() => this.series().some((s) => s.points.length > 0), /* @ts-ignore */
|
|
1658
|
+
...(ngDevMode ? [{ debugName: "hasData" }] : /* istanbul ignore next */ []));
|
|
1659
|
+
xSpec = computed(() => this.xKind() === 'time'
|
|
1660
|
+
? { kind: 'time', domain: timeXDomain(this.series()) }
|
|
1661
|
+
: {
|
|
1662
|
+
kind: 'linear',
|
|
1663
|
+
domain: niceXDomain(this.series(), this.xTickCount()),
|
|
1664
|
+
}, /* @ts-ignore */
|
|
1665
|
+
...(ngDevMode ? [{ debugName: "xSpec" }] : /* istanbul ignore next */ []));
|
|
1666
|
+
ySpec = computed(() => ({
|
|
1667
|
+
kind: 'linear',
|
|
1668
|
+
domain: niceYDomain(this.series(), this.yZero(), this.yTickCount()),
|
|
1669
|
+
}), /* @ts-ignore */
|
|
1670
|
+
...(ngDevMode ? [{ debugName: "ySpec" }] : /* istanbul ignore next */ []));
|
|
1671
|
+
legendEntries = computed(() => {
|
|
1672
|
+
const index = this.activeIndex();
|
|
1673
|
+
const xValues = this.xValues();
|
|
1674
|
+
const x = index === null ? xValues[xValues.length - 1] : xValues[index];
|
|
1675
|
+
return this.series().map((s, seriesIndex) => ({
|
|
1676
|
+
label: s.label,
|
|
1677
|
+
pattern: s.pattern ?? DEFAULT_PATTERNS[seriesIndex % DEFAULT_PATTERNS.length],
|
|
1678
|
+
value: x === undefined ? ABSENT : this.displayValue(s, x),
|
|
1679
|
+
}));
|
|
1680
|
+
}, /* @ts-ignore */
|
|
1681
|
+
...(ngDevMode ? [{ debugName: "legendEntries" }] : /* istanbul ignore next */ []));
|
|
1682
|
+
publicXValues = computed(() => this.xValues(), /* @ts-ignore */
|
|
1683
|
+
...(ngDevMode ? [{ debugName: "publicXValues" }] : /* istanbul ignore next */ []));
|
|
1684
|
+
tooltipPoints = computed(() => this.xValues().map((x) => ({
|
|
1685
|
+
x,
|
|
1686
|
+
header: this.formatX(x),
|
|
1687
|
+
rows: this.series().map((s, index) => ({
|
|
1688
|
+
label: s.label,
|
|
1689
|
+
value: this.displayValue(s, x),
|
|
1690
|
+
series: ((index % 3) + 1),
|
|
1691
|
+
pattern: s.pattern ?? DEFAULT_PATTERNS[index % DEFAULT_PATTERNS.length],
|
|
1692
|
+
})),
|
|
1693
|
+
})), /* @ts-ignore */
|
|
1694
|
+
...(ngDevMode ? [{ debugName: "tooltipPoints" }] : /* istanbul ignore next */ []));
|
|
1695
|
+
tableColumns = computed(() => [
|
|
1696
|
+
this.xColumn(),
|
|
1697
|
+
...this.series().map((s) => s.label),
|
|
1698
|
+
], /* @ts-ignore */
|
|
1699
|
+
...(ngDevMode ? [{ debugName: "tableColumns" }] : /* istanbul ignore next */ []));
|
|
1700
|
+
tableRows = computed(() => this.xValues().map((x) => [
|
|
1701
|
+
this.formatX(x),
|
|
1702
|
+
...this.series().map((s) => this.displayValue(s, x)),
|
|
1703
|
+
]), /* @ts-ignore */
|
|
1704
|
+
...(ngDevMode ? [{ debugName: "tableRows" }] : /* istanbul ignore next */ []));
|
|
1705
|
+
formatX = (x) => x instanceof Date
|
|
1706
|
+
? new Intl.DateTimeFormat(this.locale(), {
|
|
1707
|
+
dateStyle: 'short',
|
|
1708
|
+
timeStyle: 'short',
|
|
1709
|
+
timeZone: 'UTC',
|
|
1710
|
+
}).format(x)
|
|
1711
|
+
: formatCompact(x, this.locale());
|
|
1712
|
+
xValues = computed(() => {
|
|
1713
|
+
const seen = new Map();
|
|
1714
|
+
for (const oneSeries of this.series()) {
|
|
1715
|
+
for (const point of oneSeries.points) {
|
|
1716
|
+
seen.set(point.x instanceof Date ? point.x.getTime() : point.x, point.x);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
return [...seen.entries()]
|
|
1720
|
+
.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))
|
|
1721
|
+
.map(([, x]) => x);
|
|
1722
|
+
}, /* @ts-ignore */
|
|
1723
|
+
...(ngDevMode ? [{ debugName: "xValues" }] : /* istanbul ignore next */ []));
|
|
1724
|
+
findPoint(oneSeries, x) {
|
|
1725
|
+
const key = x instanceof Date ? x.getTime() : x;
|
|
1726
|
+
return oneSeries.points.find((p) => (p.x instanceof Date ? p.x.getTime() : p.x) === key) ?? null;
|
|
1727
|
+
}
|
|
1728
|
+
displayValue(oneSeries, x) {
|
|
1729
|
+
const point = this.findPoint(oneSeries, x);
|
|
1730
|
+
if (point === null)
|
|
1731
|
+
return ABSENT;
|
|
1732
|
+
return point.display ?? formatNumber(point.y, this.locale());
|
|
1733
|
+
}
|
|
1734
|
+
constructor() {
|
|
1735
|
+
if (isDevMode()) {
|
|
1736
|
+
effect(() => {
|
|
1737
|
+
const count = this.series().length;
|
|
1738
|
+
if (count > MAX_SERIES) {
|
|
1739
|
+
console.warn(`gbt-line-chart: ${count} series received for ${MAX_SERIES} distinguishable colors. The palette cycles.`);
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: LineChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1745
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: LineChart, isStandalone: true, selector: "gbt-line-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null }, xKind: { classPropertyName: "xKind", publicName: "xKind", isSignal: true, isRequired: true, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, tableCaption: { classPropertyName: "tableCaption", publicName: "tableCaption", isSignal: true, isRequired: true, transformFunction: null }, xColumn: { classPropertyName: "xColumn", publicName: "xColumn", isSignal: true, isRequired: true, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: true, transformFunction: null }, area: { classPropertyName: "area", publicName: "area", isSignal: true, isRequired: false, transformFunction: null }, yZero: { classPropertyName: "yZero", publicName: "yZero", isSignal: true, isRequired: false, transformFunction: null }, yTickCount: { classPropertyName: "yTickCount", publicName: "yTickCount", isSignal: true, isRequired: false, transformFunction: null }, xTickCount: { classPropertyName: "xTickCount", publicName: "xTickCount", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, headingLevel: { classPropertyName: "headingLevel", publicName: "headingLevel", isSignal: true, isRequired: false, transformFunction: null }, headline: { classPropertyName: "headline", publicName: "headline", isSignal: true, isRequired: false, transformFunction: null }, trend: { classPropertyName: "trend", publicName: "trend", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<gbt-chart-frame\n [label]=\"label()\"\n [x]=\"xSpec()\"\n [y]=\"ySpec()\"\n [pointValues]=\"publicXValues()\"\n [size]=\"size()\"\n [heading]=\"heading()\"\n [headingLevel]=\"headingLevel()\"\n [headline]=\"headline()\"\n [trend]=\"trend()\"\n (activeIndexChange)=\"activeIndex.set($event)\"\n>\n <svg:g gbtChartLayer>\n <svg:g gbtChartAxis axis=\"y\" [locale]=\"locale()\" [tickCount]=\"yTickCount()\" grid></svg:g>\n <svg:g gbtChartAxis axis=\"x\" [locale]=\"locale()\" [tickCount]=\"xTickCount()\"></svg:g>\n <svg:g gbtLineSeries [series]=\"series()\" [area]=\"area()\"></svg:g>\n </svg:g>\n <gbt-chart-tooltip [points]=\"tooltipPoints()\" />\n @if (hasData()) {\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"tableColumns()\" [rows]=\"tableRows()\" />\n } @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n }\n</gbt-chart-frame>\n@if (series().length > 1) {\n <gbt-chart-legend [entries]=\"legendEntries()\" />\n}\n", styles: [":host{display:block;height:100%}gbt-chart-frame{display:block;height:100%}\n"], dependencies: [{ kind: "component", type: ChartFrame, selector: "gbt-chart-frame", inputs: ["label", "heading", "headingLevel", "headline", "trend", "x", "y", "margin", "size", "pointValues"], outputs: ["activeIndexChange"] }, { kind: "component", type: ChartAxis, selector: "g[gbtChartAxis]", inputs: ["axis", "locale", "tickCount", "format", "grid"] }, { kind: "component", type: ChartTooltip, selector: "gbt-chart-tooltip", inputs: ["points"] }, { kind: "component", type: ChartLegend, selector: "gbt-chart-legend", inputs: ["entries"] }, { kind: "component", type: ChartEmpty, selector: "gbt-chart-empty", inputs: ["message", "actionLabel"], outputs: ["action"] }, { kind: "component", type: ChartTable, selector: "gbt-chart-table", inputs: ["caption", "columns", "rows"] }, { kind: "component", type: LineSeries, selector: "g[gbtLineSeries]", inputs: ["series", "area"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1746
|
+
}
|
|
1747
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: LineChart, decorators: [{
|
|
1748
|
+
type: Component,
|
|
1749
|
+
args: [{ selector: 'gbt-line-chart', standalone: true, imports: [ChartFrame, ChartAxis, ChartTooltip, ChartLegend, ChartEmpty, ChartTable, LineSeries], changeDetection: ChangeDetectionStrategy.OnPush, template: "<gbt-chart-frame\n [label]=\"label()\"\n [x]=\"xSpec()\"\n [y]=\"ySpec()\"\n [pointValues]=\"publicXValues()\"\n [size]=\"size()\"\n [heading]=\"heading()\"\n [headingLevel]=\"headingLevel()\"\n [headline]=\"headline()\"\n [trend]=\"trend()\"\n (activeIndexChange)=\"activeIndex.set($event)\"\n>\n <svg:g gbtChartLayer>\n <svg:g gbtChartAxis axis=\"y\" [locale]=\"locale()\" [tickCount]=\"yTickCount()\" grid></svg:g>\n <svg:g gbtChartAxis axis=\"x\" [locale]=\"locale()\" [tickCount]=\"xTickCount()\"></svg:g>\n <svg:g gbtLineSeries [series]=\"series()\" [area]=\"area()\"></svg:g>\n </svg:g>\n <gbt-chart-tooltip [points]=\"tooltipPoints()\" />\n @if (hasData()) {\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"tableColumns()\" [rows]=\"tableRows()\" />\n } @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n }\n</gbt-chart-frame>\n@if (series().length > 1) {\n <gbt-chart-legend [entries]=\"legendEntries()\" />\n}\n", styles: [":host{display:block;height:100%}gbt-chart-frame{display:block;height:100%}\n"] }]
|
|
1750
|
+
}], ctorParameters: () => [], propDecorators: { series: [{ type: i0.Input, args: [{ isSignal: true, alias: "series", required: true }] }], xKind: [{ type: i0.Input, args: [{ isSignal: true, alias: "xKind", required: true }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], tableCaption: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableCaption", required: true }] }], xColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "xColumn", required: true }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: true }] }], area: [{ type: i0.Input, args: [{ isSignal: true, alias: "area", required: false }] }], yZero: [{ type: i0.Input, args: [{ isSignal: true, alias: "yZero", required: false }] }], yTickCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "yTickCount", required: false }] }], xTickCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "xTickCount", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], headingLevel: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingLevel", required: false }] }], headline: [{ type: i0.Input, args: [{ isSignal: true, alias: "headline", required: false }] }], trend: [{ type: i0.Input, args: [{ isSignal: true, alias: "trend", required: false }] }] } });
|
|
1751
|
+
|
|
1752
|
+
class BarSeries {
|
|
1753
|
+
context = inject(CHART_CONTEXT);
|
|
1754
|
+
series = input.required(/* @ts-ignore */
|
|
1755
|
+
...(ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []));
|
|
1756
|
+
activeIndex = computed(() => this.context.activeIndex(), /* @ts-ignore */
|
|
1757
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
1758
|
+
bars = computed(() => {
|
|
1759
|
+
const x = this.context.xScale();
|
|
1760
|
+
const y = this.context.yScale();
|
|
1761
|
+
const base = y.map(0);
|
|
1762
|
+
return this.series().points.map((point) => {
|
|
1763
|
+
const top = y.map(point.y);
|
|
1764
|
+
return {
|
|
1765
|
+
category: point.x,
|
|
1766
|
+
x: x.map(point.x),
|
|
1767
|
+
y: Math.min(top, base),
|
|
1768
|
+
width: x.bandwidth,
|
|
1769
|
+
height: Math.abs(base - top),
|
|
1770
|
+
};
|
|
1771
|
+
});
|
|
1772
|
+
}, /* @ts-ignore */
|
|
1773
|
+
...(ngDevMode ? [{ debugName: "bars" }] : /* istanbul ignore next */ []));
|
|
1774
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: BarSeries, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1775
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: BarSeries, isStandalone: true, selector: "g[gbtBarSeries]", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "aria-hidden": "true" } }, ngImport: i0, template: "@for (bar of bars(); track bar.category) {\n <svg:rect\n class=\"gbt-bar-series__bar\"\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [attr.width]=\"bar.width\"\n [attr.height]=\"bar.height\"\n [attr.data-active]=\"$index === activeIndex() ? '' : null\"\n />\n}\n", styles: [".gbt-bar-series__bar{fill:var(--chart-series-1-base)}.gbt-bar-series__bar[data-active]{filter:brightness(1.15)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1776
|
+
}
|
|
1777
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: BarSeries, decorators: [{
|
|
1778
|
+
type: Component,
|
|
1779
|
+
args: [{ selector: 'g[gbtBarSeries]', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, host: { 'aria-hidden': 'true' }, template: "@for (bar of bars(); track bar.category) {\n <svg:rect\n class=\"gbt-bar-series__bar\"\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [attr.width]=\"bar.width\"\n [attr.height]=\"bar.height\"\n [attr.data-active]=\"$index === activeIndex() ? '' : null\"\n />\n}\n", styles: [".gbt-bar-series__bar{fill:var(--chart-series-1-base)}.gbt-bar-series__bar[data-active]{filter:brightness(1.15)}\n"] }]
|
|
1780
|
+
}], propDecorators: { series: [{ type: i0.Input, args: [{ isSignal: true, alias: "series", required: true }] }] } });
|
|
1781
|
+
|
|
1782
|
+
const BAND_PADDING = 0.2;
|
|
1783
|
+
class BarChart {
|
|
1784
|
+
series = input.required(/* @ts-ignore */
|
|
1785
|
+
...(ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []));
|
|
1786
|
+
locale = input.required(/* @ts-ignore */
|
|
1787
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
1788
|
+
label = input.required(/* @ts-ignore */
|
|
1789
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
1790
|
+
tableCaption = input.required(/* @ts-ignore */
|
|
1791
|
+
...(ngDevMode ? [{ debugName: "tableCaption" }] : /* istanbul ignore next */ []));
|
|
1792
|
+
xColumn = input.required(/* @ts-ignore */
|
|
1793
|
+
...(ngDevMode ? [{ debugName: "xColumn" }] : /* istanbul ignore next */ []));
|
|
1794
|
+
emptyMessage = input.required(/* @ts-ignore */
|
|
1795
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
1796
|
+
yTickCount = input(5, /* @ts-ignore */
|
|
1797
|
+
...(ngDevMode ? [{ debugName: "yTickCount" }] : /* istanbul ignore next */ []));
|
|
1798
|
+
size = input(null, /* @ts-ignore */
|
|
1799
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1800
|
+
heading = input('', /* @ts-ignore */
|
|
1801
|
+
...(ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []));
|
|
1802
|
+
headingLevel = input(2, /* @ts-ignore */
|
|
1803
|
+
...(ngDevMode ? [{ debugName: "headingLevel" }] : /* istanbul ignore next */ []));
|
|
1804
|
+
headline = input('', /* @ts-ignore */
|
|
1805
|
+
...(ngDevMode ? [{ debugName: "headline" }] : /* istanbul ignore next */ []));
|
|
1806
|
+
trend = input('', /* @ts-ignore */
|
|
1807
|
+
...(ngDevMode ? [{ debugName: "trend" }] : /* istanbul ignore next */ []));
|
|
1808
|
+
hasData = computed(() => this.series().points.length > 0, /* @ts-ignore */
|
|
1809
|
+
...(ngDevMode ? [{ debugName: "hasData" }] : /* istanbul ignore next */ []));
|
|
1810
|
+
publicXValues = computed(() => this.series().points.map((p) => p.x), /* @ts-ignore */
|
|
1811
|
+
...(ngDevMode ? [{ debugName: "publicXValues" }] : /* istanbul ignore next */ []));
|
|
1812
|
+
xSpec = computed(() => ({
|
|
1813
|
+
kind: 'band',
|
|
1814
|
+
domain: this.series().points.map((p) => p.x),
|
|
1815
|
+
padding: BAND_PADDING,
|
|
1816
|
+
}), /* @ts-ignore */
|
|
1817
|
+
...(ngDevMode ? [{ debugName: "xSpec" }] : /* istanbul ignore next */ []));
|
|
1818
|
+
ySpec = computed(() => ({
|
|
1819
|
+
kind: 'linear',
|
|
1820
|
+
domain: niceYDomain([this.series()], true, this.yTickCount()),
|
|
1821
|
+
}), /* @ts-ignore */
|
|
1822
|
+
...(ngDevMode ? [{ debugName: "ySpec" }] : /* istanbul ignore next */ []));
|
|
1823
|
+
displayValue(point) {
|
|
1824
|
+
return point.display ?? formatNumber(point.y, this.locale());
|
|
1825
|
+
}
|
|
1826
|
+
tooltipPoints = computed(() => this.series().points.map((point) => ({
|
|
1827
|
+
x: point.x,
|
|
1828
|
+
header: point.x,
|
|
1829
|
+
rows: [{ label: this.series().label, value: this.displayValue(point), series: 1 }],
|
|
1830
|
+
})), /* @ts-ignore */
|
|
1831
|
+
...(ngDevMode ? [{ debugName: "tooltipPoints" }] : /* istanbul ignore next */ []));
|
|
1832
|
+
tableColumns = computed(() => [this.xColumn(), this.series().label], /* @ts-ignore */
|
|
1833
|
+
...(ngDevMode ? [{ debugName: "tableColumns" }] : /* istanbul ignore next */ []));
|
|
1834
|
+
tableRows = computed(() => this.series().points.map((point) => [point.x, this.displayValue(point)]), /* @ts-ignore */
|
|
1835
|
+
...(ngDevMode ? [{ debugName: "tableRows" }] : /* istanbul ignore next */ []));
|
|
1836
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: BarChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1837
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: BarChart, isStandalone: true, selector: "gbt-bar-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, tableCaption: { classPropertyName: "tableCaption", publicName: "tableCaption", isSignal: true, isRequired: true, transformFunction: null }, xColumn: { classPropertyName: "xColumn", publicName: "xColumn", isSignal: true, isRequired: true, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: true, transformFunction: null }, yTickCount: { classPropertyName: "yTickCount", publicName: "yTickCount", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, headingLevel: { classPropertyName: "headingLevel", publicName: "headingLevel", isSignal: true, isRequired: false, transformFunction: null }, headline: { classPropertyName: "headline", publicName: "headline", isSignal: true, isRequired: false, transformFunction: null }, trend: { classPropertyName: "trend", publicName: "trend", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<gbt-chart-frame\n [label]=\"label()\"\n [x]=\"xSpec()\"\n [y]=\"ySpec()\"\n [pointValues]=\"publicXValues()\"\n [size]=\"size()\"\n [heading]=\"heading()\"\n [headingLevel]=\"headingLevel()\"\n [headline]=\"headline()\"\n [trend]=\"trend()\"\n>\n <svg:g gbtChartLayer>\n <svg:g gbtChartAxis axis=\"y\" [locale]=\"locale()\" [tickCount]=\"yTickCount()\" grid></svg:g>\n <svg:g gbtChartAxis axis=\"x\" [locale]=\"locale()\"></svg:g>\n <svg:g gbtBarSeries [series]=\"series()\"></svg:g>\n </svg:g>\n <gbt-chart-tooltip [points]=\"tooltipPoints()\" />\n @if (hasData()) {\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"tableColumns()\" [rows]=\"tableRows()\" />\n } @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n }\n</gbt-chart-frame>\n", styles: [":host{display:block;height:100%}gbt-chart-frame{display:block;height:100%}\n"], dependencies: [{ kind: "component", type: ChartFrame, selector: "gbt-chart-frame", inputs: ["label", "heading", "headingLevel", "headline", "trend", "x", "y", "margin", "size", "pointValues"], outputs: ["activeIndexChange"] }, { kind: "component", type: ChartAxis, selector: "g[gbtChartAxis]", inputs: ["axis", "locale", "tickCount", "format", "grid"] }, { kind: "component", type: ChartTooltip, selector: "gbt-chart-tooltip", inputs: ["points"] }, { kind: "component", type: ChartEmpty, selector: "gbt-chart-empty", inputs: ["message", "actionLabel"], outputs: ["action"] }, { kind: "component", type: ChartTable, selector: "gbt-chart-table", inputs: ["caption", "columns", "rows"] }, { kind: "component", type: BarSeries, selector: "g[gbtBarSeries]", inputs: ["series"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1838
|
+
}
|
|
1839
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: BarChart, decorators: [{
|
|
1840
|
+
type: Component,
|
|
1841
|
+
args: [{ selector: 'gbt-bar-chart', standalone: true, imports: [ChartFrame, ChartAxis, ChartTooltip, ChartEmpty, ChartTable, BarSeries], changeDetection: ChangeDetectionStrategy.OnPush, template: "<gbt-chart-frame\n [label]=\"label()\"\n [x]=\"xSpec()\"\n [y]=\"ySpec()\"\n [pointValues]=\"publicXValues()\"\n [size]=\"size()\"\n [heading]=\"heading()\"\n [headingLevel]=\"headingLevel()\"\n [headline]=\"headline()\"\n [trend]=\"trend()\"\n>\n <svg:g gbtChartLayer>\n <svg:g gbtChartAxis axis=\"y\" [locale]=\"locale()\" [tickCount]=\"yTickCount()\" grid></svg:g>\n <svg:g gbtChartAxis axis=\"x\" [locale]=\"locale()\"></svg:g>\n <svg:g gbtBarSeries [series]=\"series()\"></svg:g>\n </svg:g>\n <gbt-chart-tooltip [points]=\"tooltipPoints()\" />\n @if (hasData()) {\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"tableColumns()\" [rows]=\"tableRows()\" />\n } @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n }\n</gbt-chart-frame>\n", styles: [":host{display:block;height:100%}gbt-chart-frame{display:block;height:100%}\n"] }]
|
|
1842
|
+
}], propDecorators: { series: [{ type: i0.Input, args: [{ isSignal: true, alias: "series", required: true }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], tableCaption: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableCaption", required: true }] }], xColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "xColumn", required: true }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: true }] }], yTickCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "yTickCount", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], headingLevel: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingLevel", required: false }] }], headline: [{ type: i0.Input, args: [{ isSignal: true, alias: "headline", required: false }] }], trend: [{ type: i0.Input, args: [{ isSignal: true, alias: "trend", required: false }] }] } });
|
|
1843
|
+
|
|
1844
|
+
const LABEL_INSET = 4;
|
|
1845
|
+
const STROKE_WIDTH = 3;
|
|
1846
|
+
const STROKE_WIDTH_ACTIVE = 6;
|
|
1847
|
+
class TimelineSeries {
|
|
1848
|
+
series = input.required(/* @ts-ignore */
|
|
1849
|
+
...(ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []));
|
|
1850
|
+
intervals = input.required(/* @ts-ignore */
|
|
1851
|
+
...(ngDevMode ? [{ debugName: "intervals" }] : /* istanbul ignore next */ []));
|
|
1852
|
+
context = inject(CHART_CONTEXT);
|
|
1853
|
+
height = computed(() => this.context.box().innerHeight, /* @ts-ignore */
|
|
1854
|
+
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
1855
|
+
strokePath = computed(() => {
|
|
1856
|
+
const x = this.context.xScale();
|
|
1857
|
+
const y = this.context.yScale();
|
|
1858
|
+
return linePath(this.series().points.map((p) => ({ x: x.map(p.x), y: y.map(p.y) })));
|
|
1859
|
+
}, /* @ts-ignore */
|
|
1860
|
+
...(ngDevMode ? [{ debugName: "strokePath" }] : /* istanbul ignore next */ []));
|
|
1861
|
+
activeInstant = computed(() => {
|
|
1862
|
+
const index = this.context.activeIndex();
|
|
1863
|
+
if (index === null)
|
|
1864
|
+
return null;
|
|
1865
|
+
const value = this.context.pointValues()[index];
|
|
1866
|
+
return value instanceof Date ? value.getTime() : null;
|
|
1867
|
+
}, /* @ts-ignore */
|
|
1868
|
+
...(ngDevMode ? [{ debugName: "activeInstant" }] : /* istanbul ignore next */ []));
|
|
1869
|
+
activePoint = computed(() => {
|
|
1870
|
+
const time = this.activeInstant();
|
|
1871
|
+
if (time === null)
|
|
1872
|
+
return null;
|
|
1873
|
+
const point = this.series().points.find((p) => p.x.getTime() === time);
|
|
1874
|
+
if (point === undefined)
|
|
1875
|
+
return null;
|
|
1876
|
+
const x = this.context.xScale();
|
|
1877
|
+
const y = this.context.yScale();
|
|
1878
|
+
return { x: x.map(point.x), y: y.map(point.y) };
|
|
1879
|
+
}, /* @ts-ignore */
|
|
1880
|
+
...(ngDevMode ? [{ debugName: "activePoint" }] : /* istanbul ignore next */ []));
|
|
1881
|
+
bands = computed(() => {
|
|
1882
|
+
const x = this.context.xScale();
|
|
1883
|
+
const activeTime = this.activeInstant();
|
|
1884
|
+
return this.intervals().map((interval) => {
|
|
1885
|
+
const start = x.map(interval.start);
|
|
1886
|
+
const end = x.map(interval.end);
|
|
1887
|
+
const width = Math.max(1, end - start);
|
|
1888
|
+
const active = activeTime !== null &&
|
|
1889
|
+
activeTime >= interval.start.getTime() &&
|
|
1890
|
+
activeTime <= interval.end.getTime();
|
|
1891
|
+
return {
|
|
1892
|
+
label: interval.label,
|
|
1893
|
+
x: start,
|
|
1894
|
+
width,
|
|
1895
|
+
labeled: LABEL_INSET + estimateLabelWidth(interval.label) <= width,
|
|
1896
|
+
active,
|
|
1897
|
+
strokeWidth: active ? STROKE_WIDTH_ACTIVE : STROKE_WIDTH,
|
|
1898
|
+
};
|
|
1899
|
+
});
|
|
1900
|
+
}, /* @ts-ignore */
|
|
1901
|
+
...(ngDevMode ? [{ debugName: "bands" }] : /* istanbul ignore next */ []));
|
|
1902
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: TimelineSeries, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1903
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: TimelineSeries, isStandalone: true, selector: "g[gbtTimelineSeries]", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null }, intervals: { classPropertyName: "intervals", publicName: "intervals", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "aria-hidden": "true" } }, ngImport: i0, template: "@for (band of bands(); track $index) {\n <svg:rect\n class=\"gbt-timeline-series__band\"\n [attr.x]=\"band.x\"\n y=\"0\"\n [attr.width]=\"band.width\"\n [attr.height]=\"height()\"\n />\n <svg:rect\n class=\"gbt-timeline-series__band-edge\"\n [attr.x]=\"band.x\"\n y=\"0\"\n [attr.width]=\"band.width\"\n [attr.height]=\"band.strokeWidth\"\n [attr.data-active]=\"band.active ? '' : null\"\n />\n @if (band.labeled) {\n <svg:text class=\"gbt-timeline-series__band-label\" [attr.x]=\"band.x + 4\" y=\"14\">\n {{ band.label }}\n </svg:text>\n }\n}\n@if (strokePath(); as d) {\n <svg:path class=\"gbt-timeline-series__line\" [attr.d]=\"d\" />\n}\n@if (activePoint(); as p) {\n <svg:circle class=\"gbt-timeline-series__dot\" [attr.cx]=\"p.x\" [attr.cy]=\"p.y\" r=\"4\" />\n}\n", styles: [".gbt-timeline-series__band{fill:var(--chart-series-3-base);opacity:.12}.gbt-timeline-series__band-edge{fill:var(--chart-series-3-base)}.gbt-timeline-series__band-edge[data-active]{filter:brightness(1.15)}.gbt-timeline-series__band-label{fill:var(--text-discret);font-size:.6875rem;font-family:var(--font-family)}.gbt-timeline-series__line{fill:none;stroke:var(--chart-series-1-base);stroke-width:2;stroke-linejoin:round;stroke-linecap:round}.gbt-timeline-series__dot{fill:var(--chart-series-1-base);stroke:var(--bg-principal);stroke-width:2;pointer-events:none}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1904
|
+
}
|
|
1905
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: TimelineSeries, decorators: [{
|
|
1906
|
+
type: Component,
|
|
1907
|
+
args: [{ selector: 'g[gbtTimelineSeries]', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, host: { 'aria-hidden': 'true' }, template: "@for (band of bands(); track $index) {\n <svg:rect\n class=\"gbt-timeline-series__band\"\n [attr.x]=\"band.x\"\n y=\"0\"\n [attr.width]=\"band.width\"\n [attr.height]=\"height()\"\n />\n <svg:rect\n class=\"gbt-timeline-series__band-edge\"\n [attr.x]=\"band.x\"\n y=\"0\"\n [attr.width]=\"band.width\"\n [attr.height]=\"band.strokeWidth\"\n [attr.data-active]=\"band.active ? '' : null\"\n />\n @if (band.labeled) {\n <svg:text class=\"gbt-timeline-series__band-label\" [attr.x]=\"band.x + 4\" y=\"14\">\n {{ band.label }}\n </svg:text>\n }\n}\n@if (strokePath(); as d) {\n <svg:path class=\"gbt-timeline-series__line\" [attr.d]=\"d\" />\n}\n@if (activePoint(); as p) {\n <svg:circle class=\"gbt-timeline-series__dot\" [attr.cx]=\"p.x\" [attr.cy]=\"p.y\" r=\"4\" />\n}\n", styles: [".gbt-timeline-series__band{fill:var(--chart-series-3-base);opacity:.12}.gbt-timeline-series__band-edge{fill:var(--chart-series-3-base)}.gbt-timeline-series__band-edge[data-active]{filter:brightness(1.15)}.gbt-timeline-series__band-label{fill:var(--text-discret);font-size:.6875rem;font-family:var(--font-family)}.gbt-timeline-series__line{fill:none;stroke:var(--chart-series-1-base);stroke-width:2;stroke-linejoin:round;stroke-linecap:round}.gbt-timeline-series__dot{fill:var(--chart-series-1-base);stroke:var(--bg-principal);stroke-width:2;pointer-events:none}\n"] }]
|
|
1908
|
+
}], propDecorators: { series: [{ type: i0.Input, args: [{ isSignal: true, alias: "series", required: true }] }], intervals: [{ type: i0.Input, args: [{ isSignal: true, alias: "intervals", required: true }] }] } });
|
|
1909
|
+
|
|
1910
|
+
class TimelineChart {
|
|
1911
|
+
series = input.required(/* @ts-ignore */
|
|
1912
|
+
...(ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []));
|
|
1913
|
+
intervals = input.required(/* @ts-ignore */
|
|
1914
|
+
...(ngDevMode ? [{ debugName: "intervals" }] : /* istanbul ignore next */ []));
|
|
1915
|
+
locale = input.required(/* @ts-ignore */
|
|
1916
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
1917
|
+
label = input.required(/* @ts-ignore */
|
|
1918
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
1919
|
+
tableCaption = input.required(/* @ts-ignore */
|
|
1920
|
+
...(ngDevMode ? [{ debugName: "tableCaption" }] : /* istanbul ignore next */ []));
|
|
1921
|
+
intervalsCaption = input.required(/* @ts-ignore */
|
|
1922
|
+
...(ngDevMode ? [{ debugName: "intervalsCaption" }] : /* istanbul ignore next */ []));
|
|
1923
|
+
xColumn = input.required(/* @ts-ignore */
|
|
1924
|
+
...(ngDevMode ? [{ debugName: "xColumn" }] : /* istanbul ignore next */ []));
|
|
1925
|
+
emptyMessage = input.required(/* @ts-ignore */
|
|
1926
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
1927
|
+
yZero = input(true, /* @ts-ignore */
|
|
1928
|
+
...(ngDevMode ? [{ debugName: "yZero" }] : /* istanbul ignore next */ []));
|
|
1929
|
+
yTickCount = input(5, /* @ts-ignore */
|
|
1930
|
+
...(ngDevMode ? [{ debugName: "yTickCount" }] : /* istanbul ignore next */ []));
|
|
1931
|
+
size = input(null, /* @ts-ignore */
|
|
1932
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
1933
|
+
heading = input('', /* @ts-ignore */
|
|
1934
|
+
...(ngDevMode ? [{ debugName: "heading" }] : /* istanbul ignore next */ []));
|
|
1935
|
+
headingLevel = input(2, /* @ts-ignore */
|
|
1936
|
+
...(ngDevMode ? [{ debugName: "headingLevel" }] : /* istanbul ignore next */ []));
|
|
1937
|
+
headline = input('', /* @ts-ignore */
|
|
1938
|
+
...(ngDevMode ? [{ debugName: "headline" }] : /* istanbul ignore next */ []));
|
|
1939
|
+
trend = input('', /* @ts-ignore */
|
|
1940
|
+
...(ngDevMode ? [{ debugName: "trend" }] : /* istanbul ignore next */ []));
|
|
1941
|
+
hasData = computed(() => this.series().points.length > 0, /* @ts-ignore */
|
|
1942
|
+
...(ngDevMode ? [{ debugName: "hasData" }] : /* istanbul ignore next */ []));
|
|
1943
|
+
publicXValues = computed(() => this.series().points.map((p) => p.x), /* @ts-ignore */
|
|
1944
|
+
...(ngDevMode ? [{ debugName: "publicXValues" }] : /* istanbul ignore next */ []));
|
|
1945
|
+
xSpec = computed(() => ({
|
|
1946
|
+
kind: 'time',
|
|
1947
|
+
domain: timeXDomain([this.series()]),
|
|
1948
|
+
}), /* @ts-ignore */
|
|
1949
|
+
...(ngDevMode ? [{ debugName: "xSpec" }] : /* istanbul ignore next */ []));
|
|
1950
|
+
ySpec = computed(() => ({
|
|
1951
|
+
kind: 'linear',
|
|
1952
|
+
domain: niceYDomain([this.series()], this.yZero(), this.yTickCount()),
|
|
1953
|
+
}), /* @ts-ignore */
|
|
1954
|
+
...(ngDevMode ? [{ debugName: "ySpec" }] : /* istanbul ignore next */ []));
|
|
1955
|
+
tooltipPoints = computed(() => this.series().points.map((point) => ({
|
|
1956
|
+
x: point.x,
|
|
1957
|
+
header: this.formatInstant(point.x),
|
|
1958
|
+
rows: [{ label: this.series().label, value: this.displayValue(point), series: 1 }],
|
|
1959
|
+
})), /* @ts-ignore */
|
|
1960
|
+
...(ngDevMode ? [{ debugName: "tooltipPoints" }] : /* istanbul ignore next */ []));
|
|
1961
|
+
tableColumns = computed(() => [this.xColumn(), this.series().label], /* @ts-ignore */
|
|
1962
|
+
...(ngDevMode ? [{ debugName: "tableColumns" }] : /* istanbul ignore next */ []));
|
|
1963
|
+
tableRows = computed(() => this.series().points.map((point) => [this.formatInstant(point.x), this.displayValue(point)]), /* @ts-ignore */
|
|
1964
|
+
...(ngDevMode ? [{ debugName: "tableRows" }] : /* istanbul ignore next */ []));
|
|
1965
|
+
intervalColumns = computed(() => [
|
|
1966
|
+
this.intervalsCaption(),
|
|
1967
|
+
`${this.xColumn()} — start`,
|
|
1968
|
+
`${this.xColumn()} — end`,
|
|
1969
|
+
], /* @ts-ignore */
|
|
1970
|
+
...(ngDevMode ? [{ debugName: "intervalColumns" }] : /* istanbul ignore next */ []));
|
|
1971
|
+
intervalRows = computed(() => this.intervals().map((interval) => [
|
|
1972
|
+
interval.label,
|
|
1973
|
+
this.formatInstant(interval.start),
|
|
1974
|
+
this.formatInstant(interval.end),
|
|
1975
|
+
]), /* @ts-ignore */
|
|
1976
|
+
...(ngDevMode ? [{ debugName: "intervalRows" }] : /* istanbul ignore next */ []));
|
|
1977
|
+
formatInstant = (d) => new Intl.DateTimeFormat(this.locale(), {
|
|
1978
|
+
dateStyle: 'short',
|
|
1979
|
+
timeStyle: 'short',
|
|
1980
|
+
timeZone: 'UTC',
|
|
1981
|
+
}).format(d);
|
|
1982
|
+
displayValue(point) {
|
|
1983
|
+
return point.display ?? formatNumber(point.y, this.locale());
|
|
1984
|
+
}
|
|
1985
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: TimelineChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1986
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: TimelineChart, isStandalone: true, selector: "gbt-timeline-chart", inputs: { series: { classPropertyName: "series", publicName: "series", isSignal: true, isRequired: true, transformFunction: null }, intervals: { classPropertyName: "intervals", publicName: "intervals", isSignal: true, isRequired: true, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, tableCaption: { classPropertyName: "tableCaption", publicName: "tableCaption", isSignal: true, isRequired: true, transformFunction: null }, intervalsCaption: { classPropertyName: "intervalsCaption", publicName: "intervalsCaption", isSignal: true, isRequired: true, transformFunction: null }, xColumn: { classPropertyName: "xColumn", publicName: "xColumn", isSignal: true, isRequired: true, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: true, transformFunction: null }, yZero: { classPropertyName: "yZero", publicName: "yZero", isSignal: true, isRequired: false, transformFunction: null }, yTickCount: { classPropertyName: "yTickCount", publicName: "yTickCount", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, headingLevel: { classPropertyName: "headingLevel", publicName: "headingLevel", isSignal: true, isRequired: false, transformFunction: null }, headline: { classPropertyName: "headline", publicName: "headline", isSignal: true, isRequired: false, transformFunction: null }, trend: { classPropertyName: "trend", publicName: "trend", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<gbt-chart-frame\n [label]=\"label()\"\n [x]=\"xSpec()\"\n [y]=\"ySpec()\"\n [pointValues]=\"publicXValues()\"\n [size]=\"size()\"\n [heading]=\"heading()\"\n [headingLevel]=\"headingLevel()\"\n [headline]=\"headline()\"\n [trend]=\"trend()\"\n>\n <svg:g gbtChartLayer>\n <svg:g gbtChartAxis axis=\"y\" [locale]=\"locale()\" [tickCount]=\"yTickCount()\" grid></svg:g>\n <svg:g gbtChartAxis axis=\"x\" [locale]=\"locale()\"></svg:g>\n <svg:g gbtTimelineSeries [series]=\"series()\" [intervals]=\"intervals()\"></svg:g>\n </svg:g>\n <gbt-chart-tooltip [points]=\"tooltipPoints()\" />\n @if (hasData()) {\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"tableColumns()\" [rows]=\"tableRows()\" />\n }\n @if (hasData() && intervals().length > 0) {\n <gbt-chart-table\n [caption]=\"intervalsCaption()\"\n [columns]=\"intervalColumns()\"\n [rows]=\"intervalRows()\"\n />\n }\n @if (!hasData()) {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n }\n</gbt-chart-frame>\n", styles: [":host{display:block;height:100%}gbt-chart-frame{display:block;height:100%}\n"], dependencies: [{ kind: "component", type: ChartFrame, selector: "gbt-chart-frame", inputs: ["label", "heading", "headingLevel", "headline", "trend", "x", "y", "margin", "size", "pointValues"], outputs: ["activeIndexChange"] }, { kind: "component", type: ChartAxis, selector: "g[gbtChartAxis]", inputs: ["axis", "locale", "tickCount", "format", "grid"] }, { kind: "component", type: ChartTooltip, selector: "gbt-chart-tooltip", inputs: ["points"] }, { kind: "component", type: ChartEmpty, selector: "gbt-chart-empty", inputs: ["message", "actionLabel"], outputs: ["action"] }, { kind: "component", type: ChartTable, selector: "gbt-chart-table", inputs: ["caption", "columns", "rows"] }, { kind: "component", type: TimelineSeries, selector: "g[gbtTimelineSeries]", inputs: ["series", "intervals"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1987
|
+
}
|
|
1988
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: TimelineChart, decorators: [{
|
|
1989
|
+
type: Component,
|
|
1990
|
+
args: [{ selector: 'gbt-timeline-chart', standalone: true, imports: [ChartFrame, ChartAxis, ChartTooltip, ChartEmpty, ChartTable, TimelineSeries], changeDetection: ChangeDetectionStrategy.OnPush, template: "<gbt-chart-frame\n [label]=\"label()\"\n [x]=\"xSpec()\"\n [y]=\"ySpec()\"\n [pointValues]=\"publicXValues()\"\n [size]=\"size()\"\n [heading]=\"heading()\"\n [headingLevel]=\"headingLevel()\"\n [headline]=\"headline()\"\n [trend]=\"trend()\"\n>\n <svg:g gbtChartLayer>\n <svg:g gbtChartAxis axis=\"y\" [locale]=\"locale()\" [tickCount]=\"yTickCount()\" grid></svg:g>\n <svg:g gbtChartAxis axis=\"x\" [locale]=\"locale()\"></svg:g>\n <svg:g gbtTimelineSeries [series]=\"series()\" [intervals]=\"intervals()\"></svg:g>\n </svg:g>\n <gbt-chart-tooltip [points]=\"tooltipPoints()\" />\n @if (hasData()) {\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"tableColumns()\" [rows]=\"tableRows()\" />\n }\n @if (hasData() && intervals().length > 0) {\n <gbt-chart-table\n [caption]=\"intervalsCaption()\"\n [columns]=\"intervalColumns()\"\n [rows]=\"intervalRows()\"\n />\n }\n @if (!hasData()) {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n }\n</gbt-chart-frame>\n", styles: [":host{display:block;height:100%}gbt-chart-frame{display:block;height:100%}\n"] }]
|
|
1991
|
+
}], propDecorators: { series: [{ type: i0.Input, args: [{ isSignal: true, alias: "series", required: true }] }], intervals: [{ type: i0.Input, args: [{ isSignal: true, alias: "intervals", required: true }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], tableCaption: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableCaption", required: true }] }], intervalsCaption: [{ type: i0.Input, args: [{ isSignal: true, alias: "intervalsCaption", required: true }] }], xColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "xColumn", required: true }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: true }] }], yZero: [{ type: i0.Input, args: [{ isSignal: true, alias: "yZero", required: false }] }], yTickCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "yTickCount", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], heading: [{ type: i0.Input, args: [{ isSignal: true, alias: "heading", required: false }] }], headingLevel: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingLevel", required: false }] }], headline: [{ type: i0.Input, args: [{ isSignal: true, alias: "headline", required: false }] }], trend: [{ type: i0.Input, args: [{ isSignal: true, alias: "trend", required: false }] }] } });
|
|
1992
|
+
|
|
1993
|
+
const MARGIN = 4;
|
|
1994
|
+
class Sparkline {
|
|
1995
|
+
values = input.required(/* @ts-ignore */
|
|
1996
|
+
...(ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []));
|
|
1997
|
+
tableCaption = input.required(/* @ts-ignore */
|
|
1998
|
+
...(ngDevMode ? [{ debugName: "tableCaption" }] : /* istanbul ignore next */ []));
|
|
1999
|
+
xColumn = input.required(/* @ts-ignore */
|
|
2000
|
+
...(ngDevMode ? [{ debugName: "xColumn" }] : /* istanbul ignore next */ []));
|
|
2001
|
+
yColumn = input.required(/* @ts-ignore */
|
|
2002
|
+
...(ngDevMode ? [{ debugName: "yColumn" }] : /* istanbul ignore next */ []));
|
|
2003
|
+
locale = input.required(/* @ts-ignore */
|
|
2004
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
2005
|
+
emptyMessage = input.required(/* @ts-ignore */
|
|
2006
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
2007
|
+
width = input(80, /* @ts-ignore */
|
|
2008
|
+
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
2009
|
+
height = input(24, /* @ts-ignore */
|
|
2010
|
+
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
2011
|
+
activeIndex = signal(null, /* @ts-ignore */
|
|
2012
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
2013
|
+
viewBox = computed(() => `0 0 ${this.width()} ${this.height()}`, /* @ts-ignore */
|
|
2014
|
+
...(ngDevMode ? [{ debugName: "viewBox" }] : /* istanbul ignore next */ []));
|
|
2015
|
+
columns = computed(() => [this.xColumn(), this.yColumn()], /* @ts-ignore */
|
|
2016
|
+
...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
2017
|
+
tableRows = computed(() => this.values().map((value, index) => [
|
|
2018
|
+
formatNumber(index + 1, this.locale()),
|
|
2019
|
+
formatNumber(value, this.locale()),
|
|
2020
|
+
]), /* @ts-ignore */
|
|
2021
|
+
...(ngDevMode ? [{ debugName: "tableRows" }] : /* istanbul ignore next */ []));
|
|
2022
|
+
scales = computed(() => {
|
|
2023
|
+
const values = this.values();
|
|
2024
|
+
const min = Math.min(...values);
|
|
2025
|
+
const max = Math.max(...values);
|
|
2026
|
+
return {
|
|
2027
|
+
x: linearScale([0, Math.max(values.length - 1, 0)], [MARGIN, this.width() - MARGIN]),
|
|
2028
|
+
y: linearScale([min, max], [this.height() - MARGIN, MARGIN]),
|
|
2029
|
+
};
|
|
2030
|
+
}, /* @ts-ignore */
|
|
2031
|
+
...(ngDevMode ? [{ debugName: "scales" }] : /* istanbul ignore next */ []));
|
|
2032
|
+
path = computed(() => {
|
|
2033
|
+
const values = this.values();
|
|
2034
|
+
if (values.length === 0)
|
|
2035
|
+
return null;
|
|
2036
|
+
const { x, y } = this.scales();
|
|
2037
|
+
return linePath(values.map((value, index) => ({ x: x.map(index), y: y.map(value) })));
|
|
2038
|
+
}, /* @ts-ignore */
|
|
2039
|
+
...(ngDevMode ? [{ debugName: "path" }] : /* istanbul ignore next */ []));
|
|
2040
|
+
positions = computed(() => {
|
|
2041
|
+
const { x } = this.scales();
|
|
2042
|
+
return this.values().map((_, index) => x.map(index));
|
|
2043
|
+
}, /* @ts-ignore */
|
|
2044
|
+
...(ngDevMode ? [{ debugName: "positions" }] : /* istanbul ignore next */ []));
|
|
2045
|
+
dot = computed(() => {
|
|
2046
|
+
const index = this.activeIndex();
|
|
2047
|
+
if (index === null)
|
|
2048
|
+
return null;
|
|
2049
|
+
const value = this.values()[index];
|
|
2050
|
+
if (value === undefined)
|
|
2051
|
+
return null;
|
|
2052
|
+
const { x, y } = this.scales();
|
|
2053
|
+
return { x: x.map(index), y: y.map(value) };
|
|
2054
|
+
}, /* @ts-ignore */
|
|
2055
|
+
...(ngDevMode ? [{ debugName: "dot" }] : /* istanbul ignore next */ []));
|
|
2056
|
+
tooltip = computed(() => {
|
|
2057
|
+
const index = this.activeIndex();
|
|
2058
|
+
if (index === null)
|
|
2059
|
+
return null;
|
|
2060
|
+
const value = this.values()[index];
|
|
2061
|
+
if (value === undefined)
|
|
2062
|
+
return null;
|
|
2063
|
+
return `${this.xColumn()} ${formatNumber(index + 1, this.locale())} — ${this.yColumn()} ${formatNumber(value, this.locale())}`;
|
|
2064
|
+
}, /* @ts-ignore */
|
|
2065
|
+
...(ngDevMode ? [{ debugName: "tooltip" }] : /* istanbul ignore next */ []));
|
|
2066
|
+
onPointerMove(event) {
|
|
2067
|
+
const positions = this.positions();
|
|
2068
|
+
if (positions.length === 0)
|
|
2069
|
+
return;
|
|
2070
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
2071
|
+
this.activeIndex.set(nearestIndex(positions, event.clientX - rect.left));
|
|
2072
|
+
}
|
|
2073
|
+
onPointerLeave(event) {
|
|
2074
|
+
const target = event.currentTarget;
|
|
2075
|
+
if (target.ownerDocument.activeElement === target)
|
|
2076
|
+
return;
|
|
2077
|
+
this.activeIndex.set(null);
|
|
2078
|
+
}
|
|
2079
|
+
onBlur() {
|
|
2080
|
+
this.activeIndex.set(null);
|
|
2081
|
+
}
|
|
2082
|
+
onKeydown(event) {
|
|
2083
|
+
const lastIndex = this.values().length - 1;
|
|
2084
|
+
if (lastIndex < 0)
|
|
2085
|
+
return;
|
|
2086
|
+
const current = this.activeIndex();
|
|
2087
|
+
switch (event.key) {
|
|
2088
|
+
case 'ArrowRight':
|
|
2089
|
+
this.activeIndex.set(current === null ? 0 : Math.min(lastIndex, current + 1));
|
|
2090
|
+
break;
|
|
2091
|
+
case 'ArrowLeft':
|
|
2092
|
+
this.activeIndex.set(current === null ? lastIndex : Math.max(0, current - 1));
|
|
2093
|
+
break;
|
|
2094
|
+
case 'Home':
|
|
2095
|
+
this.activeIndex.set(0);
|
|
2096
|
+
break;
|
|
2097
|
+
case 'End':
|
|
2098
|
+
this.activeIndex.set(lastIndex);
|
|
2099
|
+
break;
|
|
2100
|
+
case 'Escape':
|
|
2101
|
+
this.activeIndex.set(null);
|
|
2102
|
+
break;
|
|
2103
|
+
default:
|
|
2104
|
+
return;
|
|
2105
|
+
}
|
|
2106
|
+
event.preventDefault();
|
|
2107
|
+
}
|
|
2108
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Sparkline, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2109
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Sparkline, isStandalone: true, selector: "gbt-sparkline", inputs: { values: { classPropertyName: "values", publicName: "values", isSignal: true, isRequired: true, transformFunction: null }, tableCaption: { classPropertyName: "tableCaption", publicName: "tableCaption", isSignal: true, isRequired: true, transformFunction: null }, xColumn: { classPropertyName: "xColumn", publicName: "xColumn", isSignal: true, isRequired: true, transformFunction: null }, yColumn: { classPropertyName: "yColumn", publicName: "yColumn", isSignal: true, isRequired: true, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: true, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: true, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (path(); as d) {\n <div class=\"gbt-sparkline\" role=\"status\" aria-live=\"polite\">\n <svg\n class=\"gbt-sparkline__svg\"\n [attr.viewBox]=\"viewBox()\"\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n tabindex=\"0\"\n role=\"group\"\n [attr.aria-label]=\"tableCaption()\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerleave)=\"onPointerLeave($event)\"\n (keydown)=\"onKeydown($event)\"\n (blur)=\"onBlur()\"\n >\n <path class=\"gbt-sparkline__line\" [attr.d]=\"d\" />\n @if (dot(); as p) {\n <circle class=\"gbt-sparkline__dot\" [attr.cx]=\"p.x\" [attr.cy]=\"p.y\" r=\"3\" />\n }\n </svg>\n @if (tooltip(); as text) {\n <span class=\"gbt-sparkline__tooltip\">{{ text }}</span>\n }\n </div>\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"columns()\" [rows]=\"tableRows()\" />\n} @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n}\n", styles: [":host{display:inline-block;line-height:0}.gbt-sparkline{position:relative;display:inline-block}.gbt-sparkline__svg:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-sparkline__line{fill:none;stroke:var(--chart-series-1-base);stroke-width:1.5;stroke-linejoin:round;stroke-linecap:round}.gbt-sparkline__dot{fill:var(--chart-series-1-base);stroke:var(--bg-principal);stroke-width:1.5;pointer-events:none}.gbt-sparkline__tooltip{position:absolute;left:50%;bottom:100%;transform:translate(-50%);white-space:nowrap;padding:.125rem .375rem;border-radius:var(--site-border-radius);background:var(--bg-panel);border:1px solid var(--border-color);font-size:.6875rem;font-variant-numeric:tabular-nums;color:var(--text-primary);pointer-events:none}\n"], dependencies: [{ kind: "component", type: ChartEmpty, selector: "gbt-chart-empty", inputs: ["message", "actionLabel"], outputs: ["action"] }, { kind: "component", type: ChartTable, selector: "gbt-chart-table", inputs: ["caption", "columns", "rows"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2110
|
+
}
|
|
2111
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Sparkline, decorators: [{
|
|
2112
|
+
type: Component,
|
|
2113
|
+
args: [{ selector: 'gbt-sparkline', standalone: true, imports: [ChartEmpty, ChartTable], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (path(); as d) {\n <div class=\"gbt-sparkline\" role=\"status\" aria-live=\"polite\">\n <svg\n class=\"gbt-sparkline__svg\"\n [attr.viewBox]=\"viewBox()\"\n [attr.width]=\"width()\"\n [attr.height]=\"height()\"\n tabindex=\"0\"\n role=\"group\"\n [attr.aria-label]=\"tableCaption()\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerleave)=\"onPointerLeave($event)\"\n (keydown)=\"onKeydown($event)\"\n (blur)=\"onBlur()\"\n >\n <path class=\"gbt-sparkline__line\" [attr.d]=\"d\" />\n @if (dot(); as p) {\n <circle class=\"gbt-sparkline__dot\" [attr.cx]=\"p.x\" [attr.cy]=\"p.y\" r=\"3\" />\n }\n </svg>\n @if (tooltip(); as text) {\n <span class=\"gbt-sparkline__tooltip\">{{ text }}</span>\n }\n </div>\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"columns()\" [rows]=\"tableRows()\" />\n} @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n}\n", styles: [":host{display:inline-block;line-height:0}.gbt-sparkline{position:relative;display:inline-block}.gbt-sparkline__svg:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-sparkline__line{fill:none;stroke:var(--chart-series-1-base);stroke-width:1.5;stroke-linejoin:round;stroke-linecap:round}.gbt-sparkline__dot{fill:var(--chart-series-1-base);stroke:var(--bg-principal);stroke-width:1.5;pointer-events:none}.gbt-sparkline__tooltip{position:absolute;left:50%;bottom:100%;transform:translate(-50%);white-space:nowrap;padding:.125rem .375rem;border-radius:var(--site-border-radius);background:var(--bg-panel);border:1px solid var(--border-color);font-size:.6875rem;font-variant-numeric:tabular-nums;color:var(--text-primary);pointer-events:none}\n"] }]
|
|
2114
|
+
}], propDecorators: { values: [{ type: i0.Input, args: [{ isSignal: true, alias: "values", required: true }] }], tableCaption: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableCaption", required: true }] }], xColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "xColumn", required: true }] }], yColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "yColumn", required: true }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: true }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: true }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }] } });
|
|
2115
|
+
|
|
2116
|
+
class GaugeBar {
|
|
2117
|
+
value = input.required(/* @ts-ignore */
|
|
2118
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
2119
|
+
max = input.required(/* @ts-ignore */
|
|
2120
|
+
...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
2121
|
+
label = input.required(/* @ts-ignore */
|
|
2122
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
2123
|
+
formattedValue = input.required(/* @ts-ignore */
|
|
2124
|
+
...(ngDevMode ? [{ debugName: "formattedValue" }] : /* istanbul ignore next */ []));
|
|
2125
|
+
warningLabel = input.required(/* @ts-ignore */
|
|
2126
|
+
...(ngDevMode ? [{ debugName: "warningLabel" }] : /* istanbul ignore next */ []));
|
|
2127
|
+
criticalLabel = input.required(/* @ts-ignore */
|
|
2128
|
+
...(ngDevMode ? [{ debugName: "criticalLabel" }] : /* istanbul ignore next */ []));
|
|
2129
|
+
thresholds = input({ warning: 70, critical: 90 }, /* @ts-ignore */
|
|
2130
|
+
...(ngDevMode ? [{ debugName: "thresholds" }] : /* istanbul ignore next */ []));
|
|
2131
|
+
percentage = computed(() => {
|
|
2132
|
+
const max = this.max();
|
|
2133
|
+
if (max <= 0)
|
|
2134
|
+
return 0;
|
|
2135
|
+
return Math.max(0, Math.min(100, (this.value() / max) * 100));
|
|
2136
|
+
}, /* @ts-ignore */
|
|
2137
|
+
...(ngDevMode ? [{ debugName: "percentage" }] : /* istanbul ignore next */ []));
|
|
2138
|
+
severity = computed(() => {
|
|
2139
|
+
const percentage = this.percentage();
|
|
2140
|
+
const { warning, critical } = this.thresholds();
|
|
2141
|
+
if (percentage >= critical)
|
|
2142
|
+
return 'critical';
|
|
2143
|
+
if (percentage >= warning)
|
|
2144
|
+
return 'warning';
|
|
2145
|
+
return null;
|
|
2146
|
+
}, /* @ts-ignore */
|
|
2147
|
+
...(ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []));
|
|
2148
|
+
severityLabel = computed(() => {
|
|
2149
|
+
const severity = this.severity();
|
|
2150
|
+
if (severity === 'critical')
|
|
2151
|
+
return this.criticalLabel();
|
|
2152
|
+
if (severity === 'warning')
|
|
2153
|
+
return this.warningLabel();
|
|
2154
|
+
return null;
|
|
2155
|
+
}, /* @ts-ignore */
|
|
2156
|
+
...(ngDevMode ? [{ debugName: "severityLabel" }] : /* istanbul ignore next */ []));
|
|
2157
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: GaugeBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2158
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: GaugeBar, isStandalone: true, selector: "gbt-gauge-bar", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, formattedValue: { classPropertyName: "formattedValue", publicName: "formattedValue", isSignal: true, isRequired: true, transformFunction: null }, warningLabel: { classPropertyName: "warningLabel", publicName: "warningLabel", isSignal: true, isRequired: true, transformFunction: null }, criticalLabel: { classPropertyName: "criticalLabel", publicName: "criticalLabel", isSignal: true, isRequired: true, transformFunction: null }, thresholds: { classPropertyName: "thresholds", publicName: "thresholds", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div class=\"gbt-gauge-bar\">\n <div class=\"gbt-gauge-bar__header\">\n <span class=\"gbt-gauge-bar__label\">{{ label() }}</span>\n <span class=\"gbt-gauge-bar__value\">\n {{ formattedValue() }}\n @if (severityLabel(); as tierLabel) {\n <span class=\"gbt-gauge-bar__tier\" [attr.data-tier]=\"severity()\">{{ tierLabel }}</span>\n }\n </span>\n </div>\n <div\n class=\"gbt-gauge-bar__track\"\n role=\"progressbar\"\n [attr.aria-label]=\"label()\"\n [attr.aria-valuenow]=\"percentage()\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuetext]=\"formattedValue()\"\n >\n <div\n class=\"gbt-gauge-bar__fill\"\n [attr.data-tier]=\"severity()\"\n [style.width.%]=\"percentage()\"\n ></div>\n </div>\n</div>\n", styles: [":host{display:block}.gbt-gauge-bar__header{display:flex;justify-content:space-between;gap:.75rem;margin-bottom:.375rem;font-size:.875rem}.gbt-gauge-bar__label{color:var(--text-primary)}.gbt-gauge-bar__value{color:var(--text-secondary);font-variant-numeric:tabular-nums}.gbt-gauge-bar__tier{margin-left:.5rem}.gbt-gauge-bar__tier[data-tier=warning]{color:var(--color-warning-text)}.gbt-gauge-bar__tier[data-tier=critical]{color:var(--color-error-text)}.gbt-gauge-bar__track{height:.5rem;border-radius:var(--site-border-radius);background:var(--bg-hover);overflow:hidden}.gbt-gauge-bar__fill{height:100%;background:var(--color-success-base)}.gbt-gauge-bar__fill[data-tier=warning]{background:var(--color-warning-base)}.gbt-gauge-bar__fill[data-tier=critical]{background:var(--color-error-base)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2159
|
+
}
|
|
2160
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: GaugeBar, decorators: [{
|
|
2161
|
+
type: Component,
|
|
2162
|
+
args: [{ selector: 'gbt-gauge-bar', standalone: true, imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"gbt-gauge-bar\">\n <div class=\"gbt-gauge-bar__header\">\n <span class=\"gbt-gauge-bar__label\">{{ label() }}</span>\n <span class=\"gbt-gauge-bar__value\">\n {{ formattedValue() }}\n @if (severityLabel(); as tierLabel) {\n <span class=\"gbt-gauge-bar__tier\" [attr.data-tier]=\"severity()\">{{ tierLabel }}</span>\n }\n </span>\n </div>\n <div\n class=\"gbt-gauge-bar__track\"\n role=\"progressbar\"\n [attr.aria-label]=\"label()\"\n [attr.aria-valuenow]=\"percentage()\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n [attr.aria-valuetext]=\"formattedValue()\"\n >\n <div\n class=\"gbt-gauge-bar__fill\"\n [attr.data-tier]=\"severity()\"\n [style.width.%]=\"percentage()\"\n ></div>\n </div>\n</div>\n", styles: [":host{display:block}.gbt-gauge-bar__header{display:flex;justify-content:space-between;gap:.75rem;margin-bottom:.375rem;font-size:.875rem}.gbt-gauge-bar__label{color:var(--text-primary)}.gbt-gauge-bar__value{color:var(--text-secondary);font-variant-numeric:tabular-nums}.gbt-gauge-bar__tier{margin-left:.5rem}.gbt-gauge-bar__tier[data-tier=warning]{color:var(--color-warning-text)}.gbt-gauge-bar__tier[data-tier=critical]{color:var(--color-error-text)}.gbt-gauge-bar__track{height:.5rem;border-radius:var(--site-border-radius);background:var(--bg-hover);overflow:hidden}.gbt-gauge-bar__fill{height:100%;background:var(--color-success-base)}.gbt-gauge-bar__fill[data-tier=warning]{background:var(--color-warning-base)}.gbt-gauge-bar__fill[data-tier=critical]{background:var(--color-error-base)}\n"] }]
|
|
2163
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], formattedValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "formattedValue", required: true }] }], warningLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "warningLabel", required: true }] }], criticalLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "criticalLabel", required: true }] }], thresholds: [{ type: i0.Input, args: [{ isSignal: true, alias: "thresholds", required: false }] }] } });
|
|
2164
|
+
|
|
2165
|
+
class DimensionCard {
|
|
2166
|
+
rows = input.required(/* @ts-ignore */
|
|
2167
|
+
...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
2168
|
+
caption = input.required(/* @ts-ignore */
|
|
2169
|
+
...(ngDevMode ? [{ debugName: "caption" }] : /* istanbul ignore next */ []));
|
|
2170
|
+
labelColumn = input.required(/* @ts-ignore */
|
|
2171
|
+
...(ngDevMode ? [{ debugName: "labelColumn" }] : /* istanbul ignore next */ []));
|
|
2172
|
+
valueColumn = input.required(/* @ts-ignore */
|
|
2173
|
+
...(ngDevMode ? [{ debugName: "valueColumn" }] : /* istanbul ignore next */ []));
|
|
2174
|
+
emptyMessage = input.required(/* @ts-ignore */
|
|
2175
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
2176
|
+
locale = input.required(/* @ts-ignore */
|
|
2177
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
2178
|
+
activeIndex = signal(null, /* @ts-ignore */
|
|
2179
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
2180
|
+
renderedRows = computed(() => {
|
|
2181
|
+
const rows = this.rows();
|
|
2182
|
+
const maxValue = rows.reduce((max, row) => Math.max(max, row.value), 0);
|
|
2183
|
+
return rows.map((row) => ({
|
|
2184
|
+
label: row.label,
|
|
2185
|
+
formattedValue: formatNumber(row.value, this.locale()),
|
|
2186
|
+
part: maxValue <= 0 ? 0 : (row.value / maxValue) * 100,
|
|
2187
|
+
}));
|
|
2188
|
+
}, /* @ts-ignore */
|
|
2189
|
+
...(ngDevMode ? [{ debugName: "renderedRows" }] : /* istanbul ignore next */ []));
|
|
2190
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: DimensionCard, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2191
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: DimensionCard, isStandalone: true, selector: "gbt-dimension-card", inputs: { rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: true, transformFunction: null }, caption: { classPropertyName: "caption", publicName: "caption", isSignal: true, isRequired: true, transformFunction: null }, labelColumn: { classPropertyName: "labelColumn", publicName: "labelColumn", isSignal: true, isRequired: true, transformFunction: null }, valueColumn: { classPropertyName: "valueColumn", publicName: "valueColumn", isSignal: true, isRequired: true, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: true, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@if (rows().length > 0) {\n <table class=\"gbt-dimension-card\">\n <caption>\n {{\n caption()\n }}\n </caption>\n <thead>\n <tr>\n <th scope=\"col\">{{ labelColumn() }}</th>\n <th scope=\"col\">{{ valueColumn() }}</th>\n </tr>\n </thead>\n <tbody>\n @for (row of renderedRows(); track $index) {\n <tr\n [attr.data-active]=\"$index === activeIndex() ? '' : null\"\n (mouseenter)=\"activeIndex.set($index)\"\n (mouseleave)=\"activeIndex.set(null)\"\n >\n <th scope=\"row\" class=\"gbt-dimension-card__cell\">\n <span\n class=\"gbt-dimension-card__bar\"\n [style.width.%]=\"row.part\"\n aria-hidden=\"true\"\n ></span>\n <span class=\"gbt-dimension-card__label\">{{ row.label }}</span>\n </th>\n <td class=\"gbt-dimension-card__value\">{{ row.formattedValue }}</td>\n </tr>\n }\n </tbody>\n </table>\n} @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n}\n", styles: [":host{display:block}.gbt-dimension-card{width:100%;border-collapse:collapse;font-size:.875rem}.gbt-dimension-card caption{margin-bottom:.5rem;color:var(--text-primary);font-weight:600;text-align:left}.gbt-dimension-card th,.gbt-dimension-card td{padding:.375rem .5rem;text-align:left;font-weight:400;color:var(--text-primary)}.gbt-dimension-card thead th{color:var(--text-secondary);font-size:.75rem}.gbt-dimension-card__cell{position:relative}.gbt-dimension-card__bar{position:absolute;inset:0 auto 0 0;background:var(--chart-series-3-base);opacity:.16;border-radius:var(--site-border-radius)}.gbt-dimension-card__label,.gbt-dimension-card__value{position:relative}.gbt-dimension-card__value{text-align:right;font-variant-numeric:tabular-nums}.gbt-dimension-card tbody tr[data-active]{background:var(--bg-hover)}\n"], dependencies: [{ kind: "component", type: ChartEmpty, selector: "gbt-chart-empty", inputs: ["message", "actionLabel"], outputs: ["action"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2192
|
+
}
|
|
2193
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: DimensionCard, decorators: [{
|
|
2194
|
+
type: Component,
|
|
2195
|
+
args: [{ selector: 'gbt-dimension-card', standalone: true, imports: [ChartEmpty], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (rows().length > 0) {\n <table class=\"gbt-dimension-card\">\n <caption>\n {{\n caption()\n }}\n </caption>\n <thead>\n <tr>\n <th scope=\"col\">{{ labelColumn() }}</th>\n <th scope=\"col\">{{ valueColumn() }}</th>\n </tr>\n </thead>\n <tbody>\n @for (row of renderedRows(); track $index) {\n <tr\n [attr.data-active]=\"$index === activeIndex() ? '' : null\"\n (mouseenter)=\"activeIndex.set($index)\"\n (mouseleave)=\"activeIndex.set(null)\"\n >\n <th scope=\"row\" class=\"gbt-dimension-card__cell\">\n <span\n class=\"gbt-dimension-card__bar\"\n [style.width.%]=\"row.part\"\n aria-hidden=\"true\"\n ></span>\n <span class=\"gbt-dimension-card__label\">{{ row.label }}</span>\n </th>\n <td class=\"gbt-dimension-card__value\">{{ row.formattedValue }}</td>\n </tr>\n }\n </tbody>\n </table>\n} @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n}\n", styles: [":host{display:block}.gbt-dimension-card{width:100%;border-collapse:collapse;font-size:.875rem}.gbt-dimension-card caption{margin-bottom:.5rem;color:var(--text-primary);font-weight:600;text-align:left}.gbt-dimension-card th,.gbt-dimension-card td{padding:.375rem .5rem;text-align:left;font-weight:400;color:var(--text-primary)}.gbt-dimension-card thead th{color:var(--text-secondary);font-size:.75rem}.gbt-dimension-card__cell{position:relative}.gbt-dimension-card__bar{position:absolute;inset:0 auto 0 0;background:var(--chart-series-3-base);opacity:.16;border-radius:var(--site-border-radius)}.gbt-dimension-card__label,.gbt-dimension-card__value{position:relative}.gbt-dimension-card__value{text-align:right;font-variant-numeric:tabular-nums}.gbt-dimension-card tbody tr[data-active]{background:var(--bg-hover)}\n"] }]
|
|
2196
|
+
}], propDecorators: { rows: [{ type: i0.Input, args: [{ isSignal: true, alias: "rows", required: true }] }], caption: [{ type: i0.Input, args: [{ isSignal: true, alias: "caption", required: true }] }], labelColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelColumn", required: true }] }], valueColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueColumn", required: true }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: true }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: true }] }] } });
|
|
2197
|
+
|
|
2198
|
+
class FunnelChart {
|
|
2199
|
+
steps = input.required(/* @ts-ignore */
|
|
2200
|
+
...(ngDevMode ? [{ debugName: "steps" }] : /* istanbul ignore next */ []));
|
|
2201
|
+
label = input.required(/* @ts-ignore */
|
|
2202
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
2203
|
+
locale = input.required(/* @ts-ignore */
|
|
2204
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
2205
|
+
emptyMessage = input.required(/* @ts-ignore */
|
|
2206
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
2207
|
+
tableCaption = input.required(/* @ts-ignore */
|
|
2208
|
+
...(ngDevMode ? [{ debugName: "tableCaption" }] : /* istanbul ignore next */ []));
|
|
2209
|
+
stepColumn = input.required(/* @ts-ignore */
|
|
2210
|
+
...(ngDevMode ? [{ debugName: "stepColumn" }] : /* istanbul ignore next */ []));
|
|
2211
|
+
valueColumn = input.required(/* @ts-ignore */
|
|
2212
|
+
...(ngDevMode ? [{ debugName: "valueColumn" }] : /* istanbul ignore next */ []));
|
|
2213
|
+
conversionColumn = input.required(/* @ts-ignore */
|
|
2214
|
+
...(ngDevMode ? [{ debugName: "conversionColumn" }] : /* istanbul ignore next */ []));
|
|
2215
|
+
stepAnnouncement = input.required(/* @ts-ignore */
|
|
2216
|
+
...(ngDevMode ? [{ debugName: "stepAnnouncement" }] : /* istanbul ignore next */ []));
|
|
2217
|
+
reference = computed(() => this.steps()[0]?.value ?? 0, /* @ts-ignore */
|
|
2218
|
+
...(ngDevMode ? [{ debugName: "reference" }] : /* istanbul ignore next */ []));
|
|
2219
|
+
activeIndex = signal(null, /* @ts-ignore */
|
|
2220
|
+
...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
|
|
2221
|
+
onMouseLeave(event) {
|
|
2222
|
+
const target = event.currentTarget;
|
|
2223
|
+
if (target.ownerDocument.activeElement === target)
|
|
2224
|
+
return;
|
|
2225
|
+
this.activeIndex.set(null);
|
|
2226
|
+
}
|
|
2227
|
+
renderedSteps = computed(() => {
|
|
2228
|
+
const reference = this.reference();
|
|
2229
|
+
const steps = this.steps();
|
|
2230
|
+
return steps.map((step, index) => {
|
|
2231
|
+
const previousValue = index === 0 ? step.value : steps[index - 1].value;
|
|
2232
|
+
return {
|
|
2233
|
+
label: step.label,
|
|
2234
|
+
formattedValue: formatNumber(step.value, this.locale()),
|
|
2235
|
+
part: reference <= 0 ? 0 : (step.value / reference) * 100,
|
|
2236
|
+
conversionFromPrevious: formatPercent(previousValue <= 0 ? 0 : step.value / previousValue, this.locale()),
|
|
2237
|
+
};
|
|
2238
|
+
});
|
|
2239
|
+
}, /* @ts-ignore */
|
|
2240
|
+
...(ngDevMode ? [{ debugName: "renderedSteps" }] : /* istanbul ignore next */ []));
|
|
2241
|
+
activeStep = computed(() => {
|
|
2242
|
+
const index = this.activeIndex();
|
|
2243
|
+
if (index === null)
|
|
2244
|
+
return null;
|
|
2245
|
+
return this.renderedSteps()[index] ?? null;
|
|
2246
|
+
}, /* @ts-ignore */
|
|
2247
|
+
...(ngDevMode ? [{ debugName: "activeStep" }] : /* istanbul ignore next */ []));
|
|
2248
|
+
columns = computed(() => [
|
|
2249
|
+
this.stepColumn(),
|
|
2250
|
+
this.valueColumn(),
|
|
2251
|
+
this.conversionColumn(),
|
|
2252
|
+
], /* @ts-ignore */
|
|
2253
|
+
...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
|
|
2254
|
+
tableRows = computed(() => {
|
|
2255
|
+
const reference = this.reference();
|
|
2256
|
+
return this.steps().map((step) => [
|
|
2257
|
+
step.label,
|
|
2258
|
+
formatNumber(step.value, this.locale()),
|
|
2259
|
+
formatPercent(reference <= 0 ? 0 : step.value / reference, this.locale()),
|
|
2260
|
+
]);
|
|
2261
|
+
}, /* @ts-ignore */
|
|
2262
|
+
...(ngDevMode ? [{ debugName: "tableRows" }] : /* istanbul ignore next */ []));
|
|
2263
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: FunnelChart, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2264
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: FunnelChart, isStandalone: true, selector: "gbt-funnel-chart", inputs: { steps: { classPropertyName: "steps", publicName: "steps", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: true, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: true, transformFunction: null }, tableCaption: { classPropertyName: "tableCaption", publicName: "tableCaption", isSignal: true, isRequired: true, transformFunction: null }, stepColumn: { classPropertyName: "stepColumn", publicName: "stepColumn", isSignal: true, isRequired: true, transformFunction: null }, valueColumn: { classPropertyName: "valueColumn", publicName: "valueColumn", isSignal: true, isRequired: true, transformFunction: null }, conversionColumn: { classPropertyName: "conversionColumn", publicName: "conversionColumn", isSignal: true, isRequired: true, transformFunction: null }, stepAnnouncement: { classPropertyName: "stepAnnouncement", publicName: "stepAnnouncement", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@if (renderedSteps().length > 0) {\n <ol class=\"gbt-funnel-chart\" [attr.aria-label]=\"label()\">\n @for (step of renderedSteps(); track $index) {\n <li\n class=\"gbt-funnel-chart__step\"\n [attr.data-active]=\"$index === activeIndex() ? '' : null\"\n tabindex=\"0\"\n (mouseenter)=\"activeIndex.set($index)\"\n (mouseleave)=\"onMouseLeave($event)\"\n (focus)=\"activeIndex.set($index)\"\n (blur)=\"activeIndex.set(null)\"\n >\n <div class=\"gbt-funnel-chart__bar\" [style.width.%]=\"step.part\" aria-hidden=\"true\"></div>\n <span class=\"gbt-funnel-chart__label\">{{ step.label }}</span>\n <span class=\"gbt-funnel-chart__value\">{{ step.formattedValue }}</span>\n @if ($index === activeIndex()) {\n <span class=\"gbt-funnel-chart__tip\" aria-hidden=\"true\">{{\n step.conversionFromPrevious\n }}</span>\n }\n </li>\n }\n </ol>\n <div class=\"gbt-sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n @if (activeStep(); as step) {\n {{ stepAnnouncement()(step.label, step.conversionFromPrevious) }}\n }\n </div>\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"columns()\" [rows]=\"tableRows()\" />\n} @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n}\n", styles: [":host{display:block}.gbt-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.gbt-funnel-chart{margin:0;padding:0;list-style:none}.gbt-funnel-chart__step{position:relative;display:flex;justify-content:space-between;gap:.75rem;padding:.625rem .75rem;font-size:.875rem;color:var(--text-primary)}.gbt-funnel-chart__step+.gbt-funnel-chart__step{margin-top:.25rem}.gbt-funnel-chart__step[data-active]{background:var(--bg-hover)}.gbt-funnel-chart__step:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}.gbt-funnel-chart__bar{position:absolute;inset:0 auto 0 0;background:var(--chart-series-2-base);opacity:.14;border-radius:var(--site-border-radius)}.gbt-funnel-chart__label,.gbt-funnel-chart__value,.gbt-funnel-chart__tip{position:relative}.gbt-funnel-chart__value{font-variant-numeric:tabular-nums;color:var(--text-secondary)}.gbt-funnel-chart__tip{margin-left:.5rem;font-variant-numeric:tabular-nums;color:var(--text-secondary)}\n"], dependencies: [{ kind: "component", type: ChartTable, selector: "gbt-chart-table", inputs: ["caption", "columns", "rows"] }, { kind: "component", type: ChartEmpty, selector: "gbt-chart-empty", inputs: ["message", "actionLabel"], outputs: ["action"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2265
|
+
}
|
|
2266
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: FunnelChart, decorators: [{
|
|
2267
|
+
type: Component,
|
|
2268
|
+
args: [{ selector: 'gbt-funnel-chart', standalone: true, imports: [ChartTable, ChartEmpty], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (renderedSteps().length > 0) {\n <ol class=\"gbt-funnel-chart\" [attr.aria-label]=\"label()\">\n @for (step of renderedSteps(); track $index) {\n <li\n class=\"gbt-funnel-chart__step\"\n [attr.data-active]=\"$index === activeIndex() ? '' : null\"\n tabindex=\"0\"\n (mouseenter)=\"activeIndex.set($index)\"\n (mouseleave)=\"onMouseLeave($event)\"\n (focus)=\"activeIndex.set($index)\"\n (blur)=\"activeIndex.set(null)\"\n >\n <div class=\"gbt-funnel-chart__bar\" [style.width.%]=\"step.part\" aria-hidden=\"true\"></div>\n <span class=\"gbt-funnel-chart__label\">{{ step.label }}</span>\n <span class=\"gbt-funnel-chart__value\">{{ step.formattedValue }}</span>\n @if ($index === activeIndex()) {\n <span class=\"gbt-funnel-chart__tip\" aria-hidden=\"true\">{{\n step.conversionFromPrevious\n }}</span>\n }\n </li>\n }\n </ol>\n <div class=\"gbt-sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n @if (activeStep(); as step) {\n {{ stepAnnouncement()(step.label, step.conversionFromPrevious) }}\n }\n </div>\n <gbt-chart-table [caption]=\"tableCaption()\" [columns]=\"columns()\" [rows]=\"tableRows()\" />\n} @else {\n <gbt-chart-empty [message]=\"emptyMessage()\" />\n}\n", styles: [":host{display:block}.gbt-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.gbt-funnel-chart{margin:0;padding:0;list-style:none}.gbt-funnel-chart__step{position:relative;display:flex;justify-content:space-between;gap:.75rem;padding:.625rem .75rem;font-size:.875rem;color:var(--text-primary)}.gbt-funnel-chart__step+.gbt-funnel-chart__step{margin-top:.25rem}.gbt-funnel-chart__step[data-active]{background:var(--bg-hover)}.gbt-funnel-chart__step:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}.gbt-funnel-chart__bar{position:absolute;inset:0 auto 0 0;background:var(--chart-series-2-base);opacity:.14;border-radius:var(--site-border-radius)}.gbt-funnel-chart__label,.gbt-funnel-chart__value,.gbt-funnel-chart__tip{position:relative}.gbt-funnel-chart__value{font-variant-numeric:tabular-nums;color:var(--text-secondary)}.gbt-funnel-chart__tip{margin-left:.5rem;font-variant-numeric:tabular-nums;color:var(--text-secondary)}\n"] }]
|
|
2269
|
+
}], propDecorators: { steps: [{ type: i0.Input, args: [{ isSignal: true, alias: "steps", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: true }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: true }] }], tableCaption: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableCaption", required: true }] }], stepColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "stepColumn", required: true }] }], valueColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueColumn", required: true }] }], conversionColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "conversionColumn", required: true }] }], stepAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "stepAnnouncement", required: true }] }] } });
|
|
2270
|
+
|
|
2271
|
+
class Menu {
|
|
2272
|
+
elementRef = inject((ElementRef));
|
|
2273
|
+
injector = inject(Injector);
|
|
2274
|
+
label = input.required(/* @ts-ignore */
|
|
2275
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
2276
|
+
align = input('start', /* @ts-ignore */
|
|
2277
|
+
...(ngDevMode ? [{ debugName: "align" }] : /* istanbul ignore next */ []));
|
|
2278
|
+
open = signal(false, /* @ts-ignore */
|
|
2279
|
+
...(ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []));
|
|
2280
|
+
position = signal(null, /* @ts-ignore */
|
|
2281
|
+
...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
2282
|
+
trigger = viewChild('trigger', /* @ts-ignore */
|
|
2283
|
+
...(ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []));
|
|
2284
|
+
list = viewChild('list', /* @ts-ignore */
|
|
2285
|
+
...(ngDevMode ? [{ debugName: "list" }] : /* istanbul ignore next */ []));
|
|
2286
|
+
toggle() {
|
|
2287
|
+
this.open.update((value) => !value);
|
|
2288
|
+
if (this.open()) {
|
|
2289
|
+
this.updatePosition();
|
|
2290
|
+
this.focusAfterRender('first');
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
close(returnFocus) {
|
|
2294
|
+
if (!this.open())
|
|
2295
|
+
return;
|
|
2296
|
+
this.open.set(false);
|
|
2297
|
+
if (returnFocus) {
|
|
2298
|
+
this.trigger()?.nativeElement.focus();
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
onTriggerKeydown(event) {
|
|
2302
|
+
if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')
|
|
2303
|
+
return;
|
|
2304
|
+
event.preventDefault();
|
|
2305
|
+
const target = event.key === 'ArrowUp' ? 'last' : 'first';
|
|
2306
|
+
if (!this.open()) {
|
|
2307
|
+
this.open.set(true);
|
|
2308
|
+
this.updatePosition();
|
|
2309
|
+
}
|
|
2310
|
+
this.focusAfterRender(target);
|
|
2311
|
+
}
|
|
2312
|
+
onListKeydown(event) {
|
|
2313
|
+
const items = this.items();
|
|
2314
|
+
if (items.length === 0)
|
|
2315
|
+
return;
|
|
2316
|
+
const index = items.indexOf(document.activeElement);
|
|
2317
|
+
switch (event.key) {
|
|
2318
|
+
case 'Escape':
|
|
2319
|
+
event.preventDefault();
|
|
2320
|
+
this.close(true);
|
|
2321
|
+
break;
|
|
2322
|
+
case 'ArrowDown':
|
|
2323
|
+
event.preventDefault();
|
|
2324
|
+
this.focus((index + 1) % items.length);
|
|
2325
|
+
break;
|
|
2326
|
+
case 'ArrowUp':
|
|
2327
|
+
event.preventDefault();
|
|
2328
|
+
this.focus((index - 1 + items.length) % items.length);
|
|
2329
|
+
break;
|
|
2330
|
+
case 'Home':
|
|
2331
|
+
event.preventDefault();
|
|
2332
|
+
this.focus(0);
|
|
2333
|
+
break;
|
|
2334
|
+
case 'End':
|
|
2335
|
+
event.preventDefault();
|
|
2336
|
+
this.focus(items.length - 1);
|
|
2337
|
+
break;
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
onListClick() {
|
|
2341
|
+
this.close(false);
|
|
2342
|
+
}
|
|
2343
|
+
onDocumentClick(event) {
|
|
2344
|
+
if (this.open() && !this.elementRef.nativeElement.contains(event.target)) {
|
|
2345
|
+
this.close(false);
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
onFocusOut(event) {
|
|
2349
|
+
const target = event.relatedTarget;
|
|
2350
|
+
if (this.open() && !this.elementRef.nativeElement.contains(target)) {
|
|
2351
|
+
this.open.set(false);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
updatePosition() {
|
|
2355
|
+
if (!this.open())
|
|
2356
|
+
return;
|
|
2357
|
+
const trigger = this.trigger()?.nativeElement;
|
|
2358
|
+
if (!trigger)
|
|
2359
|
+
return;
|
|
2360
|
+
const rect = trigger.getBoundingClientRect();
|
|
2361
|
+
this.position.set(this.align() === 'end'
|
|
2362
|
+
? { top: `${rect.bottom + 6}px`, left: null, right: `${window.innerWidth - rect.right}px` }
|
|
2363
|
+
: { top: `${rect.bottom + 6}px`, left: `${rect.left}px`, right: null });
|
|
2364
|
+
}
|
|
2365
|
+
items() {
|
|
2366
|
+
const list = this.list()?.nativeElement;
|
|
2367
|
+
if (!list)
|
|
2368
|
+
return [];
|
|
2369
|
+
return [...list.querySelectorAll('[role="menuitem"]')];
|
|
2370
|
+
}
|
|
2371
|
+
focus(index) {
|
|
2372
|
+
this.items()[index]?.focus();
|
|
2373
|
+
}
|
|
2374
|
+
focusAfterRender(target) {
|
|
2375
|
+
afterNextRender(() => {
|
|
2376
|
+
const items = this.items();
|
|
2377
|
+
this.focus(target === 'last' ? items.length - 1 : 0);
|
|
2378
|
+
}, { injector: this.injector });
|
|
2379
|
+
}
|
|
2380
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Menu, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2381
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: Menu, isStandalone: true, selector: "gbt-menu", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "document:click": "onDocumentClick($event)", "focusout": "onFocusOut($event)", "window:scroll": "updatePosition()", "window:resize": "updatePosition()" } }, viewQueries: [{ propertyName: "trigger", first: true, predicate: ["trigger"], descendants: true, isSignal: true }, { propertyName: "list", first: true, predicate: ["list"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"gbt-menu\">\n <button\n #trigger\n type=\"button\"\n class=\"gbt-menu__trigger\"\n [class.gbt-menu__trigger--open]=\"open()\"\n aria-haspopup=\"menu\"\n [attr.aria-expanded]=\"open()\"\n (click)=\"toggle()\"\n (keydown)=\"onTriggerKeydown($event)\"\n >\n <span class=\"gbt-menu__label\">{{ label() }}</span>\n <gbt-icon name=\"chevron-down\" class=\"gbt-menu__chevron\" aria-hidden=\"true\" />\n </button>\n\n @if (open() && position(); as pos) {\n <div\n #list\n class=\"gbt-menu__list\"\n role=\"menu\"\n tabindex=\"-1\"\n [attr.aria-label]=\"label()\"\n [style.top]=\"pos.top\"\n [style.left]=\"pos.left\"\n [style.right]=\"pos.right\"\n (keydown)=\"onListKeydown($event)\"\n (click)=\"onListClick()\"\n >\n <ng-content />\n </div>\n }\n</div>\n", styles: [":host{display:inline-block}.gbt-menu{position:relative;display:inline-block}.gbt-menu__trigger{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;background:transparent;border:1px solid transparent;border-radius:var(--site-border-radius-sm);color:var(--text-primary);font-size:.875rem;cursor:pointer;transition:background .12s cubic-bezier(.4,0,.2,1)}.gbt-menu__trigger:hover{background:var(--bg-hover)}.gbt-menu__trigger:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-menu__trigger--open{background:var(--bg-hover)}.gbt-menu__chevron{flex-shrink:0;color:var(--text-secondary);transition:transform .2s cubic-bezier(.4,0,.2,1)}.gbt-menu__trigger--open .gbt-menu__chevron{transform:rotate(180deg)}.gbt-menu__list{position:fixed;z-index:1000;display:flex;flex-direction:column;min-width:180px;padding:6px;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);box-shadow:var(--site-shadow-lg);animation:gbt-menu-scale-in .15s cubic-bezier(.34,1.56,.64,1) both}@keyframes gbt-menu-scale-in{0%{opacity:0;transform:scale(.97) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}@media(prefers-reduced-motion:reduce){.gbt-menu__list{animation:none}.gbt-menu__chevron{transition:none}}\n"], dependencies: [{ kind: "component", type: Icon, selector: "gbt-icon", inputs: ["name"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2382
|
+
}
|
|
2383
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: Menu, decorators: [{
|
|
2384
|
+
type: Component,
|
|
2385
|
+
args: [{ selector: 'gbt-menu', standalone: true, imports: [Icon], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2386
|
+
'(document:click)': 'onDocumentClick($event)',
|
|
2387
|
+
'(focusout)': 'onFocusOut($event)',
|
|
2388
|
+
'(window:scroll)': 'updatePosition()',
|
|
2389
|
+
'(window:resize)': 'updatePosition()',
|
|
2390
|
+
}, template: "<div class=\"gbt-menu\">\n <button\n #trigger\n type=\"button\"\n class=\"gbt-menu__trigger\"\n [class.gbt-menu__trigger--open]=\"open()\"\n aria-haspopup=\"menu\"\n [attr.aria-expanded]=\"open()\"\n (click)=\"toggle()\"\n (keydown)=\"onTriggerKeydown($event)\"\n >\n <span class=\"gbt-menu__label\">{{ label() }}</span>\n <gbt-icon name=\"chevron-down\" class=\"gbt-menu__chevron\" aria-hidden=\"true\" />\n </button>\n\n @if (open() && position(); as pos) {\n <div\n #list\n class=\"gbt-menu__list\"\n role=\"menu\"\n tabindex=\"-1\"\n [attr.aria-label]=\"label()\"\n [style.top]=\"pos.top\"\n [style.left]=\"pos.left\"\n [style.right]=\"pos.right\"\n (keydown)=\"onListKeydown($event)\"\n (click)=\"onListClick()\"\n >\n <ng-content />\n </div>\n }\n</div>\n", styles: [":host{display:inline-block}.gbt-menu{position:relative;display:inline-block}.gbt-menu__trigger{display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;background:transparent;border:1px solid transparent;border-radius:var(--site-border-radius-sm);color:var(--text-primary);font-size:.875rem;cursor:pointer;transition:background .12s cubic-bezier(.4,0,.2,1)}.gbt-menu__trigger:hover{background:var(--bg-hover)}.gbt-menu__trigger:focus-visible{outline:2px solid var(--primary);outline-offset:2px}.gbt-menu__trigger--open{background:var(--bg-hover)}.gbt-menu__chevron{flex-shrink:0;color:var(--text-secondary);transition:transform .2s cubic-bezier(.4,0,.2,1)}.gbt-menu__trigger--open .gbt-menu__chevron{transform:rotate(180deg)}.gbt-menu__list{position:fixed;z-index:1000;display:flex;flex-direction:column;min-width:180px;padding:6px;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-sm);box-shadow:var(--site-shadow-lg);animation:gbt-menu-scale-in .15s cubic-bezier(.34,1.56,.64,1) both}@keyframes gbt-menu-scale-in{0%{opacity:0;transform:scale(.97) translateY(-4px)}to{opacity:1;transform:scale(1) translateY(0)}}@media(prefers-reduced-motion:reduce){.gbt-menu__list{animation:none}.gbt-menu__chevron{transition:none}}\n"] }]
|
|
2391
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], align: [{ type: i0.Input, args: [{ isSignal: true, alias: "align", required: false }] }], trigger: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }], list: [{ type: i0.ViewChild, args: ['list', { isSignal: true }] }] } });
|
|
2392
|
+
|
|
2393
|
+
/**
|
|
2394
|
+
* Generated bundle index. Do not edit.
|
|
2395
|
+
*/
|
|
2396
|
+
|
|
2397
|
+
export { AppShell, BarChart, BarSeries, Button, CHART_CONTEXT, Card, ChartAxis, ChartEmpty, ChartFrame, ChartLegend, ChartTable, ChartTooltip, Checkbox, DimensionCard, FunnelChart, GABARIT_VERSION, GaugeBar, GbtInput, Icon, IconRegistry, LineChart, LineSeries, Menu, Modal, SearchBar, Select, Sparkline, Tab, Table, Tabs, TimelineChart, TimelineSeries, areaPath, bandScale, formatCompact, formatDuration, formatNumber, formatPercent, linePath, linearScale, nearestIndex, niceTicks, niceXDomain, niceYDomain, timeScale, timeTicks };
|
|
2398
|
+
//# sourceMappingURL=masmarino-gabarit.mjs.map
|