@vaadin/crud 24.1.1 → 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 +12 -12
- package/src/vaadin-crud-dialog.js +1 -4
- package/src/vaadin-crud.d.ts +1 -1
- package/src/vaadin-crud.js +75 -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,16 +37,16 @@
|
|
|
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",
|
|
@@ -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.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
|
@@ -26,16 +26,48 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
26
26
|
import { getProperty, setProperty } from './vaadin-crud-helpers.js';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
+
* A controller for initializing slotted button.
|
|
29
30
|
* @private
|
|
30
|
-
* A to initialize slotted button.
|
|
31
31
|
*/
|
|
32
32
|
class ButtonSlotController extends SlotController {
|
|
33
33
|
constructor(host, type, theme) {
|
|
34
|
-
super(host, `${type}-button`, 'vaadin-button'
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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;
|
|
39
71
|
}
|
|
40
72
|
}
|
|
41
73
|
|
|
@@ -169,7 +201,7 @@ class ButtonSlotController extends SlotController {
|
|
|
169
201
|
* --vaadin-crud-editor-max-height | max height of editor when opened on the bottom | 40%
|
|
170
202
|
* --vaadin-crud-editor-max-width | max width of editor when opened on the side | 40%
|
|
171
203
|
*
|
|
172
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/
|
|
204
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
173
205
|
*
|
|
174
206
|
* @fires {CustomEvent} editor-opened-changed - Fired when the `editorOpened` property changes.
|
|
175
207
|
* @fires {CustomEvent} edited-item-changed - Fired when `editedItem` property changes.
|
|
@@ -665,6 +697,11 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
665
697
|
this.__onGridSizeChanged = this.__onGridSizeChanged.bind(this);
|
|
666
698
|
this.__onGridActiveItemChanged = this.__onGridActiveItemChanged.bind(this);
|
|
667
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
|
+
|
|
668
705
|
this.__focusRestorationController = new FocusRestorationController();
|
|
669
706
|
|
|
670
707
|
this._observer = new FlattenedNodesObserver(this, (info) => {
|
|
@@ -708,12 +745,12 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
708
745
|
|
|
709
746
|
this.addController(new SlotController(this, 'form', 'vaadin-crud-form'));
|
|
710
747
|
|
|
711
|
-
this.addController(
|
|
748
|
+
this.addController(this._newButtonController);
|
|
712
749
|
|
|
713
750
|
// NOTE: order in which buttons are added should match the order of slots in template
|
|
714
|
-
this.addController(
|
|
715
|
-
this.addController(
|
|
716
|
-
this.addController(
|
|
751
|
+
this.addController(this._saveButtonController);
|
|
752
|
+
this.addController(this._cancelButtonController);
|
|
753
|
+
this.addController(this._deleteButtonController);
|
|
717
754
|
|
|
718
755
|
this.addController(
|
|
719
756
|
new MediaQueryController(this._fullscreenMediaQuery, (matches) => {
|
|
@@ -868,9 +905,6 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
868
905
|
|
|
869
906
|
/** @private */
|
|
870
907
|
__onDomChange(addedNodes) {
|
|
871
|
-
// TODO: restore default button when a corresponding slotted button is removed.
|
|
872
|
-
// This would require us to detect where to insert a button after teleporting it,
|
|
873
|
-
// which happens after opening a dialog and closing it (default editor position).
|
|
874
908
|
addedNodes
|
|
875
909
|
.filter((node) => node.nodeType === Node.ELEMENT_NODE)
|
|
876
910
|
.forEach((node) => {
|
|
@@ -886,9 +920,6 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
886
920
|
this.__editOnClickChanged(this.editOnClick, this._grid);
|
|
887
921
|
} else if (slotAttributeValue === 'form') {
|
|
888
922
|
this._form = node;
|
|
889
|
-
} else if (slotAttributeValue.indexOf('button') >= 0) {
|
|
890
|
-
const [button] = slotAttributeValue.split('-');
|
|
891
|
-
this.__setupSlottedButton(button, node);
|
|
892
923
|
}
|
|
893
924
|
});
|
|
894
925
|
|
|
@@ -979,7 +1010,7 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
979
1010
|
}
|
|
980
1011
|
|
|
981
1012
|
/**
|
|
982
|
-
* @param {HTMLElement | undefined}
|
|
1013
|
+
* @param {HTMLElement | undefined} grid
|
|
983
1014
|
* @param {string} theme
|
|
984
1015
|
* @param {string | string[] | undefined} include
|
|
985
1016
|
* @param {string | RegExp} exclude
|
|
@@ -1021,7 +1052,10 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1021
1052
|
__saveButtonPropsChanged(saveButton, i18nLabel, isDirty) {
|
|
1022
1053
|
if (saveButton) {
|
|
1023
1054
|
saveButton.toggleAttribute('disabled', this.__isSaveBtnDisabled(isDirty));
|
|
1024
|
-
|
|
1055
|
+
|
|
1056
|
+
if (saveButton === this._saveButtonController.defaultNode) {
|
|
1057
|
+
saveButton.textContent = i18nLabel;
|
|
1058
|
+
}
|
|
1025
1059
|
}
|
|
1026
1060
|
}
|
|
1027
1061
|
|
|
@@ -1033,18 +1067,21 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1033
1067
|
*/
|
|
1034
1068
|
__deleteButtonPropsChanged(deleteButton, i18nLabel, isNew) {
|
|
1035
1069
|
if (deleteButton) {
|
|
1036
|
-
deleteButton.textContent = i18nLabel;
|
|
1037
1070
|
deleteButton.toggleAttribute('hidden', isNew);
|
|
1071
|
+
|
|
1072
|
+
if (deleteButton === this._deleteButtonController.defaultNode) {
|
|
1073
|
+
deleteButton.textContent = i18nLabel;
|
|
1074
|
+
}
|
|
1038
1075
|
}
|
|
1039
1076
|
}
|
|
1040
1077
|
|
|
1041
1078
|
/**
|
|
1042
|
-
* @param {HTMLElement | undefined}
|
|
1079
|
+
* @param {HTMLElement | undefined} cancelButton
|
|
1043
1080
|
* @param {string} i18nLabel
|
|
1044
1081
|
* @private
|
|
1045
1082
|
*/
|
|
1046
1083
|
__cancelButtonPropsChanged(cancelButton, i18nLabel) {
|
|
1047
|
-
if (cancelButton) {
|
|
1084
|
+
if (cancelButton && cancelButton === this._cancelButtonController.defaultNode) {
|
|
1048
1085
|
cancelButton.textContent = i18nLabel;
|
|
1049
1086
|
}
|
|
1050
1087
|
}
|
|
@@ -1055,28 +1092,11 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1055
1092
|
* @private
|
|
1056
1093
|
*/
|
|
1057
1094
|
__newButtonPropsChanged(newButton, i18nNewItem) {
|
|
1058
|
-
if (newButton) {
|
|
1095
|
+
if (newButton && newButton === this._newButtonController.defaultNode) {
|
|
1059
1096
|
newButton.textContent = i18nNewItem;
|
|
1060
1097
|
}
|
|
1061
1098
|
}
|
|
1062
1099
|
|
|
1063
|
-
/**
|
|
1064
|
-
* @param {string} type
|
|
1065
|
-
* @param {HTMLElement} newButton
|
|
1066
|
-
* @private
|
|
1067
|
-
*/
|
|
1068
|
-
__setupSlottedButton(type, button) {
|
|
1069
|
-
const property = `_${type}Button`;
|
|
1070
|
-
const listener = `__${type}`;
|
|
1071
|
-
|
|
1072
|
-
if (this[property] && this[property] !== button) {
|
|
1073
|
-
this[property].remove();
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
button.addEventListener('click', this[listener]);
|
|
1077
|
-
this[property] = button;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
1100
|
/** @private */
|
|
1081
1101
|
__dataProviderChanged(dataProvider) {
|
|
1082
1102
|
if (this._grid) {
|
|
@@ -1237,16 +1257,21 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1237
1257
|
this.__openEditor('edit', item);
|
|
1238
1258
|
}
|
|
1239
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
|
+
|
|
1240
1267
|
/** @private */
|
|
1241
1268
|
__openEditor(type, item) {
|
|
1242
1269
|
this.__focusRestorationController.saveFocus();
|
|
1243
1270
|
|
|
1244
1271
|
this.__isDirty = false;
|
|
1245
1272
|
this.__isNew = !item;
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1248
|
-
);
|
|
1249
|
-
if (evt) {
|
|
1273
|
+
const result = this.__fireEvent(this.__isNew ? 'new' : 'edit', item);
|
|
1274
|
+
if (result) {
|
|
1250
1275
|
this.editedItem = item || {};
|
|
1251
1276
|
} else {
|
|
1252
1277
|
this.editorOpened = true;
|
|
@@ -1291,8 +1316,8 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1291
1316
|
setProperty(path, e.value, item);
|
|
1292
1317
|
}
|
|
1293
1318
|
});
|
|
1294
|
-
const
|
|
1295
|
-
if (
|
|
1319
|
+
const result = this.__fireEvent('save', item);
|
|
1320
|
+
if (result) {
|
|
1296
1321
|
if (this.__isNew && !this.dataProvider) {
|
|
1297
1322
|
if (!this.items) {
|
|
1298
1323
|
this.items = [item];
|
|
@@ -1323,8 +1348,8 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1323
1348
|
|
|
1324
1349
|
/** @private */
|
|
1325
1350
|
__confirmCancel() {
|
|
1326
|
-
const
|
|
1327
|
-
if (
|
|
1351
|
+
const result = this.__fireEvent('cancel', this.editedItem);
|
|
1352
|
+
if (result) {
|
|
1328
1353
|
this.__restoreFocusOnSaveOrCancel();
|
|
1329
1354
|
this.__closeEditor();
|
|
1330
1355
|
}
|
|
@@ -1337,8 +1362,8 @@ class Crud extends ControllerMixin(ElementMixin(ThemableMixin(PolymerElement)))
|
|
|
1337
1362
|
|
|
1338
1363
|
/** @private */
|
|
1339
1364
|
__confirmDelete() {
|
|
1340
|
-
const
|
|
1341
|
-
if (
|
|
1365
|
+
const result = this.__fireEvent('delete', this.editedItem);
|
|
1366
|
+
if (result) {
|
|
1342
1367
|
if (this.items && this.items.indexOf(this.editedItem) >= 0) {
|
|
1343
1368
|
this.items.splice(this.items.indexOf(this.editedItem), 1);
|
|
1344
1369
|
}
|
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
|
}
|