@vaadin/grid-pro 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 +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-column.js +11 -9
- package/src/vaadin-grid-pro-edit-select.js +9 -7
- package/src/vaadin-grid-pro-inline-editing-mixin.d.ts +1 -1
- package/src/vaadin-grid-pro-inline-editing-mixin.js +42 -30
- package/src/vaadin-grid-pro.d.ts +9 -13
- package/src/vaadin-grid-pro.js +4 -0
- package/theme/lumo/vaadin-grid-pro-edit-select-styles.js +1 -1
- package/theme/lumo/vaadin-grid-pro-edit-text-field-styles.js +1 -1
- package/theme/lumo/vaadin-grid-pro-styles.js +4 -6
- package/theme/material/vaadin-grid-pro-edit-select-styles.js +1 -1
- package/theme/material/vaadin-grid-pro-edit-text-field-styles.js +1 -1
- package/theme/material/vaadin-grid-pro-styles.js +2 -3
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-beta2",
|
|
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-beta2",
|
|
42
|
+
"@vaadin/component-base": "23.1.0-beta2",
|
|
43
|
+
"@vaadin/grid": "23.1.0-beta2",
|
|
44
|
+
"@vaadin/item": "23.1.0-beta2",
|
|
45
|
+
"@vaadin/list-box": "23.1.0-beta2",
|
|
46
|
+
"@vaadin/lit-renderer": "23.1.0-beta2",
|
|
47
|
+
"@vaadin/select": "23.1.0-beta2",
|
|
48
|
+
"@vaadin/text-field": "23.1.0-beta2",
|
|
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-beta2",
|
|
51
|
+
"@vaadin/vaadin-material-styles": "23.1.0-beta2",
|
|
52
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
|
|
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-beta2",
|
|
57
|
+
"@vaadin/dialog": "23.1.0-beta2",
|
|
58
|
+
"@vaadin/polymer-legacy-adapter": "23.1.0-beta2",
|
|
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": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
|
|
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);
|
|
@@ -59,7 +59,7 @@ class GridProEditColumn extends GridColumn {
|
|
|
59
59
|
*/
|
|
60
60
|
editorOptions: {
|
|
61
61
|
type: Array,
|
|
62
|
-
value: () => []
|
|
62
|
+
value: () => [],
|
|
63
63
|
},
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -75,7 +75,7 @@ class GridProEditColumn extends GridColumn {
|
|
|
75
75
|
editorType: {
|
|
76
76
|
type: String,
|
|
77
77
|
notify: true, // FIXME(web-padawan): needed by Flow counterpart
|
|
78
|
-
value: 'text'
|
|
78
|
+
value: 'text',
|
|
79
79
|
},
|
|
80
80
|
|
|
81
81
|
/**
|
|
@@ -85,7 +85,7 @@ class GridProEditColumn extends GridColumn {
|
|
|
85
85
|
*/
|
|
86
86
|
editorValuePath: {
|
|
87
87
|
type: String,
|
|
88
|
-
value: 'value'
|
|
88
|
+
value: 'value',
|
|
89
89
|
},
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -93,11 +93,11 @@ class GridProEditColumn extends GridColumn {
|
|
|
93
93
|
*/
|
|
94
94
|
path: {
|
|
95
95
|
type: String,
|
|
96
|
-
observer: '_pathChanged'
|
|
96
|
+
observer: '_pathChanged',
|
|
97
97
|
},
|
|
98
98
|
|
|
99
99
|
/** @private */
|
|
100
|
-
_oldRenderer: Function
|
|
100
|
+
_oldRenderer: Function,
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -122,7 +122,7 @@ class GridProEditColumn extends GridColumn {
|
|
|
122
122
|
|
|
123
123
|
/** @private */
|
|
124
124
|
_pathChanged(path) {
|
|
125
|
-
if (!path || path.length
|
|
125
|
+
if (!path || path.length === 0) {
|
|
126
126
|
throw new Error('You should specify the path for the edit column');
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -132,7 +132,7 @@ class GridProEditColumn extends GridColumn {
|
|
|
132
132
|
this._cells.forEach((cell) => {
|
|
133
133
|
const part = cell.getAttribute('part');
|
|
134
134
|
if (part.indexOf('editable-cell') < 0) {
|
|
135
|
-
cell.setAttribute('part', part
|
|
135
|
+
cell.setAttribute('part', `${part} editable-cell`);
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
}
|
|
@@ -243,9 +243,11 @@ class GridProEditColumn extends GridColumn {
|
|
|
243
243
|
_setEditorValue(editor, value) {
|
|
244
244
|
const path = this.editorType === 'checkbox' ? 'checked' : this.editorValuePath;
|
|
245
245
|
// FIXME(yuriy): Required for the flow counterpart as it is passing the string value to webcomponent
|
|
246
|
-
value = this.editorType === 'checkbox' && typeof value === 'string' ? value
|
|
246
|
+
value = this.editorType === 'checkbox' && typeof value === 'string' ? value === 'true' : value;
|
|
247
247
|
set(editor, path, value);
|
|
248
|
-
|
|
248
|
+
if (editor.notifyPath) {
|
|
249
|
+
editor.notifyPath(path, value);
|
|
250
|
+
}
|
|
249
251
|
}
|
|
250
252
|
|
|
251
253
|
/**
|
|
@@ -23,16 +23,16 @@ class GridProEditSelect extends Select {
|
|
|
23
23
|
return {
|
|
24
24
|
options: {
|
|
25
25
|
type: Array,
|
|
26
|
-
value: () => []
|
|
26
|
+
value: () => [],
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
_grid: {
|
|
30
|
-
type: Object
|
|
30
|
+
type: Object,
|
|
31
31
|
},
|
|
32
32
|
|
|
33
33
|
_initialized: {
|
|
34
|
-
type: Boolean
|
|
35
|
-
}
|
|
34
|
+
type: Boolean,
|
|
35
|
+
},
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -72,7 +72,9 @@ class GridProEditSelect extends Select {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (event.keyCode === 9) {
|
|
75
|
-
!this._grid.singleCellEdit
|
|
75
|
+
if (!this._grid.singleCellEdit) {
|
|
76
|
+
this._grid._switchEditCell(event);
|
|
77
|
+
}
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
// Call `super` to close overlay on Tab.
|
|
@@ -82,7 +84,7 @@ class GridProEditSelect extends Select {
|
|
|
82
84
|
_valueChanged(value, oldValue) {
|
|
83
85
|
super._valueChanged(value, oldValue);
|
|
84
86
|
|
|
85
|
-
//
|
|
87
|
+
// Select is first created without a value
|
|
86
88
|
if (value === '' && oldValue === undefined) {
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
@@ -123,7 +125,7 @@ class GridProEditSelect extends Select {
|
|
|
123
125
|
// see https://github.com/vaadin/vaadin-list-mixin/issues/49
|
|
124
126
|
setTimeout(() => {
|
|
125
127
|
this.opened = true;
|
|
126
|
-
//
|
|
128
|
+
// Any value change after first open will stop edit
|
|
127
129
|
this._initialized = true;
|
|
128
130
|
});
|
|
129
131
|
}
|
|
@@ -22,7 +22,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
22
22
|
*/
|
|
23
23
|
enterNextRow: {
|
|
24
24
|
type: Boolean,
|
|
25
|
-
notify: true // FIXME(yuriy-fix): needed by Flow counterpart
|
|
25
|
+
notify: true, // FIXME(yuriy-fix): needed by Flow counterpart
|
|
26
26
|
},
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -35,7 +35,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
35
35
|
*/
|
|
36
36
|
singleCellEdit: {
|
|
37
37
|
type: Boolean,
|
|
38
|
-
notify: true // FIXME(yuriy-fix): needed by Flow counterpart
|
|
38
|
+
notify: true, // FIXME(yuriy-fix): needed by Flow counterpart
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -44,13 +44,13 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
44
44
|
* @attr {boolean} edit-on-click
|
|
45
45
|
*/
|
|
46
46
|
editOnClick: {
|
|
47
|
-
type: Boolean
|
|
47
|
+
type: Boolean,
|
|
48
48
|
},
|
|
49
49
|
|
|
50
50
|
/** @private */
|
|
51
51
|
_editingDisabled: {
|
|
52
|
-
type: Boolean
|
|
53
|
-
}
|
|
52
|
+
type: Boolean,
|
|
53
|
+
},
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -63,36 +63,48 @@ 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:
|
|
83
|
-
this.__edited
|
|
83
|
+
if (this.__edited) {
|
|
84
|
+
this._stopEdit(true);
|
|
85
|
+
}
|
|
84
86
|
break;
|
|
85
87
|
case 9:
|
|
86
|
-
this.__edited
|
|
88
|
+
if (this.__edited) {
|
|
89
|
+
this._switchEditCell(e);
|
|
90
|
+
}
|
|
87
91
|
break;
|
|
88
92
|
case 13:
|
|
89
|
-
this.__edited
|
|
93
|
+
if (this.__edited) {
|
|
94
|
+
this._switchEditCell(e);
|
|
95
|
+
} else {
|
|
96
|
+
this._enterEditFromEvent(e);
|
|
97
|
+
}
|
|
90
98
|
break;
|
|
91
99
|
case 32:
|
|
92
|
-
!this.__edited
|
|
100
|
+
if (!this.__edited) {
|
|
101
|
+
this._enterEditFromEvent(e);
|
|
102
|
+
}
|
|
93
103
|
break;
|
|
94
104
|
default:
|
|
95
|
-
e.key && e.key.length === 1
|
|
105
|
+
if (e.key && e.key.length === 1) {
|
|
106
|
+
this._enterEditFromEvent(e, 'text');
|
|
107
|
+
}
|
|
96
108
|
break;
|
|
97
109
|
}
|
|
98
110
|
});
|
|
@@ -117,7 +129,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
117
129
|
}
|
|
118
130
|
});
|
|
119
131
|
|
|
120
|
-
//
|
|
132
|
+
// Dblclick does not work on iOS Safari
|
|
121
133
|
if (this._ios) {
|
|
122
134
|
let firstClickTime;
|
|
123
135
|
let waitingSecondClick = false;
|
|
@@ -179,7 +191,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
179
191
|
/** @private */
|
|
180
192
|
_applyEdit({ path, value, index, item }) {
|
|
181
193
|
this.set(path, value, item);
|
|
182
|
-
this.notifyPath(
|
|
194
|
+
this.notifyPath(`items.${index}.${path}`, value);
|
|
183
195
|
}
|
|
184
196
|
|
|
185
197
|
/** @private */
|
|
@@ -233,7 +245,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
233
245
|
|
|
234
246
|
/** @private */
|
|
235
247
|
_cancelStopEdit() {
|
|
236
|
-
//
|
|
248
|
+
// Stop edit on outside click will always trigger notify resize.
|
|
237
249
|
// when tabbing within same row it might not be needed, so cancel
|
|
238
250
|
if (this._debouncerStopEdit) {
|
|
239
251
|
this._debouncerStopEdit.cancel();
|
|
@@ -281,7 +293,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
281
293
|
|
|
282
294
|
/** @private */
|
|
283
295
|
_onEditorFocusOut() {
|
|
284
|
-
//
|
|
296
|
+
// Schedule stop on editor component focusout
|
|
285
297
|
this._debouncerStopEdit = Debouncer.debounce(this._debouncerStopEdit, animationFrame, this._stopEdit.bind(this));
|
|
286
298
|
}
|
|
287
299
|
|
|
@@ -294,9 +306,9 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
294
306
|
_onGlobalFocusIn(e) {
|
|
295
307
|
const edited = this.__edited;
|
|
296
308
|
if (edited) {
|
|
297
|
-
//
|
|
309
|
+
// Detect focus moving to e.g. vaadin-select-overlay
|
|
298
310
|
const overlay = Array.from(e.composedPath()).filter(
|
|
299
|
-
(node) => node.nodeType === Node.ELEMENT_NODE && /^vaadin-(?!dialog).*-overlay$/i.test(node.localName)
|
|
311
|
+
(node) => node.nodeType === Node.ELEMENT_NODE && /^vaadin-(?!dialog).*-overlay$/i.test(node.localName),
|
|
300
312
|
)[0];
|
|
301
313
|
|
|
302
314
|
if (overlay) {
|
|
@@ -312,7 +324,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
312
324
|
if (this.disabled || this._editingDisabled) {
|
|
313
325
|
return;
|
|
314
326
|
}
|
|
315
|
-
//
|
|
327
|
+
// Cancel debouncer enqueued on focusout
|
|
316
328
|
this._cancelStopEdit();
|
|
317
329
|
|
|
318
330
|
this._scrollHorizontallyToCell(cell);
|
|
@@ -326,10 +338,10 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
326
338
|
detail: {
|
|
327
339
|
index: model.index,
|
|
328
340
|
item: model.item,
|
|
329
|
-
path: column.path
|
|
341
|
+
path: column.path,
|
|
330
342
|
},
|
|
331
|
-
composed: true
|
|
332
|
-
})
|
|
343
|
+
composed: true,
|
|
344
|
+
}),
|
|
333
345
|
);
|
|
334
346
|
this.addEventListener('item-property-changed', this.__boundItemPropertyChanged);
|
|
335
347
|
}
|
|
@@ -363,12 +375,12 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
363
375
|
index: model.index,
|
|
364
376
|
item: model.item,
|
|
365
377
|
path: column.path,
|
|
366
|
-
value
|
|
378
|
+
value,
|
|
367
379
|
},
|
|
368
380
|
bubbles: true,
|
|
369
381
|
cancelable: true,
|
|
370
|
-
composed: true
|
|
371
|
-
})
|
|
382
|
+
composed: true,
|
|
383
|
+
}),
|
|
372
384
|
);
|
|
373
385
|
}
|
|
374
386
|
}
|
|
@@ -411,17 +423,17 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
411
423
|
let nextCol = null;
|
|
412
424
|
let nextIdx = index;
|
|
413
425
|
|
|
414
|
-
//
|
|
426
|
+
// Enter key
|
|
415
427
|
if (e.keyCode === 13) {
|
|
416
428
|
nextCol = column;
|
|
417
429
|
|
|
418
|
-
//
|
|
430
|
+
// Move up / down
|
|
419
431
|
if (this.enterNextRow) {
|
|
420
432
|
nextIdx = e.shiftKey ? index - 1 : index + 1;
|
|
421
433
|
}
|
|
422
434
|
}
|
|
423
435
|
|
|
424
|
-
//
|
|
436
|
+
// Tab: move right / left
|
|
425
437
|
if (e.keyCode === 9) {
|
|
426
438
|
if (e.shiftKey) {
|
|
427
439
|
if (cols[colIndex - 1]) {
|
|
@@ -446,7 +458,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
446
458
|
const nextCell = Array.from(nextRow.children).filter((cell) => cell._column === nextCol)[0];
|
|
447
459
|
e.preventDefault();
|
|
448
460
|
|
|
449
|
-
//
|
|
461
|
+
// Prevent vaadin-grid handler from being called
|
|
450
462
|
e.stopImmediatePropagation();
|
|
451
463
|
|
|
452
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> {
|
|
@@ -78,13 +74,13 @@ declare class GridPro<TItem = GridDefaultItem> extends Grid<TItem> {
|
|
|
78
74
|
addEventListener<K extends keyof GridProEventMap<TItem>>(
|
|
79
75
|
type: K,
|
|
80
76
|
listener: (this: GridPro<TItem>, ev: GridProEventMap<TItem>[K]) => void,
|
|
81
|
-
options?: boolean | AddEventListenerOptions
|
|
77
|
+
options?: boolean | AddEventListenerOptions,
|
|
82
78
|
): void;
|
|
83
79
|
|
|
84
80
|
removeEventListener<K extends keyof GridProEventMap<TItem>>(
|
|
85
81
|
type: K,
|
|
86
82
|
listener: (this: GridPro<TItem>, ev: GridProEventMap<TItem>[K]) => void,
|
|
87
|
-
options?: boolean | EventListenerOptions
|
|
83
|
+
options?: boolean | EventListenerOptions,
|
|
88
84
|
): void;
|
|
89
85
|
}
|
|
90
86
|
|
package/src/vaadin-grid-pro.js
CHANGED
|
@@ -2,5 +2,5 @@ import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mi
|
|
|
2
2
|
import { gridProEditor } from './vaadin-grid-pro-editor-styles.js';
|
|
3
3
|
|
|
4
4
|
registerStyles('vaadin-grid-pro-edit-text-field', gridProEditor, {
|
|
5
|
-
moduleId: 'lumo-grid-pro-edit-text-field'
|
|
5
|
+
moduleId: 'lumo-grid-pro-edit-text-field',
|
|
6
6
|
});
|
|
@@ -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 */
|
|
@@ -51,5 +49,5 @@ registerStyles(
|
|
|
51
49
|
);
|
|
52
50
|
}
|
|
53
51
|
`,
|
|
54
|
-
{ moduleId: 'lumo-grid-pro' }
|
|
52
|
+
{ moduleId: 'lumo-grid-pro' },
|
|
55
53
|
);
|
|
@@ -2,5 +2,5 @@ import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mi
|
|
|
2
2
|
import { gridProEditor } from './vaadin-grid-pro-editor-styles.js';
|
|
3
3
|
|
|
4
4
|
registerStyles('vaadin-grid-pro-edit-text-field', gridProEditor, {
|
|
5
|
-
moduleId: 'material-grid-pro-edit-text-field'
|
|
5
|
+
moduleId: 'material-grid-pro-edit-text-field',
|
|
6
6
|
});
|
|
@@ -16,9 +16,8 @@ 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
|
-
{ moduleId: 'material-grid-pro' }
|
|
22
|
+
{ moduleId: 'material-grid-pro' },
|
|
24
23
|
);
|