@skyux/grids 8.6.0 → 9.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/documentation.json +2 -2
  2. package/{esm2020 → esm2022}/lib/modules/grid/grid-adapter.service.mjs +4 -4
  3. package/{esm2020 → esm2022}/lib/modules/grid/grid-cell.component.mjs +4 -4
  4. package/{esm2020 → esm2022}/lib/modules/grid/grid-column.component.mjs +4 -4
  5. package/esm2022/lib/modules/grid/grid.component.mjs +1034 -0
  6. package/{esm2020 → esm2022}/lib/modules/grid/grid.module.mjs +29 -29
  7. package/esm2022/lib/modules/shared/sky-grids-resources.module.mjs +45 -0
  8. package/{fesm2015 → fesm2022}/skyux-grids.mjs +50 -50
  9. package/fesm2022/skyux-grids.mjs.map +1 -0
  10. package/lib/modules/grid/grid-cell.component.d.ts +1 -1
  11. package/lib/modules/grid/grid-column.component.d.ts +1 -1
  12. package/lib/modules/grid/grid.component.d.ts +1 -1
  13. package/package.json +16 -22
  14. package/esm2020/lib/modules/grid/grid.component.mjs +0 -1034
  15. package/esm2020/lib/modules/shared/sky-grids-resources.module.mjs +0 -45
  16. package/fesm2015/skyux-grids.mjs.map +0 -1
  17. package/fesm2020/skyux-grids.mjs +0 -1442
  18. package/fesm2020/skyux-grids.mjs.map +0 -1
  19. /package/{esm2020 → esm2022}/index.mjs +0 -0
  20. /package/{esm2020 → esm2022}/lib/modules/grid/grid-column.model.mjs +0 -0
  21. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-column-alignment.mjs +0 -0
  22. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-column-description-model-change.mjs +0 -0
  23. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-column-heading-model-change.mjs +0 -0
  24. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-column-inline-help-popover-model-change.mjs +0 -0
  25. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-column-width-model-change.mjs +0 -0
  26. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-message-type.mjs +0 -0
  27. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-message.mjs +0 -0
  28. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-row-delete-cancel-args.mjs +0 -0
  29. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-row-delete-config.mjs +0 -0
  30. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-row-delete-confirm-args.mjs +0 -0
  31. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-row-delete-contents.mjs +0 -0
  32. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-selected-rows-model-change.mjs +0 -0
  33. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-selected-rows-source.mjs +0 -0
  34. /package/{esm2020 → esm2022}/lib/modules/grid/types/grid-ui-config.mjs +0 -0
  35. /package/{esm2020 → esm2022}/skyux-grids.mjs +0 -0
@@ -1,1442 +0,0 @@
1
- import * as i4 from '@angular/common';
2
- import { CommonModule } from '@angular/common';
3
- import * as i0 from '@angular/core';
4
- import { NgModule, ViewContainerRef, Component, ChangeDetectionStrategy, Input, ViewChild, EventEmitter, TemplateRef, ContentChildren, Injectable, Output, ViewChildren, HostListener } from '@angular/core';
5
- import * as i5 from '@angular/forms';
6
- import { FormsModule } from '@angular/forms';
7
- import * as i1 from '@skyux/core';
8
- import { SkyAffixAutoFitContext, SkyAffixModule, SkyOverlayModule } from '@skyux/core';
9
- import * as i6 from '@skyux/forms';
10
- import { SkyCheckboxModule } from '@skyux/forms';
11
- import * as i7 from '@skyux/indicators';
12
- import { SkyHelpInlineModule, SkyIconModule, SkyTextHighlightModule } from '@skyux/indicators';
13
- import * as i8 from '@skyux/layout';
14
- import { SkyInlineDeleteModule } from '@skyux/layout';
15
- import * as i9 from '@skyux/popovers';
16
- import { SkyPopoverModule } from '@skyux/popovers';
17
- import * as i2 from 'ng2-dragula';
18
- import { DragulaService, DragulaModule } from 'ng2-dragula';
19
- import * as i11 from '@skyux/i18n';
20
- import { getLibStringForLocale, SkyI18nModule, SKY_LIB_RESOURCES_PROVIDERS } from '@skyux/i18n';
21
- import { getData, ListItemModel } from '@skyux/list-builder-common';
22
- import { Subject, BehaviorSubject, fromEvent, merge } from 'rxjs';
23
- import { takeUntil, take, map, distinctUntilChanged, takeWhile } from 'rxjs/operators';
24
-
25
- /**
26
- * NOTICE: DO NOT MODIFY THIS FILE!
27
- * The contents of this file were automatically generated by
28
- * the 'ng generate @skyux/i18n:lib-resources-module lib/modules/shared/sky-grids' schematic.
29
- * To update this file, simply rerun the command.
30
- */
31
- const RESOURCES = {
32
- 'EN-US': { skyux_grid_multiselect_select_row: { message: 'Select row' } },
33
- };
34
- class SkyGridsResourcesProvider {
35
- getString(localeInfo, name) {
36
- return getLibStringForLocale(RESOURCES, localeInfo.locale, name);
37
- }
38
- }
39
- /**
40
- * Import into any component library module that needs to use resource strings.
41
- */
42
- class SkyGridsResourcesModule {
43
- }
44
- SkyGridsResourcesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridsResourcesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
45
- SkyGridsResourcesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SkyGridsResourcesModule, exports: [SkyI18nModule] });
46
- SkyGridsResourcesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridsResourcesModule, providers: [
47
- {
48
- provide: SKY_LIB_RESOURCES_PROVIDERS,
49
- useClass: SkyGridsResourcesProvider,
50
- multi: true,
51
- },
52
- ], imports: [SkyI18nModule] });
53
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridsResourcesModule, decorators: [{
54
- type: NgModule,
55
- args: [{
56
- exports: [SkyI18nModule],
57
- providers: [
58
- {
59
- provide: SKY_LIB_RESOURCES_PROVIDERS,
60
- useClass: SkyGridsResourcesProvider,
61
- multi: true,
62
- },
63
- ],
64
- }]
65
- }] });
66
-
67
- /**
68
- * @internal
69
- * @deprecated `SkyGridComponent` and its features are deprecated. We recommend using the data grid instead. For more information, see https://developer.blackbaud.com/skyux/components/data-grid
70
- */
71
- class SkyGridCellComponent {
72
- ngOnInit() {
73
- this.container.createEmbeddedView(this.template, this);
74
- }
75
- get row() {
76
- return this.item.data;
77
- }
78
- get value() {
79
- if (this.item.data && (this.fieldSelector || this.columnId)) {
80
- return getData(this.item.data, this.fieldSelector || this.columnId);
81
- }
82
- return undefined;
83
- }
84
- }
85
- SkyGridCellComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
86
- SkyGridCellComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: SkyGridCellComponent, selector: "sky-grid-cell", inputs: { item: "item", columnId: "columnId", template: "template", fieldSelector: "fieldSelector" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["cell"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: '<ng-template #cell></ng-template>', isInline: true, styles: [":host{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;min-height:35px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
87
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridCellComponent, decorators: [{
88
- type: Component,
89
- args: [{ selector: 'sky-grid-cell', template: '<ng-template #cell></ng-template>', changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;min-height:35px}\n"] }]
90
- }], propDecorators: { item: [{
91
- type: Input
92
- }], columnId: [{
93
- type: Input
94
- }], template: [{
95
- type: Input
96
- }], fieldSelector: [{
97
- type: Input
98
- }], container: [{
99
- type: ViewChild,
100
- args: ['cell', {
101
- read: ViewContainerRef,
102
- static: true,
103
- }]
104
- }] } });
105
-
106
- /**
107
- * Specifies the column information.
108
- * @deprecated `SkyGridComponent` and its features are deprecated. We recommend using the data grid instead. For more information, see https://developer.blackbaud.com/skyux/components/data-grid
109
- */
110
- class SkyGridColumnComponent {
111
- constructor() {
112
- /**
113
- * The horizontal alignment of the column's data and header.
114
- * Options include: `"left"`, `"center"`, and `"right"`.
115
- * @default "left"
116
- */
117
- this.alignment = 'left';
118
- /**
119
- * Whether the column sorts the grid when users click the column header.
120
- * @default true
121
- */
122
- this.isSortable = true;
123
- /**
124
- * The search function to apply for the specific column. By default,
125
- * the column executes a string compare on the column data.
126
- * @default (value, searchText) => value.toString().toLowerCase().indexOf(searchText) !== -1
127
- */
128
- // eslint-disable-next-line @angular-eslint/no-input-rename
129
- this.searchFunction = this.search;
130
- this.descriptionChanges = new EventEmitter();
131
- this.descriptionModelChanges = new EventEmitter();
132
- this.headingChanges = new EventEmitter();
133
- this.headingModelChanges = new EventEmitter();
134
- this.inlineHelpPopoverModelChanges = new EventEmitter();
135
- }
136
- ngOnChanges(changes) {
137
- if (changes['heading'] && changes['heading'].firstChange === false) {
138
- this.headingChanges.emit(this.heading);
139
- this.headingModelChanges.emit({
140
- value: this.heading,
141
- id: this.id,
142
- field: this.field,
143
- });
144
- }
145
- if (changes['description'] &&
146
- changes['description'].firstChange === false) {
147
- this.descriptionChanges.emit(this.description);
148
- this.descriptionModelChanges.emit({
149
- value: this.description,
150
- id: this.id,
151
- field: this.field,
152
- });
153
- }
154
- if (changes['inlineHelpPopover'] &&
155
- changes['inlineHelpPopover'].firstChange === false) {
156
- this.inlineHelpPopoverModelChanges.emit({
157
- value: this.inlineHelpPopover,
158
- id: this.id,
159
- field: this.field,
160
- });
161
- }
162
- }
163
- get template() {
164
- if (this.templates.length > 0) {
165
- return this.templates.first;
166
- }
167
- return this.templateInput;
168
- }
169
- search(value, searchText) {
170
- if (value !== undefined && value !== null) {
171
- return value.toString().toLowerCase().indexOf(searchText) !== -1;
172
- }
173
- return false;
174
- }
175
- }
176
- SkyGridColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridColumnComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
177
- SkyGridColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: SkyGridColumnComponent, selector: "sky-grid-column", inputs: { alignment: "alignment", description: "description", excludeFromHighlighting: "excludeFromHighlighting", field: "field", heading: "heading", hidden: "hidden", id: "id", inlineHelpPopover: "inlineHelpPopover", isSortable: "isSortable", locked: "locked", searchFunction: ["search", "searchFunction"], type: "type", templateInput: ["template", "templateInput"], width: "width" }, queries: [{ propertyName: "templates", predicate: TemplateRef }], usesOnChanges: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
178
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridColumnComponent, decorators: [{
179
- type: Component,
180
- args: [{
181
- selector: 'sky-grid-column',
182
- template: '<ng-content></ng-content>',
183
- changeDetection: ChangeDetectionStrategy.OnPush,
184
- }]
185
- }], propDecorators: { alignment: [{
186
- type: Input
187
- }], description: [{
188
- type: Input
189
- }], excludeFromHighlighting: [{
190
- type: Input
191
- }], field: [{
192
- type: Input
193
- }], heading: [{
194
- type: Input
195
- }], hidden: [{
196
- type: Input
197
- }], id: [{
198
- type: Input
199
- }], inlineHelpPopover: [{
200
- type: Input
201
- }], isSortable: [{
202
- type: Input
203
- }], locked: [{
204
- type: Input
205
- }], searchFunction: [{
206
- type: Input,
207
- args: ['search']
208
- }], type: [{
209
- type: Input
210
- }], templateInput: [{
211
- type: Input,
212
- args: ['template']
213
- }], width: [{
214
- type: Input
215
- }], templates: [{
216
- type: ContentChildren,
217
- args: [TemplateRef]
218
- }] } });
219
-
220
- const GRID_HEADER_DRAGGING_CLASS = 'sky-grid-header-dragging';
221
- const GRID_HEADER_LOCKED_SELECTOR = '.sky-grid-header-locked';
222
- const GRID_HEADER_RESIZE_HANDLE = '.sky-grid-resize-handle';
223
- const GRID_ROW_DELETE_SELECTOR = '.sky-grid-row-delete-heading';
224
- const GRID_MULTISELECT_SELECTOR = '.sky-grid-multiselect-cell';
225
- /**
226
- * @internal
227
- */
228
- class SkyGridAdapterService {
229
- constructor(rendererFactory) {
230
- this.rendererFactory = rendererFactory;
231
- this.renderer = this.rendererFactory.createRenderer(undefined, undefined);
232
- }
233
- initializeDragAndDrop(dragulaGroupName, dragulaService, dropCallback) {
234
- dragulaService
235
- .drag(dragulaGroupName)
236
- .subscribe((args) => args.el.classList.add(GRID_HEADER_DRAGGING_CLASS));
237
- dragulaService
238
- .dragend(dragulaGroupName)
239
- .subscribe((args) => args.el.classList.remove(GRID_HEADER_DRAGGING_CLASS));
240
- dragulaService.drop(dragulaGroupName).subscribe((args) => {
241
- const columnIds = [];
242
- const nodes = args.target.querySelectorAll(`th:not(${GRID_MULTISELECT_SELECTOR}):not(${GRID_ROW_DELETE_SELECTOR})`);
243
- for (let i = 0; i < nodes.length; i++) {
244
- const el = nodes[i];
245
- const id = el.getAttribute('sky-cmp-id');
246
- columnIds.push(id);
247
- }
248
- dropCallback(columnIds);
249
- });
250
- dragulaService.createGroup(dragulaGroupName, {
251
- moves: (el, container, handle) => {
252
- const columns = container.querySelectorAll('th div');
253
- const isLeftOfLocked = this.isLeftOfLocked(handle, columns);
254
- return (!el.querySelector(GRID_HEADER_LOCKED_SELECTOR) &&
255
- handle !== undefined &&
256
- !handle.matches(GRID_HEADER_RESIZE_HANDLE) &&
257
- !handle.matches(GRID_MULTISELECT_SELECTOR) &&
258
- !handle.matches(GRID_ROW_DELETE_SELECTOR) &&
259
- !isLeftOfLocked);
260
- },
261
- accepts: (el, target, source, sibling) => {
262
- if (sibling === undefined || !sibling) {
263
- return true;
264
- }
265
- const columns = source.querySelectorAll('th div');
266
- const siblingDiv = sibling.querySelector('div');
267
- const isLeftOfLocked = this.isLeftOfLocked(siblingDiv, columns);
268
- return (!sibling.matches(GRID_HEADER_LOCKED_SELECTOR) &&
269
- !sibling.matches(GRID_HEADER_RESIZE_HANDLE) &&
270
- !isLeftOfLocked);
271
- },
272
- });
273
- }
274
- getRowHeight(el, index) {
275
- return (el.nativeElement.querySelectorAll('tbody tr')[index].scrollHeight + 'px');
276
- }
277
- setStyle(el, style, value) {
278
- if (el) {
279
- this.renderer.setStyle(el.nativeElement, style, value);
280
- }
281
- }
282
- isLeftOfLocked(handle, columns) {
283
- let sourceColumn = handle;
284
- for (const column of Array.from(columns)) {
285
- if (column.contains(handle)) {
286
- sourceColumn = column;
287
- }
288
- }
289
- for (let i = columns.length - 1; i >= 0; i--) {
290
- if (columns[i].classList.contains('sky-grid-header-locked')) {
291
- return true;
292
- }
293
- if (columns[i] === sourceColumn) {
294
- break;
295
- }
296
- }
297
- return false;
298
- }
299
- }
300
- SkyGridAdapterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridAdapterService, deps: [{ token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable });
301
- SkyGridAdapterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridAdapterService });
302
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridAdapterService, decorators: [{
303
- type: Injectable
304
- }], ctorParameters: function () { return [{ type: i0.RendererFactory2 }]; } });
305
-
306
- /**
307
- * @internal
308
- * @deprecated `SkyGridComponent` and its features are deprecated. We recommend using the data grid instead. For more information, see https://developer.blackbaud.com/skyux/components/data-grid
309
- */
310
- class SkyGridColumnModel {
311
- constructor(template, data) {
312
- this.isSortable = true;
313
- this.template = template;
314
- if (data) {
315
- this.id = data.id || data.field;
316
- this.type = data.type;
317
- this.field = data.field;
318
- this.heading = data.heading;
319
- this.inlineHelpPopover = data.inlineHelpPopover;
320
- this.width = data.width ? Number(data.width) : undefined;
321
- this.hidden = data.hidden;
322
- this.locked = data.locked;
323
- this.description = data.description;
324
- this.searchFunction = data.searchFunction;
325
- this.isSortable = data.isSortable;
326
- this.excludeFromHighlighting = data.excludeFromHighlighting;
327
- this.alignment = data.alignment;
328
- }
329
- }
330
- }
331
-
332
- /**
333
- * @deprecated `SkyGridComponent` and its features are deprecated. We recommend using the data grid instead. For more information, see https://developer.blackbaud.com/skyux/components/data-grid
334
- */
335
- var SkyGridMessageType;
336
- (function (SkyGridMessageType) {
337
- /**
338
- * Selects the multiselect checkboxes for all rows in the grid.
339
- */
340
- SkyGridMessageType[SkyGridMessageType["SelectAll"] = 0] = "SelectAll";
341
- /**
342
- * Clears the multiselect checkboxes for all rows in the grid.
343
- */
344
- SkyGridMessageType[SkyGridMessageType["ClearAll"] = 1] = "ClearAll";
345
- /**
346
- * @internal
347
- */
348
- SkyGridMessageType[SkyGridMessageType["PromptDeleteRow"] = 2] = "PromptDeleteRow";
349
- /**
350
- * @internal
351
- */
352
- SkyGridMessageType[SkyGridMessageType["AbortDeleteRow"] = 3] = "AbortDeleteRow";
353
- })(SkyGridMessageType || (SkyGridMessageType = {}));
354
-
355
- /**
356
- * @internal
357
- * @deprecated `SkyGridComponent` and its features are deprecated. We recommend using the data grid instead. For more information, see https://developer.blackbaud.com/skyux/components/data-grid
358
- */
359
- var SkyGridSelectedRowsSource;
360
- (function (SkyGridSelectedRowsSource) {
361
- SkyGridSelectedRowsSource[SkyGridSelectedRowsSource["CheckboxChange"] = 0] = "CheckboxChange";
362
- SkyGridSelectedRowsSource[SkyGridSelectedRowsSource["ClearAll"] = 1] = "ClearAll";
363
- SkyGridSelectedRowsSource[SkyGridSelectedRowsSource["RowClick"] = 2] = "RowClick";
364
- SkyGridSelectedRowsSource[SkyGridSelectedRowsSource["SelectAll"] = 3] = "SelectAll";
365
- SkyGridSelectedRowsSource[SkyGridSelectedRowsSource["SelectedRowIdsChange"] = 4] = "SelectedRowIdsChange";
366
- })(SkyGridSelectedRowsSource || (SkyGridSelectedRowsSource = {}));
367
-
368
- let nextId = 0;
369
- /**
370
- * @deprecated `SkyGridComponent` and its features are deprecated. We recommend using the data grid instead. For more information, see https://developer.blackbaud.com/skyux/components/data-grid
371
- */
372
- class SkyGridComponent {
373
- /**
374
- * Columns and column properties for the grid.
375
- */
376
- set columns(newColumns) {
377
- const oldColumns = this.columns;
378
- this._columns = newColumns;
379
- if (oldColumns) {
380
- this.transferColumnWidths(oldColumns, this.columns);
381
- this.isResized = false;
382
- this.setDisplayedColumns(true);
383
- }
384
- this.changeDetector.markForCheck();
385
- }
386
- get columns() {
387
- return this._columns;
388
- }
389
- /**
390
- * The columns to display in the grid based on the `id` or `field` properties
391
- * of the columns. If no columns are specified, then the grid displays all columns.
392
- */
393
- set selectedColumnIds(value) {
394
- const currentIds = this._selectedColumnIds;
395
- this._selectedColumnIds = value;
396
- if (this.columns) {
397
- this.setDisplayedColumns();
398
- }
399
- // Ensure that the ids have changed.
400
- if (!currentIds || !value || !this.arraysEqual(value, currentIds)) {
401
- // This variable ensures that we do not set user config options or fire the change event
402
- // on the first time that the columns are set up
403
- if (this.selectedColumnIdsSet) {
404
- this.setUserConfig({
405
- selectedColumnIds: value,
406
- });
407
- this.selectedColumnIdsChange.emit(this._selectedColumnIds);
408
- if (this.isResized) {
409
- this.resetTableWidth();
410
- }
411
- }
412
- }
413
- this.selectedColumnIdsSet = true;
414
- }
415
- get selectedColumnIds() {
416
- return this._selectedColumnIds;
417
- }
418
- /**
419
- * The set of IDs for the rows to select in a multiselect grid.
420
- * The IDs match the `id` properties of the `data` objects.
421
- * Rows with IDs that are not included are de-selected in the grid.
422
- */
423
- set selectedRowIds(value) {
424
- if (value) {
425
- this._selectedRowIds = value;
426
- this.applySelectedRows();
427
- this.emitSelectedRows(SkyGridSelectedRowsSource.SelectedRowIdsChange);
428
- }
429
- }
430
- get selectedRowIds() {
431
- return this._selectedRowIds;
432
- }
433
- get tableWidth() {
434
- return this.tableElementRef.nativeElement.offsetWidth;
435
- }
436
- constructor(affixService, changeDetector, dragulaService, gridAdapter, overlayService, skyWindow, uiConfigService, logger) {
437
- this.affixService = affixService;
438
- this.changeDetector = changeDetector;
439
- this.dragulaService = dragulaService;
440
- this.gridAdapter = gridAdapter;
441
- this.overlayService = overlayService;
442
- this.skyWindow = skyWindow;
443
- this.uiConfigService = uiConfigService;
444
- /**
445
- * Whether to enable the multiselect feature to display a column of
446
- * checkboxes on the left side of the grid. You can specify a unique ID with
447
- * the `multiselectRowId` property, but multiselect defaults to the `id` property on
448
- * the `data` object.
449
- * @default false
450
- */
451
- this.enableMultiselect = false;
452
- /**
453
- * How the grid fits to its parent. The valid options are `width`,
454
- * which fits the grid to the parent's full width, and `scroll`, which allows the grid
455
- * to exceed the parent's width. If the grid does not have enough columns to fill
456
- * the parent's width, it always stretches to the parent's full width.
457
- * @default "width"
458
- */
459
- this.fit = 'width';
460
- /**
461
- * Whether to display a toolbar with the grid.
462
- */
463
- this.hasToolbar = false;
464
- /**
465
- * The observable to send commands to the grid.
466
- */
467
- this.messageStream = new Subject();
468
- /**
469
- * Fires when the width of a column changes.
470
- */
471
- this.columnWidthChange = new EventEmitter();
472
- /**
473
- * Fires when the selection of multiselect checkboxes changes.
474
- * Emits an array of IDs for the selected rows based on the `multiselectRowId` property
475
- * that the consumer provides.
476
- */
477
- this.multiselectSelectionChange = new EventEmitter();
478
- /**
479
- * @internal
480
- */
481
- this.rowDeleteCancel = new EventEmitter();
482
- /**
483
- * @internal
484
- */
485
- this.rowDeleteConfirm = new EventEmitter();
486
- /**
487
- * Fires when the columns to display in the grid change or when the order of the columns changes.
488
- * The event emits an array of IDs for the displayed columns that reflects the column order.
489
- */
490
- this.selectedColumnIdsChange = new EventEmitter();
491
- /**
492
- * Fires when the active sort field changes.
493
- */
494
- this.sortFieldChange = new EventEmitter();
495
- this.columnResizeStep = 10;
496
- this.gridId = ++nextId;
497
- this.rowDeleteConfigs = [];
498
- this.maxColWidth = 9999; // This is an arbitrary number, as the input range picker won't work without a value.
499
- this.minColWidth = 50;
500
- this.showResizeBar = false;
501
- this.showTopScroll = false;
502
- this.isDraggingResizeHandle = false;
503
- this.isResized = false;
504
- this.ngUnsubscribe = new Subject();
505
- this.rowDeleteContents = {};
506
- this.subscriptions = [];
507
- this.scrollTriggered = false;
508
- this.selectedColumnIdsSet = false;
509
- logger.deprecated('SkyGridComponent', {
510
- deprecationMajorVersion: 6,
511
- moreInfoUrl: 'https://developer.blackbaud.com/skyux/components/data-grid',
512
- replacementRecommendation: 'Use data grid instead.',
513
- });
514
- this.displayedColumns = new Array();
515
- this.items = new Array();
516
- this.currentSortField = new BehaviorSubject({
517
- fieldSelector: '',
518
- descending: false,
519
- });
520
- this.dragulaGroupName = `sky-grids-group-${this.gridId}`;
521
- }
522
- ngOnInit() {
523
- this.messageStream
524
- .pipe(takeUntil(this.ngUnsubscribe))
525
- .subscribe((message) => {
526
- this.handleIncomingMessages(message);
527
- });
528
- }
529
- ngAfterContentInit() {
530
- if (this.settingsKey) {
531
- this.applyUserConfig().then(() => {
532
- this.initColumns();
533
- });
534
- }
535
- else {
536
- this.initColumns();
537
- }
538
- // Setup column drag-and-drop.
539
- this.gridAdapter.initializeDragAndDrop(this.dragulaGroupName, this.dragulaService, (selectedColumnIds) => {
540
- this.onHeaderDrop(selectedColumnIds);
541
- });
542
- this.applySelectedRows();
543
- }
544
- ngAfterViewInit() {
545
- this.checkUserColumnWidthsForScroll();
546
- }
547
- ngOnChanges(changes) {
548
- if (changes['columns'] && this.columns) {
549
- if (this.selectedColumnIds) {
550
- this.selectedColumnIds = this.selectedColumnIds.filter((columnId) => {
551
- return this.columns.find((column) => column.id === columnId);
552
- });
553
- }
554
- this.setDisplayedColumns(true);
555
- }
556
- if (changes['data'] && this.data) {
557
- this.transformData();
558
- // This set timeout is necessary to ensure the data has rendered in the grid
559
- setTimeout(() => {
560
- // This cleans up any lingering row deletes for items that have been removed.
561
- Object.keys(this.rowDeleteContents).forEach((id) => {
562
- if (!this.data.find((item) => item.id === id)) {
563
- this.destroyRowDelete(id);
564
- }
565
- else {
566
- // The rows re-render thus messing up the affixers. We must reaffix them so that things
567
- // continue to render correctly.
568
- const rowElement = this.tableElementRef.nativeElement.querySelector('[sky-cmp-id="' + id + '"]');
569
- this.rowDeleteContents[id].affixer.affixTo(rowElement, {
570
- autoFitContext: SkyAffixAutoFitContext.Viewport,
571
- isSticky: true,
572
- placement: 'above',
573
- verticalAlignment: 'top',
574
- horizontalAlignment: 'left',
575
- enableAutoFit: false,
576
- });
577
- }
578
- });
579
- this.checkUserColumnWidthsForScroll();
580
- });
581
- }
582
- if (changes['sortField']) {
583
- this.setSortHeaders();
584
- }
585
- }
586
- ngOnDestroy() {
587
- this.subscriptions.forEach((subscription) => {
588
- subscription.unsubscribe();
589
- });
590
- this.multiselectSelectionChange.complete();
591
- this.ngUnsubscribe.next();
592
- this.ngUnsubscribe.complete();
593
- Object.keys(this.rowDeleteContents).forEach((id) => {
594
- this.destroyRowDelete(id);
595
- });
596
- this.dragulaService.destroy(this.dragulaGroupName);
597
- }
598
- onWindowResize() {
599
- this.checkUserColumnWidthsForScroll();
600
- }
601
- getTopScrollWidth() {
602
- return this.tableElementRef.nativeElement.scrollWidth;
603
- }
604
- getTableClassNames() {
605
- const classNames = [];
606
- if (this.fit !== 'scroll') {
607
- classNames.push('sky-grid-fit');
608
- }
609
- if (this.hasToolbar) {
610
- classNames.push('sky-grid-has-toolbar');
611
- }
612
- return this.addDelimiter(classNames, ' ');
613
- }
614
- getTableHeaderClassNames(column) {
615
- const classNames = [];
616
- if (column && column.locked) {
617
- classNames.push('sky-grid-header-locked');
618
- }
619
- return this.addDelimiter(classNames, ' ');
620
- }
621
- getCaretIconNames(column) {
622
- const iconNames = [];
623
- this.getSortDirection(column.field).subscribe((sortDir) => {
624
- if (sortDir === 'asc') {
625
- iconNames.push('caret-up');
626
- }
627
- if (sortDir === 'desc') {
628
- iconNames.push('caret-down');
629
- }
630
- });
631
- return this.addDelimiter(iconNames, ' ');
632
- }
633
- onKeydown(event, column) {
634
- const key = event.key.toLowerCase();
635
- if (key === 'enter' || key === ' ') {
636
- this.sortByColumn(column);
637
- }
638
- }
639
- sortByColumn(column) {
640
- if (!this.isDraggingResizeHandle && column.isSortable) {
641
- this.currentSortField
642
- .pipe(take(1), map((field) => {
643
- let selector = {
644
- fieldSelector: column.field,
645
- descending: true,
646
- };
647
- if (field &&
648
- field.fieldSelector === column.field &&
649
- field.descending) {
650
- selector = {
651
- fieldSelector: column.field,
652
- descending: false,
653
- };
654
- }
655
- this.sortFieldChange.emit(selector);
656
- this.currentSortField.next(selector);
657
- }))
658
- .subscribe();
659
- }
660
- }
661
- getSortDirection(columnField) {
662
- return this.currentSortField.pipe(distinctUntilChanged(), map((field) => {
663
- return field.fieldSelector === columnField
664
- ? field.descending
665
- ? 'desc'
666
- : 'asc'
667
- : undefined;
668
- }));
669
- }
670
- getAriaSortDirection(column) {
671
- return this.currentSortField.pipe(distinctUntilChanged(), map((field) => {
672
- return field.fieldSelector === column.field
673
- ? field.descending
674
- ? 'descending'
675
- : 'ascending'
676
- : column.isSortable
677
- ? 'none'
678
- : undefined;
679
- }));
680
- }
681
- getCaretVisibility(columnField) {
682
- return this.currentSortField.pipe(distinctUntilChanged(), map((field) => {
683
- return field.fieldSelector === columnField ? 'visible' : 'hidden';
684
- }));
685
- }
686
- getHelpInlineClass(columnField) {
687
- return this.getCaretVisibility(columnField).pipe(map((visibility) => {
688
- return visibility === 'hidden';
689
- }));
690
- }
691
- onMultiselectCheckboxChange() {
692
- this.emitSelectedRows(SkyGridSelectedRowsSource.CheckboxChange);
693
- }
694
- updateColumnHeading(change) {
695
- const foundColumnModel = this.columns.find((column) => {
696
- return ((change.id !== undefined && change.id === column.id) ||
697
- (change.field !== undefined && change.field === column.field));
698
- });
699
- /* istanbul ignore else */
700
- if (foundColumnModel) {
701
- foundColumnModel.heading = change.value;
702
- this.changeDetector.markForCheck();
703
- }
704
- }
705
- updateInlineHelpPopover(change) {
706
- const foundColumnModel = this.columns.find((column) => {
707
- return ((change.id !== undefined && change.id === column.id) ||
708
- (change.field !== undefined && change.field === column.field));
709
- });
710
- /* istanbul ignore else */
711
- if (foundColumnModel) {
712
- foundColumnModel.inlineHelpPopover = change.value;
713
- this.changeDetector.markForCheck();
714
- }
715
- }
716
- updateColumnDescription(change) {
717
- const foundColumnModel = this.columns.find((column) => {
718
- return ((change.id !== undefined && change.id === column.id) ||
719
- (change.field !== undefined && change.field === column.field));
720
- });
721
- /* istanbul ignore else */
722
- if (foundColumnModel) {
723
- foundColumnModel.description = change.value;
724
- this.changeDetector.markForCheck();
725
- }
726
- }
727
- onResizeColumnStart(event) {
728
- // If this table hasn't been resized, initialize all the resize widths.
729
- if (!this.isResized) {
730
- this.initColumnWidths();
731
- this.isResized = true;
732
- }
733
- this.initializeResizeColumn(event);
734
- this.isDraggingResizeHandle = true;
735
- this.xPosStart = event.pageX;
736
- this.showResizeBar = true;
737
- // Show visual indicator of where mouse is dragging (resizeBar).
738
- this.changeDetector.detectChanges();
739
- this.setResizeBarPosition(event.pageX);
740
- event.preventDefault();
741
- event.stopPropagation();
742
- const mouseMoveEvent = fromEvent(document, 'mousemove');
743
- const touchMoveEvent = fromEvent(document, 'touchmove');
744
- merge(mouseMoveEvent, touchMoveEvent)
745
- .pipe(takeWhile(() => {
746
- return this.isDraggingResizeHandle;
747
- }))
748
- .subscribe((moveEvent) => {
749
- this.onResizeHandleMove(moveEvent);
750
- });
751
- const mouseUpEvent = fromEvent(document, 'mouseup');
752
- const touchEndEvent = fromEvent(document, 'touchend');
753
- merge(mouseUpEvent, touchEndEvent)
754
- .pipe(takeWhile(() => {
755
- return this.isDraggingResizeHandle;
756
- }))
757
- .subscribe((endEvent) => {
758
- this.onResizeHandleRelease(endEvent);
759
- });
760
- }
761
- onKeydownResizeCol(event) {
762
- // If this table hasn't been resized, initialize all the resize widths.
763
- if (!this.isResized) {
764
- this.initColumnWidths();
765
- this.isResized = true;
766
- }
767
- this.initializeResizeColumn(event);
768
- }
769
- onInputChangeResizeCol(event) {
770
- const input = event.target;
771
- const newValue = Number(input.value);
772
- const deltaX = newValue - this.startColumnWidth;
773
- this.resizeColumnByIndex(this.activeResizeColumnIndex, newValue, deltaX);
774
- const left = input.getBoundingClientRect().left;
775
- this.setResizeBarPosition(left);
776
- }
777
- onResizeHandleMove(event) {
778
- const deltaX = event.pageX - this.xPosStart;
779
- const newColWidth = this.startColumnWidth + deltaX;
780
- if (newColWidth <= this.minColWidth) {
781
- event.stopPropagation();
782
- return;
783
- }
784
- const max = this.getMaxRangeByIndex(this.activeResizeColumnIndex);
785
- if (this.fit === 'width' && newColWidth > max) {
786
- event.stopPropagation();
787
- return;
788
- }
789
- this.setResizeBarPosition(event.pageX);
790
- }
791
- onResizeHandleBlur() {
792
- this.showResizeBar = false;
793
- }
794
- onResizeHandleFocus(event) {
795
- this.showResizeBar = true;
796
- this.changeDetector.detectChanges();
797
- const target = event.target;
798
- const left = target.getBoundingClientRect().left;
799
- this.setResizeBarPosition(left);
800
- }
801
- onResizeHandleRelease(event) {
802
- this.showResizeBar = false;
803
- const deltaX = event.pageX - this.xPosStart;
804
- const newColWidth = this.startColumnWidth + deltaX;
805
- this.resizeColumnByIndex(this.activeResizeColumnIndex, newColWidth, deltaX);
806
- this.isDraggingResizeHandle = false;
807
- this.activeResizeColumnIndex = undefined;
808
- event.stopPropagation();
809
- this.changeDetector.markForCheck();
810
- }
811
- onRowClick(event, selectedItem) {
812
- /* istanbul ignore else */
813
- if (this.enableMultiselect) {
814
- if (event.target === event.currentTarget ||
815
- !this.isInteractiveElement(event)) {
816
- selectedItem.isSelected = !selectedItem.isSelected;
817
- this.changeDetector.markForCheck();
818
- this.emitSelectedRows(SkyGridSelectedRowsSource.RowClick);
819
- }
820
- }
821
- }
822
- isRowHighlighted(id) {
823
- if (this.rowHighlightedId) {
824
- return id === this.rowHighlightedId;
825
- }
826
- return false;
827
- }
828
- getRowHeight(index) {
829
- return this.gridAdapter.getRowHeight(this.tableElementRef, index);
830
- }
831
- cancelRowDelete(id) {
832
- this.rowDeleteConfigs = this.rowDeleteConfigs.filter((config) => config.id !== id);
833
- this.rowDeleteCancel.emit({ id: id });
834
- this.destroyRowDelete(id);
835
- }
836
- confirmRowDelete(id) {
837
- this.rowDeleteConfigs.find((config) => config.id === id).pending = true;
838
- this.rowDeleteConfirm.emit({ id: id });
839
- }
840
- getRowDeleteItem(id) {
841
- return this.rowDeleteConfigs.find((rowDelete) => rowDelete.id === id);
842
- }
843
- // Prevent touch devices from inadvertently scrolling grid while dragging columns.
844
- onTouchMove(event) {
845
- event.preventDefault();
846
- }
847
- onTopScroll(event) {
848
- /* sanity check */
849
- /* istanbul ignore else */
850
- if (this.tableContainerElementRef) {
851
- if (this.scrollTriggered) {
852
- this.scrollTriggered = false;
853
- this.tableContainerElementRef.nativeElement.scrollLeft =
854
- this.topScrollContainerElementRef.nativeElement.scrollLeft;
855
- }
856
- else {
857
- this.scrollTriggered = true;
858
- }
859
- }
860
- }
861
- onGridScroll(event) {
862
- /* sanity check */
863
- /* istanbul ignore else */
864
- if (this.topScrollContainerElementRef) {
865
- if (this.scrollTriggered) {
866
- this.scrollTriggered = false;
867
- this.topScrollContainerElementRef.nativeElement.scrollLeft =
868
- this.tableContainerElementRef.nativeElement.scrollLeft;
869
- }
870
- else {
871
- this.scrollTriggered = true;
872
- }
873
- }
874
- }
875
- checkUserColumnWidthsForScroll() {
876
- if (!this.showTopScroll &&
877
- this.columnElementRefs &&
878
- this.columnElementRefs.length > 0) {
879
- let columnsWidthTotal = 0;
880
- const windowSize = this.skyWindow.nativeWindow.innerWidth;
881
- this.columnElementRefs.forEach((col) => {
882
- if (!this.showTopScroll) {
883
- const computedWidth = parseFloat(window.getComputedStyle(col.nativeElement).width);
884
- const offsetWidth = col.nativeElement.offsetWidth;
885
- const width = Math.max(computedWidth || offsetWidth, this.minColWidth);
886
- columnsWidthTotal = columnsWidthTotal + width;
887
- if (columnsWidthTotal > windowSize) {
888
- this.showTopScroll = true;
889
- setTimeout(() => {
890
- this.changeDetector.markForCheck();
891
- });
892
- }
893
- }
894
- });
895
- }
896
- }
897
- multiselectSelectAll() {
898
- for (let i = 0; i < this.items.length; i++) {
899
- this.items[i].isSelected = true;
900
- }
901
- this.changeDetector.markForCheck();
902
- this.emitSelectedRows(SkyGridSelectedRowsSource.SelectAll);
903
- }
904
- multiselectClearAll() {
905
- for (let i = 0; i < this.items.length; i++) {
906
- this.items[i].isSelected = false;
907
- }
908
- this.changeDetector.markForCheck();
909
- this.emitSelectedRows(SkyGridSelectedRowsSource.ClearAll);
910
- }
911
- handleIncomingMessages(message) {
912
- switch (message.type) {
913
- case SkyGridMessageType.SelectAll:
914
- this.multiselectSelectAll();
915
- break;
916
- case SkyGridMessageType.ClearAll:
917
- this.multiselectClearAll();
918
- break;
919
- case SkyGridMessageType.PromptDeleteRow:
920
- /* sanity check */
921
- /* istanbul ignore else */
922
- if (message.data && message.data.promptDeleteRow) {
923
- const existingConfig = this.rowDeleteConfigs.find((config) => config.id === message.data.promptDeleteRow.id);
924
- if (existingConfig) {
925
- existingConfig.pending = false;
926
- }
927
- else {
928
- this.rowDeleteConfigs.push({
929
- id: message.data.promptDeleteRow.id,
930
- pending: false,
931
- });
932
- const overlay = this.overlayService.create({
933
- enableScroll: true,
934
- showBackdrop: false,
935
- closeOnNavigation: true,
936
- enableClose: false,
937
- enablePointerEvents: true,
938
- });
939
- overlay.attachTemplate(this.inlineDeleteTemplateRef, {
940
- $implicit: this.data.find((item) => item.id === message.data.promptDeleteRow.id),
941
- });
942
- /**
943
- * We are manually setting the z-index here because overlays will always be on top of
944
- * the omnibar. This manual setting is 1 less than the omnibar's z-index of 1000. We
945
- * discussed changing the overlay service to allow for this but decided against that
946
- * change at this time due to its niche nature.
947
- */
948
- overlay.componentRef.instance.zIndex = '999';
949
- setTimeout(() => {
950
- const inlineDeleteRef = this.inlineDeleteRefs
951
- .toArray()
952
- .find((elRef) => {
953
- return (elRef.nativeElement.id ===
954
- 'row-delete-ref-' + message.data.promptDeleteRow.id);
955
- });
956
- const affixer = this.affixService.createAffixer(inlineDeleteRef);
957
- const rowElement = this.tableElementRef.nativeElement.querySelector('[sky-cmp-id="' + message.data.promptDeleteRow.id + '"]');
958
- affixer.affixTo(rowElement, {
959
- autoFitContext: SkyAffixAutoFitContext.Viewport,
960
- isSticky: true,
961
- placement: 'above',
962
- verticalAlignment: 'top',
963
- horizontalAlignment: 'left',
964
- enableAutoFit: false,
965
- });
966
- this.rowDeleteContents[message.data.promptDeleteRow.id] = {
967
- affixer: affixer,
968
- overlay: overlay,
969
- };
970
- });
971
- }
972
- }
973
- break;
974
- case SkyGridMessageType.AbortDeleteRow:
975
- /* sanity check */
976
- /* istanbul ignore else */
977
- if (message.data && message.data.abortDeleteRow) {
978
- this.rowDeleteConfigs = this.rowDeleteConfigs.filter((config) => config.id !== message.data.abortDeleteRow.id);
979
- this.destroyRowDelete(message.data.abortDeleteRow.id);
980
- }
981
- break;
982
- }
983
- this.changeDetector.markForCheck();
984
- }
985
- onHeaderDrop(newColumnIds) {
986
- // update selected columnIds
987
- this.selectedColumnIdsSet = true;
988
- this.selectedColumnIds = newColumnIds;
989
- // mark for check because we are using ChangeDetectionStrategy.onPush
990
- this.changeDetector.markForCheck();
991
- }
992
- setDisplayedColumns(respectHidden = false) {
993
- /* sanity check */
994
- /* istanbul ignore else */
995
- if (this.columns) {
996
- if (this.selectedColumnIds !== undefined) {
997
- // setup displayed columns
998
- this.displayedColumns = this.selectedColumnIds
999
- .filter((columnId) => {
1000
- return this.columns.find((column) => column.id === columnId);
1001
- })
1002
- .map((columnId) => {
1003
- return this.columns.filter((column) => column.id === columnId)[0];
1004
- });
1005
- }
1006
- else if (respectHidden) {
1007
- this.displayedColumns = this.columns.filter((column) => {
1008
- return !column.hidden;
1009
- });
1010
- }
1011
- else {
1012
- this.displayedColumns = this.columns;
1013
- }
1014
- }
1015
- }
1016
- transformData() {
1017
- // Transform data into object with id and data properties
1018
- if (this.data &&
1019
- this.data.length > 0 &&
1020
- this.data[0].id &&
1021
- !this.data[0].data) {
1022
- if (this.multiselectRowId) {
1023
- this.items = this.getGridDataWithSelectedRows();
1024
- }
1025
- else {
1026
- this.items = this.data.map((item) => new ListItemModel(item.id, item));
1027
- }
1028
- }
1029
- else {
1030
- this.items = this.data;
1031
- }
1032
- }
1033
- getGridDataWithSelectedRows() {
1034
- const selectedRows = this.getSelectedRows();
1035
- return this.data.map((item) => {
1036
- let checked;
1037
- if (Object.prototype.hasOwnProperty.call(item, this.multiselectRowId)) {
1038
- checked = selectedRows.indexOf(item[this.multiselectRowId]) > -1;
1039
- }
1040
- else {
1041
- checked = selectedRows.indexOf(item.id) > -1;
1042
- }
1043
- return new ListItemModel(item.id, item, checked);
1044
- });
1045
- }
1046
- applySelectedRows() {
1047
- if (this.items && this.items.length > 0 && this.selectedRowIds) {
1048
- for (let i = 0; i < this.items.length; i++) {
1049
- this.items[i].isSelected =
1050
- this.selectedRowIds.indexOf(this.items[i].id) > -1;
1051
- }
1052
- this.changeDetector.markForCheck();
1053
- }
1054
- }
1055
- setSortHeaders() {
1056
- this.currentSortField.next(this.sortField || { fieldSelector: '', descending: false });
1057
- }
1058
- getColumnsFromComponent() {
1059
- this.columns = this.columnComponents.map((columnComponent) => {
1060
- return new SkyGridColumnModel(columnComponent.template, columnComponent);
1061
- });
1062
- }
1063
- updateColumns() {
1064
- this.getColumnsFromComponent();
1065
- // This set timeout is necessary to ensure the columns have rendered in the grid
1066
- setTimeout(() => {
1067
- this.checkUserColumnWidthsForScroll();
1068
- });
1069
- }
1070
- resizeColumnByIndex(columnIndex, newColWidth, deltaX) {
1071
- const column = this.getColumnModelByIndex(columnIndex);
1072
- // Prevent accidental shrinkage below minimum width.
1073
- if (newColWidth <= this.minColWidth) {
1074
- deltaX = deltaX + this.minColWidth - newColWidth;
1075
- newColWidth = this.minColWidth;
1076
- }
1077
- // fit=width adds/removes width from the last column
1078
- // fit=scroll adds/removes width from the table
1079
- if (this.fit === 'width') {
1080
- const lastColumn = this.getLastDisplayedColumn();
1081
- // Prevent accidental growth that would bump last column off screen.
1082
- const max = this.getMaxRangeByIndex(columnIndex);
1083
- if (newColWidth > max) {
1084
- newColWidth = max;
1085
- deltaX = max - this.startColumnWidth;
1086
- }
1087
- column.width = newColWidth;
1088
- lastColumn.width = lastColumn.width - deltaX;
1089
- this.updateMaxRange();
1090
- }
1091
- else {
1092
- this.gridAdapter.setStyle(this.tableElementRef, 'width', `${this.tableWidth + deltaX}px`);
1093
- column.width = newColWidth;
1094
- }
1095
- this.changeDetector.detectChanges();
1096
- this.columnWidthChange.emit(this.getColumnWidthModelChange());
1097
- }
1098
- initColumnWidths() {
1099
- // Establish table width.
1100
- this.showTopScroll = true;
1101
- // Set column widths based on the width initially given by the browser.
1102
- // computedWidth prevents accidental overflow for browsers with sub-pixel widths.
1103
- this.columnElementRefs.forEach((col, index) => {
1104
- const computedWidth = parseFloat(window.getComputedStyle(col.nativeElement).width);
1105
- const offsetWidth = col.nativeElement.offsetWidth;
1106
- /* istanbul ignore next */
1107
- this.getColumnModelByIndex(index).width = Math.max(computedWidth || offsetWidth, this.minColWidth);
1108
- });
1109
- // 'scroll' tables should be allowed to expand outside of their constraints.
1110
- if (this.fit === 'scroll') {
1111
- this.gridAdapter.setStyle(this.tableElementRef, 'min-width', 'auto');
1112
- }
1113
- // Update max limits for input ranges.
1114
- if (this.fit === 'width') {
1115
- this.updateMaxRange();
1116
- }
1117
- this.changeDetector.detectChanges();
1118
- }
1119
- transferColumnWidths(oldColumns, newColumns) {
1120
- /* sanity check */
1121
- /* istanbul ignore else */
1122
- if (oldColumns && newColumns) {
1123
- for (const oldColumn of oldColumns) {
1124
- if (oldColumn.width) {
1125
- const matchingColumn = newColumns.find((newColumn) => oldColumn.id === newColumn.id);
1126
- if (matchingColumn && !matchingColumn.width) {
1127
- matchingColumn.width = oldColumn.width;
1128
- }
1129
- }
1130
- }
1131
- }
1132
- this.changeDetector.markForCheck();
1133
- }
1134
- getColumnWidthModelChange() {
1135
- const columnWidthModelChange = new Array();
1136
- this.columns.forEach((column) => {
1137
- columnWidthModelChange.push({
1138
- id: column.id,
1139
- field: column.field,
1140
- width: column.width,
1141
- });
1142
- });
1143
- return columnWidthModelChange;
1144
- }
1145
- updateMaxRange() {
1146
- const leftoverWidth = this.getLastDisplayedColumn().width - this.minColWidth;
1147
- this.displayedColumns.forEach((column, index) => {
1148
- const newMaxRange = column.width + leftoverWidth;
1149
- const rangeInput = this.getRangeInputByIndex(index);
1150
- rangeInput.nativeElement.max = newMaxRange;
1151
- rangeInput.nativeElement.setAttribute('aria-valuemax', newMaxRange);
1152
- });
1153
- }
1154
- initializeResizeColumn(event) {
1155
- const clickTarget = event.target;
1156
- this.activeResizeColumnIndex = clickTarget.getAttribute('sky-cmp-index');
1157
- const column = this.getColumnModelByIndex(this.activeResizeColumnIndex);
1158
- this.startColumnWidth = column.width;
1159
- }
1160
- resetTableWidth() {
1161
- this.skyWindow.nativeWindow.setTimeout(() => {
1162
- this.gridAdapter.setStyle(this.tableElementRef, 'width', `auto`);
1163
- this.changeDetector.detectChanges();
1164
- this.gridAdapter.setStyle(this.tableElementRef, 'width', `${this.tableWidth}px`);
1165
- this.changeDetector.detectChanges();
1166
- });
1167
- }
1168
- getRangeInputByIndex(index) {
1169
- return this.columnRangeInputElementRefs.find((input) => input.nativeElement.getAttribute('sky-cmp-index') === index.toString());
1170
- }
1171
- getColumnModelByIndex(index) {
1172
- return this.displayedColumns[Number(index)];
1173
- }
1174
- getMaxRangeByIndex(index) {
1175
- const columnElementRef = this.columnElementRefs.find((th) => th.nativeElement.getAttribute('sky-cmp-index') === index);
1176
- const rangeInput = columnElementRef.nativeElement.querySelector('.sky-grid-column-input-aria-only');
1177
- return Number(rangeInput.max);
1178
- }
1179
- getLastDisplayedColumn() {
1180
- return this.getColumnModelByIndex(this.displayedColumns.length - 1);
1181
- }
1182
- addDelimiter(text, delimiter) {
1183
- return text.filter((val) => val).join(delimiter);
1184
- }
1185
- destroyRowDelete(id) {
1186
- const rowDeleteContents = this.rowDeleteContents[id];
1187
- /* istanbul ignore else */
1188
- if (rowDeleteContents) {
1189
- rowDeleteContents.affixer.destroy();
1190
- this.overlayService.close(rowDeleteContents.overlay);
1191
- delete this.rowDeleteContents[id];
1192
- }
1193
- }
1194
- emitSelectedRows(source) {
1195
- const selectedRows = {
1196
- selectedRowIds: this.getSelectedRows(),
1197
- source: source,
1198
- };
1199
- this.multiselectSelectionChange.emit(selectedRows);
1200
- }
1201
- getSelectedRows() {
1202
- return this.items
1203
- .filter((item) => {
1204
- return item.isSelected;
1205
- })
1206
- .map((item) => {
1207
- if (Object.prototype.hasOwnProperty.call(item.data, this.multiselectRowId)) {
1208
- return item.data[this.multiselectRowId];
1209
- }
1210
- return item.id;
1211
- });
1212
- }
1213
- isInteractiveElement(event) {
1214
- const interactiveElSelectors = `
1215
- a,
1216
- button,
1217
- input,
1218
- label,
1219
- option,
1220
- select,
1221
- textarea,
1222
- details,
1223
- dialog,
1224
- menu,
1225
- menuitem,
1226
- summary`;
1227
- return event.target.closest(interactiveElSelectors);
1228
- }
1229
- setResizeBarPosition(xPosition) {
1230
- const parentScroll = this.tableContainerElementRef.nativeElement.scrollLeft;
1231
- const resizeBarX = xPosition -
1232
- this.tableElementRef.nativeElement.getBoundingClientRect().left -
1233
- parentScroll;
1234
- this.gridAdapter.setStyle(this.resizeBar, 'left', resizeBarX + 'px');
1235
- }
1236
- applyUserConfig() {
1237
- return new Promise((resolve) => {
1238
- this.uiConfigService
1239
- .getConfig(this.settingsKey)
1240
- .pipe(take(1))
1241
- .subscribe((config) => {
1242
- /* istanbul ignore else */
1243
- if (config && config.selectedColumnIds) {
1244
- // Remove any columnIds that don't exist in the current data set.
1245
- this.selectedColumnIds = config.selectedColumnIds.filter((id) => this.columns.find((column) => column.id === id));
1246
- this.changeDetector.markForCheck();
1247
- }
1248
- resolve();
1249
- }, () => {
1250
- resolve();
1251
- });
1252
- });
1253
- }
1254
- setUserConfig(config) {
1255
- if (!this.settingsKey) {
1256
- return;
1257
- }
1258
- this.uiConfigService
1259
- .setConfig(this.settingsKey, config)
1260
- .pipe(takeUntil(this.ngUnsubscribe))
1261
- .subscribe(
1262
- // eslint-disable-next-line @typescript-eslint/no-empty-function
1263
- () => { }, (err) => {
1264
- console.warn('Could not save grid settings.');
1265
- console.warn(err);
1266
- });
1267
- }
1268
- initColumns() {
1269
- /* istanbul ignore else */
1270
- if (this.columnComponents.length !== 0 || this.columns !== undefined) {
1271
- /* istanbul ignore else */
1272
- /* sanity check */
1273
- if (this.columnComponents.length > 0) {
1274
- this.getColumnsFromComponent();
1275
- }
1276
- this.transformData();
1277
- this.setDisplayedColumns(true);
1278
- this.changeDetector.markForCheck();
1279
- }
1280
- // Watch for added/removed columns:
1281
- this.subscriptions.push(this.columnComponents.changes.subscribe(() => this.updateColumns()));
1282
- // Watch for column heading changes:
1283
- this.columnComponents.forEach((comp) => {
1284
- this.subscriptions.push(comp.headingModelChanges.subscribe((change) => {
1285
- this.updateColumnHeading(change);
1286
- }));
1287
- this.subscriptions.push(comp.descriptionModelChanges.subscribe((change) => {
1288
- this.updateColumnDescription(change);
1289
- }));
1290
- this.subscriptions.push(comp.inlineHelpPopoverModelChanges.subscribe((change) => {
1291
- this.updateInlineHelpPopover(change);
1292
- }));
1293
- });
1294
- }
1295
- arraysEqual(arrayA, arrayB) {
1296
- return (arrayA.length === arrayB.length &&
1297
- arrayA.every((value, index) => value === arrayB[index]));
1298
- }
1299
- }
1300
- SkyGridComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridComponent, deps: [{ token: i1.SkyAffixService }, { token: i0.ChangeDetectorRef }, { token: i2.DragulaService }, { token: SkyGridAdapterService }, { token: i1.SkyOverlayService }, { token: i1.SkyAppWindowRef }, { token: i1.SkyUIConfigService }, { token: i1.SkyLogService }], target: i0.ɵɵFactoryTarget.Component });
1301
- SkyGridComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: SkyGridComponent, selector: "sky-grid", inputs: { columns: "columns", data: "data", enableMultiselect: "enableMultiselect", fit: "fit", hasToolbar: "hasToolbar", height: "height", highlightText: "highlightText", messageStream: "messageStream", multiselectRowId: "multiselectRowId", rowHighlightedId: "rowHighlightedId", selectedColumnIds: "selectedColumnIds", selectedRowIds: "selectedRowIds", settingsKey: "settingsKey", sortField: "sortField", width: "width" }, outputs: { columnWidthChange: "columnWidthChange", multiselectSelectionChange: "multiselectSelectionChange", rowDeleteCancel: "rowDeleteCancel", rowDeleteConfirm: "rowDeleteConfirm", selectedColumnIdsChange: "selectedColumnIdsChange", sortFieldChange: "sortFieldChange" }, host: { listeners: { "window:resize": "onWindowResize()" } }, providers: [SkyGridAdapterService], queries: [{ propertyName: "columnComponents", predicate: SkyGridColumnComponent }], viewQueries: [{ propertyName: "inlineDeleteTemplateRef", first: true, predicate: ["inlineDeleteTemplateRef"], descendants: true, read: TemplateRef }, { propertyName: "tableContainerElementRef", first: true, predicate: ["gridContainer"], descendants: true }, { propertyName: "tableElementRef", first: true, predicate: ["gridTable"], descendants: true }, { propertyName: "topScrollContainerElementRef", first: true, predicate: ["topScrollContainer"], descendants: true }, { propertyName: "resizeBar", first: true, predicate: ["resizeBar"], descendants: true }, { propertyName: "columnElementRefs", predicate: ["gridCol"], descendants: true }, { propertyName: "columnRangeInputElementRefs", predicate: ["colSizeRange"], descendants: true }, { propertyName: "inlineDeleteRefs", predicate: ["inlineDeleteRef"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"sky-grid\">\n <div\n *ngIf=\"showTopScroll\"\n class=\"sky-grid-top-scroll-container\"\n (scroll)=\"onTopScroll($event)\"\n #topScrollContainer\n >\n <div\n class=\"sky-grid-top-scroll\"\n [style.width.px]=\"getTopScrollWidth()\"\n ></div>\n </div>\n <div\n class=\"sky-grid-table-container\"\n [style.height.px]=\"height\"\n [style.width.px]=\"width\"\n (scroll)=\"onGridScroll($event)\"\n #gridContainer\n >\n <table class=\"sky-grid-table\" [ngClass]=\"getTableClassNames()\" #gridTable>\n <thead>\n <tr [dragula]=\"dragulaGroupName\">\n <th\n *ngIf=\"enableMultiselect\"\n class=\"sky-grid-heading sky-grid-multiselect-cell sky-grid-header-locked\"\n scope=\"col\"\n [style.max-width.px]=\"minColWidth\"\n [style.width.px]=\"minColWidth\"\n >\n <span class=\"screen-reader-only\">\n {{ 'skyux_grid_multiselect_select_row' | skyLibResources }}\n </span>\n </th>\n <th\n *ngFor=\"\n let column of displayedColumns;\n let last = last;\n let i = index\n \"\n class=\"sky-grid-heading sky-field-label\"\n scope=\"col\"\n [attr.sky-cmp-index]=\"i\"\n [attr.sky-cmp-id]=\"column.id || column.field\"\n [attr.aria-sort]=\"getAriaSortDirection(column) | async\"\n [id]=\"'sky-grid-' + gridId + '-column-' + i\"\n [ngClass]=\"'sky-grid-column-alignment-' + column.alignment\"\n [style.max-width.px]=\"column.width\"\n [style.width.px]=\"column.width\"\n [tabIndex]=\"column.isSortable ? 0 : -1\"\n (mouseup)=\"sortByColumn(column)\"\n (keydown)=\"onKeydown($event, column)\"\n (touchmove)=\"onTouchMove($event)\"\n #gridCol\n >\n <div\n class=\"overflow\"\n [ngClass]=\"getTableHeaderClassNames(column)\"\n [style.max-width.px]=\"column.width - 1\"\n [style.width.px]=\"column.width - 1\"\n >\n <span\n *ngIf=\"(getCaretVisibility(column.field) | async) === 'hidden'\"\n class=\"sky-grid-header-caret-hidden-spacing\"\n ></span>\n <!-- The no spacing here is intentional to avoid extra spaces due to these being inline elements -->\n <span class=\"sky-grid-header-text\">{{\n column.heading?.trim()\n }}</span>\n <sky-icon\n class=\"sky-grid-heading-sort\"\n [ngClass]=\"\n 'sky-grid-heading-sort-' +\n (getCaretVisibility(column.field) | async)\n \"\n [icon]=\"getCaretIconNames(column)\"\n >\n </sky-icon>\n <sky-help-inline\n *ngIf=\"column.inlineHelpPopover\"\n [ngClass]=\"{\n 'sky-grid-help-inline-sort-hidden':\n getHelpInlineClass(column.field) | async\n }\"\n [skyPopover]=\"column.inlineHelpPopover\"\n (keydown.enter)=\"$event.stopPropagation()\"\n (keydown.space)=\"$event.stopPropagation()\"\n (mousedown)=\"$event.stopPropagation()\"\n (mouseup)=\"$event.stopPropagation()\"\n >\n </sky-help-inline>\n </div>\n <span\n *ngIf=\"(fit === 'width' && !last) || fit === 'scroll'\"\n aria-hidden=\"true\"\n class=\"sky-grid-resize-handle\"\n tabindex=\"-1\"\n [attr.sky-cmp-index]=\"i\"\n (mousedown)=\"onResizeColumnStart($event)\"\n (touchstart)=\"onResizeColumnStart($event)\"\n >\n </span>\n <input\n aria-label=\"Width of column\"\n class=\"sky-grid-column-input-aria-only\"\n role=\"slider\"\n type=\"range\"\n [attr.aria-controls]=\"'sky-grid-' + gridId + '-column-' + i\"\n [attr.aria-valuemin]=\"minColWidth\"\n [attr.aria-valuemax]=\"maxColWidth\"\n [attr.aria-valuenow]=\"column.width\"\n [attr.sky-cmp-index]=\"i\"\n [min]=\"minColWidth\"\n [max]=\"maxColWidth\"\n [step]=\"columnResizeStep\"\n [(ngModel)]=\"column.width\"\n (blur)=\"onResizeHandleBlur()\"\n (focus)=\"onResizeHandleFocus($event)\"\n (keydown)=\"onKeydownResizeCol($event)\"\n (change)=\"onInputChangeResizeCol($event)\"\n #colSizeRange\n />\n </th>\n </tr>\n </thead>\n <tbody class=\"sky-grid-tbody\">\n <tr\n class=\"sky-grid-row\"\n *ngFor=\"let item of items; let i = index\"\n [attr.aria-current]=\"isRowHighlighted(item.id) ? true : null\"\n [attr.sky-cmp-id]=\"item.id\"\n [ngClass]=\"{\n 'sky-grid-multiselect-selected-row': item.isSelected,\n 'sky-grid-multiselect-row': enableMultiselect,\n 'sky-grid-row-highlight': isRowHighlighted(item.id)\n }\"\n (click)=\"onRowClick($event, item)\"\n >\n <td\n *ngIf=\"enableMultiselect\"\n class=\"sky-grid-multiselect-cell sky-grid-header-locked\"\n >\n <div\n [style.max-width.px]=\"minColWidth\"\n [style.width.px]=\"minColWidth\"\n >\n <sky-checkbox\n [label]=\"'skyux_grid_multiselect_select_row' | skyLibResources\"\n (change)=\"onMultiselectCheckboxChange()\"\n [(ngModel)]=\"item.isSelected\"\n >\n </sky-checkbox>\n </div>\n </td>\n <td\n *ngFor=\"\n let column of displayedColumns;\n let last = last;\n let i = index\n \"\n class=\"sky-grid-cell\"\n [ngClass]=\"'sky-grid-column-alignment-' + column.alignment\"\n [style.max-width.px]=\"column.width\"\n [style.width.px]=\"column.width\"\n >\n <sky-grid-cell\n [skyHighlight]=\"\n !column.excludeFromHighlighting ? highlightText : undefined\n \"\n [template]=\"column.template || defaultCellTemplate\"\n [fieldSelector]=\"column.field\"\n [item]=\"item\"\n [columnId]=\"column.id\"\n [attr.sky-cmp-id]=\"column.id || column.field\"\n >\n </sky-grid-cell>\n </td>\n </tr>\n </tbody>\n </table>\n <div\n *ngIf=\"showResizeBar\"\n aria-hidden=\"true\"\n id=\"sky-grid-resize-bar\"\n tabindex=\"-1\"\n #resizeBar\n ></div>\n </div>\n</div>\n\n<ng-template #defaultCellTemplate let-row=\"row\" let-value=\"value\">{{\n value\n}}</ng-template>\n\n<ng-template let-item #inlineDeleteTemplateRef>\n <div\n [id]=\"'row-delete-ref-' + item.id\"\n [ngStyle]=\"{\n height: getRowHeight(0),\n position: 'fixed',\n width: tableWidth + 'px'\n }\"\n #inlineDeleteRef\n >\n <sky-inline-delete\n [pending]=\"getRowDeleteItem(item.id).pending\"\n (cancelTriggered)=\"cancelRowDelete(item.id)\"\n (deleteTriggered)=\"confirmRowDelete(item.id)\"\n ></sky-inline-delete>\n </div>\n</ng-template>\n", styles: [".sky-grid{position:relative;display:block}.sky-grid-table-container{overflow:auto}.sky-grid-table{position:relative;table-layout:fixed;border-collapse:collapse;margin:0;font-size:15px;min-width:100%}.sky-grid-table.sky-grid-fit{max-width:100%;width:100%}.sky-grid-tbody{background-color:#fff}.sky-grid-row{border-bottom:1px dotted #cdcfd2}.sky-grid-row:nth-child(odd){background-color:#fbfbfb}.sky-grid-row.sky-grid-row-highlight{border-top:1px solid #0974a1;box-shadow:0 0 0 3px inset #0974a1}.sky-grid-row .sky-grid-cell{padding:0;min-width:10px}.sky-grid-heading{position:relative;border-top:1px solid #cdcfd2;border-bottom:1px solid #cdcfd2;border-left:1px solid #cdcfd2;border-right:1px solid #cdcfd2;border-right-width:0px;padding:0;cursor:pointer;background-color:#fff;overflow:visible;background-clip:padding-box;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;user-select:none}.sky-grid-heading:first-child{border-left:1px solid transparent}.sky-grid-heading.sky-grid-header-dragging{background-color:#eeeeef}.sky-grid-heading.sky-grid-column-alignment-left .sky-grid-heading-sort,.sky-grid-heading.sky-grid-column-alignment-center .sky-grid-heading-sort{width:14px}.sky-grid-heading.sky-grid-column-alignment-left .sky-grid-help-inline-sort-hidden,.sky-grid-heading.sky-grid-column-alignment-center .sky-grid-help-inline-sort-hidden{margin-left:-14px;margin-right:14px}.sky-grid-heading.sky-grid-column-alignment-right .sky-grid-header-caret-hidden-spacing{padding-left:14px}.sky-grid-heading.sky-grid-column-alignment-right .sky-grid-heading-sort-visible{width:14px}.sky-grid-heading div{padding:8px}.sky-grid-heading .overflow{text-overflow:ellipsis;white-space:nowrap;position:relative;z-index:1;overflow:hidden;min-width:100%}.sky-grid-heading .sky-grid-column-input-aria-only{-webkit-appearance:none;-moz-appearance:none;height:100%;width:5px;position:absolute;display:block;top:0;bottom:0;right:0}.sky-grid-heading .sky-grid-column-input-aria-only::-moz-range-track{background:transparent}.sky-grid-heading .sky-grid-column-input-aria-only::-moz-range-thumb{-webkit-appearance:none;-moz-appearance:none;width:0;height:0;border-radius:0;border:0 none;background:none;display:none}.sky-grid-heading .sky-grid-column-input-aria-only::-ms-thumb{-webkit-appearance:none;-moz-appearance:none;width:0;height:0;border-radius:0;border:0 none;background:none;display:none}.sky-grid-heading .sky-grid-column-input-aria-only::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;width:0;height:0;border-radius:0;border:0 none;background:none;display:none}.sky-grid-heading .sky-grid-column-input-aria-only:focus{background-color:#00b4f1}.sky-grid-column-alignment-left{text-align:left}.sky-grid-column-alignment-center{text-align:center}.sky-grid-column-alignment-right{text-align:right}.sky-grid-multiselect-cell{padding:0;text-align:center}.sky-grid-multiselect-cell ::ng-deep .sky-switch-control{margin:0 auto}th.sky-grid-multiselect-cell{cursor:default}th.sky-grid-multiselect-cell .screen-reader-only{width:0;height:0;padding:0;opacity:0;position:absolute;margin:-1px;border:0;overflow:hidden;clip:rect(0,0,0,0);outline:none;white-space:nowrap}@-moz-document url-prefix(){.sky-grid-multiselect-row td{border-left:0px solid transparent;border-right:0px solid transparent}}.sky-grid-multiselect-row:hover{background-color:#e9e4f1}.sky-grid-multiselect-row:hover:nth-child(odd){background:#e9e4f1}.sky-grid-multiselect-selected-row{background:#f1eef6;border-top:1px solid #dadbf6;border-bottom:1px solid #dadbf6}.sky-grid-multiselect-selected-row:nth-child(odd){background:#f1eef6}.sky-grid-has-toolbar .sky-grid-heading{border-top-width:0px}.sky-grid-heading-sort.sky-grid-heading-sort-hidden{visibility:hidden}.sky-grid-heading-sort.sky-grid-heading-sort-visible{visibility:visible;padding-left:5px}.sky-grid-resize-handle{position:absolute;right:0;top:0;bottom:0;width:30px;z-index:2;min-height:20px;height:100%!important;vertical-align:middle;cursor:col-resize}.sky-grid-resize-handle:hover:after{background-color:#00b4f1}.sky-grid-resize-handle:after{position:absolute;right:0;top:0;bottom:0;width:5px;height:100%;content:\"\"}#sky-grid-resize-bar{position:absolute;top:0;left:0;z-index:99;height:100%;width:5px;background:#00b4f1;opacity:.6}tr{position:relative}.sky-grid-top-scroll-container{overflow:auto}.sky-grid-top-scroll{height:1px}\n"], dependencies: [{ kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i4.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i2.DragulaDirective, selector: "[dragula]", inputs: ["dragula", "dragulaModel"], outputs: ["dragulaModelChange"] }, { kind: "directive", type: i5.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5.RangeValueAccessor, selector: "input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]" }, { kind: "directive", type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i6.λ3, selector: "sky-checkbox", inputs: ["label", "labelledBy", "id", "disabled", "tabindex", "name", "icon", "checkboxType", "checked", "indeterminate", "required"], outputs: ["change", "checkedChange", "disabledChange", "indeterminateChange"] }, { kind: "component", type: i7.λ3, selector: "sky-help-inline", inputs: ["ariaControls", "ariaExpanded", "ariaLabel"], outputs: ["actionClick"] }, { kind: "component", type: i7.λ4, selector: "sky-icon", inputs: ["icon", "iconType", "size", "fixedWidth", "variant"] }, { kind: "component", type: i8.λ8, selector: "sky-inline-delete", inputs: ["pending"], outputs: ["cancelTriggered", "deleteTriggered"] }, { kind: "directive", type: i9.λ7, selector: "[skyPopover]", inputs: ["skyPopover", "skyPopoverAlignment", "skyPopoverMessageStream", "skyPopoverPlacement", "skyPopoverTrigger"] }, { kind: "directive", type: i7.λ11, selector: "[skyHighlight]", inputs: ["skyHighlight"] }, { kind: "component", type: SkyGridCellComponent, selector: "sky-grid-cell", inputs: ["item", "columnId", "template", "fieldSelector"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i11.SkyLibResourcesPipe, name: "skyLibResources" }], viewProviders: [DragulaService], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1302
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridComponent, decorators: [{
1303
- type: Component,
1304
- args: [{ selector: 'sky-grid', viewProviders: [DragulaService], providers: [SkyGridAdapterService], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"sky-grid\">\n <div\n *ngIf=\"showTopScroll\"\n class=\"sky-grid-top-scroll-container\"\n (scroll)=\"onTopScroll($event)\"\n #topScrollContainer\n >\n <div\n class=\"sky-grid-top-scroll\"\n [style.width.px]=\"getTopScrollWidth()\"\n ></div>\n </div>\n <div\n class=\"sky-grid-table-container\"\n [style.height.px]=\"height\"\n [style.width.px]=\"width\"\n (scroll)=\"onGridScroll($event)\"\n #gridContainer\n >\n <table class=\"sky-grid-table\" [ngClass]=\"getTableClassNames()\" #gridTable>\n <thead>\n <tr [dragula]=\"dragulaGroupName\">\n <th\n *ngIf=\"enableMultiselect\"\n class=\"sky-grid-heading sky-grid-multiselect-cell sky-grid-header-locked\"\n scope=\"col\"\n [style.max-width.px]=\"minColWidth\"\n [style.width.px]=\"minColWidth\"\n >\n <span class=\"screen-reader-only\">\n {{ 'skyux_grid_multiselect_select_row' | skyLibResources }}\n </span>\n </th>\n <th\n *ngFor=\"\n let column of displayedColumns;\n let last = last;\n let i = index\n \"\n class=\"sky-grid-heading sky-field-label\"\n scope=\"col\"\n [attr.sky-cmp-index]=\"i\"\n [attr.sky-cmp-id]=\"column.id || column.field\"\n [attr.aria-sort]=\"getAriaSortDirection(column) | async\"\n [id]=\"'sky-grid-' + gridId + '-column-' + i\"\n [ngClass]=\"'sky-grid-column-alignment-' + column.alignment\"\n [style.max-width.px]=\"column.width\"\n [style.width.px]=\"column.width\"\n [tabIndex]=\"column.isSortable ? 0 : -1\"\n (mouseup)=\"sortByColumn(column)\"\n (keydown)=\"onKeydown($event, column)\"\n (touchmove)=\"onTouchMove($event)\"\n #gridCol\n >\n <div\n class=\"overflow\"\n [ngClass]=\"getTableHeaderClassNames(column)\"\n [style.max-width.px]=\"column.width - 1\"\n [style.width.px]=\"column.width - 1\"\n >\n <span\n *ngIf=\"(getCaretVisibility(column.field) | async) === 'hidden'\"\n class=\"sky-grid-header-caret-hidden-spacing\"\n ></span>\n <!-- The no spacing here is intentional to avoid extra spaces due to these being inline elements -->\n <span class=\"sky-grid-header-text\">{{\n column.heading?.trim()\n }}</span>\n <sky-icon\n class=\"sky-grid-heading-sort\"\n [ngClass]=\"\n 'sky-grid-heading-sort-' +\n (getCaretVisibility(column.field) | async)\n \"\n [icon]=\"getCaretIconNames(column)\"\n >\n </sky-icon>\n <sky-help-inline\n *ngIf=\"column.inlineHelpPopover\"\n [ngClass]=\"{\n 'sky-grid-help-inline-sort-hidden':\n getHelpInlineClass(column.field) | async\n }\"\n [skyPopover]=\"column.inlineHelpPopover\"\n (keydown.enter)=\"$event.stopPropagation()\"\n (keydown.space)=\"$event.stopPropagation()\"\n (mousedown)=\"$event.stopPropagation()\"\n (mouseup)=\"$event.stopPropagation()\"\n >\n </sky-help-inline>\n </div>\n <span\n *ngIf=\"(fit === 'width' && !last) || fit === 'scroll'\"\n aria-hidden=\"true\"\n class=\"sky-grid-resize-handle\"\n tabindex=\"-1\"\n [attr.sky-cmp-index]=\"i\"\n (mousedown)=\"onResizeColumnStart($event)\"\n (touchstart)=\"onResizeColumnStart($event)\"\n >\n </span>\n <input\n aria-label=\"Width of column\"\n class=\"sky-grid-column-input-aria-only\"\n role=\"slider\"\n type=\"range\"\n [attr.aria-controls]=\"'sky-grid-' + gridId + '-column-' + i\"\n [attr.aria-valuemin]=\"minColWidth\"\n [attr.aria-valuemax]=\"maxColWidth\"\n [attr.aria-valuenow]=\"column.width\"\n [attr.sky-cmp-index]=\"i\"\n [min]=\"minColWidth\"\n [max]=\"maxColWidth\"\n [step]=\"columnResizeStep\"\n [(ngModel)]=\"column.width\"\n (blur)=\"onResizeHandleBlur()\"\n (focus)=\"onResizeHandleFocus($event)\"\n (keydown)=\"onKeydownResizeCol($event)\"\n (change)=\"onInputChangeResizeCol($event)\"\n #colSizeRange\n />\n </th>\n </tr>\n </thead>\n <tbody class=\"sky-grid-tbody\">\n <tr\n class=\"sky-grid-row\"\n *ngFor=\"let item of items; let i = index\"\n [attr.aria-current]=\"isRowHighlighted(item.id) ? true : null\"\n [attr.sky-cmp-id]=\"item.id\"\n [ngClass]=\"{\n 'sky-grid-multiselect-selected-row': item.isSelected,\n 'sky-grid-multiselect-row': enableMultiselect,\n 'sky-grid-row-highlight': isRowHighlighted(item.id)\n }\"\n (click)=\"onRowClick($event, item)\"\n >\n <td\n *ngIf=\"enableMultiselect\"\n class=\"sky-grid-multiselect-cell sky-grid-header-locked\"\n >\n <div\n [style.max-width.px]=\"minColWidth\"\n [style.width.px]=\"minColWidth\"\n >\n <sky-checkbox\n [label]=\"'skyux_grid_multiselect_select_row' | skyLibResources\"\n (change)=\"onMultiselectCheckboxChange()\"\n [(ngModel)]=\"item.isSelected\"\n >\n </sky-checkbox>\n </div>\n </td>\n <td\n *ngFor=\"\n let column of displayedColumns;\n let last = last;\n let i = index\n \"\n class=\"sky-grid-cell\"\n [ngClass]=\"'sky-grid-column-alignment-' + column.alignment\"\n [style.max-width.px]=\"column.width\"\n [style.width.px]=\"column.width\"\n >\n <sky-grid-cell\n [skyHighlight]=\"\n !column.excludeFromHighlighting ? highlightText : undefined\n \"\n [template]=\"column.template || defaultCellTemplate\"\n [fieldSelector]=\"column.field\"\n [item]=\"item\"\n [columnId]=\"column.id\"\n [attr.sky-cmp-id]=\"column.id || column.field\"\n >\n </sky-grid-cell>\n </td>\n </tr>\n </tbody>\n </table>\n <div\n *ngIf=\"showResizeBar\"\n aria-hidden=\"true\"\n id=\"sky-grid-resize-bar\"\n tabindex=\"-1\"\n #resizeBar\n ></div>\n </div>\n</div>\n\n<ng-template #defaultCellTemplate let-row=\"row\" let-value=\"value\">{{\n value\n}}</ng-template>\n\n<ng-template let-item #inlineDeleteTemplateRef>\n <div\n [id]=\"'row-delete-ref-' + item.id\"\n [ngStyle]=\"{\n height: getRowHeight(0),\n position: 'fixed',\n width: tableWidth + 'px'\n }\"\n #inlineDeleteRef\n >\n <sky-inline-delete\n [pending]=\"getRowDeleteItem(item.id).pending\"\n (cancelTriggered)=\"cancelRowDelete(item.id)\"\n (deleteTriggered)=\"confirmRowDelete(item.id)\"\n ></sky-inline-delete>\n </div>\n</ng-template>\n", styles: [".sky-grid{position:relative;display:block}.sky-grid-table-container{overflow:auto}.sky-grid-table{position:relative;table-layout:fixed;border-collapse:collapse;margin:0;font-size:15px;min-width:100%}.sky-grid-table.sky-grid-fit{max-width:100%;width:100%}.sky-grid-tbody{background-color:#fff}.sky-grid-row{border-bottom:1px dotted #cdcfd2}.sky-grid-row:nth-child(odd){background-color:#fbfbfb}.sky-grid-row.sky-grid-row-highlight{border-top:1px solid #0974a1;box-shadow:0 0 0 3px inset #0974a1}.sky-grid-row .sky-grid-cell{padding:0;min-width:10px}.sky-grid-heading{position:relative;border-top:1px solid #cdcfd2;border-bottom:1px solid #cdcfd2;border-left:1px solid #cdcfd2;border-right:1px solid #cdcfd2;border-right-width:0px;padding:0;cursor:pointer;background-color:#fff;overflow:visible;background-clip:padding-box;-webkit-user-select:none;-webkit-tap-highlight-color:transparent;user-select:none}.sky-grid-heading:first-child{border-left:1px solid transparent}.sky-grid-heading.sky-grid-header-dragging{background-color:#eeeeef}.sky-grid-heading.sky-grid-column-alignment-left .sky-grid-heading-sort,.sky-grid-heading.sky-grid-column-alignment-center .sky-grid-heading-sort{width:14px}.sky-grid-heading.sky-grid-column-alignment-left .sky-grid-help-inline-sort-hidden,.sky-grid-heading.sky-grid-column-alignment-center .sky-grid-help-inline-sort-hidden{margin-left:-14px;margin-right:14px}.sky-grid-heading.sky-grid-column-alignment-right .sky-grid-header-caret-hidden-spacing{padding-left:14px}.sky-grid-heading.sky-grid-column-alignment-right .sky-grid-heading-sort-visible{width:14px}.sky-grid-heading div{padding:8px}.sky-grid-heading .overflow{text-overflow:ellipsis;white-space:nowrap;position:relative;z-index:1;overflow:hidden;min-width:100%}.sky-grid-heading .sky-grid-column-input-aria-only{-webkit-appearance:none;-moz-appearance:none;height:100%;width:5px;position:absolute;display:block;top:0;bottom:0;right:0}.sky-grid-heading .sky-grid-column-input-aria-only::-moz-range-track{background:transparent}.sky-grid-heading .sky-grid-column-input-aria-only::-moz-range-thumb{-webkit-appearance:none;-moz-appearance:none;width:0;height:0;border-radius:0;border:0 none;background:none;display:none}.sky-grid-heading .sky-grid-column-input-aria-only::-ms-thumb{-webkit-appearance:none;-moz-appearance:none;width:0;height:0;border-radius:0;border:0 none;background:none;display:none}.sky-grid-heading .sky-grid-column-input-aria-only::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;width:0;height:0;border-radius:0;border:0 none;background:none;display:none}.sky-grid-heading .sky-grid-column-input-aria-only:focus{background-color:#00b4f1}.sky-grid-column-alignment-left{text-align:left}.sky-grid-column-alignment-center{text-align:center}.sky-grid-column-alignment-right{text-align:right}.sky-grid-multiselect-cell{padding:0;text-align:center}.sky-grid-multiselect-cell ::ng-deep .sky-switch-control{margin:0 auto}th.sky-grid-multiselect-cell{cursor:default}th.sky-grid-multiselect-cell .screen-reader-only{width:0;height:0;padding:0;opacity:0;position:absolute;margin:-1px;border:0;overflow:hidden;clip:rect(0,0,0,0);outline:none;white-space:nowrap}@-moz-document url-prefix(){.sky-grid-multiselect-row td{border-left:0px solid transparent;border-right:0px solid transparent}}.sky-grid-multiselect-row:hover{background-color:#e9e4f1}.sky-grid-multiselect-row:hover:nth-child(odd){background:#e9e4f1}.sky-grid-multiselect-selected-row{background:#f1eef6;border-top:1px solid #dadbf6;border-bottom:1px solid #dadbf6}.sky-grid-multiselect-selected-row:nth-child(odd){background:#f1eef6}.sky-grid-has-toolbar .sky-grid-heading{border-top-width:0px}.sky-grid-heading-sort.sky-grid-heading-sort-hidden{visibility:hidden}.sky-grid-heading-sort.sky-grid-heading-sort-visible{visibility:visible;padding-left:5px}.sky-grid-resize-handle{position:absolute;right:0;top:0;bottom:0;width:30px;z-index:2;min-height:20px;height:100%!important;vertical-align:middle;cursor:col-resize}.sky-grid-resize-handle:hover:after{background-color:#00b4f1}.sky-grid-resize-handle:after{position:absolute;right:0;top:0;bottom:0;width:5px;height:100%;content:\"\"}#sky-grid-resize-bar{position:absolute;top:0;left:0;z-index:99;height:100%;width:5px;background:#00b4f1;opacity:.6}tr{position:relative}.sky-grid-top-scroll-container{overflow:auto}.sky-grid-top-scroll{height:1px}\n"] }]
1305
- }], ctorParameters: function () { return [{ type: i1.SkyAffixService }, { type: i0.ChangeDetectorRef }, { type: i2.DragulaService }, { type: SkyGridAdapterService }, { type: i1.SkyOverlayService }, { type: i1.SkyAppWindowRef }, { type: i1.SkyUIConfigService }, { type: i1.SkyLogService }]; }, propDecorators: { columns: [{
1306
- type: Input
1307
- }], data: [{
1308
- type: Input
1309
- }], enableMultiselect: [{
1310
- type: Input
1311
- }], fit: [{
1312
- type: Input
1313
- }], hasToolbar: [{
1314
- type: Input
1315
- }], height: [{
1316
- type: Input
1317
- }], highlightText: [{
1318
- type: Input
1319
- }], messageStream: [{
1320
- type: Input
1321
- }], multiselectRowId: [{
1322
- type: Input
1323
- }], rowHighlightedId: [{
1324
- type: Input
1325
- }], selectedColumnIds: [{
1326
- type: Input
1327
- }], selectedRowIds: [{
1328
- type: Input
1329
- }], settingsKey: [{
1330
- type: Input
1331
- }], sortField: [{
1332
- type: Input
1333
- }], width: [{
1334
- type: Input
1335
- }], columnWidthChange: [{
1336
- type: Output
1337
- }], multiselectSelectionChange: [{
1338
- type: Output
1339
- }], rowDeleteCancel: [{
1340
- type: Output
1341
- }], rowDeleteConfirm: [{
1342
- type: Output
1343
- }], selectedColumnIdsChange: [{
1344
- type: Output
1345
- }], sortFieldChange: [{
1346
- type: Output
1347
- }], columnComponents: [{
1348
- type: ContentChildren,
1349
- args: [SkyGridColumnComponent]
1350
- }], columnElementRefs: [{
1351
- type: ViewChildren,
1352
- args: ['gridCol']
1353
- }], columnRangeInputElementRefs: [{
1354
- type: ViewChildren,
1355
- args: ['colSizeRange']
1356
- }], inlineDeleteRefs: [{
1357
- type: ViewChildren,
1358
- args: ['inlineDeleteRef']
1359
- }], inlineDeleteTemplateRef: [{
1360
- type: ViewChild,
1361
- args: ['inlineDeleteTemplateRef', { read: TemplateRef }]
1362
- }], tableContainerElementRef: [{
1363
- type: ViewChild,
1364
- args: ['gridContainer']
1365
- }], tableElementRef: [{
1366
- type: ViewChild,
1367
- args: ['gridTable']
1368
- }], topScrollContainerElementRef: [{
1369
- type: ViewChild,
1370
- args: ['topScrollContainer']
1371
- }], resizeBar: [{
1372
- type: ViewChild,
1373
- args: ['resizeBar']
1374
- }], onWindowResize: [{
1375
- type: HostListener,
1376
- args: ['window:resize']
1377
- }] } });
1378
-
1379
- /**
1380
- * @deprecated `SkyGridComponent` and its features are deprecated. We recommend using the data grid instead. For more information, see https://developer.blackbaud.com/skyux/components/data-grid
1381
- */
1382
- class SkyGridModule {
1383
- }
1384
- SkyGridModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1385
- SkyGridModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SkyGridModule, declarations: [SkyGridComponent,
1386
- SkyGridColumnComponent,
1387
- SkyGridCellComponent], imports: [CommonModule,
1388
- DragulaModule,
1389
- FormsModule,
1390
- SkyAffixModule,
1391
- SkyCheckboxModule,
1392
- SkyGridsResourcesModule,
1393
- SkyHelpInlineModule,
1394
- SkyIconModule,
1395
- SkyInlineDeleteModule,
1396
- SkyOverlayModule,
1397
- SkyPopoverModule,
1398
- SkyTextHighlightModule], exports: [SkyGridComponent, SkyGridColumnComponent] });
1399
- SkyGridModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridModule, imports: [CommonModule,
1400
- DragulaModule,
1401
- FormsModule,
1402
- SkyAffixModule,
1403
- SkyCheckboxModule,
1404
- SkyGridsResourcesModule,
1405
- SkyHelpInlineModule,
1406
- SkyIconModule,
1407
- SkyInlineDeleteModule,
1408
- SkyOverlayModule,
1409
- SkyPopoverModule,
1410
- SkyTextHighlightModule] });
1411
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SkyGridModule, decorators: [{
1412
- type: NgModule,
1413
- args: [{
1414
- declarations: [
1415
- SkyGridComponent,
1416
- SkyGridColumnComponent,
1417
- SkyGridCellComponent,
1418
- ],
1419
- imports: [
1420
- CommonModule,
1421
- DragulaModule,
1422
- FormsModule,
1423
- SkyAffixModule,
1424
- SkyCheckboxModule,
1425
- SkyGridsResourcesModule,
1426
- SkyHelpInlineModule,
1427
- SkyIconModule,
1428
- SkyInlineDeleteModule,
1429
- SkyOverlayModule,
1430
- SkyPopoverModule,
1431
- SkyTextHighlightModule,
1432
- ],
1433
- exports: [SkyGridComponent, SkyGridColumnComponent],
1434
- }]
1435
- }] });
1436
-
1437
- /**
1438
- * Generated bundle index. Do not edit.
1439
- */
1440
-
1441
- export { SkyGridColumnComponent, SkyGridColumnModel, SkyGridComponent, SkyGridMessageType, SkyGridModule, SkyGridSelectedRowsSource };
1442
- //# sourceMappingURL=skyux-grids.mjs.map