@i-cell/ids-angular 0.0.0-watch
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/accordion/index.d.ts +81 -0
- package/accordion/package.json +3 -0
- package/avatar/index.d.ts +66 -0
- package/avatar/package.json +3 -0
- package/badge/index.d.ts +61 -0
- package/badge/package.json +3 -0
- package/breadcrumb/index.d.ts +67 -0
- package/breadcrumb/package.json +3 -0
- package/button/index.d.ts +81 -0
- package/button/package.json +3 -0
- package/card/index.d.ts +91 -0
- package/card/package.json +3 -0
- package/checkbox/index.d.ts +137 -0
- package/checkbox/package.json +3 -0
- package/chip/index.d.ts +82 -0
- package/chip/package.json +3 -0
- package/core/index.d.ts +168 -0
- package/core/package.json +3 -0
- package/datepicker/index.d.ts +112 -0
- package/datepicker/package.json +3 -0
- package/dialog/index.d.ts +72 -0
- package/dialog/package.json +3 -0
- package/divider/index.d.ts +45 -0
- package/divider/package.json +3 -0
- package/fesm2022/i-cell-ids-angular-accordion.mjs +223 -0
- package/fesm2022/i-cell-ids-angular-accordion.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-avatar.mjs +125 -0
- package/fesm2022/i-cell-ids-angular-avatar.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-badge.mjs +172 -0
- package/fesm2022/i-cell-ids-angular-badge.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-breadcrumb.mjs +313 -0
- package/fesm2022/i-cell-ids-angular-breadcrumb.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-button.mjs +149 -0
- package/fesm2022/i-cell-ids-angular-button.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-card.mjs +222 -0
- package/fesm2022/i-cell-ids-angular-card.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-checkbox.mjs +350 -0
- package/fesm2022/i-cell-ids-angular-checkbox.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-chip.mjs +166 -0
- package/fesm2022/i-cell-ids-angular-chip.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-core.mjs +409 -0
- package/fesm2022/i-cell-ids-angular-core.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-datepicker.mjs +860 -0
- package/fesm2022/i-cell-ids-angular-datepicker.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-dialog.mjs +183 -0
- package/fesm2022/i-cell-ids-angular-dialog.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-divider.mjs +76 -0
- package/fesm2022/i-cell-ids-angular-divider.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-forms.mjs +972 -0
- package/fesm2022/i-cell-ids-angular-forms.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-icon-button.mjs +120 -0
- package/fesm2022/i-cell-ids-angular-icon-button.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-icon.mjs +158 -0
- package/fesm2022/i-cell-ids-angular-icon.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-menu.mjs +154 -0
- package/fesm2022/i-cell-ids-angular-menu.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-notification.mjs +167 -0
- package/fesm2022/i-cell-ids-angular-notification.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-overlay-panel.mjs +72 -0
- package/fesm2022/i-cell-ids-angular-overlay-panel.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-paginator.mjs +319 -0
- package/fesm2022/i-cell-ids-angular-paginator.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-radio.mjs +312 -0
- package/fesm2022/i-cell-ids-angular-radio.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-segmented-control-toggle.mjs +264 -0
- package/fesm2022/i-cell-ids-angular-segmented-control-toggle.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-segmented-control.mjs +283 -0
- package/fesm2022/i-cell-ids-angular-segmented-control.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-select.mjs +549 -0
- package/fesm2022/i-cell-ids-angular-select.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-side-nav.mjs +375 -0
- package/fesm2022/i-cell-ids-angular-side-nav.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-side-sheet.mjs +179 -0
- package/fesm2022/i-cell-ids-angular-side-sheet.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-snackbar.mjs +440 -0
- package/fesm2022/i-cell-ids-angular-snackbar.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-spinner.mjs +67 -0
- package/fesm2022/i-cell-ids-angular-spinner.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-switch.mjs +181 -0
- package/fesm2022/i-cell-ids-angular-switch.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-tab.mjs +142 -0
- package/fesm2022/i-cell-ids-angular-tab.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-table.mjs +663 -0
- package/fesm2022/i-cell-ids-angular-table.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-tag.mjs +116 -0
- package/fesm2022/i-cell-ids-angular-tag.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular-tooltip.mjs +586 -0
- package/fesm2022/i-cell-ids-angular-tooltip.mjs.map +1 -0
- package/fesm2022/i-cell-ids-angular.mjs +9 -0
- package/fesm2022/i-cell-ids-angular.mjs.map +1 -0
- package/forms/index.d.ts +470 -0
- package/forms/package.json +3 -0
- package/icon/index.d.ts +69 -0
- package/icon/package.json +3 -0
- package/icon-button/index.d.ts +68 -0
- package/icon-button/package.json +3 -0
- package/index.d.ts +2 -0
- package/menu/index.d.ts +68 -0
- package/menu/package.json +3 -0
- package/notification/index.d.ts +68 -0
- package/notification/package.json +3 -0
- package/overlay-panel/index.d.ts +41 -0
- package/overlay-panel/package.json +3 -0
- package/package.json +180 -0
- package/paginator/index.d.ts +122 -0
- package/paginator/package.json +3 -0
- package/radio/index.d.ts +95 -0
- package/radio/package.json +3 -0
- package/segmented-control/index.d.ts +98 -0
- package/segmented-control/package.json +3 -0
- package/segmented-control-toggle/index.d.ts +103 -0
- package/segmented-control-toggle/package.json +3 -0
- package/select/index.d.ts +103 -0
- package/select/package.json +3 -0
- package/side-nav/index.d.ts +107 -0
- package/side-nav/package.json +3 -0
- package/side-sheet/index.d.ts +84 -0
- package/side-sheet/package.json +3 -0
- package/snackbar/index.d.ts +149 -0
- package/snackbar/package.json +3 -0
- package/spinner/index.d.ts +41 -0
- package/spinner/package.json +3 -0
- package/switch/index.d.ts +89 -0
- package/switch/package.json +3 -0
- package/tab/index.d.ts +78 -0
- package/tab/package.json +3 -0
- package/table/index.d.ts +393 -0
- package/table/package.json +3 -0
- package/tag/index.d.ts +70 -0
- package/tag/package.json +3 -0
- package/tooltip/index.d.ts +96 -0
- package/tooltip/package.json +3 -0
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
import { DEFAULT_PAGE_SIZE } from '@i-cell/ids-angular/paginator';
|
|
2
|
+
import { BehaviorSubject, Subject, map, merge, debounceTime, switchMap, Observable, catchError, of, tap, finalize, startWith } from 'rxjs';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { input, Directive, inject, TemplateRef, InjectionToken, Injectable, Optional, SkipSelf, ElementRef, computed, signal, Component, ChangeDetectorRef, viewChildren, contentChildren, output, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
|
|
5
|
+
import { isTypeDerivedFrom, isString, IdsSize, ComponentBaseWithDefaults, coerceBooleanAttribute } from '@i-cell/ids-angular/core';
|
|
6
|
+
import { NgComponentOutlet, NgTemplateOutlet, NgClass } from '@angular/common';
|
|
7
|
+
import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
8
|
+
import { IdsIconComponent } from '@i-cell/ids-angular/icon';
|
|
9
|
+
import { trigger, state, transition, style, animate } from '@angular/animations';
|
|
10
|
+
import { SelectionModel } from '@angular/cdk/collections';
|
|
11
|
+
import { CdkCell, CdkCellDef, CdkColumnDef, CdkHeaderCell, CdkHeaderCellDef, CdkHeaderRow, CdkHeaderRowDef, CdkNoDataRow, CdkRow, CdkRowDef, CdkTable } from '@angular/cdk/table';
|
|
12
|
+
import { IdsCheckboxComponent } from '@i-cell/ids-angular/checkbox';
|
|
13
|
+
import { IdsIconButtonVariant, IdsIconButtonAppearance, IdsIconButtonComponent, IDS_ICON_BUTTON_PARENT } from '@i-cell/ids-angular/icon-button';
|
|
14
|
+
|
|
15
|
+
const DEFAULT_DATA_LOAD_DEBOUNCE_TIME = 100;
|
|
16
|
+
class ServerSideDataSource {
|
|
17
|
+
get data() {
|
|
18
|
+
return this._dataSubject.value;
|
|
19
|
+
}
|
|
20
|
+
set data(value) {
|
|
21
|
+
this._dataSubject.next(value);
|
|
22
|
+
}
|
|
23
|
+
get pageInfo() {
|
|
24
|
+
return this._pageInfoSubject.value;
|
|
25
|
+
}
|
|
26
|
+
set pageInfo(value) {
|
|
27
|
+
this._pageInfoSubject.next(value);
|
|
28
|
+
}
|
|
29
|
+
get length() {
|
|
30
|
+
return this.data.length;
|
|
31
|
+
}
|
|
32
|
+
constructor(_requestFactory, _resetDataAndPagingOnError = false) {
|
|
33
|
+
this._requestFactory = _requestFactory;
|
|
34
|
+
this._resetDataAndPagingOnError = _resetDataAndPagingOnError;
|
|
35
|
+
this._dataSubject = new BehaviorSubject([]);
|
|
36
|
+
this._sortSubject = new BehaviorSubject(null);
|
|
37
|
+
this._pageSubject = new BehaviorSubject(null);
|
|
38
|
+
this._pageInfoSubject = new BehaviorSubject(null);
|
|
39
|
+
this._loadDataTriggerSubject = new Subject();
|
|
40
|
+
this._loadingSubject = new BehaviorSubject(false);
|
|
41
|
+
this.data$ = this._dataSubject.asObservable();
|
|
42
|
+
this.isLoading$ = this._loadingSubject.asObservable();
|
|
43
|
+
this.pageInfo$ = this._pageInfoSubject.asObservable();
|
|
44
|
+
this.pageIndex$ = this.pageInfo$.pipe(map((pageInfo) => ((pageInfo?.page ?? 1) - 1)));
|
|
45
|
+
}
|
|
46
|
+
connect() {
|
|
47
|
+
this._initDataLoading();
|
|
48
|
+
this.refreshData();
|
|
49
|
+
return this.data$;
|
|
50
|
+
}
|
|
51
|
+
disconnect() {
|
|
52
|
+
this._dataSubject.complete();
|
|
53
|
+
this._sortSubject.complete();
|
|
54
|
+
this._loadingSubject.complete();
|
|
55
|
+
this._loadDataSubscription?.unsubscribe();
|
|
56
|
+
}
|
|
57
|
+
sort(sortInfo) {
|
|
58
|
+
// sorting resets the "page" to 1 (TODO: config option?)
|
|
59
|
+
this._pageSubject.next({
|
|
60
|
+
page: 1,
|
|
61
|
+
rows: this._pageSubject.value?.rows ?? DEFAULT_PAGE_SIZE,
|
|
62
|
+
});
|
|
63
|
+
this._sortSubject.next(sortInfo ?? null);
|
|
64
|
+
}
|
|
65
|
+
page(pageEvent) {
|
|
66
|
+
this._pageSubject.next(pageEvent ? {
|
|
67
|
+
page: pageEvent.pageIndex + 1,
|
|
68
|
+
rows: pageEvent.pageSize,
|
|
69
|
+
} : null);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Loads data from specified endpoint.
|
|
73
|
+
*/
|
|
74
|
+
refreshData() {
|
|
75
|
+
this._loadDataTriggerSubject.next();
|
|
76
|
+
}
|
|
77
|
+
_initDataLoading() {
|
|
78
|
+
this._loadDataSubscription = merge(this._sortSubject, this._pageSubject, this._loadDataTriggerSubject)
|
|
79
|
+
.pipe(debounceTime(DEFAULT_DATA_LOAD_DEBOUNCE_TIME), switchMap(() => {
|
|
80
|
+
this._loadingSubject.next(true);
|
|
81
|
+
const pageInfo = this.pageInfo;
|
|
82
|
+
const paginationData = this._pageSubject.value;
|
|
83
|
+
let requestPaginationData = null;
|
|
84
|
+
if (pageInfo || paginationData) {
|
|
85
|
+
requestPaginationData = {
|
|
86
|
+
page: paginationData?.page ?? pageInfo?.page ?? 1,
|
|
87
|
+
rows: paginationData?.rows ?? pageInfo?.rows ?? DEFAULT_PAGE_SIZE,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const request$ = this._requestFactory(requestPaginationData, this._sortSubject.value);
|
|
91
|
+
if (!(request$ instanceof Observable)) {
|
|
92
|
+
throw new Error('The `requestFactory` should return an Observable!');
|
|
93
|
+
}
|
|
94
|
+
return request$.pipe(catchError(() => of(this._resetDataAndPagingOnError ?
|
|
95
|
+
{
|
|
96
|
+
resultList: [],
|
|
97
|
+
paginationParams: {
|
|
98
|
+
page: 1,
|
|
99
|
+
totalRows: 0,
|
|
100
|
+
rows: this.pageInfo?.rows ?? DEFAULT_PAGE_SIZE,
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
:
|
|
104
|
+
{
|
|
105
|
+
resultList: this.data,
|
|
106
|
+
paginationParams: this.pageInfo,
|
|
107
|
+
})), tap((response) => {
|
|
108
|
+
this.data = response.resultList ?? [];
|
|
109
|
+
this._pageInfoSubject.next(response.paginationParams);
|
|
110
|
+
}), finalize(() => this._loadingSubject.next(false)));
|
|
111
|
+
})).subscribe();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
class IdsTableCellRenderer {
|
|
116
|
+
constructor() {
|
|
117
|
+
this._entities = [
|
|
118
|
+
{ rx: '&', entity: '&' },
|
|
119
|
+
{ rx: '<', entity: '<' },
|
|
120
|
+
{ rx: '>', entity: '>' },
|
|
121
|
+
{ rx: '"', entity: '"' },
|
|
122
|
+
{ rx: '\'', entity: ''' },
|
|
123
|
+
{ rx: '/', entity: '/' },
|
|
124
|
+
];
|
|
125
|
+
this.cellValue = input('', ...(ngDevMode ? [{ debugName: "cellValue", transform: (value) => this._preSanitize(String(value ?? '')) }] : [{ transform: (value) => this._preSanitize(String(value ?? '')) }]));
|
|
126
|
+
this.colDef = input.required(...(ngDevMode ? [{ debugName: "colDef" }] : []));
|
|
127
|
+
this.rowData = input(...(ngDevMode ? [undefined, { debugName: "rowData" }] : []));
|
|
128
|
+
}
|
|
129
|
+
_isComponentCellRenderer(cellRendererDef) {
|
|
130
|
+
return !!cellRendererDef && !isString(cellRendererDef) && isTypeDerivedFrom(cellRendererDef, IdsTableCellRenderer);
|
|
131
|
+
}
|
|
132
|
+
_preSanitize(input) {
|
|
133
|
+
if (!input) {
|
|
134
|
+
return input;
|
|
135
|
+
}
|
|
136
|
+
// Convert & to &, Convert < to <, Convert > to >, Convert " to ", Convert ' to ', Convert / to /
|
|
137
|
+
return this._entities.reduce((result, item) => result.replaceAll(item.rx, item.entity), input);
|
|
138
|
+
}
|
|
139
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableCellRenderer, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
140
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.7", type: IdsTableCellRenderer, isStandalone: true, inputs: { cellValue: { classPropertyName: "cellValue", publicName: "cellValue", isSignal: true, isRequired: false, transformFunction: null }, colDef: { classPropertyName: "colDef", publicName: "colDef", isSignal: true, isRequired: true, transformFunction: null }, rowData: { classPropertyName: "rowData", publicName: "rowData", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
141
|
+
}
|
|
142
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableCellRenderer, decorators: [{
|
|
143
|
+
type: Directive
|
|
144
|
+
}] });
|
|
145
|
+
|
|
146
|
+
class IdsTableCellTemplateDirective {
|
|
147
|
+
constructor() {
|
|
148
|
+
this.templateName = input.required(...(ngDevMode ? [{ debugName: "templateName", alias: 'idsCellTemplate' }] : [{ alias: 'idsCellTemplate' }]));
|
|
149
|
+
this.templateRef = inject(TemplateRef);
|
|
150
|
+
}
|
|
151
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableCellTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
152
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.7", type: IdsTableCellTemplateDirective, isStandalone: true, selector: "[idsCellTemplate]", inputs: { templateName: { classPropertyName: "templateName", publicName: "idsCellTemplate", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
|
|
153
|
+
}
|
|
154
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableCellTemplateDirective, decorators: [{
|
|
155
|
+
type: Directive,
|
|
156
|
+
args: [{
|
|
157
|
+
selector: '[idsCellTemplate]',
|
|
158
|
+
standalone: true,
|
|
159
|
+
}]
|
|
160
|
+
}] });
|
|
161
|
+
|
|
162
|
+
const IdsTableAppearance = {
|
|
163
|
+
PLAIN: 'plain',
|
|
164
|
+
LINE_DIVISION: 'line-division',
|
|
165
|
+
ZEBRA: 'zebra',
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const IdsTableSortDirection = {
|
|
169
|
+
NONE: '',
|
|
170
|
+
ASC: 'asc',
|
|
171
|
+
DESC: 'desc',
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
class IdsTableSortInfo {
|
|
175
|
+
constructor(sortBy, direction) {
|
|
176
|
+
this.sortBy = sortBy;
|
|
177
|
+
this.direction = direction;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const IdsTableVariant = {
|
|
182
|
+
PRIMARY: 'primary',
|
|
183
|
+
SECONDARY: 'secondary',
|
|
184
|
+
SURFACE: 'surface',
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const DEFAULT_MASTER_DETAIL_TEMPLATE_NAME = 'detail';
|
|
188
|
+
const IDS_TABLE_DEFAULT_CONFIG = new InjectionToken('IDS_TABLE_DEFAULT_CONFIG', {
|
|
189
|
+
providedIn: 'root',
|
|
190
|
+
factory: IDS_TABLE_DEFAULT_CONFIG_FACTORY,
|
|
191
|
+
});
|
|
192
|
+
function IDS_TABLE_DEFAULT_CONFIG_FACTORY() {
|
|
193
|
+
return {
|
|
194
|
+
appearance: IdsTableAppearance.LINE_DIVISION,
|
|
195
|
+
size: IdsSize.COMPACT,
|
|
196
|
+
variant: IdsTableVariant.SURFACE,
|
|
197
|
+
fixedHeader: false,
|
|
198
|
+
enableSorting: false,
|
|
199
|
+
masterDetail: false,
|
|
200
|
+
detailTemplateName: DEFAULT_MASTER_DETAIL_TEMPLATE_NAME,
|
|
201
|
+
detailStickyColumns: true,
|
|
202
|
+
showDetailHeader: false,
|
|
203
|
+
enableRowSelection: false,
|
|
204
|
+
clearSelectionOnChange: true,
|
|
205
|
+
noRowsToShowOverlayBelow: false,
|
|
206
|
+
withBorder: false,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
class IdsTableIntl {
|
|
211
|
+
constructor() {
|
|
212
|
+
this.changes = new Subject();
|
|
213
|
+
this.numberFormat = new Intl.NumberFormat();
|
|
214
|
+
this.headerSelectorAriaLabel = 'Select/deselect all rows';
|
|
215
|
+
this.rowSelectorAriaLabel = 'Select/deselect row';
|
|
216
|
+
this.detailHeaderLabel = 'Actions';
|
|
217
|
+
}
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
219
|
+
getDetailExpandButtonAriaLabel(rowData) {
|
|
220
|
+
return 'Expand row details';
|
|
221
|
+
}
|
|
222
|
+
getSortButtonAriaLabel(colDef, nextSortDirection) {
|
|
223
|
+
const label = this.getColLabel(colDef);
|
|
224
|
+
switch (nextSortDirection) {
|
|
225
|
+
case IdsTableSortDirection.NONE:
|
|
226
|
+
return `Unsort ${label}`;
|
|
227
|
+
case IdsTableSortDirection.ASC:
|
|
228
|
+
return `Sort ${label} ascending`;
|
|
229
|
+
case IdsTableSortDirection.DESC:
|
|
230
|
+
return `Sort ${label} descending`;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
;
|
|
234
|
+
getColLabel(colDef) {
|
|
235
|
+
return colDef.label || '';
|
|
236
|
+
}
|
|
237
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableIntl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
238
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableIntl, providedIn: 'root' }); }
|
|
239
|
+
}
|
|
240
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableIntl, decorators: [{
|
|
241
|
+
type: Injectable,
|
|
242
|
+
args: [{ providedIn: 'root' }]
|
|
243
|
+
}] });
|
|
244
|
+
/** @docs-private */
|
|
245
|
+
function IDS_TABLE_INTL_PROVIDER_FACTORY(parentIntl) {
|
|
246
|
+
return parentIntl || new IdsTableIntl();
|
|
247
|
+
}
|
|
248
|
+
/** @docs-private */
|
|
249
|
+
const IDS_TABLE_INTL_PROVIDER = {
|
|
250
|
+
// If there is already an IdsTableIntl available, use that. Otherwise, provide a new one.
|
|
251
|
+
provide: IdsTableIntl,
|
|
252
|
+
deps: [
|
|
253
|
+
[
|
|
254
|
+
new Optional(),
|
|
255
|
+
new SkipSelf(),
|
|
256
|
+
IdsTableIntl,
|
|
257
|
+
],
|
|
258
|
+
],
|
|
259
|
+
useFactory: IDS_TABLE_INTL_PROVIDER_FACTORY,
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* This component handles the rendering of a table cell based on the column definition and row data using internal or external cell renderer
|
|
264
|
+
* templates or components.
|
|
265
|
+
*/
|
|
266
|
+
class IdsCellContentComponent extends IdsTableCellRenderer {
|
|
267
|
+
constructor() {
|
|
268
|
+
super(...arguments);
|
|
269
|
+
this._elementRef = inject(ElementRef);
|
|
270
|
+
this._intl = inject(IdsTableIntl);
|
|
271
|
+
this._isHeader = this._elementRef.nativeElement.hasAttribute('idsHeaderCellContent');
|
|
272
|
+
this._numberFormat = toSignal(this._intl.changes.pipe(map(() => this._intl.numberFormat), startWith(this._intl.numberFormat)));
|
|
273
|
+
this.externalCellTemplates = input(...(ngDevMode ? [undefined, { debugName: "externalCellTemplates" }] : []));
|
|
274
|
+
this._cellRendererDef = computed(() => (this._isHeader ? this.colDef().headerCellRenderer : this.colDef().cellRenderer), ...(ngDevMode ? [{ debugName: "_cellRendererDef" }] : []));
|
|
275
|
+
this._updateCellContent = signal(true, ...(ngDevMode ? [{ debugName: "_updateCellContent" }] : []));
|
|
276
|
+
this._cellValue = computed(() => {
|
|
277
|
+
// Forces recalculation of this computed signal
|
|
278
|
+
this._updateCellContent();
|
|
279
|
+
if (this._isHeader) {
|
|
280
|
+
return this.colDef().label ?? '';
|
|
281
|
+
}
|
|
282
|
+
const rowData = this.rowData();
|
|
283
|
+
if (!rowData) {
|
|
284
|
+
return '';
|
|
285
|
+
}
|
|
286
|
+
const field = this.colDef().field ?? '';
|
|
287
|
+
const valueFn = this.colDef().value ?? (() => '');
|
|
288
|
+
const rawResult = field && Object.hasOwn(rowData, field) ? rowData[field] : valueFn(rowData);
|
|
289
|
+
return isString(rawResult) ? this._preSanitize(rawResult) : rawResult;
|
|
290
|
+
}, ...(ngDevMode ? [{ debugName: "_cellValue" }] : []));
|
|
291
|
+
this._stringCellValue = computed(() => String(this._cellValue() ?? ''), ...(ngDevMode ? [{ debugName: "_stringCellValue" }] : []));
|
|
292
|
+
this._numericCellValue = computed(() => {
|
|
293
|
+
const stringValue = this._stringCellValue();
|
|
294
|
+
return this._numberFormat()?.format(parseFloat(stringValue)) ?? stringValue;
|
|
295
|
+
}, ...(ngDevMode ? [{ debugName: "_numericCellValue" }] : []));
|
|
296
|
+
this._cellRendererComp = computed(() => {
|
|
297
|
+
const renderer = this._cellRendererDef();
|
|
298
|
+
if (this._isComponentCellRenderer(renderer)) {
|
|
299
|
+
return renderer;
|
|
300
|
+
}
|
|
301
|
+
return null;
|
|
302
|
+
}, ...(ngDevMode ? [{ debugName: "_cellRendererComp" }] : []));
|
|
303
|
+
this._cellTemplateName = computed(() => {
|
|
304
|
+
if (isString(this._cellRendererDef())) {
|
|
305
|
+
return this._cellRendererDef();
|
|
306
|
+
}
|
|
307
|
+
return undefined;
|
|
308
|
+
}, ...(ngDevMode ? [{ debugName: "_cellTemplateName" }] : []));
|
|
309
|
+
this._cellTemplate = computed(() => {
|
|
310
|
+
const templateName = this._cellTemplateName();
|
|
311
|
+
const templates = this.externalCellTemplates();
|
|
312
|
+
return isString(templateName) && templates?.has(templateName) ? templates.get(templateName) ?? null : null;
|
|
313
|
+
}, ...(ngDevMode ? [{ debugName: "_cellTemplate" }] : []));
|
|
314
|
+
}
|
|
315
|
+
updateValue() {
|
|
316
|
+
this._updateCellContent.set(!this._updateCellContent());
|
|
317
|
+
}
|
|
318
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsCellContentComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
319
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.7", type: IdsCellContentComponent, isStandalone: true, selector: "th[idsCellContent],td[idsCellContent],th[idsHeaderCellContent],td[idsHeaderCellContent]", inputs: { externalCellTemplates: { classPropertyName: "externalCellTemplates", publicName: "externalCellTemplates", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0, template: "<ng-content select=\"[colStart]\" />\r\n\r\n@if (_cellRendererComp()) {\r\n <ng-container *ngComponentOutlet=\"_cellRendererComp(); inputs: { rowData: rowData(), colDef: colDef(), cellValue: _cellValue() }\" />\r\n} @else {\r\n @switch (_cellTemplateName()) {\r\n @case ('strong') {\r\n <strong class=\"ids-cell-content ids-cell-content__strong\">{{ _cellValue() }}</strong>\r\n }\r\n @case ('numeric') {\r\n <div class=\"ids-cell-content ids-cell-content__numeric\">{{ _numericCellValue() }}</div>\r\n }\r\n @case ('icon') {\r\n <ids-icon\r\n class=\"ids-cell-content ids-cell-content__icon\"\r\n [fontIcon]=\"_stringCellValue()\"\r\n [aria-hidden]=\"true\"\r\n />\r\n }\r\n <!-- TODO: label-description template (needs further discussion) -->\r\n @default {\r\n @let template = _cellTemplate();\r\n @if (template) {\r\n <!-- external template ref -->\r\n <ng-container *ngTemplateOutlet=\"template; context: { $implicit: rowData(), colDef: colDef(), cellValue: _cellValue() }\" />\r\n } @else {\r\n <!-- default basic cell content -->\r\n <div class=\"ids-cell-content ids-cell-content__default\">{{ _cellValue() }}</div>\r\n }\r\n }\r\n }\r\n}\r\n\r\n<ng-content select=\"[colEnd]\" />\r\n", dependencies: [{ kind: "component", type: IdsIconComponent, selector: "ids-icon", inputs: ["size", "sizeCollection", "variant", "fontIcon", "svgIcon", "aria-hidden"] }, { kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"], exportAs: ["ngComponentOutlet"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
320
|
+
}
|
|
321
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsCellContentComponent, decorators: [{
|
|
322
|
+
type: Component,
|
|
323
|
+
args: [{ selector: 'th[idsCellContent],td[idsCellContent],th[idsHeaderCellContent],td[idsHeaderCellContent]', imports: [
|
|
324
|
+
IdsIconComponent,
|
|
325
|
+
NgComponentOutlet,
|
|
326
|
+
NgTemplateOutlet,
|
|
327
|
+
], template: "<ng-content select=\"[colStart]\" />\r\n\r\n@if (_cellRendererComp()) {\r\n <ng-container *ngComponentOutlet=\"_cellRendererComp(); inputs: { rowData: rowData(), colDef: colDef(), cellValue: _cellValue() }\" />\r\n} @else {\r\n @switch (_cellTemplateName()) {\r\n @case ('strong') {\r\n <strong class=\"ids-cell-content ids-cell-content__strong\">{{ _cellValue() }}</strong>\r\n }\r\n @case ('numeric') {\r\n <div class=\"ids-cell-content ids-cell-content__numeric\">{{ _numericCellValue() }}</div>\r\n }\r\n @case ('icon') {\r\n <ids-icon\r\n class=\"ids-cell-content ids-cell-content__icon\"\r\n [fontIcon]=\"_stringCellValue()\"\r\n [aria-hidden]=\"true\"\r\n />\r\n }\r\n <!-- TODO: label-description template (needs further discussion) -->\r\n @default {\r\n @let template = _cellTemplate();\r\n @if (template) {\r\n <!-- external template ref -->\r\n <ng-container *ngTemplateOutlet=\"template; context: { $implicit: rowData(), colDef: colDef(), cellValue: _cellValue() }\" />\r\n } @else {\r\n <!-- default basic cell content -->\r\n <div class=\"ids-cell-content ids-cell-content__default\">{{ _cellValue() }}</div>\r\n }\r\n }\r\n }\r\n}\r\n\r\n<ng-content select=\"[colEnd]\" />\r\n" }]
|
|
328
|
+
}] });
|
|
329
|
+
|
|
330
|
+
class RowInfoHolderDirective {
|
|
331
|
+
constructor() {
|
|
332
|
+
this.rowInfo = input.required(...(ngDevMode ? [{ debugName: "rowInfo" }] : []));
|
|
333
|
+
}
|
|
334
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RowInfoHolderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
335
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.1.7", type: RowInfoHolderDirective, isStandalone: true, selector: "[rowInfo]", inputs: { rowInfo: { classPropertyName: "rowInfo", publicName: "rowInfo", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
|
|
336
|
+
}
|
|
337
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RowInfoHolderDirective, decorators: [{
|
|
338
|
+
type: Directive,
|
|
339
|
+
args: [{
|
|
340
|
+
selector: '[rowInfo]',
|
|
341
|
+
standalone: true,
|
|
342
|
+
}]
|
|
343
|
+
}] });
|
|
344
|
+
|
|
345
|
+
const defaultConfig = IDS_TABLE_DEFAULT_CONFIG_FACTORY();
|
|
346
|
+
class IdsTableComponent extends ComponentBaseWithDefaults {
|
|
347
|
+
constructor() {
|
|
348
|
+
super(...arguments);
|
|
349
|
+
this._sortDirections = [
|
|
350
|
+
'',
|
|
351
|
+
'asc',
|
|
352
|
+
'desc',
|
|
353
|
+
];
|
|
354
|
+
this._appearanceZebra = IdsTableAppearance.ZEBRA;
|
|
355
|
+
this._defaultMasterDetailTemplateName = DEFAULT_MASTER_DETAIL_TEMPLATE_NAME;
|
|
356
|
+
this._defaultConfig = this._getDefaultConfig(defaultConfig, IDS_TABLE_DEFAULT_CONFIG);
|
|
357
|
+
this._cdRef = inject(ChangeDetectorRef);
|
|
358
|
+
this._intl = inject(IdsTableIntl);
|
|
359
|
+
this._viewCellTemplates = viewChildren(IdsTableCellTemplateDirective, ...(ngDevMode ? [{ debugName: "_viewCellTemplates" }] : []));
|
|
360
|
+
this._rowDataHolders = viewChildren((RowInfoHolderDirective), ...(ngDevMode ? [{ debugName: "_rowDataHolders" }] : []));
|
|
361
|
+
this._selectorCheckboxes = viewChildren(IdsCheckboxComponent, ...(ngDevMode ? [{ debugName: "_selectorCheckboxes" }] : []));
|
|
362
|
+
this._cellContentRenderers = viewChildren((IdsCellContentComponent), ...(ngDevMode ? [{ debugName: "_cellContentRenderers" }] : []));
|
|
363
|
+
this._contentCellTemplates = contentChildren(IdsTableCellTemplateDirective, ...(ngDevMode ? [{ debugName: "_contentCellTemplates" }] : []));
|
|
364
|
+
this.columnDefs = input.required(...(ngDevMode ? [{ debugName: "columnDefs" }] : []));
|
|
365
|
+
this.dataSource = input.required(...(ngDevMode ? [{ debugName: "dataSource" }] : []));
|
|
366
|
+
/** Flag to have sticky header. */
|
|
367
|
+
this.fixedHeader = input(this._defaultConfig.fixedHeader, ...(ngDevMode ? [{ debugName: "fixedHeader", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
368
|
+
/** Enable sorting feature */
|
|
369
|
+
this.enableSorting = input(this._defaultConfig.enableSorting, ...(ngDevMode ? [{ debugName: "enableSorting", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
370
|
+
/** Enable master-detail rows */
|
|
371
|
+
this.masterDetail = input(this._defaultConfig.masterDetail, ...(ngDevMode ? [{ debugName: "masterDetail", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
372
|
+
/** Name of the detail row renderer template */
|
|
373
|
+
this.detailTemplateName = input(this._defaultConfig.detailTemplateName, ...(ngDevMode ? [{ debugName: "detailTemplateName" }] : []));
|
|
374
|
+
/** If true the detail cell will not span sticky and stickyEnd columns. If false the detail cell will span the table's full width */
|
|
375
|
+
this.detailStickyColumns = input(this._defaultConfig.detailStickyColumns, ...(ngDevMode ? [{ debugName: "detailStickyColumns", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
376
|
+
/** Whether to show the master-detail column label or not. */
|
|
377
|
+
this.showDetailHeader = input(this._defaultConfig.showDetailHeader, ...(ngDevMode ? [{ debugName: "showDetailHeader", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
378
|
+
/** Predicate function to decide whether a data row has details or not */
|
|
379
|
+
this.hasDetailRow = input(() => false, ...(ngDevMode ? [{ debugName: "hasDetailRow" }] : []));
|
|
380
|
+
/** Enable row selection feature */
|
|
381
|
+
this.enableRowSelection = input(this._defaultConfig.enableRowSelection, ...(ngDevMode ? [{ debugName: "enableRowSelection", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
382
|
+
/** Clear row selection if the table's content changes */
|
|
383
|
+
this.clearSelectionOnChange = input(this._defaultConfig.clearSelectionOnChange, ...(ngDevMode ? [{ debugName: "clearSelectionOnChange", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
384
|
+
/** Predicate function to decide whether a row can be selected or not */
|
|
385
|
+
this.isRowSelectable = input(() => true, ...(ngDevMode ? [{ debugName: "isRowSelectable" }] : []));
|
|
386
|
+
/** Render "no rows to show" overlay below the table instead of as a row */
|
|
387
|
+
this.noRowsToShowOverlayBelow = input(this._defaultConfig.noRowsToShowOverlayBelow, ...(ngDevMode ? [{ debugName: "noRowsToShowOverlayBelow", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
388
|
+
/** Whether to show a border around the table or not. */
|
|
389
|
+
this.withBorder = input(this._defaultConfig.withBorder, ...(ngDevMode ? [{ debugName: "withBorder", transform: coerceBooleanAttribute }] : [{ transform: coerceBooleanAttribute }]));
|
|
390
|
+
/**
|
|
391
|
+
* The table's appearance type. Availabla options:
|
|
392
|
+
* - "line-division": row backgrounds are uniformly colored and divided by thin border lines
|
|
393
|
+
* - "zebra": the backgrounds of even and odd rows are different colors
|
|
394
|
+
* - "plain": row backgrounds are uniformly colored without border lines
|
|
395
|
+
*/
|
|
396
|
+
this.appearance = input(this._defaultConfig.appearance, ...(ngDevMode ? [{ debugName: "appearance" }] : []));
|
|
397
|
+
/** The size type of the table. Affects paddings, margins, gaps, typography, etc. */
|
|
398
|
+
this.size = input(this._defaultConfig.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
399
|
+
/** The color variant of the table. Availabla options: "primary", "secondary", "surface" */
|
|
400
|
+
this.variant = input(this._defaultConfig.variant, ...(ngDevMode ? [{ debugName: "variant" }] : []));
|
|
401
|
+
/** Emits if the column sorting has changed */
|
|
402
|
+
this.sortChange = output();
|
|
403
|
+
/** Emits if the user clicked a cell */
|
|
404
|
+
this.cellClick = output();
|
|
405
|
+
/** Emits if the user clicked a row */
|
|
406
|
+
this.rowClick = output();
|
|
407
|
+
/** Emits if the user hits a key while a row is in focus */
|
|
408
|
+
this.rowKeydown = output();
|
|
409
|
+
/** Emits if the table's contents have changed */
|
|
410
|
+
this.contentChanged = output();
|
|
411
|
+
//#region IdsIconButtonParent implementation
|
|
412
|
+
this.embeddedIconButtonVariant = computed(() => {
|
|
413
|
+
const tableVariant = this.variant();
|
|
414
|
+
switch (tableVariant) {
|
|
415
|
+
case IdsTableVariant.PRIMARY:
|
|
416
|
+
return IdsIconButtonVariant.SURFACE;
|
|
417
|
+
default:
|
|
418
|
+
return tableVariant;
|
|
419
|
+
}
|
|
420
|
+
}, ...(ngDevMode ? [{ debugName: "embeddedIconButtonVariant" }] : []));
|
|
421
|
+
this.embeddedIconButtonAppearance = signal(IdsIconButtonAppearance.STANDARD, ...(ngDevMode ? [{ debugName: "embeddedIconButtonAppearance" }] : []));
|
|
422
|
+
this.disabled = signal(false, ...(ngDevMode ? [{ debugName: "disabled" }] : []));
|
|
423
|
+
//#endregion
|
|
424
|
+
/** Signal that holds the current table contents as an array of objects */
|
|
425
|
+
this.rowData = computed(() => {
|
|
426
|
+
const dataHolders = this._rowDataHolders();
|
|
427
|
+
if (!dataHolders?.length) {
|
|
428
|
+
return [];
|
|
429
|
+
}
|
|
430
|
+
try {
|
|
431
|
+
// try-catch for now to avoid "NG0950: Input is required but no value is available yet. Find more at https://angular.dev/errors/NG0950" at "holder.rowInfo()"
|
|
432
|
+
return dataHolders
|
|
433
|
+
.map((holder) => holder.rowInfo())
|
|
434
|
+
.sort((data1, data2) => data1.index - data2.index)
|
|
435
|
+
.map((data) => data.rowData);
|
|
436
|
+
}
|
|
437
|
+
catch {
|
|
438
|
+
return [];
|
|
439
|
+
}
|
|
440
|
+
}, ...(ngDevMode ? [{ debugName: "rowData" }] : []));
|
|
441
|
+
/** The row selection model for the table */
|
|
442
|
+
this.rowSelection = new SelectionModel(true, [], true);
|
|
443
|
+
this._expandedRows = new Set();
|
|
444
|
+
this._allRowsExpanded = signal(false, ...(ngDevMode ? [{ debugName: "_allRowsExpanded" }] : []));
|
|
445
|
+
this._sortState = signal(null, ...(ngDevMode ? [{ debugName: "_sortState" }] : []));
|
|
446
|
+
this._hostClasses = computed(() => this._getHostClasses([
|
|
447
|
+
this.appearance(),
|
|
448
|
+
this.size(),
|
|
449
|
+
this.variant(),
|
|
450
|
+
(this.withBorder() ? 'with-border' : null),
|
|
451
|
+
]), ...(ngDevMode ? [{ debugName: "_hostClasses" }] : []));
|
|
452
|
+
this._actualColumns = computed(() => {
|
|
453
|
+
const cols = this.columnDefs()
|
|
454
|
+
// Filter non-visible columns
|
|
455
|
+
.filter((colDef) => (colDef.visible !== false))
|
|
456
|
+
// Sort sticky columns to the beginning and stickyEnd columns to the end of the list
|
|
457
|
+
.reduce((acc, colDef) => {
|
|
458
|
+
if (colDef.sticky) {
|
|
459
|
+
// Sticky columns first
|
|
460
|
+
acc[0].push(colDef.id);
|
|
461
|
+
}
|
|
462
|
+
else if (colDef.stickyEnd) {
|
|
463
|
+
// StickyEnd columns last
|
|
464
|
+
acc[2].push(colDef.id);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
// The rest of the columns in between
|
|
468
|
+
acc[1].push(colDef.id);
|
|
469
|
+
}
|
|
470
|
+
return acc;
|
|
471
|
+
// eslint-disable-next-line @stylistic/js/array-bracket-newline, @stylistic/js/array-element-newline
|
|
472
|
+
}, [[], [], []])
|
|
473
|
+
.flat();
|
|
474
|
+
if (this.masterDetail()) {
|
|
475
|
+
cols.push('$masterDetail');
|
|
476
|
+
}
|
|
477
|
+
if (this.enableRowSelection()) {
|
|
478
|
+
cols.unshift('$selectBoxes');
|
|
479
|
+
}
|
|
480
|
+
return cols;
|
|
481
|
+
}, ...(ngDevMode ? [{ debugName: "_actualColumns" }] : []));
|
|
482
|
+
this._hiddenColumns = computed(() => this.columnDefs()
|
|
483
|
+
.filter((colDef) => (colDef.visible === false))
|
|
484
|
+
.map((colDef) => ({ ...colDef, visible: true })), ...(ngDevMode ? [{ debugName: "_hiddenColumns" }] : []));
|
|
485
|
+
this._detailRowTemplates = computed(() => {
|
|
486
|
+
if (!this.detailStickyColumns()) {
|
|
487
|
+
return ['$expandedDetail'];
|
|
488
|
+
}
|
|
489
|
+
return [
|
|
490
|
+
...(this.enableRowSelection() ? ['$empty'] : []),
|
|
491
|
+
...this.columnDefs().filter((colDef) => colDef.sticky).map(() => '$empty'),
|
|
492
|
+
'$expandedDetail',
|
|
493
|
+
...this.columnDefs().filter((colDef) => colDef.stickyEnd).map(() => '$emptyEnd'),
|
|
494
|
+
...(this.masterDetail() ? ['$emptyEnd'] : []),
|
|
495
|
+
];
|
|
496
|
+
}, ...(ngDevMode ? [{ debugName: "_detailRowTemplates" }] : []));
|
|
497
|
+
this._detailColSpan = computed(() => {
|
|
498
|
+
const colDefs = this.columnDefs();
|
|
499
|
+
let detailColSpan = colDefs.length;
|
|
500
|
+
if (this.detailStickyColumns()) {
|
|
501
|
+
detailColSpan = colDefs.filter((def) => (!def.sticky && !def.stickyEnd && def.visible !== false)).length;
|
|
502
|
+
}
|
|
503
|
+
return detailColSpan;
|
|
504
|
+
}, ...(ngDevMode ? [{ debugName: "_detailColSpan" }] : []));
|
|
505
|
+
this._cellTemplatesByName = computed(() => {
|
|
506
|
+
const templateMap = new Map();
|
|
507
|
+
for (const cellTemplate of this._viewCellTemplates()) {
|
|
508
|
+
templateMap.set(cellTemplate.templateName(), cellTemplate.templateRef);
|
|
509
|
+
}
|
|
510
|
+
for (const cellTemplate of this._contentCellTemplates()) {
|
|
511
|
+
templateMap.set(cellTemplate.templateName(), cellTemplate.templateRef);
|
|
512
|
+
}
|
|
513
|
+
return templateMap;
|
|
514
|
+
}, ...(ngDevMode ? [{ debugName: "_cellTemplatesByName" }] : []));
|
|
515
|
+
this._defaulDetailTemplate = computed(() => this._viewCellTemplates().find((cellTemplate) => cellTemplate.templateName() === this._defaultMasterDetailTemplateName)?.templateRef, ...(ngDevMode ? [{ debugName: "_defaulDetailTemplate" }] : []));
|
|
516
|
+
this._detailTemplate = computed(() => this._cellTemplatesByName().get(this.detailTemplateName()), ...(ngDevMode ? [{ debugName: "_detailTemplate" }] : []));
|
|
517
|
+
this._hasNoRows = computed(() => this.rowData().length === 0, ...(ngDevMode ? [{ debugName: "_hasNoRows" }] : []));
|
|
518
|
+
this._masterDetailEnabled = computed(() => this.masterDetail() && this._cellTemplatesByName().has(this._defaultMasterDetailTemplateName), ...(ngDevMode ? [{ debugName: "_masterDetailEnabled" }] : []));
|
|
519
|
+
this._unselectableRows = computed(() => {
|
|
520
|
+
const rows = this.rowData();
|
|
521
|
+
return new Set(rows.filter((rowData, index) => !this.isRowSelectable()(index, rowData)));
|
|
522
|
+
}, ...(ngDevMode ? [{ debugName: "_unselectableRows" }] : []));
|
|
523
|
+
this._rowSelectorCheckboxes = computed(() => {
|
|
524
|
+
const disabledRows = this._unselectableRows();
|
|
525
|
+
return this._selectorCheckboxes().filter((component) => {
|
|
526
|
+
const value = component.value();
|
|
527
|
+
return value && !disabledRows.has(value);
|
|
528
|
+
});
|
|
529
|
+
}, ...(ngDevMode ? [{ debugName: "_rowSelectorCheckboxes" }] : []));
|
|
530
|
+
this._selectableRowData = computed(() => this._rowSelectorCheckboxes().map((component) => component.value()), ...(ngDevMode ? [{ debugName: "_selectableRowData" }] : []));
|
|
531
|
+
this._rowSelectionChange = toSignal(this.rowSelection.changed);
|
|
532
|
+
this._isAllSelected = computed(() => {
|
|
533
|
+
const selectionChange = this._rowSelectionChange();
|
|
534
|
+
const data = this._selectableRowData();
|
|
535
|
+
const disabledRows = this._unselectableRows();
|
|
536
|
+
if (!selectionChange || !data) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
const numSelected = selectionChange.source.selected.length;
|
|
540
|
+
const activeRowCount = data.filter((row) => !disabledRows.has(row)).length;
|
|
541
|
+
return numSelected === activeRowCount;
|
|
542
|
+
}, ...(ngDevMode ? [{ debugName: "_isAllSelected" }] : []));
|
|
543
|
+
this._isSelectAllDisabled = computed(() => this._unselectableRows().size === this._selectableRowData().length, ...(ngDevMode ? [{ debugName: "_isSelectAllDisabled" }] : []));
|
|
544
|
+
}
|
|
545
|
+
get _hostName() {
|
|
546
|
+
return 'table';
|
|
547
|
+
}
|
|
548
|
+
ngOnInit() {
|
|
549
|
+
this._intl.changes.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(() => this._cdRef.markForCheck());
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Open up all row details.
|
|
553
|
+
*/
|
|
554
|
+
expandAll() {
|
|
555
|
+
this.rowData().forEach((rowData, idx) => {
|
|
556
|
+
if (!this._expandedRows.has(rowData) && this.hasDetailRow()(idx, rowData)) {
|
|
557
|
+
this._expandedRows.add(rowData);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
this._cdRef.markForCheck();
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Closes all opened row details.
|
|
564
|
+
*/
|
|
565
|
+
collapseAll() {
|
|
566
|
+
this._expandedRows.clear();
|
|
567
|
+
this._cdRef.markForCheck();
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Refresh rendered cell values. Useful if for eg. the `value` getter function is not pure and the values need to be refreshed manually.
|
|
571
|
+
*/
|
|
572
|
+
updateCellContents() {
|
|
573
|
+
this._cellContentRenderers().forEach((cellContent) => cellContent.updateValue());
|
|
574
|
+
}
|
|
575
|
+
_tableContentChanged() {
|
|
576
|
+
this.contentChanged.emit();
|
|
577
|
+
if (this.clearSelectionOnChange()) {
|
|
578
|
+
this.rowSelection.clear();
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
_getNextSortDirectionFor(colId) {
|
|
582
|
+
const sortState = this._sortState();
|
|
583
|
+
const nextIndex = sortState?.sortBy === colId ?
|
|
584
|
+
(this._sortDirections.indexOf(sortState.direction) + 1) % this._sortDirections.length : 1;
|
|
585
|
+
return this._sortDirections[nextIndex];
|
|
586
|
+
}
|
|
587
|
+
_handleSortClick(colId) {
|
|
588
|
+
const nextSortDirection = this._getNextSortDirectionFor(colId);
|
|
589
|
+
this._sortState.set(nextSortDirection !== IdsTableSortDirection.NONE ? new IdsTableSortInfo(colId, nextSortDirection) : null);
|
|
590
|
+
this.sortChange.emit(this._sortState());
|
|
591
|
+
}
|
|
592
|
+
_handleCellClick(event, rowData, colDef) {
|
|
593
|
+
this.cellClick.emit({ event, colDef, rowData });
|
|
594
|
+
}
|
|
595
|
+
_handleRowClick(event, rowData) {
|
|
596
|
+
this.rowClick.emit({ event, rowData });
|
|
597
|
+
}
|
|
598
|
+
_handleRowKeyDown(event, rowData) {
|
|
599
|
+
this.rowKeydown.emit({ event, rowData });
|
|
600
|
+
}
|
|
601
|
+
_handleMasterDetailClick(rowData) {
|
|
602
|
+
if (this._expandedRows.has(rowData)) {
|
|
603
|
+
this._expandedRows.delete(rowData);
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
this._expandedRows.add(rowData);
|
|
607
|
+
}
|
|
608
|
+
this._cdRef.markForCheck();
|
|
609
|
+
}
|
|
610
|
+
_masterToggle() {
|
|
611
|
+
const data = this._selectableRowData();
|
|
612
|
+
if (this._isAllSelected() || !data) {
|
|
613
|
+
this.rowSelection.clear();
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
this.rowSelection.select(...data);
|
|
617
|
+
}
|
|
618
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
619
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.7", type: IdsTableComponent, isStandalone: true, selector: "ids-table", inputs: { columnDefs: { classPropertyName: "columnDefs", publicName: "columnDefs", isSignal: true, isRequired: true, transformFunction: null }, dataSource: { classPropertyName: "dataSource", publicName: "dataSource", isSignal: true, isRequired: true, transformFunction: null }, fixedHeader: { classPropertyName: "fixedHeader", publicName: "fixedHeader", isSignal: true, isRequired: false, transformFunction: null }, enableSorting: { classPropertyName: "enableSorting", publicName: "enableSorting", isSignal: true, isRequired: false, transformFunction: null }, masterDetail: { classPropertyName: "masterDetail", publicName: "masterDetail", isSignal: true, isRequired: false, transformFunction: null }, detailTemplateName: { classPropertyName: "detailTemplateName", publicName: "detailTemplateName", isSignal: true, isRequired: false, transformFunction: null }, detailStickyColumns: { classPropertyName: "detailStickyColumns", publicName: "detailStickyColumns", isSignal: true, isRequired: false, transformFunction: null }, showDetailHeader: { classPropertyName: "showDetailHeader", publicName: "showDetailHeader", isSignal: true, isRequired: false, transformFunction: null }, hasDetailRow: { classPropertyName: "hasDetailRow", publicName: "hasDetailRow", isSignal: true, isRequired: false, transformFunction: null }, enableRowSelection: { classPropertyName: "enableRowSelection", publicName: "enableRowSelection", isSignal: true, isRequired: false, transformFunction: null }, clearSelectionOnChange: { classPropertyName: "clearSelectionOnChange", publicName: "clearSelectionOnChange", isSignal: true, isRequired: false, transformFunction: null }, isRowSelectable: { classPropertyName: "isRowSelectable", publicName: "isRowSelectable", isSignal: true, isRequired: false, transformFunction: null }, noRowsToShowOverlayBelow: { classPropertyName: "noRowsToShowOverlayBelow", publicName: "noRowsToShowOverlayBelow", isSignal: true, isRequired: false, transformFunction: null }, withBorder: { classPropertyName: "withBorder", publicName: "withBorder", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sortChange: "sortChange", cellClick: "cellClick", rowClick: "rowClick", rowKeydown: "rowKeydown", contentChanged: "contentChanged" }, providers: [{ provide: IDS_ICON_BUTTON_PARENT, useExisting: IdsTableComponent }], queries: [{ propertyName: "_contentCellTemplates", predicate: IdsTableCellTemplateDirective, isSignal: true }], viewQueries: [{ propertyName: "_viewCellTemplates", predicate: IdsTableCellTemplateDirective, descendants: true, isSignal: true }, { propertyName: "_rowDataHolders", predicate: (RowInfoHolderDirective), descendants: true, isSignal: true }, { propertyName: "_selectorCheckboxes", predicate: IdsCheckboxComponent, descendants: true, isSignal: true }, { propertyName: "_cellContentRenderers", predicate: (IdsCellContentComponent), descendants: true, isSignal: true }], exportAs: ["idsTable"], usesInheritance: true, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/prefer-self-closing-tags -->\n\n<!-- Empty table message template -->\n<ng-template #noRowsToShow>\n <div class=\"ids-table__no-rows-to-show\">\n <ng-content select=\"[idsNoRowsToShow]\">No rows to show</ng-content>\n </div>\n</ng-template>\n\n<!-- Default detail cell template (a table showing the non-visible columns) -->\n<ng-template #defaultDetail let-row let-cols=\"cols\" [idsCellTemplate]=\"_defaultMasterDetailTemplateName\">\n <ids-table appearance=\"zebra\" [dataSource]=\"[row]\" [columnDefs]=\"cols\"></ids-table>\n</ng-template>\n\n<!-- TODO: Loading spinner -->\n\n<div class=\"ids-table__horizontal-scroll\">\n <table\n cdk-table\n cdkDropListGroup\n multiTemplateDataRows\n [id]=\"id()\"\n [dataSource]=\"dataSource()\"\n (contentChanged)=\"_tableContentChanged()\"\n >\n <caption><ng-content select=\"[idsTableCaption]\"></ng-content></caption>\n\n <!-- Column and row definitions for row selection -->\n <ng-container cdkColumnDef=\"$selectBoxes\" sticky>\n <th\n *cdkHeaderCellDef\n cdk-header-cell\n scope=\"col\"\n role=\"cell\"\n class=\"ids-table__header-cell ids-table__header-cell--select-all-rows\"\n >\n @let isRowSelected = rowSelection.hasValue();\n @let isTableVariantPrimary = variant() === 'primary';\n <ids-checkbox\n [indeterminate]=\"isRowSelected && !_isAllSelected()\"\n [checked]=\"isRowSelected && _isAllSelected()\"\n [disabled]=\"_isSelectAllDisabled()\"\n [aria-label]=\"_intl.headerSelectorAriaLabel\"\n [variant]=\"isTableVariantPrimary && isRowSelected ? 'light' : 'surface'\"\n (change)=\"$event ? _masterToggle() : null\"\n >\n </ids-checkbox>\n </th>\n <td\n *cdkCellDef=\"let row; let idx = index\"\n cdk-cell\n class=\"ids-table__cell ids-table__cell--row-select\"\n >\n <ids-checkbox\n class=\"ids-table__checkbox--row-selector\"\n [disabled]=\"_unselectableRows().has(row)\"\n [checked]=\"rowSelection.isSelected(row)\"\n [value]=\"row\"\n [aria-label]=\"_intl.rowSelectorAriaLabel\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"$event ? rowSelection.toggle(row) : null\"\n >\n </ids-checkbox>\n </td>\n </ng-container>\n\n <!-- Column and row definitions for the master-detail toggle feature -->\n <ng-container cdkColumnDef=\"$masterDetail\" stickyEnd>\n <th\n *cdkHeaderCellDef\n cdk-header-cell\n scope=\"col\"\n class=\"ids-table__header-cell ids-table__header-cell--master-detail-toggle\"\n [class.ids-table__header-cell--master-detail-toggle-expand]=\"showDetailHeader()\"\n >\n @if (showDetailHeader()) {\n <span>{{ _intl.detailHeaderLabel }}</span>\n }\n </th>\n <td\n *cdkCellDef=\"let row; let idx = $index\"\n cdk-cell\n class=\"ids-table__cell ids-table__cell--master-detail-toggle\"\n [class.ids-table__cell--master-detail-toggle-expand]=\"showDetailHeader()\"\n >\n @let hasDetail = hasDetailRow()(idx, row);\n @let rowExpanded = _expandedRows.has(row);\n @if (hasDetail) {\n <button\n type=\"button\"\n idsIconButton\n class=\"ids-table__button--master-detail\"\n [attr.aria-expanded]=\"rowExpanded || false\"\n [attr.aria-label]=\"_intl.getDetailExpandButtonAriaLabel(row) || null\"\n (click)=\"_handleMasterDetailClick(row)\"\n >\n <ids-icon aria-hidden=\"true\" alt=\"\" [fontIcon]=\"rowExpanded ? 'chevron-up' : 'chevron-down'\" />\n </button>\n }\n </td>\n </ng-container>\n <!-- Column definition for the detail cells -->\n <ng-container cdkColumnDef=\"$expandedDetail\">\n <td *cdkCellDef=\"let row; let idx = index\" cdk-cell class=\"ids-table__cell ids-table__detail-cell\" [attr.colspan]=\"_detailColSpan()\">\n <div class=\"ids-table__detail-cell--content-wrapper\" [@detailExpand]=\"_expandedRows.has(row) ? 'expanded' : 'collapsed'\">\n @let isDefaultTemplate = _detailTemplate() === _defaulDetailTemplate();\n @let context = isDefaultTemplate ? { $implicit: row, cols: _hiddenColumns() } : { $implicit: row };\n <ng-container *ngTemplateOutlet=\"_detailTemplate() ?? defaultDetail; context: context\"></ng-container>\n </div>\n </td>\n </ng-container>\n\n <!-- Column definitions for sticky empty cells -->\n <ng-container cdkColumnDef=\"$empty\" sticky>\n <td *cdkCellDef=\"let row; let idx = index\" cdk-cell class=\"ids-table__cell\"></td>\n </ng-container>\n <ng-container cdkColumnDef=\"$emptyEnd\" stickyEnd>\n <td *cdkCellDef=\"let row; let idx = index\" cdk-cell class=\"ids-table__cell\"></td>\n </ng-container>\n\n <!-- Column and row definitions for the actual data -->\n @for (col of columnDefs(); track col.id; let colIndex = $index; let isLast = $last ) {\n <ng-container\n [cdkColumnDef]=\"col.id\"\n [sticky]=\"col.sticky && !col.stickyEnd\"\n [stickyEnd]=\"col.stickyEnd && !col.sticky\"\n >\n @let colSortable = col.sortable && enableSorting();\n @let colNumeric = col.cellRenderer === 'numeric';\n @let orderName = col.orderName || col.field || col.id;\n @let sortDirection = colSortable && _sortState()?.sortBy === orderName ? _sortState()?.direction : null;\n @let nextSortDirection = _getNextSortDirectionFor(orderName);\n <th\n *cdkHeaderCellDef\n cdk-header-cell\n class=\"ids-table__header-cell\"\n idsHeaderCellContent\n scope=\"col\"\n [class.ids-table__header-cell--sortable]=\"colSortable\"\n [class.ids-table__header-cell--numeric]=\"colNumeric\"\n [class]=\"col.columnClasses || ''\"\n [colDef]=\"col\"\n [externalCellTemplates]=\"_cellTemplatesByName()\"\n [id]=\"id() + '-header-' + col.id\"\n >\n @if (colSortable) {\n <button\n type=\"button\"\n idsIconButton\n colEnd\n class=\"ids-table__header-cell--sort-button\"\n [attr.aria-label]=\"_intl.getSortButtonAriaLabel(col, nextSortDirection)\"\n (click)=\"_handleSortClick(orderName)\"\n >\n @switch (sortDirection) {\n @case ('asc') {\n <ids-icon [fontIcon]=\"'chevron-up'\"></ids-icon>\n }\n @case ('desc') {\n <ids-icon [fontIcon]=\"'chevron-down'\"></ids-icon>\n }\n @default {\n <ids-icon [fontIcon]=\"'adjustments-horizontal'\"></ids-icon>\n }\n }\n </button>\n }\n </th>\n\n @if (col.identifier) {\n <th\n *cdkCellDef=\"let row; let idx = index\"\n cdk-cell\n idsCellContent\n class=\"ids-table__cell ids-table__cell--identifier\"\n role=\"gridcell\"\n scope=\"row\"\n [class]=\"col.cellClasses || ''\"\n [colDef]=\"col\"\n [rowData]=\"row\"\n [externalCellTemplates]=\"_cellTemplatesByName()\"\n (click)=\"_handleCellClick($event, row, col)\"\n ></th>\n } @else {\n <td\n *cdkCellDef=\"let row; let idx = index\"\n cdk-cell\n class=\"ids-table__cell\"\n idsCellContent\n [class]=\"col.cellClasses || ''\"\n [colDef]=\"col\"\n [rowData]=\"row\"\n [externalCellTemplates]=\"_cellTemplatesByName()\"\n (click)=\"_handleCellClick($event, row, col)\"\n ></td>\n }\n </ng-container>\n }\n\n <!-- Header row render definition -->\n <tr *cdkHeaderRowDef=\"_actualColumns(); sticky: fixedHeader()\" cdk-header-row class=\"ids-table__header-row\"></tr>\n\n <!-- Row render definition -->\n <tr\n *cdkRowDef=\"let row; columns: _actualColumns(); let idx = dataIndex\"\n cdk-row\n class=\"ids-table__row\"\n [rowInfo]=\"{ rowData: row, index: idx }\"\n [ngClass]=\"(appearance() !== _appearanceZebra || idx % 2 === 0) ? 'ids-table__row--surface' : 'ids-table__row--secondary'\"\n (click)=\"_handleRowClick($event, row)\"\n (keydown)=\"_handleRowKeyDown($event, row)\"\n ></tr>\n\n <!-- Detail row render definition -->\n @if (masterDetail()) {\n <tr\n *cdkRowDef=\"let row; columns: _detailRowTemplates(); when: hasDetailRow()\"\n cdk-row\n class=\"ids-table__detail-row ids-table__row--surface\"\n [class.ids-table__detail-row--expanded]=\"_expandedRows.has(row) || _allRowsExpanded()\"\n ></tr>\n }\n\n <!-- Empty table message (inside the table) -->\n @if (!noRowsToShowOverlayBelow()) {\n <tr *cdkNoDataRow class=\"ids-table__row\">\n <td class=\"ids-table__cell\" [attr.colspan]=\"_actualColumns().length\">\n <ng-container [ngTemplateOutlet]=\"noRowsToShow\"></ng-container>\n </td>\n </tr>\n }\n </table>\n</div>\n<!-- Empty table message (outside the table) -->\n@if (noRowsToShowOverlayBelow() && _hasNoRows()) {\n <ng-container [ngTemplateOutlet]=\"noRowsToShow\"></ng-container>\n}\n", dependencies: [{ kind: "component", type: IdsTableComponent, selector: "ids-table", inputs: ["columnDefs", "dataSource", "fixedHeader", "enableSorting", "masterDetail", "detailTemplateName", "detailStickyColumns", "showDetailHeader", "hasDetailRow", "enableRowSelection", "clearSelectionOnChange", "isRowSelectable", "noRowsToShowOverlayBelow", "withBorder", "appearance", "size", "variant"], outputs: ["sortChange", "cellClick", "rowClick", "rowKeydown", "contentChanged"], exportAs: ["idsTable"] }, { kind: "component", type: IdsCellContentComponent, selector: "th[idsCellContent],td[idsCellContent],th[idsHeaderCellContent],td[idsHeaderCellContent]", inputs: ["externalCellTemplates"] }, { kind: "component", type: IdsCheckboxComponent, selector: "ids-checkbox", inputs: ["name", "required", "readonly", "size", "tabIndex", "value", "variant", "checked", "indeterminate", "aria-label", "aria-labelledby", "aria-describedby", "disabled"], outputs: ["disabledChange", "change", "indeterminateChange"] }, { kind: "component", type: IdsIconComponent, selector: "ids-icon", inputs: ["size", "sizeCollection", "variant", "fontIcon", "svgIcon", "aria-hidden"] }, { kind: "component", type: IdsIconButtonComponent, selector: "button[idsIconButton], a[idsIconButton]", inputs: ["appearance", "size", "variant", "disabled"] }, { kind: "directive", type: IdsTableCellTemplateDirective, selector: "[idsCellTemplate]", inputs: ["idsCellTemplate"] }, { kind: "directive", type: CdkCell, selector: "cdk-cell, td[cdk-cell]" }, { kind: "directive", type: CdkCellDef, selector: "[cdkCellDef]" }, { kind: "directive", type: CdkColumnDef, selector: "[cdkColumnDef]", inputs: ["cdkColumnDef", "sticky", "stickyEnd"] }, { kind: "directive", type: CdkHeaderCell, selector: "cdk-header-cell, th[cdk-header-cell]" }, { kind: "directive", type: CdkHeaderCellDef, selector: "[cdkHeaderCellDef]" }, { kind: "component", type: CdkHeaderRow, selector: "cdk-header-row, tr[cdk-header-row]" }, { kind: "directive", type: CdkHeaderRowDef, selector: "[cdkHeaderRowDef]", inputs: ["cdkHeaderRowDef", "cdkHeaderRowDefSticky"] }, { kind: "directive", type: CdkNoDataRow, selector: "ng-template[cdkNoDataRow]" }, { kind: "component", type: CdkRow, selector: "cdk-row, tr[cdk-row]" }, { kind: "directive", type: CdkRowDef, selector: "[cdkRowDef]", inputs: ["cdkRowDefColumns", "cdkRowDefWhen"] }, { kind: "component", type: CdkTable, selector: "cdk-table, table[cdk-table]", inputs: ["trackBy", "dataSource", "multiTemplateDataRows", "fixedLayout"], outputs: ["contentChanged"], exportAs: ["cdkTable"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: RowInfoHolderDirective, selector: "[rowInfo]", inputs: ["rowInfo"] }], animations: [
|
|
620
|
+
trigger('detailExpand', [
|
|
621
|
+
state('collapsed', style({ height: '0px', minHeight: '0', visibility: 'hidden' })),
|
|
622
|
+
state('expanded', style({ height: '*', visibility: 'visible' })),
|
|
623
|
+
transition('expanded <=> collapsed', animate('200ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
|
|
624
|
+
]),
|
|
625
|
+
], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
626
|
+
}
|
|
627
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: IdsTableComponent, decorators: [{
|
|
628
|
+
type: Component,
|
|
629
|
+
args: [{ selector: 'ids-table', imports: [
|
|
630
|
+
IdsCellContentComponent,
|
|
631
|
+
IdsCheckboxComponent,
|
|
632
|
+
IdsIconComponent,
|
|
633
|
+
IdsIconButtonComponent,
|
|
634
|
+
IdsTableCellTemplateDirective,
|
|
635
|
+
CdkCell,
|
|
636
|
+
CdkCellDef,
|
|
637
|
+
CdkColumnDef,
|
|
638
|
+
CdkHeaderCell,
|
|
639
|
+
CdkHeaderCellDef,
|
|
640
|
+
CdkHeaderRow,
|
|
641
|
+
CdkHeaderRowDef,
|
|
642
|
+
CdkNoDataRow,
|
|
643
|
+
CdkRow,
|
|
644
|
+
CdkRowDef,
|
|
645
|
+
CdkTable,
|
|
646
|
+
NgClass,
|
|
647
|
+
NgTemplateOutlet,
|
|
648
|
+
RowInfoHolderDirective,
|
|
649
|
+
], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, animations: [
|
|
650
|
+
trigger('detailExpand', [
|
|
651
|
+
state('collapsed', style({ height: '0px', minHeight: '0', visibility: 'hidden' })),
|
|
652
|
+
state('expanded', style({ height: '*', visibility: 'visible' })),
|
|
653
|
+
transition('expanded <=> collapsed', animate('200ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
|
|
654
|
+
]),
|
|
655
|
+
], providers: [{ provide: IDS_ICON_BUTTON_PARENT, useExisting: IdsTableComponent }], exportAs: 'idsTable', template: "<!-- eslint-disable @angular-eslint/template/prefer-self-closing-tags -->\n\n<!-- Empty table message template -->\n<ng-template #noRowsToShow>\n <div class=\"ids-table__no-rows-to-show\">\n <ng-content select=\"[idsNoRowsToShow]\">No rows to show</ng-content>\n </div>\n</ng-template>\n\n<!-- Default detail cell template (a table showing the non-visible columns) -->\n<ng-template #defaultDetail let-row let-cols=\"cols\" [idsCellTemplate]=\"_defaultMasterDetailTemplateName\">\n <ids-table appearance=\"zebra\" [dataSource]=\"[row]\" [columnDefs]=\"cols\"></ids-table>\n</ng-template>\n\n<!-- TODO: Loading spinner -->\n\n<div class=\"ids-table__horizontal-scroll\">\n <table\n cdk-table\n cdkDropListGroup\n multiTemplateDataRows\n [id]=\"id()\"\n [dataSource]=\"dataSource()\"\n (contentChanged)=\"_tableContentChanged()\"\n >\n <caption><ng-content select=\"[idsTableCaption]\"></ng-content></caption>\n\n <!-- Column and row definitions for row selection -->\n <ng-container cdkColumnDef=\"$selectBoxes\" sticky>\n <th\n *cdkHeaderCellDef\n cdk-header-cell\n scope=\"col\"\n role=\"cell\"\n class=\"ids-table__header-cell ids-table__header-cell--select-all-rows\"\n >\n @let isRowSelected = rowSelection.hasValue();\n @let isTableVariantPrimary = variant() === 'primary';\n <ids-checkbox\n [indeterminate]=\"isRowSelected && !_isAllSelected()\"\n [checked]=\"isRowSelected && _isAllSelected()\"\n [disabled]=\"_isSelectAllDisabled()\"\n [aria-label]=\"_intl.headerSelectorAriaLabel\"\n [variant]=\"isTableVariantPrimary && isRowSelected ? 'light' : 'surface'\"\n (change)=\"$event ? _masterToggle() : null\"\n >\n </ids-checkbox>\n </th>\n <td\n *cdkCellDef=\"let row; let idx = index\"\n cdk-cell\n class=\"ids-table__cell ids-table__cell--row-select\"\n >\n <ids-checkbox\n class=\"ids-table__checkbox--row-selector\"\n [disabled]=\"_unselectableRows().has(row)\"\n [checked]=\"rowSelection.isSelected(row)\"\n [value]=\"row\"\n [aria-label]=\"_intl.rowSelectorAriaLabel\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"$event ? rowSelection.toggle(row) : null\"\n >\n </ids-checkbox>\n </td>\n </ng-container>\n\n <!-- Column and row definitions for the master-detail toggle feature -->\n <ng-container cdkColumnDef=\"$masterDetail\" stickyEnd>\n <th\n *cdkHeaderCellDef\n cdk-header-cell\n scope=\"col\"\n class=\"ids-table__header-cell ids-table__header-cell--master-detail-toggle\"\n [class.ids-table__header-cell--master-detail-toggle-expand]=\"showDetailHeader()\"\n >\n @if (showDetailHeader()) {\n <span>{{ _intl.detailHeaderLabel }}</span>\n }\n </th>\n <td\n *cdkCellDef=\"let row; let idx = $index\"\n cdk-cell\n class=\"ids-table__cell ids-table__cell--master-detail-toggle\"\n [class.ids-table__cell--master-detail-toggle-expand]=\"showDetailHeader()\"\n >\n @let hasDetail = hasDetailRow()(idx, row);\n @let rowExpanded = _expandedRows.has(row);\n @if (hasDetail) {\n <button\n type=\"button\"\n idsIconButton\n class=\"ids-table__button--master-detail\"\n [attr.aria-expanded]=\"rowExpanded || false\"\n [attr.aria-label]=\"_intl.getDetailExpandButtonAriaLabel(row) || null\"\n (click)=\"_handleMasterDetailClick(row)\"\n >\n <ids-icon aria-hidden=\"true\" alt=\"\" [fontIcon]=\"rowExpanded ? 'chevron-up' : 'chevron-down'\" />\n </button>\n }\n </td>\n </ng-container>\n <!-- Column definition for the detail cells -->\n <ng-container cdkColumnDef=\"$expandedDetail\">\n <td *cdkCellDef=\"let row; let idx = index\" cdk-cell class=\"ids-table__cell ids-table__detail-cell\" [attr.colspan]=\"_detailColSpan()\">\n <div class=\"ids-table__detail-cell--content-wrapper\" [@detailExpand]=\"_expandedRows.has(row) ? 'expanded' : 'collapsed'\">\n @let isDefaultTemplate = _detailTemplate() === _defaulDetailTemplate();\n @let context = isDefaultTemplate ? { $implicit: row, cols: _hiddenColumns() } : { $implicit: row };\n <ng-container *ngTemplateOutlet=\"_detailTemplate() ?? defaultDetail; context: context\"></ng-container>\n </div>\n </td>\n </ng-container>\n\n <!-- Column definitions for sticky empty cells -->\n <ng-container cdkColumnDef=\"$empty\" sticky>\n <td *cdkCellDef=\"let row; let idx = index\" cdk-cell class=\"ids-table__cell\"></td>\n </ng-container>\n <ng-container cdkColumnDef=\"$emptyEnd\" stickyEnd>\n <td *cdkCellDef=\"let row; let idx = index\" cdk-cell class=\"ids-table__cell\"></td>\n </ng-container>\n\n <!-- Column and row definitions for the actual data -->\n @for (col of columnDefs(); track col.id; let colIndex = $index; let isLast = $last ) {\n <ng-container\n [cdkColumnDef]=\"col.id\"\n [sticky]=\"col.sticky && !col.stickyEnd\"\n [stickyEnd]=\"col.stickyEnd && !col.sticky\"\n >\n @let colSortable = col.sortable && enableSorting();\n @let colNumeric = col.cellRenderer === 'numeric';\n @let orderName = col.orderName || col.field || col.id;\n @let sortDirection = colSortable && _sortState()?.sortBy === orderName ? _sortState()?.direction : null;\n @let nextSortDirection = _getNextSortDirectionFor(orderName);\n <th\n *cdkHeaderCellDef\n cdk-header-cell\n class=\"ids-table__header-cell\"\n idsHeaderCellContent\n scope=\"col\"\n [class.ids-table__header-cell--sortable]=\"colSortable\"\n [class.ids-table__header-cell--numeric]=\"colNumeric\"\n [class]=\"col.columnClasses || ''\"\n [colDef]=\"col\"\n [externalCellTemplates]=\"_cellTemplatesByName()\"\n [id]=\"id() + '-header-' + col.id\"\n >\n @if (colSortable) {\n <button\n type=\"button\"\n idsIconButton\n colEnd\n class=\"ids-table__header-cell--sort-button\"\n [attr.aria-label]=\"_intl.getSortButtonAriaLabel(col, nextSortDirection)\"\n (click)=\"_handleSortClick(orderName)\"\n >\n @switch (sortDirection) {\n @case ('asc') {\n <ids-icon [fontIcon]=\"'chevron-up'\"></ids-icon>\n }\n @case ('desc') {\n <ids-icon [fontIcon]=\"'chevron-down'\"></ids-icon>\n }\n @default {\n <ids-icon [fontIcon]=\"'adjustments-horizontal'\"></ids-icon>\n }\n }\n </button>\n }\n </th>\n\n @if (col.identifier) {\n <th\n *cdkCellDef=\"let row; let idx = index\"\n cdk-cell\n idsCellContent\n class=\"ids-table__cell ids-table__cell--identifier\"\n role=\"gridcell\"\n scope=\"row\"\n [class]=\"col.cellClasses || ''\"\n [colDef]=\"col\"\n [rowData]=\"row\"\n [externalCellTemplates]=\"_cellTemplatesByName()\"\n (click)=\"_handleCellClick($event, row, col)\"\n ></th>\n } @else {\n <td\n *cdkCellDef=\"let row; let idx = index\"\n cdk-cell\n class=\"ids-table__cell\"\n idsCellContent\n [class]=\"col.cellClasses || ''\"\n [colDef]=\"col\"\n [rowData]=\"row\"\n [externalCellTemplates]=\"_cellTemplatesByName()\"\n (click)=\"_handleCellClick($event, row, col)\"\n ></td>\n }\n </ng-container>\n }\n\n <!-- Header row render definition -->\n <tr *cdkHeaderRowDef=\"_actualColumns(); sticky: fixedHeader()\" cdk-header-row class=\"ids-table__header-row\"></tr>\n\n <!-- Row render definition -->\n <tr\n *cdkRowDef=\"let row; columns: _actualColumns(); let idx = dataIndex\"\n cdk-row\n class=\"ids-table__row\"\n [rowInfo]=\"{ rowData: row, index: idx }\"\n [ngClass]=\"(appearance() !== _appearanceZebra || idx % 2 === 0) ? 'ids-table__row--surface' : 'ids-table__row--secondary'\"\n (click)=\"_handleRowClick($event, row)\"\n (keydown)=\"_handleRowKeyDown($event, row)\"\n ></tr>\n\n <!-- Detail row render definition -->\n @if (masterDetail()) {\n <tr\n *cdkRowDef=\"let row; columns: _detailRowTemplates(); when: hasDetailRow()\"\n cdk-row\n class=\"ids-table__detail-row ids-table__row--surface\"\n [class.ids-table__detail-row--expanded]=\"_expandedRows.has(row) || _allRowsExpanded()\"\n ></tr>\n }\n\n <!-- Empty table message (inside the table) -->\n @if (!noRowsToShowOverlayBelow()) {\n <tr *cdkNoDataRow class=\"ids-table__row\">\n <td class=\"ids-table__cell\" [attr.colspan]=\"_actualColumns().length\">\n <ng-container [ngTemplateOutlet]=\"noRowsToShow\"></ng-container>\n </td>\n </tr>\n }\n </table>\n</div>\n<!-- Empty table message (outside the table) -->\n@if (noRowsToShowOverlayBelow() && _hasNoRows()) {\n <ng-container [ngTemplateOutlet]=\"noRowsToShow\"></ng-container>\n}\n" }]
|
|
656
|
+
}] });
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Generated bundle index. Do not edit.
|
|
660
|
+
*/
|
|
661
|
+
|
|
662
|
+
export { DEFAULT_DATA_LOAD_DEBOUNCE_TIME, DEFAULT_MASTER_DETAIL_TEMPLATE_NAME, IDS_TABLE_DEFAULT_CONFIG, IDS_TABLE_DEFAULT_CONFIG_FACTORY, IDS_TABLE_INTL_PROVIDER, IDS_TABLE_INTL_PROVIDER_FACTORY, IdsTableAppearance, IdsTableCellRenderer, IdsTableCellTemplateDirective, IdsTableComponent, IdsTableIntl, IdsTableSortDirection, IdsTableSortInfo, IdsTableVariant, ServerSideDataSource };
|
|
663
|
+
//# sourceMappingURL=i-cell-ids-angular-table.mjs.map
|