igniteui-grid-lite 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/components/cell.d.ts +1 -1
- package/components/cell.js +2 -3
- package/components/cell.js.map +1 -1
- package/components/column.d.ts +39 -0
- package/components/column.js +77 -0
- package/components/column.js.map +1 -0
- package/components/filter-row.d.ts +1 -1
- package/components/filter-row.js +45 -33
- package/components/filter-row.js.map +1 -1
- package/components/grid.d.ts +34 -34
- package/components/grid.js +143 -104
- package/components/grid.js.map +1 -1
- package/components/header-row.d.ts +5 -8
- package/components/header-row.js +18 -28
- package/components/header-row.js.map +1 -1
- package/components/header.d.ts +1 -1
- package/components/header.js +7 -11
- package/components/header.js.map +1 -1
- package/components/row.d.ts +3 -5
- package/components/row.js +6 -12
- package/components/row.js.map +1 -1
- package/components/virtualizer.d.ts +0 -1
- package/components/virtualizer.js +0 -5
- package/components/virtualizer.js.map +1 -1
- package/controllers/data-operation.d.ts +4 -1
- package/controllers/data-operation.js +5 -1
- package/controllers/data-operation.js.map +1 -1
- package/controllers/dom.d.ts +9 -10
- package/controllers/dom.js +20 -34
- package/controllers/dom.js.map +1 -1
- package/controllers/filter.d.ts +7 -4
- package/controllers/filter.js +8 -5
- package/controllers/filter.js.map +1 -1
- package/controllers/navigation.d.ts +8 -8
- package/controllers/navigation.js +28 -28
- package/controllers/navigation.js.map +1 -1
- package/controllers/sort.d.ts +4 -4
- package/controllers/sort.js +2 -2
- package/controllers/sort.js.map +1 -1
- package/controllers/state.d.ts +32 -15
- package/controllers/state.js +54 -17
- package/controllers/state.js.map +1 -1
- package/custom-elements.json +924 -190
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +3 -3
- package/docs/classes/IgcGridLite.html +15 -17
- package/docs/classes/IgcGridLiteColumn.html +38 -0
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +6 -6
- package/docs/interfaces/BaseColumnConfiguration.html +2 -2
- package/docs/interfaces/BaseColumnSortConfiguration.html +1 -1
- package/docs/interfaces/BaseFilterExpression.html +1 -1
- package/docs/interfaces/BaseIgcCellContext.html +1 -1
- package/docs/interfaces/{BaseSortExpression.html → BaseSortingExpression.html} +2 -2
- package/docs/interfaces/ColumnFilterConfiguration.html +1 -1
- package/docs/interfaces/DataPipelineConfiguration.html +1 -1
- package/docs/interfaces/GridLiteSortingOptions.html +4 -0
- package/docs/interfaces/IgcFilteredEvent.html +1 -1
- package/docs/interfaces/IgcFilteringEvent.html +1 -1
- package/docs/interfaces/IgcGridLiteEventMap.html +4 -4
- package/docs/interfaces/IgcHeaderContext.html +1 -1
- package/docs/modules.html +1 -1
- package/docs/types/BasePropertyType.html +1 -1
- package/docs/types/BaseSortComparer.html +1 -1
- package/docs/types/ColumnConfiguration.html +1 -1
- package/docs/types/ColumnSortConfiguration.html +1 -1
- package/docs/types/DataPipelineHook.html +1 -1
- package/docs/types/DataPipelineParams.html +1 -1
- package/docs/types/DataType.html +1 -1
- package/docs/types/FilterCriteria.html +1 -1
- package/docs/types/FilterExpression.html +1 -1
- package/docs/types/IgcCellContext.html +1 -1
- package/docs/types/Keys.html +1 -1
- package/docs/types/PropertyType.html +1 -1
- package/docs/types/SortComparer.html +1 -1
- package/docs/types/SortState.html +1 -1
- package/docs/types/SortingDirection.html +1 -1
- package/docs/types/SortingExpression.html +2 -0
- package/index.d.ts +3 -2
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/internal/constants.js +5 -1
- package/internal/constants.js.map +1 -1
- package/internal/context.d.ts +9 -0
- package/internal/context.js +7 -0
- package/internal/context.js.map +1 -0
- package/internal/element-from-event-path.d.ts +2 -0
- package/internal/element-from-event-path.js +12 -0
- package/internal/element-from-event-path.js.map +1 -0
- package/internal/part-map.d.ts +16 -3
- package/internal/part-map.js +44 -4
- package/internal/part-map.js.map +1 -1
- package/internal/tags.d.ts +1 -0
- package/internal/tags.js +1 -0
- package/internal/tags.js.map +1 -1
- package/internal/types.d.ts +3 -7
- package/internal/types.js.map +1 -1
- package/internal/utils.d.ts +6 -2
- package/internal/utils.js +43 -14
- package/internal/utils.js.map +1 -1
- package/operations/sort/types.d.ts +4 -4
- package/operations/sort/types.js.map +1 -1
- package/operations/sort.d.ts +2 -2
- package/operations/sort.js.map +1 -1
- package/package.json +1 -1
- package/styles/themes/dark/grid.bootstrap.css.js +1 -1
- package/styles/themes/dark/grid.bootstrap.css.js.map +1 -1
- package/styles/themes/dark/grid.fluent.css.js +1 -1
- package/styles/themes/dark/grid.fluent.css.js.map +1 -1
- package/styles/themes/dark/grid.indigo.css.js +1 -1
- package/styles/themes/dark/grid.indigo.css.js.map +1 -1
- package/styles/themes/dark/grid.material.css.js +1 -1
- package/styles/themes/dark/grid.material.css.js.map +1 -1
- package/styles/themes/grid.base.css.js +1 -1
- package/styles/themes/grid.base.css.js.map +1 -1
- package/styles/themes/light/grid.fluent.css.js +1 -1
- package/styles/themes/light/grid.fluent.css.js.map +1 -1
- package/styles/themes/light/grid.indigo.css.js +1 -1
- package/styles/themes/light/grid.indigo.css.js.map +1 -1
- package/styles/themes/light/grid.shared.css.js +1 -1
- package/styles/themes/light/grid.shared.css.js.map +1 -1
- package/docs/interfaces/GridSortConfiguration.html +0 -6
- package/docs/types/SortExpression.html +0 -2
package/components/grid.js
CHANGED
|
@@ -7,22 +7,26 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { ContextProvider } from '@lit/context';
|
|
8
8
|
import { IgcButtonComponent, IgcChipComponent, IgcDropdownComponent, IgcInputComponent, } from 'igniteui-webcomponents';
|
|
9
9
|
import { html, nothing } from 'lit';
|
|
10
|
-
import { eventOptions, property,
|
|
10
|
+
import { eventOptions, property, state } from 'lit/decorators.js';
|
|
11
|
+
import { cache } from 'lit/directives/cache.js';
|
|
11
12
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { createDataOperationsController } from '../controllers/data-operation.js';
|
|
14
|
+
import { createDomController } from '../controllers/dom.js';
|
|
15
|
+
import { createStateController } from '../controllers/state.js';
|
|
16
|
+
import { PIPELINE } from '../internal/constants.js';
|
|
17
|
+
import { COLUMN_UPDATE_CONTEXT, GRID_STATE_CONTEXT } from '../internal/context.js';
|
|
18
|
+
import { getElementFromEventPath } from '../internal/element-from-event-path.js';
|
|
16
19
|
import { EventEmitterBase } from '../internal/mixins/event-emitter.js';
|
|
17
20
|
import { registerComponent } from '../internal/register.js';
|
|
18
21
|
import { GRID_TAG } from '../internal/tags.js';
|
|
19
22
|
import { addThemingController } from '../internal/theming.js';
|
|
20
|
-
import { asArray,
|
|
23
|
+
import { asArray, getFilterOperandsFor, isNumber, isString } from '../internal/utils.js';
|
|
21
24
|
import { watch } from '../internal/watch.js';
|
|
22
25
|
import { styles } from '../styles/themes/grid.base.css.js';
|
|
23
26
|
import { all } from '../styles/themes/grid-themes.js';
|
|
24
27
|
import { styles as shared } from '../styles/themes/shared/grid.common.css.js';
|
|
25
28
|
import IgcGridLiteCell from './cell.js';
|
|
29
|
+
import { IgcGridLiteColumn } from './column.js';
|
|
26
30
|
import IgcFilterRow from './filter-row.js';
|
|
27
31
|
import IgcGridLiteHeaderRow from './header-row.js';
|
|
28
32
|
import IgcGridLiteRow from './row.js';
|
|
@@ -33,168 +37,206 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
33
37
|
}
|
|
34
38
|
static { this.styles = [styles, shared]; }
|
|
35
39
|
static register() {
|
|
36
|
-
registerComponent(IgcGridLite, IgcVirtualizer, IgcGridLiteRow, IgcGridLiteHeaderRow, IgcFilterRow, IgcButtonComponent, IgcChipComponent, IgcInputComponent, IgcDropdownComponent);
|
|
40
|
+
registerComponent(IgcGridLite, IgcGridLiteColumn, IgcVirtualizer, IgcGridLiteRow, IgcGridLiteHeaderRow, IgcFilterRow, IgcButtonComponent, IgcChipComponent, IgcInputComponent, IgcDropdownComponent);
|
|
37
41
|
}
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
_updateObservers() {
|
|
43
|
+
this._stateProvider.updateObservers();
|
|
44
|
+
}
|
|
45
|
+
_updateConfiguration(config) {
|
|
46
|
+
this._stateController.updateColumnsConfiguration(asArray(config));
|
|
47
|
+
}
|
|
48
|
+
set sortingExpressions(expressions) {
|
|
49
|
+
if (this.hasUpdated && expressions.length) {
|
|
40
50
|
this.sort(expressions);
|
|
41
51
|
}
|
|
52
|
+
else {
|
|
53
|
+
this._initialSortExpressions = expressions;
|
|
54
|
+
}
|
|
42
55
|
}
|
|
43
|
-
get
|
|
44
|
-
return Array.from(this.
|
|
56
|
+
get sortingExpressions() {
|
|
57
|
+
return Array.from(this._stateController.sorting.state.values());
|
|
45
58
|
}
|
|
46
59
|
set filterExpressions(expressions) {
|
|
47
|
-
if (expressions.length) {
|
|
60
|
+
if (this.hasUpdated && expressions.length) {
|
|
48
61
|
this.filter(expressions);
|
|
49
62
|
}
|
|
63
|
+
else {
|
|
64
|
+
this._initialFilterExpressions = expressions;
|
|
65
|
+
}
|
|
50
66
|
}
|
|
51
67
|
get filterExpressions() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
return expressions;
|
|
68
|
+
return this._stateController.filtering.state.values.flatMap((each) => each.all);
|
|
69
|
+
}
|
|
70
|
+
get columns() {
|
|
71
|
+
return this._stateController.columns.map((col) => ({ ...col }));
|
|
57
72
|
}
|
|
58
73
|
get rows() {
|
|
59
|
-
return
|
|
74
|
+
return this._stateController.rows;
|
|
60
75
|
}
|
|
61
76
|
get dataView() {
|
|
62
|
-
return this.
|
|
77
|
+
return this._dataState;
|
|
63
78
|
}
|
|
64
79
|
get totalItems() {
|
|
65
|
-
return this.
|
|
66
|
-
}
|
|
67
|
-
watchColumns(_, newConfig = []) {
|
|
68
|
-
this.columns = newConfig.map((config) => ({ ...DEFAULT_COLUMN_CONFIG, ...config }));
|
|
80
|
+
return this._dataState.length;
|
|
69
81
|
}
|
|
70
82
|
dataChanged() {
|
|
71
|
-
this.
|
|
72
|
-
autoGenerateColumns(this);
|
|
83
|
+
this._dataState = [...this.data];
|
|
73
84
|
if (this.hasUpdated) {
|
|
85
|
+
if (!this._hasAssignedColumns()) {
|
|
86
|
+
this._stateController.setAutoColumnConfiguration();
|
|
87
|
+
}
|
|
74
88
|
this.pipeline();
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
91
|
async pipeline() {
|
|
78
|
-
this.
|
|
92
|
+
this._dataState = await this._dataController.apply([...this.data], this._stateController);
|
|
79
93
|
}
|
|
80
94
|
constructor() {
|
|
81
95
|
super();
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
86
|
-
context:
|
|
87
|
-
initialValue: this.
|
|
96
|
+
this._stateController = createStateController(this, this._updateObservers);
|
|
97
|
+
this._domController = createDomController(this, this._stateController);
|
|
98
|
+
this._dataController = createDataOperationsController(this);
|
|
99
|
+
this._stateProvider = new ContextProvider(this, {
|
|
100
|
+
context: GRID_STATE_CONTEXT,
|
|
101
|
+
initialValue: this._stateController,
|
|
88
102
|
});
|
|
89
|
-
this.
|
|
90
|
-
|
|
103
|
+
this._columnUpdateProvider = new ContextProvider(this, {
|
|
104
|
+
context: COLUMN_UPDATE_CONTEXT,
|
|
105
|
+
initialValue: ((config) => {
|
|
106
|
+
this._updateConfiguration(config);
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
this._initialSortExpressions = [];
|
|
110
|
+
this._initialFilterExpressions = [];
|
|
111
|
+
this._dataState = [];
|
|
91
112
|
this.data = [];
|
|
92
113
|
this.autoGenerate = false;
|
|
93
|
-
this.
|
|
94
|
-
|
|
95
|
-
|
|
114
|
+
this.sortingOptions = {
|
|
115
|
+
mode: 'multiple',
|
|
116
|
+
};
|
|
117
|
+
this._renderRow = (item, index) => {
|
|
118
|
+
const styles = {
|
|
119
|
+
...this._domController.columnSizes,
|
|
120
|
+
...this._domController.getActiveRowStyles(index),
|
|
121
|
+
};
|
|
122
|
+
const activeNode = this._stateController.active;
|
|
123
|
+
return html `
|
|
124
|
+
<igc-grid-lite-row
|
|
125
|
+
part="row"
|
|
126
|
+
exportparts="cell"
|
|
127
|
+
style=${styleMap(styles)}
|
|
128
|
+
.index=${index}
|
|
129
|
+
.activeNode=${activeNode}
|
|
130
|
+
.data=${item}
|
|
131
|
+
.columns=${this._stateController.columns}
|
|
132
|
+
></igc-grid-lite-row>
|
|
133
|
+
`;
|
|
96
134
|
};
|
|
97
135
|
addThemingController(this, all);
|
|
98
136
|
}
|
|
137
|
+
createRenderRoot() {
|
|
138
|
+
const root = super.createRenderRoot();
|
|
139
|
+
root.addEventListener('slotchange', this._handleSlotChange.bind(this));
|
|
140
|
+
return root;
|
|
141
|
+
}
|
|
142
|
+
firstUpdated() {
|
|
143
|
+
this.updateComplete.then(() => {
|
|
144
|
+
if (this.autoGenerate && !this._hasAssignedColumns()) {
|
|
145
|
+
this._stateController.setAutoColumnConfiguration();
|
|
146
|
+
}
|
|
147
|
+
if (this._initialFilterExpressions.length) {
|
|
148
|
+
this.filter(this._initialFilterExpressions);
|
|
149
|
+
}
|
|
150
|
+
if (this._initialSortExpressions.length) {
|
|
151
|
+
this.sort(this._initialSortExpressions);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
_hasAssignedColumns() {
|
|
156
|
+
const slot = this.renderRoot.querySelector('slot');
|
|
157
|
+
const assignedNodes = slot
|
|
158
|
+
.assignedElements({ flatten: true })
|
|
159
|
+
.filter((element) => element.matches(IgcGridLiteColumn.tagName));
|
|
160
|
+
return assignedNodes.length > 0;
|
|
161
|
+
}
|
|
162
|
+
_handleSlotChange(event) {
|
|
163
|
+
const slot = event.target;
|
|
164
|
+
const assignedNodes = slot
|
|
165
|
+
.assignedElements({ flatten: true })
|
|
166
|
+
.filter((element) => element.matches(IgcGridLiteColumn.tagName));
|
|
167
|
+
this._stateController.setColumnConfiguration(assignedNodes);
|
|
168
|
+
}
|
|
99
169
|
filter(config) {
|
|
100
|
-
this.
|
|
101
|
-
?
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})
|
|
170
|
+
this._stateController.filtering.filter(asArray(config).map((each) => isString(each.condition)
|
|
171
|
+
? Object.assign(each, {
|
|
172
|
+
condition: getFilterOperandsFor(this.getColumn(each.key))[each.condition],
|
|
173
|
+
})
|
|
105
174
|
: each));
|
|
106
175
|
}
|
|
107
176
|
sort(expressions) {
|
|
108
|
-
this.
|
|
177
|
+
this._stateController.sorting.sort(expressions);
|
|
109
178
|
}
|
|
110
179
|
clearSort(key) {
|
|
111
|
-
this.
|
|
180
|
+
this._stateController.sorting.reset(key);
|
|
112
181
|
this.requestUpdate(PIPELINE);
|
|
113
182
|
}
|
|
114
183
|
clearFilter(key) {
|
|
115
|
-
this.
|
|
184
|
+
this._stateController.filtering.reset(key);
|
|
116
185
|
this.requestUpdate(PIPELINE);
|
|
117
186
|
}
|
|
118
187
|
getColumn(id) {
|
|
119
|
-
return
|
|
120
|
-
? this.columns.at(id)
|
|
121
|
-
: this.columns.find(({ key }) => key === id);
|
|
188
|
+
return this._stateController.columns.find((column, index) => isNumber(id) ? index === id : column.key === id);
|
|
122
189
|
}
|
|
123
190
|
updateColumns(columns) {
|
|
124
|
-
|
|
125
|
-
const instance = this.columns.find((curr) => curr.key === column.key);
|
|
126
|
-
if (instance) {
|
|
127
|
-
Object.assign(instance, column);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
this.requestUpdate(PIPELINE);
|
|
191
|
+
this._stateController.updateColumnsConfiguration(asArray(columns));
|
|
131
192
|
}
|
|
132
|
-
|
|
133
|
-
const target = event
|
|
134
|
-
.composedPath()
|
|
135
|
-
.find((el) => el instanceof IgcGridLiteCell);
|
|
193
|
+
_bodyClickHandler(event) {
|
|
194
|
+
const target = getElementFromEventPath(IgcGridLiteCell.tagName, event);
|
|
136
195
|
if (target) {
|
|
137
|
-
this.
|
|
138
|
-
column: target.column.key,
|
|
139
|
-
row: target.row.index,
|
|
140
|
-
};
|
|
196
|
+
this._stateController.active = { column: target.column.key, row: target.row.index };
|
|
141
197
|
}
|
|
142
198
|
}
|
|
143
|
-
|
|
144
|
-
if (this.
|
|
145
|
-
this.
|
|
199
|
+
_bodyKeydownHandler(event) {
|
|
200
|
+
if (event.target === this._stateController.virtualizer) {
|
|
201
|
+
this._stateController.navigation.navigate(event);
|
|
146
202
|
}
|
|
147
203
|
}
|
|
148
|
-
|
|
204
|
+
_renderHeaderRow() {
|
|
149
205
|
return html `
|
|
150
206
|
<igc-grid-lite-header-row
|
|
151
|
-
|
|
152
|
-
|
|
207
|
+
tabindex="0"
|
|
208
|
+
style=${styleMap(this._domController.columnSizes)}
|
|
209
|
+
.columns=${this._stateController.columns}
|
|
153
210
|
></igc-grid-lite-header-row>
|
|
154
211
|
`;
|
|
155
212
|
}
|
|
156
|
-
|
|
213
|
+
_renderBody() {
|
|
157
214
|
return html `
|
|
158
215
|
<igc-virtualizer
|
|
159
|
-
|
|
160
|
-
.
|
|
161
|
-
|
|
162
|
-
@
|
|
216
|
+
tabindex="0"
|
|
217
|
+
.items=${this._dataState}
|
|
218
|
+
.renderItem=${this._renderRow}
|
|
219
|
+
@click=${this._bodyClickHandler}
|
|
220
|
+
@keydown=${this._bodyKeydownHandler}
|
|
163
221
|
></igc-virtualizer>
|
|
164
222
|
`;
|
|
165
223
|
}
|
|
166
|
-
|
|
167
|
-
return this.columns.some((column) => column.filter)
|
|
168
|
-
? html `<igc-filter-row style=${styleMap(this.
|
|
169
|
-
: nothing
|
|
224
|
+
_renderFilterRow() {
|
|
225
|
+
return html `${cache(this._stateController.columns.some((column) => column.filter)
|
|
226
|
+
? html `<igc-filter-row style=${styleMap(this._domController.columnSizes)}></igc-filter-row>`
|
|
227
|
+
: nothing)}`;
|
|
170
228
|
}
|
|
171
229
|
render() {
|
|
172
230
|
return html `
|
|
173
|
-
|
|
174
|
-
${this.
|
|
175
|
-
${this.
|
|
176
|
-
${this.renderBody()}
|
|
231
|
+
<slot part="column-sink"></slot>
|
|
232
|
+
${this._stateController.resizing.renderIndicator()} ${this._renderHeaderRow()}
|
|
233
|
+
${this._renderFilterRow()} ${this._renderBody()}
|
|
177
234
|
`;
|
|
178
235
|
}
|
|
179
236
|
}
|
|
180
|
-
__decorate([
|
|
181
|
-
query(IgcVirtualizer.tagName)
|
|
182
|
-
], IgcGridLite.prototype, "scrollContainer", void 0);
|
|
183
|
-
__decorate([
|
|
184
|
-
query(IgcGridLiteHeaderRow.tagName)
|
|
185
|
-
], IgcGridLite.prototype, "headerRow", void 0);
|
|
186
|
-
__decorate([
|
|
187
|
-
query(IgcFilterRow.tagName)
|
|
188
|
-
], IgcGridLite.prototype, "filterRow", void 0);
|
|
189
237
|
__decorate([
|
|
190
238
|
state()
|
|
191
|
-
], IgcGridLite.prototype, "
|
|
192
|
-
__decorate([
|
|
193
|
-
queryAll(IgcGridLiteRow.tagName)
|
|
194
|
-
], IgcGridLite.prototype, "_rows", void 0);
|
|
195
|
-
__decorate([
|
|
196
|
-
property({ attribute: false })
|
|
197
|
-
], IgcGridLite.prototype, "columns", void 0);
|
|
239
|
+
], IgcGridLite.prototype, "_dataState", void 0);
|
|
198
240
|
__decorate([
|
|
199
241
|
property({ attribute: false })
|
|
200
242
|
], IgcGridLite.prototype, "data", void 0);
|
|
@@ -203,19 +245,16 @@ __decorate([
|
|
|
203
245
|
], IgcGridLite.prototype, "autoGenerate", void 0);
|
|
204
246
|
__decorate([
|
|
205
247
|
property({ attribute: false })
|
|
206
|
-
], IgcGridLite.prototype, "
|
|
248
|
+
], IgcGridLite.prototype, "sortingOptions", void 0);
|
|
207
249
|
__decorate([
|
|
208
250
|
property({ attribute: false })
|
|
209
251
|
], IgcGridLite.prototype, "dataPipelineConfiguration", void 0);
|
|
210
252
|
__decorate([
|
|
211
253
|
property({ attribute: false })
|
|
212
|
-
], IgcGridLite.prototype, "
|
|
254
|
+
], IgcGridLite.prototype, "sortingExpressions", null);
|
|
213
255
|
__decorate([
|
|
214
256
|
property({ attribute: false })
|
|
215
257
|
], IgcGridLite.prototype, "filterExpressions", null);
|
|
216
|
-
__decorate([
|
|
217
|
-
watch('columns')
|
|
218
|
-
], IgcGridLite.prototype, "watchColumns", null);
|
|
219
258
|
__decorate([
|
|
220
259
|
watch('data')
|
|
221
260
|
], IgcGridLite.prototype, "dataChanged", null);
|
|
@@ -224,5 +263,5 @@ __decorate([
|
|
|
224
263
|
], IgcGridLite.prototype, "pipeline", null);
|
|
225
264
|
__decorate([
|
|
226
265
|
eventOptions({ capture: true })
|
|
227
|
-
], IgcGridLite.prototype, "
|
|
266
|
+
], IgcGridLite.prototype, "_bodyClickHandler", null);
|
|
228
267
|
//# sourceMappingURL=grid.js.map
|
package/components/grid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/components/grid.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,QA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,CAAC;IACJ,CAAC;;AA/QS;IADT,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;oDACa;AAGjC;IADT,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC;8CACU;AAGpC;IADT,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC;8CACU;AAG5B;IADT,KAAK,EAAE;8CAC2B;AAGzB;IADT,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC;0CACe;AAIzC;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CACoB;AAI5C;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;yCACJ;AA2BpB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;iDAC5B;AAIrB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;sDAI7B;AAMK;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8DACiC;AAehE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;kDAG9B;AAeD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDAS9B;AA6BS;IADT,KAAK,CAAC,SAAS,CAAC;+CAGhB;AAGS;IADT,KAAK,CAAC,MAAM,CAAC;8CAQb;AAGe;IADf,KAAK,CAAC,QAAQ,CAAC;2CAMf;AAuES;IADT,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAW/B","sourcesContent":["import { ContextProvider } from '@lit/context';\nimport {\n IgcButtonComponent,\n IgcChipComponent,\n IgcDropdownComponent,\n IgcInputComponent,\n} from 'igniteui-webcomponents';\nimport { html, nothing } from 'lit';\nimport { eventOptions, property, query, queryAll, state } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { DataOperationsController } from '../controllers/data-operation.js';\nimport { GridDOMController } from '../controllers/dom.js';\nimport { gridStateContext, StateController } from '../controllers/state.js';\nimport { DEFAULT_COLUMN_CONFIG, PIPELINE } from '../internal/constants.js';\nimport { EventEmitterBase } from '../internal/mixins/event-emitter.js';\nimport { registerComponent } from '../internal/register.js';\nimport { GRID_TAG } from '../internal/tags.js';\nimport { addThemingController } from '../internal/theming.js';\nimport type {\n ColumnConfiguration,\n DataPipelineConfiguration,\n GridSortConfiguration,\n Keys,\n} from '../internal/types.js';\nimport { asArray, autoGenerateColumns, getFilterOperandsFor } from '../internal/utils.js';\nimport { watch } from '../internal/watch.js';\nimport type { FilterExpression } from '../operations/filter/types.js';\nimport type { SortExpression } from '../operations/sort/types.js';\nimport { styles } from '../styles/themes/grid.base.css.js';\nimport { all } from '../styles/themes/grid-themes.js';\nimport { styles as shared } from '../styles/themes/shared/grid.common.css.js';\nimport IgcGridLiteCell from './cell.js';\nimport IgcFilterRow from './filter-row.js';\nimport IgcGridLiteHeaderRow from './header-row.js';\nimport IgcGridLiteRow from './row.js';\nimport IgcVirtualizer from './virtualizer.js';\n\n/**\n * Event object for the filtering event of the grid.\n */\nexport interface IgcFilteringEvent<T extends object> {\n /**\n * The target column for the filter operation.\n */\n key: Keys<T>;\n\n /**\n * The filter expression(s) to apply.\n */\n expressions: FilterExpression<T>[];\n\n /**\n * The type of modification which will be applied to the filter\n * state of the column.\n *\n * @remarks\n * `add` - a new filter expression will be added to the state of the column.\n * `modify` - an existing filter expression will be modified.\n * `remove` - the expression(s) will be removed from the state of the column.\n */\n type: 'add' | 'modify' | 'remove';\n}\n\n/**\n * Event object for the filtered event of the grid.\n */\nexport interface IgcFilteredEvent<T extends object> {\n /**\n * The target column for the filter operation.\n */\n key: Keys<T>;\n\n /**\n * The filter state of the column after the operation.\n */\n state: FilterExpression<T>[];\n}\n\n/**\n * Events for the igc-grid-lite.\n */\nexport interface IgcGridLiteEventMap<T extends object> {\n /**\n * Emitted when sorting is initiated through the UI.\n * Returns the sort expression which will be used for the operation.\n *\n * @remarks\n * The event is cancellable which prevents the operation from being applied.\n * The expression can be modified prior to the operation running.\n *\n * @event\n */\n sorting: CustomEvent<SortExpression<T>>;\n /**\n * Emitted when a sort operation initiated through the UI has completed.\n * Returns the sort expression used for the operation.\n *\n * @event\n */\n sorted: CustomEvent<SortExpression<T>>;\n /**\n * Emitted when filtering is initiated through the UI.\n *\n * @remarks\n * The event is cancellable which prevents the operation from being applied.\n * The expression can be modified prior to the operation running.\n *\n * @event\n */\n filtering: CustomEvent<IgcFilteringEvent<T>>;\n /**\n * Emitted when a filter operation initiated through the UI has completed.\n * Returns the filter state for the affected column.\n *\n * @event\n */\n filtered: CustomEvent<IgcFilteredEvent<T>>;\n}\n\n/**\n * IgcGridLite is a web component for displaying data in a tabular format quick and easy.\n *\n * Out of the box it provides row virtualization, sort and filter operations (client and server side),\n * the ability to template cells and headers and column hiding.\n *\n * @element igc-grid-lite\n *\n * @fires sorting - Emitted when sorting is initiated through the UI.\n * @fires sorted - Emitted when a sort operation initiated through the UI has completed.\n * @fires filtering - Emitted when filtering is initiated through the UI.\n * @fires filtered - Emitted when a filter operation initiated through the UI has completed.\n *\n */\nexport class IgcGridLite<T extends object> extends EventEmitterBase<IgcGridLiteEventMap<T>> {\n public static get tagName() {\n return GRID_TAG;\n }\n\n public static override styles = [styles, shared];\n\n public static register() {\n registerComponent(\n IgcGridLite,\n IgcVirtualizer,\n IgcGridLiteRow,\n IgcGridLiteHeaderRow,\n IgcFilterRow,\n IgcButtonComponent,\n IgcChipComponent,\n IgcInputComponent,\n IgcDropdownComponent\n );\n }\n\n protected stateController = new StateController<T>(this);\n protected DOM = new GridDOMController<T>(this, this.stateController);\n protected dataController = new DataOperationsController<T>(this);\n\n protected stateProvider = new ContextProvider(this, {\n context: gridStateContext,\n initialValue: this.stateController,\n });\n\n @query(IgcVirtualizer.tagName)\n protected scrollContainer!: IgcVirtualizer;\n\n @query(IgcGridLiteHeaderRow.tagName)\n protected headerRow!: IgcGridLiteHeaderRow<T>;\n\n @query(IgcFilterRow.tagName)\n protected filterRow!: IgcFilterRow<T>;\n\n @state()\n protected dataState: Array<T> = [];\n\n @queryAll(IgcGridLiteRow.tagName)\n protected _rows!: NodeListOf<IgcGridLiteRow<T>>;\n\n /** Column configuration for the grid. */\n @property({ attribute: false })\n public columns: Array<ColumnConfiguration<T>> = [];\n\n /** The data source for the grid. */\n @property({ attribute: false })\n public data: Array<T> = [];\n\n /**\n * Whether the grid will try to \"resolve\" its column configuration based on the passed\n * data source.\n *\n * @remarks\n * This is usually executed on initial rendering in the DOM. It depends on having an existing data source\n * to infer the column configuration for the grid.\n * Passing an empty data source or having a late bound data source (such as a HTTP request) will usually\n * result in empty column configuration for the grid.\n *\n * This property is ignored if any existing column configuration already exists in the grid.\n *\n * In a scenario where you want to bind a new data source and still keep the auto-generation behavior,\n * make sure to reset the column collection of the grid before passing in the new data source.\n *\n * @example\n * ```typescript\n * // assuming autoGenerate is set to true\n * grid.columns = [];\n * grid.data = [...];\n * ```\n *\n * @attr auto-generate\n */\n @property({ type: Boolean, attribute: 'auto-generate' })\n public autoGenerate = false;\n\n /** Sort configuration property for the grid. */\n @property({ attribute: false })\n public sortConfiguration: GridSortConfiguration = {\n multiple: true,\n triState: true,\n };\n\n /**\n * Configuration object which controls remote data operations for the grid.\n */\n @property({ attribute: false })\n public dataPipelineConfiguration!: DataPipelineConfiguration<T>;\n\n /**\n * Set the sort state for the grid.\n */\n public set sortExpressions(expressions: SortExpression<T>[]) {\n if (expressions.length) {\n this.sort(expressions);\n }\n }\n\n /**\n * Get the sort state for the grid.\n */\n @property({ attribute: false })\n public get sortExpressions(): SortExpression<T>[] {\n return Array.from(this.stateController.sorting.state.values());\n }\n\n /**\n * Set the filter state for the grid.\n */\n public set filterExpressions(expressions: FilterExpression<T>[]) {\n if (expressions.length) {\n this.filter(expressions);\n }\n }\n\n /**\n * Get the filter state for the grid.\n */\n @property({ attribute: false })\n public get filterExpressions(): FilterExpression<T>[] {\n const expressions: FilterExpression<T>[] = [];\n\n for (const each of this.stateController.filtering.state.values) {\n expressions.push(...each.all);\n }\n\n return expressions;\n }\n\n /**\n * Returns the collection of rendered row elements in the grid.\n *\n * @remarks\n * Since the grid has virtualization, this property returns only the currently rendered\n * chunk of elements in the DOM.\n */\n public get rows() {\n return Array.from(this._rows);\n }\n\n /**\n * Returns the state of the data source after sort/filter operations\n * have been applied.\n */\n public get dataView(): ReadonlyArray<T> {\n return this.dataState;\n }\n\n /**\n * The total number of items in the {@link IgcGridLite.dataView} collection.\n */\n public get totalItems() {\n return this.dataState.length;\n }\n\n @watch('columns')\n protected watchColumns(_: ColumnConfiguration<T>[], newConfig: ColumnConfiguration<T>[] = []) {\n this.columns = newConfig.map((config) => ({ ...DEFAULT_COLUMN_CONFIG, ...config }));\n }\n\n @watch('data')\n protected dataChanged() {\n this.dataState = structuredClone(this.data);\n autoGenerateColumns(this);\n\n if (this.hasUpdated) {\n this.pipeline();\n }\n }\n\n @watch(PIPELINE)\n protected async pipeline() {\n this.dataState = await this.dataController.apply(\n structuredClone(this.data),\n this.stateController\n );\n }\n\n constructor() {\n super();\n\n addThemingController(this, all);\n }\n\n /**\n * Performs a filter operation in the grid based on the passed expression(s).\n */\n public filter(config: FilterExpression<T> | FilterExpression<T>[]) {\n this.stateController.filtering.filter(\n asArray(config).map((each) =>\n typeof each.condition === 'string'\n ? // XXX: Types\n Object.assign(each, {\n condition: (getFilterOperandsFor(this.getColumn(each.key)!) as any)[each.condition],\n })\n : each\n )\n );\n }\n\n /**\n * Performs a sort operation in the grid based on the passed expression(s).\n */\n public sort(expressions: SortExpression<T> | SortExpression<T>[]) {\n this.stateController.sorting.sort(expressions);\n }\n\n /**\n * Resets the current sort state of the control.\n */\n public clearSort(key?: Keys<T>) {\n this.stateController.sorting.reset(key);\n this.requestUpdate(PIPELINE);\n }\n\n /**\n * Resets the current filter state of the control.\n */\n public clearFilter(key?: Keys<T>) {\n this.stateController.filtering.reset(key);\n this.requestUpdate(PIPELINE);\n }\n\n /**\n * Returns a {@link ColumnConfiguration} for a given column.\n */\n public getColumn(id: Keys<T> | number) {\n return typeof id === 'number'\n ? this.columns.at(id)\n : this.columns.find(({ key }) => key === id);\n }\n\n /**\n * Updates the column configuration of the grid.\n */\n public updateColumns(columns: ColumnConfiguration<T> | ColumnConfiguration<T>[]) {\n for (const column of asArray(columns)) {\n const instance = this.columns.find((curr) => curr.key === column.key);\n if (instance) {\n Object.assign(instance, column);\n }\n }\n\n this.requestUpdate(PIPELINE);\n }\n\n @eventOptions({ capture: true })\n protected bodyClickHandler(event: MouseEvent) {\n const target = event\n .composedPath()\n .find((el) => el instanceof IgcGridLiteCell) as IgcGridLiteCell<T>;\n if (target) {\n this.stateController.active = {\n column: target.column.key,\n row: target.row.index,\n };\n }\n }\n\n protected bodyKeydownHandler(event: KeyboardEvent) {\n if (this.scrollContainer.isSameNode(event.target as HTMLElement)) {\n this.stateController.navigation.navigate(event);\n }\n }\n\n protected renderHeaderRow() {\n return html`\n <igc-grid-lite-header-row\n style=${styleMap(this.DOM.columnSizes)}\n .columns=${this.columns}\n ></igc-grid-lite-header-row>\n `;\n }\n\n protected renderBody() {\n return html`\n <igc-virtualizer\n .items=${this.dataState}\n .renderItem=${this.DOM.rowRenderer}\n @click=${this.bodyClickHandler}\n @keydown=${this.bodyKeydownHandler}\n ></igc-virtualizer>\n `;\n }\n\n protected renderFilterRow() {\n return this.columns.some((column) => column.filter)\n ? html`<igc-filter-row style=${styleMap(this.DOM.columnSizes)}></igc-filter-row>`\n : nothing;\n }\n\n protected override render() {\n return html`\n ${this.stateController.resizing.renderIndicator()}\n ${this.renderHeaderRow()}\n ${this.renderFilterRow()}\n ${this.renderBody()}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [IgcGridLite.tagName]: IgcGridLite<object>;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/components/grid.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAA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CACjB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;YAC3D,CAAC,CAAC,IAAI,CAAA,yBAAyB,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,oBAAoB;YAC5F,CAAC,CAAC,OAAO,CACZ,EAAE,CAAC;IACN,CAAC;IAEkB,MAAM;QACvB,OAAO,IAAI,CAAA;;QAEP,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,gBAAgB,EAAE;QAC3E,IAAI,CAAC,gBAAgB,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE;KAChD,CAAC;IACJ,CAAC;;AA9SS;IADT,KAAK,EAAE;+CACuB;AAIxB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;yCACT;AA2Bf;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;iDAC5B;AAIrB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;mDAG7B;AAMK;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8DACiC;AAiBhE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDAG9B;AAiBD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDAG9B;AAiCS;IADT,KAAK,CAAC,MAAM,CAAC;8CAUb;AAGe;IADf,KAAK,CAAC,QAAQ,CAAC;2CAGf;AAwGS;IADT,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAO/B","sourcesContent":["import { ContextProvider } from '@lit/context';\nimport type { RenderItemFunction } from '@lit-labs/virtualizer/virtualize.js';\nimport {\n IgcButtonComponent,\n IgcChipComponent,\n IgcDropdownComponent,\n IgcInputComponent,\n} from 'igniteui-webcomponents';\nimport { html, nothing } from 'lit';\nimport { eventOptions, property, state } from 'lit/decorators.js';\nimport { cache } from 'lit/directives/cache.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { createDataOperationsController } from '../controllers/data-operation.js';\nimport { createDomController } from '../controllers/dom.js';\nimport { createStateController } from '../controllers/state.js';\nimport { PIPELINE } from '../internal/constants.js';\nimport { COLUMN_UPDATE_CONTEXT, GRID_STATE_CONTEXT } from '../internal/context.js';\nimport { getElementFromEventPath } from '../internal/element-from-event-path.js';\nimport { EventEmitterBase } from '../internal/mixins/event-emitter.js';\nimport { registerComponent } from '../internal/register.js';\nimport { GRID_TAG } from '../internal/tags.js';\nimport { addThemingController } from '../internal/theming.js';\nimport type {\n ColumnConfiguration,\n DataPipelineConfiguration,\n GridLiteSortingOptions,\n Keys,\n} from '../internal/types.js';\nimport { asArray, getFilterOperandsFor, isNumber, isString } from '../internal/utils.js';\nimport { watch } from '../internal/watch.js';\nimport type { FilterExpression } from '../operations/filter/types.js';\nimport type { SortingExpression } from '../operations/sort/types.js';\nimport { styles } from '../styles/themes/grid.base.css.js';\nimport { all } from '../styles/themes/grid-themes.js';\nimport { styles as shared } from '../styles/themes/shared/grid.common.css.js';\nimport IgcGridLiteCell from './cell.js';\nimport { IgcGridLiteColumn } from './column.js';\nimport IgcFilterRow from './filter-row.js';\nimport IgcGridLiteHeaderRow from './header-row.js';\nimport IgcGridLiteRow from './row.js';\nimport IgcVirtualizer from './virtualizer.js';\n\n/**\n * Event object for the filtering event of the grid.\n */\nexport interface IgcFilteringEvent<T extends object> {\n /**\n * The target column for the filter operation.\n */\n key: Keys<T>;\n\n /**\n * The filter expression(s) to apply.\n */\n expressions: FilterExpression<T>[];\n\n /**\n * The type of modification which will be applied to the filter\n * state of the column.\n *\n * @remarks\n * `add` - a new filter expression will be added to the state of the column.\n * `modify` - an existing filter expression will be modified.\n * `remove` - the expression(s) will be removed from the state of the column.\n */\n type: 'add' | 'modify' | 'remove';\n}\n\n/**\n * Event object for the filtered event of the grid.\n */\nexport interface IgcFilteredEvent<T extends object> {\n /**\n * The target column for the filter operation.\n */\n key: Keys<T>;\n\n /**\n * The filter state of the column after the operation.\n */\n state: FilterExpression<T>[];\n}\n\n/**\n * Events for the igc-grid-lite.\n */\nexport interface IgcGridLiteEventMap<T extends object> {\n /**\n * Emitted when sorting is initiated through the UI.\n * Returns the sort expression which will be used for the operation.\n *\n * @remarks\n * The event is cancellable which prevents the operation from being applied.\n * The expression can be modified prior to the operation running.\n *\n * @event\n */\n sorting: CustomEvent<SortingExpression<T>>;\n /**\n * Emitted when a sort operation initiated through the UI has completed.\n * Returns the sort expression used for the operation.\n *\n * @event\n */\n sorted: CustomEvent<SortingExpression<T>>;\n /**\n * Emitted when filtering is initiated through the UI.\n *\n * @remarks\n * The event is cancellable which prevents the operation from being applied.\n * The expression can be modified prior to the operation running.\n *\n * @event\n */\n filtering: CustomEvent<IgcFilteringEvent<T>>;\n /**\n * Emitted when a filter operation initiated through the UI has completed.\n * Returns the filter state for the affected column.\n *\n * @event\n */\n filtered: CustomEvent<IgcFilteredEvent<T>>;\n}\n\n/**\n * IgcGridLite is a web component for displaying data in a tabular format quick and easy.\n *\n * Out of the box it provides row virtualization, sort and filter operations (client and server side),\n * the ability to template cells and headers and column hiding.\n *\n * @element igc-grid-lite\n *\n * @fires sorting - Emitted when sorting is initiated through the UI.\n * @fires sorted - Emitted when a sort operation initiated through the UI has completed.\n * @fires filtering - Emitted when filtering is initiated through the UI.\n * @fires filtered - Emitted when a filter operation initiated through the UI has completed.\n *\n */\nexport class IgcGridLite<T extends object> extends EventEmitterBase<IgcGridLiteEventMap<T>> {\n public static get tagName() {\n return GRID_TAG;\n }\n\n public static override styles = [styles, shared];\n\n public static register(): void {\n registerComponent(\n IgcGridLite,\n IgcGridLiteColumn,\n IgcVirtualizer,\n IgcGridLiteRow,\n IgcGridLiteHeaderRow,\n IgcFilterRow,\n IgcButtonComponent,\n IgcChipComponent,\n IgcInputComponent,\n IgcDropdownComponent\n );\n }\n\n protected readonly _stateController = createStateController(this, this._updateObservers);\n protected readonly _domController = createDomController(this, this._stateController);\n protected readonly _dataController = createDataOperationsController(this);\n\n protected readonly _stateProvider = new ContextProvider(this, {\n context: GRID_STATE_CONTEXT,\n initialValue: this._stateController,\n });\n\n protected readonly _columnUpdateProvider = new ContextProvider(this, {\n context: COLUMN_UPDATE_CONTEXT,\n initialValue: ((config: ColumnConfiguration<T>) => {\n this._updateConfiguration(config);\n }) as any,\n });\n\n private _initialSortExpressions: SortingExpression<T>[] = [];\n private _initialFilterExpressions: FilterExpression<T>[] = [];\n\n private _updateObservers(): void {\n this._stateProvider.updateObservers();\n }\n\n private _updateConfiguration(config: ColumnConfiguration<T>): void {\n this._stateController.updateColumnsConfiguration(asArray(config));\n }\n\n @state()\n protected _dataState: T[] = [];\n\n /** The data source for the grid. */\n @property({ attribute: false })\n public data: T[] = [];\n\n /**\n * Whether the grid will try to \"resolve\" its column configuration based on the passed\n * data source.\n *\n * @remarks\n * This is usually executed on initial rendering in the DOM. It depends on having an existing data source\n * to infer the column configuration for the grid.\n * Passing an empty data source or having a late bound data source (such as a HTTP request) will usually\n * result in empty column configuration for the grid.\n *\n * This property is ignored if any existing column configuration already exists in the grid.\n *\n * In a scenario where you want to bind a new data source and still keep the auto-generation behavior,\n * make sure to reset the column collection of the grid before passing in the new data source.\n *\n * @example\n * ```typescript\n * // assuming autoGenerate is set to true\n * grid.columns = [];\n * grid.data = [...];\n * ```\n *\n * @attr auto-generate\n */\n @property({ type: Boolean, attribute: 'auto-generate' })\n public autoGenerate = false;\n\n /** Sort configuration property for the grid. */\n @property({ attribute: false })\n public sortingOptions: GridLiteSortingOptions = {\n mode: 'multiple',\n };\n\n /**\n * Configuration object which controls remote data operations for the grid.\n */\n @property({ attribute: false })\n public dataPipelineConfiguration!: DataPipelineConfiguration<T>;\n\n /**\n * Set the sort state for the grid.\n */\n public set sortingExpressions(expressions: SortingExpression<T>[]) {\n if (this.hasUpdated && expressions.length) {\n this.sort(expressions);\n } else {\n this._initialSortExpressions = expressions;\n }\n }\n\n /**\n * Get the sort state for the grid.\n */\n @property({ attribute: false })\n public get sortingExpressions(): SortingExpression<T>[] {\n return Array.from(this._stateController.sorting.state.values());\n }\n\n /**\n * Set the filter state for the grid.\n */\n public set filterExpressions(expressions: FilterExpression<T>[]) {\n if (this.hasUpdated && expressions.length) {\n this.filter(expressions);\n } else {\n this._initialFilterExpressions = expressions;\n }\n }\n\n /**\n * Get the filter state for the grid.\n */\n @property({ attribute: false })\n public get filterExpressions(): FilterExpression<T>[] {\n return this._stateController.filtering.state.values.flatMap((each) => each.all);\n }\n\n public get columns(): ColumnConfiguration<T>[] {\n return this._stateController.columns.map((col) => ({ ...col }));\n }\n\n /**\n * Returns the collection of rendered row elements in the grid.\n *\n * @remarks\n * Since the grid has virtualization, this property returns only the currently rendered\n * chunk of elements in the DOM.\n */\n public get rows() {\n return this._stateController.rows;\n }\n\n /**\n * Returns the state of the data source after sort/filter operations\n * have been applied.\n */\n public get dataView(): ReadonlyArray<T> {\n return this._dataState;\n }\n\n /**\n * The total number of items in the {@link IgcGridLite.dataView} collection.\n */\n public get totalItems(): number {\n return this._dataState.length;\n }\n\n @watch('data')\n protected dataChanged() {\n this._dataState = [...this.data];\n\n if (this.hasUpdated) {\n if (!this._hasAssignedColumns()) {\n this._stateController.setAutoColumnConfiguration();\n }\n this.pipeline();\n }\n }\n\n @watch(PIPELINE)\n protected async pipeline() {\n this._dataState = await this._dataController.apply([...this.data], this._stateController);\n }\n\n constructor() {\n super();\n\n addThemingController(this, all);\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n root.addEventListener('slotchange', this._handleSlotChange.bind(this));\n return root;\n }\n\n protected override firstUpdated(): void {\n this.updateComplete.then(() => {\n if (this.autoGenerate && !this._hasAssignedColumns()) {\n this._stateController.setAutoColumnConfiguration();\n }\n\n if (this._initialFilterExpressions.length) {\n this.filter(this._initialFilterExpressions);\n }\n\n if (this._initialSortExpressions.length) {\n this.sort(this._initialSortExpressions);\n }\n });\n }\n\n private _hasAssignedColumns(): boolean {\n const slot = this.renderRoot.querySelector('slot') as HTMLSlotElement;\n const assignedNodes = slot\n .assignedElements({ flatten: true })\n .filter((element) => element.matches(IgcGridLiteColumn.tagName));\n return assignedNodes.length > 0;\n }\n\n private _handleSlotChange(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n const assignedNodes = slot\n .assignedElements({ flatten: true })\n .filter((element) => element.matches(IgcGridLiteColumn.tagName));\n\n this._stateController.setColumnConfiguration(\n assignedNodes as unknown as ColumnConfiguration<T>[]\n );\n }\n\n /**\n * Performs a filter operation in the grid based on the passed expression(s).\n */\n public filter(config: FilterExpression<T> | FilterExpression<T>[]): void {\n this._stateController.filtering.filter(\n asArray(config).map((each) =>\n isString(each.condition)\n ? Object.assign(each, {\n condition: (getFilterOperandsFor(this.getColumn(each.key)!) as any)[each.condition],\n })\n : each\n )\n );\n }\n\n /**\n * Performs a sort operation in the grid based on the passed expression(s).\n */\n public sort(expressions: SortingExpression<T> | SortingExpression<T>[]) {\n this._stateController.sorting.sort(expressions);\n }\n\n /**\n * Resets the current sort state of the control.\n */\n public clearSort(key?: Keys<T>): void {\n this._stateController.sorting.reset(key);\n this.requestUpdate(PIPELINE);\n }\n\n /**\n * Resets the current filter state of the control.\n */\n public clearFilter(key?: Keys<T>): void {\n this._stateController.filtering.reset(key);\n this.requestUpdate(PIPELINE);\n }\n\n /**\n * Returns a {@link ColumnConfiguration} for a given column.\n */\n public getColumn(id: Keys<T> | number): ColumnConfiguration<T> | undefined {\n return this._stateController.columns.find((column, index) =>\n isNumber(id) ? index === id : column.key === id\n );\n }\n\n /**\n * Updates the column configuration of the grid.\n */\n public updateColumns(columns: ColumnConfiguration<T> | ColumnConfiguration<T>[]): void {\n this._stateController.updateColumnsConfiguration(asArray(columns));\n }\n\n @eventOptions({ capture: true })\n protected _bodyClickHandler(event: PointerEvent): void {\n const target = getElementFromEventPath<IgcGridLiteCell<T>>(IgcGridLiteCell.tagName, event);\n\n if (target) {\n this._stateController.active = { column: target.column.key, row: target.row.index };\n }\n }\n\n protected _bodyKeydownHandler(event: KeyboardEvent): void {\n if (event.target === this._stateController.virtualizer) {\n this._stateController.navigation.navigate(event);\n }\n }\n\n protected _renderRow: RenderItemFunction<T> = (item: T, index: number) => {\n const styles = {\n ...this._domController.columnSizes,\n ...this._domController.getActiveRowStyles(index),\n };\n const activeNode = this._stateController.active;\n\n return html`\n <igc-grid-lite-row\n part=\"row\"\n exportparts=\"cell\"\n style=${styleMap(styles)}\n .index=${index}\n .activeNode=${activeNode}\n .data=${item}\n .columns=${this._stateController.columns}\n ></igc-grid-lite-row>\n `;\n };\n\n protected _renderHeaderRow() {\n return html`\n <igc-grid-lite-header-row\n tabindex=\"0\"\n style=${styleMap(this._domController.columnSizes)}\n .columns=${this._stateController.columns}\n ></igc-grid-lite-header-row>\n `;\n }\n\n protected _renderBody() {\n return html`\n <igc-virtualizer\n tabindex=\"0\"\n .items=${this._dataState}\n .renderItem=${this._renderRow}\n @click=${this._bodyClickHandler}\n @keydown=${this._bodyKeydownHandler}\n ></igc-virtualizer>\n `;\n }\n\n protected _renderFilterRow() {\n return html`${cache(\n this._stateController.columns.some((column) => column.filter)\n ? html`<igc-filter-row style=${styleMap(this._domController.columnSizes)}></igc-filter-row>`\n : nothing\n )}`;\n }\n\n protected override render() {\n return html`\n <slot part=\"column-sink\"></slot>\n ${this._stateController.resizing.renderIndicator()} ${this._renderHeaderRow()}\n ${this._renderFilterRow()} ${this._renderBody()}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [IgcGridLite.tagName]: IgcGridLite<object>;\n }\n}\n"]}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { LitElement, type
|
|
2
|
-
import { type StateController } from '../controllers/state.js';
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
3
2
|
import type { ColumnConfiguration } from '../internal/types.js';
|
|
4
3
|
import IgcGridLiteHeader from './header.js';
|
|
5
4
|
export default class IgcGridLiteHeaderRow<T extends object> extends LitElement {
|
|
6
|
-
#private;
|
|
7
5
|
static get tagName(): "igc-grid-lite-header-row";
|
|
8
6
|
static styles: import("lit").CSSResult;
|
|
9
7
|
static register(): void;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
columns: Array<ColumnConfiguration<T>>;
|
|
8
|
+
private readonly _state?;
|
|
9
|
+
columns: ColumnConfiguration<T>[];
|
|
13
10
|
get headers(): IgcGridLiteHeader<T>[];
|
|
14
11
|
constructor();
|
|
15
|
-
|
|
16
|
-
protected shouldUpdate(props:
|
|
12
|
+
private _setActiveFilterColumn;
|
|
13
|
+
protected shouldUpdate(props: PropertyValues<this>): boolean;
|
|
17
14
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
18
15
|
}
|
|
19
16
|
declare global {
|
package/components/header-row.js
CHANGED
|
@@ -6,10 +6,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { consume } from '@lit/context';
|
|
8
8
|
import { html, LitElement, nothing } from 'lit';
|
|
9
|
-
import { property
|
|
9
|
+
import { property } from 'lit/decorators.js';
|
|
10
10
|
import { map } from 'lit/directives/map.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { GRID_STATE_CONTEXT } from '../internal/context.js';
|
|
12
|
+
import { getElementFromEventPath } from '../internal/element-from-event-path.js';
|
|
13
|
+
import { partMap } from '../internal/part-map.js';
|
|
13
14
|
import { registerComponent } from '../internal/register.js';
|
|
14
15
|
import { GRID_HEADER_ROW_TAG } from '../internal/tags.js';
|
|
15
16
|
import { styles } from '../styles/header-row/header-row.base.css.js';
|
|
@@ -23,23 +24,16 @@ export default class IgcGridLiteHeaderRow extends LitElement {
|
|
|
23
24
|
registerComponent(IgcGridLiteHeaderRow, IgcGridLiteHeader);
|
|
24
25
|
}
|
|
25
26
|
get headers() {
|
|
26
|
-
return Array.from(this.
|
|
27
|
+
return Array.from(this.renderRoot.querySelectorAll(IgcGridLiteHeader.tagName));
|
|
27
28
|
}
|
|
28
29
|
constructor() {
|
|
29
30
|
super();
|
|
30
31
|
this.columns = [];
|
|
31
|
-
this.addEventListener('click', this
|
|
32
|
+
this.addEventListener('click', this._setActiveFilterColumn);
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
}
|
|
37
|
-
#activeFilterColumn(event) {
|
|
38
|
-
const header = event
|
|
39
|
-
.composedPath()
|
|
40
|
-
.filter((target) => target instanceof IgcGridLiteHeader)
|
|
41
|
-
.at(0);
|
|
42
|
-
this.state.filtering.setActiveColumn(header?.column);
|
|
34
|
+
_setActiveFilterColumn(event) {
|
|
35
|
+
const header = getElementFromEventPath(IgcGridLiteHeader.tagName, event);
|
|
36
|
+
this._state?.filtering.setActiveColumn(header?.column);
|
|
43
37
|
}
|
|
44
38
|
shouldUpdate(props) {
|
|
45
39
|
for (const header of this.headers) {
|
|
@@ -48,24 +42,20 @@ export default class IgcGridLiteHeaderRow extends LitElement {
|
|
|
48
42
|
return super.shouldUpdate(props);
|
|
49
43
|
}
|
|
50
44
|
render() {
|
|
51
|
-
const filterRow = this.
|
|
45
|
+
const filterRow = this._state?.filtering.filterRow;
|
|
52
46
|
return html `${map(this.columns, (column) => column.hidden
|
|
53
47
|
? nothing
|
|
54
|
-
: html
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
: html `
|
|
49
|
+
<igc-grid-lite-header
|
|
50
|
+
part=${partMap({ filtered: column.key === filterRow?.column?.key })}
|
|
51
|
+
.column=${column}
|
|
52
|
+
></igc-grid-lite-header>
|
|
53
|
+
`)}`;
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
__decorate([
|
|
63
|
-
|
|
64
|
-
], IgcGridLiteHeaderRow.prototype, "
|
|
65
|
-
__decorate([
|
|
66
|
-
consume({ context: gridStateContext, subscribe: true }),
|
|
67
|
-
property({ attribute: false })
|
|
68
|
-
], IgcGridLiteHeaderRow.prototype, "state", void 0);
|
|
57
|
+
consume({ context: GRID_STATE_CONTEXT, subscribe: true })
|
|
58
|
+
], IgcGridLiteHeaderRow.prototype, "_state", void 0);
|
|
69
59
|
__decorate([
|
|
70
60
|
property({ attribute: false })
|
|
71
61
|
], IgcGridLiteHeaderRow.prototype, "columns", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header-row.js","sourceRoot":"","sources":["../../src/components/header-row.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"header-row.js","sourceRoot":"","sources":["../../src/components/header-row.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,6CAA6C,CAAC;AACrE,OAAO,iBAAiB,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,oBAAuC,SAAQ,UAAU;IACr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,GAAG,EAAE,CAAC;wBACzD,MAAM;;WAEnB,CACN,EAAE,CAAC;IACN,CAAC;;AA1CgB;IADhB,OAAO,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oDACb;AAGtC;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACe","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, nothing, type PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { map } from 'lit/directives/map.js';\nimport type { StateController } from '../controllers/state.js';\nimport { GRID_STATE_CONTEXT } from '../internal/context.js';\nimport { getElementFromEventPath } from '../internal/element-from-event-path.js';\nimport { partMap } from '../internal/part-map.js';\nimport { registerComponent } from '../internal/register.js';\nimport { GRID_HEADER_ROW_TAG } from '../internal/tags.js';\nimport type { ColumnConfiguration } from '../internal/types.js';\nimport { styles } from '../styles/header-row/header-row.base.css.js';\nimport IgcGridLiteHeader from './header.js';\n\nexport default class IgcGridLiteHeaderRow<T extends object> extends LitElement {\n public static get tagName() {\n return GRID_HEADER_ROW_TAG;\n }\n public static override styles = styles;\n\n public static register(): void {\n registerComponent(IgcGridLiteHeaderRow, IgcGridLiteHeader);\n }\n\n @consume({ context: GRID_STATE_CONTEXT, subscribe: true })\n private readonly _state?: StateController<T>;\n\n @property({ attribute: false })\n public columns: ColumnConfiguration<T>[] = [];\n\n public get headers(): IgcGridLiteHeader<T>[] {\n return Array.from(\n this.renderRoot.querySelectorAll<IgcGridLiteHeader<T>>(IgcGridLiteHeader.tagName)\n );\n }\n\n constructor() {\n super();\n this.addEventListener('click', this._setActiveFilterColumn);\n }\n\n private _setActiveFilterColumn(event: PointerEvent): void {\n const header = getElementFromEventPath<IgcGridLiteHeader<T>>(IgcGridLiteHeader.tagName, event);\n this._state?.filtering.setActiveColumn(header?.column);\n }\n\n protected override shouldUpdate(props: PropertyValues<this>): boolean {\n for (const header of this.headers) {\n header.requestUpdate();\n }\n\n return super.shouldUpdate(props);\n }\n\n protected override render() {\n const filterRow = this._state?.filtering.filterRow;\n\n return html`${map(this.columns, (column) =>\n column.hidden\n ? nothing\n : html`\n <igc-grid-lite-header\n part=${partMap({ filtered: column.key === filterRow?.column?.key })}\n .column=${column}\n ></igc-grid-lite-header>\n `\n )}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [IgcGridLiteHeaderRow.tagName]: IgcGridLiteHeaderRow<object>;\n }\n}\n"]}
|
package/components/header.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, nothing } from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import type { StateController } from '../controllers/state.js';
|
|
3
3
|
import type { ColumnConfiguration, IgcHeaderContext } from '../internal/types.js';
|
|
4
4
|
export default class IgcGridLiteHeader<T extends object> extends LitElement {
|
|
5
5
|
#private;
|