@vaadin/grid-pro 24.3.0-alpha8 → 24.3.0-beta1
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 +11 -13
- package/src/vaadin-grid-pro-edit-column-mixin.d.ts +68 -0
- package/src/vaadin-grid-pro-edit-column-mixin.js +284 -0
- package/src/vaadin-grid-pro-edit-column.d.ts +9 -56
- package/src/vaadin-grid-pro-edit-column.js +3 -263
- package/src/vaadin-grid-pro-edit-select-mixin.js +119 -0
- package/src/vaadin-grid-pro-edit-select.js +3 -115
- package/src/vaadin-grid-pro-inline-editing-mixin.js +4 -3
- package/src/vaadin-lit-grid-pro-edit-checkbox.js +28 -0
- package/src/vaadin-lit-grid-pro-edit-column.js +34 -0
- package/src/vaadin-lit-grid-pro-edit-select.js +29 -0
- package/src/vaadin-lit-grid-pro-edit-text-field.js +33 -0
- package/src/vaadin-lit-grid-pro.js +35 -0
- package/theme/lumo/vaadin-grid-pro-edit-select.js +0 -2
- package/theme/lumo/vaadin-lit-grid-pro-edit-checkbox.js +2 -0
- package/theme/lumo/vaadin-lit-grid-pro-edit-column.js +4 -0
- package/theme/lumo/vaadin-lit-grid-pro-edit-select.js +3 -0
- package/theme/lumo/vaadin-lit-grid-pro-edit-text-field.js +3 -0
- package/theme/lumo/vaadin-lit-grid-pro.js +3 -0
- package/theme/material/vaadin-grid-pro-edit-select.js +0 -2
- package/theme/material/vaadin-lit-grid-pro-edit-checkbox.js +2 -0
- package/theme/material/vaadin-lit-grid-pro-edit-column.js +4 -0
- package/theme/material/vaadin-lit-grid-pro-edit-select.js +3 -0
- package/theme/material/vaadin-lit-grid-pro-edit-text-field.js +3 -0
- package/theme/material/vaadin-lit-grid-pro.js +3 -0
- package/vaadin-lit-grid-pro-edit-column.d.ts +1 -0
- package/vaadin-lit-grid-pro-edit-column.js +3 -0
- package/vaadin-lit-grid-pro.d.ts +1 -0
- package/vaadin-lit-grid-pro.js +3 -0
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
|
@@ -11,10 +11,9 @@
|
|
|
11
11
|
import './vaadin-grid-pro-edit-checkbox.js';
|
|
12
12
|
import './vaadin-grid-pro-edit-select.js';
|
|
13
13
|
import './vaadin-grid-pro-edit-text-field.js';
|
|
14
|
-
import { get, set } from '@polymer/polymer/lib/utils/path.js';
|
|
15
14
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
16
|
-
import { addValueToAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
17
15
|
import { GridColumn } from '@vaadin/grid/src/vaadin-grid-column.js';
|
|
16
|
+
import { GridProEditColumnMixin } from './vaadin-grid-pro-edit-column-mixin.js';
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* `<vaadin-grid-pro-edit-column>` is a helper element for the `<vaadin-grid-pro>`
|
|
@@ -33,271 +32,12 @@ import { GridColumn } from '@vaadin/grid/src/vaadin-grid-column.js';
|
|
|
33
32
|
*
|
|
34
33
|
* @customElement
|
|
35
34
|
* @extends GridColumn
|
|
35
|
+
* @mixes GridProEditColumnMixin
|
|
36
36
|
*/
|
|
37
|
-
class GridProEditColumn extends GridColumn {
|
|
37
|
+
class GridProEditColumn extends GridProEditColumnMixin(GridColumn) {
|
|
38
38
|
static get is() {
|
|
39
39
|
return 'vaadin-grid-pro-edit-column';
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
static get properties() {
|
|
43
|
-
return {
|
|
44
|
-
/**
|
|
45
|
-
* Custom function for rendering the cell content in edit mode.
|
|
46
|
-
* Receives three arguments:
|
|
47
|
-
*
|
|
48
|
-
* - `root` The cell content DOM element. Append your editor component to it.
|
|
49
|
-
* - `column` The `<vaadin-grid-pro-edit-column>` element.
|
|
50
|
-
* - `model` The object with the properties related with
|
|
51
|
-
* the rendered item, contains:
|
|
52
|
-
* - `model.index` The index of the item.
|
|
53
|
-
* - `model.item` The item.
|
|
54
|
-
* - `model.expanded` Sublevel toggle state.
|
|
55
|
-
* - `model.level` Level of the tree represented with a horizontal offset of the toggle button.
|
|
56
|
-
* - `model.selected` Selected state.
|
|
57
|
-
* - `model.detailsOpened` Details opened state.
|
|
58
|
-
* @type {!GridBodyRenderer | null | undefined}
|
|
59
|
-
*/
|
|
60
|
-
editModeRenderer: Function,
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The list of options which should be passed to cell editor component.
|
|
64
|
-
* Used with the `select` editor type, to provide a list of items.
|
|
65
|
-
* @type {!Array<string>}
|
|
66
|
-
*/
|
|
67
|
-
editorOptions: {
|
|
68
|
-
type: Array,
|
|
69
|
-
value: () => [],
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Type of the cell editor component to be rendered. Allowed values:
|
|
74
|
-
* - `text` (default) - renders a text field
|
|
75
|
-
* - `checkbox` - renders a checkbox
|
|
76
|
-
* - `select` - renders a select with a list of items passed as `editorOptions`
|
|
77
|
-
*
|
|
78
|
-
* Editor type is set to `custom` when `editModeRenderer` is set.
|
|
79
|
-
* @attr {text|checkbox|select|custom} editor-type
|
|
80
|
-
* @type {!GridProEditorType}
|
|
81
|
-
*/
|
|
82
|
-
editorType: {
|
|
83
|
-
type: String,
|
|
84
|
-
notify: true, // FIXME(web-padawan): needed by Flow counterpart
|
|
85
|
-
value: 'text',
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Path of the property used for the value of the editor component.
|
|
90
|
-
* @attr {string} editor-value-path
|
|
91
|
-
* @type {string}
|
|
92
|
-
*/
|
|
93
|
-
editorValuePath: {
|
|
94
|
-
type: String,
|
|
95
|
-
value: 'value',
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* JS Path of the property in the item used for the editable content.
|
|
100
|
-
*/
|
|
101
|
-
path: {
|
|
102
|
-
type: String,
|
|
103
|
-
observer: '_pathChanged',
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
/** @private */
|
|
107
|
-
_oldRenderer: Function,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
static get observers() {
|
|
112
|
-
return ['_editModeRendererChanged(editModeRenderer, __initialized)', '_cellsChanged(_cells.*)'];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
constructor() {
|
|
116
|
-
super();
|
|
117
|
-
|
|
118
|
-
// Enable focus button mode for Mac OS to ensure focused
|
|
119
|
-
// editable cell stays in sync with the VoiceOver cursor
|
|
120
|
-
// https://github.com/vaadin/web-components/issues/3820
|
|
121
|
-
this._focusButtonMode = navigator.platform.includes('Mac');
|
|
122
|
-
|
|
123
|
-
this.__editModeRenderer = function (root, column) {
|
|
124
|
-
const cell = root.assignedSlot.parentNode;
|
|
125
|
-
|
|
126
|
-
const tagName = column._getEditorTagName(cell);
|
|
127
|
-
if (!root.firstElementChild || root.firstElementChild.localName.toLowerCase() !== tagName) {
|
|
128
|
-
root.innerHTML = `
|
|
129
|
-
<${tagName}></${tagName}>
|
|
130
|
-
`;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** @private */
|
|
136
|
-
_pathChanged(path) {
|
|
137
|
-
if (!path || path.length === 0) {
|
|
138
|
-
throw new Error('You should specify the path for the edit column');
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** @private */
|
|
143
|
-
_cellsChanged() {
|
|
144
|
-
this._cells.forEach((cell) => {
|
|
145
|
-
const target = cell._focusButton || cell;
|
|
146
|
-
addValueToAttribute(target, 'part', 'editable-cell');
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/** @private */
|
|
151
|
-
_editModeRendererChanged(renderer) {
|
|
152
|
-
if (renderer) {
|
|
153
|
-
this.editorType = 'custom';
|
|
154
|
-
} else if (this._oldRenderer) {
|
|
155
|
-
this.editorType = 'text';
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
this._oldRenderer = renderer;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @param {!HTMLElement} cell
|
|
163
|
-
* @return {string}
|
|
164
|
-
* @protected
|
|
165
|
-
*/
|
|
166
|
-
_getEditorTagName(cell) {
|
|
167
|
-
return this.editorType === 'custom' ? this._getEditorComponent(cell).localName : this._getTagNameByType();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* @param {!HTMLElement} cell
|
|
172
|
-
* @return {HTMLElement | null}
|
|
173
|
-
* @protected
|
|
174
|
-
*/
|
|
175
|
-
_getEditorComponent(cell) {
|
|
176
|
-
return this.editorType === 'custom'
|
|
177
|
-
? cell._content.firstElementChild
|
|
178
|
-
: cell._content.querySelector(this._getEditorTagName(cell));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** @private */
|
|
182
|
-
_getTagNameByType() {
|
|
183
|
-
let type;
|
|
184
|
-
switch (this.editorType) {
|
|
185
|
-
case 'checkbox':
|
|
186
|
-
type = 'checkbox';
|
|
187
|
-
break;
|
|
188
|
-
case 'select':
|
|
189
|
-
type = 'select';
|
|
190
|
-
break;
|
|
191
|
-
case 'text':
|
|
192
|
-
default:
|
|
193
|
-
type = 'text-field';
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
return this.constructor.is.replace('column', type);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** @private */
|
|
200
|
-
_focusEditor(editor) {
|
|
201
|
-
editor.focus();
|
|
202
|
-
if (this.editorType === 'checkbox') {
|
|
203
|
-
editor.setAttribute('focus-ring', '');
|
|
204
|
-
} else if (editor instanceof HTMLInputElement) {
|
|
205
|
-
editor.select();
|
|
206
|
-
} else if (editor.focusElement && editor.focusElement instanceof HTMLInputElement) {
|
|
207
|
-
editor.focusElement.select();
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* @param {!HTMLElement} editor
|
|
213
|
-
* @return {unknown}
|
|
214
|
-
* @protected
|
|
215
|
-
*/
|
|
216
|
-
_getEditorValue(editor) {
|
|
217
|
-
const path = this.editorType === 'checkbox' ? 'checked' : this.editorValuePath;
|
|
218
|
-
return get(editor, path);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/** @private */
|
|
222
|
-
_renderEditor(cell, model) {
|
|
223
|
-
cell.__savedRenderer = this._renderer || cell._renderer;
|
|
224
|
-
cell._renderer = this.editModeRenderer || this.__editModeRenderer;
|
|
225
|
-
|
|
226
|
-
// Remove role to avoid announcing button while editing
|
|
227
|
-
if (cell._focusButton) {
|
|
228
|
-
cell._focusButton.removeAttribute('role');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
this._clearCellContent(cell);
|
|
232
|
-
this._runRenderer(cell._renderer, cell, model);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** @private */
|
|
236
|
-
_removeEditor(cell, _model) {
|
|
237
|
-
if (!cell.__savedRenderer) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
cell._renderer = cell.__savedRenderer;
|
|
242
|
-
cell.__savedRenderer = undefined;
|
|
243
|
-
|
|
244
|
-
this._clearCellContent(cell);
|
|
245
|
-
|
|
246
|
-
// Restore previously removed role attribute
|
|
247
|
-
if (cell._focusButton) {
|
|
248
|
-
cell._focusButton.setAttribute('role', 'button');
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
this.__renderCellsContent(cell._renderer, [cell]);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** @private */
|
|
255
|
-
_setEditorOptions(editor) {
|
|
256
|
-
if (this.editorOptions && this.editorOptions.length) {
|
|
257
|
-
editor.options = this.editorOptions;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/** @private */
|
|
262
|
-
_setEditorValue(editor, value) {
|
|
263
|
-
const path = this.editorType === 'checkbox' ? 'checked' : this.editorValuePath;
|
|
264
|
-
// FIXME(yuriy): Required for the flow counterpart as it is passing the string value to webcomponent
|
|
265
|
-
value = this.editorType === 'checkbox' && typeof value === 'string' ? value === 'true' : value;
|
|
266
|
-
set(editor, path, value);
|
|
267
|
-
if (editor.notifyPath) {
|
|
268
|
-
editor.notifyPath(path, value);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* @param {!HTMLElement} cell
|
|
274
|
-
* @param {!GridItemModel} model
|
|
275
|
-
* @protected
|
|
276
|
-
*/
|
|
277
|
-
_startCellEdit(cell, model) {
|
|
278
|
-
this._renderEditor(cell, model);
|
|
279
|
-
|
|
280
|
-
const editor = this._getEditorComponent(cell);
|
|
281
|
-
editor.addEventListener('focusout', this._grid.__boundEditorFocusOut);
|
|
282
|
-
editor.addEventListener('focusin', this._grid.__boundEditorFocusIn);
|
|
283
|
-
editor.addEventListener('internal-tab', this._grid.__boundCancelCellSwitch);
|
|
284
|
-
document.body.addEventListener('focusin', this._grid.__boundGlobalFocusIn);
|
|
285
|
-
this._setEditorOptions(editor);
|
|
286
|
-
this._setEditorValue(editor, get(model.item, this.path));
|
|
287
|
-
editor._grid = this._grid;
|
|
288
|
-
this._focusEditor(editor);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* @param {!HTMLElement} cell
|
|
293
|
-
* @param {!GridItemModel} model
|
|
294
|
-
* @protected
|
|
295
|
-
*/
|
|
296
|
-
_stopCellEdit(cell, model) {
|
|
297
|
-
document.body.removeEventListener('focusin', this._grid.__boundGlobalFocusIn);
|
|
298
|
-
|
|
299
|
-
this._removeEditor(cell, model);
|
|
300
|
-
}
|
|
301
41
|
}
|
|
302
42
|
|
|
303
43
|
defineCustomElement(GridProEditColumn);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2023 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @polymerMixin
|
|
14
|
+
*/
|
|
15
|
+
export const GridProEditSelectMixin = (superClass) =>
|
|
16
|
+
class extends superClass {
|
|
17
|
+
static get properties() {
|
|
18
|
+
return {
|
|
19
|
+
options: {
|
|
20
|
+
type: Array,
|
|
21
|
+
value: () => [],
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
_grid: {
|
|
25
|
+
type: Object,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
_initialized: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static get observers() {
|
|
35
|
+
return ['_optionsChanged(options)'];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ready() {
|
|
39
|
+
super.ready();
|
|
40
|
+
|
|
41
|
+
this.setAttribute('theme', 'grid-pro-editor');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_onKeyDown(e) {
|
|
45
|
+
super._onKeyDown(e);
|
|
46
|
+
|
|
47
|
+
if (this.options.length === 0 && /^(ArrowDown|Down|ArrowUp|Up|Enter|SpaceBar| )$/u.test(e.key)) {
|
|
48
|
+
console.warn('Missing "editorOptions" for <vaadin-grid-pro-edit-column> select editor!');
|
|
49
|
+
}
|
|
50
|
+
// Event handled in select, stop here
|
|
51
|
+
if (e.defaultPrevented) {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Override list-box event listener inherited from `Select`:
|
|
58
|
+
* - Enter: set flag for moving to next row on value change,
|
|
59
|
+
* - Tab: switch to next cell when "singleCellEdit" is false.
|
|
60
|
+
* @param {!KeyboardEvent} event
|
|
61
|
+
* @protected
|
|
62
|
+
* @override
|
|
63
|
+
*/
|
|
64
|
+
_onKeyDownInside(event) {
|
|
65
|
+
if (event.keyCode === 13) {
|
|
66
|
+
this._enterKeydown = event;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (event.keyCode === 9) {
|
|
70
|
+
if (!this._grid.singleCellEdit) {
|
|
71
|
+
this._grid._switchEditCell(event);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Call `super` to close overlay on Tab.
|
|
76
|
+
super._onKeyDownInside(event);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_valueChanged(value, oldValue) {
|
|
80
|
+
super._valueChanged(value, oldValue);
|
|
81
|
+
|
|
82
|
+
// Select is first created without a value
|
|
83
|
+
if (value === '' && oldValue === undefined) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (this._initialized) {
|
|
87
|
+
const enter = this._enterKeydown;
|
|
88
|
+
if (enter && this._grid.enterNextRow) {
|
|
89
|
+
this._grid._switchEditCell(enter);
|
|
90
|
+
} else if (this._grid.singleCellEdit) {
|
|
91
|
+
this._grid._stopEdit(false, true);
|
|
92
|
+
} else {
|
|
93
|
+
this.focus();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
_optionsChanged(options) {
|
|
99
|
+
if (options && options.length) {
|
|
100
|
+
this.items = options.map((option) => ({
|
|
101
|
+
label: option,
|
|
102
|
+
value: option,
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
this._overlayElement ||= this.shadowRoot.querySelector('vaadin-select-overlay');
|
|
106
|
+
this._overlayElement.addEventListener('vaadin-overlay-outside-click', () => {
|
|
107
|
+
this._grid._stopEdit();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// FIXME(web-padawan): _updateValueSlot() in `vaadin-select` resets opened to false
|
|
111
|
+
// see https://github.com/vaadin/vaadin-list-mixin/issues/49
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
this.opened = true;
|
|
114
|
+
// Any value change after first open will stop edit
|
|
115
|
+
this._initialized = true;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
@@ -8,134 +8,22 @@
|
|
|
8
8
|
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
9
|
* license.
|
|
10
10
|
*/
|
|
11
|
-
import '@vaadin/item/src/vaadin-item.js';
|
|
12
|
-
import '@vaadin/list-box/src/vaadin-list-box.js';
|
|
13
11
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
14
12
|
import { Select } from '@vaadin/select/src/vaadin-select.js';
|
|
13
|
+
import { GridProEditSelectMixin } from './vaadin-grid-pro-edit-select-mixin.js';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* An element used internally by `<vaadin-grid-pro>`. Not intended to be used separately.
|
|
18
17
|
*
|
|
19
18
|
* @customElement
|
|
20
19
|
* @extends Select
|
|
20
|
+
* @mixes GridProEditSelectMixin
|
|
21
21
|
* @private
|
|
22
22
|
*/
|
|
23
|
-
class GridProEditSelect extends Select {
|
|
23
|
+
class GridProEditSelect extends GridProEditSelectMixin(Select) {
|
|
24
24
|
static get is() {
|
|
25
25
|
return 'vaadin-grid-pro-edit-select';
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
static get properties() {
|
|
29
|
-
return {
|
|
30
|
-
options: {
|
|
31
|
-
type: Array,
|
|
32
|
-
value: () => [],
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
_grid: {
|
|
36
|
-
type: Object,
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
_initialized: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static get observers() {
|
|
46
|
-
return ['_optionsChanged(options)'];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
ready() {
|
|
50
|
-
super.ready();
|
|
51
|
-
|
|
52
|
-
this.setAttribute('theme', 'grid-pro-editor');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
_onKeyDown(e) {
|
|
56
|
-
super._onKeyDown(e);
|
|
57
|
-
|
|
58
|
-
if (this.options.length === 0 && /^(ArrowDown|Down|ArrowUp|Up|Enter|SpaceBar| )$/u.test(e.key)) {
|
|
59
|
-
console.warn('Missing "editorOptions" for <vaadin-grid-pro-edit-column> select editor!');
|
|
60
|
-
}
|
|
61
|
-
// Event handled in select, stop here
|
|
62
|
-
if (e.defaultPrevented) {
|
|
63
|
-
e.stopPropagation();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Override list-box event listener inherited from `Select`:
|
|
69
|
-
* - Enter: set flag for moving to next row on value change,
|
|
70
|
-
* - Tab: switch to next cell when "singleCellEdit" is false.
|
|
71
|
-
* @param {!KeyboardEvent} event
|
|
72
|
-
* @protected
|
|
73
|
-
* @override
|
|
74
|
-
*/
|
|
75
|
-
_onKeyDownInside(event) {
|
|
76
|
-
if (event.keyCode === 13) {
|
|
77
|
-
this._enterKeydown = event;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (event.keyCode === 9) {
|
|
81
|
-
if (!this._grid.singleCellEdit) {
|
|
82
|
-
this._grid._switchEditCell(event);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Call `super` to close overlay on Tab.
|
|
87
|
-
super._onKeyDownInside(event);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
_valueChanged(value, oldValue) {
|
|
91
|
-
super._valueChanged(value, oldValue);
|
|
92
|
-
|
|
93
|
-
// Select is first created without a value
|
|
94
|
-
if (value === '' && oldValue === undefined) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (this._initialized) {
|
|
98
|
-
const enter = this._enterKeydown;
|
|
99
|
-
if (enter && this._grid.enterNextRow) {
|
|
100
|
-
this._grid._switchEditCell(enter);
|
|
101
|
-
} else if (this._grid.singleCellEdit) {
|
|
102
|
-
this._grid._stopEdit(false, true);
|
|
103
|
-
} else {
|
|
104
|
-
this.focus();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
_optionsChanged(options) {
|
|
110
|
-
if (options && options.length) {
|
|
111
|
-
this.renderer = (root) => {
|
|
112
|
-
if (root.firstChild) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const listBox = document.createElement('vaadin-list-box');
|
|
116
|
-
listBox.selected = options.indexOf(this.value);
|
|
117
|
-
options.forEach((option) => {
|
|
118
|
-
const item = document.createElement('vaadin-item');
|
|
119
|
-
item.textContent = option;
|
|
120
|
-
listBox.appendChild(item);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
root.appendChild(listBox);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
this._overlayElement.addEventListener('vaadin-overlay-outside-click', () => {
|
|
127
|
-
this._grid._stopEdit();
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// FIXME(web-padawan): _updateValueSlot() in `vaadin-select` resets opened to false
|
|
131
|
-
// see https://github.com/vaadin/vaadin-list-mixin/issues/49
|
|
132
|
-
setTimeout(() => {
|
|
133
|
-
this.opened = true;
|
|
134
|
-
// Any value change after first open will stop edit
|
|
135
|
-
this._initialized = true;
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
27
|
}
|
|
140
28
|
|
|
141
29
|
defineCustomElement(GridProEditSelect);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { animationFrame } from '@vaadin/component-base/src/async.js';
|
|
12
12
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
13
|
+
import { get, set } from '@vaadin/component-base/src/path-utils.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @polymerMixin
|
|
@@ -194,8 +195,8 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
194
195
|
|
|
195
196
|
/** @private */
|
|
196
197
|
_applyEdit({ path, value, index, item }) {
|
|
197
|
-
|
|
198
|
-
this.
|
|
198
|
+
set(path, value, item);
|
|
199
|
+
this.requestContentUpdate();
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
/** @private */
|
|
@@ -365,7 +366,7 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
365
366
|
const editor = column._getEditorComponent(cell);
|
|
366
367
|
if (editor) {
|
|
367
368
|
const value = column._getEditorValue(editor);
|
|
368
|
-
if (value !==
|
|
369
|
+
if (value !== get(column.path, model.item)) {
|
|
369
370
|
// In some cases, where the value comes from the editor's change
|
|
370
371
|
// event (eg. custom editor in vaadin-grid-pro-flow), the event is
|
|
371
372
|
// not dispatched in FF/Safari/Edge. That's due the change event
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2023 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import { Checkbox } from '@vaadin/checkbox/src/vaadin-lit-checkbox.js';
|
|
12
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* LitElement based version of `<vaadin-grid-pro-edit-checkbox>` web component.
|
|
16
|
+
*
|
|
17
|
+
* ## Disclaimer
|
|
18
|
+
*
|
|
19
|
+
* This component is an experiment not intended for publishing to npm.
|
|
20
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
21
|
+
*/
|
|
22
|
+
class GridProEditCheckbox extends Checkbox {
|
|
23
|
+
static get is() {
|
|
24
|
+
return 'vaadin-grid-pro-edit-checkbox';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
defineCustomElement(GridProEditCheckbox);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2023 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import './vaadin-lit-grid-pro-edit-checkbox.js';
|
|
12
|
+
import './vaadin-lit-grid-pro-edit-select.js';
|
|
13
|
+
import './vaadin-lit-grid-pro-edit-text-field.js';
|
|
14
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
15
|
+
import { GridColumn } from '@vaadin/grid/src/vaadin-lit-grid-column.js';
|
|
16
|
+
import { GridProEditColumnMixin } from './vaadin-grid-pro-edit-column-mixin.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* LitElement based version of `<vaadin-grid-pro-edit-column>` web component.
|
|
20
|
+
*
|
|
21
|
+
* ## Disclaimer
|
|
22
|
+
*
|
|
23
|
+
* This component is an experiment not intended for publishing to npm.
|
|
24
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
25
|
+
*/
|
|
26
|
+
class GridProEditColumn extends GridProEditColumnMixin(GridColumn) {
|
|
27
|
+
static get is() {
|
|
28
|
+
return 'vaadin-grid-pro-edit-column';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
defineCustomElement(GridProEditColumn);
|
|
33
|
+
|
|
34
|
+
export { GridProEditColumn };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2023 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
12
|
+
import { Select } from '@vaadin/select/src/vaadin-lit-select.js';
|
|
13
|
+
import { GridProEditSelectMixin } from './vaadin-grid-pro-edit-select-mixin.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* LitElement based version of `<vaadin-grid-pro-edit-select>` web component.
|
|
17
|
+
*
|
|
18
|
+
* ## Disclaimer
|
|
19
|
+
*
|
|
20
|
+
* This component is an experiment not intended for publishing to npm.
|
|
21
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
22
|
+
*/
|
|
23
|
+
class GridProEditSelect extends GridProEditSelectMixin(Select) {
|
|
24
|
+
static get is() {
|
|
25
|
+
return 'vaadin-grid-pro-edit-select';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
defineCustomElement(GridProEditSelect);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2000 - 2023 Vaadin Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
+
* license.
|
|
10
|
+
*/
|
|
11
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
12
|
+
import { TextField } from '@vaadin/text-field/src/vaadin-lit-text-field.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* LitElement based version of `<vaadin-grid-pro-edit-text-field>` web component.
|
|
16
|
+
*
|
|
17
|
+
* ## Disclaimer
|
|
18
|
+
*
|
|
19
|
+
* This component is an experiment not intended for publishing to npm.
|
|
20
|
+
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
21
|
+
*/
|
|
22
|
+
class GridProEditText extends TextField {
|
|
23
|
+
static get is() {
|
|
24
|
+
return 'vaadin-grid-pro-edit-text-field';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
ready() {
|
|
28
|
+
super.ready();
|
|
29
|
+
this.setAttribute('theme', 'grid-pro-editor');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
defineCustomElement(GridProEditText);
|