@sentry/scraps 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/README.md +74 -8
  2. package/dist/alert/alert.js +0 -3
  3. package/dist/badge/badge.js +1 -2
  4. package/dist/badge/tag.js +4 -4
  5. package/dist/button/button.js +1 -0
  6. package/dist/button/index.d.ts +0 -1
  7. package/dist/button/index.js +0 -1
  8. package/dist/button/linkButton.js +1 -0
  9. package/dist/button/styles.js +157 -152
  10. package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
  11. package/dist/clipboard/copyToClipboardButton.js +32 -0
  12. package/dist/clipboard/index.d.ts +1 -0
  13. package/dist/clipboard/index.js +1 -0
  14. package/dist/code/index.d.ts +1 -0
  15. package/dist/code/index.js +1 -0
  16. package/dist/codeBlock/codeBlock.d.ts +68 -0
  17. package/dist/codeBlock/codeBlock.js +243 -0
  18. package/dist/codeBlock/index.d.ts +2 -0
  19. package/dist/codeBlock/index.js +2 -0
  20. package/dist/codeBlock/prism.d.ts +11 -0
  21. package/dist/codeBlock/prism.js +101 -0
  22. package/dist/codeBlock/styles.d.ts +2 -0
  23. package/dist/codeBlock/styles.js +133 -0
  24. package/dist/compactSelect/compactSelect.d.ts +21 -0
  25. package/dist/compactSelect/compactSelect.js +150 -0
  26. package/dist/compactSelect/composite.d.ts +54 -0
  27. package/dist/compactSelect/composite.js +101 -0
  28. package/dist/compactSelect/control.d.ts +112 -0
  29. package/dist/compactSelect/control.js +355 -0
  30. package/dist/compactSelect/gridList/index.d.ts +46 -0
  31. package/dist/compactSelect/gridList/index.js +102 -0
  32. package/dist/compactSelect/gridList/option.d.ts +15 -0
  33. package/dist/compactSelect/gridList/option.js +111 -0
  34. package/dist/compactSelect/gridList/section.d.ts +15 -0
  35. package/dist/compactSelect/gridList/section.js +58 -0
  36. package/dist/compactSelect/highlightText.d.ts +6 -0
  37. package/dist/compactSelect/highlightText.js +33 -0
  38. package/dist/compactSelect/index.d.ts +9 -0
  39. package/dist/compactSelect/index.js +8 -0
  40. package/dist/compactSelect/list.d.ts +94 -0
  41. package/dist/compactSelect/list.js +167 -0
  42. package/dist/compactSelect/listBox/index.d.ts +84 -0
  43. package/dist/compactSelect/listBox/index.js +175 -0
  44. package/dist/compactSelect/listBox/option.d.ts +19 -0
  45. package/dist/compactSelect/listBox/option.js +101 -0
  46. package/dist/compactSelect/listBox/section.d.ts +21 -0
  47. package/dist/compactSelect/listBox/section.js +58 -0
  48. package/dist/compactSelect/menuComponents.d.ts +89 -0
  49. package/dist/compactSelect/menuComponents.js +117 -0
  50. package/dist/compactSelect/selectFilterContext.d.ts +2 -0
  51. package/dist/compactSelect/selectFilterContext.js +3 -0
  52. package/dist/compactSelect/styles.d.ts +39 -0
  53. package/dist/compactSelect/styles.js +155 -0
  54. package/dist/compactSelect/types.d.ts +1 -0
  55. package/dist/compactSelect/types.js +0 -0
  56. package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
  57. package/dist/compactSelect/useVirtualizedItems.js +74 -0
  58. package/dist/compactSelect/utils.d.ts +80 -0
  59. package/dist/compactSelect/utils.js +264 -0
  60. package/dist/confirm/index.d.ts +153 -0
  61. package/dist/confirm/index.js +132 -0
  62. package/dist/dateTime/config.d.ts +23 -0
  63. package/dist/dateTime/config.js +50 -0
  64. package/dist/dateTime/context.d.ts +18 -0
  65. package/dist/dateTime/context.js +46 -0
  66. package/dist/dateTime/dateTime.d.ts +6 -0
  67. package/dist/dateTime/dateTime.js +30 -0
  68. package/dist/dateTime/format.d.ts +24 -0
  69. package/dist/dateTime/format.js +45 -0
  70. package/dist/dateTime/index.d.ts +6 -0
  71. package/dist/dateTime/index.js +6 -0
  72. package/dist/dateTime/intlFormatter.d.ts +9 -0
  73. package/dist/dateTime/intlFormatter.js +16 -0
  74. package/dist/dateTime/parseDate.d.ts +3 -0
  75. package/dist/dateTime/parseDate.js +12 -0
  76. package/dist/descriptionList/descriptionList.js +4 -3
  77. package/dist/disclosure/disclosure.js +2 -2
  78. package/dist/dragHandle/dragHandle.d.ts +3 -1
  79. package/dist/dragHandle/dragHandle.js +8 -5
  80. package/dist/drawer/components.d.ts +46 -0
  81. package/dist/drawer/components.js +265 -0
  82. package/dist/drawer/globalDrawer.d.ts +106 -0
  83. package/dist/drawer/globalDrawer.js +173 -0
  84. package/dist/drawer/index.d.ts +3 -0
  85. package/dist/drawer/index.js +2 -0
  86. package/dist/drawer/useDrawerResizing.d.ts +19 -0
  87. package/dist/drawer/useDrawerResizing.js +111 -0
  88. package/dist/drawer/useDrawerWidth.d.ts +1 -0
  89. package/dist/drawer/useDrawerWidth.js +42 -0
  90. package/dist/dropdownMenu/content.d.ts +1 -0
  91. package/dist/dropdownMenu/content.js +1 -0
  92. package/dist/dropdownMenu/context.d.ts +39 -0
  93. package/dist/dropdownMenu/context.js +3 -0
  94. package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
  95. package/dist/dropdownMenu/dropdownMenu.js +109 -0
  96. package/dist/dropdownMenu/index.d.ts +2 -0
  97. package/dist/dropdownMenu/index.js +1 -0
  98. package/dist/dropdownMenu/item.d.ts +140 -0
  99. package/dist/dropdownMenu/item.js +142 -0
  100. package/dist/dropdownMenu/list.d.ts +85 -0
  101. package/dist/dropdownMenu/list.js +429 -0
  102. package/dist/dropdownMenu/search.d.ts +16 -0
  103. package/dist/dropdownMenu/search.js +16 -0
  104. package/dist/dropdownMenu/section.d.ts +21 -0
  105. package/dist/dropdownMenu/section.js +40 -0
  106. package/dist/dropdownMenu/separator.d.ts +7 -0
  107. package/dist/dropdownMenu/separator.js +15 -0
  108. package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +24 -0
  109. package/dist/dropdownMenu/useDropdownMenuKeyboard.js +31 -0
  110. package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
  111. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
  112. package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
  113. package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
  114. package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
  115. package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
  116. package/dist/dropdownMenu/utils.d.ts +21 -0
  117. package/dist/dropdownMenu/utils.js +55 -0
  118. package/dist/duration/formatElapsedDuration.d.ts +4 -0
  119. package/dist/duration/formatElapsedDuration.js +10 -0
  120. package/dist/duration/getDuration.d.ts +68 -0
  121. package/dist/duration/getDuration.js +80 -0
  122. package/dist/duration/index.d.ts +2 -0
  123. package/dist/duration/index.js +2 -0
  124. package/dist/form/FormSearch.d.ts +19 -0
  125. package/dist/form/FormSearch.js +4 -0
  126. package/dist/form/autoSaveForm.d.ts +110 -0
  127. package/dist/form/autoSaveForm.js +100 -0
  128. package/dist/{formPresentation → form}/displayField.js +2 -2
  129. package/dist/form/field/baseField.d.ts +23 -0
  130. package/dist/form/field/baseField.js +116 -0
  131. package/dist/form/field/checkboxField.d.ts +11 -0
  132. package/dist/form/field/checkboxField.js +42 -0
  133. package/dist/form/field/checkboxGroupField.d.ts +16 -0
  134. package/dist/form/field/checkboxGroupField.js +80 -0
  135. package/dist/form/field/compactSelectField.d.ts +19 -0
  136. package/dist/form/field/compactSelectField.js +77 -0
  137. package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
  138. package/dist/form/field/inputField.d.ts +19 -0
  139. package/dist/form/field/inputField.js +31 -0
  140. package/dist/{formPresentation → form/field}/meta.js +6 -6
  141. package/dist/form/field/numberField.d.ts +5 -0
  142. package/dist/form/field/numberField.js +11 -0
  143. package/dist/form/field/passwordField.d.ts +3 -0
  144. package/dist/form/field/passwordField.js +27 -0
  145. package/dist/form/field/radioGroupField.d.ts +16 -0
  146. package/dist/form/field/radioGroupField.js +92 -0
  147. package/dist/form/field/rangeField.d.ts +8 -0
  148. package/dist/form/field/rangeField.js +34 -0
  149. package/dist/form/field/selectAsyncField.d.ts +31 -0
  150. package/dist/form/field/selectAsyncField.js +22 -0
  151. package/dist/form/field/selectField.d.ts +9 -0
  152. package/dist/form/field/selectField.js +72 -0
  153. package/dist/form/field/switchField.d.ts +7 -0
  154. package/dist/form/field/switchField.js +37 -0
  155. package/dist/form/field/textAreaField.d.ts +7 -0
  156. package/dist/form/field/textAreaField.js +25 -0
  157. package/dist/{formPresentation → form}/formContext.js +1 -1
  158. package/dist/form/formErrorContext/index.d.ts +9 -0
  159. package/dist/form/formErrorContext/index.js +7 -0
  160. package/dist/form/index.d.ts +9 -0
  161. package/dist/form/index.js +8 -0
  162. package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
  163. package/dist/{formPresentation → form/layout}/base.js +1 -1
  164. package/dist/form/layout/fieldGroup.d.ts +6 -0
  165. package/dist/form/layout/fieldGroup.js +60 -0
  166. package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
  167. package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
  168. package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
  169. package/dist/form/scrapsForm.d.ts +220 -0
  170. package/dist/form/scrapsForm.js +126 -0
  171. package/dist/fzf.d.ts +9 -0
  172. package/dist/fzf.js +155 -0
  173. package/dist/hotkey/hotkey.d.ts +9 -8
  174. package/dist/hotkey/hotkey.js +13 -6
  175. package/dist/hotkey/index.d.ts +2 -1
  176. package/dist/hotkey/index.js +2 -1
  177. package/dist/hotkey/keyMappings.d.ts +1 -15
  178. package/dist/hotkey/keyMappings.js +29 -174
  179. package/dist/hotkey/useHotkeys.d.ts +3 -47
  180. package/dist/hotkey/useHotkeys.js +8 -42
  181. package/dist/image/image.js +2 -1
  182. package/dist/info/infoTip.d.ts +1 -1
  183. package/dist/info/infoTip.js +4 -3
  184. package/dist/input/index.d.ts +0 -3
  185. package/dist/input/index.js +0 -2
  186. package/dist/input/input.d.ts +2 -0
  187. package/dist/input/input.js +2 -0
  188. package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
  189. package/dist/input/passwordManagerIgnoreProps.js +8 -0
  190. package/dist/layout/container.d.ts +8 -2
  191. package/dist/layout/container.js +2 -2
  192. package/dist/layout/index.d.ts +2 -2
  193. package/dist/layout/index.js +1 -1
  194. package/dist/layout/styles.d.ts +2 -1
  195. package/dist/layout/styles.js +11 -5
  196. package/dist/legacyDatetime.d.ts +21 -0
  197. package/dist/legacyDatetime.js +13 -0
  198. package/dist/link/index.d.ts +1 -1
  199. package/dist/link/index.js +1 -1
  200. package/dist/link/link.js +4 -3
  201. package/dist/link/linkBehaviorContext.d.ts +11 -0
  202. package/dist/link/linkBehaviorContext.js +48 -11
  203. package/dist/menu/index.d.ts +1 -1
  204. package/dist/menu/index.js +1 -1
  205. package/dist/menu/menu.d.ts +14 -8
  206. package/dist/menu/menu.js +163 -60
  207. package/dist/modal/components.d.ts +19 -0
  208. package/dist/modal/components.js +99 -0
  209. package/dist/modal/errorBoundary.d.ts +2 -0
  210. package/dist/modal/errorBoundary.js +35 -0
  211. package/dist/modal/index.d.ts +33 -0
  212. package/dist/modal/index.js +260 -0
  213. package/dist/modal/portal.d.ts +1 -0
  214. package/dist/modal/portal.js +10 -0
  215. package/dist/modal/state.d.ts +17 -0
  216. package/dist/modal/state.js +41 -0
  217. package/dist/modal/types.d.ts +75 -0
  218. package/dist/modal/types.js +0 -0
  219. package/dist/numberInput/index.d.ts +3 -0
  220. package/dist/numberInput/index.js +2 -0
  221. package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
  222. package/dist/{input → numberInput}/numberDragInput.js +1 -1
  223. package/dist/{input → numberInput}/numberInput.d.ts +1 -1
  224. package/dist/{input → numberInput}/numberInput.js +1 -1
  225. package/dist/overlayContext.d.ts +29 -0
  226. package/dist/overlayContext.js +7 -0
  227. package/dist/pagination/index.d.ts +1 -0
  228. package/dist/pagination/index.js +1 -0
  229. package/dist/pagination/pagination.d.ts +24 -0
  230. package/dist/pagination/pagination.js +63 -0
  231. package/dist/pictureInPicture/index.d.ts +2 -0
  232. package/dist/pictureInPicture/index.js +2 -0
  233. package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
  234. package/dist/pictureInPicture/pictureInPicture.js +100 -0
  235. package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
  236. package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
  237. package/dist/pictureInPicture/portalContext.d.ts +2 -0
  238. package/dist/pictureInPicture/portalContext.js +3 -0
  239. package/dist/relativeTime/getRelativeDate.d.ts +14 -0
  240. package/dist/relativeTime/getRelativeDate.js +107 -0
  241. package/dist/relativeTime/index.d.ts +3 -0
  242. package/dist/relativeTime/index.js +3 -0
  243. package/dist/relativeTime/relativeTime.d.ts +55 -0
  244. package/dist/relativeTime/relativeTime.js +102 -0
  245. package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
  246. package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
  247. package/dist/revealOnHover/revealOnHover.js +1 -1
  248. package/dist/segmentedControl/segmentedControl.js +1 -1
  249. package/dist/select/filter.d.ts +4 -0
  250. package/dist/select/filter.js +12 -0
  251. package/dist/select/index.d.ts +3 -0
  252. package/dist/select/index.js +2 -0
  253. package/dist/select/option.d.ts +16 -0
  254. package/dist/select/option.js +81 -0
  255. package/dist/select/reactSelectWrapper.d.ts +8 -0
  256. package/dist/select/reactSelectWrapper.js +25 -0
  257. package/dist/select/select.d.ts +79 -0
  258. package/dist/select/select.js +454 -0
  259. package/dist/select/styles.d.ts +9 -0
  260. package/dist/select/styles.js +27 -0
  261. package/dist/select/types.d.ts +60 -0
  262. package/dist/select/types.js +0 -0
  263. package/dist/select/virtualizedMenuList.d.ts +24 -0
  264. package/dist/select/virtualizedMenuList.js +123 -0
  265. package/dist/slideOverPanel.d.ts +20 -0
  266. package/dist/slideOverPanel.js +141 -0
  267. package/dist/splitPanel/splitPanel.d.ts +3 -1
  268. package/dist/splitPanel/splitPanel.js +2 -1
  269. package/dist/table/table.d.ts +1 -1
  270. package/dist/table/table.js +39 -20
  271. package/dist/table/useColumnResize.d.ts +6 -5
  272. package/dist/table/useColumnResize.js +5 -4
  273. package/dist/tabs/context.d.ts +9 -0
  274. package/dist/tabs/context.js +9 -0
  275. package/dist/tabs/index.d.ts +2 -0
  276. package/dist/tabs/index.js +1 -0
  277. package/dist/tabs/item.d.ts +24 -0
  278. package/dist/tabs/item.js +4 -0
  279. package/dist/tabs/tab.d.ts +22 -0
  280. package/dist/tabs/tab.js +208 -0
  281. package/dist/tabs/tabList.d.ts +18 -0
  282. package/dist/tabs/tabList.js +258 -0
  283. package/dist/tabs/tabPanels.d.ts +13 -0
  284. package/dist/tabs/tabPanels.js +62 -0
  285. package/dist/tabs/tabs.d.ts +53 -0
  286. package/dist/tabs/tabs.js +59 -0
  287. package/dist/tabs/utils.d.ts +3 -0
  288. package/dist/tabs/utils.js +6 -0
  289. package/dist/text/heading.d.ts +1 -1
  290. package/dist/text/heading.js +1 -1
  291. package/dist/text/prose.d.ts +2 -2
  292. package/dist/text/styles.js +1 -1
  293. package/dist/text/text.d.ts +1 -1
  294. package/dist/text/text.js +1 -1
  295. package/dist/theme/dark.js +9 -9
  296. package/dist/theme/light.js +9 -9
  297. package/dist/theme/theme.d.ts +34 -34
  298. package/dist/theme/theme.js +9 -0
  299. package/dist/theme/types.d.ts +20 -2
  300. package/dist/tooltip/tooltip.js +2 -5
  301. package/dist/translation/index.d.ts +1 -0
  302. package/dist/translation/index.js +1 -0
  303. package/dist/translation/translate.d.ts +9 -0
  304. package/dist/translation/translate.js +5 -0
  305. package/dist/translation/translationContext.d.ts +2 -1
  306. package/dist/translation/translationContext.js +2 -1
  307. package/dist/useMedia.d.ts +15 -0
  308. package/dist/useMedia.js +24 -0
  309. package/dist/useOnClickOutside.d.ts +2 -0
  310. package/dist/useOnClickOutside.js +22 -0
  311. package/dist/useOverlay.d.ts +1 -0
  312. package/dist/useOverlay.js +1 -0
  313. package/dist/useVirtualCollection.d.ts +154 -0
  314. package/dist/useVirtualCollection.js +143 -0
  315. package/dist/useVirtualRows.d.ts +26 -0
  316. package/dist/useVirtualRows.js +26 -0
  317. package/dist/virtualCollectionLayout.d.ts +51 -0
  318. package/dist/virtualCollectionLayout.js +49 -0
  319. package/fonts/OFL.txt +94 -0
  320. package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
  321. package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
  322. package/fonts/roboto-mono-variable-greek.woff2 +0 -0
  323. package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
  324. package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
  325. package/fonts/roboto-mono-variable.woff2 +0 -0
  326. package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
  327. package/fonts/rubik-variable-cyrillic.woff2 +0 -0
  328. package/fonts/rubik-variable-latin-ext.woff2 +0 -0
  329. package/fonts/rubik-variable.woff2 +0 -0
  330. package/fonts.css +211 -0
  331. package/package.json +140 -23
  332. package/dist/datetime.d.ts +0 -39
  333. package/dist/datetime.js +0 -20
  334. package/dist/formPresentation/index.d.ts +0 -8
  335. package/dist/formPresentation/index.js +0 -8
  336. package/dist/interactionStateLayer/index.d.ts +0 -1
  337. package/dist/interactionStateLayer/index.js +0 -1
  338. package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
  339. package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
  340. package/dist/unreachable.d.ts +0 -1
  341. package/dist/unreachable.js +0 -4
  342. /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
  343. /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
  344. /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
  345. /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
  346. /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
  347. /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
  348. /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
  349. /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
  350. /package/dist/{formPresentation → form}/icons.d.ts +0 -0
  351. /package/dist/{formPresentation → form}/icons.js +0 -0
  352. /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
@@ -0,0 +1,265 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { Fragment, createContext, useContext, useMemo, useRef, useState } from "react";
3
+ import { css } from "@emotion/react";
4
+ import styled from "@emotion/styled";
5
+ import { mergeRefs } from "@react-aria/utils";
6
+ import { IconClose } from "@sentry/icons/close";
7
+ import { Button } from "../button/index.js";
8
+ import { ContainerQueryProvider } from "../layout/index.js";
9
+ import { useOverlayContext } from "../overlayContext.js";
10
+ import { SlideOverPanel } from "../slideOverPanel.js";
11
+ import { TooltipContext } from "../tooltip/index.js";
12
+ import { useTranslation } from "../translation/useTranslation.js";
13
+ import { DEFAULT_WIDTH_PERCENT, MAX_WIDTH_PERCENT, MIN_WIDTH_PERCENT, useDrawerResizing } from "./useDrawerResizing.js";
14
+ const DrawerWidthContext = /*#__PURE__*/ createContext(void 0);
15
+ const DrawerContentContext = /*#__PURE__*/ createContext({
16
+ onClose: ()=>{},
17
+ ariaLabel: 'slide out drawer'
18
+ });
19
+ function useDrawerContentContext() {
20
+ return useContext(DrawerContentContext);
21
+ }
22
+ function DrawerPanel({ ref, mode, ariaLabel, children, onClose, drawerWidth, drawerMaxWidth, drawerKey, minPanelWidth, topOffset, resizable = true }) {
23
+ const { panelRef, resizeHandleRef, handleResizeStart, persistedWidthPercent, enabled } = useDrawerResizing({
24
+ drawerKey,
25
+ drawerWidth,
26
+ drawerMaxWidth,
27
+ enabled: resizable
28
+ });
29
+ const [tooltipContainer, setTooltipContainer] = useState(null);
30
+ const actualDrawerWidth = window.innerWidth * (enabled ? persistedWidthPercent : 100) / 100;
31
+ return /*#__PURE__*/ jsx(DrawerContainer, {
32
+ mode: mode,
33
+ children: /*#__PURE__*/ jsx(DrawerWidthContext.Provider, {
34
+ value: actualDrawerWidth,
35
+ children: /*#__PURE__*/ jsxs(DrawerSlidePanel, {
36
+ mode: mode,
37
+ minPanelWidth: minPanelWidth,
38
+ topOffset: void 0 === topOffset ? void 0 : `${topOffset}px`,
39
+ height: void 0 === topOffset ? void 0 : `calc(100% - ${topOffset}px)`,
40
+ ariaLabel: ariaLabel,
41
+ position: "right",
42
+ ref: mergeRefs(panelRef, ref, (node)=>setTooltipContainer(node)),
43
+ panelWidth: "var(--drawer-width)",
44
+ className: "drawer-panel",
45
+ children: [
46
+ drawerKey && enabled && /*#__PURE__*/ jsx(ResizeHandle, {
47
+ ref: resizeHandleRef,
48
+ onMouseDown: handleResizeStart,
49
+ "data-at-min-width": (persistedWidthPercent <= MIN_WIDTH_PERCENT).toString(),
50
+ "data-at-max-width": (Math.abs(persistedWidthPercent - MAX_WIDTH_PERCENT) < 1).toString()
51
+ }),
52
+ /*#__PURE__*/ jsx(TooltipContext, {
53
+ value: {
54
+ container: tooltipContainer
55
+ },
56
+ children: /*#__PURE__*/ jsx(DrawerContentContext, {
57
+ value: {
58
+ onClose,
59
+ ariaLabel
60
+ },
61
+ children: children
62
+ })
63
+ })
64
+ ]
65
+ })
66
+ })
67
+ });
68
+ }
69
+ function DrawerHeader({ ref, className, children = null, hideBar = false, hideCloseButton = false, hideCloseButtonText = false }) {
70
+ const { onClose } = useDrawerContentContext();
71
+ const { headerHeight } = useOverlayContext();
72
+ const { t } = useTranslation();
73
+ return /*#__PURE__*/ jsxs(Header, {
74
+ ref: ref,
75
+ className: className,
76
+ hideCloseButton: hideCloseButton,
77
+ hideBar: hideBar,
78
+ height: headerHeight,
79
+ children: [
80
+ !hideCloseButton && /*#__PURE__*/ jsxs(Fragment, {
81
+ children: [
82
+ /*#__PURE__*/ jsx(Button, {
83
+ variant: "transparent",
84
+ size: "xs",
85
+ "aria-label": t('Close Drawer'),
86
+ icon: /*#__PURE__*/ jsx(IconClose, {}),
87
+ onClick: onClose,
88
+ children: !hideCloseButtonText && t('Close')
89
+ }),
90
+ !hideBar && /*#__PURE__*/ jsx(HeaderBar, {})
91
+ ]
92
+ }),
93
+ children
94
+ ]
95
+ });
96
+ }
97
+ const HeaderBar = styled('div')`
98
+ margin: 0 ${(p)=>p.theme.space.xl};
99
+ margin-left: ${(p)=>p.theme.space.md};
100
+ align-self: stretch;
101
+ border-right: 1px solid ${(p)=>p.theme.tokens.border.primary};
102
+ `;
103
+ const Header = styled('header')`
104
+ position: sticky;
105
+ top: 0;
106
+ z-index: ${(p)=>p.theme.zIndex.drawer + 1};
107
+ background: ${(p)=>p.theme.tokens.background.primary};
108
+ justify-content: flex-start;
109
+ display: flex;
110
+ flex-shrink: 0;
111
+ gap: ${(p)=>p.hideBar ? p.theme.space.md : 0};
112
+ padding: ${(p)=>p.theme.space.lg};
113
+ /* oxlint-disable-next-line @sentry/scraps/use-semantic-token */
114
+ box-shadow: ${(p)=>p.theme.tokens.border.primary} 0 1px;
115
+ padding-left: ${(p)=>p.theme.space.lg};
116
+ padding-top: ${(p)=>p.hideCloseButton ? p.theme.space.lg : p.theme.space.sm};
117
+ padding-bottom: ${(p)=>p.hideCloseButton ? p.theme.space.lg : p.theme.space.sm};
118
+ ${(p)=>p.height && css`
119
+ --drawer-header-height: ${p.height};
120
+ height: var(--drawer-header-height);
121
+ box-sizing: border-box;
122
+ align-items: center;
123
+ box-shadow: none;
124
+ border-bottom: 1px solid ${p.theme.tokens.border.primary};
125
+ `}
126
+ `;
127
+ function DrawerBody({ ref, ...props }) {
128
+ const bodyRef = useRef(null);
129
+ const refs = useMemo(()=>mergeRefs(ref, bodyRef), [
130
+ ref
131
+ ]);
132
+ return /*#__PURE__*/ jsx(ContainerQueryProvider, {
133
+ elementRef: bodyRef,
134
+ children: /*#__PURE__*/ jsx(DrawerBodyElement, {
135
+ ref: refs,
136
+ ...props
137
+ })
138
+ });
139
+ }
140
+ const DrawerBodyElement = styled('aside')`
141
+ container-type: inline-size;
142
+ padding: ${(p)=>p.theme.space.xl} 24px;
143
+ font-size: ${(p)=>p.theme.font.size.md};
144
+ `;
145
+ const DrawerContainer = styled('div')`
146
+ position: fixed;
147
+ inset: 0;
148
+ z-index: ${(p)=>p.theme.zIndex.drawer};
149
+ pointer-events: none;
150
+
151
+ @media (max-width: ${(p)=>p.theme.breakpoints.sm}) {
152
+ overflow-x: auto;
153
+ pointer-events: auto;
154
+ }
155
+ `;
156
+ const DrawerSlidePanel = styled(SlideOverPanel)`
157
+ border-left: 1px solid ${(p)=>p.theme.tokens.border.primary};
158
+ position: relative;
159
+ pointer-events: auto;
160
+ height: ${(p)=>p.height ?? '100%'};
161
+
162
+ /* Extend the panel's background 20px past its right edge so the bounce-in
163
+ overshoot doesn't briefly expose the page beneath. A box-shadow is used
164
+ (vs. a pseudo-element) because the panel's own overflow: auto would clip
165
+ anything positioned outside its bounds. */
166
+ /* oxlint-disable-next-line @sentry/scraps/use-semantic-token -- Extend the drawer background beyond its scrollable bounds. */
167
+ box-shadow:
168
+ 20px 0 0 ${(p)=>p.theme.tokens.background.overlay},
169
+ ${(p)=>p.theme.shadow.high};
170
+
171
+ --drawer-width: ${DEFAULT_WIDTH_PERCENT}%;
172
+ --drawer-min-width: ${MIN_WIDTH_PERCENT}%;
173
+ --drawer-max-width: ${MAX_WIDTH_PERCENT}%;
174
+
175
+ width: clamp(
176
+ var(--drawer-min-width),
177
+ var(--drawer-width),
178
+ var(--drawer-max-width)
179
+ ) !important;
180
+
181
+ /* A drawer narrower than a pane docked against the viewport's right edge
182
+ (Seer) would leave a strip of that pane showing beside it. */
183
+ ${(p)=>p.minPanelWidth ? css`
184
+ min-width: ${p.minPanelWidth}px;
185
+ ` : null}
186
+
187
+ @media (max-width: ${(p)=>p.theme.breakpoints.sm}) {
188
+ top: ${(p)=>p.topOffset ?? 0};
189
+ bottom: 0;
190
+ left: 0;
191
+ right: 0;
192
+ border: none;
193
+ box-shadow: none;
194
+ /* Without this, the base SlideOverPanel's overscroll-behavior: contain blocks horizontal scroll chaining. */
195
+ overscroll-behavior-x: auto;
196
+ }
197
+
198
+ &[data-resizing] {
199
+ /* Hide scrollbars during resize */
200
+ overflow: hidden !important;
201
+
202
+ /* Hide scrollbars in Firefox */
203
+ scrollbar-width: none;
204
+
205
+ /* Hide scrollbars in WebKit browsers */
206
+ &::-webkit-scrollbar {
207
+ display: none;
208
+ }
209
+
210
+ /* Apply to all scrollable children */
211
+ * {
212
+ scrollbar-width: none;
213
+
214
+ &::-webkit-scrollbar {
215
+ display: none;
216
+ }
217
+ }
218
+ }
219
+ `;
220
+ const ResizeHandle = styled('div')`
221
+ position: absolute;
222
+ left: -2px;
223
+ top: 0;
224
+ bottom: 0;
225
+ width: 8px;
226
+ cursor: ew-resize;
227
+ z-index: ${(p)=>p.theme.zIndex.drawer + 2};
228
+
229
+ &[data-at-min-width='true'] {
230
+ cursor: w-resize;
231
+ }
232
+
233
+ &[data-at-max-width='true'] {
234
+ cursor: e-resize;
235
+ }
236
+
237
+ &:hover,
238
+ &:active {
239
+ &::after {
240
+ background: ${(p)=>p.theme.tokens.graphics.accent.vibrant};
241
+ }
242
+ }
243
+
244
+ &::after {
245
+ content: '';
246
+ position: absolute;
247
+ left: 2px;
248
+ top: 0;
249
+ bottom: 0;
250
+ width: 4px;
251
+ opacity: 0.8;
252
+ background: transparent;
253
+ transition: background 0.1s ease;
254
+ }
255
+
256
+ &[data-resizing]::after {
257
+ background: ${(p)=>p.theme.tokens.graphics.accent.vibrant};
258
+ }
259
+ `;
260
+ const DrawerComponents = {
261
+ DrawerBody,
262
+ DrawerHeader,
263
+ DrawerPanel
264
+ };
265
+ export { DrawerBody, DrawerComponents, DrawerHeader, DrawerPanel, useDrawerContentContext };
@@ -0,0 +1,106 @@
1
+ import type * as React from 'react';
2
+ import { type OverlayLocation } from '../overlayContext.js';
3
+ export interface DrawerOptions {
4
+ /**
5
+ * Accessbility label for the drawer
6
+ */
7
+ ariaLabel: string;
8
+ /**
9
+ * Key to identify the drawer and enable persistence of the drawer width
10
+ */
11
+ drawerKey?: string;
12
+ /**
13
+ * Custom max width for the drawer, as any CSS length. Applies on top of the
14
+ * default percentage ceiling rather than replacing it.
15
+ */
16
+ drawerMaxWidth?: string;
17
+ /**
18
+ * Custom width for the drawer
19
+ */
20
+ drawerWidth?: string;
21
+ /**
22
+ * Controls scroll locking, click-outside close, and location-change close behavior.
23
+ * - 'blocking' (default): scroll locked, click outside closes, location change closes
24
+ * - 'passive': scroll not locked, click outside does NOT close, location change does NOT close
25
+ */
26
+ mode?: 'blocking' | 'passive';
27
+ /**
28
+ * Callback for when the drawer closes
29
+ */
30
+ onClose?: () => void;
31
+ /**
32
+ * Callback for when the drawer opens
33
+ */
34
+ onOpen?: () => void;
35
+ /**
36
+ * If true (default), allows the drawer to be resized - requires `drawerKey`
37
+ * to be defined
38
+ */
39
+ resizable?: boolean;
40
+ /**
41
+ * Function to determine whether the drawer should close when interacting with
42
+ * other elements. Only applies in 'blocking' mode.
43
+ */
44
+ shouldCloseOnInteractOutside?: (interactedElement: Element) => boolean;
45
+ /**
46
+ * Callback to determine whether the drawer should close when the location changes.
47
+ * Defaults to closing in 'blocking' mode, staying open in 'passive' mode.
48
+ */
49
+ shouldCloseOnLocationChange?: (nextLocation: OverlayLocation) => boolean;
50
+ }
51
+ interface DrawerRenderProps {
52
+ /**
53
+ * Close the drawer
54
+ */
55
+ closeDrawer: () => void;
56
+ }
57
+ type DrawerRenderer = (renderProps: DrawerRenderProps) => React.ReactNode;
58
+ export interface DrawerConfig {
59
+ options: DrawerOptions;
60
+ renderer: DrawerRenderer | null;
61
+ }
62
+ interface DrawerPlacement {
63
+ minWidth: number;
64
+ topOffset: number;
65
+ }
66
+ export interface GlobalDrawerProps {
67
+ children: React.ReactNode;
68
+ }
69
+ export declare function GlobalDrawer({ children }: GlobalDrawerProps): import("@emotion/react/jsx-runtime").JSX.Element;
70
+ /**
71
+ * Returns helper functions to control the slide out drawer above the page content. For example:
72
+ * ```
73
+ * const {openDrawer, closeDrawer} = useDrawer()
74
+ * ```
75
+ *
76
+ * The `openDrawer` function accepts a renderer, and options. By default (`mode: 'blocking'`),
77
+ * the drawer locks scroll, closes on outside clicks, closes on location changes, and closes
78
+ * on 'Escape'. Use `mode: 'passive'` to opt out of scroll locking, outside-click close, and
79
+ * location-change close — useful for drawers that coexist with page interaction.
80
+ *
81
+ * The `closeDrawer` function accepts no parameters and closes the drawer, unmounting its contents.
82
+ * For example:
83
+ * ```
84
+ * openDrawer(() => <button onClick={closeDrawer}>Close!</button>)
85
+ * ```
86
+ *
87
+ * `isDrawerOpen` is scoped to this call-site: it is `true` only when the drawer
88
+ * currently open was opened via the `openDrawer` returned by *this* `useDrawer`
89
+ * call (including calls made through a shared wrapper hook). Use
90
+ * `isAnyDrawerOpen` if you need to know whether *any* drawer is open.
91
+ */
92
+ export declare function useDrawer(): {
93
+ openDrawer: (renderer: DrawerConfig["renderer"], options: DrawerConfig["options"]) => void;
94
+ closeDrawer: () => void;
95
+ panelRef: React.RefObject<HTMLDivElement | null>;
96
+ isDrawerOpen: boolean;
97
+ isAnyDrawerOpen: boolean;
98
+ };
99
+ /**
100
+ * Lets the app layout place global drawers around its own chrome. Drawers start
101
+ * `topOffset` pixels from the viewport top (below page banners) and, while
102
+ * `minWidth` is positive, are at least that many pixels wide (to cover a pane
103
+ * docked against the viewport's right edge, such as Seer).
104
+ */
105
+ export declare function useDrawerPlacement({ minWidth, topOffset }: DrawerPlacement): void;
106
+ export {};
@@ -0,0 +1,173 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
3
+ import { AnimatePresence } from "framer-motion";
4
+ import { Backdrop } from "../backdrop/index.js";
5
+ import { useHotkeys } from "../hotkey/index.js";
6
+ import { useOverlayContext } from "../overlayContext.js";
7
+ import { useOnClickOutside } from "../useOnClickOutside.js";
8
+ import { useScrollLock } from "../useScrollLock.js";
9
+ import { DrawerComponents } from "./components.js";
10
+ const DrawerContext = /*#__PURE__*/ createContext({
11
+ openDrawer: ()=>{},
12
+ activeDrawerId: null,
13
+ closeDrawer: ()=>{},
14
+ panelRef: {
15
+ current: null
16
+ },
17
+ setPlacement: ()=>{}
18
+ });
19
+ function getTargetElement(target) {
20
+ if (target instanceof Element) return target;
21
+ if (target instanceof Node && target.parentElement) return target.parentElement;
22
+ return document.documentElement;
23
+ }
24
+ function shouldCloseOnInteractOutsideByDefault(element) {
25
+ const overlay = element.closest('[data-overlay]');
26
+ return !overlay || overlay.hasAttribute('data-drawer-backdrop');
27
+ }
28
+ function DrawerBoundary({ children }) {
29
+ return children;
30
+ }
31
+ function GlobalDrawer({ children }) {
32
+ const { drawer, location } = useOverlayContext();
33
+ const Boundary = drawer?.boundaryComponent ?? DrawerBoundary;
34
+ const [currentDrawerConfig, overwriteDrawerConfig] = useState();
35
+ const currentDrawerConfigRef = useRef(currentDrawerConfig);
36
+ const [placement, setPlacement] = useState(null);
37
+ const isDrawerOpen = !!currentDrawerConfig;
38
+ const activeDrawerId = currentDrawerConfig?.callerId ?? null;
39
+ const scrollLock = useScrollLock(document.body);
40
+ const openDrawer = useCallback((renderer, options, callerId)=>{
41
+ if ('passive' !== options.mode) scrollLock.acquire();
42
+ overwriteDrawerConfig({
43
+ renderer,
44
+ options,
45
+ callerId
46
+ });
47
+ options.onOpen?.();
48
+ }, [
49
+ scrollLock
50
+ ]);
51
+ const closeDrawer = useCallback(()=>{
52
+ scrollLock.release();
53
+ overwriteDrawerConfig(void 0);
54
+ }, [
55
+ scrollLock
56
+ ]);
57
+ const handleClose = useCallback(()=>{
58
+ currentDrawerConfig?.options?.onClose?.();
59
+ closeDrawer();
60
+ }, [
61
+ currentDrawerConfig,
62
+ closeDrawer
63
+ ]);
64
+ useEffect(()=>{
65
+ currentDrawerConfigRef.current = currentDrawerConfig;
66
+ }, [
67
+ currentDrawerConfig
68
+ ]);
69
+ useLayoutEffect(()=>{
70
+ if (void 0 !== location && void 0 !== currentDrawerConfigRef.current && (currentDrawerConfigRef.current.options?.shouldCloseOnLocationChange?.(location) ?? currentDrawerConfigRef.current.options?.mode !== 'passive')) closeDrawer();
71
+ }, [
72
+ closeDrawer,
73
+ location
74
+ ]);
75
+ const panelRef = useRef(null);
76
+ const handleClickOutside = useCallback(()=>{
77
+ if (currentDrawerConfig?.options?.mode !== 'passive') handleClose();
78
+ }, [
79
+ currentDrawerConfig,
80
+ handleClose
81
+ ]);
82
+ const { shouldCloseOnInteractOutside = shouldCloseOnInteractOutsideByDefault } = currentDrawerConfig?.options ?? {};
83
+ useOnClickOutside(panelRef, (e)=>{
84
+ if (!shouldCloseOnInteractOutside(getTargetElement(e.target))) return;
85
+ handleClickOutside();
86
+ });
87
+ useHotkeys([
88
+ {
89
+ hotkey: 'Escape',
90
+ options: {
91
+ enabled: isDrawerOpen
92
+ },
93
+ callback: ()=>{
94
+ handleClose();
95
+ }
96
+ }
97
+ ]);
98
+ const renderedChild = currentDrawerConfig?.renderer ? currentDrawerConfig.renderer({
99
+ closeDrawer: handleClose
100
+ }) : null;
101
+ return /*#__PURE__*/ jsxs(DrawerContext, {
102
+ value: {
103
+ closeDrawer,
104
+ activeDrawerId,
105
+ openDrawer,
106
+ panelRef,
107
+ setPlacement
108
+ },
109
+ children: [
110
+ /*#__PURE__*/ jsx(Boundary, {
111
+ children: /*#__PURE__*/ jsxs(AnimatePresence, {
112
+ children: [
113
+ isDrawerOpen && 'passive' !== currentDrawerConfig.options.mode ? /*#__PURE__*/ jsx(Backdrop, {
114
+ zIndex: "drawer",
115
+ "data-drawer-backdrop": ""
116
+ }, "backdrop") : null,
117
+ isDrawerOpen && /*#__PURE__*/ jsx(DrawerComponents.DrawerPanel, {
118
+ ariaLabel: currentDrawerConfig.options.ariaLabel,
119
+ onClose: handleClose,
120
+ ref: panelRef,
121
+ mode: currentDrawerConfig.options.mode ?? 'blocking',
122
+ minPanelWidth: placement?.minWidth,
123
+ topOffset: placement?.topOffset,
124
+ drawerWidth: currentDrawerConfig?.options?.drawerWidth,
125
+ drawerMaxWidth: currentDrawerConfig?.options?.drawerMaxWidth,
126
+ drawerKey: currentDrawerConfig?.options?.drawerKey,
127
+ resizable: currentDrawerConfig?.options?.resizable,
128
+ children: renderedChild
129
+ }, "panel")
130
+ ]
131
+ })
132
+ }),
133
+ children
134
+ ]
135
+ });
136
+ }
137
+ function useDrawer() {
138
+ const context = useContext(DrawerContext);
139
+ const callerId = useId();
140
+ const openDrawerRef = useRef(context.openDrawer);
141
+ useEffect(()=>{
142
+ openDrawerRef.current = context.openDrawer;
143
+ });
144
+ const openDrawer = useCallback((renderer, options)=>{
145
+ openDrawerRef.current(renderer, options, callerId);
146
+ }, [
147
+ callerId
148
+ ]);
149
+ return {
150
+ openDrawer,
151
+ closeDrawer: context.closeDrawer,
152
+ panelRef: context.panelRef,
153
+ isDrawerOpen: context.activeDrawerId === callerId,
154
+ isAnyDrawerOpen: null !== context.activeDrawerId
155
+ };
156
+ }
157
+ function useDrawerPlacement({ minWidth, topOffset }) {
158
+ const { setPlacement } = useContext(DrawerContext);
159
+ useLayoutEffect(()=>{
160
+ setPlacement({
161
+ minWidth,
162
+ topOffset
163
+ });
164
+ return ()=>{
165
+ setPlacement(null);
166
+ };
167
+ }, [
168
+ setPlacement,
169
+ minWidth,
170
+ topOffset
171
+ ]);
172
+ }
173
+ export { GlobalDrawer, useDrawer, useDrawerPlacement };
@@ -0,0 +1,3 @@
1
+ export { DrawerBody, DrawerHeader, DrawerPanel, useDrawerContentContext, type DrawerHeaderProps, type DrawerPanelProps, } from './components.js';
2
+ export { GlobalDrawer, useDrawer, useDrawerPlacement, type DrawerOptions, type DrawerConfig, type GlobalDrawerProps, } from './globalDrawer.js';
3
+ export type { OverlayLocation } from '../overlayContext.js';
@@ -0,0 +1,2 @@
1
+ export { DrawerBody, DrawerHeader, DrawerPanel, useDrawerContentContext } from "./components.js";
2
+ export { GlobalDrawer, useDrawer, useDrawerPlacement } from "./globalDrawer.js";
@@ -0,0 +1,19 @@
1
+ import type * as React from 'react';
2
+ declare const MIN_WIDTH_PERCENT = 20;
3
+ declare const MAX_WIDTH_PERCENT = 85;
4
+ declare const DEFAULT_WIDTH_PERCENT = 50;
5
+ interface UseDrawerResizingOptions {
6
+ drawerKey?: string;
7
+ drawerMaxWidth?: string;
8
+ drawerWidth?: string;
9
+ enabled?: boolean;
10
+ }
11
+ interface UseDrawerResizingResult {
12
+ enabled: boolean;
13
+ handleResizeStart: (e: React.MouseEvent) => void;
14
+ panelRef: React.RefObject<HTMLDivElement>;
15
+ persistedWidthPercent: number;
16
+ resizeHandleRef: React.RefObject<HTMLDivElement>;
17
+ }
18
+ export declare function useDrawerResizing({ drawerKey, drawerWidth, drawerMaxWidth, enabled, }: UseDrawerResizingOptions): UseDrawerResizingResult;
19
+ export { MIN_WIDTH_PERCENT, MAX_WIDTH_PERCENT, DEFAULT_WIDTH_PERCENT };
@@ -0,0 +1,111 @@
1
+ import { useCallback, useLayoutEffect, useRef } from "react";
2
+ import { useTheme } from "@emotion/react";
3
+ import { useMedia } from "../useMedia.js";
4
+ import { useDrawerWidth } from "./useDrawerWidth.js";
5
+ const MIN_WIDTH_PERCENT = 20;
6
+ const MAX_WIDTH_PERCENT = 85;
7
+ const DEFAULT_WIDTH_PERCENT = 50;
8
+ function getDrawerWidthKey(drawerKey) {
9
+ return `drawer-width:${drawerKey}`;
10
+ }
11
+ function useDrawerResizing({ drawerKey, drawerWidth, drawerMaxWidth, enabled = true }) {
12
+ const theme = useTheme();
13
+ const isSmallScreen = useMedia(`(max-width: ${theme.breakpoints.sm})`);
14
+ const resizeHandleRef = useRef(null);
15
+ const panelRef = useRef(null);
16
+ const rafIdRef = useRef(null);
17
+ const initialMousePositionRef = useRef(null);
18
+ const calculateInitialWidth = (savedWidth)=>{
19
+ if (void 0 !== savedWidth) return Math.min(Math.max(savedWidth, MIN_WIDTH_PERCENT), MAX_WIDTH_PERCENT);
20
+ if (drawerWidth) {
21
+ if (drawerWidth.endsWith('%')) {
22
+ const parsedPercent = parseFloat(drawerWidth);
23
+ return Math.min(Math.max(parsedPercent, MIN_WIDTH_PERCENT), MAX_WIDTH_PERCENT);
24
+ }
25
+ const viewportWidth = window.innerWidth;
26
+ const parsedPixels = parseFloat(drawerWidth);
27
+ const percentValue = parsedPixels / viewportWidth * 100;
28
+ return Math.min(Math.max(percentValue, MIN_WIDTH_PERCENT), MAX_WIDTH_PERCENT);
29
+ }
30
+ return DEFAULT_WIDTH_PERCENT;
31
+ };
32
+ const [persistedWidthPercent, setPersistedWidthPercent] = useDrawerWidth(drawerKey ? getDrawerWidthKey(drawerKey) : 'drawer-width:default', (value)=>{
33
+ const savedWidth = 'number' == typeof value ? value : void 0;
34
+ return calculateInitialWidth(savedWidth);
35
+ });
36
+ useLayoutEffect(()=>{
37
+ if (isSmallScreen) {
38
+ panelRef.current?.style.setProperty('--drawer-width', '100%');
39
+ panelRef.current?.style.setProperty('--drawer-min-width', '100%');
40
+ panelRef.current?.style.setProperty('--drawer-max-width', '100%');
41
+ } else if (!enabled && drawerWidth) {
42
+ panelRef.current?.style.setProperty('--drawer-width', drawerWidth);
43
+ panelRef.current?.style.setProperty('--drawer-min-width', drawerWidth);
44
+ panelRef.current?.style.setProperty('--drawer-max-width', drawerWidth);
45
+ } else {
46
+ panelRef.current?.style.setProperty('--drawer-width', `${persistedWidthPercent}%`);
47
+ panelRef.current?.style.setProperty('--drawer-min-width', `${MIN_WIDTH_PERCENT}%`);
48
+ panelRef.current?.style.setProperty('--drawer-max-width', drawerMaxWidth ? `min(${MAX_WIDTH_PERCENT}%, ${drawerMaxWidth})` : `${MAX_WIDTH_PERCENT}%`);
49
+ }
50
+ }, [
51
+ persistedWidthPercent,
52
+ isSmallScreen,
53
+ drawerWidth,
54
+ drawerMaxWidth,
55
+ enabled
56
+ ]);
57
+ const handleResizeStart = useCallback((e)=>{
58
+ if (isSmallScreen || !enabled) return;
59
+ e.preventDefault();
60
+ const handle = resizeHandleRef.current;
61
+ const panel = panelRef.current;
62
+ if (!handle || !panel) return;
63
+ handle.setAttribute('data-resizing', '');
64
+ panel.setAttribute('data-resizing', '');
65
+ initialMousePositionRef.current = e.clientX;
66
+ const viewportWidth = "u" < typeof window ? 1000 : window.innerWidth;
67
+ const handleMouseMove = (moveEvent)=>{
68
+ moveEvent.preventDefault();
69
+ if (null !== rafIdRef.current) window.cancelAnimationFrame(rafIdRef.current);
70
+ rafIdRef.current = window.requestAnimationFrame(()=>{
71
+ if (!panel || !handle || null === initialMousePositionRef.current) return;
72
+ const newWidthPercent = (viewportWidth - moveEvent.clientX) / viewportWidth * 100;
73
+ panel.style.setProperty('--drawer-width', `${newWidthPercent}%`);
74
+ handle.setAttribute('data-at-min-width', (newWidthPercent <= MIN_WIDTH_PERCENT).toString());
75
+ handle.setAttribute('data-at-max-width', (Math.abs(newWidthPercent - MAX_WIDTH_PERCENT) < 1).toString());
76
+ });
77
+ };
78
+ const handleMouseUp = ()=>{
79
+ if (null !== rafIdRef.current) {
80
+ window.cancelAnimationFrame(rafIdRef.current);
81
+ rafIdRef.current = null;
82
+ }
83
+ if (handle) handle.removeAttribute('data-resizing');
84
+ if (panel) {
85
+ panel.removeAttribute('data-resizing');
86
+ const computedStyle = window.getComputedStyle(panel);
87
+ const widthValue = parseFloat(computedStyle.width) / viewportWidth * 100;
88
+ setPersistedWidthPercent(widthValue);
89
+ }
90
+ document.removeEventListener('mousemove', handleMouseMove);
91
+ document.removeEventListener('mouseup', handleMouseUp);
92
+ };
93
+ document.addEventListener('mousemove', handleMouseMove);
94
+ document.addEventListener('mouseup', handleMouseUp);
95
+ }, [
96
+ isSmallScreen,
97
+ enabled,
98
+ setPersistedWidthPercent
99
+ ]);
100
+ useLayoutEffect(()=>()=>{
101
+ if (null !== rafIdRef.current) window.cancelAnimationFrame(rafIdRef.current);
102
+ }, []);
103
+ return {
104
+ panelRef,
105
+ resizeHandleRef,
106
+ handleResizeStart,
107
+ persistedWidthPercent,
108
+ enabled: !isSmallScreen && !!drawerKey && enabled
109
+ };
110
+ }
111
+ export { DEFAULT_WIDTH_PERCENT, MAX_WIDTH_PERCENT, MIN_WIDTH_PERCENT, useDrawerResizing };
@@ -0,0 +1 @@
1
+ export declare function useDrawerWidth(key: string, initialize: (value?: unknown) => number): readonly [number, (nextWidth: number) => void];