@poolse/react-ui 2.12.1 → 2.13.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.
package/dist/index.cjs CHANGED
@@ -13,112 +13,6 @@ var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
13
13
  var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
14
14
 
15
15
  // src/CallVideoGrid.tsx
16
- function CallVideoGrid({ participants, labelFor, className }) {
17
- const label = labelFor ?? ((id) => `User ${id.slice(0, 6)}`);
18
- if (participants.length === 0) return null;
19
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: className ?? "callgrid", children: participants.map((participant) => /* @__PURE__ */ jsxRuntime.jsx(CallVideoTile, { participant, label }, participant.userId)) });
20
- }
21
- function CallVideoTile({
22
- participant,
23
- label
24
- }) {
25
- const ref = react.useRef(null);
26
- const track = participant.videoTrack;
27
- react.useEffect(() => {
28
- const element = ref.current;
29
- if (!element || !track) return;
30
- track.attach(element);
31
- return () => {
32
- track.detach(element);
33
- };
34
- }, [track]);
35
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `callgrid__tile${participant.speaking ? " callgrid__tile--speaking" : ""}`, children: [
36
- track ? /* @__PURE__ */ jsxRuntime.jsx(
37
- "video",
38
- {
39
- ref,
40
- className: "callgrid__video",
41
- autoPlay: true,
42
- playsInline: true,
43
- muted: participant.isSelf,
44
- style: participant.isSelf ? { transform: "scaleX(-1)" } : void 0
45
- }
46
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "callgrid__placeholder", "aria-hidden": "true", children: label(participant.userId).slice(0, 1).toUpperCase() }),
47
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "callgrid__caption", children: [
48
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "callgrid__name", children: participant.isSelf ? "You" : participant.name ?? label(participant.userId) }),
49
- !participant.micEnabled && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "callgrid__muted", children: "muted" })
50
- ] })
51
- ] });
52
- }
53
- var FONT_HREF = "https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,800&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap";
54
- var FONT_HREF_PRECONNECT_GOOGLE = "https://fonts.googleapis.com";
55
- var FONT_HREF_PRECONNECT_STATIC = "https://fonts.gstatic.com";
56
- var MARKER_ATTR = "data-poolse-fonts";
57
- function injectFontLinks() {
58
- if (typeof document === "undefined") return;
59
- if (document.querySelector(`link[${MARKER_ATTR}]`)) return;
60
- const head = document.head;
61
- const pre1 = document.createElement("link");
62
- pre1.rel = "preconnect";
63
- pre1.href = FONT_HREF_PRECONNECT_GOOGLE;
64
- pre1.setAttribute(MARKER_ATTR, "preconnect");
65
- head.appendChild(pre1);
66
- const pre2 = document.createElement("link");
67
- pre2.rel = "preconnect";
68
- pre2.href = FONT_HREF_PRECONNECT_STATIC;
69
- pre2.crossOrigin = "anonymous";
70
- pre2.setAttribute(MARKER_ATTR, "preconnect");
71
- head.appendChild(pre2);
72
- const font = document.createElement("link");
73
- font.rel = "stylesheet";
74
- font.href = FONT_HREF;
75
- font.setAttribute(MARKER_ATTR, "stylesheet");
76
- head.appendChild(font);
77
- }
78
- function usePoolseFonts(enabled = true) {
79
- react.useEffect(() => {
80
- if (!enabled) return;
81
- injectFontLinks();
82
- }, [enabled]);
83
- }
84
- function PoolseFonts() {
85
- usePoolseFonts(true);
86
- return null;
87
- }
88
-
89
- // src/listAutocomplete.ts
90
- var UNORDERED_RE = /^(\s*)([-*+]) (.*)$/;
91
- var ORDERED_RE = /^(\s*)(\d+)\. (.*)$/;
92
- function handleListEnter(value, caret) {
93
- const lineStart = value.lastIndexOf("\n", caret - 1) + 1;
94
- const lineEnd = (() => {
95
- const nl = value.indexOf("\n", caret);
96
- return nl === -1 ? value.length : nl;
97
- })();
98
- const currentLine = value.slice(lineStart, lineEnd);
99
- const unordered = UNORDERED_RE.exec(currentLine);
100
- const ordered = ORDERED_RE.exec(currentLine);
101
- const match = unordered ?? ordered;
102
- if (!match) return null;
103
- const indent = match[1] ?? "";
104
- const marker = match[2] ?? "";
105
- const content = match[3] ?? "";
106
- if (content === "") {
107
- const before2 = value.slice(0, lineStart);
108
- const after2 = value.slice(lineEnd);
109
- return { kind: "end", value: before2 + after2, caret: lineStart };
110
- }
111
- const nextMarker = ordered ? `${parseInt(marker, 10) + 1}.` : marker;
112
- const prefix = `
113
- ${indent}${nextMarker} `;
114
- const before = value.slice(0, caret);
115
- const after = value.slice(caret);
116
- return {
117
- kind: "continue",
118
- value: before + prefix + after,
119
- caret: caret + prefix.length
120
- };
121
- }
122
16
 
123
17
  // src/icons-data.ts
124
18
  var ICONS = {
@@ -130,6 +24,14 @@ var ICONS = {
130
24
  vb: "0 0 24 24",
131
25
  d: '<path d="M6 9.2a6 6 0 0 1 12 0c0 4.8 1.4 6.3 1.9 6.8H4.1C4.6 15.5 6 14 6 9.2Z"/><path d="M9.6 19.8a2.5 2.5 0 0 0 4.8 0"/>'
132
26
  },
27
+ bluetooth: {
28
+ vb: "0 0 24 24",
29
+ d: '<path d="M7.5 7.5 16.5 16.5 12 21V3l4.5 4.5L7.5 16.5"/>'
30
+ },
31
+ "camera-flip": {
32
+ vb: "0 0 24 24",
33
+ d: '<path d="M3 8.5a2 2 0 0 1 2-2h2.4l1.4-2h6.4l1.4 2H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-9Z"/><path d="M14.6 13a2.6 2.6 0 0 1-4.5 1.8"/><path d="M9.4 13a2.6 2.6 0 0 1 4.5-1.8"/><path d="M13.9 9.6v1.7h-1.7"/><path d="M10.1 16.4v-1.7h1.7"/>'
34
+ },
133
35
  "check-double": {
134
36
  vb: "0 0 24 24",
135
37
  d: '<path d="M2.5 12.8 6.9 17 15.4 7.6"/><path d="M11.4 16.4 12.3 17.2 21 7.6"/>'
@@ -146,6 +48,10 @@ var ICONS = {
146
48
  vb: "0 0 24 24",
147
49
  d: '<path d="M9 5 16 12 9 19"/>'
148
50
  },
51
+ "chevron-up": {
52
+ vb: "0 0 24 24",
53
+ d: '<path d="M6 14.5 12 8.5 18 14.5"/>'
54
+ },
149
55
  close: {
150
56
  vb: "0 0 24 24",
151
57
  d: '<path d="M6 6 18 18M18 6 6 18"/>'
@@ -174,6 +80,10 @@ var ICONS = {
174
80
  vb: "0 0 24 24",
175
81
  d: '<circle cx="12" cy="12" r="8.6"/><circle cx="9" cy="10" r="1" fill="currentColor" stroke="none"/><circle cx="15" cy="10" r="1" fill="currentColor" stroke="none"/><path d="M8.4 14.2a4.6 4.6 0 0 0 7.2 0"/>'
176
82
  },
83
+ headphones: {
84
+ vb: "0 0 24 24",
85
+ d: '<path d="M4 14v-2a8 8 0 0 1 16 0v2"/><path d="M4 14h2.6a1.4 1.4 0 0 1 1.4 1.4v3.2A1.4 1.4 0 0 1 6.6 20H5.4A1.4 1.4 0 0 1 4 18.6Z"/><path d="M20 14h-2.6a1.4 1.4 0 0 0-1.4 1.4v3.2A1.4 1.4 0 0 0 17.4 20h1.2A1.4 1.4 0 0 0 20 18.6Z"/>'
86
+ },
177
87
  heart: {
178
88
  vb: "0 0 24 24",
179
89
  d: '<path d="M12 20.3 4.4 12.9a4.6 4.6 0 1 1 6.5-6.5l1.1 1.1 1.1-1.1a4.6 4.6 0 1 1 6.5 6.5L12 20.3Z"/>'
@@ -210,6 +120,10 @@ var ICONS = {
210
120
  vb: "0 0 24 24",
211
121
  d: '<rect x="9" y="2.6" width="6" height="11.2" rx="3"/><path d="M5.6 11.2a6.4 6.4 0 0 0 12.8 0"/><path d="M12 17.6v3.4"/><path d="M8.6 21h6.8"/>'
212
122
  },
123
+ "mic-off": {
124
+ vb: "0 0 24 24",
125
+ d: '<rect x="9" y="2.6" width="6" height="11.2" rx="3"/><path d="M5.6 11.2a6.4 6.4 0 0 0 12.8 0"/><path d="M12 17.6v3.4"/><path d="M8.6 21h6.8"/><path d="M3.6 3.2 20.4 20.8"/>'
126
+ },
213
127
  "more-h": {
214
128
  vb: "0 0 24 24",
215
129
  d: '<circle cx="5.4" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="18.6" cy="12" r="1.6" fill="currentColor" stroke="none"/>'
@@ -218,6 +132,14 @@ var ICONS = {
218
132
  vb: "0 0 24 24",
219
133
  d: '<circle cx="12" cy="5.4" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.6" fill="currentColor" stroke="none"/><circle cx="12" cy="18.6" r="1.6" fill="currentColor" stroke="none"/>'
220
134
  },
135
+ phone: {
136
+ vb: "0 0 24 24",
137
+ d: '<path d="M6.6 3.5h3l1.5 3.7-1.9 1.4a12.5 12.5 0 0 0 6.2 6.2l1.4-1.9 3.7 1.5v3a2 2 0 0 1-2.2 2A16.8 16.8 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2Z"/>'
138
+ },
139
+ "phone-off": {
140
+ vb: "0 0 24 24",
141
+ d: '<g transform="rotate(135 12 12)"><path d="M6.6 3.5h3l1.5 3.7-1.9 1.4a12.5 12.5 0 0 0 6.2 6.2l1.4-1.9 3.7 1.5v3a2 2 0 0 1-2.2 2A16.8 16.8 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2Z"/></g>'
142
+ },
221
143
  pin: {
222
144
  vb: "0 0 24 24",
223
145
  d: '<path d="M9 3.4h6v1.8l-1 5.6 3 3.2H7l3-3.2-1-5.6V3.4Z"/><path d="M12 17v3.6"/>'
@@ -258,6 +180,14 @@ var ICONS = {
258
180
  vb: "0 0 24 24",
259
181
  d: '<path d="M4 7h9M17 7h3"/><circle cx="15" cy="7" r="2.1"/><path d="M4 17h3M11 17h9"/><circle cx="9" cy="17" r="2.1"/>'
260
182
  },
183
+ speaker: {
184
+ vb: "0 0 24 24",
185
+ d: '<path d="M4 9.5h3.2L12 5.4v13.2L7.2 14.5H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1Z"/><path d="M15.6 9.2a4 4 0 0 1 0 5.6"/><path d="M18.2 6.6a7.7 7.7 0 0 1 0 10.8"/>'
186
+ },
187
+ "speaker-off": {
188
+ vb: "0 0 24 24",
189
+ d: '<path d="M4 9.5h3.2L12 5.4v13.2L7.2 14.5H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1Z"/><path d="M16.4 9.6 21.4 14.4"/><path d="M21.4 9.6 16.4 14.4"/>'
190
+ },
261
191
  "thumbs-up": {
262
192
  vb: "0 0 24 24",
263
193
  d: '<path d="M7 10.4V20H4.2V10.4Z"/><path d="M7 10.4 11 3.2a2 2 0 0 1 1.9 2.2L12.4 9H18a2 2 0 0 1 2 2.4l-1.1 6A2 2 0 0 1 16.9 20H7"/>'
@@ -282,6 +212,14 @@ var ICONS = {
282
212
  vb: "0 0 24 24",
283
213
  d: '<circle cx="9" cy="8" r="3.6"/><path d="M2.6 20a6.4 6.4 0 0 1 12.8 0"/><path d="M15.8 4.7a3.6 3.6 0 0 1 0 6.6"/><path d="M17.6 20a6.4 6.4 0 0 0-3.1-5.5"/>'
284
214
  },
215
+ video: {
216
+ vb: "0 0 24 24",
217
+ d: '<rect x="2.6" y="6" width="13" height="12" rx="2.4"/><path d="M15.6 11.2 21.4 8v8l-5.8-3.2Z"/>'
218
+ },
219
+ "video-off": {
220
+ vb: "0 0 24 24",
221
+ d: '<rect x="2.6" y="6" width="13" height="12" rx="2.4"/><path d="M15.6 11.2 21.4 8v8l-5.8-3.2Z"/><path d="M3.6 3.2 20.4 20.8"/>'
222
+ },
285
223
  webhook: {
286
224
  vb: "0 0 24 24",
287
225
  d: '<circle cx="6" cy="6" r="2.6"/><circle cx="18" cy="9" r="2.6"/><circle cx="9.5" cy="18" r="2.6"/><path d="M7.9 7.9 12 12l3.7-1.5"/><path d="M11.6 12.7 9.8 16"/>'
@@ -324,6 +262,179 @@ function PoolseIcon({
324
262
  }
325
263
  );
326
264
  }
265
+
266
+ // src/userColor.ts
267
+ var PALETTE = [
268
+ "#6366f1",
269
+ // indigo
270
+ "#10b981",
271
+ // emerald
272
+ "#f59e0b",
273
+ // amber
274
+ "#ec4899",
275
+ // rose
276
+ "#0ea5e9",
277
+ // sky
278
+ "#8b5cf6",
279
+ // violet
280
+ "#14b8a6",
281
+ // teal
282
+ "#d946ef"
283
+ // fuchsia
284
+ ];
285
+ function userColor(userId) {
286
+ let h = 0;
287
+ for (let i = 0; i < userId.length; i++) {
288
+ h = h * 31 + userId.charCodeAt(i) | 0;
289
+ }
290
+ return PALETTE[Math.abs(h) % PALETTE.length];
291
+ }
292
+ function CallVideoGrid({ participants, labelFor, className }) {
293
+ const label = labelFor ?? ((id) => `User ${id.slice(0, 6)}`);
294
+ const self = participants.find((p) => p.isSelf) ?? null;
295
+ const others = react.useMemo(() => participants.filter((p) => !p.isSelf), [participants]);
296
+ if (participants.length === 0) return null;
297
+ if (others.length <= 1) {
298
+ const spotlight = others[0] ?? self;
299
+ if (!spotlight) return null;
300
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: className ?? "callstage callstage--solo", children: [
301
+ /* @__PURE__ */ jsxRuntime.jsx(CallVideoTile, { participant: spotlight, label, bleed: true }),
302
+ self && others.length === 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "callstage__pip", children: /* @__PURE__ */ jsxRuntime.jsx(CallVideoTile, { participant: self, label, hideName: true }) })
303
+ ] });
304
+ }
305
+ const tiles = [...others, ...self ? [self] : []];
306
+ return /* @__PURE__ */ jsxRuntime.jsx(
307
+ "div",
308
+ {
309
+ className: className ?? "callgrid",
310
+ "data-count": tiles.length > 6 ? "many" : String(tiles.length),
311
+ children: tiles.map((participant) => /* @__PURE__ */ jsxRuntime.jsx(CallVideoTile, { participant, label }, participant.userId))
312
+ }
313
+ );
314
+ }
315
+ function CallVideoTile({
316
+ participant,
317
+ label,
318
+ bleed = false,
319
+ hideName = false
320
+ }) {
321
+ const ref = react.useRef(null);
322
+ const track = participant.videoTrack;
323
+ const name = participant.isSelf ? "You" : participant.name ?? label(participant.userId);
324
+ react.useEffect(() => {
325
+ const element = ref.current;
326
+ if (!element || !track) return;
327
+ track.attach(element);
328
+ return () => {
329
+ track.detach(element);
330
+ };
331
+ }, [track]);
332
+ const classes = [
333
+ "callgrid__tile",
334
+ bleed ? "callgrid__tile--bleed" : "",
335
+ participant.speaking ? "callgrid__tile--speaking" : ""
336
+ ].filter(Boolean).join(" ");
337
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes, children: [
338
+ track ? /* @__PURE__ */ jsxRuntime.jsx(
339
+ "video",
340
+ {
341
+ ref,
342
+ className: "callgrid__video",
343
+ autoPlay: true,
344
+ playsInline: true,
345
+ muted: participant.isSelf,
346
+ style: participant.isSelf ? { transform: "scaleX(-1)" } : void 0
347
+ }
348
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "callgrid__placeholder", children: /* @__PURE__ */ jsxRuntime.jsx(
349
+ "span",
350
+ {
351
+ className: "callgrid__avatar",
352
+ style: { background: userColor(participant.userId) },
353
+ "aria-hidden": "true",
354
+ children: initialsOf(name)
355
+ }
356
+ ) }),
357
+ !hideName && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "callgrid__caption", children: [
358
+ !participant.micEnabled && /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "mic-off", size: 13, label: "muted", className: "callgrid__mutedicon" }),
359
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "callgrid__name", children: name })
360
+ ] })
361
+ ] });
362
+ }
363
+ function initialsOf(name) {
364
+ const parts = name.trim().split(/\s+/).filter(Boolean);
365
+ if (parts.length === 0) return "?";
366
+ if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
367
+ return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
368
+ }
369
+ var FONT_HREF = "https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,800&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap";
370
+ var FONT_HREF_PRECONNECT_GOOGLE = "https://fonts.googleapis.com";
371
+ var FONT_HREF_PRECONNECT_STATIC = "https://fonts.gstatic.com";
372
+ var MARKER_ATTR = "data-poolse-fonts";
373
+ function injectFontLinks() {
374
+ if (typeof document === "undefined") return;
375
+ if (document.querySelector(`link[${MARKER_ATTR}]`)) return;
376
+ const head = document.head;
377
+ const pre1 = document.createElement("link");
378
+ pre1.rel = "preconnect";
379
+ pre1.href = FONT_HREF_PRECONNECT_GOOGLE;
380
+ pre1.setAttribute(MARKER_ATTR, "preconnect");
381
+ head.appendChild(pre1);
382
+ const pre2 = document.createElement("link");
383
+ pre2.rel = "preconnect";
384
+ pre2.href = FONT_HREF_PRECONNECT_STATIC;
385
+ pre2.crossOrigin = "anonymous";
386
+ pre2.setAttribute(MARKER_ATTR, "preconnect");
387
+ head.appendChild(pre2);
388
+ const font = document.createElement("link");
389
+ font.rel = "stylesheet";
390
+ font.href = FONT_HREF;
391
+ font.setAttribute(MARKER_ATTR, "stylesheet");
392
+ head.appendChild(font);
393
+ }
394
+ function usePoolseFonts(enabled = true) {
395
+ react.useEffect(() => {
396
+ if (!enabled) return;
397
+ injectFontLinks();
398
+ }, [enabled]);
399
+ }
400
+ function PoolseFonts() {
401
+ usePoolseFonts(true);
402
+ return null;
403
+ }
404
+
405
+ // src/listAutocomplete.ts
406
+ var UNORDERED_RE = /^(\s*)([-*+]) (.*)$/;
407
+ var ORDERED_RE = /^(\s*)(\d+)\. (.*)$/;
408
+ function handleListEnter(value, caret) {
409
+ const lineStart = value.lastIndexOf("\n", caret - 1) + 1;
410
+ const lineEnd = (() => {
411
+ const nl = value.indexOf("\n", caret);
412
+ return nl === -1 ? value.length : nl;
413
+ })();
414
+ const currentLine = value.slice(lineStart, lineEnd);
415
+ const unordered = UNORDERED_RE.exec(currentLine);
416
+ const ordered = ORDERED_RE.exec(currentLine);
417
+ const match = unordered ?? ordered;
418
+ if (!match) return null;
419
+ const indent = match[1] ?? "";
420
+ const marker = match[2] ?? "";
421
+ const content = match[3] ?? "";
422
+ if (content === "") {
423
+ const before2 = value.slice(0, lineStart);
424
+ const after2 = value.slice(lineEnd);
425
+ return { kind: "end", value: before2 + after2, caret: lineStart };
426
+ }
427
+ const nextMarker = ordered ? `${parseInt(marker, 10) + 1}.` : marker;
428
+ const prefix = `
429
+ ${indent}${nextMarker} `;
430
+ const before = value.slice(0, caret);
431
+ const after = value.slice(caret);
432
+ return {
433
+ kind: "continue",
434
+ value: before + prefix + after,
435
+ caret: caret + prefix.length
436
+ };
437
+ }
327
438
  function UploadQueueStrip({ items, onCancel, onDismiss }) {
328
439
  if (items.length === 0) return null;
329
440
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-upload-strip", role: "status", "aria-live": "polite", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -1079,33 +1190,6 @@ function formatBytes(n) {
1079
1190
  if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
1080
1191
  return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
1081
1192
  }
1082
-
1083
- // src/userColor.ts
1084
- var PALETTE = [
1085
- "#6366f1",
1086
- // indigo
1087
- "#10b981",
1088
- // emerald
1089
- "#f59e0b",
1090
- // amber
1091
- "#ec4899",
1092
- // rose
1093
- "#0ea5e9",
1094
- // sky
1095
- "#8b5cf6",
1096
- // violet
1097
- "#14b8a6",
1098
- // teal
1099
- "#d946ef"
1100
- // fuchsia
1101
- ];
1102
- function userColor(userId) {
1103
- let h = 0;
1104
- for (let i = 0; i < userId.length; i++) {
1105
- h = h * 31 + userId.charCodeAt(i) | 0;
1106
- }
1107
- return PALETTE[Math.abs(h) % PALETTE.length];
1108
- }
1109
1193
  function MessageBubble({
1110
1194
  message,
1111
1195
  currentUserId,