@vaadin/grid 24.3.0-alpha1 → 24.3.0-alpha3
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/package.json +10 -10
- package/src/vaadin-grid-array-data-provider-mixin.js +1 -1
- package/src/vaadin-grid-column-group-mixin.d.ts +20 -0
- package/src/vaadin-grid-column-group-mixin.js +369 -0
- package/src/vaadin-grid-column-group.d.ts +4 -14
- package/src/vaadin-grid-column-group.js +5 -355
- package/src/vaadin-grid-column-mixin.d.ts +170 -0
- package/src/vaadin-grid-column-mixin.js +922 -0
- package/src/vaadin-grid-column.d.ts +11 -138
- package/src/vaadin-grid-column.js +3 -876
- package/src/vaadin-grid-data-provider-mixin.d.ts +6 -5
- package/src/vaadin-grid-data-provider-mixin.js +38 -7
- package/src/vaadin-grid-drag-and-drop-mixin.js +1 -1
- package/src/vaadin-grid-filter-column-mixin.d.ts +22 -0
- package/src/vaadin-grid-filter-column-mixin.js +100 -0
- package/src/vaadin-grid-filter-column.d.ts +9 -11
- package/src/vaadin-grid-filter-column.js +3 -90
- package/src/vaadin-grid-filter-element-mixin.d.ts +34 -0
- package/src/vaadin-grid-filter-element-mixin.js +99 -0
- package/src/vaadin-grid-filter.d.ts +4 -21
- package/src/vaadin-grid-filter.js +5 -84
- package/src/vaadin-grid-keyboard-navigation-mixin.js +16 -3
- package/src/vaadin-grid-mixin.js +11 -8
- package/src/vaadin-grid-scroll-mixin.js +1 -1
- package/src/vaadin-grid-selection-column-mixin.d.ts +24 -0
- package/src/vaadin-grid-selection-column-mixin.js +194 -0
- package/src/vaadin-grid-selection-column.d.ts +13 -17
- package/src/vaadin-grid-selection-column.js +4 -186
- package/src/vaadin-grid-sort-column-mixin.d.ts +36 -0
- package/src/vaadin-grid-sort-column-mixin.js +97 -0
- package/src/vaadin-grid-sort-column.d.ts +8 -26
- package/src/vaadin-grid-sort-column.js +3 -87
- package/src/vaadin-grid-sorter-mixin.d.ts +44 -0
- package/src/vaadin-grid-sorter-mixin.js +198 -0
- package/src/vaadin-grid-sorter.d.ts +3 -32
- package/src/vaadin-grid-sorter.js +5 -181
- package/src/vaadin-grid-tree-column-mixin.d.ts +18 -0
- package/src/vaadin-grid-tree-column-mixin.js +92 -0
- package/src/vaadin-grid-tree-column.d.ts +9 -7
- package/src/vaadin-grid-tree-column.js +3 -82
- package/src/vaadin-grid-tree-toggle-mixin.d.ts +39 -0
- package/src/vaadin-grid-tree-toggle-mixin.js +151 -0
- package/src/vaadin-grid-tree-toggle.d.ts +4 -27
- package/src/vaadin-grid-tree-toggle.js +9 -141
- package/web-types.json +331 -126
- package/web-types.lit.json +114 -58
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type {
|
|
8
|
+
DataProvider,
|
|
9
|
+
DataProviderCallback,
|
|
10
|
+
} from '@vaadin/component-base/src/data-provider-controller/data-provider-controller.js';
|
|
7
11
|
import { GridSorterDirection } from './vaadin-grid-sorter.js';
|
|
8
12
|
|
|
9
13
|
export { GridSorterDirection };
|
|
@@ -18,7 +22,7 @@ export interface GridSorterDefinition {
|
|
|
18
22
|
direction: GridSorterDirection;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
export type GridDataProviderCallback<TItem> =
|
|
25
|
+
export type GridDataProviderCallback<TItem> = DataProviderCallback<TItem>;
|
|
22
26
|
|
|
23
27
|
export type GridDataProviderParams<TItem> = {
|
|
24
28
|
page: number;
|
|
@@ -28,10 +32,7 @@ export type GridDataProviderParams<TItem> = {
|
|
|
28
32
|
parentItem?: TItem;
|
|
29
33
|
};
|
|
30
34
|
|
|
31
|
-
export type GridDataProvider<TItem> =
|
|
32
|
-
params: GridDataProviderParams<TItem>,
|
|
33
|
-
callback: GridDataProviderCallback<TItem>,
|
|
34
|
-
) => void;
|
|
35
|
+
export type GridDataProvider<TItem> = DataProvider<TItem, GridDataProviderParams<TItem>>;
|
|
35
36
|
|
|
36
37
|
export declare function DataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
37
38
|
base: T,
|
|
@@ -134,6 +134,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
134
134
|
this._dataProviderController = new DataProviderController(this, {
|
|
135
135
|
size: this.size,
|
|
136
136
|
pageSize: this.pageSize,
|
|
137
|
+
getItemId: this.getItemId.bind(this),
|
|
137
138
|
isExpanded: this._isExpanded.bind(this),
|
|
138
139
|
dataProvider: this.dataProvider ? this.dataProvider.bind(this) : null,
|
|
139
140
|
dataProviderParams: () => {
|
|
@@ -149,10 +150,28 @@ export const DataProviderMixin = (superClass) =>
|
|
|
149
150
|
this._dataProviderController.addEventListener('page-loaded', this._onDataProviderPageLoaded.bind(this));
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
/**
|
|
154
|
+
* @protected
|
|
155
|
+
* @deprecated since 24.3 and will be removed in Vaadin 25.
|
|
156
|
+
*/
|
|
157
|
+
get _cache() {
|
|
158
|
+
console.warn('<vaadin-grid> The `_cache` property is deprecated and will be removed in Vaadin 25.');
|
|
159
|
+
return this._dataProviderController.rootCache;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @protected
|
|
164
|
+
* @deprecated since 24.3 and will be removed in Vaadin 25.
|
|
165
|
+
*/
|
|
166
|
+
get _effectiveSize() {
|
|
167
|
+
console.warn('<vaadin-grid> The `_effectiveSize` property is deprecated and will be removed in Vaadin 25.');
|
|
168
|
+
return this._flatSize;
|
|
169
|
+
}
|
|
170
|
+
|
|
152
171
|
/** @private */
|
|
153
172
|
_sizeChanged(size) {
|
|
154
173
|
this._dataProviderController.setSize(size);
|
|
155
|
-
this.
|
|
174
|
+
this._flatSize = this._dataProviderController.flatSize;
|
|
156
175
|
}
|
|
157
176
|
|
|
158
177
|
/** @private */
|
|
@@ -170,7 +189,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
170
189
|
* @protected
|
|
171
190
|
*/
|
|
172
191
|
_getItem(index, el) {
|
|
173
|
-
if (index >= this.
|
|
192
|
+
if (index >= this._flatSize) {
|
|
174
193
|
return;
|
|
175
194
|
}
|
|
176
195
|
|
|
@@ -225,8 +244,8 @@ export const DataProviderMixin = (superClass) =>
|
|
|
225
244
|
|
|
226
245
|
/** @private */
|
|
227
246
|
_expandedItemsChanged() {
|
|
228
|
-
this._dataProviderController.
|
|
229
|
-
this.
|
|
247
|
+
this._dataProviderController.recalculateFlatSize();
|
|
248
|
+
this._flatSize = this._dataProviderController.flatSize;
|
|
230
249
|
this.__updateVisibleRows();
|
|
231
250
|
}
|
|
232
251
|
|
|
@@ -271,6 +290,17 @@ export const DataProviderMixin = (superClass) =>
|
|
|
271
290
|
return level;
|
|
272
291
|
}
|
|
273
292
|
|
|
293
|
+
/**
|
|
294
|
+
* @param {number} page
|
|
295
|
+
* @param {ItemCache} cache
|
|
296
|
+
* @protected
|
|
297
|
+
* @deprecated since 24.3 and will be removed in Vaadin 25.
|
|
298
|
+
*/
|
|
299
|
+
_loadPage(page, cache) {
|
|
300
|
+
console.warn('<vaadin-grid> The `_loadPage` method is deprecated and will be removed in Vaadin 25.');
|
|
301
|
+
this._dataProviderController.__loadCachePage(cache, page);
|
|
302
|
+
}
|
|
303
|
+
|
|
274
304
|
/** @protected */
|
|
275
305
|
_onDataProviderPageRequested() {
|
|
276
306
|
this._setLoading(true);
|
|
@@ -279,7 +309,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
279
309
|
/** @protected */
|
|
280
310
|
_onDataProviderPageReceived() {
|
|
281
311
|
// With the new items added, update the cache size and the grid's effective size
|
|
282
|
-
this.
|
|
312
|
+
this._flatSize = this._dataProviderController.flatSize;
|
|
283
313
|
|
|
284
314
|
// After updating the cache, check if some of the expanded items should have sub-caches loaded
|
|
285
315
|
this._getRenderedRows().forEach((row) => {
|
|
@@ -303,6 +333,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
303
333
|
});
|
|
304
334
|
|
|
305
335
|
this.__scrollToPendingIndexes();
|
|
336
|
+
this.__dispatchPendingBodyCellFocus();
|
|
306
337
|
});
|
|
307
338
|
|
|
308
339
|
// If the grid is not loading anything, flush the debouncer immediately
|
|
@@ -319,7 +350,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
319
350
|
this._hasData = false;
|
|
320
351
|
this.__updateVisibleRows();
|
|
321
352
|
|
|
322
|
-
if (!this.
|
|
353
|
+
if (!this._flatSize) {
|
|
323
354
|
this._dataProviderController.loadFirstPage();
|
|
324
355
|
}
|
|
325
356
|
}
|
|
@@ -335,7 +366,7 @@ export const DataProviderMixin = (superClass) =>
|
|
|
335
366
|
|
|
336
367
|
/** @protected */
|
|
337
368
|
_checkSize() {
|
|
338
|
-
if (this.size === undefined && this.
|
|
369
|
+
if (this.size === undefined && this._flatSize === 0) {
|
|
339
370
|
console.warn(
|
|
340
371
|
'The <vaadin-grid> needs the total number of items in' +
|
|
341
372
|
' order to display rows, which you can specify either by setting' +
|
|
@@ -211,7 +211,7 @@ export const DragAndDropMixin = (superClass) =>
|
|
|
211
211
|
|
|
212
212
|
let row = e.composedPath().find((node) => node.localName === 'tr');
|
|
213
213
|
|
|
214
|
-
if (!this.
|
|
214
|
+
if (!this._flatSize || this.dropMode === DropMode.ON_GRID) {
|
|
215
215
|
// The grid is empty or "on-grid" drop mode was used, always default to "empty"
|
|
216
216
|
this._dropLocation = DropLocation.EMPTY;
|
|
217
217
|
} else if (!row || row.parentNode !== this.$.items) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
|
|
8
|
+
export declare function GridFilterColumnMixin<T extends Constructor<HTMLElement>>(
|
|
9
|
+
superclass: T,
|
|
10
|
+
): Constructor<GridFilterColumnMixinClass> & T;
|
|
11
|
+
|
|
12
|
+
export declare class GridFilterColumnMixinClass {
|
|
13
|
+
/**
|
|
14
|
+
* Text to display as the label of the column filter text-field.
|
|
15
|
+
*/
|
|
16
|
+
header: string | null | undefined;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* JS Path of the property in the item used for filtering the data.
|
|
20
|
+
*/
|
|
21
|
+
path: string | null | undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @polymerMixin
|
|
9
|
+
*/
|
|
10
|
+
export const GridFilterColumnMixin = (superClass) =>
|
|
11
|
+
class extends superClass {
|
|
12
|
+
static get properties() {
|
|
13
|
+
return {
|
|
14
|
+
/**
|
|
15
|
+
* JS Path of the property in the item used for filtering the data.
|
|
16
|
+
*/
|
|
17
|
+
path: String,
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Text to display as the label of the column filter text-field.
|
|
21
|
+
*/
|
|
22
|
+
header: String,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static get observers() {
|
|
27
|
+
return ['_onHeaderRendererOrBindingChanged(_headerRenderer, _headerCell, path, header, _filterValue)'];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
|
|
33
|
+
this.__boundOnFilterValueChanged = this.__onFilterValueChanged.bind(this);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Renders the grid filter with the custom text field to the header cell.
|
|
38
|
+
*
|
|
39
|
+
* @override
|
|
40
|
+
*/
|
|
41
|
+
_defaultHeaderRenderer(root, _column) {
|
|
42
|
+
let filter = root.firstElementChild;
|
|
43
|
+
let textField = filter ? filter.firstElementChild : undefined;
|
|
44
|
+
|
|
45
|
+
if (!filter) {
|
|
46
|
+
filter = document.createElement('vaadin-grid-filter');
|
|
47
|
+
textField = document.createElement('vaadin-text-field');
|
|
48
|
+
textField.setAttribute('theme', 'small');
|
|
49
|
+
textField.setAttribute('style', 'max-width: 100%;');
|
|
50
|
+
textField.setAttribute('focus-target', '');
|
|
51
|
+
textField.addEventListener('value-changed', this.__boundOnFilterValueChanged);
|
|
52
|
+
filter.appendChild(textField);
|
|
53
|
+
root.appendChild(filter);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
filter.path = this.path;
|
|
57
|
+
filter.value = this._filterValue;
|
|
58
|
+
|
|
59
|
+
textField.__rendererValue = this._filterValue;
|
|
60
|
+
textField.value = this._filterValue;
|
|
61
|
+
textField.label = this.__getHeader(this.header, this.path);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The filter column doesn't allow to use a custom header renderer
|
|
66
|
+
* to override the header cell content.
|
|
67
|
+
* It always renders the grid filter to the header cell.
|
|
68
|
+
*
|
|
69
|
+
* @override
|
|
70
|
+
*/
|
|
71
|
+
_computeHeaderRenderer() {
|
|
72
|
+
return this._defaultHeaderRenderer;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Updates the internal filter value once the filter text field is changed.
|
|
77
|
+
* The listener handles only user-fired events.
|
|
78
|
+
*
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
__onFilterValueChanged(e) {
|
|
82
|
+
// Skip if the value is changed by the renderer.
|
|
83
|
+
if (e.detail.value === e.target.__rendererValue) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this._filterValue = e.detail.value;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** @private */
|
|
91
|
+
__getHeader(header, path) {
|
|
92
|
+
if (header) {
|
|
93
|
+
return header;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (path) {
|
|
97
|
+
return this._generateHeader(path);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { GridDefaultItem } from './vaadin-grid.js';
|
|
7
|
-
import { GridColumn } from './vaadin-grid-column.js';
|
|
7
|
+
import type { GridColumn, GridColumnMixin } from './vaadin-grid-column.js';
|
|
8
|
+
import type { GridFilterColumnMixinClass } from './vaadin-grid-filter-column-mixin.js';
|
|
9
|
+
|
|
10
|
+
export * from './vaadin-grid-filter-column-mixin.js';
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* `<vaadin-grid-filter-column>` is a helper element for the `<vaadin-grid>`
|
|
@@ -19,17 +22,12 @@ import { GridColumn } from './vaadin-grid-column.js';
|
|
|
19
22
|
* ...
|
|
20
23
|
* ```
|
|
21
24
|
*/
|
|
22
|
-
declare class GridFilterColumn<TItem = GridDefaultItem> extends
|
|
23
|
-
/**
|
|
24
|
-
* Text to display as the label of the column filter text-field.
|
|
25
|
-
*/
|
|
26
|
-
header: string | null | undefined;
|
|
25
|
+
declare class GridFilterColumn<TItem = GridDefaultItem> extends HTMLElement {}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
27
|
+
interface GridFilterColumn<TItem = GridDefaultItem>
|
|
28
|
+
extends GridFilterColumnMixinClass,
|
|
29
|
+
GridColumnMixin<TItem, GridColumn<TItem>>,
|
|
30
|
+
GridColumn<TItem> {}
|
|
33
31
|
|
|
34
32
|
declare global {
|
|
35
33
|
interface HTMLElementTagNameMap {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import './vaadin-grid-filter.js';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { GridColumn } from './vaadin-grid-column.js';
|
|
9
|
+
import { GridFilterColumnMixin } from './vaadin-grid-filter-column-mixin.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* `<vaadin-grid-filter-column>` is a helper element for the `<vaadin-grid>`
|
|
@@ -22,100 +23,12 @@ import { GridColumn } from './vaadin-grid-column.js';
|
|
|
22
23
|
*
|
|
23
24
|
* @customElement
|
|
24
25
|
* @extends GridColumn
|
|
26
|
+
* @mixes GridFilterColumnMixin
|
|
25
27
|
*/
|
|
26
|
-
class GridFilterColumn extends GridColumn {
|
|
28
|
+
class GridFilterColumn extends GridFilterColumnMixin(GridColumn) {
|
|
27
29
|
static get is() {
|
|
28
30
|
return 'vaadin-grid-filter-column';
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
static get properties() {
|
|
32
|
-
return {
|
|
33
|
-
/**
|
|
34
|
-
* JS Path of the property in the item used for filtering the data.
|
|
35
|
-
*/
|
|
36
|
-
path: String,
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Text to display as the label of the column filter text-field.
|
|
40
|
-
*/
|
|
41
|
-
header: String,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static get observers() {
|
|
46
|
-
return ['_onHeaderRendererOrBindingChanged(_headerRenderer, _headerCell, path, header, _filterValue)'];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
constructor() {
|
|
50
|
-
super();
|
|
51
|
-
|
|
52
|
-
this.__boundOnFilterValueChanged = this.__onFilterValueChanged.bind(this);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Renders the grid filter with the custom text field to the header cell.
|
|
57
|
-
*
|
|
58
|
-
* @override
|
|
59
|
-
*/
|
|
60
|
-
_defaultHeaderRenderer(root, _column) {
|
|
61
|
-
let filter = root.firstElementChild;
|
|
62
|
-
let textField = filter ? filter.firstElementChild : undefined;
|
|
63
|
-
|
|
64
|
-
if (!filter) {
|
|
65
|
-
filter = document.createElement('vaadin-grid-filter');
|
|
66
|
-
textField = document.createElement('vaadin-text-field');
|
|
67
|
-
textField.setAttribute('theme', 'small');
|
|
68
|
-
textField.setAttribute('style', 'max-width: 100%;');
|
|
69
|
-
textField.setAttribute('focus-target', '');
|
|
70
|
-
textField.addEventListener('value-changed', this.__boundOnFilterValueChanged);
|
|
71
|
-
filter.appendChild(textField);
|
|
72
|
-
root.appendChild(filter);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
filter.path = this.path;
|
|
76
|
-
filter.value = this._filterValue;
|
|
77
|
-
|
|
78
|
-
textField.__rendererValue = this._filterValue;
|
|
79
|
-
textField.value = this._filterValue;
|
|
80
|
-
textField.label = this.__getHeader(this.header, this.path);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The filter column doesn't allow to use a custom header renderer
|
|
85
|
-
* to override the header cell content.
|
|
86
|
-
* It always renders the grid filter to the header cell.
|
|
87
|
-
*
|
|
88
|
-
* @override
|
|
89
|
-
*/
|
|
90
|
-
_computeHeaderRenderer() {
|
|
91
|
-
return this._defaultHeaderRenderer;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Updates the internal filter value once the filter text field is changed.
|
|
96
|
-
* The listener handles only user-fired events.
|
|
97
|
-
*
|
|
98
|
-
* @private
|
|
99
|
-
*/
|
|
100
|
-
__onFilterValueChanged(e) {
|
|
101
|
-
// Skip if the value is changed by the renderer.
|
|
102
|
-
if (e.detail.value === e.target.__rendererValue) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this._filterValue = e.detail.value;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** @private */
|
|
110
|
-
__getHeader(header, path) {
|
|
111
|
-
if (header) {
|
|
112
|
-
return header;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (path) {
|
|
116
|
-
return this._generateHeader(path);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
32
|
}
|
|
120
33
|
|
|
121
34
|
defineCustomElement(GridFilterColumn);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Fired when the `value` property changes.
|
|
11
|
+
*/
|
|
12
|
+
export type GridFilterValueChangedEvent = CustomEvent<{ value: string }>;
|
|
13
|
+
|
|
14
|
+
export interface GridFilterCustomEventMap {
|
|
15
|
+
'value-changed': GridFilterValueChangedEvent;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface GridFilterEventMap extends HTMLElementEventMap, GridFilterCustomEventMap {}
|
|
19
|
+
|
|
20
|
+
export declare function GridFilterElementMixin<T extends Constructor<HTMLElement>>(
|
|
21
|
+
base: T,
|
|
22
|
+
): Constructor<ControllerMixinClass> & Constructor<GridFilterElementMixinClass> & T;
|
|
23
|
+
|
|
24
|
+
declare class GridFilterElementMixinClass {
|
|
25
|
+
/**
|
|
26
|
+
* JS Path of the property in the item used for filtering the data.
|
|
27
|
+
*/
|
|
28
|
+
path: string | null | undefined;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Current filter value.
|
|
32
|
+
*/
|
|
33
|
+
value: string | null | undefined;
|
|
34
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { timeOut } from '@vaadin/component-base/src/async.js';
|
|
7
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
8
|
+
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
9
|
+
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
10
|
+
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin';
|
|
11
|
+
|
|
12
|
+
registerStyles(
|
|
13
|
+
'vaadin-grid-filter',
|
|
14
|
+
css`
|
|
15
|
+
:host {
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
max-width: 100%;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
::slotted(*) {
|
|
21
|
+
width: 100%;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
}
|
|
24
|
+
`,
|
|
25
|
+
{ moduleId: 'vaadin-grid-filter-styles' },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @polymerMixin
|
|
30
|
+
*
|
|
31
|
+
* @mixes ControllerMixin
|
|
32
|
+
*/
|
|
33
|
+
export const GridFilterElementMixin = (superClass) =>
|
|
34
|
+
class extends ControllerMixin(superClass) {
|
|
35
|
+
static get properties() {
|
|
36
|
+
return {
|
|
37
|
+
/**
|
|
38
|
+
* JS Path of the property in the item used for filtering the data.
|
|
39
|
+
*/
|
|
40
|
+
path: String,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Current filter value.
|
|
44
|
+
*/
|
|
45
|
+
value: {
|
|
46
|
+
type: String,
|
|
47
|
+
notify: true,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/** @private */
|
|
51
|
+
_textField: {
|
|
52
|
+
type: Object,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static get observers() {
|
|
58
|
+
return ['_filterChanged(path, value, _textField)'];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** @protected */
|
|
62
|
+
ready() {
|
|
63
|
+
super.ready();
|
|
64
|
+
|
|
65
|
+
this._filterController = new SlotController(this, '', 'vaadin-text-field', {
|
|
66
|
+
initializer: (field) => {
|
|
67
|
+
field.addEventListener('value-changed', (e) => {
|
|
68
|
+
this.value = e.detail.value;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
this._textField = field;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
this.addController(this._filterController);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** @private */
|
|
78
|
+
_filterChanged(path, value, textField) {
|
|
79
|
+
if (path === undefined || value === undefined || !textField) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (this._previousValue === undefined && value === '') {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
textField.value = value;
|
|
87
|
+
this._previousValue = value;
|
|
88
|
+
|
|
89
|
+
this._debouncerFilterChanged = Debouncer.debounce(this._debouncerFilterChanged, timeOut.after(200), () => {
|
|
90
|
+
this.dispatchEvent(new CustomEvent('filter-changed', { bubbles: true }));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
focus() {
|
|
95
|
+
if (this._textField) {
|
|
96
|
+
this._textField.focus();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
@@ -3,18 +3,11 @@
|
|
|
3
3
|
* Copyright (c) 2016 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
export type GridFilterValueChangedEvent = CustomEvent<{ value: string }>;
|
|
12
|
-
|
|
13
|
-
export interface GridFilterCustomEventMap {
|
|
14
|
-
'value-changed': GridFilterValueChangedEvent;
|
|
15
|
-
}
|
|
7
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin';
|
|
8
|
+
import { GridFilterElementMixin, type GridFilterEventMap } from './vaadin-grid-filter-element-mixin.js';
|
|
16
9
|
|
|
17
|
-
export
|
|
10
|
+
export * from './vaadin-grid-filter-element-mixin.js';
|
|
18
11
|
|
|
19
12
|
/**
|
|
20
13
|
* `<vaadin-grid-filter>` is a helper element for the `<vaadin-grid>` that provides out-of-the-box UI controls,
|
|
@@ -41,17 +34,7 @@ export interface GridFilterEventMap extends HTMLElementEventMap, GridFilterCusto
|
|
|
41
34
|
*
|
|
42
35
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
43
36
|
*/
|
|
44
|
-
declare class GridFilter extends
|
|
45
|
-
/**
|
|
46
|
-
* JS Path of the property in the item used for filtering the data.
|
|
47
|
-
*/
|
|
48
|
-
path: string | null | undefined;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Current filter value.
|
|
52
|
-
*/
|
|
53
|
-
value: string | null | undefined;
|
|
54
|
-
|
|
37
|
+
declare class GridFilter extends GridFilterElementMixin(ThemableMixin(HTMLElement)) {
|
|
55
38
|
addEventListener<K extends keyof GridFilterEventMap>(
|
|
56
39
|
type: K,
|
|
57
40
|
listener: (this: GridFilter, ev: GridFilterEventMap[K]) => void,
|