@vaadin/vaadin-crud 1.3.0 → 1.3.2
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 +9 -13
- package/package.json +8 -4
- package/src/vaadin-crud.js +6 -6
- package/src/vaadin-dialog-layout.js +38 -16
package/README.md
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
[](https://github.com/vaadin/vaadin-crud/releases)
|
|
3
|
-
[](https://www.webcomponents.org/element/vaadin/vaadin-crud)
|
|
4
|
-
[](https://travis-ci.org/vaadin/vaadin-crud)
|
|
5
|
-
[](https://coveralls.io/github/vaadin/vaadin-crud?branch=master)
|
|
6
|
-
[](https://gitter.im/vaadin/web-components?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
|
1
|
+
# <vaadin-crud>
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
> ⚠️ Starting from Vaadin 20, the source code and issues for this component are migrated to the [`vaadin/web-components`](https://github.com/vaadin/web-components/tree/master/packages/vaadin-crud) monorepository.
|
|
4
|
+
> This repository contains the source code and releases of `<vaadin-crud>` for the Vaadin versions 10 to 19.
|
|
10
5
|
|
|
11
|
-
|
|
6
|
+
[<vaadin-crud>](https://vaadin.com/components/vaadin-crud) is a Web Component for
|
|
7
|
+
[CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations.
|
|
8
|
+
It is part of the [Vaadin components](https://vaadin.com/components).
|
|
12
9
|
|
|
13
10
|
[Live Demo ↗](https://vaadin.com/components/vaadin-crud/html-examples)
|
|
14
11
|
|
|
|
15
12
|
[API documentation ↗](https://vaadin.com/components/vaadin-crud/html-api)
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
It is part of the [Vaadin components](https://vaadin.com/components).
|
|
14
|
+
[](https://www.npmjs.com/package/@vaadin/vaadin-crud)
|
|
15
|
+
[](https://vaadin.com/directory/component/vaadinvaadin-crud)
|
|
16
|
+
[](https://discord.gg/PHmkCKC)
|
|
21
17
|
|
|
22
18
|
```html
|
|
23
19
|
<vaadin-crud items='[{"name": "Juan", "surname": "Garcia"}]'>
|
package/package.json
CHANGED
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
"repository": "vaadin/vaadin-crud",
|
|
11
11
|
"homepage": "https://vaadin.com/components",
|
|
12
12
|
"name": "@vaadin/vaadin-crud",
|
|
13
|
-
"version": "1.3.
|
|
13
|
+
"version": "1.3.2",
|
|
14
14
|
"main": "vaadin-crud.js",
|
|
15
15
|
"author": "Vaadin Ltd",
|
|
16
16
|
"license": "https://raw.githubusercontent.com/vaadin/vaadin-crud/master/LICENSE",
|
|
17
|
+
"cvdlName": "vaadin-crud",
|
|
17
18
|
"bugs": {
|
|
18
19
|
"url": "https://github.com/vaadin/vaadin-crud/issues"
|
|
19
20
|
},
|
|
@@ -45,15 +46,18 @@
|
|
|
45
46
|
"@vaadin/vaadin-confirm-dialog": "^1.3.0",
|
|
46
47
|
"@vaadin/vaadin-license-checker": "^2.1.0"
|
|
47
48
|
},
|
|
48
|
-
"scripts": {
|
|
49
|
-
"generate-typings": "gen-typescript-declarations --outDir . --verify"
|
|
50
|
-
},
|
|
51
49
|
"devDependencies": {
|
|
50
|
+
"@web-padawan/gen-typescript-declarations": "^1.6.2",
|
|
51
|
+
"web-component-tester": "6.9.2",
|
|
52
52
|
"@polymer/iron-component-page": "^4.0.0",
|
|
53
53
|
"@webcomponents/webcomponentsjs": "^2.0.0",
|
|
54
54
|
"wct-browser-legacy": "^1.0.1",
|
|
55
55
|
"@vaadin/vaadin-demo-helpers": "^3.1.0",
|
|
56
56
|
"@vaadin/vaadin-combo-box": "^5.3.0",
|
|
57
57
|
"@vaadin/vaadin-notification": "^1.6.0"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"generate-typings": "gen-typescript-declarations --outDir . --verify",
|
|
61
|
+
"test": "wct --npm"
|
|
58
62
|
}
|
|
59
63
|
}
|
package/src/vaadin-crud.js
CHANGED
|
@@ -174,7 +174,7 @@ class CrudElement extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
174
174
|
</slot>
|
|
175
175
|
</div>
|
|
176
176
|
</div>
|
|
177
|
-
<vaadin-dialog-layout theme\$="[[theme]]" id="dialog" no-close-on-outside-click="[[__isDirty]]" no-close-on-esc="[[__isDirty]]" opened="{{editorOpened}}" editor-position\$="{{editorPosition}}" mobile="[[__mobile]]" theme="crud">
|
|
177
|
+
<vaadin-dialog-layout theme\$="[[theme]]" form="[[_form]]" id="dialog" no-close-on-outside-click="[[__isDirty]]" no-close-on-esc="[[__isDirty]]" opened="{{editorOpened}}" editor-position\$="{{editorPosition}}" mobile="[[__mobile]]" theme="crud">
|
|
178
178
|
<h3 slot="header">[[__computeEditorHeader(__isNew, i18n.newItem, i18n.editItem)]]</h3>
|
|
179
179
|
<div id="editor">
|
|
180
180
|
<slot name="form">
|
|
@@ -203,7 +203,11 @@ class CrudElement extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
static get version() {
|
|
206
|
-
return '1.3.
|
|
206
|
+
return '1.3.2';
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static get cvdlName() {
|
|
210
|
+
return 'vaadin-crud';
|
|
207
211
|
}
|
|
208
212
|
|
|
209
213
|
static get properties() {
|
|
@@ -593,10 +597,6 @@ class CrudElement extends ElementMixin(ThemableMixin(PolymerElement)) {
|
|
|
593
597
|
if (this.editedItem) {
|
|
594
598
|
this.__onItemChange(this.editedItem);
|
|
595
599
|
}
|
|
596
|
-
if (this.$.form != form) {
|
|
597
|
-
// move slotted from this to the slot parent
|
|
598
|
-
this.$.editor.appendChild(form);
|
|
599
|
-
}
|
|
600
600
|
form.addEventListener('change', this.__changeListener);
|
|
601
601
|
form.addEventListener('input', this.__changeListener);
|
|
602
602
|
}
|
|
@@ -160,6 +160,8 @@ const DialogLayout = (() =>
|
|
|
160
160
|
noCloseOnOutsideClick: Boolean,
|
|
161
161
|
/** Disable closing when user presses escape */
|
|
162
162
|
noCloseOnEsc: Boolean,
|
|
163
|
+
/** Reference to the edit form */
|
|
164
|
+
form: Object,
|
|
163
165
|
mobile: {
|
|
164
166
|
type: Boolean,
|
|
165
167
|
observer: '__mobileChanged',
|
|
@@ -173,6 +175,8 @@ const DialogLayout = (() =>
|
|
|
173
175
|
super.ready();
|
|
174
176
|
this._dialogOpenedChangedListener = this._dialogOpenedChangedListener.bind(this);
|
|
175
177
|
this.$.dialog.addEventListener('opened-changed', this._dialogOpenedChangedListener);
|
|
178
|
+
this.__header = this.querySelector('[slot="header"]');
|
|
179
|
+
this.__footer = Array.from(this.querySelectorAll('[slot="footer"]'));
|
|
176
180
|
}
|
|
177
181
|
|
|
178
182
|
_dialogOpenedChangedListener() {
|
|
@@ -192,29 +196,47 @@ const DialogLayout = (() =>
|
|
|
192
196
|
this._ensureChildren();
|
|
193
197
|
}
|
|
194
198
|
|
|
199
|
+
__moveChildNodes(target) {
|
|
200
|
+
// Teleport header node
|
|
201
|
+
target.appendChild(this.__header);
|
|
202
|
+
|
|
203
|
+
// For custom form, remove slot attribute
|
|
204
|
+
// so that it is properly moved to dialog.
|
|
205
|
+
if (this.form.hasAttribute('slot')) {
|
|
206
|
+
this.form.removeAttribute('slot');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Teleport edit form
|
|
210
|
+
target.appendChild(this.form);
|
|
211
|
+
|
|
212
|
+
// Teleport footer nodes
|
|
213
|
+
this.__footer.forEach(node => target.appendChild(node));
|
|
214
|
+
|
|
215
|
+
window.ShadyDOM && window.ShadyDOM.flush();
|
|
216
|
+
|
|
217
|
+
// Wait to set label until slotted element has been moved.
|
|
218
|
+
setTimeout(() => {
|
|
219
|
+
this.__ariaLabel = this.__header.textContent.trim();
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
195
223
|
_ensureChildren() {
|
|
196
|
-
if (!this
|
|
224
|
+
if (!this.form) {
|
|
197
225
|
return;
|
|
198
226
|
}
|
|
199
227
|
|
|
200
|
-
|
|
201
|
-
// Move children from editor to dialog
|
|
202
|
-
Array.from(this.$.editor.childNodes).forEach(c => this.$.dialog.$.overlay.$.content.shadowRoot.appendChild(c));
|
|
203
|
-
Array.from(this.childNodes).forEach(c => this.$.dialog.$.overlay.$.content.appendChild(c));
|
|
228
|
+
const content = this.$.dialog.$.overlay.$.content;
|
|
204
229
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
230
|
+
if ((this.editorPosition === '' || this.mobile) && content.shadowRoot) {
|
|
231
|
+
// Move children from editor to dialog
|
|
232
|
+
Array.from(this.$.editor.childNodes).forEach(node => content.shadowRoot.appendChild(node));
|
|
233
|
+
this.__moveChildNodes(content);
|
|
209
234
|
} else {
|
|
210
235
|
// Move children from dialog to editor
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
setTimeout(() =>
|
|
216
|
-
this.__ariaLabel = Array.from(this.querySelectorAll('[slot=header]'))
|
|
217
|
-
.reduce((prev, ele) => prev + ' ' + ele.textContent, '').trim());
|
|
236
|
+
if (content.shadowRoot) {
|
|
237
|
+
Array.from(content.shadowRoot.childNodes).forEach(node => this.$.editor.appendChild(node));
|
|
238
|
+
}
|
|
239
|
+
this.__moveChildNodes(this);
|
|
218
240
|
}
|
|
219
241
|
}
|
|
220
242
|
|