@flamingo-stack/openframe-frontend-core 0.0.455 → 0.0.456-snapshot.20260720115226

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.
Files changed (157) hide show
  1. package/dist/{chunk-6W4ZEVIC.js → chunk-2ZW2ZPDW.js} +3 -3
  2. package/dist/{chunk-XAQLBUCP.js → chunk-4423DHRX.js} +2 -2
  3. package/dist/{chunk-5YPKZM6Y.js → chunk-5BKBG653.js} +6 -6
  4. package/dist/{chunk-YSKSBLCG.cjs → chunk-5XFJG3TC.cjs} +73 -73
  5. package/dist/{chunk-YSKSBLCG.cjs.map → chunk-5XFJG3TC.cjs.map} +1 -1
  6. package/dist/{chunk-RT7DIGTN.cjs → chunk-6TI3DCOG.cjs} +3 -3
  7. package/dist/{chunk-RT7DIGTN.cjs.map → chunk-6TI3DCOG.cjs.map} +1 -1
  8. package/dist/{chunk-M5RT26WQ.cjs → chunk-AB65PWU2.cjs} +73 -73
  9. package/dist/{chunk-M5RT26WQ.cjs.map → chunk-AB65PWU2.cjs.map} +1 -1
  10. package/dist/{chunk-DGPKGESY.js → chunk-AJGZ3YSR.js} +4 -4
  11. package/dist/{chunk-FCVF4YAB.cjs → chunk-BDTQIIJR.cjs} +40 -40
  12. package/dist/{chunk-FCVF4YAB.cjs.map → chunk-BDTQIIJR.cjs.map} +1 -1
  13. package/dist/{chunk-BE77G7GW.cjs → chunk-C2TDHJBO.cjs} +40 -40
  14. package/dist/{chunk-BE77G7GW.cjs.map → chunk-C2TDHJBO.cjs.map} +1 -1
  15. package/dist/{chunk-XT6S6DYS.cjs → chunk-CCT5VCRP.cjs} +12 -12
  16. package/dist/{chunk-XT6S6DYS.cjs.map → chunk-CCT5VCRP.cjs.map} +1 -1
  17. package/dist/{chunk-NNDNJCJ3.cjs → chunk-EOVQVVDJ.cjs} +18 -18
  18. package/dist/{chunk-NNDNJCJ3.cjs.map → chunk-EOVQVVDJ.cjs.map} +1 -1
  19. package/dist/{chunk-62AXZKYN.cjs → chunk-FM5DTJPA.cjs} +1753 -1376
  20. package/dist/chunk-FM5DTJPA.cjs.map +1 -0
  21. package/dist/{chunk-YXCYQKAX.js → chunk-GJ7BN4MI.js} +5 -5
  22. package/dist/{chunk-VNE5R4LQ.js → chunk-I7M6KCCS.js} +5 -5
  23. package/dist/{chunk-X62ICFPJ.js → chunk-ILUX3DXS.js} +2 -2
  24. package/dist/{chunk-KTGGM5WA.cjs → chunk-IOHQJOLR.cjs} +36 -12
  25. package/dist/chunk-IOHQJOLR.cjs.map +1 -0
  26. package/dist/{chunk-GNYV6HYO.cjs → chunk-KQ36EHE4.cjs} +15 -15
  27. package/dist/{chunk-GNYV6HYO.cjs.map → chunk-KQ36EHE4.cjs.map} +1 -1
  28. package/dist/{chunk-QSIZW6EX.js → chunk-KXIIUE75.js} +2 -2
  29. package/dist/{chunk-BD3JBEUC.js → chunk-MK2YWJAA.js} +64 -40
  30. package/dist/chunk-MK2YWJAA.js.map +1 -0
  31. package/dist/{chunk-N4CHA7T7.js → chunk-NSL5MNS4.js} +5210 -4833
  32. package/dist/chunk-NSL5MNS4.js.map +1 -0
  33. package/dist/{chunk-LB3OZE4B.js → chunk-O7F7RZFN.js} +6 -6
  34. package/dist/{chunk-JUUPMMKI.js → chunk-R5IQJXA3.js} +3 -3
  35. package/dist/{chunk-EGTGRG7N.js → chunk-RSW42GTZ.js} +2 -2
  36. package/dist/{chunk-RZL7I6YN.cjs → chunk-SQ3CP2IV.cjs} +7 -7
  37. package/dist/{chunk-RZL7I6YN.cjs.map → chunk-SQ3CP2IV.cjs.map} +1 -1
  38. package/dist/{chunk-D5PBUVGB.cjs → chunk-U4APSAAR.cjs} +5 -5
  39. package/dist/{chunk-D5PBUVGB.cjs.map → chunk-U4APSAAR.cjs.map} +1 -1
  40. package/dist/{chunk-2KUIA2AR.js → chunk-WXDEMTLD.js} +3 -3
  41. package/dist/{chunk-IDCPYG7N.cjs → chunk-YCIVMKRS.cjs} +29 -29
  42. package/dist/{chunk-IDCPYG7N.cjs.map → chunk-YCIVMKRS.cjs.map} +1 -1
  43. package/dist/{chunk-UJZ6O2ON.cjs → chunk-YHB4MNUX.cjs} +32 -32
  44. package/dist/{chunk-UJZ6O2ON.cjs.map → chunk-YHB4MNUX.cjs.map} +1 -1
  45. package/dist/components/case-studies/index.cjs +9 -9
  46. package/dist/components/case-studies/index.js +3 -3
  47. package/dist/components/chat/chat-message-list.d.ts.map +1 -1
  48. package/dist/components/chat/chat-sidebar.d.ts.map +1 -1
  49. package/dist/components/chat/chat-ticket-list.d.ts.map +1 -1
  50. package/dist/components/chat/guide-welcome.d.ts.map +1 -1
  51. package/dist/components/chat/index.cjs +3 -3
  52. package/dist/components/chat/index.js +2 -2
  53. package/dist/components/chat/mingo-chat-history.d.ts.map +1 -1
  54. package/dist/components/chat/mingo-welcome.d.ts.map +1 -1
  55. package/dist/components/chat/quick-action-wall.d.ts +5 -1
  56. package/dist/components/chat/quick-action-wall.d.ts.map +1 -1
  57. package/dist/components/chat/types/component.types.d.ts +17 -0
  58. package/dist/components/chat/types/component.types.d.ts.map +1 -1
  59. package/dist/components/contact/index.cjs +4 -4
  60. package/dist/components/contact/index.js +3 -3
  61. package/dist/components/docs/index.cjs +6 -6
  62. package/dist/components/docs/index.js +5 -5
  63. package/dist/components/embeds/index.cjs +4 -4
  64. package/dist/components/embeds/index.js +3 -3
  65. package/dist/components/faq/index.cjs +5 -5
  66. package/dist/components/faq/index.js +4 -4
  67. package/dist/components/features/cards-strip.d.ts.map +1 -1
  68. package/dist/components/features/index.cjs +3 -3
  69. package/dist/components/features/index.js +2 -2
  70. package/dist/components/features/notifications/notification-drawer.d.ts.map +1 -1
  71. package/dist/components/features/time-tracker/time-tracker-panel.d.ts.map +1 -1
  72. package/dist/components/help-center-pages/index.cjs +22 -22
  73. package/dist/components/help-center-pages/index.js +13 -13
  74. package/dist/components/index.cjs +141 -135
  75. package/dist/components/index.cjs.map +1 -1
  76. package/dist/components/index.js +17 -11
  77. package/dist/components/index.js.map +1 -1
  78. package/dist/components/layout/page-container.d.ts.map +1 -1
  79. package/dist/components/navigation/app-layout-drawer.d.ts +1 -1
  80. package/dist/components/navigation/index.cjs +3 -3
  81. package/dist/components/navigation/index.js +2 -2
  82. package/dist/components/onboarding-guides/index.cjs +7 -7
  83. package/dist/components/onboarding-guides/index.js +6 -6
  84. package/dist/components/related-content/index.cjs +5 -5
  85. package/dist/components/related-content/index.js +4 -4
  86. package/dist/components/tickets/index.cjs +6 -6
  87. package/dist/components/tickets/index.js +5 -5
  88. package/dist/components/ui/drawer.d.ts +1 -1
  89. package/dist/components/ui/drawer.d.ts.map +1 -1
  90. package/dist/components/ui/index.cjs +9 -3
  91. package/dist/components/ui/index.cjs.map +1 -1
  92. package/dist/components/ui/index.d.ts +1 -0
  93. package/dist/components/ui/index.d.ts.map +1 -1
  94. package/dist/components/ui/index.js +8 -2
  95. package/dist/components/ui/marquee-wall.d.ts +8 -1
  96. package/dist/components/ui/marquee-wall.d.ts.map +1 -1
  97. package/dist/components/ui/menubar.d.ts +3 -6
  98. package/dist/components/ui/menubar.d.ts.map +1 -1
  99. package/dist/components/ui/modal-v2.d.ts.map +1 -1
  100. package/dist/components/ui/modal.d.ts.map +1 -1
  101. package/dist/components/ui/overlay-scroll-area.d.ts +59 -0
  102. package/dist/components/ui/overlay-scroll-area.d.ts.map +1 -0
  103. package/dist/hooks/index.cjs +4 -2
  104. package/dist/hooks/index.cjs.map +1 -1
  105. package/dist/hooks/index.js +3 -1
  106. package/dist/hooks/ui/index.d.ts +1 -0
  107. package/dist/hooks/ui/index.d.ts.map +1 -1
  108. package/dist/hooks/ui/use-reset-on-page-hidden.d.ts +19 -0
  109. package/dist/hooks/ui/use-reset-on-page-hidden.d.ts.map +1 -0
  110. package/dist/hooks/use-near-viewport.d.ts +3 -1
  111. package/dist/hooks/use-near-viewport.d.ts.map +1 -1
  112. package/dist/index.cjs +11 -3
  113. package/dist/index.cjs.map +1 -1
  114. package/dist/index.js +10 -2
  115. package/package.json +3 -1
  116. package/src/components/chat/chat-message-list.tsx +54 -10
  117. package/src/components/chat/chat-sidebar.tsx +9 -4
  118. package/src/components/chat/chat-ticket-list.tsx +8 -2
  119. package/src/components/chat/embeddable-chat.tsx +31 -3
  120. package/src/components/chat/guide-welcome.tsx +7 -4
  121. package/src/components/chat/mingo-chat-history.tsx +6 -4
  122. package/src/components/chat/mingo-welcome.tsx +7 -4
  123. package/src/components/chat/quick-action-wall.tsx +7 -0
  124. package/src/components/chat/types/component.types.ts +17 -0
  125. package/src/components/features/cards-strip.tsx +16 -0
  126. package/src/components/features/notifications/notification-drawer.tsx +6 -4
  127. package/src/components/features/time-tracker/time-tracker-panel.tsx +5 -3
  128. package/src/components/layout/page-container.tsx +13 -5
  129. package/src/components/ui/drawer.tsx +8 -3
  130. package/src/components/ui/index.ts +1 -0
  131. package/src/components/ui/marquee-wall.tsx +185 -11
  132. package/src/components/ui/modal-v2.tsx +6 -2
  133. package/src/components/ui/modal.tsx +6 -2
  134. package/src/components/ui/overlay-scroll-area.tsx +219 -0
  135. package/src/hooks/ui/index.ts +1 -0
  136. package/src/hooks/ui/use-reset-on-page-hidden.ts +32 -0
  137. package/src/hooks/use-near-viewport.ts +36 -12
  138. package/src/stories/OverlayScrollArea.stories.tsx +52 -0
  139. package/src/styles/index.css +2 -0
  140. package/src/styles/overlay-scrollbars-theme.css +19 -0
  141. package/src/styles/vendor-overlayscrollbars.css +673 -0
  142. package/dist/chunk-62AXZKYN.cjs.map +0 -1
  143. package/dist/chunk-BD3JBEUC.js.map +0 -1
  144. package/dist/chunk-KTGGM5WA.cjs.map +0 -1
  145. package/dist/chunk-N4CHA7T7.js.map +0 -1
  146. /package/dist/{chunk-6W4ZEVIC.js.map → chunk-2ZW2ZPDW.js.map} +0 -0
  147. /package/dist/{chunk-XAQLBUCP.js.map → chunk-4423DHRX.js.map} +0 -0
  148. /package/dist/{chunk-5YPKZM6Y.js.map → chunk-5BKBG653.js.map} +0 -0
  149. /package/dist/{chunk-DGPKGESY.js.map → chunk-AJGZ3YSR.js.map} +0 -0
  150. /package/dist/{chunk-YXCYQKAX.js.map → chunk-GJ7BN4MI.js.map} +0 -0
  151. /package/dist/{chunk-VNE5R4LQ.js.map → chunk-I7M6KCCS.js.map} +0 -0
  152. /package/dist/{chunk-X62ICFPJ.js.map → chunk-ILUX3DXS.js.map} +0 -0
  153. /package/dist/{chunk-QSIZW6EX.js.map → chunk-KXIIUE75.js.map} +0 -0
  154. /package/dist/{chunk-LB3OZE4B.js.map → chunk-O7F7RZFN.js.map} +0 -0
  155. /package/dist/{chunk-JUUPMMKI.js.map → chunk-R5IQJXA3.js.map} +0 -0
  156. /package/dist/{chunk-EGTGRG7N.js.map → chunk-RSW42GTZ.js.map} +0 -0
  157. /package/dist/{chunk-2KUIA2AR.js.map → chunk-WXDEMTLD.js.map} +0 -0
@@ -4,6 +4,7 @@ import * as React from 'react'
4
4
  import { cn } from '../../utils/cn'
5
5
  import { useMarqueeEngine } from '../../hooks/ui/use-marquee-engine'
6
6
  import { useMediaQuery } from '../../hooks/ui/use-media-query'
7
+ import { useResetOnPageHidden } from '../../hooks/ui/use-reset-on-page-hidden'
7
8
  import { useSuppressCloneFocus } from '../../hooks/ui/use-suppress-clone-focus'
8
9
  import { NEAR_VIEWPORT_ROOT_MARGIN } from '../../hooks/use-near-viewport'
9
10
 
@@ -153,6 +154,13 @@ export interface MarqueeWallProps {
153
154
  * must never move under a pointing cursor (required for interactive chip
154
155
  * walls). Default true. */
155
156
  pauseOnHover?: boolean
157
+ /** Opt-in MANUAL scroll: pointer-drag + horizontal wheel move the wall along
158
+ * its axis (transform-based — no inner scroller is created, so it stays
159
+ * deck-safe). The auto-marquee pauses during the interaction and briefly
160
+ * after, then resumes drifting from wherever the user left it. Off by
161
+ * default (decorative walls stay auto-only); enabled on the embeddable-chat
162
+ * quick-action walls so users can browse the actions by hand. */
163
+ dragScroll?: boolean
156
164
  /** Edge fade(s) — the "there's more" affordance. ONE spelling of the
157
165
  * clip-and-fade across every wall surface. */
158
166
  fade?: MarqueeWallFadeEdge | ReadonlyArray<MarqueeWallFadeEdge>
@@ -295,6 +303,7 @@ export function MarqueeWall({
295
303
  speed = 40,
296
304
  animate = true,
297
305
  pauseOnHover = true,
306
+ dragScroll = false,
298
307
  fade,
299
308
  fadeColor = 'var(--color-bg)',
300
309
  fadeSize,
@@ -386,6 +395,9 @@ export function MarqueeWall({
386
395
 
387
396
  // ---- pause-reason set ------------------------------------------------------
388
397
  const pointerInsideRef = React.useRef(false)
398
+ const clearPointerInside = React.useCallback(() => {
399
+ pointerInsideRef.current = false
400
+ }, [])
389
401
  const onPointerEnter = React.useCallback((e: React.PointerEvent) => {
390
402
  if (e.pointerType === 'touch') return
391
403
  pointerInsideRef.current = true
@@ -394,6 +406,21 @@ export function MarqueeWall({
394
406
  if (e.pointerType === 'touch') return
395
407
  pointerInsideRef.current = false
396
408
  }, [])
409
+ // Stale-flag self-heal (shared SSOT): if a `pointerleave` is MISSED (tab blur,
410
+ // overlay under the cursor, interrupted pointer), `inside` stays stuck true and
411
+ // the wall freezes forever — so un-stick it whenever the tab hides / the window
412
+ // loses focus. The next real pointer/enter re-arms it.
413
+ useResetOnPageHidden(clearPointerInside)
414
+
415
+ // ---- manual drag / wheel scroll (opt-in via `dragScroll`) ------------------
416
+ // Transform-based (no inner scroller → deck-safe): drag/wheel move the
417
+ // engine's float position directly; `draggingRef` + a short suppress window
418
+ // pause the auto-marquee during and just after the interaction so it resumes
419
+ // drifting from where the user left it. Refs declared here (before the engine)
420
+ // so `isPaused` can read them; the handlers (which need the engine's `wrap`)
421
+ // are defined after the engine call.
422
+ const draggingRef = React.useRef(false)
423
+ const dragSuppressUntilRef = React.useRef(0)
397
424
 
398
425
  // ---- transform driver ------------------------------------------------------
399
426
  const applyTransform = React.useCallback(
@@ -414,6 +441,26 @@ export function MarqueeWall({
414
441
  },
415
442
  [axis, reverse, trackId],
416
443
  )
444
+ // Sync-aware position writer — THE single entry point for every position
445
+ // update (the engine's rAF apply AND the manual drag/wheel handlers). With a
446
+ // `sync` controller it publishes to the shared position and drives every peer
447
+ // wall's transform; without one it just writes our own. Routing drag/wheel
448
+ // through here (instead of raw `applyTransform`) keeps a wall that is both
449
+ // `sync`-ed and `dragScroll`-ed in lockstep with its peers — a direct
450
+ // `applyTransform` would move only this wall and leave `sync.position` + peers
451
+ // stale. Members' own `apply` stays the raw `applyTransform` (no re-publish),
452
+ // so the `forEach` fan-out can't recurse.
453
+ const applyPos = React.useCallback(
454
+ (pos: number) => {
455
+ if (sync) {
456
+ sync.position = pos
457
+ sync.members.forEach(m => m.apply(pos))
458
+ } else {
459
+ applyTransform(pos)
460
+ }
461
+ },
462
+ [sync, applyTransform],
463
+ )
417
464
  // Clear any residual offset only when the marquee turns off STRUCTURALLY
418
465
  // (content shrank so it fits, reduced-motion flipped) — the static wall must
419
466
  // sit at its natural origin. A mere run-gate pause (`animate` false) does NOT
@@ -457,18 +504,16 @@ export function MarqueeWall({
457
504
  }
458
505
  }, [sync, applyTransform])
459
506
 
460
- const { posRef } = useMarqueeEngine({
507
+ const { posRef, wrap } = useMarqueeEngine({
461
508
  active: marqueeActive && nearViewport && isDriver,
462
509
  speed,
463
- isPaused: () =>
464
- (pauseOnHover && pointerInsideRef.current) || document.visibilityState === 'hidden',
510
+ isPaused: now =>
511
+ (pauseOnHover && pointerInsideRef.current) ||
512
+ draggingRef.current ||
513
+ now < dragSuppressUntilRef.current ||
514
+ document.visibilityState === 'hidden',
465
515
  getWrapSize: () => wrapSizeRef.current,
466
- apply: sync
467
- ? pos => {
468
- sync.position = pos
469
- sync.members.forEach(m => m.apply(pos))
470
- }
471
- : applyTransform,
516
+ apply: applyPos,
472
517
  // Synced pairs: a re-elected driver resumes from the pair's live position
473
518
  // (engine seeds from readBack on activation) instead of restarting at 0.
474
519
  readBack: sync ? () => sync.position : undefined,
@@ -490,17 +535,146 @@ export function MarqueeWall({
490
535
  }
491
536
  }, [marqueeMounted, reverse, posRef])
492
537
 
538
+ // ---- manual drag / wheel handlers (only wired when `dragScroll`) -----------
539
+ const DRAG_RESUME_MS = 1200
540
+ const dragStartRef = React.useRef({ coord: 0, pos: 0 })
541
+ const dragMovedRef = React.useRef(false)
542
+ const suppressClickRef = React.useRef(false)
543
+
544
+ const onDragPointerDown = React.useCallback((e: React.PointerEvent) => {
545
+ if (!marqueeMounted) return
546
+ draggingRef.current = true
547
+ dragMovedRef.current = false
548
+ // Clear any click-suppress left armed by a prior drag that ended WITHOUT a
549
+ // synthetic click on this container (pointercancel, or the pointer released
550
+ // off the wall) — otherwise `onDragClickCapture` would swallow this fresh
551
+ // tap's action. A new press is unambiguously a new intent.
552
+ suppressClickRef.current = false
553
+ dragStartRef.current = { coord: axis === 'y' ? e.clientY : e.clientX, pos: posRef.current }
554
+ // NOTE deliberately NO setPointerCapture here — capture is taken LAZILY in
555
+ // `onDragPointerMove`, once the press is proven to be a drag. Capturing on
556
+ // pointerdown retargets the compatibility mouse events (mouseup, and hence
557
+ // `click`, which fires at the nearest common ancestor of down/up) from the
558
+ // pressed element to this container — so a plain tap on a quick-action chip
559
+ // never reaches the chip's own onClick and the whole wall reads as dead.
560
+ }, [marqueeMounted, axis, posRef])
561
+
562
+ const onDragPointerMove = React.useCallback((e: React.PointerEvent) => {
563
+ if (!draggingRef.current) return
564
+ const delta = (axis === 'y' ? e.clientY : e.clientX) - dragStartRef.current.coord
565
+ if (Math.abs(delta) > 3 && !dragMovedRef.current) {
566
+ dragMovedRef.current = true
567
+ // Past the threshold this IS a drag: capture so the gesture keeps
568
+ // tracking once the pointer leaves the wall. Retargeting click is now
569
+ // WANTED — the trailing synthetic click is suppressed below anyway.
570
+ try { containerRef.current?.setPointerCapture(e.pointerId) } catch { /* best-effort */ }
571
+ }
572
+ // Track follows the pointer. `applyPos` maps pos→translate as `-pos`
573
+ // (forward) / `pos-wrap` (reverse), so a rightward/downward drag (delta > 0)
574
+ // must DECREASE pos on a forward wall and INCREASE it on a reverse one.
575
+ // Via `applyPos` (not raw `applyTransform`) so synced peer walls follow.
576
+ posRef.current = wrap(dragStartRef.current.pos + (reverse ? delta : -delta))
577
+ applyPos(posRef.current)
578
+ dragSuppressUntilRef.current = performance.now() + DRAG_RESUME_MS
579
+ }, [axis, reverse, wrap, posRef, applyPos])
580
+
581
+ const onDragPointerUp = React.useCallback((e: React.PointerEvent) => {
582
+ if (!draggingRef.current) return
583
+ draggingRef.current = false
584
+ // A real drag ends over a chip → swallow the synthetic click so the drag
585
+ // doesn't fire the chip's action.
586
+ if (dragMovedRef.current) suppressClickRef.current = true
587
+ dragSuppressUntilRef.current = performance.now() + DRAG_RESUME_MS
588
+ // Only ever captured past the drag threshold (see `onDragPointerMove`).
589
+ if (dragMovedRef.current) {
590
+ try { containerRef.current?.releasePointerCapture(e.pointerId) } catch { /* best-effort */ }
591
+ }
592
+ }, [])
593
+
594
+ // Pre-threshold presses hold NO pointer capture, so a pointer that leaves the
595
+ // wall before becoming a drag would never deliver its `pointerup` here and
596
+ // `draggingRef` would stay stuck true — freezing the marquee forever. End the
597
+ // gesture on leave; a captured (real) drag keeps running, capture guarantees
598
+ // its own pointerup.
599
+ const onDragPointerLeave = React.useCallback((e: React.PointerEvent) => {
600
+ onPointerLeave(e)
601
+ if (draggingRef.current && !dragMovedRef.current) draggingRef.current = false
602
+ }, [onPointerLeave])
603
+
604
+ const onDragClickCapture = React.useCallback((e: React.MouseEvent) => {
605
+ if (suppressClickRef.current) {
606
+ suppressClickRef.current = false
607
+ e.preventDefault()
608
+ e.stopPropagation()
609
+ }
610
+ }, [])
611
+
612
+ // Along-axis wheel → move the wall. Wired as a NATIVE non-passive listener
613
+ // (not React's `onWheel`, which React attaches passively so `preventDefault`
614
+ // is a no-op): once WE consume an along-axis wheel we must `preventDefault` to
615
+ // suppress the browser's horizontal history-swipe (two-finger trackpad) on an
616
+ // x-wall. An x-wall ignores vertical page-scroll wheels (and vice-versa) so the
617
+ // surrounding page still scrolls normally.
618
+ React.useEffect(() => {
619
+ const el = containerRef.current
620
+ if (!el || !dragScroll || !marqueeMounted) return
621
+ const onWheel = (e: WheelEvent) => {
622
+ // Only claim the DOMINANT-axis wheel (per axis), so a cross-axis wheel
623
+ // still scrolls the page: an x-wall ignores vertical wheels, a y-wall
624
+ // ignores horizontal ones.
625
+ const primary =
626
+ axis === 'y'
627
+ ? Math.abs(e.deltaY) >= Math.abs(e.deltaX)
628
+ ? e.deltaY
629
+ : 0
630
+ : Math.abs(e.deltaX) >= Math.abs(e.deltaY)
631
+ ? e.deltaX
632
+ : 0
633
+ if (primary === 0) return
634
+ e.preventDefault()
635
+ // Via `applyPos` (not raw `applyTransform`) so synced peer walls follow.
636
+ posRef.current = wrap(posRef.current + (reverse ? -primary : primary))
637
+ applyPos(posRef.current)
638
+ dragSuppressUntilRef.current = performance.now() + DRAG_RESUME_MS
639
+ }
640
+ el.addEventListener('wheel', onWheel, { passive: false })
641
+ return () => el.removeEventListener('wheel', onWheel)
642
+ }, [dragScroll, marqueeMounted, axis, reverse, wrap, posRef, applyPos])
643
+
493
644
  // ---- render ----------------------------------------------------------------
494
645
  const renderContent = (isClone: boolean) =>
495
646
  typeof children === 'function' ? children({ isClone }) : children
496
647
 
648
+ // Reduced-motion static fallback: when the marquee does NOT mount (chiefly
649
+ // prefers-reduced-motion) but the content OVERFLOWS, the drag/transform path
650
+ // is inert — so on a `dragScroll` wall fall back to NATIVE
651
+ // overflow scroll along the axis. Otherwise the overflowing chips would be
652
+ // clipped by `overflow-hidden` with no way to reach them (a11y regression vs
653
+ // the old wrapping row). The visible thin scrollbar (global `*` rule) is the
654
+ // right affordance for reduced-motion users. No engine needed — the browser
655
+ // scrolls the single static track.
656
+ const staticScrollable = dragScroll && overflows && !marqueeMounted
657
+
497
658
  return (
498
659
  <div
499
660
  ref={containerRef}
500
- className={cn('relative overflow-hidden', className)}
661
+ className={cn(
662
+ 'relative',
663
+ staticScrollable ? (axis === 'y' ? 'overflow-y-auto' : 'overflow-x-auto') : 'overflow-hidden',
664
+ dragScroll && marqueeMounted && 'cursor-grab active:cursor-grabbing select-none',
665
+ className,
666
+ )}
667
+ // x-walls let vertical page-scroll pass (`pan-y`) and own horizontal
668
+ // drags; y-walls the reverse. Only when drag is actually live.
669
+ style={dragScroll && marqueeMounted ? { touchAction: axis === 'y' ? 'pan-x' : 'pan-y' } : undefined}
501
670
  data-marquee-track={trackId}
502
671
  onPointerEnter={onPointerEnter}
503
- onPointerLeave={onPointerLeave}
672
+ onPointerLeave={dragScroll ? onDragPointerLeave : onPointerLeave}
673
+ onPointerDown={dragScroll ? onDragPointerDown : undefined}
674
+ onPointerMove={dragScroll ? onDragPointerMove : undefined}
675
+ onPointerUp={dragScroll ? onDragPointerUp : undefined}
676
+ onPointerCancel={dragScroll ? onDragPointerUp : undefined}
677
+ onClickCapture={dragScroll ? onDragClickCapture : undefined}
504
678
  >
505
679
  <div
506
680
  ref={trackRef}
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react"
5
5
  import { usePreventScroll } from "@react-aria/overlays"
6
6
  import { XmarkIcon } from "../icons-v2-generated"
7
7
  import { cn } from "../../utils/cn"
8
+ import { OverlayScrollArea } from "./overlay-scroll-area"
8
9
 
9
10
  // Duration of the open/close animation in ms — keep in sync with the
10
11
  // `duration-200` utilities applied to the backdrop and panel below.
@@ -131,9 +132,12 @@ Modal.displayName = "ModalV2"
131
132
 
132
133
  const ModalContent = React.forwardRef<HTMLDivElement, ModalContentProps>(
133
134
  ({ children, className }, ref) => (
134
- <div ref={ref} className={cn("flex-1 min-h-0 overflow-y-auto", className)}>
135
+ <OverlayScrollArea
136
+ viewportRef={ref}
137
+ className={cn("flex-1 min-h-0", className)}
138
+ >
135
139
  {children}
136
- </div>
140
+ </OverlayScrollArea>
137
141
  )
138
142
  )
139
143
  ModalContent.displayName = "ModalV2Content"
@@ -4,6 +4,7 @@ import * as React from "react"
4
4
  import { useEffect } from "react"
5
5
  import { usePreventScroll } from "@react-aria/overlays"
6
6
  import { cn } from "../../utils/cn"
7
+ import { OverlayScrollArea } from "./overlay-scroll-area"
7
8
 
8
9
  interface ModalProps {
9
10
  isOpen: boolean
@@ -82,9 +83,12 @@ Modal.displayName = "Modal"
82
83
  /** @deprecated Use ModalV2Content from './modal-v2' instead. */
83
84
  const ModalContent = React.forwardRef<HTMLDivElement, ModalContentProps>(
84
85
  ({ children, className }, ref) => (
85
- <div ref={ref} className={cn("overflow-y-auto min-h-0 flex-1", className)}>
86
+ <OverlayScrollArea
87
+ viewportRef={ref}
88
+ className={cn("min-h-0 flex-1", className)}
89
+ >
86
90
  {children}
87
- </div>
91
+ </OverlayScrollArea>
88
92
  )
89
93
  )
90
94
  ModalContent.displayName = "ModalContent"
@@ -0,0 +1,219 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import { OverlayScrollbars, type PartialOptions } from 'overlayscrollbars'
5
+ import { cn } from '../../utils/cn'
6
+
7
+ // =============================================================================
8
+ // Standardized macOS-like overlay scrollbars on every platform.
9
+ //
10
+ // OverlayScrollbars hides the native scrollbar and draws a styleable overlay
11
+ // one on top while keeping NATIVE scrolling (wheel, touchpad momentum,
12
+ // keyboard, drag-the-thumb). With `autoHide` the bar shows only while
13
+ // scrolling and fades out when idle — the macOS behavior, now identical on
14
+ // Windows/Linux and for mouse users.
15
+ //
16
+ // Touch devices keep the native scrollbars: mobile bars are already overlay
17
+ // and auto-hiding, so the custom layer is initialized only on fine-pointer
18
+ // devices (desktop / tablet with a mouse).
19
+ // =============================================================================
20
+
21
+ /** Overlay scrollbars are desktop-only; touch keeps native scrolling. */
22
+ const FINE_POINTER_QUERY = '(hover: hover) and (pointer: fine)'
23
+
24
+ /**
25
+ * `matchMedia` for the fine-pointer query, or `null` where it doesn't exist —
26
+ * jsdom (every consumer's component tests) and non-browser render paths. The
27
+ * whole overlay layer is progressive enhancement, so "can't detect" degrades
28
+ * to the native scrollbar instead of throwing.
29
+ */
30
+ const matchFinePointer = (): MediaQueryList | null =>
31
+ typeof window !== 'undefined' && typeof window.matchMedia === 'function'
32
+ ? window.matchMedia(FINE_POINTER_QUERY)
33
+ : null
34
+
35
+ /** True once mounted on a device with a mouse/trackpad-grade pointer. */
36
+ export function useFinePointer(): boolean {
37
+ const [fine, setFine] = React.useState(false)
38
+ React.useEffect(() => {
39
+ const mq = matchFinePointer()
40
+ if (!mq) return
41
+ setFine(mq.matches)
42
+ const onChange = (e: MediaQueryListEvent) => setFine(e.matches)
43
+ mq.addEventListener('change', onChange)
44
+ return () => mq.removeEventListener('change', onChange)
45
+ }, [])
46
+ return fine
47
+ }
48
+
49
+ /** Shared ODS defaults: thin grey thumb, transparent track, show on scroll. */
50
+ const ODS_SCROLLBAR_OPTIONS: PartialOptions = {
51
+ scrollbars: {
52
+ theme: 'os-theme-ods',
53
+ autoHide: 'scroll',
54
+ autoHideDelay: 800,
55
+ // Keep the bar visible until the first scroll so keyboard/AT users still
56
+ // get the affordance on freshly opened views.
57
+ autoHideSuspend: true,
58
+ },
59
+ }
60
+
61
+ const setRef = <T,>(ref: React.Ref<T> | undefined, value: T | null) => {
62
+ if (!ref) return
63
+ if (typeof ref === 'function') ref(value)
64
+ else (ref as React.MutableRefObject<T | null>).current = value
65
+ }
66
+
67
+ export interface OverlayScrollAreaProps extends React.HTMLAttributes<HTMLDivElement> {
68
+ /** Sizing/box classes of the scroll container (`flex-1 min-h-0`, `max-h-…`,
69
+ * borders, background) — AND paddings. Do NOT include `overflow-*` here.
70
+ *
71
+ * PADDING BELONGS HERE, NOT ON `contentClassName`: OverlayScrollbars owns
72
+ * the viewport's box and writes `padding: 0` inline on it, so a padding
73
+ * class on the viewport is silently dropped (measured — this is why the
74
+ * wrapper components keep passing their consumer `className` to the host). */
75
+ className?: string
76
+ /** Layout classes for the scrolling element itself (`flex flex-col gap-…`).
77
+ * Children are its direct children, so `gap`/`flex` applies exactly as it
78
+ * did on the old single `overflow-auto` div. Paddings do NOT work here —
79
+ * see `className`. */
80
+ contentClassName?: string
81
+ /** Receives the actual scrolling element — use for scrollTop/scrollHeight
82
+ * logic and as IntersectionObserver root. Set from the first commit, valid
83
+ * on both the overlay and the native fallback path. */
84
+ viewportRef?: React.Ref<HTMLDivElement>
85
+ /** Extra OverlayScrollbars options merged over the ODS defaults. */
86
+ options?: PartialOptions
87
+ children?: React.ReactNode
88
+ }
89
+
90
+ /**
91
+ * Replacement for an `overflow-auto` scroll container with the standardized
92
+ * ODS overlay scrollbar. Split the old scroller's classes: sizing goes to
93
+ * `className`, content layout to `contentClassName`. The inner scroller div
94
+ * is stable across pointer modes — refs and `onScroll` (via the standard
95
+ * HTML props) keep working like on the plain div it replaces.
96
+ *
97
+ * On touch devices (no fine pointer) the overlay layer is never initialized
98
+ * and the inner div scrolls with its native (already overlay) scrollbar.
99
+ */
100
+ export function OverlayScrollArea({
101
+ className,
102
+ contentClassName,
103
+ viewportRef,
104
+ options,
105
+ children,
106
+ ...props
107
+ }: OverlayScrollAreaProps) {
108
+ const hostRef = React.useRef<HTMLDivElement>(null)
109
+ const scrollerRef = React.useRef<HTMLDivElement>(null)
110
+
111
+ // Serialize to keep the effect dep stable for inline `options` objects.
112
+ const optionsJson = JSON.stringify(options ?? null)
113
+
114
+ // Layout effect so the viewport is upgraded before consumers' own layout
115
+ // effects (scroll-fade hooks, observers) measure it.
116
+ React.useLayoutEffect(() => {
117
+ const host = hostRef.current
118
+ const viewport = scrollerRef.current
119
+ if (!host || !viewport) return
120
+ const extra = (JSON.parse(optionsJson) ?? {}) as PartialOptions
121
+ const mq = matchFinePointer()
122
+ if (!mq) return
123
+ let instance: ReturnType<typeof OverlayScrollbars> | null = null
124
+
125
+ const sync = () => {
126
+ if (mq.matches && !instance) {
127
+ // Our own div is passed as the viewport: children stay inside it and
128
+ // it remains the scrolling element; the library only suppresses its
129
+ // native scrollbar and appends the overlay handles to the host.
130
+ instance = OverlayScrollbars(
131
+ { target: host, elements: { viewport } },
132
+ // `scrollbars` merges one level deep: a caller overriding a single
133
+ // key (e.g. `autoHide`) must not drop the ODS theme and the other
134
+ // defaults with it.
135
+ {
136
+ ...ODS_SCROLLBAR_OPTIONS,
137
+ ...extra,
138
+ scrollbars: { ...ODS_SCROLLBAR_OPTIONS.scrollbars, ...extra.scrollbars },
139
+ },
140
+ )
141
+ } else if (!mq.matches && instance) {
142
+ instance.destroy()
143
+ instance = null
144
+ }
145
+ }
146
+
147
+ sync()
148
+ mq.addEventListener('change', sync)
149
+ return () => {
150
+ mq.removeEventListener('change', sync)
151
+ instance?.destroy()
152
+ }
153
+ }, [optionsJson])
154
+
155
+ return (
156
+ <div ref={hostRef} className={cn('relative', className)}>
157
+ <div
158
+ ref={(el) => {
159
+ scrollerRef.current = el
160
+ setRef(viewportRef, el)
161
+ }}
162
+ className={cn('h-full w-full overflow-auto', contentClassName)}
163
+ {...props}
164
+ >
165
+ {children}
166
+ </div>
167
+ </div>
168
+ )
169
+ }
170
+
171
+ export interface GlobalOverlayScrollbarsProps {
172
+ /** Extra OverlayScrollbars options merged over the ODS defaults. */
173
+ options?: PartialOptions
174
+ }
175
+
176
+ /**
177
+ * Applies the same overlay scrollbar to the PAGE scroller (`<body>`).
178
+ * Render once near the app root (client side). No-op on touch devices.
179
+ *
180
+ * ONLY mount this on APP-SHELL pages whose body barely scrolls — the real
181
+ * scrolling happens in inner `OverlayScrollArea` containers (openframe-frontend,
182
+ * openframe-chat). Do NOT mount it on long scroll-driven documents: the thumb is
183
+ * repositioned from JS on every scroll frame, so on a page whose main thread is
184
+ * already busy with reveal-on-scroll sections, tickers and marquees the scroll
185
+ * visibly stutters. Measured on multi-platform-hub; raising the update debounce
186
+ * (`update.debounce.mutation`/`resize`) did NOT help, which rules out the
187
+ * observer re-measurement and points at the per-frame cost itself — i.e. it is
188
+ * inherent to any JS-drawn scrollbar, not to this library. Such pages keep the
189
+ * native page scrollbar, styled by the ODS `scrollbar-width`/`scrollbar-color`
190
+ * globals; their inner containers can still use `OverlayScrollArea`.
191
+ */
192
+ export function GlobalOverlayScrollbars({ options }: GlobalOverlayScrollbarsProps = {}) {
193
+ const fine = useFinePointer()
194
+ // Serialize to keep the effect dep stable for inline `options` objects.
195
+ const optionsJson = JSON.stringify(options ?? null)
196
+
197
+ React.useEffect(() => {
198
+ if (!fine) return
199
+ const extra = (JSON.parse(optionsJson) ?? {}) as PartialOptions
200
+ // Required by OverlayScrollbars for body initialization — suppresses the
201
+ // native scrollbars on both scroll roots before the overlay takes over.
202
+ document.documentElement.setAttribute('data-overlayscrollbars-initialize', '')
203
+ document.body.setAttribute('data-overlayscrollbars-initialize', '')
204
+ const instance = OverlayScrollbars(document.body, {
205
+ ...ODS_SCROLLBAR_OPTIONS,
206
+ ...extra,
207
+ // Same one-level-deep merge as OverlayScrollArea: a caller overriding a
208
+ // single key must not drop the ODS theme (or a tuning preset's siblings).
209
+ scrollbars: { ...ODS_SCROLLBAR_OPTIONS.scrollbars, ...extra.scrollbars },
210
+ })
211
+ return () => {
212
+ instance.destroy()
213
+ document.documentElement.removeAttribute('data-overlayscrollbars-initialize')
214
+ document.body.removeAttribute('data-overlayscrollbars-initialize')
215
+ }
216
+ }, [fine, optionsJson])
217
+
218
+ return null
219
+ }
@@ -12,6 +12,7 @@ export * from './use-media-query'
12
12
  export * from './use-memoized-callback'
13
13
  export * from './use-notification-permission'
14
14
  export * from './use-onboarding-state'
15
+ export * from './use-reset-on-page-hidden'
15
16
  export * from './use-search'
16
17
  export * from './use-suppress-clone-focus'
17
18
  export * from './use-table-pagination'
@@ -0,0 +1,32 @@
1
+ import { useEffect } from 'react'
2
+
3
+ /**
4
+ * Runs `reset` whenever the tab is hidden or the window loses focus — exactly the
5
+ * moments a `pointerleave` / `pointercancel` can be SWALLOWED (tab blur, an
6
+ * overlay mounting under the cursor, an interrupted pointer), which otherwise
7
+ * leaves a hover/"inside" flag stuck `true` and freezes a marquee FOREVER. The
8
+ * next real pointer/hover re-arms the flag.
9
+ *
10
+ * SSOT self-heal for every marquee surface (MarqueeWall, CardsStrip) so the
11
+ * blur + `visibilitychange` wiring lives in one place. `reset` almost always
12
+ * only UN-sticks state. The one edge: on `blur` WITHOUT the tab hiding (a second
13
+ * window focused beside this one), clearing the hover-pause can let the marquee
14
+ * resume under a still-stationary cursor in the now-unfocused window — it
15
+ * re-pauses on the next `pointermove`/`pointerenter`. We keep the `blur` reset
16
+ * anyway because it's the only signal that catches a tab-blur that swallows the
17
+ * `pointerleave` without a `visibilitychange`. Pass a STABLE `reset` (memoize
18
+ * with `useCallback`) — the listeners re-attach whenever its identity changes.
19
+ */
20
+ export function useResetOnPageHidden(reset: () => void): void {
21
+ useEffect(() => {
22
+ const onVisibility = () => {
23
+ if (document.visibilityState === 'hidden') reset()
24
+ }
25
+ window.addEventListener('blur', reset)
26
+ document.addEventListener('visibilitychange', onVisibility)
27
+ return () => {
28
+ window.removeEventListener('blur', reset)
29
+ document.removeEventListener('visibilitychange', onVisibility)
30
+ }
31
+ }, [reset])
32
+ }
@@ -29,19 +29,39 @@
29
29
 
30
30
  import { useEffect, useRef, useState, useCallback } from 'react';
31
31
 
32
- // Per-rootMargin IO map. Multiple call sites with different margins each
33
- // get their own singleton observer.
32
+ // Per-(rootMargin, threshold) IO map. Multiple call sites with different
33
+ // margins/thresholds each get their own singleton observer.
34
34
  const observers = new Map<string, IntersectionObserver>();
35
35
  const subscribers = new WeakMap<Element, () => void>();
36
36
 
37
- function getObserverFor(rootMargin: string): IntersectionObserver {
38
- const existing = observers.get(rootMargin);
37
+ // Slack for the explicit ratio check: an element sized to exactly meet the
38
+ // threshold can report a ratio a hair under it (sub-pixel / float rounding), so
39
+ // accept `ratio >= threshold - EPSILON`. With `threshold: 0` this is a no-op
40
+ // (ratio is always ≥ 0 > -EPSILON) — the `isIntersecting` check alone gates.
41
+ const THRESHOLD_EPSILON = 0.01;
42
+
43
+ /** Stable map key for an observer config. */
44
+ function observerKey(rootMargin: string, threshold: number): string {
45
+ return `${rootMargin}|${threshold}`;
46
+ }
47
+
48
+ function getObserverFor(rootMargin: string, threshold: number): IntersectionObserver {
49
+ const key = observerKey(rootMargin, threshold);
50
+ const existing = observers.get(key);
39
51
  if (existing) return existing;
40
52
 
41
53
  const io = new IntersectionObserver(
42
54
  (entries) => {
43
55
  entries.forEach((entry) => {
56
+ // Enforce the threshold EXPLICITLY. `isIntersecting` is spec-defined as
57
+ // `intersectionRatio > 0` (any overlap), so the initial `observe()`
58
+ // firing can report `true` at, say, 20% visible even with
59
+ // `threshold: 0.5` — which would prematurely pass the gate. Require both
60
+ // an intersection AND the ratio to actually meet the threshold (minus a
61
+ // small epsilon for the float rounding where the ratio lands a hair
62
+ // under the exact value).
44
63
  if (!entry.isIntersecting) return;
64
+ if (entry.intersectionRatio < threshold - THRESHOLD_EPSILON) return;
45
65
  // Race-safe: re-read the callback at fire time. A late IO firing
46
66
  // after cleanup must not invoke a stale callback.
47
67
  const cb = subscribers.get(entry.target);
@@ -52,9 +72,9 @@ function getObserverFor(rootMargin: string): IntersectionObserver {
52
72
  }
53
73
  });
54
74
  },
55
- { rootMargin }
75
+ { rootMargin, threshold }
56
76
  );
57
- observers.set(rootMargin, io);
77
+ observers.set(key, io);
58
78
  return io;
59
79
  }
60
80
 
@@ -78,12 +98,16 @@ export interface UseNearViewportResult<T extends Element = HTMLElement> {
78
98
  * '500px' = element starts mounting 500px before scroll-in.
79
99
  * '1000px' = a full viewport's worth of lookahead.
80
100
  * '0px' = strict on-screen detection.
101
+ * @param threshold Fraction of the element that must be visible before firing
102
+ * (0 = any pixel — the default; 0.5 = at least half on-screen).
81
103
  */
82
104
  export function useNearViewport<T extends Element = HTMLElement>(
83
- rootMargin: string = NEAR_VIEWPORT_ROOT_MARGIN
105
+ rootMargin: string = NEAR_VIEWPORT_ROOT_MARGIN,
106
+ threshold: number = 0
84
107
  ): UseNearViewportResult<T> {
85
108
  const [isNear, setIsNear] = useState(false);
86
109
  const elRef = useRef<T | null>(null);
110
+ const key = observerKey(rootMargin, threshold);
87
111
 
88
112
  // Subscribe/unsubscribe on element change.
89
113
  const ref = useCallback(
@@ -96,7 +120,7 @@ export function useNearViewport<T extends Element = HTMLElement>(
96
120
  const stillOurs = subscribers.get(prev);
97
121
  if (stillOurs) {
98
122
  subscribers.delete(prev);
99
- observers.get(rootMargin)?.unobserve(prev);
123
+ observers.get(key)?.unobserve(prev);
100
124
  }
101
125
  }
102
126
 
@@ -105,9 +129,9 @@ export function useNearViewport<T extends Element = HTMLElement>(
105
129
 
106
130
  const cb = () => setIsNear(true);
107
131
  subscribers.set(node, cb);
108
- getObserverFor(rootMargin).observe(node);
132
+ getObserverFor(rootMargin, threshold).observe(node);
109
133
  },
110
- [rootMargin]
134
+ [key, rootMargin, threshold]
111
135
  );
112
136
 
113
137
  // Unsubscribe on unmount. Identity check guards the StrictMode race.
@@ -117,10 +141,10 @@ export function useNearViewport<T extends Element = HTMLElement>(
117
141
  if (!el) return;
118
142
  if (subscribers.get(el)) {
119
143
  subscribers.delete(el);
120
- observers.get(rootMargin)?.unobserve(el);
144
+ observers.get(key)?.unobserve(el);
121
145
  }
122
146
  };
123
- }, [rootMargin]);
147
+ }, [key]);
124
148
 
125
149
  return { ref, isNear };
126
150
  }