@proximus/lavender-layout 1.1.2 → 2.0.0-alpha.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/dist/Spacer.d.ts CHANGED
@@ -1,8 +1,17 @@
1
1
  export declare class Spacer extends HTMLElement {
2
+ private resizeObserver?;
3
+ private recheckHandle?;
4
+ private isZeroSized;
5
+ private growValue;
2
6
  constructor();
3
7
  static get observedAttributes(): string[];
4
8
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
5
9
  connectedCallback(): void;
10
+ disconnectedCallback(): void;
6
11
  get grow(): string;
7
12
  set grow(value: string);
13
+ private scheduleRecheck;
14
+ private recalculateVisibility;
15
+ private handleSizeChange;
16
+ private updateParticipation;
8
17
  }
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { WithExtraAttributes as c, AttributeBreakpointHandlerDelegate as b, gapValues as u, checkName as h, backgroundColorValues as f } from "@proximus/lavender-common";
1
+ import { WithExtraAttributes as p, AttributeBreakpointHandlerDelegate as h, gapValues as u, checkName as b, backgroundColorValues as f } from "@proximus/lavender-common";
2
2
  const x = ':host{display:block}:host([overflow-x="auto"]){margin:calc(calc(var(--px-focus-outline-mobile) + var(--px-focus-offset-mobile)) * -1)}:host([overflow-x="auto"]) .flex-container{padding:calc(var(--px-focus-outline-mobile) + var(--px-focus-offset-mobile))}.flex-container{display:flex;height:100%;width:100%;box-sizing:border-box;flex-direction:var(--flex-direction--mobile-value);gap:var(--flex-gap--mobile-value);flex-wrap:var(--flex-wrap--mobile-value);justify-content:var(--flex-justify-content--mobile-value);align-items:var(--flex-align-items--mobile-value);overflow-x:var(--overflow-x-all)}@media only screen and (max-width: 47.9375em){.flex-container{overflow-x:var(--overflow-x-all-mobile, var(--overflow-x-all));scrollbar-width:none}.flex-container::-webkit-scrollbar{display:none}}@media only screen and (min-width: 48em){.flex-container{flex-direction:var(--flex-direction--tablet-value);gap:var(--flex-gap--tablet-value);flex-wrap:var(--flex-wrap--tablet-value);justify-content:var(--flex-justify-content--tablet-value);align-items:var(--flex-align-items--tablet-value)}:host([overflow-x="auto"]){margin:calc(calc(var(--px-focus-outline-tablet) + var(--px-focus-offset-tablet)) * -1)}:host([overflow-x="auto"]) .flex-container{padding:calc(var(--px-focus-outline-tablet) + var(--px-focus-offset-tablet))}}@media only screen and (min-width: 48em) and (max-width: 64em){.flex-container{overflow-x:var(--overflow-x-all-tablet, var(--overflow-x-all));scrollbar-width:none}.flex-container::-webkit-scrollbar{display:none}}@media only screen and (min-width: 64.0625em){.flex-container{flex-direction:var(--flex-direction--laptop-value);gap:var(--flex-gap--laptop-value);flex-wrap:var(--flex-wrap--laptop-value);justify-content:var(--flex-justify-content--laptop-value);align-items:var(--flex-align-items--laptop-value)}:host([overflow-x="auto"]){margin:calc(calc(var(--px-focus-outline-laptop) + var(--px-focus-offset-laptop)) * -1)}:host([overflow-x="auto"]) .flex-container{padding:calc(var(--px-focus-outline-laptop) + var(--px-focus-offset-laptop))}}@media only screen and (min-width: 64.0625em) and (max-width: 90em){.flex-container{overflow-x:var(--overflow-x-all-laptop, var(--overflow-x-all))}}@media only screen and (min-width: 90.0625em){.flex-container{flex-direction:var(--flex-direction--desktop-value);gap:var(--flex-gap--desktop-value);flex-wrap:var(--flex-wrap--desktop-value);justify-content:var(--flex-justify-content--desktop-value);align-items:var(--flex-align-items--desktop-value);overflow-x:var(--overflow-x-all-desktop, var(--overflow-x-all))}:host([overflow-x="auto"]){margin:calc(calc(var(--px-focus-outline-desktop) + var(--px-focus-offset-desktop)) * -1)}:host([overflow-x="auto"]) .flex-container{padding:calc(var(--px-focus-outline-desktop) + var(--px-focus-offset-desktop))}}', d = new CSSStyleSheet();
3
3
  d.replaceSync(x);
4
4
  const m = [
@@ -26,9 +26,9 @@ const m = [
26
26
  "space-around",
27
27
  "space-evenly"
28
28
  ], w = ["", "default", "nowrap", "wrap", "wrap-reverse"], y = ["", "visible", "hidden", "scroll", "auto"];
29
- class l extends c {
29
+ class l extends p {
30
30
  constructor() {
31
- super(d), this.overflowXAttributeDelegate = new b(
31
+ super(d), this.overflowXAttributeDelegate = new h(
32
32
  this,
33
33
  "overflow-x",
34
34
  (t) => t,
@@ -130,7 +130,7 @@ class l extends c {
130
130
  }
131
131
  }
132
132
  updateOverflowX(t, i, e, o) {
133
- if (!h(o, e)) {
133
+ if (!b(o, e)) {
134
134
  console.error(`${e} is not an allowed ${t} value`);
135
135
  return;
136
136
  }
@@ -142,14 +142,14 @@ class l extends c {
142
142
  }
143
143
  updateFlexProperties(t, i, e, o) {
144
144
  this.checkName(o, e) || console.error(`${e} is not a valid value for ${o}`);
145
- const p = t.indexOf("--") > -1, a = p ? t.split("--")[0] : t, r = [];
146
- if (!p)
147
- this.getAttribute(a + "--mobile") || r.push("mobile"), this.getAttribute(a + "--tablet") || r.push("tablet"), this.getAttribute(a + "--laptop") || r.push("laptop"), this.getAttribute(a + "--desktop") || r.push("desktop"), r.forEach((s) => {
148
- this.updateStyle(a, s, i, o), this.updateStyle(a, s, e, o);
145
+ const c = t.indexOf("--") > -1, a = c ? t.split("--")[0] : t, s = [];
146
+ if (!c)
147
+ this.getAttribute(a + "--mobile") || s.push("mobile"), this.getAttribute(a + "--tablet") || s.push("tablet"), this.getAttribute(a + "--laptop") || s.push("laptop"), this.getAttribute(a + "--desktop") || s.push("desktop"), s.forEach((r) => {
148
+ this.updateStyle(a, r, i, o), this.updateStyle(a, r, e, o);
149
149
  });
150
150
  else {
151
- const s = t.split("--")[1];
152
- this.updateStyle(a, s, i, o), this.updateStyle(a, s, e, o);
151
+ const r = t.split("--")[1];
152
+ this.updateStyle(a, r, i, o), this.updateStyle(a, r, e, o);
153
153
  }
154
154
  }
155
155
  updateStyle(t, i, e, o) {
@@ -366,16 +366,26 @@ class C extends l {
366
366
  customElements.get("px-hstack") || customElements.define("px-hstack", C);
367
367
  class $ extends HTMLElement {
368
368
  constructor() {
369
- super();
369
+ super(), this.isZeroSized = !1, this.growValue = "1";
370
370
  }
371
371
  static get observedAttributes() {
372
372
  return ["grow"];
373
373
  }
374
374
  attributeChangedCallback(t, i, e) {
375
- t === "grow" && (this.style.flexGrow = e);
375
+ t === "grow" && (this.growValue = e || "1", this.isZeroSized || (this.style.flexGrow = this.growValue), this.scheduleRecheck());
376
376
  }
377
377
  connectedCallback() {
378
- this.style.flexGrow = this.getAttribute("grow") || "1";
378
+ this.growValue = this.getAttribute("grow") || "1", this.style.flexGrow = this.growValue, this.resizeObserver = new ResizeObserver((t) => {
379
+ t.forEach((i) => {
380
+ this.handleSizeChange(
381
+ i.contentRect.width === 0 || i.contentRect.height === 0
382
+ );
383
+ });
384
+ }), this.resizeObserver.observe(this), this.scheduleRecheck();
385
+ }
386
+ disconnectedCallback() {
387
+ var t;
388
+ (t = this.resizeObserver) == null || t.disconnect(), this.recheckHandle && (cancelAnimationFrame(this.recheckHandle), this.recheckHandle = void 0);
379
389
  }
380
390
  get grow() {
381
391
  return this.getAttribute("grow");
@@ -383,11 +393,29 @@ class $ extends HTMLElement {
383
393
  set grow(t) {
384
394
  this.setAttribute("grow", t);
385
395
  }
396
+ scheduleRecheck() {
397
+ this.recheckHandle && cancelAnimationFrame(this.recheckHandle), this.recheckHandle = requestAnimationFrame(() => {
398
+ this.recheckHandle = void 0, this.recalculateVisibility();
399
+ });
400
+ }
401
+ recalculateVisibility() {
402
+ if (!this.isConnected)
403
+ return;
404
+ this.style.display = "", this.style.flexGrow = this.growValue;
405
+ const t = this.getBoundingClientRect(), i = t.width === 0 || t.height === 0;
406
+ this.handleSizeChange(i);
407
+ }
408
+ handleSizeChange(t) {
409
+ this.isZeroSized !== t && (this.isZeroSized = t, this.updateParticipation());
410
+ }
411
+ updateParticipation() {
412
+ this.isZeroSized ? (this.style.display = "none", this.style.flexGrow = "0") : (this.style.display = "", this.style.flexGrow = this.growValue);
413
+ }
386
414
  }
387
415
  customElements.get("px-spacer") || customElements.define("px-spacer", $);
388
- const j = ":host{display:block;box-sizing:border-box}slot[name=body-container]{min-height:100vh}#image-sticky-box{margin-top:-2.5em}", g = new CSSStyleSheet();
389
- g.replaceSync(j);
390
- class S extends c {
416
+ const S = ":host{display:block;box-sizing:border-box}slot[name=body-container]{min-height:100vh}#image-sticky-box{margin-top:-2.5em}", g = new CSSStyleSheet();
417
+ g.replaceSync(S);
418
+ class j extends p {
391
419
  constructor() {
392
420
  super(g), this.template = (t) => `
393
421
  <px-container border-radius="none" padding="none">
@@ -586,10 +614,10 @@ class S extends c {
586
614
  this.$headerContainer.paddingLeft = t, this.$headerContainer.paddingRight = t, this.$bodyContainer.paddingLeft = t, this.$bodyContainer.paddingRight = t, this.$contactContainer.paddingLeft = t, this.$contactContainer.paddingRight = t, this.$footerContainer.paddingLeft = t, this.$footerContainer.paddingRight = t, this.$imageContainer.paddingLeft = t, this.$imageContainer.paddingRight = t;
587
615
  }
588
616
  }
589
- customElements.get("px-page") === void 0 && customElements.define("px-page", S);
617
+ customElements.get("px-page") === void 0 && customElements.define("px-page", j);
590
618
  export {
591
619
  C as HStack,
592
- S as Page,
620
+ j as Page,
593
621
  $ as Spacer,
594
622
  l as Stack,
595
623
  A as VStack,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-layout",
3
- "version": "1.1.2",
3
+ "version": "2.0.0-alpha.2",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",