@nectary/components 5.47.2 → 5.48.0

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.
@@ -11,6 +11,8 @@ export type TEmojiGroup = {
11
11
  emojis: TEmoji[];
12
12
  };
13
13
  export type TSinchEmojiPickerProps = {
14
+ /** How many rows of emojis to show and scroll the rest, defaults to 10 */
15
+ 'max-rows'?: number;
14
16
  readonly skinToneButtonRect?: TRect;
15
17
  readonly searchInputRect?: TRect;
16
18
  readonly searchClearButtonRect?: TRect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "5.47.2",
3
+ "version": "5.48.0",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
package/skeleton/index.js CHANGED
@@ -5,6 +5,29 @@ const templateHTML = '<style>:host{display:block;position:relative}#wrapper{posi
5
5
  const template = document.createElement("template");
6
6
  template.innerHTML = templateHTML;
7
7
  const BORDER_WIDTH = 1;
8
+ const roundedRectPath = ({
9
+ x,
10
+ y,
11
+ width,
12
+ height,
13
+ radius
14
+ }) => {
15
+ if (radius <= 0) {
16
+ return `M${x},${y}h${width}v${height}h${-width}z`;
17
+ }
18
+ return [
19
+ `M${x + radius},${y}`,
20
+ `H${x + width - radius}`,
21
+ `A${radius},${radius} 0 0 1 ${x + width},${y + radius}`,
22
+ `V${y + height - radius}`,
23
+ `A${radius},${radius} 0 0 1 ${x + width - radius},${y + height}`,
24
+ `H${x + radius}`,
25
+ `A${radius},${radius} 0 0 1 ${x},${y + height - radius}`,
26
+ `V${y + radius}`,
27
+ `A${radius},${radius} 0 0 1 ${x + radius},${y}`,
28
+ "Z"
29
+ ].join(" ");
30
+ };
8
31
  class Skeleton extends NectaryElement {
9
32
  #shimmer;
10
33
  #wrapper;
@@ -93,21 +116,29 @@ class Skeleton extends NectaryElement {
93
116
  };
94
117
  #addClipRect(child, bb) {
95
118
  const data = child.getBoundingClientRect();
96
- const radiusStr = getCssVar(child, "--sinch-local-shape-radius") ?? "0";
97
- const radius = attrValueToInteger(radiusStr, {
98
- min: 0,
99
- defaultValue: 0
100
- });
101
- const rect = document.createElementNS(
119
+ const x = data.x - bb.x - this.#borderWidth;
120
+ const y = data.y - bb.y - this.#borderWidth;
121
+ const width = data.width;
122
+ const height = data.height;
123
+ const radius = Math.min(this.#getClipRadius(child), width / 2, height / 2);
124
+ const path = document.createElementNS(
102
125
  "http://www.w3.org/2000/svg",
103
- "rect"
126
+ "path"
104
127
  );
105
- rect.setAttribute("x", String(data.x - bb.x - this.#borderWidth));
106
- rect.setAttribute("y", String(data.y - bb.y - this.#borderWidth));
107
- rect.setAttribute("width", String(data.width));
108
- rect.setAttribute("height", String(data.height));
109
- rect.setAttribute("rx", String(radius));
110
- this.#clip.appendChild(rect);
128
+ path.setAttribute(
129
+ "d",
130
+ roundedRectPath({ x, y, width, height, radius })
131
+ );
132
+ this.#clip.appendChild(path);
133
+ }
134
+ /** Match the painted skeleton-item corner radius (on #content inside its shadow). */
135
+ #getClipRadius(child) {
136
+ const content = child.shadowRoot?.querySelector("#content");
137
+ const radiusStr = content !== void 0 && content !== null ? getComputedStyle(content).borderRadius.split(/\s+/)[0] ?? "0" : getCssVar(child, "--sinch-local-shape-radius") ?? "0";
138
+ return attrValueToInteger(radiusStr, {
139
+ min: 0,
140
+ defaultValue: 0
141
+ }) ?? 0;
111
142
  }
112
143
  }
113
144
  defineCustomElement("sinch-skeleton", Skeleton);