@proximus/lavender-layout 2.0.0-alpha.1 → 2.0.0-alpha.100

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,21 @@
1
1
  export declare class Spacer extends HTMLElement {
2
+ private resizeObserver?;
3
+ private intersectionObserver?;
4
+ private recheckHandle?;
5
+ private isZeroSized;
6
+ private growValue;
7
+ private isVertical;
2
8
  constructor();
3
9
  static get observedAttributes(): string[];
4
10
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
5
11
  connectedCallback(): void;
12
+ disconnectedCallback(): void;
6
13
  get grow(): string;
7
14
  set grow(value: string);
15
+ private scheduleRecheck;
16
+ private recalculateVisibility;
17
+ private handleSizeChange;
18
+ private updateParticipation;
19
+ get nogap(): boolean;
20
+ set nogap(value: boolean);
8
21
  }
package/dist/index.es.js CHANGED
@@ -1,14 +1,14 @@
1
- import { WithExtraAttributes as c, AttributeBreakpointHandlerDelegate as b, gapValues as u, checkName as h, backgroundColorValues as f } from "@proximus/lavender-common";
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
- d.replaceSync(x);
4
- const m = [
1
+ import { WithExtraAttributes as d, AttributeBreakpointHandlerDelegate as u, gapValues as b, checkName as x, log as c, backgroundColorValues as f } from "@proximus/lavender-common";
2
+ const m = ':host{display:block}:host ::slotted(px-h1[auto-spacing]),:host ::slotted(px-h2[auto-spacing]),:host ::slotted(px-h3[auto-spacing]),:host ::slotted(px-h4[auto-spacing]),:host ::slotted(px-h5[auto-spacing]),:host ::slotted(px-h6[auto-spacing]){margin-bottom:calc(var(--px-spacing-heading-to-content-mobile) - var(--host-gap--mobile))}: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 screen and (max-width: 47.938rem){.flex-container{overflow-x:var(--overflow-x-all-mobile, var(--overflow-x-all));scrollbar-width:none}.flex-container::-webkit-scrollbar{display:none}}@media screen and (min-width: 48rem){.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 ::slotted(px-h1[auto-spacing]),:host ::slotted(px-h2[auto-spacing]),:host ::slotted(px-h3[auto-spacing]),:host ::slotted(px-h4[auto-spacing]),:host ::slotted(px-h5[auto-spacing]),:host ::slotted(px-h6[auto-spacing]){margin-bottom:calc(var(--px-spacing-heading-to-content-tablet) - var(--host-gap--tablet))}: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 screen and (min-width: 48rem) and (max-width: 64rem){.flex-container{overflow-x:var(--overflow-x-all-tablet, var(--overflow-x-all));scrollbar-width:none}.flex-container::-webkit-scrollbar{display:none}}@media screen and (min-width: 64.0625rem){.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 ::slotted(px-h1[auto-spacing]),:host ::slotted(px-h2[auto-spacing]),:host ::slotted(px-h3[auto-spacing]),:host ::slotted(px-h4[auto-spacing]),:host ::slotted(px-h5[auto-spacing]),:host ::slotted(px-h6[auto-spacing]){margin-bottom:calc(var(--px-spacing-heading-to-content-laptop) - var(--host-gap--laptop))}: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 screen and (min-width: 64.0625rem) and (max-width: 90rem){.flex-container{overflow-x:var(--overflow-x-all-laptop, var(--overflow-x-all))}}@media screen and (min-width: 90.0625rem){.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 ::slotted(px-h1[auto-spacing]),:host ::slotted(px-h2[auto-spacing]),:host ::slotted(px-h3[auto-spacing]),:host ::slotted(px-h4[auto-spacing]),:host ::slotted(px-h5[auto-spacing]),:host ::slotted(px-h6[auto-spacing]){margin-bottom:calc(var(--px-spacing-heading-to-content-desktop) - var(--host-gap--desktop))}: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))}}', h = new CSSStyleSheet();
3
+ h.replaceSync(m);
4
+ const v = [
5
5
  "",
6
6
  "default",
7
7
  "row",
8
8
  "row-reverse",
9
9
  "column",
10
10
  "column-reverse"
11
- ], v = [
11
+ ], k = [
12
12
  "",
13
13
  "default",
14
14
  "stretch",
@@ -16,7 +16,7 @@ const m = [
16
16
  "flex-end",
17
17
  "center",
18
18
  "baseline"
19
- ], k = [
19
+ ], w = [
20
20
  "",
21
21
  "default",
22
22
  "flex-start",
@@ -25,10 +25,10 @@ const m = [
25
25
  "space-between",
26
26
  "space-around",
27
27
  "space-evenly"
28
- ], w = ["", "default", "nowrap", "wrap", "wrap-reverse"], y = ["", "visible", "hidden", "scroll", "auto"];
29
- class l extends c {
28
+ ], y = ["", "default", "nowrap", "wrap", "wrap-reverse"], A = ["", "visible", "hidden", "scroll", "auto"];
29
+ class l extends d {
30
30
  constructor() {
31
- super(d), this.overflowXAttributeDelegate = new b(
31
+ super(h), this.overflowXAttributeDelegate = new u(
32
32
  this,
33
33
  "overflow-x",
34
34
  (t) => t,
@@ -82,7 +82,7 @@ class l extends c {
82
82
  case "gap--tablet":
83
83
  case "gap--laptop":
84
84
  case "gap--desktop":
85
- this.updateFlexProperties(t, i, e, u);
85
+ this.updateFlexProperties(t, i, e, b);
86
86
  break;
87
87
  case "justify-content":
88
88
  case "justify-content--mobile":
@@ -93,7 +93,7 @@ class l extends c {
93
93
  t,
94
94
  i,
95
95
  e,
96
- k
96
+ w
97
97
  );
98
98
  break;
99
99
  case "align-items":
@@ -101,28 +101,28 @@ class l extends c {
101
101
  case "align-items--tablet":
102
102
  case "align-items--laptop":
103
103
  case "align-items--desktop":
104
- this.updateFlexProperties(t, i, e, v);
104
+ this.updateFlexProperties(t, i, e, k);
105
105
  break;
106
106
  case "wrap":
107
107
  case "wrap--mobile":
108
108
  case "wrap--tablet":
109
109
  case "wrap--laptop":
110
110
  case "wrap--desktop":
111
- this.updateFlexProperties(t, i, e, w);
111
+ this.updateFlexProperties(t, i, e, y);
112
112
  break;
113
113
  case "direction":
114
114
  case "direction--mobile":
115
115
  case "direction--tablet":
116
116
  case "direction--laptop":
117
117
  case "direction--desktop":
118
- this.updateFlexProperties(t, i, e, m);
118
+ this.updateFlexProperties(t, i, e, v);
119
119
  break;
120
120
  case "overflow-x":
121
121
  case "overflow-x--mobile":
122
122
  case "overflow-x--tablet":
123
123
  case "overflow-x--laptop":
124
124
  case "overflow-x--desktop":
125
- this.updateOverflowX(t, i, e, y);
125
+ this.updateOverflowX(t, i, e, A);
126
126
  break;
127
127
  default:
128
128
  super.attributeChangedCallback(t, i, e);
@@ -130,8 +130,10 @@ class l extends c {
130
130
  }
131
131
  }
132
132
  updateOverflowX(t, i, e, o) {
133
- if (!h(o, e)) {
134
- console.error(`${e} is not an allowed ${t} value`);
133
+ if (!x(o, e)) {
134
+ c(
135
+ `${e} is not an allowed ${t} value for ${this.tagName.toLowerCase()}`
136
+ );
135
137
  return;
136
138
  }
137
139
  this.overflowXAttributeDelegate.attributeChangedCallback(
@@ -141,22 +143,27 @@ class l extends c {
141
143
  );
142
144
  }
143
145
  updateFlexProperties(t, i, e, o) {
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
+ this.checkName(o, e) || c(
147
+ `${e} is not an allowed ${t} value for ${this.tagName.toLowerCase()}`
148
+ );
149
+ const p = t.indexOf("--") > -1, a = p ? t.split("--")[0] : t, s = [];
146
150
  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);
151
+ 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) => {
152
+ this.updateStyle(a, r, i, o), this.updateStyle(a, r, e, o);
149
153
  });
150
154
  else {
151
- const s = t.split("--")[1];
152
- this.updateStyle(a, s, i, o), this.updateStyle(a, s, e, o);
155
+ const r = t.split("--")[1];
156
+ this.updateStyle(a, r, i, o), this.updateStyle(a, r, e, o);
153
157
  }
154
158
  }
155
159
  updateStyle(t, i, e, o) {
156
- e && (t === "gap" && o && o.includes(e) ? this.$el.style.setProperty(
160
+ e && (t === "gap" && o && o.includes(e) ? (this.$el.style.setProperty(
157
161
  `--flex-${t}--${i}-value`,
158
162
  `var(--px-spacing-${e}-${i === "laptop" ? "desktop" : i})`
159
- ) : this.$el.style.setProperty(
163
+ ), this.style.setProperty(
164
+ `--host-gap--${i}`,
165
+ `var(--px-spacing-${e}-${i === "laptop" ? "desktop" : i})`
166
+ )) : this.$el.style.setProperty(
160
167
  `--flex-${t}--${i}-value`,
161
168
  e
162
169
  ));
@@ -346,7 +353,7 @@ class l extends c {
346
353
  }
347
354
  }
348
355
  customElements.get("px-stack") || customElements.define("px-stack", l);
349
- class A extends l {
356
+ class C extends l {
350
357
  constructor() {
351
358
  super();
352
359
  }
@@ -354,8 +361,8 @@ class A extends l {
354
361
  super.connectedCallback(), this.direction = "column", this.directionMobile = "column", this.directionTablet = "column", this.directionLaptop = "column", this.directionDesktop = "column";
355
362
  }
356
363
  }
357
- customElements.get("px-vstack") || customElements.define("px-vstack", A);
358
- class C extends l {
364
+ customElements.get("px-vstack") || customElements.define("px-vstack", C);
365
+ class $ extends l {
359
366
  constructor() {
360
367
  super();
361
368
  }
@@ -363,19 +370,25 @@ class C extends l {
363
370
  super.connectedCallback(), this.direction = "row", this.directionMobile = "row", this.directionTablet = "row", this.directionLaptop = "row", this.directionDesktop = "row";
364
371
  }
365
372
  }
366
- customElements.get("px-hstack") || customElements.define("px-hstack", C);
367
- class $ extends HTMLElement {
373
+ customElements.get("px-hstack") || customElements.define("px-hstack", $);
374
+ class S extends HTMLElement {
368
375
  constructor() {
369
- super();
376
+ super(), this.isZeroSized = !1, this.growValue = "1", this.isVertical = !1;
370
377
  }
371
378
  static get observedAttributes() {
372
- return ["grow"];
379
+ return ["grow", "nogap"];
373
380
  }
374
381
  attributeChangedCallback(t, i, e) {
375
- t === "grow" && (this.style.flexGrow = e);
382
+ t === "grow" && (this.growValue = e || "1", this.isZeroSized || (this.style.flexGrow = this.growValue), this.scheduleRecheck());
376
383
  }
377
384
  connectedCallback() {
378
- this.style.flexGrow = this.getAttribute("grow") || "1";
385
+ this.growValue = this.getAttribute("grow") || "1", this.style.flexGrow = this.growValue, this.nogap && (this.resizeObserver = new ResizeObserver(() => {
386
+ this.handleSizeChange();
387
+ }), this.isVertical = this.parentElement.localName === "px-vstack" || this.parentElement.style.flexDirection === "column", this.resizeObserver.observe(this), this.scheduleRecheck());
388
+ }
389
+ disconnectedCallback() {
390
+ var t;
391
+ (t = this.resizeObserver) == null || t.disconnect(), this.recheckHandle && (cancelAnimationFrame(this.recheckHandle), this.recheckHandle = void 0);
379
392
  }
380
393
  get grow() {
381
394
  return this.getAttribute("grow");
@@ -383,11 +396,32 @@ class $ extends HTMLElement {
383
396
  set grow(t) {
384
397
  this.setAttribute("grow", t);
385
398
  }
399
+ scheduleRecheck() {
400
+ this.recheckHandle && cancelAnimationFrame(this.recheckHandle), this.recheckHandle = requestAnimationFrame(() => {
401
+ this.recheckHandle = void 0, this.recalculateVisibility();
402
+ });
403
+ }
404
+ recalculateVisibility() {
405
+ this.isConnected && (this.style.display = "", this.style.flexGrow = this.growValue, this.handleSizeChange());
406
+ }
407
+ handleSizeChange() {
408
+ const t = this.getBoundingClientRect(), i = t.width === 0 && !this.isVertical || t.height === 0 && this.isVertical;
409
+ this.isZeroSized !== i && (this.isZeroSized = i, 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
+ }
414
+ get nogap() {
415
+ return this.hasAttribute("nogap");
416
+ }
417
+ set nogap(t) {
418
+ t ? this.setAttribute("nogap", "") : this.removeAttribute("nogap");
419
+ }
386
420
  }
387
- 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();
421
+ customElements.get("px-spacer") || customElements.define("px-spacer", S);
422
+ const j = ":host{display:block;box-sizing:border-box}slot[name=body-container]{min-height:100vh}#image-sticky-box{margin-top:-2.5rem}", g = new CSSStyleSheet();
389
423
  g.replaceSync(j);
390
- class S extends c {
424
+ class z extends d {
391
425
  constructor() {
392
426
  super(g), this.template = (t) => `
393
427
  <px-container border-radius="none" padding="none">
@@ -586,16 +620,16 @@ class S extends c {
586
620
  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
621
  }
588
622
  }
589
- customElements.get("px-page") === void 0 && customElements.define("px-page", S);
623
+ customElements.get("px-page") === void 0 && customElements.define("px-page", z);
590
624
  export {
591
- C as HStack,
592
- S as Page,
593
- $ as Spacer,
625
+ $ as HStack,
626
+ z as Page,
627
+ S as Spacer,
594
628
  l as Stack,
595
- A as VStack,
596
- v as alignItemsValues,
597
- m as directionValues,
598
- k as justifyContentValues,
599
- y as overflowValues,
600
- w as wrapValues
629
+ C as VStack,
630
+ k as alignItemsValues,
631
+ v as directionValues,
632
+ w as justifyContentValues,
633
+ A as overflowValues,
634
+ y as wrapValues
601
635
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-layout",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.100",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",