igniteui-grid-lite 0.0.1
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/LICENSE +9 -0
- package/README.md +17 -0
- package/components/cell.d.ts +35 -0
- package/components/cell.js +47 -0
- package/components/cell.js.map +1 -0
- package/components/filter-row.d.ts +47 -0
- package/components/filter-row.js +313 -0
- package/components/filter-row.js.map +1 -0
- package/components/grid.d.ts +226 -0
- package/components/grid.js +227 -0
- package/components/grid.js.map +1 -0
- package/components/header-row.d.ts +23 -0
- package/components/header-row.js +72 -0
- package/components/header-row.js.map +1 -0
- package/components/header.d.ts +23 -0
- package/components/header.js +137 -0
- package/components/header.js.map +1 -0
- package/components/row.d.ts +24 -0
- package/components/row.js +64 -0
- package/components/row.js.map +1 -0
- package/components/virtualizer.d.ts +12 -0
- package/components/virtualizer.js +21 -0
- package/components/virtualizer.js.map +1 -0
- package/controllers/data-operation.d.ts +17 -0
- package/controllers/data-operation.js +36 -0
- package/controllers/data-operation.js.map +1 -0
- package/controllers/dom.d.ts +19 -0
- package/controllers/dom.js +54 -0
- package/controllers/dom.js.map +1 -0
- package/controllers/filter.d.ts +21 -0
- package/controllers/filter.js +105 -0
- package/controllers/filter.js.map +1 -0
- package/controllers/navigation.d.ts +27 -0
- package/controllers/navigation.js +98 -0
- package/controllers/navigation.js.map +1 -0
- package/controllers/resize.d.ts +27 -0
- package/controllers/resize.js +52 -0
- package/controllers/resize.js.map +1 -0
- package/controllers/sort.d.ts +15 -0
- package/controllers/sort.js +94 -0
- package/controllers/sort.js.map +1 -0
- package/controllers/state.d.ts +24 -0
- package/controllers/state.js +37 -0
- package/controllers/state.js.map +1 -0
- package/custom-elements.json +4166 -0
- package/define.d.ts +2 -0
- package/define.js +4 -0
- package/define.js.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +71 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1633 -0
- package/docs/classes/IgcGridLite.html +74 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +11 -0
- package/docs/interfaces/BaseColumnConfiguration.html +28 -0
- package/docs/interfaces/BaseColumnSortConfiguration.html +6 -0
- package/docs/interfaces/BaseFilterExpression.html +15 -0
- package/docs/interfaces/BaseIgcCellContext.html +10 -0
- package/docs/interfaces/BaseSortExpression.html +12 -0
- package/docs/interfaces/ColumnFilterConfiguration.html +4 -0
- package/docs/interfaces/DataPipelineConfiguration.html +6 -0
- package/docs/interfaces/GridSortConfiguration.html +6 -0
- package/docs/interfaces/IgcFilteredEvent.html +6 -0
- package/docs/interfaces/IgcFilteringEvent.html +12 -0
- package/docs/interfaces/IgcGridLiteEventMap.html +17 -0
- package/docs/interfaces/IgcHeaderContext.html +6 -0
- package/docs/modules.html +1 -0
- package/docs/types/BasePropertyType.html +2 -0
- package/docs/types/BaseSortComparer.html +2 -0
- package/docs/types/ColumnConfiguration.html +2 -0
- package/docs/types/ColumnSortConfiguration.html +2 -0
- package/docs/types/DataPipelineHook.html +2 -0
- package/docs/types/DataPipelineParams.html +8 -0
- package/docs/types/DataType.html +2 -0
- package/docs/types/FilterCriteria.html +6 -0
- package/docs/types/FilterExpression.html +2 -0
- package/docs/types/IgcCellContext.html +2 -0
- package/docs/types/Keys.html +2 -0
- package/docs/types/PropertyType.html +2 -0
- package/docs/types/SortComparer.html +2 -0
- package/docs/types/SortExpression.html +2 -0
- package/docs/types/SortState.html +2 -0
- package/docs/types/SortingDirection.html +3 -0
- package/index.d.ts +8 -0
- package/index.js +5 -0
- package/index.js.map +1 -0
- package/internal/constants.d.ts +8 -0
- package/internal/constants.js +19 -0
- package/internal/constants.js.map +1 -0
- package/internal/icon-registry.d.ts +1 -0
- package/internal/icon-registry.js +29 -0
- package/internal/icon-registry.js.map +1 -0
- package/internal/is-defined.d.ts +1 -0
- package/internal/is-defined.js +4 -0
- package/internal/is-defined.js.map +1 -0
- package/internal/mixins/event-emitter.d.ts +7 -0
- package/internal/mixins/event-emitter.js +18 -0
- package/internal/mixins/event-emitter.js.map +1 -0
- package/internal/normalize-case.d.ts +1 -0
- package/internal/normalize-case.js +4 -0
- package/internal/normalize-case.js.map +1 -0
- package/internal/part-map.d.ts +4 -0
- package/internal/part-map.js +6 -0
- package/internal/part-map.js.map +1 -0
- package/internal/register.d.ts +6 -0
- package/internal/register.js +9 -0
- package/internal/register.js.map +1 -0
- package/internal/tags.d.ts +7 -0
- package/internal/tags.js +8 -0
- package/internal/tags.js.map +1 -0
- package/internal/theming.d.ts +34 -0
- package/internal/theming.js +123 -0
- package/internal/theming.js.map +1 -0
- package/internal/types.d.ts +198 -0
- package/internal/types.js +2 -0
- package/internal/types.js.map +1 -0
- package/internal/utils.d.ts +6 -0
- package/internal/utils.js +34 -0
- package/internal/utils.js.map +1 -0
- package/internal/watch.d.ts +5 -0
- package/internal/watch.js +19 -0
- package/internal/watch.js.map +1 -0
- package/operations/base.d.ts +6 -0
- package/operations/base.js +9 -0
- package/operations/base.js.map +1 -0
- package/operations/filter/operands/boolean.d.ts +3 -0
- package/operations/filter/operands/boolean.js +34 -0
- package/operations/filter/operands/boolean.js.map +1 -0
- package/operations/filter/operands/number.d.ts +3 -0
- package/operations/filter/operands/number.js +52 -0
- package/operations/filter/operands/number.js.map +1 -0
- package/operations/filter/operands/string.d.ts +3 -0
- package/operations/filter/operands/string.js +53 -0
- package/operations/filter/operands/string.js.map +1 -0
- package/operations/filter/state.d.ts +16 -0
- package/operations/filter/state.js +41 -0
- package/operations/filter/state.js.map +1 -0
- package/operations/filter/tree.d.ts +17 -0
- package/operations/filter/tree.js +46 -0
- package/operations/filter/tree.js.map +1 -0
- package/operations/filter/types.d.ts +57 -0
- package/operations/filter/types.js +2 -0
- package/operations/filter/types.js.map +1 -0
- package/operations/filter.d.ts +8 -0
- package/operations/filter.js +22 -0
- package/operations/filter.js.map +1 -0
- package/operations/sort/types.d.ts +49 -0
- package/operations/sort/types.js +2 -0
- package/operations/sort/types.js.map +1 -0
- package/operations/sort.d.ts +8 -0
- package/operations/sort.js +37 -0
- package/operations/sort.js.map +1 -0
- package/package.json +41 -0
- package/styles/_common.css.d.ts +1 -0
- package/styles/_common.css.js +3 -0
- package/styles/_common.css.js.map +1 -0
- package/styles/body-cell/body-cell.css.d.ts +1 -0
- package/styles/body-cell/body-cell.css.js +3 -0
- package/styles/body-cell/body-cell.css.js.map +1 -0
- package/styles/body-row/body-row.css.d.ts +1 -0
- package/styles/body-row/body-row.css.js +3 -0
- package/styles/body-row/body-row.css.js.map +1 -0
- package/styles/filter-row/filter-row.css.d.ts +1 -0
- package/styles/filter-row/filter-row.css.js +3 -0
- package/styles/filter-row/filter-row.css.js.map +1 -0
- package/styles/grid/themes/dark/grid.bootstrap.css.d.ts +1 -0
- package/styles/grid/themes/dark/grid.bootstrap.css.js +3 -0
- package/styles/grid/themes/dark/grid.bootstrap.css.js.map +1 -0
- package/styles/grid/themes/dark/grid.fluent.css.d.ts +1 -0
- package/styles/grid/themes/dark/grid.fluent.css.js +3 -0
- package/styles/grid/themes/dark/grid.fluent.css.js.map +1 -0
- package/styles/grid/themes/dark/grid.indigo.css.d.ts +1 -0
- package/styles/grid/themes/dark/grid.indigo.css.js +3 -0
- package/styles/grid/themes/dark/grid.indigo.css.js.map +1 -0
- package/styles/grid/themes/dark/grid.material.css.d.ts +1 -0
- package/styles/grid/themes/dark/grid.material.css.js +3 -0
- package/styles/grid/themes/dark/grid.material.css.js.map +1 -0
- package/styles/grid/themes/grid.base.css.d.ts +1 -0
- package/styles/grid/themes/grid.base.css.js +3 -0
- package/styles/grid/themes/grid.base.css.js.map +1 -0
- package/styles/grid/themes/light/grid.bootstrap.css.d.ts +1 -0
- package/styles/grid/themes/light/grid.bootstrap.css.js +3 -0
- package/styles/grid/themes/light/grid.bootstrap.css.js.map +1 -0
- package/styles/grid/themes/light/grid.fluent.css.d.ts +1 -0
- package/styles/grid/themes/light/grid.fluent.css.js +3 -0
- package/styles/grid/themes/light/grid.fluent.css.js.map +1 -0
- package/styles/grid/themes/light/grid.indigo.css.d.ts +1 -0
- package/styles/grid/themes/light/grid.indigo.css.js +3 -0
- package/styles/grid/themes/light/grid.indigo.css.js.map +1 -0
- package/styles/grid/themes/light/grid.material.css.d.ts +1 -0
- package/styles/grid/themes/light/grid.material.css.js +3 -0
- package/styles/grid/themes/light/grid.material.css.js.map +1 -0
- package/styles/grid/themes/themes.d.ts +2 -0
- package/styles/grid/themes/themes.js +39 -0
- package/styles/grid/themes/themes.js.map +1 -0
- package/styles/header-cell/header-cell.css.d.ts +1 -0
- package/styles/header-cell/header-cell.css.js +3 -0
- package/styles/header-cell/header-cell.css.js.map +1 -0
- package/styles/header-row/header-row.base.css.d.ts +1 -0
- package/styles/header-row/header-row.base.css.js +3 -0
- package/styles/header-row/header-row.base.css.js.map +1 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { ContextProvider } from '@lit/context';
|
|
2
|
+
import { nothing } from 'lit';
|
|
3
|
+
import { DataOperationsController } from '../controllers/data-operation.js';
|
|
4
|
+
import { GridDOMController } from '../controllers/dom.js';
|
|
5
|
+
import { StateController } from '../controllers/state.js';
|
|
6
|
+
import { EventEmitterBase } from '../internal/mixins/event-emitter.js';
|
|
7
|
+
import type { ColumnConfiguration, DataPipelineConfiguration, GridSortConfiguration, Keys } from '../internal/types.js';
|
|
8
|
+
import type { FilterExpression } from '../operations/filter/types.js';
|
|
9
|
+
import type { SortExpression } from '../operations/sort/types.js';
|
|
10
|
+
import IgcFilterRow from './filter-row.js';
|
|
11
|
+
import IgcGridLiteHeaderRow from './header-row.js';
|
|
12
|
+
import IgcGridLiteRow from './row.js';
|
|
13
|
+
import IgcVirtualizer from './virtualizer.js';
|
|
14
|
+
/**
|
|
15
|
+
* Event object for the filtering event of the grid.
|
|
16
|
+
*/
|
|
17
|
+
export interface IgcFilteringEvent<T extends object> {
|
|
18
|
+
/**
|
|
19
|
+
* The target column for the filter operation.
|
|
20
|
+
*/
|
|
21
|
+
key: Keys<T>;
|
|
22
|
+
/**
|
|
23
|
+
* The filter expression(s) to apply.
|
|
24
|
+
*/
|
|
25
|
+
expressions: FilterExpression<T>[];
|
|
26
|
+
/**
|
|
27
|
+
* The type of modification which will be applied to the filter
|
|
28
|
+
* state of the column.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* `add` - a new filter expression will be added to the state of the column.
|
|
32
|
+
* `modify` - an existing filter expression will be modified.
|
|
33
|
+
* `remove` - the expression(s) will be removed from the state of the column.
|
|
34
|
+
*/
|
|
35
|
+
type: 'add' | 'modify' | 'remove';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Event object for the filtered event of the grid.
|
|
39
|
+
*/
|
|
40
|
+
export interface IgcFilteredEvent<T extends object> {
|
|
41
|
+
/**
|
|
42
|
+
* The target column for the filter operation.
|
|
43
|
+
*/
|
|
44
|
+
key: Keys<T>;
|
|
45
|
+
/**
|
|
46
|
+
* The filter state of the column after the operation.
|
|
47
|
+
*/
|
|
48
|
+
state: FilterExpression<T>[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Events for the igc-grid-lite.
|
|
52
|
+
*/
|
|
53
|
+
export interface IgcGridLiteEventMap<T extends object> {
|
|
54
|
+
/**
|
|
55
|
+
* Emitted when sorting is initiated through the UI.
|
|
56
|
+
* Returns the sort expression which will be used for the operation.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* The event is cancellable which prevents the operation from being applied.
|
|
60
|
+
* The expression can be modified prior to the operation running.
|
|
61
|
+
*
|
|
62
|
+
* @event
|
|
63
|
+
*/
|
|
64
|
+
sorting: CustomEvent<SortExpression<T>>;
|
|
65
|
+
/**
|
|
66
|
+
* Emitted when a sort operation initiated through the UI has completed.
|
|
67
|
+
* Returns the sort expression used for the operation.
|
|
68
|
+
*
|
|
69
|
+
* @event
|
|
70
|
+
*/
|
|
71
|
+
sorted: CustomEvent<SortExpression<T>>;
|
|
72
|
+
/**
|
|
73
|
+
* Emitted when filtering is initiated through the UI.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* The event is cancellable which prevents the operation from being applied.
|
|
77
|
+
* The expression can be modified prior to the operation running.
|
|
78
|
+
*
|
|
79
|
+
* @event
|
|
80
|
+
*/
|
|
81
|
+
filtering: CustomEvent<IgcFilteringEvent<T>>;
|
|
82
|
+
/**
|
|
83
|
+
* Emitted when a filter operation initiated through the UI has completed.
|
|
84
|
+
* Returns the filter state for the affected column.
|
|
85
|
+
*
|
|
86
|
+
* @event
|
|
87
|
+
*/
|
|
88
|
+
filtered: CustomEvent<IgcFilteredEvent<T>>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* IgcGridLite is a web component for displaying data in a tabular format quick and easy.
|
|
92
|
+
*
|
|
93
|
+
* Out of the box it provides row virtualization, sort and filter operations (client and server side),
|
|
94
|
+
* the ability to template cells and headers and column hiding.
|
|
95
|
+
*
|
|
96
|
+
* @element igc-grid-lite
|
|
97
|
+
*
|
|
98
|
+
* @fires sorting - Emitted when sorting is initiated through the UI.
|
|
99
|
+
* @fires sorted - Emitted when a sort operation initiated through the UI has completed.
|
|
100
|
+
* @fires filtering - Emitted when filtering is initiated through the UI.
|
|
101
|
+
* @fires filtered - Emitted when a filter operation initiated through the UI has completed.
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
export declare class IgcGridLite<T extends object> extends EventEmitterBase<IgcGridLiteEventMap<T>> {
|
|
105
|
+
static get tagName(): "igc-grid-lite";
|
|
106
|
+
static styles: import("lit").CSSResult;
|
|
107
|
+
static register(): void;
|
|
108
|
+
protected stateController: StateController<T>;
|
|
109
|
+
protected DOM: GridDOMController<T>;
|
|
110
|
+
protected dataController: DataOperationsController<T>;
|
|
111
|
+
protected stateProvider: ContextProvider<{
|
|
112
|
+
__context__: StateController<any>;
|
|
113
|
+
}, this>;
|
|
114
|
+
protected scrollContainer: IgcVirtualizer;
|
|
115
|
+
protected headerRow: IgcGridLiteHeaderRow<T>;
|
|
116
|
+
protected filterRow: IgcFilterRow<T>;
|
|
117
|
+
protected dataState: Array<T>;
|
|
118
|
+
protected _rows: NodeListOf<IgcGridLiteRow<T>>;
|
|
119
|
+
/** Column configuration for the grid. */
|
|
120
|
+
columns: Array<ColumnConfiguration<T>>;
|
|
121
|
+
/** The data source for the grid. */
|
|
122
|
+
data: Array<T>;
|
|
123
|
+
/**
|
|
124
|
+
* Whether the grid will try to "resolve" its column configuration based on the passed
|
|
125
|
+
* data source.
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* This is usually executed on initial rendering in the DOM. It depends on having an existing data source
|
|
129
|
+
* to infer the column configuration for the grid.
|
|
130
|
+
* Passing an empty data source or having a late bound data source (such as a HTTP request) will usually
|
|
131
|
+
* result in empty column configuration for the grid.
|
|
132
|
+
*
|
|
133
|
+
* This property is ignored if any existing column configuration already exists in the grid.
|
|
134
|
+
*
|
|
135
|
+
* In a scenario where you want to bind a new data source and still keep the auto-generation behavior,
|
|
136
|
+
* make sure to reset the column collection of the grid before passing in the new data source.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* // assuming autoGenerate is set to true
|
|
141
|
+
* grid.columns = [];
|
|
142
|
+
* grid.data = [...];
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @attr auto-generate
|
|
146
|
+
*/
|
|
147
|
+
autoGenerate: boolean;
|
|
148
|
+
/** Sort configuration property for the grid. */
|
|
149
|
+
sortConfiguration: GridSortConfiguration;
|
|
150
|
+
/**
|
|
151
|
+
* Configuration object which controls remote data operations for the grid.
|
|
152
|
+
*/
|
|
153
|
+
dataPipelineConfiguration: DataPipelineConfiguration<T>;
|
|
154
|
+
/**
|
|
155
|
+
* Set the sort state for the grid.
|
|
156
|
+
*/
|
|
157
|
+
set sortExpressions(expressions: SortExpression<T>[]);
|
|
158
|
+
/**
|
|
159
|
+
* Get the sort state for the grid.
|
|
160
|
+
*/
|
|
161
|
+
get sortExpressions(): SortExpression<T>[];
|
|
162
|
+
/**
|
|
163
|
+
* Set the filter state for the grid.
|
|
164
|
+
*/
|
|
165
|
+
set filterExpressions(expressions: FilterExpression<T>[]);
|
|
166
|
+
/**
|
|
167
|
+
* Get the filter state for the grid.
|
|
168
|
+
*/
|
|
169
|
+
get filterExpressions(): FilterExpression<T>[];
|
|
170
|
+
/**
|
|
171
|
+
* Returns the collection of rendered row elements in the grid.
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* Since the grid has virtualization, this property returns only the currently rendered
|
|
175
|
+
* chunk of elements in the DOM.
|
|
176
|
+
*/
|
|
177
|
+
get rows(): IgcGridLiteRow<T>[];
|
|
178
|
+
/**
|
|
179
|
+
* Returns the state of the data source after sort/filter operations
|
|
180
|
+
* have been applied.
|
|
181
|
+
*/
|
|
182
|
+
get dataView(): ReadonlyArray<T>;
|
|
183
|
+
/**
|
|
184
|
+
* The total number of items in the {@link IgcGridLite.dataView} collection.
|
|
185
|
+
*/
|
|
186
|
+
get totalItems(): number;
|
|
187
|
+
protected watchColumns(_: ColumnConfiguration<T>[], newConfig?: ColumnConfiguration<T>[]): void;
|
|
188
|
+
protected dataChanged(): void;
|
|
189
|
+
protected pipeline(): Promise<void>;
|
|
190
|
+
constructor();
|
|
191
|
+
/**
|
|
192
|
+
* Performs a filter operation in the grid based on the passed expression(s).
|
|
193
|
+
*/
|
|
194
|
+
filter(config: FilterExpression<T> | FilterExpression<T>[]): void;
|
|
195
|
+
/**
|
|
196
|
+
* Performs a sort operation in the grid based on the passed expression(s).
|
|
197
|
+
*/
|
|
198
|
+
sort(expressions: SortExpression<T> | SortExpression<T>[]): void;
|
|
199
|
+
/**
|
|
200
|
+
* Resets the current sort state of the control.
|
|
201
|
+
*/
|
|
202
|
+
clearSort(key?: Keys<T>): void;
|
|
203
|
+
/**
|
|
204
|
+
* Resets the current filter state of the control.
|
|
205
|
+
*/
|
|
206
|
+
clearFilter(key?: Keys<T>): void;
|
|
207
|
+
/**
|
|
208
|
+
* Returns a {@link ColumnConfiguration} for a given column.
|
|
209
|
+
*/
|
|
210
|
+
getColumn(id: Keys<T> | number): ColumnConfiguration<T> | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* Updates the column configuration of the grid.
|
|
213
|
+
*/
|
|
214
|
+
updateColumns(columns: ColumnConfiguration<T> | ColumnConfiguration<T>[]): void;
|
|
215
|
+
protected bodyClickHandler(event: MouseEvent): void;
|
|
216
|
+
protected bodyKeydownHandler(event: KeyboardEvent): void;
|
|
217
|
+
protected renderHeaderRow(): import("lit-html").TemplateResult<1>;
|
|
218
|
+
protected renderBody(): import("lit-html").TemplateResult<1>;
|
|
219
|
+
protected renderFilterRow(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
220
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
221
|
+
}
|
|
222
|
+
declare global {
|
|
223
|
+
interface HTMLElementTagNameMap {
|
|
224
|
+
[IgcGridLite.tagName]: IgcGridLite<object>;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { ContextProvider } from '@lit/context';
|
|
8
|
+
import { IgcButtonComponent, IgcChipComponent, IgcDropdownComponent, IgcInputComponent, } from 'igniteui-webcomponents';
|
|
9
|
+
import { html, nothing } from 'lit';
|
|
10
|
+
import { eventOptions, property, query, queryAll, state } from 'lit/decorators.js';
|
|
11
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
12
|
+
import { DataOperationsController } from '../controllers/data-operation.js';
|
|
13
|
+
import { GridDOMController } from '../controllers/dom.js';
|
|
14
|
+
import { gridStateContext, StateController } from '../controllers/state.js';
|
|
15
|
+
import { DEFAULT_COLUMN_CONFIG, PIPELINE } from '../internal/constants.js';
|
|
16
|
+
import { EventEmitterBase } from '../internal/mixins/event-emitter.js';
|
|
17
|
+
import { registerComponent } from '../internal/register.js';
|
|
18
|
+
import { GRID_TAG } from '../internal/tags.js';
|
|
19
|
+
import { addThemingController } from '../internal/theming.js';
|
|
20
|
+
import { asArray, autoGenerateColumns, getFilterOperandsFor } from '../internal/utils.js';
|
|
21
|
+
import { watch } from '../internal/watch.js';
|
|
22
|
+
import { styles } from '../styles/grid/themes/grid.base.css.js';
|
|
23
|
+
import { all } from '../styles/grid/themes/themes.js';
|
|
24
|
+
import IgcGridLiteCell from './cell.js';
|
|
25
|
+
import IgcFilterRow from './filter-row.js';
|
|
26
|
+
import IgcGridLiteHeaderRow from './header-row.js';
|
|
27
|
+
import IgcGridLiteRow from './row.js';
|
|
28
|
+
import IgcVirtualizer from './virtualizer.js';
|
|
29
|
+
export class IgcGridLite extends EventEmitterBase {
|
|
30
|
+
static get tagName() {
|
|
31
|
+
return GRID_TAG;
|
|
32
|
+
}
|
|
33
|
+
static { this.styles = styles; }
|
|
34
|
+
static register() {
|
|
35
|
+
registerComponent(IgcGridLite, IgcVirtualizer, IgcGridLiteRow, IgcGridLiteHeaderRow, IgcFilterRow, IgcButtonComponent, IgcChipComponent, IgcInputComponent, IgcDropdownComponent);
|
|
36
|
+
}
|
|
37
|
+
set sortExpressions(expressions) {
|
|
38
|
+
if (expressions.length) {
|
|
39
|
+
this.sort(expressions);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
get sortExpressions() {
|
|
43
|
+
return Array.from(this.stateController.sorting.state.values());
|
|
44
|
+
}
|
|
45
|
+
set filterExpressions(expressions) {
|
|
46
|
+
if (expressions.length) {
|
|
47
|
+
this.filter(expressions);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
get filterExpressions() {
|
|
51
|
+
const expressions = [];
|
|
52
|
+
for (const each of this.stateController.filtering.state.values) {
|
|
53
|
+
expressions.push(...each.all);
|
|
54
|
+
}
|
|
55
|
+
return expressions;
|
|
56
|
+
}
|
|
57
|
+
get rows() {
|
|
58
|
+
return Array.from(this._rows);
|
|
59
|
+
}
|
|
60
|
+
get dataView() {
|
|
61
|
+
return this.dataState;
|
|
62
|
+
}
|
|
63
|
+
get totalItems() {
|
|
64
|
+
return this.dataState.length;
|
|
65
|
+
}
|
|
66
|
+
watchColumns(_, newConfig = []) {
|
|
67
|
+
this.columns = newConfig.map((config) => ({ ...DEFAULT_COLUMN_CONFIG, ...config }));
|
|
68
|
+
}
|
|
69
|
+
dataChanged() {
|
|
70
|
+
this.dataState = structuredClone(this.data);
|
|
71
|
+
autoGenerateColumns(this);
|
|
72
|
+
if (this.hasUpdated) {
|
|
73
|
+
this.pipeline();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async pipeline() {
|
|
77
|
+
this.dataState = await this.dataController.apply(structuredClone(this.data), this.stateController);
|
|
78
|
+
}
|
|
79
|
+
constructor() {
|
|
80
|
+
super();
|
|
81
|
+
this.stateController = new StateController(this);
|
|
82
|
+
this.DOM = new GridDOMController(this, this.stateController);
|
|
83
|
+
this.dataController = new DataOperationsController(this);
|
|
84
|
+
this.stateProvider = new ContextProvider(this, {
|
|
85
|
+
context: gridStateContext,
|
|
86
|
+
initialValue: this.stateController,
|
|
87
|
+
});
|
|
88
|
+
this.dataState = [];
|
|
89
|
+
this.columns = [];
|
|
90
|
+
this.data = [];
|
|
91
|
+
this.autoGenerate = false;
|
|
92
|
+
this.sortConfiguration = {
|
|
93
|
+
multiple: true,
|
|
94
|
+
triState: true,
|
|
95
|
+
};
|
|
96
|
+
addThemingController(this, all);
|
|
97
|
+
}
|
|
98
|
+
filter(config) {
|
|
99
|
+
this.stateController.filtering.filter(asArray(config).map((each) => typeof each.condition === 'string'
|
|
100
|
+
?
|
|
101
|
+
Object.assign(each, {
|
|
102
|
+
condition: getFilterOperandsFor(this.getColumn(each.key))[each.condition],
|
|
103
|
+
})
|
|
104
|
+
: each));
|
|
105
|
+
}
|
|
106
|
+
sort(expressions) {
|
|
107
|
+
this.stateController.sorting.sort(expressions);
|
|
108
|
+
}
|
|
109
|
+
clearSort(key) {
|
|
110
|
+
this.stateController.sorting.reset(key);
|
|
111
|
+
this.requestUpdate(PIPELINE);
|
|
112
|
+
}
|
|
113
|
+
clearFilter(key) {
|
|
114
|
+
this.stateController.filtering.reset(key);
|
|
115
|
+
this.requestUpdate(PIPELINE);
|
|
116
|
+
}
|
|
117
|
+
getColumn(id) {
|
|
118
|
+
return typeof id === 'number'
|
|
119
|
+
? this.columns.at(id)
|
|
120
|
+
: this.columns.find(({ key }) => key === id);
|
|
121
|
+
}
|
|
122
|
+
updateColumns(columns) {
|
|
123
|
+
for (const column of asArray(columns)) {
|
|
124
|
+
const instance = this.columns.find((curr) => curr.key === column.key);
|
|
125
|
+
if (instance) {
|
|
126
|
+
Object.assign(instance, column);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
this.requestUpdate(PIPELINE);
|
|
130
|
+
}
|
|
131
|
+
bodyClickHandler(event) {
|
|
132
|
+
const target = event
|
|
133
|
+
.composedPath()
|
|
134
|
+
.find((el) => el instanceof IgcGridLiteCell);
|
|
135
|
+
if (target) {
|
|
136
|
+
this.stateController.active = {
|
|
137
|
+
column: target.column.key,
|
|
138
|
+
row: target.row.index,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
bodyKeydownHandler(event) {
|
|
143
|
+
if (this.scrollContainer.isSameNode(event.target)) {
|
|
144
|
+
this.stateController.navigation.navigate(event);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
renderHeaderRow() {
|
|
148
|
+
return html `
|
|
149
|
+
<igc-grid-lite-header-row
|
|
150
|
+
style=${styleMap(this.DOM.columnSizes)}
|
|
151
|
+
.columns=${this.columns}
|
|
152
|
+
></igc-grid-lite-header-row>
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
renderBody() {
|
|
156
|
+
return html `
|
|
157
|
+
<igc-virtualizer
|
|
158
|
+
.items=${this.dataState}
|
|
159
|
+
.renderItem=${this.DOM.rowRenderer}
|
|
160
|
+
@click=${this.bodyClickHandler}
|
|
161
|
+
@keydown=${this.bodyKeydownHandler}
|
|
162
|
+
></igc-virtualizer>
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
renderFilterRow() {
|
|
166
|
+
return this.columns.some((column) => column.filter)
|
|
167
|
+
? html `<igc-filter-row style=${styleMap(this.DOM.columnSizes)}></igc-filter-row>`
|
|
168
|
+
: nothing;
|
|
169
|
+
}
|
|
170
|
+
render() {
|
|
171
|
+
return html `
|
|
172
|
+
${this.stateController.resizing.renderIndicator()}
|
|
173
|
+
${this.renderHeaderRow()}
|
|
174
|
+
${this.renderFilterRow()}
|
|
175
|
+
${this.renderBody()}
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
__decorate([
|
|
180
|
+
query(IgcVirtualizer.tagName)
|
|
181
|
+
], IgcGridLite.prototype, "scrollContainer", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
query(IgcGridLiteHeaderRow.tagName)
|
|
184
|
+
], IgcGridLite.prototype, "headerRow", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
query(IgcFilterRow.tagName)
|
|
187
|
+
], IgcGridLite.prototype, "filterRow", void 0);
|
|
188
|
+
__decorate([
|
|
189
|
+
state()
|
|
190
|
+
], IgcGridLite.prototype, "dataState", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
queryAll(IgcGridLiteRow.tagName)
|
|
193
|
+
], IgcGridLite.prototype, "_rows", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
property({ attribute: false })
|
|
196
|
+
], IgcGridLite.prototype, "columns", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
property({ attribute: false })
|
|
199
|
+
], IgcGridLite.prototype, "data", void 0);
|
|
200
|
+
__decorate([
|
|
201
|
+
property({ type: Boolean, attribute: 'auto-generate' })
|
|
202
|
+
], IgcGridLite.prototype, "autoGenerate", void 0);
|
|
203
|
+
__decorate([
|
|
204
|
+
property({ attribute: false })
|
|
205
|
+
], IgcGridLite.prototype, "sortConfiguration", void 0);
|
|
206
|
+
__decorate([
|
|
207
|
+
property({ attribute: false })
|
|
208
|
+
], IgcGridLite.prototype, "dataPipelineConfiguration", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
property({ attribute: false })
|
|
211
|
+
], IgcGridLite.prototype, "sortExpressions", null);
|
|
212
|
+
__decorate([
|
|
213
|
+
property({ attribute: false })
|
|
214
|
+
], IgcGridLite.prototype, "filterExpressions", null);
|
|
215
|
+
__decorate([
|
|
216
|
+
watch('columns')
|
|
217
|
+
], IgcGridLite.prototype, "watchColumns", null);
|
|
218
|
+
__decorate([
|
|
219
|
+
watch('data')
|
|
220
|
+
], IgcGridLite.prototype, "dataChanged", null);
|
|
221
|
+
__decorate([
|
|
222
|
+
watch(PIPELINE)
|
|
223
|
+
], IgcGridLite.prototype, "pipeline", null);
|
|
224
|
+
__decorate([
|
|
225
|
+
eventOptions({ capture: true })
|
|
226
|
+
], IgcGridLite.prototype, "bodyClickHandler", null);
|
|
227
|
+
//# sourceMappingURL=grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/components/grid.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;A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AS,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/grid/themes/grid.base.css.js';\nimport { all } from '../styles/grid/themes/themes.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;\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"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement, type PropertyValueMap } from 'lit';
|
|
2
|
+
import { type StateController } from '../controllers/state.js';
|
|
3
|
+
import type { ColumnConfiguration } from '../internal/types.js';
|
|
4
|
+
import IgcGridLiteHeader from './header.js';
|
|
5
|
+
export default class IgcGridLiteHeaderRow<T extends object> extends LitElement {
|
|
6
|
+
#private;
|
|
7
|
+
static get tagName(): "igc-grid-lite-header-row";
|
|
8
|
+
static styles: import("lit").CSSResult;
|
|
9
|
+
static register(): void;
|
|
10
|
+
protected _headers: NodeListOf<IgcGridLiteHeader<T>>;
|
|
11
|
+
state: StateController<T>;
|
|
12
|
+
columns: Array<ColumnConfiguration<T>>;
|
|
13
|
+
get headers(): IgcGridLiteHeader<T>[];
|
|
14
|
+
constructor();
|
|
15
|
+
connectedCallback(): void;
|
|
16
|
+
protected shouldUpdate(props: PropertyValueMap<this> | Map<PropertyKey, this>): boolean;
|
|
17
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
[IgcGridLiteHeaderRow.tagName]: IgcGridLiteHeaderRow<object>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { consume } from '@lit/context';
|
|
8
|
+
import { html, LitElement, nothing } from 'lit';
|
|
9
|
+
import { property, queryAll } from 'lit/decorators.js';
|
|
10
|
+
import { map } from 'lit/directives/map.js';
|
|
11
|
+
import { gridStateContext } from '../controllers/state.js';
|
|
12
|
+
import { partNameMap } from '../internal/part-map.js';
|
|
13
|
+
import { registerComponent } from '../internal/register.js';
|
|
14
|
+
import { GRID_HEADER_ROW_TAG } from '../internal/tags.js';
|
|
15
|
+
import { styles } from '../styles/header-row/header-row.base.css.js';
|
|
16
|
+
import IgcGridLiteHeader from './header.js';
|
|
17
|
+
export default class IgcGridLiteHeaderRow extends LitElement {
|
|
18
|
+
static get tagName() {
|
|
19
|
+
return GRID_HEADER_ROW_TAG;
|
|
20
|
+
}
|
|
21
|
+
static { this.styles = styles; }
|
|
22
|
+
static register() {
|
|
23
|
+
registerComponent(IgcGridLiteHeaderRow, IgcGridLiteHeader);
|
|
24
|
+
}
|
|
25
|
+
get headers() {
|
|
26
|
+
return Array.from(this._headers);
|
|
27
|
+
}
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this.columns = [];
|
|
31
|
+
this.addEventListener('click', this.#activeFilterColumn);
|
|
32
|
+
}
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
super.connectedCallback();
|
|
35
|
+
this.setAttribute('tabindex', '0');
|
|
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);
|
|
43
|
+
}
|
|
44
|
+
shouldUpdate(props) {
|
|
45
|
+
for (const header of this.headers) {
|
|
46
|
+
header.requestUpdate();
|
|
47
|
+
}
|
|
48
|
+
return super.shouldUpdate(props);
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
const filterRow = this.state.filtering.filterRow;
|
|
52
|
+
return html `${map(this.columns, (column) => column.hidden
|
|
53
|
+
? nothing
|
|
54
|
+
: html `<igc-grid-lite-header
|
|
55
|
+
part=${partNameMap({
|
|
56
|
+
filtered: column === filterRow?.column,
|
|
57
|
+
})}
|
|
58
|
+
.column=${column}
|
|
59
|
+
></igc-grid-lite-header>`)}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
__decorate([
|
|
63
|
+
queryAll(IgcGridLiteHeader.tagName)
|
|
64
|
+
], IgcGridLiteHeaderRow.prototype, "_headers", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
consume({ context: gridStateContext, subscribe: true }),
|
|
67
|
+
property({ attribute: false })
|
|
68
|
+
], IgcGridLiteHeaderRow.prototype, "state", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
property({ attribute: false })
|
|
71
|
+
], IgcGridLiteHeaderRow.prototype, "columns", void 0);
|
|
72
|
+
//# sourceMappingURL=header-row.js.map
|
|
@@ -0,0 +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,EAAyB,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAwB,MAAM,yBAAyB,CAAC;AACjF,OAAO,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C,MAAM,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC;QAED,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAEkB,MAAM;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC;QAEjD,OAAO,IAAI,CAAA,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CACzC,MAAM,CAAC,MAAM;YACX,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,IAAI,CAAA;mBACK,WAAW,CAAC;gBACjB,QAAQ,EAAE,MAAM,KAAK,SAAS,EAAE,MAAM;aACvC,CAAC;sBACQ,MAAM;mCACO,CAC9B,EAAE,CAAC;IACN,CAAC;;AArDS;IADT,QAAQ,CAAC,iBAAiB,CAAC,OAAO,CAAC;sDACkB;AAI/C;IAFN,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACvD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;mDACG;AAG3B;IADN,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACoB","sourcesContent":["import { consume } from '@lit/context';\nimport { html, LitElement, nothing, type PropertyValueMap } from 'lit';\nimport { property, queryAll } from 'lit/decorators.js';\nimport { map } from 'lit/directives/map.js';\nimport { gridStateContext, type StateController } from '../controllers/state.js';\nimport { partNameMap } 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 @queryAll(IgcGridLiteHeader.tagName)\n protected _headers!: NodeListOf<IgcGridLiteHeader<T>>;\n\n @consume({ context: gridStateContext, subscribe: true })\n @property({ attribute: false })\n public state!: StateController<T>;\n\n @property({ attribute: false })\n public columns: Array<ColumnConfiguration<T>> = [];\n\n public get headers() {\n return Array.from(this._headers);\n }\n\n constructor() {\n super();\n this.addEventListener('click', this.#activeFilterColumn);\n }\n\n public override connectedCallback() {\n super.connectedCallback();\n this.setAttribute('tabindex', '0');\n }\n\n #activeFilterColumn(event: MouseEvent) {\n const header = event\n .composedPath()\n .filter((target) => target instanceof IgcGridLiteHeader)\n .at(0) as IgcGridLiteHeader<T>;\n\n this.state.filtering.setActiveColumn(header?.column);\n }\n\n protected override shouldUpdate(props: PropertyValueMap<this> | Map<PropertyKey, 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`<igc-grid-lite-header\n part=${partNameMap({\n filtered: column === filterRow?.column,\n })}\n .column=${column}\n ></igc-grid-lite-header>`\n )}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [IgcGridLiteHeaderRow.tagName]: IgcGridLiteHeaderRow<object>;\n }\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement, nothing } from 'lit';
|
|
2
|
+
import { type StateController } from '../controllers/state.js';
|
|
3
|
+
import type { ColumnConfiguration, IgcHeaderContext } from '../internal/types.js';
|
|
4
|
+
export default class IgcGridLiteHeader<T extends object> extends LitElement {
|
|
5
|
+
#private;
|
|
6
|
+
static get tagName(): "igc-grid-lite-header";
|
|
7
|
+
static styles: import("lit").CSSResult;
|
|
8
|
+
static register(): void;
|
|
9
|
+
protected get context(): IgcHeaderContext<T>;
|
|
10
|
+
protected get isSortable(): boolean;
|
|
11
|
+
protected get resizeController(): import("../controllers/resize.js").ResizeController<T>;
|
|
12
|
+
state: StateController<T>;
|
|
13
|
+
column: ColumnConfiguration<T>;
|
|
14
|
+
protected renderSortPart(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
15
|
+
protected renderContentPart(): import("lit-html").TemplateResult<1>;
|
|
16
|
+
protected renderResizePart(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
17
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
[IgcGridLiteHeader.tagName]: IgcGridLiteHeader<object>;
|
|
22
|
+
}
|
|
23
|
+
}
|