@vaadin/grid 23.1.0-alpha3 → 23.1.0-beta2
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/lit.d.ts +2 -0
- package/lit.js +2 -0
- package/package.json +12 -9
- package/src/array-data-provider.js +2 -2
- package/src/lit/column-renderer-directives.d.ts +152 -0
- package/src/lit/column-renderer-directives.js +149 -0
- package/src/lit/renderer-directives.d.ts +62 -0
- package/src/lit/renderer-directives.js +70 -0
- package/src/vaadin-grid-a11y-mixin.js +5 -5
- package/src/vaadin-grid-active-item-mixin.d.ts +1 -1
- package/src/vaadin-grid-active-item-mixin.js +8 -8
- package/src/vaadin-grid-array-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-grid-array-data-provider-mixin.js +4 -4
- package/src/vaadin-grid-column-group.js +57 -53
- package/src/vaadin-grid-column-reordering-mixin.d.ts +1 -1
- package/src/vaadin-grid-column-reordering-mixin.js +12 -12
- package/src/vaadin-grid-column-resizing-mixin.js +12 -18
- package/src/vaadin-grid-column.d.ts +2 -2
- package/src/vaadin-grid-column.js +39 -28
- package/src/vaadin-grid-data-provider-mixin.d.ts +2 -2
- package/src/vaadin-grid-data-provider-mixin.js +18 -18
- package/src/vaadin-grid-drag-and-drop-mixin.d.ts +1 -1
- package/src/vaadin-grid-drag-and-drop-mixin.js +9 -9
- package/src/vaadin-grid-dynamic-columns-mixin.js +23 -24
- package/src/vaadin-grid-event-context-mixin.d.ts +1 -1
- package/src/vaadin-grid-event-context-mixin.js +1 -1
- package/src/vaadin-grid-filter-column.js +1 -1
- package/src/vaadin-grid-filter-mixin.js +4 -6
- package/src/vaadin-grid-filter.d.ts +2 -2
- package/src/vaadin-grid-filter.js +2 -2
- package/src/vaadin-grid-helpers.js +1 -1
- package/src/vaadin-grid-keyboard-navigation-mixin.js +20 -17
- package/src/vaadin-grid-row-details-mixin.d.ts +2 -2
- package/src/vaadin-grid-row-details-mixin.js +4 -6
- package/src/vaadin-grid-scroll-mixin.js +7 -10
- package/src/vaadin-grid-selection-column.d.ts +2 -2
- package/src/vaadin-grid-selection-column.js +8 -8
- package/src/vaadin-grid-selection-mixin.d.ts +1 -1
- package/src/vaadin-grid-selection-mixin.js +2 -2
- package/src/vaadin-grid-sort-column.d.ts +2 -2
- package/src/vaadin-grid-sort-column.js +2 -2
- package/src/vaadin-grid-sort-mixin.js +7 -11
- package/src/vaadin-grid-sorter.d.ts +2 -2
- package/src/vaadin-grid-sorter.js +4 -4
- package/src/vaadin-grid-styles.js +1 -1
- package/src/vaadin-grid-styling-mixin.d.ts +1 -1
- package/src/vaadin-grid-styling-mixin.js +2 -2
- package/src/vaadin-grid-tree-column.js +3 -3
- package/src/vaadin-grid-tree-toggle.d.ts +2 -2
- package/src/vaadin-grid-tree-toggle.js +4 -4
- package/src/vaadin-grid.d.ts +7 -7
- package/src/vaadin-grid.js +50 -45
- package/theme/lumo/vaadin-grid-sorter-styles.js +1 -1
- package/theme/lumo/vaadin-grid-styles.js +2 -2
- package/theme/lumo/vaadin-grid-tree-toggle-styles.js +1 -1
- package/theme/material/vaadin-grid-sorter-styles.js +1 -1
- package/theme/material/vaadin-grid-styles.js +1 -1
- package/theme/material/vaadin-grid-tree-toggle-styles.js +1 -1
package/lit.d.ts
ADDED
package/lit.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid",
|
|
3
|
-
"version": "23.1.0-
|
|
3
|
+
"version": "23.1.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"all-imports.js",
|
|
24
24
|
"src",
|
|
25
25
|
"theme",
|
|
26
|
+
"lit.js",
|
|
27
|
+
"lit.d.ts",
|
|
26
28
|
"vaadin-*.d.ts",
|
|
27
29
|
"vaadin-*.js"
|
|
28
30
|
],
|
|
@@ -41,19 +43,20 @@
|
|
|
41
43
|
"dependencies": {
|
|
42
44
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
43
45
|
"@polymer/polymer": "^3.0.0",
|
|
44
|
-
"@vaadin/checkbox": "23.1.0-
|
|
45
|
-
"@vaadin/component-base": "23.1.0-
|
|
46
|
-
"@vaadin/
|
|
47
|
-
"@vaadin/
|
|
48
|
-
"@vaadin/vaadin-
|
|
49
|
-
"@vaadin/vaadin-
|
|
46
|
+
"@vaadin/checkbox": "23.1.0-beta2",
|
|
47
|
+
"@vaadin/component-base": "23.1.0-beta2",
|
|
48
|
+
"@vaadin/lit-renderer": "23.1.0-beta2",
|
|
49
|
+
"@vaadin/text-field": "23.1.0-beta2",
|
|
50
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-beta2",
|
|
51
|
+
"@vaadin/vaadin-material-styles": "23.1.0-beta2",
|
|
52
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@esm-bundle/chai": "^4.3.4",
|
|
53
|
-
"@vaadin/polymer-legacy-adapter": "23.1.0-
|
|
56
|
+
"@vaadin/polymer-legacy-adapter": "23.1.0-beta2",
|
|
54
57
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
55
58
|
"lit": "^2.0.0",
|
|
56
59
|
"sinon": "^13.0.2"
|
|
57
60
|
},
|
|
58
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
|
|
59
62
|
}
|
|
@@ -25,12 +25,12 @@ function checkPaths(arrayToCheck, action, items) {
|
|
|
25
25
|
for (const i in arrayToCheck) {
|
|
26
26
|
const path = arrayToCheck[i].path;
|
|
27
27
|
|
|
28
|
-
//
|
|
28
|
+
// Skip simple paths
|
|
29
29
|
if (!path || path.indexOf('.') === -1) {
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const parentProperty = path.replace(/\.[^.]*$/, ''); //
|
|
33
|
+
const parentProperty = path.replace(/\.[^.]*$/, ''); // A.b.c -> a.b
|
|
34
34
|
if (get(parentProperty, items[0]) === undefined) {
|
|
35
35
|
console.warn(`Path "${path}" used for ${action} does not exist in all of the items, ${action} is disabled.`);
|
|
36
36
|
result = false;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
/* eslint-disable max-classes-per-file */
|
|
7
|
+
import { TemplateResult } from 'lit';
|
|
8
|
+
import { DirectiveResult } from 'lit/directive';
|
|
9
|
+
import { LitRenderer, LitRendererDirective } from '@vaadin/lit-renderer';
|
|
10
|
+
import { GridItemModel } from '../vaadin-grid.js';
|
|
11
|
+
import { GridColumn } from '../vaadin-grid-column.js';
|
|
12
|
+
|
|
13
|
+
export type GridColumnBodyLitRenderer<TItem> = (
|
|
14
|
+
item: TItem,
|
|
15
|
+
model: GridItemModel<TItem>,
|
|
16
|
+
column: GridColumn,
|
|
17
|
+
) => TemplateResult;
|
|
18
|
+
|
|
19
|
+
export type GridColumnHeaderLitRenderer = (column: GridColumn) => TemplateResult;
|
|
20
|
+
export type GridColumnFooterLitRenderer = (column: GridColumn) => TemplateResult;
|
|
21
|
+
|
|
22
|
+
declare abstract class AbstractGridColumnRendererDirective<R extends LitRenderer> extends LitRendererDirective<
|
|
23
|
+
GridColumn,
|
|
24
|
+
R
|
|
25
|
+
> {
|
|
26
|
+
/**
|
|
27
|
+
* A property to that the renderer callback will be assigned.
|
|
28
|
+
*/
|
|
29
|
+
abstract rendererProperty: 'renderer' | 'headerRenderer' | 'footerRenderer';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Adds the renderer callback to the grid column.
|
|
33
|
+
*/
|
|
34
|
+
addRenderer(): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Runs the renderer callback on the grid column.
|
|
38
|
+
*/
|
|
39
|
+
runRenderer(): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Removes the renderer callback from the grid column.
|
|
43
|
+
*/
|
|
44
|
+
removeRenderer(): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare class GridColumnBodyRendererDirective<TItem> extends AbstractGridColumnRendererDirective<
|
|
48
|
+
GridColumnBodyLitRenderer<TItem>
|
|
49
|
+
> {
|
|
50
|
+
rendererProperty: 'renderer';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare class GridColumnHeaderRendererDirective extends AbstractGridColumnRendererDirective<GridColumnHeaderLitRenderer> {
|
|
54
|
+
rendererProperty: 'headerRenderer';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export declare class GridColumnFooterRendererDirective extends AbstractGridColumnRendererDirective<GridColumnFooterLitRenderer> {
|
|
58
|
+
rendererProperty: 'footerRenderer';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A Lit directive for rendering the content of the column's body cells.
|
|
63
|
+
*
|
|
64
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid column
|
|
65
|
+
* via the `renderer` property. The renderer is called for each column's body cell when assigned and whenever
|
|
66
|
+
* a single dependency or an array of dependencies changes.
|
|
67
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
68
|
+
*
|
|
69
|
+
* Dependencies can be a single value or an array of values.
|
|
70
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
71
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
72
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
73
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
74
|
+
* equality.
|
|
75
|
+
*
|
|
76
|
+
* Example of usage:
|
|
77
|
+
* ```js
|
|
78
|
+
* `<vaadin-grid-column
|
|
79
|
+
* ${columnBodyRenderer((item, model, column) => html`...`)}
|
|
80
|
+
* ></vaadin-grid-column>`
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param renderer the renderer callback.
|
|
84
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
85
|
+
* which trigger a re-render when changed.
|
|
86
|
+
*/
|
|
87
|
+
export declare function columnBodyRenderer<TItem>(
|
|
88
|
+
renderer: GridColumnBodyLitRenderer<TItem>,
|
|
89
|
+
dependencies?: unknown,
|
|
90
|
+
): DirectiveResult<typeof GridColumnBodyRendererDirective>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A Lit directive for rendering the content of the column's header cell.
|
|
94
|
+
*
|
|
95
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid column
|
|
96
|
+
* via the `headerRenderer` property. The renderer is called once when assigned and whenever
|
|
97
|
+
* a single dependency or an array of dependencies changes.
|
|
98
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
99
|
+
*
|
|
100
|
+
* Dependencies can be a single value or an array of values.
|
|
101
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
102
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
103
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
104
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
105
|
+
* equality.
|
|
106
|
+
*
|
|
107
|
+
* Example of usage:
|
|
108
|
+
* ```js
|
|
109
|
+
* `<vaadin-grid-column
|
|
110
|
+
* ${columnHeaderRenderer((column) => html`...`)}
|
|
111
|
+
* ></vaadin-grid-column>`
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @param renderer the renderer callback.
|
|
115
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
116
|
+
* which trigger a re-render when changed.
|
|
117
|
+
*/
|
|
118
|
+
export declare function columnHeaderRenderer(
|
|
119
|
+
renderer: GridColumnHeaderLitRenderer,
|
|
120
|
+
dependencies?: unknown,
|
|
121
|
+
): DirectiveResult<typeof GridColumnHeaderRendererDirective>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A Lit directive for rendering the content of the column's footer cell.
|
|
125
|
+
*
|
|
126
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid column
|
|
127
|
+
* via the `footerRenderer` property. The renderer is called once when assigned and whenever
|
|
128
|
+
* a single dependency or an array of dependencies changes.
|
|
129
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
130
|
+
*
|
|
131
|
+
* Dependencies can be a single value or an array of values.
|
|
132
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
133
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
134
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
135
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
136
|
+
* equality.
|
|
137
|
+
*
|
|
138
|
+
* Example of usage:
|
|
139
|
+
* ```js
|
|
140
|
+
* `<vaadin-grid-column
|
|
141
|
+
* ${columnFooterRenderer((column) => html`...`)}
|
|
142
|
+
* ></vaadin-grid-column>`
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @param renderer the renderer callback.
|
|
146
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
147
|
+
* which trigger a re-render when changed.
|
|
148
|
+
*/
|
|
149
|
+
export declare function columnFooterRenderer(
|
|
150
|
+
renderer: GridColumnFooterLitRenderer,
|
|
151
|
+
dependencies?: unknown,
|
|
152
|
+
): DirectiveResult<typeof GridColumnFooterRendererDirective>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
/* eslint-disable max-classes-per-file */
|
|
7
|
+
import { directive } from 'lit/directive.js';
|
|
8
|
+
import { microTask } from '@vaadin/component-base/src/async';
|
|
9
|
+
import { Debouncer } from '@vaadin/component-base/src/debounce';
|
|
10
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
11
|
+
import { CONTENT_UPDATE_DEBOUNCER } from './renderer-directives.js';
|
|
12
|
+
|
|
13
|
+
class AbstractGridColumnRendererDirective extends LitRendererDirective {
|
|
14
|
+
/**
|
|
15
|
+
* A property to that the renderer callback will be assigned.
|
|
16
|
+
*
|
|
17
|
+
* @abstract
|
|
18
|
+
*/
|
|
19
|
+
rendererProperty;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Adds the renderer callback to the grid column.
|
|
23
|
+
*/
|
|
24
|
+
addRenderer() {
|
|
25
|
+
this.element[this.rendererProperty] = (root, column) => {
|
|
26
|
+
this.renderRenderer(root, column);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Runs the renderer callback on the grid column.
|
|
32
|
+
*/
|
|
33
|
+
runRenderer() {
|
|
34
|
+
const grid = this.element._grid;
|
|
35
|
+
|
|
36
|
+
grid[CONTENT_UPDATE_DEBOUNCER] = Debouncer.debounce(grid[CONTENT_UPDATE_DEBOUNCER], microTask, () => {
|
|
37
|
+
grid.requestContentUpdate();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Removes the renderer callback from the grid column.
|
|
43
|
+
*/
|
|
44
|
+
removeRenderer() {
|
|
45
|
+
this.element[this.rendererProperty] = null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class GridColumnBodyRendererDirective extends AbstractGridColumnRendererDirective {
|
|
50
|
+
rendererProperty = 'renderer';
|
|
51
|
+
|
|
52
|
+
addRenderer() {
|
|
53
|
+
this.element[this.rendererProperty] = (root, column, model) => {
|
|
54
|
+
this.renderRenderer(root, model.item, model, column);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class GridColumnHeaderRendererDirective extends AbstractGridColumnRendererDirective {
|
|
60
|
+
rendererProperty = 'headerRenderer';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class GridColumnFooterRendererDirective extends AbstractGridColumnRendererDirective {
|
|
64
|
+
rendererProperty = 'footerRenderer';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A Lit directive for rendering the content of the column's body cells.
|
|
69
|
+
*
|
|
70
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid column
|
|
71
|
+
* via the `renderer` property. The renderer is called for each column's body cell when assigned and whenever
|
|
72
|
+
* a single dependency or an array of dependencies changes.
|
|
73
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
74
|
+
*
|
|
75
|
+
* Dependencies can be a single value or an array of values.
|
|
76
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
77
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
78
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
79
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
80
|
+
* equality.
|
|
81
|
+
*
|
|
82
|
+
* Example of usage:
|
|
83
|
+
* ```js
|
|
84
|
+
* `<vaadin-grid-column
|
|
85
|
+
* ${columnBodyRenderer((item, model, column) => html`...`)}
|
|
86
|
+
* ></vaadin-grid-column>`
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @param renderer the renderer callback.
|
|
90
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
91
|
+
* which trigger a re-render when changed.
|
|
92
|
+
*/
|
|
93
|
+
export const columnBodyRenderer = directive(GridColumnBodyRendererDirective);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A Lit directive for rendering the content of the column's header cell.
|
|
97
|
+
*
|
|
98
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid column
|
|
99
|
+
* via the `headerRenderer` property. The renderer is called once when assigned and whenever
|
|
100
|
+
* a single dependency or an array of dependencies changes.
|
|
101
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
102
|
+
*
|
|
103
|
+
* Dependencies can be a single value or an array of values.
|
|
104
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
105
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
106
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
107
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
108
|
+
* equality.
|
|
109
|
+
*
|
|
110
|
+
* Example of usage:
|
|
111
|
+
* ```js
|
|
112
|
+
* `<vaadin-grid-column
|
|
113
|
+
* ${columnHeaderRenderer((column) => html`...`)}
|
|
114
|
+
* ></vaadin-grid-column>`
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @param renderer the renderer callback.
|
|
118
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
119
|
+
* which trigger a re-render when changed.
|
|
120
|
+
*/
|
|
121
|
+
export const columnHeaderRenderer = directive(GridColumnHeaderRendererDirective);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A Lit directive for rendering the content of the column's footer cell.
|
|
125
|
+
*
|
|
126
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid column
|
|
127
|
+
* via the `footerRenderer` property. The renderer is called once when assigned and whenever
|
|
128
|
+
* a single dependency or an array of dependencies changes.
|
|
129
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
130
|
+
*
|
|
131
|
+
* Dependencies can be a single value or an array of values.
|
|
132
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
133
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
134
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
135
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
136
|
+
* equality.
|
|
137
|
+
*
|
|
138
|
+
* Example of usage:
|
|
139
|
+
* ```js
|
|
140
|
+
* `<vaadin-grid-column
|
|
141
|
+
* ${columnFooterRenderer((column) => html`...`)}
|
|
142
|
+
* ></vaadin-grid-column>`
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @param renderer the renderer callback.
|
|
146
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
147
|
+
* which trigger a re-render when changed.
|
|
148
|
+
*/
|
|
149
|
+
export const columnFooterRenderer = directive(GridColumnFooterRendererDirective);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { TemplateResult } from 'lit';
|
|
7
|
+
import { DirectiveResult } from 'lit/directive';
|
|
8
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
9
|
+
import { Grid, GridItemModel } from '../vaadin-grid.js';
|
|
10
|
+
|
|
11
|
+
export type GridRowDetailsLitRenderer<TItem> = (item: TItem, model: GridItemModel<TItem>, grid: Grid) => TemplateResult;
|
|
12
|
+
|
|
13
|
+
export declare class GridRowDetailsRendererDirective<TItem> extends LitRendererDirective<
|
|
14
|
+
Grid,
|
|
15
|
+
GridRowDetailsLitRenderer<TItem>
|
|
16
|
+
> {
|
|
17
|
+
/**
|
|
18
|
+
* Adds the row details renderer callback to the grid.
|
|
19
|
+
*/
|
|
20
|
+
addRenderer(): void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Runs the row details renderer callback on the grid.
|
|
24
|
+
*/
|
|
25
|
+
runRenderer(): void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Removes the row details renderer callback from the grid.
|
|
29
|
+
*/
|
|
30
|
+
removeRenderer(): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A Lit directive for rendering the content of the row details cell.
|
|
35
|
+
*
|
|
36
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid
|
|
37
|
+
* via the `rowDetailsRenderer` property. The renderer is called for each grid item that is in `detailsOpened`
|
|
38
|
+
* when assigned and whenever a single dependency or an array of dependencies changes.
|
|
39
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
40
|
+
*
|
|
41
|
+
* Dependencies can be a single value or an array of values.
|
|
42
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
43
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
44
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
45
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
46
|
+
* equality.
|
|
47
|
+
*
|
|
48
|
+
* Example of usage:
|
|
49
|
+
* ```js
|
|
50
|
+
* `<vaadin-grid
|
|
51
|
+
* ${gridRowDetailsRenderer((item, model, grid) => html`...`)}
|
|
52
|
+
* ></vaadin-grid>`
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @param renderer the renderer callback.
|
|
56
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
57
|
+
* which trigger a re-render when changed.
|
|
58
|
+
*/
|
|
59
|
+
export declare function gridRowDetailsRenderer<TItem>(
|
|
60
|
+
renderer: GridRowDetailsLitRenderer<TItem>,
|
|
61
|
+
dependencies?: unknown,
|
|
62
|
+
): DirectiveResult<typeof GridRowDetailsRendererDirective>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { directive } from 'lit/directive.js';
|
|
7
|
+
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
8
|
+
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
9
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
10
|
+
|
|
11
|
+
export const CONTENT_UPDATE_DEBOUNCER = Symbol('contentUpdateDebouncer');
|
|
12
|
+
|
|
13
|
+
export class GridRowDetailsRendererDirective extends LitRendererDirective {
|
|
14
|
+
/**
|
|
15
|
+
* Adds the row details renderer callback to the grid.
|
|
16
|
+
*/
|
|
17
|
+
addRenderer() {
|
|
18
|
+
this.element.rowDetailsRenderer = (root, grid, model) => {
|
|
19
|
+
this.renderRenderer(root, model.item, model, grid);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Runs the row details renderer callback on the grid.
|
|
25
|
+
*/
|
|
26
|
+
runRenderer() {
|
|
27
|
+
this.element[CONTENT_UPDATE_DEBOUNCER] = Debouncer.debounce(
|
|
28
|
+
this.element[CONTENT_UPDATE_DEBOUNCER],
|
|
29
|
+
microTask,
|
|
30
|
+
() => {
|
|
31
|
+
this.element.requestContentUpdate();
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Removes the row details renderer callback from the grid.
|
|
38
|
+
*/
|
|
39
|
+
removeRenderer() {
|
|
40
|
+
this.element.rowDetailsRenderer = null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A Lit directive for rendering the content of the row details cell.
|
|
46
|
+
*
|
|
47
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid
|
|
48
|
+
* via the `rowDetailsRenderer` property. The renderer is called for each grid item that is in `detailsOpened`
|
|
49
|
+
* when assigned and whenever a single dependency or an array of dependencies changes.
|
|
50
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
51
|
+
*
|
|
52
|
+
* Dependencies can be a single value or an array of values.
|
|
53
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
54
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
55
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
56
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
57
|
+
* equality.
|
|
58
|
+
*
|
|
59
|
+
* Example of usage:
|
|
60
|
+
* ```js
|
|
61
|
+
* `<vaadin-grid
|
|
62
|
+
* ${gridRowDetailsRenderer((item, model, grid) => html`...`)}
|
|
63
|
+
* ></vaadin-grid>`
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param renderer the renderer callback.
|
|
67
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
68
|
+
* which trigger a re-render when changed.
|
|
69
|
+
*/
|
|
70
|
+
export const gridRowDetailsRenderer = directive(GridRowDetailsRendererDirective);
|
|
@@ -32,7 +32,7 @@ export const A11yMixin = (superClass) =>
|
|
|
32
32
|
const bodyColumns = _columnTree[_columnTree.length - 1];
|
|
33
33
|
this.$.table.setAttribute(
|
|
34
34
|
'aria-rowcount',
|
|
35
|
-
size + this._a11yGetHeaderRowCount(_columnTree) + this._a11yGetFooterRowCount(_columnTree)
|
|
35
|
+
size + this._a11yGetHeaderRowCount(_columnTree) + this._a11yGetFooterRowCount(_columnTree),
|
|
36
36
|
);
|
|
37
37
|
this.$.table.setAttribute('aria-colcount', (bodyColumns && bodyColumns.length) || 0);
|
|
38
38
|
|
|
@@ -43,14 +43,14 @@ export const A11yMixin = (superClass) =>
|
|
|
43
43
|
/** @protected */
|
|
44
44
|
_a11yUpdateHeaderRows() {
|
|
45
45
|
Array.from(this.$.header.children).forEach((headerRow, index) =>
|
|
46
|
-
headerRow.setAttribute('aria-rowindex', index + 1)
|
|
46
|
+
headerRow.setAttribute('aria-rowindex', index + 1),
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/** @protected */
|
|
51
51
|
_a11yUpdateFooterRows() {
|
|
52
52
|
Array.from(this.$.footer.children).forEach((footerRow, index) =>
|
|
53
|
-
footerRow.setAttribute('aria-rowindex', this._a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1)
|
|
53
|
+
footerRow.setAttribute('aria-rowindex', this._a11yGetHeaderRowCount(this._columnTree) + this.size + index + 1),
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -137,8 +137,8 @@ export const A11yMixin = (superClass) =>
|
|
|
137
137
|
'aria-sort',
|
|
138
138
|
{
|
|
139
139
|
asc: 'ascending',
|
|
140
|
-
desc: 'descending'
|
|
141
|
-
}[String(sorter.direction)] || 'none'
|
|
140
|
+
desc: 'descending',
|
|
141
|
+
}[String(sorter.direction)] || 'none',
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
|
|
8
8
|
export declare function ActiveItemMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
9
|
-
base: T
|
|
9
|
+
base: T,
|
|
10
10
|
): T & Constructor<ActiveItemMixinClass<TItem>>;
|
|
11
11
|
|
|
12
12
|
export declare class ActiveItemMixinClass<TItem> {
|
|
@@ -19,8 +19,8 @@ export const ActiveItemMixin = (superClass) =>
|
|
|
19
19
|
activeItem: {
|
|
20
20
|
type: Object,
|
|
21
21
|
notify: true,
|
|
22
|
-
value: null
|
|
23
|
-
}
|
|
22
|
+
value: null,
|
|
23
|
+
},
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -68,9 +68,9 @@ export const ActiveItemMixin = (superClass) =>
|
|
|
68
68
|
this.dispatchEvent(
|
|
69
69
|
new CustomEvent('cell-activate', {
|
|
70
70
|
detail: {
|
|
71
|
-
model: this.__getRowModel(cell.parentElement)
|
|
72
|
-
}
|
|
73
|
-
})
|
|
71
|
+
model: this.__getRowModel(cell.parentElement),
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -108,10 +108,10 @@ export const isFocusable = (target) => {
|
|
|
108
108
|
}
|
|
109
109
|
const focusables = Array.from(
|
|
110
110
|
target.parentNode.querySelectorAll(
|
|
111
|
-
'[tabindex], button, input, select, textarea, object, iframe, label, a[href], area[href]'
|
|
112
|
-
)
|
|
111
|
+
'[tabindex], button, input, select, textarea, object, iframe, label, a[href], area[href]',
|
|
112
|
+
),
|
|
113
113
|
).filter((element) => element.getAttribute('part') !== 'cell body-cell');
|
|
114
114
|
|
|
115
|
-
const isFocusableElement = focusables.
|
|
115
|
+
const isFocusableElement = focusables.includes(target);
|
|
116
116
|
return !target.disabled && isFocusableElement;
|
|
117
117
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
|
|
8
8
|
export declare function ArrayDataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
9
|
-
base: T
|
|
9
|
+
base: T,
|
|
10
10
|
): T & Constructor<ArrayDataProviderMixinClass<TItem>>;
|
|
11
11
|
|
|
12
12
|
export declare class ArrayDataProviderMixinClass<TItem> {
|
|
@@ -17,7 +17,7 @@ export const ArrayDataProviderMixin = (superClass) =>
|
|
|
17
17
|
*
|
|
18
18
|
* @type {Array<!GridItem> | undefined}
|
|
19
19
|
*/
|
|
20
|
-
items: Array
|
|
20
|
+
items: Array,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -32,7 +32,7 @@ export const ArrayDataProviderMixin = (superClass) =>
|
|
|
32
32
|
this.setProperties({
|
|
33
33
|
_arrayDataProvider: arrayDataProvider,
|
|
34
34
|
size: items.length,
|
|
35
|
-
dataProvider: arrayDataProvider
|
|
35
|
+
dataProvider: arrayDataProvider,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -49,14 +49,14 @@ export const ArrayDataProviderMixin = (superClass) =>
|
|
|
49
49
|
// A custom data provider was set externally
|
|
50
50
|
this.setProperties({
|
|
51
51
|
_arrayDataProvider: undefined,
|
|
52
|
-
items: undefined
|
|
52
|
+
items: undefined,
|
|
53
53
|
});
|
|
54
54
|
} else if (!items) {
|
|
55
55
|
// The items array was unset
|
|
56
56
|
this.setProperties({
|
|
57
57
|
_arrayDataProvider: undefined,
|
|
58
58
|
dataProvider: undefined,
|
|
59
|
-
size: 0
|
|
59
|
+
size: 0,
|
|
60
60
|
});
|
|
61
61
|
this.clearCache();
|
|
62
62
|
} else if (this._arrayDataProvider.__items === items) {
|