@proximus/lavender-light 1.2.0-alpha.35 → 1.2.0-alpha.39
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.
|
@@ -2285,17 +2285,41 @@ if (!customElements.get("px-hstack")) {
|
|
|
2285
2285
|
class Spacer extends HTMLElement {
|
|
2286
2286
|
constructor() {
|
|
2287
2287
|
super();
|
|
2288
|
+
this.isZeroSized = false;
|
|
2289
|
+
this.growValue = `${1}`;
|
|
2288
2290
|
}
|
|
2289
2291
|
static get observedAttributes() {
|
|
2290
2292
|
return ["grow"];
|
|
2291
2293
|
}
|
|
2292
2294
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2293
2295
|
if (name === "grow") {
|
|
2294
|
-
this.
|
|
2296
|
+
this.growValue = newValue || `${1}`;
|
|
2297
|
+
if (!this.isZeroSized) {
|
|
2298
|
+
this.style.flexGrow = this.growValue;
|
|
2299
|
+
}
|
|
2300
|
+
this.scheduleRecheck();
|
|
2295
2301
|
}
|
|
2296
2302
|
}
|
|
2297
2303
|
connectedCallback() {
|
|
2298
|
-
this.
|
|
2304
|
+
this.growValue = this.getAttribute("grow") || `${1}`;
|
|
2305
|
+
this.style.flexGrow = this.growValue;
|
|
2306
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
2307
|
+
entries.forEach((entry) => {
|
|
2308
|
+
this.handleSizeChange(
|
|
2309
|
+
entry.contentRect.width === 0 || entry.contentRect.height === 0
|
|
2310
|
+
);
|
|
2311
|
+
});
|
|
2312
|
+
});
|
|
2313
|
+
this.resizeObserver.observe(this);
|
|
2314
|
+
this.scheduleRecheck();
|
|
2315
|
+
}
|
|
2316
|
+
disconnectedCallback() {
|
|
2317
|
+
var _a;
|
|
2318
|
+
(_a = this.resizeObserver) == null ? void 0 : _a.disconnect();
|
|
2319
|
+
if (this.recheckHandle) {
|
|
2320
|
+
cancelAnimationFrame(this.recheckHandle);
|
|
2321
|
+
this.recheckHandle = void 0;
|
|
2322
|
+
}
|
|
2299
2323
|
}
|
|
2300
2324
|
get grow() {
|
|
2301
2325
|
return this.getAttribute("grow");
|
|
@@ -2303,6 +2327,41 @@ class Spacer extends HTMLElement {
|
|
|
2303
2327
|
set grow(value) {
|
|
2304
2328
|
this.setAttribute("grow", value);
|
|
2305
2329
|
}
|
|
2330
|
+
scheduleRecheck() {
|
|
2331
|
+
if (this.recheckHandle) {
|
|
2332
|
+
cancelAnimationFrame(this.recheckHandle);
|
|
2333
|
+
}
|
|
2334
|
+
this.recheckHandle = requestAnimationFrame(() => {
|
|
2335
|
+
this.recheckHandle = void 0;
|
|
2336
|
+
this.recalculateVisibility();
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
recalculateVisibility() {
|
|
2340
|
+
if (!this.isConnected) {
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
this.style.display = "";
|
|
2344
|
+
this.style.flexGrow = this.growValue;
|
|
2345
|
+
const rect = this.getBoundingClientRect();
|
|
2346
|
+
const hasZeroSize = rect.width === 0 || rect.height === 0;
|
|
2347
|
+
this.handleSizeChange(hasZeroSize);
|
|
2348
|
+
}
|
|
2349
|
+
handleSizeChange(hasZeroSize) {
|
|
2350
|
+
if (this.isZeroSized === hasZeroSize) {
|
|
2351
|
+
return;
|
|
2352
|
+
}
|
|
2353
|
+
this.isZeroSized = hasZeroSize;
|
|
2354
|
+
this.updateParticipation();
|
|
2355
|
+
}
|
|
2356
|
+
updateParticipation() {
|
|
2357
|
+
if (this.isZeroSized) {
|
|
2358
|
+
this.style.display = "none";
|
|
2359
|
+
this.style.flexGrow = `${0}`;
|
|
2360
|
+
} else {
|
|
2361
|
+
this.style.display = "";
|
|
2362
|
+
this.style.flexGrow = this.growValue;
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2306
2365
|
}
|
|
2307
2366
|
if (!customElements.get("px-spacer")) {
|
|
2308
2367
|
customElements.define("px-spacer", Spacer);
|