@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 +52 -54
- package/package.json +1 -1
- package/skeleton/index.d.ts +1 -1
- package/skeleton/index.js +48 -50
- package/skeleton-item/index.js +1 -1
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
|
|
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
|
|
3783
|
-
hideAnimationDuration: this.#shouldReduceMotion ? 0 : ANIMATION_DURATION
|
|
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
|
|
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;
|
|
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;
|
|
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
|
-
#
|
|
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, {
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
|
|
12526
|
-
|
|
12527
|
-
|
|
12528
|
-
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
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.#
|
|
12538
|
-
this.#
|
|
12539
|
-
this.#
|
|
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,
|
|
12548
|
-
|
|
12549
|
-
|
|
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
|
-
#
|
|
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.#
|
|
12561
|
+
this.#addClipRect(child);
|
|
12573
12562
|
}
|
|
12563
|
+
}
|
|
12564
|
+
#onSlotChange = () => {
|
|
12565
|
+
this.#buildClipPath();
|
|
12574
12566
|
};
|
|
12575
|
-
#
|
|
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
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12584
|
-
|
|
12585
|
-
rect
|
|
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
package/skeleton/index.d.ts
CHANGED
|
@@ -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,
|
|
9
|
+
attributeChangedCallback(name: string, _oldVal: string | null, newVal: string | null): void;
|
|
10
10
|
}
|
package/skeleton/index.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import {
|
|
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;
|
|
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
|
-
#
|
|
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, {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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.#
|
|
52
|
-
this.#
|
|
53
|
-
this.#
|
|
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,
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
#
|
|
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.#
|
|
75
|
+
this.#addClipRect(child);
|
|
87
76
|
}
|
|
77
|
+
}
|
|
78
|
+
#onSlotChange = () => {
|
|
79
|
+
this.#buildClipPath();
|
|
88
80
|
};
|
|
89
|
-
#
|
|
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
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
rect
|
|
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
|
}
|
package/skeleton-item/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
2
|
-
const templateHTML = '<style>:host{display:block;
|
|
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 {
|