@proximus/lavender-layout 1.3.0-beta.1 → 1.3.0

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,18 @@
1
1
  export declare class Spacer extends HTMLElement {
2
+ private resizeObserver?;
3
+ private recheckHandle?;
4
+ private isZeroSized;
5
+ private growValue;
6
+ private isVertical;
2
7
  constructor();
3
8
  static get observedAttributes(): string[];
4
9
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
5
10
  connectedCallback(): void;
11
+ disconnectedCallback(): void;
6
12
  get grow(): string;
7
13
  set grow(value: string);
14
+ private scheduleRecheck;
15
+ private recalculateVisibility;
16
+ private handleSizeChange;
17
+ private updateParticipation;
8
18
  }
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,22 @@ 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", this.isVertical = !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(() => {
379
+ this.handleSizeChange();
380
+ }), this.isVertical = this.parentElement.localName === "px-vstack" || this.parentElement.style.flexDirection === "column", this.resizeObserver.observe(this), this.scheduleRecheck();
381
+ }
382
+ disconnectedCallback() {
383
+ var t;
384
+ (t = this.resizeObserver) == null || t.disconnect(), this.recheckHandle && (cancelAnimationFrame(this.recheckHandle), this.recheckHandle = void 0);
379
385
  }
380
386
  get grow() {
381
387
  return this.getAttribute("grow");
@@ -383,11 +389,26 @@ class $ extends HTMLElement {
383
389
  set grow(t) {
384
390
  this.setAttribute("grow", t);
385
391
  }
392
+ scheduleRecheck() {
393
+ this.recheckHandle && cancelAnimationFrame(this.recheckHandle), this.recheckHandle = requestAnimationFrame(() => {
394
+ this.recheckHandle = void 0, this.recalculateVisibility();
395
+ });
396
+ }
397
+ recalculateVisibility() {
398
+ this.isConnected && (this.style.display = "", this.style.flexGrow = this.growValue, this.handleSizeChange());
399
+ }
400
+ handleSizeChange() {
401
+ const t = this.getBoundingClientRect(), i = t.width === 0 && !this.isVertical || t.height === 0 && this.isVertical;
402
+ this.isZeroSized !== i && (this.isZeroSized = i, this.updateParticipation());
403
+ }
404
+ updateParticipation() {
405
+ this.isZeroSized ? (this.style.display = "none", this.style.flexGrow = "0") : (this.style.display = "", this.style.flexGrow = this.growValue);
406
+ }
386
407
  }
387
408
  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 {
409
+ 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();
410
+ g.replaceSync(S);
411
+ class j extends p {
391
412
  constructor() {
392
413
  super(g), this.template = (t) => `
393
414
  <px-container border-radius="none" padding="none">
@@ -586,10 +607,10 @@ class S extends c {
586
607
  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
608
  }
588
609
  }
589
- customElements.get("px-page") === void 0 && customElements.define("px-page", S);
610
+ customElements.get("px-page") === void 0 && customElements.define("px-page", j);
590
611
  export {
591
612
  C as HStack,
592
- S as Page,
613
+ j as Page,
593
614
  $ as Spacer,
594
615
  l as Stack,
595
616
  A as VStack,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-layout",
3
- "version": "1.3.0-beta.1",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",