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