@nectary/components 5.20.2 → 5.20.3

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
@@ -3751,7 +3751,7 @@ const TIP_SIZE$1 = 8;
3751
3751
  const SHOW_DELAY_SLOW = 1e3;
3752
3752
  const SHOW_DELAY_FAST = 250;
3753
3753
  const HIDE_DELAY = 0;
3754
- const ANIMATION_DURATION$1 = 100;
3754
+ const ANIMATION_DURATION = 100;
3755
3755
  const template$Q = document.createElement("template");
3756
3756
  template$Q.innerHTML = templateHTML$Q;
3757
3757
  class Tooltip extends NectaryElement {
@@ -3779,8 +3779,8 @@ class Tooltip extends NectaryElement {
3779
3779
  this.#shouldReduceMotion = shouldReduceMotion();
3780
3780
  this.#tooltipState = new TooltipState({
3781
3781
  showDelay: SHOW_DELAY_SLOW,
3782
- hideDelay: this.#shouldReduceMotion ? HIDE_DELAY + ANIMATION_DURATION$1 : HIDE_DELAY,
3783
- hideAnimationDuration: this.#shouldReduceMotion ? 0 : ANIMATION_DURATION$1,
3782
+ hideDelay: this.#shouldReduceMotion ? HIDE_DELAY + ANIMATION_DURATION : HIDE_DELAY,
3783
+ hideAnimationDuration: this.#shouldReduceMotion ? 0 : ANIMATION_DURATION,
3784
3784
  onShowStart: this.#onStateShowStart,
3785
3785
  onShowEnd: this.#onStateShowEnd,
3786
3786
  onHideStart: this.#onStateHideStart,
@@ -3947,7 +3947,7 @@ class Tooltip extends NectaryElement {
3947
3947
  this.#animation = this.#$content.animate({
3948
3948
  opacity: [0, 1]
3949
3949
  }, {
3950
- duration: this.#shouldReduceMotion ? 0 : ANIMATION_DURATION$1,
3950
+ duration: this.#shouldReduceMotion ? 0 : ANIMATION_DURATION,
3951
3951
  iterations: 1,
3952
3952
  fill: "forwards"
3953
3953
  });
@@ -12463,7 +12463,7 @@ class SelectMenu extends NectaryElement {
12463
12463
  };
12464
12464
  }
12465
12465
  defineCustomElement("sinch-select-menu", SelectMenu);
12466
- const templateHTML$e = '<style>:host{display:block;height:var(--sinch-sys-size-m);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m)}:host([size=xs]){height:var(--sinch-sys-size-xs);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-xs)}:host([size="s"]){height:var(--sinch-sys-size-s);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-s)}:host([size="m"]){height:var(--sinch-sys-size-m);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m)}:host([size="l"]){height:var(--sinch-sys-size-l);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-l)}#content{height:100%;background-color:var(--sinch-sys-color-border-subtle);border-radius:var(--sinch-local-shape-radius)}</style><div id="content"></div>';
12466
+ const templateHTML$e = '<style>:host{display:block;box-sizing:border-box;--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m, 4px)}#content{width:100%;height:100%;min-height:100%;box-sizing:border-box;background-color:var(--sinch-sys-color-border-subtle);overflow:hidden;position:relative;border-radius:var(--sinch-local-shape-radius)}:host([size=xs]){height:var(--sinch-sys-size-xs,24px);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-xs, 4px)}:host([size="s"]){height:var(--sinch-sys-size-s,32px);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-s, 4px)}:host(:not([size])),:host([size="m"]){height:var(--sinch-sys-size-m,40px);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m, 4px)}:host([size="l"]){height:var(--sinch-sys-size-l,48px);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-l, 4px)}</style><div id="content"></div>';
12467
12467
  const template$e = document.createElement("template");
12468
12468
  template$e.innerHTML = templateHTML$e;
12469
12469
  class SkeletonItem extends NectaryElement {
@@ -12487,21 +12487,19 @@ const getUid = () => crypto.getRandomValues(new Uint8Array(21)).reduce((id, byte
12487
12487
  }
12488
12488
  return `${id}_`;
12489
12489
  }, "");
12490
- const templateHTML$d = '<style>:host{display:block}#wrapper{position:relative;display:flex;flex-direction:column;gap:16px;height:100%;box-sizing:border-box;overflow:hidden}:host([card]:not([card=false]))>#wrapper{padding:16px;background-color:var(--sinch-sys-color-surface-primary-default);border-radius:var(--sinch-sys-shape-radius-l);border:1px solid var(--sinch-sys-color-border-subtle)}#shimmer{position:absolute;inset:0;background-image:linear-gradient(90deg,transparent 0,var(--sinch-sys-color-surface-tertiary-default) 100px,transparent 200px);clip-path:url("#clip")}#svg{display:block;width:0;height:0}</style><svg id="svg"><defs><clipPath id="clip"></clipPath></defs></svg><div id="wrapper"><slot></slot><div id="shimmer"></div></div>';
12490
+ const templateHTML$d = '<style>:host{display:block;position:relative}#wrapper{position:relative;display:flex;flex-direction:column;gap:16px;overflow:hidden;box-sizing:border-box}:host([card]:not([card=false])) #wrapper{background-color:var(--sinch-sys-color-surface-primary-default);border:1px solid var(--sinch-sys-color-border-subtle);border-radius:var(--sinch-sys-shape-radius-l);padding:16px}#shimmer{position:absolute;inset:0;overflow:hidden;pointer-events:none}#shimmer-inner{position:absolute;left:0;top:0;width:400%;height:100%;background-image:linear-gradient(90deg,transparent 0,transparent 47%,var(--sinch-sys-color-surface-tertiary-default) 50%,transparent 53%,transparent 100%);background-size:100% 100%}#shimmer.animated #shimmer-inner{animation:nectary-skeleton-shimmer 2s linear infinite}@media (prefers-reduced-motion:reduce){#shimmer.animated #shimmer-inner{animation:none}}@keyframes nectary-skeleton-shimmer{0%{transform:translateX(-75%)}100%{transform:translateX(0)}}#svg{display:block;width:0;height:0}</style><svg id="svg"><defs><clipPath id="clip"></clipPath></defs></svg><div id="wrapper"><slot></slot><div id="shimmer"><div id="shimmer-inner"></div></div></div>';
12491
12491
  const template$d = document.createElement("template");
12492
12492
  template$d.innerHTML = templateHTML$d;
12493
- const ANIMATION_DURATION = 2e3;
12494
12493
  const BORDER_WIDTH = 1;
12495
12494
  class Skeleton extends NectaryElement {
12496
- #animation = null;
12497
12495
  #shimmer;
12498
12496
  #wrapper;
12499
12497
  #slot;
12500
- #controller = null;
12501
12498
  #clip;
12502
- #borderWidth = 0;
12499
+ #controller = null;
12503
12500
  #bb = null;
12504
12501
  #observer = null;
12502
+ #borderWidth = 0;
12505
12503
  constructor() {
12506
12504
  super();
12507
12505
  const shadowRoot = this.attachShadow();
@@ -12515,28 +12513,33 @@ class Skeleton extends NectaryElement {
12515
12513
  const id = getUid();
12516
12514
  this.#shimmer.style.setProperty("clip-path", `url(#${id})`);
12517
12515
  this.#clip.setAttribute("id", id);
12516
+ this.#borderWidth = isAttrTrue(this.getAttribute("card")) ? BORDER_WIDTH : 0;
12518
12517
  this.#controller = new AbortController();
12519
12518
  if (!shouldReduceMotion()) {
12520
- this.#slot.addEventListener("slotchange", this.#onSlotChange, { signal: this.#controller.signal });
12521
- this.#observer = new IntersectionObserver((entries) => {
12522
- this.#bb = entries[0].boundingClientRect;
12523
- if (this.#bb.width === 0) {
12524
- return;
12525
- }
12526
- this.#updateAnimation();
12527
- for (const child of this.#slot.assignedElements()) {
12528
- this.#handleSkeletonItemData(child);
12529
- }
12530
- this.#observer.disconnect();
12531
- this.#observer = null;
12532
- }, { threshold: 1 });
12519
+ this.#slot.addEventListener("slotchange", this.#onSlotChange, {
12520
+ signal: this.#controller.signal
12521
+ });
12522
+ this.#observer = new IntersectionObserver(
12523
+ (entries) => {
12524
+ this.#bb = entries[0].boundingClientRect;
12525
+ if (this.#bb.width === 0) {
12526
+ return;
12527
+ }
12528
+ this.#buildClipPath();
12529
+ this.#shimmer.classList.add("animated");
12530
+ this.#observer?.disconnect();
12531
+ this.#observer = null;
12532
+ },
12533
+ { threshold: 1 }
12534
+ );
12533
12535
  this.#observer.observe(this.#wrapper);
12534
12536
  }
12535
12537
  }
12536
12538
  disconnectedCallback() {
12537
- this.#animation?.cancel();
12538
- this.#animation = null;
12539
- this.#controller.abort();
12539
+ this.#shimmer.classList.remove("animated");
12540
+ this.#bb = null;
12541
+ this.#clip.innerHTML = "";
12542
+ this.#controller?.abort();
12540
12543
  this.#controller = null;
12541
12544
  this.#observer?.disconnect();
12542
12545
  this.#observer = null;
@@ -12544,45 +12547,40 @@ class Skeleton extends NectaryElement {
12544
12547
  static get observedAttributes() {
12545
12548
  return ["card"];
12546
12549
  }
12547
- attributeChangedCallback(name, oldVal, newVal) {
12548
- switch (name) {
12549
- case "card": {
12550
- this.#borderWidth = isAttrTrue(newVal) ? BORDER_WIDTH : 0;
12551
- break;
12552
- }
12550
+ attributeChangedCallback(name, _oldVal, newVal) {
12551
+ if (name === "card") {
12552
+ this.#borderWidth = isAttrTrue(newVal) ? BORDER_WIDTH : 0;
12553
12553
  }
12554
12554
  }
12555
- #updateAnimation() {
12556
- const bb = this.#bb;
12557
- const bgWidth = bb.width * 4;
12558
- this.#shimmer.style.setProperty("background-size", `${bgWidth}px`);
12559
- this.#animation = this.#shimmer.animate({
12560
- backgroundPosition: [`0px`, `${bgWidth}px`]
12561
- }, {
12562
- duration: ANIMATION_DURATION,
12563
- iterations: Infinity
12564
- });
12565
- }
12566
- #onSlotChange = () => {
12555
+ #buildClipPath() {
12567
12556
  this.#clip.innerHTML = "";
12568
12557
  if (this.#bb === null) {
12569
12558
  return;
12570
12559
  }
12571
12560
  for (const child of this.#slot.assignedElements()) {
12572
- this.#handleSkeletonItemData(child);
12561
+ this.#addClipRect(child);
12573
12562
  }
12563
+ }
12564
+ #onSlotChange = () => {
12565
+ this.#buildClipPath();
12574
12566
  };
12575
- #handleSkeletonItemData(child) {
12567
+ #addClipRect(child) {
12576
12568
  const data2 = child.getBoundingClientRect();
12577
- const radiusStr = getCssVar(child, "--sinch-local-shape-radius") ?? "0";
12578
- const radius = attrValueToInteger(radiusStr, { min: 0, defaultValue: 0 });
12579
12569
  const bb = this.#bb;
12580
- const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
12581
- rect.setAttribute("x", (data2.x - bb.x - this.#borderWidth).toString());
12582
- rect.setAttribute("y", (data2.y - bb.y - this.#borderWidth).toString());
12583
- rect.setAttribute("width", data2.width.toString());
12584
- rect.setAttribute("height", data2.height.toString());
12585
- rect.setAttribute("rx", radius.toString());
12570
+ const radiusStr = getCssVar(child, "--sinch-local-shape-radius") ?? "0";
12571
+ const radius = attrValueToInteger(radiusStr, {
12572
+ min: 0,
12573
+ defaultValue: 0
12574
+ });
12575
+ const rect = document.createElementNS(
12576
+ "http://www.w3.org/2000/svg",
12577
+ "rect"
12578
+ );
12579
+ rect.setAttribute("x", String(data2.x - bb.x - this.#borderWidth));
12580
+ rect.setAttribute("y", String(data2.y - bb.y - this.#borderWidth));
12581
+ rect.setAttribute("width", String(data2.width));
12582
+ rect.setAttribute("height", String(data2.height));
12583
+ rect.setAttribute("rx", String(radius));
12586
12584
  this.#clip.appendChild(rect);
12587
12585
  }
12588
12586
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "5.20.2",
3
+ "version": "5.20.3",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -6,5 +6,5 @@ export declare class Skeleton extends NectaryElement {
6
6
  connectedCallback(): void;
7
7
  disconnectedCallback(): void;
8
8
  static get observedAttributes(): string[];
9
- attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
9
+ attributeChangedCallback(name: string, _oldVal: string | null, newVal: string | null): void;
10
10
  }
package/skeleton/index.js CHANGED
@@ -1,21 +1,19 @@
1
- import { shouldReduceMotion, isAttrTrue, getCssVar, attrValueToInteger } from "../utils/dom.js";
1
+ import { isAttrTrue, shouldReduceMotion, getCssVar, attrValueToInteger } from "../utils/dom.js";
2
2
  import { defineCustomElement, NectaryElement } from "../utils/element.js";
3
3
  import { getUid } from "../utils/uid.js";
4
- const templateHTML = '<style>:host{display:block}#wrapper{position:relative;display:flex;flex-direction:column;gap:16px;height:100%;box-sizing:border-box;overflow:hidden}:host([card]:not([card=false]))>#wrapper{padding:16px;background-color:var(--sinch-sys-color-surface-primary-default);border-radius:var(--sinch-sys-shape-radius-l);border:1px solid var(--sinch-sys-color-border-subtle)}#shimmer{position:absolute;inset:0;background-image:linear-gradient(90deg,transparent 0,var(--sinch-sys-color-surface-tertiary-default) 100px,transparent 200px);clip-path:url("#clip")}#svg{display:block;width:0;height:0}</style><svg id="svg"><defs><clipPath id="clip"></clipPath></defs></svg><div id="wrapper"><slot></slot><div id="shimmer"></div></div>';
4
+ const templateHTML = '<style>:host{display:block;position:relative}#wrapper{position:relative;display:flex;flex-direction:column;gap:16px;overflow:hidden;box-sizing:border-box}:host([card]:not([card=false])) #wrapper{background-color:var(--sinch-sys-color-surface-primary-default);border:1px solid var(--sinch-sys-color-border-subtle);border-radius:var(--sinch-sys-shape-radius-l);padding:16px}#shimmer{position:absolute;inset:0;overflow:hidden;pointer-events:none}#shimmer-inner{position:absolute;left:0;top:0;width:400%;height:100%;background-image:linear-gradient(90deg,transparent 0,transparent 47%,var(--sinch-sys-color-surface-tertiary-default) 50%,transparent 53%,transparent 100%);background-size:100% 100%}#shimmer.animated #shimmer-inner{animation:nectary-skeleton-shimmer 2s linear infinite}@media (prefers-reduced-motion:reduce){#shimmer.animated #shimmer-inner{animation:none}}@keyframes nectary-skeleton-shimmer{0%{transform:translateX(-75%)}100%{transform:translateX(0)}}#svg{display:block;width:0;height:0}</style><svg id="svg"><defs><clipPath id="clip"></clipPath></defs></svg><div id="wrapper"><slot></slot><div id="shimmer"><div id="shimmer-inner"></div></div></div>';
5
5
  const template = document.createElement("template");
6
6
  template.innerHTML = templateHTML;
7
- const ANIMATION_DURATION = 2e3;
8
7
  const BORDER_WIDTH = 1;
9
8
  class Skeleton extends NectaryElement {
10
- #animation = null;
11
9
  #shimmer;
12
10
  #wrapper;
13
11
  #slot;
14
- #controller = null;
15
12
  #clip;
16
- #borderWidth = 0;
13
+ #controller = null;
17
14
  #bb = null;
18
15
  #observer = null;
16
+ #borderWidth = 0;
19
17
  constructor() {
20
18
  super();
21
19
  const shadowRoot = this.attachShadow();
@@ -29,28 +27,33 @@ class Skeleton extends NectaryElement {
29
27
  const id = getUid();
30
28
  this.#shimmer.style.setProperty("clip-path", `url(#${id})`);
31
29
  this.#clip.setAttribute("id", id);
30
+ this.#borderWidth = isAttrTrue(this.getAttribute("card")) ? BORDER_WIDTH : 0;
32
31
  this.#controller = new AbortController();
33
32
  if (!shouldReduceMotion()) {
34
- this.#slot.addEventListener("slotchange", this.#onSlotChange, { signal: this.#controller.signal });
35
- this.#observer = new IntersectionObserver((entries) => {
36
- this.#bb = entries[0].boundingClientRect;
37
- if (this.#bb.width === 0) {
38
- return;
39
- }
40
- this.#updateAnimation();
41
- for (const child of this.#slot.assignedElements()) {
42
- this.#handleSkeletonItemData(child);
43
- }
44
- this.#observer.disconnect();
45
- this.#observer = null;
46
- }, { threshold: 1 });
33
+ this.#slot.addEventListener("slotchange", this.#onSlotChange, {
34
+ signal: this.#controller.signal
35
+ });
36
+ this.#observer = new IntersectionObserver(
37
+ (entries) => {
38
+ this.#bb = entries[0].boundingClientRect;
39
+ if (this.#bb.width === 0) {
40
+ return;
41
+ }
42
+ this.#buildClipPath();
43
+ this.#shimmer.classList.add("animated");
44
+ this.#observer?.disconnect();
45
+ this.#observer = null;
46
+ },
47
+ { threshold: 1 }
48
+ );
47
49
  this.#observer.observe(this.#wrapper);
48
50
  }
49
51
  }
50
52
  disconnectedCallback() {
51
- this.#animation?.cancel();
52
- this.#animation = null;
53
- this.#controller.abort();
53
+ this.#shimmer.classList.remove("animated");
54
+ this.#bb = null;
55
+ this.#clip.innerHTML = "";
56
+ this.#controller?.abort();
54
57
  this.#controller = null;
55
58
  this.#observer?.disconnect();
56
59
  this.#observer = null;
@@ -58,45 +61,40 @@ class Skeleton extends NectaryElement {
58
61
  static get observedAttributes() {
59
62
  return ["card"];
60
63
  }
61
- attributeChangedCallback(name, oldVal, newVal) {
62
- switch (name) {
63
- case "card": {
64
- this.#borderWidth = isAttrTrue(newVal) ? BORDER_WIDTH : 0;
65
- break;
66
- }
64
+ attributeChangedCallback(name, _oldVal, newVal) {
65
+ if (name === "card") {
66
+ this.#borderWidth = isAttrTrue(newVal) ? BORDER_WIDTH : 0;
67
67
  }
68
68
  }
69
- #updateAnimation() {
70
- const bb = this.#bb;
71
- const bgWidth = bb.width * 4;
72
- this.#shimmer.style.setProperty("background-size", `${bgWidth}px`);
73
- this.#animation = this.#shimmer.animate({
74
- backgroundPosition: [`0px`, `${bgWidth}px`]
75
- }, {
76
- duration: ANIMATION_DURATION,
77
- iterations: Infinity
78
- });
79
- }
80
- #onSlotChange = () => {
69
+ #buildClipPath() {
81
70
  this.#clip.innerHTML = "";
82
71
  if (this.#bb === null) {
83
72
  return;
84
73
  }
85
74
  for (const child of this.#slot.assignedElements()) {
86
- this.#handleSkeletonItemData(child);
75
+ this.#addClipRect(child);
87
76
  }
77
+ }
78
+ #onSlotChange = () => {
79
+ this.#buildClipPath();
88
80
  };
89
- #handleSkeletonItemData(child) {
81
+ #addClipRect(child) {
90
82
  const data = child.getBoundingClientRect();
91
- const radiusStr = getCssVar(child, "--sinch-local-shape-radius") ?? "0";
92
- const radius = attrValueToInteger(radiusStr, { min: 0, defaultValue: 0 });
93
83
  const bb = this.#bb;
94
- const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
95
- rect.setAttribute("x", (data.x - bb.x - this.#borderWidth).toString());
96
- rect.setAttribute("y", (data.y - bb.y - this.#borderWidth).toString());
97
- rect.setAttribute("width", data.width.toString());
98
- rect.setAttribute("height", data.height.toString());
99
- rect.setAttribute("rx", radius.toString());
84
+ const radiusStr = getCssVar(child, "--sinch-local-shape-radius") ?? "0";
85
+ const radius = attrValueToInteger(radiusStr, {
86
+ min: 0,
87
+ defaultValue: 0
88
+ });
89
+ const rect = document.createElementNS(
90
+ "http://www.w3.org/2000/svg",
91
+ "rect"
92
+ );
93
+ rect.setAttribute("x", String(data.x - bb.x - this.#borderWidth));
94
+ rect.setAttribute("y", String(data.y - bb.y - this.#borderWidth));
95
+ rect.setAttribute("width", String(data.width));
96
+ rect.setAttribute("height", String(data.height));
97
+ rect.setAttribute("rx", String(radius));
100
98
  this.#clip.appendChild(rect);
101
99
  }
102
100
  }
@@ -1,5 +1,5 @@
1
1
  import { defineCustomElement, NectaryElement } from "../utils/element.js";
2
- const templateHTML = '<style>:host{display:block;height:var(--sinch-sys-size-m);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m)}:host([size=xs]){height:var(--sinch-sys-size-xs);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-xs)}:host([size="s"]){height:var(--sinch-sys-size-s);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-s)}:host([size="m"]){height:var(--sinch-sys-size-m);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m)}:host([size="l"]){height:var(--sinch-sys-size-l);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-l)}#content{height:100%;background-color:var(--sinch-sys-color-border-subtle);border-radius:var(--sinch-local-shape-radius)}</style><div id="content"></div>';
2
+ const templateHTML = '<style>:host{display:block;box-sizing:border-box;--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m, 4px)}#content{width:100%;height:100%;min-height:100%;box-sizing:border-box;background-color:var(--sinch-sys-color-border-subtle);overflow:hidden;position:relative;border-radius:var(--sinch-local-shape-radius)}:host([size=xs]){height:var(--sinch-sys-size-xs,24px);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-xs, 4px)}:host([size="s"]){height:var(--sinch-sys-size-s,32px);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-s, 4px)}:host(:not([size])),:host([size="m"]){height:var(--sinch-sys-size-m,40px);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-m, 4px)}:host([size="l"]){height:var(--sinch-sys-size-l,48px);--sinch-local-shape-radius:var(--sinch-sys-shape-radius-l, 4px)}</style><div id="content"></div>';
3
3
  const template = document.createElement("template");
4
4
  template.innerHTML = templateHTML;
5
5
  class SkeletonItem extends NectaryElement {