@vaadin/grid-pro 23.1.0-alpha4 → 23.1.0-beta3
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 +1 -0
- package/lit.js +1 -0
- package/package.json +19 -15
- package/src/lit/column-renderer-directives.d.ts +68 -0
- package/src/lit/column-renderer-directives.js +68 -0
- package/src/vaadin-grid-pro-edit-select.js +2 -2
- package/src/vaadin-grid-pro-inline-editing-mixin.js +13 -13
- package/src/vaadin-grid-pro.d.ts +7 -11
- package/src/vaadin-grid-pro.js +4 -0
- package/theme/lumo/vaadin-grid-pro-styles.js +3 -5
- package/theme/material/vaadin-grid-pro-styles.js +1 -2
package/lit.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/lit/column-renderer-directives.js';
|
package/lit.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/lit/column-renderer-directives.js';
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid-pro",
|
|
3
|
-
"version": "23.1.0-
|
|
3
|
+
"version": "23.1.0-beta3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "vaadin-grid-pro",
|
|
8
8
|
"license": "https://raw.githubusercontent.com/vaadin/web-components/master/packages/grid-pro/LICENSE",
|
|
9
|
+
"cvdlName": "vaadin-grid-pro",
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "https://github.com/vaadin/web-components.git",
|
|
@@ -22,6 +23,8 @@
|
|
|
22
23
|
"files": [
|
|
23
24
|
"src",
|
|
24
25
|
"theme",
|
|
26
|
+
"lit.js",
|
|
27
|
+
"lit.d.ts",
|
|
25
28
|
"vaadin-*.d.ts",
|
|
26
29
|
"vaadin-*.js"
|
|
27
30
|
],
|
|
@@ -35,26 +38,27 @@
|
|
|
35
38
|
"dependencies": {
|
|
36
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
37
40
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/checkbox": "23.1.0-
|
|
39
|
-
"@vaadin/component-base": "23.1.0-
|
|
40
|
-
"@vaadin/grid": "23.1.0-
|
|
41
|
-
"@vaadin/item": "23.1.0-
|
|
42
|
-
"@vaadin/list-box": "23.1.0-
|
|
43
|
-
"@vaadin/
|
|
44
|
-
"@vaadin/
|
|
41
|
+
"@vaadin/checkbox": "23.1.0-beta3",
|
|
42
|
+
"@vaadin/component-base": "23.1.0-beta3",
|
|
43
|
+
"@vaadin/grid": "23.1.0-beta3",
|
|
44
|
+
"@vaadin/item": "23.1.0-beta3",
|
|
45
|
+
"@vaadin/list-box": "23.1.0-beta3",
|
|
46
|
+
"@vaadin/lit-renderer": "23.1.0-beta3",
|
|
47
|
+
"@vaadin/select": "23.1.0-beta3",
|
|
48
|
+
"@vaadin/text-field": "23.1.0-beta3",
|
|
45
49
|
"@vaadin/vaadin-license-checker": "^2.1.0",
|
|
46
|
-
"@vaadin/vaadin-lumo-styles": "23.1.0-
|
|
47
|
-
"@vaadin/vaadin-material-styles": "23.1.0-
|
|
48
|
-
"@vaadin/vaadin-themable-mixin": "23.1.0-
|
|
50
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-beta3",
|
|
51
|
+
"@vaadin/vaadin-material-styles": "23.1.0-beta3",
|
|
52
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-beta3"
|
|
49
53
|
},
|
|
50
54
|
"devDependencies": {
|
|
51
55
|
"@esm-bundle/chai": "^4.3.4",
|
|
52
|
-
"@vaadin/date-picker": "23.1.0-
|
|
53
|
-
"@vaadin/dialog": "23.1.0-
|
|
54
|
-
"@vaadin/polymer-legacy-adapter": "23.1.0-
|
|
56
|
+
"@vaadin/date-picker": "23.1.0-beta3",
|
|
57
|
+
"@vaadin/dialog": "23.1.0-beta3",
|
|
58
|
+
"@vaadin/polymer-legacy-adapter": "23.1.0-beta3",
|
|
55
59
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
56
60
|
"lit": "^2.0.0",
|
|
57
61
|
"sinon": "^13.0.2"
|
|
58
62
|
},
|
|
59
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "c787ceb8a312f88631c6d429ff320d5f89b1b838"
|
|
60
64
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Commercial Vaadin Developer License 4.0 (CVDLv4).
|
|
5
|
+
* See <a href="https://vaadin.com/license/cvdl-4.0">the website</a> for the complete license.
|
|
6
|
+
*/
|
|
7
|
+
import { TemplateResult } from 'lit';
|
|
8
|
+
import { DirectiveResult } from 'lit/directive';
|
|
9
|
+
import { GridItemModel } from '@vaadin/grid';
|
|
10
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
11
|
+
import { GridProEditColumn } from '../vaadin-grid-pro-edit-column.js';
|
|
12
|
+
|
|
13
|
+
export type GridProColumnEditModeLitRenderer<TItem> = (
|
|
14
|
+
item: TItem,
|
|
15
|
+
model: GridItemModel<TItem>,
|
|
16
|
+
column: GridProEditColumn,
|
|
17
|
+
) => TemplateResult;
|
|
18
|
+
|
|
19
|
+
export declare class GridProColumnEditModeRendererDirective<TItem> extends LitRendererDirective<
|
|
20
|
+
GridProEditColumn,
|
|
21
|
+
GridProColumnEditModeLitRenderer<TItem>
|
|
22
|
+
> {
|
|
23
|
+
/**
|
|
24
|
+
* Adds the renderer callback to the grid edit column.
|
|
25
|
+
*/
|
|
26
|
+
addRenderer(): void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Runs the renderer callback on the grid edit column.
|
|
30
|
+
*/
|
|
31
|
+
runRenderer(): void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Removes the renderer callback from the grid edit column.
|
|
35
|
+
*/
|
|
36
|
+
removeRenderer(): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A Lit directive for rendering the content of column's body cells when they are in edit mode.
|
|
41
|
+
*
|
|
42
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid edit column
|
|
43
|
+
* via the `editModeRenderer` property. The renderer is called when a column's body cell switches to edit mode
|
|
44
|
+
* and whenever a single dependency or an array of dependencies changes as long as edit mode is on.
|
|
45
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
46
|
+
*
|
|
47
|
+
* Dependencies can be a single value or an array of values.
|
|
48
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
49
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
50
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
51
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
52
|
+
* equality.
|
|
53
|
+
*
|
|
54
|
+
* Example of usage:
|
|
55
|
+
* ```js
|
|
56
|
+
* `<vaadin-grid-pro-edit-column
|
|
57
|
+
* ${columnEditModeRenderer((item, model, column) => html`...`)}
|
|
58
|
+
* ></vaadin-grid-pro-edit-column>`
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @param renderer the renderer callback.
|
|
62
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
63
|
+
* which trigger a re-render when changed.
|
|
64
|
+
*/
|
|
65
|
+
export declare function columnEditModeRenderer<TItem>(
|
|
66
|
+
renderer: GridProColumnEditModeLitRenderer<TItem>,
|
|
67
|
+
dependencies?: unknown,
|
|
68
|
+
): DirectiveResult<typeof GridProColumnEditModeRendererDirective>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Commercial Vaadin Developer License 4.0 (CVDLv4).
|
|
5
|
+
* See <a href="https://vaadin.com/license/cvdl-4.0">the website</a> for the complete license.
|
|
6
|
+
*/
|
|
7
|
+
import { directive } from 'lit/directive.js';
|
|
8
|
+
import { microTask } from '@vaadin/component-base/src/async.js';
|
|
9
|
+
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
10
|
+
import { CONTENT_UPDATE_DEBOUNCER } from '@vaadin/grid/src/lit/renderer-directives.js';
|
|
11
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
12
|
+
|
|
13
|
+
export class GridProColumnEditModeRendererDirective extends LitRendererDirective {
|
|
14
|
+
/**
|
|
15
|
+
* Adds the renderer callback to the grid edit column.
|
|
16
|
+
*/
|
|
17
|
+
addRenderer() {
|
|
18
|
+
this.element.editModeRenderer = (root, column, model) => {
|
|
19
|
+
this.renderRenderer(root, model.item, model, column);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Runs the renderer callback on the grid edit column.
|
|
25
|
+
*/
|
|
26
|
+
runRenderer() {
|
|
27
|
+
const grid = this.element._grid;
|
|
28
|
+
|
|
29
|
+
grid[CONTENT_UPDATE_DEBOUNCER] = Debouncer.debounce(grid[CONTENT_UPDATE_DEBOUNCER], microTask, () => {
|
|
30
|
+
grid.requestContentUpdate();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Removes the renderer callback from the grid edit column.
|
|
36
|
+
*/
|
|
37
|
+
removeRenderer() {
|
|
38
|
+
this.element.editModeRenderer = null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A Lit directive for rendering the content of column's body cells when they are in edit mode.
|
|
44
|
+
*
|
|
45
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the grid edit column
|
|
46
|
+
* via the `editModeRenderer` property. The renderer is called when a column's body cell switches to edit mode
|
|
47
|
+
* and whenever a single dependency or an array of dependencies changes as long as edit mode is on.
|
|
48
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
49
|
+
*
|
|
50
|
+
* Dependencies can be a single value or an array of values.
|
|
51
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
52
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
53
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
54
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
55
|
+
* equality.
|
|
56
|
+
*
|
|
57
|
+
* Example of usage:
|
|
58
|
+
* ```js
|
|
59
|
+
* `<vaadin-grid-pro-edit-column
|
|
60
|
+
* ${columnEditModeRenderer((item, model, column) => html`...`)}
|
|
61
|
+
* ></vaadin-grid-pro-edit-column>`
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param renderer the renderer callback.
|
|
65
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
66
|
+
* which trigger a re-render when changed.
|
|
67
|
+
*/
|
|
68
|
+
export const columnEditModeRenderer = directive(GridProColumnEditModeRendererDirective);
|
|
@@ -84,7 +84,7 @@ class GridProEditSelect extends Select {
|
|
|
84
84
|
_valueChanged(value, oldValue) {
|
|
85
85
|
super._valueChanged(value, oldValue);
|
|
86
86
|
|
|
87
|
-
//
|
|
87
|
+
// Select is first created without a value
|
|
88
88
|
if (value === '' && oldValue === undefined) {
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
@@ -125,7 +125,7 @@ class GridProEditSelect extends Select {
|
|
|
125
125
|
// see https://github.com/vaadin/vaadin-list-mixin/issues/49
|
|
126
126
|
setTimeout(() => {
|
|
127
127
|
this.opened = true;
|
|
128
|
-
//
|
|
128
|
+
// Any value change after first open will stop edit
|
|
129
129
|
this._initialized = true;
|
|
130
130
|
});
|
|
131
131
|
}
|
|
@@ -63,20 +63,20 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
63
63
|
this.__boundGlobalFocusIn = this._onGlobalFocusIn.bind(this);
|
|
64
64
|
|
|
65
65
|
this._addEditColumnListener('mousedown', (e) => {
|
|
66
|
-
//
|
|
66
|
+
// Prevent grid from resetting navigating state
|
|
67
67
|
e.stopImmediatePropagation();
|
|
68
68
|
this.toggleAttribute('navigating', true);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
this._addEditColumnListener('focusout', (e) => {
|
|
72
|
-
//
|
|
72
|
+
// Prevent grid from resetting navigating state
|
|
73
73
|
e.stopImmediatePropagation();
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/** @protected */
|
|
78
78
|
ready() {
|
|
79
|
-
//
|
|
79
|
+
// Add listener before `vaadin-grid` interaction mode listener
|
|
80
80
|
this.addEventListener('keydown', (e) => {
|
|
81
81
|
switch (e.keyCode) {
|
|
82
82
|
case 27:
|
|
@@ -129,7 +129,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
//
|
|
132
|
+
// Dblclick does not work on iOS Safari
|
|
133
133
|
if (this._ios) {
|
|
134
134
|
let firstClickTime;
|
|
135
135
|
let waitingSecondClick = false;
|
|
@@ -245,7 +245,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
245
245
|
|
|
246
246
|
/** @private */
|
|
247
247
|
_cancelStopEdit() {
|
|
248
|
-
//
|
|
248
|
+
// Stop edit on outside click will always trigger notify resize.
|
|
249
249
|
// when tabbing within same row it might not be needed, so cancel
|
|
250
250
|
if (this._debouncerStopEdit) {
|
|
251
251
|
this._debouncerStopEdit.cancel();
|
|
@@ -293,7 +293,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
293
293
|
|
|
294
294
|
/** @private */
|
|
295
295
|
_onEditorFocusOut() {
|
|
296
|
-
//
|
|
296
|
+
// Schedule stop on editor component focusout
|
|
297
297
|
this._debouncerStopEdit = Debouncer.debounce(this._debouncerStopEdit, animationFrame, this._stopEdit.bind(this));
|
|
298
298
|
}
|
|
299
299
|
|
|
@@ -306,7 +306,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
306
306
|
_onGlobalFocusIn(e) {
|
|
307
307
|
const edited = this.__edited;
|
|
308
308
|
if (edited) {
|
|
309
|
-
//
|
|
309
|
+
// Detect focus moving to e.g. vaadin-select-overlay
|
|
310
310
|
const overlay = Array.from(e.composedPath()).filter(
|
|
311
311
|
(node) => node.nodeType === Node.ELEMENT_NODE && /^vaadin-(?!dialog).*-overlay$/i.test(node.localName),
|
|
312
312
|
)[0];
|
|
@@ -324,7 +324,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
324
324
|
if (this.disabled || this._editingDisabled) {
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
|
-
//
|
|
327
|
+
// Cancel debouncer enqueued on focusout
|
|
328
328
|
this._cancelStopEdit();
|
|
329
329
|
|
|
330
330
|
this._scrollHorizontallyToCell(cell);
|
|
@@ -375,7 +375,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
375
375
|
index: model.index,
|
|
376
376
|
item: model.item,
|
|
377
377
|
path: column.path,
|
|
378
|
-
value
|
|
378
|
+
value,
|
|
379
379
|
},
|
|
380
380
|
bubbles: true,
|
|
381
381
|
cancelable: true,
|
|
@@ -423,17 +423,17 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
423
423
|
let nextCol = null;
|
|
424
424
|
let nextIdx = index;
|
|
425
425
|
|
|
426
|
-
//
|
|
426
|
+
// Enter key
|
|
427
427
|
if (e.keyCode === 13) {
|
|
428
428
|
nextCol = column;
|
|
429
429
|
|
|
430
|
-
//
|
|
430
|
+
// Move up / down
|
|
431
431
|
if (this.enterNextRow) {
|
|
432
432
|
nextIdx = e.shiftKey ? index - 1 : index + 1;
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
-
//
|
|
436
|
+
// Tab: move right / left
|
|
437
437
|
if (e.keyCode === 9) {
|
|
438
438
|
if (e.shiftKey) {
|
|
439
439
|
if (cols[colIndex - 1]) {
|
|
@@ -458,7 +458,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
458
458
|
const nextCell = Array.from(nextRow.children).filter((cell) => cell._column === nextCol)[0];
|
|
459
459
|
e.preventDefault();
|
|
460
460
|
|
|
461
|
-
//
|
|
461
|
+
// Prevent vaadin-grid handler from being called
|
|
462
462
|
e.stopImmediatePropagation();
|
|
463
463
|
|
|
464
464
|
if (!this.singleCellEdit && nextCell !== cell) {
|
package/src/vaadin-grid-pro.d.ts
CHANGED
|
@@ -12,23 +12,19 @@ export { GridProEditorType } from './vaadin-grid-pro-edit-column.js';
|
|
|
12
12
|
* Fired when the user starts editing a grid cell.
|
|
13
13
|
*/
|
|
14
14
|
export type GridProCellEditStartedEvent<TItem> = CustomEvent<{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
path: string;
|
|
19
|
-
};
|
|
15
|
+
index: number;
|
|
16
|
+
item: TItem;
|
|
17
|
+
path: string;
|
|
20
18
|
}>;
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* Fired before exiting the cell edit mode, if the value has been changed.
|
|
24
22
|
*/
|
|
25
23
|
export type GridProItemPropertyChangedEvent<TItem> = CustomEvent<{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
value: string | boolean;
|
|
31
|
-
};
|
|
24
|
+
index: number;
|
|
25
|
+
item: TItem;
|
|
26
|
+
path: string;
|
|
27
|
+
value: string | boolean;
|
|
32
28
|
}>;
|
|
33
29
|
|
|
34
30
|
export interface GridProCustomEventMap<TItem> {
|
package/src/vaadin-grid-pro.js
CHANGED
|
@@ -23,20 +23,18 @@ registerStyles(
|
|
|
23
23
|
|
|
24
24
|
[part~='editable-cell']:hover,
|
|
25
25
|
[part~='editable-cell']:focus {
|
|
26
|
-
background-color
|
|
27
|
-
background-clip: padding-box;
|
|
26
|
+
background: var(--lumo-base-color) linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
/* Indicate editable cells */
|
|
31
30
|
|
|
32
31
|
:host([theme~='highlight-editable-cells']) [part~='editable-cell'] {
|
|
33
|
-
background-color
|
|
34
|
-
background-clip: border-box;
|
|
32
|
+
background: var(--lumo-base-color) linear-gradient(var(--lumo-contrast-5pct), var(--lumo-contrast-5pct));
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
:host([theme~='highlight-editable-cells']) [part~='editable-cell']:hover,
|
|
38
36
|
:host([theme~='highlight-editable-cells']) [part~='editable-cell']:focus {
|
|
39
|
-
background-color
|
|
37
|
+
background: var(--lumo-base-color) linear-gradient(var(--lumo-contrast-10pct), var(--lumo-contrast-10pct));
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
/* Indicate read-only cells */
|
|
@@ -16,8 +16,7 @@ registerStyles(
|
|
|
16
16
|
|
|
17
17
|
[part~='row'] > [part~='editable-cell']:hover,
|
|
18
18
|
[part~='row'] > [part~='editable-cell']:focus {
|
|
19
|
-
background
|
|
20
|
-
background-clip: padding-box;
|
|
19
|
+
background: var(--material-background-color) linear-gradient(rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.08));
|
|
21
20
|
}
|
|
22
21
|
`,
|
|
23
22
|
{ moduleId: 'material-grid-pro' },
|