@vaadin/component-base 24.6.0 → 24.7.0-alpha2
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 +3 -3
- package/src/define.js +1 -1
- package/src/polylit-mixin.js +47 -13
- package/src/resize-mixin.js +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.7.0-alpha2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"lit": "^3.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@vaadin/chai-plugins": "
|
|
41
|
+
"@vaadin/chai-plugins": "24.7.0-alpha2",
|
|
42
42
|
"@vaadin/testing-helpers": "^1.0.0",
|
|
43
43
|
"sinon": "^18.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "e2523f9b4abc5a9586fb758166f823dc40c399dd"
|
|
46
46
|
}
|
package/src/define.js
CHANGED
|
@@ -13,7 +13,7 @@ function dashToCamelCase(dash) {
|
|
|
13
13
|
|
|
14
14
|
const experimentalMap = {};
|
|
15
15
|
|
|
16
|
-
export function defineCustomElement(CustomElement, version = '24.
|
|
16
|
+
export function defineCustomElement(CustomElement, version = '24.7.0-alpha2') {
|
|
17
17
|
Object.defineProperty(CustomElement, 'version', {
|
|
18
18
|
get() {
|
|
19
19
|
return version;
|
package/src/polylit-mixin.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { dedupeMixin } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import { notEqual } from 'lit';
|
|
7
8
|
import { get, set } from './path-utils.js';
|
|
8
9
|
|
|
9
10
|
const caseMap = {};
|
|
@@ -101,12 +102,15 @@ const PolylitMixinImplementation = (superclass) => {
|
|
|
101
102
|
get: defaultDescriptor.get,
|
|
102
103
|
set(value) {
|
|
103
104
|
const oldValue = this[name];
|
|
104
|
-
this[key] = value;
|
|
105
|
-
this.requestUpdate(name, oldValue, options);
|
|
106
105
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.
|
|
106
|
+
if (notEqual(value, oldValue)) {
|
|
107
|
+
this[key] = value;
|
|
108
|
+
this.requestUpdate(name, oldValue, options);
|
|
109
|
+
|
|
110
|
+
// Enforce synchronous update
|
|
111
|
+
if (this.hasUpdated) {
|
|
112
|
+
this.performUpdate();
|
|
113
|
+
}
|
|
110
114
|
}
|
|
111
115
|
},
|
|
112
116
|
configurable: true,
|
|
@@ -115,21 +119,17 @@ const PolylitMixinImplementation = (superclass) => {
|
|
|
115
119
|
}
|
|
116
120
|
|
|
117
121
|
if (options.readOnly) {
|
|
118
|
-
const setter =
|
|
122
|
+
const setter = result.set;
|
|
119
123
|
|
|
120
124
|
this.addCheckedInitializer((instance) => {
|
|
121
125
|
// This is run during construction of the element
|
|
122
126
|
instance[`_set${upper(name)}`] = function (value) {
|
|
123
127
|
setter.call(instance, value);
|
|
124
|
-
|
|
125
|
-
if (options.sync) {
|
|
126
|
-
this.performUpdate();
|
|
127
|
-
}
|
|
128
128
|
};
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
result = {
|
|
132
|
-
get:
|
|
132
|
+
get: result.get,
|
|
133
133
|
set() {
|
|
134
134
|
// Do nothing, property is read-only.
|
|
135
135
|
},
|
|
@@ -195,6 +195,38 @@ const PolylitMixinImplementation = (superclass) => {
|
|
|
195
195
|
return result;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
static get polylitConfig() {
|
|
199
|
+
return {
|
|
200
|
+
asyncFirstRender: false,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
constructor() {
|
|
205
|
+
super();
|
|
206
|
+
this.__hasPolylitMixin = true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** @protected */
|
|
210
|
+
connectedCallback() {
|
|
211
|
+
super.connectedCallback();
|
|
212
|
+
|
|
213
|
+
// Components like `vaadin-overlay` are teleported to the body element when opened.
|
|
214
|
+
// If their opened state is set as an attribute, the teleportation happens immediately
|
|
215
|
+
// after they are connected to the DOM. This means they will be outside the scope of
|
|
216
|
+
// querySelectorAll in the parent component's `firstUpdated()`. To ensure their reference
|
|
217
|
+
// is still registered in the $ map, we propagate the reference here.
|
|
218
|
+
const parentHost = this.getRootNode().host;
|
|
219
|
+
if (parentHost && parentHost.__hasPolylitMixin && this.id) {
|
|
220
|
+
parentHost.$ ||= {};
|
|
221
|
+
parentHost.$[this.id] = this;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const { polylitConfig } = this.constructor;
|
|
225
|
+
if (!this.hasUpdated && !polylitConfig.asyncFirstRender) {
|
|
226
|
+
this.performUpdate();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
198
230
|
/** @protected */
|
|
199
231
|
firstUpdated() {
|
|
200
232
|
super.firstUpdated();
|
|
@@ -203,8 +235,10 @@ const PolylitMixinImplementation = (superclass) => {
|
|
|
203
235
|
this.$ = {};
|
|
204
236
|
}
|
|
205
237
|
|
|
206
|
-
this.renderRoot
|
|
207
|
-
|
|
238
|
+
[...Object.values(this.$), this.renderRoot].forEach((node) => {
|
|
239
|
+
node.querySelectorAll('[id]').forEach((node) => {
|
|
240
|
+
this.$[node.id] = node;
|
|
241
|
+
});
|
|
208
242
|
});
|
|
209
243
|
}
|
|
210
244
|
|
package/src/resize-mixin.js
CHANGED
|
@@ -8,6 +8,10 @@ import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
|
|
|
8
8
|
const observer = new ResizeObserver((entries) => {
|
|
9
9
|
setTimeout(() => {
|
|
10
10
|
entries.forEach((entry) => {
|
|
11
|
+
if (!entry.target.isConnected) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
// Notify child resizables, if any
|
|
12
16
|
if (entry.target.resizables) {
|
|
13
17
|
entry.target.resizables.forEach((resizable) => {
|