@vaadin/crud 25.0.0-alpha8 → 25.0.0-beta1
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 +16 -17
- package/src/styles/vaadin-crud-base-styles.js +171 -0
- package/src/styles/vaadin-crud-dialog-overlay-base-styles.js +50 -0
- package/src/styles/vaadin-crud-edit-base-styles.js +28 -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/vaadin-crud-controllers.js +1 -1
- package/src/vaadin-crud-dialog.js +50 -14
- package/src/vaadin-crud-edit-column.js +4 -4
- package/src/vaadin-crud-edit.js +4 -11
- package/src/vaadin-crud-grid.js +5 -0
- package/src/vaadin-crud-mixin.d.ts +1 -1
- package/src/vaadin-crud-mixin.js +57 -80
- package/src/vaadin-crud.d.ts +17 -2
- package/src/vaadin-crud.js +65 -33
- package/vaadin-crud.js +1 -1
- package/web-types.json +42 -17
- package/web-types.lit.json +20 -13
- package/src/styles/vaadin-crud-core-styles.js +0 -93
- package/src/styles/vaadin-crud-dialog-overlay-core-styles.js +0 -54
- package/theme/lumo/vaadin-crud-styles.d.ts +0 -4
- package/theme/lumo/vaadin-crud-styles.js +0 -155
- package/theme/lumo/vaadin-crud.d.ts +0 -8
- package/theme/lumo/vaadin-crud.js +0 -8
- /package/src/styles/{vaadin-crud-core-styles.d.ts → vaadin-crud-base-styles.d.ts} +0 -0
- /package/src/styles/{vaadin-crud-dialog-overlay-core-styles.d.ts → vaadin-crud-dialog-overlay-base-styles.d.ts} +0 -0
package/src/vaadin-crud-mixin.js
CHANGED
|
@@ -307,7 +307,7 @@ export const CrudMixin = (superClass) =>
|
|
|
307
307
|
*
|
|
308
308
|
* The object has the following JSON structure and default values:
|
|
309
309
|
*
|
|
310
|
-
* ```
|
|
310
|
+
* ```js
|
|
311
311
|
* {
|
|
312
312
|
* newItem: 'New item',
|
|
313
313
|
* editItem: 'Edit item',
|
|
@@ -377,18 +377,30 @@ export const CrudMixin = (superClass) =>
|
|
|
377
377
|
return this.__fields;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
/** @private */
|
|
381
|
+
get _editor() {
|
|
382
|
+
return this.shadowRoot.querySelector('#editor');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** @private */
|
|
386
|
+
get _scroller() {
|
|
387
|
+
return this.shadowRoot.querySelector('#scroller');
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/** @private */
|
|
391
|
+
get _dialogMode() {
|
|
392
|
+
return this.editorPosition === '' || this._fullscreen;
|
|
393
|
+
}
|
|
394
|
+
|
|
380
395
|
/** @protected */
|
|
381
396
|
ready() {
|
|
382
397
|
super.ready();
|
|
383
398
|
|
|
384
|
-
this.$.dialog.$.overlay.addEventListener('vaadin-overlay-outside-click', this.__cancel);
|
|
385
|
-
this.$.dialog.$.overlay.addEventListener('vaadin-overlay-escape-press', this.__cancel);
|
|
386
|
-
|
|
387
399
|
this._gridController = new GridSlotController(this);
|
|
388
400
|
this.addController(this._gridController);
|
|
389
401
|
|
|
390
402
|
// Init button controllers in `ready()` (not constructor) so that Flow can set `_noDefaultButtons`
|
|
391
|
-
this._newButtonController = new ButtonSlotController(this, 'new',
|
|
403
|
+
this._newButtonController = new ButtonSlotController(this, 'new', null, this._noDefaultButtons);
|
|
392
404
|
this.addController(this._newButtonController);
|
|
393
405
|
|
|
394
406
|
this._headerController = new SlotController(this, 'header', 'h3', {
|
|
@@ -421,6 +433,24 @@ export const CrudMixin = (superClass) =>
|
|
|
421
433
|
this._confirmDeleteDialog = this.querySelector('vaadin-confirm-dialog[slot="confirm-delete"]');
|
|
422
434
|
}
|
|
423
435
|
|
|
436
|
+
/** @protected */
|
|
437
|
+
updated(props) {
|
|
438
|
+
super.updated(props);
|
|
439
|
+
|
|
440
|
+
// When using dialog mode, hide elements not slotted into the dialog from accessibility tree
|
|
441
|
+
if (
|
|
442
|
+
props.has('_grid') ||
|
|
443
|
+
props.has('_newButton') ||
|
|
444
|
+
props.has('editorOpened') ||
|
|
445
|
+
props.has('editorPosition') ||
|
|
446
|
+
props.has('_fullscreen')
|
|
447
|
+
) {
|
|
448
|
+
const hide = this.editorOpened && this._dialogMode;
|
|
449
|
+
this.__hideElement(this._grid, hide);
|
|
450
|
+
this.__hideElement(this._newButton, hide);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
424
454
|
/**
|
|
425
455
|
* @param {boolean} isDirty
|
|
426
456
|
* @private
|
|
@@ -477,25 +507,24 @@ export const CrudMixin = (superClass) =>
|
|
|
477
507
|
}
|
|
478
508
|
|
|
479
509
|
if (opened) {
|
|
480
|
-
this.__ensureChildren();
|
|
481
|
-
|
|
482
510
|
// When using bottom / aside editor position,
|
|
483
511
|
// auto-focus the editor element on open.
|
|
484
|
-
if (this.
|
|
485
|
-
this
|
|
486
|
-
this.$.editor.focus();
|
|
487
|
-
} else {
|
|
488
|
-
this.$.editor.removeAttribute('tabindex');
|
|
512
|
+
if (this._editor) {
|
|
513
|
+
this._editor.focus();
|
|
489
514
|
}
|
|
490
|
-
|
|
491
|
-
//
|
|
492
|
-
|
|
515
|
+
|
|
516
|
+
// Wait to set label until header node has updated (observer seems to run after this one)
|
|
517
|
+
setTimeout(() => {
|
|
518
|
+
this.__dialogAriaLabel = this._headerNode.textContent.trim();
|
|
519
|
+
});
|
|
493
520
|
}
|
|
494
521
|
|
|
495
522
|
this.__toggleToolbar();
|
|
496
523
|
|
|
497
524
|
// Make sure to reset scroll position
|
|
498
|
-
this
|
|
525
|
+
if (this._scroller) {
|
|
526
|
+
this._scroller.scrollTop = 0;
|
|
527
|
+
}
|
|
499
528
|
}
|
|
500
529
|
|
|
501
530
|
/** @private */
|
|
@@ -503,8 +532,6 @@ export const CrudMixin = (superClass) =>
|
|
|
503
532
|
if (fullscreen || oldFullscreen) {
|
|
504
533
|
this.__toggleToolbar();
|
|
505
534
|
|
|
506
|
-
this.__ensureChildren();
|
|
507
|
-
|
|
508
535
|
this.toggleAttribute('fullscreen', fullscreen);
|
|
509
536
|
}
|
|
510
537
|
}
|
|
@@ -517,66 +544,6 @@ export const CrudMixin = (superClass) =>
|
|
|
517
544
|
}
|
|
518
545
|
}
|
|
519
546
|
|
|
520
|
-
/** @private */
|
|
521
|
-
__moveChildNodes(target) {
|
|
522
|
-
const nodes = [this._headerNode, this._form];
|
|
523
|
-
const buttons = [this._saveButton, this._cancelButton, this._deleteButton].filter(Boolean);
|
|
524
|
-
if (!nodes.every((node) => node instanceof HTMLElement)) {
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// Teleport header node, form, and the buttons to corresponding slots.
|
|
529
|
-
// NOTE: order in which buttons are moved matches the order of slots.
|
|
530
|
-
[...nodes, ...buttons].forEach((node) => {
|
|
531
|
-
// Do not move nodes if the editor position has not changed
|
|
532
|
-
if (node.parentNode !== target) {
|
|
533
|
-
target.appendChild(node);
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
// Wait to set label until slotted element has been moved.
|
|
538
|
-
setTimeout(() => {
|
|
539
|
-
this.__dialogAriaLabel = this._headerNode.textContent.trim();
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/** @private */
|
|
544
|
-
__shouldOpenDialog(fullscreen, editorPosition) {
|
|
545
|
-
return editorPosition === '' || fullscreen;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/** @private */
|
|
549
|
-
__ensureChildren() {
|
|
550
|
-
if (this.__shouldOpenDialog(this._fullscreen, this.editorPosition)) {
|
|
551
|
-
// Move form to dialog
|
|
552
|
-
this.__moveChildNodes(this.$.dialog.$.overlay);
|
|
553
|
-
} else {
|
|
554
|
-
// Move form to crud
|
|
555
|
-
this.__moveChildNodes(this);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/** @private */
|
|
560
|
-
__computeDialogOpened(opened, fullscreen, editorPosition) {
|
|
561
|
-
// Only open dialog when editorPosition is "" or fullscreen is set
|
|
562
|
-
return this.__shouldOpenDialog(fullscreen, editorPosition) ? opened : false;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
/** @private */
|
|
566
|
-
__computeEditorHidden(opened, fullscreen, editorPosition) {
|
|
567
|
-
// Only show editor when editorPosition is "bottom" or "aside"
|
|
568
|
-
if (['aside', 'bottom'].includes(editorPosition) && !fullscreen) {
|
|
569
|
-
return !opened;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
return true;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/** @private */
|
|
576
|
-
__onDialogOpened(event) {
|
|
577
|
-
this.editorOpened = event.detail.value;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
547
|
/** @private */
|
|
581
548
|
__onGridEdit(event) {
|
|
582
549
|
event.stopPropagation();
|
|
@@ -620,8 +587,7 @@ export const CrudMixin = (superClass) =>
|
|
|
620
587
|
* @private
|
|
621
588
|
*/
|
|
622
589
|
__formChanged(form, oldForm) {
|
|
623
|
-
if (oldForm
|
|
624
|
-
oldForm.parentElement.removeChild(oldForm);
|
|
590
|
+
if (oldForm) {
|
|
625
591
|
oldForm.removeEventListener('change', this.__onFormChange);
|
|
626
592
|
oldForm.removeEventListener('input', this.__onFormChange);
|
|
627
593
|
}
|
|
@@ -1023,6 +989,17 @@ export const CrudMixin = (superClass) =>
|
|
|
1023
989
|
}
|
|
1024
990
|
}
|
|
1025
991
|
|
|
992
|
+
/** @private */
|
|
993
|
+
__hideElement(element, value) {
|
|
994
|
+
if (!element) return;
|
|
995
|
+
|
|
996
|
+
if (value) {
|
|
997
|
+
element.setAttribute('aria-hidden', 'true');
|
|
998
|
+
} else {
|
|
999
|
+
element.removeAttribute('aria-hidden');
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1026
1003
|
/**
|
|
1027
1004
|
* Fired when user wants to edit an existing item. If the default is prevented, then
|
|
1028
1005
|
* a new item is not assigned to the form, giving that responsibility to the app, though
|
package/src/vaadin-crud.d.ts
CHANGED
|
@@ -132,11 +132,26 @@ export * from './vaadin-crud-mixin.js';
|
|
|
132
132
|
*
|
|
133
133
|
* ### Styling
|
|
134
134
|
*
|
|
135
|
-
* The following shadow DOM parts are available for styling:
|
|
135
|
+
* The following shadow DOM parts are available for styling when the editor is rendered next to, or below, the grid:
|
|
136
136
|
*
|
|
137
137
|
* Part name | Description
|
|
138
138
|
* ----------------|----------------
|
|
139
|
-
* `toolbar`
|
|
139
|
+
* `toolbar` | Toolbar container at the bottom of the grid. By default, it contains the `new` button
|
|
140
|
+
* `editor` | The editor container
|
|
141
|
+
* `scroller` | The wrapper for the header and the form
|
|
142
|
+
* `header` | The header of the editor
|
|
143
|
+
* `footer` | The footer of the editor
|
|
144
|
+
*
|
|
145
|
+
* The following shadow DOM parts are available for styling when the editor renders as a dialog:
|
|
146
|
+
*
|
|
147
|
+
* Part name | Description
|
|
148
|
+
* ----------------|----------------
|
|
149
|
+
* `toolbar` | Toolbar container at the bottom of the grid. By default, it contains the `new` button
|
|
150
|
+
* `overlay` | The dialog overlay
|
|
151
|
+
* `backdrop` | The dialog backdrop
|
|
152
|
+
* `header` | The header of the dialog
|
|
153
|
+
* `footer` | The footer of the dialog
|
|
154
|
+
* `content` | The wrapper for the form
|
|
140
155
|
*
|
|
141
156
|
* The following custom properties are available:
|
|
142
157
|
*
|
package/src/vaadin-crud.js
CHANGED
|
@@ -13,14 +13,14 @@ 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, LitElement, render } from 'lit';
|
|
16
|
+
import { html, LitElement, nothing, render } from 'lit';
|
|
17
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
20
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
21
21
|
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
22
22
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
23
|
-
import { crudStyles } from './styles/vaadin-crud-
|
|
23
|
+
import { crudStyles } from './styles/vaadin-crud-base-styles.js';
|
|
24
24
|
import { CrudMixin } from './vaadin-crud-mixin.js';
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -140,11 +140,26 @@ import { CrudMixin } from './vaadin-crud-mixin.js';
|
|
|
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
144
|
*
|
|
145
145
|
* Part name | Description
|
|
146
146
|
* ----------------|----------------
|
|
147
|
-
* `toolbar`
|
|
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:
|
|
154
|
+
*
|
|
155
|
+
* Part name | Description
|
|
156
|
+
* ----------------|----------------
|
|
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
|
*
|
|
@@ -197,38 +212,55 @@ class Crud extends CrudMixin(ElementMixin(ThemableMixin(PolylitMixin(LumoInjecti
|
|
|
197
212
|
</div>
|
|
198
213
|
</div>
|
|
199
214
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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>
|
|
213
231
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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}
|
|
220
240
|
</div>
|
|
221
241
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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}
|
|
232
264
|
|
|
233
265
|
<slot name="confirm-cancel"></slot>
|
|
234
266
|
|
package/vaadin-crud.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './src/vaadin-crud.js';
|
|
2
2
|
export * from './src/vaadin-crud.js';
|
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": "25.0.0-
|
|
4
|
+
"version": "25.0.0-beta1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -10,6 +10,17 @@
|
|
|
10
10
|
"name": "vaadin-crud-edit",
|
|
11
11
|
"description": "`<vaadin-crud-edit>` is a helper element for `<vaadin-grid-column>` that provides\nan easily themable button that fires an `edit` event with the row item as detail\nwhen clicked.\n\nTypical usage is in a `<vaadin-grid-column>` of a custom `<vaadin-grid>` inside\na `<vaadin-crud>` to enable editing.",
|
|
12
12
|
"attributes": [
|
|
13
|
+
{
|
|
14
|
+
"name": "disabled",
|
|
15
|
+
"description": "When disabled, the button is rendered as \"dimmed\" and prevents all\nuser interactions (mouse and keyboard).\n\nSince disabled buttons are not focusable and cannot react to hover\nevents by default, it can cause accessibility issues by making them\nentirely invisible to assistive technologies, and prevents the use\nof Tooltips to explain why the action is not available. This can be\naddressed by enabling the feature flag `accessibleDisabledButtons`,\nwhich makes disabled buttons focusable and hoverable, while still\npreventing them from being triggered:\n\n```js\n// Set before any button is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledButtons = true\n```",
|
|
16
|
+
"value": {
|
|
17
|
+
"type": [
|
|
18
|
+
"boolean",
|
|
19
|
+
"null",
|
|
20
|
+
"undefined"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
13
24
|
{
|
|
14
25
|
"name": "theme",
|
|
15
26
|
"description": "The theme variants to apply to the component.",
|
|
@@ -23,7 +34,19 @@
|
|
|
23
34
|
}
|
|
24
35
|
],
|
|
25
36
|
"js": {
|
|
26
|
-
"properties": [
|
|
37
|
+
"properties": [
|
|
38
|
+
{
|
|
39
|
+
"name": "disabled",
|
|
40
|
+
"description": "When disabled, the button is rendered as \"dimmed\" and prevents all\nuser interactions (mouse and keyboard).\n\nSince disabled buttons are not focusable and cannot react to hover\nevents by default, it can cause accessibility issues by making them\nentirely invisible to assistive technologies, and prevents the use\nof Tooltips to explain why the action is not available. This can be\naddressed by enabling the feature flag `accessibleDisabledButtons`,\nwhich makes disabled buttons focusable and hoverable, while still\npreventing them from being triggered:\n\n```js\n// Set before any button is attached to the DOM.\nwindow.Vaadin.featureFlags.accessibleDisabledButtons = true\n```",
|
|
41
|
+
"value": {
|
|
42
|
+
"type": [
|
|
43
|
+
"boolean",
|
|
44
|
+
"null",
|
|
45
|
+
"undefined"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
],
|
|
27
50
|
"events": [
|
|
28
51
|
{
|
|
29
52
|
"name": "edit",
|
|
@@ -310,33 +333,35 @@
|
|
|
310
333
|
}
|
|
311
334
|
},
|
|
312
335
|
{
|
|
313
|
-
"name": "
|
|
314
|
-
"description": "
|
|
336
|
+
"name": "width",
|
|
337
|
+
"description": "Width of the cells for this column.\n\nPlease note that using the `em` length unit is discouraged as\nit might lead to misalignment issues if the header, body, and footer\ncells have different font sizes. Instead, use `rem` if you need\na length unit relative to the font size.",
|
|
315
338
|
"value": {
|
|
316
339
|
"type": [
|
|
317
|
-
"
|
|
340
|
+
"string",
|
|
318
341
|
"null",
|
|
319
342
|
"undefined"
|
|
320
343
|
]
|
|
321
344
|
}
|
|
322
345
|
},
|
|
323
346
|
{
|
|
324
|
-
"name": "
|
|
325
|
-
"description": "
|
|
347
|
+
"name": "renderer",
|
|
348
|
+
"description": "Custom function for rendering the cell content.\nReceives three arguments:\n\n- `root` The cell content DOM element. Append your content to it.\n- `column` The `<vaadin-grid-column>` element.\n- `model` The object with the properties related with\n the rendered item, contains:\n - `model.index` The index of the item.\n - `model.item` The item.\n - `model.expanded` Sublevel toggle state.\n - `model.level` Level of the tree represented with a horizontal offset of the toggle button.\n - `model.selected` Selected state.\n - `model.detailsOpened` Details opened state.\n - `model.hasChildren` Whether the item has children.",
|
|
326
349
|
"value": {
|
|
327
350
|
"type": [
|
|
328
|
-
"
|
|
351
|
+
"GridBodyRenderer",
|
|
329
352
|
"null",
|
|
330
353
|
"undefined"
|
|
331
354
|
]
|
|
332
355
|
}
|
|
333
356
|
},
|
|
334
357
|
{
|
|
335
|
-
"name": "
|
|
336
|
-
"description": "
|
|
358
|
+
"name": "path",
|
|
359
|
+
"description": "Path to an item sub-property whose value gets displayed in the column body cells.\nThe property name is also shown in the column header if an explicit header or renderer isn't defined.",
|
|
337
360
|
"value": {
|
|
338
361
|
"type": [
|
|
339
|
-
"
|
|
362
|
+
"string",
|
|
363
|
+
"null",
|
|
364
|
+
"undefined"
|
|
340
365
|
]
|
|
341
366
|
}
|
|
342
367
|
},
|
|
@@ -357,7 +382,7 @@
|
|
|
357
382
|
},
|
|
358
383
|
{
|
|
359
384
|
"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/25.0.0-
|
|
385
|
+
"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-beta1/#/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-beta1/#/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-beta1/#/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-beta1/#/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-beta1/#/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
386
|
"attributes": [
|
|
362
387
|
{
|
|
363
388
|
"name": "i18n",
|
|
@@ -421,7 +446,7 @@
|
|
|
421
446
|
},
|
|
422
447
|
{
|
|
423
448
|
"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/25.0.0-
|
|
449
|
+
"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-beta1/#/elements/vaadin-crud#property-exclude) is ignored.\n\nDefault is undefined meaning that all properties in the object should be mapped to fields.",
|
|
425
450
|
"value": {
|
|
426
451
|
"type": [
|
|
427
452
|
"string",
|
|
@@ -432,7 +457,7 @@
|
|
|
432
457
|
},
|
|
433
458
|
{
|
|
434
459
|
"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/25.0.0-
|
|
460
|
+
"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-beta1/#/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
461
|
"value": {
|
|
437
462
|
"type": [
|
|
438
463
|
"string",
|
|
@@ -479,7 +504,7 @@
|
|
|
479
504
|
"properties": [
|
|
480
505
|
{
|
|
481
506
|
"name": "i18n",
|
|
482
|
-
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n\n
|
|
507
|
+
"description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n\n```js\n{\n newItem: 'New item',\n editItem: 'Edit item',\n saveItem: 'Save',\n cancel: 'Cancel',\n deleteItem: 'Delete...',\n editLabel: 'Edit',\n confirm: {\n delete: {\n title: 'Confirm delete',\n content: 'Are you sure you want to delete the selected item? This action cannot be undone.',\n button: {\n confirm: 'Delete',\n dismiss: 'Cancel'\n }\n },\n cancel: {\n title: 'Unsaved changes',\n content: 'There are unsaved modifications to the item.',\n button: {\n confirm: 'Discard',\n dismiss: 'Continue editing'\n }\n }\n }\n}\n```",
|
|
483
508
|
"value": {
|
|
484
509
|
"type": [
|
|
485
510
|
"CrudI18n"
|
|
@@ -568,7 +593,7 @@
|
|
|
568
593
|
},
|
|
569
594
|
{
|
|
570
595
|
"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/25.0.0-
|
|
596
|
+
"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-beta1/#/elements/vaadin-crud#property-exclude) is ignored.\n\nDefault is undefined meaning that all properties in the object should be mapped to fields.",
|
|
572
597
|
"value": {
|
|
573
598
|
"type": [
|
|
574
599
|
"string",
|
|
@@ -579,7 +604,7 @@
|
|
|
579
604
|
},
|
|
580
605
|
{
|
|
581
606
|
"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/25.0.0-
|
|
607
|
+
"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-beta1/#/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
608
|
"value": {
|
|
584
609
|
"type": [
|
|
585
610
|
"string",
|