@vaadin/grid-pro 24.4.0-dev.4b20a0c55.3 → 24.4.0-rc1
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 -11
- package/src/vaadin-grid-pro-edit-column-mixin.d.ts +18 -0
- package/src/vaadin-grid-pro-edit-column-mixin.js +32 -9
- package/src/vaadin-grid-pro-inline-editing-mixin.js +98 -43
- package/theme/lumo/vaadin-grid-pro-edit-checkbox.d.ts +2 -0
- package/theme/lumo/vaadin-grid-pro-edit-column.d.ts +4 -0
- package/theme/lumo/vaadin-grid-pro-edit-select-styles.d.ts +2 -0
- package/theme/lumo/vaadin-grid-pro-edit-select.d.ts +3 -0
- package/theme/lumo/vaadin-grid-pro-edit-text-field-styles.d.ts +1 -0
- package/theme/lumo/vaadin-grid-pro-edit-text-field.d.ts +3 -0
- package/theme/lumo/vaadin-grid-pro-editor-styles.d.ts +5 -0
- package/theme/lumo/vaadin-grid-pro-styles.d.ts +2 -0
- package/theme/lumo/vaadin-grid-pro.d.ts +3 -0
- package/theme/lumo/vaadin-lit-grid-pro-edit-checkbox.d.ts +2 -0
- package/theme/lumo/vaadin-lit-grid-pro-edit-column.d.ts +4 -0
- package/theme/lumo/vaadin-lit-grid-pro-edit-select.d.ts +3 -0
- package/theme/lumo/vaadin-lit-grid-pro-edit-text-field.d.ts +3 -0
- package/theme/lumo/vaadin-lit-grid-pro.d.ts +3 -0
- package/theme/material/vaadin-grid-pro-edit-checkbox.d.ts +2 -0
- package/theme/material/vaadin-grid-pro-edit-column.d.ts +4 -0
- package/theme/material/vaadin-grid-pro-edit-select-styles.d.ts +1 -0
- package/theme/material/vaadin-grid-pro-edit-select.d.ts +3 -0
- package/theme/material/vaadin-grid-pro-edit-text-field-styles.d.ts +1 -0
- package/theme/material/vaadin-grid-pro-edit-text-field.d.ts +3 -0
- package/theme/material/vaadin-grid-pro-editor-styles.d.ts +2 -0
- package/theme/material/vaadin-grid-pro-styles.d.ts +2 -0
- package/theme/material/vaadin-grid-pro.d.ts +3 -0
- package/theme/material/vaadin-lit-grid-pro-edit-checkbox.d.ts +2 -0
- package/theme/material/vaadin-lit-grid-pro-edit-column.d.ts +4 -0
- package/theme/material/vaadin-lit-grid-pro-edit-select.d.ts +3 -0
- package/theme/material/vaadin-lit-grid-pro-edit-text-field.d.ts +3 -0
- package/theme/material/vaadin-lit-grid-pro.d.ts +3 -0
- package/web-types.json +910 -0
- package/web-types.lit.json +489 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/grid-pro",
|
|
3
|
-
"version": "24.4.0-
|
|
3
|
+
"version": "24.4.0-rc1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
41
41
|
"@polymer/polymer": "^3.0.0",
|
|
42
|
-
"@vaadin/checkbox": "24.4.0-
|
|
43
|
-
"@vaadin/component-base": "24.4.0-
|
|
44
|
-
"@vaadin/grid": "24.4.0-
|
|
45
|
-
"@vaadin/lit-renderer": "24.4.0-
|
|
46
|
-
"@vaadin/select": "24.4.0-
|
|
47
|
-
"@vaadin/text-field": "24.4.0-
|
|
48
|
-
"@vaadin/vaadin-lumo-styles": "24.4.0-
|
|
49
|
-
"@vaadin/vaadin-material-styles": "24.4.0-
|
|
50
|
-
"@vaadin/vaadin-themable-mixin": "24.4.0-
|
|
42
|
+
"@vaadin/checkbox": "24.4.0-rc1",
|
|
43
|
+
"@vaadin/component-base": "24.4.0-rc1",
|
|
44
|
+
"@vaadin/grid": "24.4.0-rc1",
|
|
45
|
+
"@vaadin/lit-renderer": "24.4.0-rc1",
|
|
46
|
+
"@vaadin/select": "24.4.0-rc1",
|
|
47
|
+
"@vaadin/text-field": "24.4.0-rc1",
|
|
48
|
+
"@vaadin/vaadin-lumo-styles": "24.4.0-rc1",
|
|
49
|
+
"@vaadin/vaadin-material-styles": "24.4.0-rc1",
|
|
50
|
+
"@vaadin/vaadin-themable-mixin": "24.4.0-rc1",
|
|
51
51
|
"lit": "^3.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"web-types.json",
|
|
61
61
|
"web-types.lit.json"
|
|
62
62
|
],
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "a81e3b927d44c56613fa4e1307494a2acc81005f"
|
|
64
64
|
}
|
|
@@ -58,6 +58,24 @@ export declare class GridProEditColumnMixinClass<TItem> {
|
|
|
58
58
|
*/
|
|
59
59
|
editorValuePath: string;
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* A function to check whether a specific cell of this column can be
|
|
63
|
+
* edited. This allows to disable editing of individual rows or cells,
|
|
64
|
+
* based on the item.
|
|
65
|
+
*
|
|
66
|
+
* Receives a `model` object containing the item for an individual row,
|
|
67
|
+
* and should return a boolean indicating whether the column's cell in
|
|
68
|
+
* that row is editable.
|
|
69
|
+
*
|
|
70
|
+
* The `model` object contains:
|
|
71
|
+
* - `model.index` The index of the item.
|
|
72
|
+
* - `model.item` The item.
|
|
73
|
+
* - `model.expanded` Sublevel toggle state.
|
|
74
|
+
* - `model.level` Level of the tree represented with a horizontal offset of the toggle button.
|
|
75
|
+
* - `model.selected` Selected state.
|
|
76
|
+
*/
|
|
77
|
+
isCellEditable: (model: GridItemModel<TItem>) => boolean;
|
|
78
|
+
|
|
61
79
|
protected _getEditorComponent(cell: HTMLElement): HTMLElement | null;
|
|
62
80
|
|
|
63
81
|
protected _getEditorValue(editor: HTMLElement): unknown | null;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
9
|
* license.
|
|
10
10
|
*/
|
|
11
|
-
import { addValueToAttribute } from '@vaadin/component-base/src/dom-utils.js';
|
|
12
11
|
import { get, set } from '@vaadin/component-base/src/path-utils.js';
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -84,13 +83,36 @@ export const GridProEditColumnMixin = (superClass) =>
|
|
|
84
83
|
sync: true,
|
|
85
84
|
},
|
|
86
85
|
|
|
86
|
+
/**
|
|
87
|
+
* A function to check whether a specific cell of this column can be
|
|
88
|
+
* edited. This allows to disable editing of individual rows or cells,
|
|
89
|
+
* based on the item.
|
|
90
|
+
*
|
|
91
|
+
* Receives a `model` object containing the item for an individual row,
|
|
92
|
+
* and should return a boolean indicating whether the column's cell in
|
|
93
|
+
* that row is editable.
|
|
94
|
+
*
|
|
95
|
+
* The `model` object contains:
|
|
96
|
+
* - `model.index` The index of the item.
|
|
97
|
+
* - `model.item` The item.
|
|
98
|
+
* - `model.expanded` Sublevel toggle state.
|
|
99
|
+
* - `model.level` Level of the tree represented with a horizontal offset of the toggle button.
|
|
100
|
+
* - `model.selected` Selected state.
|
|
101
|
+
*
|
|
102
|
+
* @type {(model: GridItemModel) => boolean}
|
|
103
|
+
*/
|
|
104
|
+
isCellEditable: {
|
|
105
|
+
type: Function,
|
|
106
|
+
observer: '_isCellEditableChanged',
|
|
107
|
+
},
|
|
108
|
+
|
|
87
109
|
/** @private */
|
|
88
110
|
_oldRenderer: Function,
|
|
89
111
|
};
|
|
90
112
|
}
|
|
91
113
|
|
|
92
114
|
static get observers() {
|
|
93
|
-
return ['_editModeRendererChanged(editModeRenderer, __initialized)'
|
|
115
|
+
return ['_editModeRendererChanged(editModeRenderer, __initialized)'];
|
|
94
116
|
}
|
|
95
117
|
|
|
96
118
|
constructor() {
|
|
@@ -121,11 +143,9 @@ export const GridProEditColumnMixin = (superClass) =>
|
|
|
121
143
|
}
|
|
122
144
|
|
|
123
145
|
/** @private */
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
addValueToAttribute(target, 'part', 'editable-cell');
|
|
128
|
-
});
|
|
146
|
+
_isCellEditableChanged(newValue, oldValue) {
|
|
147
|
+
// Re-render grid to update editable-cell part names
|
|
148
|
+
this._grid.requestContentUpdate();
|
|
129
149
|
}
|
|
130
150
|
|
|
131
151
|
/** @private */
|
|
@@ -267,8 +287,11 @@ export const GridProEditColumnMixin = (superClass) =>
|
|
|
267
287
|
this._setEditorValue(editor, get(this.path, model.item));
|
|
268
288
|
editor._grid = this._grid;
|
|
269
289
|
|
|
270
|
-
|
|
271
|
-
|
|
290
|
+
if (editor.updateComplete) {
|
|
291
|
+
editor.updateComplete.then(() => this._focusEditor(editor));
|
|
292
|
+
} else {
|
|
293
|
+
this._focusEditor(editor);
|
|
294
|
+
}
|
|
272
295
|
}
|
|
273
296
|
|
|
274
297
|
/**
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { animationFrame } from '@vaadin/component-base/src/async.js';
|
|
12
12
|
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
|
|
13
13
|
import { get, set } from '@vaadin/component-base/src/path-utils.js';
|
|
14
|
+
import { iterateRowCells, updatePart } from '@vaadin/grid/src/vaadin-grid-helpers.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @polymerMixin
|
|
@@ -218,6 +219,10 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
218
219
|
return;
|
|
219
220
|
}
|
|
220
221
|
|
|
222
|
+
if (!this._isCellEditable(cell)) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
221
226
|
callback(e);
|
|
222
227
|
}
|
|
223
228
|
});
|
|
@@ -325,8 +330,10 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
325
330
|
|
|
326
331
|
/** @private */
|
|
327
332
|
_startEdit(cell, column) {
|
|
333
|
+
const isCellEditable = this._isCellEditable(cell);
|
|
334
|
+
|
|
328
335
|
// TODO: remove `_editingDisabled` after Flow counterpart is updated.
|
|
329
|
-
if (this.disabled || this._editingDisabled) {
|
|
336
|
+
if (this.disabled || this._editingDisabled || !isCellEditable) {
|
|
330
337
|
return;
|
|
331
338
|
}
|
|
332
339
|
// Cancel debouncer enqueued on focusout
|
|
@@ -421,59 +428,67 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
421
428
|
|
|
422
429
|
this._cancelStopEdit();
|
|
423
430
|
|
|
424
|
-
const
|
|
425
|
-
|
|
431
|
+
const editableColumns = this._getEditColumns();
|
|
426
432
|
const { cell, column, model } = this.__edited;
|
|
427
|
-
const colIndex = cols.indexOf(column);
|
|
428
|
-
const { index } = model;
|
|
429
433
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
434
|
+
this._stopEdit();
|
|
435
|
+
e.preventDefault();
|
|
436
|
+
// Prevent vaadin-grid handler from being called
|
|
437
|
+
e.stopImmediatePropagation();
|
|
438
|
+
|
|
439
|
+
// Try to find the next editable cell
|
|
440
|
+
let nextIndex = model.index;
|
|
441
|
+
let nextColumn = column;
|
|
442
|
+
let nextCell = cell;
|
|
443
|
+
let directionX = 0;
|
|
444
|
+
let directionY = 0;
|
|
445
|
+
|
|
446
|
+
// Enter key: move up / down
|
|
447
|
+
if (e.keyCode === 13 && this.enterNextRow) {
|
|
448
|
+
directionY = e.shiftKey ? -1 : 1;
|
|
441
449
|
}
|
|
442
450
|
|
|
443
451
|
// Tab: move right / left
|
|
444
452
|
if (e.keyCode === 9) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
453
|
+
directionX = e.shiftKey ? -1 : 1;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (directionX || directionY) {
|
|
457
|
+
while (nextCell) {
|
|
458
|
+
if (directionX) {
|
|
459
|
+
// Move horizontally
|
|
460
|
+
nextColumn = editableColumns[editableColumns.indexOf(nextColumn) + directionX];
|
|
461
|
+
if (!nextColumn) {
|
|
462
|
+
// Wrap to the next or previous row
|
|
463
|
+
nextIndex += directionX;
|
|
464
|
+
nextColumn = editableColumns[directionX > 0 ? 0 : editableColumns.length - 1];
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
// Move vertically
|
|
468
|
+
if (directionY) {
|
|
469
|
+
nextIndex += directionY;
|
|
470
|
+
}
|
|
471
|
+
// Stop looking if the next cell is editable
|
|
472
|
+
const nextRow = this._getRowByIndex(nextIndex);
|
|
473
|
+
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
|
474
|
+
nextCell = nextRow && Array.from(nextRow.children).find((cell) => cell._column === nextColumn);
|
|
475
|
+
if (nextCell && this._isCellEditable(nextCell)) {
|
|
476
|
+
break;
|
|
451
477
|
}
|
|
452
|
-
} else if (cols[colIndex + 1]) {
|
|
453
|
-
nextCol = cols[colIndex + 1];
|
|
454
|
-
} else {
|
|
455
|
-
nextIdx = index + 1;
|
|
456
|
-
nextCol = cols[0];
|
|
457
478
|
}
|
|
458
479
|
}
|
|
459
480
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const nextCell = Array.from(nextRow.children).find((cell) => cell._column === nextCol);
|
|
466
|
-
e.preventDefault();
|
|
467
|
-
|
|
468
|
-
// Prevent vaadin-grid handler from being called
|
|
469
|
-
e.stopImmediatePropagation();
|
|
481
|
+
// Focus current cell as fallback
|
|
482
|
+
if (!nextCell) {
|
|
483
|
+
nextCell = cell;
|
|
484
|
+
nextIndex = model.index;
|
|
485
|
+
}
|
|
470
486
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
487
|
+
if (!this.singleCellEdit && nextCell !== cell) {
|
|
488
|
+
this._startEdit(nextCell, nextColumn);
|
|
489
|
+
} else {
|
|
490
|
+
this._ensureScrolledToIndex(nextIndex);
|
|
491
|
+
nextCell.focus();
|
|
477
492
|
}
|
|
478
493
|
}
|
|
479
494
|
|
|
@@ -492,6 +507,46 @@ export const InlineEditingMixin = (superClass) =>
|
|
|
492
507
|
super._updateItem(row, item);
|
|
493
508
|
}
|
|
494
509
|
|
|
510
|
+
/**
|
|
511
|
+
* Override method from `StylingMixin` to apply `editable-cell` part to the
|
|
512
|
+
* cells of edit columns.
|
|
513
|
+
*
|
|
514
|
+
* @override
|
|
515
|
+
*/
|
|
516
|
+
_generateCellPartNames(row, model) {
|
|
517
|
+
super._generateCellPartNames(row, model);
|
|
518
|
+
|
|
519
|
+
iterateRowCells(row, (cell) => {
|
|
520
|
+
const isEditable = this._isCellEditable(cell);
|
|
521
|
+
const target = cell._focusButton || cell;
|
|
522
|
+
updatePart(target, isEditable, 'editable-cell');
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/** @private */
|
|
527
|
+
_isCellEditable(cell) {
|
|
528
|
+
const column = cell._column;
|
|
529
|
+
// Not editable if the column is not an edit column
|
|
530
|
+
if (!this._isEditColumn(column)) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
// Cell is editable by default if isCellEditable is not configured
|
|
534
|
+
if (!column.isCellEditable) {
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
// Otherwise, check isCellEditable function
|
|
538
|
+
const model = this.__getRowModel(cell.parentElement);
|
|
539
|
+
const isEditable = column.isCellEditable(model);
|
|
540
|
+
|
|
541
|
+
// Cancel editing if the cell is currently edited one and becomes no longer editable
|
|
542
|
+
// TODO: should be moved to `_updateItem` when Grid connector is updated to use it.
|
|
543
|
+
if (this.__edited && this.__edited.cell === cell && !isEditable) {
|
|
544
|
+
this._stopEdit(true, true);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
return isEditable;
|
|
548
|
+
}
|
|
549
|
+
|
|
495
550
|
/**
|
|
496
551
|
* Fired before exiting the cell edit mode, if the value has been changed.
|
|
497
552
|
* If the default is prevented, value change would not be applied.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|