@flamingo-stack/openframe-frontend-core 0.0.556 → 0.0.557-snapshot.20260818183037

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 (193) hide show
  1. package/dist/{chunk-Q5SZ2QTZ.cjs → chunk-3TKG7SW6.cjs} +42 -42
  2. package/dist/{chunk-Q5SZ2QTZ.cjs.map → chunk-3TKG7SW6.cjs.map} +1 -1
  3. package/dist/{chunk-5JWLZJK5.js → chunk-4VLGJEKQ.js} +2 -2
  4. package/dist/{chunk-7Q7GFIFB.cjs → chunk-53GNFRVQ.cjs} +7 -7
  5. package/dist/{chunk-7Q7GFIFB.cjs.map → chunk-53GNFRVQ.cjs.map} +1 -1
  6. package/dist/{chunk-VF4DCOPD.js → chunk-5JHJX7OX.js} +5 -5
  7. package/dist/{chunk-Z3R3LOC5.cjs → chunk-5WQPOH27.cjs} +5 -5
  8. package/dist/{chunk-Z3R3LOC5.cjs.map → chunk-5WQPOH27.cjs.map} +1 -1
  9. package/dist/{chunk-VXNMOGRP.js → chunk-C5HQCF4R.js} +6 -6
  10. package/dist/{chunk-SXMJLNOF.cjs → chunk-CWQSUYVV.cjs} +3 -3
  11. package/dist/{chunk-SXMJLNOF.cjs.map → chunk-CWQSUYVV.cjs.map} +1 -1
  12. package/dist/{chunk-JDUPAHJR.cjs → chunk-DHSIAIFG.cjs} +18 -18
  13. package/dist/{chunk-JDUPAHJR.cjs.map → chunk-DHSIAIFG.cjs.map} +1 -1
  14. package/dist/{chunk-YM2WHYYK.js → chunk-DNPQ2U7P.js} +4 -4
  15. package/dist/{chunk-JXJ4FTKN.js → chunk-DV4CSNZD.js} +3 -3
  16. package/dist/{chunk-5756Q6UN.js → chunk-E26KVZJM.js} +3 -3
  17. package/dist/{chunk-C74PZU6M.cjs → chunk-FCCSHC3H.cjs} +32 -32
  18. package/dist/{chunk-C74PZU6M.cjs.map → chunk-FCCSHC3H.cjs.map} +1 -1
  19. package/dist/{chunk-JRWOHH7K.js → chunk-FVHFBEXH.js} +2 -2
  20. package/dist/{chunk-BZKUID4R.cjs → chunk-GYQHUJWR.cjs} +14 -14
  21. package/dist/{chunk-BZKUID4R.cjs.map → chunk-GYQHUJWR.cjs.map} +1 -1
  22. package/dist/{chunk-XGBVHQP7.js → chunk-IHXUZBBV.js} +3249 -2558
  23. package/dist/chunk-IHXUZBBV.js.map +1 -0
  24. package/dist/{chunk-WBQ3NOH7.js → chunk-KL6ZDLDF.js} +2 -2
  25. package/dist/{chunk-FZT7BYNF.js → chunk-LM6NDYGD.js} +2 -2
  26. package/dist/{chunk-LZD3VSPS.cjs → chunk-N3OGB543.cjs} +12 -12
  27. package/dist/{chunk-LZD3VSPS.cjs.map → chunk-N3OGB543.cjs.map} +1 -1
  28. package/dist/{chunk-VJTD2DGF.cjs → chunk-NK3M6F5A.cjs} +39 -30
  29. package/dist/chunk-NK3M6F5A.cjs.map +1 -0
  30. package/dist/{chunk-DFJ7TWH6.cjs → chunk-NKEOD2AD.cjs} +3 -3
  31. package/dist/{chunk-DFJ7TWH6.cjs.map → chunk-NKEOD2AD.cjs.map} +1 -1
  32. package/dist/{chunk-HYABNMBN.cjs → chunk-R3OCP4A7.cjs} +76 -76
  33. package/dist/{chunk-HYABNMBN.cjs.map → chunk-R3OCP4A7.cjs.map} +1 -1
  34. package/dist/{chunk-S4LL6QI6.cjs → chunk-R3TXAMMB.cjs} +1768 -1077
  35. package/dist/chunk-R3TXAMMB.cjs.map +1 -0
  36. package/dist/{chunk-5M4PS3XX.js → chunk-S3NZZKNU.js} +3 -3
  37. package/dist/{chunk-ICG7JRYT.cjs → chunk-SI64DC72.cjs} +40 -40
  38. package/dist/{chunk-ICG7JRYT.cjs.map → chunk-SI64DC72.cjs.map} +1 -1
  39. package/dist/{chunk-CGUSNV6R.js → chunk-UVGFICZT.js} +8 -8
  40. package/dist/{chunk-CRGIXNUE.cjs → chunk-VNWGXQJD.cjs} +23 -23
  41. package/dist/{chunk-CRGIXNUE.cjs.map → chunk-VNWGXQJD.cjs.map} +1 -1
  42. package/dist/{chunk-HOEOGFQM.cjs → chunk-XDMRN3SG.cjs} +97 -97
  43. package/dist/{chunk-HOEOGFQM.cjs.map → chunk-XDMRN3SG.cjs.map} +1 -1
  44. package/dist/{chunk-BNMKHG2L.cjs → chunk-XL2G2HHJ.cjs} +4 -4
  45. package/dist/{chunk-BNMKHG2L.cjs.map → chunk-XL2G2HHJ.cjs.map} +1 -1
  46. package/dist/{chunk-5EES5HD4.js → chunk-YUVCH2LX.js} +6 -6
  47. package/dist/{chunk-FLSEJSTN.js → chunk-Z5FN5VTC.js} +2 -2
  48. package/dist/{chunk-VRX6Y6A7.js → chunk-ZNEVGXMU.js} +23 -14
  49. package/dist/chunk-ZNEVGXMU.js.map +1 -0
  50. package/dist/{chunk-WX5UCLL7.js → chunk-ZSZ24UY6.js} +2 -2
  51. package/dist/components/case-studies/index.cjs +9 -9
  52. package/dist/components/case-studies/index.js +3 -3
  53. package/dist/components/chat/index.cjs +3 -3
  54. package/dist/components/chat/index.js +2 -2
  55. package/dist/components/contact/index.cjs +4 -4
  56. package/dist/components/contact/index.js +3 -3
  57. package/dist/components/docs/index.cjs +6 -6
  58. package/dist/components/docs/index.js +5 -5
  59. package/dist/components/embeds/index.cjs +4 -4
  60. package/dist/components/embeds/index.js +3 -3
  61. package/dist/components/faq/index.cjs +5 -5
  62. package/dist/components/faq/index.js +4 -4
  63. package/dist/components/features/board/aim.d.ts +57 -0
  64. package/dist/components/features/board/aim.d.ts.map +1 -0
  65. package/dist/components/features/board/board-column-header.d.ts.map +1 -1
  66. package/dist/components/features/board/board-column.d.ts +8 -4
  67. package/dist/components/features/board/board-column.d.ts.map +1 -1
  68. package/dist/components/features/board/board.d.ts +15 -4
  69. package/dist/components/features/board/board.d.ts.map +1 -1
  70. package/dist/components/features/board/drop-aim.d.ts +34 -0
  71. package/dist/components/features/board/drop-aim.d.ts.map +1 -0
  72. package/dist/components/features/board/lane-geometry.d.ts +22 -0
  73. package/dist/components/features/board/lane-geometry.d.ts.map +1 -0
  74. package/dist/components/features/board/pending-move.d.ts +77 -0
  75. package/dist/components/features/board/pending-move.d.ts.map +1 -0
  76. package/dist/components/features/board/resolve-drop.d.ts +19 -0
  77. package/dist/components/features/board/resolve-drop.d.ts.map +1 -0
  78. package/dist/components/features/board/ticket-card.d.ts +25 -9
  79. package/dist/components/features/board/ticket-card.d.ts.map +1 -1
  80. package/dist/components/features/board/use-board-collapse.d.ts.map +1 -1
  81. package/dist/components/features/board/use-lane-scroll-anchor.d.ts +27 -0
  82. package/dist/components/features/board/use-lane-scroll-anchor.d.ts.map +1 -0
  83. package/dist/components/features/index.cjs +9 -3
  84. package/dist/components/features/index.cjs.map +1 -1
  85. package/dist/components/features/index.d.ts +1 -0
  86. package/dist/components/features/index.d.ts.map +1 -1
  87. package/dist/components/features/index.js +8 -2
  88. package/dist/components/features/sortable-list/index.d.ts +4 -0
  89. package/dist/components/features/sortable-list/index.d.ts.map +1 -0
  90. package/dist/components/features/sortable-list/slot-geometry.d.ts +57 -0
  91. package/dist/components/features/sortable-list/slot-geometry.d.ts.map +1 -0
  92. package/dist/components/features/sortable-list/sortable-list.d.ts +50 -0
  93. package/dist/components/features/sortable-list/sortable-list.d.ts.map +1 -0
  94. package/dist/components/features/sortable-list/use-sortable-item.d.ts +29 -0
  95. package/dist/components/features/sortable-list/use-sortable-item.d.ts.map +1 -0
  96. package/dist/components/features/video.d.ts.map +1 -1
  97. package/dist/components/help-center-pages/index.cjs +24 -24
  98. package/dist/components/help-center-pages/index.js +15 -15
  99. package/dist/components/index.cjs +143 -137
  100. package/dist/components/index.cjs.map +1 -1
  101. package/dist/components/index.js +19 -13
  102. package/dist/components/index.js.map +1 -1
  103. package/dist/components/meeting-scheduler/index.cjs +34 -34
  104. package/dist/components/meeting-scheduler/index.js +4 -4
  105. package/dist/components/navigation/index.cjs +3 -3
  106. package/dist/components/navigation/index.js +2 -2
  107. package/dist/components/onboarding-guides/index.cjs +7 -7
  108. package/dist/components/onboarding-guides/index.js +6 -6
  109. package/dist/components/related-content/index.cjs +5 -5
  110. package/dist/components/related-content/index.js +4 -4
  111. package/dist/components/tickets/index.cjs +7 -7
  112. package/dist/components/tickets/index.js +6 -6
  113. package/dist/components/ui/index.cjs +3 -3
  114. package/dist/components/ui/index.js +2 -2
  115. package/dist/components/ui/square-avatar.d.ts.map +1 -1
  116. package/dist/hooks/index.cjs +6 -2
  117. package/dist/hooks/index.cjs.map +1 -1
  118. package/dist/hooks/index.d.ts +1 -0
  119. package/dist/hooks/index.d.ts.map +1 -1
  120. package/dist/hooks/index.js +5 -1
  121. package/dist/hooks/use-authed-asset-src.d.ts +16 -0
  122. package/dist/hooks/use-authed-asset-src.d.ts.map +1 -0
  123. package/dist/hooks/use-authed-image-src.d.ts +15 -6
  124. package/dist/hooks/use-authed-image-src.d.ts.map +1 -1
  125. package/dist/index.cjs +13 -3
  126. package/dist/index.cjs.map +1 -1
  127. package/dist/index.js +12 -2
  128. package/dist/utils/auto-scroll-ancestors.d.ts +43 -0
  129. package/dist/utils/auto-scroll-ancestors.d.ts.map +1 -0
  130. package/dist/utils/drag-effect.d.ts +21 -0
  131. package/dist/utils/drag-effect.d.ts.map +1 -0
  132. package/dist/utils/embed-authed-fetch.d.ts +24 -10
  133. package/dist/utils/embed-authed-fetch.d.ts.map +1 -1
  134. package/dist/utils/index.cjs.map +1 -1
  135. package/dist/utils/index.js.map +1 -1
  136. package/dist/utils/scroll-parent.d.ts +11 -0
  137. package/dist/utils/scroll-parent.d.ts.map +1 -0
  138. package/package.json +6 -3
  139. package/src/__tests__/board-aim.test.ts +152 -0
  140. package/src/__tests__/board-pending-move.test.ts +113 -0
  141. package/src/__tests__/board-resolve-drop.test.ts +68 -0
  142. package/src/__tests__/sortable-slot-geometry.test.ts +105 -0
  143. package/src/components/features/board/.board-column.md +17 -4
  144. package/src/components/features/board/.board.md +11 -7
  145. package/src/components/features/board/.ticket-card.md +27 -5
  146. package/src/components/features/board/aim.ts +131 -0
  147. package/src/components/features/board/board-column-header.tsx +2 -9
  148. package/src/components/features/board/board-column.tsx +137 -66
  149. package/src/components/features/board/board.tsx +501 -258
  150. package/src/components/features/board/drop-aim.ts +50 -0
  151. package/src/components/features/board/lane-geometry.ts +44 -0
  152. package/src/components/features/board/pending-move.ts +116 -0
  153. package/src/components/features/board/resolve-drop.ts +28 -0
  154. package/src/components/features/board/ticket-card.tsx +256 -47
  155. package/src/components/features/board/use-board-collapse.ts +16 -14
  156. package/src/components/features/board/use-lane-scroll-anchor.ts +79 -0
  157. package/src/components/features/index.ts +1 -0
  158. package/src/components/features/sortable-list/.sortable-list.md +82 -0
  159. package/src/components/features/sortable-list/index.ts +3 -0
  160. package/src/components/features/sortable-list/slot-geometry.ts +100 -0
  161. package/src/components/features/sortable-list/sortable-list.tsx +270 -0
  162. package/src/components/features/sortable-list/use-sortable-item.ts +92 -0
  163. package/src/components/features/video.tsx +13 -2
  164. package/src/components/ui/square-avatar.tsx +5 -0
  165. package/src/hooks/index.ts +1 -0
  166. package/src/hooks/use-authed-asset-src.ts +98 -0
  167. package/src/hooks/use-authed-image-src.ts +15 -84
  168. package/src/stories/.TicketCard.stories.md +6 -12
  169. package/src/stories/Board.stories.tsx +16 -7
  170. package/src/stories/TicketCard.stories.tsx +38 -76
  171. package/src/utils/__tests__/embed-authed-fetch.test.ts +50 -1
  172. package/src/utils/auto-scroll-ancestors.ts +90 -0
  173. package/src/utils/drag-effect.ts +26 -0
  174. package/src/utils/embed-authed-fetch.ts +31 -14
  175. package/src/utils/scroll-parent.ts +23 -0
  176. package/dist/chunk-S4LL6QI6.cjs.map +0 -1
  177. package/dist/chunk-VJTD2DGF.cjs.map +0 -1
  178. package/dist/chunk-VRX6Y6A7.js.map +0 -1
  179. package/dist/chunk-XGBVHQP7.js.map +0 -1
  180. /package/dist/{chunk-5JWLZJK5.js.map → chunk-4VLGJEKQ.js.map} +0 -0
  181. /package/dist/{chunk-VF4DCOPD.js.map → chunk-5JHJX7OX.js.map} +0 -0
  182. /package/dist/{chunk-VXNMOGRP.js.map → chunk-C5HQCF4R.js.map} +0 -0
  183. /package/dist/{chunk-YM2WHYYK.js.map → chunk-DNPQ2U7P.js.map} +0 -0
  184. /package/dist/{chunk-JXJ4FTKN.js.map → chunk-DV4CSNZD.js.map} +0 -0
  185. /package/dist/{chunk-5756Q6UN.js.map → chunk-E26KVZJM.js.map} +0 -0
  186. /package/dist/{chunk-JRWOHH7K.js.map → chunk-FVHFBEXH.js.map} +0 -0
  187. /package/dist/{chunk-WBQ3NOH7.js.map → chunk-KL6ZDLDF.js.map} +0 -0
  188. /package/dist/{chunk-FZT7BYNF.js.map → chunk-LM6NDYGD.js.map} +0 -0
  189. /package/dist/{chunk-5M4PS3XX.js.map → chunk-S3NZZKNU.js.map} +0 -0
  190. /package/dist/{chunk-CGUSNV6R.js.map → chunk-UVGFICZT.js.map} +0 -0
  191. /package/dist/{chunk-5EES5HD4.js.map → chunk-YUVCH2LX.js.map} +0 -0
  192. /package/dist/{chunk-FLSEJSTN.js.map → chunk-Z5FN5VTC.js.map} +0 -0
  193. /package/dist/{chunk-WX5UCLL7.js.map → chunk-ZSZ24UY6.js.map} +0 -0
@@ -0,0 +1,92 @@
1
+ 'use client'
2
+
3
+ import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine'
4
+ import { draggable } from '@atlaskit/pragmatic-drag-and-drop/element/adapter'
5
+ import { disableNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview'
6
+ import { type KeyboardEvent, useCallback, useEffect, useState } from 'react'
7
+ import { holdMoveDragEffect } from '../../../utils/drag-effect'
8
+ import { SORTABLE_ITEM_ATTRIBUTE, useSortableListContext } from './sortable-list'
9
+
10
+ export interface SortableItem {
11
+ /** Goes on the item's root element — the thing that moves. */
12
+ itemRef: (node: HTMLElement | null) => void
13
+ /**
14
+ * Goes on the grip. Only the grip starts a drag, so text selection and normal
15
+ * clicking inside the item keep working, and it carries the keyboard
16
+ * alternative — so spread it rather than picking it apart.
17
+ */
18
+ dragHandleProps: {
19
+ // Callback refs, not `Ref<HTMLElement>`: a ref OBJECT of the wider type
20
+ // cannot be attached to a `<button>` or a `<div>`, a callback taking the
21
+ // wider type can.
22
+ ref: (node: HTMLElement | null) => void
23
+ onKeyDown: (event: KeyboardEvent<HTMLElement>) => void
24
+ }
25
+ isDragging: boolean
26
+ }
27
+
28
+ /**
29
+ * Registers one item of a {@link SortableList}.
30
+ *
31
+ * The item's own element is the draggable, and the list finds it by the marker
32
+ * this hook sets — so nothing about a row's identity has to survive a round trip
33
+ * through the DOM, and there is no per-item id to mismatch during hydration.
34
+ *
35
+ * Pragmatic drag and drop deliberately ships no keyboard dragging, so the grip
36
+ * carries its own: Arrow Up / Arrow Down move the item one place. One press, one
37
+ * move — no lift-and-place mode to get stuck in, and it works identically for
38
+ * screen-reader users, who hear the result from the list's live region.
39
+ */
40
+ export function useSortableItem(): SortableItem {
41
+ const { dragType, disabled, reorder, readItems } = useSortableListContext()
42
+ // State rather than refs: registration has to wait until the consumer has
43
+ // actually rendered its grip, and only a re-render tells us it did.
44
+ const [item, setItem] = useState<HTMLElement | null>(null)
45
+ const [handle, setHandle] = useState<HTMLElement | null>(null)
46
+ const [isDragging, setIsDragging] = useState(false)
47
+
48
+ const itemRef = useCallback((node: HTMLElement | null) => {
49
+ // Set here rather than rendered as a prop: it is this module's private
50
+ // bookkeeping, and a consumer forgetting to spread it would break the list
51
+ // silently.
52
+ node?.setAttribute(SORTABLE_ITEM_ATTRIBUTE, '')
53
+ setItem(node)
54
+ }, [])
55
+
56
+ useEffect(() => {
57
+ if (!item || !handle || disabled) return
58
+ return combine(
59
+ // The drag has to start as a "move", or its first frame is drawn with the
60
+ // copy cursor — see `drag-effect.ts`.
61
+ holdMoveDragEffect(item),
62
+ draggable({
63
+ element: item,
64
+ dragHandle: handle,
65
+ getInitialData: () => ({ type: dragType }),
66
+ // The list moves the real item instead — see `SortableList`.
67
+ onGenerateDragPreview: ({ nativeSetDragImage }) => disableNativeDragPreview({ nativeSetDragImage }),
68
+ onDragStart: () => setIsDragging(true),
69
+ onDrop: () => setIsDragging(false),
70
+ }),
71
+ )
72
+ }, [item, handle, disabled, dragType])
73
+
74
+ const onKeyDown = useCallback(
75
+ (event: KeyboardEvent<HTMLElement>) => {
76
+ const step = event.key === 'ArrowUp' ? -1 : event.key === 'ArrowDown' ? 1 : 0
77
+ if (!step || disabled) return
78
+ const items = readItems()
79
+ const from = items.indexOf(event.currentTarget.closest(`[${SORTABLE_ITEM_ATTRIBUTE}]`) as HTMLElement)
80
+ const to = from + step
81
+ if (from < 0 || to < 0 || to >= items.length) return
82
+ event.preventDefault()
83
+ reorder(from, to)
84
+ // The grip is re-rendered at its new position; keep the focus on it so a
85
+ // run of presses keeps moving the same item.
86
+ requestAnimationFrame(() => handle?.focus())
87
+ },
88
+ [disabled, readItems, reorder, handle],
89
+ )
90
+
91
+ return { itemRef, dragHandleProps: { ref: setHandle, onKeyDown }, isDragging }
92
+ }
@@ -36,6 +36,7 @@ import { VideoPlayBadge, VideoUnmuteGlyph } from './video-center-badge';
36
36
  import { fetchPriorityProp } from '../../utils/fetch-priority';
37
37
  import { useIosNativeVideoFullscreen } from './use-ios-native-video-fullscreen';
38
38
  import { saveDataEnabled } from './use-video-warmup';
39
+ import { useAuthedAssetSrc } from '../../hooks/use-authed-asset-src';
39
40
 
40
41
  // =============================================================================
41
42
  // Dev-only hover→playing latency instrumentation gate. Always on in dev
@@ -647,6 +648,16 @@ function FilePlayer({
647
648
  // an early manifest fetch is at most one bounded manifest+segment — the
648
649
  // Save-Data verification gate covers it (see plan A2.4).
649
650
  const effectivePreload = preload ?? (saveDataEnabled() ? 'none' : 'metadata');
651
+ // THE captions seam. `<track src>` is a browser subresource: it carries no
652
+ // custom headers, so it authenticates by cookie only. Fine on the cookie-auth
653
+ // web, a guaranteed 401 on every HEADER-auth host — native shells and
654
+ // dev-ticket web — whose caption route sits behind the same proxied
655
+ // `/content/api/captions` path as every other embedded endpoint. Resolving it
656
+ // through `useAuthedAssetSrc` puts the track on the SAME single auth knob as
657
+ // every embedded `fetch` (adapter bearer + 401-refresh-retry), so a host
658
+ // configures `endpoints.captionsUrlPrefix` and nothing else — no per-surface,
659
+ // per-host caption plumbing. Cookie-auth hosts get the URL back untouched.
660
+ const resolvedCaptionsUrl = useAuthedAssetSrc(captionsUrl, 'text/vtt, */*');
650
661
  // True while hover playback is running MUTED because the browser's autoplay
651
662
  // policy blocked sound (no user activation yet). Drives the center unmute
652
663
  // control — the industry pattern (muted autoplay + explicit unmute button)
@@ -1030,10 +1041,10 @@ function FilePlayer({
1030
1041
  ...(fit === 'cover' ? ({ '--media-object-fit': 'cover' } as React.CSSProperties) : {}),
1031
1042
  }}
1032
1043
  >
1033
- {captionsUrl ? (
1044
+ {resolvedCaptionsUrl ? (
1034
1045
  <track
1035
1046
  kind="captions"
1036
- src={captionsUrl}
1047
+ src={resolvedCaptionsUrl}
1037
1048
  srcLang="en"
1038
1049
  label="English"
1039
1050
  default
@@ -80,6 +80,11 @@ const SquareAvatar = React.memo(React.forwardRef<HTMLDivElement, SquareAvatarPro
80
80
  {resolvedSrc && (
81
81
  <Image
82
82
  className="absolute -inset-px h-[calc(100%+2px)] w-[calc(100%+2px)] max-w-none object-cover"
83
+ // Images are draggable by default, and a draggable child WINS over a
84
+ // draggable ancestor: an avatar inside a drag-and-drop card lets the
85
+ // browser start its own "drag this picture" instead of the card's
86
+ // drag, so grabbing a card by its assignee did nothing.
87
+ draggable={false}
83
88
  src={resolvedSrc}
84
89
  alt={alt || ''}
85
90
  width={sizePx ?? sizePxBySize[size]}
@@ -8,6 +8,7 @@ export * from './use-copy-to-clipboard'
8
8
  // Image authentication hooks
9
9
  export * from './use-batch-images'
10
10
  export * from './use-authenticated-image'
11
+ export * from './use-authed-asset-src'
11
12
  export * from './use-authed-image-src'
12
13
 
13
14
  // URL State Management hooks
@@ -0,0 +1,98 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useReducer } from 'react'
4
+ import { embedAuthedFetch, needsBearerAssetFetch } from '../utils/embed-authed-fetch'
5
+
6
+ /**
7
+ * Resolve ANY asset URL the browser would load natively — `<img src>`,
8
+ * `<track src>`, a font, a poster — for hosts whose auth rides in request
9
+ * HEADERS instead of cookies: native shells (`capacitor://`, `tauri://`) and
10
+ * dev-ticket web, both in bearer mode. A native subresource load can't carry
11
+ * an `Authorization` header, so a gateway URL that works on the cookie-auth
12
+ * web 401s there.
13
+ *
14
+ * When `needsBearerAssetFetch` says the URL is bearer-authed, this hook
15
+ * fetches it through `embedAuthedFetch` (bearer + deduped 401-refresh-retry +
16
+ * the adapter's cross-origin guard — the SAME single auth knob every embedded
17
+ * `fetch` in the lib rides) and returns a blob object-URL. Every other URL is
18
+ * returned unchanged, so on the cookie-auth web the hook is a pass-through.
19
+ *
20
+ * Returns `undefined` while the fetch is in flight OR after it fails, so
21
+ * callers show their existing placeholder / "no captions" branch instead of a
22
+ * broken asset; a failed fetch retries on the next mount.
23
+ *
24
+ * Cache: module-level, session-lifetime, keyed by full URL — so the two
25
+ * `<track>` URLs of one player, or the same avatar in twenty rows, cost one
26
+ * request. Gateway URLs carry a `?v=<content-hash>` cache-buster, so changed
27
+ * content is a new key; entries are never revoked (a VTT / avatar is a few KB
28
+ * — refcount churn isn't worth it) and are dropped wholesale at session end
29
+ * via `clearAuthedAssetCache`.
30
+ */
31
+
32
+ const resolvedCache = new Map<string, string>()
33
+ const inFlight = new Map<string, Promise<void>>()
34
+ let cacheGeneration = 0
35
+
36
+ /**
37
+ * Drop every cached blob and revoke its object URL. Hosts call this at
38
+ * session end (logout / forced re-login) so a follow-on login as a
39
+ * different identity cannot be served blobs fetched under the previous
40
+ * one's bearer. Fetches still in flight when the clear happens are fenced
41
+ * by a generation counter — their results are revoked instead of cached.
42
+ */
43
+ export function clearAuthedAssetCache(): void {
44
+ cacheGeneration++
45
+ for (const url of resolvedCache.values()) URL.revokeObjectURL(url)
46
+ resolvedCache.clear()
47
+ inFlight.clear()
48
+ }
49
+
50
+ function fetchAsBlobUrl(src: string, accept: string): Promise<void> {
51
+ let pending = inFlight.get(src)
52
+ if (!pending) {
53
+ const startedGeneration = cacheGeneration
54
+ pending = embedAuthedFetch(src, { headers: { Accept: accept } })
55
+ .then(async response => {
56
+ if (!response.ok) throw new Error(`asset fetch failed: ${response.status}`)
57
+ const blobUrl = URL.createObjectURL(await response.blob())
58
+ if (startedGeneration === cacheGeneration) {
59
+ resolvedCache.set(src, blobUrl)
60
+ } else {
61
+ URL.revokeObjectURL(blobUrl)
62
+ }
63
+ })
64
+ .finally(() => {
65
+ if (inFlight.get(src) === pending) inFlight.delete(src)
66
+ })
67
+ inFlight.set(src, pending)
68
+ }
69
+ return pending
70
+ }
71
+
72
+ /**
73
+ * @param src the asset URL (relative or absolute), or null/undefined
74
+ * @param accept `Accept` header for the authed fetch — narrow it to what the
75
+ * consumer renders (`image/*`, `text/vtt`); it also replaces
76
+ * `embedAuthedFetch`'s default JSON `Content-Type` on the GET.
77
+ */
78
+ export function useAuthedAssetSrc(src?: string | null, accept = '*/*'): string | undefined {
79
+ const bearerSrc = src && needsBearerAssetFetch(src) ? src : null
80
+ const [, rerender] = useReducer((c: number) => c + 1, 0)
81
+
82
+ useEffect(() => {
83
+ if (!bearerSrc || resolvedCache.has(bearerSrc)) return
84
+ let cancelled = false
85
+ fetchAsBlobUrl(bearerSrc, accept)
86
+ .catch(() => {})
87
+ .finally(() => {
88
+ if (!cancelled) rerender()
89
+ })
90
+ return () => {
91
+ cancelled = true
92
+ }
93
+ }, [bearerSrc, accept])
94
+
95
+ if (!src) return undefined
96
+ if (!bearerSrc) return src
97
+ return resolvedCache.get(bearerSrc)
98
+ }
@@ -1,93 +1,24 @@
1
1
  'use client'
2
2
 
3
- import { useEffect, useReducer } from 'react'
4
- import { embedAuthedFetch, needsBearerAssetFetch } from '../utils/embed-authed-fetch'
3
+ import { clearAuthedAssetCache, useAuthedAssetSrc } from './use-authed-asset-src'
5
4
 
6
5
  /**
7
- * Resolve an image URL for hosts whose auth rides in request headers
8
- * instead of cookies (native shells — `capacitor://localhost`,
9
- * `tauri://localhost` — running in bearer mode). A native `<img>` load
10
- * can't carry an `Authorization` header, so a gateway image URL that
11
- * works on the cookie-auth web 401s in a shell. When
12
- * `needsBearerAssetFetch` says the URL's origin is bearer-authed, this
13
- * hook fetches it through `embedAuthedFetch` (bearer + deduped
14
- * 401-refresh-retry + the adapter's cross-origin guard) and returns a
15
- * blob object-URL; every other URL is returned unchanged, so on the
16
- * cookie-auth web the hook is a pass-through.
6
+ * Image flavor of `useAuthedAssetSrc` — see that hook for the full contract.
7
+ * Kept as its own export because it is the lib's most-used consumer (avatars,
8
+ * entity images, markdown `<img>`) and because hosts already import this name.
17
9
  *
18
- * Returns `undefined` while the fetch is in flight OR after it fails, so
19
- * callers show their existing initials/placeholder fallback instead of a
20
- * broken image; a failed fetch retries on the next mount.
21
- *
22
- * Cache: module-level, session-lifetime, keyed by full URL. Gateway image
23
- * URLs carry a `?v=<content-hash>` cache-buster, so a changed image is a
24
- * new key; entries are never revoked (avatars are a few KB — refcount
25
- * churn isn't worth it).
26
- *
27
- * Distinct from the legacy `useAuthenticatedImage`, which ALWAYS
28
- * blob-fetches with `credentials: 'include'` and its own global config.
29
- * This hook is pass-through-first and keys off the single auth knob the
30
- * lib already has: the registered `EmbedAuthAdapter`.
10
+ * Distinct from the legacy `useAuthenticatedImage`, which ALWAYS blob-fetches
11
+ * with `credentials: 'include'` and its own global config. This hook is
12
+ * pass-through-first and keys off the single auth knob the lib already has:
13
+ * the registered `EmbedAuthAdapter`.
31
14
  */
32
-
33
- const resolvedCache = new Map<string, string>()
34
- const inFlight = new Map<string, Promise<void>>()
35
- let cacheGeneration = 0
15
+ export function useAuthedImageSrc(src?: string | null): string | undefined {
16
+ return useAuthedAssetSrc(src, 'image/*')
17
+ }
36
18
 
37
19
  /**
38
- * Drop every cached blob and revoke its object URL. Hosts call this at
39
- * session end (logout / forced re-login) so a follow-on login as a
40
- * different identity cannot be served blobs fetched under the previous
41
- * one's bearer. Fetches still in flight when the clear happens are fenced
42
- * by a generation counter — their results are revoked instead of cached.
20
+ * Session-end cache drop. Now an alias of `clearAuthedAssetCache` — one cache
21
+ * backs every authed asset (images AND caption tracks), so hosts keep calling
22
+ * this single function on logout / forced re-login.
43
23
  */
44
- export function clearAuthedImageCache(): void {
45
- cacheGeneration++
46
- for (const url of resolvedCache.values()) URL.revokeObjectURL(url)
47
- resolvedCache.clear()
48
- inFlight.clear()
49
- }
50
-
51
- function fetchAsBlobUrl(src: string): Promise<void> {
52
- let pending = inFlight.get(src)
53
- if (!pending) {
54
- const startedGeneration = cacheGeneration
55
- pending = embedAuthedFetch(src, { headers: { Accept: 'image/*' } })
56
- .then(async response => {
57
- if (!response.ok) throw new Error(`image fetch failed: ${response.status}`)
58
- const blobUrl = URL.createObjectURL(await response.blob())
59
- if (startedGeneration === cacheGeneration) {
60
- resolvedCache.set(src, blobUrl)
61
- } else {
62
- URL.revokeObjectURL(blobUrl)
63
- }
64
- })
65
- .finally(() => {
66
- if (inFlight.get(src) === pending) inFlight.delete(src)
67
- })
68
- inFlight.set(src, pending)
69
- }
70
- return pending
71
- }
72
-
73
- export function useAuthedImageSrc(src?: string | null): string | undefined {
74
- const bearerSrc = src && needsBearerAssetFetch(src) ? src : null
75
- const [, rerender] = useReducer((c: number) => c + 1, 0)
76
-
77
- useEffect(() => {
78
- if (!bearerSrc || resolvedCache.has(bearerSrc)) return
79
- let cancelled = false
80
- fetchAsBlobUrl(bearerSrc)
81
- .catch(() => {})
82
- .finally(() => {
83
- if (!cancelled) rerender()
84
- })
85
- return () => {
86
- cancelled = true
87
- }
88
- }, [bearerSrc])
89
-
90
- if (!src) return undefined
91
- if (!bearerSrc) return src
92
- return resolvedCache.get(bearerSrc)
93
- }
24
+ export const clearAuthedImageCache = clearAuthedAssetCache
@@ -12,19 +12,17 @@ Storybook stories for the `TicketCard` board component, covering drag-and-drop c
12
12
  | `WithNewMessage` | `Story` | Colored "New Message" tag and tinted card border via `columnColor` |
13
13
  | `PendingClientApproval` | `Story` | Collapsed client approval row with approve/reject handlers |
14
14
  | `PendingTechApproval` | `Story` | Yellow shield admin approval header variant |
15
- | `Approved` | `Story` | Green checkmark resolved state |
15
+ | `EscalatedByUser` | `Story` | Escalation flag raised by the requester |
16
+ | `ActivityIndicators` | `Story` | The four activity states (AI working, user typing, waiting, stale) |
16
17
  | `AsLink` | `Story` | Full-card anchor overlay via `href` |
17
- | `DragDisabled` | `Story` | Pinned card — no grab cursor, sortable listeners off |
18
- | `DragOverlay` | `Story` | Drag-overlay presentation (tilted + elevated shadow) |
18
+ | `DragDisabled` | `Story` | Pinned card — no grab cursor, registers no drag |
19
19
  | `Priorities` | `Story` | All four priority colors (`low`, `medium`, `high`, `urgent`) side by side |
20
- | `Harness` | Helper | Wraps `TicketCard` in the minimal `DndContext` + `SortableContext` required by `useSortable` |
20
+ | `Harness` | Helper | Puts `TicketCard` on the column surface it normally sits on, so its border reads correctly |
21
21
 
22
22
  ## Usage Example
23
23
 
24
24
  ```typescript
25
- // Render the card in a DnD harness (as stories do)
26
- import { DndContext } from '@dnd-kit/core'
27
- import { SortableContext } from '@dnd-kit/sortable'
25
+ // The card registers its own drag and drop — no provider to wrap it in
28
26
  import { TicketCard } from '../components/features/board'
29
27
 
30
28
  const ticket = {
@@ -40,8 +38,6 @@ const ticket = {
40
38
 
41
39
  export function Example() {
42
40
  return (
43
- <DndContext>
44
- <SortableContext items={[ticket.id]}>
45
41
  <TicketCard
46
42
  ticket={ticket}
47
43
  columnId="TECH_REQUIRED"
@@ -49,12 +45,10 @@ export function Example() {
49
45
  onApprove={(ticketId, requestId) => console.log('approve', ticketId, requestId)}
50
46
  onReject={(ticketId, requestId) => console.log('reject', ticketId, requestId)}
51
47
  />
52
- </SortableContext>
53
- </DndContext>
54
48
  )
55
49
  }
56
50
  ```
57
51
 
58
- > **Note:** `TicketCard` internally calls `useSortable`, which requires both `DndContext` and `SortableContext` ancestors with the card's own `id` registered. In the app the Board provides these; in isolation (tests, stories) you must supply the `Harness` wrapper shown above.
52
+ > **Note:** `TicketCard` registers its drag and drop behaviour against its own DOM node and needs no provider around it, so it renders standalone in tests and stories. Only a `<Board>` gives it somewhere to be dropped.
59
53
 
60
54
  **Source:** [`TicketCard.stories.tsx`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/TicketCard.stories.tsx)
@@ -232,7 +232,10 @@ export const Pagination: Story = {
232
232
  render: function Render() {
233
233
  const TOTAL = 50
234
234
  const PAGE = 10
235
- const allTickets = Array.from({ length: TOTAL }, (_, i) => baseTicket(i, 'ACTIVE'))
235
+ // Built once: rebuilding per render hands every card a new object, which
236
+ // defeats the memoization the board relies on to stay smooth under a drag.
237
+ const allTickets = React.useMemo(() => Array.from({ length: TOTAL }, (_, i) => baseTicket(i, 'ACTIVE')), [])
238
+ const loadedRef = React.useRef(PAGE)
236
239
 
237
240
  const [columns, setColumns] = React.useState<BoardColumnDef[]>([
238
241
  columnFromTicketStatus('ACTIVE', allTickets.slice(0, PAGE), { total: TOTAL, hasMore: true }),
@@ -243,13 +246,19 @@ export const Pagination: Story = {
243
246
  const handleLoadMore = (columnId: string) => {
244
247
  setColumns(prev => prev.map(c => (c.id === columnId ? { ...c, isLoadingMore: true } : c)))
245
248
  setTimeout(() => {
249
+ // APPEND the next page. Re-slicing the seed from 0 also threw away every
250
+ // drop the person had made, and a drag that auto-scrolls a lane to its
251
+ // bottom loads a page mid-drag — so the card silently snapped back to
252
+ // where it started, moments after landing where it was dropped.
253
+ const from = loadedRef.current
254
+ loadedRef.current = Math.min(from + PAGE, TOTAL)
255
+ const page = allTickets.slice(from, loadedRef.current)
246
256
  setColumns(prev =>
247
- prev.map(c => {
248
- if (c.id !== columnId) return c
249
- const nextTickets = allTickets.slice(0, c.tickets.length + PAGE)
250
- const hasMore = nextTickets.length < TOTAL
251
- return { ...c, tickets: nextTickets, hasMore, isLoadingMore: false }
252
- }),
257
+ prev.map(c =>
258
+ c.id === columnId
259
+ ? { ...c, tickets: [...c.tickets, ...page], hasMore: loadedRef.current < TOTAL, isLoadingMore: false }
260
+ : c,
261
+ ),
253
262
  )
254
263
  }, 600)
255
264
  }
@@ -1,6 +1,4 @@
1
1
  import type { Meta, StoryObj } from '@storybook/nextjs-vite'
2
- import { DndContext } from '@dnd-kit/core'
3
- import { SortableContext } from '@dnd-kit/sortable'
4
2
  import * as React from 'react'
5
3
  import {
6
4
  TicketCard,
@@ -11,22 +9,17 @@ import {
11
9
  import type { PendingToolCallData } from '../components/chat/types'
12
10
 
13
11
  // =============================================================================
14
- // Harness — `TicketCard` calls `useSortable`, which reads from a `DndContext` +
15
- // `SortableContext`. In the app the Board provides these; the story supplies a
16
- // minimal pair (with the card's own id registered) so drag bookkeeping resolves
17
- // without a full board. The card renders on `bg-ods-bg`, so we pad it on the
18
- // darker `bg-ods-card` column surface to keep the border readable.
12
+ // Harness — the card registers its own drag behaviour against the DOM and needs
13
+ // no provider around it, so the story is just the card on the column surface it
14
+ // normally sits on (`bg-ods-card` behind the card's own `bg-ods-bg`, which is
15
+ // what keeps its border readable).
19
16
  // =============================================================================
20
17
 
21
18
  function Harness(args: TicketCardProps) {
22
19
  return (
23
- <DndContext>
24
- <SortableContext items={[args.ticket.id]}>
25
- <div className="w-[320px] rounded-lg bg-ods-card p-[var(--spacing-system-sf)]">
26
- <TicketCard {...args} />
27
- </div>
28
- </SortableContext>
29
- </DndContext>
20
+ <div className="w-[320px] rounded-lg bg-ods-card p-[var(--spacing-system-sf)]">
21
+ <TicketCard {...args} />
22
+ </div>
30
23
  )
31
24
  }
32
25
 
@@ -178,25 +171,21 @@ export const ActivityIndicators: Story = {
178
171
  { kind: 'stale', label: 'No activity for 2 hours' },
179
172
  ]
180
173
  return (
181
- <DndContext>
182
- <SortableContext items={activities.map((a) => `ticket-activity-${a.kind}`)}>
183
- <div className="flex w-[320px] flex-col gap-[var(--spacing-system-sf)] rounded-lg bg-ods-card p-[var(--spacing-system-sf)]">
184
- {activities.map((activity) => (
185
- <TicketCard
186
- key={activity.kind}
187
- columnId="ACTIVE"
188
- ticket={{
189
- ...BASE_TICKET,
190
- id: `ticket-activity-${activity.kind}`,
191
- priority: undefined,
192
- tags: undefined,
193
- activity,
194
- }}
195
- />
196
- ))}
197
- </div>
198
- </SortableContext>
199
- </DndContext>
174
+ <div className="flex w-[320px] flex-col gap-[var(--spacing-system-sf)] rounded-lg bg-ods-card p-[var(--spacing-system-sf)]">
175
+ {activities.map((activity) => (
176
+ <TicketCard
177
+ key={activity.kind}
178
+ columnId="ACTIVE"
179
+ ticket={{
180
+ ...BASE_TICKET,
181
+ id: `ticket-activity-${activity.kind}`,
182
+ priority: undefined,
183
+ tags: undefined,
184
+ activity,
185
+ }}
186
+ />
187
+ ))}
188
+ </div>
200
189
  )
201
190
  },
202
191
  }
@@ -242,21 +231,6 @@ export const PendingTechApproval: Story = {
242
231
  },
243
232
  }
244
233
 
245
- /** `approved` — green check mark in the header right section (resolved look). */
246
- export const Approved: Story = {
247
- args: {
248
- ticket: {
249
- id: 'ticket-approved',
250
- title: 'Slack Installation',
251
- ticketNumber: '#1042',
252
- status: 'RESOLVED',
253
- deviceHostnames: ['PR-OFFICE-02'],
254
- organizationName: 'TechFlow Solutions',
255
- },
256
- approved: true,
257
- },
258
- }
259
-
260
234
  /** `href` set — the whole card is a link (Link anchor overlays the surface). */
261
235
  export const AsLink: Story = {
262
236
  args: {
@@ -273,39 +247,27 @@ export const DragDisabled: Story = {
273
247
  },
274
248
  }
275
249
 
276
- /** `isOverlay` — the drag-overlay presentation (tilted + elevated shadow). */
277
- export const DragOverlay: Story = {
278
- args: {
279
- ticket: { ...BASE_TICKET, id: 'ticket-overlay' },
280
- isOverlay: true,
281
- },
282
- }
283
-
284
250
  /** All four priority flag colors side by side. */
285
251
  export const Priorities: Story = {
286
252
  render: () => {
287
253
  const priorities: BoardTicket['priority'][] = ['low', 'medium', 'high', 'urgent']
288
254
  return (
289
- <DndContext>
290
- <SortableContext items={priorities.map((p) => `ticket-prio-${p}`)}>
291
- <div className="flex w-[320px] flex-col gap-[var(--spacing-system-sf)] rounded-lg bg-ods-card p-[var(--spacing-system-sf)]">
292
- {priorities.map((p) => (
293
- <TicketCard
294
- key={p}
295
- columnId="ACTIVE"
296
- ticket={{
297
- ...BASE_TICKET,
298
- id: `ticket-prio-${p}`,
299
- title: `${p![0].toUpperCase()}${p!.slice(1)} priority ticket`,
300
- priority: p,
301
- tags: undefined,
302
- assignees: undefined,
303
- }}
304
- />
305
- ))}
306
- </div>
307
- </SortableContext>
308
- </DndContext>
255
+ <div className="flex w-[320px] flex-col gap-[var(--spacing-system-sf)] rounded-lg bg-ods-card p-[var(--spacing-system-sf)]">
256
+ {priorities.map((p) => (
257
+ <TicketCard
258
+ key={p}
259
+ columnId="ACTIVE"
260
+ ticket={{
261
+ ...BASE_TICKET,
262
+ id: `ticket-prio-${p}`,
263
+ title: `${p![0].toUpperCase()}${p!.slice(1)} priority ticket`,
264
+ priority: p,
265
+ tags: undefined,
266
+ assignees: undefined,
267
+ }}
268
+ />
269
+ ))}
270
+ </div>
309
271
  )
310
272
  },
311
273
  }