@elgiborsolution/ui 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/README.md +24 -0
- package/esm2022/elgiborsolution-ui.mjs +5 -0
- package/esm2022/lib/accordion/accordion-item.component.mjs +102 -0
- package/esm2022/lib/accordion/accordion.component.mjs +44 -0
- package/esm2022/lib/accordion/index.mjs +3 -0
- package/esm2022/lib/alert/alert.component.mjs +115 -0
- package/esm2022/lib/alert/index.mjs +2 -0
- package/esm2022/lib/autocomplete/autocomplete.component.mjs +240 -0
- package/esm2022/lib/autocomplete/index.mjs +2 -0
- package/esm2022/lib/badge/badge.component.mjs +24 -0
- package/esm2022/lib/badge/index.mjs +2 -0
- package/esm2022/lib/breadcrumb/breadcrumb.component.mjs +51 -0
- package/esm2022/lib/breadcrumb/index.mjs +2 -0
- package/esm2022/lib/button/button.component.mjs +71 -0
- package/esm2022/lib/button/index.mjs +2 -0
- package/esm2022/lib/card/card.component.mjs +38 -0
- package/esm2022/lib/card/index.mjs +2 -0
- package/esm2022/lib/checkbox/checkbox.component.mjs +125 -0
- package/esm2022/lib/checkbox/index.mjs +2 -0
- package/esm2022/lib/chip-input/chip-input.component.mjs +142 -0
- package/esm2022/lib/chip-input/index.mjs +2 -0
- package/esm2022/lib/core/elg-ui.provider.mjs +23 -0
- package/esm2022/lib/core/index.mjs +4 -0
- package/esm2022/lib/core/theme.service.mjs +49 -0
- package/esm2022/lib/core/types.mjs +2 -0
- package/esm2022/lib/date-picker/date-picker.component.mjs +379 -0
- package/esm2022/lib/date-picker/index.mjs +2 -0
- package/esm2022/lib/dialog/dialog.component.mjs +131 -0
- package/esm2022/lib/dialog/dialog.service.mjs +37 -0
- package/esm2022/lib/dialog/dialog.types.mjs +10 -0
- package/esm2022/lib/dialog/index.mjs +4 -0
- package/esm2022/lib/dropdown-menu/dropdown-menu.component.mjs +139 -0
- package/esm2022/lib/dropdown-menu/dropdown-trigger.directive.mjs +36 -0
- package/esm2022/lib/dropdown-menu/index.mjs +4 -0
- package/esm2022/lib/dropdown-menu/menu-item.component.mjs +46 -0
- package/esm2022/lib/file-upload/file-upload.component.mjs +257 -0
- package/esm2022/lib/file-upload/index.mjs +2 -0
- package/esm2022/lib/form-field/form-field.component.mjs +51 -0
- package/esm2022/lib/form-field/index.mjs +2 -0
- package/esm2022/lib/input/index.mjs +2 -0
- package/esm2022/lib/input/input.directive.mjs +85 -0
- package/esm2022/lib/locale/index.mjs +2 -0
- package/esm2022/lib/locale/locale.service.mjs +48 -0
- package/esm2022/lib/number-input/index.mjs +2 -0
- package/esm2022/lib/number-input/number-input.component.mjs +152 -0
- package/esm2022/lib/pagination/index.mjs +2 -0
- package/esm2022/lib/pagination/pagination.component.mjs +184 -0
- package/esm2022/lib/progress/index.mjs +2 -0
- package/esm2022/lib/progress/progress.component.mjs +56 -0
- package/esm2022/lib/radio/index.mjs +3 -0
- package/esm2022/lib/radio/radio-group.component.mjs +86 -0
- package/esm2022/lib/radio/radio.component.mjs +77 -0
- package/esm2022/lib/select/index.mjs +2 -0
- package/esm2022/lib/select/select.component.mjs +118 -0
- package/esm2022/lib/sidebar/index.mjs +2 -0
- package/esm2022/lib/sidebar/sidebar.component.mjs +109 -0
- package/esm2022/lib/skeleton/index.mjs +2 -0
- package/esm2022/lib/skeleton/skeleton.component.mjs +28 -0
- package/esm2022/lib/stepper/index.mjs +3 -0
- package/esm2022/lib/stepper/step.component.mjs +32 -0
- package/esm2022/lib/stepper/stepper.component.mjs +142 -0
- package/esm2022/lib/switch/index.mjs +2 -0
- package/esm2022/lib/switch/switch.component.mjs +98 -0
- package/esm2022/lib/table/index.mjs +2 -0
- package/esm2022/lib/table/table.component.mjs +323 -0
- package/esm2022/lib/table/table.types.mjs +2 -0
- package/esm2022/lib/tabs/index.mjs +3 -0
- package/esm2022/lib/tabs/tab-group.component.mjs +134 -0
- package/esm2022/lib/tabs/tab.component.mjs +30 -0
- package/esm2022/lib/textarea/index.mjs +2 -0
- package/esm2022/lib/textarea/textarea.component.mjs +96 -0
- package/esm2022/lib/toast/index.mjs +3 -0
- package/esm2022/lib/toast/toast-container.component.mjs +80 -0
- package/esm2022/lib/toast/toast.service.mjs +56 -0
- package/esm2022/lib/toast/toast.types.mjs +2 -0
- package/esm2022/lib/tooltip/index.mjs +2 -0
- package/esm2022/lib/tooltip/tooltip.directive.mjs +134 -0
- package/esm2022/lib/tree/index.mjs +3 -0
- package/esm2022/lib/tree/tree-node.component.mjs +155 -0
- package/esm2022/lib/tree/tree.component.mjs +59 -0
- package/esm2022/lib/tree/tree.types.mjs +2 -0
- package/esm2022/public-api.mjs +36 -0
- package/fesm2022/elgiborsolution-ui.mjs +4298 -0
- package/fesm2022/elgiborsolution-ui.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/accordion/accordion-item.component.d.ts +16 -0
- package/lib/accordion/accordion.component.d.ts +11 -0
- package/lib/accordion/index.d.ts +2 -0
- package/lib/alert/alert.component.d.ts +12 -0
- package/lib/alert/index.d.ts +2 -0
- package/lib/autocomplete/autocomplete.component.d.ts +38 -0
- package/lib/autocomplete/index.d.ts +1 -0
- package/lib/badge/badge.component.d.ts +10 -0
- package/lib/badge/index.d.ts +2 -0
- package/lib/breadcrumb/breadcrumb.component.d.ts +13 -0
- package/lib/breadcrumb/index.d.ts +2 -0
- package/lib/button/button.component.d.ts +10 -0
- package/lib/button/index.d.ts +1 -0
- package/lib/card/card.component.d.ts +6 -0
- package/lib/card/index.d.ts +1 -0
- package/lib/checkbox/checkbox.component.d.ts +24 -0
- package/lib/checkbox/index.d.ts +1 -0
- package/lib/chip-input/chip-input.component.d.ts +27 -0
- package/lib/chip-input/index.d.ts +1 -0
- package/lib/core/elg-ui.provider.d.ts +3 -0
- package/lib/core/index.d.ts +3 -0
- package/lib/core/theme.service.d.ts +15 -0
- package/lib/core/types.d.ts +11 -0
- package/lib/date-picker/date-picker.component.d.ts +47 -0
- package/lib/date-picker/index.d.ts +1 -0
- package/lib/dialog/dialog.component.d.ts +21 -0
- package/lib/dialog/dialog.service.d.ts +10 -0
- package/lib/dialog/dialog.types.d.ts +12 -0
- package/lib/dialog/index.d.ts +5 -0
- package/lib/dropdown-menu/dropdown-menu.component.d.ts +24 -0
- package/lib/dropdown-menu/dropdown-trigger.directive.d.ts +9 -0
- package/lib/dropdown-menu/index.d.ts +3 -0
- package/lib/dropdown-menu/menu-item.component.d.ts +13 -0
- package/lib/file-upload/file-upload.component.d.ts +25 -0
- package/lib/file-upload/index.d.ts +1 -0
- package/lib/form-field/form-field.component.d.ts +10 -0
- package/lib/form-field/index.d.ts +1 -0
- package/lib/input/index.d.ts +1 -0
- package/lib/input/input.directive.d.ts +27 -0
- package/lib/locale/index.d.ts +2 -0
- package/lib/locale/locale.service.d.ts +36 -0
- package/lib/number-input/index.d.ts +1 -0
- package/lib/number-input/number-input.component.d.ts +34 -0
- package/lib/pagination/index.d.ts +1 -0
- package/lib/pagination/pagination.component.d.ts +17 -0
- package/lib/progress/index.d.ts +2 -0
- package/lib/progress/progress.component.d.ts +12 -0
- package/lib/radio/index.d.ts +2 -0
- package/lib/radio/radio-group.component.d.ts +26 -0
- package/lib/radio/radio.component.d.ts +16 -0
- package/lib/select/index.d.ts +2 -0
- package/lib/select/select.component.d.ts +28 -0
- package/lib/sidebar/index.d.ts +2 -0
- package/lib/sidebar/sidebar.component.d.ts +27 -0
- package/lib/skeleton/index.d.ts +2 -0
- package/lib/skeleton/skeleton.component.d.ts +10 -0
- package/lib/stepper/index.d.ts +2 -0
- package/lib/stepper/step.component.d.ts +11 -0
- package/lib/stepper/stepper.component.d.ts +16 -0
- package/lib/switch/index.d.ts +1 -0
- package/lib/switch/switch.component.d.ts +21 -0
- package/lib/table/index.d.ts +2 -0
- package/lib/table/table.component.d.ts +36 -0
- package/lib/table/table.types.d.ts +15 -0
- package/lib/tabs/index.d.ts +2 -0
- package/lib/tabs/tab-group.component.d.ts +16 -0
- package/lib/tabs/tab.component.d.ts +9 -0
- package/lib/textarea/index.d.ts +1 -0
- package/lib/textarea/textarea.component.d.ts +28 -0
- package/lib/toast/index.d.ts +3 -0
- package/lib/toast/toast-container.component.d.ts +7 -0
- package/lib/toast/toast.service.d.ts +18 -0
- package/lib/toast/toast.types.d.ts +23 -0
- package/lib/tooltip/index.d.ts +2 -0
- package/lib/tooltip/tooltip.directive.d.ts +22 -0
- package/lib/tree/index.d.ts +3 -0
- package/lib/tree/tree-node.component.d.ts +14 -0
- package/lib/tree/tree.component.d.ts +16 -0
- package/lib/tree/tree.types.d.ts +10 -0
- package/package.json +302 -0
- package/public-api.d.ts +32 -0
- package/styles/tokens.css +414 -0
|
@@ -0,0 +1,4298 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, Injectable, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, inject, input, computed, Component, ElementRef, forwardRef, Directive, ChangeDetectionStrategy, output, ContentChildren, ViewChild, HostListener, Renderer2, DestroyRef, ApplicationRef, EnvironmentInjector, createComponent } from '@angular/core';
|
|
3
|
+
import { NgClass, NgTemplateOutlet } from '@angular/common';
|
|
4
|
+
import * as i1$1 from '@angular/forms';
|
|
5
|
+
import { NgControl, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
6
|
+
import * as i1 from '@angular/cdk/a11y';
|
|
7
|
+
import { A11yModule } from '@angular/cdk/a11y';
|
|
8
|
+
import { Subject } from 'rxjs';
|
|
9
|
+
|
|
10
|
+
class ElgThemeService {
|
|
11
|
+
theme = signal('system');
|
|
12
|
+
density = signal('default');
|
|
13
|
+
darkModeQuery = typeof window !== 'undefined'
|
|
14
|
+
? window.matchMedia('(prefers-color-scheme: dark)')
|
|
15
|
+
: null;
|
|
16
|
+
constructor() {
|
|
17
|
+
this.darkModeQuery?.addEventListener('change', () => {
|
|
18
|
+
if (this.theme() === 'system') {
|
|
19
|
+
this.applyThemeToDocument();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
setTheme(theme) {
|
|
24
|
+
this.theme.set(theme);
|
|
25
|
+
this.applyThemeToDocument();
|
|
26
|
+
}
|
|
27
|
+
setDensity(density) {
|
|
28
|
+
this.density.set(density);
|
|
29
|
+
this.applyDensityToDocument();
|
|
30
|
+
}
|
|
31
|
+
applyThemeToDocument() {
|
|
32
|
+
if (typeof document === 'undefined')
|
|
33
|
+
return;
|
|
34
|
+
const resolvedTheme = this.resolveTheme();
|
|
35
|
+
document.documentElement.setAttribute('data-theme', resolvedTheme);
|
|
36
|
+
}
|
|
37
|
+
applyDensityToDocument() {
|
|
38
|
+
if (typeof document === 'undefined')
|
|
39
|
+
return;
|
|
40
|
+
document.documentElement.setAttribute('data-density', this.density());
|
|
41
|
+
}
|
|
42
|
+
resolveTheme() {
|
|
43
|
+
const currentTheme = this.theme();
|
|
44
|
+
if (currentTheme === 'system') {
|
|
45
|
+
return this.darkModeQuery?.matches ? 'dark' : 'light';
|
|
46
|
+
}
|
|
47
|
+
return currentTheme;
|
|
48
|
+
}
|
|
49
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
50
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgThemeService, providedIn: 'root' });
|
|
51
|
+
}
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgThemeService, decorators: [{
|
|
53
|
+
type: Injectable,
|
|
54
|
+
args: [{ providedIn: 'root' }]
|
|
55
|
+
}], ctorParameters: () => [] });
|
|
56
|
+
|
|
57
|
+
function provideElgUi(config) {
|
|
58
|
+
return makeEnvironmentProviders([
|
|
59
|
+
{
|
|
60
|
+
provide: ENVIRONMENT_INITIALIZER,
|
|
61
|
+
multi: true,
|
|
62
|
+
useValue: () => {
|
|
63
|
+
const themeService = inject(ElgThemeService);
|
|
64
|
+
if (config?.theme) {
|
|
65
|
+
themeService.setTheme(config.theme);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
themeService.setTheme('system');
|
|
69
|
+
}
|
|
70
|
+
if (config?.density) {
|
|
71
|
+
themeService.setDensity(config.density);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class ElgButtonComponent {
|
|
79
|
+
variant = input('primary');
|
|
80
|
+
size = input('md');
|
|
81
|
+
loading = input(false);
|
|
82
|
+
hostClasses = computed(() => {
|
|
83
|
+
return `elg-button elg-button--${this.variant()} elg-button--${this.size()}`;
|
|
84
|
+
});
|
|
85
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
86
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgButtonComponent, isStandalone: true, selector: "button[elg-button], a[elg-button]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClasses()", "attr.disabled": "loading() || null", "class.elg-button-loading": "loading()" } }, ngImport: i0, template: `
|
|
87
|
+
@if (loading()) {
|
|
88
|
+
<svg
|
|
89
|
+
class="elg-button-spinner"
|
|
90
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
91
|
+
fill="none"
|
|
92
|
+
viewBox="0 0 24 24"
|
|
93
|
+
aria-hidden="true"
|
|
94
|
+
>
|
|
95
|
+
<circle
|
|
96
|
+
cx="12"
|
|
97
|
+
cy="12"
|
|
98
|
+
r="10"
|
|
99
|
+
stroke="currentColor"
|
|
100
|
+
stroke-width="4"
|
|
101
|
+
opacity="0.25"
|
|
102
|
+
/>
|
|
103
|
+
<path
|
|
104
|
+
fill="currentColor"
|
|
105
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
106
|
+
opacity="0.75"
|
|
107
|
+
/>
|
|
108
|
+
</svg>
|
|
109
|
+
}
|
|
110
|
+
<ng-content />
|
|
111
|
+
`, isInline: true, styles: [":host{--elg-button-font-family: inherit;--elg-button-font-weight: 500;--elg-button-border-radius: .5rem;--elg-button-transition: all .15s ease-in-out;--elg-button-focus-ring-width: 2px;--elg-button-focus-ring-offset: 2px;--elg-button-focus-ring-color: var(--elg-color-primary, #3b82f6);display:inline-flex;align-items:center;justify-content:center;gap:.5rem;white-space:nowrap;border:1px solid transparent;border-radius:var(--elg-button-border-radius);font-family:var(--elg-button-font-family);font-weight:var(--elg-button-font-weight);cursor:pointer;text-decoration:none;transition:var(--elg-button-transition);-webkit-user-select:none;user-select:none;vertical-align:middle;line-height:1}:host(.elg-button--sm){height:2rem;padding:.375rem .75rem;font-size:.75rem;border-radius:calc(var(--elg-button-border-radius) - 2px)}:host(.elg-button--md){height:2.5rem;padding:.5rem 1rem;font-size:.875rem}:host(.elg-button--lg){height:3rem;padding:.625rem 1.5rem;font-size:1rem;border-radius:calc(var(--elg-button-border-radius) + 2px)}:host(.elg-button--primary){background-color:var(--elg-color-primary, #3b82f6);color:var(--elg-color-primary-foreground, #ffffff);border-color:var(--elg-color-primary, #3b82f6)}:host(.elg-button--primary:hover){background-color:var(--elg-color-primary-hover, #2563eb);border-color:var(--elg-color-primary-hover, #2563eb)}:host(.elg-button--primary:active){background-color:var(--elg-color-primary-active, #1d4ed8);border-color:var(--elg-color-primary-active, #1d4ed8)}:host(.elg-button--secondary){background-color:var(--elg-color-secondary, #f1f5f9);color:var(--elg-color-secondary-foreground, #0f172a);border-color:var(--elg-color-secondary, #f1f5f9)}:host(.elg-button--secondary:hover){background-color:var(--elg-color-secondary-hover, #e2e8f0);border-color:var(--elg-color-secondary-hover, #e2e8f0)}:host(.elg-button--secondary:active){background-color:var(--elg-color-secondary-active, #cbd5e1);border-color:var(--elg-color-secondary-active, #cbd5e1)}:host(.elg-button--outline){background-color:transparent;color:var(--elg-color-foreground, #0f172a);border-color:var(--elg-color-border, #e2e8f0)}:host(.elg-button--outline:hover){background-color:var(--elg-color-accent, #f8fafc);color:var(--elg-color-foreground, #0f172a);border-color:var(--elg-color-border-hover, #cbd5e1)}:host(.elg-button--outline:active){background-color:var(--elg-color-accent-active, #f1f5f9)}:host(.elg-button--ghost){background-color:transparent;color:var(--elg-color-foreground, #0f172a);border-color:transparent}:host(.elg-button--ghost:hover){background-color:var(--elg-color-accent, #f8fafc)}:host(.elg-button--ghost:active){background-color:var(--elg-color-accent-active, #f1f5f9)}:host(.elg-button--destructive){background-color:var(--elg-color-destructive, #ef4444);color:var(--elg-color-destructive-foreground, #ffffff);border-color:var(--elg-color-destructive, #ef4444)}:host(.elg-button--destructive:hover){background-color:var(--elg-color-destructive-hover, #dc2626);border-color:var(--elg-color-destructive-hover, #dc2626)}:host(.elg-button--destructive:active){background-color:var(--elg-color-destructive-active, #b91c1c);border-color:var(--elg-color-destructive-active, #b91c1c)}:host(.elg-button--link){background-color:transparent;color:var(--elg-color-primary, #3b82f6);border-color:transparent;text-decoration:underline;text-underline-offset:4px;height:auto;padding:0}:host(.elg-button--link:hover){color:var(--elg-color-primary-hover, #2563eb)}:host(.elg-button--link:active){color:var(--elg-color-primary-active, #1d4ed8)}:host(:focus-visible){outline:var(--elg-button-focus-ring-width) solid var(--elg-button-focus-ring-color);outline-offset:var(--elg-button-focus-ring-offset)}:host([disabled]){opacity:.5;cursor:not-allowed;pointer-events:none}:host(.elg-button-loading){position:relative;cursor:wait;pointer-events:none}.elg-button-spinner{width:1em;height:1em;animation:elg-button-spin .6s linear infinite;flex-shrink:0}@keyframes elg-button-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}\n"] });
|
|
112
|
+
}
|
|
113
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgButtonComponent, decorators: [{
|
|
114
|
+
type: Component,
|
|
115
|
+
args: [{ selector: 'button[elg-button], a[elg-button]', standalone: true, template: `
|
|
116
|
+
@if (loading()) {
|
|
117
|
+
<svg
|
|
118
|
+
class="elg-button-spinner"
|
|
119
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
120
|
+
fill="none"
|
|
121
|
+
viewBox="0 0 24 24"
|
|
122
|
+
aria-hidden="true"
|
|
123
|
+
>
|
|
124
|
+
<circle
|
|
125
|
+
cx="12"
|
|
126
|
+
cy="12"
|
|
127
|
+
r="10"
|
|
128
|
+
stroke="currentColor"
|
|
129
|
+
stroke-width="4"
|
|
130
|
+
opacity="0.25"
|
|
131
|
+
/>
|
|
132
|
+
<path
|
|
133
|
+
fill="currentColor"
|
|
134
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
135
|
+
opacity="0.75"
|
|
136
|
+
/>
|
|
137
|
+
</svg>
|
|
138
|
+
}
|
|
139
|
+
<ng-content />
|
|
140
|
+
`, host: {
|
|
141
|
+
'[class]': 'hostClasses()',
|
|
142
|
+
'[attr.disabled]': 'loading() || null',
|
|
143
|
+
'[class.elg-button-loading]': 'loading()',
|
|
144
|
+
}, styles: [":host{--elg-button-font-family: inherit;--elg-button-font-weight: 500;--elg-button-border-radius: .5rem;--elg-button-transition: all .15s ease-in-out;--elg-button-focus-ring-width: 2px;--elg-button-focus-ring-offset: 2px;--elg-button-focus-ring-color: var(--elg-color-primary, #3b82f6);display:inline-flex;align-items:center;justify-content:center;gap:.5rem;white-space:nowrap;border:1px solid transparent;border-radius:var(--elg-button-border-radius);font-family:var(--elg-button-font-family);font-weight:var(--elg-button-font-weight);cursor:pointer;text-decoration:none;transition:var(--elg-button-transition);-webkit-user-select:none;user-select:none;vertical-align:middle;line-height:1}:host(.elg-button--sm){height:2rem;padding:.375rem .75rem;font-size:.75rem;border-radius:calc(var(--elg-button-border-radius) - 2px)}:host(.elg-button--md){height:2.5rem;padding:.5rem 1rem;font-size:.875rem}:host(.elg-button--lg){height:3rem;padding:.625rem 1.5rem;font-size:1rem;border-radius:calc(var(--elg-button-border-radius) + 2px)}:host(.elg-button--primary){background-color:var(--elg-color-primary, #3b82f6);color:var(--elg-color-primary-foreground, #ffffff);border-color:var(--elg-color-primary, #3b82f6)}:host(.elg-button--primary:hover){background-color:var(--elg-color-primary-hover, #2563eb);border-color:var(--elg-color-primary-hover, #2563eb)}:host(.elg-button--primary:active){background-color:var(--elg-color-primary-active, #1d4ed8);border-color:var(--elg-color-primary-active, #1d4ed8)}:host(.elg-button--secondary){background-color:var(--elg-color-secondary, #f1f5f9);color:var(--elg-color-secondary-foreground, #0f172a);border-color:var(--elg-color-secondary, #f1f5f9)}:host(.elg-button--secondary:hover){background-color:var(--elg-color-secondary-hover, #e2e8f0);border-color:var(--elg-color-secondary-hover, #e2e8f0)}:host(.elg-button--secondary:active){background-color:var(--elg-color-secondary-active, #cbd5e1);border-color:var(--elg-color-secondary-active, #cbd5e1)}:host(.elg-button--outline){background-color:transparent;color:var(--elg-color-foreground, #0f172a);border-color:var(--elg-color-border, #e2e8f0)}:host(.elg-button--outline:hover){background-color:var(--elg-color-accent, #f8fafc);color:var(--elg-color-foreground, #0f172a);border-color:var(--elg-color-border-hover, #cbd5e1)}:host(.elg-button--outline:active){background-color:var(--elg-color-accent-active, #f1f5f9)}:host(.elg-button--ghost){background-color:transparent;color:var(--elg-color-foreground, #0f172a);border-color:transparent}:host(.elg-button--ghost:hover){background-color:var(--elg-color-accent, #f8fafc)}:host(.elg-button--ghost:active){background-color:var(--elg-color-accent-active, #f1f5f9)}:host(.elg-button--destructive){background-color:var(--elg-color-destructive, #ef4444);color:var(--elg-color-destructive-foreground, #ffffff);border-color:var(--elg-color-destructive, #ef4444)}:host(.elg-button--destructive:hover){background-color:var(--elg-color-destructive-hover, #dc2626);border-color:var(--elg-color-destructive-hover, #dc2626)}:host(.elg-button--destructive:active){background-color:var(--elg-color-destructive-active, #b91c1c);border-color:var(--elg-color-destructive-active, #b91c1c)}:host(.elg-button--link){background-color:transparent;color:var(--elg-color-primary, #3b82f6);border-color:transparent;text-decoration:underline;text-underline-offset:4px;height:auto;padding:0}:host(.elg-button--link:hover){color:var(--elg-color-primary-hover, #2563eb)}:host(.elg-button--link:active){color:var(--elg-color-primary-active, #1d4ed8)}:host(:focus-visible){outline:var(--elg-button-focus-ring-width) solid var(--elg-button-focus-ring-color);outline-offset:var(--elg-button-focus-ring-offset)}:host([disabled]){opacity:.5;cursor:not-allowed;pointer-events:none}:host(.elg-button-loading){position:relative;cursor:wait;pointer-events:none}.elg-button-spinner{width:1em;height:1em;animation:elg-button-spin .6s linear infinite;flex-shrink:0}@keyframes elg-button-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}\n"] }]
|
|
145
|
+
}] });
|
|
146
|
+
|
|
147
|
+
let nextId = 0;
|
|
148
|
+
class ElgFormFieldComponent {
|
|
149
|
+
label = input('');
|
|
150
|
+
hint = input('');
|
|
151
|
+
error = input('');
|
|
152
|
+
required = input(false);
|
|
153
|
+
inputId = computed(() => `elg-input-${nextId++}`);
|
|
154
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgFormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
155
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgFormFieldComponent, isStandalone: true, selector: "elg-form-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.elg-form-field--error": "!!error()" }, classAttribute: "elg-form-field" }, ngImport: i0, template: `
|
|
156
|
+
<label class="elg-form-field__label" [for]="inputId()">
|
|
157
|
+
{{ label() }}
|
|
158
|
+
@if (required()) {
|
|
159
|
+
<span class="elg-form-field__required" aria-hidden="true">*</span>
|
|
160
|
+
}
|
|
161
|
+
</label>
|
|
162
|
+
<div class="elg-form-field__input-wrapper">
|
|
163
|
+
<ng-content />
|
|
164
|
+
</div>
|
|
165
|
+
@if (error()) {
|
|
166
|
+
<small class="elg-form-field__error">{{ error() }}</small>
|
|
167
|
+
} @else if (hint()) {
|
|
168
|
+
<small class="elg-form-field__hint">{{ hint() }}</small>
|
|
169
|
+
}
|
|
170
|
+
`, isInline: true, styles: [":host{display:block;margin-bottom:var(--elg-form-field-margin-bottom, 1rem)}.elg-form-field__label{display:block;font-size:var(--elg-form-field-label-font-size, .875rem);font-weight:var(--elg-form-field-label-font-weight, 500);color:var(--elg-form-field-label-color, var(--elg-color-foreground, #1f2937));margin-bottom:var(--elg-form-field-label-margin-bottom, .375rem);line-height:1.4}.elg-form-field__required{color:var(--elg-form-field-required-color, var(--elg-color-destructive, #ef4444));margin-left:.125rem}.elg-form-field__input-wrapper{position:relative}.elg-form-field__hint{display:block;font-size:var(--elg-form-field-hint-font-size, .75rem);color:var(--elg-form-field-hint-color, var(--elg-color-muted-foreground, #6b7280));margin-top:var(--elg-form-field-hint-margin-top, .25rem);line-height:1.4}.elg-form-field__error{display:block;font-size:var(--elg-form-field-error-font-size, .75rem);color:var(--elg-form-field-error-color, var(--elg-color-destructive, #ef4444));margin-top:var(--elg-form-field-error-margin-top, .25rem);line-height:1.4}\n"] });
|
|
171
|
+
}
|
|
172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgFormFieldComponent, decorators: [{
|
|
173
|
+
type: Component,
|
|
174
|
+
args: [{ selector: 'elg-form-field', standalone: true, imports: [NgClass], template: `
|
|
175
|
+
<label class="elg-form-field__label" [for]="inputId()">
|
|
176
|
+
{{ label() }}
|
|
177
|
+
@if (required()) {
|
|
178
|
+
<span class="elg-form-field__required" aria-hidden="true">*</span>
|
|
179
|
+
}
|
|
180
|
+
</label>
|
|
181
|
+
<div class="elg-form-field__input-wrapper">
|
|
182
|
+
<ng-content />
|
|
183
|
+
</div>
|
|
184
|
+
@if (error()) {
|
|
185
|
+
<small class="elg-form-field__error">{{ error() }}</small>
|
|
186
|
+
} @else if (hint()) {
|
|
187
|
+
<small class="elg-form-field__hint">{{ hint() }}</small>
|
|
188
|
+
}
|
|
189
|
+
`, host: {
|
|
190
|
+
'class': 'elg-form-field',
|
|
191
|
+
'[class.elg-form-field--error]': '!!error()',
|
|
192
|
+
}, styles: [":host{display:block;margin-bottom:var(--elg-form-field-margin-bottom, 1rem)}.elg-form-field__label{display:block;font-size:var(--elg-form-field-label-font-size, .875rem);font-weight:var(--elg-form-field-label-font-weight, 500);color:var(--elg-form-field-label-color, var(--elg-color-foreground, #1f2937));margin-bottom:var(--elg-form-field-label-margin-bottom, .375rem);line-height:1.4}.elg-form-field__required{color:var(--elg-form-field-required-color, var(--elg-color-destructive, #ef4444));margin-left:.125rem}.elg-form-field__input-wrapper{position:relative}.elg-form-field__hint{display:block;font-size:var(--elg-form-field-hint-font-size, .75rem);color:var(--elg-form-field-hint-color, var(--elg-color-muted-foreground, #6b7280));margin-top:var(--elg-form-field-hint-margin-top, .25rem);line-height:1.4}.elg-form-field__error{display:block;font-size:var(--elg-form-field-error-font-size, .75rem);color:var(--elg-form-field-error-color, var(--elg-color-destructive, #ef4444));margin-top:var(--elg-form-field-error-margin-top, .25rem);line-height:1.4}\n"] }]
|
|
193
|
+
}] });
|
|
194
|
+
|
|
195
|
+
class ElgInputDirective {
|
|
196
|
+
elgSize = input('md');
|
|
197
|
+
el = inject((ElementRef));
|
|
198
|
+
ngControl = inject(NgControl, { optional: true, self: true });
|
|
199
|
+
focused = signal(false);
|
|
200
|
+
isDisabled = signal(false);
|
|
201
|
+
hostClasses = computed(() => {
|
|
202
|
+
return `elg-input elg-input--${this.elgSize()}`;
|
|
203
|
+
});
|
|
204
|
+
hasError = computed(() => {
|
|
205
|
+
if (this.ngControl?.control) {
|
|
206
|
+
return this.ngControl.control.invalid && this.ngControl.control.touched;
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
});
|
|
210
|
+
onChange = () => { };
|
|
211
|
+
onTouched = () => { };
|
|
212
|
+
constructor() {
|
|
213
|
+
if (this.ngControl) {
|
|
214
|
+
this.ngControl.valueAccessor = this;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
ngOnInit() { }
|
|
218
|
+
ngOnDestroy() { }
|
|
219
|
+
onFocus() {
|
|
220
|
+
this.focused.set(true);
|
|
221
|
+
}
|
|
222
|
+
onBlur() {
|
|
223
|
+
this.focused.set(false);
|
|
224
|
+
this.onTouched();
|
|
225
|
+
}
|
|
226
|
+
onInputChange(event) {
|
|
227
|
+
const target = event.target;
|
|
228
|
+
this.onChange(target.value);
|
|
229
|
+
}
|
|
230
|
+
// ControlValueAccessor implementation
|
|
231
|
+
writeValue(value) {
|
|
232
|
+
this.el.nativeElement.value = value ?? '';
|
|
233
|
+
}
|
|
234
|
+
registerOnChange(fn) {
|
|
235
|
+
this.onChange = fn;
|
|
236
|
+
}
|
|
237
|
+
registerOnTouched(fn) {
|
|
238
|
+
this.onTouched = fn;
|
|
239
|
+
}
|
|
240
|
+
setDisabledState(isDisabled) {
|
|
241
|
+
this.isDisabled.set(isDisabled);
|
|
242
|
+
this.el.nativeElement.disabled = isDisabled;
|
|
243
|
+
}
|
|
244
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgInputDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
245
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.14", type: ElgInputDirective, isStandalone: true, selector: "input[elgInput], textarea[elgInput]", inputs: { elgSize: { classPropertyName: "elgSize", publicName: "elgSize", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "focus": "onFocus()", "blur": "onBlur()", "input": "onInputChange($event)" }, properties: { "class": "hostClasses()", "class.elg-input--focused": "focused()", "class.elg-input--disabled": "isDisabled()", "class.elg-input--error": "hasError()" } }, providers: [
|
|
246
|
+
{
|
|
247
|
+
provide: NG_VALUE_ACCESSOR,
|
|
248
|
+
useExisting: forwardRef(() => ElgInputDirective),
|
|
249
|
+
multi: true,
|
|
250
|
+
},
|
|
251
|
+
], ngImport: i0 });
|
|
252
|
+
}
|
|
253
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgInputDirective, decorators: [{
|
|
254
|
+
type: Directive,
|
|
255
|
+
args: [{
|
|
256
|
+
selector: 'input[elgInput], textarea[elgInput]',
|
|
257
|
+
standalone: true,
|
|
258
|
+
providers: [
|
|
259
|
+
{
|
|
260
|
+
provide: NG_VALUE_ACCESSOR,
|
|
261
|
+
useExisting: forwardRef(() => ElgInputDirective),
|
|
262
|
+
multi: true,
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
host: {
|
|
266
|
+
'[class]': 'hostClasses()',
|
|
267
|
+
'[class.elg-input--focused]': 'focused()',
|
|
268
|
+
'[class.elg-input--disabled]': 'isDisabled()',
|
|
269
|
+
'[class.elg-input--error]': 'hasError()',
|
|
270
|
+
'(focus)': 'onFocus()',
|
|
271
|
+
'(blur)': 'onBlur()',
|
|
272
|
+
'(input)': 'onInputChange($event)',
|
|
273
|
+
},
|
|
274
|
+
}]
|
|
275
|
+
}], ctorParameters: () => [] });
|
|
276
|
+
|
|
277
|
+
class ElgSelectComponent {
|
|
278
|
+
options = input([]);
|
|
279
|
+
placeholder = input('');
|
|
280
|
+
disabled = input(false);
|
|
281
|
+
elgSize = input('md');
|
|
282
|
+
focused = signal(false);
|
|
283
|
+
isDisabled = signal(false);
|
|
284
|
+
selectedValue = signal(null);
|
|
285
|
+
hostClasses = computed(() => {
|
|
286
|
+
return `elg-select elg-select--${this.elgSize()}`;
|
|
287
|
+
});
|
|
288
|
+
onChange = () => { };
|
|
289
|
+
onTouched = () => { };
|
|
290
|
+
onSelectChange(event) {
|
|
291
|
+
const target = event.target;
|
|
292
|
+
const index = parseInt(target.value, 10);
|
|
293
|
+
const opts = this.options();
|
|
294
|
+
if (!isNaN(index) && index >= 0 && index < opts.length) {
|
|
295
|
+
const value = opts[index].value;
|
|
296
|
+
this.selectedValue.set(value);
|
|
297
|
+
this.onChange(value);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
onFocus() {
|
|
301
|
+
this.focused.set(true);
|
|
302
|
+
}
|
|
303
|
+
onBlur() {
|
|
304
|
+
this.focused.set(false);
|
|
305
|
+
this.onTouched();
|
|
306
|
+
}
|
|
307
|
+
// ControlValueAccessor
|
|
308
|
+
writeValue(value) {
|
|
309
|
+
this.selectedValue.set(value);
|
|
310
|
+
}
|
|
311
|
+
registerOnChange(fn) {
|
|
312
|
+
this.onChange = fn;
|
|
313
|
+
}
|
|
314
|
+
registerOnTouched(fn) {
|
|
315
|
+
this.onTouched = fn;
|
|
316
|
+
}
|
|
317
|
+
setDisabledState(isDisabled) {
|
|
318
|
+
this.isDisabled.set(isDisabled);
|
|
319
|
+
}
|
|
320
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
321
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgSelectComponent, isStandalone: true, selector: "elg-select", inputs: { options: { classPropertyName: "options", publicName: "options", 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 }, elgSize: { classPropertyName: "elgSize", publicName: "elgSize", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClasses()", "class.elg-select--focused": "focused()", "class.elg-select--disabled": "isDisabled()" } }, providers: [
|
|
322
|
+
{
|
|
323
|
+
provide: NG_VALUE_ACCESSOR,
|
|
324
|
+
useExisting: forwardRef(() => ElgSelectComponent),
|
|
325
|
+
multi: true,
|
|
326
|
+
},
|
|
327
|
+
], ngImport: i0, template: `
|
|
328
|
+
<select
|
|
329
|
+
class="elg-select__native"
|
|
330
|
+
[disabled]="isDisabled()"
|
|
331
|
+
(change)="onSelectChange($event)"
|
|
332
|
+
(focus)="onFocus()"
|
|
333
|
+
(blur)="onBlur()"
|
|
334
|
+
>
|
|
335
|
+
@if (placeholder()) {
|
|
336
|
+
<option value="" disabled [selected]="selectedValue() === null">
|
|
337
|
+
{{ placeholder() }}
|
|
338
|
+
</option>
|
|
339
|
+
}
|
|
340
|
+
@for (option of options(); track option.value) {
|
|
341
|
+
<option [value]="$index" [selected]="option.value === selectedValue()">
|
|
342
|
+
{{ option.label }}
|
|
343
|
+
</option>
|
|
344
|
+
}
|
|
345
|
+
</select>
|
|
346
|
+
<span class="elg-select__arrow">
|
|
347
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
348
|
+
<path d="M2.5 4.5L6 8L9.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
349
|
+
</svg>
|
|
350
|
+
</span>
|
|
351
|
+
`, isInline: true, styles: [":host{display:block;position:relative;width:100%}.elg-select__native{display:block;width:100%;box-sizing:border-box;height:var(--elg-select-height, var(--elg-input-height, 2.5rem));padding-left:var(--elg-select-padding-x, var(--elg-input-padding-x, .75rem));padding-right:var(--elg-select-padding-right, 2.25rem);border:1px solid var(--elg-select-border-color, var(--elg-input-border-color, var(--elg-color-border, #d1d5db)));border-radius:var(--elg-select-border-radius, var(--elg-input-border-radius, var(--elg-radius-md, .375rem)));font-size:var(--elg-select-font-size, var(--elg-input-font-size, .875rem));font-family:inherit;color:var(--elg-select-color, var(--elg-input-color, var(--elg-color-foreground, #1f2937)));background-color:var(--elg-select-bg, var(--elg-input-bg, var(--elg-color-background, #ffffff)));outline:none;appearance:none;-webkit-appearance:none;-moz-appearance:none;cursor:pointer;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.elg-select__native:focus{border-color:var(--elg-select-focus-border-color, var(--elg-input-focus-border-color, var(--elg-color-primary, #3b82f6)));box-shadow:0 0 0 var(--elg-select-focus-ring-width, var(--elg-input-focus-ring-width, 3px)) var(--elg-select-focus-ring-color, var(--elg-input-focus-ring-color, rgba(59, 130, 246, .15)))}:host(.elg-select--focused) .elg-select__native{border-color:var(--elg-select-focus-border-color, var(--elg-input-focus-border-color, var(--elg-color-primary, #3b82f6)));box-shadow:0 0 0 var(--elg-select-focus-ring-width, var(--elg-input-focus-ring-width, 3px)) var(--elg-select-focus-ring-color, var(--elg-input-focus-ring-color, rgba(59, 130, 246, .15)))}:host(.elg-select--disabled) .elg-select__native,.elg-select__native:disabled{background-color:var(--elg-select-disabled-bg, var(--elg-input-disabled-bg, var(--elg-color-muted, #f3f4f6)));color:var(--elg-select-disabled-color, var(--elg-input-disabled-color, var(--elg-color-muted-foreground, #9ca3af)));cursor:not-allowed;opacity:var(--elg-select-disabled-opacity, var(--elg-input-disabled-opacity, .7))}.elg-select__arrow{position:absolute;right:var(--elg-select-arrow-right, .75rem);top:50%;transform:translateY(-50%);pointer-events:none;color:var(--elg-select-arrow-color, var(--elg-color-muted-foreground, #9ca3af));display:flex;align-items:center}:host(.elg-select--sm) .elg-select__native{height:var(--elg-select-height-sm, var(--elg-input-height-sm, 2rem));font-size:var(--elg-select-font-size-sm, var(--elg-input-font-size-sm, .75rem));padding-left:var(--elg-select-padding-x-sm, var(--elg-input-padding-x-sm, .5rem));padding-right:var(--elg-select-padding-right-sm, 1.75rem)}:host(.elg-select--sm) .elg-select__arrow{right:.5rem}:host(.elg-select--lg) .elg-select__native{height:var(--elg-select-height-lg, var(--elg-input-height-lg, 3rem));font-size:var(--elg-select-font-size-lg, var(--elg-input-font-size-lg, 1rem));padding-left:var(--elg-select-padding-x-lg, var(--elg-input-padding-x-lg, 1rem));padding-right:var(--elg-select-padding-right-lg, 2.5rem)}:host(.elg-select--lg) .elg-select__arrow{right:1rem}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
352
|
+
}
|
|
353
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgSelectComponent, decorators: [{
|
|
354
|
+
type: Component,
|
|
355
|
+
args: [{ selector: 'elg-select', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
356
|
+
{
|
|
357
|
+
provide: NG_VALUE_ACCESSOR,
|
|
358
|
+
useExisting: forwardRef(() => ElgSelectComponent),
|
|
359
|
+
multi: true,
|
|
360
|
+
},
|
|
361
|
+
], host: {
|
|
362
|
+
'[class]': 'hostClasses()',
|
|
363
|
+
'[class.elg-select--focused]': 'focused()',
|
|
364
|
+
'[class.elg-select--disabled]': 'isDisabled()',
|
|
365
|
+
}, template: `
|
|
366
|
+
<select
|
|
367
|
+
class="elg-select__native"
|
|
368
|
+
[disabled]="isDisabled()"
|
|
369
|
+
(change)="onSelectChange($event)"
|
|
370
|
+
(focus)="onFocus()"
|
|
371
|
+
(blur)="onBlur()"
|
|
372
|
+
>
|
|
373
|
+
@if (placeholder()) {
|
|
374
|
+
<option value="" disabled [selected]="selectedValue() === null">
|
|
375
|
+
{{ placeholder() }}
|
|
376
|
+
</option>
|
|
377
|
+
}
|
|
378
|
+
@for (option of options(); track option.value) {
|
|
379
|
+
<option [value]="$index" [selected]="option.value === selectedValue()">
|
|
380
|
+
{{ option.label }}
|
|
381
|
+
</option>
|
|
382
|
+
}
|
|
383
|
+
</select>
|
|
384
|
+
<span class="elg-select__arrow">
|
|
385
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
386
|
+
<path d="M2.5 4.5L6 8L9.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
387
|
+
</svg>
|
|
388
|
+
</span>
|
|
389
|
+
`, styles: [":host{display:block;position:relative;width:100%}.elg-select__native{display:block;width:100%;box-sizing:border-box;height:var(--elg-select-height, var(--elg-input-height, 2.5rem));padding-left:var(--elg-select-padding-x, var(--elg-input-padding-x, .75rem));padding-right:var(--elg-select-padding-right, 2.25rem);border:1px solid var(--elg-select-border-color, var(--elg-input-border-color, var(--elg-color-border, #d1d5db)));border-radius:var(--elg-select-border-radius, var(--elg-input-border-radius, var(--elg-radius-md, .375rem)));font-size:var(--elg-select-font-size, var(--elg-input-font-size, .875rem));font-family:inherit;color:var(--elg-select-color, var(--elg-input-color, var(--elg-color-foreground, #1f2937)));background-color:var(--elg-select-bg, var(--elg-input-bg, var(--elg-color-background, #ffffff)));outline:none;appearance:none;-webkit-appearance:none;-moz-appearance:none;cursor:pointer;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.elg-select__native:focus{border-color:var(--elg-select-focus-border-color, var(--elg-input-focus-border-color, var(--elg-color-primary, #3b82f6)));box-shadow:0 0 0 var(--elg-select-focus-ring-width, var(--elg-input-focus-ring-width, 3px)) var(--elg-select-focus-ring-color, var(--elg-input-focus-ring-color, rgba(59, 130, 246, .15)))}:host(.elg-select--focused) .elg-select__native{border-color:var(--elg-select-focus-border-color, var(--elg-input-focus-border-color, var(--elg-color-primary, #3b82f6)));box-shadow:0 0 0 var(--elg-select-focus-ring-width, var(--elg-input-focus-ring-width, 3px)) var(--elg-select-focus-ring-color, var(--elg-input-focus-ring-color, rgba(59, 130, 246, .15)))}:host(.elg-select--disabled) .elg-select__native,.elg-select__native:disabled{background-color:var(--elg-select-disabled-bg, var(--elg-input-disabled-bg, var(--elg-color-muted, #f3f4f6)));color:var(--elg-select-disabled-color, var(--elg-input-disabled-color, var(--elg-color-muted-foreground, #9ca3af)));cursor:not-allowed;opacity:var(--elg-select-disabled-opacity, var(--elg-input-disabled-opacity, .7))}.elg-select__arrow{position:absolute;right:var(--elg-select-arrow-right, .75rem);top:50%;transform:translateY(-50%);pointer-events:none;color:var(--elg-select-arrow-color, var(--elg-color-muted-foreground, #9ca3af));display:flex;align-items:center}:host(.elg-select--sm) .elg-select__native{height:var(--elg-select-height-sm, var(--elg-input-height-sm, 2rem));font-size:var(--elg-select-font-size-sm, var(--elg-input-font-size-sm, .75rem));padding-left:var(--elg-select-padding-x-sm, var(--elg-input-padding-x-sm, .5rem));padding-right:var(--elg-select-padding-right-sm, 1.75rem)}:host(.elg-select--sm) .elg-select__arrow{right:.5rem}:host(.elg-select--lg) .elg-select__native{height:var(--elg-select-height-lg, var(--elg-input-height-lg, 3rem));font-size:var(--elg-select-font-size-lg, var(--elg-input-font-size-lg, 1rem));padding-left:var(--elg-select-padding-x-lg, var(--elg-input-padding-x-lg, 1rem));padding-right:var(--elg-select-padding-right-lg, 2.5rem)}:host(.elg-select--lg) .elg-select__arrow{right:1rem}\n"] }]
|
|
390
|
+
}] });
|
|
391
|
+
|
|
392
|
+
class ElgCheckboxComponent {
|
|
393
|
+
checked = input(false);
|
|
394
|
+
indeterminate = input(false);
|
|
395
|
+
disabled = input(false);
|
|
396
|
+
label = input('');
|
|
397
|
+
checkedChange = output();
|
|
398
|
+
isChecked = signal(false);
|
|
399
|
+
isIndeterminate = signal(false);
|
|
400
|
+
isDisabled = signal(false);
|
|
401
|
+
onChange = () => { };
|
|
402
|
+
onTouched = () => { };
|
|
403
|
+
constructor() {
|
|
404
|
+
// Sync inputs to signals via effect-like pattern
|
|
405
|
+
}
|
|
406
|
+
ngOnChanges() {
|
|
407
|
+
this.isChecked.set(this.checked());
|
|
408
|
+
this.isIndeterminate.set(this.indeterminate());
|
|
409
|
+
this.isDisabled.set(this.disabled());
|
|
410
|
+
}
|
|
411
|
+
onCheckboxChange(event) {
|
|
412
|
+
const target = event.target;
|
|
413
|
+
const value = target.checked;
|
|
414
|
+
this.isChecked.set(value);
|
|
415
|
+
this.isIndeterminate.set(false);
|
|
416
|
+
this.onChange(value);
|
|
417
|
+
this.checkedChange.emit(value);
|
|
418
|
+
}
|
|
419
|
+
onBlur() {
|
|
420
|
+
this.onTouched();
|
|
421
|
+
}
|
|
422
|
+
// ControlValueAccessor
|
|
423
|
+
writeValue(value) {
|
|
424
|
+
this.isChecked.set(!!value);
|
|
425
|
+
}
|
|
426
|
+
registerOnChange(fn) {
|
|
427
|
+
this.onChange = fn;
|
|
428
|
+
}
|
|
429
|
+
registerOnTouched(fn) {
|
|
430
|
+
this.onTouched = fn;
|
|
431
|
+
}
|
|
432
|
+
setDisabledState(isDisabled) {
|
|
433
|
+
this.isDisabled.set(isDisabled);
|
|
434
|
+
}
|
|
435
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgCheckboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
436
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgCheckboxComponent, isStandalone: true, selector: "elg-checkbox", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checkedChange: "checkedChange" }, host: { properties: { "class": "\"elg-checkbox\"", "class.elg-checkbox--checked": "isChecked()", "class.elg-checkbox--indeterminate": "isIndeterminate()", "class.elg-checkbox--disabled": "isDisabled()" } }, providers: [
|
|
437
|
+
{
|
|
438
|
+
provide: NG_VALUE_ACCESSOR,
|
|
439
|
+
useExisting: forwardRef(() => ElgCheckboxComponent),
|
|
440
|
+
multi: true,
|
|
441
|
+
},
|
|
442
|
+
], usesOnChanges: true, ngImport: i0, template: `
|
|
443
|
+
<label class="elg-checkbox__label">
|
|
444
|
+
<input
|
|
445
|
+
type="checkbox"
|
|
446
|
+
class="elg-checkbox__native"
|
|
447
|
+
[checked]="isChecked()"
|
|
448
|
+
[disabled]="isDisabled()"
|
|
449
|
+
[indeterminate]="isIndeterminate()"
|
|
450
|
+
(change)="onCheckboxChange($event)"
|
|
451
|
+
(blur)="onBlur()"
|
|
452
|
+
/>
|
|
453
|
+
<span class="elg-checkbox__box">
|
|
454
|
+
@if (isChecked() && !isIndeterminate()) {
|
|
455
|
+
<svg class="elg-checkbox__icon" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
456
|
+
<path d="M2.5 6L5 8.5L9.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
457
|
+
</svg>
|
|
458
|
+
}
|
|
459
|
+
@if (isIndeterminate()) {
|
|
460
|
+
<svg class="elg-checkbox__icon" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
461
|
+
<path d="M2.5 6H9.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
462
|
+
</svg>
|
|
463
|
+
}
|
|
464
|
+
</span>
|
|
465
|
+
@if (label()) {
|
|
466
|
+
<span class="elg-checkbox__text">{{ label() }}</span>
|
|
467
|
+
}
|
|
468
|
+
</label>
|
|
469
|
+
`, isInline: true, styles: [":host{display:inline-block}.elg-checkbox__label{display:inline-flex;align-items:center;gap:var(--elg-checkbox-gap, .5rem);cursor:pointer;-webkit-user-select:none;user-select:none}.elg-checkbox__native{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.elg-checkbox__box{display:inline-flex;align-items:center;justify-content:center;width:var(--elg-checkbox-size, 1.125rem);height:var(--elg-checkbox-size, 1.125rem);border:2px solid var(--elg-checkbox-border-color, var(--elg-color-border, #d1d5db));border-radius:var(--elg-checkbox-border-radius, var(--elg-radius-sm, .25rem));background-color:var(--elg-checkbox-bg, var(--elg-color-background, #ffffff));transition:background-color .15s ease-in-out,border-color .15s ease-in-out;flex-shrink:0}.elg-checkbox__icon{width:var(--elg-checkbox-icon-size, .75rem);height:var(--elg-checkbox-icon-size, .75rem);color:var(--elg-checkbox-check-color, #ffffff)}.elg-checkbox__text{font-size:var(--elg-checkbox-font-size, .875rem);color:var(--elg-checkbox-label-color, var(--elg-color-foreground, #1f2937));line-height:1.4}:host(.elg-checkbox--checked) .elg-checkbox__box,:host(.elg-checkbox--indeterminate) .elg-checkbox__box{background-color:var(--elg-checkbox-checked-bg, var(--elg-color-primary, #3b82f6));border-color:var(--elg-checkbox-checked-border-color, var(--elg-color-primary, #3b82f6))}.elg-checkbox__native:focus-visible+.elg-checkbox__box{box-shadow:0 0 0 var(--elg-checkbox-focus-ring-width, 3px) var(--elg-checkbox-focus-ring-color, rgba(59, 130, 246, .15));border-color:var(--elg-checkbox-focus-border-color, var(--elg-color-primary, #3b82f6))}:host(.elg-checkbox--disabled) .elg-checkbox__label{cursor:not-allowed;opacity:var(--elg-checkbox-disabled-opacity, .5)}:host(.elg-checkbox--disabled) .elg-checkbox__box{background-color:var(--elg-checkbox-disabled-bg, var(--elg-color-muted, #f3f4f6))}:host(:not(.elg-checkbox--disabled)) .elg-checkbox__label:hover .elg-checkbox__box{border-color:var(--elg-checkbox-hover-border-color, var(--elg-color-primary, #3b82f6))}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
470
|
+
}
|
|
471
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgCheckboxComponent, decorators: [{
|
|
472
|
+
type: Component,
|
|
473
|
+
args: [{ selector: 'elg-checkbox', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
474
|
+
{
|
|
475
|
+
provide: NG_VALUE_ACCESSOR,
|
|
476
|
+
useExisting: forwardRef(() => ElgCheckboxComponent),
|
|
477
|
+
multi: true,
|
|
478
|
+
},
|
|
479
|
+
], host: {
|
|
480
|
+
'[class]': '"elg-checkbox"',
|
|
481
|
+
'[class.elg-checkbox--checked]': 'isChecked()',
|
|
482
|
+
'[class.elg-checkbox--indeterminate]': 'isIndeterminate()',
|
|
483
|
+
'[class.elg-checkbox--disabled]': 'isDisabled()',
|
|
484
|
+
}, template: `
|
|
485
|
+
<label class="elg-checkbox__label">
|
|
486
|
+
<input
|
|
487
|
+
type="checkbox"
|
|
488
|
+
class="elg-checkbox__native"
|
|
489
|
+
[checked]="isChecked()"
|
|
490
|
+
[disabled]="isDisabled()"
|
|
491
|
+
[indeterminate]="isIndeterminate()"
|
|
492
|
+
(change)="onCheckboxChange($event)"
|
|
493
|
+
(blur)="onBlur()"
|
|
494
|
+
/>
|
|
495
|
+
<span class="elg-checkbox__box">
|
|
496
|
+
@if (isChecked() && !isIndeterminate()) {
|
|
497
|
+
<svg class="elg-checkbox__icon" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
498
|
+
<path d="M2.5 6L5 8.5L9.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
499
|
+
</svg>
|
|
500
|
+
}
|
|
501
|
+
@if (isIndeterminate()) {
|
|
502
|
+
<svg class="elg-checkbox__icon" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
503
|
+
<path d="M2.5 6H9.5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
504
|
+
</svg>
|
|
505
|
+
}
|
|
506
|
+
</span>
|
|
507
|
+
@if (label()) {
|
|
508
|
+
<span class="elg-checkbox__text">{{ label() }}</span>
|
|
509
|
+
}
|
|
510
|
+
</label>
|
|
511
|
+
`, styles: [":host{display:inline-block}.elg-checkbox__label{display:inline-flex;align-items:center;gap:var(--elg-checkbox-gap, .5rem);cursor:pointer;-webkit-user-select:none;user-select:none}.elg-checkbox__native{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.elg-checkbox__box{display:inline-flex;align-items:center;justify-content:center;width:var(--elg-checkbox-size, 1.125rem);height:var(--elg-checkbox-size, 1.125rem);border:2px solid var(--elg-checkbox-border-color, var(--elg-color-border, #d1d5db));border-radius:var(--elg-checkbox-border-radius, var(--elg-radius-sm, .25rem));background-color:var(--elg-checkbox-bg, var(--elg-color-background, #ffffff));transition:background-color .15s ease-in-out,border-color .15s ease-in-out;flex-shrink:0}.elg-checkbox__icon{width:var(--elg-checkbox-icon-size, .75rem);height:var(--elg-checkbox-icon-size, .75rem);color:var(--elg-checkbox-check-color, #ffffff)}.elg-checkbox__text{font-size:var(--elg-checkbox-font-size, .875rem);color:var(--elg-checkbox-label-color, var(--elg-color-foreground, #1f2937));line-height:1.4}:host(.elg-checkbox--checked) .elg-checkbox__box,:host(.elg-checkbox--indeterminate) .elg-checkbox__box{background-color:var(--elg-checkbox-checked-bg, var(--elg-color-primary, #3b82f6));border-color:var(--elg-checkbox-checked-border-color, var(--elg-color-primary, #3b82f6))}.elg-checkbox__native:focus-visible+.elg-checkbox__box{box-shadow:0 0 0 var(--elg-checkbox-focus-ring-width, 3px) var(--elg-checkbox-focus-ring-color, rgba(59, 130, 246, .15));border-color:var(--elg-checkbox-focus-border-color, var(--elg-color-primary, #3b82f6))}:host(.elg-checkbox--disabled) .elg-checkbox__label{cursor:not-allowed;opacity:var(--elg-checkbox-disabled-opacity, .5)}:host(.elg-checkbox--disabled) .elg-checkbox__box{background-color:var(--elg-checkbox-disabled-bg, var(--elg-color-muted, #f3f4f6))}:host(:not(.elg-checkbox--disabled)) .elg-checkbox__label:hover .elg-checkbox__box{border-color:var(--elg-checkbox-hover-border-color, var(--elg-color-primary, #3b82f6))}\n"] }]
|
|
512
|
+
}], ctorParameters: () => [] });
|
|
513
|
+
|
|
514
|
+
class ElgRadioComponent {
|
|
515
|
+
value = input(null);
|
|
516
|
+
disabled = input(false);
|
|
517
|
+
label = input('');
|
|
518
|
+
groupName = signal('');
|
|
519
|
+
isSelected = signal(false);
|
|
520
|
+
isDisabled = signal(false);
|
|
521
|
+
group = inject(ElgRadioGroupComponent, { optional: true });
|
|
522
|
+
/** Called by the parent group to sync state */
|
|
523
|
+
_setGroupState(name, selectedValue, groupDisabled) {
|
|
524
|
+
this.groupName.set(name);
|
|
525
|
+
this.isSelected.set(this.value() === selectedValue);
|
|
526
|
+
this.isDisabled.set(this.disabled() || groupDisabled);
|
|
527
|
+
}
|
|
528
|
+
onRadioChange() {
|
|
529
|
+
if (this.group) {
|
|
530
|
+
this.group.selectValue(this.value());
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
onBlur() {
|
|
534
|
+
if (this.group) {
|
|
535
|
+
this.group.markTouched();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgRadioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
539
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgRadioComponent, isStandalone: true, selector: "elg-radio", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "\"elg-radio\"", "class.elg-radio--checked": "isSelected()", "class.elg-radio--disabled": "isDisabled()" } }, ngImport: i0, template: `
|
|
540
|
+
<label class="elg-radio__label">
|
|
541
|
+
<input
|
|
542
|
+
type="radio"
|
|
543
|
+
class="elg-radio__native"
|
|
544
|
+
[name]="groupName()"
|
|
545
|
+
[value]="value()"
|
|
546
|
+
[checked]="isSelected()"
|
|
547
|
+
[disabled]="isDisabled()"
|
|
548
|
+
(change)="onRadioChange()"
|
|
549
|
+
(blur)="onBlur()"
|
|
550
|
+
/>
|
|
551
|
+
<span class="elg-radio__circle">
|
|
552
|
+
<span class="elg-radio__dot"></span>
|
|
553
|
+
</span>
|
|
554
|
+
@if (label()) {
|
|
555
|
+
<span class="elg-radio__text">{{ label() }}</span>
|
|
556
|
+
}
|
|
557
|
+
</label>
|
|
558
|
+
`, isInline: true, styles: [":host{display:block}.elg-radio__label{display:inline-flex;align-items:center;gap:var(--elg-radio-gap, .5rem);cursor:pointer;-webkit-user-select:none;user-select:none}.elg-radio__native{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.elg-radio__circle{display:inline-flex;align-items:center;justify-content:center;width:var(--elg-radio-size, 1.125rem);height:var(--elg-radio-size, 1.125rem);border:2px solid var(--elg-radio-border-color, var(--elg-color-border, #d1d5db));border-radius:50%;background-color:var(--elg-radio-bg, var(--elg-color-background, #ffffff));transition:border-color .15s ease-in-out,background-color .15s ease-in-out;flex-shrink:0}.elg-radio__dot{width:var(--elg-radio-dot-size, .5rem);height:var(--elg-radio-dot-size, .5rem);border-radius:50%;background-color:transparent;transition:background-color .15s ease-in-out,transform .15s ease-in-out;transform:scale(0)}.elg-radio__text{font-size:var(--elg-radio-font-size, .875rem);color:var(--elg-radio-label-color, var(--elg-color-foreground, #1f2937));line-height:1.4}:host(.elg-radio--checked) .elg-radio__circle{border-color:var(--elg-radio-checked-border-color, var(--elg-color-primary, #3b82f6))}:host(.elg-radio--checked) .elg-radio__dot{background-color:var(--elg-radio-checked-color, var(--elg-color-primary, #3b82f6));transform:scale(1)}.elg-radio__native:focus-visible+.elg-radio__circle{box-shadow:0 0 0 var(--elg-radio-focus-ring-width, 3px) var(--elg-radio-focus-ring-color, rgba(59, 130, 246, .15));border-color:var(--elg-radio-focus-border-color, var(--elg-color-primary, #3b82f6))}:host(.elg-radio--disabled) .elg-radio__label{cursor:not-allowed;opacity:var(--elg-radio-disabled-opacity, .5)}:host(.elg-radio--disabled) .elg-radio__circle{background-color:var(--elg-radio-disabled-bg, var(--elg-color-muted, #f3f4f6))}:host(:not(.elg-radio--disabled)) .elg-radio__label:hover .elg-radio__circle{border-color:var(--elg-radio-hover-border-color, var(--elg-color-primary, #3b82f6))}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
559
|
+
}
|
|
560
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgRadioComponent, decorators: [{
|
|
561
|
+
type: Component,
|
|
562
|
+
args: [{ selector: 'elg-radio', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
563
|
+
'[class]': '"elg-radio"',
|
|
564
|
+
'[class.elg-radio--checked]': 'isSelected()',
|
|
565
|
+
'[class.elg-radio--disabled]': 'isDisabled()',
|
|
566
|
+
}, template: `
|
|
567
|
+
<label class="elg-radio__label">
|
|
568
|
+
<input
|
|
569
|
+
type="radio"
|
|
570
|
+
class="elg-radio__native"
|
|
571
|
+
[name]="groupName()"
|
|
572
|
+
[value]="value()"
|
|
573
|
+
[checked]="isSelected()"
|
|
574
|
+
[disabled]="isDisabled()"
|
|
575
|
+
(change)="onRadioChange()"
|
|
576
|
+
(blur)="onBlur()"
|
|
577
|
+
/>
|
|
578
|
+
<span class="elg-radio__circle">
|
|
579
|
+
<span class="elg-radio__dot"></span>
|
|
580
|
+
</span>
|
|
581
|
+
@if (label()) {
|
|
582
|
+
<span class="elg-radio__text">{{ label() }}</span>
|
|
583
|
+
}
|
|
584
|
+
</label>
|
|
585
|
+
`, styles: [":host{display:block}.elg-radio__label{display:inline-flex;align-items:center;gap:var(--elg-radio-gap, .5rem);cursor:pointer;-webkit-user-select:none;user-select:none}.elg-radio__native{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.elg-radio__circle{display:inline-flex;align-items:center;justify-content:center;width:var(--elg-radio-size, 1.125rem);height:var(--elg-radio-size, 1.125rem);border:2px solid var(--elg-radio-border-color, var(--elg-color-border, #d1d5db));border-radius:50%;background-color:var(--elg-radio-bg, var(--elg-color-background, #ffffff));transition:border-color .15s ease-in-out,background-color .15s ease-in-out;flex-shrink:0}.elg-radio__dot{width:var(--elg-radio-dot-size, .5rem);height:var(--elg-radio-dot-size, .5rem);border-radius:50%;background-color:transparent;transition:background-color .15s ease-in-out,transform .15s ease-in-out;transform:scale(0)}.elg-radio__text{font-size:var(--elg-radio-font-size, .875rem);color:var(--elg-radio-label-color, var(--elg-color-foreground, #1f2937));line-height:1.4}:host(.elg-radio--checked) .elg-radio__circle{border-color:var(--elg-radio-checked-border-color, var(--elg-color-primary, #3b82f6))}:host(.elg-radio--checked) .elg-radio__dot{background-color:var(--elg-radio-checked-color, var(--elg-color-primary, #3b82f6));transform:scale(1)}.elg-radio__native:focus-visible+.elg-radio__circle{box-shadow:0 0 0 var(--elg-radio-focus-ring-width, 3px) var(--elg-radio-focus-ring-color, rgba(59, 130, 246, .15));border-color:var(--elg-radio-focus-border-color, var(--elg-color-primary, #3b82f6))}:host(.elg-radio--disabled) .elg-radio__label{cursor:not-allowed;opacity:var(--elg-radio-disabled-opacity, .5)}:host(.elg-radio--disabled) .elg-radio__circle{background-color:var(--elg-radio-disabled-bg, var(--elg-color-muted, #f3f4f6))}:host(:not(.elg-radio--disabled)) .elg-radio__label:hover .elg-radio__circle{border-color:var(--elg-radio-hover-border-color, var(--elg-color-primary, #3b82f6))}\n"] }]
|
|
586
|
+
}] });
|
|
587
|
+
|
|
588
|
+
class ElgRadioGroupComponent {
|
|
589
|
+
name = input('');
|
|
590
|
+
value = input(null);
|
|
591
|
+
disabled = input(false);
|
|
592
|
+
valueChange = output();
|
|
593
|
+
radios;
|
|
594
|
+
selectedValue = signal(null);
|
|
595
|
+
isDisabled = signal(false);
|
|
596
|
+
onChange = () => { };
|
|
597
|
+
onTouched = () => { };
|
|
598
|
+
ngAfterContentInit() {
|
|
599
|
+
this.updateRadios();
|
|
600
|
+
this.radios.changes.subscribe(() => this.updateRadios());
|
|
601
|
+
}
|
|
602
|
+
ngOnChanges() {
|
|
603
|
+
this.selectedValue.set(this.value());
|
|
604
|
+
this.isDisabled.set(this.disabled());
|
|
605
|
+
if (this.radios) {
|
|
606
|
+
this.updateRadios();
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
selectValue(value) {
|
|
610
|
+
this.selectedValue.set(value);
|
|
611
|
+
this.onChange(value);
|
|
612
|
+
this.valueChange.emit(value);
|
|
613
|
+
this.updateRadios();
|
|
614
|
+
}
|
|
615
|
+
markTouched() {
|
|
616
|
+
this.onTouched();
|
|
617
|
+
}
|
|
618
|
+
updateRadios() {
|
|
619
|
+
if (!this.radios)
|
|
620
|
+
return;
|
|
621
|
+
this.radios.forEach((radio) => {
|
|
622
|
+
radio._setGroupState(this.name(), this.selectedValue(), this.isDisabled());
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
// ControlValueAccessor
|
|
626
|
+
writeValue(value) {
|
|
627
|
+
this.selectedValue.set(value);
|
|
628
|
+
if (this.radios) {
|
|
629
|
+
this.updateRadios();
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
registerOnChange(fn) {
|
|
633
|
+
this.onChange = fn;
|
|
634
|
+
}
|
|
635
|
+
registerOnTouched(fn) {
|
|
636
|
+
this.onTouched = fn;
|
|
637
|
+
}
|
|
638
|
+
setDisabledState(isDisabled) {
|
|
639
|
+
this.isDisabled.set(isDisabled);
|
|
640
|
+
if (this.radios) {
|
|
641
|
+
this.updateRadios();
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgRadioGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
645
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgRadioGroupComponent, isStandalone: true, selector: "elg-radio-group", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { properties: { "class": "\"elg-radio-group\"", "attr.role": "\"radiogroup\"" } }, providers: [
|
|
646
|
+
{
|
|
647
|
+
provide: NG_VALUE_ACCESSOR,
|
|
648
|
+
useExisting: forwardRef(() => ElgRadioGroupComponent),
|
|
649
|
+
multi: true,
|
|
650
|
+
},
|
|
651
|
+
], queries: [{ propertyName: "radios", predicate: ElgRadioComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [":host{display:flex;flex-direction:column;gap:var(--elg-radio-group-gap, .5rem)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
652
|
+
}
|
|
653
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgRadioGroupComponent, decorators: [{
|
|
654
|
+
type: Component,
|
|
655
|
+
args: [{ selector: 'elg-radio-group', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
656
|
+
{
|
|
657
|
+
provide: NG_VALUE_ACCESSOR,
|
|
658
|
+
useExisting: forwardRef(() => ElgRadioGroupComponent),
|
|
659
|
+
multi: true,
|
|
660
|
+
},
|
|
661
|
+
], host: {
|
|
662
|
+
'[class]': '"elg-radio-group"',
|
|
663
|
+
'[attr.role]': '"radiogroup"',
|
|
664
|
+
}, template: `<ng-content></ng-content>`, styles: [":host{display:flex;flex-direction:column;gap:var(--elg-radio-group-gap, .5rem)}\n"] }]
|
|
665
|
+
}], propDecorators: { radios: [{
|
|
666
|
+
type: ContentChildren,
|
|
667
|
+
args: [ElgRadioComponent, { descendants: true }]
|
|
668
|
+
}] } });
|
|
669
|
+
|
|
670
|
+
class ElgSwitchComponent {
|
|
671
|
+
checked = input(false);
|
|
672
|
+
disabled = input(false);
|
|
673
|
+
label = input('');
|
|
674
|
+
checkedChange = output();
|
|
675
|
+
isChecked = signal(false);
|
|
676
|
+
isDisabled = signal(false);
|
|
677
|
+
onChange = () => { };
|
|
678
|
+
onTouched = () => { };
|
|
679
|
+
ngOnChanges() {
|
|
680
|
+
this.isChecked.set(this.checked());
|
|
681
|
+
this.isDisabled.set(this.disabled());
|
|
682
|
+
}
|
|
683
|
+
toggle() {
|
|
684
|
+
if (this.isDisabled())
|
|
685
|
+
return;
|
|
686
|
+
const newValue = !this.isChecked();
|
|
687
|
+
this.isChecked.set(newValue);
|
|
688
|
+
this.onChange(newValue);
|
|
689
|
+
this.checkedChange.emit(newValue);
|
|
690
|
+
}
|
|
691
|
+
onBlur() {
|
|
692
|
+
this.onTouched();
|
|
693
|
+
}
|
|
694
|
+
// ControlValueAccessor
|
|
695
|
+
writeValue(value) {
|
|
696
|
+
this.isChecked.set(!!value);
|
|
697
|
+
}
|
|
698
|
+
registerOnChange(fn) {
|
|
699
|
+
this.onChange = fn;
|
|
700
|
+
}
|
|
701
|
+
registerOnTouched(fn) {
|
|
702
|
+
this.onTouched = fn;
|
|
703
|
+
}
|
|
704
|
+
setDisabledState(isDisabled) {
|
|
705
|
+
this.isDisabled.set(isDisabled);
|
|
706
|
+
}
|
|
707
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgSwitchComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
708
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgSwitchComponent, isStandalone: true, selector: "elg-switch", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checkedChange: "checkedChange" }, host: { properties: { "class": "\"elg-switch\"", "class.elg-switch--checked": "isChecked()", "class.elg-switch--disabled": "isDisabled()" } }, providers: [
|
|
709
|
+
{
|
|
710
|
+
provide: NG_VALUE_ACCESSOR,
|
|
711
|
+
useExisting: forwardRef(() => ElgSwitchComponent),
|
|
712
|
+
multi: true,
|
|
713
|
+
},
|
|
714
|
+
], usesOnChanges: true, ngImport: i0, template: `
|
|
715
|
+
<label class="elg-switch__label">
|
|
716
|
+
<button
|
|
717
|
+
type="button"
|
|
718
|
+
role="switch"
|
|
719
|
+
class="elg-switch__track"
|
|
720
|
+
[attr.aria-checked]="isChecked()"
|
|
721
|
+
[disabled]="isDisabled()"
|
|
722
|
+
(click)="toggle()"
|
|
723
|
+
(blur)="onBlur()"
|
|
724
|
+
>
|
|
725
|
+
<span class="elg-switch__thumb"></span>
|
|
726
|
+
</button>
|
|
727
|
+
@if (label()) {
|
|
728
|
+
<span class="elg-switch__text">{{ label() }}</span>
|
|
729
|
+
}
|
|
730
|
+
</label>
|
|
731
|
+
`, isInline: true, styles: [":host{display:inline-block}.elg-switch__label{display:inline-flex;align-items:center;gap:var(--elg-switch-gap, .5rem);cursor:pointer;-webkit-user-select:none;user-select:none}.elg-switch__track{position:relative;display:inline-flex;align-items:center;width:var(--elg-switch-width, 2.5rem);height:var(--elg-switch-height, 1.375rem);padding:var(--elg-switch-padding, 2px);border:none;border-radius:var(--elg-switch-border-radius, 9999px);background-color:var(--elg-switch-track-bg, var(--elg-color-border, #d1d5db));cursor:pointer;transition:background-color .2s ease-in-out;outline:none;flex-shrink:0}.elg-switch__track:focus-visible{box-shadow:0 0 0 var(--elg-switch-focus-ring-width, 3px) var(--elg-switch-focus-ring-color, rgba(59, 130, 246, .15))}.elg-switch__thumb{display:block;width:var(--elg-switch-thumb-size, 1.125rem);height:var(--elg-switch-thumb-size, 1.125rem);border-radius:50%;background-color:var(--elg-switch-thumb-bg, #ffffff);box-shadow:var(--elg-switch-thumb-shadow, 0 1px 3px rgba(0, 0, 0, .15));transition:transform .2s ease-in-out;transform:translate(0)}.elg-switch__text{font-size:var(--elg-switch-font-size, .875rem);color:var(--elg-switch-label-color, var(--elg-color-foreground, #1f2937));line-height:1.4}:host(.elg-switch--checked) .elg-switch__track{background-color:var(--elg-switch-checked-bg, var(--elg-color-primary, #3b82f6))}:host(.elg-switch--checked) .elg-switch__thumb{transform:translate(calc(var(--elg-switch-width, 2.5rem) - var(--elg-switch-thumb-size, 1.125rem) - var(--elg-switch-padding, 2px) * 2))}:host(.elg-switch--disabled) .elg-switch__label{cursor:not-allowed}:host(.elg-switch--disabled) .elg-switch__track{opacity:var(--elg-switch-disabled-opacity, .5);cursor:not-allowed}:host(:not(.elg-switch--disabled)) .elg-switch__track:hover{background-color:var(--elg-switch-track-hover-bg, #b0b5c0)}:host(.elg-switch--checked:not(.elg-switch--disabled)) .elg-switch__track:hover{background-color:var(--elg-switch-checked-hover-bg, var(--elg-color-primary-hover, #2563eb))}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
732
|
+
}
|
|
733
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgSwitchComponent, decorators: [{
|
|
734
|
+
type: Component,
|
|
735
|
+
args: [{ selector: 'elg-switch', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
736
|
+
{
|
|
737
|
+
provide: NG_VALUE_ACCESSOR,
|
|
738
|
+
useExisting: forwardRef(() => ElgSwitchComponent),
|
|
739
|
+
multi: true,
|
|
740
|
+
},
|
|
741
|
+
], host: {
|
|
742
|
+
'[class]': '"elg-switch"',
|
|
743
|
+
'[class.elg-switch--checked]': 'isChecked()',
|
|
744
|
+
'[class.elg-switch--disabled]': 'isDisabled()',
|
|
745
|
+
}, template: `
|
|
746
|
+
<label class="elg-switch__label">
|
|
747
|
+
<button
|
|
748
|
+
type="button"
|
|
749
|
+
role="switch"
|
|
750
|
+
class="elg-switch__track"
|
|
751
|
+
[attr.aria-checked]="isChecked()"
|
|
752
|
+
[disabled]="isDisabled()"
|
|
753
|
+
(click)="toggle()"
|
|
754
|
+
(blur)="onBlur()"
|
|
755
|
+
>
|
|
756
|
+
<span class="elg-switch__thumb"></span>
|
|
757
|
+
</button>
|
|
758
|
+
@if (label()) {
|
|
759
|
+
<span class="elg-switch__text">{{ label() }}</span>
|
|
760
|
+
}
|
|
761
|
+
</label>
|
|
762
|
+
`, styles: [":host{display:inline-block}.elg-switch__label{display:inline-flex;align-items:center;gap:var(--elg-switch-gap, .5rem);cursor:pointer;-webkit-user-select:none;user-select:none}.elg-switch__track{position:relative;display:inline-flex;align-items:center;width:var(--elg-switch-width, 2.5rem);height:var(--elg-switch-height, 1.375rem);padding:var(--elg-switch-padding, 2px);border:none;border-radius:var(--elg-switch-border-radius, 9999px);background-color:var(--elg-switch-track-bg, var(--elg-color-border, #d1d5db));cursor:pointer;transition:background-color .2s ease-in-out;outline:none;flex-shrink:0}.elg-switch__track:focus-visible{box-shadow:0 0 0 var(--elg-switch-focus-ring-width, 3px) var(--elg-switch-focus-ring-color, rgba(59, 130, 246, .15))}.elg-switch__thumb{display:block;width:var(--elg-switch-thumb-size, 1.125rem);height:var(--elg-switch-thumb-size, 1.125rem);border-radius:50%;background-color:var(--elg-switch-thumb-bg, #ffffff);box-shadow:var(--elg-switch-thumb-shadow, 0 1px 3px rgba(0, 0, 0, .15));transition:transform .2s ease-in-out;transform:translate(0)}.elg-switch__text{font-size:var(--elg-switch-font-size, .875rem);color:var(--elg-switch-label-color, var(--elg-color-foreground, #1f2937));line-height:1.4}:host(.elg-switch--checked) .elg-switch__track{background-color:var(--elg-switch-checked-bg, var(--elg-color-primary, #3b82f6))}:host(.elg-switch--checked) .elg-switch__thumb{transform:translate(calc(var(--elg-switch-width, 2.5rem) - var(--elg-switch-thumb-size, 1.125rem) - var(--elg-switch-padding, 2px) * 2))}:host(.elg-switch--disabled) .elg-switch__label{cursor:not-allowed}:host(.elg-switch--disabled) .elg-switch__track{opacity:var(--elg-switch-disabled-opacity, .5);cursor:not-allowed}:host(:not(.elg-switch--disabled)) .elg-switch__track:hover{background-color:var(--elg-switch-track-hover-bg, #b0b5c0)}:host(.elg-switch--checked:not(.elg-switch--disabled)) .elg-switch__track:hover{background-color:var(--elg-switch-checked-hover-bg, var(--elg-color-primary-hover, #2563eb))}\n"] }]
|
|
763
|
+
}] });
|
|
764
|
+
|
|
765
|
+
class ElgTextareaDirective {
|
|
766
|
+
elgSize = input('md');
|
|
767
|
+
autoResize = input(false);
|
|
768
|
+
maxRows = input(0);
|
|
769
|
+
el = inject((ElementRef));
|
|
770
|
+
focused = signal(false);
|
|
771
|
+
isDisabled = signal(false);
|
|
772
|
+
hostClasses = computed(() => {
|
|
773
|
+
return `elg-textarea elg-textarea--${this.elgSize()}`;
|
|
774
|
+
});
|
|
775
|
+
onChange = () => { };
|
|
776
|
+
onTouched = () => { };
|
|
777
|
+
ngOnInit() { }
|
|
778
|
+
ngAfterViewInit() {
|
|
779
|
+
if (this.autoResize()) {
|
|
780
|
+
this.adjustHeight();
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
ngOnDestroy() { }
|
|
784
|
+
onFocus() {
|
|
785
|
+
this.focused.set(true);
|
|
786
|
+
}
|
|
787
|
+
onBlur() {
|
|
788
|
+
this.focused.set(false);
|
|
789
|
+
this.onTouched();
|
|
790
|
+
}
|
|
791
|
+
onInputChange(event) {
|
|
792
|
+
const target = event.target;
|
|
793
|
+
this.onChange(target.value);
|
|
794
|
+
if (this.autoResize()) {
|
|
795
|
+
this.adjustHeight();
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
adjustHeight() {
|
|
799
|
+
const textarea = this.el.nativeElement;
|
|
800
|
+
textarea.style.height = 'auto';
|
|
801
|
+
let newHeight = textarea.scrollHeight;
|
|
802
|
+
if (this.maxRows() > 0) {
|
|
803
|
+
const lineHeight = parseInt(getComputedStyle(textarea).lineHeight, 10) || 20;
|
|
804
|
+
const maxHeight = lineHeight * this.maxRows();
|
|
805
|
+
newHeight = Math.min(newHeight, maxHeight);
|
|
806
|
+
}
|
|
807
|
+
textarea.style.height = `${newHeight}px`;
|
|
808
|
+
}
|
|
809
|
+
// ControlValueAccessor
|
|
810
|
+
writeValue(value) {
|
|
811
|
+
this.el.nativeElement.value = value ?? '';
|
|
812
|
+
if (this.autoResize()) {
|
|
813
|
+
setTimeout(() => this.adjustHeight());
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
registerOnChange(fn) {
|
|
817
|
+
this.onChange = fn;
|
|
818
|
+
}
|
|
819
|
+
registerOnTouched(fn) {
|
|
820
|
+
this.onTouched = fn;
|
|
821
|
+
}
|
|
822
|
+
setDisabledState(isDisabled) {
|
|
823
|
+
this.isDisabled.set(isDisabled);
|
|
824
|
+
this.el.nativeElement.disabled = isDisabled;
|
|
825
|
+
}
|
|
826
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTextareaDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
827
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.14", type: ElgTextareaDirective, isStandalone: true, selector: "textarea[elgTextarea]", inputs: { elgSize: { classPropertyName: "elgSize", publicName: "elgSize", isSignal: true, isRequired: false, transformFunction: null }, autoResize: { classPropertyName: "autoResize", publicName: "autoResize", isSignal: true, isRequired: false, transformFunction: null }, maxRows: { classPropertyName: "maxRows", publicName: "maxRows", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "focus": "onFocus()", "blur": "onBlur()", "input": "onInputChange($event)" }, properties: { "class": "hostClasses()", "class.elg-textarea--focused": "focused()", "class.elg-textarea--disabled": "isDisabled()" } }, providers: [
|
|
828
|
+
{
|
|
829
|
+
provide: NG_VALUE_ACCESSOR,
|
|
830
|
+
useExisting: forwardRef(() => ElgTextareaDirective),
|
|
831
|
+
multi: true,
|
|
832
|
+
},
|
|
833
|
+
], ngImport: i0 });
|
|
834
|
+
}
|
|
835
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTextareaDirective, decorators: [{
|
|
836
|
+
type: Directive,
|
|
837
|
+
args: [{
|
|
838
|
+
selector: 'textarea[elgTextarea]',
|
|
839
|
+
standalone: true,
|
|
840
|
+
providers: [
|
|
841
|
+
{
|
|
842
|
+
provide: NG_VALUE_ACCESSOR,
|
|
843
|
+
useExisting: forwardRef(() => ElgTextareaDirective),
|
|
844
|
+
multi: true,
|
|
845
|
+
},
|
|
846
|
+
],
|
|
847
|
+
host: {
|
|
848
|
+
'[class]': 'hostClasses()',
|
|
849
|
+
'[class.elg-textarea--focused]': 'focused()',
|
|
850
|
+
'[class.elg-textarea--disabled]': 'isDisabled()',
|
|
851
|
+
'(focus)': 'onFocus()',
|
|
852
|
+
'(blur)': 'onBlur()',
|
|
853
|
+
'(input)': 'onInputChange($event)',
|
|
854
|
+
},
|
|
855
|
+
}]
|
|
856
|
+
}] });
|
|
857
|
+
|
|
858
|
+
class ElgAutocompleteComponent {
|
|
859
|
+
elementRef;
|
|
860
|
+
inputEl;
|
|
861
|
+
// Inputs
|
|
862
|
+
options = input([]);
|
|
863
|
+
displayWith = input((item) => String(item));
|
|
864
|
+
filterFn = input(undefined);
|
|
865
|
+
placeholder = input('');
|
|
866
|
+
disabled = input(false);
|
|
867
|
+
loading = input(false);
|
|
868
|
+
minChars = input(1);
|
|
869
|
+
emptyText = input('No results found');
|
|
870
|
+
// Outputs
|
|
871
|
+
optionSelected = output();
|
|
872
|
+
// Internal state
|
|
873
|
+
isOpen = signal(false);
|
|
874
|
+
highlightedIndex = signal(-1);
|
|
875
|
+
isDisabled = signal(false);
|
|
876
|
+
inputValue = signal('');
|
|
877
|
+
selectedItem = null;
|
|
878
|
+
filteredOptions = computed(() => {
|
|
879
|
+
const term = this.inputValue();
|
|
880
|
+
const opts = this.options();
|
|
881
|
+
const customFilter = this.filterFn();
|
|
882
|
+
if (!term || term.length < this.minChars()) {
|
|
883
|
+
return opts;
|
|
884
|
+
}
|
|
885
|
+
const filterFunction = customFilter
|
|
886
|
+
? (item) => customFilter(term, item)
|
|
887
|
+
: (item) => this.getDisplayText(item).toLowerCase().includes(term.toLowerCase());
|
|
888
|
+
return opts.filter(filterFunction);
|
|
889
|
+
});
|
|
890
|
+
onChange = () => { };
|
|
891
|
+
onTouched = () => { };
|
|
892
|
+
constructor(elementRef) {
|
|
893
|
+
this.elementRef = elementRef;
|
|
894
|
+
}
|
|
895
|
+
onDocumentClick(event) {
|
|
896
|
+
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
897
|
+
this.closePanel();
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
getDisplayText(item) {
|
|
901
|
+
const fn = this.displayWith();
|
|
902
|
+
return fn(item);
|
|
903
|
+
}
|
|
904
|
+
onInputChange(event) {
|
|
905
|
+
const value = event.target.value;
|
|
906
|
+
this.inputValue.set(value);
|
|
907
|
+
this.selectedItem = null;
|
|
908
|
+
this.onChange(null);
|
|
909
|
+
this.highlightedIndex.set(-1);
|
|
910
|
+
if (value.length >= this.minChars()) {
|
|
911
|
+
this.isOpen.set(true);
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
this.isOpen.set(false);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
onFocus() {
|
|
918
|
+
const value = this.inputValue();
|
|
919
|
+
if (value.length >= this.minChars()) {
|
|
920
|
+
this.isOpen.set(true);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
onKeydown(event) {
|
|
924
|
+
const filtered = this.filteredOptions();
|
|
925
|
+
switch (event.key) {
|
|
926
|
+
case 'ArrowDown':
|
|
927
|
+
event.preventDefault();
|
|
928
|
+
if (!this.isOpen()) {
|
|
929
|
+
this.isOpen.set(true);
|
|
930
|
+
}
|
|
931
|
+
this.highlightedIndex.set(Math.min(this.highlightedIndex() + 1, filtered.length - 1));
|
|
932
|
+
break;
|
|
933
|
+
case 'ArrowUp':
|
|
934
|
+
event.preventDefault();
|
|
935
|
+
this.highlightedIndex.set(Math.max(this.highlightedIndex() - 1, 0));
|
|
936
|
+
break;
|
|
937
|
+
case 'Enter':
|
|
938
|
+
event.preventDefault();
|
|
939
|
+
if (this.isOpen() && this.highlightedIndex() >= 0 && this.highlightedIndex() < filtered.length) {
|
|
940
|
+
this.selectOption(filtered[this.highlightedIndex()]);
|
|
941
|
+
}
|
|
942
|
+
break;
|
|
943
|
+
case 'Escape':
|
|
944
|
+
event.preventDefault();
|
|
945
|
+
this.closePanel();
|
|
946
|
+
break;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
selectOption(option) {
|
|
950
|
+
this.selectedItem = option;
|
|
951
|
+
this.inputValue.set(this.getDisplayText(option));
|
|
952
|
+
this.onChange(option);
|
|
953
|
+
this.optionSelected.emit(option);
|
|
954
|
+
this.closePanel();
|
|
955
|
+
}
|
|
956
|
+
closePanel() {
|
|
957
|
+
this.isOpen.set(false);
|
|
958
|
+
this.highlightedIndex.set(-1);
|
|
959
|
+
this.onTouched();
|
|
960
|
+
}
|
|
961
|
+
// ControlValueAccessor
|
|
962
|
+
writeValue(value) {
|
|
963
|
+
if (value != null) {
|
|
964
|
+
this.selectedItem = value;
|
|
965
|
+
this.inputValue.set(this.getDisplayText(value));
|
|
966
|
+
}
|
|
967
|
+
else {
|
|
968
|
+
this.selectedItem = null;
|
|
969
|
+
this.inputValue.set('');
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
registerOnChange(fn) {
|
|
973
|
+
this.onChange = fn;
|
|
974
|
+
}
|
|
975
|
+
registerOnTouched(fn) {
|
|
976
|
+
this.onTouched = fn;
|
|
977
|
+
}
|
|
978
|
+
setDisabledState(isDisabled) {
|
|
979
|
+
this.isDisabled.set(isDisabled);
|
|
980
|
+
}
|
|
981
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgAutocompleteComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
982
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgAutocompleteComponent, isStandalone: true, selector: "elg-autocomplete", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, displayWith: { classPropertyName: "displayWith", publicName: "displayWith", isSignal: true, isRequired: false, transformFunction: null }, filterFn: { classPropertyName: "filterFn", publicName: "filterFn", 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 }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, minChars: { classPropertyName: "minChars", publicName: "minChars", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { optionSelected: "optionSelected" }, host: { listeners: { "document:click": "onDocumentClick($event)" }, properties: { "class.elg-autocomplete--disabled": "isDisabled()", "class.elg-autocomplete--open": "isOpen()" }, classAttribute: "elg-autocomplete" }, providers: [
|
|
983
|
+
{
|
|
984
|
+
provide: NG_VALUE_ACCESSOR,
|
|
985
|
+
useExisting: forwardRef(() => ElgAutocompleteComponent),
|
|
986
|
+
multi: true,
|
|
987
|
+
},
|
|
988
|
+
], viewQueries: [{ propertyName: "inputEl", first: true, predicate: ["inputEl"], descendants: true }], ngImport: i0, template: `
|
|
989
|
+
<input
|
|
990
|
+
#inputEl
|
|
991
|
+
class="elg-autocomplete__input"
|
|
992
|
+
type="text"
|
|
993
|
+
[placeholder]="placeholder()"
|
|
994
|
+
[disabled]="isDisabled()"
|
|
995
|
+
[value]="inputValue()"
|
|
996
|
+
(input)="onInputChange($event)"
|
|
997
|
+
(focus)="onFocus()"
|
|
998
|
+
(keydown)="onKeydown($event)"
|
|
999
|
+
autocomplete="off"
|
|
1000
|
+
role="combobox"
|
|
1001
|
+
[attr.aria-expanded]="isOpen()"
|
|
1002
|
+
aria-autocomplete="list"
|
|
1003
|
+
aria-haspopup="listbox"
|
|
1004
|
+
/>
|
|
1005
|
+
@if (isOpen()) {
|
|
1006
|
+
<div class="elg-autocomplete__panel" role="listbox">
|
|
1007
|
+
@if (loading()) {
|
|
1008
|
+
<div class="elg-autocomplete__loading">
|
|
1009
|
+
<span class="elg-autocomplete__spinner"></span>
|
|
1010
|
+
<span>Loading...</span>
|
|
1011
|
+
</div>
|
|
1012
|
+
} @else if (filteredOptions().length === 0) {
|
|
1013
|
+
<div class="elg-autocomplete__empty">{{ emptyText() }}</div>
|
|
1014
|
+
} @else {
|
|
1015
|
+
@for (option of filteredOptions(); track option; let i = $index) {
|
|
1016
|
+
<div
|
|
1017
|
+
class="elg-autocomplete__option"
|
|
1018
|
+
[class.elg-autocomplete__option--highlighted]="i === highlightedIndex()"
|
|
1019
|
+
(mousedown)="selectOption(option)"
|
|
1020
|
+
(mouseenter)="highlightedIndex.set(i)"
|
|
1021
|
+
role="option"
|
|
1022
|
+
[attr.aria-selected]="i === highlightedIndex()"
|
|
1023
|
+
>
|
|
1024
|
+
{{ getDisplayText(option) }}
|
|
1025
|
+
</div>
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
</div>
|
|
1029
|
+
}
|
|
1030
|
+
`, isInline: true, styles: [":host{display:block;position:relative;width:100%}.elg-autocomplete__input{display:block;width:100%;box-sizing:border-box;height:var(--elg-input-height, 2.5rem);padding-left:var(--elg-input-padding-x, .75rem);padding-right:var(--elg-input-padding-x, .75rem);border:1px solid var(--elg-input-border-color, var(--elg-color-border, #d1d5db));border-radius:var(--elg-input-border-radius, var(--elg-radius-md, .375rem));font-size:var(--elg-input-font-size, .875rem);font-family:inherit;color:var(--elg-input-color, var(--elg-color-foreground, #1f2937));background-color:var(--elg-input-bg, var(--elg-color-background, #ffffff));outline:none;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.elg-autocomplete__input::placeholder{color:var(--elg-input-placeholder-color, var(--elg-color-muted-foreground, #9ca3af))}.elg-autocomplete__input:focus{border-color:var(--elg-input-focus-border-color, var(--elg-color-primary, #3b82f6));box-shadow:0 0 0 var(--elg-input-focus-ring-width, 3px) var(--elg-input-focus-ring-color, rgba(59, 130, 246, .15))}:host(.elg-autocomplete--disabled) .elg-autocomplete__input,.elg-autocomplete__input:disabled{background-color:var(--elg-input-disabled-bg, var(--elg-color-muted, #f3f4f6));color:var(--elg-input-disabled-color, var(--elg-color-muted-foreground, #9ca3af));cursor:not-allowed;opacity:var(--elg-input-disabled-opacity, .7)}.elg-autocomplete__panel{position:absolute;top:100%;left:0;right:0;z-index:var(--elg-dropdown-z-index, var(--elg-z-dropdown, 1000));margin-top:var(--elg-dropdown-offset, .25rem);border:1px solid var(--elg-dropdown-border-color, var(--elg-color-border, #d1d5db));border-radius:var(--elg-dropdown-border-radius, var(--elg-radius-md, .375rem));background-color:var(--elg-dropdown-bg, var(--elg-color-background, #ffffff));box-shadow:var(--elg-dropdown-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));max-height:var(--elg-dropdown-max-height, 15rem);overflow-y:auto}.elg-autocomplete__option{padding:var(--elg-dropdown-item-padding-y, .5rem) var(--elg-dropdown-item-padding-x, .75rem);font-size:var(--elg-dropdown-item-font-size, .875rem);color:var(--elg-dropdown-item-color, var(--elg-color-foreground, #1f2937));cursor:pointer;transition:background-color .1s ease-in-out}.elg-autocomplete__option:hover{background-color:var(--elg-dropdown-item-hover-bg, var(--elg-color-muted, #f3f4f6))}.elg-autocomplete__option--highlighted{background-color:var(--elg-dropdown-item-highlighted-bg, var(--elg-color-primary-muted, rgba(59, 130, 246, .1)));color:var(--elg-dropdown-item-highlighted-color, var(--elg-color-primary, #3b82f6))}.elg-autocomplete__loading{display:flex;align-items:center;gap:.5rem;padding:var(--elg-dropdown-item-padding-y, .5rem) var(--elg-dropdown-item-padding-x, .75rem);font-size:var(--elg-dropdown-item-font-size, .875rem);color:var(--elg-color-muted-foreground, #9ca3af)}.elg-autocomplete__spinner{display:inline-block;width:1rem;height:1rem;border:2px solid var(--elg-color-border, #d1d5db);border-top-color:var(--elg-color-primary, #3b82f6);border-radius:50%;animation:elg-autocomplete-spin .6s linear infinite}@keyframes elg-autocomplete-spin{to{transform:rotate(360deg)}}.elg-autocomplete__empty{padding:var(--elg-dropdown-item-padding-y, .5rem) var(--elg-dropdown-item-padding-x, .75rem);font-size:var(--elg-dropdown-item-font-size, .875rem);color:var(--elg-color-muted-foreground, #9ca3af);text-align:center}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1031
|
+
}
|
|
1032
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgAutocompleteComponent, decorators: [{
|
|
1033
|
+
type: Component,
|
|
1034
|
+
args: [{ selector: 'elg-autocomplete', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
1035
|
+
{
|
|
1036
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1037
|
+
useExisting: forwardRef(() => ElgAutocompleteComponent),
|
|
1038
|
+
multi: true,
|
|
1039
|
+
},
|
|
1040
|
+
], host: {
|
|
1041
|
+
class: 'elg-autocomplete',
|
|
1042
|
+
'[class.elg-autocomplete--disabled]': 'isDisabled()',
|
|
1043
|
+
'[class.elg-autocomplete--open]': 'isOpen()',
|
|
1044
|
+
}, template: `
|
|
1045
|
+
<input
|
|
1046
|
+
#inputEl
|
|
1047
|
+
class="elg-autocomplete__input"
|
|
1048
|
+
type="text"
|
|
1049
|
+
[placeholder]="placeholder()"
|
|
1050
|
+
[disabled]="isDisabled()"
|
|
1051
|
+
[value]="inputValue()"
|
|
1052
|
+
(input)="onInputChange($event)"
|
|
1053
|
+
(focus)="onFocus()"
|
|
1054
|
+
(keydown)="onKeydown($event)"
|
|
1055
|
+
autocomplete="off"
|
|
1056
|
+
role="combobox"
|
|
1057
|
+
[attr.aria-expanded]="isOpen()"
|
|
1058
|
+
aria-autocomplete="list"
|
|
1059
|
+
aria-haspopup="listbox"
|
|
1060
|
+
/>
|
|
1061
|
+
@if (isOpen()) {
|
|
1062
|
+
<div class="elg-autocomplete__panel" role="listbox">
|
|
1063
|
+
@if (loading()) {
|
|
1064
|
+
<div class="elg-autocomplete__loading">
|
|
1065
|
+
<span class="elg-autocomplete__spinner"></span>
|
|
1066
|
+
<span>Loading...</span>
|
|
1067
|
+
</div>
|
|
1068
|
+
} @else if (filteredOptions().length === 0) {
|
|
1069
|
+
<div class="elg-autocomplete__empty">{{ emptyText() }}</div>
|
|
1070
|
+
} @else {
|
|
1071
|
+
@for (option of filteredOptions(); track option; let i = $index) {
|
|
1072
|
+
<div
|
|
1073
|
+
class="elg-autocomplete__option"
|
|
1074
|
+
[class.elg-autocomplete__option--highlighted]="i === highlightedIndex()"
|
|
1075
|
+
(mousedown)="selectOption(option)"
|
|
1076
|
+
(mouseenter)="highlightedIndex.set(i)"
|
|
1077
|
+
role="option"
|
|
1078
|
+
[attr.aria-selected]="i === highlightedIndex()"
|
|
1079
|
+
>
|
|
1080
|
+
{{ getDisplayText(option) }}
|
|
1081
|
+
</div>
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
</div>
|
|
1085
|
+
}
|
|
1086
|
+
`, styles: [":host{display:block;position:relative;width:100%}.elg-autocomplete__input{display:block;width:100%;box-sizing:border-box;height:var(--elg-input-height, 2.5rem);padding-left:var(--elg-input-padding-x, .75rem);padding-right:var(--elg-input-padding-x, .75rem);border:1px solid var(--elg-input-border-color, var(--elg-color-border, #d1d5db));border-radius:var(--elg-input-border-radius, var(--elg-radius-md, .375rem));font-size:var(--elg-input-font-size, .875rem);font-family:inherit;color:var(--elg-input-color, var(--elg-color-foreground, #1f2937));background-color:var(--elg-input-bg, var(--elg-color-background, #ffffff));outline:none;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}.elg-autocomplete__input::placeholder{color:var(--elg-input-placeholder-color, var(--elg-color-muted-foreground, #9ca3af))}.elg-autocomplete__input:focus{border-color:var(--elg-input-focus-border-color, var(--elg-color-primary, #3b82f6));box-shadow:0 0 0 var(--elg-input-focus-ring-width, 3px) var(--elg-input-focus-ring-color, rgba(59, 130, 246, .15))}:host(.elg-autocomplete--disabled) .elg-autocomplete__input,.elg-autocomplete__input:disabled{background-color:var(--elg-input-disabled-bg, var(--elg-color-muted, #f3f4f6));color:var(--elg-input-disabled-color, var(--elg-color-muted-foreground, #9ca3af));cursor:not-allowed;opacity:var(--elg-input-disabled-opacity, .7)}.elg-autocomplete__panel{position:absolute;top:100%;left:0;right:0;z-index:var(--elg-dropdown-z-index, var(--elg-z-dropdown, 1000));margin-top:var(--elg-dropdown-offset, .25rem);border:1px solid var(--elg-dropdown-border-color, var(--elg-color-border, #d1d5db));border-radius:var(--elg-dropdown-border-radius, var(--elg-radius-md, .375rem));background-color:var(--elg-dropdown-bg, var(--elg-color-background, #ffffff));box-shadow:var(--elg-dropdown-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));max-height:var(--elg-dropdown-max-height, 15rem);overflow-y:auto}.elg-autocomplete__option{padding:var(--elg-dropdown-item-padding-y, .5rem) var(--elg-dropdown-item-padding-x, .75rem);font-size:var(--elg-dropdown-item-font-size, .875rem);color:var(--elg-dropdown-item-color, var(--elg-color-foreground, #1f2937));cursor:pointer;transition:background-color .1s ease-in-out}.elg-autocomplete__option:hover{background-color:var(--elg-dropdown-item-hover-bg, var(--elg-color-muted, #f3f4f6))}.elg-autocomplete__option--highlighted{background-color:var(--elg-dropdown-item-highlighted-bg, var(--elg-color-primary-muted, rgba(59, 130, 246, .1)));color:var(--elg-dropdown-item-highlighted-color, var(--elg-color-primary, #3b82f6))}.elg-autocomplete__loading{display:flex;align-items:center;gap:.5rem;padding:var(--elg-dropdown-item-padding-y, .5rem) var(--elg-dropdown-item-padding-x, .75rem);font-size:var(--elg-dropdown-item-font-size, .875rem);color:var(--elg-color-muted-foreground, #9ca3af)}.elg-autocomplete__spinner{display:inline-block;width:1rem;height:1rem;border:2px solid var(--elg-color-border, #d1d5db);border-top-color:var(--elg-color-primary, #3b82f6);border-radius:50%;animation:elg-autocomplete-spin .6s linear infinite}@keyframes elg-autocomplete-spin{to{transform:rotate(360deg)}}.elg-autocomplete__empty{padding:var(--elg-dropdown-item-padding-y, .5rem) var(--elg-dropdown-item-padding-x, .75rem);font-size:var(--elg-dropdown-item-font-size, .875rem);color:var(--elg-color-muted-foreground, #9ca3af);text-align:center}\n"] }]
|
|
1087
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { inputEl: [{
|
|
1088
|
+
type: ViewChild,
|
|
1089
|
+
args: ['inputEl']
|
|
1090
|
+
}], onDocumentClick: [{
|
|
1091
|
+
type: HostListener,
|
|
1092
|
+
args: ['document:click', ['$event']]
|
|
1093
|
+
}] } });
|
|
1094
|
+
|
|
1095
|
+
class ElgMenuItemComponent {
|
|
1096
|
+
disabled = input(false);
|
|
1097
|
+
itemClick = output();
|
|
1098
|
+
focused = signal(false);
|
|
1099
|
+
elementRef = inject(ElementRef);
|
|
1100
|
+
onItemClick(event) {
|
|
1101
|
+
if (this.disabled()) {
|
|
1102
|
+
event.preventDefault();
|
|
1103
|
+
event.stopPropagation();
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
this.itemClick.emit();
|
|
1107
|
+
}
|
|
1108
|
+
focus() {
|
|
1109
|
+
this.focused.set(true);
|
|
1110
|
+
this.elementRef.nativeElement.focus();
|
|
1111
|
+
}
|
|
1112
|
+
blur() {
|
|
1113
|
+
this.focused.set(false);
|
|
1114
|
+
}
|
|
1115
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgMenuItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1116
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgMenuItemComponent, isStandalone: true, selector: "elg-menu-item", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemClick: "itemClick" }, host: { listeners: { "click": "onItemClick($event)", "keydown.enter": "onItemClick($event)", "keydown.space": "onItemClick($event)" }, properties: { "class": "\"elg-menu-item\"", "class.elg-menu-item--disabled": "disabled()", "class.elg-menu-item--focused": "focused()", "attr.role": "\"menuitem\"", "attr.tabindex": "disabled() ? -1 : 0", "attr.aria-disabled": "disabled()" } }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1117
|
+
}
|
|
1118
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgMenuItemComponent, decorators: [{
|
|
1119
|
+
type: Component,
|
|
1120
|
+
args: [{
|
|
1121
|
+
selector: 'elg-menu-item',
|
|
1122
|
+
standalone: true,
|
|
1123
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1124
|
+
host: {
|
|
1125
|
+
'[class]': '"elg-menu-item"',
|
|
1126
|
+
'[class.elg-menu-item--disabled]': 'disabled()',
|
|
1127
|
+
'[class.elg-menu-item--focused]': 'focused()',
|
|
1128
|
+
'[attr.role]': '"menuitem"',
|
|
1129
|
+
'[attr.tabindex]': 'disabled() ? -1 : 0',
|
|
1130
|
+
'[attr.aria-disabled]': 'disabled()',
|
|
1131
|
+
'(click)': 'onItemClick($event)',
|
|
1132
|
+
'(keydown.enter)': 'onItemClick($event)',
|
|
1133
|
+
'(keydown.space)': 'onItemClick($event)',
|
|
1134
|
+
},
|
|
1135
|
+
template: `<ng-content></ng-content>`,
|
|
1136
|
+
}]
|
|
1137
|
+
}] });
|
|
1138
|
+
|
|
1139
|
+
class ElgDropdownMenuComponent {
|
|
1140
|
+
items;
|
|
1141
|
+
isOpen = signal(false);
|
|
1142
|
+
focusedIndex = -1;
|
|
1143
|
+
clickOutsideListener = null;
|
|
1144
|
+
elementRef = inject(ElementRef);
|
|
1145
|
+
ngAfterContentInit() {
|
|
1146
|
+
// items ready
|
|
1147
|
+
}
|
|
1148
|
+
ngOnDestroy() {
|
|
1149
|
+
this.removeClickOutsideListener();
|
|
1150
|
+
}
|
|
1151
|
+
open() {
|
|
1152
|
+
this.isOpen.set(true);
|
|
1153
|
+
this.focusedIndex = -1;
|
|
1154
|
+
this.addClickOutsideListener();
|
|
1155
|
+
}
|
|
1156
|
+
close() {
|
|
1157
|
+
this.isOpen.set(false);
|
|
1158
|
+
this.focusedIndex = -1;
|
|
1159
|
+
this.clearItemFocus();
|
|
1160
|
+
this.removeClickOutsideListener();
|
|
1161
|
+
}
|
|
1162
|
+
toggle() {
|
|
1163
|
+
if (this.isOpen()) {
|
|
1164
|
+
this.close();
|
|
1165
|
+
}
|
|
1166
|
+
else {
|
|
1167
|
+
this.open();
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
onKeydown(event) {
|
|
1171
|
+
if (!this.isOpen())
|
|
1172
|
+
return;
|
|
1173
|
+
switch (event.key) {
|
|
1174
|
+
case 'Escape':
|
|
1175
|
+
event.preventDefault();
|
|
1176
|
+
this.close();
|
|
1177
|
+
break;
|
|
1178
|
+
case 'ArrowDown':
|
|
1179
|
+
event.preventDefault();
|
|
1180
|
+
this.focusNextItem();
|
|
1181
|
+
break;
|
|
1182
|
+
case 'ArrowUp':
|
|
1183
|
+
event.preventDefault();
|
|
1184
|
+
this.focusPreviousItem();
|
|
1185
|
+
break;
|
|
1186
|
+
case 'Enter':
|
|
1187
|
+
case ' ':
|
|
1188
|
+
event.preventDefault();
|
|
1189
|
+
this.selectFocusedItem();
|
|
1190
|
+
break;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
focusNextItem() {
|
|
1194
|
+
const itemsArray = this.items.toArray().filter(i => !i.disabled());
|
|
1195
|
+
if (itemsArray.length === 0)
|
|
1196
|
+
return;
|
|
1197
|
+
this.clearItemFocus();
|
|
1198
|
+
this.focusedIndex++;
|
|
1199
|
+
if (this.focusedIndex >= itemsArray.length) {
|
|
1200
|
+
this.focusedIndex = 0;
|
|
1201
|
+
}
|
|
1202
|
+
itemsArray[this.focusedIndex].focus();
|
|
1203
|
+
}
|
|
1204
|
+
focusPreviousItem() {
|
|
1205
|
+
const itemsArray = this.items.toArray().filter(i => !i.disabled());
|
|
1206
|
+
if (itemsArray.length === 0)
|
|
1207
|
+
return;
|
|
1208
|
+
this.clearItemFocus();
|
|
1209
|
+
this.focusedIndex--;
|
|
1210
|
+
if (this.focusedIndex < 0) {
|
|
1211
|
+
this.focusedIndex = itemsArray.length - 1;
|
|
1212
|
+
}
|
|
1213
|
+
itemsArray[this.focusedIndex].focus();
|
|
1214
|
+
}
|
|
1215
|
+
selectFocusedItem() {
|
|
1216
|
+
const itemsArray = this.items.toArray().filter(i => !i.disabled());
|
|
1217
|
+
if (this.focusedIndex >= 0 && this.focusedIndex < itemsArray.length) {
|
|
1218
|
+
itemsArray[this.focusedIndex].onItemClick(new Event('click'));
|
|
1219
|
+
this.close();
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
clearItemFocus() {
|
|
1223
|
+
this.items?.forEach(item => item.blur());
|
|
1224
|
+
}
|
|
1225
|
+
addClickOutsideListener() {
|
|
1226
|
+
this.removeClickOutsideListener();
|
|
1227
|
+
this.clickOutsideListener = (event) => {
|
|
1228
|
+
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
1229
|
+
this.close();
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
setTimeout(() => {
|
|
1233
|
+
document.addEventListener('click', this.clickOutsideListener);
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
removeClickOutsideListener() {
|
|
1237
|
+
if (this.clickOutsideListener) {
|
|
1238
|
+
document.removeEventListener('click', this.clickOutsideListener);
|
|
1239
|
+
this.clickOutsideListener = null;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDropdownMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1243
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: ElgDropdownMenuComponent, isStandalone: true, selector: "elg-dropdown-menu", host: { listeners: { "keydown": "onKeydown($event)" }, properties: { "class": "\"elg-dropdown-menu\"", "class.elg-dropdown-menu--open": "isOpen()" } }, queries: [{ propertyName: "items", predicate: ElgMenuItemComponent, descendants: true }], ngImport: i0, template: `
|
|
1244
|
+
<div
|
|
1245
|
+
class="elg-dropdown-menu__panel"
|
|
1246
|
+
[attr.role]="'menu'"
|
|
1247
|
+
[attr.aria-hidden]="!isOpen()"
|
|
1248
|
+
>
|
|
1249
|
+
<ng-content></ng-content>
|
|
1250
|
+
</div>
|
|
1251
|
+
`, isInline: true, styles: [":host{position:relative;display:inline-block}.elg-dropdown-menu__panel{position:absolute;top:100%;left:0;z-index:var(--elg-dropdown-z-index, 1000);min-width:var(--elg-dropdown-min-width, 180px);padding:var(--elg-dropdown-padding, .25rem 0);margin-top:var(--elg-dropdown-offset, .25rem);background:var(--elg-dropdown-bg, #ffffff);border:var(--elg-dropdown-border, 1px solid #e2e8f0);border-radius:var(--elg-dropdown-border-radius, .375rem);box-shadow:var(--elg-dropdown-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));opacity:0;visibility:hidden;transform:translateY(-4px);transition:opacity .15s ease,transform .15s ease,visibility .15s}:host(.elg-dropdown-menu--open) .elg-dropdown-menu__panel{opacity:1;visibility:visible;transform:translateY(0)}::ng-deep .elg-menu-item{display:flex;align-items:center;gap:var(--elg-dropdown-item-gap, .5rem);width:100%;padding:var(--elg-dropdown-item-padding, .5rem .75rem);font-size:var(--elg-dropdown-item-font-size, .875rem);color:var(--elg-dropdown-item-color, #1a202c);cursor:pointer;border:none;background:none;outline:none;transition:background-color .15s ease}::ng-deep .elg-menu-item:hover,::ng-deep .elg-menu-item.elg-menu-item--focused{background-color:var(--elg-dropdown-item-hover-bg, #f7fafc)}::ng-deep .elg-menu-item--disabled{opacity:var(--elg-dropdown-item-disabled-opacity, .5);cursor:not-allowed;pointer-events:none}::ng-deep .elg-menu-separator{height:1px;margin:.25rem 0;background:var(--elg-dropdown-separator-color, #e2e8f0)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1252
|
+
}
|
|
1253
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDropdownMenuComponent, decorators: [{
|
|
1254
|
+
type: Component,
|
|
1255
|
+
args: [{ selector: 'elg-dropdown-menu', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1256
|
+
'[class]': '"elg-dropdown-menu"',
|
|
1257
|
+
'[class.elg-dropdown-menu--open]': 'isOpen()',
|
|
1258
|
+
}, template: `
|
|
1259
|
+
<div
|
|
1260
|
+
class="elg-dropdown-menu__panel"
|
|
1261
|
+
[attr.role]="'menu'"
|
|
1262
|
+
[attr.aria-hidden]="!isOpen()"
|
|
1263
|
+
>
|
|
1264
|
+
<ng-content></ng-content>
|
|
1265
|
+
</div>
|
|
1266
|
+
`, styles: [":host{position:relative;display:inline-block}.elg-dropdown-menu__panel{position:absolute;top:100%;left:0;z-index:var(--elg-dropdown-z-index, 1000);min-width:var(--elg-dropdown-min-width, 180px);padding:var(--elg-dropdown-padding, .25rem 0);margin-top:var(--elg-dropdown-offset, .25rem);background:var(--elg-dropdown-bg, #ffffff);border:var(--elg-dropdown-border, 1px solid #e2e8f0);border-radius:var(--elg-dropdown-border-radius, .375rem);box-shadow:var(--elg-dropdown-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));opacity:0;visibility:hidden;transform:translateY(-4px);transition:opacity .15s ease,transform .15s ease,visibility .15s}:host(.elg-dropdown-menu--open) .elg-dropdown-menu__panel{opacity:1;visibility:visible;transform:translateY(0)}::ng-deep .elg-menu-item{display:flex;align-items:center;gap:var(--elg-dropdown-item-gap, .5rem);width:100%;padding:var(--elg-dropdown-item-padding, .5rem .75rem);font-size:var(--elg-dropdown-item-font-size, .875rem);color:var(--elg-dropdown-item-color, #1a202c);cursor:pointer;border:none;background:none;outline:none;transition:background-color .15s ease}::ng-deep .elg-menu-item:hover,::ng-deep .elg-menu-item.elg-menu-item--focused{background-color:var(--elg-dropdown-item-hover-bg, #f7fafc)}::ng-deep .elg-menu-item--disabled{opacity:var(--elg-dropdown-item-disabled-opacity, .5);cursor:not-allowed;pointer-events:none}::ng-deep .elg-menu-separator{height:1px;margin:.25rem 0;background:var(--elg-dropdown-separator-color, #e2e8f0)}\n"] }]
|
|
1267
|
+
}], propDecorators: { items: [{
|
|
1268
|
+
type: ContentChildren,
|
|
1269
|
+
args: [ElgMenuItemComponent, { descendants: true }]
|
|
1270
|
+
}], onKeydown: [{
|
|
1271
|
+
type: HostListener,
|
|
1272
|
+
args: ['keydown', ['$event']]
|
|
1273
|
+
}] } });
|
|
1274
|
+
|
|
1275
|
+
class ElgDropdownTriggerDirective {
|
|
1276
|
+
elgDropdownTrigger = input.required();
|
|
1277
|
+
onClick(event) {
|
|
1278
|
+
event.stopPropagation();
|
|
1279
|
+
this.elgDropdownTrigger().toggle();
|
|
1280
|
+
}
|
|
1281
|
+
onKeydown(event) {
|
|
1282
|
+
event.preventDefault();
|
|
1283
|
+
this.elgDropdownTrigger().open();
|
|
1284
|
+
}
|
|
1285
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDropdownTriggerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1286
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.14", type: ElgDropdownTriggerDirective, isStandalone: true, selector: "[elgDropdownTrigger]", inputs: { elgDropdownTrigger: { classPropertyName: "elgDropdownTrigger", publicName: "elgDropdownTrigger", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "click": "onClick($event)", "keydown.enter": "onKeydown($event)", "keydown.space": "onKeydown($event)" }, properties: { "attr.aria-haspopup": "\"menu\"", "attr.aria-expanded": "elgDropdownTrigger()?.isOpen()" } }, ngImport: i0 });
|
|
1287
|
+
}
|
|
1288
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDropdownTriggerDirective, decorators: [{
|
|
1289
|
+
type: Directive,
|
|
1290
|
+
args: [{
|
|
1291
|
+
selector: '[elgDropdownTrigger]',
|
|
1292
|
+
standalone: true,
|
|
1293
|
+
host: {
|
|
1294
|
+
'[attr.aria-haspopup]': '"menu"',
|
|
1295
|
+
'[attr.aria-expanded]': 'elgDropdownTrigger()?.isOpen()',
|
|
1296
|
+
},
|
|
1297
|
+
}]
|
|
1298
|
+
}], propDecorators: { onClick: [{
|
|
1299
|
+
type: HostListener,
|
|
1300
|
+
args: ['click', ['$event']]
|
|
1301
|
+
}], onKeydown: [{
|
|
1302
|
+
type: HostListener,
|
|
1303
|
+
args: ['keydown.enter', ['$event']]
|
|
1304
|
+
}, {
|
|
1305
|
+
type: HostListener,
|
|
1306
|
+
args: ['keydown.space', ['$event']]
|
|
1307
|
+
}] } });
|
|
1308
|
+
|
|
1309
|
+
class ElgTooltipDirective {
|
|
1310
|
+
elgTooltip = input.required();
|
|
1311
|
+
elgTooltipPosition = input('top');
|
|
1312
|
+
elgTooltipDelay = input(300);
|
|
1313
|
+
tooltipElement = null;
|
|
1314
|
+
showTimeout = null;
|
|
1315
|
+
elementRef = inject(ElementRef);
|
|
1316
|
+
renderer = inject(Renderer2);
|
|
1317
|
+
tooltipId = `elg-tooltip-${Math.random().toString(36).substring(2, 9)}`;
|
|
1318
|
+
onMouseEnter() {
|
|
1319
|
+
if (this.showTimeout)
|
|
1320
|
+
return;
|
|
1321
|
+
this.showTimeout = setTimeout(() => {
|
|
1322
|
+
this.show();
|
|
1323
|
+
}, this.elgTooltipDelay());
|
|
1324
|
+
}
|
|
1325
|
+
onMouseLeave() {
|
|
1326
|
+
if (this.showTimeout) {
|
|
1327
|
+
clearTimeout(this.showTimeout);
|
|
1328
|
+
this.showTimeout = null;
|
|
1329
|
+
}
|
|
1330
|
+
this.hide();
|
|
1331
|
+
}
|
|
1332
|
+
ngOnDestroy() {
|
|
1333
|
+
this.hide();
|
|
1334
|
+
if (this.showTimeout) {
|
|
1335
|
+
clearTimeout(this.showTimeout);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
show() {
|
|
1339
|
+
if (this.tooltipElement)
|
|
1340
|
+
return;
|
|
1341
|
+
const text = this.elgTooltip();
|
|
1342
|
+
if (!text)
|
|
1343
|
+
return;
|
|
1344
|
+
this.tooltipElement = this.renderer.createElement('div');
|
|
1345
|
+
this.renderer.setAttribute(this.tooltipElement, 'id', this.tooltipId);
|
|
1346
|
+
this.renderer.setAttribute(this.tooltipElement, 'role', 'tooltip');
|
|
1347
|
+
this.renderer.addClass(this.tooltipElement, 'elg-tooltip');
|
|
1348
|
+
this.renderer.addClass(this.tooltipElement, `elg-tooltip--${this.elgTooltipPosition()}`);
|
|
1349
|
+
const textNode = this.renderer.createText(text);
|
|
1350
|
+
this.renderer.appendChild(this.tooltipElement, textNode);
|
|
1351
|
+
this.renderer.appendChild(document.body, this.tooltipElement);
|
|
1352
|
+
// Set aria-describedby on host
|
|
1353
|
+
this.renderer.setAttribute(this.elementRef.nativeElement, 'aria-describedby', this.tooltipId);
|
|
1354
|
+
// Apply styles
|
|
1355
|
+
this.applyStyles();
|
|
1356
|
+
this.positionTooltip();
|
|
1357
|
+
// Animate in
|
|
1358
|
+
requestAnimationFrame(() => {
|
|
1359
|
+
if (this.tooltipElement) {
|
|
1360
|
+
this.renderer.addClass(this.tooltipElement, 'elg-tooltip--visible');
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
hide() {
|
|
1365
|
+
if (this.tooltipElement) {
|
|
1366
|
+
this.renderer.removeAttribute(this.elementRef.nativeElement, 'aria-describedby');
|
|
1367
|
+
this.renderer.removeChild(document.body, this.tooltipElement);
|
|
1368
|
+
this.tooltipElement = null;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
applyStyles() {
|
|
1372
|
+
if (!this.tooltipElement)
|
|
1373
|
+
return;
|
|
1374
|
+
const styles = {
|
|
1375
|
+
position: 'absolute',
|
|
1376
|
+
'z-index': 'var(--elg-tooltip-z-index, 9999)',
|
|
1377
|
+
padding: 'var(--elg-tooltip-padding, 0.375rem 0.625rem)',
|
|
1378
|
+
'font-size': 'var(--elg-tooltip-font-size, 0.75rem)',
|
|
1379
|
+
'line-height': '1.4',
|
|
1380
|
+
color: 'var(--elg-tooltip-color, #ffffff)',
|
|
1381
|
+
'background-color': 'var(--elg-tooltip-bg, #1a202c)',
|
|
1382
|
+
'border-radius': 'var(--elg-tooltip-border-radius, 0.25rem)',
|
|
1383
|
+
'box-shadow': 'var(--elg-tooltip-shadow, 0 2px 4px rgba(0,0,0,0.2))',
|
|
1384
|
+
'white-space': 'nowrap',
|
|
1385
|
+
'pointer-events': 'none',
|
|
1386
|
+
opacity: '0',
|
|
1387
|
+
transition: 'opacity 0.15s ease',
|
|
1388
|
+
};
|
|
1389
|
+
for (const [key, value] of Object.entries(styles)) {
|
|
1390
|
+
this.renderer.setStyle(this.tooltipElement, key, value);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
positionTooltip() {
|
|
1394
|
+
if (!this.tooltipElement)
|
|
1395
|
+
return;
|
|
1396
|
+
const hostRect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
1397
|
+
const tooltipRect = this.tooltipElement.getBoundingClientRect();
|
|
1398
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
1399
|
+
const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
|
|
1400
|
+
const gap = 8;
|
|
1401
|
+
let top = 0;
|
|
1402
|
+
let left = 0;
|
|
1403
|
+
switch (this.elgTooltipPosition()) {
|
|
1404
|
+
case 'top':
|
|
1405
|
+
top = hostRect.top + scrollTop - tooltipRect.height - gap;
|
|
1406
|
+
left = hostRect.left + scrollLeft + (hostRect.width - tooltipRect.width) / 2;
|
|
1407
|
+
break;
|
|
1408
|
+
case 'bottom':
|
|
1409
|
+
top = hostRect.bottom + scrollTop + gap;
|
|
1410
|
+
left = hostRect.left + scrollLeft + (hostRect.width - tooltipRect.width) / 2;
|
|
1411
|
+
break;
|
|
1412
|
+
case 'left':
|
|
1413
|
+
top = hostRect.top + scrollTop + (hostRect.height - tooltipRect.height) / 2;
|
|
1414
|
+
left = hostRect.left + scrollLeft - tooltipRect.width - gap;
|
|
1415
|
+
break;
|
|
1416
|
+
case 'right':
|
|
1417
|
+
top = hostRect.top + scrollTop + (hostRect.height - tooltipRect.height) / 2;
|
|
1418
|
+
left = hostRect.right + scrollLeft + gap;
|
|
1419
|
+
break;
|
|
1420
|
+
}
|
|
1421
|
+
this.renderer.setStyle(this.tooltipElement, 'top', `${top}px`);
|
|
1422
|
+
this.renderer.setStyle(this.tooltipElement, 'left', `${left}px`);
|
|
1423
|
+
}
|
|
1424
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1425
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "18.2.14", type: ElgTooltipDirective, isStandalone: true, selector: "[elgTooltip]", inputs: { elgTooltip: { classPropertyName: "elgTooltip", publicName: "elgTooltip", isSignal: true, isRequired: true, transformFunction: null }, elgTooltipPosition: { classPropertyName: "elgTooltipPosition", publicName: "elgTooltipPosition", isSignal: true, isRequired: false, transformFunction: null }, elgTooltipDelay: { classPropertyName: "elgTooltipDelay", publicName: "elgTooltipDelay", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "onMouseEnter()", "mouseleave": "onMouseLeave()", "focusin": "onMouseEnter()", "focusout": "onMouseLeave()" } }, ngImport: i0 });
|
|
1426
|
+
}
|
|
1427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTooltipDirective, decorators: [{
|
|
1428
|
+
type: Directive,
|
|
1429
|
+
args: [{
|
|
1430
|
+
selector: '[elgTooltip]',
|
|
1431
|
+
standalone: true,
|
|
1432
|
+
host: {
|
|
1433
|
+
'(mouseenter)': 'onMouseEnter()',
|
|
1434
|
+
'(mouseleave)': 'onMouseLeave()',
|
|
1435
|
+
'(focusin)': 'onMouseEnter()',
|
|
1436
|
+
'(focusout)': 'onMouseLeave()',
|
|
1437
|
+
},
|
|
1438
|
+
}]
|
|
1439
|
+
}] });
|
|
1440
|
+
|
|
1441
|
+
class ElgTabComponent {
|
|
1442
|
+
label = input.required();
|
|
1443
|
+
disabled = input(false);
|
|
1444
|
+
contentTemplate;
|
|
1445
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTabComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1446
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgTabComponent, isStandalone: true, selector: "elg-tab", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "contentTemplate", first: true, predicate: ["tabContent"], descendants: true, static: true }], ngImport: i0, template: `
|
|
1447
|
+
<ng-template #tabContent>
|
|
1448
|
+
<ng-content></ng-content>
|
|
1449
|
+
</ng-template>
|
|
1450
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1451
|
+
}
|
|
1452
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTabComponent, decorators: [{
|
|
1453
|
+
type: Component,
|
|
1454
|
+
args: [{
|
|
1455
|
+
selector: 'elg-tab',
|
|
1456
|
+
standalone: true,
|
|
1457
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1458
|
+
template: `
|
|
1459
|
+
<ng-template #tabContent>
|
|
1460
|
+
<ng-content></ng-content>
|
|
1461
|
+
</ng-template>
|
|
1462
|
+
`,
|
|
1463
|
+
}]
|
|
1464
|
+
}], propDecorators: { contentTemplate: [{
|
|
1465
|
+
type: ViewChild,
|
|
1466
|
+
args: ['tabContent', { static: true }]
|
|
1467
|
+
}] } });
|
|
1468
|
+
|
|
1469
|
+
class ElgTabGroupComponent {
|
|
1470
|
+
selectedIndexInput = input(0, { alias: 'selectedIndex' });
|
|
1471
|
+
selectedIndexChange = output();
|
|
1472
|
+
tabs;
|
|
1473
|
+
selectedIndex = signal(0);
|
|
1474
|
+
instanceId = Math.random().toString(36).substring(2, 9);
|
|
1475
|
+
ngAfterContentInit() {
|
|
1476
|
+
this.selectedIndex.set(this.selectedIndexInput());
|
|
1477
|
+
}
|
|
1478
|
+
selectTab(index) {
|
|
1479
|
+
const tab = this.tabs.get(index);
|
|
1480
|
+
if (tab && !tab.disabled()) {
|
|
1481
|
+
this.selectedIndex.set(index);
|
|
1482
|
+
this.selectedIndexChange.emit(index);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
onKeydown(event) {
|
|
1486
|
+
const target = event.target;
|
|
1487
|
+
if (!target.classList.contains('elg-tab-group__tab'))
|
|
1488
|
+
return;
|
|
1489
|
+
let newIndex = this.selectedIndex();
|
|
1490
|
+
const tabCount = this.tabs.length;
|
|
1491
|
+
switch (event.key) {
|
|
1492
|
+
case 'ArrowRight':
|
|
1493
|
+
event.preventDefault();
|
|
1494
|
+
newIndex = this.findNextEnabledTab(newIndex, 1, tabCount);
|
|
1495
|
+
break;
|
|
1496
|
+
case 'ArrowLeft':
|
|
1497
|
+
event.preventDefault();
|
|
1498
|
+
newIndex = this.findNextEnabledTab(newIndex, -1, tabCount);
|
|
1499
|
+
break;
|
|
1500
|
+
case 'Home':
|
|
1501
|
+
event.preventDefault();
|
|
1502
|
+
newIndex = this.findNextEnabledTab(-1, 1, tabCount);
|
|
1503
|
+
break;
|
|
1504
|
+
case 'End':
|
|
1505
|
+
event.preventDefault();
|
|
1506
|
+
newIndex = this.findNextEnabledTab(tabCount, -1, tabCount);
|
|
1507
|
+
break;
|
|
1508
|
+
default:
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
this.selectTab(newIndex);
|
|
1512
|
+
// Focus the new tab button
|
|
1513
|
+
const tabButtons = event.currentTarget.querySelectorAll('.elg-tab-group__tab');
|
|
1514
|
+
tabButtons[newIndex]?.focus();
|
|
1515
|
+
}
|
|
1516
|
+
findNextEnabledTab(current, direction, count) {
|
|
1517
|
+
let index = current + direction;
|
|
1518
|
+
while (index >= 0 && index < count) {
|
|
1519
|
+
const tab = this.tabs.get(index);
|
|
1520
|
+
if (tab && !tab.disabled()) {
|
|
1521
|
+
return index;
|
|
1522
|
+
}
|
|
1523
|
+
index += direction;
|
|
1524
|
+
}
|
|
1525
|
+
return current;
|
|
1526
|
+
}
|
|
1527
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTabGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1528
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgTabGroupComponent, isStandalone: true, selector: "elg-tab-group", inputs: { selectedIndexInput: { classPropertyName: "selectedIndexInput", publicName: "selectedIndex", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedIndexChange: "selectedIndexChange" }, host: { listeners: { "keydown": "onKeydown($event)" }, properties: { "class": "\"elg-tab-group\"" } }, queries: [{ propertyName: "tabs", predicate: ElgTabComponent }], ngImport: i0, template: `
|
|
1529
|
+
<div class="elg-tab-group__header" role="tablist">
|
|
1530
|
+
@for (tab of tabs; track $index) {
|
|
1531
|
+
<button
|
|
1532
|
+
class="elg-tab-group__tab"
|
|
1533
|
+
[class.elg-tab-group__tab--active]="selectedIndex() === $index"
|
|
1534
|
+
[class.elg-tab-group__tab--disabled]="tab.disabled()"
|
|
1535
|
+
[attr.role]="'tab'"
|
|
1536
|
+
[attr.aria-selected]="selectedIndex() === $index"
|
|
1537
|
+
[attr.aria-controls]="'elg-tabpanel-' + instanceId + '-' + $index"
|
|
1538
|
+
[attr.id]="'elg-tab-' + instanceId + '-' + $index"
|
|
1539
|
+
[attr.tabindex]="selectedIndex() === $index ? 0 : -1"
|
|
1540
|
+
[disabled]="tab.disabled()"
|
|
1541
|
+
(click)="selectTab($index)"
|
|
1542
|
+
>
|
|
1543
|
+
{{ tab.label() }}
|
|
1544
|
+
</button>
|
|
1545
|
+
}
|
|
1546
|
+
</div>
|
|
1547
|
+
<div
|
|
1548
|
+
class="elg-tab-group__content"
|
|
1549
|
+
[attr.role]="'tabpanel'"
|
|
1550
|
+
[attr.aria-labelledby]="'elg-tab-' + instanceId + '-' + selectedIndex()"
|
|
1551
|
+
[attr.id]="'elg-tabpanel-' + instanceId + '-' + selectedIndex()"
|
|
1552
|
+
>
|
|
1553
|
+
@if (tabs && tabs.length > 0 && tabs.get(selectedIndex()); as activeTab) {
|
|
1554
|
+
<ng-container [ngTemplateOutlet]="activeTab.contentTemplate"></ng-container>
|
|
1555
|
+
}
|
|
1556
|
+
</div>
|
|
1557
|
+
`, isInline: true, styles: [":host{display:block}.elg-tab-group__header{display:flex;border-bottom:var(--elg-tabs-border, 1px solid #e2e8f0);gap:var(--elg-tabs-gap, 0)}.elg-tab-group__tab{position:relative;padding:var(--elg-tabs-tab-padding, .75rem 1rem);font-size:var(--elg-tabs-font-size, .875rem);font-weight:var(--elg-tabs-font-weight, 500);color:var(--elg-tabs-inactive-color, #64748b);background:none;border:none;border-bottom:2px solid transparent;cursor:pointer;transition:color .15s ease,border-color .15s ease;outline:none;white-space:nowrap}.elg-tab-group__tab:hover:not(.elg-tab-group__tab--disabled){color:var(--elg-tabs-hover-color, #334155)}.elg-tab-group__tab:focus-visible{outline:2px solid var(--elg-tabs-focus-ring, #3b82f6);outline-offset:-2px;border-radius:2px}.elg-tab-group__tab--active{color:var(--elg-tabs-active-color, #1e293b);border-bottom-color:var(--elg-tabs-active-border-color, #3b82f6)}.elg-tab-group__tab--disabled{opacity:var(--elg-tabs-disabled-opacity, .5);cursor:not-allowed}.elg-tab-group__content{padding-top:var(--elg-tabs-content-padding, 1rem)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1558
|
+
}
|
|
1559
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTabGroupComponent, decorators: [{
|
|
1560
|
+
type: Component,
|
|
1561
|
+
args: [{ selector: 'elg-tab-group', standalone: true, imports: [NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1562
|
+
'[class]': '"elg-tab-group"',
|
|
1563
|
+
'(keydown)': 'onKeydown($event)',
|
|
1564
|
+
}, template: `
|
|
1565
|
+
<div class="elg-tab-group__header" role="tablist">
|
|
1566
|
+
@for (tab of tabs; track $index) {
|
|
1567
|
+
<button
|
|
1568
|
+
class="elg-tab-group__tab"
|
|
1569
|
+
[class.elg-tab-group__tab--active]="selectedIndex() === $index"
|
|
1570
|
+
[class.elg-tab-group__tab--disabled]="tab.disabled()"
|
|
1571
|
+
[attr.role]="'tab'"
|
|
1572
|
+
[attr.aria-selected]="selectedIndex() === $index"
|
|
1573
|
+
[attr.aria-controls]="'elg-tabpanel-' + instanceId + '-' + $index"
|
|
1574
|
+
[attr.id]="'elg-tab-' + instanceId + '-' + $index"
|
|
1575
|
+
[attr.tabindex]="selectedIndex() === $index ? 0 : -1"
|
|
1576
|
+
[disabled]="tab.disabled()"
|
|
1577
|
+
(click)="selectTab($index)"
|
|
1578
|
+
>
|
|
1579
|
+
{{ tab.label() }}
|
|
1580
|
+
</button>
|
|
1581
|
+
}
|
|
1582
|
+
</div>
|
|
1583
|
+
<div
|
|
1584
|
+
class="elg-tab-group__content"
|
|
1585
|
+
[attr.role]="'tabpanel'"
|
|
1586
|
+
[attr.aria-labelledby]="'elg-tab-' + instanceId + '-' + selectedIndex()"
|
|
1587
|
+
[attr.id]="'elg-tabpanel-' + instanceId + '-' + selectedIndex()"
|
|
1588
|
+
>
|
|
1589
|
+
@if (tabs && tabs.length > 0 && tabs.get(selectedIndex()); as activeTab) {
|
|
1590
|
+
<ng-container [ngTemplateOutlet]="activeTab.contentTemplate"></ng-container>
|
|
1591
|
+
}
|
|
1592
|
+
</div>
|
|
1593
|
+
`, styles: [":host{display:block}.elg-tab-group__header{display:flex;border-bottom:var(--elg-tabs-border, 1px solid #e2e8f0);gap:var(--elg-tabs-gap, 0)}.elg-tab-group__tab{position:relative;padding:var(--elg-tabs-tab-padding, .75rem 1rem);font-size:var(--elg-tabs-font-size, .875rem);font-weight:var(--elg-tabs-font-weight, 500);color:var(--elg-tabs-inactive-color, #64748b);background:none;border:none;border-bottom:2px solid transparent;cursor:pointer;transition:color .15s ease,border-color .15s ease;outline:none;white-space:nowrap}.elg-tab-group__tab:hover:not(.elg-tab-group__tab--disabled){color:var(--elg-tabs-hover-color, #334155)}.elg-tab-group__tab:focus-visible{outline:2px solid var(--elg-tabs-focus-ring, #3b82f6);outline-offset:-2px;border-radius:2px}.elg-tab-group__tab--active{color:var(--elg-tabs-active-color, #1e293b);border-bottom-color:var(--elg-tabs-active-border-color, #3b82f6)}.elg-tab-group__tab--disabled{opacity:var(--elg-tabs-disabled-opacity, .5);cursor:not-allowed}.elg-tab-group__content{padding-top:var(--elg-tabs-content-padding, 1rem)}\n"] }]
|
|
1594
|
+
}], propDecorators: { tabs: [{
|
|
1595
|
+
type: ContentChildren,
|
|
1596
|
+
args: [ElgTabComponent]
|
|
1597
|
+
}] } });
|
|
1598
|
+
|
|
1599
|
+
class ElgAccordionItemComponent {
|
|
1600
|
+
title = input.required();
|
|
1601
|
+
expanded = input(false);
|
|
1602
|
+
disabled = input(false);
|
|
1603
|
+
expandedChange = output();
|
|
1604
|
+
isExpanded = signal(false);
|
|
1605
|
+
itemId = Math.random().toString(36).substring(2, 9);
|
|
1606
|
+
ngOnInit() {
|
|
1607
|
+
this.isExpanded.set(this.expanded());
|
|
1608
|
+
}
|
|
1609
|
+
ngOnChanges() {
|
|
1610
|
+
this.isExpanded.set(this.expanded());
|
|
1611
|
+
}
|
|
1612
|
+
toggle() {
|
|
1613
|
+
if (this.disabled())
|
|
1614
|
+
return;
|
|
1615
|
+
const newState = !this.isExpanded();
|
|
1616
|
+
this.isExpanded.set(newState);
|
|
1617
|
+
this.expandedChange.emit(newState);
|
|
1618
|
+
}
|
|
1619
|
+
expand() {
|
|
1620
|
+
if (this.disabled())
|
|
1621
|
+
return;
|
|
1622
|
+
this.isExpanded.set(true);
|
|
1623
|
+
this.expandedChange.emit(true);
|
|
1624
|
+
}
|
|
1625
|
+
collapse() {
|
|
1626
|
+
this.isExpanded.set(false);
|
|
1627
|
+
this.expandedChange.emit(false);
|
|
1628
|
+
}
|
|
1629
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgAccordionItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1630
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgAccordionItemComponent, isStandalone: true, selector: "elg-accordion-item", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: true, transformFunction: null }, expanded: { classPropertyName: "expanded", publicName: "expanded", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { expandedChange: "expandedChange" }, host: { properties: { "class": "\"elg-accordion-item\"", "class.elg-accordion-item--expanded": "isExpanded()", "class.elg-accordion-item--disabled": "disabled()" } }, usesOnChanges: true, ngImport: i0, template: `
|
|
1631
|
+
<button
|
|
1632
|
+
class="elg-accordion-item__header"
|
|
1633
|
+
[attr.aria-expanded]="isExpanded()"
|
|
1634
|
+
[attr.aria-controls]="'elg-accordion-content-' + itemId"
|
|
1635
|
+
[attr.id]="'elg-accordion-header-' + itemId"
|
|
1636
|
+
[disabled]="disabled()"
|
|
1637
|
+
(click)="toggle()"
|
|
1638
|
+
>
|
|
1639
|
+
<span class="elg-accordion-item__title">{{ title() }}</span>
|
|
1640
|
+
<span class="elg-accordion-item__chevron">
|
|
1641
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1642
|
+
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1643
|
+
</svg>
|
|
1644
|
+
</span>
|
|
1645
|
+
</button>
|
|
1646
|
+
<div
|
|
1647
|
+
class="elg-accordion-item__content"
|
|
1648
|
+
[attr.role]="'region'"
|
|
1649
|
+
[attr.aria-labelledby]="'elg-accordion-header-' + itemId"
|
|
1650
|
+
[attr.id]="'elg-accordion-content-' + itemId"
|
|
1651
|
+
>
|
|
1652
|
+
<div class="elg-accordion-item__body">
|
|
1653
|
+
<ng-content></ng-content>
|
|
1654
|
+
</div>
|
|
1655
|
+
</div>
|
|
1656
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1657
|
+
}
|
|
1658
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgAccordionItemComponent, decorators: [{
|
|
1659
|
+
type: Component,
|
|
1660
|
+
args: [{
|
|
1661
|
+
selector: 'elg-accordion-item',
|
|
1662
|
+
standalone: true,
|
|
1663
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1664
|
+
host: {
|
|
1665
|
+
'[class]': '"elg-accordion-item"',
|
|
1666
|
+
'[class.elg-accordion-item--expanded]': 'isExpanded()',
|
|
1667
|
+
'[class.elg-accordion-item--disabled]': 'disabled()',
|
|
1668
|
+
},
|
|
1669
|
+
template: `
|
|
1670
|
+
<button
|
|
1671
|
+
class="elg-accordion-item__header"
|
|
1672
|
+
[attr.aria-expanded]="isExpanded()"
|
|
1673
|
+
[attr.aria-controls]="'elg-accordion-content-' + itemId"
|
|
1674
|
+
[attr.id]="'elg-accordion-header-' + itemId"
|
|
1675
|
+
[disabled]="disabled()"
|
|
1676
|
+
(click)="toggle()"
|
|
1677
|
+
>
|
|
1678
|
+
<span class="elg-accordion-item__title">{{ title() }}</span>
|
|
1679
|
+
<span class="elg-accordion-item__chevron">
|
|
1680
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1681
|
+
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1682
|
+
</svg>
|
|
1683
|
+
</span>
|
|
1684
|
+
</button>
|
|
1685
|
+
<div
|
|
1686
|
+
class="elg-accordion-item__content"
|
|
1687
|
+
[attr.role]="'region'"
|
|
1688
|
+
[attr.aria-labelledby]="'elg-accordion-header-' + itemId"
|
|
1689
|
+
[attr.id]="'elg-accordion-content-' + itemId"
|
|
1690
|
+
>
|
|
1691
|
+
<div class="elg-accordion-item__body">
|
|
1692
|
+
<ng-content></ng-content>
|
|
1693
|
+
</div>
|
|
1694
|
+
</div>
|
|
1695
|
+
`,
|
|
1696
|
+
}]
|
|
1697
|
+
}] });
|
|
1698
|
+
|
|
1699
|
+
class ElgAccordionComponent {
|
|
1700
|
+
multi = input(false);
|
|
1701
|
+
items;
|
|
1702
|
+
ngAfterContentInit() {
|
|
1703
|
+
this.items.forEach(item => {
|
|
1704
|
+
item.expandedChange.subscribe((expanded) => {
|
|
1705
|
+
if (expanded && !this.multi()) {
|
|
1706
|
+
this.collapseAllExcept(item);
|
|
1707
|
+
}
|
|
1708
|
+
});
|
|
1709
|
+
});
|
|
1710
|
+
this.items.changes.subscribe((items) => {
|
|
1711
|
+
items.forEach(item => {
|
|
1712
|
+
item.expandedChange.subscribe((expanded) => {
|
|
1713
|
+
if (expanded && !this.multi()) {
|
|
1714
|
+
this.collapseAllExcept(item);
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1717
|
+
});
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
collapseAllExcept(except) {
|
|
1721
|
+
this.items.forEach(item => {
|
|
1722
|
+
if (item !== except && item.isExpanded()) {
|
|
1723
|
+
item.collapse();
|
|
1724
|
+
}
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1727
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgAccordionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1728
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgAccordionComponent, isStandalone: true, selector: "elg-accordion", inputs: { multi: { classPropertyName: "multi", publicName: "multi", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "\"elg-accordion\"" } }, queries: [{ propertyName: "items", predicate: ElgAccordionItemComponent }], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [":host{display:block}::ng-deep .elg-accordion-item{display:block;border-bottom:var(--elg-accordion-border, 1px solid #e2e8f0)}::ng-deep .elg-accordion-item:last-child{border-bottom:none}::ng-deep .elg-accordion-item__header{display:flex;align-items:center;justify-content:space-between;width:100%;padding:var(--elg-accordion-header-padding, .875rem 0);font-size:var(--elg-accordion-font-size, .9375rem);font-weight:var(--elg-accordion-font-weight, 500);color:var(--elg-accordion-header-color, #1a202c);background:none;border:none;cursor:pointer;outline:none;text-align:left;transition:color .15s ease}::ng-deep .elg-accordion-item__header:hover:not(:disabled){color:var(--elg-accordion-header-hover-color, #3b82f6)}::ng-deep .elg-accordion-item__header:focus-visible{outline:2px solid var(--elg-accordion-focus-ring, #3b82f6);outline-offset:2px;border-radius:2px}::ng-deep .elg-accordion-item__chevron{display:flex;align-items:center;justify-content:center;transition:transform .2s ease;color:var(--elg-accordion-chevron-color, #64748b)}::ng-deep .elg-accordion-item--expanded .elg-accordion-item__chevron{transform:rotate(180deg)}::ng-deep .elg-accordion-item__content{height:0;overflow:hidden;transition:height .2s ease}::ng-deep .elg-accordion-item--expanded .elg-accordion-item__content{height:auto}::ng-deep .elg-accordion-item__body{padding:var(--elg-accordion-content-padding, 0 0 .875rem 0);font-size:var(--elg-accordion-content-font-size, .875rem);color:var(--elg-accordion-content-color, #475569);line-height:1.6}::ng-deep .elg-accordion-item--disabled .elg-accordion-item__header{opacity:var(--elg-accordion-disabled-opacity, .5);cursor:default}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1729
|
+
}
|
|
1730
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgAccordionComponent, decorators: [{
|
|
1731
|
+
type: Component,
|
|
1732
|
+
args: [{ selector: 'elg-accordion', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1733
|
+
'[class]': '"elg-accordion"',
|
|
1734
|
+
}, template: `<ng-content></ng-content>`, styles: [":host{display:block}::ng-deep .elg-accordion-item{display:block;border-bottom:var(--elg-accordion-border, 1px solid #e2e8f0)}::ng-deep .elg-accordion-item:last-child{border-bottom:none}::ng-deep .elg-accordion-item__header{display:flex;align-items:center;justify-content:space-between;width:100%;padding:var(--elg-accordion-header-padding, .875rem 0);font-size:var(--elg-accordion-font-size, .9375rem);font-weight:var(--elg-accordion-font-weight, 500);color:var(--elg-accordion-header-color, #1a202c);background:none;border:none;cursor:pointer;outline:none;text-align:left;transition:color .15s ease}::ng-deep .elg-accordion-item__header:hover:not(:disabled){color:var(--elg-accordion-header-hover-color, #3b82f6)}::ng-deep .elg-accordion-item__header:focus-visible{outline:2px solid var(--elg-accordion-focus-ring, #3b82f6);outline-offset:2px;border-radius:2px}::ng-deep .elg-accordion-item__chevron{display:flex;align-items:center;justify-content:center;transition:transform .2s ease;color:var(--elg-accordion-chevron-color, #64748b)}::ng-deep .elg-accordion-item--expanded .elg-accordion-item__chevron{transform:rotate(180deg)}::ng-deep .elg-accordion-item__content{height:0;overflow:hidden;transition:height .2s ease}::ng-deep .elg-accordion-item--expanded .elg-accordion-item__content{height:auto}::ng-deep .elg-accordion-item__body{padding:var(--elg-accordion-content-padding, 0 0 .875rem 0);font-size:var(--elg-accordion-content-font-size, .875rem);color:var(--elg-accordion-content-color, #475569);line-height:1.6}::ng-deep .elg-accordion-item--disabled .elg-accordion-item__header{opacity:var(--elg-accordion-disabled-opacity, .5);cursor:default}\n"] }]
|
|
1735
|
+
}], propDecorators: { items: [{
|
|
1736
|
+
type: ContentChildren,
|
|
1737
|
+
args: [ElgAccordionItemComponent]
|
|
1738
|
+
}] } });
|
|
1739
|
+
|
|
1740
|
+
class ElgTableComponent {
|
|
1741
|
+
// Inputs
|
|
1742
|
+
dataSource = input([]);
|
|
1743
|
+
columns = input([]);
|
|
1744
|
+
sortable = input(true);
|
|
1745
|
+
selectable = input(false);
|
|
1746
|
+
striped = input(false);
|
|
1747
|
+
loading = input(false);
|
|
1748
|
+
virtualScroll = input(false);
|
|
1749
|
+
rowHeight = input(40);
|
|
1750
|
+
maxHeight = input("600px");
|
|
1751
|
+
emptyText = input('No data available');
|
|
1752
|
+
stickyHeader = input(false);
|
|
1753
|
+
// Outputs
|
|
1754
|
+
sortChange = output();
|
|
1755
|
+
selectionChange = output();
|
|
1756
|
+
rowClick = output();
|
|
1757
|
+
// Internal state
|
|
1758
|
+
currentSort = signal({ column: '', direction: null });
|
|
1759
|
+
selectedRows = signal(new Set());
|
|
1760
|
+
// Computed
|
|
1761
|
+
totalColumns = computed(() => {
|
|
1762
|
+
return this.columns().length + (this.selectable() ? 1 : 0);
|
|
1763
|
+
});
|
|
1764
|
+
allSelected = computed(() => {
|
|
1765
|
+
const data = this.dataSource();
|
|
1766
|
+
const selected = this.selectedRows();
|
|
1767
|
+
return data.length > 0 && data.every((row) => selected.has(row));
|
|
1768
|
+
});
|
|
1769
|
+
someSelected = computed(() => {
|
|
1770
|
+
const data = this.dataSource();
|
|
1771
|
+
const selected = this.selectedRows();
|
|
1772
|
+
const selectedCount = data.filter((row) => selected.has(row)).length;
|
|
1773
|
+
return selectedCount > 0 && selectedCount < data.length;
|
|
1774
|
+
});
|
|
1775
|
+
// Skeleton rows for loading state
|
|
1776
|
+
skeletonRows = Array.from({ length: 5 });
|
|
1777
|
+
isSortableColumn(col) {
|
|
1778
|
+
return this.sortable() && col.sortable !== false;
|
|
1779
|
+
}
|
|
1780
|
+
onSortClick(col) {
|
|
1781
|
+
const current = this.currentSort();
|
|
1782
|
+
let direction;
|
|
1783
|
+
if (current.column !== col.key) {
|
|
1784
|
+
direction = 'asc';
|
|
1785
|
+
}
|
|
1786
|
+
else if (current.direction === 'asc') {
|
|
1787
|
+
direction = 'desc';
|
|
1788
|
+
}
|
|
1789
|
+
else {
|
|
1790
|
+
direction = null;
|
|
1791
|
+
}
|
|
1792
|
+
const newSort = { column: direction ? col.key : '', direction };
|
|
1793
|
+
this.currentSort.set(newSort);
|
|
1794
|
+
this.sortChange.emit({ column: col.key, direction });
|
|
1795
|
+
}
|
|
1796
|
+
isRowSelected(row) {
|
|
1797
|
+
return this.selectedRows().has(row);
|
|
1798
|
+
}
|
|
1799
|
+
toggleRowSelection(row) {
|
|
1800
|
+
const selected = new Set(this.selectedRows());
|
|
1801
|
+
if (selected.has(row)) {
|
|
1802
|
+
selected.delete(row);
|
|
1803
|
+
}
|
|
1804
|
+
else {
|
|
1805
|
+
selected.add(row);
|
|
1806
|
+
}
|
|
1807
|
+
this.selectedRows.set(selected);
|
|
1808
|
+
this.selectionChange.emit(Array.from(selected));
|
|
1809
|
+
}
|
|
1810
|
+
toggleSelectAll(event) {
|
|
1811
|
+
const target = event.target;
|
|
1812
|
+
const selected = new Set();
|
|
1813
|
+
if (target.checked) {
|
|
1814
|
+
this.dataSource().forEach((row) => selected.add(row));
|
|
1815
|
+
}
|
|
1816
|
+
this.selectedRows.set(selected);
|
|
1817
|
+
this.selectionChange.emit(Array.from(selected));
|
|
1818
|
+
}
|
|
1819
|
+
onRowClick(row) {
|
|
1820
|
+
this.rowClick.emit(row);
|
|
1821
|
+
}
|
|
1822
|
+
getNestedValue(obj, path) {
|
|
1823
|
+
return path.split('.').reduce((acc, key) => acc?.[key], obj) ?? '';
|
|
1824
|
+
}
|
|
1825
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1826
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgTableComponent, isStandalone: true, selector: "elg-table", inputs: { dataSource: { classPropertyName: "dataSource", publicName: "dataSource", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, sortable: { classPropertyName: "sortable", publicName: "sortable", isSignal: true, isRequired: false, transformFunction: null }, selectable: { classPropertyName: "selectable", publicName: "selectable", isSignal: true, isRequired: false, transformFunction: null }, striped: { classPropertyName: "striped", publicName: "striped", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, virtualScroll: { classPropertyName: "virtualScroll", publicName: "virtualScroll", isSignal: true, isRequired: false, transformFunction: null }, rowHeight: { classPropertyName: "rowHeight", publicName: "rowHeight", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", isSignal: true, isRequired: false, transformFunction: null }, stickyHeader: { classPropertyName: "stickyHeader", publicName: "stickyHeader", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sortChange: "sortChange", selectionChange: "selectionChange", rowClick: "rowClick" }, host: { properties: { "class": "\"elg-table-wrapper\"", "class.elg-table--striped": "striped()", "class.elg-table--sticky-header": "stickyHeader()", "class.elg-table--selectable": "selectable()" } }, ngImport: i0, template: `
|
|
1827
|
+
<div class="elg-table__scroll-container">
|
|
1828
|
+
<table class="elg-table">
|
|
1829
|
+
<thead class="elg-table__head">
|
|
1830
|
+
<tr class="elg-table__header-row">
|
|
1831
|
+
@if (selectable()) {
|
|
1832
|
+
<th class="elg-table__header-cell elg-table__header-cell--checkbox">
|
|
1833
|
+
<input
|
|
1834
|
+
type="checkbox"
|
|
1835
|
+
class="elg-table__checkbox"
|
|
1836
|
+
[checked]="allSelected()"
|
|
1837
|
+
[indeterminate]="someSelected()"
|
|
1838
|
+
(change)="toggleSelectAll($event)"
|
|
1839
|
+
/>
|
|
1840
|
+
</th>
|
|
1841
|
+
}
|
|
1842
|
+
@for (col of columns(); track col.key) {
|
|
1843
|
+
<th
|
|
1844
|
+
class="elg-table__header-cell"
|
|
1845
|
+
[class.elg-table__header-cell--sortable]="isSortableColumn(col)"
|
|
1846
|
+
[class.elg-table__header-cell--sorted]="currentSort().column === col.key"
|
|
1847
|
+
[class.elg-table__header-cell--sticky]="col.sticky"
|
|
1848
|
+
[class.elg-table__header-cell--align-center]="col.align === 'center'"
|
|
1849
|
+
[class.elg-table__header-cell--align-right]="col.align === 'right'"
|
|
1850
|
+
[style.width]="col.width || null"
|
|
1851
|
+
(click)="isSortableColumn(col) ? onSortClick(col) : null"
|
|
1852
|
+
>
|
|
1853
|
+
@if (col.headerTemplate) {
|
|
1854
|
+
<ng-container *ngTemplateOutlet="col.headerTemplate; context: { $implicit: col }"></ng-container>
|
|
1855
|
+
} @else {
|
|
1856
|
+
<span class="elg-table__header-text">{{ col.header }}</span>
|
|
1857
|
+
}
|
|
1858
|
+
@if (isSortableColumn(col)) {
|
|
1859
|
+
<span class="elg-table__sort-indicator">
|
|
1860
|
+
<span
|
|
1861
|
+
class="elg-table__sort-arrow elg-table__sort-arrow--asc"
|
|
1862
|
+
[class.elg-table__sort-arrow--active]="currentSort().column === col.key && currentSort().direction === 'asc'"
|
|
1863
|
+
>▲</span>
|
|
1864
|
+
<span
|
|
1865
|
+
class="elg-table__sort-arrow elg-table__sort-arrow--desc"
|
|
1866
|
+
[class.elg-table__sort-arrow--active]="currentSort().column === col.key && currentSort().direction === 'desc'"
|
|
1867
|
+
>▼</span>
|
|
1868
|
+
</span>
|
|
1869
|
+
}
|
|
1870
|
+
</th>
|
|
1871
|
+
}
|
|
1872
|
+
</tr>
|
|
1873
|
+
</thead>
|
|
1874
|
+
<tbody class="elg-table__body">
|
|
1875
|
+
@if (loading()) {
|
|
1876
|
+
@for (row of skeletonRows; track $index) {
|
|
1877
|
+
<tr class="elg-table__row elg-table__row--skeleton">
|
|
1878
|
+
@if (selectable()) {
|
|
1879
|
+
<td class="elg-table__cell elg-table__cell--checkbox">
|
|
1880
|
+
<span class="elg-table__skeleton-box elg-table__skeleton-box--checkbox"></span>
|
|
1881
|
+
</td>
|
|
1882
|
+
}
|
|
1883
|
+
@for (col of columns(); track col.key) {
|
|
1884
|
+
<td class="elg-table__cell">
|
|
1885
|
+
<span class="elg-table__skeleton-box"></span>
|
|
1886
|
+
</td>
|
|
1887
|
+
}
|
|
1888
|
+
</tr>
|
|
1889
|
+
}
|
|
1890
|
+
} @else if (dataSource().length === 0) {
|
|
1891
|
+
<tr class="elg-table__row elg-table__row--empty">
|
|
1892
|
+
<td
|
|
1893
|
+
class="elg-table__cell elg-table__empty-cell"
|
|
1894
|
+
[attr.colspan]="totalColumns()"
|
|
1895
|
+
>
|
|
1896
|
+
{{ emptyText() }}
|
|
1897
|
+
</td>
|
|
1898
|
+
</tr>
|
|
1899
|
+
} @else {
|
|
1900
|
+
@for (row of dataSource(); track $index) {
|
|
1901
|
+
<tr
|
|
1902
|
+
class="elg-table__row"
|
|
1903
|
+
[class.elg-table__row--selected]="isRowSelected(row)"
|
|
1904
|
+
(click)="onRowClick(row)"
|
|
1905
|
+
>
|
|
1906
|
+
@if (selectable()) {
|
|
1907
|
+
<td class="elg-table__cell elg-table__cell--checkbox">
|
|
1908
|
+
<input
|
|
1909
|
+
type="checkbox"
|
|
1910
|
+
class="elg-table__checkbox"
|
|
1911
|
+
[checked]="isRowSelected(row)"
|
|
1912
|
+
(click)="$event.stopPropagation()"
|
|
1913
|
+
(change)="toggleRowSelection(row)"
|
|
1914
|
+
/>
|
|
1915
|
+
</td>
|
|
1916
|
+
}
|
|
1917
|
+
@for (col of columns(); track col.key) {
|
|
1918
|
+
<td
|
|
1919
|
+
class="elg-table__cell"
|
|
1920
|
+
[class.elg-table__cell--sticky]="col.sticky"
|
|
1921
|
+
[class.elg-table__cell--align-center]="col.align === 'center'"
|
|
1922
|
+
[class.elg-table__cell--align-right]="col.align === 'right'"
|
|
1923
|
+
>
|
|
1924
|
+
@if (col.cellTemplate) {
|
|
1925
|
+
<ng-container *ngTemplateOutlet="col.cellTemplate; context: { $implicit: row[col.key], row: row, column: col }"></ng-container>
|
|
1926
|
+
} @else {
|
|
1927
|
+
{{ getNestedValue(row, col.key) }}
|
|
1928
|
+
}
|
|
1929
|
+
</td>
|
|
1930
|
+
}
|
|
1931
|
+
</tr>
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
</tbody>
|
|
1935
|
+
</table>
|
|
1936
|
+
</div>
|
|
1937
|
+
`, isInline: true, styles: [":host{--elg-table-border-color: var(--elg-color-border, #e2e8f0);--elg-table-header-bg: var(--elg-color-surface-alt, #f8fafc);--elg-table-header-fg: var(--elg-color-text-secondary, #475569);--elg-table-header-font-size: .75rem;--elg-table-header-font-weight: 600;--elg-table-header-padding: .75rem 1rem;--elg-table-cell-padding: .75rem 1rem;--elg-table-cell-font-size: .875rem;--elg-table-row-hover-bg: var(--elg-color-surface-hover, #f1f5f9);--elg-table-row-selected-bg: var(--elg-color-primary-50, #eff6ff);--elg-table-row-striped-bg: var(--elg-color-surface-alt, #f8fafc);--elg-table-sort-active-color: var(--elg-color-primary, #3b82f6);--elg-table-sort-inactive-color: var(--elg-color-text-disabled, #cbd5e1);--elg-table-empty-color: var(--elg-color-text-secondary, #64748b);--elg-table-skeleton-bg: var(--elg-color-surface-alt, #e2e8f0);--elg-table-skeleton-shine: var(--elg-color-surface, #f8fafc);--elg-table-radius: var(--elg-radius-md, .5rem);--elg-table-checkbox-size: 1rem;display:block;width:100%}.elg-table__scroll-container{overflow-x:auto;border:1px solid var(--elg-table-border-color);border-radius:var(--elg-table-radius)}.elg-table{width:100%;border-collapse:collapse;border-spacing:0;font-size:var(--elg-table-cell-font-size)}.elg-table__head{background:var(--elg-table-header-bg)}:host(.elg-table--sticky-header) .elg-table__head{position:sticky;top:0;z-index:10}.elg-table__header-row{border-bottom:1px solid var(--elg-table-border-color)}.elg-table__header-cell{padding:var(--elg-table-header-padding);font-size:var(--elg-table-header-font-size);font-weight:var(--elg-table-header-font-weight);color:var(--elg-table-header-fg);text-align:left;text-transform:uppercase;letter-spacing:.05em;white-space:nowrap;-webkit-user-select:none;user-select:none;position:relative}.elg-table__header-cell--sortable{cursor:pointer;transition:background-color .15s ease}.elg-table__header-cell--sortable:hover{background:var(--elg-table-row-hover-bg)}.elg-table__header-cell--align-center{text-align:center}.elg-table__header-cell--align-right{text-align:right}.elg-table__header-cell--checkbox{width:3rem;text-align:center;padding-left:.75rem;padding-right:.5rem}.elg-table__header-cell--sticky{position:sticky;left:0;z-index:5;background:var(--elg-table-header-bg)}.elg-table__sort-indicator{display:inline-flex;flex-direction:column;margin-left:.375rem;line-height:1;vertical-align:middle;gap:0}.elg-table__sort-arrow{font-size:.5rem;line-height:.625rem;color:var(--elg-table-sort-inactive-color);transition:color .15s ease}.elg-table__sort-arrow--active{color:var(--elg-table-sort-active-color)}.elg-table__row{border-bottom:1px solid var(--elg-table-border-color);transition:background-color .15s ease}.elg-table__row:last-child{border-bottom:none}.elg-table__row:hover:not(.elg-table__row--empty):not(.elg-table__row--skeleton){background:var(--elg-table-row-hover-bg)}.elg-table__row--selected{background:var(--elg-table-row-selected-bg)!important}:host(.elg-table--striped) .elg-table__body .elg-table__row:nth-child(2n):not(.elg-table__row--selected){background:var(--elg-table-row-striped-bg)}.elg-table__cell{padding:var(--elg-table-cell-padding);color:var(--elg-color-text, #1e293b);vertical-align:middle}.elg-table__cell--align-center{text-align:center}.elg-table__cell--align-right{text-align:right}.elg-table__cell--checkbox{width:3rem;text-align:center;padding-left:.75rem;padding-right:.5rem}.elg-table__cell--sticky{position:sticky;left:0;z-index:3;background:inherit}.elg-table__empty-cell{text-align:center;padding:3rem 1rem;color:var(--elg-table-empty-color);font-style:italic}.elg-table__checkbox{width:var(--elg-table-checkbox-size);height:var(--elg-table-checkbox-size);cursor:pointer;accent-color:var(--elg-color-primary, #3b82f6);border-radius:.25rem}.elg-table__row--skeleton{pointer-events:none}.elg-table__skeleton-box{display:block;height:1rem;border-radius:.25rem;background:linear-gradient(90deg,var(--elg-table-skeleton-bg) 25%,var(--elg-table-skeleton-shine) 50%,var(--elg-table-skeleton-bg) 75%);background-size:200% 100%;animation:elg-table-shimmer 1.5s infinite}.elg-table__skeleton-box--checkbox{width:var(--elg-table-checkbox-size);height:var(--elg-table-checkbox-size);margin:0 auto;border-radius:.25rem}@keyframes elg-table-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}:host(.elg-table--selectable) .elg-table__row:not(.elg-table__row--empty):not(.elg-table__row--skeleton){cursor:pointer}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1938
|
+
}
|
|
1939
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTableComponent, decorators: [{
|
|
1940
|
+
type: Component,
|
|
1941
|
+
args: [{ selector: 'elg-table', standalone: true, imports: [NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1942
|
+
'[class]': '"elg-table-wrapper"',
|
|
1943
|
+
'[class.elg-table--striped]': 'striped()',
|
|
1944
|
+
'[class.elg-table--sticky-header]': 'stickyHeader()',
|
|
1945
|
+
'[class.elg-table--selectable]': 'selectable()',
|
|
1946
|
+
}, template: `
|
|
1947
|
+
<div class="elg-table__scroll-container">
|
|
1948
|
+
<table class="elg-table">
|
|
1949
|
+
<thead class="elg-table__head">
|
|
1950
|
+
<tr class="elg-table__header-row">
|
|
1951
|
+
@if (selectable()) {
|
|
1952
|
+
<th class="elg-table__header-cell elg-table__header-cell--checkbox">
|
|
1953
|
+
<input
|
|
1954
|
+
type="checkbox"
|
|
1955
|
+
class="elg-table__checkbox"
|
|
1956
|
+
[checked]="allSelected()"
|
|
1957
|
+
[indeterminate]="someSelected()"
|
|
1958
|
+
(change)="toggleSelectAll($event)"
|
|
1959
|
+
/>
|
|
1960
|
+
</th>
|
|
1961
|
+
}
|
|
1962
|
+
@for (col of columns(); track col.key) {
|
|
1963
|
+
<th
|
|
1964
|
+
class="elg-table__header-cell"
|
|
1965
|
+
[class.elg-table__header-cell--sortable]="isSortableColumn(col)"
|
|
1966
|
+
[class.elg-table__header-cell--sorted]="currentSort().column === col.key"
|
|
1967
|
+
[class.elg-table__header-cell--sticky]="col.sticky"
|
|
1968
|
+
[class.elg-table__header-cell--align-center]="col.align === 'center'"
|
|
1969
|
+
[class.elg-table__header-cell--align-right]="col.align === 'right'"
|
|
1970
|
+
[style.width]="col.width || null"
|
|
1971
|
+
(click)="isSortableColumn(col) ? onSortClick(col) : null"
|
|
1972
|
+
>
|
|
1973
|
+
@if (col.headerTemplate) {
|
|
1974
|
+
<ng-container *ngTemplateOutlet="col.headerTemplate; context: { $implicit: col }"></ng-container>
|
|
1975
|
+
} @else {
|
|
1976
|
+
<span class="elg-table__header-text">{{ col.header }}</span>
|
|
1977
|
+
}
|
|
1978
|
+
@if (isSortableColumn(col)) {
|
|
1979
|
+
<span class="elg-table__sort-indicator">
|
|
1980
|
+
<span
|
|
1981
|
+
class="elg-table__sort-arrow elg-table__sort-arrow--asc"
|
|
1982
|
+
[class.elg-table__sort-arrow--active]="currentSort().column === col.key && currentSort().direction === 'asc'"
|
|
1983
|
+
>▲</span>
|
|
1984
|
+
<span
|
|
1985
|
+
class="elg-table__sort-arrow elg-table__sort-arrow--desc"
|
|
1986
|
+
[class.elg-table__sort-arrow--active]="currentSort().column === col.key && currentSort().direction === 'desc'"
|
|
1987
|
+
>▼</span>
|
|
1988
|
+
</span>
|
|
1989
|
+
}
|
|
1990
|
+
</th>
|
|
1991
|
+
}
|
|
1992
|
+
</tr>
|
|
1993
|
+
</thead>
|
|
1994
|
+
<tbody class="elg-table__body">
|
|
1995
|
+
@if (loading()) {
|
|
1996
|
+
@for (row of skeletonRows; track $index) {
|
|
1997
|
+
<tr class="elg-table__row elg-table__row--skeleton">
|
|
1998
|
+
@if (selectable()) {
|
|
1999
|
+
<td class="elg-table__cell elg-table__cell--checkbox">
|
|
2000
|
+
<span class="elg-table__skeleton-box elg-table__skeleton-box--checkbox"></span>
|
|
2001
|
+
</td>
|
|
2002
|
+
}
|
|
2003
|
+
@for (col of columns(); track col.key) {
|
|
2004
|
+
<td class="elg-table__cell">
|
|
2005
|
+
<span class="elg-table__skeleton-box"></span>
|
|
2006
|
+
</td>
|
|
2007
|
+
}
|
|
2008
|
+
</tr>
|
|
2009
|
+
}
|
|
2010
|
+
} @else if (dataSource().length === 0) {
|
|
2011
|
+
<tr class="elg-table__row elg-table__row--empty">
|
|
2012
|
+
<td
|
|
2013
|
+
class="elg-table__cell elg-table__empty-cell"
|
|
2014
|
+
[attr.colspan]="totalColumns()"
|
|
2015
|
+
>
|
|
2016
|
+
{{ emptyText() }}
|
|
2017
|
+
</td>
|
|
2018
|
+
</tr>
|
|
2019
|
+
} @else {
|
|
2020
|
+
@for (row of dataSource(); track $index) {
|
|
2021
|
+
<tr
|
|
2022
|
+
class="elg-table__row"
|
|
2023
|
+
[class.elg-table__row--selected]="isRowSelected(row)"
|
|
2024
|
+
(click)="onRowClick(row)"
|
|
2025
|
+
>
|
|
2026
|
+
@if (selectable()) {
|
|
2027
|
+
<td class="elg-table__cell elg-table__cell--checkbox">
|
|
2028
|
+
<input
|
|
2029
|
+
type="checkbox"
|
|
2030
|
+
class="elg-table__checkbox"
|
|
2031
|
+
[checked]="isRowSelected(row)"
|
|
2032
|
+
(click)="$event.stopPropagation()"
|
|
2033
|
+
(change)="toggleRowSelection(row)"
|
|
2034
|
+
/>
|
|
2035
|
+
</td>
|
|
2036
|
+
}
|
|
2037
|
+
@for (col of columns(); track col.key) {
|
|
2038
|
+
<td
|
|
2039
|
+
class="elg-table__cell"
|
|
2040
|
+
[class.elg-table__cell--sticky]="col.sticky"
|
|
2041
|
+
[class.elg-table__cell--align-center]="col.align === 'center'"
|
|
2042
|
+
[class.elg-table__cell--align-right]="col.align === 'right'"
|
|
2043
|
+
>
|
|
2044
|
+
@if (col.cellTemplate) {
|
|
2045
|
+
<ng-container *ngTemplateOutlet="col.cellTemplate; context: { $implicit: row[col.key], row: row, column: col }"></ng-container>
|
|
2046
|
+
} @else {
|
|
2047
|
+
{{ getNestedValue(row, col.key) }}
|
|
2048
|
+
}
|
|
2049
|
+
</td>
|
|
2050
|
+
}
|
|
2051
|
+
</tr>
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
</tbody>
|
|
2055
|
+
</table>
|
|
2056
|
+
</div>
|
|
2057
|
+
`, styles: [":host{--elg-table-border-color: var(--elg-color-border, #e2e8f0);--elg-table-header-bg: var(--elg-color-surface-alt, #f8fafc);--elg-table-header-fg: var(--elg-color-text-secondary, #475569);--elg-table-header-font-size: .75rem;--elg-table-header-font-weight: 600;--elg-table-header-padding: .75rem 1rem;--elg-table-cell-padding: .75rem 1rem;--elg-table-cell-font-size: .875rem;--elg-table-row-hover-bg: var(--elg-color-surface-hover, #f1f5f9);--elg-table-row-selected-bg: var(--elg-color-primary-50, #eff6ff);--elg-table-row-striped-bg: var(--elg-color-surface-alt, #f8fafc);--elg-table-sort-active-color: var(--elg-color-primary, #3b82f6);--elg-table-sort-inactive-color: var(--elg-color-text-disabled, #cbd5e1);--elg-table-empty-color: var(--elg-color-text-secondary, #64748b);--elg-table-skeleton-bg: var(--elg-color-surface-alt, #e2e8f0);--elg-table-skeleton-shine: var(--elg-color-surface, #f8fafc);--elg-table-radius: var(--elg-radius-md, .5rem);--elg-table-checkbox-size: 1rem;display:block;width:100%}.elg-table__scroll-container{overflow-x:auto;border:1px solid var(--elg-table-border-color);border-radius:var(--elg-table-radius)}.elg-table{width:100%;border-collapse:collapse;border-spacing:0;font-size:var(--elg-table-cell-font-size)}.elg-table__head{background:var(--elg-table-header-bg)}:host(.elg-table--sticky-header) .elg-table__head{position:sticky;top:0;z-index:10}.elg-table__header-row{border-bottom:1px solid var(--elg-table-border-color)}.elg-table__header-cell{padding:var(--elg-table-header-padding);font-size:var(--elg-table-header-font-size);font-weight:var(--elg-table-header-font-weight);color:var(--elg-table-header-fg);text-align:left;text-transform:uppercase;letter-spacing:.05em;white-space:nowrap;-webkit-user-select:none;user-select:none;position:relative}.elg-table__header-cell--sortable{cursor:pointer;transition:background-color .15s ease}.elg-table__header-cell--sortable:hover{background:var(--elg-table-row-hover-bg)}.elg-table__header-cell--align-center{text-align:center}.elg-table__header-cell--align-right{text-align:right}.elg-table__header-cell--checkbox{width:3rem;text-align:center;padding-left:.75rem;padding-right:.5rem}.elg-table__header-cell--sticky{position:sticky;left:0;z-index:5;background:var(--elg-table-header-bg)}.elg-table__sort-indicator{display:inline-flex;flex-direction:column;margin-left:.375rem;line-height:1;vertical-align:middle;gap:0}.elg-table__sort-arrow{font-size:.5rem;line-height:.625rem;color:var(--elg-table-sort-inactive-color);transition:color .15s ease}.elg-table__sort-arrow--active{color:var(--elg-table-sort-active-color)}.elg-table__row{border-bottom:1px solid var(--elg-table-border-color);transition:background-color .15s ease}.elg-table__row:last-child{border-bottom:none}.elg-table__row:hover:not(.elg-table__row--empty):not(.elg-table__row--skeleton){background:var(--elg-table-row-hover-bg)}.elg-table__row--selected{background:var(--elg-table-row-selected-bg)!important}:host(.elg-table--striped) .elg-table__body .elg-table__row:nth-child(2n):not(.elg-table__row--selected){background:var(--elg-table-row-striped-bg)}.elg-table__cell{padding:var(--elg-table-cell-padding);color:var(--elg-color-text, #1e293b);vertical-align:middle}.elg-table__cell--align-center{text-align:center}.elg-table__cell--align-right{text-align:right}.elg-table__cell--checkbox{width:3rem;text-align:center;padding-left:.75rem;padding-right:.5rem}.elg-table__cell--sticky{position:sticky;left:0;z-index:3;background:inherit}.elg-table__empty-cell{text-align:center;padding:3rem 1rem;color:var(--elg-table-empty-color);font-style:italic}.elg-table__checkbox{width:var(--elg-table-checkbox-size);height:var(--elg-table-checkbox-size);cursor:pointer;accent-color:var(--elg-color-primary, #3b82f6);border-radius:.25rem}.elg-table__row--skeleton{pointer-events:none}.elg-table__skeleton-box{display:block;height:1rem;border-radius:.25rem;background:linear-gradient(90deg,var(--elg-table-skeleton-bg) 25%,var(--elg-table-skeleton-shine) 50%,var(--elg-table-skeleton-bg) 75%);background-size:200% 100%;animation:elg-table-shimmer 1.5s infinite}.elg-table__skeleton-box--checkbox{width:var(--elg-table-checkbox-size);height:var(--elg-table-checkbox-size);margin:0 auto;border-radius:.25rem}@keyframes elg-table-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}:host(.elg-table--selectable) .elg-table__row:not(.elg-table__row--empty):not(.elg-table__row--skeleton){cursor:pointer}\n"] }]
|
|
2058
|
+
}] });
|
|
2059
|
+
|
|
2060
|
+
class ElgCardComponent {
|
|
2061
|
+
padding = input(undefined);
|
|
2062
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2063
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgCardComponent, isStandalone: true, selector: "elg-card", inputs: { padding: { classPropertyName: "padding", publicName: "padding", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
2064
|
+
<div class="elg-card" [style.padding]="padding()">
|
|
2065
|
+
<div class="elg-card__header">
|
|
2066
|
+
<ng-content select="[elgCardHeader]" />
|
|
2067
|
+
</div>
|
|
2068
|
+
<div class="elg-card__content">
|
|
2069
|
+
<ng-content select="[elgCardContent]" />
|
|
2070
|
+
<ng-content />
|
|
2071
|
+
</div>
|
|
2072
|
+
<div class="elg-card__footer">
|
|
2073
|
+
<ng-content select="[elgCardFooter]" />
|
|
2074
|
+
</div>
|
|
2075
|
+
</div>
|
|
2076
|
+
`, isInline: true, styles: [":host{display:block}.elg-card{background:var(--elg-card-background, #ffffff);border:var(--elg-card-border, 1px solid #e2e8f0);border-radius:var(--elg-card-border-radius, .5rem);padding:var(--elg-card-padding, 1.5rem);box-shadow:var(--elg-card-shadow, 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1))}.elg-card__header{display:flex;align-items:center;padding-bottom:var(--elg-card-header-padding-bottom, 1rem);border-bottom:var(--elg-card-header-border-bottom, none)}.elg-card__header:empty{display:none;padding-bottom:0}.elg-card__content{flex:1}.elg-card__footer{display:flex;align-items:center;justify-content:flex-end;padding-top:var(--elg-card-footer-padding-top, 1rem);border-top:var(--elg-card-footer-border-top, none);gap:.5rem}.elg-card__footer:empty{display:none;padding-top:0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2077
|
+
}
|
|
2078
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgCardComponent, decorators: [{
|
|
2079
|
+
type: Component,
|
|
2080
|
+
args: [{ selector: 'elg-card', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
2081
|
+
<div class="elg-card" [style.padding]="padding()">
|
|
2082
|
+
<div class="elg-card__header">
|
|
2083
|
+
<ng-content select="[elgCardHeader]" />
|
|
2084
|
+
</div>
|
|
2085
|
+
<div class="elg-card__content">
|
|
2086
|
+
<ng-content select="[elgCardContent]" />
|
|
2087
|
+
<ng-content />
|
|
2088
|
+
</div>
|
|
2089
|
+
<div class="elg-card__footer">
|
|
2090
|
+
<ng-content select="[elgCardFooter]" />
|
|
2091
|
+
</div>
|
|
2092
|
+
</div>
|
|
2093
|
+
`, styles: [":host{display:block}.elg-card{background:var(--elg-card-background, #ffffff);border:var(--elg-card-border, 1px solid #e2e8f0);border-radius:var(--elg-card-border-radius, .5rem);padding:var(--elg-card-padding, 1.5rem);box-shadow:var(--elg-card-shadow, 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1))}.elg-card__header{display:flex;align-items:center;padding-bottom:var(--elg-card-header-padding-bottom, 1rem);border-bottom:var(--elg-card-header-border-bottom, none)}.elg-card__header:empty{display:none;padding-bottom:0}.elg-card__content{flex:1}.elg-card__footer{display:flex;align-items:center;justify-content:flex-end;padding-top:var(--elg-card-footer-padding-top, 1rem);border-top:var(--elg-card-footer-border-top, none);gap:.5rem}.elg-card__footer:empty{display:none;padding-top:0}\n"] }]
|
|
2094
|
+
}] });
|
|
2095
|
+
|
|
2096
|
+
class ElgDialogComponent {
|
|
2097
|
+
elementRef = inject(ElementRef);
|
|
2098
|
+
destroyRef = inject(DestroyRef);
|
|
2099
|
+
previousFocus = null;
|
|
2100
|
+
title = input('');
|
|
2101
|
+
size = input('md');
|
|
2102
|
+
showClose = input(true);
|
|
2103
|
+
disableClose = input(false);
|
|
2104
|
+
closed = output();
|
|
2105
|
+
panelClasses = computed(() => {
|
|
2106
|
+
return `elg-dialog-panel elg-dialog-panel--${this.size()}`;
|
|
2107
|
+
});
|
|
2108
|
+
ngAfterViewInit() {
|
|
2109
|
+
this.previousFocus = document.activeElement;
|
|
2110
|
+
// Prevent body scroll while dialog is open
|
|
2111
|
+
document.body.style.overflow = 'hidden';
|
|
2112
|
+
this.destroyRef.onDestroy(() => {
|
|
2113
|
+
document.body.style.overflow = '';
|
|
2114
|
+
this.previousFocus?.focus();
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
ngOnDestroy() {
|
|
2118
|
+
document.body.style.overflow = '';
|
|
2119
|
+
this.previousFocus?.focus();
|
|
2120
|
+
}
|
|
2121
|
+
onEscape() {
|
|
2122
|
+
if (!this.disableClose()) {
|
|
2123
|
+
this.close();
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
onBackdropClick() {
|
|
2127
|
+
if (!this.disableClose()) {
|
|
2128
|
+
this.close();
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
close() {
|
|
2132
|
+
this.closed.emit();
|
|
2133
|
+
}
|
|
2134
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2135
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgDialogComponent, isStandalone: true, selector: "elg-dialog", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, showClose: { classPropertyName: "showClose", publicName: "showClose", isSignal: true, isRequired: false, transformFunction: null }, disableClose: { classPropertyName: "disableClose", publicName: "disableClose", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed" }, host: { listeners: { "document:keydown.escape": "onEscape()" } }, ngImport: i0, template: `
|
|
2136
|
+
<div class="elg-dialog-overlay" (click)="onBackdropClick()">
|
|
2137
|
+
<div
|
|
2138
|
+
class="elg-dialog-panel"
|
|
2139
|
+
[class]="panelClasses()"
|
|
2140
|
+
role="dialog"
|
|
2141
|
+
aria-modal="true"
|
|
2142
|
+
[attr.aria-labelledby]="title() ? 'elg-dialog-title' : null"
|
|
2143
|
+
(click)="$event.stopPropagation()"
|
|
2144
|
+
cdkTrapFocus
|
|
2145
|
+
cdkTrapFocusAutoCapture
|
|
2146
|
+
>
|
|
2147
|
+
<div class="elg-dialog-header">
|
|
2148
|
+
@if (title()) {
|
|
2149
|
+
<h2 id="elg-dialog-title" class="elg-dialog-title">{{ title() }}</h2>
|
|
2150
|
+
}
|
|
2151
|
+
@if (showClose()) {
|
|
2152
|
+
<button
|
|
2153
|
+
type="button"
|
|
2154
|
+
class="elg-dialog-close"
|
|
2155
|
+
aria-label="Close dialog"
|
|
2156
|
+
(click)="close()"
|
|
2157
|
+
>
|
|
2158
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2159
|
+
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
2160
|
+
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
2161
|
+
</svg>
|
|
2162
|
+
</button>
|
|
2163
|
+
}
|
|
2164
|
+
</div>
|
|
2165
|
+
<div class="elg-dialog-content">
|
|
2166
|
+
<ng-content select="[elgDialogContent]" />
|
|
2167
|
+
<ng-content />
|
|
2168
|
+
</div>
|
|
2169
|
+
<div class="elg-dialog-footer">
|
|
2170
|
+
<ng-content select="[elgDialogFooter]" />
|
|
2171
|
+
</div>
|
|
2172
|
+
</div>
|
|
2173
|
+
</div>
|
|
2174
|
+
`, isInline: true, styles: [":host{display:contents}.elg-dialog-overlay{position:fixed;inset:0;background:var(--elg-dialog-overlay-bg, rgb(0 0 0 / .5));z-index:var(--elg-dialog-z-index, 1000);display:flex;align-items:center;justify-content:center;padding:1rem;animation:elg-dialog-overlay-in .2s ease-out}.elg-dialog-panel{background:var(--elg-dialog-panel-bg, #ffffff);border-radius:var(--elg-dialog-border-radius, .75rem);box-shadow:var(--elg-dialog-shadow, 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1));padding:var(--elg-dialog-padding, 1.5rem);width:100%;max-height:calc(100vh - 2rem);overflow-y:auto;animation:elg-dialog-panel-in .2s ease-out}.elg-dialog-panel--sm{max-width:400px}.elg-dialog-panel--md{max-width:512px}.elg-dialog-panel--lg{max-width:640px}.elg-dialog-panel--xl{max-width:800px}.elg-dialog-panel--fullscreen{max-width:100vw;width:100vw;height:100vh;max-height:100vh;border-radius:0;margin:0}.elg-dialog-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem}.elg-dialog-title{font-size:1.125rem;font-weight:600;color:var(--elg-dialog-title-color, #1a202c);margin:0}.elg-dialog-close{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;border:none;background:transparent;border-radius:.375rem;cursor:pointer;color:var(--elg-dialog-close-color, #64748b);transition:background-color .15s,color .15s;margin-left:auto}.elg-dialog-close:hover{background:var(--elg-dialog-close-hover-bg, #f1f5f9);color:var(--elg-dialog-close-hover-color, #1e293b)}.elg-dialog-content{color:var(--elg-dialog-content-color, #334155)}.elg-dialog-footer{display:flex;align-items:center;justify-content:flex-end;gap:.5rem;margin-top:1.5rem}.elg-dialog-footer:empty{display:none;margin-top:0}@keyframes elg-dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes elg-dialog-panel-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2175
|
+
}
|
|
2176
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDialogComponent, decorators: [{
|
|
2177
|
+
type: Component,
|
|
2178
|
+
args: [{ selector: 'elg-dialog', standalone: true, imports: [A11yModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
2179
|
+
<div class="elg-dialog-overlay" (click)="onBackdropClick()">
|
|
2180
|
+
<div
|
|
2181
|
+
class="elg-dialog-panel"
|
|
2182
|
+
[class]="panelClasses()"
|
|
2183
|
+
role="dialog"
|
|
2184
|
+
aria-modal="true"
|
|
2185
|
+
[attr.aria-labelledby]="title() ? 'elg-dialog-title' : null"
|
|
2186
|
+
(click)="$event.stopPropagation()"
|
|
2187
|
+
cdkTrapFocus
|
|
2188
|
+
cdkTrapFocusAutoCapture
|
|
2189
|
+
>
|
|
2190
|
+
<div class="elg-dialog-header">
|
|
2191
|
+
@if (title()) {
|
|
2192
|
+
<h2 id="elg-dialog-title" class="elg-dialog-title">{{ title() }}</h2>
|
|
2193
|
+
}
|
|
2194
|
+
@if (showClose()) {
|
|
2195
|
+
<button
|
|
2196
|
+
type="button"
|
|
2197
|
+
class="elg-dialog-close"
|
|
2198
|
+
aria-label="Close dialog"
|
|
2199
|
+
(click)="close()"
|
|
2200
|
+
>
|
|
2201
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2202
|
+
<line x1="18" y1="6" x2="6" y2="18"/>
|
|
2203
|
+
<line x1="6" y1="6" x2="18" y2="18"/>
|
|
2204
|
+
</svg>
|
|
2205
|
+
</button>
|
|
2206
|
+
}
|
|
2207
|
+
</div>
|
|
2208
|
+
<div class="elg-dialog-content">
|
|
2209
|
+
<ng-content select="[elgDialogContent]" />
|
|
2210
|
+
<ng-content />
|
|
2211
|
+
</div>
|
|
2212
|
+
<div class="elg-dialog-footer">
|
|
2213
|
+
<ng-content select="[elgDialogFooter]" />
|
|
2214
|
+
</div>
|
|
2215
|
+
</div>
|
|
2216
|
+
</div>
|
|
2217
|
+
`, styles: [":host{display:contents}.elg-dialog-overlay{position:fixed;inset:0;background:var(--elg-dialog-overlay-bg, rgb(0 0 0 / .5));z-index:var(--elg-dialog-z-index, 1000);display:flex;align-items:center;justify-content:center;padding:1rem;animation:elg-dialog-overlay-in .2s ease-out}.elg-dialog-panel{background:var(--elg-dialog-panel-bg, #ffffff);border-radius:var(--elg-dialog-border-radius, .75rem);box-shadow:var(--elg-dialog-shadow, 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1));padding:var(--elg-dialog-padding, 1.5rem);width:100%;max-height:calc(100vh - 2rem);overflow-y:auto;animation:elg-dialog-panel-in .2s ease-out}.elg-dialog-panel--sm{max-width:400px}.elg-dialog-panel--md{max-width:512px}.elg-dialog-panel--lg{max-width:640px}.elg-dialog-panel--xl{max-width:800px}.elg-dialog-panel--fullscreen{max-width:100vw;width:100vw;height:100vh;max-height:100vh;border-radius:0;margin:0}.elg-dialog-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem}.elg-dialog-title{font-size:1.125rem;font-weight:600;color:var(--elg-dialog-title-color, #1a202c);margin:0}.elg-dialog-close{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;border:none;background:transparent;border-radius:.375rem;cursor:pointer;color:var(--elg-dialog-close-color, #64748b);transition:background-color .15s,color .15s;margin-left:auto}.elg-dialog-close:hover{background:var(--elg-dialog-close-hover-bg, #f1f5f9);color:var(--elg-dialog-close-hover-color, #1e293b)}.elg-dialog-content{color:var(--elg-dialog-content-color, #334155)}.elg-dialog-footer{display:flex;align-items:center;justify-content:flex-end;gap:.5rem;margin-top:1.5rem}.elg-dialog-footer:empty{display:none;margin-top:0}@keyframes elg-dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes elg-dialog-panel-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}\n"] }]
|
|
2218
|
+
}], propDecorators: { onEscape: [{
|
|
2219
|
+
type: HostListener,
|
|
2220
|
+
args: ['document:keydown.escape']
|
|
2221
|
+
}] } });
|
|
2222
|
+
|
|
2223
|
+
class ElgDialogRef {
|
|
2224
|
+
_afterClosed = new Subject();
|
|
2225
|
+
afterClosed$ = this._afterClosed.asObservable();
|
|
2226
|
+
close(result) {
|
|
2227
|
+
this._afterClosed.next(result);
|
|
2228
|
+
this._afterClosed.complete();
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
class ElgDialogService {
|
|
2233
|
+
appRef = inject(ApplicationRef);
|
|
2234
|
+
injector = inject(EnvironmentInjector);
|
|
2235
|
+
open(component, config) {
|
|
2236
|
+
const dialogRef = new ElgDialogRef();
|
|
2237
|
+
const dialogComponentRef = createComponent(ElgDialogComponent, {
|
|
2238
|
+
environmentInjector: this.injector,
|
|
2239
|
+
});
|
|
2240
|
+
const size = config?.size ?? 'md';
|
|
2241
|
+
const disableClose = config?.disableClose ?? false;
|
|
2242
|
+
dialogComponentRef.setInput('title', config?.title ?? '');
|
|
2243
|
+
dialogComponentRef.setInput('size', size);
|
|
2244
|
+
dialogComponentRef.setInput('disableClose', disableClose);
|
|
2245
|
+
dialogComponentRef.instance.closed.subscribe(() => {
|
|
2246
|
+
dialogRef.close(undefined);
|
|
2247
|
+
});
|
|
2248
|
+
dialogRef.afterClosed$.subscribe(() => {
|
|
2249
|
+
this.appRef.detachView(dialogComponentRef.hostView);
|
|
2250
|
+
dialogComponentRef.destroy();
|
|
2251
|
+
});
|
|
2252
|
+
this.appRef.attachView(dialogComponentRef.hostView);
|
|
2253
|
+
const domElement = dialogComponentRef.hostView.rootNodes[0];
|
|
2254
|
+
document.body.appendChild(domElement);
|
|
2255
|
+
return dialogRef;
|
|
2256
|
+
}
|
|
2257
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2258
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDialogService, providedIn: 'root' });
|
|
2259
|
+
}
|
|
2260
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDialogService, decorators: [{
|
|
2261
|
+
type: Injectable,
|
|
2262
|
+
args: [{ providedIn: 'root' }]
|
|
2263
|
+
}] });
|
|
2264
|
+
|
|
2265
|
+
class ElgBadgeComponent {
|
|
2266
|
+
variant = input('default');
|
|
2267
|
+
size = input('md');
|
|
2268
|
+
badgeClasses = computed(() => {
|
|
2269
|
+
return `elg-badge elg-badge--${this.variant()} elg-badge--${this.size()}`;
|
|
2270
|
+
});
|
|
2271
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgBadgeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2272
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgBadgeComponent, isStandalone: true, selector: "elg-badge", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
2273
|
+
<span [class]="badgeClasses()">
|
|
2274
|
+
<ng-content />
|
|
2275
|
+
</span>
|
|
2276
|
+
`, isInline: true, styles: [":host{display:inline-flex}.elg-badge{display:inline-flex;align-items:center;justify-content:center;font-weight:500;white-space:nowrap;border-radius:var(--elg-badge-border-radius, 9999px);transition:background-color .15s,color .15s}.elg-badge--sm{font-size:var(--elg-badge-font-size-sm, .6875rem);padding:var(--elg-badge-padding-sm, .125rem .5rem);line-height:1.25rem}.elg-badge--md{font-size:var(--elg-badge-font-size-md, .75rem);padding:var(--elg-badge-padding-md, .25rem .625rem);line-height:1.25rem}.elg-badge--default{background:var(--elg-badge-default-bg, #f1f5f9);color:var(--elg-badge-default-color, #475569)}.elg-badge--primary{background:var(--elg-badge-primary-bg, #3b82f6);color:var(--elg-badge-primary-color, #ffffff)}.elg-badge--success{background:var(--elg-badge-success-bg, #dcfce7);color:var(--elg-badge-success-color, #166534)}.elg-badge--warning{background:var(--elg-badge-warning-bg, #fef3c7);color:var(--elg-badge-warning-color, #92400e)}.elg-badge--error{background:var(--elg-badge-error-bg, #fee2e2);color:var(--elg-badge-error-color, #991b1b)}.elg-badge--outline{background:transparent;color:var(--elg-badge-outline-color, #475569);border:1px solid var(--elg-badge-outline-border, #e2e8f0)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2277
|
+
}
|
|
2278
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgBadgeComponent, decorators: [{
|
|
2279
|
+
type: Component,
|
|
2280
|
+
args: [{ selector: 'elg-badge', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
2281
|
+
<span [class]="badgeClasses()">
|
|
2282
|
+
<ng-content />
|
|
2283
|
+
</span>
|
|
2284
|
+
`, styles: [":host{display:inline-flex}.elg-badge{display:inline-flex;align-items:center;justify-content:center;font-weight:500;white-space:nowrap;border-radius:var(--elg-badge-border-radius, 9999px);transition:background-color .15s,color .15s}.elg-badge--sm{font-size:var(--elg-badge-font-size-sm, .6875rem);padding:var(--elg-badge-padding-sm, .125rem .5rem);line-height:1.25rem}.elg-badge--md{font-size:var(--elg-badge-font-size-md, .75rem);padding:var(--elg-badge-padding-md, .25rem .625rem);line-height:1.25rem}.elg-badge--default{background:var(--elg-badge-default-bg, #f1f5f9);color:var(--elg-badge-default-color, #475569)}.elg-badge--primary{background:var(--elg-badge-primary-bg, #3b82f6);color:var(--elg-badge-primary-color, #ffffff)}.elg-badge--success{background:var(--elg-badge-success-bg, #dcfce7);color:var(--elg-badge-success-color, #166534)}.elg-badge--warning{background:var(--elg-badge-warning-bg, #fef3c7);color:var(--elg-badge-warning-color, #92400e)}.elg-badge--error{background:var(--elg-badge-error-bg, #fee2e2);color:var(--elg-badge-error-color, #991b1b)}.elg-badge--outline{background:transparent;color:var(--elg-badge-outline-color, #475569);border:1px solid var(--elg-badge-outline-border, #e2e8f0)}\n"] }]
|
|
2285
|
+
}] });
|
|
2286
|
+
|
|
2287
|
+
class ElgAlertComponent {
|
|
2288
|
+
severity = input('info');
|
|
2289
|
+
dismissible = input(false);
|
|
2290
|
+
title = input('');
|
|
2291
|
+
dismissed = output();
|
|
2292
|
+
alertClasses = computed(() => {
|
|
2293
|
+
return `elg-alert elg-alert--${this.severity()}`;
|
|
2294
|
+
});
|
|
2295
|
+
onDismiss() {
|
|
2296
|
+
this.dismissed.emit();
|
|
2297
|
+
}
|
|
2298
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgAlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2299
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgAlertComponent, isStandalone: true, selector: "elg-alert", inputs: { severity: { classPropertyName: "severity", publicName: "severity", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dismissed: "dismissed" }, ngImport: i0, template: `
|
|
2300
|
+
<div [class]="alertClasses()" role="alert">
|
|
2301
|
+
<div class="elg-alert__icon" aria-hidden="true">
|
|
2302
|
+
@switch (severity()) {
|
|
2303
|
+
@case ('info') {
|
|
2304
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2305
|
+
<circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/>
|
|
2306
|
+
</svg>
|
|
2307
|
+
}
|
|
2308
|
+
@case ('success') {
|
|
2309
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2310
|
+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>
|
|
2311
|
+
</svg>
|
|
2312
|
+
}
|
|
2313
|
+
@case ('warning') {
|
|
2314
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2315
|
+
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>
|
|
2316
|
+
</svg>
|
|
2317
|
+
}
|
|
2318
|
+
@case ('error') {
|
|
2319
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2320
|
+
<circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/>
|
|
2321
|
+
</svg>
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
</div>
|
|
2325
|
+
<div class="elg-alert__body">
|
|
2326
|
+
@if (title()) {
|
|
2327
|
+
<div class="elg-alert__title">{{ title() }}</div>
|
|
2328
|
+
}
|
|
2329
|
+
<div class="elg-alert__message">
|
|
2330
|
+
<ng-content />
|
|
2331
|
+
</div>
|
|
2332
|
+
</div>
|
|
2333
|
+
@if (dismissible()) {
|
|
2334
|
+
<button
|
|
2335
|
+
type="button"
|
|
2336
|
+
class="elg-alert__dismiss"
|
|
2337
|
+
aria-label="Dismiss alert"
|
|
2338
|
+
(click)="onDismiss()"
|
|
2339
|
+
>
|
|
2340
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2341
|
+
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
|
2342
|
+
</svg>
|
|
2343
|
+
</button>
|
|
2344
|
+
}
|
|
2345
|
+
</div>
|
|
2346
|
+
`, isInline: true, styles: [":host{display:block}.elg-alert{display:flex;align-items:flex-start;gap:.75rem;padding:var(--elg-alert-padding, 1rem);border-radius:var(--elg-alert-border-radius, .5rem);border-left:var(--elg-alert-border-left-width, 4px) solid transparent}.elg-alert--info{background:var(--elg-alert-info-bg, #eff6ff);color:var(--elg-alert-info-color, #1e40af);border-left-color:var(--elg-alert-info-border, #3b82f6)}.elg-alert--success{background:var(--elg-alert-success-bg, #f0fdf4);color:var(--elg-alert-success-color, #166534);border-left-color:var(--elg-alert-success-border, #22c55e)}.elg-alert--warning{background:var(--elg-alert-warning-bg, #fffbeb);color:var(--elg-alert-warning-color, #92400e);border-left-color:var(--elg-alert-warning-border, #f59e0b)}.elg-alert--error{background:var(--elg-alert-error-bg, #fef2f2);color:var(--elg-alert-error-color, #991b1b);border-left-color:var(--elg-alert-error-border, #ef4444)}.elg-alert__icon{flex-shrink:0;display:flex;align-items:center;margin-top:.125rem}.elg-alert__body{flex:1;min-width:0}.elg-alert__title{font-weight:600;font-size:.875rem;margin-bottom:.25rem}.elg-alert__message{font-size:.875rem;line-height:1.5}.elg-alert__dismiss{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;border:none;background:transparent;border-radius:.25rem;cursor:pointer;color:currentColor;opacity:.6;transition:opacity .15s}.elg-alert__dismiss:hover{opacity:1}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2347
|
+
}
|
|
2348
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgAlertComponent, decorators: [{
|
|
2349
|
+
type: Component,
|
|
2350
|
+
args: [{ selector: 'elg-alert', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
2351
|
+
<div [class]="alertClasses()" role="alert">
|
|
2352
|
+
<div class="elg-alert__icon" aria-hidden="true">
|
|
2353
|
+
@switch (severity()) {
|
|
2354
|
+
@case ('info') {
|
|
2355
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2356
|
+
<circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/>
|
|
2357
|
+
</svg>
|
|
2358
|
+
}
|
|
2359
|
+
@case ('success') {
|
|
2360
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2361
|
+
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>
|
|
2362
|
+
</svg>
|
|
2363
|
+
}
|
|
2364
|
+
@case ('warning') {
|
|
2365
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2366
|
+
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/>
|
|
2367
|
+
</svg>
|
|
2368
|
+
}
|
|
2369
|
+
@case ('error') {
|
|
2370
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2371
|
+
<circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/>
|
|
2372
|
+
</svg>
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
</div>
|
|
2376
|
+
<div class="elg-alert__body">
|
|
2377
|
+
@if (title()) {
|
|
2378
|
+
<div class="elg-alert__title">{{ title() }}</div>
|
|
2379
|
+
}
|
|
2380
|
+
<div class="elg-alert__message">
|
|
2381
|
+
<ng-content />
|
|
2382
|
+
</div>
|
|
2383
|
+
</div>
|
|
2384
|
+
@if (dismissible()) {
|
|
2385
|
+
<button
|
|
2386
|
+
type="button"
|
|
2387
|
+
class="elg-alert__dismiss"
|
|
2388
|
+
aria-label="Dismiss alert"
|
|
2389
|
+
(click)="onDismiss()"
|
|
2390
|
+
>
|
|
2391
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2392
|
+
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
|
2393
|
+
</svg>
|
|
2394
|
+
</button>
|
|
2395
|
+
}
|
|
2396
|
+
</div>
|
|
2397
|
+
`, styles: [":host{display:block}.elg-alert{display:flex;align-items:flex-start;gap:.75rem;padding:var(--elg-alert-padding, 1rem);border-radius:var(--elg-alert-border-radius, .5rem);border-left:var(--elg-alert-border-left-width, 4px) solid transparent}.elg-alert--info{background:var(--elg-alert-info-bg, #eff6ff);color:var(--elg-alert-info-color, #1e40af);border-left-color:var(--elg-alert-info-border, #3b82f6)}.elg-alert--success{background:var(--elg-alert-success-bg, #f0fdf4);color:var(--elg-alert-success-color, #166534);border-left-color:var(--elg-alert-success-border, #22c55e)}.elg-alert--warning{background:var(--elg-alert-warning-bg, #fffbeb);color:var(--elg-alert-warning-color, #92400e);border-left-color:var(--elg-alert-warning-border, #f59e0b)}.elg-alert--error{background:var(--elg-alert-error-bg, #fef2f2);color:var(--elg-alert-error-color, #991b1b);border-left-color:var(--elg-alert-error-border, #ef4444)}.elg-alert__icon{flex-shrink:0;display:flex;align-items:center;margin-top:.125rem}.elg-alert__body{flex:1;min-width:0}.elg-alert__title{font-weight:600;font-size:.875rem;margin-bottom:.25rem}.elg-alert__message{font-size:.875rem;line-height:1.5}.elg-alert__dismiss{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;border:none;background:transparent;border-radius:.25rem;cursor:pointer;color:currentColor;opacity:.6;transition:opacity .15s}.elg-alert__dismiss:hover{opacity:1}\n"] }]
|
|
2398
|
+
}] });
|
|
2399
|
+
|
|
2400
|
+
class ElgProgressComponent {
|
|
2401
|
+
value = input(0);
|
|
2402
|
+
indeterminate = input(false);
|
|
2403
|
+
size = input('md');
|
|
2404
|
+
color = input(undefined);
|
|
2405
|
+
trackClasses = computed(() => {
|
|
2406
|
+
return `elg-progress-track elg-progress-track--${this.size()}`;
|
|
2407
|
+
});
|
|
2408
|
+
fillWidth = computed(() => {
|
|
2409
|
+
if (this.indeterminate())
|
|
2410
|
+
return '100%';
|
|
2411
|
+
const clamped = Math.max(0, Math.min(100, this.value()));
|
|
2412
|
+
return `${clamped}%`;
|
|
2413
|
+
});
|
|
2414
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgProgressComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2415
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgProgressComponent, isStandalone: true, selector: "elg-progress", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
|
|
2416
|
+
<div
|
|
2417
|
+
class="elg-progress-track"
|
|
2418
|
+
[class]="trackClasses()"
|
|
2419
|
+
role="progressbar"
|
|
2420
|
+
[attr.aria-valuenow]="indeterminate() ? null : value()"
|
|
2421
|
+
[attr.aria-valuemin]="0"
|
|
2422
|
+
[attr.aria-valuemax]="100"
|
|
2423
|
+
>
|
|
2424
|
+
<div
|
|
2425
|
+
class="elg-progress-fill"
|
|
2426
|
+
[class.elg-progress-fill--indeterminate]="indeterminate()"
|
|
2427
|
+
[style.width]="fillWidth()"
|
|
2428
|
+
[style.background-color]="color() || null"
|
|
2429
|
+
></div>
|
|
2430
|
+
</div>
|
|
2431
|
+
`, isInline: true, styles: [":host{display:block;width:100%}.elg-progress-track{width:100%;overflow:hidden;background:var(--elg-progress-track-bg, #e2e8f0);border-radius:var(--elg-progress-border-radius, 9999px)}.elg-progress-track--sm{height:var(--elg-progress-height-sm, 4px)}.elg-progress-track--md{height:var(--elg-progress-height-md, 8px)}.elg-progress-track--lg{height:var(--elg-progress-height-lg, 12px)}.elg-progress-fill{height:100%;background:var(--elg-progress-fill-bg, #3b82f6);border-radius:inherit;transition:width .3s ease}.elg-progress-fill--indeterminate{width:40%!important;animation:elg-progress-indeterminate 1.5s ease-in-out infinite}@keyframes elg-progress-indeterminate{0%{transform:translate(-100%)}50%{transform:translate(150%)}to{transform:translate(-100%)}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2432
|
+
}
|
|
2433
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgProgressComponent, decorators: [{
|
|
2434
|
+
type: Component,
|
|
2435
|
+
args: [{ selector: 'elg-progress', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
2436
|
+
<div
|
|
2437
|
+
class="elg-progress-track"
|
|
2438
|
+
[class]="trackClasses()"
|
|
2439
|
+
role="progressbar"
|
|
2440
|
+
[attr.aria-valuenow]="indeterminate() ? null : value()"
|
|
2441
|
+
[attr.aria-valuemin]="0"
|
|
2442
|
+
[attr.aria-valuemax]="100"
|
|
2443
|
+
>
|
|
2444
|
+
<div
|
|
2445
|
+
class="elg-progress-fill"
|
|
2446
|
+
[class.elg-progress-fill--indeterminate]="indeterminate()"
|
|
2447
|
+
[style.width]="fillWidth()"
|
|
2448
|
+
[style.background-color]="color() || null"
|
|
2449
|
+
></div>
|
|
2450
|
+
</div>
|
|
2451
|
+
`, styles: [":host{display:block;width:100%}.elg-progress-track{width:100%;overflow:hidden;background:var(--elg-progress-track-bg, #e2e8f0);border-radius:var(--elg-progress-border-radius, 9999px)}.elg-progress-track--sm{height:var(--elg-progress-height-sm, 4px)}.elg-progress-track--md{height:var(--elg-progress-height-md, 8px)}.elg-progress-track--lg{height:var(--elg-progress-height-lg, 12px)}.elg-progress-fill{height:100%;background:var(--elg-progress-fill-bg, #3b82f6);border-radius:inherit;transition:width .3s ease}.elg-progress-fill--indeterminate{width:40%!important;animation:elg-progress-indeterminate 1.5s ease-in-out infinite}@keyframes elg-progress-indeterminate{0%{transform:translate(-100%)}50%{transform:translate(150%)}to{transform:translate(-100%)}}\n"] }]
|
|
2452
|
+
}] });
|
|
2453
|
+
|
|
2454
|
+
class ElgPaginationComponent {
|
|
2455
|
+
totalItems = input(0);
|
|
2456
|
+
pageSize = input(10);
|
|
2457
|
+
currentPage = input(1);
|
|
2458
|
+
pageSizeOptions = input([10, 25, 50, 100]);
|
|
2459
|
+
pageChange = output();
|
|
2460
|
+
pageSizeChange = output();
|
|
2461
|
+
totalPages = computed(() => {
|
|
2462
|
+
return Math.max(1, Math.ceil(this.totalItems() / this.pageSize()));
|
|
2463
|
+
});
|
|
2464
|
+
rangeStart = computed(() => {
|
|
2465
|
+
if (this.totalItems() === 0)
|
|
2466
|
+
return 0;
|
|
2467
|
+
return (this.currentPage() - 1) * this.pageSize() + 1;
|
|
2468
|
+
});
|
|
2469
|
+
rangeEnd = computed(() => {
|
|
2470
|
+
return Math.min(this.currentPage() * this.pageSize(), this.totalItems());
|
|
2471
|
+
});
|
|
2472
|
+
displayedPages = computed(() => {
|
|
2473
|
+
const total = this.totalPages();
|
|
2474
|
+
const current = this.currentPage();
|
|
2475
|
+
const pages = [];
|
|
2476
|
+
if (total <= 7) {
|
|
2477
|
+
for (let i = 1; i <= total; i++)
|
|
2478
|
+
pages.push(i);
|
|
2479
|
+
return pages;
|
|
2480
|
+
}
|
|
2481
|
+
pages.push(1);
|
|
2482
|
+
if (current > 3) {
|
|
2483
|
+
pages.push(-1); // ellipsis
|
|
2484
|
+
}
|
|
2485
|
+
const start = Math.max(2, current - 1);
|
|
2486
|
+
const end = Math.min(total - 1, current + 1);
|
|
2487
|
+
for (let i = start; i <= end; i++) {
|
|
2488
|
+
pages.push(i);
|
|
2489
|
+
}
|
|
2490
|
+
if (current < total - 2) {
|
|
2491
|
+
pages.push(-1); // ellipsis
|
|
2492
|
+
}
|
|
2493
|
+
pages.push(total);
|
|
2494
|
+
return pages;
|
|
2495
|
+
});
|
|
2496
|
+
goToPage(page) {
|
|
2497
|
+
if (page >= 1 && page <= this.totalPages() && page !== this.currentPage()) {
|
|
2498
|
+
this.pageChange.emit(page);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
onPageSizeChange(newSize) {
|
|
2502
|
+
this.pageSizeChange.emit(Number(newSize));
|
|
2503
|
+
}
|
|
2504
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgPaginationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2505
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgPaginationComponent, isStandalone: true, selector: "elg-pagination", inputs: { totalItems: { classPropertyName: "totalItems", publicName: "totalItems", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, currentPage: { classPropertyName: "currentPage", publicName: "currentPage", isSignal: true, isRequired: false, transformFunction: null }, pageSizeOptions: { classPropertyName: "pageSizeOptions", publicName: "pageSizeOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pageChange: "pageChange", pageSizeChange: "pageSizeChange" }, ngImport: i0, template: `
|
|
2506
|
+
<div class="elg-pagination">
|
|
2507
|
+
<div class="elg-pagination__size-select">
|
|
2508
|
+
<label class="elg-pagination__label">Rows per page:</label>
|
|
2509
|
+
<select
|
|
2510
|
+
class="elg-pagination__select"
|
|
2511
|
+
[ngModel]="pageSize()"
|
|
2512
|
+
(ngModelChange)="onPageSizeChange($event)"
|
|
2513
|
+
>
|
|
2514
|
+
@for (option of pageSizeOptions(); track option) {
|
|
2515
|
+
<option [value]="option">{{ option }}</option>
|
|
2516
|
+
}
|
|
2517
|
+
</select>
|
|
2518
|
+
</div>
|
|
2519
|
+
|
|
2520
|
+
<span class="elg-pagination__info">
|
|
2521
|
+
{{ rangeStart() }}–{{ rangeEnd() }} of {{ totalItems() }}
|
|
2522
|
+
</span>
|
|
2523
|
+
|
|
2524
|
+
<div class="elg-pagination__controls">
|
|
2525
|
+
<button
|
|
2526
|
+
type="button"
|
|
2527
|
+
class="elg-pagination__btn"
|
|
2528
|
+
[disabled]="currentPage() <= 1"
|
|
2529
|
+
aria-label="Previous page"
|
|
2530
|
+
(click)="goToPage(currentPage() - 1)"
|
|
2531
|
+
>
|
|
2532
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2533
|
+
<polyline points="15 18 9 12 15 6"/>
|
|
2534
|
+
</svg>
|
|
2535
|
+
</button>
|
|
2536
|
+
|
|
2537
|
+
@for (page of displayedPages(); track $index) {
|
|
2538
|
+
@if (page === -1) {
|
|
2539
|
+
<span class="elg-pagination__ellipsis">…</span>
|
|
2540
|
+
} @else {
|
|
2541
|
+
<button
|
|
2542
|
+
type="button"
|
|
2543
|
+
class="elg-pagination__btn elg-pagination__page"
|
|
2544
|
+
[class.elg-pagination__page--active]="page === currentPage()"
|
|
2545
|
+
[attr.aria-current]="page === currentPage() ? 'page' : null"
|
|
2546
|
+
(click)="goToPage(page)"
|
|
2547
|
+
>
|
|
2548
|
+
{{ page }}
|
|
2549
|
+
</button>
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
<button
|
|
2554
|
+
type="button"
|
|
2555
|
+
class="elg-pagination__btn"
|
|
2556
|
+
[disabled]="currentPage() >= totalPages()"
|
|
2557
|
+
aria-label="Next page"
|
|
2558
|
+
(click)="goToPage(currentPage() + 1)"
|
|
2559
|
+
>
|
|
2560
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2561
|
+
<polyline points="9 18 15 12 9 6"/>
|
|
2562
|
+
</svg>
|
|
2563
|
+
</button>
|
|
2564
|
+
</div>
|
|
2565
|
+
</div>
|
|
2566
|
+
`, isInline: true, styles: [":host{display:block}.elg-pagination{display:flex;align-items:center;justify-content:flex-end;gap:var(--elg-pagination-gap, 1rem);flex-wrap:wrap;font-size:.875rem;color:var(--elg-pagination-color, #475569)}.elg-pagination__size-select{display:flex;align-items:center;gap:.5rem}.elg-pagination__label{white-space:nowrap}.elg-pagination__select{padding:.25rem .5rem;border:1px solid var(--elg-pagination-border, #e2e8f0);border-radius:.375rem;font-size:.875rem;background:var(--elg-pagination-select-bg, #ffffff);color:inherit;cursor:pointer}.elg-pagination__select:focus{outline:2px solid var(--elg-pagination-focus-ring, #3b82f6);outline-offset:1px}.elg-pagination__info{white-space:nowrap}.elg-pagination__controls{display:flex;align-items:center;gap:.25rem}.elg-pagination__btn{display:inline-flex;align-items:center;justify-content:center;min-width:var(--elg-pagination-btn-size, 2rem);min-height:var(--elg-pagination-btn-size, 2rem);padding:.25rem;border:1px solid var(--elg-pagination-border, #e2e8f0);border-radius:var(--elg-pagination-btn-radius, .375rem);background:var(--elg-pagination-btn-bg, #ffffff);color:var(--elg-pagination-color, #475569);font-size:.875rem;cursor:pointer;transition:background-color .15s,border-color .15s}.elg-pagination__btn:hover:not(:disabled){background:var(--elg-pagination-btn-hover-bg, #f1f5f9);border-color:var(--elg-pagination-btn-hover-border, #cbd5e1)}.elg-pagination__btn:disabled{opacity:.4;cursor:not-allowed}.elg-pagination__btn:focus-visible{outline:2px solid var(--elg-pagination-focus-ring, #3b82f6);outline-offset:1px}.elg-pagination__page--active{background:var(--elg-pagination-active-bg, #3b82f6);color:var(--elg-pagination-active-color, #ffffff);border-color:var(--elg-pagination-active-bg, #3b82f6)}.elg-pagination__page--active:hover:not(:disabled){background:var(--elg-pagination-active-bg, #3b82f6);border-color:var(--elg-pagination-active-bg, #3b82f6)}.elg-pagination__ellipsis{display:inline-flex;align-items:center;justify-content:center;min-width:var(--elg-pagination-btn-size, 2rem);min-height:var(--elg-pagination-btn-size, 2rem);color:var(--elg-pagination-color, #475569)}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2567
|
+
}
|
|
2568
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgPaginationComponent, decorators: [{
|
|
2569
|
+
type: Component,
|
|
2570
|
+
args: [{ selector: 'elg-pagination', standalone: true, imports: [FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
2571
|
+
<div class="elg-pagination">
|
|
2572
|
+
<div class="elg-pagination__size-select">
|
|
2573
|
+
<label class="elg-pagination__label">Rows per page:</label>
|
|
2574
|
+
<select
|
|
2575
|
+
class="elg-pagination__select"
|
|
2576
|
+
[ngModel]="pageSize()"
|
|
2577
|
+
(ngModelChange)="onPageSizeChange($event)"
|
|
2578
|
+
>
|
|
2579
|
+
@for (option of pageSizeOptions(); track option) {
|
|
2580
|
+
<option [value]="option">{{ option }}</option>
|
|
2581
|
+
}
|
|
2582
|
+
</select>
|
|
2583
|
+
</div>
|
|
2584
|
+
|
|
2585
|
+
<span class="elg-pagination__info">
|
|
2586
|
+
{{ rangeStart() }}–{{ rangeEnd() }} of {{ totalItems() }}
|
|
2587
|
+
</span>
|
|
2588
|
+
|
|
2589
|
+
<div class="elg-pagination__controls">
|
|
2590
|
+
<button
|
|
2591
|
+
type="button"
|
|
2592
|
+
class="elg-pagination__btn"
|
|
2593
|
+
[disabled]="currentPage() <= 1"
|
|
2594
|
+
aria-label="Previous page"
|
|
2595
|
+
(click)="goToPage(currentPage() - 1)"
|
|
2596
|
+
>
|
|
2597
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2598
|
+
<polyline points="15 18 9 12 15 6"/>
|
|
2599
|
+
</svg>
|
|
2600
|
+
</button>
|
|
2601
|
+
|
|
2602
|
+
@for (page of displayedPages(); track $index) {
|
|
2603
|
+
@if (page === -1) {
|
|
2604
|
+
<span class="elg-pagination__ellipsis">…</span>
|
|
2605
|
+
} @else {
|
|
2606
|
+
<button
|
|
2607
|
+
type="button"
|
|
2608
|
+
class="elg-pagination__btn elg-pagination__page"
|
|
2609
|
+
[class.elg-pagination__page--active]="page === currentPage()"
|
|
2610
|
+
[attr.aria-current]="page === currentPage() ? 'page' : null"
|
|
2611
|
+
(click)="goToPage(page)"
|
|
2612
|
+
>
|
|
2613
|
+
{{ page }}
|
|
2614
|
+
</button>
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
<button
|
|
2619
|
+
type="button"
|
|
2620
|
+
class="elg-pagination__btn"
|
|
2621
|
+
[disabled]="currentPage() >= totalPages()"
|
|
2622
|
+
aria-label="Next page"
|
|
2623
|
+
(click)="goToPage(currentPage() + 1)"
|
|
2624
|
+
>
|
|
2625
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2626
|
+
<polyline points="9 18 15 12 9 6"/>
|
|
2627
|
+
</svg>
|
|
2628
|
+
</button>
|
|
2629
|
+
</div>
|
|
2630
|
+
</div>
|
|
2631
|
+
`, styles: [":host{display:block}.elg-pagination{display:flex;align-items:center;justify-content:flex-end;gap:var(--elg-pagination-gap, 1rem);flex-wrap:wrap;font-size:.875rem;color:var(--elg-pagination-color, #475569)}.elg-pagination__size-select{display:flex;align-items:center;gap:.5rem}.elg-pagination__label{white-space:nowrap}.elg-pagination__select{padding:.25rem .5rem;border:1px solid var(--elg-pagination-border, #e2e8f0);border-radius:.375rem;font-size:.875rem;background:var(--elg-pagination-select-bg, #ffffff);color:inherit;cursor:pointer}.elg-pagination__select:focus{outline:2px solid var(--elg-pagination-focus-ring, #3b82f6);outline-offset:1px}.elg-pagination__info{white-space:nowrap}.elg-pagination__controls{display:flex;align-items:center;gap:.25rem}.elg-pagination__btn{display:inline-flex;align-items:center;justify-content:center;min-width:var(--elg-pagination-btn-size, 2rem);min-height:var(--elg-pagination-btn-size, 2rem);padding:.25rem;border:1px solid var(--elg-pagination-border, #e2e8f0);border-radius:var(--elg-pagination-btn-radius, .375rem);background:var(--elg-pagination-btn-bg, #ffffff);color:var(--elg-pagination-color, #475569);font-size:.875rem;cursor:pointer;transition:background-color .15s,border-color .15s}.elg-pagination__btn:hover:not(:disabled){background:var(--elg-pagination-btn-hover-bg, #f1f5f9);border-color:var(--elg-pagination-btn-hover-border, #cbd5e1)}.elg-pagination__btn:disabled{opacity:.4;cursor:not-allowed}.elg-pagination__btn:focus-visible{outline:2px solid var(--elg-pagination-focus-ring, #3b82f6);outline-offset:1px}.elg-pagination__page--active{background:var(--elg-pagination-active-bg, #3b82f6);color:var(--elg-pagination-active-color, #ffffff);border-color:var(--elg-pagination-active-bg, #3b82f6)}.elg-pagination__page--active:hover:not(:disabled){background:var(--elg-pagination-active-bg, #3b82f6);border-color:var(--elg-pagination-active-bg, #3b82f6)}.elg-pagination__ellipsis{display:inline-flex;align-items:center;justify-content:center;min-width:var(--elg-pagination-btn-size, 2rem);min-height:var(--elg-pagination-btn-size, 2rem);color:var(--elg-pagination-color, #475569)}\n"] }]
|
|
2632
|
+
}] });
|
|
2633
|
+
|
|
2634
|
+
class ElgStepComponent {
|
|
2635
|
+
label = input.required();
|
|
2636
|
+
completed = input(false);
|
|
2637
|
+
optional = input(false);
|
|
2638
|
+
editable = input(true);
|
|
2639
|
+
contentTemplate;
|
|
2640
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgStepComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2641
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgStepComponent, isStandalone: true, selector: "elg-step", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, completed: { classPropertyName: "completed", publicName: "completed", isSignal: true, isRequired: false, transformFunction: null }, optional: { classPropertyName: "optional", publicName: "optional", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "contentTemplate", first: true, predicate: ["stepContent"], descendants: true, static: true }], ngImport: i0, template: `
|
|
2642
|
+
<ng-template #stepContent>
|
|
2643
|
+
<ng-content></ng-content>
|
|
2644
|
+
</ng-template>
|
|
2645
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2646
|
+
}
|
|
2647
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgStepComponent, decorators: [{
|
|
2648
|
+
type: Component,
|
|
2649
|
+
args: [{
|
|
2650
|
+
selector: 'elg-step',
|
|
2651
|
+
standalone: true,
|
|
2652
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2653
|
+
template: `
|
|
2654
|
+
<ng-template #stepContent>
|
|
2655
|
+
<ng-content></ng-content>
|
|
2656
|
+
</ng-template>
|
|
2657
|
+
`,
|
|
2658
|
+
}]
|
|
2659
|
+
}], propDecorators: { contentTemplate: [{
|
|
2660
|
+
type: ViewChild,
|
|
2661
|
+
args: ['stepContent', { static: true }]
|
|
2662
|
+
}] } });
|
|
2663
|
+
|
|
2664
|
+
class ElgStepperComponent {
|
|
2665
|
+
orientation = input('horizontal');
|
|
2666
|
+
linear = input(false);
|
|
2667
|
+
stepChange = output();
|
|
2668
|
+
steps;
|
|
2669
|
+
activeStepIndex = signal(0);
|
|
2670
|
+
ngAfterContentInit() {
|
|
2671
|
+
// Initialize at step 0
|
|
2672
|
+
}
|
|
2673
|
+
next() {
|
|
2674
|
+
const currentIndex = this.activeStepIndex();
|
|
2675
|
+
if (currentIndex < this.steps.length - 1) {
|
|
2676
|
+
if (this.linear()) {
|
|
2677
|
+
const currentStep = this.steps.get(currentIndex);
|
|
2678
|
+
if (currentStep && !currentStep.completed() && !currentStep.optional()) {
|
|
2679
|
+
return;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
this.activeStepIndex.set(currentIndex + 1);
|
|
2683
|
+
this.stepChange.emit(currentIndex + 1);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
previous() {
|
|
2687
|
+
const currentIndex = this.activeStepIndex();
|
|
2688
|
+
if (currentIndex > 0) {
|
|
2689
|
+
this.activeStepIndex.set(currentIndex - 1);
|
|
2690
|
+
this.stepChange.emit(currentIndex - 1);
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
goToStep(index) {
|
|
2694
|
+
if (index < 0 || index >= this.steps.length)
|
|
2695
|
+
return;
|
|
2696
|
+
const targetStep = this.steps.get(index);
|
|
2697
|
+
if (targetStep && !targetStep.editable() && index !== this.activeStepIndex())
|
|
2698
|
+
return;
|
|
2699
|
+
if (this.linear() && index > this.activeStepIndex()) {
|
|
2700
|
+
// In linear mode, can only go forward if all previous steps are completed
|
|
2701
|
+
for (let i = this.activeStepIndex(); i < index; i++) {
|
|
2702
|
+
const step = this.steps.get(i);
|
|
2703
|
+
if (step && !step.completed() && !step.optional()) {
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
this.activeStepIndex.set(index);
|
|
2709
|
+
this.stepChange.emit(index);
|
|
2710
|
+
}
|
|
2711
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgStepperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2712
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgStepperComponent, isStandalone: true, selector: "elg-stepper", inputs: { orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, linear: { classPropertyName: "linear", publicName: "linear", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { stepChange: "stepChange" }, host: { properties: { "class": "\"elg-stepper elg-stepper--\" + orientation()" } }, queries: [{ propertyName: "steps", predicate: ElgStepComponent }], ngImport: i0, template: `
|
|
2713
|
+
<div class="elg-stepper__header">
|
|
2714
|
+
@for (step of steps; track $index) {
|
|
2715
|
+
@if ($index > 0) {
|
|
2716
|
+
<div
|
|
2717
|
+
class="elg-stepper__connector"
|
|
2718
|
+
[class.elg-stepper__connector--completed]="step.completed() || $index < activeStepIndex()"
|
|
2719
|
+
></div>
|
|
2720
|
+
}
|
|
2721
|
+
<div
|
|
2722
|
+
class="elg-stepper__step-indicator"
|
|
2723
|
+
[class.elg-stepper__step-indicator--active]="activeStepIndex() === $index"
|
|
2724
|
+
[class.elg-stepper__step-indicator--completed]="step.completed() || $index < activeStepIndex()"
|
|
2725
|
+
[class.elg-stepper__step-indicator--disabled]="!step.editable() && $index !== activeStepIndex()"
|
|
2726
|
+
(click)="goToStep($index)"
|
|
2727
|
+
>
|
|
2728
|
+
<div class="elg-stepper__circle">
|
|
2729
|
+
@if (step.completed() || $index < activeStepIndex()) {
|
|
2730
|
+
<svg class="elg-stepper__check" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2731
|
+
<path d="M2.5 6L5 8.5L9.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2732
|
+
</svg>
|
|
2733
|
+
} @else {
|
|
2734
|
+
<span class="elg-stepper__number">{{ $index + 1 }}</span>
|
|
2735
|
+
}
|
|
2736
|
+
</div>
|
|
2737
|
+
<span class="elg-stepper__label">
|
|
2738
|
+
{{ step.label() }}
|
|
2739
|
+
@if (step.optional()) {
|
|
2740
|
+
<span class="elg-stepper__optional">(Optional)</span>
|
|
2741
|
+
}
|
|
2742
|
+
</span>
|
|
2743
|
+
</div>
|
|
2744
|
+
}
|
|
2745
|
+
</div>
|
|
2746
|
+
<div class="elg-stepper__content">
|
|
2747
|
+
@if (steps && steps.length > 0 && steps.get(activeStepIndex()); as activeStep) {
|
|
2748
|
+
<ng-container [ngTemplateOutlet]="activeStep.contentTemplate"></ng-container>
|
|
2749
|
+
}
|
|
2750
|
+
</div>
|
|
2751
|
+
`, isInline: true, styles: [":host{display:block;width:100%}.elg-stepper__header{display:flex;align-items:center}:host(.elg-stepper--vertical) .elg-stepper__header{flex-direction:column;align-items:flex-start}.elg-stepper__step-indicator{display:flex;flex-direction:column;align-items:center;cursor:pointer;position:relative;flex-shrink:0}:host(.elg-stepper--vertical) .elg-stepper__step-indicator{flex-direction:row;gap:12px;padding:8px 0}.elg-stepper__step-indicator--disabled{cursor:not-allowed;opacity:.5}.elg-stepper__circle{width:var(--elg-stepper-circle-size, 36px);height:var(--elg-stepper-circle-size, 36px);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:var(--elg-font-size-sm, .875rem);font-weight:600;border:2px solid var(--elg-color-border, #d1d5db);background:var(--elg-color-surface, #ffffff);color:var(--elg-color-text-muted, #6b7280);transition:all .2s ease}.elg-stepper__step-indicator--active .elg-stepper__circle{border-color:var(--elg-color-primary, #3b82f6);background:var(--elg-color-primary, #3b82f6);color:var(--elg-color-primary-contrast, #ffffff)}.elg-stepper__step-indicator--completed .elg-stepper__circle{border-color:var(--elg-color-success, #22c55e);background:var(--elg-color-success, #22c55e);color:#fff}.elg-stepper__number{line-height:1}.elg-stepper__check{width:16px;height:16px}.elg-stepper__label{margin-top:8px;font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-text-muted, #6b7280);text-align:center;white-space:nowrap}:host(.elg-stepper--vertical) .elg-stepper__label{margin-top:0;font-size:var(--elg-font-size-sm, .875rem)}.elg-stepper__step-indicator--active .elg-stepper__label{color:var(--elg-color-primary, #3b82f6);font-weight:600}.elg-stepper__step-indicator--completed .elg-stepper__label{color:var(--elg-color-success, #22c55e)}.elg-stepper__optional{display:block;font-size:var(--elg-font-size-xs, .75rem);font-weight:400;color:var(--elg-color-text-muted, #6b7280)}.elg-stepper__connector{flex:1;height:2px;min-width:24px;background:var(--elg-color-border, #d1d5db);margin:0 8px 28px;transition:background .2s ease}.elg-stepper__connector--completed{background:var(--elg-color-success, #22c55e)}:host(.elg-stepper--vertical) .elg-stepper__connector{width:2px;height:24px;min-width:unset;margin:0;margin-left:calc(var(--elg-stepper-circle-size, 36px) / 2 - 1px);flex:unset}.elg-stepper__content{margin-top:24px;padding:16px}:host(.elg-stepper--vertical) .elg-stepper__content{margin-top:16px;margin-left:calc(var(--elg-stepper-circle-size, 36px) + 12px)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2752
|
+
}
|
|
2753
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgStepperComponent, decorators: [{
|
|
2754
|
+
type: Component,
|
|
2755
|
+
args: [{ selector: 'elg-stepper', standalone: true, imports: [NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2756
|
+
'[class]': '"elg-stepper elg-stepper--" + orientation()',
|
|
2757
|
+
}, template: `
|
|
2758
|
+
<div class="elg-stepper__header">
|
|
2759
|
+
@for (step of steps; track $index) {
|
|
2760
|
+
@if ($index > 0) {
|
|
2761
|
+
<div
|
|
2762
|
+
class="elg-stepper__connector"
|
|
2763
|
+
[class.elg-stepper__connector--completed]="step.completed() || $index < activeStepIndex()"
|
|
2764
|
+
></div>
|
|
2765
|
+
}
|
|
2766
|
+
<div
|
|
2767
|
+
class="elg-stepper__step-indicator"
|
|
2768
|
+
[class.elg-stepper__step-indicator--active]="activeStepIndex() === $index"
|
|
2769
|
+
[class.elg-stepper__step-indicator--completed]="step.completed() || $index < activeStepIndex()"
|
|
2770
|
+
[class.elg-stepper__step-indicator--disabled]="!step.editable() && $index !== activeStepIndex()"
|
|
2771
|
+
(click)="goToStep($index)"
|
|
2772
|
+
>
|
|
2773
|
+
<div class="elg-stepper__circle">
|
|
2774
|
+
@if (step.completed() || $index < activeStepIndex()) {
|
|
2775
|
+
<svg class="elg-stepper__check" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2776
|
+
<path d="M2.5 6L5 8.5L9.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2777
|
+
</svg>
|
|
2778
|
+
} @else {
|
|
2779
|
+
<span class="elg-stepper__number">{{ $index + 1 }}</span>
|
|
2780
|
+
}
|
|
2781
|
+
</div>
|
|
2782
|
+
<span class="elg-stepper__label">
|
|
2783
|
+
{{ step.label() }}
|
|
2784
|
+
@if (step.optional()) {
|
|
2785
|
+
<span class="elg-stepper__optional">(Optional)</span>
|
|
2786
|
+
}
|
|
2787
|
+
</span>
|
|
2788
|
+
</div>
|
|
2789
|
+
}
|
|
2790
|
+
</div>
|
|
2791
|
+
<div class="elg-stepper__content">
|
|
2792
|
+
@if (steps && steps.length > 0 && steps.get(activeStepIndex()); as activeStep) {
|
|
2793
|
+
<ng-container [ngTemplateOutlet]="activeStep.contentTemplate"></ng-container>
|
|
2794
|
+
}
|
|
2795
|
+
</div>
|
|
2796
|
+
`, styles: [":host{display:block;width:100%}.elg-stepper__header{display:flex;align-items:center}:host(.elg-stepper--vertical) .elg-stepper__header{flex-direction:column;align-items:flex-start}.elg-stepper__step-indicator{display:flex;flex-direction:column;align-items:center;cursor:pointer;position:relative;flex-shrink:0}:host(.elg-stepper--vertical) .elg-stepper__step-indicator{flex-direction:row;gap:12px;padding:8px 0}.elg-stepper__step-indicator--disabled{cursor:not-allowed;opacity:.5}.elg-stepper__circle{width:var(--elg-stepper-circle-size, 36px);height:var(--elg-stepper-circle-size, 36px);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:var(--elg-font-size-sm, .875rem);font-weight:600;border:2px solid var(--elg-color-border, #d1d5db);background:var(--elg-color-surface, #ffffff);color:var(--elg-color-text-muted, #6b7280);transition:all .2s ease}.elg-stepper__step-indicator--active .elg-stepper__circle{border-color:var(--elg-color-primary, #3b82f6);background:var(--elg-color-primary, #3b82f6);color:var(--elg-color-primary-contrast, #ffffff)}.elg-stepper__step-indicator--completed .elg-stepper__circle{border-color:var(--elg-color-success, #22c55e);background:var(--elg-color-success, #22c55e);color:#fff}.elg-stepper__number{line-height:1}.elg-stepper__check{width:16px;height:16px}.elg-stepper__label{margin-top:8px;font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-text-muted, #6b7280);text-align:center;white-space:nowrap}:host(.elg-stepper--vertical) .elg-stepper__label{margin-top:0;font-size:var(--elg-font-size-sm, .875rem)}.elg-stepper__step-indicator--active .elg-stepper__label{color:var(--elg-color-primary, #3b82f6);font-weight:600}.elg-stepper__step-indicator--completed .elg-stepper__label{color:var(--elg-color-success, #22c55e)}.elg-stepper__optional{display:block;font-size:var(--elg-font-size-xs, .75rem);font-weight:400;color:var(--elg-color-text-muted, #6b7280)}.elg-stepper__connector{flex:1;height:2px;min-width:24px;background:var(--elg-color-border, #d1d5db);margin:0 8px 28px;transition:background .2s ease}.elg-stepper__connector--completed{background:var(--elg-color-success, #22c55e)}:host(.elg-stepper--vertical) .elg-stepper__connector{width:2px;height:24px;min-width:unset;margin:0;margin-left:calc(var(--elg-stepper-circle-size, 36px) / 2 - 1px);flex:unset}.elg-stepper__content{margin-top:24px;padding:16px}:host(.elg-stepper--vertical) .elg-stepper__content{margin-top:16px;margin-left:calc(var(--elg-stepper-circle-size, 36px) + 12px)}\n"] }]
|
|
2797
|
+
}], propDecorators: { steps: [{
|
|
2798
|
+
type: ContentChildren,
|
|
2799
|
+
args: [ElgStepComponent]
|
|
2800
|
+
}] } });
|
|
2801
|
+
|
|
2802
|
+
class ElgTreeNodeComponent {
|
|
2803
|
+
node = input.required();
|
|
2804
|
+
level = input(0);
|
|
2805
|
+
selectable = input(false);
|
|
2806
|
+
nodeSelected = output();
|
|
2807
|
+
nodeToggled = output();
|
|
2808
|
+
toggleNode(event) {
|
|
2809
|
+
event.stopPropagation();
|
|
2810
|
+
const currentNode = this.node();
|
|
2811
|
+
currentNode.expanded = !currentNode.expanded;
|
|
2812
|
+
this.nodeToggled.emit(currentNode);
|
|
2813
|
+
}
|
|
2814
|
+
onSelect(event) {
|
|
2815
|
+
const target = event.target;
|
|
2816
|
+
const currentNode = this.node();
|
|
2817
|
+
currentNode.selected = target.checked;
|
|
2818
|
+
this.nodeSelected.emit(currentNode);
|
|
2819
|
+
}
|
|
2820
|
+
onNodeClick() {
|
|
2821
|
+
const currentNode = this.node();
|
|
2822
|
+
if (!currentNode.disabled) {
|
|
2823
|
+
this.nodeSelected.emit(currentNode);
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTreeNodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2827
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgTreeNodeComponent, isStandalone: true, selector: "elg-tree-node", inputs: { node: { classPropertyName: "node", publicName: "node", isSignal: true, isRequired: true, transformFunction: null }, level: { classPropertyName: "level", publicName: "level", isSignal: true, isRequired: false, transformFunction: null }, selectable: { classPropertyName: "selectable", publicName: "selectable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nodeSelected: "nodeSelected", nodeToggled: "nodeToggled" }, host: { properties: { "class": "\"elg-tree-node\"" } }, ngImport: i0, template: `
|
|
2828
|
+
<div
|
|
2829
|
+
class="elg-tree-node__row"
|
|
2830
|
+
[class.elg-tree-node__row--selected]="node().selected"
|
|
2831
|
+
[class.elg-tree-node__row--disabled]="node().disabled"
|
|
2832
|
+
[style.padding-left.px]="level() * 20"
|
|
2833
|
+
>
|
|
2834
|
+
@if (node().children && node().children!.length > 0) {
|
|
2835
|
+
<button
|
|
2836
|
+
class="elg-tree-node__toggle"
|
|
2837
|
+
[class.elg-tree-node__toggle--expanded]="node().expanded"
|
|
2838
|
+
(click)="toggleNode($event)"
|
|
2839
|
+
[disabled]="node().disabled"
|
|
2840
|
+
aria-label="Toggle"
|
|
2841
|
+
>
|
|
2842
|
+
<svg class="elg-tree-node__chevron" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2843
|
+
<path d="M4.5 2.5L8 6L4.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2844
|
+
</svg>
|
|
2845
|
+
</button>
|
|
2846
|
+
} @else {
|
|
2847
|
+
<span class="elg-tree-node__spacer"></span>
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
@if (selectable()) {
|
|
2851
|
+
<input
|
|
2852
|
+
type="checkbox"
|
|
2853
|
+
class="elg-tree-node__checkbox"
|
|
2854
|
+
[checked]="node().selected || false"
|
|
2855
|
+
[disabled]="node().disabled"
|
|
2856
|
+
(change)="onSelect($event)"
|
|
2857
|
+
/>
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
@if (node().icon) {
|
|
2861
|
+
<span class="elg-tree-node__icon">{{ node().icon }}</span>
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
<span
|
|
2865
|
+
class="elg-tree-node__label"
|
|
2866
|
+
(click)="onNodeClick()"
|
|
2867
|
+
>
|
|
2868
|
+
{{ node().label }}
|
|
2869
|
+
</span>
|
|
2870
|
+
</div>
|
|
2871
|
+
|
|
2872
|
+
@if (node().expanded && node().children) {
|
|
2873
|
+
@for (child of node().children; track child.id) {
|
|
2874
|
+
<elg-tree-node
|
|
2875
|
+
[node]="child"
|
|
2876
|
+
[level]="level() + 1"
|
|
2877
|
+
[selectable]="selectable()"
|
|
2878
|
+
(nodeSelected)="nodeSelected.emit($event)"
|
|
2879
|
+
(nodeToggled)="nodeToggled.emit($event)"
|
|
2880
|
+
></elg-tree-node>
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
`, isInline: true, dependencies: [{ kind: "component", type: ElgTreeNodeComponent, selector: "elg-tree-node", inputs: ["node", "level", "selectable"], outputs: ["nodeSelected", "nodeToggled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2884
|
+
}
|
|
2885
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTreeNodeComponent, decorators: [{
|
|
2886
|
+
type: Component,
|
|
2887
|
+
args: [{
|
|
2888
|
+
selector: 'elg-tree-node',
|
|
2889
|
+
standalone: true,
|
|
2890
|
+
imports: [],
|
|
2891
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2892
|
+
host: {
|
|
2893
|
+
'[class]': '"elg-tree-node"',
|
|
2894
|
+
},
|
|
2895
|
+
template: `
|
|
2896
|
+
<div
|
|
2897
|
+
class="elg-tree-node__row"
|
|
2898
|
+
[class.elg-tree-node__row--selected]="node().selected"
|
|
2899
|
+
[class.elg-tree-node__row--disabled]="node().disabled"
|
|
2900
|
+
[style.padding-left.px]="level() * 20"
|
|
2901
|
+
>
|
|
2902
|
+
@if (node().children && node().children!.length > 0) {
|
|
2903
|
+
<button
|
|
2904
|
+
class="elg-tree-node__toggle"
|
|
2905
|
+
[class.elg-tree-node__toggle--expanded]="node().expanded"
|
|
2906
|
+
(click)="toggleNode($event)"
|
|
2907
|
+
[disabled]="node().disabled"
|
|
2908
|
+
aria-label="Toggle"
|
|
2909
|
+
>
|
|
2910
|
+
<svg class="elg-tree-node__chevron" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2911
|
+
<path d="M4.5 2.5L8 6L4.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
2912
|
+
</svg>
|
|
2913
|
+
</button>
|
|
2914
|
+
} @else {
|
|
2915
|
+
<span class="elg-tree-node__spacer"></span>
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
@if (selectable()) {
|
|
2919
|
+
<input
|
|
2920
|
+
type="checkbox"
|
|
2921
|
+
class="elg-tree-node__checkbox"
|
|
2922
|
+
[checked]="node().selected || false"
|
|
2923
|
+
[disabled]="node().disabled"
|
|
2924
|
+
(change)="onSelect($event)"
|
|
2925
|
+
/>
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
@if (node().icon) {
|
|
2929
|
+
<span class="elg-tree-node__icon">{{ node().icon }}</span>
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
<span
|
|
2933
|
+
class="elg-tree-node__label"
|
|
2934
|
+
(click)="onNodeClick()"
|
|
2935
|
+
>
|
|
2936
|
+
{{ node().label }}
|
|
2937
|
+
</span>
|
|
2938
|
+
</div>
|
|
2939
|
+
|
|
2940
|
+
@if (node().expanded && node().children) {
|
|
2941
|
+
@for (child of node().children; track child.id) {
|
|
2942
|
+
<elg-tree-node
|
|
2943
|
+
[node]="child"
|
|
2944
|
+
[level]="level() + 1"
|
|
2945
|
+
[selectable]="selectable()"
|
|
2946
|
+
(nodeSelected)="nodeSelected.emit($event)"
|
|
2947
|
+
(nodeToggled)="nodeToggled.emit($event)"
|
|
2948
|
+
></elg-tree-node>
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
`,
|
|
2952
|
+
}]
|
|
2953
|
+
}] });
|
|
2954
|
+
|
|
2955
|
+
class ElgTreeComponent {
|
|
2956
|
+
data = input([]);
|
|
2957
|
+
selectable = input(false);
|
|
2958
|
+
expandAll = input(false);
|
|
2959
|
+
nodeSelected = output();
|
|
2960
|
+
nodeToggled = output();
|
|
2961
|
+
ngOnInit() {
|
|
2962
|
+
if (this.expandAll()) {
|
|
2963
|
+
this.expandAllNodes(this.data());
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
onNodeSelected(node) {
|
|
2967
|
+
this.nodeSelected.emit(node);
|
|
2968
|
+
}
|
|
2969
|
+
onNodeToggled(node) {
|
|
2970
|
+
this.nodeToggled.emit(node);
|
|
2971
|
+
}
|
|
2972
|
+
expandAllNodes(nodes) {
|
|
2973
|
+
for (const node of nodes) {
|
|
2974
|
+
if (node.children && node.children.length > 0) {
|
|
2975
|
+
node.expanded = true;
|
|
2976
|
+
this.expandAllNodes(node.children);
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTreeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2981
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgTreeComponent, isStandalone: true, selector: "elg-tree", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, selectable: { classPropertyName: "selectable", publicName: "selectable", isSignal: true, isRequired: false, transformFunction: null }, expandAll: { classPropertyName: "expandAll", publicName: "expandAll", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nodeSelected: "nodeSelected", nodeToggled: "nodeToggled" }, host: { attributes: { "role": "tree" }, properties: { "class": "\"elg-tree\"" } }, ngImport: i0, template: `
|
|
2982
|
+
@for (node of data(); track node.id) {
|
|
2983
|
+
<elg-tree-node
|
|
2984
|
+
[node]="node"
|
|
2985
|
+
[level]="0"
|
|
2986
|
+
[selectable]="selectable()"
|
|
2987
|
+
(nodeSelected)="onNodeSelected($event)"
|
|
2988
|
+
(nodeToggled)="onNodeToggled($event)"
|
|
2989
|
+
></elg-tree-node>
|
|
2990
|
+
}
|
|
2991
|
+
`, isInline: true, styles: [":host{display:block;width:100%;font-family:var(--elg-font-family, inherit)}:host ::ng-deep .elg-tree-node__row{display:flex;align-items:center;gap:6px;padding:6px 8px;border-radius:var(--elg-border-radius-sm, 4px);cursor:default;transition:background .15s ease;-webkit-user-select:none;user-select:none}:host ::ng-deep .elg-tree-node__row:hover{background:var(--elg-color-surface-hover, #f3f4f6)}:host ::ng-deep .elg-tree-node__row--selected{background:var(--elg-color-primary-subtle, #eff6ff)}:host ::ng-deep .elg-tree-node__row--selected:hover{background:var(--elg-color-primary-subtle, #dbeafe)}:host ::ng-deep .elg-tree-node__row--disabled{opacity:.5;cursor:not-allowed}:host ::ng-deep .elg-tree-node__toggle{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border:none;background:transparent;cursor:pointer;border-radius:var(--elg-border-radius-sm, 4px);color:var(--elg-color-text-muted, #6b7280);padding:0;flex-shrink:0;transition:color .15s ease}:host ::ng-deep .elg-tree-node__toggle:hover{color:var(--elg-color-text, #111827);background:var(--elg-color-surface-hover, #e5e7eb)}:host ::ng-deep .elg-tree-node__toggle:disabled{cursor:not-allowed;opacity:.5}:host ::ng-deep .elg-tree-node__chevron{width:12px;height:12px;transition:transform .2s ease}:host ::ng-deep .elg-tree-node__toggle--expanded .elg-tree-node__chevron{transform:rotate(90deg)}:host ::ng-deep .elg-tree-node__spacer{width:20px;flex-shrink:0}:host ::ng-deep .elg-tree-node__checkbox{width:16px;height:16px;cursor:pointer;accent-color:var(--elg-color-primary, #3b82f6);flex-shrink:0}:host ::ng-deep .elg-tree-node__icon{font-size:var(--elg-font-size-sm, .875rem);flex-shrink:0}:host ::ng-deep .elg-tree-node__label{font-size:var(--elg-font-size-sm, .875rem);color:var(--elg-color-text, #111827);cursor:pointer;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"], dependencies: [{ kind: "component", type: ElgTreeNodeComponent, selector: "elg-tree-node", inputs: ["node", "level", "selectable"], outputs: ["nodeSelected", "nodeToggled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2992
|
+
}
|
|
2993
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgTreeComponent, decorators: [{
|
|
2994
|
+
type: Component,
|
|
2995
|
+
args: [{ selector: 'elg-tree', standalone: true, imports: [ElgTreeNodeComponent], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
2996
|
+
'[class]': '"elg-tree"',
|
|
2997
|
+
'role': 'tree',
|
|
2998
|
+
}, template: `
|
|
2999
|
+
@for (node of data(); track node.id) {
|
|
3000
|
+
<elg-tree-node
|
|
3001
|
+
[node]="node"
|
|
3002
|
+
[level]="0"
|
|
3003
|
+
[selectable]="selectable()"
|
|
3004
|
+
(nodeSelected)="onNodeSelected($event)"
|
|
3005
|
+
(nodeToggled)="onNodeToggled($event)"
|
|
3006
|
+
></elg-tree-node>
|
|
3007
|
+
}
|
|
3008
|
+
`, styles: [":host{display:block;width:100%;font-family:var(--elg-font-family, inherit)}:host ::ng-deep .elg-tree-node__row{display:flex;align-items:center;gap:6px;padding:6px 8px;border-radius:var(--elg-border-radius-sm, 4px);cursor:default;transition:background .15s ease;-webkit-user-select:none;user-select:none}:host ::ng-deep .elg-tree-node__row:hover{background:var(--elg-color-surface-hover, #f3f4f6)}:host ::ng-deep .elg-tree-node__row--selected{background:var(--elg-color-primary-subtle, #eff6ff)}:host ::ng-deep .elg-tree-node__row--selected:hover{background:var(--elg-color-primary-subtle, #dbeafe)}:host ::ng-deep .elg-tree-node__row--disabled{opacity:.5;cursor:not-allowed}:host ::ng-deep .elg-tree-node__toggle{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border:none;background:transparent;cursor:pointer;border-radius:var(--elg-border-radius-sm, 4px);color:var(--elg-color-text-muted, #6b7280);padding:0;flex-shrink:0;transition:color .15s ease}:host ::ng-deep .elg-tree-node__toggle:hover{color:var(--elg-color-text, #111827);background:var(--elg-color-surface-hover, #e5e7eb)}:host ::ng-deep .elg-tree-node__toggle:disabled{cursor:not-allowed;opacity:.5}:host ::ng-deep .elg-tree-node__chevron{width:12px;height:12px;transition:transform .2s ease}:host ::ng-deep .elg-tree-node__toggle--expanded .elg-tree-node__chevron{transform:rotate(90deg)}:host ::ng-deep .elg-tree-node__spacer{width:20px;flex-shrink:0}:host ::ng-deep .elg-tree-node__checkbox{width:16px;height:16px;cursor:pointer;accent-color:var(--elg-color-primary, #3b82f6);flex-shrink:0}:host ::ng-deep .elg-tree-node__icon{font-size:var(--elg-font-size-sm, .875rem);flex-shrink:0}:host ::ng-deep .elg-tree-node__label{font-size:var(--elg-font-size-sm, .875rem);color:var(--elg-color-text, #111827);cursor:pointer;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n"] }]
|
|
3009
|
+
}] });
|
|
3010
|
+
|
|
3011
|
+
class ElgDatePickerComponent {
|
|
3012
|
+
elementRef;
|
|
3013
|
+
value = input(null);
|
|
3014
|
+
min = input(undefined);
|
|
3015
|
+
max = input(undefined);
|
|
3016
|
+
placeholder = input('Select date');
|
|
3017
|
+
disabled = input(false);
|
|
3018
|
+
format = input('yyyy-MM-dd');
|
|
3019
|
+
valueChange = output();
|
|
3020
|
+
showCalendar = signal(false);
|
|
3021
|
+
viewDate = signal(new Date());
|
|
3022
|
+
selectedDate = signal(null);
|
|
3023
|
+
isDisabled = signal(false);
|
|
3024
|
+
weekDays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
3025
|
+
today = new Date();
|
|
3026
|
+
onChange = () => { };
|
|
3027
|
+
onTouched = () => { };
|
|
3028
|
+
constructor(elementRef) {
|
|
3029
|
+
this.elementRef = elementRef;
|
|
3030
|
+
}
|
|
3031
|
+
monthYearLabel = computed(() => {
|
|
3032
|
+
const date = this.viewDate();
|
|
3033
|
+
const months = [
|
|
3034
|
+
'January', 'February', 'March', 'April', 'May', 'June',
|
|
3035
|
+
'July', 'August', 'September', 'October', 'November', 'December'
|
|
3036
|
+
];
|
|
3037
|
+
return `${months[date.getMonth()]} ${date.getFullYear()}`;
|
|
3038
|
+
});
|
|
3039
|
+
displayValue = computed(() => {
|
|
3040
|
+
const date = this.selectedDate();
|
|
3041
|
+
if (!date)
|
|
3042
|
+
return '';
|
|
3043
|
+
return this.formatDate(date);
|
|
3044
|
+
});
|
|
3045
|
+
calendarDays = computed(() => {
|
|
3046
|
+
const viewDate = this.viewDate();
|
|
3047
|
+
const year = viewDate.getFullYear();
|
|
3048
|
+
const month = viewDate.getMonth();
|
|
3049
|
+
const firstDay = new Date(year, month, 1);
|
|
3050
|
+
const lastDay = new Date(year, month + 1, 0);
|
|
3051
|
+
const days = [];
|
|
3052
|
+
// Add empty slots for days before the first day of month
|
|
3053
|
+
for (let i = 0; i < firstDay.getDay(); i++) {
|
|
3054
|
+
days.push(null);
|
|
3055
|
+
}
|
|
3056
|
+
// Add all days of the month
|
|
3057
|
+
for (let d = 1; d <= lastDay.getDate(); d++) {
|
|
3058
|
+
days.push(new Date(year, month, d));
|
|
3059
|
+
}
|
|
3060
|
+
return days;
|
|
3061
|
+
});
|
|
3062
|
+
ngOnChanges() {
|
|
3063
|
+
if (this.value()) {
|
|
3064
|
+
this.selectedDate.set(this.value());
|
|
3065
|
+
this.viewDate.set(new Date(this.value()));
|
|
3066
|
+
}
|
|
3067
|
+
this.isDisabled.set(this.disabled());
|
|
3068
|
+
}
|
|
3069
|
+
onDocumentClick(event) {
|
|
3070
|
+
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
3071
|
+
this.closeCalendar();
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
toggleCalendar() {
|
|
3075
|
+
if (this.isDisabled())
|
|
3076
|
+
return;
|
|
3077
|
+
this.showCalendar.update(v => !v);
|
|
3078
|
+
this.onTouched();
|
|
3079
|
+
}
|
|
3080
|
+
closeCalendar() {
|
|
3081
|
+
this.showCalendar.set(false);
|
|
3082
|
+
}
|
|
3083
|
+
previousMonth() {
|
|
3084
|
+
const current = this.viewDate();
|
|
3085
|
+
this.viewDate.set(new Date(current.getFullYear(), current.getMonth() - 1, 1));
|
|
3086
|
+
}
|
|
3087
|
+
nextMonth() {
|
|
3088
|
+
const current = this.viewDate();
|
|
3089
|
+
this.viewDate.set(new Date(current.getFullYear(), current.getMonth() + 1, 1));
|
|
3090
|
+
}
|
|
3091
|
+
selectDate(date) {
|
|
3092
|
+
if (this.isDayDisabled(date))
|
|
3093
|
+
return;
|
|
3094
|
+
this.selectedDate.set(date);
|
|
3095
|
+
this.onChange(date);
|
|
3096
|
+
this.valueChange.emit(date);
|
|
3097
|
+
this.closeCalendar();
|
|
3098
|
+
}
|
|
3099
|
+
clearDate() {
|
|
3100
|
+
this.selectedDate.set(null);
|
|
3101
|
+
this.onChange(null);
|
|
3102
|
+
this.valueChange.emit(null);
|
|
3103
|
+
this.closeCalendar();
|
|
3104
|
+
}
|
|
3105
|
+
isToday(date) {
|
|
3106
|
+
const today = new Date();
|
|
3107
|
+
return this.isSameDay(date, today);
|
|
3108
|
+
}
|
|
3109
|
+
isSelected(date) {
|
|
3110
|
+
const selected = this.selectedDate();
|
|
3111
|
+
return selected ? this.isSameDay(date, selected) : false;
|
|
3112
|
+
}
|
|
3113
|
+
isDayDisabled(date) {
|
|
3114
|
+
const minDate = this.min();
|
|
3115
|
+
const maxDate = this.max();
|
|
3116
|
+
if (minDate && date < this.startOfDay(minDate))
|
|
3117
|
+
return true;
|
|
3118
|
+
if (maxDate && date > this.endOfDay(maxDate))
|
|
3119
|
+
return true;
|
|
3120
|
+
return false;
|
|
3121
|
+
}
|
|
3122
|
+
isOutsideMonth(date) {
|
|
3123
|
+
return date.getMonth() !== this.viewDate().getMonth();
|
|
3124
|
+
}
|
|
3125
|
+
isSameDay(a, b) {
|
|
3126
|
+
return (a.getFullYear() === b.getFullYear() &&
|
|
3127
|
+
a.getMonth() === b.getMonth() &&
|
|
3128
|
+
a.getDate() === b.getDate());
|
|
3129
|
+
}
|
|
3130
|
+
startOfDay(date) {
|
|
3131
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
3132
|
+
}
|
|
3133
|
+
endOfDay(date) {
|
|
3134
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
|
|
3135
|
+
}
|
|
3136
|
+
formatDate(date) {
|
|
3137
|
+
const fmt = this.format();
|
|
3138
|
+
const year = date.getFullYear().toString();
|
|
3139
|
+
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
3140
|
+
const day = date.getDate().toString().padStart(2, '0');
|
|
3141
|
+
return fmt
|
|
3142
|
+
.replace('yyyy', year)
|
|
3143
|
+
.replace('MM', month)
|
|
3144
|
+
.replace('dd', day);
|
|
3145
|
+
}
|
|
3146
|
+
// ControlValueAccessor
|
|
3147
|
+
writeValue(value) {
|
|
3148
|
+
this.selectedDate.set(value);
|
|
3149
|
+
if (value) {
|
|
3150
|
+
this.viewDate.set(new Date(value));
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
registerOnChange(fn) {
|
|
3154
|
+
this.onChange = fn;
|
|
3155
|
+
}
|
|
3156
|
+
registerOnTouched(fn) {
|
|
3157
|
+
this.onTouched = fn;
|
|
3158
|
+
}
|
|
3159
|
+
setDisabledState(isDisabled) {
|
|
3160
|
+
this.isDisabled.set(isDisabled);
|
|
3161
|
+
}
|
|
3162
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDatePickerComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
3163
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgDatePickerComponent, isStandalone: true, selector: "elg-date-picker", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", 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 }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { listeners: { "document:click": "onDocumentClick($event)" }, properties: { "class": "\"elg-date-picker\"", "class.elg-date-picker--disabled": "isDisabled()", "class.elg-date-picker--open": "showCalendar()" } }, providers: [
|
|
3164
|
+
{
|
|
3165
|
+
provide: NG_VALUE_ACCESSOR,
|
|
3166
|
+
useExisting: forwardRef(() => ElgDatePickerComponent),
|
|
3167
|
+
multi: true,
|
|
3168
|
+
},
|
|
3169
|
+
], usesOnChanges: true, ngImport: i0, template: `
|
|
3170
|
+
<div class="elg-date-picker__input-wrapper">
|
|
3171
|
+
<input
|
|
3172
|
+
type="text"
|
|
3173
|
+
class="elg-date-picker__input"
|
|
3174
|
+
[value]="displayValue()"
|
|
3175
|
+
[placeholder]="placeholder()"
|
|
3176
|
+
[disabled]="isDisabled()"
|
|
3177
|
+
readonly
|
|
3178
|
+
(click)="toggleCalendar()"
|
|
3179
|
+
(keydown.enter)="toggleCalendar()"
|
|
3180
|
+
(keydown.escape)="closeCalendar()"
|
|
3181
|
+
/>
|
|
3182
|
+
<button
|
|
3183
|
+
class="elg-date-picker__icon-btn"
|
|
3184
|
+
(click)="toggleCalendar()"
|
|
3185
|
+
[disabled]="isDisabled()"
|
|
3186
|
+
type="button"
|
|
3187
|
+
aria-label="Open calendar"
|
|
3188
|
+
>
|
|
3189
|
+
<svg viewBox="0 0 20 20" fill="currentColor" class="elg-date-picker__icon">
|
|
3190
|
+
<path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd"/>
|
|
3191
|
+
</svg>
|
|
3192
|
+
</button>
|
|
3193
|
+
</div>
|
|
3194
|
+
|
|
3195
|
+
@if (showCalendar()) {
|
|
3196
|
+
<div class="elg-date-picker__panel">
|
|
3197
|
+
<div class="elg-date-picker__header">
|
|
3198
|
+
<button
|
|
3199
|
+
class="elg-date-picker__nav-btn"
|
|
3200
|
+
(click)="previousMonth()"
|
|
3201
|
+
type="button"
|
|
3202
|
+
aria-label="Previous month"
|
|
3203
|
+
>
|
|
3204
|
+
<svg viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3205
|
+
<path d="M7.5 2.5L4 6L7.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3206
|
+
</svg>
|
|
3207
|
+
</button>
|
|
3208
|
+
<span class="elg-date-picker__month-year">
|
|
3209
|
+
{{ monthYearLabel() }}
|
|
3210
|
+
</span>
|
|
3211
|
+
<button
|
|
3212
|
+
class="elg-date-picker__nav-btn"
|
|
3213
|
+
(click)="nextMonth()"
|
|
3214
|
+
type="button"
|
|
3215
|
+
aria-label="Next month"
|
|
3216
|
+
>
|
|
3217
|
+
<svg viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3218
|
+
<path d="M4.5 2.5L8 6L4.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3219
|
+
</svg>
|
|
3220
|
+
</button>
|
|
3221
|
+
</div>
|
|
3222
|
+
|
|
3223
|
+
<div class="elg-date-picker__weekdays">
|
|
3224
|
+
@for (day of weekDays; track day) {
|
|
3225
|
+
<span class="elg-date-picker__weekday">{{ day }}</span>
|
|
3226
|
+
}
|
|
3227
|
+
</div>
|
|
3228
|
+
|
|
3229
|
+
<div class="elg-date-picker__grid">
|
|
3230
|
+
@for (day of calendarDays(); track $index) {
|
|
3231
|
+
@if (day) {
|
|
3232
|
+
<button
|
|
3233
|
+
class="elg-date-picker__day"
|
|
3234
|
+
[class.elg-date-picker__day--today]="isToday(day)"
|
|
3235
|
+
[class.elg-date-picker__day--selected]="isSelected(day)"
|
|
3236
|
+
[class.elg-date-picker__day--disabled]="isDayDisabled(day)"
|
|
3237
|
+
[class.elg-date-picker__day--outside]="isOutsideMonth(day)"
|
|
3238
|
+
[disabled]="isDayDisabled(day)"
|
|
3239
|
+
(click)="selectDate(day)"
|
|
3240
|
+
type="button"
|
|
3241
|
+
>
|
|
3242
|
+
{{ day.getDate() }}
|
|
3243
|
+
</button>
|
|
3244
|
+
} @else {
|
|
3245
|
+
<span class="elg-date-picker__day-empty"></span>
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
</div>
|
|
3249
|
+
|
|
3250
|
+
<div class="elg-date-picker__footer">
|
|
3251
|
+
<button
|
|
3252
|
+
class="elg-date-picker__today-btn"
|
|
3253
|
+
(click)="selectDate(today)"
|
|
3254
|
+
type="button"
|
|
3255
|
+
>
|
|
3256
|
+
Today
|
|
3257
|
+
</button>
|
|
3258
|
+
<button
|
|
3259
|
+
class="elg-date-picker__clear-btn"
|
|
3260
|
+
(click)="clearDate()"
|
|
3261
|
+
type="button"
|
|
3262
|
+
>
|
|
3263
|
+
Clear
|
|
3264
|
+
</button>
|
|
3265
|
+
</div>
|
|
3266
|
+
</div>
|
|
3267
|
+
}
|
|
3268
|
+
`, isInline: true, styles: [":host{display:inline-block;position:relative;width:100%}.elg-date-picker__input-wrapper{position:relative;display:flex;align-items:center}.elg-date-picker__input{width:100%;padding:var(--elg-input-padding-y, 10px) var(--elg-input-padding-x, 12px);padding-right:40px;font-size:var(--elg-font-size-sm, .875rem);font-family:var(--elg-font-family, inherit);border:1px solid var(--elg-color-border, #d1d5db);border-radius:var(--elg-border-radius, 6px);background:var(--elg-color-surface, #ffffff);color:var(--elg-color-text, #111827);cursor:pointer;outline:none;transition:border-color .2s ease,box-shadow .2s ease}.elg-date-picker__input:hover:not(:disabled){border-color:var(--elg-color-border-hover, #9ca3af)}.elg-date-picker__input:focus{border-color:var(--elg-color-primary, #3b82f6);box-shadow:0 0 0 3px var(--elg-color-primary-ring, rgba(59, 130, 246, .15))}.elg-date-picker__input:disabled{background:var(--elg-color-surface-disabled, #f3f4f6);cursor:not-allowed;opacity:.6}.elg-date-picker__icon-btn{position:absolute;right:8px;display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;background:transparent;cursor:pointer;color:var(--elg-color-text-muted, #6b7280);border-radius:var(--elg-border-radius-sm, 4px);transition:color .15s ease}.elg-date-picker__icon-btn:hover:not(:disabled){color:var(--elg-color-text, #111827)}.elg-date-picker__icon-btn:disabled{cursor:not-allowed;opacity:.5}.elg-date-picker__icon{width:18px;height:18px}.elg-date-picker__panel{position:absolute;top:calc(100% + 4px);left:0;z-index:1000;background:var(--elg-color-surface, #ffffff);border:1px solid var(--elg-color-border, #d1d5db);border-radius:var(--elg-border-radius, 6px);box-shadow:var(--elg-shadow-lg, 0 10px 25px rgba(0, 0, 0, .1));padding:12px;min-width:280px}.elg-date-picker__header{display:flex;align-items:center;justify-content:space-between;padding:4px 0;margin-bottom:8px}.elg-date-picker__month-year{font-size:var(--elg-font-size-sm, .875rem);font-weight:600;color:var(--elg-color-text, #111827)}.elg-date-picker__nav-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;background:transparent;cursor:pointer;color:var(--elg-color-text-muted, #6b7280);border-radius:var(--elg-border-radius-sm, 4px);transition:background .15s ease,color .15s ease}.elg-date-picker__nav-btn:hover{background:var(--elg-color-surface-hover, #f3f4f6);color:var(--elg-color-text, #111827)}.elg-date-picker__nav-btn svg{width:14px;height:14px}.elg-date-picker__weekdays{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;margin-bottom:4px}.elg-date-picker__weekday{font-size:var(--elg-font-size-xs, .75rem);font-weight:500;color:var(--elg-color-text-muted, #6b7280);text-align:center;padding:4px}.elg-date-picker__grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}.elg-date-picker__day{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;background:transparent;cursor:pointer;font-size:var(--elg-font-size-sm, .875rem);color:var(--elg-color-text, #111827);border-radius:var(--elg-border-radius-sm, 4px);transition:background .15s ease,color .15s ease}.elg-date-picker__day:hover:not(:disabled){background:var(--elg-color-surface-hover, #f3f4f6)}.elg-date-picker__day--today{border:1px solid var(--elg-color-primary, #3b82f6)}.elg-date-picker__day--selected{background:var(--elg-color-primary, #3b82f6)!important;color:var(--elg-color-primary-contrast, #ffffff)!important}.elg-date-picker__day--disabled{opacity:.35;cursor:not-allowed}.elg-date-picker__day--outside{color:var(--elg-color-text-muted, #9ca3af)}.elg-date-picker__day-empty{width:36px;height:36px}.elg-date-picker__footer{display:flex;justify-content:space-between;margin-top:8px;padding-top:8px;border-top:1px solid var(--elg-color-border, #e5e7eb)}.elg-date-picker__today-btn,.elg-date-picker__clear-btn{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-primary, #3b82f6);border:none;background:transparent;cursor:pointer;padding:4px 8px;border-radius:var(--elg-border-radius-sm, 4px);font-weight:500;transition:background .15s ease}.elg-date-picker__today-btn:hover,.elg-date-picker__clear-btn:hover{background:var(--elg-color-primary-subtle, #eff6ff)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3269
|
+
}
|
|
3270
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgDatePickerComponent, decorators: [{
|
|
3271
|
+
type: Component,
|
|
3272
|
+
args: [{ selector: 'elg-date-picker', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
3273
|
+
{
|
|
3274
|
+
provide: NG_VALUE_ACCESSOR,
|
|
3275
|
+
useExisting: forwardRef(() => ElgDatePickerComponent),
|
|
3276
|
+
multi: true,
|
|
3277
|
+
},
|
|
3278
|
+
], host: {
|
|
3279
|
+
'[class]': '"elg-date-picker"',
|
|
3280
|
+
'[class.elg-date-picker--disabled]': 'isDisabled()',
|
|
3281
|
+
'[class.elg-date-picker--open]': 'showCalendar()',
|
|
3282
|
+
}, template: `
|
|
3283
|
+
<div class="elg-date-picker__input-wrapper">
|
|
3284
|
+
<input
|
|
3285
|
+
type="text"
|
|
3286
|
+
class="elg-date-picker__input"
|
|
3287
|
+
[value]="displayValue()"
|
|
3288
|
+
[placeholder]="placeholder()"
|
|
3289
|
+
[disabled]="isDisabled()"
|
|
3290
|
+
readonly
|
|
3291
|
+
(click)="toggleCalendar()"
|
|
3292
|
+
(keydown.enter)="toggleCalendar()"
|
|
3293
|
+
(keydown.escape)="closeCalendar()"
|
|
3294
|
+
/>
|
|
3295
|
+
<button
|
|
3296
|
+
class="elg-date-picker__icon-btn"
|
|
3297
|
+
(click)="toggleCalendar()"
|
|
3298
|
+
[disabled]="isDisabled()"
|
|
3299
|
+
type="button"
|
|
3300
|
+
aria-label="Open calendar"
|
|
3301
|
+
>
|
|
3302
|
+
<svg viewBox="0 0 20 20" fill="currentColor" class="elg-date-picker__icon">
|
|
3303
|
+
<path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd"/>
|
|
3304
|
+
</svg>
|
|
3305
|
+
</button>
|
|
3306
|
+
</div>
|
|
3307
|
+
|
|
3308
|
+
@if (showCalendar()) {
|
|
3309
|
+
<div class="elg-date-picker__panel">
|
|
3310
|
+
<div class="elg-date-picker__header">
|
|
3311
|
+
<button
|
|
3312
|
+
class="elg-date-picker__nav-btn"
|
|
3313
|
+
(click)="previousMonth()"
|
|
3314
|
+
type="button"
|
|
3315
|
+
aria-label="Previous month"
|
|
3316
|
+
>
|
|
3317
|
+
<svg viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3318
|
+
<path d="M7.5 2.5L4 6L7.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3319
|
+
</svg>
|
|
3320
|
+
</button>
|
|
3321
|
+
<span class="elg-date-picker__month-year">
|
|
3322
|
+
{{ monthYearLabel() }}
|
|
3323
|
+
</span>
|
|
3324
|
+
<button
|
|
3325
|
+
class="elg-date-picker__nav-btn"
|
|
3326
|
+
(click)="nextMonth()"
|
|
3327
|
+
type="button"
|
|
3328
|
+
aria-label="Next month"
|
|
3329
|
+
>
|
|
3330
|
+
<svg viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3331
|
+
<path d="M4.5 2.5L8 6L4.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3332
|
+
</svg>
|
|
3333
|
+
</button>
|
|
3334
|
+
</div>
|
|
3335
|
+
|
|
3336
|
+
<div class="elg-date-picker__weekdays">
|
|
3337
|
+
@for (day of weekDays; track day) {
|
|
3338
|
+
<span class="elg-date-picker__weekday">{{ day }}</span>
|
|
3339
|
+
}
|
|
3340
|
+
</div>
|
|
3341
|
+
|
|
3342
|
+
<div class="elg-date-picker__grid">
|
|
3343
|
+
@for (day of calendarDays(); track $index) {
|
|
3344
|
+
@if (day) {
|
|
3345
|
+
<button
|
|
3346
|
+
class="elg-date-picker__day"
|
|
3347
|
+
[class.elg-date-picker__day--today]="isToday(day)"
|
|
3348
|
+
[class.elg-date-picker__day--selected]="isSelected(day)"
|
|
3349
|
+
[class.elg-date-picker__day--disabled]="isDayDisabled(day)"
|
|
3350
|
+
[class.elg-date-picker__day--outside]="isOutsideMonth(day)"
|
|
3351
|
+
[disabled]="isDayDisabled(day)"
|
|
3352
|
+
(click)="selectDate(day)"
|
|
3353
|
+
type="button"
|
|
3354
|
+
>
|
|
3355
|
+
{{ day.getDate() }}
|
|
3356
|
+
</button>
|
|
3357
|
+
} @else {
|
|
3358
|
+
<span class="elg-date-picker__day-empty"></span>
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
</div>
|
|
3362
|
+
|
|
3363
|
+
<div class="elg-date-picker__footer">
|
|
3364
|
+
<button
|
|
3365
|
+
class="elg-date-picker__today-btn"
|
|
3366
|
+
(click)="selectDate(today)"
|
|
3367
|
+
type="button"
|
|
3368
|
+
>
|
|
3369
|
+
Today
|
|
3370
|
+
</button>
|
|
3371
|
+
<button
|
|
3372
|
+
class="elg-date-picker__clear-btn"
|
|
3373
|
+
(click)="clearDate()"
|
|
3374
|
+
type="button"
|
|
3375
|
+
>
|
|
3376
|
+
Clear
|
|
3377
|
+
</button>
|
|
3378
|
+
</div>
|
|
3379
|
+
</div>
|
|
3380
|
+
}
|
|
3381
|
+
`, styles: [":host{display:inline-block;position:relative;width:100%}.elg-date-picker__input-wrapper{position:relative;display:flex;align-items:center}.elg-date-picker__input{width:100%;padding:var(--elg-input-padding-y, 10px) var(--elg-input-padding-x, 12px);padding-right:40px;font-size:var(--elg-font-size-sm, .875rem);font-family:var(--elg-font-family, inherit);border:1px solid var(--elg-color-border, #d1d5db);border-radius:var(--elg-border-radius, 6px);background:var(--elg-color-surface, #ffffff);color:var(--elg-color-text, #111827);cursor:pointer;outline:none;transition:border-color .2s ease,box-shadow .2s ease}.elg-date-picker__input:hover:not(:disabled){border-color:var(--elg-color-border-hover, #9ca3af)}.elg-date-picker__input:focus{border-color:var(--elg-color-primary, #3b82f6);box-shadow:0 0 0 3px var(--elg-color-primary-ring, rgba(59, 130, 246, .15))}.elg-date-picker__input:disabled{background:var(--elg-color-surface-disabled, #f3f4f6);cursor:not-allowed;opacity:.6}.elg-date-picker__icon-btn{position:absolute;right:8px;display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;background:transparent;cursor:pointer;color:var(--elg-color-text-muted, #6b7280);border-radius:var(--elg-border-radius-sm, 4px);transition:color .15s ease}.elg-date-picker__icon-btn:hover:not(:disabled){color:var(--elg-color-text, #111827)}.elg-date-picker__icon-btn:disabled{cursor:not-allowed;opacity:.5}.elg-date-picker__icon{width:18px;height:18px}.elg-date-picker__panel{position:absolute;top:calc(100% + 4px);left:0;z-index:1000;background:var(--elg-color-surface, #ffffff);border:1px solid var(--elg-color-border, #d1d5db);border-radius:var(--elg-border-radius, 6px);box-shadow:var(--elg-shadow-lg, 0 10px 25px rgba(0, 0, 0, .1));padding:12px;min-width:280px}.elg-date-picker__header{display:flex;align-items:center;justify-content:space-between;padding:4px 0;margin-bottom:8px}.elg-date-picker__month-year{font-size:var(--elg-font-size-sm, .875rem);font-weight:600;color:var(--elg-color-text, #111827)}.elg-date-picker__nav-btn{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;background:transparent;cursor:pointer;color:var(--elg-color-text-muted, #6b7280);border-radius:var(--elg-border-radius-sm, 4px);transition:background .15s ease,color .15s ease}.elg-date-picker__nav-btn:hover{background:var(--elg-color-surface-hover, #f3f4f6);color:var(--elg-color-text, #111827)}.elg-date-picker__nav-btn svg{width:14px;height:14px}.elg-date-picker__weekdays{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;margin-bottom:4px}.elg-date-picker__weekday{font-size:var(--elg-font-size-xs, .75rem);font-weight:500;color:var(--elg-color-text-muted, #6b7280);text-align:center;padding:4px}.elg-date-picker__grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}.elg-date-picker__day{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;background:transparent;cursor:pointer;font-size:var(--elg-font-size-sm, .875rem);color:var(--elg-color-text, #111827);border-radius:var(--elg-border-radius-sm, 4px);transition:background .15s ease,color .15s ease}.elg-date-picker__day:hover:not(:disabled){background:var(--elg-color-surface-hover, #f3f4f6)}.elg-date-picker__day--today{border:1px solid var(--elg-color-primary, #3b82f6)}.elg-date-picker__day--selected{background:var(--elg-color-primary, #3b82f6)!important;color:var(--elg-color-primary-contrast, #ffffff)!important}.elg-date-picker__day--disabled{opacity:.35;cursor:not-allowed}.elg-date-picker__day--outside{color:var(--elg-color-text-muted, #9ca3af)}.elg-date-picker__day-empty{width:36px;height:36px}.elg-date-picker__footer{display:flex;justify-content:space-between;margin-top:8px;padding-top:8px;border-top:1px solid var(--elg-color-border, #e5e7eb)}.elg-date-picker__today-btn,.elg-date-picker__clear-btn{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-primary, #3b82f6);border:none;background:transparent;cursor:pointer;padding:4px 8px;border-radius:var(--elg-border-radius-sm, 4px);font-weight:500;transition:background .15s ease}.elg-date-picker__today-btn:hover,.elg-date-picker__clear-btn:hover{background:var(--elg-color-primary-subtle, #eff6ff)}\n"] }]
|
|
3382
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { onDocumentClick: [{
|
|
3383
|
+
type: HostListener,
|
|
3384
|
+
args: ['document:click', ['$event']]
|
|
3385
|
+
}] } });
|
|
3386
|
+
|
|
3387
|
+
class ElgFileUploadComponent {
|
|
3388
|
+
accept = input('');
|
|
3389
|
+
multiple = input(false);
|
|
3390
|
+
maxSize = input(0);
|
|
3391
|
+
disabled = input(false);
|
|
3392
|
+
filesSelected = output();
|
|
3393
|
+
fileRemoved = output();
|
|
3394
|
+
files = signal([]);
|
|
3395
|
+
dragOver = signal(false);
|
|
3396
|
+
errors = signal([]);
|
|
3397
|
+
fileInputRef;
|
|
3398
|
+
openFileBrowser() {
|
|
3399
|
+
if (this.disabled())
|
|
3400
|
+
return;
|
|
3401
|
+
this.fileInputRef.nativeElement.click();
|
|
3402
|
+
}
|
|
3403
|
+
onDragOver(event) {
|
|
3404
|
+
event.preventDefault();
|
|
3405
|
+
event.stopPropagation();
|
|
3406
|
+
if (!this.disabled()) {
|
|
3407
|
+
this.dragOver.set(true);
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
onDragLeave(event) {
|
|
3411
|
+
event.preventDefault();
|
|
3412
|
+
event.stopPropagation();
|
|
3413
|
+
this.dragOver.set(false);
|
|
3414
|
+
}
|
|
3415
|
+
onDrop(event) {
|
|
3416
|
+
event.preventDefault();
|
|
3417
|
+
event.stopPropagation();
|
|
3418
|
+
this.dragOver.set(false);
|
|
3419
|
+
if (this.disabled())
|
|
3420
|
+
return;
|
|
3421
|
+
const droppedFiles = event.dataTransfer?.files;
|
|
3422
|
+
if (droppedFiles && droppedFiles.length > 0) {
|
|
3423
|
+
this.processFiles(Array.from(droppedFiles));
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
onFileSelected(event) {
|
|
3427
|
+
const input = event.target;
|
|
3428
|
+
if (input.files && input.files.length > 0) {
|
|
3429
|
+
this.processFiles(Array.from(input.files));
|
|
3430
|
+
// Reset input so same file can be re-selected
|
|
3431
|
+
input.value = '';
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
removeFile(file, event) {
|
|
3435
|
+
event.stopPropagation();
|
|
3436
|
+
this.files.update(files => files.filter(f => f !== file));
|
|
3437
|
+
this.fileRemoved.emit(file);
|
|
3438
|
+
}
|
|
3439
|
+
formatSize(bytes) {
|
|
3440
|
+
if (bytes === 0)
|
|
3441
|
+
return '0 B';
|
|
3442
|
+
const k = 1024;
|
|
3443
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
3444
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
3445
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
|
3446
|
+
}
|
|
3447
|
+
processFiles(newFiles) {
|
|
3448
|
+
const validFiles = [];
|
|
3449
|
+
const newErrors = [];
|
|
3450
|
+
for (const file of newFiles) {
|
|
3451
|
+
// Type validation
|
|
3452
|
+
if (this.accept() && !this.isFileTypeAccepted(file)) {
|
|
3453
|
+
newErrors.push(`"${file.name}" has an unsupported file type.`);
|
|
3454
|
+
continue;
|
|
3455
|
+
}
|
|
3456
|
+
// Size validation
|
|
3457
|
+
if (this.maxSize() && file.size > this.maxSize() * 1024 * 1024) {
|
|
3458
|
+
newErrors.push(`"${file.name}" exceeds the maximum size of ${this.maxSize()}MB.`);
|
|
3459
|
+
continue;
|
|
3460
|
+
}
|
|
3461
|
+
validFiles.push(file);
|
|
3462
|
+
}
|
|
3463
|
+
this.errors.set(newErrors);
|
|
3464
|
+
if (validFiles.length > 0) {
|
|
3465
|
+
if (this.multiple()) {
|
|
3466
|
+
this.files.update(files => [...files, ...validFiles]);
|
|
3467
|
+
}
|
|
3468
|
+
else {
|
|
3469
|
+
this.files.set([validFiles[0]]);
|
|
3470
|
+
}
|
|
3471
|
+
this.filesSelected.emit(this.files());
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
isFileTypeAccepted(file) {
|
|
3475
|
+
const acceptStr = this.accept();
|
|
3476
|
+
if (!acceptStr)
|
|
3477
|
+
return true;
|
|
3478
|
+
const acceptedTypes = acceptStr.split(',').map(t => t.trim().toLowerCase());
|
|
3479
|
+
const fileName = file.name.toLowerCase();
|
|
3480
|
+
const fileMime = file.type.toLowerCase();
|
|
3481
|
+
return acceptedTypes.some(type => {
|
|
3482
|
+
if (type.startsWith('.')) {
|
|
3483
|
+
return fileName.endsWith(type);
|
|
3484
|
+
}
|
|
3485
|
+
if (type.endsWith('/*')) {
|
|
3486
|
+
const baseType = type.replace('/*', '');
|
|
3487
|
+
return fileMime.startsWith(baseType);
|
|
3488
|
+
}
|
|
3489
|
+
return fileMime === type;
|
|
3490
|
+
});
|
|
3491
|
+
}
|
|
3492
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgFileUploadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3493
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgFileUploadComponent, isStandalone: true, selector: "elg-file-upload", inputs: { accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, maxSize: { classPropertyName: "maxSize", publicName: "maxSize", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filesSelected: "filesSelected", fileRemoved: "fileRemoved" }, host: { properties: { "class": "\"elg-file-upload\"", "class.elg-file-upload--disabled": "disabled()" } }, viewQueries: [{ propertyName: "fileInputRef", first: true, predicate: ["fileInput"], descendants: true, static: true }], ngImport: i0, template: `
|
|
3494
|
+
<div
|
|
3495
|
+
class="elg-file-upload__dropzone"
|
|
3496
|
+
[class.elg-file-upload__dropzone--dragover]="dragOver()"
|
|
3497
|
+
[class.elg-file-upload__dropzone--disabled]="disabled()"
|
|
3498
|
+
(dragover)="onDragOver($event)"
|
|
3499
|
+
(dragleave)="onDragLeave($event)"
|
|
3500
|
+
(drop)="onDrop($event)"
|
|
3501
|
+
(click)="openFileBrowser()"
|
|
3502
|
+
>
|
|
3503
|
+
<svg class="elg-file-upload__icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3504
|
+
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3505
|
+
</svg>
|
|
3506
|
+
<p class="elg-file-upload__text">
|
|
3507
|
+
<span class="elg-file-upload__text-primary">Drop files here</span>
|
|
3508
|
+
<span class="elg-file-upload__text-secondary">or click to browse</span>
|
|
3509
|
+
</p>
|
|
3510
|
+
@if (accept()) {
|
|
3511
|
+
<p class="elg-file-upload__hint">Accepted: {{ accept() }}</p>
|
|
3512
|
+
}
|
|
3513
|
+
@if (maxSize()) {
|
|
3514
|
+
<p class="elg-file-upload__hint">Max size: {{ maxSize() }}MB</p>
|
|
3515
|
+
}
|
|
3516
|
+
</div>
|
|
3517
|
+
|
|
3518
|
+
<input
|
|
3519
|
+
#fileInput
|
|
3520
|
+
type="file"
|
|
3521
|
+
class="elg-file-upload__native"
|
|
3522
|
+
[accept]="accept()"
|
|
3523
|
+
[multiple]="multiple()"
|
|
3524
|
+
[disabled]="disabled()"
|
|
3525
|
+
(change)="onFileSelected($event)"
|
|
3526
|
+
/>
|
|
3527
|
+
|
|
3528
|
+
@if (files().length > 0) {
|
|
3529
|
+
<ul class="elg-file-upload__file-list">
|
|
3530
|
+
@for (file of files(); track file.name + file.size) {
|
|
3531
|
+
<li class="elg-file-upload__file-item">
|
|
3532
|
+
<div class="elg-file-upload__file-info">
|
|
3533
|
+
<svg class="elg-file-upload__file-icon" viewBox="0 0 20 20" fill="currentColor">
|
|
3534
|
+
<path fill-rule="evenodd" d="M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z" clip-rule="evenodd"/>
|
|
3535
|
+
</svg>
|
|
3536
|
+
<span class="elg-file-upload__file-name">{{ file.name }}</span>
|
|
3537
|
+
<span class="elg-file-upload__file-size">{{ formatSize(file.size) }}</span>
|
|
3538
|
+
</div>
|
|
3539
|
+
<button
|
|
3540
|
+
class="elg-file-upload__remove-btn"
|
|
3541
|
+
(click)="removeFile(file, $event)"
|
|
3542
|
+
type="button"
|
|
3543
|
+
aria-label="Remove file"
|
|
3544
|
+
>
|
|
3545
|
+
<svg viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3546
|
+
<path d="M2.5 2.5L9.5 9.5M9.5 2.5L2.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
3547
|
+
</svg>
|
|
3548
|
+
</button>
|
|
3549
|
+
</li>
|
|
3550
|
+
}
|
|
3551
|
+
</ul>
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
@if (errors().length > 0) {
|
|
3555
|
+
<ul class="elg-file-upload__errors">
|
|
3556
|
+
@for (error of errors(); track error) {
|
|
3557
|
+
<li class="elg-file-upload__error">{{ error }}</li>
|
|
3558
|
+
}
|
|
3559
|
+
</ul>
|
|
3560
|
+
}
|
|
3561
|
+
`, isInline: true, styles: [":host{display:block;width:100%}.elg-file-upload__native{display:none}.elg-file-upload__dropzone{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 24px;border:2px dashed var(--elg-color-border, #d1d5db);border-radius:var(--elg-border-radius, 6px);background:var(--elg-color-surface, #ffffff);cursor:pointer;transition:border-color .2s ease,background .2s ease}.elg-file-upload__dropzone:hover:not(.elg-file-upload__dropzone--disabled){border-color:var(--elg-color-primary, #3b82f6);background:var(--elg-color-primary-subtle, #eff6ff)}.elg-file-upload__dropzone--dragover{border-color:var(--elg-color-primary, #3b82f6);background:var(--elg-color-primary-subtle, #eff6ff);border-style:solid}.elg-file-upload__dropzone--disabled{cursor:not-allowed;opacity:.5;background:var(--elg-color-surface-disabled, #f3f4f6)}.elg-file-upload__icon{width:40px;height:40px;color:var(--elg-color-text-muted, #9ca3af);margin-bottom:12px}.elg-file-upload__text{display:flex;flex-direction:column;align-items:center;gap:4px;margin:0}.elg-file-upload__text-primary{font-size:var(--elg-font-size-sm, .875rem);font-weight:600;color:var(--elg-color-text, #111827)}.elg-file-upload__text-secondary{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-text-muted, #6b7280)}.elg-file-upload__hint{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-text-muted, #9ca3af);margin:4px 0 0}.elg-file-upload__file-list{list-style:none;padding:0;margin:12px 0 0;display:flex;flex-direction:column;gap:8px}.elg-file-upload__file-item{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border:1px solid var(--elg-color-border, #e5e7eb);border-radius:var(--elg-border-radius-sm, 4px);background:var(--elg-color-surface, #ffffff)}.elg-file-upload__file-info{display:flex;align-items:center;gap:8px;overflow:hidden}.elg-file-upload__file-icon{width:18px;height:18px;color:var(--elg-color-text-muted, #6b7280);flex-shrink:0}.elg-file-upload__file-name{font-size:var(--elg-font-size-sm, .875rem);color:var(--elg-color-text, #111827);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.elg-file-upload__file-size{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-text-muted, #6b7280);flex-shrink:0}.elg-file-upload__remove-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border:none;background:transparent;cursor:pointer;color:var(--elg-color-text-muted, #9ca3af);border-radius:var(--elg-border-radius-sm, 4px);transition:color .15s ease,background .15s ease;flex-shrink:0}.elg-file-upload__remove-btn:hover{color:var(--elg-color-danger, #ef4444);background:var(--elg-color-danger-subtle, #fef2f2)}.elg-file-upload__remove-btn svg{width:12px;height:12px}.elg-file-upload__errors{list-style:none;padding:0;margin:8px 0 0}.elg-file-upload__error{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-danger, #ef4444);padding:4px 0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3562
|
+
}
|
|
3563
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgFileUploadComponent, decorators: [{
|
|
3564
|
+
type: Component,
|
|
3565
|
+
args: [{ selector: 'elg-file-upload', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3566
|
+
'[class]': '"elg-file-upload"',
|
|
3567
|
+
'[class.elg-file-upload--disabled]': 'disabled()',
|
|
3568
|
+
}, template: `
|
|
3569
|
+
<div
|
|
3570
|
+
class="elg-file-upload__dropzone"
|
|
3571
|
+
[class.elg-file-upload__dropzone--dragover]="dragOver()"
|
|
3572
|
+
[class.elg-file-upload__dropzone--disabled]="disabled()"
|
|
3573
|
+
(dragover)="onDragOver($event)"
|
|
3574
|
+
(dragleave)="onDragLeave($event)"
|
|
3575
|
+
(drop)="onDrop($event)"
|
|
3576
|
+
(click)="openFileBrowser()"
|
|
3577
|
+
>
|
|
3578
|
+
<svg class="elg-file-upload__icon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3579
|
+
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M17 8l-5-5-5 5M12 3v12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3580
|
+
</svg>
|
|
3581
|
+
<p class="elg-file-upload__text">
|
|
3582
|
+
<span class="elg-file-upload__text-primary">Drop files here</span>
|
|
3583
|
+
<span class="elg-file-upload__text-secondary">or click to browse</span>
|
|
3584
|
+
</p>
|
|
3585
|
+
@if (accept()) {
|
|
3586
|
+
<p class="elg-file-upload__hint">Accepted: {{ accept() }}</p>
|
|
3587
|
+
}
|
|
3588
|
+
@if (maxSize()) {
|
|
3589
|
+
<p class="elg-file-upload__hint">Max size: {{ maxSize() }}MB</p>
|
|
3590
|
+
}
|
|
3591
|
+
</div>
|
|
3592
|
+
|
|
3593
|
+
<input
|
|
3594
|
+
#fileInput
|
|
3595
|
+
type="file"
|
|
3596
|
+
class="elg-file-upload__native"
|
|
3597
|
+
[accept]="accept()"
|
|
3598
|
+
[multiple]="multiple()"
|
|
3599
|
+
[disabled]="disabled()"
|
|
3600
|
+
(change)="onFileSelected($event)"
|
|
3601
|
+
/>
|
|
3602
|
+
|
|
3603
|
+
@if (files().length > 0) {
|
|
3604
|
+
<ul class="elg-file-upload__file-list">
|
|
3605
|
+
@for (file of files(); track file.name + file.size) {
|
|
3606
|
+
<li class="elg-file-upload__file-item">
|
|
3607
|
+
<div class="elg-file-upload__file-info">
|
|
3608
|
+
<svg class="elg-file-upload__file-icon" viewBox="0 0 20 20" fill="currentColor">
|
|
3609
|
+
<path fill-rule="evenodd" d="M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z" clip-rule="evenodd"/>
|
|
3610
|
+
</svg>
|
|
3611
|
+
<span class="elg-file-upload__file-name">{{ file.name }}</span>
|
|
3612
|
+
<span class="elg-file-upload__file-size">{{ formatSize(file.size) }}</span>
|
|
3613
|
+
</div>
|
|
3614
|
+
<button
|
|
3615
|
+
class="elg-file-upload__remove-btn"
|
|
3616
|
+
(click)="removeFile(file, $event)"
|
|
3617
|
+
type="button"
|
|
3618
|
+
aria-label="Remove file"
|
|
3619
|
+
>
|
|
3620
|
+
<svg viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3621
|
+
<path d="M2.5 2.5L9.5 9.5M9.5 2.5L2.5 9.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
3622
|
+
</svg>
|
|
3623
|
+
</button>
|
|
3624
|
+
</li>
|
|
3625
|
+
}
|
|
3626
|
+
</ul>
|
|
3627
|
+
}
|
|
3628
|
+
|
|
3629
|
+
@if (errors().length > 0) {
|
|
3630
|
+
<ul class="elg-file-upload__errors">
|
|
3631
|
+
@for (error of errors(); track error) {
|
|
3632
|
+
<li class="elg-file-upload__error">{{ error }}</li>
|
|
3633
|
+
}
|
|
3634
|
+
</ul>
|
|
3635
|
+
}
|
|
3636
|
+
`, styles: [":host{display:block;width:100%}.elg-file-upload__native{display:none}.elg-file-upload__dropzone{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 24px;border:2px dashed var(--elg-color-border, #d1d5db);border-radius:var(--elg-border-radius, 6px);background:var(--elg-color-surface, #ffffff);cursor:pointer;transition:border-color .2s ease,background .2s ease}.elg-file-upload__dropzone:hover:not(.elg-file-upload__dropzone--disabled){border-color:var(--elg-color-primary, #3b82f6);background:var(--elg-color-primary-subtle, #eff6ff)}.elg-file-upload__dropzone--dragover{border-color:var(--elg-color-primary, #3b82f6);background:var(--elg-color-primary-subtle, #eff6ff);border-style:solid}.elg-file-upload__dropzone--disabled{cursor:not-allowed;opacity:.5;background:var(--elg-color-surface-disabled, #f3f4f6)}.elg-file-upload__icon{width:40px;height:40px;color:var(--elg-color-text-muted, #9ca3af);margin-bottom:12px}.elg-file-upload__text{display:flex;flex-direction:column;align-items:center;gap:4px;margin:0}.elg-file-upload__text-primary{font-size:var(--elg-font-size-sm, .875rem);font-weight:600;color:var(--elg-color-text, #111827)}.elg-file-upload__text-secondary{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-text-muted, #6b7280)}.elg-file-upload__hint{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-text-muted, #9ca3af);margin:4px 0 0}.elg-file-upload__file-list{list-style:none;padding:0;margin:12px 0 0;display:flex;flex-direction:column;gap:8px}.elg-file-upload__file-item{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border:1px solid var(--elg-color-border, #e5e7eb);border-radius:var(--elg-border-radius-sm, 4px);background:var(--elg-color-surface, #ffffff)}.elg-file-upload__file-info{display:flex;align-items:center;gap:8px;overflow:hidden}.elg-file-upload__file-icon{width:18px;height:18px;color:var(--elg-color-text-muted, #6b7280);flex-shrink:0}.elg-file-upload__file-name{font-size:var(--elg-font-size-sm, .875rem);color:var(--elg-color-text, #111827);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.elg-file-upload__file-size{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-text-muted, #6b7280);flex-shrink:0}.elg-file-upload__remove-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;border:none;background:transparent;cursor:pointer;color:var(--elg-color-text-muted, #9ca3af);border-radius:var(--elg-border-radius-sm, 4px);transition:color .15s ease,background .15s ease;flex-shrink:0}.elg-file-upload__remove-btn:hover{color:var(--elg-color-danger, #ef4444);background:var(--elg-color-danger-subtle, #fef2f2)}.elg-file-upload__remove-btn svg{width:12px;height:12px}.elg-file-upload__errors{list-style:none;padding:0;margin:8px 0 0}.elg-file-upload__error{font-size:var(--elg-font-size-xs, .75rem);color:var(--elg-color-danger, #ef4444);padding:4px 0}\n"] }]
|
|
3637
|
+
}], propDecorators: { fileInputRef: [{
|
|
3638
|
+
type: ViewChild,
|
|
3639
|
+
args: ['fileInput', { static: true }]
|
|
3640
|
+
}] } });
|
|
3641
|
+
|
|
3642
|
+
class ElgToastService {
|
|
3643
|
+
_toasts = signal([]);
|
|
3644
|
+
_globalConfig = {
|
|
3645
|
+
position: 'top-right',
|
|
3646
|
+
maxVisible: 5,
|
|
3647
|
+
defaultDuration: 5000,
|
|
3648
|
+
};
|
|
3649
|
+
toasts = computed(() => this._toasts().slice(0, this._globalConfig.maxVisible));
|
|
3650
|
+
position = signal('top-right');
|
|
3651
|
+
configure(config) {
|
|
3652
|
+
this._globalConfig = { ...this._globalConfig, ...config };
|
|
3653
|
+
if (config.position)
|
|
3654
|
+
this.position.set(config.position);
|
|
3655
|
+
}
|
|
3656
|
+
show(config) {
|
|
3657
|
+
const id = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3658
|
+
const duration = config.duration ?? this._globalConfig.defaultDuration ?? 5000;
|
|
3659
|
+
const ref = {
|
|
3660
|
+
id,
|
|
3661
|
+
config: { severity: 'info', dismissible: true, ...config },
|
|
3662
|
+
dismiss: () => this.dismiss(id),
|
|
3663
|
+
};
|
|
3664
|
+
this._toasts.update(toasts => [ref, ...toasts]);
|
|
3665
|
+
if (duration > 0) {
|
|
3666
|
+
setTimeout(() => this.dismiss(id), duration);
|
|
3667
|
+
}
|
|
3668
|
+
return ref;
|
|
3669
|
+
}
|
|
3670
|
+
success(message, title) {
|
|
3671
|
+
return this.show({ message, title, severity: 'success' });
|
|
3672
|
+
}
|
|
3673
|
+
error(message, title) {
|
|
3674
|
+
return this.show({ message, title, severity: 'error', duration: 0 });
|
|
3675
|
+
}
|
|
3676
|
+
warning(message, title) {
|
|
3677
|
+
return this.show({ message, title, severity: 'warning' });
|
|
3678
|
+
}
|
|
3679
|
+
info(message, title) {
|
|
3680
|
+
return this.show({ message, title, severity: 'info' });
|
|
3681
|
+
}
|
|
3682
|
+
dismiss(id) {
|
|
3683
|
+
this._toasts.update(toasts => toasts.filter(t => t.id !== id));
|
|
3684
|
+
}
|
|
3685
|
+
dismissAll() {
|
|
3686
|
+
this._toasts.set([]);
|
|
3687
|
+
}
|
|
3688
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3689
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgToastService, providedIn: 'root' });
|
|
3690
|
+
}
|
|
3691
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgToastService, decorators: [{
|
|
3692
|
+
type: Injectable,
|
|
3693
|
+
args: [{ providedIn: 'root' }]
|
|
3694
|
+
}] });
|
|
3695
|
+
|
|
3696
|
+
class ElgToastContainerComponent {
|
|
3697
|
+
toastService = inject(ElgToastService);
|
|
3698
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgToastContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3699
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgToastContainerComponent, isStandalone: true, selector: "elg-toast-container", host: { properties: { "class": "\"elg-toast-container--\" + toastService.position()" }, classAttribute: "elg-toast-container" }, ngImport: i0, template: `
|
|
3700
|
+
@for (toast of toastService.toasts(); track toast.id) {
|
|
3701
|
+
<div
|
|
3702
|
+
class="elg-toast"
|
|
3703
|
+
[class]="'elg-toast--' + toast.config.severity"
|
|
3704
|
+
role="alert"
|
|
3705
|
+
aria-live="assertive"
|
|
3706
|
+
>
|
|
3707
|
+
<div class="elg-toast__icon">
|
|
3708
|
+
@switch (toast.config.severity) {
|
|
3709
|
+
@case ('success') { <span>✓</span> }
|
|
3710
|
+
@case ('error') { <span>✕</span> }
|
|
3711
|
+
@case ('warning') { <span>⚠</span> }
|
|
3712
|
+
@case ('info') { <span>ℹ</span> }
|
|
3713
|
+
}
|
|
3714
|
+
</div>
|
|
3715
|
+
<div class="elg-toast__content">
|
|
3716
|
+
@if (toast.config.title) {
|
|
3717
|
+
<div class="elg-toast__title">{{ toast.config.title }}</div>
|
|
3718
|
+
}
|
|
3719
|
+
<div class="elg-toast__message">{{ toast.config.message }}</div>
|
|
3720
|
+
</div>
|
|
3721
|
+
@if (toast.config.action) {
|
|
3722
|
+
<button class="elg-toast__action" (click)="toast.config.action!.onClick(); toast.dismiss()">
|
|
3723
|
+
{{ toast.config.action!.label }}
|
|
3724
|
+
</button>
|
|
3725
|
+
}
|
|
3726
|
+
@if (toast.config.dismissible) {
|
|
3727
|
+
<button class="elg-toast__close" (click)="toast.dismiss()" aria-label="Dismiss">×</button>
|
|
3728
|
+
}
|
|
3729
|
+
</div>
|
|
3730
|
+
}
|
|
3731
|
+
`, isInline: true, styles: [":host{position:fixed;z-index:var(--elg-z-index-tooltip, 1070);display:flex;flex-direction:column;gap:var(--elg-spacing-2, 8px);padding:var(--elg-spacing-4, 16px);pointer-events:none;max-width:420px;width:100%}:host(.elg-toast-container--top-right){top:0;right:0}:host(.elg-toast-container--top-left){top:0;left:0}:host(.elg-toast-container--bottom-right){bottom:0;right:0}:host(.elg-toast-container--bottom-left){bottom:0;left:0}:host(.elg-toast-container--top-center){top:0;left:50%;transform:translate(-50%)}:host(.elg-toast-container--bottom-center){bottom:0;left:50%;transform:translate(-50%)}.elg-toast{display:flex;align-items:flex-start;gap:var(--elg-spacing-3, 12px);padding:var(--elg-spacing-3, 12px) var(--elg-spacing-4, 16px);border-radius:var(--elg-border-radius-lg, 8px);background:var(--elg-color-surface-raised, #ffffff);border:1px solid var(--elg-color-border, #e2e8f0);box-shadow:var(--elg-shadow-lg, 0 10px 15px -3px rgba(0,0,0,.1));pointer-events:auto;animation:elg-toast-enter .3s ease-out}.elg-toast--success{border-left:4px solid var(--elg-color-success, #16a34a)}.elg-toast--error{border-left:4px solid var(--elg-color-error, #dc2626)}.elg-toast--warning{border-left:4px solid var(--elg-color-warning, #f59e0b)}.elg-toast--info{border-left:4px solid var(--elg-color-info, #3b82f6)}.elg-toast__icon{flex-shrink:0;width:20px;height:20px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;border-radius:50%}.elg-toast--success .elg-toast__icon{color:var(--elg-color-success, #16a34a)}.elg-toast--error .elg-toast__icon{color:var(--elg-color-error, #dc2626)}.elg-toast--warning .elg-toast__icon{color:var(--elg-color-warning, #f59e0b)}.elg-toast--info .elg-toast__icon{color:var(--elg-color-info, #3b82f6)}.elg-toast__content{flex:1;min-width:0}.elg-toast__title{font-size:var(--elg-font-size-sm, 14px);font-weight:var(--elg-font-weight-semibold, 600);color:var(--elg-color-foreground, #0f172a);margin-bottom:2px}.elg-toast__message{font-size:var(--elg-font-size-sm, 14px);color:var(--elg-color-foreground-muted, #64748b);line-height:1.4}.elg-toast__action{flex-shrink:0;background:none;border:none;font-size:var(--elg-font-size-sm, 14px);font-weight:var(--elg-font-weight-medium, 500);color:var(--elg-color-primary, #2563eb);cursor:pointer;padding:2px 8px;border-radius:var(--elg-border-radius-sm, 4px)}.elg-toast__action:hover{background:var(--elg-color-blue-50, #eff6ff)}.elg-toast__close{flex-shrink:0;background:none;border:none;font-size:18px;line-height:1;color:var(--elg-color-foreground-subtle, #94a3b8);cursor:pointer;padding:0 4px;border-radius:var(--elg-border-radius-sm, 4px)}.elg-toast__close:hover{color:var(--elg-color-foreground, #0f172a)}@keyframes elg-toast-enter{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3732
|
+
}
|
|
3733
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgToastContainerComponent, decorators: [{
|
|
3734
|
+
type: Component,
|
|
3735
|
+
args: [{ selector: 'elg-toast-container', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3736
|
+
'class': 'elg-toast-container',
|
|
3737
|
+
'[class]': '"elg-toast-container--" + toastService.position()',
|
|
3738
|
+
}, template: `
|
|
3739
|
+
@for (toast of toastService.toasts(); track toast.id) {
|
|
3740
|
+
<div
|
|
3741
|
+
class="elg-toast"
|
|
3742
|
+
[class]="'elg-toast--' + toast.config.severity"
|
|
3743
|
+
role="alert"
|
|
3744
|
+
aria-live="assertive"
|
|
3745
|
+
>
|
|
3746
|
+
<div class="elg-toast__icon">
|
|
3747
|
+
@switch (toast.config.severity) {
|
|
3748
|
+
@case ('success') { <span>✓</span> }
|
|
3749
|
+
@case ('error') { <span>✕</span> }
|
|
3750
|
+
@case ('warning') { <span>⚠</span> }
|
|
3751
|
+
@case ('info') { <span>ℹ</span> }
|
|
3752
|
+
}
|
|
3753
|
+
</div>
|
|
3754
|
+
<div class="elg-toast__content">
|
|
3755
|
+
@if (toast.config.title) {
|
|
3756
|
+
<div class="elg-toast__title">{{ toast.config.title }}</div>
|
|
3757
|
+
}
|
|
3758
|
+
<div class="elg-toast__message">{{ toast.config.message }}</div>
|
|
3759
|
+
</div>
|
|
3760
|
+
@if (toast.config.action) {
|
|
3761
|
+
<button class="elg-toast__action" (click)="toast.config.action!.onClick(); toast.dismiss()">
|
|
3762
|
+
{{ toast.config.action!.label }}
|
|
3763
|
+
</button>
|
|
3764
|
+
}
|
|
3765
|
+
@if (toast.config.dismissible) {
|
|
3766
|
+
<button class="elg-toast__close" (click)="toast.dismiss()" aria-label="Dismiss">×</button>
|
|
3767
|
+
}
|
|
3768
|
+
</div>
|
|
3769
|
+
}
|
|
3770
|
+
`, styles: [":host{position:fixed;z-index:var(--elg-z-index-tooltip, 1070);display:flex;flex-direction:column;gap:var(--elg-spacing-2, 8px);padding:var(--elg-spacing-4, 16px);pointer-events:none;max-width:420px;width:100%}:host(.elg-toast-container--top-right){top:0;right:0}:host(.elg-toast-container--top-left){top:0;left:0}:host(.elg-toast-container--bottom-right){bottom:0;right:0}:host(.elg-toast-container--bottom-left){bottom:0;left:0}:host(.elg-toast-container--top-center){top:0;left:50%;transform:translate(-50%)}:host(.elg-toast-container--bottom-center){bottom:0;left:50%;transform:translate(-50%)}.elg-toast{display:flex;align-items:flex-start;gap:var(--elg-spacing-3, 12px);padding:var(--elg-spacing-3, 12px) var(--elg-spacing-4, 16px);border-radius:var(--elg-border-radius-lg, 8px);background:var(--elg-color-surface-raised, #ffffff);border:1px solid var(--elg-color-border, #e2e8f0);box-shadow:var(--elg-shadow-lg, 0 10px 15px -3px rgba(0,0,0,.1));pointer-events:auto;animation:elg-toast-enter .3s ease-out}.elg-toast--success{border-left:4px solid var(--elg-color-success, #16a34a)}.elg-toast--error{border-left:4px solid var(--elg-color-error, #dc2626)}.elg-toast--warning{border-left:4px solid var(--elg-color-warning, #f59e0b)}.elg-toast--info{border-left:4px solid var(--elg-color-info, #3b82f6)}.elg-toast__icon{flex-shrink:0;width:20px;height:20px;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;border-radius:50%}.elg-toast--success .elg-toast__icon{color:var(--elg-color-success, #16a34a)}.elg-toast--error .elg-toast__icon{color:var(--elg-color-error, #dc2626)}.elg-toast--warning .elg-toast__icon{color:var(--elg-color-warning, #f59e0b)}.elg-toast--info .elg-toast__icon{color:var(--elg-color-info, #3b82f6)}.elg-toast__content{flex:1;min-width:0}.elg-toast__title{font-size:var(--elg-font-size-sm, 14px);font-weight:var(--elg-font-weight-semibold, 600);color:var(--elg-color-foreground, #0f172a);margin-bottom:2px}.elg-toast__message{font-size:var(--elg-font-size-sm, 14px);color:var(--elg-color-foreground-muted, #64748b);line-height:1.4}.elg-toast__action{flex-shrink:0;background:none;border:none;font-size:var(--elg-font-size-sm, 14px);font-weight:var(--elg-font-weight-medium, 500);color:var(--elg-color-primary, #2563eb);cursor:pointer;padding:2px 8px;border-radius:var(--elg-border-radius-sm, 4px)}.elg-toast__action:hover{background:var(--elg-color-blue-50, #eff6ff)}.elg-toast__close{flex-shrink:0;background:none;border:none;font-size:18px;line-height:1;color:var(--elg-color-foreground-subtle, #94a3b8);cursor:pointer;padding:0 4px;border-radius:var(--elg-border-radius-sm, 4px)}.elg-toast__close:hover{color:var(--elg-color-foreground, #0f172a)}@keyframes elg-toast-enter{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}\n"] }]
|
|
3771
|
+
}] });
|
|
3772
|
+
|
|
3773
|
+
class ElgBreadcrumbComponent {
|
|
3774
|
+
items = input([]);
|
|
3775
|
+
separator = input('/');
|
|
3776
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgBreadcrumbComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3777
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgBreadcrumbComponent, isStandalone: true, selector: "elg-breadcrumb", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, separator: { classPropertyName: "separator", publicName: "separator", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "navigation", "aria-label": "Breadcrumb" }, classAttribute: "elg-breadcrumb" }, ngImport: i0, template: `
|
|
3778
|
+
<ol class="elg-breadcrumb__list">
|
|
3779
|
+
@for (item of items(); track $index; let last = $last) {
|
|
3780
|
+
<li class="elg-breadcrumb__item" [class.elg-breadcrumb__item--active]="last">
|
|
3781
|
+
@if (!last && item.href) {
|
|
3782
|
+
<a class="elg-breadcrumb__link" [attr.href]="item.href">{{ item.label }}</a>
|
|
3783
|
+
} @else if (!last) {
|
|
3784
|
+
<span class="elg-breadcrumb__link elg-breadcrumb__link--clickable">{{ item.label }}</span>
|
|
3785
|
+
} @else {
|
|
3786
|
+
<span class="elg-breadcrumb__current" aria-current="page">{{ item.label }}</span>
|
|
3787
|
+
}
|
|
3788
|
+
@if (!last) {
|
|
3789
|
+
<span class="elg-breadcrumb__separator" aria-hidden="true">
|
|
3790
|
+
{{ separator() }}
|
|
3791
|
+
</span>
|
|
3792
|
+
}
|
|
3793
|
+
</li>
|
|
3794
|
+
}
|
|
3795
|
+
</ol>
|
|
3796
|
+
`, isInline: true, styles: [":host{display:block}.elg-breadcrumb__list{display:flex;align-items:center;gap:var(--elg-spacing-1, 4px);list-style:none;margin:0;padding:0;font-size:var(--elg-font-size-sm, 14px)}.elg-breadcrumb__item{display:flex;align-items:center;gap:var(--elg-spacing-1, 4px)}.elg-breadcrumb__link{color:var(--elg-color-foreground-muted, #64748b);text-decoration:none;transition:color .15s}.elg-breadcrumb__link:hover,.elg-breadcrumb__link--clickable:hover{color:var(--elg-color-primary, #2563eb);cursor:pointer}.elg-breadcrumb__current{color:var(--elg-color-foreground, #0f172a);font-weight:var(--elg-font-weight-medium, 500)}.elg-breadcrumb__separator{color:var(--elg-color-foreground-subtle, #94a3b8);font-size:12px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3797
|
+
}
|
|
3798
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgBreadcrumbComponent, decorators: [{
|
|
3799
|
+
type: Component,
|
|
3800
|
+
args: [{ selector: 'elg-breadcrumb', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'elg-breadcrumb', role: 'navigation', 'aria-label': 'Breadcrumb' }, template: `
|
|
3801
|
+
<ol class="elg-breadcrumb__list">
|
|
3802
|
+
@for (item of items(); track $index; let last = $last) {
|
|
3803
|
+
<li class="elg-breadcrumb__item" [class.elg-breadcrumb__item--active]="last">
|
|
3804
|
+
@if (!last && item.href) {
|
|
3805
|
+
<a class="elg-breadcrumb__link" [attr.href]="item.href">{{ item.label }}</a>
|
|
3806
|
+
} @else if (!last) {
|
|
3807
|
+
<span class="elg-breadcrumb__link elg-breadcrumb__link--clickable">{{ item.label }}</span>
|
|
3808
|
+
} @else {
|
|
3809
|
+
<span class="elg-breadcrumb__current" aria-current="page">{{ item.label }}</span>
|
|
3810
|
+
}
|
|
3811
|
+
@if (!last) {
|
|
3812
|
+
<span class="elg-breadcrumb__separator" aria-hidden="true">
|
|
3813
|
+
{{ separator() }}
|
|
3814
|
+
</span>
|
|
3815
|
+
}
|
|
3816
|
+
</li>
|
|
3817
|
+
}
|
|
3818
|
+
</ol>
|
|
3819
|
+
`, styles: [":host{display:block}.elg-breadcrumb__list{display:flex;align-items:center;gap:var(--elg-spacing-1, 4px);list-style:none;margin:0;padding:0;font-size:var(--elg-font-size-sm, 14px)}.elg-breadcrumb__item{display:flex;align-items:center;gap:var(--elg-spacing-1, 4px)}.elg-breadcrumb__link{color:var(--elg-color-foreground-muted, #64748b);text-decoration:none;transition:color .15s}.elg-breadcrumb__link:hover,.elg-breadcrumb__link--clickable:hover{color:var(--elg-color-primary, #2563eb);cursor:pointer}.elg-breadcrumb__current{color:var(--elg-color-foreground, #0f172a);font-weight:var(--elg-font-weight-medium, 500)}.elg-breadcrumb__separator{color:var(--elg-color-foreground-subtle, #94a3b8);font-size:12px}\n"] }]
|
|
3820
|
+
}] });
|
|
3821
|
+
|
|
3822
|
+
const DEFAULT_LABELS = {
|
|
3823
|
+
paginationItemsPerPage: 'Items per page',
|
|
3824
|
+
paginationOf: 'of',
|
|
3825
|
+
paginationNext: 'Next',
|
|
3826
|
+
paginationPrevious: 'Previous',
|
|
3827
|
+
tableEmpty: 'No data available',
|
|
3828
|
+
tableLoading: 'Loading...',
|
|
3829
|
+
tableSelectAll: 'Select all',
|
|
3830
|
+
dialogClose: 'Close',
|
|
3831
|
+
fileUploadDragDrop: 'Drag and drop files here or',
|
|
3832
|
+
fileUploadBrowse: 'Browse',
|
|
3833
|
+
fileUploadMaxSize: 'Max file size:',
|
|
3834
|
+
fileUploadInvalidType: 'Invalid file type',
|
|
3835
|
+
datePickerPlaceholder: 'Select date',
|
|
3836
|
+
datePickerToday: 'Today',
|
|
3837
|
+
autocompleteNoResults: 'No results found',
|
|
3838
|
+
autocompleteLoading: 'Loading...',
|
|
3839
|
+
required: 'Required',
|
|
3840
|
+
optional: 'Optional',
|
|
3841
|
+
loading: 'Loading...',
|
|
3842
|
+
cancel: 'Cancel',
|
|
3843
|
+
confirm: 'Confirm',
|
|
3844
|
+
save: 'Save',
|
|
3845
|
+
delete: 'Delete',
|
|
3846
|
+
close: 'Close',
|
|
3847
|
+
};
|
|
3848
|
+
class ElgLocaleService {
|
|
3849
|
+
_labels = signal(DEFAULT_LABELS);
|
|
3850
|
+
labels = this._labels.asReadonly();
|
|
3851
|
+
setLabels(labels) {
|
|
3852
|
+
this._labels.update(current => ({ ...current, ...labels }));
|
|
3853
|
+
}
|
|
3854
|
+
resetLabels() {
|
|
3855
|
+
this._labels.set(DEFAULT_LABELS);
|
|
3856
|
+
}
|
|
3857
|
+
get(key) {
|
|
3858
|
+
return this._labels()[key] || '';
|
|
3859
|
+
}
|
|
3860
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgLocaleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3861
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgLocaleService, providedIn: 'root' });
|
|
3862
|
+
}
|
|
3863
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgLocaleService, decorators: [{
|
|
3864
|
+
type: Injectable,
|
|
3865
|
+
args: [{ providedIn: 'root' }]
|
|
3866
|
+
}] });
|
|
3867
|
+
|
|
3868
|
+
class ElgSkeletonComponent {
|
|
3869
|
+
variant = input('text');
|
|
3870
|
+
width = input('100%');
|
|
3871
|
+
height = input('');
|
|
3872
|
+
animate = input(true);
|
|
3873
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgSkeletonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3874
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: ElgSkeletonComponent, isStandalone: true, selector: "elg-skeleton", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "progressbar", "aria-busy": "true", "aria-valuemin": "0", "aria-valuemax": "100" }, properties: { "class.elg-skeleton--text": "variant() === \"text\"", "class.elg-skeleton--circular": "variant() === \"circular\"", "class.elg-skeleton--rectangular": "variant() === \"rectangular\"", "class.elg-skeleton--rounded": "variant() === \"rounded\"", "class.elg-skeleton--animate": "animate()", "style.width": "width()", "style.height": "height()" }, classAttribute: "elg-skeleton" }, ngImport: i0, template: ``, isInline: true, styles: [":host{display:block;background:var(--elg-skeleton-bg, var(--elg-color-neutral-200, #e2e8f0));border-radius:var(--elg-border-radius-sm, 4px)}:host(.elg-skeleton--text){height:1em;border-radius:var(--elg-border-radius-sm, 4px)}:host(.elg-skeleton--circular){border-radius:50%}:host(.elg-skeleton--rounded){border-radius:var(--elg-border-radius-lg, 8px)}:host(.elg-skeleton--rectangular){border-radius:0}:host(.elg-skeleton--animate){animation:elg-skeleton-pulse 1.5s ease-in-out infinite}@keyframes elg-skeleton-pulse{0%{opacity:1}50%{opacity:.4}to{opacity:1}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3875
|
+
}
|
|
3876
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgSkeletonComponent, decorators: [{
|
|
3877
|
+
type: Component,
|
|
3878
|
+
args: [{ selector: 'elg-skeleton', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3879
|
+
class: 'elg-skeleton',
|
|
3880
|
+
'[class.elg-skeleton--text]': 'variant() === "text"',
|
|
3881
|
+
'[class.elg-skeleton--circular]': 'variant() === "circular"',
|
|
3882
|
+
'[class.elg-skeleton--rectangular]': 'variant() === "rectangular"',
|
|
3883
|
+
'[class.elg-skeleton--rounded]': 'variant() === "rounded"',
|
|
3884
|
+
'[class.elg-skeleton--animate]': 'animate()',
|
|
3885
|
+
'[style.width]': 'width()',
|
|
3886
|
+
'[style.height]': 'height()',
|
|
3887
|
+
'role': 'progressbar',
|
|
3888
|
+
'aria-busy': 'true',
|
|
3889
|
+
'aria-valuemin': '0',
|
|
3890
|
+
'aria-valuemax': '100',
|
|
3891
|
+
}, template: ``, styles: [":host{display:block;background:var(--elg-skeleton-bg, var(--elg-color-neutral-200, #e2e8f0));border-radius:var(--elg-border-radius-sm, 4px)}:host(.elg-skeleton--text){height:1em;border-radius:var(--elg-border-radius-sm, 4px)}:host(.elg-skeleton--circular){border-radius:50%}:host(.elg-skeleton--rounded){border-radius:var(--elg-border-radius-lg, 8px)}:host(.elg-skeleton--rectangular){border-radius:0}:host(.elg-skeleton--animate){animation:elg-skeleton-pulse 1.5s ease-in-out infinite}@keyframes elg-skeleton-pulse{0%{opacity:1}50%{opacity:.4}to{opacity:1}}\n"] }]
|
|
3892
|
+
}] });
|
|
3893
|
+
|
|
3894
|
+
class ElgSidebarComponent {
|
|
3895
|
+
groups = input([]);
|
|
3896
|
+
collapsed = input(false);
|
|
3897
|
+
activeId = input('');
|
|
3898
|
+
itemSelected = output();
|
|
3899
|
+
collapsedChange = output();
|
|
3900
|
+
_collapsed = signal(false);
|
|
3901
|
+
toggleCollapse() {
|
|
3902
|
+
this._collapsed.update(v => !v);
|
|
3903
|
+
this.collapsedChange.emit(this._collapsed());
|
|
3904
|
+
}
|
|
3905
|
+
onItemClick(item) {
|
|
3906
|
+
if (!item.disabled) {
|
|
3907
|
+
this.itemSelected.emit(item);
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgSidebarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3911
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgSidebarComponent, isStandalone: true, selector: "elg-sidebar", inputs: { groups: { classPropertyName: "groups", publicName: "groups", isSignal: true, isRequired: false, transformFunction: null }, collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null }, activeId: { classPropertyName: "activeId", publicName: "activeId", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelected: "itemSelected", collapsedChange: "collapsedChange" }, host: { attributes: { "role": "navigation", "aria-label": "Main navigation" }, properties: { "class.elg-sidebar--collapsed": "collapsed()" }, classAttribute: "elg-sidebar" }, ngImport: i0, template: `
|
|
3912
|
+
<div class="elg-sidebar__header">
|
|
3913
|
+
<ng-content select="[elgSidebarHeader]" />
|
|
3914
|
+
<button class="elg-sidebar__toggle" (click)="toggleCollapse()" [attr.aria-label]="collapsed() ? 'Expand sidebar' : 'Collapse sidebar'">
|
|
3915
|
+
<span class="elg-sidebar__toggle-icon">{{ collapsed() ? '→' : '←' }}</span>
|
|
3916
|
+
</button>
|
|
3917
|
+
</div>
|
|
3918
|
+
<nav class="elg-sidebar__nav">
|
|
3919
|
+
@for (group of groups(); track $index) {
|
|
3920
|
+
<div class="elg-sidebar__group">
|
|
3921
|
+
@if (group.label && !collapsed()) {
|
|
3922
|
+
<div class="elg-sidebar__group-label">{{ group.label }}</div>
|
|
3923
|
+
}
|
|
3924
|
+
@for (item of group.items; track item.id) {
|
|
3925
|
+
<button
|
|
3926
|
+
class="elg-sidebar__item"
|
|
3927
|
+
[class.elg-sidebar__item--active]="activeId() === item.id"
|
|
3928
|
+
[class.elg-sidebar__item--disabled]="item.disabled"
|
|
3929
|
+
[disabled]="item.disabled"
|
|
3930
|
+
(click)="onItemClick(item)"
|
|
3931
|
+
[title]="collapsed() ? item.label : ''"
|
|
3932
|
+
>
|
|
3933
|
+
@if (item.icon) {
|
|
3934
|
+
<span class="elg-sidebar__item-icon">{{ item.icon }}</span>
|
|
3935
|
+
}
|
|
3936
|
+
@if (!collapsed()) {
|
|
3937
|
+
<span class="elg-sidebar__item-label">{{ item.label }}</span>
|
|
3938
|
+
@if (item.badge) {
|
|
3939
|
+
<span class="elg-sidebar__item-badge">{{ item.badge }}</span>
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
</button>
|
|
3943
|
+
}
|
|
3944
|
+
</div>
|
|
3945
|
+
}
|
|
3946
|
+
</nav>
|
|
3947
|
+
<div class="elg-sidebar__footer">
|
|
3948
|
+
<ng-content select="[elgSidebarFooter]" />
|
|
3949
|
+
</div>
|
|
3950
|
+
`, isInline: true, styles: [":host{display:flex;flex-direction:column;width:var(--elg-sidebar-width, 260px);height:100%;background:var(--elg-sidebar-bg, var(--elg-color-surface, #f8fafc));border-right:1px solid var(--elg-color-border, #e2e8f0);transition:width .2s ease;overflow:hidden}:host(.elg-sidebar--collapsed){width:var(--elg-sidebar-collapsed-width, 60px)}.elg-sidebar__header{display:flex;align-items:center;justify-content:space-between;padding:var(--elg-spacing-3, 12px);border-bottom:1px solid var(--elg-color-border, #e2e8f0);min-height:56px}.elg-sidebar__toggle{background:none;border:none;cursor:pointer;padding:var(--elg-spacing-1, 4px);border-radius:var(--elg-border-radius-sm, 4px);color:var(--elg-color-foreground-muted, #64748b)}.elg-sidebar__toggle:hover{background:var(--elg-color-neutral-200, #e2e8f0)}.elg-sidebar__nav{flex:1;overflow-y:auto;padding:var(--elg-spacing-2, 8px)}.elg-sidebar__group{margin-bottom:var(--elg-spacing-2, 8px)}.elg-sidebar__group-label{font-size:var(--elg-font-size-xs, 12px);font-weight:var(--elg-font-weight-semibold, 600);color:var(--elg-color-foreground-muted, #64748b);text-transform:uppercase;letter-spacing:.05em;padding:var(--elg-spacing-2, 8px) var(--elg-spacing-3, 12px)}.elg-sidebar__item{display:flex;align-items:center;gap:var(--elg-spacing-3, 12px);width:100%;padding:var(--elg-spacing-2, 8px) var(--elg-spacing-3, 12px);border:none;background:none;border-radius:var(--elg-border-radius-md, 6px);font-size:var(--elg-font-size-sm, 14px);color:var(--elg-color-foreground, #0f172a);cursor:pointer;text-align:left;transition:background .15s}.elg-sidebar__item:hover{background:var(--elg-color-neutral-100, #f1f5f9)}.elg-sidebar__item--active{background:var(--elg-color-blue-50, #eff6ff);color:var(--elg-color-primary, #2563eb);font-weight:var(--elg-font-weight-medium, 500)}.elg-sidebar__item--disabled{opacity:.5;cursor:not-allowed}.elg-sidebar__item-icon{font-size:18px;flex-shrink:0}.elg-sidebar__item-label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.elg-sidebar__item-badge{font-size:11px;background:var(--elg-color-primary, #2563eb);color:#fff;padding:1px 6px;border-radius:var(--elg-border-radius-full, 9999px);font-weight:var(--elg-font-weight-medium, 500)}.elg-sidebar__footer{padding:var(--elg-spacing-3, 12px);border-top:1px solid var(--elg-color-border, #e2e8f0)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3951
|
+
}
|
|
3952
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgSidebarComponent, decorators: [{
|
|
3953
|
+
type: Component,
|
|
3954
|
+
args: [{ selector: 'elg-sidebar', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
3955
|
+
class: 'elg-sidebar',
|
|
3956
|
+
'[class.elg-sidebar--collapsed]': 'collapsed()',
|
|
3957
|
+
'role': 'navigation',
|
|
3958
|
+
'aria-label': 'Main navigation',
|
|
3959
|
+
}, template: `
|
|
3960
|
+
<div class="elg-sidebar__header">
|
|
3961
|
+
<ng-content select="[elgSidebarHeader]" />
|
|
3962
|
+
<button class="elg-sidebar__toggle" (click)="toggleCollapse()" [attr.aria-label]="collapsed() ? 'Expand sidebar' : 'Collapse sidebar'">
|
|
3963
|
+
<span class="elg-sidebar__toggle-icon">{{ collapsed() ? '→' : '←' }}</span>
|
|
3964
|
+
</button>
|
|
3965
|
+
</div>
|
|
3966
|
+
<nav class="elg-sidebar__nav">
|
|
3967
|
+
@for (group of groups(); track $index) {
|
|
3968
|
+
<div class="elg-sidebar__group">
|
|
3969
|
+
@if (group.label && !collapsed()) {
|
|
3970
|
+
<div class="elg-sidebar__group-label">{{ group.label }}</div>
|
|
3971
|
+
}
|
|
3972
|
+
@for (item of group.items; track item.id) {
|
|
3973
|
+
<button
|
|
3974
|
+
class="elg-sidebar__item"
|
|
3975
|
+
[class.elg-sidebar__item--active]="activeId() === item.id"
|
|
3976
|
+
[class.elg-sidebar__item--disabled]="item.disabled"
|
|
3977
|
+
[disabled]="item.disabled"
|
|
3978
|
+
(click)="onItemClick(item)"
|
|
3979
|
+
[title]="collapsed() ? item.label : ''"
|
|
3980
|
+
>
|
|
3981
|
+
@if (item.icon) {
|
|
3982
|
+
<span class="elg-sidebar__item-icon">{{ item.icon }}</span>
|
|
3983
|
+
}
|
|
3984
|
+
@if (!collapsed()) {
|
|
3985
|
+
<span class="elg-sidebar__item-label">{{ item.label }}</span>
|
|
3986
|
+
@if (item.badge) {
|
|
3987
|
+
<span class="elg-sidebar__item-badge">{{ item.badge }}</span>
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
</button>
|
|
3991
|
+
}
|
|
3992
|
+
</div>
|
|
3993
|
+
}
|
|
3994
|
+
</nav>
|
|
3995
|
+
<div class="elg-sidebar__footer">
|
|
3996
|
+
<ng-content select="[elgSidebarFooter]" />
|
|
3997
|
+
</div>
|
|
3998
|
+
`, styles: [":host{display:flex;flex-direction:column;width:var(--elg-sidebar-width, 260px);height:100%;background:var(--elg-sidebar-bg, var(--elg-color-surface, #f8fafc));border-right:1px solid var(--elg-color-border, #e2e8f0);transition:width .2s ease;overflow:hidden}:host(.elg-sidebar--collapsed){width:var(--elg-sidebar-collapsed-width, 60px)}.elg-sidebar__header{display:flex;align-items:center;justify-content:space-between;padding:var(--elg-spacing-3, 12px);border-bottom:1px solid var(--elg-color-border, #e2e8f0);min-height:56px}.elg-sidebar__toggle{background:none;border:none;cursor:pointer;padding:var(--elg-spacing-1, 4px);border-radius:var(--elg-border-radius-sm, 4px);color:var(--elg-color-foreground-muted, #64748b)}.elg-sidebar__toggle:hover{background:var(--elg-color-neutral-200, #e2e8f0)}.elg-sidebar__nav{flex:1;overflow-y:auto;padding:var(--elg-spacing-2, 8px)}.elg-sidebar__group{margin-bottom:var(--elg-spacing-2, 8px)}.elg-sidebar__group-label{font-size:var(--elg-font-size-xs, 12px);font-weight:var(--elg-font-weight-semibold, 600);color:var(--elg-color-foreground-muted, #64748b);text-transform:uppercase;letter-spacing:.05em;padding:var(--elg-spacing-2, 8px) var(--elg-spacing-3, 12px)}.elg-sidebar__item{display:flex;align-items:center;gap:var(--elg-spacing-3, 12px);width:100%;padding:var(--elg-spacing-2, 8px) var(--elg-spacing-3, 12px);border:none;background:none;border-radius:var(--elg-border-radius-md, 6px);font-size:var(--elg-font-size-sm, 14px);color:var(--elg-color-foreground, #0f172a);cursor:pointer;text-align:left;transition:background .15s}.elg-sidebar__item:hover{background:var(--elg-color-neutral-100, #f1f5f9)}.elg-sidebar__item--active{background:var(--elg-color-blue-50, #eff6ff);color:var(--elg-color-primary, #2563eb);font-weight:var(--elg-font-weight-medium, 500)}.elg-sidebar__item--disabled{opacity:.5;cursor:not-allowed}.elg-sidebar__item-icon{font-size:18px;flex-shrink:0}.elg-sidebar__item-label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.elg-sidebar__item-badge{font-size:11px;background:var(--elg-color-primary, #2563eb);color:#fff;padding:1px 6px;border-radius:var(--elg-border-radius-full, 9999px);font-weight:var(--elg-font-weight-medium, 500)}.elg-sidebar__footer{padding:var(--elg-spacing-3, 12px);border-top:1px solid var(--elg-color-border, #e2e8f0)}\n"] }]
|
|
3999
|
+
}] });
|
|
4000
|
+
|
|
4001
|
+
class ElgNumberInputComponent {
|
|
4002
|
+
min = input(null);
|
|
4003
|
+
max = input(null);
|
|
4004
|
+
step = input(1);
|
|
4005
|
+
prefix = input('');
|
|
4006
|
+
suffix = input('');
|
|
4007
|
+
placeholder = input('0');
|
|
4008
|
+
showControls = input(true);
|
|
4009
|
+
decimals = input(2);
|
|
4010
|
+
thousandSeparator = input(',');
|
|
4011
|
+
valueChange = output();
|
|
4012
|
+
isDisabled = signal(false);
|
|
4013
|
+
isFocused = signal(false);
|
|
4014
|
+
_value = signal(null);
|
|
4015
|
+
onChange = () => { };
|
|
4016
|
+
onTouched = () => { };
|
|
4017
|
+
displayValue = signal('');
|
|
4018
|
+
writeValue(val) {
|
|
4019
|
+
this._value.set(val);
|
|
4020
|
+
this.displayValue.set(val !== null ? this.formatNumber(val) : '');
|
|
4021
|
+
}
|
|
4022
|
+
registerOnChange(fn) { this.onChange = fn; }
|
|
4023
|
+
registerOnTouched(fn) { this.onTouched = fn; }
|
|
4024
|
+
setDisabledState(disabled) { this.isDisabled.set(disabled); }
|
|
4025
|
+
onInput(event) {
|
|
4026
|
+
const raw = event.target.value;
|
|
4027
|
+
const cleaned = raw.replace(new RegExp(`[^0-9.\\-]`, 'g'), '');
|
|
4028
|
+
const num = cleaned ? parseFloat(cleaned) : null;
|
|
4029
|
+
this.setValue(num);
|
|
4030
|
+
}
|
|
4031
|
+
onFocus() { this.isFocused.set(true); }
|
|
4032
|
+
onBlur() {
|
|
4033
|
+
this.isFocused.set(false);
|
|
4034
|
+
this.onTouched();
|
|
4035
|
+
// Reformat on blur
|
|
4036
|
+
if (this._value() !== null) {
|
|
4037
|
+
this.displayValue.set(this.formatNumber(this._value()));
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
onKeydown(e) {
|
|
4041
|
+
if (e.key === 'ArrowUp') {
|
|
4042
|
+
e.preventDefault();
|
|
4043
|
+
this.increment();
|
|
4044
|
+
}
|
|
4045
|
+
if (e.key === 'ArrowDown') {
|
|
4046
|
+
e.preventDefault();
|
|
4047
|
+
this.decrement();
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
increment() {
|
|
4051
|
+
const current = this._value() ?? 0;
|
|
4052
|
+
this.setValue(current + this.step());
|
|
4053
|
+
}
|
|
4054
|
+
decrement() {
|
|
4055
|
+
const current = this._value() ?? 0;
|
|
4056
|
+
this.setValue(current - this.step());
|
|
4057
|
+
}
|
|
4058
|
+
setValue(num) {
|
|
4059
|
+
if (num !== null) {
|
|
4060
|
+
if (this.min() !== null && num < this.min())
|
|
4061
|
+
num = this.min();
|
|
4062
|
+
if (this.max() !== null && num > this.max())
|
|
4063
|
+
num = this.max();
|
|
4064
|
+
num = parseFloat(num.toFixed(this.decimals()));
|
|
4065
|
+
}
|
|
4066
|
+
this._value.set(num);
|
|
4067
|
+
this.displayValue.set(num !== null ? this.formatNumber(num) : '');
|
|
4068
|
+
this.onChange(num);
|
|
4069
|
+
this.valueChange.emit(num);
|
|
4070
|
+
}
|
|
4071
|
+
formatNumber(n) {
|
|
4072
|
+
const parts = n.toFixed(this.decimals()).split('.');
|
|
4073
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator());
|
|
4074
|
+
return this.decimals() > 0 ? parts.join('.') : parts[0];
|
|
4075
|
+
}
|
|
4076
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgNumberInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4077
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgNumberInputComponent, isStandalone: true, selector: "elg-number-input", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, showControls: { classPropertyName: "showControls", publicName: "showControls", isSignal: true, isRequired: false, transformFunction: null }, decimals: { classPropertyName: "decimals", publicName: "decimals", isSignal: true, isRequired: false, transformFunction: null }, thousandSeparator: { classPropertyName: "thousandSeparator", publicName: "thousandSeparator", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { properties: { "class.elg-number-input--disabled": "isDisabled()", "class.elg-number-input--focused": "isFocused()" }, classAttribute: "elg-number-input" }, providers: [{
|
|
4078
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4079
|
+
useExisting: forwardRef(() => ElgNumberInputComponent),
|
|
4080
|
+
multi: true,
|
|
4081
|
+
}], ngImport: i0, template: `
|
|
4082
|
+
@if (prefix()) {
|
|
4083
|
+
<span class="elg-number-input__prefix">{{ prefix() }}</span>
|
|
4084
|
+
}
|
|
4085
|
+
<input
|
|
4086
|
+
type="text"
|
|
4087
|
+
class="elg-number-input__field"
|
|
4088
|
+
[value]="displayValue()"
|
|
4089
|
+
[placeholder]="placeholder()"
|
|
4090
|
+
[disabled]="isDisabled()"
|
|
4091
|
+
[attr.min]="min()"
|
|
4092
|
+
[attr.max]="max()"
|
|
4093
|
+
[attr.step]="step()"
|
|
4094
|
+
(input)="onInput($event)"
|
|
4095
|
+
(blur)="onBlur()"
|
|
4096
|
+
(focus)="onFocus()"
|
|
4097
|
+
(keydown)="onKeydown($event)"
|
|
4098
|
+
/>
|
|
4099
|
+
@if (suffix()) {
|
|
4100
|
+
<span class="elg-number-input__suffix">{{ suffix() }}</span>
|
|
4101
|
+
}
|
|
4102
|
+
@if (showControls()) {
|
|
4103
|
+
<div class="elg-number-input__controls">
|
|
4104
|
+
<button type="button" class="elg-number-input__btn" (click)="increment()" [disabled]="isDisabled()" tabindex="-1" aria-label="Increment">+</button>
|
|
4105
|
+
<button type="button" class="elg-number-input__btn" (click)="decrement()" [disabled]="isDisabled()" tabindex="-1" aria-label="Decrement">−</button>
|
|
4106
|
+
</div>
|
|
4107
|
+
}
|
|
4108
|
+
`, isInline: true, styles: [":host{display:flex;align-items:center;gap:0;height:var(--elg-input-height, 36px);border:1px solid var(--elg-input-border-color, #cbd5e1);border-radius:var(--elg-input-border-radius, 6px);background:var(--elg-input-background, #fff);padding:0 var(--elg-input-padding-x, 12px);font-size:var(--elg-input-font-size, 14px);transition:border-color .15s,box-shadow .15s}:host(.elg-number-input--focused){border-color:var(--elg-input-border-color-focus, #3b82f6);box-shadow:0 0 0 2px #3b82f626}:host(.elg-number-input--disabled){opacity:.5;cursor:not-allowed;background:var(--elg-color-neutral-100)}.elg-number-input__field{flex:1;border:none;outline:none;background:transparent;font-size:inherit;font-family:inherit;text-align:right;color:var(--elg-input-foreground, #0f172a);min-width:0}.elg-number-input__prefix,.elg-number-input__suffix{color:var(--elg-color-foreground-muted, #64748b);font-size:var(--elg-font-size-sm, 14px);flex-shrink:0}.elg-number-input__prefix{margin-right:var(--elg-spacing-1, 4px)}.elg-number-input__suffix{margin-left:var(--elg-spacing-1, 4px)}.elg-number-input__controls{display:flex;flex-direction:column;margin-left:var(--elg-spacing-1, 4px)}.elg-number-input__btn{background:none;border:none;cursor:pointer;padding:0 4px;font-size:12px;line-height:1;color:var(--elg-color-foreground-muted);border-radius:2px}.elg-number-input__btn:hover{background:var(--elg-color-neutral-100)}.elg-number-input__btn:disabled{cursor:not-allowed;opacity:.5}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
4109
|
+
}
|
|
4110
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgNumberInputComponent, decorators: [{
|
|
4111
|
+
type: Component,
|
|
4112
|
+
args: [{ selector: 'elg-number-input', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [{
|
|
4113
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4114
|
+
useExisting: forwardRef(() => ElgNumberInputComponent),
|
|
4115
|
+
multi: true,
|
|
4116
|
+
}], host: {
|
|
4117
|
+
class: 'elg-number-input',
|
|
4118
|
+
'[class.elg-number-input--disabled]': 'isDisabled()',
|
|
4119
|
+
'[class.elg-number-input--focused]': 'isFocused()',
|
|
4120
|
+
}, template: `
|
|
4121
|
+
@if (prefix()) {
|
|
4122
|
+
<span class="elg-number-input__prefix">{{ prefix() }}</span>
|
|
4123
|
+
}
|
|
4124
|
+
<input
|
|
4125
|
+
type="text"
|
|
4126
|
+
class="elg-number-input__field"
|
|
4127
|
+
[value]="displayValue()"
|
|
4128
|
+
[placeholder]="placeholder()"
|
|
4129
|
+
[disabled]="isDisabled()"
|
|
4130
|
+
[attr.min]="min()"
|
|
4131
|
+
[attr.max]="max()"
|
|
4132
|
+
[attr.step]="step()"
|
|
4133
|
+
(input)="onInput($event)"
|
|
4134
|
+
(blur)="onBlur()"
|
|
4135
|
+
(focus)="onFocus()"
|
|
4136
|
+
(keydown)="onKeydown($event)"
|
|
4137
|
+
/>
|
|
4138
|
+
@if (suffix()) {
|
|
4139
|
+
<span class="elg-number-input__suffix">{{ suffix() }}</span>
|
|
4140
|
+
}
|
|
4141
|
+
@if (showControls()) {
|
|
4142
|
+
<div class="elg-number-input__controls">
|
|
4143
|
+
<button type="button" class="elg-number-input__btn" (click)="increment()" [disabled]="isDisabled()" tabindex="-1" aria-label="Increment">+</button>
|
|
4144
|
+
<button type="button" class="elg-number-input__btn" (click)="decrement()" [disabled]="isDisabled()" tabindex="-1" aria-label="Decrement">−</button>
|
|
4145
|
+
</div>
|
|
4146
|
+
}
|
|
4147
|
+
`, styles: [":host{display:flex;align-items:center;gap:0;height:var(--elg-input-height, 36px);border:1px solid var(--elg-input-border-color, #cbd5e1);border-radius:var(--elg-input-border-radius, 6px);background:var(--elg-input-background, #fff);padding:0 var(--elg-input-padding-x, 12px);font-size:var(--elg-input-font-size, 14px);transition:border-color .15s,box-shadow .15s}:host(.elg-number-input--focused){border-color:var(--elg-input-border-color-focus, #3b82f6);box-shadow:0 0 0 2px #3b82f626}:host(.elg-number-input--disabled){opacity:.5;cursor:not-allowed;background:var(--elg-color-neutral-100)}.elg-number-input__field{flex:1;border:none;outline:none;background:transparent;font-size:inherit;font-family:inherit;text-align:right;color:var(--elg-input-foreground, #0f172a);min-width:0}.elg-number-input__prefix,.elg-number-input__suffix{color:var(--elg-color-foreground-muted, #64748b);font-size:var(--elg-font-size-sm, 14px);flex-shrink:0}.elg-number-input__prefix{margin-right:var(--elg-spacing-1, 4px)}.elg-number-input__suffix{margin-left:var(--elg-spacing-1, 4px)}.elg-number-input__controls{display:flex;flex-direction:column;margin-left:var(--elg-spacing-1, 4px)}.elg-number-input__btn{background:none;border:none;cursor:pointer;padding:0 4px;font-size:12px;line-height:1;color:var(--elg-color-foreground-muted);border-radius:2px}.elg-number-input__btn:hover{background:var(--elg-color-neutral-100)}.elg-number-input__btn:disabled{cursor:not-allowed;opacity:.5}\n"] }]
|
|
4148
|
+
}] });
|
|
4149
|
+
|
|
4150
|
+
class ElgChipInputComponent {
|
|
4151
|
+
placeholder = input('Type and press Enter');
|
|
4152
|
+
separators = input([',', 'Enter']);
|
|
4153
|
+
maxChips = input(null);
|
|
4154
|
+
allowDuplicates = input(false);
|
|
4155
|
+
chipAdded = output();
|
|
4156
|
+
chipRemoved = output();
|
|
4157
|
+
chips = signal([]);
|
|
4158
|
+
inputValue = signal('');
|
|
4159
|
+
isFocused = signal(false);
|
|
4160
|
+
isDisabled = signal(false);
|
|
4161
|
+
onChange = () => { };
|
|
4162
|
+
onTouched = () => { };
|
|
4163
|
+
writeValue(val) {
|
|
4164
|
+
this.chips.set(val || []);
|
|
4165
|
+
}
|
|
4166
|
+
registerOnChange(fn) { this.onChange = fn; }
|
|
4167
|
+
registerOnTouched(fn) { this.onTouched = fn; }
|
|
4168
|
+
setDisabledState(d) { this.isDisabled.set(d); }
|
|
4169
|
+
onInput(e) {
|
|
4170
|
+
const val = e.target.value;
|
|
4171
|
+
// Check for separator characters (except Enter which is handled in keydown)
|
|
4172
|
+
const seps = this.separators().filter(s => s !== 'Enter');
|
|
4173
|
+
for (const sep of seps) {
|
|
4174
|
+
if (val.includes(sep)) {
|
|
4175
|
+
const parts = val.split(sep).map(p => p.trim()).filter(Boolean);
|
|
4176
|
+
for (const part of parts) {
|
|
4177
|
+
this.addChip(part);
|
|
4178
|
+
}
|
|
4179
|
+
this.inputValue.set('');
|
|
4180
|
+
e.target.value = '';
|
|
4181
|
+
return;
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
this.inputValue.set(val);
|
|
4185
|
+
}
|
|
4186
|
+
onKeydown(e) {
|
|
4187
|
+
if (this.separators().includes('Enter') && e.key === 'Enter') {
|
|
4188
|
+
e.preventDefault();
|
|
4189
|
+
const val = this.inputValue().trim();
|
|
4190
|
+
if (val) {
|
|
4191
|
+
this.addChip(val);
|
|
4192
|
+
this.inputValue.set('');
|
|
4193
|
+
e.target.value = '';
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
if (e.key === 'Backspace' && !this.inputValue() && this.chips().length > 0) {
|
|
4197
|
+
this.removeChip(this.chips().length - 1);
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
onBlur() {
|
|
4201
|
+
this.isFocused.set(false);
|
|
4202
|
+
this.onTouched();
|
|
4203
|
+
// Add remaining text as chip
|
|
4204
|
+
const val = this.inputValue().trim();
|
|
4205
|
+
if (val) {
|
|
4206
|
+
this.addChip(val);
|
|
4207
|
+
this.inputValue.set('');
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
addChip(value) {
|
|
4211
|
+
if (!value)
|
|
4212
|
+
return;
|
|
4213
|
+
if (!this.allowDuplicates() && this.chips().includes(value))
|
|
4214
|
+
return;
|
|
4215
|
+
if (this.maxChips() !== null && this.chips().length >= this.maxChips())
|
|
4216
|
+
return;
|
|
4217
|
+
this.chips.update(c => [...c, value]);
|
|
4218
|
+
this.onChange(this.chips());
|
|
4219
|
+
this.chipAdded.emit(value);
|
|
4220
|
+
}
|
|
4221
|
+
removeChip(index) {
|
|
4222
|
+
const removed = this.chips()[index];
|
|
4223
|
+
this.chips.update(c => c.filter((_, i) => i !== index));
|
|
4224
|
+
this.onChange(this.chips());
|
|
4225
|
+
this.chipRemoved.emit(removed);
|
|
4226
|
+
}
|
|
4227
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgChipInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4228
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ElgChipInputComponent, isStandalone: true, selector: "elg-chip-input", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, separators: { classPropertyName: "separators", publicName: "separators", isSignal: true, isRequired: false, transformFunction: null }, maxChips: { classPropertyName: "maxChips", publicName: "maxChips", isSignal: true, isRequired: false, transformFunction: null }, allowDuplicates: { classPropertyName: "allowDuplicates", publicName: "allowDuplicates", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { chipAdded: "chipAdded", chipRemoved: "chipRemoved" }, host: { properties: { "class.elg-chip-input--focused": "isFocused()", "class.elg-chip-input--disabled": "isDisabled()" }, classAttribute: "elg-chip-input" }, providers: [{
|
|
4229
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4230
|
+
useExisting: forwardRef(() => ElgChipInputComponent),
|
|
4231
|
+
multi: true,
|
|
4232
|
+
}], ngImport: i0, template: `
|
|
4233
|
+
<div class="elg-chip-input__chips">
|
|
4234
|
+
@for (chip of chips(); track $index) {
|
|
4235
|
+
<span class="elg-chip-input__chip">
|
|
4236
|
+
<span class="elg-chip-input__chip-text">{{ chip }}</span>
|
|
4237
|
+
@if (!isDisabled()) {
|
|
4238
|
+
<button type="button" class="elg-chip-input__chip-remove" (click)="removeChip($index)" [attr.aria-label]="'Remove ' + chip">×</button>
|
|
4239
|
+
}
|
|
4240
|
+
</span>
|
|
4241
|
+
}
|
|
4242
|
+
<input
|
|
4243
|
+
class="elg-chip-input__input"
|
|
4244
|
+
[placeholder]="chips().length === 0 ? placeholder() : ''"
|
|
4245
|
+
[disabled]="isDisabled()"
|
|
4246
|
+
[value]="inputValue()"
|
|
4247
|
+
(input)="onInput($event)"
|
|
4248
|
+
(keydown)="onKeydown($event)"
|
|
4249
|
+
(focus)="isFocused.set(true)"
|
|
4250
|
+
(blur)="onBlur()"
|
|
4251
|
+
/>
|
|
4252
|
+
</div>
|
|
4253
|
+
`, isInline: true, styles: [":host{display:block;border:1px solid var(--elg-input-border-color, #cbd5e1);border-radius:var(--elg-input-border-radius, 6px);background:var(--elg-input-background, #fff);padding:var(--elg-spacing-1, 4px) var(--elg-spacing-2, 8px);min-height:var(--elg-input-height, 36px);cursor:text;transition:border-color .15s,box-shadow .15s}:host(.elg-chip-input--focused){border-color:var(--elg-input-border-color-focus, #3b82f6);box-shadow:0 0 0 2px #3b82f626}:host(.elg-chip-input--disabled){opacity:.5;cursor:not-allowed;background:var(--elg-color-neutral-100)}.elg-chip-input__chips{display:flex;flex-wrap:wrap;gap:var(--elg-spacing-1, 4px);align-items:center}.elg-chip-input__chip{display:inline-flex;align-items:center;gap:2px;background:var(--elg-color-primary, #2563eb);color:#fff;font-size:var(--elg-font-size-xs, 12px);font-weight:var(--elg-font-weight-medium, 500);padding:2px 6px 2px 8px;border-radius:var(--elg-border-radius-full, 9999px);max-width:200px}.elg-chip-input__chip-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.elg-chip-input__chip-remove{background:none;border:none;cursor:pointer;color:#fff;font-size:14px;line-height:1;padding:0 2px;border-radius:50%;opacity:.8}.elg-chip-input__chip-remove:hover{opacity:1;background:#fff3}.elg-chip-input__input{flex:1;min-width:60px;border:none;outline:none;background:transparent;font-size:var(--elg-input-font-size, 14px);padding:4px 0;color:var(--elg-input-foreground, #0f172a)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
4254
|
+
}
|
|
4255
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ElgChipInputComponent, decorators: [{
|
|
4256
|
+
type: Component,
|
|
4257
|
+
args: [{ selector: 'elg-chip-input', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, providers: [{
|
|
4258
|
+
provide: NG_VALUE_ACCESSOR,
|
|
4259
|
+
useExisting: forwardRef(() => ElgChipInputComponent),
|
|
4260
|
+
multi: true,
|
|
4261
|
+
}], host: {
|
|
4262
|
+
class: 'elg-chip-input',
|
|
4263
|
+
'[class.elg-chip-input--focused]': 'isFocused()',
|
|
4264
|
+
'[class.elg-chip-input--disabled]': 'isDisabled()',
|
|
4265
|
+
}, template: `
|
|
4266
|
+
<div class="elg-chip-input__chips">
|
|
4267
|
+
@for (chip of chips(); track $index) {
|
|
4268
|
+
<span class="elg-chip-input__chip">
|
|
4269
|
+
<span class="elg-chip-input__chip-text">{{ chip }}</span>
|
|
4270
|
+
@if (!isDisabled()) {
|
|
4271
|
+
<button type="button" class="elg-chip-input__chip-remove" (click)="removeChip($index)" [attr.aria-label]="'Remove ' + chip">×</button>
|
|
4272
|
+
}
|
|
4273
|
+
</span>
|
|
4274
|
+
}
|
|
4275
|
+
<input
|
|
4276
|
+
class="elg-chip-input__input"
|
|
4277
|
+
[placeholder]="chips().length === 0 ? placeholder() : ''"
|
|
4278
|
+
[disabled]="isDisabled()"
|
|
4279
|
+
[value]="inputValue()"
|
|
4280
|
+
(input)="onInput($event)"
|
|
4281
|
+
(keydown)="onKeydown($event)"
|
|
4282
|
+
(focus)="isFocused.set(true)"
|
|
4283
|
+
(blur)="onBlur()"
|
|
4284
|
+
/>
|
|
4285
|
+
</div>
|
|
4286
|
+
`, styles: [":host{display:block;border:1px solid var(--elg-input-border-color, #cbd5e1);border-radius:var(--elg-input-border-radius, 6px);background:var(--elg-input-background, #fff);padding:var(--elg-spacing-1, 4px) var(--elg-spacing-2, 8px);min-height:var(--elg-input-height, 36px);cursor:text;transition:border-color .15s,box-shadow .15s}:host(.elg-chip-input--focused){border-color:var(--elg-input-border-color-focus, #3b82f6);box-shadow:0 0 0 2px #3b82f626}:host(.elg-chip-input--disabled){opacity:.5;cursor:not-allowed;background:var(--elg-color-neutral-100)}.elg-chip-input__chips{display:flex;flex-wrap:wrap;gap:var(--elg-spacing-1, 4px);align-items:center}.elg-chip-input__chip{display:inline-flex;align-items:center;gap:2px;background:var(--elg-color-primary, #2563eb);color:#fff;font-size:var(--elg-font-size-xs, 12px);font-weight:var(--elg-font-weight-medium, 500);padding:2px 6px 2px 8px;border-radius:var(--elg-border-radius-full, 9999px);max-width:200px}.elg-chip-input__chip-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.elg-chip-input__chip-remove{background:none;border:none;cursor:pointer;color:#fff;font-size:14px;line-height:1;padding:0 2px;border-radius:50%;opacity:.8}.elg-chip-input__chip-remove:hover{opacity:1;background:#fff3}.elg-chip-input__input{flex:1;min-width:60px;border:none;outline:none;background:transparent;font-size:var(--elg-input-font-size, 14px);padding:4px 0;color:var(--elg-input-foreground, #0f172a)}\n"] }]
|
|
4287
|
+
}] });
|
|
4288
|
+
|
|
4289
|
+
/*
|
|
4290
|
+
* Public API Surface of elgiborsolution-ui
|
|
4291
|
+
*/
|
|
4292
|
+
|
|
4293
|
+
/**
|
|
4294
|
+
* Generated bundle index. Do not edit.
|
|
4295
|
+
*/
|
|
4296
|
+
|
|
4297
|
+
export { ElgAccordionComponent, ElgAccordionItemComponent, ElgAlertComponent, ElgAutocompleteComponent, ElgBadgeComponent, ElgBreadcrumbComponent, ElgButtonComponent, ElgCardComponent, ElgCheckboxComponent, ElgChipInputComponent, ElgDatePickerComponent, ElgDialogComponent, ElgDialogRef, ElgDialogService, ElgDropdownMenuComponent, ElgDropdownTriggerDirective, ElgFileUploadComponent, ElgFormFieldComponent, ElgInputDirective, ElgLocaleService, ElgMenuItemComponent, ElgNumberInputComponent, ElgPaginationComponent, ElgProgressComponent, ElgRadioComponent, ElgRadioGroupComponent, ElgSelectComponent, ElgSidebarComponent, ElgSkeletonComponent, ElgStepComponent, ElgStepperComponent, ElgSwitchComponent, ElgTabComponent, ElgTabGroupComponent, ElgTableComponent, ElgTextareaDirective, ElgThemeService, ElgToastContainerComponent, ElgToastService, ElgTooltipDirective, ElgTreeComponent, ElgTreeNodeComponent, provideElgUi };
|
|
4298
|
+
//# sourceMappingURL=elgiborsolution-ui.mjs.map
|