@proximus/lavender-light 2.0.0-alpha.90 → 2.0.0-alpha.92

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.
@@ -4314,17 +4314,20 @@ class Section extends HTMLElement {
4314
4314
  this.shadowRoot.adoptedStyleSheets = [styleSheet];
4315
4315
  }
4316
4316
  connectedCallback() {
4317
+ var _a, _b;
4317
4318
  this.$container.setAttribute("background-color", this.backgroundColor);
4318
- if (this.$slotOverlap) {
4319
- this.shadowRoot.firstElementChild.querySelector(".content-wrapper").classList.add("overlapped");
4320
- }
4321
- const headingSlot = this.querySelector('[slot="heading"]');
4322
4319
  if (!this.paddingBlock && !this.paddingTop && !this.paddingBottom && !this.paddingBlockMobile && !this.paddingTopMobile && !this.paddingBottomMobile && !this.paddingBlockTablet && !this.paddingTopTablet && !this.paddingBottomTablet && !this.paddingBlockLaptop && !this.paddingTopLaptop && !this.paddingBottomLaptop) {
4323
4320
  this.$container.paddingBlock = "none";
4324
4321
  }
4325
- if (!headingSlot) {
4326
- this.shadowRoot.querySelector("px-vstack").setAttribute("gap", "none");
4327
- }
4322
+ this.setHeadingSpacing = this.setHeadingSpacing.bind(this);
4323
+ this.setHeadingSpacing();
4324
+ (_a = this.$slotHeading) == null ? void 0 : _a.addEventListener("slotchange", this.setHeadingSpacing);
4325
+ this.toggleOverlapSpacing = this.toggleOverlapSpacing.bind(this);
4326
+ this.toggleOverlapSpacing();
4327
+ (_b = this.$slotOverlap) == null ? void 0 : _b.addEventListener(
4328
+ "slotchange",
4329
+ this.toggleOverlapSpacing
4330
+ );
4328
4331
  }
4329
4332
  static get observedAttributes() {
4330
4333
  return [
@@ -4355,9 +4358,6 @@ class Section extends HTMLElement {
4355
4358
  "border-side--laptop"
4356
4359
  ];
4357
4360
  }
4358
- get $container() {
4359
- return this.shadowRoot.querySelector("px-container");
4360
- }
4361
4361
  attributeChangedCallback(name, oldValue, newValue) {
4362
4362
  if (oldValue !== newValue) {
4363
4363
  switch (name) {
@@ -4439,9 +4439,71 @@ class Section extends HTMLElement {
4439
4439
  }
4440
4440
  }
4441
4441
  }
4442
+ disconnectedCallback() {
4443
+ var _a, _b;
4444
+ (_a = this.$slotHeading) == null ? void 0 : _a.removeEventListener(
4445
+ "slotchange",
4446
+ this.setHeadingSpacing
4447
+ );
4448
+ (_b = this.$slotOverlap) == null ? void 0 : _b.removeEventListener(
4449
+ "slotchange",
4450
+ this.toggleOverlapSpacing
4451
+ );
4452
+ }
4453
+ toggleOverlapSpacing() {
4454
+ const overlapSlot = this.$slotOverlap;
4455
+ const mainContentWrapper = this.$mainContentWrapper;
4456
+ if (!overlapSlot || !mainContentWrapper) return;
4457
+ const assignedNodes = overlapSlot.assignedNodes({ flatten: true });
4458
+ const hasOverlapContent = assignedNodes.some(this.isNotEmptyNode);
4459
+ mainContentWrapper.classList.toggle("overlapped", hasOverlapContent);
4460
+ }
4461
+ isNotEmptyNode(node) {
4462
+ if (node.nodeType === Node.ELEMENT_NODE) return true;
4463
+ if (node.nodeType === Node.TEXT_NODE) {
4464
+ return (node.textContent ?? "").trim().length > 0;
4465
+ }
4466
+ return false;
4467
+ }
4468
+ setHeadingSpacing() {
4469
+ var _a;
4470
+ const headingSlot = this.$slotHeading;
4471
+ const vStack = (_a = this.shadowRoot) == null ? void 0 : _a.querySelector("px-vstack");
4472
+ if (headingSlot && vStack) {
4473
+ const hasHeadingContent = headingSlot.assignedElements().length > 0;
4474
+ if (hasHeadingContent) {
4475
+ vStack.setAttribute("gap", "heading-to-content");
4476
+ } else {
4477
+ vStack.setAttribute("gap", "none");
4478
+ }
4479
+ }
4480
+ }
4481
+ get $container() {
4482
+ var _a;
4483
+ return (_a = this.shadowRoot) == null ? void 0 : _a.querySelector("px-container");
4484
+ }
4485
+ get $mainContentWrapper() {
4486
+ var _a;
4487
+ return (_a = this.$container) == null ? void 0 : _a.querySelector(".content-wrapper");
4488
+ }
4442
4489
  get $slotOverlap() {
4490
+ var _a;
4491
+ return (_a = this.shadowRoot) == null ? void 0 : _a.querySelector(
4492
+ 'slot[name="overlap"]'
4493
+ );
4494
+ }
4495
+ get $slottedOverlap() {
4443
4496
  return this.querySelector('[slot="overlap"]');
4444
4497
  }
4498
+ get $slotHeading() {
4499
+ var _a;
4500
+ return (_a = this.shadowRoot) == null ? void 0 : _a.querySelector(
4501
+ 'slot[name="heading"]'
4502
+ );
4503
+ }
4504
+ get $slottedHeading() {
4505
+ return this.querySelector('[slot="heading"]');
4506
+ }
4445
4507
  get backgroundColor() {
4446
4508
  return this.getAttribute("background-color") || "none";
4447
4509
  }
@@ -5892,6 +5954,7 @@ const _ContentHeader = class _ContentHeader extends PxElement {
5892
5954
  </div>
5893
5955
  </px-container>
5894
5956
  </px-grid>
5957
+ <slot name="overlap" slot="overlap"></slot>
5895
5958
  </px-section>
5896
5959
  </div>`;
5897
5960
  this.shadowRoot.innerHTML = this.template();
@@ -5928,12 +5991,6 @@ const _ContentHeader = class _ContentHeader extends PxElement {
5928
5991
  </px-stack>`
5929
5992
  );
5930
5993
  }
5931
- if (this.$overlapSlot) {
5932
- this.shadowRoot.querySelector("px-section").insertAdjacentHTML(
5933
- "beforeend",
5934
- `<slot name="overlap" slot="overlap"></slot>`
5935
- );
5936
- }
5937
5994
  if (this.$subtitleSlot) {
5938
5995
  this.$subtitleSlot.setAttribute("variant", "subtitle");
5939
5996
  }