@vaadin/crud 24.1.0 → 24.2.0-alpha1
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 +13 -13
- package/src/vaadin-crud-dialog.js +1 -4
- package/src/vaadin-crud-grid.js +25 -0
- package/src/vaadin-crud.d.ts +1 -1
- package/src/vaadin-crud.js +112 -50
- package/web-types.json +6 -6
- package/web-types.lit.json +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/crud",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.2.0-alpha1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,20 +37,20 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
39
|
"@polymer/polymer": "^3.0.0",
|
|
40
|
-
"@vaadin/button": "
|
|
41
|
-
"@vaadin/component-base": "
|
|
42
|
-
"@vaadin/confirm-dialog": "
|
|
43
|
-
"@vaadin/dialog": "
|
|
44
|
-
"@vaadin/form-layout": "
|
|
45
|
-
"@vaadin/grid": "
|
|
46
|
-
"@vaadin/text-field": "
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
48
|
-
"@vaadin/vaadin-material-styles": "
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
40
|
+
"@vaadin/button": "24.2.0-alpha1",
|
|
41
|
+
"@vaadin/component-base": "24.2.0-alpha1",
|
|
42
|
+
"@vaadin/confirm-dialog": "24.2.0-alpha1",
|
|
43
|
+
"@vaadin/dialog": "24.2.0-alpha1",
|
|
44
|
+
"@vaadin/form-layout": "24.2.0-alpha1",
|
|
45
|
+
"@vaadin/grid": "24.2.0-alpha1",
|
|
46
|
+
"@vaadin/text-field": "24.2.0-alpha1",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "24.2.0-alpha1",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "24.2.0-alpha1",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "24.2.0-alpha1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@esm-bundle/chai": "^4.3.4",
|
|
53
|
-
"@vaadin/testing-helpers": "^0.4.
|
|
53
|
+
"@vaadin/testing-helpers": "^0.4.2",
|
|
54
54
|
"sinon": "^13.0.2"
|
|
55
55
|
},
|
|
56
56
|
"cvdlName": "vaadin-crud",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"web-types.json",
|
|
59
59
|
"web-types.lit.json"
|
|
60
60
|
],
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "0dbb118320203ab6c0c07450a3e718815367589f"
|
|
62
62
|
}
|
package/src/vaadin-crud-grid.js
CHANGED
|
@@ -13,6 +13,7 @@ import '@vaadin/grid/src/vaadin-grid-column-group.js';
|
|
|
13
13
|
import '@vaadin/grid/src/vaadin-grid-sorter.js';
|
|
14
14
|
import '@vaadin/grid/src/vaadin-grid-filter.js';
|
|
15
15
|
import './vaadin-crud-edit-column.js';
|
|
16
|
+
import { getClosestElement } from '@vaadin/component-base/src/dom-utils.js';
|
|
16
17
|
import { Grid } from '@vaadin/grid/src/vaadin-grid.js';
|
|
17
18
|
import { capitalize, getProperty } from './vaadin-crud-helpers.js';
|
|
18
19
|
import { IncludedMixin } from './vaadin-crud-include-mixin.js';
|
|
@@ -58,6 +59,30 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
58
59
|
return ['__onItemsChange(items)', '__onHideEditColumnChange(hideEditColumn)'];
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/** @protected */
|
|
63
|
+
_getRowContainingNode(node) {
|
|
64
|
+
const content = getClosestElement('vaadin-grid-cell-content', node);
|
|
65
|
+
if (!content) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const cell = content.assignedSlot.parentElement;
|
|
70
|
+
return cell.parentElement;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @protected */
|
|
74
|
+
_isItemAssigedToRow(item, row) {
|
|
75
|
+
const model = this.__getRowModel(row);
|
|
76
|
+
return this.getItemId(item) === this.getItemId(model.item);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @protected */
|
|
80
|
+
_focusFirstVisibleRow() {
|
|
81
|
+
const row = this.__getFirstVisibleItem();
|
|
82
|
+
this.__rowFocusMode = true;
|
|
83
|
+
row.focus();
|
|
84
|
+
}
|
|
85
|
+
|
|
61
86
|
/** @private */
|
|
62
87
|
__onItemsChange(items) {
|
|
63
88
|
if ((!this.dataProvider || this.dataProvider === this._arrayDataProvider) && !this.include && items && items[0]) {
|
package/src/vaadin-crud.d.ts
CHANGED
|
@@ -250,7 +250,7 @@ export type CrudEventMap<T> = CrudCustomEventMap<T> & HTMLElementEventMap;
|
|
|
250
250
|
* --vaadin-crud-editor-max-height | max height of editor when opened on the bottom | 40%
|
|
251
251
|
* --vaadin-crud-editor-max-width | max width of editor when opened on the side | 40%
|
|
252
252
|
*
|
|
253
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/
|
|
253
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
254
254
|
*
|
|
255
255
|
* @fires {CustomEvent} editor-opened-changed - Fired when the `editorOpened` property changes.
|
|
256
256
|
* @fires {CustomEvent} edited-item-changed - Fired when `editedItem` property changes.
|
package/src/vaadin-crud.js
CHANGED
|
@@ -17,6 +17,7 @@ import './vaadin-crud-form.js';
|
|
|
17
17
|
import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
|
|
18
18
|
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
19
19
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
20
|
+
import { FocusRestorationController } from '@vaadin/a11y-base/src/focus-restoration-controller.js';
|
|
20
21
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
21
22
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
22
23
|
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
@@ -25,16 +26,48 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
25
26
|
import { getProperty, setProperty } from './vaadin-crud-helpers.js';
|
|
26
27
|
|
|
27
28
|
/**
|
|
29
|
+
* A controller for initializing slotted button.
|
|
28
30
|
* @private
|
|
29
|
-
* A to initialize slotted button.
|
|
30
31
|
*/
|
|
31
32
|
class ButtonSlotController extends SlotController {
|
|
32
33
|
constructor(host, type, theme) {
|
|
33
|
-
super(host, `${type}-button`, 'vaadin-button'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
super(host, `${type}-button`, 'vaadin-button');
|
|
35
|
+
|
|
36
|
+
this.type = type;
|
|
37
|
+
this.theme = theme;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Override method inherited from `SlotController`
|
|
42
|
+
* to mark custom slotted button as the default.
|
|
43
|
+
*
|
|
44
|
+
* @param {Node} node
|
|
45
|
+
* @protected
|
|
46
|
+
* @override
|
|
47
|
+
*/
|
|
48
|
+
initNode(node) {
|
|
49
|
+
// Needed by Flow counterpart to apply i18n to custom button
|
|
50
|
+
if (node._isDefault) {
|
|
51
|
+
this.defaultNode = node;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (node === this.defaultNode) {
|
|
55
|
+
node.setAttribute('theme', this.theme);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const { host, type } = this;
|
|
59
|
+
const property = `_${type}Button`;
|
|
60
|
+
const listener = `__${type}`;
|
|
61
|
+
|
|
62
|
+
// TODO: restore default button when a corresponding slotted button is removed.
|
|
63
|
+
// This would require us to detect where to insert a button after teleporting it,
|
|
64
|
+
// which happens after opening a dialog and closing it (default editor position).
|
|
65
|
+
if (host[property] && host[property] !== node) {
|
|
66
|
+
host[property].remove();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
node.addEventListener('click', host[listener]);
|
|
70
|
+
host[property] = node;
|
|
38
71
|
}
|
|
39
72
|
}
|
|
40
73
|
|
|
@@ -168,7 +201,7 @@ class ButtonSlotController extends SlotController {
|
|
|
168
201
|
* --vaadin-crud-editor-max-height | max height of editor when opened on the bottom | 40%
|
|
169
202
|
* --vaadin-crud-editor-max-width | max width of editor when opened on the side | 40%
|
|
170
203
|
*
|
|
171
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/
|
|
204
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
172
205
|
*
|
|
173
206
|
* @fires {CustomEvent} editor-opened-changed - Fired when the `editorOpened` property changes.
|
|
174
207
|
* @fires {CustomEvent} edited-item-changed - Fired when `editedItem` property changes.
|
|
@@ -664,6 +697,13 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
664
697
|
this.__onGridSizeChanged = this.__onGridSizeChanged.bind(this);
|
|
665
698
|
this.__onGridActiveItemChanged = this.__onGridActiveItemChanged.bind(this);
|
|
666
699
|
|
|
700
|
+
this._newButtonController = new ButtonSlotController(this, 'new', 'primary');
|
|
701
|
+
this._saveButtonController = new ButtonSlotController(this, 'save', 'primary');
|
|
702
|
+
this._cancelButtonController = new ButtonSlotController(this, 'cancel', 'tertiary');
|
|
703
|
+
this._deleteButtonController = new ButtonSlotController(this, 'delete', 'tertiary error');
|
|
704
|
+
|
|
705
|
+
this.__focusRestorationController = new FocusRestorationController();
|
|
706
|
+
|
|
667
707
|
this._observer = new FlattenedNodesObserver(this, (info) => {
|
|
668
708
|
this.__onDomChange(info.addedNodes);
|
|
669
709
|
});
|
|
@@ -705,18 +745,20 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
705
745
|
|
|
706
746
|
this.addController(new SlotController(this, 'form', 'vaadin-crud-form'));
|
|
707
747
|
|
|
708
|
-
this.addController(
|
|
748
|
+
this.addController(this._newButtonController);
|
|
709
749
|
|
|
710
750
|
// NOTE: order in which buttons are added should match the order of slots in template
|
|
711
|
-
this.addController(
|
|
712
|
-
this.addController(
|
|
713
|
-
this.addController(
|
|
751
|
+
this.addController(this._saveButtonController);
|
|
752
|
+
this.addController(this._cancelButtonController);
|
|
753
|
+
this.addController(this._deleteButtonController);
|
|
714
754
|
|
|
715
755
|
this.addController(
|
|
716
756
|
new MediaQueryController(this._fullscreenMediaQuery, (matches) => {
|
|
717
757
|
this._fullscreen = matches;
|
|
718
758
|
}),
|
|
719
759
|
);
|
|
760
|
+
|
|
761
|
+
this.addController(this.__focusRestorationController);
|
|
720
762
|
}
|
|
721
763
|
|
|
722
764
|
/**
|
|
@@ -863,9 +905,6 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
863
905
|
|
|
864
906
|
/** @private */
|
|
865
907
|
__onDomChange(addedNodes) {
|
|
866
|
-
// TODO: restore default button when a corresponding slotted button is removed.
|
|
867
|
-
// This would require us to detect where to insert a button after teleporting it,
|
|
868
|
-
// which happens after opening a dialog and closing it (default editor position).
|
|
869
908
|
addedNodes
|
|
870
909
|
.filter((node) => node.nodeType === Node.ELEMENT_NODE)
|
|
871
910
|
.forEach((node) => {
|
|
@@ -881,9 +920,6 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
881
920
|
this.__editOnClickChanged(this.editOnClick, this._grid);
|
|
882
921
|
} else if (slotAttributeValue === 'form') {
|
|
883
922
|
this._form = node;
|
|
884
|
-
} else if (slotAttributeValue.indexOf('button') >= 0) {
|
|
885
|
-
const [button] = slotAttributeValue.split('-');
|
|
886
|
-
this.__setupSlottedButton(button, node);
|
|
887
923
|
}
|
|
888
924
|
});
|
|
889
925
|
|
|
@@ -974,7 +1010,7 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
974
1010
|
}
|
|
975
1011
|
|
|
976
1012
|
/**
|
|
977
|
-
* @param {HTMLElement | undefined}
|
|
1013
|
+
* @param {HTMLElement | undefined} grid
|
|
978
1014
|
* @param {string} theme
|
|
979
1015
|
* @param {string | string[] | undefined} include
|
|
980
1016
|
* @param {string | RegExp} exclude
|
|
@@ -1016,7 +1052,10 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1016
1052
|
__saveButtonPropsChanged(saveButton, i18nLabel, isDirty) {
|
|
1017
1053
|
if (saveButton) {
|
|
1018
1054
|
saveButton.toggleAttribute('disabled', this.__isSaveBtnDisabled(isDirty));
|
|
1019
|
-
|
|
1055
|
+
|
|
1056
|
+
if (saveButton === this._saveButtonController.defaultNode) {
|
|
1057
|
+
saveButton.textContent = i18nLabel;
|
|
1058
|
+
}
|
|
1020
1059
|
}
|
|
1021
1060
|
}
|
|
1022
1061
|
|
|
@@ -1028,18 +1067,21 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1028
1067
|
*/
|
|
1029
1068
|
__deleteButtonPropsChanged(deleteButton, i18nLabel, isNew) {
|
|
1030
1069
|
if (deleteButton) {
|
|
1031
|
-
deleteButton.textContent = i18nLabel;
|
|
1032
1070
|
deleteButton.toggleAttribute('hidden', isNew);
|
|
1071
|
+
|
|
1072
|
+
if (deleteButton === this._deleteButtonController.defaultNode) {
|
|
1073
|
+
deleteButton.textContent = i18nLabel;
|
|
1074
|
+
}
|
|
1033
1075
|
}
|
|
1034
1076
|
}
|
|
1035
1077
|
|
|
1036
1078
|
/**
|
|
1037
|
-
* @param {HTMLElement | undefined}
|
|
1079
|
+
* @param {HTMLElement | undefined} cancelButton
|
|
1038
1080
|
* @param {string} i18nLabel
|
|
1039
1081
|
* @private
|
|
1040
1082
|
*/
|
|
1041
1083
|
__cancelButtonPropsChanged(cancelButton, i18nLabel) {
|
|
1042
|
-
if (cancelButton) {
|
|
1084
|
+
if (cancelButton && cancelButton === this._cancelButtonController.defaultNode) {
|
|
1043
1085
|
cancelButton.textContent = i18nLabel;
|
|
1044
1086
|
}
|
|
1045
1087
|
}
|
|
@@ -1050,28 +1092,11 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1050
1092
|
* @private
|
|
1051
1093
|
*/
|
|
1052
1094
|
__newButtonPropsChanged(newButton, i18nNewItem) {
|
|
1053
|
-
if (newButton) {
|
|
1095
|
+
if (newButton && newButton === this._newButtonController.defaultNode) {
|
|
1054
1096
|
newButton.textContent = i18nNewItem;
|
|
1055
1097
|
}
|
|
1056
1098
|
}
|
|
1057
1099
|
|
|
1058
|
-
/**
|
|
1059
|
-
* @param {string} type
|
|
1060
|
-
* @param {HTMLElement} newButton
|
|
1061
|
-
* @private
|
|
1062
|
-
*/
|
|
1063
|
-
__setupSlottedButton(type, button) {
|
|
1064
|
-
const property = `_${type}Button`;
|
|
1065
|
-
const listener = `__${type}`;
|
|
1066
|
-
|
|
1067
|
-
if (this[property] && this[property] !== button) {
|
|
1068
|
-
this[property].remove();
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
button.addEventListener('click', this[listener]);
|
|
1072
|
-
this[property] = button;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
1100
|
/** @private */
|
|
1076
1101
|
__dataProviderChanged(dataProvider) {
|
|
1077
1102
|
if (this._grid) {
|
|
@@ -1232,20 +1257,52 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1232
1257
|
this.__openEditor('edit', item);
|
|
1233
1258
|
}
|
|
1234
1259
|
|
|
1260
|
+
/** @private */
|
|
1261
|
+
__fireEvent(type, item) {
|
|
1262
|
+
const event = new CustomEvent(type, { detail: { item }, cancelable: true });
|
|
1263
|
+
this.dispatchEvent(event);
|
|
1264
|
+
return event.defaultPrevented === false;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1235
1267
|
/** @private */
|
|
1236
1268
|
__openEditor(type, item) {
|
|
1269
|
+
this.__focusRestorationController.saveFocus();
|
|
1270
|
+
|
|
1237
1271
|
this.__isDirty = false;
|
|
1238
1272
|
this.__isNew = !item;
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
);
|
|
1242
|
-
if (evt) {
|
|
1273
|
+
const result = this.__fireEvent(this.__isNew ? 'new' : 'edit', item);
|
|
1274
|
+
if (result) {
|
|
1243
1275
|
this.editedItem = item || {};
|
|
1244
1276
|
} else {
|
|
1245
1277
|
this.editorOpened = true;
|
|
1246
1278
|
}
|
|
1247
1279
|
}
|
|
1248
1280
|
|
|
1281
|
+
/** @private */
|
|
1282
|
+
__restoreFocusOnDelete() {
|
|
1283
|
+
if (this._grid._effectiveSize === 1) {
|
|
1284
|
+
this._newButton.focus();
|
|
1285
|
+
} else {
|
|
1286
|
+
this._grid._focusFirstVisibleRow();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/** @private */
|
|
1291
|
+
__restoreFocusOnSaveOrCancel() {
|
|
1292
|
+
const focusNode = this.__focusRestorationController.focusNode;
|
|
1293
|
+
const row = this._grid._getRowContainingNode(focusNode);
|
|
1294
|
+
if (!row) {
|
|
1295
|
+
this.__focusRestorationController.restoreFocus();
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
if (this._grid._isItemAssigedToRow(this.editedItem, row) && this._grid._isInViewport(row)) {
|
|
1300
|
+
this.__focusRestorationController.restoreFocus();
|
|
1301
|
+
} else {
|
|
1302
|
+
this._grid._focusFirstVisibleRow();
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1249
1306
|
/** @private */
|
|
1250
1307
|
__save() {
|
|
1251
1308
|
if (!this.__validate()) {
|
|
@@ -1259,8 +1316,8 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1259
1316
|
setProperty(path, e.value, item);
|
|
1260
1317
|
}
|
|
1261
1318
|
});
|
|
1262
|
-
const
|
|
1263
|
-
if (
|
|
1319
|
+
const result = this.__fireEvent('save', item);
|
|
1320
|
+
if (result) {
|
|
1264
1321
|
if (this.__isNew && !this.dataProvider) {
|
|
1265
1322
|
if (!this.items) {
|
|
1266
1323
|
this.items = [item];
|
|
@@ -1273,6 +1330,8 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1273
1330
|
}
|
|
1274
1331
|
Object.assign(this.editedItem, item);
|
|
1275
1332
|
}
|
|
1333
|
+
|
|
1334
|
+
this.__restoreFocusOnSaveOrCancel();
|
|
1276
1335
|
this._grid.clearCache();
|
|
1277
1336
|
this.__closeEditor();
|
|
1278
1337
|
}
|
|
@@ -1289,8 +1348,9 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1289
1348
|
|
|
1290
1349
|
/** @private */
|
|
1291
1350
|
__confirmCancel() {
|
|
1292
|
-
const
|
|
1293
|
-
if (
|
|
1351
|
+
const result = this.__fireEvent('cancel', this.editedItem);
|
|
1352
|
+
if (result) {
|
|
1353
|
+
this.__restoreFocusOnSaveOrCancel();
|
|
1294
1354
|
this.__closeEditor();
|
|
1295
1355
|
}
|
|
1296
1356
|
}
|
|
@@ -1302,11 +1362,13 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1302
1362
|
|
|
1303
1363
|
/** @private */
|
|
1304
1364
|
__confirmDelete() {
|
|
1305
|
-
const
|
|
1306
|
-
if (
|
|
1365
|
+
const result = this.__fireEvent('delete', this.editedItem);
|
|
1366
|
+
if (result) {
|
|
1307
1367
|
if (this.items && this.items.indexOf(this.editedItem) >= 0) {
|
|
1308
1368
|
this.items.splice(this.items.indexOf(this.editedItem), 1);
|
|
1309
1369
|
}
|
|
1370
|
+
|
|
1371
|
+
this.__restoreFocusOnDelete();
|
|
1310
1372
|
this._grid.clearCache();
|
|
1311
1373
|
this.__closeEditor();
|
|
1312
1374
|
}
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/crud",
|
|
4
|
-
"version": "24.
|
|
4
|
+
"version": "24.2.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
},
|
|
296
296
|
{
|
|
297
297
|
"name": "vaadin-crud",
|
|
298
|
-
"description": "`<vaadin-crud>` is a Web Component for [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations.\n\n### Quick Start\n\nAssign an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.
|
|
298
|
+
"description": "`<vaadin-crud>` is a Web Component for [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations.\n\n### Quick Start\n\nAssign an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-items) property.\n\nA grid and an editor will be automatically generated and configured based on the data structure provided.\n\n```html\n<vaadin-crud></vaadin-crud>\n```\n```js\nconst crud = document.querySelector('vaadin-crud');\n\ncrud.items = [\n { name: 'John', surname: 'Lennon', role: 'singer' },\n { name: 'Ringo', surname: 'Starr', role: 'drums' },\n // ... more items\n];\n```\n\n### Data Provider Function\n\nOtherwise, you can provide a [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-dataProvider) function.\n\n```js\nconst crud = document.querySelector('vaadin-crud');\n\nconst users = [\n { name: 'John', surname: 'Lennon', role: 'singer' },\n { name: 'Ringo', surname: 'Starr', role: 'drums' },\n // ... more items\n];\n\ncrud.dataProvider = (params, callback) => {\n const chunk = users.slice(params.page * params.pageSize, params.page * params.pageSize + params.pageSize);\n callback(chunk, people.length);\n};\n```\n\nNOTE: The auto-generated editor only supports string types. If you need to handle special cases\ncustomizing the editor is discussed below.\n\n### Customization\n\nAlternatively you can fully configure the component by using `slot` names.\n\nSlot name | Description\n---------------|----------------\n`grid` | To replace the auto-generated grid with a custom one.\n`form` | To replace the auto-generated form.\n`save-button` | To replace the \"Save\" button.\n`cancel-button`| To replace the \"Cancel\" button.\n`delete-button`| To replace the \"Delete\" button.\n`toolbar` | To provide the toolbar content (by default, it's empty).\n`new-button` | To replace the \"New item\" button.\n\n#### Example:\n\n```html\n<vaadin-crud id=\"crud\">\n <vaadin-grid slot=\"grid\">\n <vaadin-crud-edit-column></vaadin-crud-edit-column>\n <vaadin-grid-column id=\"column1\"></vaadin-grid-column>\n <vaadin-grid-column id=\"column2\"></vaadin-grid-column>\n </vaadin-grid>\n\n <vaadin-form-layout slot=\"form\">\n <vaadin-text-field label=\"First\" path=\"name\"></vaadin-text-field>\n <vaadin-text-field label=\"Surname\" path=\"surname\"></vaadin-text-field>\n </vaadin-form-layout>\n\n <div slot=\"toolbar\">Total singers: 2</div>\n <button slot=\"new-button\">New singer</button>\n\n <button slot=\"save-button\">Save changes</button>\n <button slot=\"cancel-button\">Discard changes</button>\n <button slot=\"delete-button\">Delete singer</button>\n</vaadin-crud>\n```\n```js\nconst crud = document.querySelector('#crud');\n\nconst column1 = document.querySelector('#column1');\ncolumn1.headerRenderer = (root, column) => {\n root.textContent = 'Name';\n};\ncolumn1.renderer = (root, column, model) => {\n root.textContent = model.item.name;\n};\n\nconst column2 = document.querySelector('#column2');\ncolumn2.headerRenderer = (root, column) => {\n root.textContent = 'Surname';\n};\ncolumn2.renderer = (root, column, model) => {\n root.textContent = model.item.surname;\n};\n\ncrud.items = [\n { name: 'John', surname: 'Lennon', role: 'singer' },\n { name: 'Ringo', surname: 'Starr', role: 'drums' },\n // ... more items\n];\n```\n\n### Helpers\n\nThe following elements are used to auto-configure the grid and the editor\n- [`<vaadin-crud-edit-column>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud-edit-column)\n- `<vaadin-crud-grid>` - can be replaced with custom [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-grid)\n- `<vaadin-crud-form>` - can be replaced with custom [`<vaadin-form-layout>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-form-layout)\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`toolbar` | Toolbar container at the bottom. By default it contains the the `new` button\n\nThe following custom properties are available:\n\nCustom Property | Description | Default\n----------------|----------------\n--vaadin-crud-editor-max-height | max height of editor when opened on the bottom | 40%\n--vaadin-crud-editor-max-width | max width of editor when opened on the side | 40%\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
299
299
|
"attributes": [
|
|
300
300
|
{
|
|
301
301
|
"name": "editor-position",
|
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
},
|
|
351
351
|
{
|
|
352
352
|
"name": "include",
|
|
353
|
-
"description": "A comma-separated list of fields to include in the generated grid and the generated editor.\n\nIt can be used to explicitly define the field order.\n\nWhen it is defined [`exclude`](https://cdn.vaadin.com/vaadin-web-components/24.
|
|
353
|
+
"description": "A comma-separated list of fields to include in the generated grid and the generated editor.\n\nIt can be used to explicitly define the field order.\n\nWhen it is defined [`exclude`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-exclude) is ignored.\n\nDefault is undefined meaning that all properties in the object should be mapped to fields.",
|
|
354
354
|
"value": {
|
|
355
355
|
"type": [
|
|
356
356
|
"string",
|
|
@@ -361,7 +361,7 @@
|
|
|
361
361
|
},
|
|
362
362
|
{
|
|
363
363
|
"name": "exclude",
|
|
364
|
-
"description": "A comma-separated list of fields to be excluded from the generated grid and the generated editor.\n\nWhen [`include`](https://cdn.vaadin.com/vaadin-web-components/24.
|
|
364
|
+
"description": "A comma-separated list of fields to be excluded from the generated grid and the generated editor.\n\nWhen [`include`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-include) is defined, this parameter is ignored.\n\nDefault is to exclude all private fields (those properties starting with underscore)",
|
|
365
365
|
"value": {
|
|
366
366
|
"type": [
|
|
367
367
|
"string",
|
|
@@ -488,7 +488,7 @@
|
|
|
488
488
|
},
|
|
489
489
|
{
|
|
490
490
|
"name": "include",
|
|
491
|
-
"description": "A comma-separated list of fields to include in the generated grid and the generated editor.\n\nIt can be used to explicitly define the field order.\n\nWhen it is defined [`exclude`](https://cdn.vaadin.com/vaadin-web-components/24.
|
|
491
|
+
"description": "A comma-separated list of fields to include in the generated grid and the generated editor.\n\nIt can be used to explicitly define the field order.\n\nWhen it is defined [`exclude`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-exclude) is ignored.\n\nDefault is undefined meaning that all properties in the object should be mapped to fields.",
|
|
492
492
|
"value": {
|
|
493
493
|
"type": [
|
|
494
494
|
"string",
|
|
@@ -499,7 +499,7 @@
|
|
|
499
499
|
},
|
|
500
500
|
{
|
|
501
501
|
"name": "exclude",
|
|
502
|
-
"description": "A comma-separated list of fields to be excluded from the generated grid and the generated editor.\n\nWhen [`include`](https://cdn.vaadin.com/vaadin-web-components/24.
|
|
502
|
+
"description": "A comma-separated list of fields to be excluded from the generated grid and the generated editor.\n\nWhen [`include`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-include) is defined, this parameter is ignored.\n\nDefault is to exclude all private fields (those properties starting with underscore)",
|
|
503
503
|
"value": {
|
|
504
504
|
"type": [
|
|
505
505
|
"string",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/crud",
|
|
4
|
-
"version": "24.
|
|
4
|
+
"version": "24.2.0-alpha1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
"name": "vaadin-crud",
|
|
124
|
-
"description": "`<vaadin-crud>` is a Web Component for [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations.\n\n### Quick Start\n\nAssign an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.
|
|
124
|
+
"description": "`<vaadin-crud>` is a Web Component for [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations.\n\n### Quick Start\n\nAssign an array to the [`items`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-items) property.\n\nA grid and an editor will be automatically generated and configured based on the data structure provided.\n\n```html\n<vaadin-crud></vaadin-crud>\n```\n```js\nconst crud = document.querySelector('vaadin-crud');\n\ncrud.items = [\n { name: 'John', surname: 'Lennon', role: 'singer' },\n { name: 'Ringo', surname: 'Starr', role: 'drums' },\n // ... more items\n];\n```\n\n### Data Provider Function\n\nOtherwise, you can provide a [`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-dataProvider) function.\n\n```js\nconst crud = document.querySelector('vaadin-crud');\n\nconst users = [\n { name: 'John', surname: 'Lennon', role: 'singer' },\n { name: 'Ringo', surname: 'Starr', role: 'drums' },\n // ... more items\n];\n\ncrud.dataProvider = (params, callback) => {\n const chunk = users.slice(params.page * params.pageSize, params.page * params.pageSize + params.pageSize);\n callback(chunk, people.length);\n};\n```\n\nNOTE: The auto-generated editor only supports string types. If you need to handle special cases\ncustomizing the editor is discussed below.\n\n### Customization\n\nAlternatively you can fully configure the component by using `slot` names.\n\nSlot name | Description\n---------------|----------------\n`grid` | To replace the auto-generated grid with a custom one.\n`form` | To replace the auto-generated form.\n`save-button` | To replace the \"Save\" button.\n`cancel-button`| To replace the \"Cancel\" button.\n`delete-button`| To replace the \"Delete\" button.\n`toolbar` | To provide the toolbar content (by default, it's empty).\n`new-button` | To replace the \"New item\" button.\n\n#### Example:\n\n```html\n<vaadin-crud id=\"crud\">\n <vaadin-grid slot=\"grid\">\n <vaadin-crud-edit-column></vaadin-crud-edit-column>\n <vaadin-grid-column id=\"column1\"></vaadin-grid-column>\n <vaadin-grid-column id=\"column2\"></vaadin-grid-column>\n </vaadin-grid>\n\n <vaadin-form-layout slot=\"form\">\n <vaadin-text-field label=\"First\" path=\"name\"></vaadin-text-field>\n <vaadin-text-field label=\"Surname\" path=\"surname\"></vaadin-text-field>\n </vaadin-form-layout>\n\n <div slot=\"toolbar\">Total singers: 2</div>\n <button slot=\"new-button\">New singer</button>\n\n <button slot=\"save-button\">Save changes</button>\n <button slot=\"cancel-button\">Discard changes</button>\n <button slot=\"delete-button\">Delete singer</button>\n</vaadin-crud>\n```\n```js\nconst crud = document.querySelector('#crud');\n\nconst column1 = document.querySelector('#column1');\ncolumn1.headerRenderer = (root, column) => {\n root.textContent = 'Name';\n};\ncolumn1.renderer = (root, column, model) => {\n root.textContent = model.item.name;\n};\n\nconst column2 = document.querySelector('#column2');\ncolumn2.headerRenderer = (root, column) => {\n root.textContent = 'Surname';\n};\ncolumn2.renderer = (root, column, model) => {\n root.textContent = model.item.surname;\n};\n\ncrud.items = [\n { name: 'John', surname: 'Lennon', role: 'singer' },\n { name: 'Ringo', surname: 'Starr', role: 'drums' },\n // ... more items\n];\n```\n\n### Helpers\n\nThe following elements are used to auto-configure the grid and the editor\n- [`<vaadin-crud-edit-column>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud-edit-column)\n- `<vaadin-crud-grid>` - can be replaced with custom [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-grid)\n- `<vaadin-crud-form>` - can be replaced with custom [`<vaadin-form-layout>`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-form-layout)\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n----------------|----------------\n`toolbar` | Toolbar container at the bottom. By default it contains the the `new` button\n\nThe following custom properties are available:\n\nCustom Property | Description | Default\n----------------|----------------\n--vaadin-crud-editor-max-height | max height of editor when opened on the bottom | 40%\n--vaadin-crud-editor-max-width | max width of editor when opened on the side | 40%\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
|
|
125
125
|
"extension": true,
|
|
126
126
|
"attributes": [
|
|
127
127
|
{
|
|
@@ -196,14 +196,14 @@
|
|
|
196
196
|
},
|
|
197
197
|
{
|
|
198
198
|
"name": ".include",
|
|
199
|
-
"description": "A comma-separated list of fields to include in the generated grid and the generated editor.\n\nIt can be used to explicitly define the field order.\n\nWhen it is defined [`exclude`](https://cdn.vaadin.com/vaadin-web-components/24.
|
|
199
|
+
"description": "A comma-separated list of fields to include in the generated grid and the generated editor.\n\nIt can be used to explicitly define the field order.\n\nWhen it is defined [`exclude`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-exclude) is ignored.\n\nDefault is undefined meaning that all properties in the object should be mapped to fields.",
|
|
200
200
|
"value": {
|
|
201
201
|
"kind": "expression"
|
|
202
202
|
}
|
|
203
203
|
},
|
|
204
204
|
{
|
|
205
205
|
"name": ".exclude",
|
|
206
|
-
"description": "A comma-separated list of fields to be excluded from the generated grid and the generated editor.\n\nWhen [`include`](https://cdn.vaadin.com/vaadin-web-components/24.
|
|
206
|
+
"description": "A comma-separated list of fields to be excluded from the generated grid and the generated editor.\n\nWhen [`include`](https://cdn.vaadin.com/vaadin-web-components/24.2.0-alpha1/#/elements/vaadin-crud#property-include) is defined, this parameter is ignored.\n\nDefault is to exclude all private fields (those properties starting with underscore)",
|
|
207
207
|
"value": {
|
|
208
208
|
"kind": "expression"
|
|
209
209
|
}
|