ngx-tethys 20.0.2 → 20.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1119 @@
1
+ import * as i0 from '@angular/core';
2
+ import { signal, Injectable, input, ChangeDetectionStrategy, Component, inject, ElementRef, ChangeDetectorRef, DestroyRef, output, computed, effect, Renderer2, Directive, ContentChildren, ViewChild, booleanAttribute, NgZone, ViewContainerRef, Input, NgModule } from '@angular/core';
3
+ import { NgTemplateOutlet, CommonModule } from '@angular/common';
4
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
+ import { BehaviorSubject, Subject, ReplaySubject, merge, EMPTY, fromEvent } from 'rxjs';
6
+ import { UpdateHostClassService } from 'ngx-tethys/core';
7
+ import { ThyPagination } from 'ngx-tethys/pagination';
8
+ import { ThyEmpty } from 'ngx-tethys/empty';
9
+ import { switchMap, mergeMap, startWith, map, distinctUntilChanged, shareReplay, filter } from 'rxjs/operators';
10
+ import * as i1 from '@angular/forms';
11
+ import { FormsModule } from '@angular/forms';
12
+ import { ThyCheckbox } from 'ngx-tethys/checkbox';
13
+ import { ThyIcon } from 'ngx-tethys/icon';
14
+ import { ThyPopover } from 'ngx-tethys/popover';
15
+
16
+ class ThyNativeTableStyleService {
17
+ constructor() {
18
+ this.theadTemplate = signal(null, ...(ngDevMode ? [{ debugName: "theadTemplate" }] : []));
19
+ this.columnCount = signal(0, ...(ngDevMode ? [{ debugName: "columnCount" }] : []));
20
+ this.tableSize = signal('default', ...(ngDevMode ? [{ debugName: "tableSize" }] : []));
21
+ this.tableTheme = signal('default', ...(ngDevMode ? [{ debugName: "tableTheme" }] : []));
22
+ this.showEmpty = signal(false, ...(ngDevMode ? [{ debugName: "showEmpty" }] : []));
23
+ this.emptyOptions = signal(null, ...(ngDevMode ? [{ debugName: "emptyOptions" }] : []));
24
+ this.listOfThWidthConfigPx$ = new BehaviorSubject([]);
25
+ }
26
+ setTheadTemplate(template) {
27
+ this.theadTemplate.set(template);
28
+ }
29
+ setTableSize(size) {
30
+ this.tableSize.set(size);
31
+ }
32
+ setTableTheme(theme) {
33
+ this.tableTheme.set(theme);
34
+ }
35
+ setShowEmpty(showEmpty) {
36
+ this.showEmpty.set(showEmpty);
37
+ }
38
+ setEmptyOptions(emptyOptions) {
39
+ this.emptyOptions.set(emptyOptions);
40
+ }
41
+ setListOfTh(listOfTh) {
42
+ const listOfThPx = listOfTh.map(item => {
43
+ const width = item.thyWidth();
44
+ if (width === null || width === undefined) {
45
+ return null;
46
+ }
47
+ if (typeof width === 'number') {
48
+ return `${width}px`;
49
+ }
50
+ return width.toString();
51
+ });
52
+ this.listOfThWidthConfigPx$.next(listOfThPx);
53
+ }
54
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableStyleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
55
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableStyleService }); }
56
+ }
57
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableStyleService, decorators: [{
58
+ type: Injectable
59
+ }] });
60
+
61
+ class ThyNativeTableContentComponent {
62
+ constructor() {
63
+ this.tableLayout = input('auto', ...(ngDevMode ? [{ debugName: "tableLayout" }] : []));
64
+ this.theadTemplate = input(null, ...(ngDevMode ? [{ debugName: "theadTemplate" }] : []));
65
+ this.contentTemplate = input(null, ...(ngDevMode ? [{ debugName: "contentTemplate" }] : []));
66
+ this.tfootTemplate = input(null, ...(ngDevMode ? [{ debugName: "tfootTemplate" }] : []));
67
+ this.listOfColWidth = input([], ...(ngDevMode ? [{ debugName: "listOfColWidth" }] : []));
68
+ this.scrollX = input(null, ...(ngDevMode ? [{ debugName: "scrollX" }] : []));
69
+ }
70
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
71
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: ThyNativeTableContentComponent, isStandalone: true, selector: "table[thy-native-table-content]", inputs: { tableLayout: { classPropertyName: "tableLayout", publicName: "tableLayout", isSignal: true, isRequired: false, transformFunction: null }, theadTemplate: { classPropertyName: "theadTemplate", publicName: "theadTemplate", isSignal: true, isRequired: false, transformFunction: null }, contentTemplate: { classPropertyName: "contentTemplate", publicName: "contentTemplate", isSignal: true, isRequired: false, transformFunction: null }, tfootTemplate: { classPropertyName: "tfootTemplate", publicName: "tfootTemplate", isSignal: true, isRequired: false, transformFunction: null }, listOfColWidth: { classPropertyName: "listOfColWidth", publicName: "listOfColWidth", isSignal: true, isRequired: false, transformFunction: null }, scrollX: { classPropertyName: "scrollX", publicName: "scrollX", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.table-layout": "tableLayout()", "style.width": "scrollX()" }, classAttribute: "thy-native-table-content" }, ngImport: i0, template: `
72
+ @if (listOfColWidth().length > 0) {
73
+ <colgroup>
74
+ @for (width of listOfColWidth(); track $index) {
75
+ <col [style.width]="width" [style.minWidth]="width" />
76
+ }
77
+ </colgroup>
78
+ }
79
+ @if (theadTemplate()) {
80
+ <thead class="thy-native-table-thead">
81
+ <ng-template [ngTemplateOutlet]="theadTemplate()!"></ng-template>
82
+ </thead>
83
+ }
84
+ @if (contentTemplate()) {
85
+ <ng-template [ngTemplateOutlet]="contentTemplate()!"></ng-template>
86
+ }
87
+ <ng-content></ng-content>
88
+ @if (tfootTemplate()) {
89
+ <tfoot class="thy-native-table-summary">
90
+ <ng-template [ngTemplateOutlet]="tfootTemplate()!"></ng-template>
91
+ </tfoot>
92
+ }
93
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
94
+ }
95
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableContentComponent, decorators: [{
96
+ type: Component,
97
+ args: [{
98
+ selector: 'table[thy-native-table-content]',
99
+ changeDetection: ChangeDetectionStrategy.OnPush,
100
+ template: `
101
+ @if (listOfColWidth().length > 0) {
102
+ <colgroup>
103
+ @for (width of listOfColWidth(); track $index) {
104
+ <col [style.width]="width" [style.minWidth]="width" />
105
+ }
106
+ </colgroup>
107
+ }
108
+ @if (theadTemplate()) {
109
+ <thead class="thy-native-table-thead">
110
+ <ng-template [ngTemplateOutlet]="theadTemplate()!"></ng-template>
111
+ </thead>
112
+ }
113
+ @if (contentTemplate()) {
114
+ <ng-template [ngTemplateOutlet]="contentTemplate()!"></ng-template>
115
+ }
116
+ <ng-content></ng-content>
117
+ @if (tfootTemplate()) {
118
+ <tfoot class="thy-native-table-summary">
119
+ <ng-template [ngTemplateOutlet]="tfootTemplate()!"></ng-template>
120
+ </tfoot>
121
+ }
122
+ `,
123
+ host: {
124
+ '[style.table-layout]': 'tableLayout()',
125
+ '[style.width]': 'scrollX()',
126
+ class: 'thy-native-table-content'
127
+ },
128
+ imports: [NgTemplateOutlet]
129
+ }]
130
+ }], propDecorators: { tableLayout: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableLayout", required: false }] }], theadTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "theadTemplate", required: false }] }], contentTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentTemplate", required: false }] }], tfootTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "tfootTemplate", required: false }] }], listOfColWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "listOfColWidth", required: false }] }], scrollX: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollX", required: false }] }] } });
131
+
132
+ class ThyNativeTableInnerDefaultComponent {
133
+ constructor() {
134
+ this.tableLayout = input('auto', ...(ngDevMode ? [{ debugName: "tableLayout" }] : []));
135
+ this.listOfColWidth = input([], ...(ngDevMode ? [{ debugName: "listOfColWidth" }] : []));
136
+ this.theadTemplate = input(null, ...(ngDevMode ? [{ debugName: "theadTemplate" }] : []));
137
+ this.contentTemplate = input(null, ...(ngDevMode ? [{ debugName: "contentTemplate" }] : []));
138
+ this.tfootTemplate = input(null, ...(ngDevMode ? [{ debugName: "tfootTemplate" }] : []));
139
+ }
140
+ ngOnInit() { }
141
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableInnerDefaultComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
142
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.15", type: ThyNativeTableInnerDefaultComponent, isStandalone: true, selector: "thy-native-table-inner-default", inputs: { tableLayout: { classPropertyName: "tableLayout", publicName: "tableLayout", isSignal: true, isRequired: false, transformFunction: null }, listOfColWidth: { classPropertyName: "listOfColWidth", publicName: "listOfColWidth", isSignal: true, isRequired: false, transformFunction: null }, theadTemplate: { classPropertyName: "theadTemplate", publicName: "theadTemplate", isSignal: true, isRequired: false, transformFunction: null }, contentTemplate: { classPropertyName: "contentTemplate", publicName: "contentTemplate", isSignal: true, isRequired: false, transformFunction: null }, tfootTemplate: { classPropertyName: "tfootTemplate", publicName: "tfootTemplate", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "thy-native-table-container" }, ngImport: i0, template: `
143
+ <div class="thy-native-table-content">
144
+ <table
145
+ thy-native-table-content
146
+ [tableLayout]="tableLayout()"
147
+ [listOfColWidth]="listOfColWidth()"
148
+ [theadTemplate]="theadTemplate()"
149
+ [contentTemplate]="contentTemplate()"
150
+ [tfootTemplate]="tfootTemplate()"></table>
151
+ </div>
152
+ `, isInline: true, dependencies: [{ kind: "component", type: ThyNativeTableContentComponent, selector: "table[thy-native-table-content]", inputs: ["tableLayout", "theadTemplate", "contentTemplate", "tfootTemplate", "listOfColWidth", "scrollX"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
153
+ }
154
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableInnerDefaultComponent, decorators: [{
155
+ type: Component,
156
+ args: [{
157
+ selector: 'thy-native-table-inner-default',
158
+ changeDetection: ChangeDetectionStrategy.OnPush,
159
+ template: `
160
+ <div class="thy-native-table-content">
161
+ <table
162
+ thy-native-table-content
163
+ [tableLayout]="tableLayout()"
164
+ [listOfColWidth]="listOfColWidth()"
165
+ [theadTemplate]="theadTemplate()"
166
+ [contentTemplate]="contentTemplate()"
167
+ [tfootTemplate]="tfootTemplate()"></table>
168
+ </div>
169
+ `,
170
+ host: { class: 'thy-native-table-container' },
171
+ imports: [ThyNativeTableContentComponent]
172
+ }]
173
+ }], propDecorators: { tableLayout: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableLayout", required: false }] }], listOfColWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "listOfColWidth", required: false }] }], theadTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "theadTemplate", required: false }] }], contentTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentTemplate", required: false }] }], tfootTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "tfootTemplate", required: false }] }] } });
174
+
175
+ class ThyNativeTableInnerScrollComponent {
176
+ constructor() {
177
+ this.data = input([], ...(ngDevMode ? [{ debugName: "data" }] : []));
178
+ this.scrollX = input(null, ...(ngDevMode ? [{ debugName: "scrollX" }] : []));
179
+ this.scrollY = input(null, ...(ngDevMode ? [{ debugName: "scrollY" }] : []));
180
+ this.contentTemplate = input(null, ...(ngDevMode ? [{ debugName: "contentTemplate" }] : []));
181
+ this.widthConfig = input([], ...(ngDevMode ? [{ debugName: "widthConfig" }] : []));
182
+ this.listOfColWidth = input([], ...(ngDevMode ? [{ debugName: "listOfColWidth" }] : []));
183
+ this.theadTemplate = input(null, ...(ngDevMode ? [{ debugName: "theadTemplate" }] : []));
184
+ this.tfootTemplate = input(null, ...(ngDevMode ? [{ debugName: "tfootTemplate" }] : []));
185
+ }
186
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableInnerScrollComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
187
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: ThyNativeTableInnerScrollComponent, isStandalone: true, selector: "thy-native-table-inner-scroll", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, scrollX: { classPropertyName: "scrollX", publicName: "scrollX", isSignal: true, isRequired: false, transformFunction: null }, scrollY: { classPropertyName: "scrollY", publicName: "scrollY", isSignal: true, isRequired: false, transformFunction: null }, contentTemplate: { classPropertyName: "contentTemplate", publicName: "contentTemplate", isSignal: true, isRequired: false, transformFunction: null }, widthConfig: { classPropertyName: "widthConfig", publicName: "widthConfig", isSignal: true, isRequired: false, transformFunction: null }, listOfColWidth: { classPropertyName: "listOfColWidth", publicName: "listOfColWidth", isSignal: true, isRequired: false, transformFunction: null }, theadTemplate: { classPropertyName: "theadTemplate", publicName: "theadTemplate", isSignal: true, isRequired: false, transformFunction: null }, tfootTemplate: { classPropertyName: "tfootTemplate", publicName: "tfootTemplate", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "thy-native-table-container" }, ngImport: i0, template: `
188
+ @if (scrollY()) {
189
+ <div #tableHeaderElement class="thy-native-table-header">
190
+ <table
191
+ thy-native-table-content
192
+ [tableLayout]="'fixed'"
193
+ [scrollX]="scrollX()"
194
+ [listOfColWidth]="listOfColWidth()"
195
+ [theadTemplate]="theadTemplate()"></table>
196
+ </div>
197
+ <div #tableBodyElement class="thy-native-table-body" [style.max-height]="scrollY()">
198
+ <table
199
+ thy-native-table-content
200
+ [tableLayout]="'fixed'"
201
+ [scrollX]="scrollX()"
202
+ [listOfColWidth]="listOfColWidth()"
203
+ [contentTemplate]="contentTemplate()"></table>
204
+ </div>
205
+ <div #tableFootElement class="thy-native-table-summary">
206
+ <table
207
+ thy-native-table-content
208
+ [tableLayout]="'fixed'"
209
+ [scrollX]="scrollX()"
210
+ [listOfColWidth]="listOfColWidth()"
211
+ [tfootTemplate]="tfootTemplate()"></table>
212
+ </div>
213
+ } @else {
214
+ <div class="thy-native-table-content" [style.overflow-x]="scrollX() ? 'auto' : null">
215
+ <table
216
+ thy-native-table-content
217
+ [tableLayout]="'fixed'"
218
+ [scrollX]="scrollX()"
219
+ [listOfColWidth]="listOfColWidth()"
220
+ [theadTemplate]="theadTemplate()"
221
+ [contentTemplate]="contentTemplate()"
222
+ [tfootTemplate]="tfootTemplate()"></table>
223
+ </div>
224
+ }
225
+ `, isInline: true, dependencies: [{ kind: "component", type: ThyNativeTableContentComponent, selector: "table[thy-native-table-content]", inputs: ["tableLayout", "theadTemplate", "contentTemplate", "tfootTemplate", "listOfColWidth", "scrollX"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
226
+ }
227
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableInnerScrollComponent, decorators: [{
228
+ type: Component,
229
+ args: [{
230
+ selector: 'thy-native-table-inner-scroll',
231
+ changeDetection: ChangeDetectionStrategy.OnPush,
232
+ template: `
233
+ @if (scrollY()) {
234
+ <div #tableHeaderElement class="thy-native-table-header">
235
+ <table
236
+ thy-native-table-content
237
+ [tableLayout]="'fixed'"
238
+ [scrollX]="scrollX()"
239
+ [listOfColWidth]="listOfColWidth()"
240
+ [theadTemplate]="theadTemplate()"></table>
241
+ </div>
242
+ <div #tableBodyElement class="thy-native-table-body" [style.max-height]="scrollY()">
243
+ <table
244
+ thy-native-table-content
245
+ [tableLayout]="'fixed'"
246
+ [scrollX]="scrollX()"
247
+ [listOfColWidth]="listOfColWidth()"
248
+ [contentTemplate]="contentTemplate()"></table>
249
+ </div>
250
+ <div #tableFootElement class="thy-native-table-summary">
251
+ <table
252
+ thy-native-table-content
253
+ [tableLayout]="'fixed'"
254
+ [scrollX]="scrollX()"
255
+ [listOfColWidth]="listOfColWidth()"
256
+ [tfootTemplate]="tfootTemplate()"></table>
257
+ </div>
258
+ } @else {
259
+ <div class="thy-native-table-content" [style.overflow-x]="scrollX() ? 'auto' : null">
260
+ <table
261
+ thy-native-table-content
262
+ [tableLayout]="'fixed'"
263
+ [scrollX]="scrollX()"
264
+ [listOfColWidth]="listOfColWidth()"
265
+ [theadTemplate]="theadTemplate()"
266
+ [contentTemplate]="contentTemplate()"
267
+ [tfootTemplate]="tfootTemplate()"></table>
268
+ </div>
269
+ }
270
+ `,
271
+ host: { class: 'thy-native-table-container' },
272
+ imports: [ThyNativeTableContentComponent]
273
+ }]
274
+ }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], scrollX: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollX", required: false }] }], scrollY: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollY", required: false }] }], contentTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentTemplate", required: false }] }], widthConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "widthConfig", required: false }] }], listOfColWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "listOfColWidth", required: false }] }], theadTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "theadTemplate", required: false }] }], tfootTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "tfootTemplate", required: false }] }] } });
275
+
276
+ class ThyNativeTableComponent {
277
+ constructor(tableElementRef) {
278
+ this.tableElementRef = tableElementRef;
279
+ this.elementRef = inject(ElementRef);
280
+ this.cdr = inject(ChangeDetectorRef);
281
+ this.styleService = inject(ThyNativeTableStyleService);
282
+ this.destroyRef = inject(DestroyRef);
283
+ this.updateHostClassService = inject(UpdateHostClassService);
284
+ this.thyTableLayout = input('auto', ...(ngDevMode ? [{ debugName: "thyTableLayout" }] : []));
285
+ this.thySize = input('md', ...(ngDevMode ? [{ debugName: "thySize" }] : []));
286
+ this.thyTheme = input('default', ...(ngDevMode ? [{ debugName: "thyTheme" }] : []));
287
+ this.thyData = input([], ...(ngDevMode ? [{ debugName: "thyData" }] : []));
288
+ this.thyShowPagination = input(false, ...(ngDevMode ? [{ debugName: "thyShowPagination" }] : []));
289
+ this.thyPageIndex = input(1, ...(ngDevMode ? [{ debugName: "thyPageIndex" }] : []));
290
+ this.thyPageSize = input(20, ...(ngDevMode ? [{ debugName: "thyPageSize" }] : []));
291
+ this.thyPageTotal = input(0, ...(ngDevMode ? [{ debugName: "thyPageTotal" }] : []));
292
+ this.thyShowSizeChanger = input(false, ...(ngDevMode ? [{ debugName: "thyShowSizeChanger" }] : []));
293
+ this.thyPageSizeOptions = input([20, 50, 100], ...(ngDevMode ? [{ debugName: "thyPageSizeOptions" }] : []));
294
+ this.thyPageIndexChange = output();
295
+ this.thyPageSizeChange = output();
296
+ this.thyScroll = input({ x: null, y: null }, ...(ngDevMode ? [{ debugName: "thyScroll" }] : []));
297
+ this.thyEmptyOptions = input({}, ...(ngDevMode ? [{ debugName: "thyEmptyOptions" }] : []));
298
+ /** data for ngFor tr */
299
+ this.data = computed(() => this.thyData(), ...(ngDevMode ? [{ debugName: "data" }] : []));
300
+ this.theadTemplate = signal(null, ...(ngDevMode ? [{ debugName: "theadTemplate" }] : []));
301
+ this.listOfManualColWidth = signal([], ...(ngDevMode ? [{ debugName: "listOfManualColWidth" }] : []));
302
+ this.pagination = computed(() => {
303
+ if (!this.thyShowPagination()) {
304
+ return null;
305
+ }
306
+ return {
307
+ index: this.thyPageIndex() || this.defaultPagination.index,
308
+ size: this.thyPageSize() || this.defaultPagination.size,
309
+ sizeOptions: this.thyPageSizeOptions() || this.defaultPagination.sizeOptions
310
+ };
311
+ }, ...(ngDevMode ? [{ debugName: "pagination" }] : []));
312
+ this.defaultPagination = { index: 1, size: 20, sizeOptions: [20, 50, 100] };
313
+ this.scrollX = computed(() => this.thyScroll().x || null, ...(ngDevMode ? [{ debugName: "scrollX" }] : []));
314
+ this.scrollY = computed(() => this.thyScroll().y || null, ...(ngDevMode ? [{ debugName: "scrollY" }] : []));
315
+ effect(() => {
316
+ this.updateTableClass();
317
+ this.styleService.setEmptyOptions(this.thyEmptyOptions());
318
+ });
319
+ effect(() => {
320
+ const showEmpty = this.thyData()?.length === 0;
321
+ this.styleService.setShowEmpty(showEmpty);
322
+ });
323
+ effect(() => {
324
+ this.theadTemplate.set(this.styleService.theadTemplate());
325
+ });
326
+ }
327
+ ngOnInit() {
328
+ this.updateHostClassService.initializeElement(this.tableElementRef.nativeElement);
329
+ const { listOfThWidthConfigPx$ } = this.styleService;
330
+ listOfThWidthConfigPx$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(listOfWidth => {
331
+ this.listOfManualColWidth.set(listOfWidth);
332
+ this.cdr.markForCheck();
333
+ });
334
+ }
335
+ setNativeTableClass() {
336
+ const classNames = [];
337
+ if (this.thySize()) {
338
+ classNames.push(`native-table-${this.thySize()}`);
339
+ }
340
+ if (this.thyTheme()) {
341
+ classNames.push(`native-table-${this.thyTheme()}`);
342
+ }
343
+ if (this.elementRef.nativeElement) {
344
+ this.updateHostClassService.updateClass(classNames);
345
+ }
346
+ }
347
+ onPageIndexChange(event) {
348
+ this.thyPageIndexChange.emit(event);
349
+ }
350
+ onPageSizeChange(event) {
351
+ this.thyPageSizeChange.emit(event);
352
+ }
353
+ updateTableClass() {
354
+ const size = this.thySize();
355
+ const theme = this.thyTheme();
356
+ if (size || theme) {
357
+ this.styleService.setTableSize(size);
358
+ this.styleService.setTableTheme(theme);
359
+ this.setNativeTableClass();
360
+ }
361
+ }
362
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
363
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: ThyNativeTableComponent, isStandalone: true, selector: "thy-native-table", inputs: { thyTableLayout: { classPropertyName: "thyTableLayout", publicName: "thyTableLayout", isSignal: true, isRequired: false, transformFunction: null }, thySize: { classPropertyName: "thySize", publicName: "thySize", isSignal: true, isRequired: false, transformFunction: null }, thyTheme: { classPropertyName: "thyTheme", publicName: "thyTheme", isSignal: true, isRequired: false, transformFunction: null }, thyData: { classPropertyName: "thyData", publicName: "thyData", isSignal: true, isRequired: false, transformFunction: null }, thyShowPagination: { classPropertyName: "thyShowPagination", publicName: "thyShowPagination", isSignal: true, isRequired: false, transformFunction: null }, thyPageIndex: { classPropertyName: "thyPageIndex", publicName: "thyPageIndex", isSignal: true, isRequired: false, transformFunction: null }, thyPageSize: { classPropertyName: "thyPageSize", publicName: "thyPageSize", isSignal: true, isRequired: false, transformFunction: null }, thyPageTotal: { classPropertyName: "thyPageTotal", publicName: "thyPageTotal", isSignal: true, isRequired: false, transformFunction: null }, thyShowSizeChanger: { classPropertyName: "thyShowSizeChanger", publicName: "thyShowSizeChanger", isSignal: true, isRequired: false, transformFunction: null }, thyPageSizeOptions: { classPropertyName: "thyPageSizeOptions", publicName: "thyPageSizeOptions", isSignal: true, isRequired: false, transformFunction: null }, thyScroll: { classPropertyName: "thyScroll", publicName: "thyScroll", isSignal: true, isRequired: false, transformFunction: null }, thyEmptyOptions: { classPropertyName: "thyEmptyOptions", publicName: "thyEmptyOptions", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { thyPageIndexChange: "thyPageIndexChange", thyPageSizeChange: "thyPageSizeChange" }, host: { classAttribute: "thy-native-table" }, providers: [ThyNativeTableStyleService, UpdateHostClassService], exportAs: ["thyNativeTable"], ngImport: i0, template: "<div #tableMainElement class=\"thy-native-table-wrapper\">\n <ng-template #contentTemplate>\n <ng-content></ng-content>\n </ng-template>\n @if (scrollY() || scrollX()) {\n <thy-native-table-inner-scroll\n [scrollX]=\"scrollX()\"\n [scrollY]=\"scrollY()\"\n [contentTemplate]=\"contentTemplate\"\n [listOfColWidth]=\"listOfManualColWidth()\"\n [theadTemplate]=\"theadTemplate()\"></thy-native-table-inner-scroll>\n } @else {\n <thy-native-table-inner-default\n [tableLayout]=\"thyTableLayout()\"\n [listOfColWidth]=\"listOfManualColWidth()\"\n [theadTemplate]=\"theadTemplate()\"\n [contentTemplate]=\"contentTemplate\"></thy-native-table-inner-default>\n }\n @if (thyShowPagination()) {\n <div class=\"thy-table-pagination\">\n <thy-pagination\n [thyPageIndex]=\"pagination().index\"\n [thyTotal]=\"pagination().total\"\n [thyPageSize]=\"pagination().size\"\n [thyPageSizeOptions]=\"pagination().sizeOptions\"\n [thyShowSizeChanger]=\"thyShowSizeChanger()\"\n (thyPageIndexChange)=\"onPageIndexChange($event)\"\n (thyPageSizeChanged)=\"onPageSizeChange($event)\"></thy-pagination>\n </div>\n }\n</div>\n", dependencies: [{ kind: "component", type: ThyNativeTableInnerDefaultComponent, selector: "thy-native-table-inner-default", inputs: ["tableLayout", "listOfColWidth", "theadTemplate", "contentTemplate", "tfootTemplate"] }, { kind: "component", type: ThyNativeTableInnerScrollComponent, selector: "thy-native-table-inner-scroll", inputs: ["data", "scrollX", "scrollY", "contentTemplate", "widthConfig", "listOfColWidth", "theadTemplate", "tfootTemplate"] }, { kind: "component", type: ThyPagination, selector: "thy-pagination", inputs: ["thyPageIndex", "thyPageSize", "thyTotal", "thyCustomPages", "thyDisabled", "thyShowQuickJumper", "thyShowTotalPageCount", "thySize", "thyMaxCount", "thyMarginalCount", "thyRangeCount", "thyShowSizeChanger", "thyPageSizeOptions", "thyHideOnSinglePage", "thyUnit", "thyShowTotal", "selectedPageSize"], outputs: ["thyPageIndexChange", "thyPageChanged", "thyPageSizeChanged", "selectedPageSizeChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
364
+ }
365
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableComponent, decorators: [{
366
+ type: Component,
367
+ args: [{ selector: 'thy-native-table', exportAs: 'thyNativeTable', providers: [ThyNativeTableStyleService, UpdateHostClassService], changeDetection: ChangeDetectionStrategy.OnPush, host: {
368
+ class: 'thy-native-table'
369
+ }, imports: [ThyNativeTableInnerDefaultComponent, ThyNativeTableInnerScrollComponent, ThyPagination], template: "<div #tableMainElement class=\"thy-native-table-wrapper\">\n <ng-template #contentTemplate>\n <ng-content></ng-content>\n </ng-template>\n @if (scrollY() || scrollX()) {\n <thy-native-table-inner-scroll\n [scrollX]=\"scrollX()\"\n [scrollY]=\"scrollY()\"\n [contentTemplate]=\"contentTemplate\"\n [listOfColWidth]=\"listOfManualColWidth()\"\n [theadTemplate]=\"theadTemplate()\"></thy-native-table-inner-scroll>\n } @else {\n <thy-native-table-inner-default\n [tableLayout]=\"thyTableLayout()\"\n [listOfColWidth]=\"listOfManualColWidth()\"\n [theadTemplate]=\"theadTemplate()\"\n [contentTemplate]=\"contentTemplate\"></thy-native-table-inner-default>\n }\n @if (thyShowPagination()) {\n <div class=\"thy-table-pagination\">\n <thy-pagination\n [thyPageIndex]=\"pagination().index\"\n [thyTotal]=\"pagination().total\"\n [thyPageSize]=\"pagination().size\"\n [thyPageSizeOptions]=\"pagination().sizeOptions\"\n [thyShowSizeChanger]=\"thyShowSizeChanger()\"\n (thyPageIndexChange)=\"onPageIndexChange($event)\"\n (thyPageSizeChanged)=\"onPageSizeChange($event)\"></thy-pagination>\n </div>\n }\n</div>\n" }]
370
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { thyTableLayout: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyTableLayout", required: false }] }], thySize: [{ type: i0.Input, args: [{ isSignal: true, alias: "thySize", required: false }] }], thyTheme: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyTheme", required: false }] }], thyData: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyData", required: false }] }], thyShowPagination: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyShowPagination", required: false }] }], thyPageIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyPageIndex", required: false }] }], thyPageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyPageSize", required: false }] }], thyPageTotal: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyPageTotal", required: false }] }], thyShowSizeChanger: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyShowSizeChanger", required: false }] }], thyPageSizeOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyPageSizeOptions", required: false }] }], thyPageIndexChange: [{ type: i0.Output, args: ["thyPageIndexChange"] }], thyPageSizeChange: [{ type: i0.Output, args: ["thyPageSizeChange"] }], thyScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyScroll", required: false }] }], thyEmptyOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyEmptyOptions", required: false }] }] } });
371
+
372
+ /* eslint-disable @angular-eslint/component-selector */
373
+ class ThyNativeTableBodyComponent {
374
+ constructor() {
375
+ this.styleService = inject(ThyNativeTableStyleService, { optional: true });
376
+ this.isInsideNativeTable = !!this.styleService;
377
+ this.showEmpty = computed(() => this.styleService?.showEmpty() ?? false, ...(ngDevMode ? [{ debugName: "showEmpty" }] : []));
378
+ this.emptyOptions = computed(() => this.styleService?.emptyOptions() ?? null, ...(ngDevMode ? [{ debugName: "emptyOptions" }] : []));
379
+ }
380
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
381
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: ThyNativeTableBodyComponent, isStandalone: true, selector: "tbody", host: { properties: { "class.thy-native-table-tbody": "isInsideNativeTable" } }, ngImport: i0, template: `
382
+ <ng-content></ng-content>
383
+ @if (showEmpty()) {
384
+ <tr class="thy-table-empty">
385
+ <td colspan="100%">
386
+ <thy-empty
387
+ [thyMessage]="emptyOptions()?.message"
388
+ [thyIconName]="emptyOptions()?.iconName"
389
+ [thySize]="emptyOptions()?.size"
390
+ [thyMarginTop]="emptyOptions()?.marginTop"
391
+ [thyTopAuto]="emptyOptions()?.topAuto"></thy-empty>
392
+ </td>
393
+ </tr>
394
+ }
395
+ `, isInline: true, dependencies: [{ kind: "component", type: ThyEmpty, selector: "thy-empty", inputs: ["thyMessage", "thyTranslationKey", "thyTranslationValues", "thyEntityName", "thyEntityNameTranslateKey", "thyIconName", "thySize", "thyMarginTop", "thyTopAuto", "thyContainer", "thyImageUrl", "thyImageLoading", "thyImageFetchPriority", "thyDescription"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
396
+ }
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableBodyComponent, decorators: [{
398
+ type: Component,
399
+ args: [{
400
+ selector: 'tbody',
401
+ changeDetection: ChangeDetectionStrategy.OnPush,
402
+ template: `
403
+ <ng-content></ng-content>
404
+ @if (showEmpty()) {
405
+ <tr class="thy-table-empty">
406
+ <td colspan="100%">
407
+ <thy-empty
408
+ [thyMessage]="emptyOptions()?.message"
409
+ [thyIconName]="emptyOptions()?.iconName"
410
+ [thySize]="emptyOptions()?.size"
411
+ [thyMarginTop]="emptyOptions()?.marginTop"
412
+ [thyTopAuto]="emptyOptions()?.topAuto"></thy-empty>
413
+ </td>
414
+ </tr>
415
+ }
416
+ `,
417
+ host: {
418
+ '[class.thy-native-table-tbody]': 'isInsideNativeTable'
419
+ },
420
+ imports: [ThyEmpty]
421
+ }]
422
+ }], ctorParameters: () => [] });
423
+
424
+ /* eslint-disable @angular-eslint/directive-selector */
425
+ class ThyNativeTableThDirective {
426
+ get colspan() {
427
+ return this.thyColspan() || this.thyColSpan() || null;
428
+ }
429
+ get colSpan() {
430
+ return this.thyColspan() || this.thyColSpan() || null;
431
+ }
432
+ constructor() {
433
+ this.renderer = inject(Renderer2);
434
+ this.el = inject((ElementRef)).nativeElement;
435
+ this.changes$ = new Subject();
436
+ this.thyWidth = input(null, ...(ngDevMode ? [{ debugName: "thyWidth" }] : []));
437
+ this.thyColspan = input(null, ...(ngDevMode ? [{ debugName: "thyColspan" }] : []));
438
+ this.thyColSpan = input(null, ...(ngDevMode ? [{ debugName: "thyColSpan" }] : []));
439
+ this.thyRowspan = input(null, ...(ngDevMode ? [{ debugName: "thyRowspan" }] : []));
440
+ this.thyRowSpan = input(null, ...(ngDevMode ? [{ debugName: "thyRowSpan" }] : []));
441
+ effect(() => {
442
+ if (this.thyColspan() || this.thyColSpan()) {
443
+ const col = this.colspan;
444
+ if (col !== null && col !== undefined) {
445
+ this.renderer.setAttribute(this.el, 'colspan', `${col}`);
446
+ }
447
+ else {
448
+ this.renderer.removeAttribute(this.el, 'colspan');
449
+ }
450
+ }
451
+ if (this.thyRowspan() || this.thyRowSpan()) {
452
+ const row = this.thyRowspan() || this.thyRowSpan() || null;
453
+ if (row !== null && row !== undefined) {
454
+ this.renderer.setAttribute(this.el, 'rowspan', `${row}`);
455
+ }
456
+ else {
457
+ this.renderer.removeAttribute(this.el, 'rowspan');
458
+ }
459
+ }
460
+ if (this.thyWidth() || this.thyColspan() || this.thyColSpan()) {
461
+ this.changes$.next();
462
+ }
463
+ });
464
+ }
465
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableThDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
466
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.15", type: ThyNativeTableThDirective, isStandalone: true, selector: "th", inputs: { thyWidth: { classPropertyName: "thyWidth", publicName: "thyWidth", isSignal: true, isRequired: false, transformFunction: null }, thyColspan: { classPropertyName: "thyColspan", publicName: "thyColspan", isSignal: true, isRequired: false, transformFunction: null }, thyColSpan: { classPropertyName: "thyColSpan", publicName: "thyColSpan", isSignal: true, isRequired: false, transformFunction: null }, thyRowspan: { classPropertyName: "thyRowspan", publicName: "thyRowspan", isSignal: true, isRequired: false, transformFunction: null }, thyRowSpan: { classPropertyName: "thyRowSpan", publicName: "thyRowSpan", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
467
+ }
468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableThDirective, decorators: [{
469
+ type: Directive,
470
+ args: [{
471
+ selector: 'th'
472
+ }]
473
+ }], ctorParameters: () => [], propDecorators: { thyWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyWidth", required: false }] }], thyColspan: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyColspan", required: false }] }], thyColSpan: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyColSpan", required: false }] }], thyRowspan: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyRowspan", required: false }] }], thyRowSpan: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyRowSpan", required: false }] }] } });
474
+
475
+ /* eslint-disable @angular-eslint/directive-selector */
476
+ class ThyNativeTableTrDirective {
477
+ constructor() {
478
+ this.destroyRef = inject(DestroyRef);
479
+ this.styleService = inject(ThyNativeTableStyleService, { optional: true });
480
+ this.listOfColumns$ = new ReplaySubject(1);
481
+ this.listOfColumnsChanges$ = this.listOfColumns$.pipe(switchMap(list => merge(this.listOfColumns$, ...list.map(c => c.changes$)).pipe(mergeMap(() => this.listOfColumns$))), takeUntilDestroyed(this.destroyRef));
482
+ this.isInsideNativeTable = !!this.styleService;
483
+ }
484
+ ngAfterContentInit() {
485
+ if (this.styleService) {
486
+ this.listOfThDirective.changes
487
+ .pipe(startWith(this.listOfThDirective), takeUntilDestroyed(this.destroyRef))
488
+ .subscribe(thDirectives => {
489
+ const thList = thDirectives.toArray();
490
+ this.listOfColumns$.next(thList);
491
+ });
492
+ }
493
+ }
494
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTrDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
495
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: ThyNativeTableTrDirective, isStandalone: true, selector: "tr:not([thyNativeTableMeasureRow]):not([thyNativeTableFixedRow])", host: { properties: { "class.thy-native-table-row": "isInsideNativeTable" } }, queries: [{ propertyName: "listOfThDirective", predicate: ThyNativeTableThDirective }], ngImport: i0 }); }
496
+ }
497
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTrDirective, decorators: [{
498
+ type: Directive,
499
+ args: [{
500
+ selector: 'tr:not([thyNativeTableMeasureRow]):not([thyNativeTableFixedRow])',
501
+ host: {
502
+ '[class.thy-native-table-row]': 'isInsideNativeTable'
503
+ }
504
+ }]
505
+ }], propDecorators: { listOfThDirective: [{
506
+ type: ContentChildren,
507
+ args: [ThyNativeTableThDirective]
508
+ }] } });
509
+
510
+ /* eslint-disable @angular-eslint/component-selector */
511
+ class ThyNativeTableHeaderComponent {
512
+ constructor() {
513
+ this.styleService = inject(ThyNativeTableStyleService, { optional: true });
514
+ this.destroyRef = inject(DestroyRef);
515
+ this.el = inject((ElementRef)).nativeElement;
516
+ this.renderer = inject(Renderer2);
517
+ this.isInsideNativeTable = !!this.styleService;
518
+ }
519
+ ngOnInit() {
520
+ if (this.styleService) {
521
+ this.styleService.setTheadTemplate(this.templateRef);
522
+ }
523
+ }
524
+ ngAfterContentInit() {
525
+ if (this.styleService) {
526
+ const firstTableRow$ = this.listOfTrDirective.changes.pipe(startWith(this.listOfTrDirective), map(item => item && item.first), takeUntilDestroyed(this.destroyRef));
527
+ const listOfColumnsChanges$ = firstTableRow$.pipe(switchMap(firstTableRow => {
528
+ if (firstTableRow) {
529
+ return firstTableRow.listOfColumnsChanges$;
530
+ }
531
+ return EMPTY;
532
+ }));
533
+ listOfColumnsChanges$.subscribe(data => {
534
+ this.styleService.setListOfTh(data);
535
+ });
536
+ }
537
+ }
538
+ ngAfterViewInit() {
539
+ if (this.styleService) {
540
+ this.renderer.removeChild(this.renderer.parentNode(this.el), this.el);
541
+ }
542
+ }
543
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
544
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: ThyNativeTableHeaderComponent, isStandalone: true, selector: "thead:not(.thy-native-table-thead)", queries: [{ propertyName: "listOfTrDirective", predicate: ThyNativeTableTrDirective, descendants: true }], viewQueries: [{ propertyName: "templateRef", first: true, predicate: ["contentTemplate"], descendants: true, static: true }], ngImport: i0, template: `
545
+ <ng-template #contentTemplate>
546
+ <ng-content></ng-content>
547
+ </ng-template>
548
+ @if (!isInsideNativeTable) {
549
+ <ng-template [ngTemplateOutlet]="contentTemplate"></ng-template>
550
+ }
551
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
552
+ }
553
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableHeaderComponent, decorators: [{
554
+ type: Component,
555
+ args: [{
556
+ selector: 'thead:not(.thy-native-table-thead)',
557
+ changeDetection: ChangeDetectionStrategy.OnPush,
558
+ template: `
559
+ <ng-template #contentTemplate>
560
+ <ng-content></ng-content>
561
+ </ng-template>
562
+ @if (!isInsideNativeTable) {
563
+ <ng-template [ngTemplateOutlet]="contentTemplate"></ng-template>
564
+ }
565
+ `,
566
+ imports: [NgTemplateOutlet]
567
+ }]
568
+ }], propDecorators: { templateRef: [{
569
+ type: ViewChild,
570
+ args: ['contentTemplate', { static: true }]
571
+ }], listOfTrDirective: [{
572
+ type: ContentChildren,
573
+ args: [ThyNativeTableTrDirective, { descendants: true }]
574
+ }] } });
575
+
576
+ /* eslint-disable @angular-eslint/directive-selector */
577
+ class ThyNativeTableCellDirective {
578
+ constructor() {
579
+ this.isInsideTable = !!inject(ThyNativeTableStyleService, { optional: true });
580
+ }
581
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableCellDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
582
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: ThyNativeTableCellDirective, isStandalone: true, selector: "th, td", host: { properties: { "class.thy-native-table-cell": "isInsideTable" } }, ngImport: i0 }); }
583
+ }
584
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableCellDirective, decorators: [{
585
+ type: Directive,
586
+ args: [{
587
+ selector: 'th, td',
588
+ host: {
589
+ '[class.thy-native-table-cell]': 'isInsideTable'
590
+ }
591
+ }]
592
+ }] });
593
+
594
+ /* eslint-disable @angular-eslint/component-selector */
595
+ class ThyNativeTableTdSelectionComponent {
596
+ constructor() {
597
+ this.thyDisabled = input(false, ...(ngDevMode ? [{ debugName: "thyDisabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
598
+ this.thyCellCheckbox = input(false, ...(ngDevMode ? [{ debugName: "thyCellCheckbox", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
599
+ this.thyCellChecked = input(false, ...(ngDevMode ? [{ debugName: "thyCellChecked", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
600
+ this.thyIndeterminate = input(false, ...(ngDevMode ? [{ debugName: "thyIndeterminate", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
601
+ this.thyCheckedChange = output();
602
+ }
603
+ ngOnInit() { }
604
+ onCheckedChange(checked) {
605
+ this.thyCheckedChange.emit(checked);
606
+ }
607
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTdSelectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
608
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.15", type: ThyNativeTableTdSelectionComponent, isStandalone: true, selector: "td[thyCellChecked],td[thyCellCheckbox]", inputs: { thyDisabled: { classPropertyName: "thyDisabled", publicName: "thyDisabled", isSignal: true, isRequired: false, transformFunction: null }, thyCellCheckbox: { classPropertyName: "thyCellCheckbox", publicName: "thyCellCheckbox", isSignal: true, isRequired: false, transformFunction: null }, thyCellChecked: { classPropertyName: "thyCellChecked", publicName: "thyCellChecked", isSignal: true, isRequired: false, transformFunction: null }, thyIndeterminate: { classPropertyName: "thyIndeterminate", publicName: "thyIndeterminate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { thyCheckedChange: "thyCheckedChange" }, host: { properties: { "class.thy-native-table-selection-column": "thyCellCheckbox()" } }, ngImport: i0, template: `
609
+ <label
610
+ thyCheckbox
611
+ [ngModel]="thyCellChecked()"
612
+ [disabled]="thyDisabled()"
613
+ [thyIndeterminate]="thyIndeterminate()"
614
+ (ngModelChange)="onCheckedChange($event)"></label>
615
+ <ng-content></ng-content>
616
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ThyCheckbox, selector: "thy-checkbox,[thy-checkbox],[thyCheckbox]", inputs: ["thyIndeterminate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
617
+ }
618
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTdSelectionComponent, decorators: [{
619
+ type: Component,
620
+ args: [{
621
+ selector: 'td[thyCellChecked],td[thyCellCheckbox]',
622
+ changeDetection: ChangeDetectionStrategy.OnPush,
623
+ template: `
624
+ <label
625
+ thyCheckbox
626
+ [ngModel]="thyCellChecked()"
627
+ [disabled]="thyDisabled()"
628
+ [thyIndeterminate]="thyIndeterminate()"
629
+ (ngModelChange)="onCheckedChange($event)"></label>
630
+ <ng-content></ng-content>
631
+ `,
632
+ host: {
633
+ '[class.thy-native-table-selection-column]': 'thyCellCheckbox()'
634
+ },
635
+ imports: [FormsModule, ThyCheckbox]
636
+ }]
637
+ }], propDecorators: { thyDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyDisabled", required: false }] }], thyCellCheckbox: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyCellCheckbox", required: false }] }], thyCellChecked: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyCellChecked", required: false }] }], thyIndeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyIndeterminate", required: false }] }], thyCheckedChange: [{ type: i0.Output, args: ["thyCheckedChange"] }] } });
638
+
639
+ /* eslint-disable @angular-eslint/component-selector */
640
+ class ThyNativeTableThSelectionComponent {
641
+ constructor() {
642
+ this.thyHeaderCellCheckbox = input(true, ...(ngDevMode ? [{ debugName: "thyHeaderCellCheckbox", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
643
+ this.thyDisabled = input(false, ...(ngDevMode ? [{ debugName: "thyDisabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
644
+ this.thyHeaderCellChecked = input(false, ...(ngDevMode ? [{ debugName: "thyHeaderCellChecked", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
645
+ this.thyIndeterminate = input(false, ...(ngDevMode ? [{ debugName: "thyIndeterminate", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
646
+ this.thyCheckedChange = output();
647
+ }
648
+ ngOnInit() { }
649
+ onCheckedChange(checked) {
650
+ this.thyCheckedChange.emit(checked);
651
+ }
652
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableThSelectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
653
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.3.15", type: ThyNativeTableThSelectionComponent, isStandalone: true, selector: "th[thyHeaderCellChecked],th[thyHeaderCellCheckbox]", inputs: { thyHeaderCellCheckbox: { classPropertyName: "thyHeaderCellCheckbox", publicName: "thyHeaderCellCheckbox", isSignal: true, isRequired: false, transformFunction: null }, thyDisabled: { classPropertyName: "thyDisabled", publicName: "thyDisabled", isSignal: true, isRequired: false, transformFunction: null }, thyHeaderCellChecked: { classPropertyName: "thyHeaderCellChecked", publicName: "thyHeaderCellChecked", isSignal: true, isRequired: false, transformFunction: null }, thyIndeterminate: { classPropertyName: "thyIndeterminate", publicName: "thyIndeterminate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { thyCheckedChange: "thyCheckedChange" }, host: { properties: { "class.thy-native-table-selection-column": "thyHeaderCellCheckbox()" } }, ngImport: i0, template: `
654
+ <label
655
+ thyCheckbox
656
+ [ngModel]="thyHeaderCellChecked()"
657
+ [thyDisabled]="thyDisabled()"
658
+ [thyIndeterminate]="thyIndeterminate()"
659
+ (ngModelChange)="onCheckedChange($event)"></label>
660
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: ThyCheckbox, selector: "thy-checkbox,[thy-checkbox],[thyCheckbox]", inputs: ["thyIndeterminate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
661
+ }
662
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableThSelectionComponent, decorators: [{
663
+ type: Component,
664
+ args: [{
665
+ selector: 'th[thyHeaderCellChecked],th[thyHeaderCellCheckbox]',
666
+ changeDetection: ChangeDetectionStrategy.OnPush,
667
+ template: `
668
+ <label
669
+ thyCheckbox
670
+ [ngModel]="thyHeaderCellChecked()"
671
+ [thyDisabled]="thyDisabled()"
672
+ [thyIndeterminate]="thyIndeterminate()"
673
+ (ngModelChange)="onCheckedChange($event)"></label>
674
+ `,
675
+ host: {
676
+ '[class.thy-native-table-selection-column]': 'thyHeaderCellCheckbox()'
677
+ },
678
+ imports: [FormsModule, ThyCheckbox]
679
+ }]
680
+ }], ctorParameters: () => [], propDecorators: { thyHeaderCellCheckbox: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyHeaderCellCheckbox", required: false }] }], thyDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyDisabled", required: false }] }], thyHeaderCellChecked: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyHeaderCellChecked", required: false }] }], thyIndeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyIndeterminate", required: false }] }], thyCheckedChange: [{ type: i0.Output, args: ["thyCheckedChange"] }] } });
681
+
682
+ /* eslint-disable @angular-eslint/component-selector */
683
+ class ThyNativeTableThSortComponent {
684
+ constructor() {
685
+ this.thyHeaderCellSortable = input(false, ...(ngDevMode ? [{ debugName: "thyHeaderCellSortable", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
686
+ this.thySortOrder = input(null, ...(ngDevMode ? [{ debugName: "thySortOrder" }] : []));
687
+ this.thySortDirections = input(['asc', 'desc'], ...(ngDevMode ? [{ debugName: "thySortDirections" }] : []));
688
+ this.sortTriggerTemplate = input(null, ...(ngDevMode ? [{ debugName: "sortTriggerTemplate" }] : []));
689
+ this.thySortOrderChange = output();
690
+ this.currentSortOrder = signal(null, ...(ngDevMode ? [{ debugName: "currentSortOrder" }] : []));
691
+ this.isUp = computed(() => {
692
+ const directions = this.thySortDirections();
693
+ return directions.indexOf('asc') !== -1;
694
+ }, ...(ngDevMode ? [{ debugName: "isUp" }] : []));
695
+ this.isDown = computed(() => {
696
+ const directions = this.thySortDirections();
697
+ return directions.indexOf('desc') !== -1;
698
+ }, ...(ngDevMode ? [{ debugName: "isDown" }] : []));
699
+ }
700
+ setSortOrder(order) {
701
+ this.currentSortOrder.set(order);
702
+ }
703
+ ngOnInit() {
704
+ if (this.thySortOrder() !== null) {
705
+ this.currentSortOrder.set(this.thySortOrder());
706
+ }
707
+ }
708
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableThSortComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
709
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: ThyNativeTableThSortComponent, isStandalone: true, selector: "th[thyHeaderCellSortable]", inputs: { thyHeaderCellSortable: { classPropertyName: "thyHeaderCellSortable", publicName: "thyHeaderCellSortable", isSignal: true, isRequired: false, transformFunction: null }, thySortOrder: { classPropertyName: "thySortOrder", publicName: "thySortOrder", isSignal: true, isRequired: false, transformFunction: null }, thySortDirections: { classPropertyName: "thySortDirections", publicName: "thySortDirections", isSignal: true, isRequired: false, transformFunction: null }, sortTriggerTemplate: { classPropertyName: "sortTriggerTemplate", publicName: "sortTriggerTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { thySortOrderChange: "thySortOrderChange" }, host: { properties: { "class.thy-native-table-column-has-sorters": "thyHeaderCellSortable()", "class.thy-native-table-column-sort": "currentSortOrder() === \"desc\" || currentSortOrder() === \"asc\"" } }, ngImport: i0, template: `
710
+ <ng-content></ng-content>
711
+ <span class="thy-native-table-column-sorter" [class.thy-native-table-column-sorter-full]="isDown() && isUp()">
712
+ <span class="thy-native-table-column-sorter-inner">
713
+ @if (sortTriggerTemplate()) {
714
+ <ng-template [ngTemplateOutlet]="sortTriggerTemplate()!"></ng-template>
715
+ } @else {
716
+ @if (isUp()) {
717
+ <thy-icon
718
+ thyIconName="angle-up"
719
+ class="thy-native-table-column-sorter-up"
720
+ [class.active]="currentSortOrder() === 'asc'" />
721
+ }
722
+ @if (isDown()) {
723
+ <thy-icon
724
+ thyIconName="angle-down"
725
+ class="thy-native-table-column-sorter-down"
726
+ [class.active]="currentSortOrder() === 'desc'" />
727
+ }
728
+ }
729
+ </span>
730
+ </span>
731
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ThyIcon, selector: "thy-icon, [thy-icon]", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
732
+ }
733
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableThSortComponent, decorators: [{
734
+ type: Component,
735
+ args: [{
736
+ selector: 'th[thyHeaderCellSortable]',
737
+ changeDetection: ChangeDetectionStrategy.OnPush,
738
+ template: `
739
+ <ng-content></ng-content>
740
+ <span class="thy-native-table-column-sorter" [class.thy-native-table-column-sorter-full]="isDown() && isUp()">
741
+ <span class="thy-native-table-column-sorter-inner">
742
+ @if (sortTriggerTemplate()) {
743
+ <ng-template [ngTemplateOutlet]="sortTriggerTemplate()!"></ng-template>
744
+ } @else {
745
+ @if (isUp()) {
746
+ <thy-icon
747
+ thyIconName="angle-up"
748
+ class="thy-native-table-column-sorter-up"
749
+ [class.active]="currentSortOrder() === 'asc'" />
750
+ }
751
+ @if (isDown()) {
752
+ <thy-icon
753
+ thyIconName="angle-down"
754
+ class="thy-native-table-column-sorter-down"
755
+ [class.active]="currentSortOrder() === 'desc'" />
756
+ }
757
+ }
758
+ </span>
759
+ </span>
760
+ `,
761
+ host: {
762
+ '[class.thy-native-table-column-has-sorters]': 'thyHeaderCellSortable()',
763
+ '[class.thy-native-table-column-sort]': 'currentSortOrder() === "desc" || currentSortOrder() === "asc"'
764
+ },
765
+ imports: [NgTemplateOutlet, ThyIcon]
766
+ }]
767
+ }], propDecorators: { thyHeaderCellSortable: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyHeaderCellSortable", required: false }] }], thySortOrder: [{ type: i0.Input, args: [{ isSignal: true, alias: "thySortOrder", required: false }] }], thySortDirections: [{ type: i0.Input, args: [{ isSignal: true, alias: "thySortDirections", required: false }] }], sortTriggerTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "sortTriggerTemplate", required: false }] }], thySortOrderChange: [{ type: i0.Output, args: ["thySortOrderChange"] }] } });
768
+
769
+ class ThyNativeTableEditEventDispatcher {
770
+ constructor() {
771
+ this.editing = new Subject();
772
+ this.currentEditingCell = null;
773
+ this.editing$ = this.editing.asObservable().pipe(distinctUntilChanged(), shareReplay(1));
774
+ }
775
+ editingCell(element) {
776
+ return this.editing$.pipe(map(cell => cell === element), distinctUntilChanged());
777
+ }
778
+ startEditing(cell) {
779
+ this.currentEditingCell = cell;
780
+ this.editing.next(cell);
781
+ }
782
+ stopEditing() {
783
+ this.currentEditingCell = null;
784
+ this.editing.next(null);
785
+ }
786
+ getCurrentEditingCell() {
787
+ return this.currentEditingCell;
788
+ }
789
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableEditEventDispatcher, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
790
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableEditEventDispatcher }); }
791
+ }
792
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableEditEventDispatcher, decorators: [{
793
+ type: Injectable
794
+ }] });
795
+
796
+ class ThyNativeTableEditRef {
797
+ constructor() {
798
+ this.dispatcher = inject(ThyNativeTableEditEventDispatcher);
799
+ this.afterClosedSubject = new Subject();
800
+ this.afterClosed = this.afterClosedSubject.asObservable();
801
+ }
802
+ close() {
803
+ this.dispatcher.stopEditing();
804
+ this.afterClosedSubject.next();
805
+ }
806
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableEditRef, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
807
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableEditRef }); }
808
+ }
809
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableEditRef, decorators: [{
810
+ type: Injectable
811
+ }] });
812
+
813
+ const THY_NATIVE_TABLE_CELL_SELECTOR = '.thy-native-table-cell-edit';
814
+ const THY_NATIVE_TABLE_EDIT_PANE_SELECTOR = '.thy-native-table-popover-edit';
815
+ const THY_NATIVE_TABLE_EDIT_OPEN_SELECTOR = '[thyEditOpen]';
816
+ var ThyNativeTableEditTrigger;
817
+ (function (ThyNativeTableEditTrigger) {
818
+ ThyNativeTableEditTrigger["CLICK"] = "click";
819
+ ThyNativeTableEditTrigger["DBLCLICK"] = "dblclick";
820
+ })(ThyNativeTableEditTrigger || (ThyNativeTableEditTrigger = {}));
821
+
822
+ class ThyNativeTableEditableDirective {
823
+ constructor() {
824
+ this.elementRef = inject((ElementRef));
825
+ this.ngZone = inject(NgZone);
826
+ this.destroyRef = inject(DestroyRef);
827
+ this.dispatcher = inject(ThyNativeTableEditEventDispatcher);
828
+ this.thyEditTrigger = input(ThyNativeTableEditTrigger.CLICK, ...(ngDevMode ? [{ debugName: "thyEditTrigger" }] : []));
829
+ }
830
+ ngAfterViewInit() {
831
+ this.listenForEditEvents();
832
+ }
833
+ listenForEditEvents() {
834
+ const element = this.elementRef.nativeElement;
835
+ this.ngZone.runOutsideAngular(() => {
836
+ const trigger = this.thyEditTrigger();
837
+ if (trigger === 'click') {
838
+ fromEvent(element, 'click')
839
+ .pipe(takeUntilDestroyed(this.destroyRef))
840
+ .subscribe(event => this.handleClickEdit(event));
841
+ }
842
+ else if (trigger === 'dblclick') {
843
+ fromEvent(element, 'dblclick')
844
+ .pipe(takeUntilDestroyed(this.destroyRef))
845
+ .subscribe(event => this.handleClickEdit(event));
846
+ }
847
+ fromEvent(document, 'keydown')
848
+ .pipe(filter(event => event.key === 'Enter'), takeUntilDestroyed(this.destroyRef))
849
+ .subscribe(event => this.handelEnterEvent(event));
850
+ fromEvent(element, 'keydown')
851
+ .pipe(filter(event => event.key === 'Escape'), takeUntilDestroyed(this.destroyRef))
852
+ .subscribe(() => {
853
+ this.ngZone.run(() => this.dispatcher.stopEditing());
854
+ });
855
+ fromEvent(document, 'click')
856
+ .pipe(takeUntilDestroyed(this.destroyRef))
857
+ .subscribe(event => this.handleClickOutside(event));
858
+ });
859
+ }
860
+ handleClickEdit(event) {
861
+ const target = event.target;
862
+ if (target.closest(THY_NATIVE_TABLE_EDIT_OPEN_SELECTOR)) {
863
+ return;
864
+ }
865
+ const cell = target.closest(THY_NATIVE_TABLE_CELL_SELECTOR);
866
+ if (cell) {
867
+ this.ngZone.run(() => this.dispatcher.startEditing(cell));
868
+ }
869
+ }
870
+ handelEnterEvent(event) {
871
+ const target = event.target;
872
+ if (target.closest(THY_NATIVE_TABLE_EDIT_PANE_SELECTOR)) {
873
+ if (this.dispatcher.getCurrentEditingCell()) {
874
+ event.preventDefault();
875
+ this.ngZone.run(() => this.dispatcher.stopEditing());
876
+ }
877
+ }
878
+ }
879
+ handleClickOutside(event) {
880
+ const target = event.target;
881
+ const element = this.elementRef.nativeElement;
882
+ if (!element.contains(target) && !target.closest(THY_NATIVE_TABLE_EDIT_PANE_SELECTOR)) {
883
+ this.ngZone.run(() => this.dispatcher.stopEditing());
884
+ }
885
+ }
886
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableEditableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
887
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.15", type: ThyNativeTableEditableDirective, isStandalone: true, selector: "thy-native-table[thyEditable]", inputs: { thyEditTrigger: { classPropertyName: "thyEditTrigger", publicName: "thyEditTrigger", isSignal: true, isRequired: false, transformFunction: null } }, providers: [ThyNativeTableEditEventDispatcher], ngImport: i0 }); }
888
+ }
889
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableEditableDirective, decorators: [{
890
+ type: Directive,
891
+ args: [{
892
+ selector: 'thy-native-table[thyEditable]',
893
+ providers: [ThyNativeTableEditEventDispatcher]
894
+ }]
895
+ }], propDecorators: { thyEditTrigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "thyEditTrigger", required: false }] }] } });
896
+
897
+ class ThyNativeTableTdPopoverEditDirective {
898
+ constructor() {
899
+ this.elementRef = inject((ElementRef));
900
+ this.viewContainerRef = inject(ViewContainerRef);
901
+ this.popover = inject(ThyPopover);
902
+ this.dispatcher = inject(ThyNativeTableEditEventDispatcher);
903
+ this.destroyRef = inject(DestroyRef);
904
+ }
905
+ ngAfterViewInit() {
906
+ this.dispatcher
907
+ .editingCell(this.elementRef.nativeElement)
908
+ .pipe(takeUntilDestroyed(this.destroyRef))
909
+ .subscribe(isEditing => {
910
+ if (isEditing) {
911
+ this.openPopover();
912
+ }
913
+ else {
914
+ this.closePopover();
915
+ }
916
+ });
917
+ }
918
+ openPopover() {
919
+ if (this.popoverRef) {
920
+ return;
921
+ }
922
+ if (!this.editTemplate) {
923
+ return;
924
+ }
925
+ const tdElement = this.elementRef.nativeElement;
926
+ const rect = tdElement.getBoundingClientRect();
927
+ this.popoverRef = this.popover.open(this.editTemplate, {
928
+ origin: tdElement,
929
+ viewContainerRef: this.viewContainerRef,
930
+ placement: 'bottom',
931
+ offset: -rect.height,
932
+ hasBackdrop: false,
933
+ panelClass: 'thy-native-table-popover-edit',
934
+ originActiveClass: 'thy-native-table-cell-editing',
935
+ animationDisabled: true
936
+ });
937
+ this.popoverRef?.afterOpened().subscribe(() => {
938
+ const popoverElement = document.querySelector('.thy-native-table-popover-edit');
939
+ if (popoverElement) {
940
+ popoverElement.style.width = `${rect.width}px`;
941
+ popoverElement.style.minWidth = `${rect.width}px`;
942
+ popoverElement.style.height = `${rect.height}px`;
943
+ popoverElement.style.minHeight = `${rect.height}px`;
944
+ this.listenFocusout(popoverElement);
945
+ }
946
+ });
947
+ this.popoverRef?.afterClosed().subscribe(() => {
948
+ this.popoverRef = undefined;
949
+ this.focusoutUnsubscribe?.();
950
+ });
951
+ }
952
+ listenFocusout(popoverElement) {
953
+ const handler = () => {
954
+ // 延迟 100ms 检查焦点是否还在 popover 内
955
+ // 避免在 popover 内部元素之间切换焦点时误关闭
956
+ setTimeout(() => {
957
+ if (document.activeElement && !popoverElement.contains(document.activeElement)) {
958
+ this.dispatcher.stopEditing();
959
+ }
960
+ }, 100);
961
+ };
962
+ popoverElement.addEventListener('focusout', handler);
963
+ this.focusoutUnsubscribe = () => {
964
+ popoverElement.removeEventListener('focusout', handler);
965
+ };
966
+ }
967
+ closePopover() {
968
+ this.popoverRef?.close();
969
+ }
970
+ ngOnDestroy() {
971
+ this.closePopover();
972
+ }
973
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTdPopoverEditDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
974
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: ThyNativeTableTdPopoverEditDirective, isStandalone: true, selector: "td[thyCellPopoverEdit]", inputs: { editTemplate: ["thyCellPopoverEdit", "editTemplate"] }, host: { classAttribute: "thy-native-table-cell-edit" }, providers: [ThyNativeTableEditRef], ngImport: i0 }); }
975
+ }
976
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTdPopoverEditDirective, decorators: [{
977
+ type: Directive,
978
+ args: [{
979
+ selector: 'td[thyCellPopoverEdit]',
980
+ providers: [ThyNativeTableEditRef],
981
+ host: {
982
+ class: 'thy-native-table-cell-edit'
983
+ }
984
+ }]
985
+ }], propDecorators: { editTemplate: [{
986
+ type: Input,
987
+ args: ['thyCellPopoverEdit']
988
+ }] } });
989
+
990
+ class ThyNativeTableTdEditOpenDirective {
991
+ constructor() {
992
+ this.elementRef = inject((ElementRef));
993
+ this.dispatcher = inject(ThyNativeTableEditEventDispatcher);
994
+ this.destroyRef = inject(DestroyRef);
995
+ fromEvent(this.elementRef.nativeElement, 'click')
996
+ .pipe(takeUntilDestroyed(this.destroyRef))
997
+ .subscribe((event) => {
998
+ event.stopPropagation();
999
+ const cell = this.elementRef.nativeElement.closest(THY_NATIVE_TABLE_CELL_SELECTOR);
1000
+ if (cell) {
1001
+ this.dispatcher.startEditing(cell);
1002
+ }
1003
+ });
1004
+ }
1005
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTdEditOpenDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1006
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: ThyNativeTableTdEditOpenDirective, isStandalone: true, selector: "[thyEditOpen]", ngImport: i0 }); }
1007
+ }
1008
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTdEditOpenDirective, decorators: [{
1009
+ type: Directive,
1010
+ args: [{
1011
+ selector: '[thyEditOpen]'
1012
+ }]
1013
+ }], ctorParameters: () => [] });
1014
+
1015
+ class ThyNativeTableTdEditCloseDirective {
1016
+ constructor() {
1017
+ this.editRef = inject(ThyNativeTableEditRef);
1018
+ this.elementRef = inject((ElementRef));
1019
+ this.destroyRef = inject(DestroyRef);
1020
+ fromEvent(this.elementRef.nativeElement, 'click')
1021
+ .pipe(takeUntilDestroyed(this.destroyRef))
1022
+ .subscribe(() => {
1023
+ this.editRef.close();
1024
+ });
1025
+ }
1026
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTdEditCloseDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1027
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: ThyNativeTableTdEditCloseDirective, isStandalone: true, selector: "[thyEditClose]", ngImport: i0 }); }
1028
+ }
1029
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableTdEditCloseDirective, decorators: [{
1030
+ type: Directive,
1031
+ args: [{
1032
+ selector: '[thyEditClose]'
1033
+ }]
1034
+ }], ctorParameters: () => [] });
1035
+
1036
+ const EDIT_COMPONENTS = [
1037
+ ThyNativeTableEditableDirective,
1038
+ ThyNativeTableTdEditCloseDirective,
1039
+ ThyNativeTableTdEditOpenDirective,
1040
+ ThyNativeTableTdPopoverEditDirective
1041
+ ];
1042
+ class ThyNativeTableModule {
1043
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1044
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableModule, imports: [CommonModule,
1045
+ ThyNativeTableComponent,
1046
+ ThyNativeTableInnerScrollComponent,
1047
+ ThyNativeTableInnerDefaultComponent,
1048
+ ThyNativeTableBodyComponent,
1049
+ ThyNativeTableHeaderComponent,
1050
+ ThyNativeTableTrDirective,
1051
+ ThyNativeTableCellDirective,
1052
+ ThyNativeTableThDirective,
1053
+ ThyNativeTableTdSelectionComponent,
1054
+ ThyNativeTableThSelectionComponent,
1055
+ ThyNativeTableThSortComponent, ThyNativeTableEditableDirective,
1056
+ ThyNativeTableTdEditCloseDirective,
1057
+ ThyNativeTableTdEditOpenDirective,
1058
+ ThyNativeTableTdPopoverEditDirective], exports: [ThyNativeTableComponent,
1059
+ ThyNativeTableInnerScrollComponent,
1060
+ ThyNativeTableInnerDefaultComponent,
1061
+ ThyNativeTableBodyComponent,
1062
+ ThyNativeTableHeaderComponent,
1063
+ ThyNativeTableTrDirective,
1064
+ ThyNativeTableCellDirective,
1065
+ ThyNativeTableThDirective,
1066
+ ThyNativeTableTdSelectionComponent,
1067
+ ThyNativeTableThSelectionComponent,
1068
+ ThyNativeTableThSortComponent, ThyNativeTableEditableDirective,
1069
+ ThyNativeTableTdEditCloseDirective,
1070
+ ThyNativeTableTdEditOpenDirective,
1071
+ ThyNativeTableTdPopoverEditDirective] }); }
1072
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableModule, imports: [CommonModule,
1073
+ ThyNativeTableComponent,
1074
+ ThyNativeTableBodyComponent,
1075
+ ThyNativeTableTdSelectionComponent,
1076
+ ThyNativeTableThSelectionComponent,
1077
+ ThyNativeTableThSortComponent] }); }
1078
+ }
1079
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: ThyNativeTableModule, decorators: [{
1080
+ type: NgModule,
1081
+ args: [{
1082
+ imports: [
1083
+ CommonModule,
1084
+ ThyNativeTableComponent,
1085
+ ThyNativeTableInnerScrollComponent,
1086
+ ThyNativeTableInnerDefaultComponent,
1087
+ ThyNativeTableBodyComponent,
1088
+ ThyNativeTableHeaderComponent,
1089
+ ThyNativeTableTrDirective,
1090
+ ThyNativeTableCellDirective,
1091
+ ThyNativeTableThDirective,
1092
+ ThyNativeTableTdSelectionComponent,
1093
+ ThyNativeTableThSelectionComponent,
1094
+ ThyNativeTableThSortComponent,
1095
+ ...EDIT_COMPONENTS
1096
+ ],
1097
+ exports: [
1098
+ ThyNativeTableComponent,
1099
+ ThyNativeTableInnerScrollComponent,
1100
+ ThyNativeTableInnerDefaultComponent,
1101
+ ThyNativeTableBodyComponent,
1102
+ ThyNativeTableHeaderComponent,
1103
+ ThyNativeTableTrDirective,
1104
+ ThyNativeTableCellDirective,
1105
+ ThyNativeTableThDirective,
1106
+ ThyNativeTableTdSelectionComponent,
1107
+ ThyNativeTableThSelectionComponent,
1108
+ ThyNativeTableThSortComponent,
1109
+ ...EDIT_COMPONENTS
1110
+ ]
1111
+ }]
1112
+ }] });
1113
+
1114
+ /**
1115
+ * Generated bundle index. Do not edit.
1116
+ */
1117
+
1118
+ export { THY_NATIVE_TABLE_CELL_SELECTOR, THY_NATIVE_TABLE_EDIT_OPEN_SELECTOR, THY_NATIVE_TABLE_EDIT_PANE_SELECTOR, ThyNativeTableBodyComponent, ThyNativeTableCellDirective, ThyNativeTableComponent, ThyNativeTableContentComponent, ThyNativeTableEditEventDispatcher, ThyNativeTableEditRef, ThyNativeTableEditTrigger, ThyNativeTableEditableDirective, ThyNativeTableHeaderComponent, ThyNativeTableInnerDefaultComponent, ThyNativeTableInnerScrollComponent, ThyNativeTableModule, ThyNativeTableStyleService, ThyNativeTableTdEditCloseDirective, ThyNativeTableTdEditOpenDirective, ThyNativeTableTdPopoverEditDirective, ThyNativeTableTdSelectionComponent, ThyNativeTableThDirective, ThyNativeTableThSelectionComponent, ThyNativeTableThSortComponent, ThyNativeTableTrDirective };
1119
+ //# sourceMappingURL=ngx-tethys-native-table.mjs.map