@nectary/components 5.47.0 → 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
@@ -9144,6 +9144,9 @@ class Spinner extends NectaryElement {
9144
9144
  this.#controller = new AbortController();
9145
9145
  this.setAttribute("aria-live", "polite");
9146
9146
  this.setAttribute("aria-busy", "true");
9147
+ if (!this.hasAttribute("data-size")) {
9148
+ updateAttribute(this, "data-size", this.size);
9149
+ }
9147
9150
  subscribeContext(this, "size", this.#onContextSize, this.#controller.signal);
9148
9151
  }
9149
9152
  disconnectedCallback() {
@@ -16688,8 +16691,8 @@ class Skeleton extends NectaryElement {
16688
16691
  #slot;
16689
16692
  #clip;
16690
16693
  #controller = null;
16691
- #bb = null;
16692
- #observer = null;
16694
+ #intersectionObserver = null;
16695
+ #resizeObserver = null;
16693
16696
  #borderWidth = 0;
16694
16697
  constructor() {
16695
16698
  super();
@@ -16710,30 +16713,35 @@ class Skeleton extends NectaryElement {
16710
16713
  this.#slot.addEventListener("slotchange", this.#onSlotChange, {
16711
16714
  signal: this.#controller.signal
16712
16715
  });
16713
- this.#observer = new IntersectionObserver(
16716
+ this.#intersectionObserver = new IntersectionObserver(
16714
16717
  (entries) => {
16715
- this.#bb = entries[0].boundingClientRect;
16716
- if (this.#bb.width === 0) {
16718
+ if (!entries[0].isIntersecting) {
16717
16719
  return;
16718
16720
  }
16719
16721
  this.#buildClipPath();
16722
+ if (this.#wrapper.getBoundingClientRect().width === 0) {
16723
+ return;
16724
+ }
16720
16725
  this.#shimmer.classList.add("animated");
16721
- this.#observer?.disconnect();
16722
- this.#observer = null;
16726
+ this.#intersectionObserver?.disconnect();
16727
+ this.#intersectionObserver = null;
16728
+ this.#resizeObserver = new ResizeObserver(this.#onResize);
16729
+ this.#resizeObserver.observe(this.#wrapper);
16723
16730
  },
16724
- { threshold: 1 }
16731
+ { threshold: 0 }
16725
16732
  );
16726
- this.#observer.observe(this.#wrapper);
16733
+ this.#intersectionObserver.observe(this.#wrapper);
16727
16734
  }
16728
16735
  }
16729
16736
  disconnectedCallback() {
16730
16737
  this.#shimmer.classList.remove("animated");
16731
- this.#bb = null;
16732
16738
  this.#clip.innerHTML = "";
16733
16739
  this.#controller?.abort();
16734
16740
  this.#controller = null;
16735
- this.#observer?.disconnect();
16736
- this.#observer = null;
16741
+ this.#intersectionObserver?.disconnect();
16742
+ this.#intersectionObserver = null;
16743
+ this.#resizeObserver?.disconnect();
16744
+ this.#resizeObserver = null;
16737
16745
  }
16738
16746
  static get observedAttributes() {
16739
16747
  return [
@@ -16744,23 +16752,27 @@ class Skeleton extends NectaryElement {
16744
16752
  attributeChangedCallback(name, _oldVal, newVal) {
16745
16753
  if (name === "card") {
16746
16754
  this.#borderWidth = isAttrTrue(newVal) ? BORDER_WIDTH : 0;
16755
+ this.#buildClipPath();
16747
16756
  }
16748
16757
  }
16749
16758
  #buildClipPath() {
16750
16759
  this.#clip.innerHTML = "";
16751
- if (this.#bb === null) {
16760
+ const bb = this.#wrapper.getBoundingClientRect();
16761
+ if (bb.width === 0) {
16752
16762
  return;
16753
16763
  }
16754
- for (const child of this.#slot.assignedElements()) {
16755
- this.#addClipRect(child);
16764
+ for (const item of this.querySelectorAll("sinch-skeleton-item")) {
16765
+ this.#addClipRect(item, bb);
16756
16766
  }
16757
16767
  }
16758
16768
  #onSlotChange = () => {
16759
16769
  this.#buildClipPath();
16760
16770
  };
16761
- #addClipRect(child) {
16771
+ #onResize = () => {
16772
+ this.#buildClipPath();
16773
+ };
16774
+ #addClipRect(child, bb) {
16762
16775
  const data2 = child.getBoundingClientRect();
16763
- const bb = this.#bb;
16764
16776
  const radiusStr = getCssVar(child, "--sinch-local-shape-radius") ?? "0";
16765
16777
  const radius = attrValueToInteger(radiusStr, {
16766
16778
  min: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "5.47.0",
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,
package/spinner/index.js CHANGED
@@ -16,6 +16,9 @@ class Spinner extends NectaryElement {
16
16
  this.#controller = new AbortController();
17
17
  this.setAttribute("aria-live", "polite");
18
18
  this.setAttribute("aria-busy", "true");
19
+ if (!this.hasAttribute("data-size")) {
20
+ updateAttribute(this, "data-size", this.size);
21
+ }
19
22
  subscribeContext(this, "size", this.#onContextSize, this.#controller.signal);
20
23
  }
21
24
  disconnectedCallback() {