@coinbase/cds-mcp-server 8.17.2 → 8.17.4

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 (284) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/mcp-docs/mobile/components/Accordion.txt +188 -0
  3. package/mcp-docs/mobile/components/AccordionItem.txt +29 -0
  4. package/mcp-docs/mobile/components/Alert.txt +155 -0
  5. package/mcp-docs/mobile/components/AreaChart.txt +265 -0
  6. package/mcp-docs/mobile/components/Avatar.txt +195 -0
  7. package/mcp-docs/mobile/components/AvatarButton.txt +225 -0
  8. package/mcp-docs/mobile/components/Banner.txt +221 -0
  9. package/mcp-docs/mobile/components/BarChart.txt +815 -0
  10. package/mcp-docs/mobile/components/Box.txt +173 -0
  11. package/mcp-docs/mobile/components/BrowserBar.txt +146 -0
  12. package/mcp-docs/mobile/components/Button.txt +198 -0
  13. package/mcp-docs/mobile/components/ButtonGroup.txt +79 -0
  14. package/mcp-docs/mobile/components/Carousel.txt +1083 -0
  15. package/mcp-docs/mobile/components/CartesianChart.txt +825 -0
  16. package/mcp-docs/mobile/components/CellMedia.txt +70 -0
  17. package/mcp-docs/mobile/components/Checkbox.txt +245 -0
  18. package/mcp-docs/mobile/components/CheckboxCell.txt +201 -0
  19. package/mcp-docs/mobile/components/CheckboxGroup.txt +284 -0
  20. package/mcp-docs/mobile/components/Chip.txt +194 -0
  21. package/mcp-docs/mobile/components/Coachmark.txt +157 -0
  22. package/mcp-docs/mobile/components/Collapsible.txt +104 -0
  23. package/mcp-docs/mobile/components/ContainedAssetCard.txt +134 -0
  24. package/mcp-docs/mobile/components/ContentCard.txt +365 -0
  25. package/mcp-docs/mobile/components/ContentCardBody.txt +135 -0
  26. package/mcp-docs/mobile/components/ContentCardFooter.txt +127 -0
  27. package/mcp-docs/mobile/components/ContentCardHeader.txt +145 -0
  28. package/mcp-docs/mobile/components/ContentCell.txt +226 -0
  29. package/mcp-docs/mobile/components/ControlGroup.txt +443 -0
  30. package/mcp-docs/mobile/components/DatePicker.txt +496 -0
  31. package/mcp-docs/mobile/components/Divider.txt +138 -0
  32. package/mcp-docs/mobile/components/DotCount.txt +145 -0
  33. package/mcp-docs/mobile/components/DotStatusColor.txt +58 -0
  34. package/mcp-docs/mobile/components/DotSymbol.txt +134 -0
  35. package/mcp-docs/mobile/components/Fallback.txt +157 -0
  36. package/mcp-docs/mobile/components/FloatingAssetCard.txt +155 -0
  37. package/mcp-docs/mobile/components/HStack.txt +234 -0
  38. package/mcp-docs/mobile/components/HeroSquare.txt +47 -0
  39. package/mcp-docs/mobile/components/Icon.txt +51 -0
  40. package/mcp-docs/mobile/components/IconButton.txt +268 -0
  41. package/mcp-docs/mobile/components/InputChip.txt +187 -0
  42. package/mcp-docs/mobile/components/Interactable.txt +186 -0
  43. package/mcp-docs/mobile/components/LineChart.txt +1324 -0
  44. package/mcp-docs/mobile/components/Link.txt +291 -0
  45. package/mcp-docs/mobile/components/ListCell.txt +412 -0
  46. package/mcp-docs/mobile/components/LogoMark.txt +84 -0
  47. package/mcp-docs/mobile/components/LogoWordMark.txt +93 -0
  48. package/mcp-docs/mobile/components/Lottie.txt +138 -0
  49. package/mcp-docs/mobile/components/LottieStatusAnimation.txt +46 -0
  50. package/mcp-docs/mobile/components/Modal.txt +83 -0
  51. package/mcp-docs/mobile/components/ModalBody.txt +33 -0
  52. package/mcp-docs/mobile/components/ModalFooter.txt +24 -0
  53. package/mcp-docs/mobile/components/ModalHeader.txt +27 -0
  54. package/mcp-docs/mobile/components/MultiContentModule.txt +379 -0
  55. package/mcp-docs/mobile/components/NavigationTitle.txt +131 -0
  56. package/mcp-docs/mobile/components/NavigationTitleSelect.txt +141 -0
  57. package/mcp-docs/mobile/components/NudgeCard.txt +89 -0
  58. package/mcp-docs/mobile/components/Numpad.txt +340 -0
  59. package/mcp-docs/mobile/components/Overlay.txt +151 -0
  60. package/mcp-docs/mobile/components/PageFooter.txt +160 -0
  61. package/mcp-docs/mobile/components/PageHeader.txt +185 -0
  62. package/mcp-docs/mobile/components/PeriodSelector.txt +407 -0
  63. package/mcp-docs/mobile/components/Pictogram.txt +47 -0
  64. package/mcp-docs/mobile/components/Point.txt +204 -0
  65. package/mcp-docs/mobile/components/PortalProvider.txt +78 -0
  66. package/mcp-docs/mobile/components/Pressable.txt +210 -0
  67. package/mcp-docs/mobile/components/ProgressBar.txt +129 -0
  68. package/mcp-docs/mobile/components/ProgressBarWithFixedLabels.txt +160 -0
  69. package/mcp-docs/mobile/components/ProgressBarWithFloatLabel.txt +137 -0
  70. package/mcp-docs/mobile/components/ProgressCircle.txt +236 -0
  71. package/mcp-docs/mobile/components/Radio.txt +241 -0
  72. package/mcp-docs/mobile/components/RadioCell.txt +201 -0
  73. package/mcp-docs/mobile/components/RadioGroup.txt +281 -0
  74. package/mcp-docs/mobile/components/ReferenceLine.txt +152 -0
  75. package/mcp-docs/mobile/components/RemoteImage.txt +105 -0
  76. package/mcp-docs/mobile/components/RemoteImageGroup.txt +60 -0
  77. package/mcp-docs/mobile/components/RollingNumber.txt +788 -0
  78. package/mcp-docs/mobile/components/Scrubber.txt +203 -0
  79. package/mcp-docs/mobile/components/SearchInput.txt +191 -0
  80. package/mcp-docs/mobile/components/SectionHeader.txt +204 -0
  81. package/mcp-docs/mobile/components/SegmentedTabs.txt +315 -0
  82. package/mcp-docs/mobile/components/Select.txt +211 -0
  83. package/mcp-docs/mobile/components/SelectChip.txt +323 -0
  84. package/mcp-docs/mobile/components/SelectOption.txt +84 -0
  85. package/mcp-docs/mobile/components/SlideButton.txt +330 -0
  86. package/mcp-docs/mobile/components/Spacer.txt +83 -0
  87. package/mcp-docs/mobile/components/Sparkline.txt +122 -0
  88. package/mcp-docs/mobile/components/SparklineGradient.txt +106 -0
  89. package/mcp-docs/mobile/components/SparklineInteractive.txt +156 -0
  90. package/mcp-docs/mobile/components/SparklineInteractiveHeader.txt +72 -0
  91. package/mcp-docs/mobile/components/Spinner.txt +48 -0
  92. package/mcp-docs/mobile/components/SpotIcon.txt +47 -0
  93. package/mcp-docs/mobile/components/SpotRectangle.txt +47 -0
  94. package/mcp-docs/mobile/components/SpotSquare.txt +47 -0
  95. package/mcp-docs/mobile/components/Stepper.txt +527 -0
  96. package/mcp-docs/mobile/components/SubBrandLogoMark.txt +125 -0
  97. package/mcp-docs/mobile/components/SubBrandLogoWordMark.txt +125 -0
  98. package/mcp-docs/mobile/components/Switch.txt +97 -0
  99. package/mcp-docs/mobile/components/TabIndicator.txt +48 -0
  100. package/mcp-docs/mobile/components/TabLabel.txt +153 -0
  101. package/mcp-docs/mobile/components/TabNavigation.txt +146 -0
  102. package/mcp-docs/mobile/components/TabbedChips.txt +142 -0
  103. package/mcp-docs/mobile/components/Tabs.txt +190 -0
  104. package/mcp-docs/mobile/components/Tag.txt +300 -0
  105. package/mcp-docs/mobile/components/Text.txt +211 -0
  106. package/mcp-docs/mobile/components/TextInput.txt +717 -0
  107. package/mcp-docs/mobile/components/ThemeProvider.txt +132 -0
  108. package/mcp-docs/mobile/components/Toast.txt +196 -0
  109. package/mcp-docs/mobile/components/Tooltip.txt +59 -0
  110. package/mcp-docs/mobile/components/TopNavBar.txt +161 -0
  111. package/mcp-docs/mobile/components/Tour.txt +158 -0
  112. package/mcp-docs/mobile/components/Tray.txt +252 -0
  113. package/mcp-docs/mobile/components/UpsellCard.txt +321 -0
  114. package/mcp-docs/mobile/components/VStack.txt +222 -0
  115. package/mcp-docs/mobile/components/XAxis.txt +621 -0
  116. package/mcp-docs/mobile/components/YAxis.txt +567 -0
  117. package/mcp-docs/mobile/getting-started/ai-overview.txt +108 -0
  118. package/mcp-docs/mobile/getting-started/installation.txt +57 -0
  119. package/mcp-docs/mobile/getting-started/introduction.txt +102 -0
  120. package/mcp-docs/mobile/getting-started/playground.txt +28 -0
  121. package/mcp-docs/mobile/getting-started/styling.txt +84 -0
  122. package/mcp-docs/mobile/getting-started/theming.txt +286 -0
  123. package/mcp-docs/mobile/hooks/useDimensions.txt +72 -0
  124. package/mcp-docs/mobile/hooks/useEventHandler.txt +120 -0
  125. package/mcp-docs/mobile/hooks/useMergeRefs.txt +116 -0
  126. package/mcp-docs/mobile/hooks/useOverlayContentContext.txt +280 -0
  127. package/mcp-docs/mobile/hooks/usePreviousValue.txt +74 -0
  128. package/mcp-docs/mobile/hooks/useRefMap.txt +178 -0
  129. package/mcp-docs/mobile/hooks/useTheme.txt +321 -0
  130. package/mcp-docs/mobile/routes.txt +139 -0
  131. package/mcp-docs/web/components/Accordion.txt +189 -0
  132. package/mcp-docs/web/components/AccordionItem.txt +31 -0
  133. package/mcp-docs/web/components/Alert.txt +164 -0
  134. package/mcp-docs/web/components/AreaChart.txt +510 -0
  135. package/mcp-docs/web/components/Avatar.txt +211 -0
  136. package/mcp-docs/web/components/AvatarButton.txt +240 -0
  137. package/mcp-docs/web/components/Banner.txt +226 -0
  138. package/mcp-docs/web/components/BarChart.txt +1267 -0
  139. package/mcp-docs/web/components/Box.txt +175 -0
  140. package/mcp-docs/web/components/Button.txt +212 -0
  141. package/mcp-docs/web/components/ButtonGroup.txt +79 -0
  142. package/mcp-docs/web/components/Calendar.txt +181 -0
  143. package/mcp-docs/web/components/Carousel.txt +1575 -0
  144. package/mcp-docs/web/components/CartesianChart.txt +1044 -0
  145. package/mcp-docs/web/components/CellMedia.txt +56 -0
  146. package/mcp-docs/web/components/Checkbox.txt +188 -0
  147. package/mcp-docs/web/components/CheckboxCell.txt +202 -0
  148. package/mcp-docs/web/components/CheckboxGroup.txt +219 -0
  149. package/mcp-docs/web/components/Chip.txt +196 -0
  150. package/mcp-docs/web/components/Coachmark.txt +188 -0
  151. package/mcp-docs/web/components/Collapsible.txt +119 -0
  152. package/mcp-docs/web/components/ContainedAssetCard.txt +232 -0
  153. package/mcp-docs/web/components/ContentCard.txt +367 -0
  154. package/mcp-docs/web/components/ContentCardBody.txt +137 -0
  155. package/mcp-docs/web/components/ContentCardFooter.txt +129 -0
  156. package/mcp-docs/web/components/ContentCardHeader.txt +147 -0
  157. package/mcp-docs/web/components/ContentCell.txt +219 -0
  158. package/mcp-docs/web/components/ControlGroup.txt +436 -0
  159. package/mcp-docs/web/components/DatePicker.txt +505 -0
  160. package/mcp-docs/web/components/Divider.txt +143 -0
  161. package/mcp-docs/web/components/DotCount.txt +149 -0
  162. package/mcp-docs/web/components/DotStatusColor.txt +58 -0
  163. package/mcp-docs/web/components/DotSymbol.txt +137 -0
  164. package/mcp-docs/web/components/Dropdown.txt +119 -0
  165. package/mcp-docs/web/components/Fallback.txt +163 -0
  166. package/mcp-docs/web/components/FloatingAssetCard.txt +250 -0
  167. package/mcp-docs/web/components/FullscreenAlert.txt +69 -0
  168. package/mcp-docs/web/components/FullscreenModal.txt +145 -0
  169. package/mcp-docs/web/components/FullscreenModalLayout.txt +187 -0
  170. package/mcp-docs/web/components/Grid.txt +236 -0
  171. package/mcp-docs/web/components/GridColumn.txt +209 -0
  172. package/mcp-docs/web/components/HStack.txt +236 -0
  173. package/mcp-docs/web/components/HeroSquare.txt +48 -0
  174. package/mcp-docs/web/components/Icon.txt +145 -0
  175. package/mcp-docs/web/components/IconButton.txt +390 -0
  176. package/mcp-docs/web/components/InputChip.txt +187 -0
  177. package/mcp-docs/web/components/Interactable.txt +193 -0
  178. package/mcp-docs/web/components/LineChart.txt +1576 -0
  179. package/mcp-docs/web/components/Link.txt +243 -0
  180. package/mcp-docs/web/components/ListCell.txt +418 -0
  181. package/mcp-docs/web/components/LogoMark.txt +84 -0
  182. package/mcp-docs/web/components/LogoWordMark.txt +93 -0
  183. package/mcp-docs/web/components/Lottie.txt +157 -0
  184. package/mcp-docs/web/components/LottieStatusAnimation.txt +57 -0
  185. package/mcp-docs/web/components/MediaQueryProvider.txt +108 -0
  186. package/mcp-docs/web/components/Modal.txt +196 -0
  187. package/mcp-docs/web/components/ModalBody.txt +117 -0
  188. package/mcp-docs/web/components/ModalFooter.txt +119 -0
  189. package/mcp-docs/web/components/ModalHeader.txt +123 -0
  190. package/mcp-docs/web/components/MultiContentModule.txt +381 -0
  191. package/mcp-docs/web/components/NavigationBar.txt +102 -0
  192. package/mcp-docs/web/components/NavigationTitle.txt +25 -0
  193. package/mcp-docs/web/components/NavigationTitleSelect.txt +45 -0
  194. package/mcp-docs/web/components/NudgeCard.txt +181 -0
  195. package/mcp-docs/web/components/Overlay.txt +171 -0
  196. package/mcp-docs/web/components/PageFooter.txt +184 -0
  197. package/mcp-docs/web/components/PageHeader.txt +243 -0
  198. package/mcp-docs/web/components/Pagination.txt +499 -0
  199. package/mcp-docs/web/components/PeriodSelector.txt +703 -0
  200. package/mcp-docs/web/components/Pictogram.txt +48 -0
  201. package/mcp-docs/web/components/Point.txt +460 -0
  202. package/mcp-docs/web/components/PortalProvider.txt +76 -0
  203. package/mcp-docs/web/components/Pressable.txt +193 -0
  204. package/mcp-docs/web/components/ProgressBar.txt +163 -0
  205. package/mcp-docs/web/components/ProgressBarWithFixedLabels.txt +212 -0
  206. package/mcp-docs/web/components/ProgressBarWithFloatLabel.txt +181 -0
  207. package/mcp-docs/web/components/ProgressCircle.txt +443 -0
  208. package/mcp-docs/web/components/Radio.txt +219 -0
  209. package/mcp-docs/web/components/RadioCell.txt +215 -0
  210. package/mcp-docs/web/components/RadioGroup.txt +288 -0
  211. package/mcp-docs/web/components/ReferenceLine.txt +451 -0
  212. package/mcp-docs/web/components/RemoteImage.txt +165 -0
  213. package/mcp-docs/web/components/RemoteImageGroup.txt +86 -0
  214. package/mcp-docs/web/components/RollingNumber.txt +1021 -0
  215. package/mcp-docs/web/components/Scrubber.txt +231 -0
  216. package/mcp-docs/web/components/SearchInput.txt +117 -0
  217. package/mcp-docs/web/components/SectionHeader.txt +217 -0
  218. package/mcp-docs/web/components/SegmentedTabs.txt +324 -0
  219. package/mcp-docs/web/components/Select.txt +224 -0
  220. package/mcp-docs/web/components/SelectChip.txt +314 -0
  221. package/mcp-docs/web/components/SelectOption.txt +165 -0
  222. package/mcp-docs/web/components/Sidebar.txt +349 -0
  223. package/mcp-docs/web/components/SidebarItem.txt +131 -0
  224. package/mcp-docs/web/components/SidebarMoreMenu.txt +30 -0
  225. package/mcp-docs/web/components/Spacer.txt +173 -0
  226. package/mcp-docs/web/components/Sparkline.txt +122 -0
  227. package/mcp-docs/web/components/SparklineGradient.txt +106 -0
  228. package/mcp-docs/web/components/SparklineInteractive.txt +153 -0
  229. package/mcp-docs/web/components/SparklineInteractiveHeader.txt +76 -0
  230. package/mcp-docs/web/components/Spinner.txt +128 -0
  231. package/mcp-docs/web/components/SpotIcon.txt +48 -0
  232. package/mcp-docs/web/components/SpotRectangle.txt +48 -0
  233. package/mcp-docs/web/components/SpotSquare.txt +48 -0
  234. package/mcp-docs/web/components/Stepper.txt +682 -0
  235. package/mcp-docs/web/components/SubBrandLogoMark.txt +125 -0
  236. package/mcp-docs/web/components/SubBrandLogoWordMark.txt +125 -0
  237. package/mcp-docs/web/components/Switch.txt +85 -0
  238. package/mcp-docs/web/components/TabIndicator.txt +48 -0
  239. package/mcp-docs/web/components/TabLabel.txt +158 -0
  240. package/mcp-docs/web/components/TabNavigation.txt +159 -0
  241. package/mcp-docs/web/components/TabbedChips.txt +155 -0
  242. package/mcp-docs/web/components/Table.txt +367 -0
  243. package/mcp-docs/web/components/TableBody.txt +83 -0
  244. package/mcp-docs/web/components/TableCaption.txt +102 -0
  245. package/mcp-docs/web/components/TableCell.txt +165 -0
  246. package/mcp-docs/web/components/TableCellFallback.txt +97 -0
  247. package/mcp-docs/web/components/TableFooter.txt +83 -0
  248. package/mcp-docs/web/components/TableHeader.txt +100 -0
  249. package/mcp-docs/web/components/TableRow.txt +140 -0
  250. package/mcp-docs/web/components/Tabs.txt +212 -0
  251. package/mcp-docs/web/components/Tag.txt +304 -0
  252. package/mcp-docs/web/components/Text.txt +232 -0
  253. package/mcp-docs/web/components/TextInput.txt +652 -0
  254. package/mcp-docs/web/components/ThemeProvider.txt +199 -0
  255. package/mcp-docs/web/components/TileButton.txt +158 -0
  256. package/mcp-docs/web/components/Toast.txt +203 -0
  257. package/mcp-docs/web/components/Tooltip.txt +89 -0
  258. package/mcp-docs/web/components/Tour.txt +179 -0
  259. package/mcp-docs/web/components/Tray.txt +288 -0
  260. package/mcp-docs/web/components/UpsellCard.txt +319 -0
  261. package/mcp-docs/web/components/VStack.txt +224 -0
  262. package/mcp-docs/web/components/XAxis.txt +619 -0
  263. package/mcp-docs/web/components/YAxis.txt +548 -0
  264. package/mcp-docs/web/getting-started/ai-overview.txt +108 -0
  265. package/mcp-docs/web/getting-started/installation.txt +103 -0
  266. package/mcp-docs/web/getting-started/introduction.txt +102 -0
  267. package/mcp-docs/web/getting-started/playground.txt +28 -0
  268. package/mcp-docs/web/getting-started/styling.txt +161 -0
  269. package/mcp-docs/web/getting-started/templates.txt +121 -0
  270. package/mcp-docs/web/getting-started/theming.txt +426 -0
  271. package/mcp-docs/web/hooks/useBreakpoints.txt +61 -0
  272. package/mcp-docs/web/hooks/useDimensions.txt +114 -0
  273. package/mcp-docs/web/hooks/useEventHandler.txt +120 -0
  274. package/mcp-docs/web/hooks/useHasMounted.txt +75 -0
  275. package/mcp-docs/web/hooks/useIsoEffect.txt +58 -0
  276. package/mcp-docs/web/hooks/useMediaQuery.txt +114 -0
  277. package/mcp-docs/web/hooks/useMergeRefs.txt +116 -0
  278. package/mcp-docs/web/hooks/useOverlayContentContext.txt +279 -0
  279. package/mcp-docs/web/hooks/usePreviousValue.txt +74 -0
  280. package/mcp-docs/web/hooks/useRefMap.txt +178 -0
  281. package/mcp-docs/web/hooks/useScrollBlocker.txt +82 -0
  282. package/mcp-docs/web/hooks/useTheme.txt +364 -0
  283. package/mcp-docs/web/routes.txt +163 -0
  284. package/package.json +1 -1
@@ -0,0 +1,279 @@
1
+ # useOverlayContentContext
2
+
3
+ A React context and hook for detecting if components are rendered inside overlay containers like modals, drawers, tours, and trays.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { OverlayContentContext, useOverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext'
9
+ ```
10
+
11
+ ## API
12
+
13
+ ### Parameters
14
+
15
+ The `useOverlayContentContext` hook accepts no parameters.
16
+
17
+ ### Returns
18
+
19
+ Returns an `OverlayContentContextValue` object with overlay state information:
20
+
21
+ - `isOverlay?: boolean` - True if inside any overlay component (automatically derived from other values if not explicitly set)
22
+ - `isModal?: boolean` - True if inside a Modal component
23
+ - `isDrawer?: boolean` - True if inside a Drawer or Tray component
24
+ - `isTour?: boolean` - True if inside a Tour component
25
+
26
+ All properties are optional and will be `undefined` when outside of overlay contexts.
27
+
28
+ :::tip
29
+ This hook is safe to use anywhere in your component tree - it does not throw an error when used outside a provider. When `isOverlay` is not explicitly provided, it will be automatically derived as `true` if any of the other overlay type flags are `true`.
30
+ :::
31
+
32
+ ### OverlayContentContext
33
+
34
+ The React context that provides overlay state information. Can be used directly with `React.useContext` or through the `useOverlayContentContext` hook.
35
+
36
+ #### Context Value Type
37
+
38
+ ```typescript
39
+ type OverlayContentContextValue = {
40
+ isOverlay?: boolean;
41
+ isModal?: boolean;
42
+ isDrawer?: boolean;
43
+ isTour?: boolean;
44
+ };
45
+ ```
46
+
47
+ ### Provider Usage
48
+
49
+ ```tsx
50
+ import { OverlayContentContext } from '@coinbase/cds-common/overlays/OverlayContentContext';
51
+
52
+ function MyOverlayComponent() {
53
+ const contextValue = {
54
+ isModal: true,
55
+ isDrawer: false,
56
+ isTour: false,
57
+ // isOverlay will be automatically derived as true
58
+ };
59
+
60
+ return (
61
+ <OverlayContentContext.Provider value={contextValue}>
62
+ {/* Your overlay content */}
63
+ </OverlayContentContext.Provider>
64
+ );
65
+ }
66
+ ```
67
+
68
+ ### Automatic Derivation
69
+
70
+ If `isOverlay` is not explicitly provided in the context value, it will be automatically derived as `true` when any of `isModal`, `isDrawer`, or `isTour` is `true`. This ensures consistent behavior across the system.
71
+
72
+ **Important**: When adding new overlay types to the `OverlayContentContextValue` type, remember to update the derivation logic in the `useOverlayContentContext` hook.
73
+
74
+ ## Examples
75
+
76
+ The `useOverlayContentContext` hook provides information about whether a component is rendered inside various types of overlay containers. This is useful for conditional rendering and styling based on the overlay context.
77
+
78
+ ### Basic usage
79
+
80
+ ```tsx live
81
+ function ExampleComponent() {
82
+ const { isOverlay, isModal, isDrawer, isTour } = useOverlayContentContext();
83
+
84
+ return (
85
+ <VStack gap={2}>
86
+ <TextHeadline>Overlay Context Information</TextHeadline>
87
+ <Text>Is inside any overlay: {isOverlay ? 'Yes' : 'No'}</Text>
88
+ <Text>Is inside modal: {isModal ? 'Yes' : 'No'}</Text>
89
+ <Text>Is inside drawer/tray: {isDrawer ? 'Yes' : 'No'}</Text>
90
+ <Text>Is inside tour: {isTour ? 'Yes' : 'No'}</Text>
91
+ </VStack>
92
+ );
93
+ }
94
+ ```
95
+
96
+ ### Real Modal Example
97
+
98
+ Click the button below to open a modal and see how the hook behaves inside vs outside:
99
+
100
+ ```tsx live
101
+ function ModalExample() {
102
+ const [isModalOpen, setIsModalOpen] = useState(false);
103
+
104
+ const ExampleComponent = () => {
105
+ const { isOverlay, isModal, isDrawer, isTour } = useOverlayContentContext();
106
+
107
+ return (
108
+ <VStack gap={2}>
109
+ <TextHeadline>Overlay Context Information</TextHeadline>
110
+ <Text>Is inside any overlay: {isOverlay ? 'Yes' : 'No'}</Text>
111
+ <Text>Is inside modal: {isModal ? 'Yes' : 'No'}</Text>
112
+ <Text>Is inside drawer/tray: {isDrawer ? 'Yes' : 'No'}</Text>
113
+ <Text>Is inside tour: {isTour ? 'Yes' : 'No'}</Text>
114
+ </VStack>
115
+ );
116
+ };
117
+
118
+ return (
119
+ <VStack gap={3}>
120
+ <VStack gap={2} padding={3} background="bgSecondary" borderRadius={400}>
121
+ <TextHeadline>Outside Modal</TextHeadline>
122
+ <ExampleComponent />
123
+ </VStack>
124
+
125
+ <Button onClick={() => setIsModalOpen(true)}>Open Modal</Button>
126
+
127
+ <Modal visible={isModalOpen} onRequestClose={() => setIsModalOpen(false)}>
128
+ <ModalHeader closeAccessibilityLabel="Close" title="Modal with Context Hook" />
129
+ <ModalBody>
130
+ <VStack gap={3}>
131
+ <Text>
132
+ This content is rendered inside a modal. Notice how the context values change:
133
+ </Text>
134
+ <VStack gap={2} padding={3} background="bgAlternate" borderRadius={400}>
135
+ <ExampleComponent />
136
+ </VStack>
137
+ <Text color="fgMuted" font="caption">
138
+ The hook automatically detects it's inside a modal context!
139
+ </Text>
140
+ </VStack>
141
+ </ModalBody>
142
+ </Modal>
143
+ </VStack>
144
+ );
145
+ }
146
+ ```
147
+
148
+ ### Using the Context Provider
149
+
150
+ You can also use the `OverlayContentContext` directly to provide context values:
151
+
152
+ ```tsx live
153
+ function ContextProviderExample() {
154
+ const ExampleComponent = () => {
155
+ const { isOverlay, isModal, isDrawer, isTour } = useOverlayContentContext();
156
+
157
+ return (
158
+ <VStack gap={2}>
159
+ <TextHeadline>Overlay Context Information</TextHeadline>
160
+ <Text>Is inside any overlay: {isOverlay ? 'Yes' : 'No'}</Text>
161
+ <Text>Is inside modal: {isModal ? 'Yes' : 'No'}</Text>
162
+ <Text>Is inside drawer/tray: {isDrawer ? 'Yes' : 'No'}</Text>
163
+ <Text>Is inside tour: {isTour ? 'Yes' : 'No'}</Text>
164
+ </VStack>
165
+ );
166
+ };
167
+
168
+ const contextValue = {
169
+ isModal: true,
170
+ isDrawer: false,
171
+ isTour: false,
172
+ };
173
+
174
+ return (
175
+ <OverlayContentContext.Provider value={contextValue}>
176
+ <VStack gap={2} padding={3} background="bgSecondary" borderRadius={400}>
177
+ <TextHeadline>Inside Context Provider</TextHeadline>
178
+ <ExampleComponent />
179
+ </VStack>
180
+ </OverlayContentContext.Provider>
181
+ );
182
+ }
183
+ ```
184
+
185
+ ### Conditional Rendering
186
+
187
+ Use the hook to conditionally render content based on overlay context:
188
+
189
+ ```tsx live
190
+ function ConditionalRenderingExample() {
191
+ const [isModalOpen, setIsModalOpen] = useState(false);
192
+
193
+ const ConditionalContent = () => {
194
+ const { isOverlay, isModal } = useOverlayContentContext();
195
+
196
+ return (
197
+ <VStack gap={2}>
198
+ <TextHeadline>Conditional Content</TextHeadline>
199
+ {isOverlay ? (
200
+ <VStack gap={1}>
201
+ <Text color="fgPositive">✓ This content shows when inside an overlay</Text>
202
+ {isModal && <Text color="fgPrimary">🎯 Specifically inside a modal!</Text>}
203
+ </VStack>
204
+ ) : (
205
+ <Text color="fgMuted">This content shows when not in an overlay</Text>
206
+ )}
207
+ </VStack>
208
+ );
209
+ };
210
+
211
+ return (
212
+ <VStack gap={3}>
213
+ <VStack gap={2} padding={3} background="bgSecondary" borderRadius={400}>
214
+ <TextHeadline>Outside Modal</TextHeadline>
215
+ <ConditionalContent />
216
+ </VStack>
217
+
218
+ <Button onClick={() => setIsModalOpen(true)}>Open Modal</Button>
219
+
220
+ <Modal visible={isModalOpen} onRequestClose={() => setIsModalOpen(false)}>
221
+ <ModalHeader closeAccessibilityLabel="Close" title="Conditional Content Demo" />
222
+ <ModalBody>
223
+ <ConditionalContent />
224
+ </ModalBody>
225
+ </Modal>
226
+ </VStack>
227
+ );
228
+ }
229
+ ```
230
+
231
+ ### Styling Based on Context
232
+
233
+ ```tsx live
234
+ function StylingExample() {
235
+ const [isModalOpen, setIsModalOpen] = useState(false);
236
+
237
+ const StyledContent = () => {
238
+ const { isModal, isDrawer } = useOverlayContentContext();
239
+
240
+ const getBackgroundColor = () => {
241
+ if (isModal) return 'bgPrimaryWash';
242
+ if (isDrawer) return 'bgSecondaryWash';
243
+ return 'bgAlternate';
244
+ };
245
+
246
+ const getStatusText = () => {
247
+ if (isModal) return 'Modal styling applied! 🎉';
248
+ if (isDrawer) return 'Drawer styling applied!';
249
+ return 'Default styling';
250
+ };
251
+
252
+ return (
253
+ <VStack padding={3} background={getBackgroundColor()} borderRadius={400} gap={2}>
254
+ <TextHeadline>Dynamic Styling</TextHeadline>
255
+ <Text>{getStatusText()}</Text>
256
+ <Text color="fgMuted" font="caption">
257
+ Background color: {getBackgroundColor()}
258
+ </Text>
259
+ </VStack>
260
+ );
261
+ };
262
+
263
+ return (
264
+ <VStack gap={3}>
265
+ <StyledContent />
266
+
267
+ <Button onClick={() => setIsModalOpen(true)}>Open Modal</Button>
268
+
269
+ <Modal visible={isModalOpen} onRequestClose={() => setIsModalOpen(false)}>
270
+ <ModalHeader closeAccessibilityLabel="Close" title="Dynamic Styling Demo" />
271
+ <ModalBody>
272
+ <StyledContent />
273
+ </ModalBody>
274
+ </Modal>
275
+ </VStack>
276
+ );
277
+ }
278
+ ```
279
+
@@ -0,0 +1,74 @@
1
+ # usePreviousValue
2
+
3
+ Returns the previous value of a given variable, useful for comparing current and previous states in effects or for tracking changes over time.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { usePreviousValue } from '@coinbase/cds-common/hooks/usePreviousValue'
9
+ ```
10
+
11
+ ## API
12
+
13
+ ### Parameters
14
+
15
+ The `usePreviousValue` hook accepts a single parameter:
16
+
17
+ - `value: T` - The value to track. Can be of any type.
18
+
19
+ ### Returns
20
+
21
+ Returns the previous value of type `T | undefined`:
22
+
23
+ - Returns `undefined` on the first render
24
+ - Returns the previous value of the tracked value on subsequent renders
25
+
26
+ :::tip
27
+ This hook is useful for comparing the current value with its previous state, such as in animations, transitions, or when you need to react to value changes. The hook uses a ref to store the previous value, ensuring it persists between renders.
28
+ :::
29
+
30
+ ## Examples
31
+
32
+ ### Basic usage
33
+
34
+ ```tsx live
35
+ function Example() {
36
+ const [count, setCount] = useState(0);
37
+ const previousCount = usePreviousValue(count);
38
+
39
+ return (
40
+ <VStack gap={3} alignItems="start">
41
+ <VStack gap={1}>
42
+ <TextHeadline>Current count: {count}</TextHeadline>
43
+ <TextHeadline>Previous count: {previousCount ?? 'None'}</TextHeadline>
44
+ </VStack>
45
+ <Button onClick={() => setCount(count + 1)}>Increment</Button>
46
+ </VStack>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### With Complex Values
52
+
53
+ ```tsx live
54
+ function Example() {
55
+ const [user, setUser] = useState({ name: 'John', age: 25 });
56
+ const previousUser = usePreviousValue(user);
57
+
58
+ const updateAge = () => {
59
+ setUser((prev) => ({ ...prev, age: prev.age + 1 }));
60
+ };
61
+
62
+ return (
63
+ <VStack gap={3} alignItems="start">
64
+ <VStack gap={1}>
65
+ <TextHeadline>Name: {user.name}</TextHeadline>
66
+ <TextHeadline>Age: {user.age}</TextHeadline>
67
+ <TextHeadline>Previous age: {previousUser?.age ?? 'None'}</TextHeadline>
68
+ </VStack>
69
+ <Button onClick={updateAge}>Add Year</Button>
70
+ </VStack>
71
+ );
72
+ }
73
+ ```
74
+
@@ -0,0 +1,178 @@
1
+ # useRefMap
2
+
3
+ Manages a collection of refs using a key-value map structure, allowing dynamic registration and retrieval of refs by their unique identifiers. Commonly used in components that need to track multiple DOM elements, such as tabs, tours, or complex navigation systems.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { useRefMap } from '@coinbase/cds-common/hooks/useRefMap'
9
+ ```
10
+
11
+ ## API
12
+
13
+ ### Parameters
14
+
15
+ The `useRefMap` hook accepts an optional configuration object:
16
+
17
+ - `options?: RefMapOptions<RefValue>` - Configuration options for the ref map
18
+ - `initialRefMap?: Record<string, RefValue>` - Optional initial map of refs
19
+
20
+ The generic type `RefValue` represents the type of values stored in the ref map (typically `HTMLElement` or a specific element type).
21
+
22
+ ### Returns
23
+
24
+ Returns a `RefMapApi<RefValue>` object with the following properties:
25
+
26
+ - `refs: Record<string, RefValue>` - The current map of all registered refs
27
+ - `getRef: (id: string) => RefValue | null` - Function to retrieve a ref by its ID
28
+ - `registerRef: (id: string, ref: RefValue) => void` - Function to register a new ref with an ID
29
+
30
+ :::tip
31
+ This hook is particularly useful when working with components that need to manage multiple refs, such as in tour guides where elements need to be highlighted, or in tab systems where tab panels need to be referenced. The hook maintains a stable reference to the ref map and its utility functions across renders.
32
+ :::
33
+
34
+ ## Examples
35
+
36
+ ### Basic usage
37
+
38
+ ```tsx live
39
+ function Example() {
40
+ const { registerRef, getRef } = useRefMap<HTMLDivElement>();
41
+ const toast = useToast();
42
+
43
+ const handleClick = () => {
44
+ // Get the element by its ID and log its dimensions
45
+ const element = getRef('box1');
46
+ if (element) {
47
+ toast.show(`Box dimensions: ${element.offsetWidth}x${element.offsetHeight}`);
48
+ }
49
+ };
50
+
51
+ return (
52
+ <VStack gap={2}>
53
+ <Box
54
+ ref={(el) => el && registerRef('box1', el)}
55
+ padding={3}
56
+ background="bgAlternate"
57
+ borderRadius={300}
58
+ >
59
+ <TextBody>This box is registered with ID 'box1'</TextBody>
60
+ </Box>
61
+ <Button onClick={handleClick}>Get Box Dimensions</Button>
62
+ </VStack>
63
+ );
64
+ }
65
+ ```
66
+
67
+ ### With Multiple Elements
68
+
69
+ ```tsx live
70
+ function Example() {
71
+ const { registerRef, getRef } = useRefMap<HTMLDivElement>();
72
+ const [activeId, setActiveId] = useState<string | null>(null);
73
+
74
+ const highlightElement = (id: string) => {
75
+ // Reset previous highlight
76
+ if (activeId) {
77
+ const prevElement = getRef(activeId);
78
+ if (prevElement) {
79
+ prevElement.style.outline = 'none';
80
+ }
81
+ }
82
+
83
+ // Highlight new element
84
+ const element = getRef(id);
85
+ if (element) {
86
+ element.style.outline = '2px solid var(--color-fgPrimary)';
87
+ setActiveId(id);
88
+ }
89
+ };
90
+
91
+ return (
92
+ <VStack gap={3}>
93
+ <HStack gap={2}>
94
+ <Button onClick={() => highlightElement('box1')}>Highlight Box 1</Button>
95
+ <Button onClick={() => highlightElement('box2')}>Highlight Box 2</Button>
96
+ <Button onClick={() => highlightElement('box3')}>Highlight Box 3</Button>
97
+ </HStack>
98
+
99
+ <VStack gap={2}>
100
+ <Box
101
+ ref={(el) => el && registerRef('box1', el)}
102
+ padding={3}
103
+ background="bgAlternate"
104
+ borderRadius={300}
105
+ >
106
+ <TextBody>Box 1</TextBody>
107
+ </Box>
108
+
109
+ <Box
110
+ ref={(el) => el && registerRef('box2', el)}
111
+ padding={3}
112
+ background="bgAlternate"
113
+ borderRadius={300}
114
+ >
115
+ <TextBody>Box 2</TextBody>
116
+ </Box>
117
+
118
+ <Box
119
+ ref={(el) => el && registerRef('box3', el)}
120
+ padding={3}
121
+ background="bgAlternate"
122
+ borderRadius={300}
123
+ >
124
+ <TextBody>Box 3</TextBody>
125
+ </Box>
126
+ </VStack>
127
+ </VStack>
128
+ );
129
+ }
130
+ ```
131
+
132
+ ### With Initial Refs
133
+
134
+ ```tsx live
135
+ function Example() {
136
+ // Create initial refs map
137
+ const box1Ref = useRef<HTMLDivElement>(null);
138
+ const box2Ref = useRef<HTMLDivElement>(null);
139
+
140
+ const initialRefs = {
141
+ box1: box1Ref.current,
142
+ box2: box2Ref.current,
143
+ };
144
+
145
+ const { refs, registerRef } = useRefMap<HTMLDivElement>({
146
+ initialRefMap: initialRefs,
147
+ });
148
+
149
+ const logRefs = () => {
150
+ console.log('Current refs:', refs);
151
+ };
152
+
153
+ return (
154
+ <VStack gap={2}>
155
+ <Box
156
+ ref={(el) => el && registerRef('box1', el)}
157
+ padding={3}
158
+ background="bgAlternate"
159
+ borderRadius={300}
160
+ >
161
+ <TextBody>Box 1</TextBody>
162
+ </Box>
163
+
164
+ <Box
165
+ ref={(el) => el && registerRef('box2', el)}
166
+ padding={3}
167
+ background="bgAlternate"
168
+ borderRadius={300}
169
+ >
170
+ <TextBody>Box 2</TextBody>
171
+ </Box>
172
+
173
+ <Button onClick={logRefs}>Log Refs</Button>
174
+ </VStack>
175
+ );
176
+ }
177
+ ```
178
+
@@ -0,0 +1,82 @@
1
+ # useScrollBlocker
2
+
3
+ Block and unblock page scrolling.
4
+
5
+ ## Import
6
+
7
+ ```tsx
8
+ import { useScrollBlocker } from '@coinbase/cds-web/hooks/useScrollBlocker'
9
+ ```
10
+
11
+ ## API
12
+
13
+ ### Parameters
14
+
15
+ The `useScrollBlocker` hook does not accept any parameters.
16
+
17
+ ### Returns
18
+
19
+ ```tsx
20
+ type Return = (shouldBlock: boolean) => void;
21
+ ```
22
+
23
+ Returns a function that takes a boolean parameter to control scroll blocking:
24
+
25
+ - `shouldBlock`: When `true`, blocks page scrolling. When `false`, re-enables scrolling.
26
+
27
+ :::tip
28
+ This hook is useful for temporarily disabling page scrolling, such as when displaying modals or overlays. It automatically handles scroll bar width compensation to prevent layout shifts.
29
+ :::
30
+
31
+ ## Examples
32
+
33
+ ### Basic usage
34
+
35
+ ```tsx live
36
+ function Example() {
37
+ const blockScroll = useScrollBlocker();
38
+ const [isBlocked, setIsBlocked] = useState(false);
39
+
40
+ const toggleScroll = () => {
41
+ setIsBlocked(!isBlocked);
42
+ blockScroll(!isBlocked);
43
+ };
44
+
45
+ return (
46
+ <VStack gap={3} alignItems="start">
47
+ <TextHeadline>Scroll is currently {isBlocked ? 'blocked' : 'enabled'}</TextHeadline>
48
+ <Button onClick={toggleScroll}>{isBlocked ? 'Enable Scroll' : 'Block Scroll'}</Button>
49
+ </VStack>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ### With Overlay
55
+
56
+ ```tsx live
57
+ function Example() {
58
+ const blockScroll = useScrollBlocker();
59
+ const [isOpen, setIsOpen] = useState(false);
60
+
61
+ const openModal = () => {
62
+ setIsOpen(true);
63
+ blockScroll(true);
64
+ };
65
+
66
+ const closeModal = () => {
67
+ setIsOpen(false);
68
+ blockScroll(false);
69
+ };
70
+
71
+ return (
72
+ <VStack gap={3} alignItems="start">
73
+ <Button onClick={openModal}>Open Overlay</Button>
74
+ <Modal visible={isOpen} onRequestClose={closeModal}>
75
+ <ModalHeader title="Modal Title" />
76
+ <ModalBody>Modal Content</ModalBody>
77
+ </Modal>
78
+ </VStack>
79
+ );
80
+ }
81
+ ```
82
+