@ucme-ui/angular 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/LICENSE +21 -0
- package/README.md +151 -0
- package/fesm2022/ucme-ui-angular.mjs +2628 -0
- package/fesm2022/ucme-ui-angular.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/alert/alert.component.d.ts +18 -0
- package/lib/avatar/avatar.component.d.ts +15 -0
- package/lib/badge/badge.component.d.ts +12 -0
- package/lib/breadcrumb/breadcrumb.component.d.ts +12 -0
- package/lib/button/button-group.component.d.ts +17 -0
- package/lib/button/button.component.d.ts +39 -0
- package/lib/calendar/calendar.component.d.ts +105 -0
- package/lib/calendar/date-picker.component.d.ts +87 -0
- package/lib/calendar/date-utils.d.ts +27 -0
- package/lib/card/card.component.d.ts +30 -0
- package/lib/checkbox/checkbox.component.d.ts +36 -0
- package/lib/core/media.d.ts +6 -0
- package/lib/core/theme.service.d.ts +21 -0
- package/lib/core/unique-id.d.ts +2 -0
- package/lib/dialog/dialog.component.d.ts +39 -0
- package/lib/form-field/form-field.component.d.ts +38 -0
- package/lib/form-field/form-field.tokens.d.ts +31 -0
- package/lib/form-field/input.directive.d.ts +28 -0
- package/lib/icon/icon.component.d.ts +16 -0
- package/lib/icon/icons.d.ts +11 -0
- package/lib/imports.d.ts +15 -0
- package/lib/layout/nav.types.d.ts +15 -0
- package/lib/layout/shell.component.d.ts +51 -0
- package/lib/layout/sidebar-nav.component.d.ts +19 -0
- package/lib/layout/theme-toggle.component.d.ts +9 -0
- package/lib/menu/menu.component.d.ts +38 -0
- package/lib/paginator/paginator.component.d.ts +21 -0
- package/lib/spinner/spinner.component.d.ts +9 -0
- package/lib/switch/switch.component.d.ts +24 -0
- package/lib/table/table.component.d.ts +57 -0
- package/lib/table/table.types.d.ts +18 -0
- package/lib/tabs/tabs.component.d.ts +33 -0
- package/lib/toast/toast.service.d.ts +32 -0
- package/lib/toast/toaster.component.d.ts +11 -0
- package/package.json +65 -0
- package/public-api.d.ts +34 -0
- package/styles/_base.scss +84 -0
- package/styles/_controls.scss +146 -0
- package/styles/_tokens.scss +203 -0
- package/styles/hu-ui.scss +5 -0
|
@@ -0,0 +1,2628 @@
|
|
|
1
|
+
import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, signal, DestroyRef, computed, effect, Injectable, InjectionToken, input, isDevMode, ChangeDetectionStrategy, ViewEncapsulation, Component, ElementRef, booleanAttribute, Directive, contentChild, model, forwardRef, Injector, output, untracked, afterNextRender, viewChild, TemplateRef, contentChildren } from '@angular/core';
|
|
4
|
+
import { NgControl, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
|
|
5
|
+
import { RouterLink, Router, NavigationEnd, RouterLinkActive } from '@angular/router';
|
|
6
|
+
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
7
|
+
import { filter, map } from 'rxjs';
|
|
8
|
+
|
|
9
|
+
let nextId = 0;
|
|
10
|
+
/** Sayfa içinde benzersiz bir DOM id'si üretir (label/aria bağlantıları için). */
|
|
11
|
+
function huUniqueId(prefix = 'hu') {
|
|
12
|
+
return `${prefix}-${nextId++}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Bir media query'yi signal olarak döndürür. Injection context içinde çağrılmalıdır.
|
|
17
|
+
* @example readonly isMobile = huMediaQuery('(max-width: 1023.98px)');
|
|
18
|
+
*/
|
|
19
|
+
function huMediaQuery(query) {
|
|
20
|
+
const win = inject(DOCUMENT).defaultView;
|
|
21
|
+
const mql = win?.matchMedia?.(query);
|
|
22
|
+
const matches = signal(mql?.matches ?? false);
|
|
23
|
+
if (mql) {
|
|
24
|
+
const listener = (e) => matches.set(e.matches);
|
|
25
|
+
mql.addEventListener('change', listener);
|
|
26
|
+
inject(DestroyRef).onDestroy(() => mql.removeEventListener('change', listener));
|
|
27
|
+
}
|
|
28
|
+
return matches.asReadonly();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const STORAGE_KEY = 'hu-theme';
|
|
32
|
+
/**
|
|
33
|
+
* Açık / koyu / sistem temasını yönetir. Seçim localStorage'da saklanır ve
|
|
34
|
+
* `<html data-theme="...">` özniteliği üzerinden token'lara yansır.
|
|
35
|
+
*/
|
|
36
|
+
class HuThemeService {
|
|
37
|
+
doc = inject(DOCUMENT);
|
|
38
|
+
win = this.doc.defaultView;
|
|
39
|
+
media = this.win?.matchMedia?.('(prefers-color-scheme: dark)');
|
|
40
|
+
systemDark = signal(this.media?.matches ?? false);
|
|
41
|
+
mode = signal(this.readStoredMode());
|
|
42
|
+
resolved = computed(() => {
|
|
43
|
+
const mode = this.mode();
|
|
44
|
+
if (mode === 'system')
|
|
45
|
+
return this.systemDark() ? 'dark' : 'light';
|
|
46
|
+
return mode;
|
|
47
|
+
});
|
|
48
|
+
constructor() {
|
|
49
|
+
this.media?.addEventListener('change', (e) => this.systemDark.set(e.matches));
|
|
50
|
+
effect(() => {
|
|
51
|
+
this.doc.documentElement.setAttribute('data-theme', this.resolved());
|
|
52
|
+
try {
|
|
53
|
+
this.win?.localStorage.setItem(STORAGE_KEY, this.mode());
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Depolama kapalı olabilir (gizli pencere vb.)
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
setMode(mode) {
|
|
61
|
+
this.mode.set(mode);
|
|
62
|
+
}
|
|
63
|
+
toggle() {
|
|
64
|
+
this.mode.set(this.resolved() === 'dark' ? 'light' : 'dark');
|
|
65
|
+
}
|
|
66
|
+
readStoredMode() {
|
|
67
|
+
try {
|
|
68
|
+
const value = this.win?.localStorage.getItem(STORAGE_KEY);
|
|
69
|
+
if (value === 'light' || value === 'dark' || value === 'system')
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// yok say
|
|
74
|
+
}
|
|
75
|
+
return 'system';
|
|
76
|
+
}
|
|
77
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
78
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuThemeService, providedIn: 'root' });
|
|
79
|
+
}
|
|
80
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuThemeService, decorators: [{
|
|
81
|
+
type: Injectable,
|
|
82
|
+
args: [{ providedIn: 'root' }]
|
|
83
|
+
}], ctorParameters: () => [] });
|
|
84
|
+
|
|
85
|
+
const HU_ICON_SETS = new InjectionToken('HU_ICON_SETS');
|
|
86
|
+
/**
|
|
87
|
+
* Uygulamaya özel ikon ekler.
|
|
88
|
+
* @example providers: [provideHuIcons({ rocket: 'M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2' })]
|
|
89
|
+
*/
|
|
90
|
+
function provideHuIcons(icons) {
|
|
91
|
+
return { provide: HU_ICON_SETS, useValue: icons, multi: true };
|
|
92
|
+
}
|
|
93
|
+
/** Yerleşik ikon seti (Lucide stilinde, 2px stroke). */
|
|
94
|
+
const HU_BUILTIN_ICONS = {
|
|
95
|
+
menu: 'M4 6h16M4 12h16M4 18h16',
|
|
96
|
+
x: 'M18 6 6 18M6 6l12 12',
|
|
97
|
+
check: 'M20 6 9 17l-5-5',
|
|
98
|
+
minus: 'M5 12h14',
|
|
99
|
+
plus: 'M12 5v14M5 12h14',
|
|
100
|
+
'chevron-down': 'm6 9 6 6 6-6',
|
|
101
|
+
'chevron-up': 'm18 15-6-6-6 6',
|
|
102
|
+
'chevron-left': 'm15 18-6-6 6-6',
|
|
103
|
+
'chevron-right': 'm9 18 6-6-6-6',
|
|
104
|
+
'chevrons-left': 'm11 17-5-5 5-5M18 17l-5-5 5-5',
|
|
105
|
+
'chevrons-right': 'm6 17 5-5-5-5M13 17l5-5-5-5',
|
|
106
|
+
'chevrons-up-down': 'm7 15 5 5 5-5M7 9l5-5 5 5',
|
|
107
|
+
'arrow-up': 'm5 12 7-7 7 7M12 19V5',
|
|
108
|
+
'arrow-down': 'M12 5v14M19 12l-7 7-7-7',
|
|
109
|
+
home: 'M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6h-6v6H4a1 1 0 0 1-1-1z',
|
|
110
|
+
user: 'M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z',
|
|
111
|
+
users: 'M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75',
|
|
112
|
+
settings: 'M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6',
|
|
113
|
+
bell: 'M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9M10.3 21a1.94 1.94 0 0 0 3.4 0',
|
|
114
|
+
search: 'M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM21 21l-4.3-4.3',
|
|
115
|
+
sun: 'M12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41',
|
|
116
|
+
moon: 'M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z',
|
|
117
|
+
monitor: 'M4 3h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zM8 21h8M12 17v4',
|
|
118
|
+
'log-out': 'M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9',
|
|
119
|
+
info: 'M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 16v-4M12 8h.01',
|
|
120
|
+
'check-circle': 'M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3',
|
|
121
|
+
'alert-triangle': 'm21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3zM12 9v4M12 17h.01',
|
|
122
|
+
'alert-circle': 'M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 8v4M12 16h.01',
|
|
123
|
+
edit: 'M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z',
|
|
124
|
+
trash: 'M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2',
|
|
125
|
+
'file-text': 'M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6M16 13H8M16 17H8M10 9H8',
|
|
126
|
+
'bar-chart': 'M12 20V10M18 20V4M6 20v-4',
|
|
127
|
+
calendar: 'M8 2v4M16 2v4M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zM3 10h18',
|
|
128
|
+
folder: 'M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z',
|
|
129
|
+
grid: 'M3 3h7v7H3zM14 3h7v7h-7zM14 14h7v7h-7zM3 14h7v7H3z',
|
|
130
|
+
layers: 'm12 2 10 5-10 5L2 7zM2 17l10 5 10-5M2 12l10 5 10-5',
|
|
131
|
+
'more-vertical': 'M12 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2zM12 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2zM12 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2z',
|
|
132
|
+
mail: 'M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2zM22 6l-10 7L2 6',
|
|
133
|
+
lock: 'M5 11h14a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2zM7 11V7a5 5 0 0 1 10 0v4',
|
|
134
|
+
eye: 'M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z',
|
|
135
|
+
'book-open': 'M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2zM22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z',
|
|
136
|
+
'trending-up': 'm22 7-8.5 8.5-5-5L2 17M16 7h6v6',
|
|
137
|
+
'trending-down': 'm22 17-8.5-8.5-5 5L2 7M16 17h6v-6',
|
|
138
|
+
download: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3',
|
|
139
|
+
filter: 'M22 3H2l8 9.46V19l4 2v-8.54z',
|
|
140
|
+
'graduation-cap': 'M22 10 12 5 2 10l10 5zM6 12v5c3 3 9 3 12 0v-5',
|
|
141
|
+
building: 'M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18zM6 12H4a2 2 0 0 0-2 2v8h4M18 9h2a2 2 0 0 1 2 2v11h-4M10 6h4M10 10h4M10 14h4M10 18h4',
|
|
142
|
+
clock: 'M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 6v6l4 2',
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* SVG ikon.
|
|
147
|
+
* @example <hu-icon name="users" /> <hu-icon name="bell" [size]="20" label="Bildirimler" />
|
|
148
|
+
*/
|
|
149
|
+
class HuIcon {
|
|
150
|
+
customSets = inject(HU_ICON_SETS, { optional: true }) ?? [];
|
|
151
|
+
name = input.required();
|
|
152
|
+
size = input(18);
|
|
153
|
+
strokeWidth = input(2);
|
|
154
|
+
/** Ekran okuyucular için etiket. Verilmezse ikon dekoratif kabul edilir. */
|
|
155
|
+
label = input();
|
|
156
|
+
path = computed(() => {
|
|
157
|
+
const name = this.name();
|
|
158
|
+
for (let i = this.customSets.length - 1; i >= 0; i--) {
|
|
159
|
+
const path = this.customSets[i][name];
|
|
160
|
+
if (path)
|
|
161
|
+
return path;
|
|
162
|
+
}
|
|
163
|
+
const path = HU_BUILTIN_ICONS[name];
|
|
164
|
+
if (!path && isDevMode())
|
|
165
|
+
console.warn(`[hu-icon] "${name}" adında ikon bulunamadı.`);
|
|
166
|
+
return path ?? '';
|
|
167
|
+
});
|
|
168
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuIcon, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
169
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.25", type: HuIcon, isStandalone: true, selector: "hu-icon", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: true, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, strokeWidth: { classPropertyName: "strokeWidth", publicName: "strokeWidth", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.role": "label() ? \"img\" : null", "attr.aria-label": "label() || null", "attr.aria-hidden": "label() ? null : \"true\"" }, classAttribute: "hu-icon" }, ngImport: i0, template: `
|
|
170
|
+
<svg
|
|
171
|
+
[attr.width]="size()"
|
|
172
|
+
[attr.height]="size()"
|
|
173
|
+
viewBox="0 0 24 24"
|
|
174
|
+
fill="none"
|
|
175
|
+
stroke="currentColor"
|
|
176
|
+
[attr.stroke-width]="strokeWidth()"
|
|
177
|
+
stroke-linecap="round"
|
|
178
|
+
stroke-linejoin="round"
|
|
179
|
+
aria-hidden="true"
|
|
180
|
+
focusable="false"
|
|
181
|
+
>
|
|
182
|
+
<path [attr.d]="path()" />
|
|
183
|
+
</svg>
|
|
184
|
+
`, isInline: true, styles: [".hu-icon{display:inline-flex;flex-shrink:0;line-height:0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
185
|
+
}
|
|
186
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuIcon, decorators: [{
|
|
187
|
+
type: Component,
|
|
188
|
+
args: [{ selector: 'hu-icon', template: `
|
|
189
|
+
<svg
|
|
190
|
+
[attr.width]="size()"
|
|
191
|
+
[attr.height]="size()"
|
|
192
|
+
viewBox="0 0 24 24"
|
|
193
|
+
fill="none"
|
|
194
|
+
stroke="currentColor"
|
|
195
|
+
[attr.stroke-width]="strokeWidth()"
|
|
196
|
+
stroke-linecap="round"
|
|
197
|
+
stroke-linejoin="round"
|
|
198
|
+
aria-hidden="true"
|
|
199
|
+
focusable="false"
|
|
200
|
+
>
|
|
201
|
+
<path [attr.d]="path()" />
|
|
202
|
+
</svg>
|
|
203
|
+
`, host: {
|
|
204
|
+
class: 'hu-icon',
|
|
205
|
+
'[attr.role]': 'label() ? "img" : null',
|
|
206
|
+
'[attr.aria-label]': 'label() || null',
|
|
207
|
+
'[attr.aria-hidden]': 'label() ? null : "true"',
|
|
208
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-icon{display:inline-flex;flex-shrink:0;line-height:0}\n"] }]
|
|
209
|
+
}] });
|
|
210
|
+
|
|
211
|
+
/** @example <hu-spinner /> <hu-spinner size="lg" label="Veriler yükleniyor" /> */
|
|
212
|
+
class HuSpinner {
|
|
213
|
+
size = input('md');
|
|
214
|
+
label = input('Yükleniyor');
|
|
215
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSpinner, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
216
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.25", type: HuSpinner, isStandalone: true, selector: "hu-spinner", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "status" }, properties: { "attr.data-size": "size()", "attr.aria-label": "label()" }, classAttribute: "hu-spinner" }, ngImport: i0, template: `
|
|
217
|
+
<svg viewBox="0 0 24 24" class="hu-spinner__svg" aria-hidden="true">
|
|
218
|
+
<circle class="hu-spinner__track" cx="12" cy="12" r="10" fill="none" stroke-width="3" />
|
|
219
|
+
<circle class="hu-spinner__arc" cx="12" cy="12" r="10" fill="none" stroke-width="3" stroke-linecap="round" />
|
|
220
|
+
</svg>
|
|
221
|
+
`, isInline: true, styles: [".hu-spinner{display:inline-flex;width:1.25rem;height:1.25rem;color:var(--hu-primary);flex-shrink:0}.hu-spinner[data-size=sm]{width:1rem;height:1rem}.hu-spinner[data-size=lg]{width:2rem;height:2rem}.hu-spinner__svg{width:100%;height:100%;animation:hu-spin .8s linear infinite}.hu-spinner__track{stroke:currentColor;opacity:.2}.hu-spinner__arc{stroke:currentColor;stroke-dasharray:20 63}@keyframes hu-spin{to{transform:rotate(360deg)}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
222
|
+
}
|
|
223
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSpinner, decorators: [{
|
|
224
|
+
type: Component,
|
|
225
|
+
args: [{ selector: 'hu-spinner', template: `
|
|
226
|
+
<svg viewBox="0 0 24 24" class="hu-spinner__svg" aria-hidden="true">
|
|
227
|
+
<circle class="hu-spinner__track" cx="12" cy="12" r="10" fill="none" stroke-width="3" />
|
|
228
|
+
<circle class="hu-spinner__arc" cx="12" cy="12" r="10" fill="none" stroke-width="3" stroke-linecap="round" />
|
|
229
|
+
</svg>
|
|
230
|
+
`, host: {
|
|
231
|
+
class: 'hu-spinner',
|
|
232
|
+
role: 'status',
|
|
233
|
+
'[attr.data-size]': 'size()',
|
|
234
|
+
'[attr.aria-label]': 'label()',
|
|
235
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-spinner{display:inline-flex;width:1.25rem;height:1.25rem;color:var(--hu-primary);flex-shrink:0}.hu-spinner[data-size=sm]{width:1rem;height:1rem}.hu-spinner[data-size=lg]{width:2rem;height:2rem}.hu-spinner__svg{width:100%;height:100%;animation:hu-spin .8s linear infinite}.hu-spinner__track{stroke:currentColor;opacity:.2}.hu-spinner__arc{stroke:currentColor;stroke-dasharray:20 63}@keyframes hu-spin{to{transform:rotate(360deg)}}\n"] }]
|
|
236
|
+
}] });
|
|
237
|
+
|
|
238
|
+
/** Renk verilmezse görünüme göre varsayılan: dolgulu butonlar markalı, çerçeveli olanlar nötr. */
|
|
239
|
+
const DEFAULT_COLOR = {
|
|
240
|
+
solid: 'primary',
|
|
241
|
+
soft: 'primary',
|
|
242
|
+
link: 'primary',
|
|
243
|
+
outline: 'neutral',
|
|
244
|
+
ghost: 'neutral',
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Buton. Native `<button>` ve `<a>` elementlerine uygulanır; böylece form
|
|
248
|
+
* davranışı, routerLink ve erişilebilirlik tarayıcıdan hazır gelir.
|
|
249
|
+
*
|
|
250
|
+
* Görünüm (`variant`) ve renk (`color`) birbirinden bağımsızdır:
|
|
251
|
+
* 5 görünüm × 6 renk.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* <button hu-button>Kaydet</button>
|
|
255
|
+
* <button hu-button variant="soft" color="success">Onayla</button>
|
|
256
|
+
* <button hu-button variant="outline" color="danger" size="sm"><hu-icon name="trash" /> Sil</button>
|
|
257
|
+
* <button hu-button variant="ghost" iconOnly aria-label="Düzenle"><hu-icon name="edit" /></button>
|
|
258
|
+
* <a hu-button variant="link" routerLink="/users">Tüm kullanıcılar</a>
|
|
259
|
+
*/
|
|
260
|
+
class HuButton {
|
|
261
|
+
isButton = inject(ElementRef).nativeElement.tagName === 'BUTTON';
|
|
262
|
+
variant = input('solid');
|
|
263
|
+
/** Verilmezse: solid/soft/link → primary, outline/ghost → neutral. */
|
|
264
|
+
color = input();
|
|
265
|
+
size = input('md');
|
|
266
|
+
disabled = input(false, { transform: booleanAttribute });
|
|
267
|
+
loading = input(false, { transform: booleanAttribute });
|
|
268
|
+
/** Butonu kapsayıcı genişliğine yayar. */
|
|
269
|
+
block = input(false, { transform: booleanAttribute });
|
|
270
|
+
/** Kare, yalnızca ikon içeren buton. `aria-label` vermeyi unutmayın. */
|
|
271
|
+
iconOnly = input(false, { transform: booleanAttribute });
|
|
272
|
+
/** Tam yuvarlak köşeler. */
|
|
273
|
+
pill = input(false, { transform: booleanAttribute });
|
|
274
|
+
resolvedColor = computed(() => this.color() ?? DEFAULT_COLOR[this.variant()]);
|
|
275
|
+
isDisabled = computed(() => this.disabled() || this.loading());
|
|
276
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
277
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuButton, isStandalone: true, selector: "button[hu-button], a[hu-button]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", 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 }, block: { classPropertyName: "block", publicName: "block", isSignal: true, isRequired: false, transformFunction: null }, iconOnly: { classPropertyName: "iconOnly", publicName: "iconOnly", isSignal: true, isRequired: false, transformFunction: null }, pill: { classPropertyName: "pill", publicName: "pill", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-variant": "variant()", "attr.data-color": "resolvedColor()", "attr.data-size": "size()", "class.hu-button--block": "block()", "class.hu-button--icon": "iconOnly()", "class.hu-button--pill": "pill()", "class.hu-button--loading": "loading()", "attr.disabled": "isButton && isDisabled() ? \"\" : null", "attr.aria-disabled": "!isButton && isDisabled() ? \"true\" : null", "attr.tabindex": "!isButton && isDisabled() ? -1 : null", "attr.aria-busy": "loading() || null" }, classAttribute: "hu-button" }, ngImport: i0, template: `
|
|
278
|
+
@if (loading()) {
|
|
279
|
+
<hu-spinner class="hu-button__spinner" size="sm" />
|
|
280
|
+
}
|
|
281
|
+
<ng-content />
|
|
282
|
+
`, isInline: true, styles: [".hu-button{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:var(--hu-space-2);height:var(--hu-control-md);padding:0 var(--hu-space-4);font:inherit;font-size:var(--hu-text-sm);font-weight:500;line-height:1;white-space:nowrap;text-decoration:none;color:var(--_fg);background:var(--_bg);border:1px solid var(--_border, transparent);border-radius:var(--hu-radius-md);box-shadow:var(--_shadow, none);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--hu-transition),border-color var(--hu-transition),color var(--hu-transition),box-shadow var(--hu-transition)}.hu-button:not(:disabled,[aria-disabled=true]):hover{color:var(--_fg-hover, var(--_fg));background:var(--_bg-hover);border-color:var(--_border-hover, var(--_border, transparent))}.hu-button:not(:disabled,[aria-disabled=true]):active{background:var(--_bg-active, var(--_bg-hover))}.hu-button:focus-visible{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--_solid) 30%,transparent)}.hu-button:disabled,.hu-button[aria-disabled=true]{opacity:.5;cursor:not-allowed}.hu-button.hu-button--loading{cursor:progress}.hu-button .hu-button__spinner{color:currentColor}.hu-button[data-color=primary]{--_solid: var(--hu-primary);--_solid-hover: var(--hu-primary-hover);--_solid-active: var(--hu-primary-active);--_on-solid: var(--hu-primary-fg);--_soft: var(--hu-primary-soft);--_soft-hover: var(--hu-primary-soft-hover);--_soft-fg: var(--hu-primary-soft-fg);--_text: var(--hu-primary)}.hu-button[data-color=neutral]{--_solid: var(--hu-neutral);--_solid-hover: var(--hu-neutral-hover);--_solid-active: var(--hu-neutral-hover);--_on-solid: var(--hu-neutral-contrast);--_soft: var(--hu-surface-3);--_soft-hover: var(--hu-border);--_soft-fg: var(--hu-text);--_text: var(--hu-text)}.hu-button[data-color=success]{--_solid: var(--hu-success);--_solid-hover: var(--hu-success-hover);--_solid-active: var(--hu-success-hover);--_on-solid: var(--hu-success-contrast);--_soft: var(--hu-success-soft);--_soft-hover: color-mix(in srgb, var(--hu-success) 20%, transparent);--_soft-fg: var(--hu-success-fg);--_text: var(--hu-success)}.hu-button[data-color=warning]{--_solid: var(--hu-warning);--_solid-hover: var(--hu-warning-hover);--_solid-active: var(--hu-warning-hover);--_on-solid: var(--hu-warning-contrast);--_soft: var(--hu-warning-soft);--_soft-hover: color-mix(in srgb, var(--hu-warning) 20%, transparent);--_soft-fg: var(--hu-warning-fg);--_text: var(--hu-warning)}.hu-button[data-color=danger]{--_solid: var(--hu-danger);--_solid-hover: var(--hu-danger-hover);--_solid-active: var(--hu-danger-hover);--_on-solid: var(--hu-danger-contrast);--_soft: var(--hu-danger-soft);--_soft-hover: color-mix(in srgb, var(--hu-danger) 20%, transparent);--_soft-fg: var(--hu-danger-fg);--_text: var(--hu-danger)}.hu-button[data-color=info]{--_solid: var(--hu-info);--_solid-hover: var(--hu-info-hover);--_solid-active: var(--hu-info-hover);--_on-solid: var(--hu-info-contrast);--_soft: var(--hu-info-soft);--_soft-hover: color-mix(in srgb, var(--hu-info) 20%, transparent);--_soft-fg: var(--hu-info-fg);--_text: var(--hu-info)}.hu-button[data-variant=solid]{--_bg: var(--_solid);--_bg-hover: var(--_solid-hover);--_bg-active: var(--_solid-active);--_fg: var(--_on-solid);--_shadow: var(--hu-shadow-sm)}.hu-button[data-variant=soft]{--_bg: var(--_soft);--_bg-hover: var(--_soft-hover);--_fg: var(--_soft-fg)}.hu-button[data-variant=outline]{--_bg: var(--hu-surface);--_bg-hover: var(--_soft);--_fg: var(--_text);--_border: color-mix(in srgb, var(--_text) 40%, transparent);--_border-hover: color-mix(in srgb, var(--_text) 65%, transparent);--_shadow: var(--hu-shadow-sm)}.hu-button[data-variant=outline][data-color=neutral]{--_bg-hover: var(--hu-surface-2);--_border: var(--hu-border-strong);--_border-hover: var(--hu-gray-400)}.hu-button[data-variant=ghost]{--_bg: transparent;--_bg-hover: var(--_soft);--_fg: var(--_text)}.hu-button[data-variant=ghost][data-color=neutral]{--_fg: var(--hu-text-muted);--_fg-hover: var(--hu-text)}.hu-button[data-variant=link]{--_bg: transparent;--_bg-hover: transparent;--_fg: var(--_text);height:auto;padding:0;text-underline-offset:3px}.hu-button[data-variant=link]:not(:disabled,[aria-disabled=true]):hover{text-decoration:underline}.hu-button[aria-pressed=true]:not([data-variant=solid]){--_bg: var(--_soft);--_bg-hover: var(--_soft-hover);--_fg: var(--_soft-fg)}.hu-button[data-size=xs]{gap:var(--hu-space-1);height:var(--hu-control-xs);padding:0 var(--hu-space-2);font-size:var(--hu-text-xs);border-radius:var(--hu-radius-sm)}.hu-button[data-size=sm]{gap:var(--hu-space-1);height:var(--hu-control-sm);padding:0 var(--hu-space-3);font-size:.8125rem}.hu-button[data-size=lg]{height:var(--hu-control-lg);padding:0 var(--hu-space-5);font-size:.9375rem}.hu-button[data-size=xl]{gap:var(--hu-space-3);height:var(--hu-control-xl);padding:0 var(--hu-space-6);font-size:var(--hu-text-md);border-radius:var(--hu-radius-lg)}.hu-button[data-variant=link]{height:auto;padding:0}.hu-button--icon{padding:0}.hu-button--icon[data-size=xs]{width:var(--hu-control-xs);padding:0}.hu-button--icon[data-size=sm]{width:var(--hu-control-sm);padding:0}.hu-button--icon[data-size=md]{width:var(--hu-control-md);padding:0}.hu-button--icon[data-size=lg]{width:var(--hu-control-lg);padding:0}.hu-button--icon[data-size=xl]{width:var(--hu-control-xl);padding:0}.hu-button--pill{border-radius:var(--hu-radius-full)!important}.hu-button--block{display:flex;width:100%}\n"], dependencies: [{ kind: "component", type: HuSpinner, selector: "hu-spinner", inputs: ["size", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
283
|
+
}
|
|
284
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuButton, decorators: [{
|
|
285
|
+
type: Component,
|
|
286
|
+
args: [{ selector: 'button[hu-button], a[hu-button]', imports: [HuSpinner], template: `
|
|
287
|
+
@if (loading()) {
|
|
288
|
+
<hu-spinner class="hu-button__spinner" size="sm" />
|
|
289
|
+
}
|
|
290
|
+
<ng-content />
|
|
291
|
+
`, host: {
|
|
292
|
+
class: 'hu-button',
|
|
293
|
+
'[attr.data-variant]': 'variant()',
|
|
294
|
+
'[attr.data-color]': 'resolvedColor()',
|
|
295
|
+
'[attr.data-size]': 'size()',
|
|
296
|
+
'[class.hu-button--block]': 'block()',
|
|
297
|
+
'[class.hu-button--icon]': 'iconOnly()',
|
|
298
|
+
'[class.hu-button--pill]': 'pill()',
|
|
299
|
+
'[class.hu-button--loading]': 'loading()',
|
|
300
|
+
'[attr.disabled]': 'isButton && isDisabled() ? "" : null',
|
|
301
|
+
'[attr.aria-disabled]': '!isButton && isDisabled() ? "true" : null',
|
|
302
|
+
'[attr.tabindex]': '!isButton && isDisabled() ? -1 : null',
|
|
303
|
+
'[attr.aria-busy]': 'loading() || null',
|
|
304
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-button{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:var(--hu-space-2);height:var(--hu-control-md);padding:0 var(--hu-space-4);font:inherit;font-size:var(--hu-text-sm);font-weight:500;line-height:1;white-space:nowrap;text-decoration:none;color:var(--_fg);background:var(--_bg);border:1px solid var(--_border, transparent);border-radius:var(--hu-radius-md);box-shadow:var(--_shadow, none);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--hu-transition),border-color var(--hu-transition),color var(--hu-transition),box-shadow var(--hu-transition)}.hu-button:not(:disabled,[aria-disabled=true]):hover{color:var(--_fg-hover, var(--_fg));background:var(--_bg-hover);border-color:var(--_border-hover, var(--_border, transparent))}.hu-button:not(:disabled,[aria-disabled=true]):active{background:var(--_bg-active, var(--_bg-hover))}.hu-button:focus-visible{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--_solid) 30%,transparent)}.hu-button:disabled,.hu-button[aria-disabled=true]{opacity:.5;cursor:not-allowed}.hu-button.hu-button--loading{cursor:progress}.hu-button .hu-button__spinner{color:currentColor}.hu-button[data-color=primary]{--_solid: var(--hu-primary);--_solid-hover: var(--hu-primary-hover);--_solid-active: var(--hu-primary-active);--_on-solid: var(--hu-primary-fg);--_soft: var(--hu-primary-soft);--_soft-hover: var(--hu-primary-soft-hover);--_soft-fg: var(--hu-primary-soft-fg);--_text: var(--hu-primary)}.hu-button[data-color=neutral]{--_solid: var(--hu-neutral);--_solid-hover: var(--hu-neutral-hover);--_solid-active: var(--hu-neutral-hover);--_on-solid: var(--hu-neutral-contrast);--_soft: var(--hu-surface-3);--_soft-hover: var(--hu-border);--_soft-fg: var(--hu-text);--_text: var(--hu-text)}.hu-button[data-color=success]{--_solid: var(--hu-success);--_solid-hover: var(--hu-success-hover);--_solid-active: var(--hu-success-hover);--_on-solid: var(--hu-success-contrast);--_soft: var(--hu-success-soft);--_soft-hover: color-mix(in srgb, var(--hu-success) 20%, transparent);--_soft-fg: var(--hu-success-fg);--_text: var(--hu-success)}.hu-button[data-color=warning]{--_solid: var(--hu-warning);--_solid-hover: var(--hu-warning-hover);--_solid-active: var(--hu-warning-hover);--_on-solid: var(--hu-warning-contrast);--_soft: var(--hu-warning-soft);--_soft-hover: color-mix(in srgb, var(--hu-warning) 20%, transparent);--_soft-fg: var(--hu-warning-fg);--_text: var(--hu-warning)}.hu-button[data-color=danger]{--_solid: var(--hu-danger);--_solid-hover: var(--hu-danger-hover);--_solid-active: var(--hu-danger-hover);--_on-solid: var(--hu-danger-contrast);--_soft: var(--hu-danger-soft);--_soft-hover: color-mix(in srgb, var(--hu-danger) 20%, transparent);--_soft-fg: var(--hu-danger-fg);--_text: var(--hu-danger)}.hu-button[data-color=info]{--_solid: var(--hu-info);--_solid-hover: var(--hu-info-hover);--_solid-active: var(--hu-info-hover);--_on-solid: var(--hu-info-contrast);--_soft: var(--hu-info-soft);--_soft-hover: color-mix(in srgb, var(--hu-info) 20%, transparent);--_soft-fg: var(--hu-info-fg);--_text: var(--hu-info)}.hu-button[data-variant=solid]{--_bg: var(--_solid);--_bg-hover: var(--_solid-hover);--_bg-active: var(--_solid-active);--_fg: var(--_on-solid);--_shadow: var(--hu-shadow-sm)}.hu-button[data-variant=soft]{--_bg: var(--_soft);--_bg-hover: var(--_soft-hover);--_fg: var(--_soft-fg)}.hu-button[data-variant=outline]{--_bg: var(--hu-surface);--_bg-hover: var(--_soft);--_fg: var(--_text);--_border: color-mix(in srgb, var(--_text) 40%, transparent);--_border-hover: color-mix(in srgb, var(--_text) 65%, transparent);--_shadow: var(--hu-shadow-sm)}.hu-button[data-variant=outline][data-color=neutral]{--_bg-hover: var(--hu-surface-2);--_border: var(--hu-border-strong);--_border-hover: var(--hu-gray-400)}.hu-button[data-variant=ghost]{--_bg: transparent;--_bg-hover: var(--_soft);--_fg: var(--_text)}.hu-button[data-variant=ghost][data-color=neutral]{--_fg: var(--hu-text-muted);--_fg-hover: var(--hu-text)}.hu-button[data-variant=link]{--_bg: transparent;--_bg-hover: transparent;--_fg: var(--_text);height:auto;padding:0;text-underline-offset:3px}.hu-button[data-variant=link]:not(:disabled,[aria-disabled=true]):hover{text-decoration:underline}.hu-button[aria-pressed=true]:not([data-variant=solid]){--_bg: var(--_soft);--_bg-hover: var(--_soft-hover);--_fg: var(--_soft-fg)}.hu-button[data-size=xs]{gap:var(--hu-space-1);height:var(--hu-control-xs);padding:0 var(--hu-space-2);font-size:var(--hu-text-xs);border-radius:var(--hu-radius-sm)}.hu-button[data-size=sm]{gap:var(--hu-space-1);height:var(--hu-control-sm);padding:0 var(--hu-space-3);font-size:.8125rem}.hu-button[data-size=lg]{height:var(--hu-control-lg);padding:0 var(--hu-space-5);font-size:.9375rem}.hu-button[data-size=xl]{gap:var(--hu-space-3);height:var(--hu-control-xl);padding:0 var(--hu-space-6);font-size:var(--hu-text-md);border-radius:var(--hu-radius-lg)}.hu-button[data-variant=link]{height:auto;padding:0}.hu-button--icon{padding:0}.hu-button--icon[data-size=xs]{width:var(--hu-control-xs);padding:0}.hu-button--icon[data-size=sm]{width:var(--hu-control-sm);padding:0}.hu-button--icon[data-size=md]{width:var(--hu-control-md);padding:0}.hu-button--icon[data-size=lg]{width:var(--hu-control-lg);padding:0}.hu-button--icon[data-size=xl]{width:var(--hu-control-xl);padding:0}.hu-button--pill{border-radius:var(--hu-radius-full)!important}.hu-button--block{display:flex;width:100%}\n"] }]
|
|
305
|
+
}] });
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Butonları birleşik bir grup olarak gösterir (araç çubuğu, görünüm seçici, sayfalama).
|
|
309
|
+
* Aç/kapa davranışı için butonlara `[attr.aria-pressed]` verin.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* <hu-button-group aria-label="Görünüm">
|
|
313
|
+
* <button hu-button variant="outline" [attr.aria-pressed]="view() === 'list'" (click)="view.set('list')">Liste</button>
|
|
314
|
+
* <button hu-button variant="outline" [attr.aria-pressed]="view() === 'grid'" (click)="view.set('grid')">Kart</button>
|
|
315
|
+
* </hu-button-group>
|
|
316
|
+
*/
|
|
317
|
+
class HuButtonGroup {
|
|
318
|
+
vertical = input(false, { transform: booleanAttribute });
|
|
319
|
+
pill = input(false, { transform: booleanAttribute });
|
|
320
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuButtonGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
321
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.25", type: HuButtonGroup, isStandalone: true, selector: "hu-button-group", inputs: { vertical: { classPropertyName: "vertical", publicName: "vertical", isSignal: true, isRequired: false, transformFunction: null }, pill: { classPropertyName: "pill", publicName: "pill", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "class.hu-button-group--vertical": "vertical()", "class.hu-button-group--pill": "pill()" }, classAttribute: "hu-button-group" }, ngImport: i0, template: `<ng-content />`, isInline: true, styles: [".hu-button-group{display:inline-flex;isolation:isolate}.hu-button-group--vertical{flex-direction:column}.hu-button-group>.hu-menu{display:inline-flex}.hu-button-group:not(.hu-button-group--vertical)>.hu-button:not(:first-child),.hu-button-group:not(.hu-button-group--vertical)>:not(.hu-button):not(:first-child)>.hu-button{margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0}.hu-button-group:not(.hu-button-group--vertical)>.hu-button:not(:last-child),.hu-button-group:not(.hu-button-group--vertical)>:not(.hu-button):not(:last-child)>.hu-button{border-top-right-radius:0;border-bottom-right-radius:0}.hu-button-group--vertical>.hu-button:not(:first-child){margin-top:-1px;border-top-left-radius:0;border-top-right-radius:0}.hu-button-group--vertical>.hu-button:not(:last-child){border-bottom-left-radius:0;border-bottom-right-radius:0}.hu-button-group>.hu-button[data-variant=solid]:not(:first-child),.hu-button-group>:not(.hu-button):not(:first-child)>.hu-button[data-variant=solid]{margin-left:0;border-left-color:color-mix(in srgb,var(--_on-solid) 25%,transparent)}.hu-button-group>.hu-button:hover,.hu-button-group>.hu-button:focus-visible,.hu-button-group>.hu-button[aria-pressed=true]{z-index:1}.hu-button-group--pill>.hu-button:first-child{border-top-left-radius:var(--hu-radius-full);border-bottom-left-radius:var(--hu-radius-full)}.hu-button-group--pill>.hu-button:last-child{border-top-right-radius:var(--hu-radius-full);border-bottom-right-radius:var(--hu-radius-full)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
322
|
+
}
|
|
323
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuButtonGroup, decorators: [{
|
|
324
|
+
type: Component,
|
|
325
|
+
args: [{ selector: 'hu-button-group', template: `<ng-content />`, host: {
|
|
326
|
+
class: 'hu-button-group',
|
|
327
|
+
role: 'group',
|
|
328
|
+
'[class.hu-button-group--vertical]': 'vertical()',
|
|
329
|
+
'[class.hu-button-group--pill]': 'pill()',
|
|
330
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-button-group{display:inline-flex;isolation:isolate}.hu-button-group--vertical{flex-direction:column}.hu-button-group>.hu-menu{display:inline-flex}.hu-button-group:not(.hu-button-group--vertical)>.hu-button:not(:first-child),.hu-button-group:not(.hu-button-group--vertical)>:not(.hu-button):not(:first-child)>.hu-button{margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0}.hu-button-group:not(.hu-button-group--vertical)>.hu-button:not(:last-child),.hu-button-group:not(.hu-button-group--vertical)>:not(.hu-button):not(:last-child)>.hu-button{border-top-right-radius:0;border-bottom-right-radius:0}.hu-button-group--vertical>.hu-button:not(:first-child){margin-top:-1px;border-top-left-radius:0;border-top-right-radius:0}.hu-button-group--vertical>.hu-button:not(:last-child){border-bottom-left-radius:0;border-bottom-right-radius:0}.hu-button-group>.hu-button[data-variant=solid]:not(:first-child),.hu-button-group>:not(.hu-button):not(:first-child)>.hu-button[data-variant=solid]{margin-left:0;border-left-color:color-mix(in srgb,var(--_on-solid) 25%,transparent)}.hu-button-group>.hu-button:hover,.hu-button-group>.hu-button:focus-visible,.hu-button-group>.hu-button[aria-pressed=true]{z-index:1}.hu-button-group--pill>.hu-button:first-child{border-top-left-radius:var(--hu-radius-full);border-bottom-left-radius:var(--hu-radius-full)}.hu-button-group--pill>.hu-button:last-child{border-top-right-radius:var(--hu-radius-full);border-bottom-right-radius:var(--hu-radius-full)}\n"] }]
|
|
331
|
+
}] });
|
|
332
|
+
|
|
333
|
+
const HU_FORM_FIELD = new InjectionToken('HU_FORM_FIELD');
|
|
334
|
+
/**
|
|
335
|
+
* hu-form-field içine yerleştirilebilen her kontrolün uyguladığı sözleşme
|
|
336
|
+
* (huInput, hu-date-picker, ...). Kendi kontrolünüzü yazarken
|
|
337
|
+
* `providers: [{ provide: HuFormFieldControl, useExisting: MyControl }]` verin.
|
|
338
|
+
*/
|
|
339
|
+
class HuFormFieldControl {
|
|
340
|
+
}
|
|
341
|
+
const HU_DEFAULT_ERROR_MESSAGES = {
|
|
342
|
+
required: 'Bu alan zorunludur.',
|
|
343
|
+
requiredTrue: 'Devam etmek için onaylamanız gerekir.',
|
|
344
|
+
email: 'Geçerli bir e-posta adresi giriniz.',
|
|
345
|
+
minlength: (e) => `En az ${e.requiredLength} karakter olmalıdır.`,
|
|
346
|
+
maxlength: (e) => `En fazla ${e.requiredLength} karakter olabilir.`,
|
|
347
|
+
min: (e) => `Değer en az ${e.min} olmalıdır.`,
|
|
348
|
+
max: (e) => `Değer en fazla ${e.max} olabilir.`,
|
|
349
|
+
pattern: 'Geçersiz format.',
|
|
350
|
+
huDateParse: 'Geçerli bir tarih giriniz (gg.aa.yyyy).',
|
|
351
|
+
huDateMin: (e) => `Tarih ${e.min} veya sonrası olmalıdır.`,
|
|
352
|
+
huDateMax: (e) => `Tarih ${e.max} veya öncesi olmalıdır.`,
|
|
353
|
+
huDateUnavailable: 'Bu tarih seçilemez.',
|
|
354
|
+
};
|
|
355
|
+
const HU_ERROR_MESSAGES = new InjectionToken('HU_ERROR_MESSAGES', {
|
|
356
|
+
providedIn: 'root',
|
|
357
|
+
factory: () => HU_DEFAULT_ERROR_MESSAGES,
|
|
358
|
+
});
|
|
359
|
+
/**
|
|
360
|
+
* Varsayılan validasyon mesajlarını genişletir / değiştirir.
|
|
361
|
+
* @example provideHuErrorMessages({ tckn: 'Geçerli bir T.C. kimlik numarası giriniz.' })
|
|
362
|
+
*/
|
|
363
|
+
function provideHuErrorMessages(messages) {
|
|
364
|
+
return { provide: HU_ERROR_MESSAGES, useValue: { ...HU_DEFAULT_ERROR_MESSAGES, ...messages } };
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Native input / textarea / select elementlerine HU görünümünü ve
|
|
369
|
+
* hu-form-field entegrasyonunu (label, hata, aria) ekler.
|
|
370
|
+
*
|
|
371
|
+
* @example <input huInput formControlName="email" placeholder="ornek@example.com" />
|
|
372
|
+
*/
|
|
373
|
+
class HuInput {
|
|
374
|
+
ngControl = inject(NgControl, { optional: true, self: true });
|
|
375
|
+
field = inject(HU_FORM_FIELD, { optional: true, host: true });
|
|
376
|
+
id = input(huUniqueId('hu-input'));
|
|
377
|
+
size = input('md');
|
|
378
|
+
/** Form kontrolü olmadan hatalı görünümü zorlar. */
|
|
379
|
+
invalid = input(false, { transform: booleanAttribute });
|
|
380
|
+
/** Bir Angular form kontrolüne bağlı mı? */
|
|
381
|
+
hasControl = this.ngControl !== null;
|
|
382
|
+
/** Kontrol geçersiz ve kullanıcı etkileşime girmiş. */
|
|
383
|
+
controlErrorVisible = signal(false);
|
|
384
|
+
errors = signal(null);
|
|
385
|
+
isInvalid = computed(() => this.invalid() || this.controlErrorVisible() || (this.field?.showError() ?? false));
|
|
386
|
+
// Reactive form durumu signal değildir; her change detection turunda eşitlenir.
|
|
387
|
+
ngDoCheck() {
|
|
388
|
+
const c = this.ngControl;
|
|
389
|
+
if (!c)
|
|
390
|
+
return;
|
|
391
|
+
this.controlErrorVisible.set(!!c.invalid && !!(c.touched || c.dirty));
|
|
392
|
+
this.errors.set(c.errors);
|
|
393
|
+
}
|
|
394
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuInput, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
395
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.25", type: HuInput, isStandalone: true, selector: "input[huInput], textarea[huInput], select[huInput]", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "id": "id()", "attr.data-size": "size()", "class.hu-input--invalid": "isInvalid()", "attr.aria-invalid": "isInvalid() || null", "attr.aria-describedby": "field?.describedBy() ?? null" }, classAttribute: "hu-input" }, providers: [{ provide: HuFormFieldControl, useExisting: HuInput }], exportAs: ["huInput"], ngImport: i0 });
|
|
396
|
+
}
|
|
397
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuInput, decorators: [{
|
|
398
|
+
type: Directive,
|
|
399
|
+
args: [{
|
|
400
|
+
selector: 'input[huInput], textarea[huInput], select[huInput]',
|
|
401
|
+
exportAs: 'huInput',
|
|
402
|
+
providers: [{ provide: HuFormFieldControl, useExisting: HuInput }],
|
|
403
|
+
host: {
|
|
404
|
+
class: 'hu-input',
|
|
405
|
+
'[id]': 'id()',
|
|
406
|
+
'[attr.data-size]': 'size()',
|
|
407
|
+
'[class.hu-input--invalid]': 'isInvalid()',
|
|
408
|
+
'[attr.aria-invalid]': 'isInvalid() || null',
|
|
409
|
+
'[attr.aria-describedby]': 'field?.describedBy() ?? null',
|
|
410
|
+
},
|
|
411
|
+
}]
|
|
412
|
+
}] });
|
|
413
|
+
|
|
414
|
+
/** Kontrolün soluna yerleşen içerik (ikon, para birimi vb.). */
|
|
415
|
+
class HuPrefix {
|
|
416
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuPrefix, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
417
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuPrefix, isStandalone: true, selector: "[huPrefix]", host: { classAttribute: "hu-field__prefix" }, ngImport: i0 });
|
|
418
|
+
}
|
|
419
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuPrefix, decorators: [{
|
|
420
|
+
type: Directive,
|
|
421
|
+
args: [{ selector: '[huPrefix]', host: { class: 'hu-field__prefix' } }]
|
|
422
|
+
}] });
|
|
423
|
+
/** Kontrolün sağına yerleşen içerik. */
|
|
424
|
+
class HuSuffix {
|
|
425
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSuffix, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
426
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuSuffix, isStandalone: true, selector: "[huSuffix]", host: { classAttribute: "hu-field__suffix" }, ngImport: i0 });
|
|
427
|
+
}
|
|
428
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSuffix, decorators: [{
|
|
429
|
+
type: Directive,
|
|
430
|
+
args: [{ selector: '[huSuffix]', host: { class: 'hu-field__suffix' } }]
|
|
431
|
+
}] });
|
|
432
|
+
/**
|
|
433
|
+
* Label, yardım metni ve validasyon hatasını bir kontrol etrafında toplar.
|
|
434
|
+
* Reactive form hataları otomatik olarak Türkçe mesaja çevrilir.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* <hu-form-field label="E-posta" hint="Kurumsal adresinizi kullanın" required>
|
|
438
|
+
* <hu-icon huPrefix name="mail" />
|
|
439
|
+
* <input huInput type="email" formControlName="email" />
|
|
440
|
+
* </hu-form-field>
|
|
441
|
+
*/
|
|
442
|
+
class HuFormField {
|
|
443
|
+
messages = inject(HU_ERROR_MESSAGES);
|
|
444
|
+
label = input();
|
|
445
|
+
hint = input();
|
|
446
|
+
/** Sabit hata mesajı. Verilmezse validator hatasından üretilir. */
|
|
447
|
+
error = input();
|
|
448
|
+
required = input(false, { transform: booleanAttribute });
|
|
449
|
+
control = contentChild(HuFormFieldControl);
|
|
450
|
+
hintId = huUniqueId('hu-hint');
|
|
451
|
+
errorId = huUniqueId('hu-error');
|
|
452
|
+
errorText = computed(() => {
|
|
453
|
+
const explicit = this.error();
|
|
454
|
+
if (explicit)
|
|
455
|
+
return explicit;
|
|
456
|
+
const errors = this.control()?.errors();
|
|
457
|
+
if (!errors)
|
|
458
|
+
return null;
|
|
459
|
+
// Birden çok hata varsa daha açıklayıcı olanı göster: geçersiz metin (örn.
|
|
460
|
+
// 31.02.2026) kontrolü boş bırakıp ayrıca `required` tetikleyebilir.
|
|
461
|
+
const keys = Object.keys(errors);
|
|
462
|
+
const key = keys.find((k) => k !== 'required') ?? keys[0];
|
|
463
|
+
const message = this.messages[key];
|
|
464
|
+
if (typeof message === 'function')
|
|
465
|
+
return message(errors[key]);
|
|
466
|
+
return message ?? 'Geçersiz değer.';
|
|
467
|
+
});
|
|
468
|
+
showError = computed(() => {
|
|
469
|
+
const control = this.control();
|
|
470
|
+
if (control?.hasControl)
|
|
471
|
+
return control.controlErrorVisible() && !!this.errorText();
|
|
472
|
+
return !!this.error();
|
|
473
|
+
});
|
|
474
|
+
describedBy = computed(() => {
|
|
475
|
+
if (this.showError())
|
|
476
|
+
return this.errorId;
|
|
477
|
+
return this.hint() ? this.hintId : null;
|
|
478
|
+
});
|
|
479
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuFormField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
480
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuFormField, isStandalone: true, selector: "hu-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: { classAttribute: "hu-field" }, providers: [{ provide: HU_FORM_FIELD, useExisting: HuFormField }], queries: [{ propertyName: "control", first: true, predicate: HuFormFieldControl, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
481
|
+
@if (label()) {
|
|
482
|
+
<label class="hu-field__label" [attr.for]="control()?.id()">
|
|
483
|
+
{{ label() }}
|
|
484
|
+
@if (required()) {
|
|
485
|
+
<span class="hu-field__required" aria-hidden="true">*</span>
|
|
486
|
+
}
|
|
487
|
+
</label>
|
|
488
|
+
}
|
|
489
|
+
<div class="hu-field__control">
|
|
490
|
+
<ng-content select="[huPrefix]" />
|
|
491
|
+
<ng-content />
|
|
492
|
+
<ng-content select="[huSuffix]" />
|
|
493
|
+
</div>
|
|
494
|
+
@if (showError()) {
|
|
495
|
+
<p class="hu-field__message hu-field__message--error" [id]="errorId">
|
|
496
|
+
<hu-icon name="alert-circle" [size]="14" />
|
|
497
|
+
{{ errorText() }}
|
|
498
|
+
</p>
|
|
499
|
+
} @else if (hint()) {
|
|
500
|
+
<p class="hu-field__message" [id]="hintId">{{ hint() }}</p>
|
|
501
|
+
}
|
|
502
|
+
`, isInline: true, styles: [".hu-field{display:flex;flex-direction:column;gap:.375rem;min-width:0}.hu-field__label{font-size:var(--hu-text-sm);font-weight:500;color:var(--hu-text)}.hu-field__required{margin-left:2px;color:var(--hu-danger)}.hu-field__control{position:relative;display:flex;align-items:center}.hu-field__control>[huPrefix],.hu-field__control>[huSuffix]{position:absolute;top:50%;z-index:1;display:inline-flex;align-items:center;color:var(--hu-text-subtle);transform:translateY(-50%);pointer-events:none}.hu-field__control>[huPrefix]:is(button),.hu-field__control>[huPrefix] button,.hu-field__control>[huSuffix]:is(button),.hu-field__control>[huSuffix] button{pointer-events:auto}.hu-field__control>[huPrefix]{left:var(--hu-space-3)}.hu-field__control>[huSuffix]{right:var(--hu-space-1)}.hu-field__control:has(>[huPrefix])>.hu-input{padding-left:2.25rem}.hu-field__control:has(>[huSuffix])>.hu-input{padding-right:2.5rem}.hu-field__message{display:flex;align-items:center;gap:var(--hu-space-1);font-size:var(--hu-text-xs);color:var(--hu-text-muted)}.hu-field__message--error{color:var(--hu-danger)}\n"], dependencies: [{ kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
503
|
+
}
|
|
504
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuFormField, decorators: [{
|
|
505
|
+
type: Component,
|
|
506
|
+
args: [{ selector: 'hu-form-field', imports: [HuIcon], providers: [{ provide: HU_FORM_FIELD, useExisting: HuFormField }], template: `
|
|
507
|
+
@if (label()) {
|
|
508
|
+
<label class="hu-field__label" [attr.for]="control()?.id()">
|
|
509
|
+
{{ label() }}
|
|
510
|
+
@if (required()) {
|
|
511
|
+
<span class="hu-field__required" aria-hidden="true">*</span>
|
|
512
|
+
}
|
|
513
|
+
</label>
|
|
514
|
+
}
|
|
515
|
+
<div class="hu-field__control">
|
|
516
|
+
<ng-content select="[huPrefix]" />
|
|
517
|
+
<ng-content />
|
|
518
|
+
<ng-content select="[huSuffix]" />
|
|
519
|
+
</div>
|
|
520
|
+
@if (showError()) {
|
|
521
|
+
<p class="hu-field__message hu-field__message--error" [id]="errorId">
|
|
522
|
+
<hu-icon name="alert-circle" [size]="14" />
|
|
523
|
+
{{ errorText() }}
|
|
524
|
+
</p>
|
|
525
|
+
} @else if (hint()) {
|
|
526
|
+
<p class="hu-field__message" [id]="hintId">{{ hint() }}</p>
|
|
527
|
+
}
|
|
528
|
+
`, host: { class: 'hu-field' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-field{display:flex;flex-direction:column;gap:.375rem;min-width:0}.hu-field__label{font-size:var(--hu-text-sm);font-weight:500;color:var(--hu-text)}.hu-field__required{margin-left:2px;color:var(--hu-danger)}.hu-field__control{position:relative;display:flex;align-items:center}.hu-field__control>[huPrefix],.hu-field__control>[huSuffix]{position:absolute;top:50%;z-index:1;display:inline-flex;align-items:center;color:var(--hu-text-subtle);transform:translateY(-50%);pointer-events:none}.hu-field__control>[huPrefix]:is(button),.hu-field__control>[huPrefix] button,.hu-field__control>[huSuffix]:is(button),.hu-field__control>[huSuffix] button{pointer-events:auto}.hu-field__control>[huPrefix]{left:var(--hu-space-3)}.hu-field__control>[huSuffix]{right:var(--hu-space-1)}.hu-field__control:has(>[huPrefix])>.hu-input{padding-left:2.25rem}.hu-field__control:has(>[huSuffix])>.hu-input{padding-right:2.5rem}.hu-field__message{display:flex;align-items:center;gap:var(--hu-space-1);font-size:var(--hu-text-xs);color:var(--hu-text-muted)}.hu-field__message--error{color:var(--hu-danger)}\n"] }]
|
|
529
|
+
}] });
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Onay kutusu. Reactive/template-driven formlarla ya da `[(checked)]` ile çalışır.
|
|
533
|
+
*
|
|
534
|
+
* `indeterminate` (kısmen seçili) yalnızca görsel bir durumdur ve tıklanınca
|
|
535
|
+
* tarayıcı standardı gereği kalkar; değeri alt seçimlerden hesaplayıp siz verin:
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* <hu-checkbox formControlName="kvkk">KVKK metnini okudum</hu-checkbox>
|
|
539
|
+
*
|
|
540
|
+
* <!-- "Tümünü seç" -->
|
|
541
|
+
* <hu-checkbox [checked]="allSelected()" [indeterminate]="someSelected()" (checkedChange)="selectAll($event)">
|
|
542
|
+
* Tümünü seç
|
|
543
|
+
* </hu-checkbox>
|
|
544
|
+
*/
|
|
545
|
+
class HuCheckbox {
|
|
546
|
+
checked = model(false);
|
|
547
|
+
indeterminate = model(false);
|
|
548
|
+
disabled = input(false, { transform: booleanAttribute });
|
|
549
|
+
name = input();
|
|
550
|
+
inputId = input(huUniqueId('hu-checkbox'));
|
|
551
|
+
/** Görünür etiket yoksa ekran okuyucu etiketi. */
|
|
552
|
+
ariaLabel = input(null, { alias: 'aria-label' });
|
|
553
|
+
formDisabled = signal(false);
|
|
554
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
555
|
+
onChange = () => { };
|
|
556
|
+
onTouched = () => { };
|
|
557
|
+
onInputChange(event) {
|
|
558
|
+
const value = event.target.checked;
|
|
559
|
+
this.indeterminate.set(false);
|
|
560
|
+
this.checked.set(value);
|
|
561
|
+
this.onChange(value);
|
|
562
|
+
}
|
|
563
|
+
writeValue(value) {
|
|
564
|
+
this.checked.set(!!value);
|
|
565
|
+
}
|
|
566
|
+
registerOnChange(fn) {
|
|
567
|
+
this.onChange = fn;
|
|
568
|
+
}
|
|
569
|
+
registerOnTouched(fn) {
|
|
570
|
+
this.onTouched = fn;
|
|
571
|
+
}
|
|
572
|
+
setDisabledState(disabled) {
|
|
573
|
+
this.formDisabled.set(disabled);
|
|
574
|
+
}
|
|
575
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
576
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.25", type: HuCheckbox, isStandalone: true, selector: "hu-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 }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", indeterminate: "indeterminateChange" }, host: { classAttribute: "hu-checkbox" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => HuCheckbox), multi: true }], ngImport: i0, template: `
|
|
577
|
+
<label class="hu-check" [class.hu-check--disabled]="isDisabled()">
|
|
578
|
+
<input
|
|
579
|
+
type="checkbox"
|
|
580
|
+
class="hu-check__input"
|
|
581
|
+
[id]="inputId()"
|
|
582
|
+
[checked]="checked()"
|
|
583
|
+
[indeterminate]="indeterminate()"
|
|
584
|
+
[disabled]="isDisabled()"
|
|
585
|
+
[attr.name]="name() || null"
|
|
586
|
+
[attr.aria-label]="ariaLabel()"
|
|
587
|
+
(change)="onInputChange($event)"
|
|
588
|
+
(blur)="onTouched()"
|
|
589
|
+
/>
|
|
590
|
+
<span class="hu-check__box" aria-hidden="true">
|
|
591
|
+
<hu-icon [name]="indeterminate() ? 'minus' : 'check'" [size]="12" [strokeWidth]="3.5" />
|
|
592
|
+
</span>
|
|
593
|
+
<span class="hu-check__label"><ng-content /></span>
|
|
594
|
+
</label>
|
|
595
|
+
`, isInline: true, styles: [".hu-checkbox{display:inline-flex;width:fit-content;max-width:100%}.hu-check{position:relative;display:inline-flex;align-items:flex-start;gap:var(--hu-space-2);font-size:var(--hu-text-sm);color:var(--hu-text);cursor:pointer;-webkit-user-select:none;user-select:none}.hu-check--disabled{color:var(--hu-text-subtle);cursor:not-allowed}.hu-check__input{position:absolute;width:1rem;height:1rem;margin:.125rem 0 0;opacity:0;cursor:inherit}.hu-check__box{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1rem;height:1rem;margin-top:.125rem;color:transparent;background:var(--hu-surface);border:1px solid var(--hu-border-strong);border-radius:var(--hu-radius-sm);transition:background-color var(--hu-transition),border-color var(--hu-transition),box-shadow var(--hu-transition)}.hu-check:hover .hu-check__input:not(:disabled)+.hu-check__box{border-color:var(--hu-primary)}.hu-check__input:focus-visible+.hu-check__box{box-shadow:var(--hu-ring)}.hu-check__input:checked+.hu-check__box,.hu-check__input:indeterminate+.hu-check__box{color:var(--hu-primary-fg);background:var(--hu-primary);border-color:var(--hu-primary)}.hu-check__input:disabled+.hu-check__box{opacity:.5}.hu-check__label:empty{display:none}\n"], dependencies: [{ kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
596
|
+
}
|
|
597
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCheckbox, decorators: [{
|
|
598
|
+
type: Component,
|
|
599
|
+
args: [{ selector: 'hu-checkbox', imports: [HuIcon], providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => HuCheckbox), multi: true }], template: `
|
|
600
|
+
<label class="hu-check" [class.hu-check--disabled]="isDisabled()">
|
|
601
|
+
<input
|
|
602
|
+
type="checkbox"
|
|
603
|
+
class="hu-check__input"
|
|
604
|
+
[id]="inputId()"
|
|
605
|
+
[checked]="checked()"
|
|
606
|
+
[indeterminate]="indeterminate()"
|
|
607
|
+
[disabled]="isDisabled()"
|
|
608
|
+
[attr.name]="name() || null"
|
|
609
|
+
[attr.aria-label]="ariaLabel()"
|
|
610
|
+
(change)="onInputChange($event)"
|
|
611
|
+
(blur)="onTouched()"
|
|
612
|
+
/>
|
|
613
|
+
<span class="hu-check__box" aria-hidden="true">
|
|
614
|
+
<hu-icon [name]="indeterminate() ? 'minus' : 'check'" [size]="12" [strokeWidth]="3.5" />
|
|
615
|
+
</span>
|
|
616
|
+
<span class="hu-check__label"><ng-content /></span>
|
|
617
|
+
</label>
|
|
618
|
+
`, host: { class: 'hu-checkbox' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-checkbox{display:inline-flex;width:fit-content;max-width:100%}.hu-check{position:relative;display:inline-flex;align-items:flex-start;gap:var(--hu-space-2);font-size:var(--hu-text-sm);color:var(--hu-text);cursor:pointer;-webkit-user-select:none;user-select:none}.hu-check--disabled{color:var(--hu-text-subtle);cursor:not-allowed}.hu-check__input{position:absolute;width:1rem;height:1rem;margin:.125rem 0 0;opacity:0;cursor:inherit}.hu-check__box{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1rem;height:1rem;margin-top:.125rem;color:transparent;background:var(--hu-surface);border:1px solid var(--hu-border-strong);border-radius:var(--hu-radius-sm);transition:background-color var(--hu-transition),border-color var(--hu-transition),box-shadow var(--hu-transition)}.hu-check:hover .hu-check__input:not(:disabled)+.hu-check__box{border-color:var(--hu-primary)}.hu-check__input:focus-visible+.hu-check__box{box-shadow:var(--hu-ring)}.hu-check__input:checked+.hu-check__box,.hu-check__input:indeterminate+.hu-check__box{color:var(--hu-primary-fg);background:var(--hu-primary);border-color:var(--hu-primary)}.hu-check__input:disabled+.hu-check__box{opacity:.5}.hu-check__label:empty{display:none}\n"] }]
|
|
619
|
+
}] });
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Açık/kapalı anahtarı (ayarlar için). Formlarla ya da `[(checked)]` ile çalışır.
|
|
623
|
+
* @example <hu-switch formControlName="emailNotifications">E-posta bildirimleri</hu-switch>
|
|
624
|
+
*/
|
|
625
|
+
class HuSwitch {
|
|
626
|
+
checked = model(false);
|
|
627
|
+
disabled = input(false, { transform: booleanAttribute });
|
|
628
|
+
inputId = input(huUniqueId('hu-switch'));
|
|
629
|
+
/** Görünür etiket yoksa ekran okuyucu etiketi. */
|
|
630
|
+
ariaLabel = input(null, { alias: 'aria-label' });
|
|
631
|
+
formDisabled = signal(false);
|
|
632
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
633
|
+
onChange = () => { };
|
|
634
|
+
onTouched = () => { };
|
|
635
|
+
onInputChange(event) {
|
|
636
|
+
const value = event.target.checked;
|
|
637
|
+
this.checked.set(value);
|
|
638
|
+
this.onChange(value);
|
|
639
|
+
}
|
|
640
|
+
writeValue(value) {
|
|
641
|
+
this.checked.set(!!value);
|
|
642
|
+
}
|
|
643
|
+
registerOnChange(fn) {
|
|
644
|
+
this.onChange = fn;
|
|
645
|
+
}
|
|
646
|
+
registerOnTouched(fn) {
|
|
647
|
+
this.onTouched = fn;
|
|
648
|
+
}
|
|
649
|
+
setDisabledState(disabled) {
|
|
650
|
+
this.formDisabled.set(disabled);
|
|
651
|
+
}
|
|
652
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSwitch, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
653
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.25", type: HuSwitch, isStandalone: true, selector: "hu-switch", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange" }, host: { classAttribute: "hu-switch" }, providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => HuSwitch), multi: true }], ngImport: i0, template: `
|
|
654
|
+
<label class="hu-switch__root" [class.hu-switch__root--disabled]="isDisabled()">
|
|
655
|
+
<input
|
|
656
|
+
type="checkbox"
|
|
657
|
+
role="switch"
|
|
658
|
+
class="hu-switch__input"
|
|
659
|
+
[id]="inputId()"
|
|
660
|
+
[checked]="checked()"
|
|
661
|
+
[disabled]="isDisabled()"
|
|
662
|
+
[attr.aria-checked]="checked()"
|
|
663
|
+
[attr.aria-label]="ariaLabel()"
|
|
664
|
+
(change)="onInputChange($event)"
|
|
665
|
+
(blur)="onTouched()"
|
|
666
|
+
/>
|
|
667
|
+
<span class="hu-switch__track" aria-hidden="true"><span class="hu-switch__thumb"></span></span>
|
|
668
|
+
<span class="hu-switch__label"><ng-content /></span>
|
|
669
|
+
</label>
|
|
670
|
+
`, isInline: true, styles: [".hu-switch{display:inline-flex;width:fit-content;max-width:100%}.hu-switch__root{position:relative;display:inline-flex;align-items:center;gap:var(--hu-space-3);font-size:var(--hu-text-sm);cursor:pointer;-webkit-user-select:none;user-select:none}.hu-switch__root--disabled{color:var(--hu-text-subtle);cursor:not-allowed}.hu-switch__input{position:absolute;width:2.25rem;height:1.25rem;margin:0;opacity:0;cursor:inherit}.hu-switch__track{position:relative;flex-shrink:0;width:2.25rem;height:1.25rem;background:var(--hu-border-strong);border-radius:var(--hu-radius-full);transition:background-color var(--hu-transition),box-shadow var(--hu-transition)}.hu-switch__thumb{position:absolute;top:2px;left:2px;width:1rem;height:1rem;background:#fff;border-radius:50%;box-shadow:0 1px 3px #00000040;transition:transform var(--hu-transition)}.hu-switch__input:checked+.hu-switch__track{background:var(--hu-primary)}.hu-switch__input:checked+.hu-switch__track .hu-switch__thumb{transform:translate(1rem)}.hu-switch__input:focus-visible+.hu-switch__track{box-shadow:var(--hu-ring)}.hu-switch__input:disabled+.hu-switch__track{opacity:.5}.hu-switch__label:empty{display:none}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
671
|
+
}
|
|
672
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSwitch, decorators: [{
|
|
673
|
+
type: Component,
|
|
674
|
+
args: [{ selector: 'hu-switch', providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => HuSwitch), multi: true }], template: `
|
|
675
|
+
<label class="hu-switch__root" [class.hu-switch__root--disabled]="isDisabled()">
|
|
676
|
+
<input
|
|
677
|
+
type="checkbox"
|
|
678
|
+
role="switch"
|
|
679
|
+
class="hu-switch__input"
|
|
680
|
+
[id]="inputId()"
|
|
681
|
+
[checked]="checked()"
|
|
682
|
+
[disabled]="isDisabled()"
|
|
683
|
+
[attr.aria-checked]="checked()"
|
|
684
|
+
[attr.aria-label]="ariaLabel()"
|
|
685
|
+
(change)="onInputChange($event)"
|
|
686
|
+
(blur)="onTouched()"
|
|
687
|
+
/>
|
|
688
|
+
<span class="hu-switch__track" aria-hidden="true"><span class="hu-switch__thumb"></span></span>
|
|
689
|
+
<span class="hu-switch__label"><ng-content /></span>
|
|
690
|
+
</label>
|
|
691
|
+
`, host: { class: 'hu-switch' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-switch{display:inline-flex;width:fit-content;max-width:100%}.hu-switch__root{position:relative;display:inline-flex;align-items:center;gap:var(--hu-space-3);font-size:var(--hu-text-sm);cursor:pointer;-webkit-user-select:none;user-select:none}.hu-switch__root--disabled{color:var(--hu-text-subtle);cursor:not-allowed}.hu-switch__input{position:absolute;width:2.25rem;height:1.25rem;margin:0;opacity:0;cursor:inherit}.hu-switch__track{position:relative;flex-shrink:0;width:2.25rem;height:1.25rem;background:var(--hu-border-strong);border-radius:var(--hu-radius-full);transition:background-color var(--hu-transition),box-shadow var(--hu-transition)}.hu-switch__thumb{position:absolute;top:2px;left:2px;width:1rem;height:1rem;background:#fff;border-radius:50%;box-shadow:0 1px 3px #00000040;transition:transform var(--hu-transition)}.hu-switch__input:checked+.hu-switch__track{background:var(--hu-primary)}.hu-switch__input:checked+.hu-switch__track .hu-switch__thumb{transform:translate(1rem)}.hu-switch__input:focus-visible+.hu-switch__track{box-shadow:var(--hu-ring)}.hu-switch__input:disabled+.hu-switch__track{opacity:.5}.hu-switch__label:empty{display:none}\n"] }]
|
|
692
|
+
}] });
|
|
693
|
+
|
|
694
|
+
/*
|
|
695
|
+
* Bağımlılıksız tarih yardımcıları. Tüm fonksiyonlar yerel saatle ve gün
|
|
696
|
+
* hassasiyetinde çalışır (saat bilgisi yok sayılır).
|
|
697
|
+
*/
|
|
698
|
+
function startOfDay(date) {
|
|
699
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
700
|
+
}
|
|
701
|
+
function addDays(date, days) {
|
|
702
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
|
|
703
|
+
}
|
|
704
|
+
/** Ay ekler; hedef ayda o gün yoksa ayın son gününe sabitler (31 Ocak + 1 ay = 28/29 Şubat). */
|
|
705
|
+
function addMonths(date, months) {
|
|
706
|
+
const target = new Date(date.getFullYear(), date.getMonth() + months, 1);
|
|
707
|
+
const lastDay = daysInMonth(target.getFullYear(), target.getMonth());
|
|
708
|
+
target.setDate(Math.min(date.getDate(), lastDay));
|
|
709
|
+
return target;
|
|
710
|
+
}
|
|
711
|
+
function daysInMonth(year, month) {
|
|
712
|
+
return new Date(year, month + 1, 0).getDate();
|
|
713
|
+
}
|
|
714
|
+
function isSameDay(a, b) {
|
|
715
|
+
return !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
716
|
+
}
|
|
717
|
+
function isSameMonth(a, b) {
|
|
718
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
|
|
719
|
+
}
|
|
720
|
+
/** Gün bazında karşılaştırma: a < b → negatif. */
|
|
721
|
+
function compareDays(a, b) {
|
|
722
|
+
return startOfDay(a).getTime() - startOfDay(b).getTime();
|
|
723
|
+
}
|
|
724
|
+
/** Haftanın başlangıcı (varsayılan Pazartesi). */
|
|
725
|
+
function startOfWeek(date, firstDayOfWeek = 1) {
|
|
726
|
+
const diff = (date.getDay() - firstDayOfWeek + 7) % 7;
|
|
727
|
+
return addDays(date, -diff);
|
|
728
|
+
}
|
|
729
|
+
function clampDate(date, min, max) {
|
|
730
|
+
if (min && compareDays(date, min) < 0)
|
|
731
|
+
return startOfDay(min);
|
|
732
|
+
if (max && compareDays(date, max) > 0)
|
|
733
|
+
return startOfDay(max);
|
|
734
|
+
return date;
|
|
735
|
+
}
|
|
736
|
+
function isValidDate(value) {
|
|
737
|
+
return value instanceof Date && !isNaN(value.getTime());
|
|
738
|
+
}
|
|
739
|
+
/** `gg.aa.yyyy` biçiminde yazar. */
|
|
740
|
+
function formatDate(date) {
|
|
741
|
+
if (!isValidDate(date))
|
|
742
|
+
return '';
|
|
743
|
+
const d = String(date.getDate()).padStart(2, '0');
|
|
744
|
+
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
745
|
+
return `${d}.${m}.${date.getFullYear()}`;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Kullanıcı girdisini ayrıştırır. Kabul edilenler: `5.10.2026`, `05/10/2026`,
|
|
749
|
+
* `05-10-2026`, `05102026`. Geçersiz tarihte (31.02.2026 gibi) `null` döner.
|
|
750
|
+
*/
|
|
751
|
+
function parseDate(text) {
|
|
752
|
+
const value = text.trim();
|
|
753
|
+
let match = /^(\d{1,2})[./-](\d{1,2})[./-](\d{4})$/.exec(value);
|
|
754
|
+
if (!match)
|
|
755
|
+
match = /^(\d{2})(\d{2})(\d{4})$/.exec(value);
|
|
756
|
+
if (!match)
|
|
757
|
+
return null;
|
|
758
|
+
const [day, month, year] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
759
|
+
const date = new Date(year, month - 1, day);
|
|
760
|
+
// Taşan tarihleri (32.01 → 01.02) reddet
|
|
761
|
+
if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day)
|
|
762
|
+
return null;
|
|
763
|
+
return date;
|
|
764
|
+
}
|
|
765
|
+
const RANGE_SEPARATOR = /\s+[–-]\s+|\s*[–]\s*/;
|
|
766
|
+
function formatRange(range) {
|
|
767
|
+
if (!range?.start)
|
|
768
|
+
return '';
|
|
769
|
+
return range.end ? `${formatDate(range.start)} – ${formatDate(range.end)}` : `${formatDate(range.start)} – `;
|
|
770
|
+
}
|
|
771
|
+
/** `gg.aa.yyyy – gg.aa.yyyy` ayrıştırır. Başarısızsa `null`. */
|
|
772
|
+
function parseRange(text) {
|
|
773
|
+
const parts = text.split(RANGE_SEPARATOR).map((p) => p.trim()).filter(Boolean);
|
|
774
|
+
if (parts.length !== 2)
|
|
775
|
+
return null;
|
|
776
|
+
const start = parseDate(parts[0]);
|
|
777
|
+
const end = parseDate(parts[1]);
|
|
778
|
+
if (!start || !end)
|
|
779
|
+
return null;
|
|
780
|
+
return compareDays(start, end) <= 0 ? { start, end } : { start: end, end: start };
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
const dayKey = (d) => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
|
|
784
|
+
const YEARS_PER_PAGE = 12;
|
|
785
|
+
/**
|
|
786
|
+
* Satır içi takvim. Tek gün veya tarih aralığı seçer; ay/yıl görünümü ve
|
|
787
|
+
* tam klavye desteği vardır (oklar, Home/End, PageUp/PageDown, Enter).
|
|
788
|
+
*
|
|
789
|
+
* @example
|
|
790
|
+
* <hu-calendar [(value)]="date" [min]="today" [markers]="events" />
|
|
791
|
+
* <hu-calendar mode="range" [(range)]="period" />
|
|
792
|
+
*/
|
|
793
|
+
class HuCalendar {
|
|
794
|
+
host = inject(ElementRef);
|
|
795
|
+
injector = inject(Injector);
|
|
796
|
+
mode = input('single');
|
|
797
|
+
/** Seçili gün (`mode="single"`). */
|
|
798
|
+
value = model(null);
|
|
799
|
+
/** Seçili aralık (`mode="range"`). */
|
|
800
|
+
range = model(null);
|
|
801
|
+
min = input(null);
|
|
802
|
+
max = input(null);
|
|
803
|
+
/** `false` döndüren günler seçilemez (örn. hafta sonları). */
|
|
804
|
+
dateFilter = input(null);
|
|
805
|
+
markers = input([]);
|
|
806
|
+
/** Hiç seçim yokken açılacak ay. */
|
|
807
|
+
startAt = input(null);
|
|
808
|
+
locale = input('tr-TR');
|
|
809
|
+
firstDayOfWeek = input(1);
|
|
810
|
+
/** Kullanıcı bir gün seçtiğinde. */
|
|
811
|
+
dateSelected = output();
|
|
812
|
+
/** Görüntülenen ay değiştiğinde (ayın ilk günü). */
|
|
813
|
+
monthChange = output();
|
|
814
|
+
today = startOfDay(new Date());
|
|
815
|
+
gridId = huUniqueId('hu-calendar');
|
|
816
|
+
view = signal('days');
|
|
817
|
+
activeDate = signal(this.today);
|
|
818
|
+
hoverDate = signal(null);
|
|
819
|
+
/** Roving tabindex: yalnızca aktif gün Tab ile odaklanabilir. */
|
|
820
|
+
activeKey = computed(() => dayKey(this.activeDate()));
|
|
821
|
+
// --- Biçimlendiriciler ----------------------------------------------------------
|
|
822
|
+
fmt = computed(() => {
|
|
823
|
+
const locale = this.locale();
|
|
824
|
+
return {
|
|
825
|
+
monthYear: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }),
|
|
826
|
+
month: new Intl.DateTimeFormat(locale, { month: 'long' }),
|
|
827
|
+
monthShort: new Intl.DateTimeFormat(locale, { month: 'short' }),
|
|
828
|
+
weekdayShort: new Intl.DateTimeFormat(locale, { weekday: 'short' }),
|
|
829
|
+
weekdayLong: new Intl.DateTimeFormat(locale, { weekday: 'long' }),
|
|
830
|
+
full: new Intl.DateTimeFormat(locale, { dateStyle: 'full' }),
|
|
831
|
+
};
|
|
832
|
+
});
|
|
833
|
+
weekdays = computed(() => {
|
|
834
|
+
const first = startOfWeek(this.today, this.firstDayOfWeek());
|
|
835
|
+
return Array.from({ length: 7 }, (_, i) => {
|
|
836
|
+
const d = addDays(first, i);
|
|
837
|
+
return { short: this.fmt().weekdayShort.format(d), long: this.fmt().weekdayLong.format(d) };
|
|
838
|
+
});
|
|
839
|
+
});
|
|
840
|
+
headerLabel = computed(() => {
|
|
841
|
+
const active = this.activeDate();
|
|
842
|
+
switch (this.view()) {
|
|
843
|
+
case 'days':
|
|
844
|
+
return this.fmt().monthYear.format(active);
|
|
845
|
+
case 'months':
|
|
846
|
+
return String(active.getFullYear());
|
|
847
|
+
case 'years': {
|
|
848
|
+
const start = this.yearPageStart();
|
|
849
|
+
return `${start} – ${start + YEARS_PER_PAGE - 1}`;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
// --- Gün görünümü ----------------------------------------------------------------
|
|
854
|
+
markerMap = computed(() => {
|
|
855
|
+
const map = new Map();
|
|
856
|
+
for (const m of this.markers()) {
|
|
857
|
+
const key = dayKey(m.date);
|
|
858
|
+
map.set(key, [...(map.get(key) ?? []), m]);
|
|
859
|
+
}
|
|
860
|
+
return map;
|
|
861
|
+
});
|
|
862
|
+
weeks = computed(() => {
|
|
863
|
+
const active = this.activeDate();
|
|
864
|
+
const first = new Date(active.getFullYear(), active.getMonth(), 1);
|
|
865
|
+
const gridStart = startOfWeek(first, this.firstDayOfWeek());
|
|
866
|
+
const mode = this.mode();
|
|
867
|
+
const value = this.value();
|
|
868
|
+
const range = this.range();
|
|
869
|
+
const preview = this.previewEnd();
|
|
870
|
+
const markers = this.markerMap();
|
|
871
|
+
const fmt = this.fmt().full;
|
|
872
|
+
let rangeStart = range?.start ?? null;
|
|
873
|
+
let rangeEnd = range?.end ?? preview;
|
|
874
|
+
if (rangeStart && rangeEnd && compareDays(rangeEnd, rangeStart) < 0)
|
|
875
|
+
[rangeStart, rangeEnd] = [rangeEnd, rangeStart];
|
|
876
|
+
const weeks = [];
|
|
877
|
+
for (let w = 0; w < 6; w++) {
|
|
878
|
+
const row = [];
|
|
879
|
+
for (let i = 0; i < 7; i++) {
|
|
880
|
+
const date = addDays(gridStart, w * 7 + i);
|
|
881
|
+
const key = dayKey(date);
|
|
882
|
+
const isStart = mode === 'range' && isSameDay(date, rangeStart);
|
|
883
|
+
const isEnd = mode === 'range' && isSameDay(date, rangeEnd);
|
|
884
|
+
const dayMarkers = markers.get(key) ?? [];
|
|
885
|
+
row.push({
|
|
886
|
+
date,
|
|
887
|
+
key,
|
|
888
|
+
day: date.getDate(),
|
|
889
|
+
inMonth: isSameMonth(date, active),
|
|
890
|
+
today: isSameDay(date, this.today),
|
|
891
|
+
selected: mode === 'single' ? isSameDay(date, value) : isStart || isEnd,
|
|
892
|
+
rangeStart: isStart && !!rangeEnd && !isSameDay(rangeStart, rangeEnd),
|
|
893
|
+
rangeEnd: isEnd && !!rangeStart && !isSameDay(rangeStart, rangeEnd),
|
|
894
|
+
inRange: mode === 'range' &&
|
|
895
|
+
!!rangeStart &&
|
|
896
|
+
!!rangeEnd &&
|
|
897
|
+
compareDays(date, rangeStart) > 0 &&
|
|
898
|
+
compareDays(date, rangeEnd) < 0,
|
|
899
|
+
disabled: !this.isSelectable(date),
|
|
900
|
+
markers: dayMarkers,
|
|
901
|
+
label: fmt.format(date) + (dayMarkers.length ? ` — ${dayMarkers.map((m) => m.label).filter(Boolean).join(', ')}` : ''),
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
weeks.push(row);
|
|
905
|
+
}
|
|
906
|
+
return weeks;
|
|
907
|
+
});
|
|
908
|
+
/** Aralık seçiminde bitiş henüz seçilmemişken fareyle önizleme. */
|
|
909
|
+
previewEnd = computed(() => {
|
|
910
|
+
const range = this.range();
|
|
911
|
+
if (this.mode() !== 'range' || !range?.start || range.end)
|
|
912
|
+
return null;
|
|
913
|
+
return this.hoverDate();
|
|
914
|
+
});
|
|
915
|
+
// --- Ay / yıl görünümleri --------------------------------------------------------
|
|
916
|
+
months = computed(() => {
|
|
917
|
+
const year = this.activeDate().getFullYear();
|
|
918
|
+
const selected = this.selectedAnchor();
|
|
919
|
+
return Array.from({ length: 12 }, (_, month) => ({
|
|
920
|
+
value: month,
|
|
921
|
+
label: this.fmt().monthShort.format(new Date(year, month, 1)),
|
|
922
|
+
current: year === this.today.getFullYear() && month === this.today.getMonth(),
|
|
923
|
+
selected: !!selected && selected.getFullYear() === year && selected.getMonth() === month,
|
|
924
|
+
disabled: !this.isRangeAllowed(new Date(year, month, 1), new Date(year, month, daysInMonth(year, month))),
|
|
925
|
+
}));
|
|
926
|
+
});
|
|
927
|
+
yearPageStart = computed(() => {
|
|
928
|
+
const year = this.activeDate().getFullYear();
|
|
929
|
+
return year - (((year % YEARS_PER_PAGE) + YEARS_PER_PAGE) % YEARS_PER_PAGE);
|
|
930
|
+
});
|
|
931
|
+
years = computed(() => {
|
|
932
|
+
const start = this.yearPageStart();
|
|
933
|
+
const selected = this.selectedAnchor();
|
|
934
|
+
return Array.from({ length: YEARS_PER_PAGE }, (_, i) => {
|
|
935
|
+
const year = start + i;
|
|
936
|
+
return {
|
|
937
|
+
value: year,
|
|
938
|
+
label: String(year),
|
|
939
|
+
current: year === this.today.getFullYear(),
|
|
940
|
+
selected: selected?.getFullYear() === year,
|
|
941
|
+
disabled: !this.isRangeAllowed(new Date(year, 0, 1), new Date(year, 11, 31)),
|
|
942
|
+
};
|
|
943
|
+
});
|
|
944
|
+
});
|
|
945
|
+
selectedAnchor = computed(() => (this.mode() === 'single' ? this.value() : this.range()?.start) ?? null);
|
|
946
|
+
prevDisabled = computed(() => {
|
|
947
|
+
const min = this.min();
|
|
948
|
+
if (!min)
|
|
949
|
+
return false;
|
|
950
|
+
const active = this.activeDate();
|
|
951
|
+
switch (this.view()) {
|
|
952
|
+
case 'days':
|
|
953
|
+
return compareDays(new Date(active.getFullYear(), active.getMonth(), 0), min) < 0;
|
|
954
|
+
case 'months':
|
|
955
|
+
return active.getFullYear() - 1 < min.getFullYear();
|
|
956
|
+
case 'years':
|
|
957
|
+
return this.yearPageStart() - 1 < min.getFullYear();
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
nextDisabled = computed(() => {
|
|
961
|
+
const max = this.max();
|
|
962
|
+
if (!max)
|
|
963
|
+
return false;
|
|
964
|
+
const active = this.activeDate();
|
|
965
|
+
switch (this.view()) {
|
|
966
|
+
case 'days':
|
|
967
|
+
return compareDays(new Date(active.getFullYear(), active.getMonth() + 1, 1), max) > 0;
|
|
968
|
+
case 'months':
|
|
969
|
+
return active.getFullYear() + 1 > max.getFullYear();
|
|
970
|
+
case 'years':
|
|
971
|
+
return this.yearPageStart() + YEARS_PER_PAGE > max.getFullYear();
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
constructor() {
|
|
975
|
+
// Seçim dışarıdan değiştiğinde (örn. input'a tarih yazıldığında) o aya git.
|
|
976
|
+
effect(() => {
|
|
977
|
+
const anchor = this.selectedAnchor() ?? this.startAt();
|
|
978
|
+
if (!anchor)
|
|
979
|
+
return;
|
|
980
|
+
untracked(() => {
|
|
981
|
+
if (!isSameMonth(anchor, this.activeDate()))
|
|
982
|
+
this.setActive(startOfDay(anchor));
|
|
983
|
+
});
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
// --- Etkileşim ------------------------------------------------------------------
|
|
987
|
+
select(date) {
|
|
988
|
+
if (!this.isSelectable(date))
|
|
989
|
+
return;
|
|
990
|
+
this.setActive(date);
|
|
991
|
+
if (this.mode() === 'single') {
|
|
992
|
+
this.value.set(date);
|
|
993
|
+
}
|
|
994
|
+
else {
|
|
995
|
+
const range = this.range();
|
|
996
|
+
if (!range?.start || range.end || compareDays(date, range.start) < 0) {
|
|
997
|
+
this.range.set({ start: date, end: null });
|
|
998
|
+
}
|
|
999
|
+
else {
|
|
1000
|
+
this.range.set({ start: range.start, end: date });
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
this.dateSelected.emit(date);
|
|
1004
|
+
}
|
|
1005
|
+
/** Klavye odağını takvime taşır (tarih seçici açıldığında kullanılır). */
|
|
1006
|
+
focusActiveCell() {
|
|
1007
|
+
this.focusAfterRender('.hu-calendar__cell[tabindex="0"]');
|
|
1008
|
+
}
|
|
1009
|
+
/** Görünüm değişince tıklanan buton DOM'dan kalkar; odağı yeni görünüme taşı. */
|
|
1010
|
+
focusAfterRender(...selectors) {
|
|
1011
|
+
afterNextRender(() => {
|
|
1012
|
+
for (const selector of selectors) {
|
|
1013
|
+
const el = this.host.nativeElement.querySelector(selector);
|
|
1014
|
+
if (el)
|
|
1015
|
+
return el.focus();
|
|
1016
|
+
}
|
|
1017
|
+
}, { injector: this.injector });
|
|
1018
|
+
}
|
|
1019
|
+
focusPicker() {
|
|
1020
|
+
this.focusAfterRender('.hu-calendar__pick[aria-selected="true"]', '.hu-calendar__pick--current', '.hu-calendar__pick:not(:disabled)');
|
|
1021
|
+
}
|
|
1022
|
+
previous() {
|
|
1023
|
+
this.navigate(-1);
|
|
1024
|
+
}
|
|
1025
|
+
next() {
|
|
1026
|
+
this.navigate(1);
|
|
1027
|
+
}
|
|
1028
|
+
navigate(direction) {
|
|
1029
|
+
const active = this.activeDate();
|
|
1030
|
+
switch (this.view()) {
|
|
1031
|
+
case 'days':
|
|
1032
|
+
return this.setActive(addMonths(active, direction), false);
|
|
1033
|
+
case 'months':
|
|
1034
|
+
return this.setActive(addMonths(active, direction * 12), false);
|
|
1035
|
+
case 'years':
|
|
1036
|
+
return this.setActive(addMonths(active, direction * 12 * YEARS_PER_PAGE), false);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
toggleView() {
|
|
1040
|
+
this.view.update((v) => (v === 'days' ? 'months' : v === 'months' ? 'years' : 'days'));
|
|
1041
|
+
}
|
|
1042
|
+
pickMonth(month) {
|
|
1043
|
+
const active = this.activeDate();
|
|
1044
|
+
const day = Math.min(active.getDate(), daysInMonth(active.getFullYear(), month));
|
|
1045
|
+
this.setActive(new Date(active.getFullYear(), month, day));
|
|
1046
|
+
this.view.set('days');
|
|
1047
|
+
this.focusActiveCell();
|
|
1048
|
+
}
|
|
1049
|
+
pickYear(year) {
|
|
1050
|
+
const active = this.activeDate();
|
|
1051
|
+
const day = Math.min(active.getDate(), daysInMonth(year, active.getMonth()));
|
|
1052
|
+
this.setActive(new Date(year, active.getMonth(), day));
|
|
1053
|
+
this.view.set('months');
|
|
1054
|
+
this.focusPicker();
|
|
1055
|
+
}
|
|
1056
|
+
onGridKeydown(event) {
|
|
1057
|
+
const active = this.activeDate();
|
|
1058
|
+
const first = this.firstDayOfWeek();
|
|
1059
|
+
let next = null;
|
|
1060
|
+
switch (event.key) {
|
|
1061
|
+
case 'ArrowLeft':
|
|
1062
|
+
next = addDays(active, -1);
|
|
1063
|
+
break;
|
|
1064
|
+
case 'ArrowRight':
|
|
1065
|
+
next = addDays(active, 1);
|
|
1066
|
+
break;
|
|
1067
|
+
case 'ArrowUp':
|
|
1068
|
+
next = addDays(active, -7);
|
|
1069
|
+
break;
|
|
1070
|
+
case 'ArrowDown':
|
|
1071
|
+
next = addDays(active, 7);
|
|
1072
|
+
break;
|
|
1073
|
+
case 'Home':
|
|
1074
|
+
next = startOfWeek(active, first);
|
|
1075
|
+
break;
|
|
1076
|
+
case 'End':
|
|
1077
|
+
next = addDays(startOfWeek(active, first), 6);
|
|
1078
|
+
break;
|
|
1079
|
+
case 'PageUp':
|
|
1080
|
+
next = addMonths(active, event.shiftKey ? -12 : -1);
|
|
1081
|
+
break;
|
|
1082
|
+
case 'PageDown':
|
|
1083
|
+
next = addMonths(active, event.shiftKey ? 12 : 1);
|
|
1084
|
+
break;
|
|
1085
|
+
case 'Enter':
|
|
1086
|
+
case ' ':
|
|
1087
|
+
event.preventDefault();
|
|
1088
|
+
this.select(active);
|
|
1089
|
+
return;
|
|
1090
|
+
default:
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
event.preventDefault();
|
|
1094
|
+
this.setActive(next);
|
|
1095
|
+
this.focusActiveCell();
|
|
1096
|
+
}
|
|
1097
|
+
setActive(date, clamp = true) {
|
|
1098
|
+
const next = clamp ? clampDate(date, this.min(), this.max()) : date;
|
|
1099
|
+
const previous = this.activeDate();
|
|
1100
|
+
this.activeDate.set(next);
|
|
1101
|
+
if (!isSameMonth(previous, next))
|
|
1102
|
+
this.monthChange.emit(new Date(next.getFullYear(), next.getMonth(), 1));
|
|
1103
|
+
}
|
|
1104
|
+
isSelectable(date) {
|
|
1105
|
+
const min = this.min();
|
|
1106
|
+
const max = this.max();
|
|
1107
|
+
if (min && compareDays(date, min) < 0)
|
|
1108
|
+
return false;
|
|
1109
|
+
if (max && compareDays(date, max) > 0)
|
|
1110
|
+
return false;
|
|
1111
|
+
return this.dateFilter()?.(date) ?? true;
|
|
1112
|
+
}
|
|
1113
|
+
isRangeAllowed(from, to) {
|
|
1114
|
+
const min = this.min();
|
|
1115
|
+
const max = this.max();
|
|
1116
|
+
return !(min && compareDays(to, min) < 0) && !(max && compareDays(from, max) > 0);
|
|
1117
|
+
}
|
|
1118
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCalendar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1119
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuCalendar, isStandalone: true, selector: "hu-calendar", inputs: { mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, range: { classPropertyName: "range", publicName: "range", 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 }, dateFilter: { classPropertyName: "dateFilter", publicName: "dateFilter", isSignal: true, isRequired: false, transformFunction: null }, markers: { classPropertyName: "markers", publicName: "markers", isSignal: true, isRequired: false, transformFunction: null }, startAt: { classPropertyName: "startAt", publicName: "startAt", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, firstDayOfWeek: { classPropertyName: "firstDayOfWeek", publicName: "firstDayOfWeek", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", range: "rangeChange", dateSelected: "dateSelected", monthChange: "monthChange" }, host: { classAttribute: "hu-calendar" }, ngImport: i0, template: "<div class=\"hu-calendar__header\">\n <button type=\"button\" class=\"hu-calendar__nav\" aria-label=\"\u00D6nceki\" [disabled]=\"prevDisabled()\" (click)=\"previous()\">\n <hu-icon name=\"chevron-left\" [size]=\"16\" />\n </button>\n <button\n type=\"button\"\n class=\"hu-calendar__title\"\n [attr.aria-label]=\"view() === 'days' ? headerLabel() + ', ay ve y\u0131l se\u00E7' : view() === 'months' ? headerLabel() + ', y\u0131l se\u00E7' : 'G\u00FCn g\u00F6r\u00FCn\u00FCm\u00FCne d\u00F6n'\"\n aria-live=\"polite\"\n (click)=\"toggleView()\"\n >\n {{ headerLabel() }}\n <hu-icon name=\"chevron-down\" [size]=\"14\" [class.hu-calendar__title-icon--open]=\"view() !== 'days'\" />\n </button>\n <button type=\"button\" class=\"hu-calendar__nav\" aria-label=\"Sonraki\" [disabled]=\"nextDisabled()\" (click)=\"next()\">\n <hu-icon name=\"chevron-right\" [size]=\"16\" />\n </button>\n</div>\n\n@switch (view()) {\n @case ('days') {\n <table class=\"hu-calendar__grid\" role=\"grid\" [attr.aria-label]=\"headerLabel()\" (keydown)=\"onGridKeydown($event)\">\n <thead>\n <tr>\n @for (wd of weekdays(); track $index) {\n <th scope=\"col\" [attr.abbr]=\"wd.long\">{{ wd.short }}</th>\n }\n </tr>\n </thead>\n <tbody (mouseleave)=\"hoverDate.set(null)\">\n @for (week of weeks(); track $index) {\n <tr>\n @for (cell of week; track cell.key) {\n <td\n role=\"gridcell\"\n [attr.aria-selected]=\"cell.selected\"\n [class.hu-calendar__day--in-range]=\"cell.inRange\"\n [class.hu-calendar__day--range-start]=\"cell.rangeStart\"\n [class.hu-calendar__day--range-end]=\"cell.rangeEnd\"\n >\n <button\n type=\"button\"\n class=\"hu-calendar__cell\"\n [class.hu-calendar__cell--outside]=\"!cell.inMonth\"\n [class.hu-calendar__cell--today]=\"cell.today\"\n [class.hu-calendar__cell--selected]=\"cell.selected\"\n [attr.tabindex]=\"cell.key === activeKey() ? 0 : -1\"\n [attr.aria-label]=\"cell.label\"\n [attr.aria-current]=\"cell.today ? 'date' : null\"\n [attr.title]=\"cell.markers.length ? cell.label : null\"\n [disabled]=\"cell.disabled\"\n (click)=\"select(cell.date)\"\n (mouseenter)=\"hoverDate.set(cell.date)\"\n >\n {{ cell.day }}\n @if (cell.markers.length) {\n <span class=\"hu-calendar__markers\" aria-hidden=\"true\">\n @for (m of cell.markers.slice(0, 3); track $index) {\n <span class=\"hu-calendar__marker\" [attr.data-variant]=\"m.variant ?? 'primary'\"></span>\n }\n </span>\n }\n </button>\n </td>\n }\n </tr>\n }\n </tbody>\n </table>\n }\n @case ('months') {\n <div class=\"hu-calendar__picker\" role=\"listbox\" aria-label=\"Ay se\u00E7\">\n @for (m of months(); track m.value) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"hu-calendar__pick\"\n [class.hu-calendar__pick--current]=\"m.current\"\n [attr.aria-selected]=\"m.selected\"\n [disabled]=\"m.disabled\"\n (click)=\"pickMonth(m.value)\"\n >\n {{ m.label }}\n </button>\n }\n </div>\n }\n @case ('years') {\n <div class=\"hu-calendar__picker\" role=\"listbox\" aria-label=\"Y\u0131l se\u00E7\">\n @for (y of years(); track y.value) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"hu-calendar__pick\"\n [class.hu-calendar__pick--current]=\"y.current\"\n [attr.aria-selected]=\"y.selected\"\n [disabled]=\"y.disabled\"\n (click)=\"pickYear(y.value)\"\n >\n {{ y.label }}\n </button>\n }\n </div>\n }\n}\n", styles: [".hu-calendar{--_cell: 2.375rem;display:inline-block;width:calc(var(--_cell) * 7);box-sizing:content-box;font-size:var(--hu-text-sm);color:var(--hu-text);-webkit-user-select:none;user-select:none}.hu-calendar__header{display:flex;align-items:center;justify-content:space-between;gap:var(--hu-space-1);margin-bottom:var(--hu-space-2)}.hu-calendar__nav,.hu-calendar__title{display:inline-flex;align-items:center;justify-content:center;gap:var(--hu-space-1);height:2rem;font:inherit;color:var(--hu-text);background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer}.hu-calendar__nav:hover:not(:disabled),.hu-calendar__title:hover:not(:disabled){background:var(--hu-surface-3)}.hu-calendar__nav:focus-visible,.hu-calendar__title:focus-visible{outline:none;box-shadow:var(--hu-ring)}.hu-calendar__nav:disabled,.hu-calendar__title:disabled{opacity:.35;cursor:not-allowed}.hu-calendar__nav{width:2rem;color:var(--hu-text-muted)}.hu-calendar__title{padding:0 var(--hu-space-2);font-weight:600}.hu-calendar__title .hu-icon{color:var(--hu-text-subtle);transition:transform var(--hu-transition)}.hu-calendar__title-icon--open{transform:rotate(180deg)}.hu-calendar__grid{width:100%;border-collapse:collapse;table-layout:fixed}.hu-calendar__grid th{height:2rem;padding:0;font-size:var(--hu-text-xs);font-weight:500;color:var(--hu-text-subtle);text-align:center}.hu-calendar__grid td{position:relative;padding:1px 0;text-align:center}.hu-calendar__day--in-range:before,.hu-calendar__day--range-start:before,.hu-calendar__day--range-end:before{content:\"\";position:absolute;inset:1px 0;background:var(--hu-primary-soft)}.hu-calendar__day--range-start:before{left:50%}.hu-calendar__day--range-end:before{right:50%}.hu-calendar__cell{position:relative;display:inline-flex;flex-direction:column;align-items:center;justify-content:center;width:calc(var(--_cell) - 2px);height:calc(var(--_cell) - 2px);padding:0;font:inherit;font-variant-numeric:tabular-nums;color:inherit;background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer;transition:background-color var(--hu-transition),color var(--hu-transition)}.hu-calendar__cell:hover:not(:disabled,.hu-calendar__cell--selected){background:var(--hu-surface-3)}.hu-calendar__cell:focus-visible{outline:none;box-shadow:var(--hu-ring);z-index:1}.hu-calendar__cell--outside{color:var(--hu-text-subtle)}.hu-calendar__cell--today{font-weight:700;color:var(--hu-primary)}.hu-calendar__cell--today:after{content:\"\";position:absolute;inset:3px;border:1px solid color-mix(in srgb,var(--hu-primary) 45%,transparent);border-radius:calc(var(--hu-radius-md) - 2px);pointer-events:none}.hu-calendar__cell--selected,.hu-calendar__cell--selected:hover{font-weight:600;color:var(--hu-primary-fg);background:var(--hu-primary)}.hu-calendar__cell--selected:after,.hu-calendar__cell--selected:hover:after{display:none}.hu-calendar__cell:disabled{color:var(--hu-text-subtle);text-decoration:line-through;text-decoration-color:color-mix(in srgb,var(--hu-text-subtle) 60%,transparent);opacity:.5;cursor:not-allowed}.hu-calendar__markers{position:absolute;bottom:4px;display:flex;gap:2px}.hu-calendar__marker{width:4px;height:4px;background:var(--_marker, var(--hu-primary));border-radius:50%}.hu-calendar__marker[data-variant=info]{--_marker: var(--hu-info)}.hu-calendar__marker[data-variant=success]{--_marker: var(--hu-success)}.hu-calendar__marker[data-variant=warning]{--_marker: var(--hu-warning)}.hu-calendar__marker[data-variant=danger]{--_marker: var(--hu-danger)}.hu-calendar__cell--selected .hu-calendar__marker{--_marker: currentColor}.hu-calendar__picker{display:grid;grid-template-columns:repeat(3,1fr);gap:var(--hu-space-1);min-height:calc(var(--_cell) * 6 + 2rem);align-content:center}.hu-calendar__pick{height:3rem;font:inherit;color:inherit;background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer}.hu-calendar__pick:hover:not(:disabled){background:var(--hu-surface-3)}.hu-calendar__pick:focus-visible{outline:none;box-shadow:var(--hu-ring)}.hu-calendar__pick--current{font-weight:700;color:var(--hu-primary)}.hu-calendar__pick[aria-selected=true]{font-weight:600;color:var(--hu-primary-fg);background:var(--hu-primary)}.hu-calendar__pick:disabled{opacity:.35;cursor:not-allowed}\n"], dependencies: [{ kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1120
|
+
}
|
|
1121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCalendar, decorators: [{
|
|
1122
|
+
type: Component,
|
|
1123
|
+
args: [{ selector: 'hu-calendar', imports: [HuIcon], host: { class: 'hu-calendar' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"hu-calendar__header\">\n <button type=\"button\" class=\"hu-calendar__nav\" aria-label=\"\u00D6nceki\" [disabled]=\"prevDisabled()\" (click)=\"previous()\">\n <hu-icon name=\"chevron-left\" [size]=\"16\" />\n </button>\n <button\n type=\"button\"\n class=\"hu-calendar__title\"\n [attr.aria-label]=\"view() === 'days' ? headerLabel() + ', ay ve y\u0131l se\u00E7' : view() === 'months' ? headerLabel() + ', y\u0131l se\u00E7' : 'G\u00FCn g\u00F6r\u00FCn\u00FCm\u00FCne d\u00F6n'\"\n aria-live=\"polite\"\n (click)=\"toggleView()\"\n >\n {{ headerLabel() }}\n <hu-icon name=\"chevron-down\" [size]=\"14\" [class.hu-calendar__title-icon--open]=\"view() !== 'days'\" />\n </button>\n <button type=\"button\" class=\"hu-calendar__nav\" aria-label=\"Sonraki\" [disabled]=\"nextDisabled()\" (click)=\"next()\">\n <hu-icon name=\"chevron-right\" [size]=\"16\" />\n </button>\n</div>\n\n@switch (view()) {\n @case ('days') {\n <table class=\"hu-calendar__grid\" role=\"grid\" [attr.aria-label]=\"headerLabel()\" (keydown)=\"onGridKeydown($event)\">\n <thead>\n <tr>\n @for (wd of weekdays(); track $index) {\n <th scope=\"col\" [attr.abbr]=\"wd.long\">{{ wd.short }}</th>\n }\n </tr>\n </thead>\n <tbody (mouseleave)=\"hoverDate.set(null)\">\n @for (week of weeks(); track $index) {\n <tr>\n @for (cell of week; track cell.key) {\n <td\n role=\"gridcell\"\n [attr.aria-selected]=\"cell.selected\"\n [class.hu-calendar__day--in-range]=\"cell.inRange\"\n [class.hu-calendar__day--range-start]=\"cell.rangeStart\"\n [class.hu-calendar__day--range-end]=\"cell.rangeEnd\"\n >\n <button\n type=\"button\"\n class=\"hu-calendar__cell\"\n [class.hu-calendar__cell--outside]=\"!cell.inMonth\"\n [class.hu-calendar__cell--today]=\"cell.today\"\n [class.hu-calendar__cell--selected]=\"cell.selected\"\n [attr.tabindex]=\"cell.key === activeKey() ? 0 : -1\"\n [attr.aria-label]=\"cell.label\"\n [attr.aria-current]=\"cell.today ? 'date' : null\"\n [attr.title]=\"cell.markers.length ? cell.label : null\"\n [disabled]=\"cell.disabled\"\n (click)=\"select(cell.date)\"\n (mouseenter)=\"hoverDate.set(cell.date)\"\n >\n {{ cell.day }}\n @if (cell.markers.length) {\n <span class=\"hu-calendar__markers\" aria-hidden=\"true\">\n @for (m of cell.markers.slice(0, 3); track $index) {\n <span class=\"hu-calendar__marker\" [attr.data-variant]=\"m.variant ?? 'primary'\"></span>\n }\n </span>\n }\n </button>\n </td>\n }\n </tr>\n }\n </tbody>\n </table>\n }\n @case ('months') {\n <div class=\"hu-calendar__picker\" role=\"listbox\" aria-label=\"Ay se\u00E7\">\n @for (m of months(); track m.value) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"hu-calendar__pick\"\n [class.hu-calendar__pick--current]=\"m.current\"\n [attr.aria-selected]=\"m.selected\"\n [disabled]=\"m.disabled\"\n (click)=\"pickMonth(m.value)\"\n >\n {{ m.label }}\n </button>\n }\n </div>\n }\n @case ('years') {\n <div class=\"hu-calendar__picker\" role=\"listbox\" aria-label=\"Y\u0131l se\u00E7\">\n @for (y of years(); track y.value) {\n <button\n type=\"button\"\n role=\"option\"\n class=\"hu-calendar__pick\"\n [class.hu-calendar__pick--current]=\"y.current\"\n [attr.aria-selected]=\"y.selected\"\n [disabled]=\"y.disabled\"\n (click)=\"pickYear(y.value)\"\n >\n {{ y.label }}\n </button>\n }\n </div>\n }\n}\n", styles: [".hu-calendar{--_cell: 2.375rem;display:inline-block;width:calc(var(--_cell) * 7);box-sizing:content-box;font-size:var(--hu-text-sm);color:var(--hu-text);-webkit-user-select:none;user-select:none}.hu-calendar__header{display:flex;align-items:center;justify-content:space-between;gap:var(--hu-space-1);margin-bottom:var(--hu-space-2)}.hu-calendar__nav,.hu-calendar__title{display:inline-flex;align-items:center;justify-content:center;gap:var(--hu-space-1);height:2rem;font:inherit;color:var(--hu-text);background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer}.hu-calendar__nav:hover:not(:disabled),.hu-calendar__title:hover:not(:disabled){background:var(--hu-surface-3)}.hu-calendar__nav:focus-visible,.hu-calendar__title:focus-visible{outline:none;box-shadow:var(--hu-ring)}.hu-calendar__nav:disabled,.hu-calendar__title:disabled{opacity:.35;cursor:not-allowed}.hu-calendar__nav{width:2rem;color:var(--hu-text-muted)}.hu-calendar__title{padding:0 var(--hu-space-2);font-weight:600}.hu-calendar__title .hu-icon{color:var(--hu-text-subtle);transition:transform var(--hu-transition)}.hu-calendar__title-icon--open{transform:rotate(180deg)}.hu-calendar__grid{width:100%;border-collapse:collapse;table-layout:fixed}.hu-calendar__grid th{height:2rem;padding:0;font-size:var(--hu-text-xs);font-weight:500;color:var(--hu-text-subtle);text-align:center}.hu-calendar__grid td{position:relative;padding:1px 0;text-align:center}.hu-calendar__day--in-range:before,.hu-calendar__day--range-start:before,.hu-calendar__day--range-end:before{content:\"\";position:absolute;inset:1px 0;background:var(--hu-primary-soft)}.hu-calendar__day--range-start:before{left:50%}.hu-calendar__day--range-end:before{right:50%}.hu-calendar__cell{position:relative;display:inline-flex;flex-direction:column;align-items:center;justify-content:center;width:calc(var(--_cell) - 2px);height:calc(var(--_cell) - 2px);padding:0;font:inherit;font-variant-numeric:tabular-nums;color:inherit;background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer;transition:background-color var(--hu-transition),color var(--hu-transition)}.hu-calendar__cell:hover:not(:disabled,.hu-calendar__cell--selected){background:var(--hu-surface-3)}.hu-calendar__cell:focus-visible{outline:none;box-shadow:var(--hu-ring);z-index:1}.hu-calendar__cell--outside{color:var(--hu-text-subtle)}.hu-calendar__cell--today{font-weight:700;color:var(--hu-primary)}.hu-calendar__cell--today:after{content:\"\";position:absolute;inset:3px;border:1px solid color-mix(in srgb,var(--hu-primary) 45%,transparent);border-radius:calc(var(--hu-radius-md) - 2px);pointer-events:none}.hu-calendar__cell--selected,.hu-calendar__cell--selected:hover{font-weight:600;color:var(--hu-primary-fg);background:var(--hu-primary)}.hu-calendar__cell--selected:after,.hu-calendar__cell--selected:hover:after{display:none}.hu-calendar__cell:disabled{color:var(--hu-text-subtle);text-decoration:line-through;text-decoration-color:color-mix(in srgb,var(--hu-text-subtle) 60%,transparent);opacity:.5;cursor:not-allowed}.hu-calendar__markers{position:absolute;bottom:4px;display:flex;gap:2px}.hu-calendar__marker{width:4px;height:4px;background:var(--_marker, var(--hu-primary));border-radius:50%}.hu-calendar__marker[data-variant=info]{--_marker: var(--hu-info)}.hu-calendar__marker[data-variant=success]{--_marker: var(--hu-success)}.hu-calendar__marker[data-variant=warning]{--_marker: var(--hu-warning)}.hu-calendar__marker[data-variant=danger]{--_marker: var(--hu-danger)}.hu-calendar__cell--selected .hu-calendar__marker{--_marker: currentColor}.hu-calendar__picker{display:grid;grid-template-columns:repeat(3,1fr);gap:var(--hu-space-1);min-height:calc(var(--_cell) * 6 + 2rem);align-content:center}.hu-calendar__pick{height:3rem;font:inherit;color:inherit;background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer}.hu-calendar__pick:hover:not(:disabled){background:var(--hu-surface-3)}.hu-calendar__pick:focus-visible{outline:none;box-shadow:var(--hu-ring)}.hu-calendar__pick--current{font-weight:700;color:var(--hu-primary)}.hu-calendar__pick[aria-selected=true]{font-weight:600;color:var(--hu-primary-fg);background:var(--hu-primary)}.hu-calendar__pick:disabled{opacity:.35;cursor:not-allowed}\n"] }]
|
|
1124
|
+
}], ctorParameters: () => [] });
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Tarih seçici form kontrolü. Tarih elle (`gg.aa.yyyy`) yazılabilir veya
|
|
1128
|
+
* takvimden seçilebilir. `mode="range"` ile değer `{ start, end }` olur.
|
|
1129
|
+
* Validasyon hataları: `huDateParse`, `huDateMin`, `huDateMax`, `huDateUnavailable`.
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* <hu-form-field label="Başlangıç tarihi">
|
|
1133
|
+
* <hu-date-picker formControlName="startDate" [min]="today" />
|
|
1134
|
+
* </hu-form-field>
|
|
1135
|
+
* <hu-date-picker mode="range" [(value)]="period" placeholder="Tarih aralığı" />
|
|
1136
|
+
*/
|
|
1137
|
+
class HuDatePicker {
|
|
1138
|
+
injector = inject(Injector);
|
|
1139
|
+
host = inject(ElementRef);
|
|
1140
|
+
win = inject(DOCUMENT).defaultView;
|
|
1141
|
+
field = inject(HU_FORM_FIELD, { optional: true, host: true });
|
|
1142
|
+
mode = input('single');
|
|
1143
|
+
value = model(null);
|
|
1144
|
+
min = input(null);
|
|
1145
|
+
max = input(null);
|
|
1146
|
+
dateFilter = input(null);
|
|
1147
|
+
markers = input([]);
|
|
1148
|
+
placeholder = input();
|
|
1149
|
+
size = input('md');
|
|
1150
|
+
disabled = input(false, { transform: booleanAttribute });
|
|
1151
|
+
id = input(huUniqueId('hu-date-picker'));
|
|
1152
|
+
open = signal(false);
|
|
1153
|
+
text = signal('');
|
|
1154
|
+
panelId = huUniqueId('hu-date-picker-panel');
|
|
1155
|
+
parseError = signal(false);
|
|
1156
|
+
formDisabled = signal(false);
|
|
1157
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
1158
|
+
// --- HuFormFieldControl -----------------------------------------------------------
|
|
1159
|
+
// NgControl, NG_VALUE_ACCESSOR döngüsüne girmemek için geç çözülür.
|
|
1160
|
+
ngControl;
|
|
1161
|
+
get hasControl() {
|
|
1162
|
+
return !!this.resolveControl();
|
|
1163
|
+
}
|
|
1164
|
+
controlErrorVisible = signal(false);
|
|
1165
|
+
errors = signal(null);
|
|
1166
|
+
isInvalid = computed(() => this.controlErrorVisible() || (this.field?.showError() ?? false));
|
|
1167
|
+
placeholderText = computed(() => this.placeholder() ?? (this.mode() === 'range' ? 'gg.aa.yyyy – gg.aa.yyyy' : 'gg.aa.yyyy'));
|
|
1168
|
+
singleValue = computed(() => {
|
|
1169
|
+
const v = this.value();
|
|
1170
|
+
return v instanceof Date ? v : null;
|
|
1171
|
+
});
|
|
1172
|
+
rangeValue = computed(() => {
|
|
1173
|
+
const v = this.value();
|
|
1174
|
+
return v && !(v instanceof Date) ? v : null;
|
|
1175
|
+
});
|
|
1176
|
+
/** Takvimde aralık seçilirken geçici değer (bitiş seçilene kadar forma yazılmaz). */
|
|
1177
|
+
draftRange = signal(null);
|
|
1178
|
+
input = viewChild.required('input');
|
|
1179
|
+
panel = viewChild.required('panel');
|
|
1180
|
+
calendar = viewChild(HuCalendar);
|
|
1181
|
+
supportsPopover = typeof HTMLElement !== 'undefined' && 'showPopover' in HTMLElement.prototype;
|
|
1182
|
+
/** Son fare basışı bileşenin içinde mi? (DOM'dan kalkan butonlar focusout'u yanıltmasın) */
|
|
1183
|
+
pointerInside = false;
|
|
1184
|
+
onChange = () => { };
|
|
1185
|
+
onTouched = () => { };
|
|
1186
|
+
onValidatorChange = () => { };
|
|
1187
|
+
constructor() {
|
|
1188
|
+
// Değer dışarıdan (model) değişirse metni güncelle.
|
|
1189
|
+
effect(() => {
|
|
1190
|
+
const value = this.value();
|
|
1191
|
+
untracked(() => this.text.set(this.format(value)));
|
|
1192
|
+
});
|
|
1193
|
+
// Sınırlar değişince validasyonu yeniden çalıştır.
|
|
1194
|
+
effect(() => {
|
|
1195
|
+
this.min();
|
|
1196
|
+
this.max();
|
|
1197
|
+
this.dateFilter();
|
|
1198
|
+
untracked(() => this.onValidatorChange());
|
|
1199
|
+
});
|
|
1200
|
+
const reposition = () => this.open() && this.positionPanel();
|
|
1201
|
+
this.win?.addEventListener('resize', reposition);
|
|
1202
|
+
this.win?.addEventListener('scroll', reposition, true);
|
|
1203
|
+
inject(DestroyRef).onDestroy(() => {
|
|
1204
|
+
this.win?.removeEventListener('resize', reposition);
|
|
1205
|
+
this.win?.removeEventListener('scroll', reposition, true);
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
ngDoCheck() {
|
|
1209
|
+
const c = this.resolveControl();
|
|
1210
|
+
if (!c)
|
|
1211
|
+
return;
|
|
1212
|
+
this.controlErrorVisible.set(!!c.invalid && !!(c.touched || c.dirty));
|
|
1213
|
+
this.errors.set(c.errors);
|
|
1214
|
+
}
|
|
1215
|
+
// --- Açma / kapama ----------------------------------------------------------------
|
|
1216
|
+
toggle() {
|
|
1217
|
+
if (this.open())
|
|
1218
|
+
this.close(true);
|
|
1219
|
+
else
|
|
1220
|
+
this.openPanel();
|
|
1221
|
+
}
|
|
1222
|
+
openPanel() {
|
|
1223
|
+
if (this.isDisabled() || this.open())
|
|
1224
|
+
return;
|
|
1225
|
+
this.commitText();
|
|
1226
|
+
this.draftRange.set(this.rangeValue());
|
|
1227
|
+
this.open.set(true);
|
|
1228
|
+
// Takvim render edildikten sonra göster, ölç ve odakla.
|
|
1229
|
+
afterNextRender(() => {
|
|
1230
|
+
if (!this.open())
|
|
1231
|
+
return;
|
|
1232
|
+
if (this.supportsPopover)
|
|
1233
|
+
this.panel().nativeElement.showPopover();
|
|
1234
|
+
this.positionPanel();
|
|
1235
|
+
this.calendar()?.focusActiveCell();
|
|
1236
|
+
}, { injector: this.injector });
|
|
1237
|
+
}
|
|
1238
|
+
close(restoreFocus = false) {
|
|
1239
|
+
if (!this.open())
|
|
1240
|
+
return;
|
|
1241
|
+
this.open.set(false);
|
|
1242
|
+
this.draftRange.set(null);
|
|
1243
|
+
if (this.supportsPopover && this.panel().nativeElement.matches(':popover-open')) {
|
|
1244
|
+
this.panel().nativeElement.hidePopover();
|
|
1245
|
+
}
|
|
1246
|
+
if (restoreFocus)
|
|
1247
|
+
this.input().nativeElement.focus();
|
|
1248
|
+
}
|
|
1249
|
+
positionPanel() {
|
|
1250
|
+
const panel = this.panel().nativeElement;
|
|
1251
|
+
if (!this.supportsPopover || !this.win)
|
|
1252
|
+
return;
|
|
1253
|
+
const anchor = this.host.nativeElement.getBoundingClientRect();
|
|
1254
|
+
const { offsetWidth: width, offsetHeight: height } = panel;
|
|
1255
|
+
const gap = 6;
|
|
1256
|
+
const spaceBelow = this.win.innerHeight - anchor.bottom;
|
|
1257
|
+
const top = spaceBelow < height + gap && anchor.top > height + gap ? anchor.top - height - gap : anchor.bottom + gap;
|
|
1258
|
+
const left = Math.max(8, Math.min(anchor.left, this.win.innerWidth - width - 8));
|
|
1259
|
+
panel.style.top = `${top}px`;
|
|
1260
|
+
panel.style.left = `${left}px`;
|
|
1261
|
+
}
|
|
1262
|
+
// --- Takvimden seçim ------------------------------------------------------------
|
|
1263
|
+
onCalendarDate(date) {
|
|
1264
|
+
if (this.mode() !== 'single')
|
|
1265
|
+
return;
|
|
1266
|
+
this.commit(date);
|
|
1267
|
+
this.close(true);
|
|
1268
|
+
}
|
|
1269
|
+
onCalendarRange(range) {
|
|
1270
|
+
this.draftRange.set(range);
|
|
1271
|
+
if (range?.start && range.end) {
|
|
1272
|
+
this.commit(range);
|
|
1273
|
+
this.close(true);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
selectToday() {
|
|
1277
|
+
const today = startOfDay(new Date());
|
|
1278
|
+
if (this.mode() === 'single') {
|
|
1279
|
+
this.commit(today);
|
|
1280
|
+
this.close(true);
|
|
1281
|
+
}
|
|
1282
|
+
else {
|
|
1283
|
+
this.onCalendarRange({ start: today, end: null });
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
clear() {
|
|
1287
|
+
this.commit(null);
|
|
1288
|
+
this.close(true);
|
|
1289
|
+
}
|
|
1290
|
+
// --- Metin girişi ---------------------------------------------------------------
|
|
1291
|
+
onInput(event) {
|
|
1292
|
+
this.text.set(event.target.value);
|
|
1293
|
+
}
|
|
1294
|
+
onInputKeydown(event) {
|
|
1295
|
+
if (event.key === 'Enter') {
|
|
1296
|
+
event.preventDefault();
|
|
1297
|
+
this.commitText();
|
|
1298
|
+
}
|
|
1299
|
+
else if (event.key === 'ArrowDown' && (event.altKey || !this.open())) {
|
|
1300
|
+
event.preventDefault();
|
|
1301
|
+
this.openPanel();
|
|
1302
|
+
}
|
|
1303
|
+
else if (event.key === 'Escape' && this.open()) {
|
|
1304
|
+
event.preventDefault();
|
|
1305
|
+
this.close(true);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
onPanelKeydown(event) {
|
|
1309
|
+
if (event.key === 'Escape') {
|
|
1310
|
+
event.preventDefault();
|
|
1311
|
+
event.stopPropagation();
|
|
1312
|
+
this.close(true);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
commitText() {
|
|
1316
|
+
const text = this.text().trim();
|
|
1317
|
+
const current = this.value();
|
|
1318
|
+
if (text === this.format(current))
|
|
1319
|
+
return;
|
|
1320
|
+
if (!text) {
|
|
1321
|
+
this.commit(null);
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
const parsed = this.mode() === 'range' ? parseRange(text) : parseDate(text);
|
|
1325
|
+
if (parsed) {
|
|
1326
|
+
this.commit(parsed);
|
|
1327
|
+
}
|
|
1328
|
+
else {
|
|
1329
|
+
// Metni koru ki kullanıcı düzeltebilsin; forma null + parse hatası yaz.
|
|
1330
|
+
this.parseError.set(true);
|
|
1331
|
+
this.value.set(null);
|
|
1332
|
+
this.text.set(text);
|
|
1333
|
+
this.onChange(null);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
commit(value) {
|
|
1337
|
+
this.parseError.set(false);
|
|
1338
|
+
this.value.set(value);
|
|
1339
|
+
this.text.set(this.format(value));
|
|
1340
|
+
this.onChange(value);
|
|
1341
|
+
}
|
|
1342
|
+
// --- Odak / dış tıklama -----------------------------------------------------------
|
|
1343
|
+
onFocusOut(event) {
|
|
1344
|
+
const next = event.relatedTarget;
|
|
1345
|
+
if (next && this.host.nativeElement.contains(next))
|
|
1346
|
+
return;
|
|
1347
|
+
// Panel içinde tıklanan buton yeniden render ile kalktıysa odak "hiçbir yere" gider; kapatma.
|
|
1348
|
+
if (!next && this.pointerInside && this.open())
|
|
1349
|
+
return;
|
|
1350
|
+
this.commitText();
|
|
1351
|
+
this.close();
|
|
1352
|
+
this.onTouched();
|
|
1353
|
+
}
|
|
1354
|
+
onDocumentPointer(event) {
|
|
1355
|
+
this.pointerInside = this.host.nativeElement.contains(event.target);
|
|
1356
|
+
if (this.open() && !this.pointerInside)
|
|
1357
|
+
this.close();
|
|
1358
|
+
}
|
|
1359
|
+
// --- ControlValueAccessor / Validator ---------------------------------------------
|
|
1360
|
+
writeValue(value) {
|
|
1361
|
+
this.parseError.set(false);
|
|
1362
|
+
if (value == null || value === '')
|
|
1363
|
+
this.value.set(null);
|
|
1364
|
+
else if (isValidDate(value))
|
|
1365
|
+
this.value.set(startOfDay(value));
|
|
1366
|
+
else if (typeof value === 'object' && 'start' in value)
|
|
1367
|
+
this.value.set(value);
|
|
1368
|
+
else
|
|
1369
|
+
this.value.set(null);
|
|
1370
|
+
this.text.set(this.format(this.value()));
|
|
1371
|
+
}
|
|
1372
|
+
registerOnChange(fn) {
|
|
1373
|
+
this.onChange = fn;
|
|
1374
|
+
}
|
|
1375
|
+
registerOnTouched(fn) {
|
|
1376
|
+
this.onTouched = fn;
|
|
1377
|
+
}
|
|
1378
|
+
setDisabledState(disabled) {
|
|
1379
|
+
this.formDisabled.set(disabled);
|
|
1380
|
+
if (disabled)
|
|
1381
|
+
this.close();
|
|
1382
|
+
}
|
|
1383
|
+
validate(_control) {
|
|
1384
|
+
if (this.parseError())
|
|
1385
|
+
return { huDateParse: true };
|
|
1386
|
+
const value = this.value();
|
|
1387
|
+
const dates = value instanceof Date ? [value] : [value?.start, value?.end].filter((d) => !!d);
|
|
1388
|
+
const min = this.min();
|
|
1389
|
+
const max = this.max();
|
|
1390
|
+
for (const d of dates) {
|
|
1391
|
+
if (min && compareDays(d, min) < 0)
|
|
1392
|
+
return { huDateMin: { min: formatDate(min), actual: d } };
|
|
1393
|
+
if (max && compareDays(d, max) > 0)
|
|
1394
|
+
return { huDateMax: { max: formatDate(max), actual: d } };
|
|
1395
|
+
if (this.dateFilter() && !this.dateFilter()(d))
|
|
1396
|
+
return { huDateUnavailable: true };
|
|
1397
|
+
}
|
|
1398
|
+
return null;
|
|
1399
|
+
}
|
|
1400
|
+
registerOnValidatorChange(fn) {
|
|
1401
|
+
this.onValidatorChange = fn;
|
|
1402
|
+
}
|
|
1403
|
+
format(value) {
|
|
1404
|
+
if (value instanceof Date)
|
|
1405
|
+
return formatDate(value);
|
|
1406
|
+
return value ? formatRange(value) : '';
|
|
1407
|
+
}
|
|
1408
|
+
resolveControl() {
|
|
1409
|
+
if (this.ngControl === undefined) {
|
|
1410
|
+
this.ngControl = this.injector.get(NgControl, null, { self: true, optional: true });
|
|
1411
|
+
}
|
|
1412
|
+
return this.ngControl;
|
|
1413
|
+
}
|
|
1414
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuDatePicker, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1415
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuDatePicker, isStandalone: true, selector: "hu-date-picker", inputs: { mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, 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 }, dateFilter: { classPropertyName: "dateFilter", publicName: "dateFilter", isSignal: true, isRequired: false, transformFunction: null }, markers: { classPropertyName: "markers", publicName: "markers", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { listeners: { "focusout": "onFocusOut($event)", "document:mousedown": "onDocumentPointer($event)" }, properties: { "class.hu-date-picker--open": "open()" }, classAttribute: "hu-date-picker" }, providers: [
|
|
1416
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => HuDatePicker), multi: true },
|
|
1417
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => HuDatePicker), multi: true },
|
|
1418
|
+
{ provide: HuFormFieldControl, useExisting: forwardRef(() => HuDatePicker) },
|
|
1419
|
+
], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true, isSignal: true }, { propertyName: "panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }, { propertyName: "calendar", first: true, predicate: HuCalendar, descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"hu-date-picker__control\">\n <input\n #input\n type=\"text\"\n class=\"hu-input hu-date-picker__input\"\n inputmode=\"numeric\"\n autocomplete=\"off\"\n aria-haspopup=\"dialog\"\n [id]=\"id()\"\n [attr.data-size]=\"size()\"\n [class.hu-input--invalid]=\"isInvalid()\"\n [attr.aria-invalid]=\"isInvalid() || null\"\n [attr.aria-describedby]=\"field?.describedBy() ?? null\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\"\n [attr.placeholder]=\"placeholderText()\"\n [value]=\"text()\"\n [disabled]=\"isDisabled()\"\n (input)=\"onInput($event)\"\n (keydown)=\"onInputKeydown($event)\"\n />\n <button\n type=\"button\"\n class=\"hu-date-picker__toggle\"\n tabindex=\"-1\"\n [attr.aria-label]=\"open() ? 'Takvimi kapat' : 'Takvimi a\u00E7'\"\n [disabled]=\"isDisabled()\"\n (click)=\"toggle()\"\n >\n <hu-icon name=\"calendar\" [size]=\"16\" />\n </button>\n</div>\n\n<div\n #panel\n popover=\"manual\"\n class=\"hu-date-picker__panel\"\n role=\"dialog\"\n aria-label=\"Tarih se\u00E7\"\n [id]=\"panelId\"\n [class.hu-date-picker__panel--inline]=\"!supportsPopover\"\n [attr.hidden]=\"!supportsPopover && !open() ? '' : null\"\n (keydown)=\"onPanelKeydown($event)\"\n>\n @if (open()) {\n <hu-calendar\n [mode]=\"mode()\"\n [value]=\"singleValue()\"\n [range]=\"draftRange()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [dateFilter]=\"dateFilter()\"\n [markers]=\"markers()\"\n (dateSelected)=\"onCalendarDate($event)\"\n (rangeChange)=\"onCalendarRange($event)\"\n />\n <div class=\"hu-date-picker__footer\">\n @if (mode() === 'range') {\n <span class=\"hu-date-picker__hint\">\n {{ draftRange()?.start && !draftRange()?.end ? 'Biti\u015F tarihini se\u00E7in' : 'Ba\u015Flang\u0131\u00E7 tarihini se\u00E7in' }}\n </span>\n } @else {\n <button hu-button variant=\"ghost\" size=\"sm\" type=\"button\" (click)=\"selectToday()\">Bug\u00FCn</button>\n }\n <button hu-button variant=\"ghost\" size=\"sm\" type=\"button\" (click)=\"clear()\">Temizle</button>\n </div>\n }\n</div>\n", styles: [".hu-date-picker{position:relative;display:block;width:100%}.hu-date-picker__control{position:relative;display:flex;align-items:center}.hu-date-picker__input{padding-right:2.5rem;font-variant-numeric:tabular-nums}.hu-date-picker__toggle{position:absolute;right:var(--hu-space-1);display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;color:var(--hu-text-subtle);background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer}.hu-date-picker__toggle:hover:not(:disabled){color:var(--hu-text);background:var(--hu-surface-3)}.hu-date-picker__toggle:disabled{cursor:not-allowed}.hu-date-picker--open .hu-date-picker__toggle{color:var(--hu-primary)}.hu-date-picker__panel{position:fixed;inset:auto;margin:0;padding:var(--hu-space-3);color:var(--hu-text);background:var(--hu-surface);border:1px solid var(--hu-border);border-radius:var(--hu-radius-lg);box-shadow:var(--hu-shadow-lg)}.hu-date-picker__panel:popover-open{animation:hu-date-picker-in .12s ease-out}.hu-date-picker__panel--inline{position:absolute;top:calc(100% + 6px);left:0;z-index:1000}.hu-date-picker__panel--inline[hidden]{display:none}.hu-date-picker__footer{display:flex;align-items:center;justify-content:space-between;gap:var(--hu-space-2);margin-top:var(--hu-space-2);padding-top:var(--hu-space-2);border-top:1px solid var(--hu-border)}.hu-date-picker__hint{font-size:var(--hu-text-xs);color:var(--hu-text-muted)}@keyframes hu-date-picker-in{0%{opacity:0;transform:translateY(-4px)}}\n"], dependencies: [{ kind: "component", type: HuButton, selector: "button[hu-button], a[hu-button]", inputs: ["variant", "color", "size", "disabled", "loading", "block", "iconOnly", "pill"] }, { kind: "component", type: HuCalendar, selector: "hu-calendar", inputs: ["mode", "value", "range", "min", "max", "dateFilter", "markers", "startAt", "locale", "firstDayOfWeek"], outputs: ["valueChange", "rangeChange", "dateSelected", "monthChange"] }, { kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1420
|
+
}
|
|
1421
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuDatePicker, decorators: [{
|
|
1422
|
+
type: Component,
|
|
1423
|
+
args: [{ selector: 'hu-date-picker', imports: [HuButton, HuCalendar, HuIcon], providers: [
|
|
1424
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => HuDatePicker), multi: true },
|
|
1425
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => HuDatePicker), multi: true },
|
|
1426
|
+
{ provide: HuFormFieldControl, useExisting: forwardRef(() => HuDatePicker) },
|
|
1427
|
+
], host: {
|
|
1428
|
+
class: 'hu-date-picker',
|
|
1429
|
+
'[class.hu-date-picker--open]': 'open()',
|
|
1430
|
+
'(focusout)': 'onFocusOut($event)',
|
|
1431
|
+
'(document:mousedown)': 'onDocumentPointer($event)',
|
|
1432
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"hu-date-picker__control\">\n <input\n #input\n type=\"text\"\n class=\"hu-input hu-date-picker__input\"\n inputmode=\"numeric\"\n autocomplete=\"off\"\n aria-haspopup=\"dialog\"\n [id]=\"id()\"\n [attr.data-size]=\"size()\"\n [class.hu-input--invalid]=\"isInvalid()\"\n [attr.aria-invalid]=\"isInvalid() || null\"\n [attr.aria-describedby]=\"field?.describedBy() ?? null\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"panelId\"\n [attr.placeholder]=\"placeholderText()\"\n [value]=\"text()\"\n [disabled]=\"isDisabled()\"\n (input)=\"onInput($event)\"\n (keydown)=\"onInputKeydown($event)\"\n />\n <button\n type=\"button\"\n class=\"hu-date-picker__toggle\"\n tabindex=\"-1\"\n [attr.aria-label]=\"open() ? 'Takvimi kapat' : 'Takvimi a\u00E7'\"\n [disabled]=\"isDisabled()\"\n (click)=\"toggle()\"\n >\n <hu-icon name=\"calendar\" [size]=\"16\" />\n </button>\n</div>\n\n<div\n #panel\n popover=\"manual\"\n class=\"hu-date-picker__panel\"\n role=\"dialog\"\n aria-label=\"Tarih se\u00E7\"\n [id]=\"panelId\"\n [class.hu-date-picker__panel--inline]=\"!supportsPopover\"\n [attr.hidden]=\"!supportsPopover && !open() ? '' : null\"\n (keydown)=\"onPanelKeydown($event)\"\n>\n @if (open()) {\n <hu-calendar\n [mode]=\"mode()\"\n [value]=\"singleValue()\"\n [range]=\"draftRange()\"\n [min]=\"min()\"\n [max]=\"max()\"\n [dateFilter]=\"dateFilter()\"\n [markers]=\"markers()\"\n (dateSelected)=\"onCalendarDate($event)\"\n (rangeChange)=\"onCalendarRange($event)\"\n />\n <div class=\"hu-date-picker__footer\">\n @if (mode() === 'range') {\n <span class=\"hu-date-picker__hint\">\n {{ draftRange()?.start && !draftRange()?.end ? 'Biti\u015F tarihini se\u00E7in' : 'Ba\u015Flang\u0131\u00E7 tarihini se\u00E7in' }}\n </span>\n } @else {\n <button hu-button variant=\"ghost\" size=\"sm\" type=\"button\" (click)=\"selectToday()\">Bug\u00FCn</button>\n }\n <button hu-button variant=\"ghost\" size=\"sm\" type=\"button\" (click)=\"clear()\">Temizle</button>\n </div>\n }\n</div>\n", styles: [".hu-date-picker{position:relative;display:block;width:100%}.hu-date-picker__control{position:relative;display:flex;align-items:center}.hu-date-picker__input{padding-right:2.5rem;font-variant-numeric:tabular-nums}.hu-date-picker__toggle{position:absolute;right:var(--hu-space-1);display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;color:var(--hu-text-subtle);background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer}.hu-date-picker__toggle:hover:not(:disabled){color:var(--hu-text);background:var(--hu-surface-3)}.hu-date-picker__toggle:disabled{cursor:not-allowed}.hu-date-picker--open .hu-date-picker__toggle{color:var(--hu-primary)}.hu-date-picker__panel{position:fixed;inset:auto;margin:0;padding:var(--hu-space-3);color:var(--hu-text);background:var(--hu-surface);border:1px solid var(--hu-border);border-radius:var(--hu-radius-lg);box-shadow:var(--hu-shadow-lg)}.hu-date-picker__panel:popover-open{animation:hu-date-picker-in .12s ease-out}.hu-date-picker__panel--inline{position:absolute;top:calc(100% + 6px);left:0;z-index:1000}.hu-date-picker__panel--inline[hidden]{display:none}.hu-date-picker__footer{display:flex;align-items:center;justify-content:space-between;gap:var(--hu-space-2);margin-top:var(--hu-space-2);padding-top:var(--hu-space-2);border-top:1px solid var(--hu-border)}.hu-date-picker__hint{font-size:var(--hu-text-xs);color:var(--hu-text-muted)}@keyframes hu-date-picker-in{0%{opacity:0;transform:translateY(-4px)}}\n"] }]
|
|
1433
|
+
}], ctorParameters: () => [] });
|
|
1434
|
+
|
|
1435
|
+
const HU_STATUS_ICONS = {
|
|
1436
|
+
info: 'info',
|
|
1437
|
+
success: 'check-circle',
|
|
1438
|
+
warning: 'alert-triangle',
|
|
1439
|
+
danger: 'alert-circle',
|
|
1440
|
+
};
|
|
1441
|
+
/**
|
|
1442
|
+
* Sayfa içi bilgi / uyarı mesajı.
|
|
1443
|
+
* @example <hu-alert variant="warning" title="Dikkat">Dönem kayıtları 5 gün içinde kapanacak.</hu-alert>
|
|
1444
|
+
*/
|
|
1445
|
+
class HuAlert {
|
|
1446
|
+
variant = input('info');
|
|
1447
|
+
title = input();
|
|
1448
|
+
dismissible = input(false, { transform: booleanAttribute });
|
|
1449
|
+
dismissed = signal(false);
|
|
1450
|
+
closed = output();
|
|
1451
|
+
icon = computed(() => HU_STATUS_ICONS[this.variant()]);
|
|
1452
|
+
dismiss() {
|
|
1453
|
+
this.dismissed.set(true);
|
|
1454
|
+
this.closed.emit();
|
|
1455
|
+
}
|
|
1456
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuAlert, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1457
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuAlert, isStandalone: true, selector: "hu-alert", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed" }, host: { properties: { "attr.data-variant": "variant()", "attr.role": "variant() === \"danger\" || variant() === \"warning\" ? \"alert\" : \"status\"", "attr.hidden": "dismissed() ? \"\" : null" }, classAttribute: "hu-alert" }, ngImport: i0, template: `
|
|
1458
|
+
<hu-icon class="hu-alert__icon" [name]="icon()" [size]="18" />
|
|
1459
|
+
<div class="hu-alert__content">
|
|
1460
|
+
@if (title()) {
|
|
1461
|
+
<p class="hu-alert__title">{{ title() }}</p>
|
|
1462
|
+
}
|
|
1463
|
+
<div class="hu-alert__body"><ng-content /></div>
|
|
1464
|
+
</div>
|
|
1465
|
+
@if (dismissible()) {
|
|
1466
|
+
<button type="button" class="hu-alert__close" aria-label="Kapat" (click)="dismiss()">
|
|
1467
|
+
<hu-icon name="x" [size]="16" />
|
|
1468
|
+
</button>
|
|
1469
|
+
}
|
|
1470
|
+
`, isInline: true, styles: [".hu-alert{display:flex;align-items:flex-start;gap:var(--hu-space-3);padding:var(--hu-space-3) var(--hu-space-4);font-size:var(--hu-text-sm);color:var(--_fg);background:var(--_bg);border:1px solid color-mix(in srgb,var(--_accent) 25%,transparent);border-radius:var(--hu-radius-lg)}.hu-alert[hidden]{display:none}.hu-alert[data-variant=info]{--_bg: var(--hu-info-soft);--_fg: var(--hu-info-fg);--_accent: var(--hu-info)}.hu-alert[data-variant=success]{--_bg: var(--hu-success-soft);--_fg: var(--hu-success-fg);--_accent: var(--hu-success)}.hu-alert[data-variant=warning]{--_bg: var(--hu-warning-soft);--_fg: var(--hu-warning-fg);--_accent: var(--hu-warning)}.hu-alert[data-variant=danger]{--_bg: var(--hu-danger-soft);--_fg: var(--hu-danger-fg);--_accent: var(--hu-danger)}.hu-alert__icon{margin-top:1px;color:var(--_accent)}.hu-alert__content{flex:1;min-width:0}.hu-alert__title{margin-bottom:2px;font-weight:600}.hu-alert__close{display:inline-flex;margin:-2px -6px 0 0;padding:4px;color:inherit;background:none;border:0;border-radius:var(--hu-radius-sm);opacity:.7;cursor:pointer}.hu-alert__close:hover{opacity:1;background:color-mix(in srgb,var(--_accent) 12%,transparent)}\n"], dependencies: [{ kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1471
|
+
}
|
|
1472
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuAlert, decorators: [{
|
|
1473
|
+
type: Component,
|
|
1474
|
+
args: [{ selector: 'hu-alert', imports: [HuIcon], template: `
|
|
1475
|
+
<hu-icon class="hu-alert__icon" [name]="icon()" [size]="18" />
|
|
1476
|
+
<div class="hu-alert__content">
|
|
1477
|
+
@if (title()) {
|
|
1478
|
+
<p class="hu-alert__title">{{ title() }}</p>
|
|
1479
|
+
}
|
|
1480
|
+
<div class="hu-alert__body"><ng-content /></div>
|
|
1481
|
+
</div>
|
|
1482
|
+
@if (dismissible()) {
|
|
1483
|
+
<button type="button" class="hu-alert__close" aria-label="Kapat" (click)="dismiss()">
|
|
1484
|
+
<hu-icon name="x" [size]="16" />
|
|
1485
|
+
</button>
|
|
1486
|
+
}
|
|
1487
|
+
`, host: {
|
|
1488
|
+
class: 'hu-alert',
|
|
1489
|
+
'[attr.data-variant]': 'variant()',
|
|
1490
|
+
'[attr.role]': 'variant() === "danger" || variant() === "warning" ? "alert" : "status"',
|
|
1491
|
+
'[attr.hidden]': 'dismissed() ? "" : null',
|
|
1492
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-alert{display:flex;align-items:flex-start;gap:var(--hu-space-3);padding:var(--hu-space-3) var(--hu-space-4);font-size:var(--hu-text-sm);color:var(--_fg);background:var(--_bg);border:1px solid color-mix(in srgb,var(--_accent) 25%,transparent);border-radius:var(--hu-radius-lg)}.hu-alert[hidden]{display:none}.hu-alert[data-variant=info]{--_bg: var(--hu-info-soft);--_fg: var(--hu-info-fg);--_accent: var(--hu-info)}.hu-alert[data-variant=success]{--_bg: var(--hu-success-soft);--_fg: var(--hu-success-fg);--_accent: var(--hu-success)}.hu-alert[data-variant=warning]{--_bg: var(--hu-warning-soft);--_fg: var(--hu-warning-fg);--_accent: var(--hu-warning)}.hu-alert[data-variant=danger]{--_bg: var(--hu-danger-soft);--_fg: var(--hu-danger-fg);--_accent: var(--hu-danger)}.hu-alert__icon{margin-top:1px;color:var(--_accent)}.hu-alert__content{flex:1;min-width:0}.hu-alert__title{margin-bottom:2px;font-weight:600}.hu-alert__close{display:inline-flex;margin:-2px -6px 0 0;padding:4px;color:inherit;background:none;border:0;border-radius:var(--hu-radius-sm);opacity:.7;cursor:pointer}.hu-alert__close:hover{opacity:1;background:color-mix(in srgb,var(--_accent) 12%,transparent)}\n"] }]
|
|
1493
|
+
}] });
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Durum etiketi.
|
|
1497
|
+
* @example <hu-badge variant="success" dot>Aktif</hu-badge>
|
|
1498
|
+
*/
|
|
1499
|
+
class HuBadge {
|
|
1500
|
+
variant = input('neutral');
|
|
1501
|
+
dot = input(false, { transform: booleanAttribute });
|
|
1502
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuBadge, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1503
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuBadge, isStandalone: true, selector: "hu-badge", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, dot: { classPropertyName: "dot", publicName: "dot", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-variant": "variant()" }, classAttribute: "hu-badge" }, ngImport: i0, template: `
|
|
1504
|
+
@if (dot()) {
|
|
1505
|
+
<span class="hu-badge__dot" aria-hidden="true"></span>
|
|
1506
|
+
}
|
|
1507
|
+
<ng-content />
|
|
1508
|
+
`, isInline: true, styles: [".hu-badge{--_bg: var(--hu-surface-3);--_fg: var(--hu-text-muted);--_dot: var(--hu-text-subtle);display:inline-flex;align-items:center;gap:.375rem;height:1.375rem;padding:0 .5rem;font-size:var(--hu-text-xs);font-weight:500;line-height:1;white-space:nowrap;color:var(--_fg);background:var(--_bg);border-radius:var(--hu-radius-full)}.hu-badge[data-variant=primary]{--_bg: var(--hu-primary-soft);--_fg: var(--hu-primary-soft-fg);--_dot: var(--hu-primary)}.hu-badge[data-variant=info]{--_bg: var(--hu-info-soft);--_fg: var(--hu-info-fg);--_dot: var(--hu-info)}.hu-badge[data-variant=success]{--_bg: var(--hu-success-soft);--_fg: var(--hu-success-fg);--_dot: var(--hu-success)}.hu-badge[data-variant=warning]{--_bg: var(--hu-warning-soft);--_fg: var(--hu-warning-fg);--_dot: var(--hu-warning)}.hu-badge[data-variant=danger]{--_bg: var(--hu-danger-soft);--_fg: var(--hu-danger-fg);--_dot: var(--hu-danger)}.hu-badge__dot{width:6px;height:6px;background:var(--_dot);border-radius:50%}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1509
|
+
}
|
|
1510
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuBadge, decorators: [{
|
|
1511
|
+
type: Component,
|
|
1512
|
+
args: [{ selector: 'hu-badge', template: `
|
|
1513
|
+
@if (dot()) {
|
|
1514
|
+
<span class="hu-badge__dot" aria-hidden="true"></span>
|
|
1515
|
+
}
|
|
1516
|
+
<ng-content />
|
|
1517
|
+
`, host: { class: 'hu-badge', '[attr.data-variant]': 'variant()' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-badge{--_bg: var(--hu-surface-3);--_fg: var(--hu-text-muted);--_dot: var(--hu-text-subtle);display:inline-flex;align-items:center;gap:.375rem;height:1.375rem;padding:0 .5rem;font-size:var(--hu-text-xs);font-weight:500;line-height:1;white-space:nowrap;color:var(--_fg);background:var(--_bg);border-radius:var(--hu-radius-full)}.hu-badge[data-variant=primary]{--_bg: var(--hu-primary-soft);--_fg: var(--hu-primary-soft-fg);--_dot: var(--hu-primary)}.hu-badge[data-variant=info]{--_bg: var(--hu-info-soft);--_fg: var(--hu-info-fg);--_dot: var(--hu-info)}.hu-badge[data-variant=success]{--_bg: var(--hu-success-soft);--_fg: var(--hu-success-fg);--_dot: var(--hu-success)}.hu-badge[data-variant=warning]{--_bg: var(--hu-warning-soft);--_fg: var(--hu-warning-fg);--_dot: var(--hu-warning)}.hu-badge[data-variant=danger]{--_bg: var(--hu-danger-soft);--_fg: var(--hu-danger-fg);--_dot: var(--hu-danger)}.hu-badge__dot{width:6px;height:6px;background:var(--_dot);border-radius:50%}\n"] }]
|
|
1518
|
+
}] });
|
|
1519
|
+
|
|
1520
|
+
/**
|
|
1521
|
+
* Kullanıcı avatarı. Görsel yoksa veya yüklenemezse baş harfleri gösterir.
|
|
1522
|
+
* @example <hu-avatar name="Ayşe Yılmaz" /> <hu-avatar name="Ali Can" [src]="user.photo" size="lg" />
|
|
1523
|
+
*/
|
|
1524
|
+
class HuAvatar {
|
|
1525
|
+
name = input('');
|
|
1526
|
+
src = input();
|
|
1527
|
+
size = input('md');
|
|
1528
|
+
failed = signal(false);
|
|
1529
|
+
initials = computed(() => {
|
|
1530
|
+
const parts = this.name().trim().split(/\s+/).filter(Boolean);
|
|
1531
|
+
if (!parts.length)
|
|
1532
|
+
return '?';
|
|
1533
|
+
const first = parts[0][0];
|
|
1534
|
+
const last = parts.length > 1 ? parts[parts.length - 1][0] : '';
|
|
1535
|
+
return (first + last).toLocaleUpperCase('tr-TR');
|
|
1536
|
+
});
|
|
1537
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuAvatar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1538
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuAvatar, isStandalone: true, selector: "hu-avatar", inputs: { name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "img" }, properties: { "attr.aria-label": "name()", "attr.data-size": "size()" }, classAttribute: "hu-avatar" }, ngImport: i0, template: `
|
|
1539
|
+
@if (src() && !failed()) {
|
|
1540
|
+
<img class="hu-avatar__img" [src]="src()" [alt]="name()" (error)="failed.set(true)" />
|
|
1541
|
+
} @else {
|
|
1542
|
+
<span aria-hidden="true">{{ initials() }}</span>
|
|
1543
|
+
}
|
|
1544
|
+
`, isInline: true, styles: [".hu-avatar{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:2rem;overflow:hidden;font-size:.75rem;font-weight:600;color:var(--hu-primary-soft-fg);background:var(--hu-primary-soft);border-radius:50%;-webkit-user-select:none;user-select:none}.hu-avatar[data-size=sm]{width:1.5rem;height:1.5rem;font-size:.625rem}.hu-avatar[data-size=lg]{width:2.75rem;height:2.75rem;font-size:.9375rem}.hu-avatar__img{width:100%;height:100%;object-fit:cover}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1545
|
+
}
|
|
1546
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuAvatar, decorators: [{
|
|
1547
|
+
type: Component,
|
|
1548
|
+
args: [{ selector: 'hu-avatar', template: `
|
|
1549
|
+
@if (src() && !failed()) {
|
|
1550
|
+
<img class="hu-avatar__img" [src]="src()" [alt]="name()" (error)="failed.set(true)" />
|
|
1551
|
+
} @else {
|
|
1552
|
+
<span aria-hidden="true">{{ initials() }}</span>
|
|
1553
|
+
}
|
|
1554
|
+
`, host: {
|
|
1555
|
+
class: 'hu-avatar',
|
|
1556
|
+
role: 'img',
|
|
1557
|
+
'[attr.aria-label]': 'name()',
|
|
1558
|
+
'[attr.data-size]': 'size()',
|
|
1559
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-avatar{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2rem;height:2rem;overflow:hidden;font-size:.75rem;font-weight:600;color:var(--hu-primary-soft-fg);background:var(--hu-primary-soft);border-radius:50%;-webkit-user-select:none;user-select:none}.hu-avatar[data-size=sm]{width:1.5rem;height:1.5rem;font-size:.625rem}.hu-avatar[data-size=lg]{width:2.75rem;height:2.75rem;font-size:.9375rem}.hu-avatar__img{width:100%;height:100%;object-fit:cover}\n"] }]
|
|
1560
|
+
}] });
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* Geçici bildirimler. Uygulamada bir kez `<hu-toaster />` yerleştirilmelidir.
|
|
1564
|
+
* @example inject(HuToastService).success('Kayıt güncellendi.');
|
|
1565
|
+
*/
|
|
1566
|
+
class HuToastService {
|
|
1567
|
+
nextId = 1;
|
|
1568
|
+
timers = new Map();
|
|
1569
|
+
_toasts = signal([]);
|
|
1570
|
+
toasts = this._toasts.asReadonly();
|
|
1571
|
+
show(options) {
|
|
1572
|
+
const toast = { id: this.nextId++, variant: 'info', duration: 5000, ...options };
|
|
1573
|
+
this._toasts.update((list) => [...list, toast].slice(-5));
|
|
1574
|
+
if (toast.duration > 0) {
|
|
1575
|
+
this.timers.set(toast.id, setTimeout(() => this.dismiss(toast.id), toast.duration));
|
|
1576
|
+
}
|
|
1577
|
+
return toast.id;
|
|
1578
|
+
}
|
|
1579
|
+
info(message, title) {
|
|
1580
|
+
return this.show({ message, title, variant: 'info' });
|
|
1581
|
+
}
|
|
1582
|
+
success(message, title) {
|
|
1583
|
+
return this.show({ message, title, variant: 'success' });
|
|
1584
|
+
}
|
|
1585
|
+
warning(message, title) {
|
|
1586
|
+
return this.show({ message, title, variant: 'warning' });
|
|
1587
|
+
}
|
|
1588
|
+
error(message, title) {
|
|
1589
|
+
return this.show({ message, title, variant: 'danger', duration: 8000 });
|
|
1590
|
+
}
|
|
1591
|
+
dismiss(id) {
|
|
1592
|
+
clearTimeout(this.timers.get(id));
|
|
1593
|
+
this.timers.delete(id);
|
|
1594
|
+
this._toasts.update((list) => list.filter((t) => t.id !== id));
|
|
1595
|
+
}
|
|
1596
|
+
clear() {
|
|
1597
|
+
this.timers.forEach((t) => clearTimeout(t));
|
|
1598
|
+
this.timers.clear();
|
|
1599
|
+
this._toasts.set([]);
|
|
1600
|
+
}
|
|
1601
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1602
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuToastService, providedIn: 'root' });
|
|
1603
|
+
}
|
|
1604
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuToastService, decorators: [{
|
|
1605
|
+
type: Injectable,
|
|
1606
|
+
args: [{ providedIn: 'root' }]
|
|
1607
|
+
}] });
|
|
1608
|
+
|
|
1609
|
+
/** Toast'ların gösterildiği alan. Kök componentte bir kez kullanın: `<hu-toaster />` */
|
|
1610
|
+
class HuToaster {
|
|
1611
|
+
service = inject(HuToastService);
|
|
1612
|
+
icons = HU_STATUS_ICONS;
|
|
1613
|
+
position = input('top-right');
|
|
1614
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuToaster, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1615
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuToaster, isStandalone: true, selector: "hu-toaster", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "aria-live": "polite", "role": "region", "aria-label": "Bildirimler" }, properties: { "attr.data-position": "position()" }, classAttribute: "hu-toaster" }, ngImport: i0, template: `
|
|
1616
|
+
@for (toast of service.toasts(); track toast.id) {
|
|
1617
|
+
<div class="hu-toast" [attr.data-variant]="toast.variant" [attr.role]="toast.variant === 'danger' ? 'alert' : 'status'">
|
|
1618
|
+
<hu-icon class="hu-toast__icon" [name]="icons[toast.variant]" [size]="18" />
|
|
1619
|
+
<div class="hu-toast__content">
|
|
1620
|
+
@if (toast.title) {
|
|
1621
|
+
<p class="hu-toast__title">{{ toast.title }}</p>
|
|
1622
|
+
}
|
|
1623
|
+
<p class="hu-toast__message">{{ toast.message }}</p>
|
|
1624
|
+
</div>
|
|
1625
|
+
<button type="button" class="hu-toast__close" aria-label="Bildirimi kapat" (click)="service.dismiss(toast.id)">
|
|
1626
|
+
<hu-icon name="x" [size]="16" />
|
|
1627
|
+
</button>
|
|
1628
|
+
</div>
|
|
1629
|
+
}
|
|
1630
|
+
`, isInline: true, styles: [".hu-toaster{position:fixed;z-index:1100;display:flex;flex-direction:column;gap:var(--hu-space-2);width:min(380px,calc(100vw - 2rem));pointer-events:none}.hu-toaster[data-position^=top]{top:var(--hu-space-4)}.hu-toaster[data-position^=bottom]{bottom:var(--hu-space-4);flex-direction:column-reverse}.hu-toaster[data-position$=right]{right:var(--hu-space-4)}.hu-toaster[data-position$=center]{left:50%;transform:translate(-50%)}.hu-toast{display:flex;align-items:flex-start;gap:var(--hu-space-3);padding:var(--hu-space-3) var(--hu-space-4);background:var(--hu-surface);border:1px solid var(--hu-border);border-left:3px solid var(--_accent);border-radius:var(--hu-radius-lg);box-shadow:var(--hu-shadow-lg);pointer-events:auto;animation:hu-toast-in .2s cubic-bezier(.2,.9,.3,1.2)}.hu-toast[data-variant=info]{--_accent: var(--hu-info)}.hu-toast[data-variant=success]{--_accent: var(--hu-success)}.hu-toast[data-variant=warning]{--_accent: var(--hu-warning)}.hu-toast[data-variant=danger]{--_accent: var(--hu-danger)}.hu-toast__icon{margin-top:1px;color:var(--_accent)}.hu-toast__content{flex:1;min-width:0}.hu-toast__title{font-weight:600}.hu-toast__message{color:var(--hu-text-muted)}.hu-toast__close{display:inline-flex;margin:-2px -6px 0 0;padding:4px;color:var(--hu-text-subtle);background:none;border:0;border-radius:var(--hu-radius-sm);cursor:pointer}.hu-toast__close:hover{color:var(--hu-text);background:var(--hu-surface-3)}@keyframes hu-toast-in{0%{opacity:0;transform:translateY(-8px) scale(.98)}}\n"], dependencies: [{ kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1631
|
+
}
|
|
1632
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuToaster, decorators: [{
|
|
1633
|
+
type: Component,
|
|
1634
|
+
args: [{ selector: 'hu-toaster', imports: [HuIcon], template: `
|
|
1635
|
+
@for (toast of service.toasts(); track toast.id) {
|
|
1636
|
+
<div class="hu-toast" [attr.data-variant]="toast.variant" [attr.role]="toast.variant === 'danger' ? 'alert' : 'status'">
|
|
1637
|
+
<hu-icon class="hu-toast__icon" [name]="icons[toast.variant]" [size]="18" />
|
|
1638
|
+
<div class="hu-toast__content">
|
|
1639
|
+
@if (toast.title) {
|
|
1640
|
+
<p class="hu-toast__title">{{ toast.title }}</p>
|
|
1641
|
+
}
|
|
1642
|
+
<p class="hu-toast__message">{{ toast.message }}</p>
|
|
1643
|
+
</div>
|
|
1644
|
+
<button type="button" class="hu-toast__close" aria-label="Bildirimi kapat" (click)="service.dismiss(toast.id)">
|
|
1645
|
+
<hu-icon name="x" [size]="16" />
|
|
1646
|
+
</button>
|
|
1647
|
+
</div>
|
|
1648
|
+
}
|
|
1649
|
+
`, host: {
|
|
1650
|
+
class: 'hu-toaster',
|
|
1651
|
+
'[attr.data-position]': 'position()',
|
|
1652
|
+
'aria-live': 'polite',
|
|
1653
|
+
role: 'region',
|
|
1654
|
+
'aria-label': 'Bildirimler',
|
|
1655
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-toaster{position:fixed;z-index:1100;display:flex;flex-direction:column;gap:var(--hu-space-2);width:min(380px,calc(100vw - 2rem));pointer-events:none}.hu-toaster[data-position^=top]{top:var(--hu-space-4)}.hu-toaster[data-position^=bottom]{bottom:var(--hu-space-4);flex-direction:column-reverse}.hu-toaster[data-position$=right]{right:var(--hu-space-4)}.hu-toaster[data-position$=center]{left:50%;transform:translate(-50%)}.hu-toast{display:flex;align-items:flex-start;gap:var(--hu-space-3);padding:var(--hu-space-3) var(--hu-space-4);background:var(--hu-surface);border:1px solid var(--hu-border);border-left:3px solid var(--_accent);border-radius:var(--hu-radius-lg);box-shadow:var(--hu-shadow-lg);pointer-events:auto;animation:hu-toast-in .2s cubic-bezier(.2,.9,.3,1.2)}.hu-toast[data-variant=info]{--_accent: var(--hu-info)}.hu-toast[data-variant=success]{--_accent: var(--hu-success)}.hu-toast[data-variant=warning]{--_accent: var(--hu-warning)}.hu-toast[data-variant=danger]{--_accent: var(--hu-danger)}.hu-toast__icon{margin-top:1px;color:var(--_accent)}.hu-toast__content{flex:1;min-width:0}.hu-toast__title{font-weight:600}.hu-toast__message{color:var(--hu-text-muted)}.hu-toast__close{display:inline-flex;margin:-2px -6px 0 0;padding:4px;color:var(--hu-text-subtle);background:none;border:0;border-radius:var(--hu-radius-sm);cursor:pointer}.hu-toast__close:hover{color:var(--hu-text);background:var(--hu-surface-3)}@keyframes hu-toast-in{0%{opacity:0;transform:translateY(-8px) scale(.98)}}\n"] }]
|
|
1656
|
+
}] });
|
|
1657
|
+
|
|
1658
|
+
/** Dialog alt kısmındaki aksiyon alanı. */
|
|
1659
|
+
class HuDialogFooter {
|
|
1660
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuDialogFooter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1661
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuDialogFooter, isStandalone: true, selector: "[huDialogFooter]", host: { classAttribute: "hu-dialog__footer" }, ngImport: i0 });
|
|
1662
|
+
}
|
|
1663
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuDialogFooter, decorators: [{
|
|
1664
|
+
type: Directive,
|
|
1665
|
+
args: [{ selector: '[huDialogFooter]', host: { class: 'hu-dialog__footer' } }]
|
|
1666
|
+
}] });
|
|
1667
|
+
/**
|
|
1668
|
+
* Modal pencere. Native `<dialog>` elementini kullanır; odak hapsi, Esc ile
|
|
1669
|
+
* kapanma ve üst katman (top layer) tarayıcıdan gelir.
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* <hu-dialog [(open)]="editOpen" title="Kullanıcıyı düzenle">
|
|
1673
|
+
* ...form...
|
|
1674
|
+
* <div huDialogFooter>
|
|
1675
|
+
* <button hu-button variant="outline" (click)="editOpen.set(false)">Vazgeç</button>
|
|
1676
|
+
* <button hu-button (click)="save()">Kaydet</button>
|
|
1677
|
+
* </div>
|
|
1678
|
+
* </hu-dialog>
|
|
1679
|
+
*/
|
|
1680
|
+
class HuDialog {
|
|
1681
|
+
open = model(false);
|
|
1682
|
+
title = input('');
|
|
1683
|
+
description = input();
|
|
1684
|
+
size = input('md');
|
|
1685
|
+
closeOnBackdrop = input(true, { transform: booleanAttribute });
|
|
1686
|
+
closeOnEsc = input(true, { transform: booleanAttribute });
|
|
1687
|
+
closed = output();
|
|
1688
|
+
titleId = huUniqueId('hu-dialog-title');
|
|
1689
|
+
pointerDownOnBackdrop = false;
|
|
1690
|
+
dialogRef = viewChild.required('dialog');
|
|
1691
|
+
constructor() {
|
|
1692
|
+
effect(() => {
|
|
1693
|
+
const el = this.dialogRef().nativeElement;
|
|
1694
|
+
if (this.open() && !el.open)
|
|
1695
|
+
el.showModal();
|
|
1696
|
+
else if (!this.open() && el.open)
|
|
1697
|
+
el.close();
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
close() {
|
|
1701
|
+
this.open.set(false);
|
|
1702
|
+
}
|
|
1703
|
+
onNativeClose() {
|
|
1704
|
+
if (this.open())
|
|
1705
|
+
this.open.set(false);
|
|
1706
|
+
this.closed.emit();
|
|
1707
|
+
}
|
|
1708
|
+
onCancel(event) {
|
|
1709
|
+
if (!this.closeOnEsc())
|
|
1710
|
+
event.preventDefault();
|
|
1711
|
+
}
|
|
1712
|
+
onClick(event) {
|
|
1713
|
+
// Yalnızca basma ve bırakma ikisi de backdrop üzerindeyse kapat (metin seçerken kapanmasın).
|
|
1714
|
+
if (this.closeOnBackdrop() && this.pointerDownOnBackdrop && event.target === this.dialogRef().nativeElement) {
|
|
1715
|
+
this.close();
|
|
1716
|
+
}
|
|
1717
|
+
this.pointerDownOnBackdrop = false;
|
|
1718
|
+
}
|
|
1719
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1720
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuDialog, isStandalone: true, selector: "hu-dialog", inputs: { open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, closeOnBackdrop: { classPropertyName: "closeOnBackdrop", publicName: "closeOnBackdrop", isSignal: true, isRequired: false, transformFunction: null }, closeOnEsc: { classPropertyName: "closeOnEsc", publicName: "closeOnEsc", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { open: "openChange", closed: "closed" }, host: { classAttribute: "hu-dialog-host" }, viewQueries: [{ propertyName: "dialogRef", first: true, predicate: ["dialog"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1721
|
+
<dialog
|
|
1722
|
+
#dialog
|
|
1723
|
+
class="hu-dialog"
|
|
1724
|
+
[attr.data-size]="size()"
|
|
1725
|
+
[attr.aria-labelledby]="titleId"
|
|
1726
|
+
(close)="onNativeClose()"
|
|
1727
|
+
(cancel)="onCancel($event)"
|
|
1728
|
+
(mousedown)="pointerDownOnBackdrop = $event.target === dialog"
|
|
1729
|
+
(click)="onClick($event)"
|
|
1730
|
+
>
|
|
1731
|
+
<div class="hu-dialog__panel">
|
|
1732
|
+
<header class="hu-dialog__header">
|
|
1733
|
+
<div>
|
|
1734
|
+
<h2 class="hu-dialog__title" [id]="titleId">{{ title() }}</h2>
|
|
1735
|
+
@if (description()) {
|
|
1736
|
+
<p class="hu-dialog__description">{{ description() }}</p>
|
|
1737
|
+
}
|
|
1738
|
+
</div>
|
|
1739
|
+
<button type="button" class="hu-dialog__close" aria-label="Kapat" (click)="close()">
|
|
1740
|
+
<hu-icon name="x" [size]="18" />
|
|
1741
|
+
</button>
|
|
1742
|
+
</header>
|
|
1743
|
+
<div class="hu-dialog__body"><ng-content /></div>
|
|
1744
|
+
<ng-content select="[huDialogFooter]" />
|
|
1745
|
+
</div>
|
|
1746
|
+
</dialog>
|
|
1747
|
+
`, isInline: true, styles: [".hu-dialog-host{display:contents}html:has(.hu-dialog[open]){overflow:hidden}.hu-dialog{width:calc(100vw - 2rem);max-width:32rem;max-height:calc(100dvh - 4rem);padding:0;color:var(--hu-text);background:var(--hu-surface);border:1px solid var(--hu-border);border-radius:var(--hu-radius-xl);box-shadow:var(--hu-shadow-lg)}.hu-dialog[data-size=sm]{max-width:24rem}.hu-dialog[data-size=lg]{max-width:44rem}.hu-dialog[data-size=xl]{max-width:60rem}.hu-dialog::backdrop{background:#0c0c0e80;backdrop-filter:blur(2px)}.hu-dialog[open]{animation:hu-dialog-in .18s cubic-bezier(.2,.9,.3,1)}.hu-dialog[open]::backdrop{animation:hu-fade-in .18s ease-out}.hu-dialog__panel{display:flex;flex-direction:column;max-height:inherit}.hu-dialog__header{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--hu-space-4);padding:var(--hu-space-5) var(--hu-space-6) var(--hu-space-3)}.hu-dialog__title{font-size:var(--hu-text-lg)}.hu-dialog__description{margin-top:var(--hu-space-1);color:var(--hu-text-muted)}.hu-dialog__close{display:inline-flex;margin:-4px -8px 0 0;padding:6px;color:var(--hu-text-subtle);background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer}.hu-dialog__close:hover{color:var(--hu-text);background:var(--hu-surface-3)}.hu-dialog__body{flex:1;padding:var(--hu-space-2) var(--hu-space-6) var(--hu-space-5);overflow-y:auto}.hu-dialog__footer{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hu-space-2);padding:var(--hu-space-4) var(--hu-space-6);background:var(--hu-surface-2);border-top:1px solid var(--hu-border);border-radius:0 0 var(--hu-radius-xl) var(--hu-radius-xl)}@keyframes hu-dialog-in{0%{opacity:0;transform:translateY(8px) scale(.98)}}@keyframes hu-fade-in{0%{opacity:0}}\n"], dependencies: [{ kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1748
|
+
}
|
|
1749
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuDialog, decorators: [{
|
|
1750
|
+
type: Component,
|
|
1751
|
+
args: [{ selector: 'hu-dialog', imports: [HuIcon], template: `
|
|
1752
|
+
<dialog
|
|
1753
|
+
#dialog
|
|
1754
|
+
class="hu-dialog"
|
|
1755
|
+
[attr.data-size]="size()"
|
|
1756
|
+
[attr.aria-labelledby]="titleId"
|
|
1757
|
+
(close)="onNativeClose()"
|
|
1758
|
+
(cancel)="onCancel($event)"
|
|
1759
|
+
(mousedown)="pointerDownOnBackdrop = $event.target === dialog"
|
|
1760
|
+
(click)="onClick($event)"
|
|
1761
|
+
>
|
|
1762
|
+
<div class="hu-dialog__panel">
|
|
1763
|
+
<header class="hu-dialog__header">
|
|
1764
|
+
<div>
|
|
1765
|
+
<h2 class="hu-dialog__title" [id]="titleId">{{ title() }}</h2>
|
|
1766
|
+
@if (description()) {
|
|
1767
|
+
<p class="hu-dialog__description">{{ description() }}</p>
|
|
1768
|
+
}
|
|
1769
|
+
</div>
|
|
1770
|
+
<button type="button" class="hu-dialog__close" aria-label="Kapat" (click)="close()">
|
|
1771
|
+
<hu-icon name="x" [size]="18" />
|
|
1772
|
+
</button>
|
|
1773
|
+
</header>
|
|
1774
|
+
<div class="hu-dialog__body"><ng-content /></div>
|
|
1775
|
+
<ng-content select="[huDialogFooter]" />
|
|
1776
|
+
</div>
|
|
1777
|
+
</dialog>
|
|
1778
|
+
`, host: { class: 'hu-dialog-host' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-dialog-host{display:contents}html:has(.hu-dialog[open]){overflow:hidden}.hu-dialog{width:calc(100vw - 2rem);max-width:32rem;max-height:calc(100dvh - 4rem);padding:0;color:var(--hu-text);background:var(--hu-surface);border:1px solid var(--hu-border);border-radius:var(--hu-radius-xl);box-shadow:var(--hu-shadow-lg)}.hu-dialog[data-size=sm]{max-width:24rem}.hu-dialog[data-size=lg]{max-width:44rem}.hu-dialog[data-size=xl]{max-width:60rem}.hu-dialog::backdrop{background:#0c0c0e80;backdrop-filter:blur(2px)}.hu-dialog[open]{animation:hu-dialog-in .18s cubic-bezier(.2,.9,.3,1)}.hu-dialog[open]::backdrop{animation:hu-fade-in .18s ease-out}.hu-dialog__panel{display:flex;flex-direction:column;max-height:inherit}.hu-dialog__header{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--hu-space-4);padding:var(--hu-space-5) var(--hu-space-6) var(--hu-space-3)}.hu-dialog__title{font-size:var(--hu-text-lg)}.hu-dialog__description{margin-top:var(--hu-space-1);color:var(--hu-text-muted)}.hu-dialog__close{display:inline-flex;margin:-4px -8px 0 0;padding:6px;color:var(--hu-text-subtle);background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer}.hu-dialog__close:hover{color:var(--hu-text);background:var(--hu-surface-3)}.hu-dialog__body{flex:1;padding:var(--hu-space-2) var(--hu-space-6) var(--hu-space-5);overflow-y:auto}.hu-dialog__footer{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hu-space-2);padding:var(--hu-space-4) var(--hu-space-6);background:var(--hu-surface-2);border-top:1px solid var(--hu-border);border-radius:0 0 var(--hu-radius-xl) var(--hu-radius-xl)}@keyframes hu-dialog-in{0%{opacity:0;transform:translateY(8px) scale(.98)}}@keyframes hu-fade-in{0%{opacity:0}}\n"] }]
|
|
1779
|
+
}], ctorParameters: () => [] });
|
|
1780
|
+
|
|
1781
|
+
/** Kart başlığının sağındaki aksiyonlar. */
|
|
1782
|
+
class HuCardActions {
|
|
1783
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCardActions, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1784
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuCardActions, isStandalone: true, selector: "[huCardActions]", host: { classAttribute: "hu-card__actions" }, ngImport: i0 });
|
|
1785
|
+
}
|
|
1786
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCardActions, decorators: [{
|
|
1787
|
+
type: Directive,
|
|
1788
|
+
args: [{ selector: '[huCardActions]', host: { class: 'hu-card__actions' } }]
|
|
1789
|
+
}] });
|
|
1790
|
+
/** Kart alt bilgisi. */
|
|
1791
|
+
class HuCardFooter {
|
|
1792
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCardFooter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1793
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuCardFooter, isStandalone: true, selector: "[huCardFooter]", host: { classAttribute: "hu-card__footer" }, ngImport: i0 });
|
|
1794
|
+
}
|
|
1795
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCardFooter, decorators: [{
|
|
1796
|
+
type: Directive,
|
|
1797
|
+
args: [{ selector: '[huCardFooter]', host: { class: 'hu-card__footer' } }]
|
|
1798
|
+
}] });
|
|
1799
|
+
/**
|
|
1800
|
+
* İçerik kartı.
|
|
1801
|
+
* @example
|
|
1802
|
+
* <hu-card title="Son başvurular" subtitle="Son 7 gün">
|
|
1803
|
+
* <button huCardActions hu-button variant="ghost" size="sm">Tümü</button>
|
|
1804
|
+
* ...
|
|
1805
|
+
* <div huCardFooter>...</div>
|
|
1806
|
+
* </hu-card>
|
|
1807
|
+
*/
|
|
1808
|
+
class HuCard {
|
|
1809
|
+
title = input();
|
|
1810
|
+
subtitle = input();
|
|
1811
|
+
padding = input('md');
|
|
1812
|
+
actions = contentChild(HuCardActions);
|
|
1813
|
+
hasHeader = computed(() => !!(this.title() || this.subtitle() || this.actions()));
|
|
1814
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCard, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1815
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuCard, isStandalone: true, selector: "hu-card", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, subtitle: { classPropertyName: "subtitle", publicName: "subtitle", isSignal: true, isRequired: false, transformFunction: null }, padding: { classPropertyName: "padding", publicName: "padding", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-padding": "padding()" }, classAttribute: "hu-card" }, queries: [{ propertyName: "actions", first: true, predicate: HuCardActions, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
1816
|
+
<div class="hu-card__header" [hidden]="!hasHeader()">
|
|
1817
|
+
<div class="hu-card__heading">
|
|
1818
|
+
@if (title()) {
|
|
1819
|
+
<h3 class="hu-card__title">{{ title() }}</h3>
|
|
1820
|
+
}
|
|
1821
|
+
@if (subtitle()) {
|
|
1822
|
+
<p class="hu-card__subtitle">{{ subtitle() }}</p>
|
|
1823
|
+
}
|
|
1824
|
+
</div>
|
|
1825
|
+
<ng-content select="[huCardActions]" />
|
|
1826
|
+
</div>
|
|
1827
|
+
<div class="hu-card__body">
|
|
1828
|
+
<ng-content />
|
|
1829
|
+
</div>
|
|
1830
|
+
<ng-content select="[huCardFooter]" />
|
|
1831
|
+
`, isInline: true, styles: [".hu-card{display:flex;flex-direction:column;min-width:0;background:var(--hu-surface);border:1px solid var(--hu-border);border-radius:var(--hu-radius-lg);box-shadow:var(--hu-shadow-sm)}.hu-card__header{display:flex;align-items:center;justify-content:space-between;gap:var(--hu-space-3);padding:var(--hu-space-4) var(--hu-space-5);border-bottom:1px solid var(--hu-border)}.hu-card__header[hidden]{display:none}.hu-card__heading{min-width:0}.hu-card__title{font-size:.9375rem;font-weight:600}.hu-card__subtitle{margin-top:2px;font-size:var(--hu-text-xs);color:var(--hu-text-muted)}.hu-card__actions{display:flex;align-items:center;gap:var(--hu-space-2);flex-shrink:0}.hu-card__body{flex:1;padding:var(--hu-space-5)}.hu-card[data-padding=sm] .hu-card__body{padding:var(--hu-space-3)}.hu-card[data-padding=none] .hu-card__body{padding:0}.hu-card__footer{display:flex;align-items:center;gap:var(--hu-space-2);padding:var(--hu-space-3) var(--hu-space-5);border-top:1px solid var(--hu-border)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1832
|
+
}
|
|
1833
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCard, decorators: [{
|
|
1834
|
+
type: Component,
|
|
1835
|
+
args: [{ selector: 'hu-card', template: `
|
|
1836
|
+
<div class="hu-card__header" [hidden]="!hasHeader()">
|
|
1837
|
+
<div class="hu-card__heading">
|
|
1838
|
+
@if (title()) {
|
|
1839
|
+
<h3 class="hu-card__title">{{ title() }}</h3>
|
|
1840
|
+
}
|
|
1841
|
+
@if (subtitle()) {
|
|
1842
|
+
<p class="hu-card__subtitle">{{ subtitle() }}</p>
|
|
1843
|
+
}
|
|
1844
|
+
</div>
|
|
1845
|
+
<ng-content select="[huCardActions]" />
|
|
1846
|
+
</div>
|
|
1847
|
+
<div class="hu-card__body">
|
|
1848
|
+
<ng-content />
|
|
1849
|
+
</div>
|
|
1850
|
+
<ng-content select="[huCardFooter]" />
|
|
1851
|
+
`, host: { class: 'hu-card', '[attr.data-padding]': 'padding()' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-card{display:flex;flex-direction:column;min-width:0;background:var(--hu-surface);border:1px solid var(--hu-border);border-radius:var(--hu-radius-lg);box-shadow:var(--hu-shadow-sm)}.hu-card__header{display:flex;align-items:center;justify-content:space-between;gap:var(--hu-space-3);padding:var(--hu-space-4) var(--hu-space-5);border-bottom:1px solid var(--hu-border)}.hu-card__header[hidden]{display:none}.hu-card__heading{min-width:0}.hu-card__title{font-size:.9375rem;font-weight:600}.hu-card__subtitle{margin-top:2px;font-size:var(--hu-text-xs);color:var(--hu-text-muted)}.hu-card__actions{display:flex;align-items:center;gap:var(--hu-space-2);flex-shrink:0}.hu-card__body{flex:1;padding:var(--hu-space-5)}.hu-card[data-padding=sm] .hu-card__body{padding:var(--hu-space-3)}.hu-card[data-padding=none] .hu-card__body{padding:0}.hu-card__footer{display:flex;align-items:center;gap:var(--hu-space-2);padding:var(--hu-space-3) var(--hu-space-5);border-top:1px solid var(--hu-border)}\n"] }]
|
|
1852
|
+
}] });
|
|
1853
|
+
|
|
1854
|
+
/**
|
|
1855
|
+
* Bir sütun için özel hücre şablonu. `huCellOf` ile tabloya verilen veriyi
|
|
1856
|
+
* bağlarsanız `let-row` değişkeni tip güvenli olur.
|
|
1857
|
+
* @example <ng-template huCell="status" [huCellOf]="users()" let-row><hu-badge>{{ row.status }}</hu-badge></ng-template>
|
|
1858
|
+
*/
|
|
1859
|
+
class HuCellDef {
|
|
1860
|
+
key = input.required({ alias: 'huCell' });
|
|
1861
|
+
/** Yalnızca tip çıkarımı içindir; çalışma zamanında kullanılmaz. */
|
|
1862
|
+
of = input(undefined, { alias: 'huCellOf' });
|
|
1863
|
+
template = inject(TemplateRef);
|
|
1864
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
1865
|
+
return true;
|
|
1866
|
+
}
|
|
1867
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCellDef, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1868
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.25", type: HuCellDef, isStandalone: true, selector: "ng-template[huCell]", inputs: { key: { classPropertyName: "key", publicName: "huCell", isSignal: true, isRequired: true, transformFunction: null }, of: { classPropertyName: "of", publicName: "huCellOf", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
|
|
1869
|
+
}
|
|
1870
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuCellDef, decorators: [{
|
|
1871
|
+
type: Directive,
|
|
1872
|
+
args: [{ selector: 'ng-template[huCell]' }]
|
|
1873
|
+
}] });
|
|
1874
|
+
const collator = new Intl.Collator('tr-TR', { numeric: true, sensitivity: 'base' });
|
|
1875
|
+
function compareValues(a, b) {
|
|
1876
|
+
if (a == null && b == null)
|
|
1877
|
+
return 0;
|
|
1878
|
+
if (a == null)
|
|
1879
|
+
return 1;
|
|
1880
|
+
if (b == null)
|
|
1881
|
+
return -1;
|
|
1882
|
+
if (typeof a === 'number' && typeof b === 'number')
|
|
1883
|
+
return a - b;
|
|
1884
|
+
if (a instanceof Date && b instanceof Date)
|
|
1885
|
+
return a.getTime() - b.getTime();
|
|
1886
|
+
return collator.compare(String(a), String(b));
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Veri tablosu: sıralama, özel hücre şablonları, yükleniyor ve boş durumları.
|
|
1890
|
+
* Sayfalama için `hu-paginator` ile birlikte kullanın.
|
|
1891
|
+
*
|
|
1892
|
+
* @example
|
|
1893
|
+
* <hu-table [data]="users()" [columns]="columns" [(sort)]="sort">
|
|
1894
|
+
* <ng-template huCell="status" let-user>
|
|
1895
|
+
* <hu-badge [variant]="user.active ? 'success' : 'neutral'">{{ user.active ? 'Aktif' : 'Pasif' }}</hu-badge>
|
|
1896
|
+
* </ng-template>
|
|
1897
|
+
* </hu-table>
|
|
1898
|
+
*/
|
|
1899
|
+
class HuTable {
|
|
1900
|
+
data = input([]);
|
|
1901
|
+
columns = input.required();
|
|
1902
|
+
loading = input(false, { transform: booleanAttribute });
|
|
1903
|
+
emptyText = input('Kayıt bulunamadı.');
|
|
1904
|
+
/** `client`: tablo kendisi sıralar. `server`: yalnızca `sort` değişir, veriyi siz getirirsiniz. */
|
|
1905
|
+
sortMode = input('client');
|
|
1906
|
+
sort = model({ key: '', direction: '' });
|
|
1907
|
+
trackBy = input((row) => row);
|
|
1908
|
+
striped = input(false, { transform: booleanAttribute });
|
|
1909
|
+
dense = input(false, { transform: booleanAttribute });
|
|
1910
|
+
stickyHeader = input(false, { transform: booleanAttribute });
|
|
1911
|
+
clickableRows = input(false, { transform: booleanAttribute });
|
|
1912
|
+
rowClick = output();
|
|
1913
|
+
cellDefs = contentChildren(HuCellDef);
|
|
1914
|
+
templates = computed(() => new Map(this.cellDefs().map((d) => [d.key(), d.template])));
|
|
1915
|
+
rows = computed(() => {
|
|
1916
|
+
const data = this.data();
|
|
1917
|
+
const { key, direction } = this.sort();
|
|
1918
|
+
if (this.sortMode() === 'server' || !key || !direction)
|
|
1919
|
+
return data;
|
|
1920
|
+
const column = this.columns().find((c) => c.key === key);
|
|
1921
|
+
if (!column)
|
|
1922
|
+
return data;
|
|
1923
|
+
const factor = direction === 'asc' ? 1 : -1;
|
|
1924
|
+
return [...data].sort((a, b) => compareValues(this.cellValue(a, column), this.cellValue(b, column)) * factor);
|
|
1925
|
+
});
|
|
1926
|
+
cellValue(row, column) {
|
|
1927
|
+
return column.value ? column.value(row) : row[column.key];
|
|
1928
|
+
}
|
|
1929
|
+
toggleSort(column) {
|
|
1930
|
+
const current = this.sort();
|
|
1931
|
+
if (current.key !== column.key || !current.direction) {
|
|
1932
|
+
this.sort.set({ key: column.key, direction: 'asc' });
|
|
1933
|
+
}
|
|
1934
|
+
else if (current.direction === 'asc') {
|
|
1935
|
+
this.sort.set({ key: column.key, direction: 'desc' });
|
|
1936
|
+
}
|
|
1937
|
+
else {
|
|
1938
|
+
this.sort.set({ key: '', direction: '' });
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
sortIcon(column) {
|
|
1942
|
+
const { key, direction } = this.sort();
|
|
1943
|
+
if (key !== column.key || !direction)
|
|
1944
|
+
return 'chevrons-up-down';
|
|
1945
|
+
return direction === 'asc' ? 'arrow-up' : 'arrow-down';
|
|
1946
|
+
}
|
|
1947
|
+
ariaSort(column) {
|
|
1948
|
+
if (!column.sortable)
|
|
1949
|
+
return null;
|
|
1950
|
+
const { key, direction } = this.sort();
|
|
1951
|
+
if (key !== column.key || !direction)
|
|
1952
|
+
return 'none';
|
|
1953
|
+
return direction === 'asc' ? 'ascending' : 'descending';
|
|
1954
|
+
}
|
|
1955
|
+
onRowClick(row) {
|
|
1956
|
+
if (this.clickableRows())
|
|
1957
|
+
this.rowClick.emit(row);
|
|
1958
|
+
}
|
|
1959
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTable, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1960
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuTable, isStandalone: true, selector: "hu-table", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: true, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", isSignal: true, isRequired: false, transformFunction: null }, sortMode: { classPropertyName: "sortMode", publicName: "sortMode", isSignal: true, isRequired: false, transformFunction: null }, sort: { classPropertyName: "sort", publicName: "sort", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null }, striped: { classPropertyName: "striped", publicName: "striped", isSignal: true, isRequired: false, transformFunction: null }, dense: { classPropertyName: "dense", publicName: "dense", isSignal: true, isRequired: false, transformFunction: null }, stickyHeader: { classPropertyName: "stickyHeader", publicName: "stickyHeader", isSignal: true, isRequired: false, transformFunction: null }, clickableRows: { classPropertyName: "clickableRows", publicName: "clickableRows", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sort: "sortChange", rowClick: "rowClick" }, host: { properties: { "class.hu-table--striped": "striped()", "class.hu-table--dense": "dense()", "class.hu-table--sticky": "stickyHeader()" }, classAttribute: "hu-table" }, queries: [{ propertyName: "cellDefs", predicate: HuCellDef, isSignal: true }], ngImport: i0, template: "<div class=\"hu-table__scroll\" [attr.aria-busy]=\"loading() || null\">\n <table class=\"hu-table__table\">\n <thead>\n <tr>\n @for (col of columns(); track col.key) {\n <th\n scope=\"col\"\n [style.width]=\"col.width\"\n [attr.data-align]=\"col.align\"\n [attr.aria-sort]=\"ariaSort(col)\"\n [class.hu-table__cell--hide-mobile]=\"col.hideOnMobile\"\n >\n @if (col.sortable) {\n <button type=\"button\" class=\"hu-table__sort\" [class.hu-table__sort--active]=\"sort().key === col.key && sort().direction\" (click)=\"toggleSort(col)\">\n {{ col.header }}\n <hu-icon [name]=\"sortIcon(col)\" [size]=\"14\" />\n </button>\n } @else {\n {{ col.header }}\n }\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @if (loading() && !rows().length) {\n <tr>\n <td class=\"hu-table__state\" [attr.colspan]=\"columns().length\">\n <hu-spinner />\n </td>\n </tr>\n } @else {\n @for (row of rows(); track trackBy()(row); let i = $index) {\n <tr [class.hu-table__row--clickable]=\"clickableRows()\" (click)=\"onRowClick(row)\">\n @for (col of columns(); track col.key) {\n <td [attr.data-align]=\"col.align\" [class.hu-table__cell--hide-mobile]=\"col.hideOnMobile\">\n @if (templates().get(col.key); as tpl) {\n <ng-container *ngTemplateOutlet=\"tpl; context: { $implicit: row, index: i }\" />\n } @else {\n {{ cellValue(row, col) }}\n }\n </td>\n }\n </tr>\n } @empty {\n <tr>\n <td class=\"hu-table__state\" [attr.colspan]=\"columns().length\">\n <ng-content select=\"[huTableEmpty]\">{{ emptyText() }}</ng-content>\n </td>\n </tr>\n }\n }\n </tbody>\n </table>\n @if (loading() && rows().length) {\n <div class=\"hu-table__overlay\"><hu-spinner size=\"lg\" /></div>\n }\n</div>\n", styles: [".hu-table{display:block;min-width:0}.hu-table__scroll{position:relative;overflow-x:auto}.hu-table--sticky .hu-table__scroll{max-height:var(--hu-table-max-height, 32rem);overflow-y:auto}.hu-table__table{width:100%;border-collapse:separate;border-spacing:0;font-size:var(--hu-text-sm)}.hu-table__table th,.hu-table__table td{padding:var(--hu-space-3) var(--hu-space-4);text-align:left;vertical-align:middle;border-bottom:1px solid var(--hu-border)}.hu-table__table th[data-align=center],.hu-table__table td[data-align=center]{text-align:center}.hu-table__table th[data-align=end],.hu-table__table td[data-align=end]{text-align:right}.hu-table__table th{height:2.5rem;padding-top:var(--hu-space-2);padding-bottom:var(--hu-space-2);font-size:var(--hu-text-xs);font-weight:600;letter-spacing:.02em;color:var(--hu-text-muted);white-space:nowrap;background:var(--hu-surface-2)}.hu-table__table tbody tr{transition:background-color var(--hu-transition)}.hu-table__table tbody tr:hover{background:var(--hu-surface-2)}.hu-table__table tbody tr:last-child td{border-bottom:0}.hu-table--sticky thead th{position:sticky;top:0;z-index:1}.hu-table--striped tbody tr:nth-child(2n){background:color-mix(in srgb,var(--hu-surface-3) 45%,transparent)}.hu-table--dense .hu-table__table td{padding-top:var(--hu-space-2);padding-bottom:var(--hu-space-2)}.hu-table__row--clickable{cursor:pointer}.hu-table__sort{display:inline-flex;align-items:center;gap:var(--hu-space-1);margin:0 calc(var(--hu-space-1) * -1);padding:2px var(--hu-space-1);font:inherit;color:inherit;letter-spacing:inherit;background:none;border:0;border-radius:var(--hu-radius-sm);cursor:pointer}.hu-table__sort .hu-icon{opacity:.5}.hu-table__sort:hover,.hu-table__sort--active{color:var(--hu-text)}.hu-table__sort--active .hu-icon{color:var(--hu-primary);opacity:1}.hu-table__state{height:8rem;color:var(--hu-text-muted);text-align:center!important}.hu-table__state .hu-spinner{margin:0 auto}.hu-table__overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--hu-surface) 60%,transparent)}@media(max-width:767.98px){.hu-table__cell--hide-mobile{display:none}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }, { kind: "component", type: HuSpinner, selector: "hu-spinner", inputs: ["size", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1961
|
+
}
|
|
1962
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTable, decorators: [{
|
|
1963
|
+
type: Component,
|
|
1964
|
+
args: [{ selector: 'hu-table', imports: [NgTemplateOutlet, HuIcon, HuSpinner], host: {
|
|
1965
|
+
class: 'hu-table',
|
|
1966
|
+
'[class.hu-table--striped]': 'striped()',
|
|
1967
|
+
'[class.hu-table--dense]': 'dense()',
|
|
1968
|
+
'[class.hu-table--sticky]': 'stickyHeader()',
|
|
1969
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"hu-table__scroll\" [attr.aria-busy]=\"loading() || null\">\n <table class=\"hu-table__table\">\n <thead>\n <tr>\n @for (col of columns(); track col.key) {\n <th\n scope=\"col\"\n [style.width]=\"col.width\"\n [attr.data-align]=\"col.align\"\n [attr.aria-sort]=\"ariaSort(col)\"\n [class.hu-table__cell--hide-mobile]=\"col.hideOnMobile\"\n >\n @if (col.sortable) {\n <button type=\"button\" class=\"hu-table__sort\" [class.hu-table__sort--active]=\"sort().key === col.key && sort().direction\" (click)=\"toggleSort(col)\">\n {{ col.header }}\n <hu-icon [name]=\"sortIcon(col)\" [size]=\"14\" />\n </button>\n } @else {\n {{ col.header }}\n }\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @if (loading() && !rows().length) {\n <tr>\n <td class=\"hu-table__state\" [attr.colspan]=\"columns().length\">\n <hu-spinner />\n </td>\n </tr>\n } @else {\n @for (row of rows(); track trackBy()(row); let i = $index) {\n <tr [class.hu-table__row--clickable]=\"clickableRows()\" (click)=\"onRowClick(row)\">\n @for (col of columns(); track col.key) {\n <td [attr.data-align]=\"col.align\" [class.hu-table__cell--hide-mobile]=\"col.hideOnMobile\">\n @if (templates().get(col.key); as tpl) {\n <ng-container *ngTemplateOutlet=\"tpl; context: { $implicit: row, index: i }\" />\n } @else {\n {{ cellValue(row, col) }}\n }\n </td>\n }\n </tr>\n } @empty {\n <tr>\n <td class=\"hu-table__state\" [attr.colspan]=\"columns().length\">\n <ng-content select=\"[huTableEmpty]\">{{ emptyText() }}</ng-content>\n </td>\n </tr>\n }\n }\n </tbody>\n </table>\n @if (loading() && rows().length) {\n <div class=\"hu-table__overlay\"><hu-spinner size=\"lg\" /></div>\n }\n</div>\n", styles: [".hu-table{display:block;min-width:0}.hu-table__scroll{position:relative;overflow-x:auto}.hu-table--sticky .hu-table__scroll{max-height:var(--hu-table-max-height, 32rem);overflow-y:auto}.hu-table__table{width:100%;border-collapse:separate;border-spacing:0;font-size:var(--hu-text-sm)}.hu-table__table th,.hu-table__table td{padding:var(--hu-space-3) var(--hu-space-4);text-align:left;vertical-align:middle;border-bottom:1px solid var(--hu-border)}.hu-table__table th[data-align=center],.hu-table__table td[data-align=center]{text-align:center}.hu-table__table th[data-align=end],.hu-table__table td[data-align=end]{text-align:right}.hu-table__table th{height:2.5rem;padding-top:var(--hu-space-2);padding-bottom:var(--hu-space-2);font-size:var(--hu-text-xs);font-weight:600;letter-spacing:.02em;color:var(--hu-text-muted);white-space:nowrap;background:var(--hu-surface-2)}.hu-table__table tbody tr{transition:background-color var(--hu-transition)}.hu-table__table tbody tr:hover{background:var(--hu-surface-2)}.hu-table__table tbody tr:last-child td{border-bottom:0}.hu-table--sticky thead th{position:sticky;top:0;z-index:1}.hu-table--striped tbody tr:nth-child(2n){background:color-mix(in srgb,var(--hu-surface-3) 45%,transparent)}.hu-table--dense .hu-table__table td{padding-top:var(--hu-space-2);padding-bottom:var(--hu-space-2)}.hu-table__row--clickable{cursor:pointer}.hu-table__sort{display:inline-flex;align-items:center;gap:var(--hu-space-1);margin:0 calc(var(--hu-space-1) * -1);padding:2px var(--hu-space-1);font:inherit;color:inherit;letter-spacing:inherit;background:none;border:0;border-radius:var(--hu-radius-sm);cursor:pointer}.hu-table__sort .hu-icon{opacity:.5}.hu-table__sort:hover,.hu-table__sort--active{color:var(--hu-text)}.hu-table__sort--active .hu-icon{color:var(--hu-primary);opacity:1}.hu-table__state{height:8rem;color:var(--hu-text-muted);text-align:center!important}.hu-table__state .hu-spinner{margin:0 auto}.hu-table__overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--hu-surface) 60%,transparent)}@media(max-width:767.98px){.hu-table__cell--hide-mobile{display:none}}\n"] }]
|
|
1970
|
+
}] });
|
|
1971
|
+
|
|
1972
|
+
/**
|
|
1973
|
+
* Sayfalama.
|
|
1974
|
+
* @example <hu-paginator [length]="total()" [(pageIndex)]="page" [(pageSize)]="size" />
|
|
1975
|
+
*/
|
|
1976
|
+
class HuPaginator {
|
|
1977
|
+
length = input.required();
|
|
1978
|
+
pageIndex = model(0);
|
|
1979
|
+
pageSize = model(10);
|
|
1980
|
+
pageSizeOptions = input([10, 25, 50]);
|
|
1981
|
+
pageCount = computed(() => Math.max(1, Math.ceil(this.length() / this.pageSize())));
|
|
1982
|
+
rangeLabel = computed(() => {
|
|
1983
|
+
const total = this.length();
|
|
1984
|
+
if (!total)
|
|
1985
|
+
return '0 kayıt';
|
|
1986
|
+
const start = this.pageIndex() * this.pageSize() + 1;
|
|
1987
|
+
const end = Math.min(total, start + this.pageSize() - 1);
|
|
1988
|
+
return `${start}–${end} / ${total} kayıt`;
|
|
1989
|
+
});
|
|
1990
|
+
/** Mevcut sayfanın etrafında en fazla 7 öğe (ilk, son, komşular ve boşluklar). */
|
|
1991
|
+
pages = computed(() => {
|
|
1992
|
+
const count = this.pageCount();
|
|
1993
|
+
const current = Math.min(this.pageIndex(), count - 1);
|
|
1994
|
+
if (count <= 7)
|
|
1995
|
+
return Array.from({ length: count }, (_, i) => i);
|
|
1996
|
+
const start = Math.max(1, Math.min(current - 1, count - 5));
|
|
1997
|
+
const end = Math.min(count - 2, Math.max(current + 1, 4));
|
|
1998
|
+
const items = [0];
|
|
1999
|
+
if (start > 1)
|
|
2000
|
+
items.push('gap-start');
|
|
2001
|
+
for (let i = start; i <= end; i++)
|
|
2002
|
+
items.push(i);
|
|
2003
|
+
if (end < count - 2)
|
|
2004
|
+
items.push('gap-end');
|
|
2005
|
+
items.push(count - 1);
|
|
2006
|
+
return items;
|
|
2007
|
+
});
|
|
2008
|
+
goTo(index) {
|
|
2009
|
+
const clamped = Math.max(0, Math.min(index, this.pageCount() - 1));
|
|
2010
|
+
if (clamped !== this.pageIndex())
|
|
2011
|
+
this.pageIndex.set(clamped);
|
|
2012
|
+
}
|
|
2013
|
+
changePageSize(event) {
|
|
2014
|
+
this.pageSize.set(Number(event.target.value));
|
|
2015
|
+
this.pageIndex.set(0);
|
|
2016
|
+
}
|
|
2017
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuPaginator, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2018
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuPaginator, isStandalone: true, selector: "hu-paginator", inputs: { length: { classPropertyName: "length", publicName: "length", isSignal: true, isRequired: true, transformFunction: null }, pageIndex: { classPropertyName: "pageIndex", publicName: "pageIndex", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, pageSizeOptions: { classPropertyName: "pageSizeOptions", publicName: "pageSizeOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pageIndex: "pageIndexChange", pageSize: "pageSizeChange" }, host: { classAttribute: "hu-paginator" }, ngImport: i0, template: `
|
|
2019
|
+
<div class="hu-paginator__info">
|
|
2020
|
+
@if (pageSizeOptions().length > 1) {
|
|
2021
|
+
<label class="hu-paginator__size">
|
|
2022
|
+
<span>Sayfa başına</span>
|
|
2023
|
+
<select huInput size="sm" [value]="pageSize()" (change)="changePageSize($event)">
|
|
2024
|
+
@for (option of pageSizeOptions(); track option) {
|
|
2025
|
+
<option [value]="option" [selected]="option === pageSize()">{{ option }}</option>
|
|
2026
|
+
}
|
|
2027
|
+
</select>
|
|
2028
|
+
</label>
|
|
2029
|
+
}
|
|
2030
|
+
<span class="hu-paginator__range">{{ rangeLabel() }}</span>
|
|
2031
|
+
</div>
|
|
2032
|
+
|
|
2033
|
+
<nav class="hu-paginator__pages" aria-label="Sayfalama">
|
|
2034
|
+
<button hu-button variant="ghost" size="sm" iconOnly aria-label="Önceki sayfa" [disabled]="pageIndex() === 0" (click)="goTo(pageIndex() - 1)">
|
|
2035
|
+
<hu-icon name="chevron-left" [size]="16" />
|
|
2036
|
+
</button>
|
|
2037
|
+
@for (item of pages(); track item) {
|
|
2038
|
+
@if (item === 'gap-start' || item === 'gap-end') {
|
|
2039
|
+
<span class="hu-paginator__gap" aria-hidden="true">…</span>
|
|
2040
|
+
} @else {
|
|
2041
|
+
<button
|
|
2042
|
+
type="button"
|
|
2043
|
+
class="hu-paginator__page"
|
|
2044
|
+
[class.hu-paginator__page--active]="item === pageIndex()"
|
|
2045
|
+
[attr.aria-current]="item === pageIndex() ? 'page' : null"
|
|
2046
|
+
[attr.aria-label]="'Sayfa ' + (item + 1)"
|
|
2047
|
+
(click)="goTo(item)"
|
|
2048
|
+
>
|
|
2049
|
+
{{ item + 1 }}
|
|
2050
|
+
</button>
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
<button hu-button variant="ghost" size="sm" iconOnly aria-label="Sonraki sayfa" [disabled]="pageIndex() >= pageCount() - 1" (click)="goTo(pageIndex() + 1)">
|
|
2054
|
+
<hu-icon name="chevron-right" [size]="16" />
|
|
2055
|
+
</button>
|
|
2056
|
+
</nav>
|
|
2057
|
+
`, isInline: true, styles: [".hu-paginator{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--hu-space-3);padding:var(--hu-space-3) var(--hu-space-4);font-size:var(--hu-text-sm);color:var(--hu-text-muted)}.hu-paginator__info{display:flex;align-items:center;gap:var(--hu-space-4)}.hu-paginator__size{display:inline-flex;align-items:center;gap:var(--hu-space-2);white-space:nowrap}.hu-paginator__size .hu-input{width:auto}.hu-paginator__pages{display:flex;align-items:center;gap:2px}.hu-paginator__page{min-width:var(--hu-control-sm);height:var(--hu-control-sm);padding:0 var(--hu-space-2);font:inherit;font-variant-numeric:tabular-nums;color:var(--hu-text-muted);background:none;border:1px solid transparent;border-radius:var(--hu-radius-md);cursor:pointer}.hu-paginator__page:hover{color:var(--hu-text);background:var(--hu-surface-3)}.hu-paginator__page--active,.hu-paginator__page--active:hover{font-weight:600;color:var(--hu-primary-soft-fg);background:var(--hu-primary-soft)}.hu-paginator__gap{padding:0 var(--hu-space-1)}@media(max-width:639.98px){.hu-paginator__size{display:none}}\n"], dependencies: [{ kind: "component", type: HuButton, selector: "button[hu-button], a[hu-button]", inputs: ["variant", "color", "size", "disabled", "loading", "block", "iconOnly", "pill"] }, { kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }, { kind: "directive", type: HuInput, selector: "input[huInput], textarea[huInput], select[huInput]", inputs: ["id", "size", "invalid"], exportAs: ["huInput"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2058
|
+
}
|
|
2059
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuPaginator, decorators: [{
|
|
2060
|
+
type: Component,
|
|
2061
|
+
args: [{ selector: 'hu-paginator', imports: [HuButton, HuIcon, HuInput], template: `
|
|
2062
|
+
<div class="hu-paginator__info">
|
|
2063
|
+
@if (pageSizeOptions().length > 1) {
|
|
2064
|
+
<label class="hu-paginator__size">
|
|
2065
|
+
<span>Sayfa başına</span>
|
|
2066
|
+
<select huInput size="sm" [value]="pageSize()" (change)="changePageSize($event)">
|
|
2067
|
+
@for (option of pageSizeOptions(); track option) {
|
|
2068
|
+
<option [value]="option" [selected]="option === pageSize()">{{ option }}</option>
|
|
2069
|
+
}
|
|
2070
|
+
</select>
|
|
2071
|
+
</label>
|
|
2072
|
+
}
|
|
2073
|
+
<span class="hu-paginator__range">{{ rangeLabel() }}</span>
|
|
2074
|
+
</div>
|
|
2075
|
+
|
|
2076
|
+
<nav class="hu-paginator__pages" aria-label="Sayfalama">
|
|
2077
|
+
<button hu-button variant="ghost" size="sm" iconOnly aria-label="Önceki sayfa" [disabled]="pageIndex() === 0" (click)="goTo(pageIndex() - 1)">
|
|
2078
|
+
<hu-icon name="chevron-left" [size]="16" />
|
|
2079
|
+
</button>
|
|
2080
|
+
@for (item of pages(); track item) {
|
|
2081
|
+
@if (item === 'gap-start' || item === 'gap-end') {
|
|
2082
|
+
<span class="hu-paginator__gap" aria-hidden="true">…</span>
|
|
2083
|
+
} @else {
|
|
2084
|
+
<button
|
|
2085
|
+
type="button"
|
|
2086
|
+
class="hu-paginator__page"
|
|
2087
|
+
[class.hu-paginator__page--active]="item === pageIndex()"
|
|
2088
|
+
[attr.aria-current]="item === pageIndex() ? 'page' : null"
|
|
2089
|
+
[attr.aria-label]="'Sayfa ' + (item + 1)"
|
|
2090
|
+
(click)="goTo(item)"
|
|
2091
|
+
>
|
|
2092
|
+
{{ item + 1 }}
|
|
2093
|
+
</button>
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
<button hu-button variant="ghost" size="sm" iconOnly aria-label="Sonraki sayfa" [disabled]="pageIndex() >= pageCount() - 1" (click)="goTo(pageIndex() + 1)">
|
|
2097
|
+
<hu-icon name="chevron-right" [size]="16" />
|
|
2098
|
+
</button>
|
|
2099
|
+
</nav>
|
|
2100
|
+
`, host: { class: 'hu-paginator' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-paginator{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--hu-space-3);padding:var(--hu-space-3) var(--hu-space-4);font-size:var(--hu-text-sm);color:var(--hu-text-muted)}.hu-paginator__info{display:flex;align-items:center;gap:var(--hu-space-4)}.hu-paginator__size{display:inline-flex;align-items:center;gap:var(--hu-space-2);white-space:nowrap}.hu-paginator__size .hu-input{width:auto}.hu-paginator__pages{display:flex;align-items:center;gap:2px}.hu-paginator__page{min-width:var(--hu-control-sm);height:var(--hu-control-sm);padding:0 var(--hu-space-2);font:inherit;font-variant-numeric:tabular-nums;color:var(--hu-text-muted);background:none;border:1px solid transparent;border-radius:var(--hu-radius-md);cursor:pointer}.hu-paginator__page:hover{color:var(--hu-text);background:var(--hu-surface-3)}.hu-paginator__page--active,.hu-paginator__page--active:hover{font-weight:600;color:var(--hu-primary-soft-fg);background:var(--hu-primary-soft)}.hu-paginator__gap{padding:0 var(--hu-space-1)}@media(max-width:639.98px){.hu-paginator__size{display:none}}\n"] }]
|
|
2101
|
+
}] });
|
|
2102
|
+
|
|
2103
|
+
/** Tek bir sekme. İçeriği yalnızca aktifken render edilir. */
|
|
2104
|
+
class HuTab {
|
|
2105
|
+
label = input.required();
|
|
2106
|
+
icon = input();
|
|
2107
|
+
disabled = input(false, { transform: booleanAttribute });
|
|
2108
|
+
content = viewChild.required(TemplateRef);
|
|
2109
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTab, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2110
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.25", type: HuTab, isStandalone: true, selector: "hu-tab", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "content", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], ngImport: i0, template: `<ng-template><ng-content /></ng-template>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2111
|
+
}
|
|
2112
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTab, decorators: [{
|
|
2113
|
+
type: Component,
|
|
2114
|
+
args: [{
|
|
2115
|
+
selector: 'hu-tab',
|
|
2116
|
+
template: `<ng-template><ng-content /></ng-template>`,
|
|
2117
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2118
|
+
}]
|
|
2119
|
+
}] });
|
|
2120
|
+
/**
|
|
2121
|
+
* Sekmeler. Ok tuşları, Home/End ile klavye gezintisi destekler.
|
|
2122
|
+
* @example
|
|
2123
|
+
* <hu-tabs [(selectedIndex)]="tab">
|
|
2124
|
+
* <hu-tab label="Profil" icon="user">...</hu-tab>
|
|
2125
|
+
* <hu-tab label="Güvenlik" icon="lock">...</hu-tab>
|
|
2126
|
+
* </hu-tabs>
|
|
2127
|
+
*/
|
|
2128
|
+
class HuTabs {
|
|
2129
|
+
host = inject(ElementRef);
|
|
2130
|
+
selectedIndex = model(0);
|
|
2131
|
+
variant = input('line');
|
|
2132
|
+
tabs = contentChildren(HuTab);
|
|
2133
|
+
baseId = huUniqueId('hu-tabs');
|
|
2134
|
+
activeIndex = computed(() => Math.min(this.selectedIndex(), this.tabs().length - 1));
|
|
2135
|
+
activeTab = computed(() => this.tabs()[this.activeIndex()]);
|
|
2136
|
+
select(index) {
|
|
2137
|
+
if (!this.tabs()[index]?.disabled())
|
|
2138
|
+
this.selectedIndex.set(index);
|
|
2139
|
+
}
|
|
2140
|
+
onKeydown(event) {
|
|
2141
|
+
const tabs = this.tabs();
|
|
2142
|
+
const enabled = tabs.map((t, i) => (t.disabled() ? -1 : i)).filter((i) => i >= 0);
|
|
2143
|
+
const pos = enabled.indexOf(this.activeIndex());
|
|
2144
|
+
let next;
|
|
2145
|
+
switch (event.key) {
|
|
2146
|
+
case 'ArrowRight':
|
|
2147
|
+
next = enabled[(pos + 1) % enabled.length];
|
|
2148
|
+
break;
|
|
2149
|
+
case 'ArrowLeft':
|
|
2150
|
+
next = enabled[(pos - 1 + enabled.length) % enabled.length];
|
|
2151
|
+
break;
|
|
2152
|
+
case 'Home':
|
|
2153
|
+
next = enabled[0];
|
|
2154
|
+
break;
|
|
2155
|
+
case 'End':
|
|
2156
|
+
next = enabled[enabled.length - 1];
|
|
2157
|
+
break;
|
|
2158
|
+
default:
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
event.preventDefault();
|
|
2162
|
+
if (next === undefined)
|
|
2163
|
+
return;
|
|
2164
|
+
this.select(next);
|
|
2165
|
+
this.host.nativeElement.querySelectorAll('.hu-tabs__tab')[next]?.focus();
|
|
2166
|
+
}
|
|
2167
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTabs, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2168
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuTabs, isStandalone: true, selector: "hu-tabs", inputs: { selectedIndex: { classPropertyName: "selectedIndex", publicName: "selectedIndex", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedIndex: "selectedIndexChange" }, host: { properties: { "attr.data-variant": "variant()" }, classAttribute: "hu-tabs" }, queries: [{ propertyName: "tabs", predicate: HuTab, isSignal: true }], ngImport: i0, template: `
|
|
2169
|
+
<div class="hu-tabs__list" role="tablist" (keydown)="onKeydown($event)">
|
|
2170
|
+
@for (tab of tabs(); track tab; let i = $index) {
|
|
2171
|
+
<button
|
|
2172
|
+
type="button"
|
|
2173
|
+
role="tab"
|
|
2174
|
+
class="hu-tabs__tab"
|
|
2175
|
+
[id]="baseId + '-tab-' + i"
|
|
2176
|
+
[attr.aria-selected]="i === activeIndex()"
|
|
2177
|
+
[attr.aria-controls]="baseId + '-panel-' + i"
|
|
2178
|
+
[tabIndex]="i === activeIndex() ? 0 : -1"
|
|
2179
|
+
[disabled]="tab.disabled()"
|
|
2180
|
+
(click)="select(i)"
|
|
2181
|
+
>
|
|
2182
|
+
@if (tab.icon()) {
|
|
2183
|
+
<hu-icon [name]="tab.icon()!" [size]="16" />
|
|
2184
|
+
}
|
|
2185
|
+
{{ tab.label() }}
|
|
2186
|
+
</button>
|
|
2187
|
+
}
|
|
2188
|
+
</div>
|
|
2189
|
+
@if (activeTab(); as tab) {
|
|
2190
|
+
<div
|
|
2191
|
+
class="hu-tabs__panel"
|
|
2192
|
+
role="tabpanel"
|
|
2193
|
+
tabindex="0"
|
|
2194
|
+
[id]="baseId + '-panel-' + activeIndex()"
|
|
2195
|
+
[attr.aria-labelledby]="baseId + '-tab-' + activeIndex()"
|
|
2196
|
+
>
|
|
2197
|
+
<ng-container [ngTemplateOutlet]="tab.content()" />
|
|
2198
|
+
</div>
|
|
2199
|
+
}
|
|
2200
|
+
`, isInline: true, styles: [".hu-tabs{display:block}.hu-tabs__list{display:flex;gap:var(--hu-space-1);overflow-x:auto;scrollbar-width:none}.hu-tabs[data-variant=line] .hu-tabs__list{gap:var(--hu-space-5);border-bottom:1px solid var(--hu-border)}.hu-tabs__tab{display:inline-flex;align-items:center;gap:var(--hu-space-2);flex-shrink:0;font:inherit;font-weight:500;color:var(--hu-text-muted);white-space:nowrap;background:none;border:0;cursor:pointer;transition:color var(--hu-transition),background-color var(--hu-transition),border-color var(--hu-transition)}.hu-tabs__tab:hover:not(:disabled){color:var(--hu-text)}.hu-tabs__tab:disabled{opacity:.45;cursor:not-allowed}.hu-tabs__tab:focus-visible{outline:none;box-shadow:var(--hu-ring);border-radius:var(--hu-radius-sm)}.hu-tabs[data-variant=line] .hu-tabs__tab{margin-bottom:-1px;padding:var(--hu-space-3) 0;border-bottom:2px solid transparent}.hu-tabs[data-variant=line] .hu-tabs__tab[aria-selected=true]{color:var(--hu-primary);border-bottom-color:var(--hu-primary)}.hu-tabs[data-variant=pills] .hu-tabs__list{display:inline-flex;padding:3px;background:var(--hu-surface-3);border-radius:var(--hu-radius-md)}.hu-tabs[data-variant=pills] .hu-tabs__tab{height:2rem;padding:0 var(--hu-space-3);border-radius:var(--hu-radius-sm)}.hu-tabs[data-variant=pills] .hu-tabs__tab[aria-selected=true]{color:var(--hu-text);background:var(--hu-surface);box-shadow:var(--hu-shadow-sm)}.hu-tabs__panel{padding-top:var(--hu-space-5)}.hu-tabs__panel:focus-visible{outline:none}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2201
|
+
}
|
|
2202
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTabs, decorators: [{
|
|
2203
|
+
type: Component,
|
|
2204
|
+
args: [{ selector: 'hu-tabs', imports: [NgTemplateOutlet, HuIcon], template: `
|
|
2205
|
+
<div class="hu-tabs__list" role="tablist" (keydown)="onKeydown($event)">
|
|
2206
|
+
@for (tab of tabs(); track tab; let i = $index) {
|
|
2207
|
+
<button
|
|
2208
|
+
type="button"
|
|
2209
|
+
role="tab"
|
|
2210
|
+
class="hu-tabs__tab"
|
|
2211
|
+
[id]="baseId + '-tab-' + i"
|
|
2212
|
+
[attr.aria-selected]="i === activeIndex()"
|
|
2213
|
+
[attr.aria-controls]="baseId + '-panel-' + i"
|
|
2214
|
+
[tabIndex]="i === activeIndex() ? 0 : -1"
|
|
2215
|
+
[disabled]="tab.disabled()"
|
|
2216
|
+
(click)="select(i)"
|
|
2217
|
+
>
|
|
2218
|
+
@if (tab.icon()) {
|
|
2219
|
+
<hu-icon [name]="tab.icon()!" [size]="16" />
|
|
2220
|
+
}
|
|
2221
|
+
{{ tab.label() }}
|
|
2222
|
+
</button>
|
|
2223
|
+
}
|
|
2224
|
+
</div>
|
|
2225
|
+
@if (activeTab(); as tab) {
|
|
2226
|
+
<div
|
|
2227
|
+
class="hu-tabs__panel"
|
|
2228
|
+
role="tabpanel"
|
|
2229
|
+
tabindex="0"
|
|
2230
|
+
[id]="baseId + '-panel-' + activeIndex()"
|
|
2231
|
+
[attr.aria-labelledby]="baseId + '-tab-' + activeIndex()"
|
|
2232
|
+
>
|
|
2233
|
+
<ng-container [ngTemplateOutlet]="tab.content()" />
|
|
2234
|
+
</div>
|
|
2235
|
+
}
|
|
2236
|
+
`, host: { class: 'hu-tabs', '[attr.data-variant]': 'variant()' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-tabs{display:block}.hu-tabs__list{display:flex;gap:var(--hu-space-1);overflow-x:auto;scrollbar-width:none}.hu-tabs[data-variant=line] .hu-tabs__list{gap:var(--hu-space-5);border-bottom:1px solid var(--hu-border)}.hu-tabs__tab{display:inline-flex;align-items:center;gap:var(--hu-space-2);flex-shrink:0;font:inherit;font-weight:500;color:var(--hu-text-muted);white-space:nowrap;background:none;border:0;cursor:pointer;transition:color var(--hu-transition),background-color var(--hu-transition),border-color var(--hu-transition)}.hu-tabs__tab:hover:not(:disabled){color:var(--hu-text)}.hu-tabs__tab:disabled{opacity:.45;cursor:not-allowed}.hu-tabs__tab:focus-visible{outline:none;box-shadow:var(--hu-ring);border-radius:var(--hu-radius-sm)}.hu-tabs[data-variant=line] .hu-tabs__tab{margin-bottom:-1px;padding:var(--hu-space-3) 0;border-bottom:2px solid transparent}.hu-tabs[data-variant=line] .hu-tabs__tab[aria-selected=true]{color:var(--hu-primary);border-bottom-color:var(--hu-primary)}.hu-tabs[data-variant=pills] .hu-tabs__list{display:inline-flex;padding:3px;background:var(--hu-surface-3);border-radius:var(--hu-radius-md)}.hu-tabs[data-variant=pills] .hu-tabs__tab{height:2rem;padding:0 var(--hu-space-3);border-radius:var(--hu-radius-sm)}.hu-tabs[data-variant=pills] .hu-tabs__tab[aria-selected=true]{color:var(--hu-text);background:var(--hu-surface);box-shadow:var(--hu-shadow-sm)}.hu-tabs__panel{padding-top:var(--hu-space-5)}.hu-tabs__panel:focus-visible{outline:none}\n"] }]
|
|
2237
|
+
}] });
|
|
2238
|
+
|
|
2239
|
+
/** @example <hu-breadcrumb [items]="[{ label: 'Ana Sayfa', link: '/' }, { label: 'Kullanıcılar' }]" /> */
|
|
2240
|
+
class HuBreadcrumb {
|
|
2241
|
+
items = input([]);
|
|
2242
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuBreadcrumb, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2243
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuBreadcrumb, isStandalone: true, selector: "hu-breadcrumb", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "hu-breadcrumb" }, ngImport: i0, template: `
|
|
2244
|
+
<nav aria-label="Konum">
|
|
2245
|
+
<ol class="hu-breadcrumb__list">
|
|
2246
|
+
@for (item of items(); track $index; let last = $last) {
|
|
2247
|
+
<li class="hu-breadcrumb__item">
|
|
2248
|
+
@if (item.link && !last) {
|
|
2249
|
+
<a class="hu-breadcrumb__link" [routerLink]="item.link">
|
|
2250
|
+
@if (item.icon) {
|
|
2251
|
+
<hu-icon [name]="item.icon" [size]="14" />
|
|
2252
|
+
}
|
|
2253
|
+
{{ item.label }}
|
|
2254
|
+
</a>
|
|
2255
|
+
<hu-icon class="hu-breadcrumb__sep" name="chevron-right" [size]="14" />
|
|
2256
|
+
} @else {
|
|
2257
|
+
<span class="hu-breadcrumb__current" [attr.aria-current]="last ? 'page' : null">{{ item.label }}</span>
|
|
2258
|
+
@if (!last) {
|
|
2259
|
+
<hu-icon class="hu-breadcrumb__sep" name="chevron-right" [size]="14" />
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
</li>
|
|
2263
|
+
}
|
|
2264
|
+
</ol>
|
|
2265
|
+
</nav>
|
|
2266
|
+
`, isInline: true, styles: [".hu-breadcrumb{display:block;min-width:0}.hu-breadcrumb__list{display:flex;align-items:center;flex-wrap:wrap;gap:var(--hu-space-1);margin:0;padding:0;font-size:var(--hu-text-sm);list-style:none}.hu-breadcrumb__item{display:inline-flex;align-items:center;gap:var(--hu-space-1);min-width:0}.hu-breadcrumb__link{display:inline-flex;align-items:center;gap:var(--hu-space-1);color:var(--hu-text-muted);text-decoration:none;border-radius:var(--hu-radius-sm)}.hu-breadcrumb__link:hover{color:var(--hu-text)}.hu-breadcrumb__current{font-weight:500;color:var(--hu-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hu-breadcrumb__sep{color:var(--hu-text-subtle)}\n"], dependencies: [{ kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2267
|
+
}
|
|
2268
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuBreadcrumb, decorators: [{
|
|
2269
|
+
type: Component,
|
|
2270
|
+
args: [{ selector: 'hu-breadcrumb', imports: [RouterLink, HuIcon], template: `
|
|
2271
|
+
<nav aria-label="Konum">
|
|
2272
|
+
<ol class="hu-breadcrumb__list">
|
|
2273
|
+
@for (item of items(); track $index; let last = $last) {
|
|
2274
|
+
<li class="hu-breadcrumb__item">
|
|
2275
|
+
@if (item.link && !last) {
|
|
2276
|
+
<a class="hu-breadcrumb__link" [routerLink]="item.link">
|
|
2277
|
+
@if (item.icon) {
|
|
2278
|
+
<hu-icon [name]="item.icon" [size]="14" />
|
|
2279
|
+
}
|
|
2280
|
+
{{ item.label }}
|
|
2281
|
+
</a>
|
|
2282
|
+
<hu-icon class="hu-breadcrumb__sep" name="chevron-right" [size]="14" />
|
|
2283
|
+
} @else {
|
|
2284
|
+
<span class="hu-breadcrumb__current" [attr.aria-current]="last ? 'page' : null">{{ item.label }}</span>
|
|
2285
|
+
@if (!last) {
|
|
2286
|
+
<hu-icon class="hu-breadcrumb__sep" name="chevron-right" [size]="14" />
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
</li>
|
|
2290
|
+
}
|
|
2291
|
+
</ol>
|
|
2292
|
+
</nav>
|
|
2293
|
+
`, host: { class: 'hu-breadcrumb' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-breadcrumb{display:block;min-width:0}.hu-breadcrumb__list{display:flex;align-items:center;flex-wrap:wrap;gap:var(--hu-space-1);margin:0;padding:0;font-size:var(--hu-text-sm);list-style:none}.hu-breadcrumb__item{display:inline-flex;align-items:center;gap:var(--hu-space-1);min-width:0}.hu-breadcrumb__link{display:inline-flex;align-items:center;gap:var(--hu-space-1);color:var(--hu-text-muted);text-decoration:none;border-radius:var(--hu-radius-sm)}.hu-breadcrumb__link:hover{color:var(--hu-text)}.hu-breadcrumb__current{font-weight:500;color:var(--hu-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hu-breadcrumb__sep{color:var(--hu-text-subtle)}\n"] }]
|
|
2294
|
+
}] });
|
|
2295
|
+
|
|
2296
|
+
/**
|
|
2297
|
+
* Açılır menü (dropdown). Tetikleyiciye `huMenuTrigger`, öğelere `huMenuItem` verin.
|
|
2298
|
+
*
|
|
2299
|
+
* @example
|
|
2300
|
+
* <hu-menu align="end">
|
|
2301
|
+
* <button huMenuTrigger hu-button variant="ghost" iconOnly aria-label="İşlemler"><hu-icon name="more-vertical" /></button>
|
|
2302
|
+
* <button huMenuItem (click)="edit()"><hu-icon name="edit" /> Düzenle</button>
|
|
2303
|
+
* <hr class="hu-menu-divider" />
|
|
2304
|
+
* <button huMenuItem class="hu-menu-item--danger" (click)="remove()"><hu-icon name="trash" /> Sil</button>
|
|
2305
|
+
* </hu-menu>
|
|
2306
|
+
*/
|
|
2307
|
+
class HuMenu {
|
|
2308
|
+
host = inject(ElementRef);
|
|
2309
|
+
injector = inject(Injector);
|
|
2310
|
+
align = input('start');
|
|
2311
|
+
isOpen = signal(false);
|
|
2312
|
+
panelId = huUniqueId('hu-menu');
|
|
2313
|
+
toggle() {
|
|
2314
|
+
if (this.isOpen())
|
|
2315
|
+
this.close();
|
|
2316
|
+
else
|
|
2317
|
+
this.openMenu();
|
|
2318
|
+
}
|
|
2319
|
+
openMenu() {
|
|
2320
|
+
this.isOpen.set(true);
|
|
2321
|
+
afterNextRender(() => this.items()[0]?.focus(), { injector: this.injector });
|
|
2322
|
+
}
|
|
2323
|
+
close(restoreFocus = false) {
|
|
2324
|
+
if (!this.isOpen())
|
|
2325
|
+
return;
|
|
2326
|
+
this.isOpen.set(false);
|
|
2327
|
+
if (restoreFocus)
|
|
2328
|
+
this.host.nativeElement.querySelector('[huMenuTrigger]')?.focus();
|
|
2329
|
+
}
|
|
2330
|
+
onDocumentClick(event) {
|
|
2331
|
+
if (!this.host.nativeElement.contains(event.target))
|
|
2332
|
+
this.close();
|
|
2333
|
+
}
|
|
2334
|
+
onPanelKeydown(event) {
|
|
2335
|
+
const items = this.items();
|
|
2336
|
+
const current = items.indexOf(this.host.nativeElement.ownerDocument.activeElement);
|
|
2337
|
+
let next = -1;
|
|
2338
|
+
if (event.key === 'ArrowDown')
|
|
2339
|
+
next = (current + 1) % items.length;
|
|
2340
|
+
else if (event.key === 'ArrowUp')
|
|
2341
|
+
next = (current - 1 + items.length) % items.length;
|
|
2342
|
+
else if (event.key === 'Home')
|
|
2343
|
+
next = 0;
|
|
2344
|
+
else if (event.key === 'End')
|
|
2345
|
+
next = items.length - 1;
|
|
2346
|
+
else if (event.key === 'Tab')
|
|
2347
|
+
this.close();
|
|
2348
|
+
if (next >= 0) {
|
|
2349
|
+
event.preventDefault();
|
|
2350
|
+
items[next]?.focus();
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
items() {
|
|
2354
|
+
return Array.from(this.host.nativeElement.querySelectorAll('.hu-menu__panel .hu-menu-item:not(:disabled)'));
|
|
2355
|
+
}
|
|
2356
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuMenu, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2357
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.25", type: HuMenu, isStandalone: true, selector: "hu-menu", inputs: { align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "document:click": "onDocumentClick($event)", "document:keydown.escape": "close(true)" }, classAttribute: "hu-menu" }, ngImport: i0, template: `
|
|
2358
|
+
<ng-content select="[huMenuTrigger]" />
|
|
2359
|
+
<div
|
|
2360
|
+
class="hu-menu__panel"
|
|
2361
|
+
role="menu"
|
|
2362
|
+
[id]="panelId"
|
|
2363
|
+
[attr.data-align]="align()"
|
|
2364
|
+
[hidden]="!isOpen()"
|
|
2365
|
+
(keydown)="onPanelKeydown($event)"
|
|
2366
|
+
>
|
|
2367
|
+
<ng-content />
|
|
2368
|
+
</div>
|
|
2369
|
+
`, isInline: true, styles: [".hu-menu{position:relative;display:inline-flex}.hu-menu__panel{position:absolute;top:calc(100% + 6px);z-index:1000;display:flex;flex-direction:column;min-width:var(--hu-menu-min-width, 12rem);padding:var(--hu-space-1);background:var(--hu-surface);border:1px solid var(--hu-border);border-radius:var(--hu-radius-lg);box-shadow:var(--hu-shadow-lg);animation:hu-menu-in .12s ease-out}.hu-menu__panel[hidden]{display:none}.hu-menu__panel[data-align=start]{left:0}.hu-menu__panel[data-align=end]{right:0}@keyframes hu-menu-in{0%{opacity:0;transform:translateY(-4px)}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2370
|
+
}
|
|
2371
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuMenu, decorators: [{
|
|
2372
|
+
type: Component,
|
|
2373
|
+
args: [{ selector: 'hu-menu', template: `
|
|
2374
|
+
<ng-content select="[huMenuTrigger]" />
|
|
2375
|
+
<div
|
|
2376
|
+
class="hu-menu__panel"
|
|
2377
|
+
role="menu"
|
|
2378
|
+
[id]="panelId"
|
|
2379
|
+
[attr.data-align]="align()"
|
|
2380
|
+
[hidden]="!isOpen()"
|
|
2381
|
+
(keydown)="onPanelKeydown($event)"
|
|
2382
|
+
>
|
|
2383
|
+
<ng-content />
|
|
2384
|
+
</div>
|
|
2385
|
+
`, host: {
|
|
2386
|
+
class: 'hu-menu',
|
|
2387
|
+
'(document:click)': 'onDocumentClick($event)',
|
|
2388
|
+
'(document:keydown.escape)': 'close(true)',
|
|
2389
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".hu-menu{position:relative;display:inline-flex}.hu-menu__panel{position:absolute;top:calc(100% + 6px);z-index:1000;display:flex;flex-direction:column;min-width:var(--hu-menu-min-width, 12rem);padding:var(--hu-space-1);background:var(--hu-surface);border:1px solid var(--hu-border);border-radius:var(--hu-radius-lg);box-shadow:var(--hu-shadow-lg);animation:hu-menu-in .12s ease-out}.hu-menu__panel[hidden]{display:none}.hu-menu__panel[data-align=start]{left:0}.hu-menu__panel[data-align=end]{right:0}@keyframes hu-menu-in{0%{opacity:0;transform:translateY(-4px)}}\n"] }]
|
|
2390
|
+
}] });
|
|
2391
|
+
class HuMenuTrigger {
|
|
2392
|
+
menu = inject(HuMenu);
|
|
2393
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuMenuTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2394
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuMenuTrigger, isStandalone: true, selector: "[huMenuTrigger]", host: { attributes: { "aria-haspopup": "menu" }, listeners: { "click": "menu.toggle()" }, properties: { "attr.aria-expanded": "menu.isOpen()", "attr.aria-controls": "menu.panelId" } }, ngImport: i0 });
|
|
2395
|
+
}
|
|
2396
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuMenuTrigger, decorators: [{
|
|
2397
|
+
type: Directive,
|
|
2398
|
+
args: [{
|
|
2399
|
+
selector: '[huMenuTrigger]',
|
|
2400
|
+
host: {
|
|
2401
|
+
'aria-haspopup': 'menu',
|
|
2402
|
+
'[attr.aria-expanded]': 'menu.isOpen()',
|
|
2403
|
+
'[attr.aria-controls]': 'menu.panelId',
|
|
2404
|
+
'(click)': 'menu.toggle()',
|
|
2405
|
+
},
|
|
2406
|
+
}]
|
|
2407
|
+
}] });
|
|
2408
|
+
class HuMenuItem {
|
|
2409
|
+
menu = inject(HuMenu);
|
|
2410
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuMenuItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2411
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuMenuItem, isStandalone: true, selector: "[huMenuItem]", host: { attributes: { "role": "menuitem", "tabindex": "-1" }, listeners: { "click": "menu.close()" }, classAttribute: "hu-menu-item" }, ngImport: i0 });
|
|
2412
|
+
}
|
|
2413
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuMenuItem, decorators: [{
|
|
2414
|
+
type: Directive,
|
|
2415
|
+
args: [{
|
|
2416
|
+
selector: '[huMenuItem]',
|
|
2417
|
+
host: {
|
|
2418
|
+
class: 'hu-menu-item',
|
|
2419
|
+
role: 'menuitem',
|
|
2420
|
+
tabindex: '-1',
|
|
2421
|
+
'(click)': 'menu.close()',
|
|
2422
|
+
},
|
|
2423
|
+
}]
|
|
2424
|
+
}] });
|
|
2425
|
+
|
|
2426
|
+
/** Yan menü navigasyonu. Genellikle `hu-shell` içinde otomatik kullanılır. */
|
|
2427
|
+
class HuSidebarNav {
|
|
2428
|
+
router = inject(Router);
|
|
2429
|
+
groups = input([]);
|
|
2430
|
+
collapsed = input(false, { transform: booleanAttribute });
|
|
2431
|
+
/** Bir linke tıklandı (mobilde menüyü kapatmak için). */
|
|
2432
|
+
navigate = output();
|
|
2433
|
+
/** Daraltılmış moddayken alt menülü öğeye tıklandı. */
|
|
2434
|
+
expandRequest = output();
|
|
2435
|
+
url = toSignal(this.router.events.pipe(filter((e) => e instanceof NavigationEnd), map((e) => e.urlAfterRedirects)), { initialValue: this.router.url });
|
|
2436
|
+
openItems = signal(new Set());
|
|
2437
|
+
constructor() {
|
|
2438
|
+
// Aktif alt sayfanın grubu otomatik açılsın.
|
|
2439
|
+
effect(() => {
|
|
2440
|
+
const url = this.url();
|
|
2441
|
+
const parents = this.groups()
|
|
2442
|
+
.flatMap((g) => g.items)
|
|
2443
|
+
.filter((item) => this.isParentActive(item, url));
|
|
2444
|
+
if (parents.length) {
|
|
2445
|
+
untracked(() => this.openItems.update((set) => new Set([...set, ...parents])));
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
isParentActive(item, url = this.url()) {
|
|
2450
|
+
const path = url.split(/[?#]/)[0];
|
|
2451
|
+
return !!item.children?.some((c) => c.link && (path === c.link || path.startsWith(c.link + '/')));
|
|
2452
|
+
}
|
|
2453
|
+
toggle(item) {
|
|
2454
|
+
if (this.collapsed()) {
|
|
2455
|
+
this.expandRequest.emit();
|
|
2456
|
+
this.openItems.update((set) => new Set([...set, item]));
|
|
2457
|
+
return;
|
|
2458
|
+
}
|
|
2459
|
+
this.openItems.update((set) => {
|
|
2460
|
+
const next = new Set(set);
|
|
2461
|
+
if (next.has(item))
|
|
2462
|
+
next.delete(item);
|
|
2463
|
+
else
|
|
2464
|
+
next.add(item);
|
|
2465
|
+
return next;
|
|
2466
|
+
});
|
|
2467
|
+
}
|
|
2468
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSidebarNav, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2469
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuSidebarNav, isStandalone: true, selector: "hu-sidebar-nav", inputs: { groups: { classPropertyName: "groups", publicName: "groups", isSignal: true, isRequired: false, transformFunction: null }, collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { navigate: "navigate", expandRequest: "expandRequest" }, host: { properties: { "class.hu-nav--collapsed": "collapsed()" }, classAttribute: "hu-nav" }, ngImport: i0, template: "@for (group of groups(); track $index) {\n <div class=\"hu-nav__group\">\n @if (group.title) {\n <div class=\"hu-nav__title\">{{ group.title }}</div>\n }\n <ul class=\"hu-nav__list\">\n @for (item of group.items; track item.label) {\n <li>\n @if (item.children?.length) {\n @let open = openItems().has(item) && !collapsed();\n <button\n type=\"button\"\n class=\"hu-nav__link\"\n [class.hu-nav__link--parent-active]=\"isParentActive(item)\"\n [attr.aria-expanded]=\"open\"\n [attr.title]=\"collapsed() ? item.label : null\"\n (click)=\"toggle(item)\"\n >\n @if (item.icon) {\n <hu-icon class=\"hu-nav__icon\" [name]=\"item.icon\" [size]=\"18\" />\n }\n <span class=\"hu-nav__label\">{{ item.label }}</span>\n <hu-icon class=\"hu-nav__chevron\" name=\"chevron-down\" [size]=\"16\" />\n </button>\n @if (open) {\n <ul class=\"hu-nav__sublist\">\n @for (child of item.children; track child.label) {\n <li>\n <a\n class=\"hu-nav__link hu-nav__link--sub\"\n [routerLink]=\"child.link\"\n routerLinkActive=\"hu-nav__link--active\"\n [routerLinkActiveOptions]=\"{ exact: child.exact ?? false }\"\n ariaCurrentWhenActive=\"page\"\n (click)=\"navigate.emit()\"\n >\n <span class=\"hu-nav__label\">{{ child.label }}</span>\n @if (child.badge != null) {\n <span class=\"hu-nav__badge\">{{ child.badge }}</span>\n }\n </a>\n </li>\n }\n </ul>\n }\n } @else {\n <a\n class=\"hu-nav__link\"\n [routerLink]=\"item.link\"\n routerLinkActive=\"hu-nav__link--active\"\n [routerLinkActiveOptions]=\"{ exact: item.exact ?? false }\"\n ariaCurrentWhenActive=\"page\"\n [attr.title]=\"collapsed() ? item.label : null\"\n (click)=\"navigate.emit()\"\n >\n @if (item.icon) {\n <hu-icon class=\"hu-nav__icon\" [name]=\"item.icon\" [size]=\"18\" />\n }\n <span class=\"hu-nav__label\">{{ item.label }}</span>\n @if (item.badge != null) {\n <span class=\"hu-nav__badge\">{{ item.badge }}</span>\n }\n </a>\n }\n </li>\n }\n </ul>\n </div>\n}\n", dependencies: [{ kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: ["routerLinkActiveOptions", "ariaCurrentWhenActive", "routerLinkActive"], outputs: ["isActiveChange"], exportAs: ["routerLinkActive"] }, { kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2470
|
+
}
|
|
2471
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSidebarNav, decorators: [{
|
|
2472
|
+
type: Component,
|
|
2473
|
+
args: [{ selector: 'hu-sidebar-nav', imports: [RouterLink, RouterLinkActive, HuIcon], host: { class: 'hu-nav', '[class.hu-nav--collapsed]': 'collapsed()' }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "@for (group of groups(); track $index) {\n <div class=\"hu-nav__group\">\n @if (group.title) {\n <div class=\"hu-nav__title\">{{ group.title }}</div>\n }\n <ul class=\"hu-nav__list\">\n @for (item of group.items; track item.label) {\n <li>\n @if (item.children?.length) {\n @let open = openItems().has(item) && !collapsed();\n <button\n type=\"button\"\n class=\"hu-nav__link\"\n [class.hu-nav__link--parent-active]=\"isParentActive(item)\"\n [attr.aria-expanded]=\"open\"\n [attr.title]=\"collapsed() ? item.label : null\"\n (click)=\"toggle(item)\"\n >\n @if (item.icon) {\n <hu-icon class=\"hu-nav__icon\" [name]=\"item.icon\" [size]=\"18\" />\n }\n <span class=\"hu-nav__label\">{{ item.label }}</span>\n <hu-icon class=\"hu-nav__chevron\" name=\"chevron-down\" [size]=\"16\" />\n </button>\n @if (open) {\n <ul class=\"hu-nav__sublist\">\n @for (child of item.children; track child.label) {\n <li>\n <a\n class=\"hu-nav__link hu-nav__link--sub\"\n [routerLink]=\"child.link\"\n routerLinkActive=\"hu-nav__link--active\"\n [routerLinkActiveOptions]=\"{ exact: child.exact ?? false }\"\n ariaCurrentWhenActive=\"page\"\n (click)=\"navigate.emit()\"\n >\n <span class=\"hu-nav__label\">{{ child.label }}</span>\n @if (child.badge != null) {\n <span class=\"hu-nav__badge\">{{ child.badge }}</span>\n }\n </a>\n </li>\n }\n </ul>\n }\n } @else {\n <a\n class=\"hu-nav__link\"\n [routerLink]=\"item.link\"\n routerLinkActive=\"hu-nav__link--active\"\n [routerLinkActiveOptions]=\"{ exact: item.exact ?? false }\"\n ariaCurrentWhenActive=\"page\"\n [attr.title]=\"collapsed() ? item.label : null\"\n (click)=\"navigate.emit()\"\n >\n @if (item.icon) {\n <hu-icon class=\"hu-nav__icon\" [name]=\"item.icon\" [size]=\"18\" />\n }\n <span class=\"hu-nav__label\">{{ item.label }}</span>\n @if (item.badge != null) {\n <span class=\"hu-nav__badge\">{{ item.badge }}</span>\n }\n </a>\n }\n </li>\n }\n </ul>\n </div>\n}\n" }]
|
|
2474
|
+
}], ctorParameters: () => [] });
|
|
2475
|
+
|
|
2476
|
+
/** Topbar'ın sol tarafı (breadcrumb, arama vb.). */
|
|
2477
|
+
class HuTopbarStart {
|
|
2478
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTopbarStart, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2479
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuTopbarStart, isStandalone: true, selector: "[huTopbarStart]", host: { classAttribute: "hu-shell__topbar-start" }, ngImport: i0 });
|
|
2480
|
+
}
|
|
2481
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTopbarStart, decorators: [{
|
|
2482
|
+
type: Directive,
|
|
2483
|
+
args: [{ selector: '[huTopbarStart]', host: { class: 'hu-shell__topbar-start' } }]
|
|
2484
|
+
}] });
|
|
2485
|
+
/** Topbar'ın sağ tarafı (tema, bildirim, kullanıcı menüsü). */
|
|
2486
|
+
class HuTopbarEnd {
|
|
2487
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTopbarEnd, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2488
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuTopbarEnd, isStandalone: true, selector: "[huTopbarEnd]", host: { classAttribute: "hu-shell__topbar-end" }, ngImport: i0 });
|
|
2489
|
+
}
|
|
2490
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuTopbarEnd, decorators: [{
|
|
2491
|
+
type: Directive,
|
|
2492
|
+
args: [{ selector: '[huTopbarEnd]', host: { class: 'hu-shell__topbar-end' } }]
|
|
2493
|
+
}] });
|
|
2494
|
+
/** Sidebar'ın alt kısmı. */
|
|
2495
|
+
class HuSidebarFooter {
|
|
2496
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSidebarFooter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2497
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuSidebarFooter, isStandalone: true, selector: "[huSidebarFooter]", host: { classAttribute: "hu-shell__sidebar-footer" }, ngImport: i0 });
|
|
2498
|
+
}
|
|
2499
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuSidebarFooter, decorators: [{
|
|
2500
|
+
type: Directive,
|
|
2501
|
+
args: [{ selector: '[huSidebarFooter]', host: { class: 'hu-shell__sidebar-footer' } }]
|
|
2502
|
+
}] });
|
|
2503
|
+
/** Marka alanında varsayılan logonun yerine geçer. */
|
|
2504
|
+
class HuShellLogo {
|
|
2505
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuShellLogo, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2506
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.25", type: HuShellLogo, isStandalone: true, selector: "[huShellLogo]", host: { classAttribute: "hu-shell__logo" }, ngImport: i0 });
|
|
2507
|
+
}
|
|
2508
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuShellLogo, decorators: [{
|
|
2509
|
+
type: Directive,
|
|
2510
|
+
args: [{ selector: '[huShellLogo]', host: { class: 'hu-shell__logo' } }]
|
|
2511
|
+
}] });
|
|
2512
|
+
const COLLAPSED_KEY = 'hu-shell-collapsed';
|
|
2513
|
+
/**
|
|
2514
|
+
* Admin uygulama iskeleti: daraltılabilir sidebar, mobilde çekmece menü, topbar.
|
|
2515
|
+
*
|
|
2516
|
+
* @example
|
|
2517
|
+
* <hu-shell [nav]="nav" brand="Yönetim Paneli" brandSubtitle="Kurum adı">
|
|
2518
|
+
* <hu-breadcrumb huTopbarStart [items]="crumbs()" />
|
|
2519
|
+
* <div huTopbarEnd><hu-theme-toggle /></div>
|
|
2520
|
+
* <router-outlet />
|
|
2521
|
+
* </hu-shell>
|
|
2522
|
+
*/
|
|
2523
|
+
class HuShell {
|
|
2524
|
+
storage = inject(DOCUMENT).defaultView?.localStorage;
|
|
2525
|
+
nav = input([]);
|
|
2526
|
+
brand = input('');
|
|
2527
|
+
brandSubtitle = input();
|
|
2528
|
+
brandLink = input('/');
|
|
2529
|
+
/** Sidebar rengi. `dark`, açık temada da koyu sidebar kullanır. */
|
|
2530
|
+
sidebarTheme = input('default');
|
|
2531
|
+
/** Masaüstünde sidebar daraltılmış mı? Tercih localStorage'da saklanır. */
|
|
2532
|
+
collapsed = model(this.readCollapsed());
|
|
2533
|
+
isMobile = huMediaQuery('(max-width: 1023.98px)');
|
|
2534
|
+
mobileOpen = signal(false);
|
|
2535
|
+
isCollapsed = computed(() => !this.isMobile() && this.collapsed());
|
|
2536
|
+
constructor() {
|
|
2537
|
+
inject(Router)
|
|
2538
|
+
.events.pipe(filter((e) => e instanceof NavigationEnd), takeUntilDestroyed())
|
|
2539
|
+
.subscribe(() => this.mobileOpen.set(false));
|
|
2540
|
+
effect(() => {
|
|
2541
|
+
try {
|
|
2542
|
+
this.storage?.setItem(COLLAPSED_KEY, String(this.collapsed()));
|
|
2543
|
+
}
|
|
2544
|
+
catch {
|
|
2545
|
+
// yok say
|
|
2546
|
+
}
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
toggleSidebar() {
|
|
2550
|
+
if (this.isMobile())
|
|
2551
|
+
this.mobileOpen.update((v) => !v);
|
|
2552
|
+
else
|
|
2553
|
+
this.collapsed.update((v) => !v);
|
|
2554
|
+
}
|
|
2555
|
+
readCollapsed() {
|
|
2556
|
+
try {
|
|
2557
|
+
return this.storage?.getItem(COLLAPSED_KEY) === 'true';
|
|
2558
|
+
}
|
|
2559
|
+
catch {
|
|
2560
|
+
return false;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuShell, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2564
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: HuShell, isStandalone: true, selector: "hu-shell", inputs: { nav: { classPropertyName: "nav", publicName: "nav", isSignal: true, isRequired: false, transformFunction: null }, brand: { classPropertyName: "brand", publicName: "brand", isSignal: true, isRequired: false, transformFunction: null }, brandSubtitle: { classPropertyName: "brandSubtitle", publicName: "brandSubtitle", isSignal: true, isRequired: false, transformFunction: null }, brandLink: { classPropertyName: "brandLink", publicName: "brandLink", isSignal: true, isRequired: false, transformFunction: null }, sidebarTheme: { classPropertyName: "sidebarTheme", publicName: "sidebarTheme", isSignal: true, isRequired: false, transformFunction: null }, collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { collapsed: "collapsedChange" }, host: { listeners: { "document:keydown.escape": "mobileOpen.set(false)" }, properties: { "class.hu-shell--collapsed": "isCollapsed()", "class.hu-shell--mobile": "isMobile()", "class.hu-shell--drawer-open": "isMobile() && mobileOpen()" }, classAttribute: "hu-shell" }, ngImport: i0, template: "<a class=\"hu-shell__skip\" href=\"#hu-main\">\u0130\u00E7eri\u011Fe ge\u00E7</a>\n\n<aside\n class=\"hu-shell__sidebar\"\n [class.hu-shell__sidebar--dark]=\"sidebarTheme() === 'dark'\"\n [attr.aria-hidden]=\"isMobile() && !mobileOpen() ? 'true' : null\"\n [attr.inert]=\"isMobile() && !mobileOpen() ? '' : null\"\n>\n <a class=\"hu-shell__brand\" [routerLink]=\"brandLink()\">\n <ng-content select=\"[huShellLogo]\">\n <span class=\"hu-shell__logo hu-shell__logo--default\">\n <hu-icon name=\"graduation-cap\" [size]=\"20\" />\n </span>\n </ng-content>\n <span class=\"hu-shell__brand-text\">\n <span class=\"hu-shell__brand-name\">{{ brand() }}</span>\n @if (brandSubtitle()) {\n <span class=\"hu-shell__brand-subtitle\">{{ brandSubtitle() }}</span>\n }\n </span>\n </a>\n\n <nav class=\"hu-shell__nav\" aria-label=\"Ana men\u00FC\">\n <hu-sidebar-nav\n [groups]=\"nav()\"\n [collapsed]=\"isCollapsed()\"\n (navigate)=\"mobileOpen.set(false)\"\n (expandRequest)=\"collapsed.set(false)\"\n />\n </nav>\n\n <ng-content select=\"[huSidebarFooter]\" />\n\n @if (!isMobile()) {\n <button\n type=\"button\"\n class=\"hu-shell__collapse\"\n [attr.aria-label]=\"isCollapsed() ? 'Men\u00FCy\u00FC geni\u015Flet' : 'Men\u00FCy\u00FC daralt'\"\n [attr.title]=\"isCollapsed() ? 'Men\u00FCy\u00FC geni\u015Flet' : 'Men\u00FCy\u00FC daralt'\"\n (click)=\"toggleSidebar()\"\n >\n <hu-icon [name]=\"isCollapsed() ? 'chevrons-right' : 'chevrons-left'\" [size]=\"16\" />\n <span class=\"hu-nav__label\">Daralt</span>\n </button>\n }\n</aside>\n\n@if (isMobile() && mobileOpen()) {\n <div class=\"hu-shell__backdrop\" aria-hidden=\"true\" (click)=\"mobileOpen.set(false)\"></div>\n}\n\n<div class=\"hu-shell__main\">\n <header class=\"hu-shell__topbar\">\n @if (isMobile()) {\n <button\n hu-button\n variant=\"ghost\"\n iconOnly\n class=\"hu-shell__menu-toggle\"\n aria-label=\"Men\u00FCy\u00FC a\u00E7\"\n [attr.aria-expanded]=\"mobileOpen()\"\n (click)=\"toggleSidebar()\"\n >\n <hu-icon name=\"menu\" [size]=\"20\" />\n </button>\n }\n <ng-content select=\"[huTopbarStart]\" />\n <span class=\"hu-shell__spacer\"></span>\n <ng-content select=\"[huTopbarEnd]\" />\n </header>\n\n <main class=\"hu-shell__content\" id=\"hu-main\" tabindex=\"-1\">\n <ng-content />\n </main>\n</div>\n", styles: [".hu-shell{--_sidebar-w: var(--hu-sidebar-width);display:block;min-height:100dvh}.hu-shell--collapsed{--_sidebar-w: var(--hu-sidebar-collapsed-width)}.hu-shell__skip{position:fixed;top:var(--hu-space-2);left:var(--hu-space-2);z-index:1200;padding:var(--hu-space-2) var(--hu-space-4);color:var(--hu-primary-fg);background:var(--hu-primary);border-radius:var(--hu-radius-md);transform:translateY(-200%)}.hu-shell__skip:focus{transform:none}.hu-shell__sidebar{position:fixed;inset:0 auto 0 0;z-index:900;display:flex;flex-direction:column;width:var(--_sidebar-w);color:var(--hu-sidebar-fg);background:var(--hu-sidebar-bg);border-right:1px solid var(--hu-sidebar-border);transition:width .2s cubic-bezier(.4,0,.2,1),transform .25s cubic-bezier(.4,0,.2,1)}.hu-shell__sidebar--dark{--hu-sidebar-bg: var(--hu-gray-900);--hu-sidebar-fg: var(--hu-gray-300);--hu-sidebar-muted: var(--hu-gray-500);--hu-sidebar-hover: var(--hu-gray-800);--hu-sidebar-active-bg: color-mix(in srgb, var(--hu-red-500) 20%, transparent);--hu-sidebar-active-fg: #fff;--hu-sidebar-border: var(--hu-gray-800)}.hu-shell__brand{display:flex;align-items:center;gap:var(--hu-space-3);height:var(--hu-topbar-height);padding:0 var(--hu-space-4);color:inherit;text-decoration:none;border-bottom:1px solid var(--hu-sidebar-border);overflow:hidden;flex-shrink:0}.hu-shell__logo{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2.25rem;height:2.25rem}.hu-shell__logo--default{color:#fff;background:var(--hu-red-600);border-radius:var(--hu-radius-md)}.hu-shell__brand-text{display:flex;flex-direction:column;min-width:0;line-height:1.2;white-space:nowrap}.hu-shell__brand-name{font-size:.9375rem;font-weight:700;color:var(--hu-text)}.hu-shell__sidebar--dark .hu-shell__brand-name{color:#fff}.hu-shell__brand-subtitle{font-size:var(--hu-text-xs);color:var(--hu-sidebar-muted);overflow:hidden;text-overflow:ellipsis}.hu-shell__nav{flex:1;padding:var(--hu-space-3);overflow-x:hidden;overflow-y:auto;scrollbar-width:thin}.hu-shell__sidebar-footer{padding:var(--hu-space-3);border-top:1px solid var(--hu-sidebar-border)}.hu-shell__collapse{display:flex;align-items:center;gap:var(--hu-space-3);height:2.75rem;padding:0 calc(var(--hu-space-3) + var(--hu-space-3) + 1px);font:inherit;font-size:var(--hu-text-sm);color:var(--hu-sidebar-muted);text-align:left;background:none;border:0;border-top:1px solid var(--hu-sidebar-border);cursor:pointer;flex-shrink:0}.hu-shell__collapse:hover{color:var(--hu-sidebar-fg);background:var(--hu-sidebar-hover)}.hu-shell--collapsed .hu-shell__brand{padding:0 calc((var(--hu-sidebar-collapsed-width) - 2.25rem) / 2)}.hu-shell--collapsed .hu-shell__brand-text,.hu-shell--collapsed .hu-shell__collapse .hu-nav__label{display:none}.hu-shell--collapsed .hu-shell__collapse{justify-content:center;padding:0}.hu-shell__main{display:flex;flex-direction:column;min-height:100dvh;margin-left:var(--_sidebar-w);transition:margin-left .2s cubic-bezier(.4,0,.2,1)}.hu-shell__topbar{position:sticky;top:0;z-index:800;display:flex;align-items:center;gap:var(--hu-space-3);height:var(--hu-topbar-height);padding:0 var(--hu-space-6);background:color-mix(in srgb,var(--hu-surface) 85%,transparent);border-bottom:1px solid var(--hu-border);backdrop-filter:saturate(180%) blur(8px)}.hu-shell__topbar-start{display:flex;align-items:center;gap:var(--hu-space-3);min-width:0}.hu-shell__spacer{flex:1}.hu-shell__topbar-end{display:flex;align-items:center;gap:var(--hu-space-1);flex-shrink:0}.hu-shell__content{flex:1;width:100%;max-width:var(--hu-content-max-width);margin:0 auto;padding:var(--hu-space-6)}.hu-shell__content:focus{outline:none}.hu-shell--mobile .hu-shell__sidebar{width:min(var(--hu-sidebar-width),85vw);box-shadow:var(--hu-shadow-lg);transform:translate(-100%)}.hu-shell--mobile.hu-shell--drawer-open .hu-shell__sidebar{transform:none}.hu-shell--mobile .hu-shell__main{margin-left:0}.hu-shell--mobile .hu-shell__topbar{padding:0 var(--hu-space-3)}.hu-shell--mobile .hu-shell__content{padding:var(--hu-space-4)}.hu-shell__backdrop{position:fixed;inset:0;z-index:850;background:#0c0c0e73;animation:hu-fade-in .2s ease-out}.hu-nav{display:flex;flex-direction:column;gap:var(--hu-space-4)}.hu-nav__title{padding:0 var(--hu-space-3) var(--hu-space-2);font-size:.6875rem;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--hu-sidebar-muted);white-space:nowrap}.hu-nav__list,.hu-nav__sublist{display:flex;flex-direction:column;gap:2px;margin:0;padding:0;list-style:none}.hu-nav__sublist{margin:2px 0 var(--hu-space-1) calc(var(--hu-space-3) + 9px);padding-left:var(--hu-space-3);border-left:1px solid var(--hu-sidebar-border)}.hu-nav__link{position:relative;display:flex;align-items:center;gap:var(--hu-space-3);width:100%;height:2.375rem;padding:0 var(--hu-space-3);font:inherit;font-size:var(--hu-text-sm);font-weight:500;color:var(--hu-sidebar-fg);text-align:left;text-decoration:none;white-space:nowrap;background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer;transition:background-color var(--hu-transition),color var(--hu-transition)}.hu-nav__link:hover{background:var(--hu-sidebar-hover)}.hu-nav__link:focus-visible{outline:2px solid var(--hu-focus);outline-offset:-2px}.hu-nav__link--sub{height:2.125rem;font-weight:400}.hu-nav__link--active,.hu-nav__link--active:hover{color:var(--hu-sidebar-active-fg);background:var(--hu-sidebar-active-bg)}.hu-nav__link--active .hu-nav__icon,.hu-nav__link--active:hover .hu-nav__icon{color:var(--hu-primary)}.hu-nav__link--active:not(.hu-nav__link--sub):before{content:\"\";position:absolute;top:8px;bottom:8px;left:calc(var(--hu-space-3) * -1);width:3px;background:var(--hu-primary);border-radius:0 3px 3px 0}.hu-nav__link--parent-active{color:var(--hu-text)}.hu-shell__sidebar--dark .hu-nav__link--parent-active{color:#fff}.hu-nav__link--parent-active .hu-nav__icon{color:var(--hu-primary)}.hu-nav__icon{color:var(--hu-sidebar-muted);transition:color var(--hu-transition)}.hu-nav__label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}.hu-nav__chevron{color:var(--hu-sidebar-muted);transition:transform var(--hu-transition)}[aria-expanded=true]>.hu-nav__chevron{transform:rotate(180deg)}.hu-nav__badge{min-width:1.25rem;height:1.25rem;padding:0 .375rem;font-size:.6875rem;font-weight:600;line-height:1.25rem;text-align:center;color:var(--hu-primary-fg);background:var(--hu-primary);border-radius:var(--hu-radius-full)}.hu-nav--collapsed .hu-nav__title{height:1px;margin:0 var(--hu-space-2) var(--hu-space-2);padding:0;overflow:hidden;color:transparent;background:var(--hu-sidebar-border)}.hu-nav--collapsed .hu-nav__link{justify-content:center;padding:0}.hu-nav--collapsed .hu-nav__label,.hu-nav--collapsed .hu-nav__chevron{display:none}.hu-nav--collapsed .hu-nav__badge{position:absolute;top:3px;right:6px;min-width:.5rem;width:.5rem;height:.5rem;padding:0;font-size:0}@keyframes hu-fade-in{0%{opacity:0}}\n"], dependencies: [{ kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: HuButton, selector: "button[hu-button], a[hu-button]", inputs: ["variant", "color", "size", "disabled", "loading", "block", "iconOnly", "pill"] }, { kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }, { kind: "component", type: HuSidebarNav, selector: "hu-sidebar-nav", inputs: ["groups", "collapsed"], outputs: ["navigate", "expandRequest"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2565
|
+
}
|
|
2566
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuShell, decorators: [{
|
|
2567
|
+
type: Component,
|
|
2568
|
+
args: [{ selector: 'hu-shell', imports: [RouterLink, HuButton, HuIcon, HuSidebarNav], host: {
|
|
2569
|
+
class: 'hu-shell',
|
|
2570
|
+
'[class.hu-shell--collapsed]': 'isCollapsed()',
|
|
2571
|
+
'[class.hu-shell--mobile]': 'isMobile()',
|
|
2572
|
+
'[class.hu-shell--drawer-open]': 'isMobile() && mobileOpen()',
|
|
2573
|
+
'(document:keydown.escape)': 'mobileOpen.set(false)',
|
|
2574
|
+
}, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<a class=\"hu-shell__skip\" href=\"#hu-main\">\u0130\u00E7eri\u011Fe ge\u00E7</a>\n\n<aside\n class=\"hu-shell__sidebar\"\n [class.hu-shell__sidebar--dark]=\"sidebarTheme() === 'dark'\"\n [attr.aria-hidden]=\"isMobile() && !mobileOpen() ? 'true' : null\"\n [attr.inert]=\"isMobile() && !mobileOpen() ? '' : null\"\n>\n <a class=\"hu-shell__brand\" [routerLink]=\"brandLink()\">\n <ng-content select=\"[huShellLogo]\">\n <span class=\"hu-shell__logo hu-shell__logo--default\">\n <hu-icon name=\"graduation-cap\" [size]=\"20\" />\n </span>\n </ng-content>\n <span class=\"hu-shell__brand-text\">\n <span class=\"hu-shell__brand-name\">{{ brand() }}</span>\n @if (brandSubtitle()) {\n <span class=\"hu-shell__brand-subtitle\">{{ brandSubtitle() }}</span>\n }\n </span>\n </a>\n\n <nav class=\"hu-shell__nav\" aria-label=\"Ana men\u00FC\">\n <hu-sidebar-nav\n [groups]=\"nav()\"\n [collapsed]=\"isCollapsed()\"\n (navigate)=\"mobileOpen.set(false)\"\n (expandRequest)=\"collapsed.set(false)\"\n />\n </nav>\n\n <ng-content select=\"[huSidebarFooter]\" />\n\n @if (!isMobile()) {\n <button\n type=\"button\"\n class=\"hu-shell__collapse\"\n [attr.aria-label]=\"isCollapsed() ? 'Men\u00FCy\u00FC geni\u015Flet' : 'Men\u00FCy\u00FC daralt'\"\n [attr.title]=\"isCollapsed() ? 'Men\u00FCy\u00FC geni\u015Flet' : 'Men\u00FCy\u00FC daralt'\"\n (click)=\"toggleSidebar()\"\n >\n <hu-icon [name]=\"isCollapsed() ? 'chevrons-right' : 'chevrons-left'\" [size]=\"16\" />\n <span class=\"hu-nav__label\">Daralt</span>\n </button>\n }\n</aside>\n\n@if (isMobile() && mobileOpen()) {\n <div class=\"hu-shell__backdrop\" aria-hidden=\"true\" (click)=\"mobileOpen.set(false)\"></div>\n}\n\n<div class=\"hu-shell__main\">\n <header class=\"hu-shell__topbar\">\n @if (isMobile()) {\n <button\n hu-button\n variant=\"ghost\"\n iconOnly\n class=\"hu-shell__menu-toggle\"\n aria-label=\"Men\u00FCy\u00FC a\u00E7\"\n [attr.aria-expanded]=\"mobileOpen()\"\n (click)=\"toggleSidebar()\"\n >\n <hu-icon name=\"menu\" [size]=\"20\" />\n </button>\n }\n <ng-content select=\"[huTopbarStart]\" />\n <span class=\"hu-shell__spacer\"></span>\n <ng-content select=\"[huTopbarEnd]\" />\n </header>\n\n <main class=\"hu-shell__content\" id=\"hu-main\" tabindex=\"-1\">\n <ng-content />\n </main>\n</div>\n", styles: [".hu-shell{--_sidebar-w: var(--hu-sidebar-width);display:block;min-height:100dvh}.hu-shell--collapsed{--_sidebar-w: var(--hu-sidebar-collapsed-width)}.hu-shell__skip{position:fixed;top:var(--hu-space-2);left:var(--hu-space-2);z-index:1200;padding:var(--hu-space-2) var(--hu-space-4);color:var(--hu-primary-fg);background:var(--hu-primary);border-radius:var(--hu-radius-md);transform:translateY(-200%)}.hu-shell__skip:focus{transform:none}.hu-shell__sidebar{position:fixed;inset:0 auto 0 0;z-index:900;display:flex;flex-direction:column;width:var(--_sidebar-w);color:var(--hu-sidebar-fg);background:var(--hu-sidebar-bg);border-right:1px solid var(--hu-sidebar-border);transition:width .2s cubic-bezier(.4,0,.2,1),transform .25s cubic-bezier(.4,0,.2,1)}.hu-shell__sidebar--dark{--hu-sidebar-bg: var(--hu-gray-900);--hu-sidebar-fg: var(--hu-gray-300);--hu-sidebar-muted: var(--hu-gray-500);--hu-sidebar-hover: var(--hu-gray-800);--hu-sidebar-active-bg: color-mix(in srgb, var(--hu-red-500) 20%, transparent);--hu-sidebar-active-fg: #fff;--hu-sidebar-border: var(--hu-gray-800)}.hu-shell__brand{display:flex;align-items:center;gap:var(--hu-space-3);height:var(--hu-topbar-height);padding:0 var(--hu-space-4);color:inherit;text-decoration:none;border-bottom:1px solid var(--hu-sidebar-border);overflow:hidden;flex-shrink:0}.hu-shell__logo{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:2.25rem;height:2.25rem}.hu-shell__logo--default{color:#fff;background:var(--hu-red-600);border-radius:var(--hu-radius-md)}.hu-shell__brand-text{display:flex;flex-direction:column;min-width:0;line-height:1.2;white-space:nowrap}.hu-shell__brand-name{font-size:.9375rem;font-weight:700;color:var(--hu-text)}.hu-shell__sidebar--dark .hu-shell__brand-name{color:#fff}.hu-shell__brand-subtitle{font-size:var(--hu-text-xs);color:var(--hu-sidebar-muted);overflow:hidden;text-overflow:ellipsis}.hu-shell__nav{flex:1;padding:var(--hu-space-3);overflow-x:hidden;overflow-y:auto;scrollbar-width:thin}.hu-shell__sidebar-footer{padding:var(--hu-space-3);border-top:1px solid var(--hu-sidebar-border)}.hu-shell__collapse{display:flex;align-items:center;gap:var(--hu-space-3);height:2.75rem;padding:0 calc(var(--hu-space-3) + var(--hu-space-3) + 1px);font:inherit;font-size:var(--hu-text-sm);color:var(--hu-sidebar-muted);text-align:left;background:none;border:0;border-top:1px solid var(--hu-sidebar-border);cursor:pointer;flex-shrink:0}.hu-shell__collapse:hover{color:var(--hu-sidebar-fg);background:var(--hu-sidebar-hover)}.hu-shell--collapsed .hu-shell__brand{padding:0 calc((var(--hu-sidebar-collapsed-width) - 2.25rem) / 2)}.hu-shell--collapsed .hu-shell__brand-text,.hu-shell--collapsed .hu-shell__collapse .hu-nav__label{display:none}.hu-shell--collapsed .hu-shell__collapse{justify-content:center;padding:0}.hu-shell__main{display:flex;flex-direction:column;min-height:100dvh;margin-left:var(--_sidebar-w);transition:margin-left .2s cubic-bezier(.4,0,.2,1)}.hu-shell__topbar{position:sticky;top:0;z-index:800;display:flex;align-items:center;gap:var(--hu-space-3);height:var(--hu-topbar-height);padding:0 var(--hu-space-6);background:color-mix(in srgb,var(--hu-surface) 85%,transparent);border-bottom:1px solid var(--hu-border);backdrop-filter:saturate(180%) blur(8px)}.hu-shell__topbar-start{display:flex;align-items:center;gap:var(--hu-space-3);min-width:0}.hu-shell__spacer{flex:1}.hu-shell__topbar-end{display:flex;align-items:center;gap:var(--hu-space-1);flex-shrink:0}.hu-shell__content{flex:1;width:100%;max-width:var(--hu-content-max-width);margin:0 auto;padding:var(--hu-space-6)}.hu-shell__content:focus{outline:none}.hu-shell--mobile .hu-shell__sidebar{width:min(var(--hu-sidebar-width),85vw);box-shadow:var(--hu-shadow-lg);transform:translate(-100%)}.hu-shell--mobile.hu-shell--drawer-open .hu-shell__sidebar{transform:none}.hu-shell--mobile .hu-shell__main{margin-left:0}.hu-shell--mobile .hu-shell__topbar{padding:0 var(--hu-space-3)}.hu-shell--mobile .hu-shell__content{padding:var(--hu-space-4)}.hu-shell__backdrop{position:fixed;inset:0;z-index:850;background:#0c0c0e73;animation:hu-fade-in .2s ease-out}.hu-nav{display:flex;flex-direction:column;gap:var(--hu-space-4)}.hu-nav__title{padding:0 var(--hu-space-3) var(--hu-space-2);font-size:.6875rem;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--hu-sidebar-muted);white-space:nowrap}.hu-nav__list,.hu-nav__sublist{display:flex;flex-direction:column;gap:2px;margin:0;padding:0;list-style:none}.hu-nav__sublist{margin:2px 0 var(--hu-space-1) calc(var(--hu-space-3) + 9px);padding-left:var(--hu-space-3);border-left:1px solid var(--hu-sidebar-border)}.hu-nav__link{position:relative;display:flex;align-items:center;gap:var(--hu-space-3);width:100%;height:2.375rem;padding:0 var(--hu-space-3);font:inherit;font-size:var(--hu-text-sm);font-weight:500;color:var(--hu-sidebar-fg);text-align:left;text-decoration:none;white-space:nowrap;background:none;border:0;border-radius:var(--hu-radius-md);cursor:pointer;transition:background-color var(--hu-transition),color var(--hu-transition)}.hu-nav__link:hover{background:var(--hu-sidebar-hover)}.hu-nav__link:focus-visible{outline:2px solid var(--hu-focus);outline-offset:-2px}.hu-nav__link--sub{height:2.125rem;font-weight:400}.hu-nav__link--active,.hu-nav__link--active:hover{color:var(--hu-sidebar-active-fg);background:var(--hu-sidebar-active-bg)}.hu-nav__link--active .hu-nav__icon,.hu-nav__link--active:hover .hu-nav__icon{color:var(--hu-primary)}.hu-nav__link--active:not(.hu-nav__link--sub):before{content:\"\";position:absolute;top:8px;bottom:8px;left:calc(var(--hu-space-3) * -1);width:3px;background:var(--hu-primary);border-radius:0 3px 3px 0}.hu-nav__link--parent-active{color:var(--hu-text)}.hu-shell__sidebar--dark .hu-nav__link--parent-active{color:#fff}.hu-nav__link--parent-active .hu-nav__icon{color:var(--hu-primary)}.hu-nav__icon{color:var(--hu-sidebar-muted);transition:color var(--hu-transition)}.hu-nav__label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}.hu-nav__chevron{color:var(--hu-sidebar-muted);transition:transform var(--hu-transition)}[aria-expanded=true]>.hu-nav__chevron{transform:rotate(180deg)}.hu-nav__badge{min-width:1.25rem;height:1.25rem;padding:0 .375rem;font-size:.6875rem;font-weight:600;line-height:1.25rem;text-align:center;color:var(--hu-primary-fg);background:var(--hu-primary);border-radius:var(--hu-radius-full)}.hu-nav--collapsed .hu-nav__title{height:1px;margin:0 var(--hu-space-2) var(--hu-space-2);padding:0;overflow:hidden;color:transparent;background:var(--hu-sidebar-border)}.hu-nav--collapsed .hu-nav__link{justify-content:center;padding:0}.hu-nav--collapsed .hu-nav__label,.hu-nav--collapsed .hu-nav__chevron{display:none}.hu-nav--collapsed .hu-nav__badge{position:absolute;top:3px;right:6px;min-width:.5rem;width:.5rem;height:.5rem;padding:0;font-size:0}@keyframes hu-fade-in{0%{opacity:0}}\n"] }]
|
|
2575
|
+
}], ctorParameters: () => [] });
|
|
2576
|
+
|
|
2577
|
+
/** Açık / koyu tema arasında geçiş yapan buton. */
|
|
2578
|
+
class HuThemeToggle {
|
|
2579
|
+
theme = inject(HuThemeService);
|
|
2580
|
+
label = computed(() => this.theme.resolved() === 'dark' ? 'Açık temaya geç' : 'Koyu temaya geç');
|
|
2581
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuThemeToggle, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2582
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.25", type: HuThemeToggle, isStandalone: true, selector: "hu-theme-toggle", host: { styleAttribute: "display: inline-flex" }, ngImport: i0, template: `
|
|
2583
|
+
<button hu-button variant="ghost" iconOnly [attr.aria-label]="label()" [attr.title]="label()" (click)="theme.toggle()">
|
|
2584
|
+
<hu-icon [name]="theme.resolved() === 'dark' ? 'sun' : 'moon'" [size]="18" />
|
|
2585
|
+
</button>
|
|
2586
|
+
`, isInline: true, dependencies: [{ kind: "component", type: HuButton, selector: "button[hu-button], a[hu-button]", inputs: ["variant", "color", "size", "disabled", "loading", "block", "iconOnly", "pill"] }, { kind: "component", type: HuIcon, selector: "hu-icon", inputs: ["name", "size", "strokeWidth", "label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2587
|
+
}
|
|
2588
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: HuThemeToggle, decorators: [{
|
|
2589
|
+
type: Component,
|
|
2590
|
+
args: [{
|
|
2591
|
+
selector: 'hu-theme-toggle',
|
|
2592
|
+
imports: [HuButton, HuIcon],
|
|
2593
|
+
template: `
|
|
2594
|
+
<button hu-button variant="ghost" iconOnly [attr.aria-label]="label()" [attr.title]="label()" (click)="theme.toggle()">
|
|
2595
|
+
<hu-icon [name]="theme.resolved() === 'dark' ? 'sun' : 'moon'" [size]="18" />
|
|
2596
|
+
</button>
|
|
2597
|
+
`,
|
|
2598
|
+
host: { style: 'display: inline-flex' },
|
|
2599
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2600
|
+
}]
|
|
2601
|
+
}] });
|
|
2602
|
+
|
|
2603
|
+
/*
|
|
2604
|
+
* Birlikte kullanılan component/directive grupları. Bir parçayı import etmeyi
|
|
2605
|
+
* unutmak Angular'da sessizce başarısız olur (öznitelik yok sayılır); gruplar
|
|
2606
|
+
* bunu önler.
|
|
2607
|
+
*
|
|
2608
|
+
* @example imports: [HU_FORM_FIELD_IMPORTS, HU_TABLE_IMPORTS]
|
|
2609
|
+
*/
|
|
2610
|
+
const HU_FORM_FIELD_IMPORTS = [HuFormField, HuInput, HuPrefix, HuSuffix];
|
|
2611
|
+
const HU_CARD_IMPORTS = [HuCard, HuCardActions, HuCardFooter];
|
|
2612
|
+
const HU_DIALOG_IMPORTS = [HuDialog, HuDialogFooter];
|
|
2613
|
+
const HU_MENU_IMPORTS = [HuMenu, HuMenuTrigger, HuMenuItem];
|
|
2614
|
+
const HU_TABLE_IMPORTS = [HuTable, HuCellDef];
|
|
2615
|
+
const HU_TABS_IMPORTS = [HuTabs, HuTab];
|
|
2616
|
+
const HU_SHELL_IMPORTS = [HuShell, HuTopbarStart, HuTopbarEnd, HuSidebarFooter, HuShellLogo];
|
|
2617
|
+
|
|
2618
|
+
/*
|
|
2619
|
+
* HU UI — Angular component kütüphanesi ve admin layout
|
|
2620
|
+
*/
|
|
2621
|
+
// Çekirdek
|
|
2622
|
+
|
|
2623
|
+
/**
|
|
2624
|
+
* Generated bundle index. Do not edit.
|
|
2625
|
+
*/
|
|
2626
|
+
|
|
2627
|
+
export { HU_BUILTIN_ICONS, HU_CARD_IMPORTS, HU_DEFAULT_ERROR_MESSAGES, HU_DIALOG_IMPORTS, HU_ERROR_MESSAGES, HU_FORM_FIELD, HU_FORM_FIELD_IMPORTS, HU_ICON_SETS, HU_MENU_IMPORTS, HU_SHELL_IMPORTS, HU_STATUS_ICONS, HU_TABLE_IMPORTS, HU_TABS_IMPORTS, HuAlert, HuAvatar, HuBadge, HuBreadcrumb, HuButton, HuButtonGroup, HuCalendar, HuCard, HuCardActions, HuCardFooter, HuCellDef, HuCheckbox, HuDatePicker, HuDialog, HuDialogFooter, HuFormField, HuFormFieldControl, HuIcon, HuInput, HuMenu, HuMenuItem, HuMenuTrigger, HuPaginator, HuPrefix, HuShell, HuShellLogo, HuSidebarFooter, HuSidebarNav, HuSpinner, HuSuffix, HuSwitch, HuTab, HuTable, HuTabs, HuThemeService, HuThemeToggle, HuToastService, HuToaster, HuTopbarEnd, HuTopbarStart, addDays, addMonths, clampDate, compareDays, daysInMonth, formatDate, formatRange, huMediaQuery, huUniqueId, isSameDay, isSameMonth, isValidDate, parseDate, parseRange, provideHuErrorMessages, provideHuIcons, startOfDay, startOfWeek };
|
|
2628
|
+
//# sourceMappingURL=ucme-ui-angular.mjs.map
|