@nectary/components 5.47.1 → 5.47.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/bundle.js CHANGED
@@ -16691,8 +16691,8 @@ class Skeleton extends NectaryElement {
16691
16691
  #slot;
16692
16692
  #clip;
16693
16693
  #controller = null;
16694
- #bb = null;
16695
- #observer = null;
16694
+ #intersectionObserver = null;
16695
+ #resizeObserver = null;
16696
16696
  #borderWidth = 0;
16697
16697
  constructor() {
16698
16698
  super();
@@ -16713,30 +16713,35 @@ class Skeleton extends NectaryElement {
16713
16713
  this.#slot.addEventListener("slotchange", this.#onSlotChange, {
16714
16714
  signal: this.#controller.signal
16715
16715
  });
16716
- this.#observer = new IntersectionObserver(
16716
+ this.#intersectionObserver = new IntersectionObserver(
16717
16717
  (entries) => {
16718
- this.#bb = entries[0].boundingClientRect;
16719
- if (this.#bb.width === 0) {
16718
+ if (!entries[0].isIntersecting) {
16720
16719
  return;
16721
16720
  }
16722
16721
  this.#buildClipPath();
16722
+ if (this.#wrapper.getBoundingClientRect().width === 0) {
16723
+ return;
16724
+ }
16723
16725
  this.#shimmer.classList.add("animated");
16724
- this.#observer?.disconnect();
16725
- this.#observer = null;
16726
+ this.#intersectionObserver?.disconnect();
16727
+ this.#intersectionObserver = null;
16728
+ this.#resizeObserver = new ResizeObserver(this.#onResize);
16729
+ this.#resizeObserver.observe(this.#wrapper);
16726
16730
  },
16727
- { threshold: 1 }
16731
+ { threshold: 0 }
16728
16732
  );
16729
- this.#observer.observe(this.#wrapper);
16733
+ this.#intersectionObserver.observe(this.#wrapper);
16730
16734
  }
16731
16735
  }
16732
16736
  disconnectedCallback() {
16733
16737
  this.#shimmer.classList.remove("animated");
16734
- this.#bb = null;
16735
16738
  this.#clip.innerHTML = "";
16736
16739
  this.#controller?.abort();
16737
16740
  this.#controller = null;
16738
- this.#observer?.disconnect();
16739
- this.#observer = null;
16741
+ this.#intersectionObserver?.disconnect();
16742
+ this.#intersectionObserver = null;
16743
+ this.#resizeObserver?.disconnect();
16744
+ this.#resizeObserver = null;
16740
16745
  }
16741
16746
  static get observedAttributes() {
16742
16747
  return [
@@ -16747,23 +16752,27 @@ class Skeleton extends NectaryElement {
16747
16752
  attributeChangedCallback(name, _oldVal, newVal) {
16748
16753
  if (name === "card") {
16749
16754
  this.#borderWidth = isAttrTrue(newVal) ? BORDER_WIDTH : 0;
16755
+ this.#buildClipPath();
16750
16756
  }
16751
16757
  }
16752
16758
  #buildClipPath() {
16753
16759
  this.#clip.innerHTML = "";
16754
- if (this.#bb === null) {
16760
+ const bb = this.#wrapper.getBoundingClientRect();
16761
+ if (bb.width === 0) {
16755
16762
  return;
16756
16763
  }
16757
- for (const child of this.#slot.assignedElements()) {
16758
- this.#addClipRect(child);
16764
+ for (const item of this.querySelectorAll("sinch-skeleton-item")) {
16765
+ this.#addClipRect(item, bb);
16759
16766
  }
16760
16767
  }
16761
16768
  #onSlotChange = () => {
16762
16769
  this.#buildClipPath();
16763
16770
  };
16764
- #addClipRect(child) {
16771
+ #onResize = () => {
16772
+ this.#buildClipPath();
16773
+ };
16774
+ #addClipRect(child, bb) {
16765
16775
  const data2 = child.getBoundingClientRect();
16766
- const bb = this.#bb;
16767
16776
  const radiusStr = getCssVar(child, "--sinch-local-shape-radius") ?? "0";
16768
16777
  const radius = attrValueToInteger(radiusStr, {
16769
16778
  min: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "5.47.1",
3
+ "version": "5.47.2",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
package/skeleton/index.js CHANGED
@@ -11,8 +11,8 @@ class Skeleton extends NectaryElement {
11
11
  #slot;
12
12
  #clip;
13
13
  #controller = null;
14
- #bb = null;
15
- #observer = null;
14
+ #intersectionObserver = null;
15
+ #resizeObserver = null;
16
16
  #borderWidth = 0;
17
17
  constructor() {
18
18
  super();
@@ -33,30 +33,35 @@ class Skeleton extends NectaryElement {
33
33
  this.#slot.addEventListener("slotchange", this.#onSlotChange, {
34
34
  signal: this.#controller.signal
35
35
  });
36
- this.#observer = new IntersectionObserver(
36
+ this.#intersectionObserver = new IntersectionObserver(
37
37
  (entries) => {
38
- this.#bb = entries[0].boundingClientRect;
39
- if (this.#bb.width === 0) {
38
+ if (!entries[0].isIntersecting) {
40
39
  return;
41
40
  }
42
41
  this.#buildClipPath();
42
+ if (this.#wrapper.getBoundingClientRect().width === 0) {
43
+ return;
44
+ }
43
45
  this.#shimmer.classList.add("animated");
44
- this.#observer?.disconnect();
45
- this.#observer = null;
46
+ this.#intersectionObserver?.disconnect();
47
+ this.#intersectionObserver = null;
48
+ this.#resizeObserver = new ResizeObserver(this.#onResize);
49
+ this.#resizeObserver.observe(this.#wrapper);
46
50
  },
47
- { threshold: 1 }
51
+ { threshold: 0 }
48
52
  );
49
- this.#observer.observe(this.#wrapper);
53
+ this.#intersectionObserver.observe(this.#wrapper);
50
54
  }
51
55
  }
52
56
  disconnectedCallback() {
53
57
  this.#shimmer.classList.remove("animated");
54
- this.#bb = null;
55
58
  this.#clip.innerHTML = "";
56
59
  this.#controller?.abort();
57
60
  this.#controller = null;
58
- this.#observer?.disconnect();
59
- this.#observer = null;
61
+ this.#intersectionObserver?.disconnect();
62
+ this.#intersectionObserver = null;
63
+ this.#resizeObserver?.disconnect();
64
+ this.#resizeObserver = null;
60
65
  }
61
66
  static get observedAttributes() {
62
67
  return [
@@ -67,23 +72,27 @@ class Skeleton extends NectaryElement {
67
72
  attributeChangedCallback(name, _oldVal, newVal) {
68
73
  if (name === "card") {
69
74
  this.#borderWidth = isAttrTrue(newVal) ? BORDER_WIDTH : 0;
75
+ this.#buildClipPath();
70
76
  }
71
77
  }
72
78
  #buildClipPath() {
73
79
  this.#clip.innerHTML = "";
74
- if (this.#bb === null) {
80
+ const bb = this.#wrapper.getBoundingClientRect();
81
+ if (bb.width === 0) {
75
82
  return;
76
83
  }
77
- for (const child of this.#slot.assignedElements()) {
78
- this.#addClipRect(child);
84
+ for (const item of this.querySelectorAll("sinch-skeleton-item")) {
85
+ this.#addClipRect(item, bb);
79
86
  }
80
87
  }
81
88
  #onSlotChange = () => {
82
89
  this.#buildClipPath();
83
90
  };
84
- #addClipRect(child) {
91
+ #onResize = () => {
92
+ this.#buildClipPath();
93
+ };
94
+ #addClipRect(child, bb) {
85
95
  const data = child.getBoundingClientRect();
86
- const bb = this.#bb;
87
96
  const radiusStr = getCssVar(child, "--sinch-local-shape-radius") ?? "0";
88
97
  const radius = attrValueToInteger(radiusStr, {
89
98
  min: 0,