@vaadin/crud 24.0.0-alpha1 → 24.0.0-alpha11
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/LICENSE +1105 -248
- package/README.md +1 -1
- package/package.json +12 -12
- package/src/vaadin-crud-dialog.js +9 -3
- package/src/vaadin-crud-edit-column.d.ts +7 -2
- package/src/vaadin-crud-edit-column.js +8 -3
- package/src/vaadin-crud-edit.d.ts +7 -2
- package/src/vaadin-crud-edit.js +7 -2
- package/src/vaadin-crud-form.d.ts +7 -2
- package/src/vaadin-crud-form.js +9 -26
- package/src/vaadin-crud-grid.d.ts +7 -2
- package/src/vaadin-crud-grid.js +20 -36
- package/src/vaadin-crud-helpers.d.ts +29 -0
- package/src/vaadin-crud-helpers.js +64 -0
- package/src/vaadin-crud-include-mixin.d.ts +7 -2
- package/src/vaadin-crud-include-mixin.js +13 -5
- package/src/vaadin-crud.d.ts +50 -26
- package/src/vaadin-crud.js +203 -176
- package/theme/material/vaadin-crud-styles.js +0 -7
- package/vaadin-crud-edit-column.d.ts +1 -0
- package/vaadin-crud-edit-column.js +1 -0
- package/vaadin-crud-edit.d.ts +1 -0
- package/vaadin-crud-edit.js +1 -0
- package/web-types.json +6 -6
- package/web-types.lit.json +4 -4
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ Read the [contributing guide](https://vaadin.com/docs/latest/contributing/overvi
|
|
|
58
58
|
|
|
59
59
|
## License
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
This program is available under Vaadin Commercial License and Service Terms. For license terms, see LICENSE.
|
|
62
62
|
|
|
63
63
|
Vaadin collects usage statistics at development time to improve this product.
|
|
64
64
|
For details and to opt-out, see https://github.com/vaadin/vaadin-usage-statistics.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/crud",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha11",
|
|
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": "24.0.0-
|
|
41
|
-
"@vaadin/component-base": "24.0.0-
|
|
42
|
-
"@vaadin/confirm-dialog": "24.0.0-
|
|
43
|
-
"@vaadin/dialog": "24.0.0-
|
|
44
|
-
"@vaadin/form-layout": "24.0.0-
|
|
45
|
-
"@vaadin/grid": "24.0.0-
|
|
46
|
-
"@vaadin/text-field": "24.0.0-
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
48
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
40
|
+
"@vaadin/button": "24.0.0-alpha11",
|
|
41
|
+
"@vaadin/component-base": "24.0.0-alpha11",
|
|
42
|
+
"@vaadin/confirm-dialog": "24.0.0-alpha11",
|
|
43
|
+
"@vaadin/dialog": "24.0.0-alpha11",
|
|
44
|
+
"@vaadin/form-layout": "24.0.0-alpha11",
|
|
45
|
+
"@vaadin/grid": "24.0.0-alpha11",
|
|
46
|
+
"@vaadin/text-field": "24.0.0-alpha11",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha11",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha11",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha11"
|
|
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": "641b3d96ceeb3e503a093682ebe686afdd8c3a68"
|
|
62
62
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
7
|
-
import { Dialog
|
|
12
|
+
import { Dialog } from '@vaadin/dialog/src/vaadin-dialog.js';
|
|
13
|
+
import { DialogOverlay } from '@vaadin/dialog/src/vaadin-dialog-overlay.js';
|
|
8
14
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
15
|
|
|
10
16
|
registerStyles(
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import { GridColumn } from '@vaadin/grid/src/vaadin-grid-column.js';
|
|
7
12
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import './vaadin-crud-edit.js';
|
|
7
12
|
import { GridColumn } from '@vaadin/grid/src/vaadin-grid-column.js';
|
|
@@ -36,7 +41,7 @@ class CrudEditColumn extends GridColumn {
|
|
|
36
41
|
*/
|
|
37
42
|
width: {
|
|
38
43
|
type: String,
|
|
39
|
-
value: '
|
|
44
|
+
value: '4rem',
|
|
40
45
|
},
|
|
41
46
|
|
|
42
47
|
/**
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import { Button } from '@vaadin/button/src/vaadin-button.js';
|
|
7
12
|
|
package/src/vaadin-crud-edit.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import { html } from '@polymer/polymer/polymer-element.js';
|
|
7
12
|
import { Button } from '@vaadin/button/src/vaadin-button.js';
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import { FormLayout } from '@vaadin/form-layout/src/vaadin-form-layout.js';
|
|
7
12
|
import { IncludedMixin } from './vaadin-crud-include-mixin.js';
|
package/src/vaadin-crud-form.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import '@vaadin/text-field/src/vaadin-text-field.js';
|
|
7
12
|
import { FormLayout } from '@vaadin/form-layout/src/vaadin-form-layout.js';
|
|
13
|
+
import { capitalize } from './vaadin-crud-helpers.js';
|
|
8
14
|
import { IncludedMixin } from './vaadin-crud-include-mixin.js';
|
|
9
15
|
|
|
10
16
|
/**
|
|
@@ -57,7 +63,7 @@ class CrudForm extends IncludedMixin(FormLayout) {
|
|
|
57
63
|
/** @private */
|
|
58
64
|
__createField(parent, path) {
|
|
59
65
|
const field = document.createElement('vaadin-text-field');
|
|
60
|
-
field.label =
|
|
66
|
+
field.label = capitalize(path);
|
|
61
67
|
field.path = path;
|
|
62
68
|
field.required = true;
|
|
63
69
|
parent.appendChild(field);
|
|
@@ -82,29 +88,6 @@ class CrudForm extends IncludedMixin(FormLayout) {
|
|
|
82
88
|
this._fields = undefined;
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
|
-
|
|
86
|
-
/** @private */
|
|
87
|
-
__capitalize(path) {
|
|
88
|
-
return path
|
|
89
|
-
.toLowerCase()
|
|
90
|
-
.replace(/([^\w]+)/g, ' ')
|
|
91
|
-
.trim()
|
|
92
|
-
.replace(/^./, (c) => c.toUpperCase());
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** @private */
|
|
96
|
-
__set(path, val, obj) {
|
|
97
|
-
if (obj && path) {
|
|
98
|
-
path
|
|
99
|
-
.split('.')
|
|
100
|
-
.slice(0, -1)
|
|
101
|
-
.reduce((o, p) => {
|
|
102
|
-
o[p] = o[p] || {};
|
|
103
|
-
return o[p];
|
|
104
|
-
}, obj);
|
|
105
|
-
this.set(path, val, obj);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
91
|
}
|
|
109
92
|
|
|
110
93
|
customElements.define(CrudForm.is, CrudForm);
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import { Grid } from '@vaadin/grid/src/vaadin-grid.js';
|
|
7
12
|
import { IncludedMixin } from './vaadin-crud-include-mixin.js';
|
package/src/vaadin-crud-grid.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import '@vaadin/grid/src/vaadin-grid-column.js';
|
|
7
12
|
import '@vaadin/grid/src/vaadin-grid-column-group.js';
|
|
@@ -9,6 +14,7 @@ import '@vaadin/grid/src/vaadin-grid-sorter.js';
|
|
|
9
14
|
import '@vaadin/grid/src/vaadin-grid-filter.js';
|
|
10
15
|
import './vaadin-crud-edit-column.js';
|
|
11
16
|
import { Grid } from '@vaadin/grid/src/vaadin-grid.js';
|
|
17
|
+
import { capitalize, getProperty } from './vaadin-crud-helpers.js';
|
|
12
18
|
import { IncludedMixin } from './vaadin-crud-include-mixin.js';
|
|
13
19
|
|
|
14
20
|
/**
|
|
@@ -68,13 +74,15 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
68
74
|
|
|
69
75
|
/** @private */
|
|
70
76
|
__toggleEditColumn() {
|
|
71
|
-
|
|
77
|
+
let editColumn = this.querySelector('vaadin-crud-edit-column');
|
|
72
78
|
if (this.hideEditColumn) {
|
|
73
|
-
if (
|
|
74
|
-
this.removeChild(
|
|
79
|
+
if (editColumn) {
|
|
80
|
+
this.removeChild(editColumn);
|
|
75
81
|
}
|
|
76
|
-
} else if (!
|
|
77
|
-
|
|
82
|
+
} else if (!editColumn) {
|
|
83
|
+
editColumn = document.createElement('vaadin-crud-edit-column');
|
|
84
|
+
editColumn.frozenToEnd = true;
|
|
85
|
+
this.appendChild(editColumn);
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
|
|
@@ -141,10 +149,10 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
141
149
|
_generateHeader(path) {
|
|
142
150
|
return path
|
|
143
151
|
.substr(path.lastIndexOf('.') + 1)
|
|
144
|
-
.replace(/([A-Z])/
|
|
152
|
+
.replace(/([A-Z])/gu, '-$1')
|
|
145
153
|
.toLowerCase()
|
|
146
|
-
.replace(/-/
|
|
147
|
-
.replace(
|
|
154
|
+
.replace(/-/gu, ' ')
|
|
155
|
+
.replace(/^./u, (match) => match.toUpperCase());
|
|
148
156
|
}
|
|
149
157
|
|
|
150
158
|
/** @private */
|
|
@@ -162,7 +170,7 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
162
170
|
col = document.createElement('vaadin-grid-column');
|
|
163
171
|
parent.appendChild(col);
|
|
164
172
|
col.renderer = (root, _column, model) => {
|
|
165
|
-
root.textContent = path ?
|
|
173
|
+
root.textContent = path ? getProperty(path, model.item) : model.item;
|
|
166
174
|
};
|
|
167
175
|
}
|
|
168
176
|
|
|
@@ -194,7 +202,6 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
194
202
|
|
|
195
203
|
const textField = window.document.createElement('vaadin-text-field');
|
|
196
204
|
textField.setAttribute('theme', 'small');
|
|
197
|
-
textField.setAttribute('slot', 'filter');
|
|
198
205
|
textField.setAttribute('focus-target', true);
|
|
199
206
|
textField.style.width = '100%';
|
|
200
207
|
if (this.noSort) {
|
|
@@ -261,34 +268,11 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
261
268
|
__createGroup(parent, header) {
|
|
262
269
|
const grp = document.createElement('vaadin-grid-column-group');
|
|
263
270
|
if (header) {
|
|
264
|
-
grp.header =
|
|
271
|
+
grp.header = capitalize(header);
|
|
265
272
|
}
|
|
266
273
|
parent.appendChild(grp);
|
|
267
274
|
return grp;
|
|
268
275
|
}
|
|
269
|
-
|
|
270
|
-
/** @private */
|
|
271
|
-
__capitalize(path) {
|
|
272
|
-
return path
|
|
273
|
-
.toLowerCase()
|
|
274
|
-
.replace(/([^\w]+)/g, ' ')
|
|
275
|
-
.trim()
|
|
276
|
-
.replace(/^./, (c) => c.toUpperCase());
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/** @private */
|
|
280
|
-
__set(path, val, obj) {
|
|
281
|
-
if (obj && path) {
|
|
282
|
-
path
|
|
283
|
-
.split('.')
|
|
284
|
-
.slice(0, -1)
|
|
285
|
-
.reduce((o, p) => {
|
|
286
|
-
o[p] = o[p] || {};
|
|
287
|
-
return o[p];
|
|
288
|
-
}, obj);
|
|
289
|
-
this.set(path, val, obj);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
276
|
}
|
|
293
277
|
|
|
294
278
|
customElements.define(CrudGrid.is, CrudGrid);
|
|
@@ -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
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Convenience utility for capitalizing a string, with
|
|
14
|
+
* replacing non-alphanumeric characters with spaces.
|
|
15
|
+
*/
|
|
16
|
+
export function capitalize(path: string): string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Convenience method for reading a value from a path.
|
|
20
|
+
*/
|
|
21
|
+
export function getProperty(path: string, obj: Record<string, unknown>): unknown;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Convenience utility for setting a value to a path.
|
|
25
|
+
*
|
|
26
|
+
* Note, if any part in the path is undefined, this
|
|
27
|
+
* function initializes it with an empty object.
|
|
28
|
+
*/
|
|
29
|
+
export function setProperty(path: string, value: unknown, obj: Record<string, unknown>): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { get, set } from '@polymer/polymer/lib/utils/path.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Convenience utility for capitalizing a string, with
|
|
15
|
+
* replacing non-alphanumeric characters with spaces.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} path
|
|
18
|
+
* @return {string}
|
|
19
|
+
*/
|
|
20
|
+
export function capitalize(path) {
|
|
21
|
+
return path
|
|
22
|
+
.toLowerCase()
|
|
23
|
+
.replace(/([^\w]+)/gu, ' ')
|
|
24
|
+
.trim()
|
|
25
|
+
.replace(/^./u, (c) => c.toUpperCase());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Convenience utility for reading a value from a path.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} path
|
|
32
|
+
* @param {Object} obj
|
|
33
|
+
* @return {*}
|
|
34
|
+
*/
|
|
35
|
+
export function getProperty(path, obj) {
|
|
36
|
+
return get(obj, path);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Convenience utility for setting a value to a path.
|
|
41
|
+
*
|
|
42
|
+
* Note, if any part in the path is undefined, this
|
|
43
|
+
* function initializes it with an empty object.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} path
|
|
46
|
+
* @param {*} value
|
|
47
|
+
* @param {Object} obj
|
|
48
|
+
*/
|
|
49
|
+
export function setProperty(path, value, obj) {
|
|
50
|
+
if (obj && path) {
|
|
51
|
+
path
|
|
52
|
+
.split('.')
|
|
53
|
+
.slice(0, -1)
|
|
54
|
+
.reduce((o, p) => {
|
|
55
|
+
// Create an object
|
|
56
|
+
if (!o[p]) {
|
|
57
|
+
o[p] = {};
|
|
58
|
+
}
|
|
59
|
+
return o[p];
|
|
60
|
+
}, obj);
|
|
61
|
+
|
|
62
|
+
set(obj, path, value);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
12
|
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
11
|
+
import { setProperty } from './vaadin-crud-helpers.js';
|
|
6
12
|
|
|
7
13
|
/**
|
|
8
14
|
* @polymerMixin
|
|
@@ -41,17 +47,19 @@ export const IncludedMixin = (superClass) =>
|
|
|
41
47
|
/** @private */
|
|
42
48
|
__onExcludeChange(exclude) {
|
|
43
49
|
if (typeof exclude === 'string') {
|
|
44
|
-
this.exclude = exclude ? RegExp(exclude.replace(/, */
|
|
50
|
+
this.exclude = exclude ? RegExp(exclude.replace(/, */gu, '|'), 'iu') : undefined;
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
/** @private */
|
|
49
55
|
__onIncludeChange(include) {
|
|
50
56
|
if (typeof include === 'string') {
|
|
51
|
-
this.include = include ? include.split(/, */) : undefined;
|
|
57
|
+
this.include = include ? include.split(/, */u) : undefined;
|
|
52
58
|
} else if (!this._fields && Array.isArray(include)) {
|
|
53
59
|
const item = {};
|
|
54
|
-
this.include.forEach((path) =>
|
|
60
|
+
this.include.forEach((path) => {
|
|
61
|
+
setProperty(path, null, item);
|
|
62
|
+
});
|
|
55
63
|
this._configure(item);
|
|
56
64
|
}
|
|
57
65
|
}
|
package/src/vaadin-crud.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
4
|
-
*
|
|
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.
|
|
5
10
|
*/
|
|
6
11
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
12
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
@@ -76,7 +81,7 @@ export type CrudNewEvent = CustomEvent<{ item: null }>;
|
|
|
76
81
|
/**
|
|
77
82
|
* Fired when user wants to edit an existing item.
|
|
78
83
|
*/
|
|
79
|
-
export type CrudEditEvent<T> = CustomEvent<{ item: T }>;
|
|
84
|
+
export type CrudEditEvent<T> = CustomEvent<{ item: T; index: number }>;
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
87
|
* Fired when user wants to delete item.
|
|
@@ -124,23 +129,34 @@ export type CrudEventMap<T> = CrudCustomEventMap<T> & HTMLElementEventMap;
|
|
|
124
129
|
*
|
|
125
130
|
* A grid and an editor will be automatically generated and configured based on the data structure provided.
|
|
126
131
|
*
|
|
127
|
-
* #### Example:
|
|
128
132
|
* ```html
|
|
129
|
-
* <vaadin-crud
|
|
130
|
-
*
|
|
133
|
+
* <vaadin-crud></vaadin-crud>
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* ```js
|
|
137
|
+
* const crud = document.querySelector('vaadin-crud');
|
|
138
|
+
*
|
|
139
|
+
* crud.items = [
|
|
140
|
+
* { name: 'John', surname: 'Lennon', role: 'singer' },
|
|
141
|
+
* { name: 'Ringo', surname: 'Starr', role: 'drums' },
|
|
142
|
+
* // ... more items
|
|
143
|
+
* ];
|
|
131
144
|
* ```
|
|
132
145
|
*
|
|
133
146
|
* ### Data Provider Function
|
|
134
147
|
*
|
|
135
148
|
* Otherwise, you can provide a [`dataProvider`](#/elements/vaadin-crud#property-dataProvider) function.
|
|
136
|
-
*
|
|
137
|
-
* ```html
|
|
138
|
-
* <vaadin-crud></vaadin-crud>
|
|
139
|
-
* ```
|
|
149
|
+
*
|
|
140
150
|
* ```js
|
|
141
151
|
* const crud = document.querySelector('vaadin-crud');
|
|
142
|
-
*
|
|
143
|
-
*
|
|
152
|
+
*
|
|
153
|
+
* const users = [
|
|
154
|
+
* { name: 'John', surname: 'Lennon', role: 'singer' },
|
|
155
|
+
* { name: 'Ringo', surname: 'Starr', role: 'drums' },
|
|
156
|
+
* // ... more items
|
|
157
|
+
* ];
|
|
158
|
+
*
|
|
159
|
+
* crud.dataProvider = (params, callback) => {
|
|
144
160
|
* const chunk = users.slice(params.page * params.pageSize, params.page * params.pageSize + params.pageSize);
|
|
145
161
|
* callback(chunk, people.length);
|
|
146
162
|
* };
|
|
@@ -153,20 +169,20 @@ export type CrudEventMap<T> = CrudCustomEventMap<T> & HTMLElementEventMap;
|
|
|
153
169
|
*
|
|
154
170
|
* Alternatively you can fully configure the component by using `slot` names.
|
|
155
171
|
*
|
|
156
|
-
* Slot name
|
|
157
|
-
*
|
|
158
|
-
* `grid`
|
|
159
|
-
* `form`
|
|
160
|
-
* `
|
|
172
|
+
* Slot name | Description
|
|
173
|
+
* ---------------|----------------
|
|
174
|
+
* `grid` | To replace the auto-generated grid with a custom one.
|
|
175
|
+
* `form` | To replace the auto-generated form.
|
|
176
|
+
* `save-button` | To replace the "Save" button.
|
|
177
|
+
* `cancel-button`| To replace the "Cancel" button.
|
|
178
|
+
* `delete-button`| To replace the "Delete" button.
|
|
179
|
+
* `toolbar` | To provide the toolbar content (by default, it's empty).
|
|
180
|
+
* `new-button` | To replace the "New item" button.
|
|
161
181
|
*
|
|
162
182
|
* #### Example:
|
|
163
183
|
*
|
|
164
184
|
* ```html
|
|
165
|
-
* <vaadin-crud
|
|
166
|
-
* id="crud"
|
|
167
|
-
* items='[{"name": "John", "surname": "Lennon", "role": "singer"},
|
|
168
|
-
* {"name": "Ringo", "surname": "Starr", "role": "drums"}]'
|
|
169
|
-
* >
|
|
185
|
+
* <vaadin-crud id="crud">
|
|
170
186
|
* <vaadin-grid slot="grid">
|
|
171
187
|
* <vaadin-crud-edit-column></vaadin-crud-edit-column>
|
|
172
188
|
* <vaadin-grid-column id="column1"></vaadin-grid-column>
|
|
@@ -178,10 +194,12 @@ export type CrudEventMap<T> = CrudCustomEventMap<T> & HTMLElementEventMap;
|
|
|
178
194
|
* <vaadin-text-field label="Surname" path="surname"></vaadin-text-field>
|
|
179
195
|
* </vaadin-form-layout>
|
|
180
196
|
*
|
|
181
|
-
* <div slot="toolbar">
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* </
|
|
197
|
+
* <div slot="toolbar">Total singers: 2</div>
|
|
198
|
+
* <button slot="new-button">New singer</button>
|
|
199
|
+
*
|
|
200
|
+
* <button slot="save-button">Save changes</button>
|
|
201
|
+
* <button slot="cancel-button">Discard changes</button>
|
|
202
|
+
* <button slot="delete-button">Delete singer</button>
|
|
185
203
|
* </vaadin-crud>
|
|
186
204
|
* ```
|
|
187
205
|
* ```js
|
|
@@ -202,6 +220,12 @@ export type CrudEventMap<T> = CrudCustomEventMap<T> & HTMLElementEventMap;
|
|
|
202
220
|
* column2.renderer = (root, column, model) => {
|
|
203
221
|
* root.textContent = model.item.surname;
|
|
204
222
|
* };
|
|
223
|
+
*
|
|
224
|
+
* crud.items = [
|
|
225
|
+
* { name: 'John', surname: 'Lennon', role: 'singer' },
|
|
226
|
+
* { name: 'Ringo', surname: 'Starr', role: 'drums' },
|
|
227
|
+
* // ... more items
|
|
228
|
+
* ];
|
|
205
229
|
* ```
|
|
206
230
|
*
|
|
207
231
|
* ### Helpers
|