@poolse/react-ui 2.13.1 → 2.14.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/CHANGELOG.md CHANGED
@@ -4,6 +4,27 @@ All notable changes to `@poolse/react-ui` are documented here. Format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
5
  [semver](https://semver.org).
6
6
 
7
+ ## [2.14.0] — 2026-08-23
8
+
9
+ ### Fixed
10
+
11
+ - **A phone's video is no longer cropped to a sliver.** The spotlight
12
+ tile filled its box with `object-fit: cover`, so portrait video in a
13
+ landscape window was cropped to roughly the caller's nose. The
14
+ spotlight now letterboxes; fixed-ratio tiles still crop, where the
15
+ alternative is a grid of pillarboxed slivers. Set on the element
16
+ rather than left to host CSS — it is behaviour, not theme.
17
+
18
+ ### Added
19
+
20
+ - **`CallControlButton`** and **`CallDeviceMenu`** — round call controls
21
+ and a device picker, matching `@poolse/react-native`'s controls so the
22
+ two platforms read the same. Still no CSS: the host owns the look.
23
+ - **`CallVideoGrid`'s local preview is draggable**, snapping to the
24
+ nearest corner, with an `onLocalClick` prop for switching camera.
25
+ - New class hooks: `.callstage__pip--c0…c3`, `.callstage__pip--dragging`,
26
+ `.calldevices*`, `.callbtn__caret`, `.callbtn__wrap`.
27
+
7
28
  ## [2.13.1] — 2026-08-23
8
29
 
9
30
  Republished in lockstep with `@poolse/react-native@2.13.1`. No changes
package/dist/index.cjs CHANGED
@@ -289,7 +289,12 @@ function userColor(userId) {
289
289
  }
290
290
  return PALETTE[Math.abs(h) % PALETTE.length];
291
291
  }
292
- function CallVideoGrid({ participants, labelFor, className }) {
292
+ function CallVideoGrid({
293
+ participants,
294
+ labelFor,
295
+ className,
296
+ onLocalClick
297
+ }) {
293
298
  const label = labelFor ?? ((id) => `User ${id.slice(0, 6)}`);
294
299
  const self = participants.find((p) => p.isSelf) ?? null;
295
300
  const others = react.useMemo(() => participants.filter((p) => !p.isSelf), [participants]);
@@ -299,7 +304,7 @@ function CallVideoGrid({ participants, labelFor, className }) {
299
304
  if (!spotlight) return null;
300
305
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: className ?? "callstage callstage--solo", children: [
301
306
  /* @__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 }) })
307
+ self && others.length === 1 && /* @__PURE__ */ jsxRuntime.jsx(FloatingSelf, { onClick: onLocalClick, children: /* @__PURE__ */ jsxRuntime.jsx(CallVideoTile, { participant: self, label, hideName: true }) })
303
308
  ] });
304
309
  }
305
310
  const tiles = [...others, ...self ? [self] : []];
@@ -343,7 +348,24 @@ function CallVideoTile({
343
348
  autoPlay: true,
344
349
  playsInline: true,
345
350
  muted: participant.isSelf,
346
- style: participant.isSelf ? { transform: "scaleX(-1)" } : void 0
351
+ style: {
352
+ // `contain` for the spotlight, `cover` for everything else,
353
+ // and set here rather than left to host CSS because it is
354
+ // behaviour rather than theme.
355
+ //
356
+ // A phone publishes portrait video. Cropping that to fill a
357
+ // landscape browser window — which is what `cover` does —
358
+ // throws away most of the frame and lands somewhere around
359
+ // the caller's nose. Letterboxing shows the picture they
360
+ // are actually sending. Fixed-ratio tiles keep `cover`,
361
+ // where the crop is slight and the alternative is a grid
362
+ // full of pillarboxed slivers.
363
+ objectFit: bleed ? "contain" : "cover",
364
+ // Mirrored only for yourself — mirroring a remote feed would
365
+ // flip their text and reverse which hand they are waving
366
+ // with.
367
+ ...participant.isSelf ? { transform: "scaleX(-1)" } : {}
368
+ }
347
369
  }
348
370
  ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "callgrid__placeholder", children: /* @__PURE__ */ jsxRuntime.jsx(
349
371
  "span",
@@ -360,12 +382,171 @@ function CallVideoTile({
360
382
  ] })
361
383
  ] });
362
384
  }
385
+ function FloatingSelf({
386
+ children,
387
+ onClick
388
+ }) {
389
+ const ref = react.useRef(null);
390
+ const [corner, setCorner] = react.useState(1);
391
+ const [drag, setDrag] = react.useState(null);
392
+ const origin = react.useRef(null);
393
+ const moved = react.useRef(false);
394
+ const onPointerDown = react.useCallback((event) => {
395
+ origin.current = { x: event.clientX, y: event.clientY };
396
+ moved.current = false;
397
+ event.currentTarget.setPointerCapture(event.pointerId);
398
+ }, []);
399
+ const onPointerMove = react.useCallback((event) => {
400
+ const from = origin.current;
401
+ if (!from) return;
402
+ const dx = event.clientX - from.x;
403
+ const dy = event.clientY - from.y;
404
+ if (!moved.current && Math.abs(dx) < 4 && Math.abs(dy) < 4) return;
405
+ moved.current = true;
406
+ setDrag({ x: dx, y: dy });
407
+ }, []);
408
+ const onPointerUp = react.useCallback(
409
+ (event) => {
410
+ const from = origin.current;
411
+ origin.current = null;
412
+ setDrag(null);
413
+ if (!moved.current) {
414
+ onClick?.();
415
+ return;
416
+ }
417
+ if (!from) return;
418
+ const stage = ref.current?.parentElement?.getBoundingClientRect();
419
+ if (!stage) return;
420
+ const right = event.clientX > stage.left + stage.width / 2;
421
+ const bottom = event.clientY > stage.top + stage.height / 2;
422
+ setCorner((bottom ? 2 : 0) + (right ? 1 : 0));
423
+ },
424
+ [onClick]
425
+ );
426
+ return /* @__PURE__ */ jsxRuntime.jsx(
427
+ "div",
428
+ {
429
+ ref,
430
+ className: `callstage__pip callstage__pip--c${corner}${drag ? " callstage__pip--dragging" : ""}`,
431
+ style: drag ? { transform: `translate(${drag.x}px, ${drag.y}px)` } : void 0,
432
+ onPointerDown,
433
+ onPointerMove,
434
+ onPointerUp,
435
+ onPointerCancel: onPointerUp,
436
+ role: onClick ? "button" : void 0,
437
+ "aria-label": onClick ? "Your camera. Drag to move, click to switch camera." : void 0,
438
+ children
439
+ }
440
+ );
441
+ }
363
442
  function initialsOf(name) {
364
443
  const parts = name.trim().split(/\s+/).filter(Boolean);
365
444
  if (parts.length === 0) return "?";
366
445
  if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
367
446
  return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
368
447
  }
448
+ function CallControlButton({
449
+ icon,
450
+ label,
451
+ onClick,
452
+ active = false,
453
+ tone = "neutral",
454
+ large = false,
455
+ disabled = false,
456
+ hasMenu = false,
457
+ onMenuClick
458
+ }) {
459
+ const classes = [
460
+ "callbtn",
461
+ tone !== "neutral" ? `callbtn--${tone}` : "",
462
+ active ? "callbtn--active" : "",
463
+ large ? "callbtn--large" : ""
464
+ ].filter(Boolean).join(" ");
465
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callbtn__slot", children: [
466
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "callbtn__wrap", children: [
467
+ /* @__PURE__ */ jsxRuntime.jsx(
468
+ "button",
469
+ {
470
+ type: "button",
471
+ className: classes,
472
+ onClick,
473
+ disabled,
474
+ "aria-pressed": tone === "neutral" ? active : void 0,
475
+ "aria-label": label,
476
+ children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: icon, size: large ? 26 : 22, label: null })
477
+ }
478
+ ),
479
+ hasMenu && // A separate hit target, not a long-press: the toggle and the
480
+ // device list are different actions, and hiding one inside a
481
+ // timed gesture on the other is how people end up muting
482
+ // themselves while trying to change microphone.
483
+ /* @__PURE__ */ jsxRuntime.jsx(
484
+ "button",
485
+ {
486
+ type: "button",
487
+ className: "callbtn__caret",
488
+ onClick: onMenuClick,
489
+ "aria-label": `${label} options`,
490
+ children: /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "chevron-up", size: 13, label: null })
491
+ }
492
+ )
493
+ ] }),
494
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "callbtn__label", children: label })
495
+ ] });
496
+ }
497
+ function CallDeviceMenu({
498
+ title,
499
+ devices,
500
+ activeId,
501
+ onSelect,
502
+ onClose
503
+ }) {
504
+ const ref = react.useRef(null);
505
+ react.useEffect(() => {
506
+ const onDown = (event) => {
507
+ if (!ref.current?.contains(event.target)) onClose();
508
+ };
509
+ const onKey = (event) => {
510
+ if (event.key === "Escape") onClose();
511
+ };
512
+ document.addEventListener("mousedown", onDown);
513
+ document.addEventListener("keydown", onKey);
514
+ return () => {
515
+ document.removeEventListener("mousedown", onDown);
516
+ document.removeEventListener("keydown", onKey);
517
+ };
518
+ }, [onClose]);
519
+ if (devices.length === 0) return null;
520
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "calldevices", ref, role: "menu", "aria-label": title, children: [
521
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "calldevices__title", children: title }),
522
+ devices.map((device, index) => {
523
+ const selected = device.deviceId === activeId;
524
+ return /* @__PURE__ */ jsxRuntime.jsxs(
525
+ "button",
526
+ {
527
+ type: "button",
528
+ role: "menuitemradio",
529
+ "aria-checked": selected,
530
+ className: `calldevices__row${selected ? " calldevices__row--on" : ""}`,
531
+ onClick: () => {
532
+ onSelect(device.kind, device.deviceId);
533
+ onClose();
534
+ },
535
+ children: [
536
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "calldevices__name", children: device.label || `${kindLabel(device.kind)} ${index + 1}` }),
537
+ selected && /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: "check", size: 16, label: "selected" })
538
+ ]
539
+ },
540
+ device.deviceId || `${device.kind}-${index}`
541
+ );
542
+ })
543
+ ] });
544
+ }
545
+ function kindLabel(kind) {
546
+ if (kind === "videoinput") return "Camera";
547
+ if (kind === "audioinput") return "Microphone";
548
+ return "Output";
549
+ }
369
550
  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
551
  var FONT_HREF_PRECONNECT_GOOGLE = "https://fonts.googleapis.com";
371
552
  var FONT_HREF_PRECONNECT_STATIC = "https://fonts.gstatic.com";
@@ -3133,6 +3314,8 @@ function PoolseLogo({
3133
3314
 
3134
3315
  exports.AttachmentPreview = AttachmentPreview;
3135
3316
  exports.Avatar = Avatar;
3317
+ exports.CallControlButton = CallControlButton;
3318
+ exports.CallDeviceMenu = CallDeviceMenu;
3136
3319
  exports.CallVideoGrid = CallVideoGrid;
3137
3320
  exports.ChatHeader = ChatHeader;
3138
3321
  exports.ConversationList = ConversationList;