igniteui-grid-lite 0.9.0 → 0.10.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/components/cell.d.ts +8 -0
- package/components/cell.js +12 -1
- package/components/cell.js.map +1 -1
- package/components/column.d.ts +2 -2
- package/components/column.js.map +1 -1
- package/components/filter-row.d.ts +7 -2
- package/components/filter-row.js +87 -52
- package/components/filter-row.js.map +1 -1
- package/components/grid.d.ts +49 -3
- package/components/grid.js +102 -62
- package/components/grid.js.map +1 -1
- package/components/header-row.d.ts +1 -2
- package/components/header-row.js +4 -7
- package/components/header-row.js.map +1 -1
- package/components/header.d.ts +9 -0
- package/components/header.js +36 -23
- package/components/header.js.map +1 -1
- package/components/row.d.ts +4 -1
- package/components/row.js +12 -1
- package/components/row.js.map +1 -1
- package/components/virtualizer.d.ts +3 -1
- package/components/virtualizer.js +36 -7
- package/components/virtualizer.js.map +1 -1
- package/controllers/data-operation.d.ts +0 -4
- package/controllers/data-operation.js +7 -22
- package/controllers/data-operation.js.map +1 -1
- package/controllers/dom.d.ts +28 -9
- package/controllers/dom.js +70 -20
- package/controllers/dom.js.map +1 -1
- package/controllers/filter.d.ts +20 -4
- package/controllers/filter.js +39 -55
- package/controllers/filter.js.map +1 -1
- package/controllers/navigation.d.ts +10 -10
- package/controllers/navigation.js +68 -53
- package/controllers/navigation.js.map +1 -1
- package/controllers/resize.d.ts +8 -8
- package/controllers/resize.js +23 -14
- package/controllers/resize.js.map +1 -1
- package/controllers/sort.d.ts +12 -3
- package/controllers/sort.js +25 -32
- package/controllers/sort.js.map +1 -1
- package/controllers/state.d.ts +28 -18
- package/controllers/state.js +20 -26
- package/controllers/state.js.map +1 -1
- package/custom-elements.json +874 -243
- package/docs/igniteui-grid-lite.json +1339 -818
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/internal/a11y.d.ts +29 -0
- package/internal/a11y.js +24 -0
- package/internal/a11y.js.map +1 -0
- package/internal/constants.d.ts +3 -2
- package/internal/constants.js +1 -4
- package/internal/constants.js.map +1 -1
- package/internal/normalize-case.d.ts +5 -1
- package/internal/normalize-case.js +2 -1
- package/internal/normalize-case.js.map +1 -1
- package/internal/part-map.js +9 -17
- package/internal/part-map.js.map +1 -1
- package/internal/tags.d.ts +2 -2
- package/internal/tags.js +2 -2
- package/internal/tags.js.map +1 -1
- package/internal/types.d.ts +13 -1
- package/internal/types.js.map +1 -1
- package/internal/utils.d.ts +3 -0
- package/internal/utils.js +17 -4
- package/internal/utils.js.map +1 -1
- package/internal/watch.js +8 -9
- package/internal/watch.js.map +1 -1
- package/operations/base.js +2 -1
- package/operations/base.js.map +1 -1
- package/operations/filter/state.js +2 -5
- package/operations/filter/state.js.map +1 -1
- package/operations/filter/tree.d.ts +1 -2
- package/operations/filter/tree.js +2 -7
- package/operations/filter/tree.js.map +1 -1
- package/operations/filter.js +13 -1
- package/operations/filter.js.map +1 -1
- package/operations/sort.d.ts +0 -1
- package/operations/sort.js +7 -9
- package/operations/sort.js.map +1 -1
- package/package.json +2 -2
- package/styles/themes/grid.base.css.js +1 -1
- package/styles/themes/grid.base.css.js.map +1 -1
- package/styles/themes/shared/grid.common.css.js +1 -1
- package/styles/themes/shared/grid.common.css.js.map +1 -1
package/components/grid.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ContextProvider } from '@lit/context';
|
|
2
2
|
import type { RenderItemFunction } from '@lit-labs/virtualizer/virtualize.js';
|
|
3
|
+
import { type PropertyValues } from 'lit';
|
|
3
4
|
import { EventEmitterBase } from '../internal/mixins/event-emitter.js';
|
|
4
|
-
import type { ColumnConfiguration, DataPipelineConfiguration, GridLiteSortingOptions, Keys } from '../internal/types.js';
|
|
5
|
+
import type { ColumnConfiguration, DataPipelineConfiguration, GridLiteSortingOptions, Keys, NavigateToOptions } from '../internal/types.js';
|
|
5
6
|
import type { FilterExpression } from '../operations/filter/types.js';
|
|
6
7
|
import type { SortingExpression } from '../operations/sort/types.js';
|
|
7
8
|
import IgcGridLiteRow from './row.js';
|
|
@@ -99,8 +100,9 @@ export declare class IgcGridLite<T extends object = any> extends EventEmitterBas
|
|
|
99
100
|
static get tagName(): "igc-grid-lite";
|
|
100
101
|
static styles: import("lit").CSSResult[];
|
|
101
102
|
static register(): void;
|
|
102
|
-
|
|
103
|
+
private readonly _a11y;
|
|
103
104
|
protected readonly _domController: import("../controllers/dom.js").GridDOMController<T>;
|
|
105
|
+
protected readonly _stateController: import("../controllers/state.js").StateController<T>;
|
|
104
106
|
protected readonly _dataController: import("../controllers/data-operation.js").DataOperationsController<T>;
|
|
105
107
|
protected readonly _stateProvider: ContextProvider<{
|
|
106
108
|
__context__: import("../controllers/state.js").StateController<any>;
|
|
@@ -111,6 +113,17 @@ export declare class IgcGridLite<T extends object = any> extends EventEmitterBas
|
|
|
111
113
|
private _updateObservers;
|
|
112
114
|
private _updateConfiguration;
|
|
113
115
|
protected _dataState: T[];
|
|
116
|
+
/** Monotonic token identifying the most recently started pipeline run. */
|
|
117
|
+
private _pipelineEpoch;
|
|
118
|
+
private _pipelineTask;
|
|
119
|
+
/**
|
|
120
|
+
* Resolves when the latest pipeline run completes and its result is rendered.
|
|
121
|
+
* The sort and filter controllers await this so that `sorted` and `filtered`
|
|
122
|
+
* report an up-to-date {@link IgcGridLite.dataView}.
|
|
123
|
+
*
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
get _pipelineComplete(): Promise<void>;
|
|
114
127
|
adoptRootStyles: boolean;
|
|
115
128
|
/** The data source for the grid. */
|
|
116
129
|
data: T[];
|
|
@@ -161,6 +174,17 @@ export declare class IgcGridLite<T extends object = any> extends EventEmitterBas
|
|
|
161
174
|
* Get the filter state for the grid.
|
|
162
175
|
*/
|
|
163
176
|
get filterExpressions(): FilterExpression<T>[];
|
|
177
|
+
/**
|
|
178
|
+
* Sets the column configuration for the grid.
|
|
179
|
+
*
|
|
180
|
+
* @remarks
|
|
181
|
+
* Passing an empty collection resets the columns, which - with `autoGenerate` -
|
|
182
|
+
* lets the next data source binding re-generate them.
|
|
183
|
+
*/
|
|
184
|
+
set columns(configuration: ColumnConfiguration<T>[]);
|
|
185
|
+
/**
|
|
186
|
+
* Returns the column configuration of the grid.
|
|
187
|
+
*/
|
|
164
188
|
get columns(): ColumnConfiguration<T>[];
|
|
165
189
|
/**
|
|
166
190
|
* Returns the collection of rendered row elements in the grid.
|
|
@@ -179,11 +203,24 @@ export declare class IgcGridLite<T extends object = any> extends EventEmitterBas
|
|
|
179
203
|
* The total number of items in the {@link IgcGridLite.dataView} collection.
|
|
180
204
|
*/
|
|
181
205
|
get totalItems(): number;
|
|
206
|
+
protected sortingOptionsChanged(): void;
|
|
182
207
|
protected dataChanged(): void;
|
|
183
|
-
|
|
208
|
+
/**
|
|
209
|
+
* NOTE: The `PIPELINE` sentinel equals this method's name. That equality makes
|
|
210
|
+
* the `@watch` comparison (`undefined !== <method>`) fire on each requested
|
|
211
|
+
* update. A rename of this method silently disables the pipeline.
|
|
212
|
+
*/
|
|
213
|
+
protected pipeline(): void;
|
|
214
|
+
/** Runs the data operations. Discards a result that a newer run supersedes. */
|
|
215
|
+
private _runPipeline;
|
|
184
216
|
constructor();
|
|
217
|
+
/** The column set the current row renderer was built from. */
|
|
218
|
+
private _rowColumns?;
|
|
219
|
+
protected willUpdate(props: PropertyValues<this>): void;
|
|
185
220
|
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
186
221
|
protected firstUpdated(): void;
|
|
222
|
+
/** The column elements assigned to the slot, either direct or nested in a container. */
|
|
223
|
+
private _assignedColumns;
|
|
187
224
|
private _hasAssignedColumns;
|
|
188
225
|
private _handleSlotChange;
|
|
189
226
|
/**
|
|
@@ -202,11 +239,18 @@ export declare class IgcGridLite<T extends object = any> extends EventEmitterBas
|
|
|
202
239
|
* Resets the current filter state of the control.
|
|
203
240
|
*/
|
|
204
241
|
clearFilter(key?: Keys<T>): void;
|
|
242
|
+
/**
|
|
243
|
+
* Navigates to a position in the grid based on provided row index and column field.
|
|
244
|
+
* @param row The row index to navigate to
|
|
245
|
+
* @param options The column field to navigate to and whether to activate the cell
|
|
246
|
+
*/
|
|
247
|
+
navigateTo(row: number, options?: NavigateToOptions<T>): Promise<void>;
|
|
205
248
|
/**
|
|
206
249
|
* Navigates to a position in the grid based on provided row index and column field.
|
|
207
250
|
* @param row The row index to navigate to
|
|
208
251
|
* @param column The column field to navigate to, if any
|
|
209
252
|
* @param activate Optionally also activate the navigated cell
|
|
253
|
+
* @deprecated Use `navigateTo(row, options)` instead.
|
|
210
254
|
*/
|
|
211
255
|
navigateTo(row: number, column?: Keys<T>, activate?: boolean): Promise<void>;
|
|
212
256
|
/**
|
|
@@ -215,7 +259,9 @@ export declare class IgcGridLite<T extends object = any> extends EventEmitterBas
|
|
|
215
259
|
getColumn(id: Keys<T> | number): ColumnConfiguration<T> | undefined;
|
|
216
260
|
protected _bodyClickHandler(event: PointerEvent): void;
|
|
217
261
|
protected _bodyKeydownHandler(event: KeyboardEvent): void;
|
|
262
|
+
/** Rebuilt by {@link IgcGridLite.willUpdate} when a row input changes. */
|
|
218
263
|
protected _renderRow: RenderItemFunction<T>;
|
|
264
|
+
private _createRowRenderer;
|
|
219
265
|
protected _renderHeaderRow(): import("lit-html").TemplateResult<1>;
|
|
220
266
|
protected _renderBody(): import("lit-html").TemplateResult<1>;
|
|
221
267
|
protected _renderFilterRow(): import("lit-html").TemplateResult<1>;
|
package/components/grid.js
CHANGED
|
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { ContextProvider } from '@lit/context';
|
|
8
|
-
import { θaddThemingController as addThemingController
|
|
8
|
+
import { θaddThemingController as addThemingController } from 'igniteui-webcomponents';
|
|
9
9
|
import { html, nothing } from 'lit';
|
|
10
10
|
import { eventOptions, property, state } from 'lit/decorators.js';
|
|
11
11
|
import { cache } from 'lit/directives/cache.js';
|
|
@@ -13,13 +13,14 @@ import { styleMap } from 'lit/directives/style-map.js';
|
|
|
13
13
|
import { createDataOperationsController } from '../controllers/data-operation.js';
|
|
14
14
|
import { createDomController } from '../controllers/dom.js';
|
|
15
15
|
import { createStateController } from '../controllers/state.js';
|
|
16
|
-
import {
|
|
16
|
+
import { addA11y, headerRowsFor } from '../internal/a11y.js';
|
|
17
|
+
import { FOCUS_WITHIN, PIPELINE } from '../internal/constants.js';
|
|
17
18
|
import { COLUMN_UPDATE_CONTEXT, GRID_STATE_CONTEXT } from '../internal/context.js';
|
|
18
19
|
import { getElementFromEventPath } from '../internal/element-from-event-path.js';
|
|
19
20
|
import { EventEmitterBase } from '../internal/mixins/event-emitter.js';
|
|
20
21
|
import { registerComponent } from '../internal/register.js';
|
|
21
22
|
import { GRID_TAG } from '../internal/tags.js';
|
|
22
|
-
import { asArray,
|
|
23
|
+
import { asArray, isNumber, isString, resolveCondition } from '../internal/utils.js';
|
|
23
24
|
import { watch } from '../internal/watch.js';
|
|
24
25
|
import { styles as base } from '../styles/themes/grid.base.css.js';
|
|
25
26
|
import { all } from '../styles/themes/grid-themes.js';
|
|
@@ -30,20 +31,13 @@ import IgcFilterRow from './filter-row.js';
|
|
|
30
31
|
import IgcGridLiteHeaderRow from './header-row.js';
|
|
31
32
|
import IgcGridLiteRow from './row.js';
|
|
32
33
|
import IgcVirtualizer from './virtualizer.js';
|
|
33
|
-
function columnReducer(acc, el) {
|
|
34
|
-
const tag = IgcGridLiteColumn.tagName;
|
|
35
|
-
const column = el.matches(tag) ? el : el.querySelector(tag);
|
|
36
|
-
if (column)
|
|
37
|
-
acc.push(column);
|
|
38
|
-
return acc;
|
|
39
|
-
}
|
|
40
34
|
export class IgcGridLite extends EventEmitterBase {
|
|
41
35
|
static get tagName() {
|
|
42
36
|
return GRID_TAG;
|
|
43
37
|
}
|
|
44
38
|
static { this.styles = [base, shared]; }
|
|
45
39
|
static register() {
|
|
46
|
-
registerComponent(IgcGridLite, IgcGridLiteColumn, IgcVirtualizer, IgcGridLiteRow, IgcGridLiteHeaderRow
|
|
40
|
+
registerComponent(IgcGridLite, IgcGridLiteColumn, IgcVirtualizer, IgcGridLiteRow, IgcGridLiteHeaderRow);
|
|
47
41
|
}
|
|
48
42
|
_updateObservers() {
|
|
49
43
|
this._stateProvider.updateObservers();
|
|
@@ -51,6 +45,9 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
51
45
|
_updateConfiguration(config) {
|
|
52
46
|
this._stateController.updateColumnsConfiguration(asArray(config));
|
|
53
47
|
}
|
|
48
|
+
get _pipelineComplete() {
|
|
49
|
+
return this.updateComplete.then(() => this._pipelineTask);
|
|
50
|
+
}
|
|
54
51
|
set sortingExpressions(expressions) {
|
|
55
52
|
this._stateController.sorting.reset();
|
|
56
53
|
if (this.hasUpdated) {
|
|
@@ -63,7 +60,7 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
62
|
get sortingExpressions() {
|
|
66
|
-
return Array.from(this._stateController.sorting.state.values());
|
|
63
|
+
return Array.from(this._stateController.sorting.state.values(), (expr) => ({ ...expr }));
|
|
67
64
|
}
|
|
68
65
|
set filterExpressions(expressions) {
|
|
69
66
|
this._stateController.filtering.reset();
|
|
@@ -75,13 +72,16 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
get filterExpressions() {
|
|
78
|
-
return this._stateController.filtering.state.values.flatMap((each) => each.all);
|
|
75
|
+
return this._stateController.filtering.state.values.flatMap((each) => each.all.map((expr) => ({ ...expr })));
|
|
76
|
+
}
|
|
77
|
+
set columns(configuration) {
|
|
78
|
+
this._stateController.setColumnConfiguration(asArray(configuration));
|
|
79
79
|
}
|
|
80
80
|
get columns() {
|
|
81
81
|
return this._stateController.columns.map((col) => ({ ...col }));
|
|
82
82
|
}
|
|
83
83
|
get rows() {
|
|
84
|
-
return this.
|
|
84
|
+
return this._domController.rows;
|
|
85
85
|
}
|
|
86
86
|
get dataView() {
|
|
87
87
|
return this._dataState;
|
|
@@ -89,6 +89,9 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
89
89
|
get totalItems() {
|
|
90
90
|
return this._dataState.length;
|
|
91
91
|
}
|
|
92
|
+
sortingOptionsChanged() {
|
|
93
|
+
this._updateObservers();
|
|
94
|
+
}
|
|
92
95
|
dataChanged() {
|
|
93
96
|
this._dataState = [...this.data];
|
|
94
97
|
if (this.hasUpdated) {
|
|
@@ -98,13 +101,28 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
98
101
|
this.pipeline();
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
|
-
|
|
102
|
-
this.
|
|
104
|
+
pipeline() {
|
|
105
|
+
this._pipelineTask = this._runPipeline();
|
|
106
|
+
}
|
|
107
|
+
async _runPipeline() {
|
|
108
|
+
const epoch = ++this._pipelineEpoch;
|
|
109
|
+
try {
|
|
110
|
+
const state = await this._dataController.apply([...this.data], this._stateController);
|
|
111
|
+
if (epoch !== this._pipelineEpoch) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this._dataState = state;
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
console.error(e);
|
|
118
|
+
}
|
|
119
|
+
await this.updateComplete;
|
|
103
120
|
}
|
|
104
121
|
constructor() {
|
|
105
122
|
super();
|
|
106
|
-
this.
|
|
107
|
-
this._domController = createDomController(this
|
|
123
|
+
this._a11y = addA11y(this, 'grid');
|
|
124
|
+
this._domController = createDomController(this);
|
|
125
|
+
this._stateController = createStateController(this, this._domController, this._updateObservers);
|
|
108
126
|
this._dataController = createDataOperationsController(this);
|
|
109
127
|
this._stateProvider = new ContextProvider(this, {
|
|
110
128
|
context: GRID_STATE_CONTEXT,
|
|
@@ -117,33 +135,29 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
117
135
|
}),
|
|
118
136
|
});
|
|
119
137
|
this._dataState = [];
|
|
138
|
+
this._pipelineEpoch = 0;
|
|
139
|
+
this._pipelineTask = Promise.resolve();
|
|
120
140
|
this.adoptRootStyles = false;
|
|
121
141
|
this.data = [];
|
|
122
142
|
this.autoGenerate = false;
|
|
123
143
|
this.sortingOptions = {
|
|
124
144
|
mode: 'multiple',
|
|
125
145
|
};
|
|
126
|
-
this._renderRow = (
|
|
127
|
-
const styles = {
|
|
128
|
-
...this._domController.columnSizes,
|
|
129
|
-
...this._domController.getActiveRowStyles(index),
|
|
130
|
-
};
|
|
131
|
-
const activeNode = this._stateController.active;
|
|
132
|
-
return html `
|
|
133
|
-
<igc-grid-lite-row
|
|
134
|
-
part="row"
|
|
135
|
-
exportparts="cell"
|
|
136
|
-
style=${styleMap(styles)}
|
|
137
|
-
.adoptRootStyles=${this.adoptRootStyles}
|
|
138
|
-
.index=${index}
|
|
139
|
-
.activeNode=${activeNode}
|
|
140
|
-
.data=${item}
|
|
141
|
-
.columns=${this._stateController.columns}
|
|
142
|
-
></igc-grid-lite-row>
|
|
143
|
-
`;
|
|
144
|
-
};
|
|
146
|
+
this._renderRow = () => html ``;
|
|
145
147
|
addThemingController(this, all);
|
|
146
148
|
}
|
|
149
|
+
willUpdate(props) {
|
|
150
|
+
const { columns } = this._stateController;
|
|
151
|
+
this._domController.setColumns(columns);
|
|
152
|
+
this._a11y.set({
|
|
153
|
+
ariaRowCount: `${headerRowsFor(columns) + this._dataState.length}`,
|
|
154
|
+
ariaColCount: `${columns.filter((column) => !column.hidden).length}`,
|
|
155
|
+
});
|
|
156
|
+
if (columns !== this._rowColumns || props.has('adoptRootStyles')) {
|
|
157
|
+
this._rowColumns = columns;
|
|
158
|
+
this._renderRow = this._createRowRenderer(columns);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
147
161
|
createRenderRoot() {
|
|
148
162
|
const root = super.createRenderRoot();
|
|
149
163
|
root.addEventListener('slotchange', this._handleSlotChange.bind(this));
|
|
@@ -156,30 +170,27 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
156
170
|
}
|
|
157
171
|
});
|
|
158
172
|
}
|
|
159
|
-
|
|
173
|
+
_assignedColumns() {
|
|
160
174
|
const slot = this.renderRoot.querySelector('slot');
|
|
161
|
-
const
|
|
175
|
+
const tag = IgcGridLiteColumn.tagName;
|
|
176
|
+
return slot
|
|
162
177
|
.assignedElements({ flatten: true })
|
|
163
|
-
.
|
|
164
|
-
return assignedNodes.length > 0;
|
|
178
|
+
.flatMap((el) => (el.matches(tag) ? el : Array.from(el.querySelectorAll(tag))));
|
|
165
179
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this._stateController.setColumnConfiguration(assignedNodes);
|
|
180
|
+
_hasAssignedColumns() {
|
|
181
|
+
return this._assignedColumns().length > 0;
|
|
182
|
+
}
|
|
183
|
+
_handleSlotChange() {
|
|
184
|
+
this._stateController.setColumnConfiguration(this._assignedColumns());
|
|
172
185
|
}
|
|
173
186
|
filter(config) {
|
|
174
|
-
const expressions = asArray(config)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
187
|
+
const expressions = asArray(config)
|
|
188
|
+
.filter((expr) => this.getColumn(expr.key) !== undefined)
|
|
189
|
+
.map((expr) => ({ ...expr }));
|
|
178
190
|
for (const expr of expressions) {
|
|
179
|
-
if (
|
|
180
|
-
|
|
191
|
+
if (isString(expr.condition)) {
|
|
192
|
+
expr.condition = resolveCondition(this.getColumn(expr.key), expr.condition);
|
|
181
193
|
}
|
|
182
|
-
expr.condition = getFilterOperandsFor(this.getColumn(expr.key))[expr.condition];
|
|
183
194
|
}
|
|
184
195
|
this._stateController.filtering.filter(expressions);
|
|
185
196
|
}
|
|
@@ -194,23 +205,43 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
194
205
|
this._stateController.filtering.reset(key);
|
|
195
206
|
this.requestUpdate(PIPELINE);
|
|
196
207
|
}
|
|
197
|
-
async navigateTo(row,
|
|
198
|
-
|
|
208
|
+
async navigateTo(row, columnOrOptions, activate) {
|
|
209
|
+
const options = typeof columnOrOptions === 'object' ? columnOrOptions : { column: columnOrOptions, activate };
|
|
210
|
+
await this._stateController.navigation.navigateTo(row, options);
|
|
199
211
|
}
|
|
200
212
|
getColumn(id) {
|
|
201
|
-
|
|
213
|
+
const columns = this._stateController.columns;
|
|
214
|
+
return isNumber(id) ? columns[id] : columns.find((column) => column.field === id);
|
|
202
215
|
}
|
|
203
216
|
_bodyClickHandler(event) {
|
|
204
217
|
const target = getElementFromEventPath(IgcGridLiteCell.tagName, event);
|
|
205
218
|
if (target) {
|
|
206
219
|
this._stateController.active = { column: target.column.field, row: target.row.index };
|
|
220
|
+
if (!target.matches(FOCUS_WITHIN)) {
|
|
221
|
+
target.focus({ preventScroll: true });
|
|
222
|
+
}
|
|
207
223
|
}
|
|
208
224
|
}
|
|
209
225
|
_bodyKeydownHandler(event) {
|
|
210
|
-
|
|
226
|
+
const [origin] = event.composedPath();
|
|
227
|
+
if (origin === this._domController.virtualizer || origin instanceof IgcGridLiteCell) {
|
|
211
228
|
this._stateController.navigation.navigate(event);
|
|
212
229
|
}
|
|
213
230
|
}
|
|
231
|
+
_createRowRenderer(columns) {
|
|
232
|
+
return (item, index) => html `
|
|
233
|
+
<igc-grid-lite-row
|
|
234
|
+
part="row"
|
|
235
|
+
exportparts="cell"
|
|
236
|
+
style=${styleMap(this._domController.columnSizes)}
|
|
237
|
+
.adoptRootStyles=${this.adoptRootStyles}
|
|
238
|
+
.index=${index}
|
|
239
|
+
.activeNode=${this._stateController.active}
|
|
240
|
+
.data=${item}
|
|
241
|
+
.columns=${columns}
|
|
242
|
+
></igc-grid-lite-row>
|
|
243
|
+
`;
|
|
244
|
+
}
|
|
214
245
|
_renderHeaderRow() {
|
|
215
246
|
return html `
|
|
216
247
|
<igc-grid-lite-header-row
|
|
@@ -223,18 +254,24 @@ export class IgcGridLite extends EventEmitterBase {
|
|
|
223
254
|
}
|
|
224
255
|
_renderBody() {
|
|
225
256
|
return html `
|
|
226
|
-
<igc-virtualizer
|
|
257
|
+
<igc-grid-lite-virtualizer
|
|
227
258
|
tabindex="0"
|
|
228
259
|
.items=${this._dataState}
|
|
229
260
|
.renderItem=${this._renderRow}
|
|
230
261
|
@click=${this._bodyClickHandler}
|
|
231
262
|
@keydown=${this._bodyKeydownHandler}
|
|
232
|
-
></igc-virtualizer>
|
|
263
|
+
></igc-grid-lite-virtualizer>
|
|
233
264
|
`;
|
|
234
265
|
}
|
|
235
266
|
_renderFilterRow() {
|
|
236
|
-
|
|
237
|
-
|
|
267
|
+
const filterable = this._stateController.columns.some((column) => column.filterable);
|
|
268
|
+
if (filterable) {
|
|
269
|
+
IgcFilterRow.register();
|
|
270
|
+
}
|
|
271
|
+
return html `${cache(filterable
|
|
272
|
+
? html `<igc-grid-lite-filter-row
|
|
273
|
+
style=${styleMap(this._domController.columnSizes)}
|
|
274
|
+
></igc-grid-lite-filter-row>`
|
|
238
275
|
: nothing)}`;
|
|
239
276
|
}
|
|
240
277
|
render() {
|
|
@@ -269,6 +306,9 @@ __decorate([
|
|
|
269
306
|
__decorate([
|
|
270
307
|
property({ attribute: false })
|
|
271
308
|
], IgcGridLite.prototype, "filterExpressions", null);
|
|
309
|
+
__decorate([
|
|
310
|
+
watch('sortingOptions', { waitUntilFirstUpdate: true })
|
|
311
|
+
], IgcGridLite.prototype, "sortingOptionsChanged", null);
|
|
272
312
|
__decorate([
|
|
273
313
|
watch('data')
|
|
274
314
|
], IgcGridLite.prototype, "dataChanged", null);
|
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;AAE/C,OAAO,EACL,qBAAqB,IAAI,oBAAoB,EAC7C,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC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AAK,EAAE,CAAC;8DACiC;AAoBhE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDAG9B;AAkBD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDAG9B;AAiCS;IADT,KAAK,CAAC,MAAM,CAAC;8CAUb;AAGe;IADf,KAAK,CAAC,QAAQ,CAAC;2CAGf;AAuGS;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 θaddThemingController as addThemingController,\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 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 as base } 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/** Column reducer matching either direct column element or one nested in container */\nfunction columnReducer<T extends Element>(acc: T[], el: T): T[] {\n const tag = IgcGridLiteColumn.tagName;\n const column = el.matches(tag) ? el : el.querySelector(tag);\n if (column) acc.push(column as unknown as T);\n return acc;\n}\n\n/**\n * Event object for the filtering event of the grid.\n */\nexport interface IgcFilteringEvent<T extends object = any> {\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 = any> {\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 = any> {\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, any>>;\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, any>>;\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 = any> extends EventEmitterBase<IgcGridLiteEventMap<T>> {\n public static get tagName() {\n return GRID_TAG;\n }\n\n public static override styles = [base, 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 _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 @property({ type: Boolean, reflect: true, attribute: 'adopt-root-styles' })\n public adoptRootStyles = false;\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 this._stateController.sorting.reset();\n if (this.hasUpdated) {\n this.sort(expressions);\n } else {\n for (const expr of expressions) {\n this._stateController.sorting.state.set(expr.key, { ...expr });\n }\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 this._stateController.filtering.reset();\n if (this.hasUpdated) {\n this.filter(expressions);\n } else {\n this._stateController.filtering.setRaw(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 }\n\n private _hasAssignedColumns(): boolean {\n const slot = this.renderRoot.querySelector('slot') as HTMLSlotElement;\n const assignedNodes = slot\n .assignedElements({ flatten: true })\n .reduce<Element[]>(columnReducer, []);\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 .reduce<Element[]>(columnReducer, []);\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 const expressions = asArray(config).filter((expr) => {\n const column = this.getColumn(expr.key);\n return column !== undefined;\n });\n\n for (const expr of expressions) {\n if (!isString(expr.condition)) {\n continue;\n }\n expr.condition = (getFilterOperandsFor(this.getColumn(expr.key)!) as any)[expr.condition];\n }\n\n this._stateController.filtering.filter(expressions);\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 * Navigates to a position in the grid based on provided row index and column field.\n * @param row The row index to navigate to\n * @param column The column field to navigate to, if any\n * @param activate Optionally also activate the navigated cell\n */\n public async navigateTo(row: number, column?: Keys<T>, activate = false) {\n await this._stateController.navigation.navigateTo(row, column, activate);\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.field === id\n );\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.field, 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 .adoptRootStyles=${this.adoptRootStyles}\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 .adoptRootStyles=${this.adoptRootStyles}\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.filterable)\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;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/components/grid.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,qBAAqB,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBA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AAS,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;AAoBhE;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDAG9B;AAkBD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDAK9B;AA+CS;IADT,KAAK,CAAC,gBAAgB,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;wDAIvD;AAGS;IADT,KAAK,CAAC,MAAM,CAAC;8CAUb;AAQS;IADT,KAAK,CAAC,QAAQ,CAAC;2CAGf;AAmKS;IADT,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAa/B","sourcesContent":["import { ContextProvider } from '@lit/context';\nimport type { RenderItemFunction } from '@lit-labs/virtualizer/virtualize.js';\nimport { θaddThemingController as addThemingController } from 'igniteui-webcomponents';\nimport { html, nothing, type PropertyValues } 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 { addA11y, headerRowsFor } from '../internal/a11y.js';\nimport { FOCUS_WITHIN, 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 type {\n ColumnConfiguration,\n DataPipelineConfiguration,\n GridLiteSortingOptions,\n Keys,\n NavigateToOptions,\n} from '../internal/types.js';\nimport { asArray, isNumber, isString, resolveCondition } 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 as base } 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 = any> {\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 = any> {\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 = any> {\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, any>>;\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, any>>;\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 = any> extends EventEmitterBase<IgcGridLiteEventMap<T>> {\n public static get tagName() {\n return GRID_TAG;\n }\n\n public static override styles = [base, shared];\n\n public static register(): void {\n registerComponent(\n IgcGridLite,\n IgcGridLiteColumn,\n IgcVirtualizer,\n IgcGridLiteRow,\n IgcGridLiteHeaderRow\n );\n }\n\n private readonly _a11y = addA11y(this, 'grid');\n\n protected readonly _domController = createDomController<T>(this);\n protected readonly _stateController = createStateController(\n this,\n this._domController,\n this._updateObservers\n );\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 _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 /** Monotonic token identifying the most recently started pipeline run. */\n private _pipelineEpoch = 0;\n\n private _pipelineTask: Promise<void> = Promise.resolve();\n\n /**\n * Resolves when the latest pipeline run completes and its result is rendered.\n * The sort and filter controllers await this so that `sorted` and `filtered`\n * report an up-to-date {@link IgcGridLite.dataView}.\n *\n * @internal\n */\n public get _pipelineComplete(): Promise<void> {\n // The `updateComplete` hop lets a pending PIPELINE update install its task first.\n return this.updateComplete.then(() => this._pipelineTask);\n }\n\n @property({ type: Boolean, reflect: true, attribute: 'adopt-root-styles' })\n public adoptRootStyles = false;\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 this._stateController.sorting.reset();\n if (this.hasUpdated) {\n this.sort(expressions);\n } else {\n for (const expr of expressions) {\n this._stateController.sorting.state.set(expr.key, { ...expr });\n }\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(), (expr) => ({ ...expr }));\n }\n\n /**\n * Set the filter state for the grid.\n */\n public set filterExpressions(expressions: FilterExpression<T>[]) {\n this._stateController.filtering.reset();\n if (this.hasUpdated) {\n this.filter(expressions);\n } else {\n this._stateController.filtering.setRaw(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) =>\n each.all.map((expr) => ({ ...expr }))\n );\n }\n\n /**\n * Sets the column configuration for the grid.\n *\n * @remarks\n * Passing an empty collection resets the columns, which - with `autoGenerate` -\n * lets the next data source binding re-generate them.\n */\n public set columns(configuration: ColumnConfiguration<T>[]) {\n this._stateController.setColumnConfiguration(asArray(configuration));\n }\n\n /**\n * Returns the column configuration of the grid.\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._domController.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('sortingOptions', { waitUntilFirstUpdate: true })\n protected sortingOptionsChanged() {\n // Headers render the multi-sort position out of this option.\n this._updateObservers();\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 /**\n * NOTE: The `PIPELINE` sentinel equals this method's name. That equality makes\n * the `@watch` comparison (`undefined !== <method>`) fire on each requested\n * update. A rename of this method silently disables the pipeline.\n */\n @watch(PIPELINE)\n protected pipeline(): void {\n this._pipelineTask = this._runPipeline();\n }\n\n /** Runs the data operations. Discards a result that a newer run supersedes. */\n private async _runPipeline(): Promise<void> {\n const epoch = ++this._pipelineEpoch;\n\n try {\n const state = await this._dataController.apply([...this.data], this._stateController);\n\n if (epoch !== this._pipelineEpoch) {\n return;\n }\n\n this._dataState = state;\n } catch (e) {\n // A failed hook must not blank the grid. Keep the previous data state and\n // report the error.\n // biome-ignore lint/suspicious/noConsole: the pipeline hooks are user code; swallowing their errors hides bugs\n console.error(e);\n }\n\n await this.updateComplete;\n }\n\n constructor() {\n super();\n\n addThemingController(this, all);\n }\n\n /** The column set the current row renderer was built from. */\n private _rowColumns?: ColumnConfiguration<T>[];\n\n protected override willUpdate(props: PropertyValues<this>): void {\n const { columns } = this._stateController;\n\n this._domController.setColumns(columns);\n\n // The ARIA grid pattern counts the header rows in the row count. Only visible\n // columns take part in the column index space.\n this._a11y.set({\n ariaRowCount: `${headerRowsFor(columns) + this._dataState.length}`,\n ariaColCount: `${columns.filter((column) => !column.hidden).length}`,\n });\n\n // The virtualizer re-renders its rows only when `renderItem` changes identity.\n // Build a new renderer only when a row input changes.\n if (columns !== this._rowColumns || props.has('adoptRootStyles')) {\n this._rowColumns = columns;\n this._renderRow = this._createRowRenderer(columns);\n }\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 }\n\n /** The column elements assigned to the slot, either direct or nested in a container. */\n private _assignedColumns(): Element[] {\n const slot = this.renderRoot.querySelector('slot') as HTMLSlotElement;\n const tag = IgcGridLiteColumn.tagName;\n\n return slot\n .assignedElements({ flatten: true })\n .flatMap((el) => (el.matches(tag) ? el : Array.from(el.querySelectorAll(tag))));\n }\n\n private _hasAssignedColumns(): boolean {\n return this._assignedColumns().length > 0;\n }\n\n private _handleSlotChange(): void {\n this._stateController.setColumnConfiguration(\n this._assignedColumns() 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 // Store copies. The caller's expression objects must not change.\n const expressions = asArray(config)\n .filter((expr) => this.getColumn(expr.key) !== undefined)\n .map((expr) => ({ ...expr }));\n\n for (const expr of expressions) {\n if (isString(expr.condition)) {\n expr.condition = resolveCondition(this.getColumn(expr.key)!, expr.condition);\n }\n }\n\n this._stateController.filtering.filter(expressions);\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 * Navigates to a position in the grid based on provided row index and column field.\n * @param row The row index to navigate to\n * @param options The column field to navigate to and whether to activate the cell\n */\n public async navigateTo(row: number, options?: NavigateToOptions<T>): Promise<void>;\n /**\n * Navigates to a position in the grid based on provided row index and column field.\n * @param row The row index to navigate to\n * @param column The column field to navigate to, if any\n * @param activate Optionally also activate the navigated cell\n * @deprecated Use `navigateTo(row, options)` instead.\n */\n public async navigateTo(row: number, column?: Keys<T>, activate?: boolean): Promise<void>;\n public async navigateTo(\n row: number,\n columnOrOptions?: Keys<T> | NavigateToOptions<T>,\n activate?: boolean\n ): Promise<void> {\n // Normalize the deprecated positional form into options.\n const options =\n typeof columnOrOptions === 'object' ? columnOrOptions : { column: columnOrOptions, activate };\n\n await this._stateController.navigation.navigateTo(row, options);\n }\n\n /**\n * Returns a {@link ColumnConfiguration} for a given column.\n */\n public getColumn(id: Keys<T> | number): ColumnConfiguration<T> | undefined {\n const columns = this._stateController.columns;\n return isNumber(id) ? columns[id] : columns.find((column) => column.field === id);\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.field, row: target.row.index };\n\n // Move focus so that assistive technology announces the cell. Keep focus\n // where it is when the click landed on focusable templated content.\n if (!target.matches(FOCUS_WITHIN)) {\n target.focus({ preventScroll: true });\n }\n }\n }\n\n protected _bodyKeydownHandler(event: KeyboardEvent): void {\n const [origin] = event.composedPath();\n\n // Keys from the grid focus targets (the scroller and the focused cell) drive\n // navigation. Keys from templated content in a cell pass through.\n if (origin === this._domController.virtualizer || origin instanceof IgcGridLiteCell) {\n this._stateController.navigation.navigate(event);\n }\n }\n\n /** Rebuilt by {@link IgcGridLite.willUpdate} when a row input changes. */\n protected _renderRow: RenderItemFunction<T> = () => html``;\n\n private _createRowRenderer(columns: ColumnConfiguration<T>[]): RenderItemFunction<T> {\n // The active node is read live. Activation updates only the affected rows (see\n // NavigationController) and must not rebuild the renderer: a new renderer\n // identity makes the virtualizer re-render every visible row.\n return (item: T, index: number) => html`\n <igc-grid-lite-row\n part=\"row\"\n exportparts=\"cell\"\n style=${styleMap(this._domController.columnSizes)}\n .adoptRootStyles=${this.adoptRootStyles}\n .index=${index}\n .activeNode=${this._stateController.active}\n .data=${item}\n .columns=${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 .adoptRootStyles=${this.adoptRootStyles}\n .columns=${this._stateController.columns}\n ></igc-grid-lite-header-row>\n `;\n }\n\n protected _renderBody() {\n return html`\n <igc-grid-lite-virtualizer\n tabindex=\"0\"\n .items=${this._dataState}\n .renderItem=${this._renderRow}\n @click=${this._bodyClickHandler}\n @keydown=${this._bodyKeydownHandler}\n ></igc-grid-lite-virtualizer>\n `;\n }\n\n protected _renderFilterRow() {\n const filterable = this._stateController.columns.some((column) => column.filterable);\n\n // The filter row and its editors are registered on first use. A grid without\n // filterable columns does not load their custom element definitions.\n if (filterable) {\n IgcFilterRow.register();\n }\n\n return html`${cache(\n filterable\n ? html`<igc-grid-lite-filter-row\n style=${styleMap(this._domController.columnSizes)}\n ></igc-grid-lite-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;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
2
|
import type { ColumnConfiguration } from '../internal/types.js';
|
|
3
3
|
import IgcGridLiteHeader from './header.js';
|
|
4
4
|
export default class IgcGridLiteHeaderRow<T extends object> extends LitElement {
|
|
@@ -11,7 +11,6 @@ export default class IgcGridLiteHeaderRow<T extends object> extends LitElement {
|
|
|
11
11
|
get headers(): IgcGridLiteHeader<T>[];
|
|
12
12
|
constructor();
|
|
13
13
|
private _setActiveFilterColumn;
|
|
14
|
-
protected shouldUpdate(props: PropertyValues<this>): boolean;
|
|
15
14
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
16
15
|
}
|
|
17
16
|
declare global {
|
package/components/header-row.js
CHANGED
|
@@ -8,6 +8,7 @@ import { consume } from '@lit/context';
|
|
|
8
8
|
import { html, LitElement } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
10
|
import { repeat } from 'lit/directives/repeat.js';
|
|
11
|
+
import { addA11y, HEADER_ROW_INDEX } from '../internal/a11y.js';
|
|
11
12
|
import { GRID_STATE_CONTEXT } from '../internal/context.js';
|
|
12
13
|
import { getElementFromEventPath } from '../internal/element-from-event-path.js';
|
|
13
14
|
import { partMap } from '../internal/part-map.js';
|
|
@@ -30,27 +31,23 @@ export default class IgcGridLiteHeaderRow extends LitElement {
|
|
|
30
31
|
super();
|
|
31
32
|
this.adoptRootStyles = false;
|
|
32
33
|
this.columns = [];
|
|
34
|
+
addA11y(this, 'row').set({ ariaRowIndex: `${HEADER_ROW_INDEX}` });
|
|
33
35
|
this.addEventListener('click', this._setActiveFilterColumn);
|
|
34
36
|
}
|
|
35
37
|
_setActiveFilterColumn(event) {
|
|
36
38
|
const header = getElementFromEventPath(IgcGridLiteHeader.tagName, event);
|
|
37
39
|
this._state?.filtering.setActiveColumn(header?.column);
|
|
38
40
|
}
|
|
39
|
-
shouldUpdate(props) {
|
|
40
|
-
for (const header of this.headers) {
|
|
41
|
-
header.requestUpdate();
|
|
42
|
-
}
|
|
43
|
-
return super.shouldUpdate(props);
|
|
44
|
-
}
|
|
45
41
|
render() {
|
|
46
42
|
const filterRow = this._state?.filtering.filterRow;
|
|
47
43
|
const columns = this.columns.filter((column) => !column.hidden);
|
|
48
44
|
return html `
|
|
49
|
-
${repeat(columns, (column) => column, (column) => html `
|
|
45
|
+
${repeat(columns, (column) => column.field, (column, index) => html `
|
|
50
46
|
<igc-grid-lite-header
|
|
51
47
|
part=${partMap({ filtered: column.field === filterRow?.column?.field })}
|
|
52
48
|
.adoptRootStyles=${this.adoptRootStyles}
|
|
53
49
|
.column=${column}
|
|
50
|
+
._colIndex=${index + 1}
|
|
54
51
|
></igc-grid-lite-header>
|
|
55
52
|
`)}
|
|
56
53
|
`;
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"header-row.js","sourceRoot":"","sources":["../../src/components/header-row.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAA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AgB,CAAC,OAAO,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC9D,CAAC;IAEO,sBAAsB,CAAC,KAAmB;QAChD,MAAM,MAAM,GAAG,uBAAuB,CAAuB,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC/F,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAEkB,MAAM;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC;QACnD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEhE,OAAO,IAAI,CAAA;QACP,MAAM,CACN,OAAO,EACP,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EACxB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAA;;mBAEZ,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;+BACpD,IAAI,CAAC,eAAe;sBAC7B,MAAM;yBACH,KAAK,GAAG,CAAC;;SAEzB,CACF;KACF,CAAC;IACJ,CAAC;;AA5CgB;IADhB,OAAO,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;oDACb;AAGtC;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;6DACA;AAGxB;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACe","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport type { StateController } from '../controllers/state.js';\nimport { addA11y, HEADER_ROW_INDEX } from '../internal/a11y.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 adoptRootStyles = false;\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\n addA11y(this, 'row').set({ ariaRowIndex: `${HEADER_ROW_INDEX}` });\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 render() {\n const filterRow = this._state?.filtering.filterRow;\n const columns = this.columns.filter((column) => !column.hidden);\n\n return html`\n ${repeat(\n columns,\n (column) => column.field,\n (column, index) => html`\n <igc-grid-lite-header\n part=${partMap({ filtered: column.field === filterRow?.column?.field })}\n .adoptRootStyles=${this.adoptRootStyles}\n .column=${column}\n ._colIndex=${index + 1}\n ></igc-grid-lite-header>\n `\n )}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [IgcGridLiteHeaderRow.tagName]: IgcGridLiteHeaderRow<object>;\n }\n}\n"]}
|