@flamingo-stack/openframe-frontend-core 0.0.697 → 0.0.698-2527.7764.1

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 (218) hide show
  1. package/dist/{chunk-F6U2H42L.cjs → chunk-2JRKNGJ4.cjs} +6 -1
  2. package/dist/chunk-2JRKNGJ4.cjs.map +1 -0
  3. package/dist/{chunk-WVDBRL2S.js → chunk-3I4UVWLL.js} +7 -7
  4. package/dist/{chunk-LNOXNCEC.js → chunk-3QOEL4WL.js} +4 -4
  5. package/dist/{chunk-FZFEIXGB.cjs → chunk-3Y6OCKKW.cjs} +98 -98
  6. package/dist/{chunk-FZFEIXGB.cjs.map → chunk-3Y6OCKKW.cjs.map} +1 -1
  7. package/dist/{chunk-N4G3C4B4.cjs → chunk-4QRN6FRY.cjs} +12 -12
  8. package/dist/{chunk-N4G3C4B4.cjs.map → chunk-4QRN6FRY.cjs.map} +1 -1
  9. package/dist/{chunk-NE4H4JJG.cjs → chunk-5EL4RXTH.cjs} +42 -42
  10. package/dist/{chunk-NE4H4JJG.cjs.map → chunk-5EL4RXTH.cjs.map} +1 -1
  11. package/dist/{chunk-6CDP6TGH.cjs → chunk-5TAHPP4S.cjs} +126 -27
  12. package/dist/chunk-5TAHPP4S.cjs.map +1 -0
  13. package/dist/{chunk-M3JA577H.js → chunk-6SN6IVLN.js} +3 -3
  14. package/dist/{chunk-J4VGVLQI.js → chunk-7SKHOYTF.js} +3 -3
  15. package/dist/{chunk-7MM6EDNA.cjs → chunk-7WUCZIT4.cjs} +55 -32
  16. package/dist/{chunk-7MM6EDNA.cjs.map → chunk-7WUCZIT4.cjs.map} +1 -1
  17. package/dist/{chunk-75CG72QX.cjs → chunk-A3S7VHTM.cjs} +33 -33
  18. package/dist/{chunk-75CG72QX.cjs.map → chunk-A3S7VHTM.cjs.map} +1 -1
  19. package/dist/{chunk-VSQVJHOS.js → chunk-AKVO7FP4.js} +2 -2
  20. package/dist/{chunk-T33ICOHD.cjs → chunk-AQLW7KV3.cjs} +29 -29
  21. package/dist/{chunk-T33ICOHD.cjs.map → chunk-AQLW7KV3.cjs.map} +1 -1
  22. package/dist/{chunk-J4MCVIXU.js → chunk-BNJBJTEK.js} +209 -110
  23. package/dist/chunk-BNJBJTEK.js.map +1 -0
  24. package/dist/{chunk-YCVDJX7Z.js → chunk-DBF7PGQR.js} +4 -4
  25. package/dist/{chunk-LZXZ3C6M.js → chunk-E47BI33A.js} +32 -9
  26. package/dist/chunk-E47BI33A.js.map +1 -0
  27. package/dist/{chunk-RQ3HFUKV.cjs → chunk-FEXS67IG.cjs} +8 -8
  28. package/dist/{chunk-RQ3HFUKV.cjs.map → chunk-FEXS67IG.cjs.map} +1 -1
  29. package/dist/{chunk-LEGNIETR.cjs → chunk-GPF5IV4F.cjs} +5 -5
  30. package/dist/{chunk-LEGNIETR.cjs.map → chunk-GPF5IV4F.cjs.map} +1 -1
  31. package/dist/{chunk-VE7HLTVQ.js → chunk-H45GRYL4.js} +2 -2
  32. package/dist/{chunk-QYFXRVH3.js → chunk-H7FCFGSD.js} +9 -9
  33. package/dist/{chunk-JU6SBF3C.cjs → chunk-HT7SU5UN.cjs} +7 -7
  34. package/dist/{chunk-JU6SBF3C.cjs.map → chunk-HT7SU5UN.cjs.map} +1 -1
  35. package/dist/{chunk-3V7O7J4S.cjs → chunk-IZ3B3YRO.cjs} +28 -28
  36. package/dist/{chunk-3V7O7J4S.cjs.map → chunk-IZ3B3YRO.cjs.map} +1 -1
  37. package/dist/{chunk-KLDCI3KF.cjs → chunk-JM7KIML2.cjs} +3 -3
  38. package/dist/{chunk-KLDCI3KF.cjs.map → chunk-JM7KIML2.cjs.map} +1 -1
  39. package/dist/{chunk-Y2MDXJB4.js → chunk-JZCCRN3K.js} +2 -2
  40. package/dist/{chunk-4HVWGYHI.js → chunk-LPLXCDNV.js} +6 -1
  41. package/dist/chunk-LPLXCDNV.js.map +1 -0
  42. package/dist/{chunk-LF4S37VU.js → chunk-NKKA4KY7.js} +5 -5
  43. package/dist/{chunk-RIDRAKQ5.cjs → chunk-OF6FE2KT.cjs} +15 -15
  44. package/dist/{chunk-RIDRAKQ5.cjs.map → chunk-OF6FE2KT.cjs.map} +1 -1
  45. package/dist/{chunk-QD4BVKAU.js → chunk-OKA4VKE6.js} +6 -6
  46. package/dist/{chunk-Z7A7FUWY.js → chunk-OM6WC5XG.js} +3 -3
  47. package/dist/{chunk-77XUG4Z4.js → chunk-OPXQ5E3G.js} +10 -10
  48. package/dist/{chunk-GRBZC5N3.js → chunk-PELIFROQ.js} +2 -2
  49. package/dist/{chunk-JBMFCHNT.js → chunk-PMXCBAC4.js} +2883 -2343
  50. package/dist/chunk-PMXCBAC4.js.map +1 -0
  51. package/dist/{chunk-PYNHPMDB.js → chunk-Q7PGQDD4.js} +5 -5
  52. package/dist/{chunk-EWQZ4BXD.cjs → chunk-QYTVHA6G.cjs} +7 -7
  53. package/dist/{chunk-EWQZ4BXD.cjs.map → chunk-QYTVHA6G.cjs.map} +1 -1
  54. package/dist/{chunk-H6SSHFMD.js → chunk-QZFJJRXE.js} +6 -6
  55. package/dist/{chunk-XRW5VZKH.cjs → chunk-SBBLGNXR.cjs} +14 -14
  56. package/dist/{chunk-XRW5VZKH.cjs.map → chunk-SBBLGNXR.cjs.map} +1 -1
  57. package/dist/{chunk-VCR3TW2H.cjs → chunk-TVMY3U3W.cjs} +8 -8
  58. package/dist/{chunk-VCR3TW2H.cjs.map → chunk-TVMY3U3W.cjs.map} +1 -1
  59. package/dist/{chunk-3S56I5MX.js → chunk-U7J7G5J7.js} +3 -3
  60. package/dist/{chunk-SG53SIJX.js → chunk-ULYQ4WFF.js} +6 -6
  61. package/dist/{chunk-CVMWOUAX.cjs → chunk-UTQLLMBP.cjs} +48 -48
  62. package/dist/{chunk-CVMWOUAX.cjs.map → chunk-UTQLLMBP.cjs.map} +1 -1
  63. package/dist/{chunk-5DBWXJBG.cjs → chunk-VVTWH4YS.cjs} +1529 -989
  64. package/dist/chunk-VVTWH4YS.cjs.map +1 -0
  65. package/dist/{chunk-5P2J7E5E.cjs → chunk-WC76QXUX.cjs} +3 -3
  66. package/dist/{chunk-5P2J7E5E.cjs.map → chunk-WC76QXUX.cjs.map} +1 -1
  67. package/dist/{chunk-2FK7BZIM.cjs → chunk-XFIHZS35.cjs} +18 -18
  68. package/dist/{chunk-2FK7BZIM.cjs.map → chunk-XFIHZS35.cjs.map} +1 -1
  69. package/dist/{chunk-OB3ZJ7GQ.js → chunk-XGB5EEFZ.js} +3 -3
  70. package/dist/{chunk-MFU3ALKM.cjs → chunk-YNAWEA3G.cjs} +232 -232
  71. package/dist/{chunk-MFU3ALKM.cjs.map → chunk-YNAWEA3G.cjs.map} +1 -1
  72. package/dist/{chunk-WADR7VIA.cjs → chunk-YWMEVCCZ.cjs} +70 -70
  73. package/dist/{chunk-WADR7VIA.cjs.map → chunk-YWMEVCCZ.cjs.map} +1 -1
  74. package/dist/components/announcement-bar.d.ts +1 -1
  75. package/dist/components/announcement-bar.d.ts.map +1 -1
  76. package/dist/components/calendar.cjs +4 -4
  77. package/dist/components/calendar.js +1 -1
  78. package/dist/components/case-studies/index.cjs +21 -21
  79. package/dist/components/case-studies/index.js +7 -7
  80. package/dist/components/chat/index.cjs +4 -4
  81. package/dist/components/chat/index.js +3 -3
  82. package/dist/components/contact/index.cjs +8 -8
  83. package/dist/components/contact/index.js +7 -7
  84. package/dist/components/docs/index.cjs +11 -11
  85. package/dist/components/docs/index.js +10 -10
  86. package/dist/components/embeds/index.cjs +8 -8
  87. package/dist/components/embeds/index.js +7 -7
  88. package/dist/components/faq/index.cjs +8 -8
  89. package/dist/components/faq/index.js +7 -7
  90. package/dist/components/features/conversation-card.d.ts +32 -0
  91. package/dist/components/features/conversation-card.d.ts.map +1 -0
  92. package/dist/components/features/index.cjs +9 -7
  93. package/dist/components/features/index.cjs.map +1 -1
  94. package/dist/components/features/index.d.ts +1 -0
  95. package/dist/components/features/index.d.ts.map +1 -1
  96. package/dist/components/features/index.js +8 -6
  97. package/dist/components/help-center-pages/index.cjs +101 -101
  98. package/dist/components/help-center-pages/index.js +20 -20
  99. package/dist/components/index.cjs +133 -109
  100. package/dist/components/index.cjs.map +1 -1
  101. package/dist/components/index.js +45 -21
  102. package/dist/components/index.js.map +1 -1
  103. package/dist/components/meeting-scheduler/index.cjs +59 -59
  104. package/dist/components/meeting-scheduler/index.js +8 -8
  105. package/dist/components/navigation/index.cjs +10 -10
  106. package/dist/components/navigation/index.js +9 -9
  107. package/dist/components/onboarding-guides/index.cjs +10 -10
  108. package/dist/components/onboarding-guides/index.js +9 -9
  109. package/dist/components/platform/ToolBadge.d.ts +17 -9
  110. package/dist/components/platform/ToolBadge.d.ts.map +1 -1
  111. package/dist/components/related-content/index.cjs +5 -5
  112. package/dist/components/related-content/index.js +4 -4
  113. package/dist/components/tickets/index.cjs +12 -12
  114. package/dist/components/tickets/index.js +11 -11
  115. package/dist/components/ui/app-window-frame.d.ts +20 -0
  116. package/dist/components/ui/app-window-frame.d.ts.map +1 -0
  117. package/dist/components/ui/button/button-styles.d.ts +1 -0
  118. package/dist/components/ui/button/button-styles.d.ts.map +1 -1
  119. package/dist/components/ui/button/button.d.ts +1 -1
  120. package/dist/components/ui/button/button.d.ts.map +1 -1
  121. package/dist/components/ui/feature-card.d.ts +5 -0
  122. package/dist/components/ui/feature-card.d.ts.map +1 -1
  123. package/dist/components/ui/feature-list.d.ts +7 -1
  124. package/dist/components/ui/feature-list.d.ts.map +1 -1
  125. package/dist/components/ui/file-manager/index.cjs +11 -11
  126. package/dist/components/ui/file-manager/index.js +1 -1
  127. package/dist/components/ui/incident-feed.d.ts +49 -0
  128. package/dist/components/ui/incident-feed.d.ts.map +1 -0
  129. package/dist/components/ui/index.cjs +27 -7
  130. package/dist/components/ui/index.cjs.map +1 -1
  131. package/dist/components/ui/index.d.ts +5 -0
  132. package/dist/components/ui/index.d.ts.map +1 -1
  133. package/dist/components/ui/index.js +26 -6
  134. package/dist/components/ui/page-actions.d.ts +1 -1
  135. package/dist/components/ui/page-actions.d.ts.map +1 -1
  136. package/dist/components/ui/phone-frame.d.ts +60 -0
  137. package/dist/components/ui/phone-frame.d.ts.map +1 -0
  138. package/dist/components/ui/snap-carousel.d.ts +27 -0
  139. package/dist/components/ui/snap-carousel.d.ts.map +1 -0
  140. package/dist/components/ui/sticky-action-bar.d.ts +29 -0
  141. package/dist/components/ui/sticky-action-bar.d.ts.map +1 -0
  142. package/dist/components/ui/tab-navigation.d.ts +14 -1
  143. package/dist/components/ui/tab-navigation.d.ts.map +1 -1
  144. package/dist/hooks/index.cjs +12 -2
  145. package/dist/hooks/index.cjs.map +1 -1
  146. package/dist/hooks/index.d.ts +1 -0
  147. package/dist/hooks/index.d.ts.map +1 -1
  148. package/dist/hooks/index.js +11 -1
  149. package/dist/hooks/ui/index.d.ts +2 -0
  150. package/dist/hooks/ui/index.d.ts.map +1 -1
  151. package/dist/hooks/ui/use-in-view.d.ts +20 -0
  152. package/dist/hooks/ui/use-in-view.d.ts.map +1 -0
  153. package/dist/hooks/ui/use-prefers-reduced-motion.d.ts +13 -0
  154. package/dist/hooks/ui/use-prefers-reduced-motion.d.ts.map +1 -0
  155. package/dist/hooks/use-scenario-player.d.ts +45 -0
  156. package/dist/hooks/use-scenario-player.d.ts.map +1 -0
  157. package/dist/index.cjs +44 -12
  158. package/dist/index.cjs.map +1 -1
  159. package/dist/index.js +42 -10
  160. package/dist/index.js.map +1 -1
  161. package/dist/types/announcement.cjs.map +1 -1
  162. package/dist/types/announcement.d.ts +21 -0
  163. package/dist/types/announcement.d.ts.map +1 -1
  164. package/dist/types/announcement.js.map +1 -1
  165. package/dist/types/index.cjs.map +1 -1
  166. package/dist/types/index.js.map +1 -1
  167. package/package.json +1 -1
  168. package/src/components/announcement-bar.tsx +7 -1
  169. package/src/components/features/conversation-card.tsx +93 -0
  170. package/src/components/features/index.ts +3 -0
  171. package/src/components/platform/ToolBadge.tsx +47 -13
  172. package/src/components/ui/__tests__/snap-carousel.test.tsx +116 -0
  173. package/src/components/ui/app-window-frame.tsx +41 -0
  174. package/src/components/ui/button/button-styles.ts +5 -0
  175. package/src/components/ui/button/button.tsx +1 -0
  176. package/src/components/ui/feature-card.tsx +16 -1
  177. package/src/components/ui/feature-list.tsx +23 -3
  178. package/src/components/ui/incident-feed.tsx +143 -0
  179. package/src/components/ui/index.ts +8 -0
  180. package/src/components/ui/page-actions.tsx +1 -1
  181. package/src/components/ui/phone-frame.tsx +166 -0
  182. package/src/components/ui/snap-carousel.tsx +186 -0
  183. package/src/components/ui/sticky-action-bar.tsx +81 -0
  184. package/src/components/ui/tab-navigation.tsx +63 -13
  185. package/src/hooks/__tests__/use-scenario-player.test.tsx +144 -0
  186. package/src/hooks/index.ts +3 -0
  187. package/src/hooks/ui/index.ts +2 -0
  188. package/src/hooks/ui/use-in-view.ts +63 -0
  189. package/src/hooks/ui/use-prefers-reduced-motion.ts +22 -0
  190. package/src/hooks/use-scenario-player.ts +102 -0
  191. package/src/stories/DemoStage.stories.tsx +242 -0
  192. package/src/types/announcement.ts +21 -0
  193. package/dist/chunk-4HVWGYHI.js.map +0 -1
  194. package/dist/chunk-5DBWXJBG.cjs.map +0 -1
  195. package/dist/chunk-6CDP6TGH.cjs.map +0 -1
  196. package/dist/chunk-F6U2H42L.cjs.map +0 -1
  197. package/dist/chunk-J4MCVIXU.js.map +0 -1
  198. package/dist/chunk-JBMFCHNT.js.map +0 -1
  199. package/dist/chunk-LZXZ3C6M.js.map +0 -1
  200. /package/dist/{chunk-WVDBRL2S.js.map → chunk-3I4UVWLL.js.map} +0 -0
  201. /package/dist/{chunk-LNOXNCEC.js.map → chunk-3QOEL4WL.js.map} +0 -0
  202. /package/dist/{chunk-M3JA577H.js.map → chunk-6SN6IVLN.js.map} +0 -0
  203. /package/dist/{chunk-J4VGVLQI.js.map → chunk-7SKHOYTF.js.map} +0 -0
  204. /package/dist/{chunk-VSQVJHOS.js.map → chunk-AKVO7FP4.js.map} +0 -0
  205. /package/dist/{chunk-YCVDJX7Z.js.map → chunk-DBF7PGQR.js.map} +0 -0
  206. /package/dist/{chunk-VE7HLTVQ.js.map → chunk-H45GRYL4.js.map} +0 -0
  207. /package/dist/{chunk-QYFXRVH3.js.map → chunk-H7FCFGSD.js.map} +0 -0
  208. /package/dist/{chunk-Y2MDXJB4.js.map → chunk-JZCCRN3K.js.map} +0 -0
  209. /package/dist/{chunk-LF4S37VU.js.map → chunk-NKKA4KY7.js.map} +0 -0
  210. /package/dist/{chunk-QD4BVKAU.js.map → chunk-OKA4VKE6.js.map} +0 -0
  211. /package/dist/{chunk-Z7A7FUWY.js.map → chunk-OM6WC5XG.js.map} +0 -0
  212. /package/dist/{chunk-77XUG4Z4.js.map → chunk-OPXQ5E3G.js.map} +0 -0
  213. /package/dist/{chunk-GRBZC5N3.js.map → chunk-PELIFROQ.js.map} +0 -0
  214. /package/dist/{chunk-PYNHPMDB.js.map → chunk-Q7PGQDD4.js.map} +0 -0
  215. /package/dist/{chunk-H6SSHFMD.js.map → chunk-QZFJJRXE.js.map} +0 -0
  216. /package/dist/{chunk-3S56I5MX.js.map → chunk-U7J7G5J7.js.map} +0 -0
  217. /package/dist/{chunk-SG53SIJX.js.map → chunk-ULYQ4WFF.js.map} +0 -0
  218. /package/dist/{chunk-OB3ZJ7GQ.js.map → chunk-XGB5EEFZ.js.map} +0 -0
@@ -0,0 +1,186 @@
1
+ 'use client';
2
+
3
+ import { type ReactNode, useCallback, useEffect, useRef, useState } from 'react';
4
+ import { useInView } from '../../hooks/ui/use-in-view';
5
+ import { usePrefersReducedMotionState } from '../../hooks/ui/use-prefers-reduced-motion';
6
+ import { cn } from '../../utils/cn';
7
+ import { Chevron02LeftIcon } from '../icons-v2-generated/arrows/chevron-02-left-icon';
8
+ import { Chevron02RightIcon } from '../icons-v2-generated/arrows/chevron-02-right-icon';
9
+
10
+ export interface SnapCarouselProps<T> {
11
+ items: readonly T[];
12
+ renderItem: (item: T, index: number) => ReactNode;
13
+ getKey?: (item: T, index: number) => string | number;
14
+ /** Names the carousel for assistive tech. */
15
+ label: string;
16
+ /** Move to the next slide after this long. `0` turns auto-advance off. Default 5000. */
17
+ autoAdvanceMs?: number;
18
+ /** Width of one slide. Default `basis-[300px]`. */
19
+ slideClassName?: string;
20
+ prevLabel?: string;
21
+ nextLabel?: string;
22
+ className?: string;
23
+ }
24
+
25
+ const GAP_PX = 12;
26
+
27
+ /**
28
+ * The active dot filling up while the carousel waits to advance. A transition,
29
+ * not a keyframe animation: it mounts empty and is told to be full one frame
30
+ * later, taking the whole interval to get there.
31
+ */
32
+ function DotFill({ durationMs }: { durationMs: number }) {
33
+ const [full, setFull] = useState(false);
34
+ useEffect(() => {
35
+ const frame = requestAnimationFrame(() => setFull(true));
36
+ return () => cancelAnimationFrame(frame);
37
+ }, []);
38
+ return (
39
+ <span
40
+ className="absolute inset-0 origin-left bg-ods-text-primary transition-transform ease-linear"
41
+ style={{ transform: full ? 'scaleX(1)' : 'scaleX(0)', transitionDuration: `${durationMs}ms` }}
42
+ />
43
+ );
44
+ }
45
+
46
+ /**
47
+ * A native scroll-snap carousel: swipe or use the arrows; dots show the
48
+ * position, a counter says it in words.
49
+ *
50
+ * It advances on its own only while at least 60% of it is on screen, and it
51
+ * stops FOR GOOD the first time the visitor touches it (pointer, wheel, key or
52
+ * focus): after that the visitor is driving. Under reduced motion it never
53
+ * advances by itself. While it is auto-playing the active dot fills over the
54
+ * interval, so the wait is visible.
55
+ */
56
+ export function SnapCarousel<T>({
57
+ items,
58
+ renderItem,
59
+ getKey,
60
+ label,
61
+ autoAdvanceMs = 5000,
62
+ slideClassName = 'basis-[300px]',
63
+ prevLabel = 'Previous',
64
+ nextLabel = 'Next',
65
+ className,
66
+ }: SnapCarouselProps<T>) {
67
+ const trackRef = useRef<HTMLDivElement | null>(null);
68
+ const [index, setIndex] = useState(0);
69
+ const [auto, setAuto] = useState(true);
70
+ const { ref: viewRef, inView } = useInView<HTMLDivElement>({ threshold: 0.6 });
71
+ const reducedState = usePrefersReducedMotionState();
72
+ const count = items.length;
73
+
74
+ const slideStep = useCallback(() => {
75
+ const first = trackRef.current?.firstElementChild as HTMLElement | null;
76
+ return first ? first.offsetWidth + GAP_PX : 0;
77
+ }, []);
78
+
79
+ const goTo = useCallback(
80
+ (next: number) => {
81
+ const track = trackRef.current;
82
+ const step = slideStep();
83
+ if (!track || step === 0) return;
84
+ const clamped = Math.max(0, Math.min(count - 1, next));
85
+ track.scrollTo({ left: clamped * step, behavior: 'smooth' });
86
+ },
87
+ [count, slideStep],
88
+ );
89
+
90
+ const onScroll = useCallback(() => {
91
+ const track = trackRef.current;
92
+ const step = slideStep();
93
+ if (!track || step === 0) return;
94
+ setIndex(Math.min(count - 1, Math.round(track.scrollLeft / step)));
95
+ }, [count, slideStep]);
96
+
97
+ const stop = useCallback(() => setAuto(false), []);
98
+
99
+ const playing = auto && inView && reducedState === false && autoAdvanceMs > 0 && count > 1;
100
+
101
+ useEffect(() => {
102
+ if (!playing) return undefined;
103
+ const timer = setTimeout(() => goTo(index >= count - 1 ? 0 : index + 1), autoAdvanceMs);
104
+ return () => clearTimeout(timer);
105
+ }, [playing, index, count, autoAdvanceMs, goTo]);
106
+
107
+ const setRefs = useCallback(
108
+ (node: HTMLDivElement | null) => {
109
+ trackRef.current = node;
110
+ viewRef(node);
111
+ },
112
+ [viewRef],
113
+ );
114
+
115
+ if (count === 0) return null;
116
+
117
+ return (
118
+ <div className={className} onPointerDown={stop} onTouchStart={stop} onWheel={stop} onKeyDown={stop} onFocus={stop}>
119
+ <div
120
+ ref={setRefs}
121
+ onScroll={onScroll}
122
+ role="group"
123
+ aria-roledescription="carousel"
124
+ aria-label={label}
125
+ className="scrollbar-hide flex snap-x snap-mandatory overflow-x-auto"
126
+ style={{ gap: GAP_PX }}
127
+ >
128
+ {items.map((item, itemIndex) => (
129
+ <div
130
+ key={getKey ? getKey(item, itemIndex) : itemIndex}
131
+ role="group"
132
+ aria-roledescription="slide"
133
+ aria-label={`${itemIndex + 1} / ${count}`}
134
+ aria-hidden={itemIndex !== index}
135
+ className={cn('flex shrink-0 grow-0 snap-start', slideClassName)}
136
+ >
137
+ <div className="min-w-0 flex-1">{renderItem(item, itemIndex)}</div>
138
+ </div>
139
+ ))}
140
+ </div>
141
+ <div className="mt-3 flex items-center gap-2">
142
+ <span className="flex gap-1.5" aria-hidden>
143
+ {items.map((_, dotIndex) => (
144
+ <span
145
+ key={dotIndex}
146
+ className={cn(
147
+ 'relative h-1.5 overflow-hidden rounded-full transition-[width] duration-200 motion-reduce:transition-none',
148
+ dotIndex === index ? 'w-6' : 'w-1.5',
149
+ dotIndex === index && !playing ? 'bg-ods-text-primary' : 'bg-ods-border',
150
+ )}
151
+ >
152
+ {dotIndex === index && playing && (
153
+ // Re-keyed per slide so the fill restarts from empty.
154
+ <DotFill key={index} durationMs={autoAdvanceMs} />
155
+ )}
156
+ </span>
157
+ ))}
158
+ </span>
159
+ <span
160
+ className="ml-auto mr-1 whitespace-nowrap text-ods-text-secondary text-h5"
161
+ aria-live={auto ? 'off' : 'polite'}
162
+ >
163
+ {index + 1} / {count}
164
+ </span>
165
+ <button
166
+ type="button"
167
+ aria-label={prevLabel}
168
+ disabled={index === 0}
169
+ onClick={() => goTo(index - 1)}
170
+ className="grid h-11 w-11 shrink-0 place-items-center rounded-full border border-ods-border text-ods-text-primary outline-none transition-colors hover:bg-ods-card focus-visible:ring-2 focus-visible:ring-ods-focus disabled:cursor-default disabled:text-ods-text-secondary disabled:opacity-50 disabled:hover:bg-transparent"
171
+ >
172
+ <Chevron02LeftIcon size={20} />
173
+ </button>
174
+ <button
175
+ type="button"
176
+ aria-label={nextLabel}
177
+ disabled={index === count - 1}
178
+ onClick={() => goTo(index + 1)}
179
+ className="grid h-11 w-11 shrink-0 place-items-center rounded-full border border-ods-border text-ods-text-primary outline-none transition-colors hover:bg-ods-card focus-visible:ring-2 focus-visible:ring-ods-focus disabled:cursor-default disabled:text-ods-text-secondary disabled:opacity-50 disabled:hover:bg-transparent"
180
+ >
181
+ <Chevron02RightIcon size={20} />
182
+ </button>
183
+ </div>
184
+ </div>
185
+ );
186
+ }
@@ -0,0 +1,81 @@
1
+ 'use client';
2
+
3
+ import { type ReactNode, type RefObject, useEffect, useState } from 'react';
4
+ import { cn } from '../../utils/cn';
5
+
6
+ export interface UseBetweenAnchorsOptions {
7
+ /** The bar may show once this element has scrolled above the viewport top. */
8
+ after: RefObject<Element | null>;
9
+ /** The bar hides again once this element enters the viewport. */
10
+ before: RefObject<Element | null>;
11
+ /** Height of anything fixed at the top (a sticky header) that covers `after`. */
12
+ topOffset?: number;
13
+ }
14
+
15
+ /**
16
+ * True while the page is scrolled BETWEEN two anchors: past the first, not yet
17
+ * at the second. Used to show a sticky call to action only when no other
18
+ * instance of it is on screen (the hero's has gone, the closing one has not
19
+ * arrived), so the same button is never visible twice.
20
+ */
21
+ export function useBetweenAnchors({ after, before, topOffset = 0 }: UseBetweenAnchorsOptions): boolean {
22
+ const [between, setBetween] = useState(false);
23
+
24
+ useEffect(() => {
25
+ let frame = 0;
26
+ const check = () => {
27
+ frame = 0;
28
+ const afterEl = after.current;
29
+ const beforeEl = before.current;
30
+ if (!afterEl) {
31
+ setBetween(false);
32
+ return;
33
+ }
34
+ const pastFirst = afterEl.getBoundingClientRect().bottom < topOffset;
35
+ const beforeSecond = beforeEl ? beforeEl.getBoundingClientRect().top > window.innerHeight : true;
36
+ setBetween(pastFirst && beforeSecond);
37
+ };
38
+ const schedule = () => {
39
+ if (frame === 0) frame = requestAnimationFrame(check);
40
+ };
41
+ check();
42
+ window.addEventListener('scroll', schedule, { passive: true });
43
+ window.addEventListener('resize', schedule);
44
+ return () => {
45
+ if (frame !== 0) cancelAnimationFrame(frame);
46
+ window.removeEventListener('scroll', schedule);
47
+ window.removeEventListener('resize', schedule);
48
+ };
49
+ }, [after, before, topOffset]);
50
+
51
+ return between;
52
+ }
53
+
54
+ export interface StickyActionBarProps {
55
+ /** Slides in when true, out when false. */
56
+ visible: boolean;
57
+ children: ReactNode;
58
+ className?: string;
59
+ }
60
+
61
+ /**
62
+ * A bar fixed to the bottom of the screen that holds one action, padded for
63
+ * the home-indicator safe area. Off screen it is inert: not focusable, not
64
+ * clickable, hidden from assistive tech.
65
+ */
66
+ export function StickyActionBar({ visible, children, className }: StickyActionBarProps) {
67
+ return (
68
+ <div
69
+ aria-hidden={!visible}
70
+ inert={!visible}
71
+ className={cn(
72
+ 'fixed inset-x-0 bottom-0 z-[44] border-t border-ods-border bg-ods-bg px-4 pt-3 transition-transform duration-200 ease-out motion-reduce:transition-none',
73
+ 'pb-[calc(1rem+env(safe-area-inset-bottom))]',
74
+ visible ? 'translate-y-0' : 'pointer-events-none translate-y-full',
75
+ className,
76
+ )}
77
+ >
78
+ {children}
79
+ </div>
80
+ );
81
+ }
@@ -51,6 +51,17 @@ export interface TabItem {
51
51
  * "Label (Badge)". Cased as read — the chip upper-cases it.
52
52
  */
53
53
  badge?: string;
54
+ /** A second, quieter line of text: beside the label from `md`, under it below. */
55
+ sublabel?: string;
56
+ /** A leading visual used instead of `icon` (an avatar, a logo). Rendered as given. */
57
+ avatar?: React.ReactNode;
58
+ /**
59
+ * 0..1. Set on the ACTIVE tab, the underline stops being a selection marker
60
+ * and becomes a progress line: its width is this fraction of the tab, and it
61
+ * moves there linearly over `progressTransitionMs`. A timed, auto-advancing
62
+ * strip (a looping demo) uses it; `0` snaps back with no animation.
63
+ */
64
+ progress?: number;
54
65
  }
55
66
 
56
67
  export interface TabNavigationUrlSyncOptions {
@@ -73,6 +84,8 @@ interface TabNavigationProps {
73
84
  /** Tabs grow to share the bar's full width equally (Figma segmented-underline
74
85
  * look, e.g. the 480px homepage strip switcher). Default: natural width. */
75
86
  stretchTabs?: boolean;
87
+ /** How long the underline takes to reach a new `TabItem.progress` value. Default 200. */
88
+ progressTransitionMs?: number;
76
89
 
77
90
  // URL sync mode
78
91
  urlSync?: boolean | TabNavigationUrlSyncOptions;
@@ -117,6 +130,7 @@ interface TabBarProps {
117
130
  showLeftGradient: boolean;
118
131
  showRightGradient: boolean;
119
132
  stretchTabs: boolean;
133
+ progressTransitionMs: number;
120
134
  }
121
135
 
122
136
  /**
@@ -140,6 +154,7 @@ const TabBar = memo(function TabBarImpl({
140
154
  showLeftGradient,
141
155
  showRightGradient,
142
156
  stretchTabs,
157
+ progressTransitionMs,
143
158
  }: TabBarProps) {
144
159
  const scrollRef = useRef<HTMLDivElement>(null);
145
160
  const activeTabRef = useRef<HTMLButtonElement>(null);
@@ -308,10 +323,23 @@ const TabBar = memo(function TabBarImpl({
308
323
  // that for a 4px-tall bar is not measurable. Correctness at every zoom level
309
324
  // is worth more than keeping one property on the compositor.
310
325
  const isPlaced = indicator.width > 0;
326
+ // A tab that reports `progress` turns the underline into a progress line.
327
+ const activeProgress = tabs.find(tab => tab.id === activeTab)?.progress;
328
+ const hasProgress = typeof activeProgress === 'number';
329
+ const progress = hasProgress ? Math.max(0, Math.min(1, activeProgress)) : 1;
311
330
  const indicatorStyle: React.CSSProperties = {
312
- width: `${indicator.width}px`,
331
+ width: `${indicator.width * progress}px`,
313
332
  transform: `translateX(${indicator.left}px)`,
314
333
  opacity: isPlaced ? 1 : 0,
334
+ // Width only, linear: a progress line is a clock, not a slide between
335
+ // tabs. At 0 it snaps, so a restarted or newly chosen tab starts empty.
336
+ ...(hasProgress
337
+ ? {
338
+ transitionProperty: 'width',
339
+ transitionTimingFunction: 'linear',
340
+ transitionDuration: progress === 0 ? '0ms' : `${progressTransitionMs}ms`,
341
+ }
342
+ : null),
315
343
  };
316
344
  // True from the render AFTER the one that first committed a real position.
317
345
  const shouldAnimateIndicator =
@@ -353,6 +381,7 @@ const TabBar = memo(function TabBarImpl({
353
381
  // sitting 4px away.
354
382
  'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ods-focus',
355
383
  stretchTabs && 'flex-1',
384
+ tab.avatar && 'gap-[var(--spacing-system-xsf)]',
356
385
  // Known limitation: ODS color vars hold hex values, so Tailwind
357
386
  // alpha modifiers (to-ods-accent/10) silently produce no CSS.
358
387
  // color-mix() accepts hex, so we derive the 10%-alpha stop from the token.
@@ -361,7 +390,12 @@ const TabBar = memo(function TabBarImpl({
361
390
  : 'hover:bg-gradient-to-b hover:from-transparent hover:to-[color-mix(in_srgb,var(--color-accent-primary)_10%,transparent)]',
362
391
  )}
363
392
  >
364
- {tab.icon ? (
393
+ {tab.avatar ? (
394
+ <div className="relative flex shrink-0 items-center justify-center">
395
+ {tab.avatar}
396
+ {tab.indicator && <StatusDot indicator={tab.indicator} className="absolute right-0 top-[-3px]" />}
397
+ </div>
398
+ ) : tab.icon ? (
365
399
  <div className="relative flex items-center justify-center">
366
400
  <tab.icon
367
401
  className={cn(
@@ -377,14 +411,28 @@ const TabBar = memo(function TabBarImpl({
377
411
  <StatusDot indicator={tab.indicator} className="shrink-0" />
378
412
  ) : null}
379
413
 
380
- <span
381
- className={cn(
382
- 'whitespace-nowrap transition-colors text-h4',
383
- isActive ? 'text-ods-text-primary' : 'text-ods-text-secondary',
384
- )}
385
- >
386
- {tab.label}
387
- </span>
414
+ {tab.sublabel ? (
415
+ <span className="flex min-w-0 flex-col items-start text-left md:flex-row md:items-baseline md:gap-[var(--spacing-system-xsf)]">
416
+ <span
417
+ className={cn(
418
+ 'whitespace-nowrap transition-colors text-h4',
419
+ isActive ? 'text-ods-text-primary' : 'text-ods-text-secondary',
420
+ )}
421
+ >
422
+ {tab.label}
423
+ </span>
424
+ <span className="whitespace-nowrap text-ods-text-secondary text-h6">{tab.sublabel}</span>
425
+ </span>
426
+ ) : (
427
+ <span
428
+ className={cn(
429
+ 'whitespace-nowrap transition-colors text-h4',
430
+ isActive ? 'text-ods-text-primary' : 'text-ods-text-secondary',
431
+ )}
432
+ >
433
+ {tab.label}
434
+ </span>
435
+ )}
388
436
 
389
437
  {tab.badge && (
390
438
  // The chip is 32px against a 20/24px label line. The negative
@@ -414,9 +462,9 @@ const TabBar = memo(function TabBarImpl({
414
462
  // tests) rather than incidental styling.
415
463
  data-testid="tab-navigation-underline"
416
464
  className={cn(
417
- 'pointer-events-none absolute bottom-0 left-0 h-1 bg-ods-accent',
418
- shouldAnimateIndicator &&
419
- 'transition-[transform,width,opacity] duration-200 ease-out motion-reduce:transition-none',
465
+ 'pointer-events-none absolute bottom-0 left-0 bg-ods-accent motion-reduce:transition-none',
466
+ hasProgress ? 'h-0.5' : 'h-1',
467
+ !hasProgress && shouldAnimateIndicator && 'transition-[transform,width,opacity] duration-200 ease-out',
420
468
  )}
421
469
  style={indicatorStyle}
422
470
  />
@@ -455,6 +503,7 @@ export function TabNavigation({
455
503
  showRightGradient = false,
456
504
  showLeftGradient = false,
457
505
  stretchTabs = false,
506
+ progressTransitionMs = 200,
458
507
  urlSync = false,
459
508
  defaultTab,
460
509
  children,
@@ -628,6 +677,7 @@ export function TabNavigation({
628
677
  showLeftGradient={showLeftGradient}
629
678
  showRightGradient={showRightGradient}
630
679
  stretchTabs={stretchTabs}
680
+ progressTransitionMs={progressTransitionMs}
631
681
  />
632
682
 
633
683
  {/* Render children with active tab if provided */}
@@ -0,0 +1,144 @@
1
+ import { act, renderHook } from '@testing-library/react';
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { useScenarioPlayer } from '../use-scenario-player';
4
+
5
+ function stubReducedMotion(reduced: boolean) {
6
+ vi.stubGlobal(
7
+ 'matchMedia',
8
+ (query: string) =>
9
+ ({
10
+ matches: reduced,
11
+ media: query,
12
+ addEventListener() {},
13
+ removeEventListener() {},
14
+ }) as unknown as MediaQueryList,
15
+ );
16
+ }
17
+
18
+ const OPTIONS = { scenarioCount: 2, lastStep: 8, stepMs: 1700, holdMs: 4200 };
19
+
20
+ /** Each tick schedules the next one from an effect, so time moves one beat per act. */
21
+ function beats(count: number) {
22
+ for (let i = 0; i < count; i++)
23
+ act(() => {
24
+ vi.advanceTimersByTime(1700);
25
+ });
26
+ }
27
+
28
+ describe('useScenarioPlayer', () => {
29
+ beforeEach(() => {
30
+ vi.useFakeTimers();
31
+ });
32
+ afterEach(() => {
33
+ vi.useRealTimers();
34
+ vi.unstubAllGlobals();
35
+ });
36
+
37
+ it('plays 8 beats of 1.7s, holds 4.2s, then starts the other scenario', () => {
38
+ stubReducedMotion(false);
39
+ const { result } = renderHook(() => useScenarioPlayer(OPTIONS));
40
+ expect(result.current).toMatchObject({ scenario: 0, step: 0 });
41
+
42
+ for (let beat = 1; beat <= 8; beat++) {
43
+ act(() => {
44
+ vi.advanceTimersByTime(1700);
45
+ });
46
+ expect(result.current).toMatchObject({ scenario: 0, step: beat });
47
+ }
48
+
49
+ // The last step holds: nothing changes just before the hold ends.
50
+ act(() => {
51
+ vi.advanceTimersByTime(4199);
52
+ });
53
+ expect(result.current).toMatchObject({ scenario: 0, step: 8 });
54
+ act(() => {
55
+ vi.advanceTimersByTime(1);
56
+ });
57
+ expect(result.current).toMatchObject({ scenario: 1, step: 0 });
58
+
59
+ // And the second scenario wraps back to the first.
60
+ beats(8);
61
+ act(() => {
62
+ vi.advanceTimersByTime(4200);
63
+ });
64
+ expect(result.current).toMatchObject({ scenario: 0, step: 0 });
65
+ });
66
+
67
+ it('restarts a scenario from step 0 when it is chosen', () => {
68
+ stubReducedMotion(false);
69
+ const { result } = renderHook(() => useScenarioPlayer(OPTIONS));
70
+ beats(3);
71
+ expect(result.current.step).toBe(3);
72
+
73
+ act(() => {
74
+ result.current.go(1);
75
+ });
76
+ expect(result.current).toMatchObject({ scenario: 1, step: 0 });
77
+ act(() => {
78
+ result.current.go(1);
79
+ });
80
+ act(() => {
81
+ vi.advanceTimersByTime(1700);
82
+ });
83
+ expect(result.current).toMatchObject({ scenario: 1, step: 1 });
84
+ });
85
+
86
+ it('jumps to a step and keeps playing from there', () => {
87
+ stubReducedMotion(false);
88
+ const { result } = renderHook(() => useScenarioPlayer(OPTIONS));
89
+ act(() => {
90
+ result.current.setStep(7);
91
+ });
92
+ expect(result.current.step).toBe(7);
93
+ act(() => {
94
+ vi.advanceTimersByTime(1700);
95
+ });
96
+ expect(result.current.step).toBe(8);
97
+ act(() => {
98
+ result.current.setStep(99);
99
+ });
100
+ expect(result.current.step).toBe(8);
101
+ });
102
+
103
+ it('does not advance while paused or disabled', () => {
104
+ stubReducedMotion(false);
105
+ const { result, rerender } = renderHook(({ enabled }) => useScenarioPlayer({ ...OPTIONS, enabled }), {
106
+ initialProps: { enabled: false },
107
+ });
108
+ act(() => {
109
+ vi.advanceTimersByTime(10_000);
110
+ });
111
+ expect(result.current.step).toBe(0);
112
+
113
+ rerender({ enabled: true });
114
+ act(() => {
115
+ result.current.setPaused(true);
116
+ });
117
+ act(() => {
118
+ vi.advanceTimersByTime(10_000);
119
+ });
120
+ expect(result.current.step).toBe(0);
121
+
122
+ act(() => {
123
+ result.current.setPaused(false);
124
+ });
125
+ act(() => {
126
+ vi.advanceTimersByTime(1700);
127
+ });
128
+ expect(result.current.step).toBe(1);
129
+ });
130
+
131
+ it('parks on the last step under reduced motion and never advances', () => {
132
+ stubReducedMotion(true);
133
+ const { result } = renderHook(() => useScenarioPlayer(OPTIONS));
134
+ expect(result.current).toMatchObject({ scenario: 0, step: 8, reducedMotion: true });
135
+ act(() => {
136
+ vi.advanceTimersByTime(60_000);
137
+ });
138
+ expect(result.current).toMatchObject({ scenario: 0, step: 8 });
139
+ act(() => {
140
+ result.current.go(1);
141
+ });
142
+ expect(result.current).toMatchObject({ scenario: 1, step: 8 });
143
+ });
144
+ });
@@ -20,6 +20,9 @@ export * from './nats/use-nats-client';
20
20
  // Viewport / lazy-mount primitive (shared IO singleton)
21
21
  export * from './use-near-viewport';
22
22
 
23
+ // The clock of a looping scripted demo (scenarios x steps, hold, pause, jump)
24
+ export * from './use-scenario-player';
25
+
23
26
  // Access code integration — pairs with the standalone helpers in
24
27
  // `utils/access-code-client`. Lives in `hooks/` so the createContext
25
28
  // pulled in via EndpointsRuntimeContext doesn't end up in the
@@ -27,3 +27,5 @@ export * from './use-window-size';
27
27
  // hub/app consumers have one import path; lib internals may import the
28
28
  // package directly (npm dedupes to one module instance either way).
29
29
  export { usePreventScroll } from '@react-aria/overlays';
30
+ export * from './use-prefers-reduced-motion';
31
+ export * from './use-in-view';
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+
3
+ import { useCallback, useEffect, useRef, useState } from 'react';
4
+
5
+ export interface UseInViewOptions {
6
+ /** Fraction of the element that must be visible (0 = any pixel, 0.6 = 60%). */
7
+ threshold?: number;
8
+ /** Margin around the viewport, CSS-style. */
9
+ rootMargin?: string;
10
+ }
11
+
12
+ export interface UseInViewResult<T extends Element> {
13
+ ref: (node: T | null) => void;
14
+ /** Tracks visibility BOTH ways: true while in view, false again once it leaves. */
15
+ inView: boolean;
16
+ }
17
+
18
+ /**
19
+ * Two-way visibility: `inView` follows the element in and out of the viewport.
20
+ *
21
+ * `useNearViewport` is the fire-once sibling (mount a heavy thing when it gets
22
+ * close, never unmount). This one is for things that should run only WHILE
23
+ * visible, like an auto-advancing carousel or a looping demo.
24
+ */
25
+ export function useInView<T extends Element = HTMLElement>({
26
+ threshold = 0,
27
+ rootMargin = '0px',
28
+ }: UseInViewOptions = {}): UseInViewResult<T> {
29
+ const [inView, setInView] = useState(false);
30
+ const observerRef = useRef<IntersectionObserver | null>(null);
31
+ const nodeRef = useRef<T | null>(null);
32
+
33
+ const disconnect = useCallback(() => {
34
+ observerRef.current?.disconnect();
35
+ observerRef.current = null;
36
+ }, []);
37
+
38
+ const ref = useCallback(
39
+ (node: T | null) => {
40
+ disconnect();
41
+ nodeRef.current = node;
42
+ if (!node || typeof IntersectionObserver === 'undefined') {
43
+ setInView(false);
44
+ return;
45
+ }
46
+ const observer = new IntersectionObserver(
47
+ entries => {
48
+ const entry = entries[entries.length - 1];
49
+ if (!entry) return;
50
+ setInView(entry.isIntersecting && entry.intersectionRatio >= threshold);
51
+ },
52
+ { threshold, rootMargin },
53
+ );
54
+ observer.observe(node);
55
+ observerRef.current = observer;
56
+ },
57
+ [disconnect, threshold, rootMargin],
58
+ );
59
+
60
+ useEffect(() => disconnect, [disconnect]);
61
+
62
+ return { ref, inView };
63
+ }
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+
3
+ import { useMediaQuery } from './use-media-query';
4
+
5
+ export const PREFERS_REDUCED_MOTION_QUERY = '(prefers-reduced-motion: reduce)';
6
+
7
+ /**
8
+ * Whether the visitor asked the system for reduced motion.
9
+ *
10
+ * `false` until the first client effect has read the media query, so a
11
+ * server render and the first client render agree. Callers that must not
12
+ * START an animation before the answer is known should gate on
13
+ * `usePrefersReducedMotionState()` instead, which keeps the unknown state.
14
+ */
15
+ export function usePrefersReducedMotion(): boolean {
16
+ return useMediaQuery(PREFERS_REDUCED_MOTION_QUERY) === true;
17
+ }
18
+
19
+ /** Same query, keeping `undefined` while the answer is not yet known. */
20
+ export function usePrefersReducedMotionState(): boolean | undefined {
21
+ return useMediaQuery(PREFERS_REDUCED_MOTION_QUERY);
22
+ }