@vaadin/crud 24.6.5 → 24.7.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/package.json +17 -16
- package/src/vaadin-crud-controllers.d.ts +1 -1
- package/src/vaadin-crud-controllers.js +1 -1
- package/src/vaadin-crud-dialog.js +1 -1
- package/src/vaadin-crud-edit-column.d.ts +1 -1
- package/src/vaadin-crud-edit-column.js +4 -16
- package/src/vaadin-crud-edit.d.ts +1 -1
- package/src/vaadin-crud-edit.js +1 -1
- package/src/vaadin-crud-form.d.ts +1 -1
- package/src/vaadin-crud-form.js +4 -23
- package/src/vaadin-crud-grid-mixin.d.ts +7 -1
- package/src/vaadin-crud-grid-mixin.js +9 -3
- package/src/vaadin-crud-grid.d.ts +1 -1
- package/src/vaadin-crud-grid.js +1 -1
- package/src/vaadin-crud-helpers.d.ts +1 -1
- package/src/vaadin-crud-helpers.js +45 -1
- package/src/vaadin-crud-include-mixin.d.ts +1 -1
- package/src/vaadin-crud-include-mixin.js +3 -1
- package/src/vaadin-crud-mixin.d.ts +8 -7
- package/src/vaadin-crud-mixin.js +110 -99
- package/src/vaadin-crud-styles.d.ts +1 -1
- package/src/vaadin-crud-styles.js +1 -1
- package/src/vaadin-crud.d.ts +1 -1
- package/src/vaadin-crud.js +9 -9
- package/src/vaadin-lit-crud-dialog.d.ts +11 -0
- package/src/vaadin-lit-crud-dialog.js +128 -0
- package/src/vaadin-lit-crud-edit-column.d.ts +11 -0
- package/src/vaadin-lit-crud-edit-column.js +70 -0
- package/src/vaadin-lit-crud-edit.d.ts +11 -0
- package/src/vaadin-lit-crud-edit.js +75 -0
- package/src/vaadin-lit-crud-form.d.ts +11 -0
- package/src/vaadin-lit-crud-form.js +80 -0
- package/src/vaadin-lit-crud-grid.d.ts +11 -0
- package/src/vaadin-lit-crud-grid.js +35 -0
- package/src/vaadin-lit-crud.js +122 -0
- package/theme/lumo/vaadin-lit-crud.d.ts +8 -0
- package/theme/lumo/vaadin-lit-crud.js +8 -0
- package/theme/material/vaadin-lit-crud.d.ts +8 -0
- package/theme/material/vaadin-lit-crud.js +8 -0
- package/vaadin-lit-crud-edit .js +1 -0
- package/vaadin-lit-crud-edit-column.js +1 -0
- package/vaadin-lit-crud.js +2 -0
- package/web-types.json +15 -15
- package/web-types.lit.json +11 -11
package/src/vaadin-crud-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2000 -
|
|
3
|
+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
|
|
4
4
|
*
|
|
5
5
|
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
6
|
*
|
|
@@ -10,18 +10,47 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
12
12
|
import { FocusRestorationController } from '@vaadin/a11y-base/src/focus-restoration-controller.js';
|
|
13
|
+
import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
|
|
13
14
|
import { MediaQueryController } from '@vaadin/component-base/src/media-query-controller.js';
|
|
14
15
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
15
16
|
import { ButtonSlotController, FormSlotController, GridSlotController } from './vaadin-crud-controllers.js';
|
|
16
17
|
import { getProperty, isValidEditorPosition, setProperty } from './vaadin-crud-helpers.js';
|
|
17
18
|
|
|
19
|
+
const DEFAULT_I18N = {
|
|
20
|
+
newItem: 'New item',
|
|
21
|
+
editItem: 'Edit item',
|
|
22
|
+
saveItem: 'Save',
|
|
23
|
+
cancel: 'Cancel',
|
|
24
|
+
deleteItem: 'Delete...',
|
|
25
|
+
editLabel: 'Edit',
|
|
26
|
+
confirm: {
|
|
27
|
+
delete: {
|
|
28
|
+
title: 'Delete item',
|
|
29
|
+
content: 'Are you sure you want to delete this item? This action cannot be undone.',
|
|
30
|
+
button: {
|
|
31
|
+
confirm: 'Delete',
|
|
32
|
+
dismiss: 'Cancel',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
cancel: {
|
|
36
|
+
title: 'Discard changes',
|
|
37
|
+
content: 'There are unsaved changes to this item.',
|
|
38
|
+
button: {
|
|
39
|
+
confirm: 'Discard',
|
|
40
|
+
dismiss: 'Cancel',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
18
46
|
/**
|
|
19
47
|
* A mixin providing common crud functionality.
|
|
20
48
|
*
|
|
21
49
|
* @polymerMixin
|
|
50
|
+
* @mixes I18nMixin
|
|
22
51
|
*/
|
|
23
52
|
export const CrudMixin = (superClass) =>
|
|
24
|
-
class extends superClass {
|
|
53
|
+
class extends I18nMixin(DEFAULT_I18N, superClass) {
|
|
25
54
|
static get properties() {
|
|
26
55
|
return {
|
|
27
56
|
/**
|
|
@@ -100,6 +129,7 @@ export const CrudMixin = (superClass) =>
|
|
|
100
129
|
type: Object,
|
|
101
130
|
observer: '__editedItemChanged',
|
|
102
131
|
notify: true,
|
|
132
|
+
sync: true,
|
|
103
133
|
},
|
|
104
134
|
|
|
105
135
|
/**
|
|
@@ -117,6 +147,7 @@ export const CrudMixin = (superClass) =>
|
|
|
117
147
|
value: '',
|
|
118
148
|
reflectToAttribute: true,
|
|
119
149
|
observer: '__editorPositionChanged',
|
|
150
|
+
sync: true,
|
|
120
151
|
},
|
|
121
152
|
|
|
122
153
|
/**
|
|
@@ -128,6 +159,7 @@ export const CrudMixin = (superClass) =>
|
|
|
128
159
|
editOnClick: {
|
|
129
160
|
type: Boolean,
|
|
130
161
|
value: false,
|
|
162
|
+
sync: true,
|
|
131
163
|
},
|
|
132
164
|
|
|
133
165
|
/**
|
|
@@ -194,6 +226,7 @@ export const CrudMixin = (superClass) =>
|
|
|
194
226
|
reflectToAttribute: true,
|
|
195
227
|
notify: true,
|
|
196
228
|
observer: '__editorOpenedChanged',
|
|
229
|
+
sync: true,
|
|
197
230
|
},
|
|
198
231
|
|
|
199
232
|
/**
|
|
@@ -218,84 +251,17 @@ export const CrudMixin = (superClass) =>
|
|
|
218
251
|
type: Boolean,
|
|
219
252
|
value: false,
|
|
220
253
|
reflectToAttribute: true,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* The object used to localize this component.
|
|
225
|
-
* For changing the default localization, change the entire
|
|
226
|
-
* _i18n_ object or just the property you want to modify.
|
|
227
|
-
*
|
|
228
|
-
* The object has the following JSON structure and default values:
|
|
229
|
-
*
|
|
230
|
-
* ```
|
|
231
|
-
* {
|
|
232
|
-
* newItem: 'New item',
|
|
233
|
-
* editItem: 'Edit item',
|
|
234
|
-
* saveItem: 'Save',
|
|
235
|
-
* cancel: 'Cancel',
|
|
236
|
-
* deleteItem: 'Delete...',
|
|
237
|
-
* editLabel: 'Edit',
|
|
238
|
-
* confirm: {
|
|
239
|
-
* delete: {
|
|
240
|
-
* title: 'Confirm delete',
|
|
241
|
-
* content: 'Are you sure you want to delete the selected item? This action cannot be undone.',
|
|
242
|
-
* button: {
|
|
243
|
-
* confirm: 'Delete',
|
|
244
|
-
* dismiss: 'Cancel'
|
|
245
|
-
* }
|
|
246
|
-
* },
|
|
247
|
-
* cancel: {
|
|
248
|
-
* title: 'Unsaved changes',
|
|
249
|
-
* content: 'There are unsaved modifications to the item.',
|
|
250
|
-
* button: {
|
|
251
|
-
* confirm: 'Discard',
|
|
252
|
-
* dismiss: 'Continue editing'
|
|
253
|
-
* }
|
|
254
|
-
* }
|
|
255
|
-
* }
|
|
256
|
-
* }
|
|
257
|
-
* ```
|
|
258
|
-
*
|
|
259
|
-
* @type {!CrudI18n}
|
|
260
|
-
* @default {English/US}
|
|
261
|
-
*/
|
|
262
|
-
i18n: {
|
|
263
|
-
type: Object,
|
|
264
|
-
value() {
|
|
265
|
-
return {
|
|
266
|
-
newItem: 'New item',
|
|
267
|
-
editItem: 'Edit item',
|
|
268
|
-
saveItem: 'Save',
|
|
269
|
-
cancel: 'Cancel',
|
|
270
|
-
deleteItem: 'Delete...',
|
|
271
|
-
editLabel: 'Edit',
|
|
272
|
-
confirm: {
|
|
273
|
-
delete: {
|
|
274
|
-
title: 'Delete item',
|
|
275
|
-
content: 'Are you sure you want to delete this item? This action cannot be undone.',
|
|
276
|
-
button: {
|
|
277
|
-
confirm: 'Delete',
|
|
278
|
-
dismiss: 'Cancel',
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
cancel: {
|
|
282
|
-
title: 'Discard changes',
|
|
283
|
-
content: 'There are unsaved changes to this item.',
|
|
284
|
-
button: {
|
|
285
|
-
confirm: 'Discard',
|
|
286
|
-
dismiss: 'Cancel',
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
};
|
|
291
|
-
},
|
|
254
|
+
sync: true,
|
|
292
255
|
},
|
|
293
256
|
|
|
294
257
|
/** @private */
|
|
295
258
|
__dialogAriaLabel: String,
|
|
296
259
|
|
|
297
260
|
/** @private */
|
|
298
|
-
__isDirty:
|
|
261
|
+
__isDirty: {
|
|
262
|
+
type: Boolean,
|
|
263
|
+
sync: true,
|
|
264
|
+
},
|
|
299
265
|
|
|
300
266
|
/** @private */
|
|
301
267
|
__isNew: Boolean,
|
|
@@ -307,6 +273,7 @@ export const CrudMixin = (superClass) =>
|
|
|
307
273
|
_fullscreen: {
|
|
308
274
|
type: Boolean,
|
|
309
275
|
observer: '__fullscreenChanged',
|
|
276
|
+
sync: true,
|
|
310
277
|
},
|
|
311
278
|
|
|
312
279
|
/**
|
|
@@ -321,18 +288,63 @@ export const CrudMixin = (superClass) =>
|
|
|
321
288
|
|
|
322
289
|
static get observers() {
|
|
323
290
|
return [
|
|
324
|
-
'__headerPropsChanged(_defaultHeader, __isNew,
|
|
291
|
+
'__headerPropsChanged(_defaultHeader, __isNew, __effectiveI18n)',
|
|
325
292
|
'__formPropsChanged(_form, _theme, include, exclude)',
|
|
326
293
|
'__gridPropsChanged(_grid, _theme, include, exclude, noFilter, noHead, noSort, items)',
|
|
327
|
-
'__i18nChanged(
|
|
294
|
+
'__i18nChanged(__effectiveI18n, _grid)',
|
|
328
295
|
'__editOnClickChanged(editOnClick, _grid)',
|
|
329
|
-
'__saveButtonPropsChanged(_saveButton,
|
|
330
|
-
'__cancelButtonPropsChanged(_cancelButton,
|
|
331
|
-
'__deleteButtonPropsChanged(_deleteButton,
|
|
332
|
-
'__newButtonPropsChanged(_newButton,
|
|
296
|
+
'__saveButtonPropsChanged(_saveButton, __effectiveI18n, __isDirty)',
|
|
297
|
+
'__cancelButtonPropsChanged(_cancelButton, __effectiveI18n)',
|
|
298
|
+
'__deleteButtonPropsChanged(_deleteButton, __effectiveI18n, __isNew)',
|
|
299
|
+
'__newButtonPropsChanged(_newButton, __effectiveI18n)',
|
|
333
300
|
];
|
|
334
301
|
}
|
|
335
302
|
|
|
303
|
+
/**
|
|
304
|
+
* The object used to localize this component. To change the default
|
|
305
|
+
* localization, replace this with an object that provides all properties, or
|
|
306
|
+
* just the individual properties you want to change.
|
|
307
|
+
*
|
|
308
|
+
* The object has the following JSON structure and default values:
|
|
309
|
+
*
|
|
310
|
+
* ```
|
|
311
|
+
* {
|
|
312
|
+
* newItem: 'New item',
|
|
313
|
+
* editItem: 'Edit item',
|
|
314
|
+
* saveItem: 'Save',
|
|
315
|
+
* cancel: 'Cancel',
|
|
316
|
+
* deleteItem: 'Delete...',
|
|
317
|
+
* editLabel: 'Edit',
|
|
318
|
+
* confirm: {
|
|
319
|
+
* delete: {
|
|
320
|
+
* title: 'Confirm delete',
|
|
321
|
+
* content: 'Are you sure you want to delete the selected item? This action cannot be undone.',
|
|
322
|
+
* button: {
|
|
323
|
+
* confirm: 'Delete',
|
|
324
|
+
* dismiss: 'Cancel'
|
|
325
|
+
* }
|
|
326
|
+
* },
|
|
327
|
+
* cancel: {
|
|
328
|
+
* title: 'Unsaved changes',
|
|
329
|
+
* content: 'There are unsaved modifications to the item.',
|
|
330
|
+
* button: {
|
|
331
|
+
* confirm: 'Discard',
|
|
332
|
+
* dismiss: 'Continue editing'
|
|
333
|
+
* }
|
|
334
|
+
* }
|
|
335
|
+
* }
|
|
336
|
+
* }
|
|
337
|
+
* ```
|
|
338
|
+
* @return {!CrudI18n}
|
|
339
|
+
*/
|
|
340
|
+
get i18n() {
|
|
341
|
+
return super.i18n;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
set i18n(value) {
|
|
345
|
+
super.i18n = value;
|
|
346
|
+
}
|
|
347
|
+
|
|
336
348
|
constructor() {
|
|
337
349
|
super();
|
|
338
350
|
|
|
@@ -419,29 +431,28 @@ export const CrudMixin = (superClass) =>
|
|
|
419
431
|
/**
|
|
420
432
|
* @param {HTMLElement | undefined} headerNode
|
|
421
433
|
* @param {boolean} isNew
|
|
422
|
-
* @param {
|
|
423
|
-
* @param {string} i18nEditItem
|
|
434
|
+
* @param {CrudI18n} effectiveI18n
|
|
424
435
|
* @private
|
|
425
436
|
*/
|
|
426
|
-
__headerPropsChanged(headerNode, isNew,
|
|
437
|
+
__headerPropsChanged(headerNode, isNew, effectiveI18n) {
|
|
427
438
|
if (headerNode) {
|
|
428
|
-
headerNode.textContent = isNew ?
|
|
439
|
+
headerNode.textContent = isNew ? effectiveI18n.newItem : effectiveI18n.editItem;
|
|
429
440
|
}
|
|
430
441
|
}
|
|
431
442
|
|
|
432
443
|
/**
|
|
433
|
-
* @param {CrudI18n}
|
|
444
|
+
* @param {CrudI18n} effectiveI18n
|
|
434
445
|
* @param {CrudGrid | Grid} grid
|
|
435
446
|
* @private
|
|
436
447
|
*/
|
|
437
|
-
__i18nChanged(
|
|
448
|
+
__i18nChanged(effectiveI18n, grid) {
|
|
438
449
|
if (!grid) {
|
|
439
450
|
return;
|
|
440
451
|
}
|
|
441
452
|
|
|
442
453
|
afterNextRender(grid, () => {
|
|
443
454
|
Array.from(grid.querySelectorAll('vaadin-crud-edit-column')).forEach((column) => {
|
|
444
|
-
column.ariaLabel =
|
|
455
|
+
column.ariaLabel = effectiveI18n.editLabel;
|
|
445
456
|
});
|
|
446
457
|
});
|
|
447
458
|
}
|
|
@@ -674,55 +685,55 @@ export const CrudMixin = (superClass) =>
|
|
|
674
685
|
|
|
675
686
|
/**
|
|
676
687
|
* @param {HTMLElement | undefined} saveButton
|
|
677
|
-
* @param {
|
|
688
|
+
* @param {CrudI18n} effectiveI18n
|
|
678
689
|
* @param {boolean} isDirty
|
|
679
690
|
* @private
|
|
680
691
|
*/
|
|
681
|
-
__saveButtonPropsChanged(saveButton,
|
|
692
|
+
__saveButtonPropsChanged(saveButton, effectiveI18n, isDirty) {
|
|
682
693
|
if (saveButton) {
|
|
683
694
|
saveButton.toggleAttribute('disabled', this.__isSaveBtnDisabled(isDirty));
|
|
684
695
|
|
|
685
696
|
if (saveButton === this._saveButtonController.defaultNode) {
|
|
686
|
-
saveButton.textContent =
|
|
697
|
+
saveButton.textContent = effectiveI18n.saveItem;
|
|
687
698
|
}
|
|
688
699
|
}
|
|
689
700
|
}
|
|
690
701
|
|
|
691
702
|
/**
|
|
692
703
|
* @param {HTMLElement | undefined} deleteButton
|
|
693
|
-
* @param {
|
|
704
|
+
* @param {CrudI18n} effectiveI18n
|
|
694
705
|
* @param {boolean} isNew
|
|
695
706
|
* @private
|
|
696
707
|
*/
|
|
697
|
-
__deleteButtonPropsChanged(deleteButton,
|
|
708
|
+
__deleteButtonPropsChanged(deleteButton, effectiveI18n, isNew) {
|
|
698
709
|
if (deleteButton) {
|
|
699
710
|
deleteButton.toggleAttribute('hidden', isNew);
|
|
700
711
|
|
|
701
712
|
if (deleteButton === this._deleteButtonController.defaultNode) {
|
|
702
|
-
deleteButton.textContent =
|
|
713
|
+
deleteButton.textContent = effectiveI18n.deleteItem;
|
|
703
714
|
}
|
|
704
715
|
}
|
|
705
716
|
}
|
|
706
717
|
|
|
707
718
|
/**
|
|
708
719
|
* @param {HTMLElement | undefined} cancelButton
|
|
709
|
-
* @param {
|
|
720
|
+
* @param {CrudI18n} effectiveI18n
|
|
710
721
|
* @private
|
|
711
722
|
*/
|
|
712
|
-
__cancelButtonPropsChanged(cancelButton,
|
|
723
|
+
__cancelButtonPropsChanged(cancelButton, effectiveI18n) {
|
|
713
724
|
if (cancelButton && cancelButton === this._cancelButtonController.defaultNode) {
|
|
714
|
-
cancelButton.textContent =
|
|
725
|
+
cancelButton.textContent = effectiveI18n.cancel;
|
|
715
726
|
}
|
|
716
727
|
}
|
|
717
728
|
|
|
718
729
|
/**
|
|
719
730
|
* @param {HTMLElement | undefined} newButton
|
|
720
|
-
* @param {
|
|
731
|
+
* @param {CrudI18n} effectiveI18n
|
|
721
732
|
* @private
|
|
722
733
|
*/
|
|
723
|
-
__newButtonPropsChanged(newButton,
|
|
734
|
+
__newButtonPropsChanged(newButton, effectiveI18n) {
|
|
724
735
|
if (newButton && newButton === this._newButtonController.defaultNode) {
|
|
725
|
-
newButton.textContent =
|
|
736
|
+
newButton.textContent = effectiveI18n.newItem;
|
|
726
737
|
}
|
|
727
738
|
}
|
|
728
739
|
|
package/src/vaadin-crud.d.ts
CHANGED
package/src/vaadin-crud.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2000 -
|
|
3
|
+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
|
|
4
4
|
*
|
|
5
5
|
* This program is available under Vaadin Commercial License and Service Terms.
|
|
6
6
|
*
|
|
@@ -223,10 +223,10 @@ class Crud extends CrudMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
223
223
|
id="confirmCancel"
|
|
224
224
|
on-confirm="__confirmCancel"
|
|
225
225
|
cancel-button-visible
|
|
226
|
-
confirm-text="[[
|
|
227
|
-
cancel-text="[[
|
|
228
|
-
header="[[
|
|
229
|
-
message="[[
|
|
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
230
|
confirm-theme="primary"
|
|
231
231
|
></vaadin-confirm-dialog>
|
|
232
232
|
|
|
@@ -235,10 +235,10 @@ class Crud extends CrudMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
235
235
|
id="confirmDelete"
|
|
236
236
|
on-confirm="__confirmDelete"
|
|
237
237
|
cancel-button-visible
|
|
238
|
-
confirm-text="[[
|
|
239
|
-
cancel-text="[[
|
|
240
|
-
header="[[
|
|
241
|
-
message="[[
|
|
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
242
|
confirm-theme="primary error"
|
|
243
243
|
></vaadin-confirm-dialog>
|
|
244
244
|
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export * from './vaadin-crud-dialog.js';
|
|
@@ -0,0 +1,128 @@
|
|
|
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);
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export * from './vaadin-crud-edit-column.js';
|
|
@@ -0,0 +1,70 @@
|
|
|
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 };
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export * from './vaadin-crud-edit.js';
|