@vaadin/crud 24.8.4 → 25.0.0-alpha10
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/README.md +0 -23
- package/package.json +19 -20
- package/src/{vaadin-crud-styles.d.ts → styles/vaadin-crud-base-styles.d.ts} +0 -2
- package/src/styles/vaadin-crud-base-styles.js +162 -0
- package/src/styles/vaadin-crud-core-styles.d.ts +13 -0
- package/src/{vaadin-crud-styles.js → styles/vaadin-crud-core-styles.js} +1 -33
- package/src/styles/vaadin-crud-dialog-overlay-base-styles.d.ts +13 -0
- package/src/styles/vaadin-crud-dialog-overlay-base-styles.js +48 -0
- package/src/styles/vaadin-crud-dialog-overlay-core-styles.d.ts +13 -0
- package/src/styles/vaadin-crud-dialog-overlay-core-styles.js +54 -0
- package/src/styles/vaadin-crud-edit-base-styles.js +28 -0
- package/src/styles/vaadin-crud-edit-core-styles.js +17 -0
- package/src/styles/vaadin-crud-grid-base-styles.d.ts +13 -0
- package/src/styles/vaadin-crud-grid-base-styles.js +21 -0
- package/src/styles/vaadin-crud-grid-core-styles.d.ts +13 -0
- package/src/styles/vaadin-crud-grid-core-styles.js +13 -0
- package/src/vaadin-crud-controllers.js +1 -1
- package/src/vaadin-crud-dialog.js +72 -41
- package/src/vaadin-crud-edit.js +12 -21
- package/src/vaadin-crud-form.js +4 -1
- package/src/vaadin-crud-grid.js +5 -0
- package/src/vaadin-crud-mixin.js +67 -81
- package/src/vaadin-crud.d.ts +18 -8
- package/src/vaadin-crud.js +126 -66
- package/web-types.json +6 -6
- package/web-types.lit.json +4 -4
- package/src/vaadin-lit-crud-dialog.js +0 -128
- package/src/vaadin-lit-crud-edit-column.js +0 -70
- package/src/vaadin-lit-crud-edit.js +0 -75
- package/src/vaadin-lit-crud-form.js +0 -80
- package/src/vaadin-lit-crud-grid.js +0 -35
- package/src/vaadin-lit-crud.js +0 -121
- package/theme/lumo/vaadin-lit-crud.d.ts +0 -8
- package/theme/lumo/vaadin-lit-crud.js +0 -8
- package/theme/material/vaadin-crud-styles.d.ts +0 -2
- package/theme/material/vaadin-crud-styles.js +0 -157
- package/theme/material/vaadin-crud.d.ts +0 -8
- package/theme/material/vaadin-crud.js +0 -8
- package/theme/material/vaadin-lit-crud.d.ts +0 -8
- package/theme/material/vaadin-lit-crud.js +0 -8
- package/vaadin-lit-crud-edit .js +0 -1
- package/vaadin-lit-crud-edit-column.d.ts +0 -1
- package/vaadin-lit-crud-edit-column.js +0 -1
- package/vaadin-lit-crud-edit.d.ts +0 -1
- package/vaadin-lit-crud.d.ts +0 -1
- package/vaadin-lit-crud.js +0 -2
package/src/vaadin-crud.js
CHANGED
|
@@ -13,15 +13,15 @@ import '@vaadin/confirm-dialog/src/vaadin-confirm-dialog.js';
|
|
|
13
13
|
import './vaadin-crud-dialog.js';
|
|
14
14
|
import './vaadin-crud-grid.js';
|
|
15
15
|
import './vaadin-crud-form.js';
|
|
16
|
-
import { html,
|
|
17
|
-
import {
|
|
16
|
+
import { html, LitElement, nothing, render } from 'lit';
|
|
17
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
18
18
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
19
19
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
20
|
-
import {
|
|
20
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
21
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
22
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
23
|
+
import { crudStyles } from './styles/vaadin-crud-core-styles.js';
|
|
21
24
|
import { CrudMixin } from './vaadin-crud-mixin.js';
|
|
22
|
-
import { crudStyles } from './vaadin-crud-styles.js';
|
|
23
|
-
|
|
24
|
-
registerStyles('vaadin-crud', crudStyles, { moduleId: 'vaadin-crud-styles' });
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* `<vaadin-crud>` is a Web Component for [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations.
|
|
@@ -140,11 +140,26 @@ registerStyles('vaadin-crud', crudStyles, { moduleId: 'vaadin-crud-styles' });
|
|
|
140
140
|
*
|
|
141
141
|
* ### Styling
|
|
142
142
|
*
|
|
143
|
-
* The following shadow DOM parts are available for styling:
|
|
143
|
+
* The following shadow DOM parts are available for styling when the editor is rendered next to, or below, the grid:
|
|
144
|
+
*
|
|
145
|
+
* Part name | Description
|
|
146
|
+
* ----------------|----------------
|
|
147
|
+
* `toolbar` | Toolbar container at the bottom of the grid. By default, it contains the `new` button
|
|
148
|
+
* `editor` | The editor container
|
|
149
|
+
* `scroller` | The wrapper for the header and the form
|
|
150
|
+
* `header` | The header of the editor
|
|
151
|
+
* `footer` | The footer of the editor
|
|
152
|
+
*
|
|
153
|
+
* The following shadow DOM parts are available for styling when the editor renders as a dialog:
|
|
144
154
|
*
|
|
145
155
|
* Part name | Description
|
|
146
156
|
* ----------------|----------------
|
|
147
|
-
* `toolbar`
|
|
157
|
+
* `toolbar` | Toolbar container at the bottom of the grid. By default, it contains the `new` button
|
|
158
|
+
* `overlay` | The dialog overlay
|
|
159
|
+
* `backdrop` | The dialog backdrop
|
|
160
|
+
* `header` | The header of the dialog
|
|
161
|
+
* `footer` | The footer of the dialog
|
|
162
|
+
* `content` | The wrapper for the form
|
|
148
163
|
*
|
|
149
164
|
* The following custom properties are available:
|
|
150
165
|
*
|
|
@@ -167,13 +182,25 @@ registerStyles('vaadin-crud', crudStyles, { moduleId: 'vaadin-crud-styles' });
|
|
|
167
182
|
*
|
|
168
183
|
* @customElement
|
|
169
184
|
* @extends HTMLElement
|
|
170
|
-
* @mixes ControllerMixin
|
|
171
185
|
* @mixes ElementMixin
|
|
172
186
|
* @mixes ThemableMixin
|
|
173
187
|
* @mixes CrudMixin
|
|
174
188
|
*/
|
|
175
|
-
class Crud extends CrudMixin(
|
|
176
|
-
static get
|
|
189
|
+
class Crud extends CrudMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
190
|
+
static get is() {
|
|
191
|
+
return 'vaadin-crud';
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static get cvdlName() {
|
|
195
|
+
return 'vaadin-crud';
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static get styles() {
|
|
199
|
+
return crudStyles;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** @protected */
|
|
203
|
+
render() {
|
|
177
204
|
return html`
|
|
178
205
|
<div id="container">
|
|
179
206
|
<div id="main">
|
|
@@ -185,71 +212,104 @@ class Crud extends CrudMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
185
212
|
</div>
|
|
186
213
|
</div>
|
|
187
214
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
215
|
+
${!this._dialogMode
|
|
216
|
+
? html`
|
|
217
|
+
<div
|
|
218
|
+
part="editor"
|
|
219
|
+
id="editor"
|
|
220
|
+
role="group"
|
|
221
|
+
aria-labelledby="header"
|
|
222
|
+
tabindex="0"
|
|
223
|
+
?hidden="${!this.editorOpened}"
|
|
224
|
+
>
|
|
225
|
+
<div part="scroller" id="scroller">
|
|
226
|
+
<div part="header" id="header">
|
|
227
|
+
<slot name="header"></slot>
|
|
228
|
+
</div>
|
|
229
|
+
<slot name="form"></slot>
|
|
230
|
+
</div>
|
|
201
231
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
232
|
+
<div part="footer" role="toolbar">
|
|
233
|
+
<slot name="save-button"></slot>
|
|
234
|
+
<slot name="cancel-button"></slot>
|
|
235
|
+
<slot name="delete-button"></slot>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
`
|
|
239
|
+
: nothing}
|
|
208
240
|
</div>
|
|
209
241
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
242
|
+
${this._dialogMode
|
|
243
|
+
? html`
|
|
244
|
+
<vaadin-crud-dialog
|
|
245
|
+
id="dialog"
|
|
246
|
+
aria-label="${ifDefined(this.__dialogAriaLabel)}"
|
|
247
|
+
theme="${ifDefined(this._theme)}"
|
|
248
|
+
exportparts="backdrop, overlay, header, content, footer"
|
|
249
|
+
.crudElement="${this}"
|
|
250
|
+
.opened="${this.editorOpened}"
|
|
251
|
+
.fullscreen="${this._fullscreen}"
|
|
252
|
+
.noCloseOnOutsideClick="${this.__isDirty}"
|
|
253
|
+
.noCloseOnEsc="${this.__isDirty}"
|
|
254
|
+
@cancel="${this.__cancel}"
|
|
255
|
+
>
|
|
256
|
+
<slot name="header" slot="header"></slot>
|
|
257
|
+
<slot name="form" slot="form"></slot>
|
|
258
|
+
<slot name="save-button" slot="save-button"></slot>
|
|
259
|
+
<slot name="cancel-button" slot="cancel-button"></slot>
|
|
260
|
+
<slot name="delete-button" slot="delete-button"></slot>
|
|
261
|
+
</vaadin-crud-dialog>
|
|
262
|
+
`
|
|
263
|
+
: nothing}
|
|
220
264
|
|
|
221
|
-
<
|
|
222
|
-
theme$="[[_theme]]"
|
|
223
|
-
id="confirmCancel"
|
|
224
|
-
on-confirm="__confirmCancel"
|
|
225
|
-
cancel-button-visible
|
|
226
|
-
confirm-text="[[__effectiveI18n.confirm.cancel.button.confirm]]"
|
|
227
|
-
cancel-text="[[__effectiveI18n.confirm.cancel.button.dismiss]]"
|
|
228
|
-
header="[[__effectiveI18n.confirm.cancel.title]]"
|
|
229
|
-
message="[[__effectiveI18n.confirm.cancel.content]]"
|
|
230
|
-
confirm-theme="primary"
|
|
231
|
-
></vaadin-confirm-dialog>
|
|
265
|
+
<slot name="confirm-cancel"></slot>
|
|
232
266
|
|
|
233
|
-
<
|
|
234
|
-
theme$="[[_theme]]"
|
|
235
|
-
id="confirmDelete"
|
|
236
|
-
on-confirm="__confirmDelete"
|
|
237
|
-
cancel-button-visible
|
|
238
|
-
confirm-text="[[__effectiveI18n.confirm.delete.button.confirm]]"
|
|
239
|
-
cancel-text="[[__effectiveI18n.confirm.delete.button.dismiss]]"
|
|
240
|
-
header="[[__effectiveI18n.confirm.delete.title]]"
|
|
241
|
-
message="[[__effectiveI18n.confirm.delete.content]]"
|
|
242
|
-
confirm-theme="primary error"
|
|
243
|
-
></vaadin-confirm-dialog>
|
|
267
|
+
<slot name="confirm-delete"></slot>
|
|
244
268
|
`;
|
|
245
269
|
}
|
|
246
270
|
|
|
247
|
-
|
|
248
|
-
|
|
271
|
+
/**
|
|
272
|
+
* Override update to render slotted overlays into light DOM after rendering shadow DOM.
|
|
273
|
+
* @param changedProperties
|
|
274
|
+
* @protected
|
|
275
|
+
*/
|
|
276
|
+
update(changedProperties) {
|
|
277
|
+
super.update(changedProperties);
|
|
278
|
+
|
|
279
|
+
this.__renderSlottedOverlays();
|
|
249
280
|
}
|
|
250
281
|
|
|
251
|
-
|
|
252
|
-
|
|
282
|
+
/** @private */
|
|
283
|
+
__renderSlottedOverlays() {
|
|
284
|
+
render(
|
|
285
|
+
html`
|
|
286
|
+
<vaadin-confirm-dialog
|
|
287
|
+
theme="${ifDefined(this._theme)}"
|
|
288
|
+
slot="confirm-cancel"
|
|
289
|
+
@confirm="${this.__confirmCancel}"
|
|
290
|
+
cancel-button-visible
|
|
291
|
+
.confirmText="${this.__effectiveI18n.confirm.cancel.button.confirm}"
|
|
292
|
+
.cancelText="${this.__effectiveI18n.confirm.cancel.button.dismiss}"
|
|
293
|
+
.header="${this.__effectiveI18n.confirm.cancel.title}"
|
|
294
|
+
.message="${this.__effectiveI18n.confirm.cancel.content}"
|
|
295
|
+
confirm-theme="primary"
|
|
296
|
+
></vaadin-confirm-dialog>
|
|
297
|
+
|
|
298
|
+
<vaadin-confirm-dialog
|
|
299
|
+
theme="${ifDefined(this._theme)}"
|
|
300
|
+
slot="confirm-delete"
|
|
301
|
+
@confirm="${this.__confirmDelete}"
|
|
302
|
+
cancel-button-visible
|
|
303
|
+
.confirmText="${this.__effectiveI18n.confirm.delete.button.confirm}"
|
|
304
|
+
.cancelText="${this.__effectiveI18n.confirm.delete.button.dismiss}"
|
|
305
|
+
.header="${this.__effectiveI18n.confirm.delete.title}"
|
|
306
|
+
.message="${this.__effectiveI18n.confirm.delete.content}"
|
|
307
|
+
confirm-theme="primary error"
|
|
308
|
+
></vaadin-confirm-dialog>
|
|
309
|
+
`,
|
|
310
|
+
this,
|
|
311
|
+
{ host: this },
|
|
312
|
+
);
|
|
253
313
|
}
|
|
254
314
|
}
|
|
255
315
|
|
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": "
|
|
4
|
+
"version": "25.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -357,7 +357,7 @@
|
|
|
357
357
|
},
|
|
358
358
|
{
|
|
359
359
|
"name": "vaadin-crud",
|
|
360
|
-
"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/
|
|
360
|
+
"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/25.0.0-alpha10/#/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/25.0.0-alpha10/#/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/25.0.0-alpha10/#/elements/vaadin-crud-edit-column)\n- `<vaadin-crud-grid>` - can be replaced with custom [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-grid)\n- `<vaadin-crud-form>` - can be replaced with custom [`<vaadin-form-layout>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout)\n\n### Styling\n\nThe following shadow DOM parts are available for styling when the editor is rendered next to, or below, the grid:\n\nPart name | Description\n----------------|----------------\n`toolbar` | Toolbar container at the bottom of the grid. By default, it contains the `new` button\n`editor` | The editor container\n`scroller` | The wrapper for the header and the form\n`header` | The header of the editor\n`footer` | The footer of the editor\n\nThe following shadow DOM parts are available for styling when the editor renders as a dialog:\n\nPart name | Description\n----------------|----------------\n`toolbar` | Toolbar container at the bottom of the grid. By default, it contains the `new` button\n`overlay` | The dialog overlay\n`backdrop` | The dialog backdrop\n`header` | The header of the dialog\n`footer` | The footer of the dialog\n`content` | The wrapper for the form\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.",
|
|
361
361
|
"attributes": [
|
|
362
362
|
{
|
|
363
363
|
"name": "i18n",
|
|
@@ -421,7 +421,7 @@
|
|
|
421
421
|
},
|
|
422
422
|
{
|
|
423
423
|
"name": "include",
|
|
424
|
-
"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/
|
|
424
|
+
"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/25.0.0-alpha10/#/elements/vaadin-crud#property-exclude) is ignored.\n\nDefault is undefined meaning that all properties in the object should be mapped to fields.",
|
|
425
425
|
"value": {
|
|
426
426
|
"type": [
|
|
427
427
|
"string",
|
|
@@ -432,7 +432,7 @@
|
|
|
432
432
|
},
|
|
433
433
|
{
|
|
434
434
|
"name": "exclude",
|
|
435
|
-
"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/
|
|
435
|
+
"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/25.0.0-alpha10/#/elements/vaadin-crud#property-include) is defined, this parameter is ignored.\n\nDefault is to exclude all private fields (those properties starting with underscore)",
|
|
436
436
|
"value": {
|
|
437
437
|
"type": [
|
|
438
438
|
"string",
|
|
@@ -568,7 +568,7 @@
|
|
|
568
568
|
},
|
|
569
569
|
{
|
|
570
570
|
"name": "include",
|
|
571
|
-
"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/
|
|
571
|
+
"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/25.0.0-alpha10/#/elements/vaadin-crud#property-exclude) is ignored.\n\nDefault is undefined meaning that all properties in the object should be mapped to fields.",
|
|
572
572
|
"value": {
|
|
573
573
|
"type": [
|
|
574
574
|
"string",
|
|
@@ -579,7 +579,7 @@
|
|
|
579
579
|
},
|
|
580
580
|
{
|
|
581
581
|
"name": "exclude",
|
|
582
|
-
"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/
|
|
582
|
+
"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/25.0.0-alpha10/#/elements/vaadin-crud#property-include) is defined, this parameter is ignored.\n\nDefault is to exclude all private fields (those properties starting with underscore)",
|
|
583
583
|
"value": {
|
|
584
584
|
"type": [
|
|
585
585
|
"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": "
|
|
4
|
+
"version": "25.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
},
|
|
143
143
|
{
|
|
144
144
|
"name": "vaadin-crud",
|
|
145
|
-
"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/
|
|
145
|
+
"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/25.0.0-alpha10/#/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/25.0.0-alpha10/#/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/25.0.0-alpha10/#/elements/vaadin-crud-edit-column)\n- `<vaadin-crud-grid>` - can be replaced with custom [`<vaadin-grid>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-grid)\n- `<vaadin-crud-form>` - can be replaced with custom [`<vaadin-form-layout>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha10/#/elements/vaadin-form-layout)\n\n### Styling\n\nThe following shadow DOM parts are available for styling when the editor is rendered next to, or below, the grid:\n\nPart name | Description\n----------------|----------------\n`toolbar` | Toolbar container at the bottom of the grid. By default, it contains the `new` button\n`editor` | The editor container\n`scroller` | The wrapper for the header and the form\n`header` | The header of the editor\n`footer` | The footer of the editor\n\nThe following shadow DOM parts are available for styling when the editor renders as a dialog:\n\nPart name | Description\n----------------|----------------\n`toolbar` | Toolbar container at the bottom of the grid. By default, it contains the `new` button\n`overlay` | The dialog overlay\n`backdrop` | The dialog backdrop\n`header` | The header of the dialog\n`footer` | The footer of the dialog\n`content` | The wrapper for the form\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.",
|
|
146
146
|
"extension": true,
|
|
147
147
|
"attributes": [
|
|
148
148
|
{
|
|
@@ -224,14 +224,14 @@
|
|
|
224
224
|
},
|
|
225
225
|
{
|
|
226
226
|
"name": ".include",
|
|
227
|
-
"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/
|
|
227
|
+
"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/25.0.0-alpha10/#/elements/vaadin-crud#property-exclude) is ignored.\n\nDefault is undefined meaning that all properties in the object should be mapped to fields.",
|
|
228
228
|
"value": {
|
|
229
229
|
"kind": "expression"
|
|
230
230
|
}
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
"name": ".exclude",
|
|
234
|
-
"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/
|
|
234
|
+
"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/25.0.0-alpha10/#/elements/vaadin-crud#property-include) is defined, this parameter is ignored.\n\nDefault is to exclude all private fields (those properties starting with underscore)",
|
|
235
235
|
"value": {
|
|
236
236
|
"kind": "expression"
|
|
237
237
|
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2000 - 2025 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 { css, html, LitElement } from 'lit';
|
|
12
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
13
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
14
|
-
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
15
|
-
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
16
|
-
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
17
|
-
import { DialogBaseMixin } from '@vaadin/dialog/src/vaadin-dialog-base-mixin.js';
|
|
18
|
-
import { dialogOverlay, resizableOverlay } from '@vaadin/dialog/src/vaadin-dialog-styles.js';
|
|
19
|
-
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
20
|
-
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
|
|
21
|
-
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
22
|
-
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
23
|
-
import { crudDialogOverlayStyles } from './vaadin-crud-styles.js';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* An element used internally by `<vaadin-crud>`. Not intended to be used separately.
|
|
27
|
-
*
|
|
28
|
-
* @extends HTMLElement
|
|
29
|
-
* @mixes DirMixin
|
|
30
|
-
* @mixes OverlayMixin
|
|
31
|
-
* @mixes ThemableMixin
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
class CrudDialogOverlay extends OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))) {
|
|
35
|
-
static get is() {
|
|
36
|
-
return 'vaadin-crud-dialog-overlay';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static get styles() {
|
|
40
|
-
return [overlayStyles, dialogOverlay, resizableOverlay, crudDialogOverlayStyles];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** @protected */
|
|
44
|
-
render() {
|
|
45
|
-
return html`
|
|
46
|
-
<div part="backdrop" id="backdrop" ?hidden="${!this.withBackdrop}"></div>
|
|
47
|
-
<div part="overlay" id="overlay" tabindex="0">
|
|
48
|
-
<section id="resizerContainer" class="resizer-container">
|
|
49
|
-
<header part="header"><slot name="header"></slot></header>
|
|
50
|
-
<div part="content" id="content">
|
|
51
|
-
<slot name="form"></slot>
|
|
52
|
-
</div>
|
|
53
|
-
<footer part="footer" role="toolbar">
|
|
54
|
-
<slot name="save-button"></slot>
|
|
55
|
-
<slot name="cancel-button"></slot>
|
|
56
|
-
<slot name="delete-button"></slot>
|
|
57
|
-
</footer>
|
|
58
|
-
</section>
|
|
59
|
-
</div>
|
|
60
|
-
`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @protected
|
|
65
|
-
* @override
|
|
66
|
-
*/
|
|
67
|
-
ready() {
|
|
68
|
-
super.ready();
|
|
69
|
-
|
|
70
|
-
// CRUD has header and footer but does not use renderers
|
|
71
|
-
this.setAttribute('has-header', '');
|
|
72
|
-
this.setAttribute('has-footer', '');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
defineCustomElement(CrudDialogOverlay);
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* An element used internally by `<vaadin-crud>`. Not intended to be used separately.
|
|
80
|
-
* @private
|
|
81
|
-
*/
|
|
82
|
-
class CrudDialog extends DialogBaseMixin(OverlayClassMixin(ThemePropertyMixin(PolylitMixin(LitElement)))) {
|
|
83
|
-
static get is() {
|
|
84
|
-
return 'vaadin-crud-dialog';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static get styles() {
|
|
88
|
-
return css`
|
|
89
|
-
:host {
|
|
90
|
-
display: none;
|
|
91
|
-
}
|
|
92
|
-
`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
static get properties() {
|
|
96
|
-
return {
|
|
97
|
-
ariaLabel: {
|
|
98
|
-
type: String,
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
fullscreen: {
|
|
102
|
-
type: Boolean,
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** @protected */
|
|
108
|
-
render() {
|
|
109
|
-
return html`
|
|
110
|
-
<vaadin-crud-dialog-overlay
|
|
111
|
-
id="overlay"
|
|
112
|
-
.opened="${this.opened}"
|
|
113
|
-
aria-label="${ifDefined(this.ariaLabel)}"
|
|
114
|
-
@opened-changed="${this._onOverlayOpened}"
|
|
115
|
-
@mousedown="${this._bringOverlayToFront}"
|
|
116
|
-
@touchstart="${this._bringOverlayToFront}"
|
|
117
|
-
theme="${ifDefined(this._theme)}"
|
|
118
|
-
.modeless="${this.modeless}"
|
|
119
|
-
.withBackdrop="${!this.modeless}"
|
|
120
|
-
?fullscreen="${this.fullscreen}"
|
|
121
|
-
role="dialog"
|
|
122
|
-
focus-trap
|
|
123
|
-
></vaadin-crud-dialog-overlay>
|
|
124
|
-
`;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
defineCustomElement(CrudDialog);
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2000 - 2025 Vaadin Ltd.
|
|
4
|
-
*
|
|
5
|
-
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* See https://vaadin.com/commercial-license-and-service-terms for the full
|
|
9
|
-
* license.
|
|
10
|
-
*/
|
|
11
|
-
import './vaadin-lit-crud-edit.js';
|
|
12
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
|
-
import { GridColumn } from '@vaadin/grid/src/vaadin-lit-grid-column.js';
|
|
14
|
-
import { editColumnDefaultRenderer } from './vaadin-crud-helpers.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* LitElement based version of `<vaadin-crud-edit-column>` web component.
|
|
18
|
-
*
|
|
19
|
-
* ## Disclaimer
|
|
20
|
-
*
|
|
21
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
22
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
23
|
-
*/
|
|
24
|
-
class CrudEditColumn extends GridColumn {
|
|
25
|
-
static get is() {
|
|
26
|
-
return 'vaadin-crud-edit-column';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static get properties() {
|
|
30
|
-
return {
|
|
31
|
-
/**
|
|
32
|
-
* Width of the cells for this column.
|
|
33
|
-
* @private
|
|
34
|
-
*/
|
|
35
|
-
width: {
|
|
36
|
-
type: String,
|
|
37
|
-
value: '4rem',
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Flex grow ratio for the cell widths. When set to 0, cell width is fixed.
|
|
42
|
-
* @private
|
|
43
|
-
*/
|
|
44
|
-
flexGrow: {
|
|
45
|
-
type: Number,
|
|
46
|
-
value: 0,
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
/** The arial-label for the edit button */
|
|
50
|
-
ariaLabel: String,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static get observers() {
|
|
55
|
-
return ['_onRendererOrBindingChanged(_renderer, _cells, _bodyContentHidden, _cells.*, path, ariaLabel)'];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Renders the crud edit element to the body cell.
|
|
60
|
-
*
|
|
61
|
-
* @override
|
|
62
|
-
*/
|
|
63
|
-
_defaultRenderer(root, column) {
|
|
64
|
-
editColumnDefaultRenderer(root, column);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
defineCustomElement(CrudEditColumn);
|
|
69
|
-
|
|
70
|
-
export { CrudEditColumn };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright (c) 2000 - 2025 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
|
-
import { html } from 'lit';
|
|
13
|
-
import { Button } from '@vaadin/button/src/vaadin-lit-button.js';
|
|
14
|
-
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
15
|
-
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* LitElement based version of `<vaadin-crud-edit>` web component.
|
|
19
|
-
*
|
|
20
|
-
* ## Disclaimer
|
|
21
|
-
*
|
|
22
|
-
* This component is an experiment and not yet a part of Vaadin platform.
|
|
23
|
-
* There is no ETA regarding specific Vaadin version where it'll land.
|
|
24
|
-
*/
|
|
25
|
-
class CrudEdit extends Button {
|
|
26
|
-
static get is() {
|
|
27
|
-
return 'vaadin-crud-edit';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static get styles() {
|
|
31
|
-
return [
|
|
32
|
-
super.styles,
|
|
33
|
-
css`
|
|
34
|
-
:host {
|
|
35
|
-
display: block;
|
|
36
|
-
}
|
|
37
|
-
`,
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** @protected */
|
|
42
|
-
render() {
|
|
43
|
-
return html`
|
|
44
|
-
<div part="icon"></div>
|
|
45
|
-
<slot name="tooltip"></slot>
|
|
46
|
-
`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** @protected */
|
|
50
|
-
ready() {
|
|
51
|
-
super.ready();
|
|
52
|
-
this.addEventListener('click', this.__onClick);
|
|
53
|
-
this.setAttribute('aria-label', 'Edit');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** @private */
|
|
57
|
-
__onClick(e) {
|
|
58
|
-
const tr = e.target.parentElement.assignedSlot.parentElement.parentElement;
|
|
59
|
-
tr.dispatchEvent(
|
|
60
|
-
new CustomEvent('edit', { detail: { item: tr._item, index: tr.index }, bubbles: true, composed: true }),
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Fired when user on the icon.
|
|
66
|
-
*
|
|
67
|
-
* @event edit
|
|
68
|
-
* @param {Object} detail.item the item to edit
|
|
69
|
-
* @param {Object} detail.index the index of the item in the data set
|
|
70
|
-
*/
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
defineCustomElement(CrudEdit);
|
|
74
|
-
|
|
75
|
-
export { CrudEdit };
|