reshaped 3.3.11 → 3.3.12

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 (250) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.js +16 -17
  4. package/dist/cjs/themes/_generator/utilities/generateColors.d.ts +1 -1
  5. package/dist/cjs/themes/_generator/utilities/generateColors.js +3 -2
  6. package/dist/cjs/themes/_generator/utilities/tests/color.test.js +32 -31
  7. package/dist/cjs/themes/slate/theme.css +1 -1
  8. package/dist/components/Accordion/tests/Accordion.stories.d.ts +30 -8
  9. package/dist/components/Accordion/tests/Accordion.stories.js +172 -119
  10. package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +12 -3
  11. package/dist/components/ActionBar/tests/ActionBar.stories.js +51 -36
  12. package/dist/components/ActionBar/tests/ActionBar.test.stories.d.ts +15 -0
  13. package/dist/components/ActionBar/tests/ActionBar.test.stories.js +26 -0
  14. package/dist/components/Actionable/Actionable.js +1 -1
  15. package/dist/components/Actionable/tests/Actionable.stories.d.ts +19 -5
  16. package/dist/components/Actionable/tests/Actionable.stories.js +88 -63
  17. package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +32 -0
  18. package/dist/components/Actionable/tests/Actionable.test.stories.js +130 -0
  19. package/dist/components/Alert/Alert.js +1 -1
  20. package/dist/components/Alert/tests/Alert.stories.d.ts +12 -3
  21. package/dist/components/Alert/tests/Alert.stories.js +51 -86
  22. package/dist/components/Alert/tests/Alert.test.stories.d.ts +15 -0
  23. package/dist/components/Alert/tests/Alert.test.stories.js +26 -0
  24. package/dist/components/Autocomplete/Autocomplete.js +9 -2
  25. package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +6 -2
  26. package/dist/components/Autocomplete/tests/Autocomplete.stories.js +94 -111
  27. package/dist/components/Autocomplete/tests/Autocomplete.test.stories.d.ts +23 -0
  28. package/dist/components/Autocomplete/tests/Autocomplete.test.stories.js +86 -0
  29. package/dist/components/Avatar/Avatar.js +1 -1
  30. package/dist/components/Avatar/tests/Avatar.stories.d.ts +14 -4
  31. package/dist/components/Avatar/tests/Avatar.stories.js +94 -80
  32. package/dist/components/Avatar/tests/Avatar.test.stories.d.ts +17 -0
  33. package/dist/components/Avatar/tests/Avatar.test.stories.js +39 -0
  34. package/dist/components/Badge/tests/Badge.stories.d.ts +33 -8
  35. package/dist/components/Badge/tests/Badge.stories.js +238 -212
  36. package/dist/components/Badge/tests/Badge.test.stories.d.ts +20 -0
  37. package/dist/components/Badge/tests/Badge.test.stories.js +44 -0
  38. package/dist/components/Breadcrumbs/Breadcrumbs.js +2 -2
  39. package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +1 -0
  40. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +24 -5
  41. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +114 -95
  42. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +23 -0
  43. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +76 -0
  44. package/dist/components/Button/Button.js +5 -2
  45. package/dist/components/Button/Button.module.css +1 -1
  46. package/dist/components/Button/Button.types.d.ts +1 -0
  47. package/dist/components/Button/tests/Button.stories.d.ts +2 -2
  48. package/dist/components/Button/tests/Button.stories.js +77 -74
  49. package/dist/components/Button/tests/Button.test.stories.d.ts +27 -0
  50. package/dist/components/Button/tests/Button.test.stories.js +112 -0
  51. package/dist/components/Calendar/tests/Calendar.test.stories.d.ts +26 -0
  52. package/dist/components/Calendar/tests/Calendar.test.stories.js +161 -0
  53. package/dist/components/Card/tests/Card.stories.d.ts +0 -1
  54. package/dist/components/Card/tests/Card.stories.js +0 -11
  55. package/dist/components/Card/tests/Card.test.stories.d.ts +35 -0
  56. package/dist/components/Card/tests/Card.test.stories.js +54 -0
  57. package/dist/components/Carousel/CarouselControl.js +1 -1
  58. package/dist/components/Carousel/tests/Carousel.stories.d.ts +3 -0
  59. package/dist/components/Carousel/tests/Carousel.stories.js +4 -0
  60. package/dist/components/Carousel/tests/Carousel.test.stories.d.ts +17 -0
  61. package/dist/components/Carousel/tests/Carousel.test.stories.js +52 -0
  62. package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +25 -0
  63. package/dist/components/Checkbox/tests/Checkbox.test.stories.js +104 -0
  64. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +22 -0
  65. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +78 -0
  66. package/dist/components/Container/Container.module.css +1 -1
  67. package/dist/components/Container/tests/Container.stories.d.ts +12 -3
  68. package/dist/components/Container/tests/Container.stories.js +50 -31
  69. package/dist/components/Container/tests/Container.test.stories.d.ts +15 -0
  70. package/dist/components/Container/tests/Container.test.stories.js +26 -0
  71. package/dist/components/ContextMenu/ContextMenu.js +13 -9
  72. package/dist/components/ContextMenu/tests/ContextMenu.stories.js +2 -3
  73. package/dist/components/ContextMenu/tests/ContextMenu.test.stories.d.ts +26 -0
  74. package/dist/components/ContextMenu/tests/ContextMenu.test.stories.js +53 -0
  75. package/dist/components/Dismissible/Dismissible.js +1 -1
  76. package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +10 -3
  77. package/dist/components/Dismissible/tests/Dismissible.stories.js +51 -34
  78. package/dist/components/Dismissible/tests/Dismissible.test.stories.d.ts +19 -0
  79. package/dist/components/Dismissible/tests/Dismissible.test.stories.js +42 -0
  80. package/dist/components/Divider/tests/Divider.test.stories.d.ts +18 -0
  81. package/dist/components/Divider/tests/Divider.test.stories.js +47 -0
  82. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +37 -0
  83. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +117 -0
  84. package/dist/components/FileUpload/tests/FileUpload.test.stories.d.ts +22 -0
  85. package/dist/components/FileUpload/tests/FileUpload.test.stories.js +52 -0
  86. package/dist/components/FormControl/FormControlCaption.js +1 -1
  87. package/dist/components/FormControl/FormControlLabel.js +1 -1
  88. package/dist/components/FormControl/tests/FormControl.stories.d.ts +11 -5
  89. package/dist/components/FormControl/tests/FormControl.stories.js +78 -73
  90. package/dist/components/FormControl/tests/FormControl.test.stories.d.ts +20 -0
  91. package/dist/components/FormControl/tests/FormControl.test.stories.js +49 -0
  92. package/dist/components/Grid/tests/Grid.stories.d.ts +20 -5
  93. package/dist/components/Grid/tests/Grid.stories.js +164 -149
  94. package/dist/components/Grid/tests/Grid.test.stories.d.ts +19 -0
  95. package/dist/components/Grid/tests/Grid.test.stories.js +42 -0
  96. package/dist/components/Hidden/tests/Hidden.stories.d.ts +4 -1
  97. package/dist/components/Hidden/tests/Hidden.stories.js +28 -25
  98. package/dist/components/Hidden/tests/Hidden.test.stories.d.ts +15 -0
  99. package/dist/components/Hidden/tests/Hidden.test.stories.js +20 -0
  100. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +4 -1
  101. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +8 -5
  102. package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.d.ts +15 -0
  103. package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.js +20 -0
  104. package/dist/components/Hotkey/tests/Hotkey.test.stories.d.ts +15 -0
  105. package/dist/components/Hotkey/tests/Hotkey.test.stories.js +26 -0
  106. package/dist/components/Icon/tests/Icon.stories.d.ts +12 -3
  107. package/dist/components/Icon/tests/Icon.stories.js +69 -60
  108. package/dist/components/Icon/tests/Icon.test.stories.d.ts +16 -0
  109. package/dist/components/Icon/tests/Icon.test.stories.js +35 -0
  110. package/dist/components/Image/tests/Image.stories.d.ts +24 -5
  111. package/dist/components/Image/tests/Image.stories.js +95 -75
  112. package/dist/components/Image/tests/Image.test.stories.d.ts +25 -0
  113. package/dist/components/Image/tests/Image.test.stories.js +80 -0
  114. package/dist/components/Link/tests/Link.test.stories.d.ts +29 -0
  115. package/dist/components/Link/tests/Link.test.stories.js +87 -0
  116. package/dist/components/Loader/Loader.js +1 -1
  117. package/dist/components/Loader/Loader.types.d.ts +1 -0
  118. package/dist/components/Loader/tests/Loader.stories.js +8 -8
  119. package/dist/components/Loader/tests/Loader.test.stories.d.ts +16 -0
  120. package/dist/components/Loader/tests/Loader.test.stories.js +32 -0
  121. package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +26 -0
  122. package/dist/components/MenuItem/tests/MenuItem.test.stories.js +100 -0
  123. package/dist/components/Modal/tests/Modal.test.stories.d.ts +32 -0
  124. package/dist/components/Modal/tests/Modal.test.stories.js +149 -0
  125. package/dist/components/Overlay/tests/Overlay.stories.d.ts +4 -2
  126. package/dist/components/Overlay/tests/Overlay.stories.js +53 -53
  127. package/dist/components/Overlay/tests/Overlay.test.stories.d.ts +28 -0
  128. package/dist/components/Overlay/tests/Overlay.test.stories.js +146 -0
  129. package/dist/components/Pagination/tests/Pagination.test.stories.d.ts +23 -0
  130. package/dist/components/Pagination/tests/Pagination.test.stories.js +86 -0
  131. package/dist/components/PinField/tests/PinField.stories.d.ts +0 -1
  132. package/dist/components/PinField/tests/PinField.stories.js +10 -19
  133. package/dist/components/PinField/tests/PinField.test.stories.d.ts +29 -0
  134. package/dist/components/PinField/tests/PinField.test.stories.js +177 -0
  135. package/dist/components/Popover/tests/Popover.test.stories.d.ts +40 -0
  136. package/dist/components/Popover/tests/Popover.test.stories.js +167 -0
  137. package/dist/components/Progress/Progress.js +2 -2
  138. package/dist/components/Progress/Progress.types.d.ts +1 -0
  139. package/dist/components/Progress/tests/Progress.stories.js +10 -10
  140. package/dist/components/Progress/tests/Progress.test.stories.d.ts +16 -0
  141. package/dist/components/Progress/tests/Progress.test.stories.js +35 -0
  142. package/dist/components/Radio/tests/Radio.test.stories.d.ts +30 -0
  143. package/dist/components/Radio/tests/Radio.test.stories.js +118 -0
  144. package/dist/components/RadioGroup/tests/RadioGroup.test.stories.d.ts +22 -0
  145. package/dist/components/RadioGroup/tests/RadioGroup.test.stories.js +78 -0
  146. package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +33 -0
  147. package/dist/components/Reshaped/tests/Reshaped.stories.js +88 -0
  148. package/dist/components/Resizable/Resizable.js +1 -0
  149. package/dist/components/Resizable/tests/Resizable.stories.d.ts +3 -0
  150. package/dist/components/Resizable/tests/Resizable.stories.js +4 -0
  151. package/dist/components/Resizable/tests/Resizable.test.stories.d.ts +19 -0
  152. package/dist/components/Resizable/tests/Resizable.test.stories.js +25 -0
  153. package/dist/components/Scrim/tests/Scrim.test.stories.d.ts +15 -0
  154. package/dist/components/Scrim/tests/Scrim.test.stories.js +25 -0
  155. package/dist/components/ScrollArea/ScrollArea.js +1 -1
  156. package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
  157. package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +17 -4
  158. package/dist/components/ScrollArea/tests/ScrollArea.stories.js +114 -139
  159. package/dist/components/ScrollArea/tests/ScrollArea.test.stories.d.ts +23 -0
  160. package/dist/components/ScrollArea/tests/ScrollArea.test.stories.js +66 -0
  161. package/dist/components/Select/tests/Select.stories.d.ts +1 -1
  162. package/dist/components/Select/tests/Select.stories.js +5 -12
  163. package/dist/components/Select/tests/Select.test.stories.d.ts +27 -0
  164. package/dist/components/Select/tests/Select.test.stories.js +132 -0
  165. package/dist/components/Skeleton/tests/Skeleton.test.stories.d.ts +15 -0
  166. package/dist/components/Skeleton/tests/Skeleton.test.stories.js +23 -0
  167. package/dist/components/Slider/tests/Slider.stories.d.ts +0 -1
  168. package/dist/components/Slider/tests/Slider.stories.js +8 -9
  169. package/dist/components/Slider/tests/Slider.test.stories.d.ts +38 -0
  170. package/dist/components/Slider/tests/Slider.test.stories.js +150 -0
  171. package/dist/components/Stepper/Stepper.js +1 -1
  172. package/dist/components/Stepper/tests/Stepper.stories.js +0 -3
  173. package/dist/components/Stepper/tests/Stepper.test.stories.d.ts +18 -0
  174. package/dist/components/Stepper/tests/Stepper.test.stories.js +28 -0
  175. package/dist/components/Switch/tests/Switch.test.stories.d.ts +23 -0
  176. package/dist/components/Switch/tests/Switch.test.stories.js +79 -0
  177. package/dist/components/Table/tests/Table.test.stories.d.ts +25 -0
  178. package/dist/components/Table/tests/Table.test.stories.js +93 -0
  179. package/dist/components/Tabs/tests/Tabs.stories.js +4 -4
  180. package/dist/components/Tabs/tests/Tabs.test.stories.d.ts +28 -0
  181. package/dist/components/Tabs/tests/Tabs.test.stories.js +128 -0
  182. package/dist/components/Text/tests/Text.stories.d.ts +28 -7
  183. package/dist/components/Text/tests/Text.stories.js +148 -125
  184. package/dist/components/Text/tests/Text.test.stories.d.ts +18 -0
  185. package/dist/components/Text/tests/Text.test.stories.js +49 -0
  186. package/dist/components/TextArea/TextArea.module.css +1 -1
  187. package/dist/components/TextArea/tests/TextArea.stories.js +1 -1
  188. package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +29 -0
  189. package/dist/components/TextArea/tests/TextArea.test.stories.js +99 -0
  190. package/dist/components/TextField/tests/TextField.stories.js +1 -1
  191. package/dist/components/TextField/tests/TextField.test.stories.d.ts +29 -0
  192. package/dist/components/TextField/tests/TextField.test.stories.js +99 -0
  193. package/dist/components/Theme/tests/Theme.test.stories.d.ts +24 -0
  194. package/dist/components/Theme/tests/Theme.test.stories.js +133 -0
  195. package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +18 -0
  196. package/dist/components/Timeline/tests/Timeline.test.stories.js +32 -0
  197. package/dist/components/Toast/tests/Toast.test.stories.d.ts +16 -0
  198. package/dist/components/Toast/tests/Toast.test.stories.js +101 -0
  199. package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -14
  200. package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +19 -0
  201. package/dist/components/Tooltip/tests/Tooltip.test.stories.js +40 -0
  202. package/dist/components/View/View.js +1 -2
  203. package/dist/components/View/tests/View.stories.d.ts +112 -28
  204. package/dist/components/View/tests/View.stories.js +1092 -1012
  205. package/dist/components/View/tests/View.test.stories.d.ts +20 -0
  206. package/dist/components/View/tests/View.test.stories.js +50 -0
  207. package/dist/components/_private/Flyout/FlyoutContent.js +1 -1
  208. package/dist/components/_private/Flyout/tests/Flyout.stories.js +4 -4
  209. package/dist/components/_private/Flyout/tests/Flyout.test.stories.d.ts +28 -0
  210. package/dist/components/_private/Flyout/tests/Flyout.test.stories.js +205 -0
  211. package/dist/components/_private/Portal/tests/Portal.stories.js +1 -1
  212. package/dist/hooks/_private/useSingletonHotkeys.d.ts +3 -3
  213. package/dist/hooks/_private/useSingletonHotkeys.js +1 -1
  214. package/dist/hooks/tests/useDrag.stories.js +1 -0
  215. package/dist/hooks/tests/useDrag.test.stories.d.ts +26 -0
  216. package/dist/hooks/tests/useDrag.test.stories.js +120 -0
  217. package/dist/hooks/tests/useElementId.stories.d.ts +6 -0
  218. package/dist/hooks/tests/useElementId.stories.js +19 -0
  219. package/dist/hooks/tests/useHotkeys.test.stories.d.ts +39 -0
  220. package/dist/hooks/tests/useHotkeys.test.stories.js +119 -0
  221. package/dist/hooks/tests/useRTL.stories.d.ts +6 -0
  222. package/dist/hooks/tests/useRTL.stories.js +25 -0
  223. package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +9 -1
  224. package/dist/hooks/tests/useResponsiveClientValue.stories.js +22 -9
  225. package/dist/hooks/tests/useScrollLock.stories.d.ts +6 -0
  226. package/dist/hooks/tests/useScrollLock.stories.js +22 -0
  227. package/dist/hooks/tests/useToggle.stories.d.ts +8 -0
  228. package/dist/hooks/tests/useToggle.stories.js +54 -0
  229. package/dist/hooks/useHotkeys.js +0 -2
  230. package/dist/hooks/useScrollLock.d.ts +1 -0
  231. package/dist/hooks/useScrollLock.js +7 -3
  232. package/dist/tests/ShadowDOM.stories.js +1 -1
  233. package/dist/themes/_generator/tests/themes.stories.d.ts +3 -0
  234. package/dist/themes/_generator/tests/themes.stories.js +7 -11
  235. package/dist/themes/_generator/utilities/generateColors.d.ts +1 -1
  236. package/dist/themes/_generator/utilities/generateColors.js +3 -2
  237. package/dist/themes/slate/theme.css +1 -1
  238. package/dist/utilities/helpers.d.ts +1 -0
  239. package/dist/utilities/helpers.js +3 -0
  240. package/dist/utilities/scroll/lock.d.ts +1 -0
  241. package/dist/utilities/scroll/lock.js +3 -3
  242. package/dist/utilities/scroll/lockSafari.d.ts +1 -1
  243. package/dist/utilities/scroll/lockSafari.js +4 -5
  244. package/dist/utilities/scroll/lockStandard.d.ts +4 -1
  245. package/dist/utilities/scroll/lockStandard.js +7 -2
  246. package/dist/utilities/storybook/Example.js +1 -2
  247. package/package.json +20 -19
  248. package/dist/components/Theme/tests/Theme.stories.d.ts +0 -13
  249. package/dist/components/Theme/tests/Theme.stories.js +0 -80
  250. package/dist/utilities/storybook/Example.module.css +0 -1
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import { StoryObj } from "@storybook/react";
3
+ import { fn } from "@storybook/test";
4
+ declare const _default: {
5
+ title: string;
6
+ component: React.ForwardRefExoticComponent<{
7
+ padding?: import("../../../types/global").Responsive<number>;
8
+ bleed?: import("../../../types/global").Responsive<number>;
9
+ selected?: boolean;
10
+ elevated?: boolean;
11
+ children?: React.ReactNode;
12
+ onClick?: import("../../Actionable").ActionableProps["onClick"];
13
+ href?: string;
14
+ as?: keyof React.JSX.IntrinsicElements | undefined;
15
+ className?: import("../../../types/global").ClassName;
16
+ attributes?: (import("../../../types/global").Attributes<keyof React.JSX.IntrinsicElements> & ((import("../../../types/global").Attributes<"button"> & Omit<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "children" | "ref" | "style" | "form" | "slot" | "title" | "disabled" | "color" | "className" | "hidden" | "content" | "aria-orientation" | "role" | "suppressHydrationWarning" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "dir" | "name" | "key" | "accessKey" | "autoCapitalize" | "autoFocus" | "contentEditable" | "contextMenu" | "draggable" | "enterKeyHint" | "nonce" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "onToggle" | "type" | "id" | "lang" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture"> & {
17
+ ref?: React.RefObject<HTMLButtonElement | HTMLAnchorElement | null>;
18
+ }) | undefined)) | undefined;
19
+ } & Pick<import("../../View").ViewProps, "height"> & React.RefAttributes<HTMLElement>>;
20
+ parameters: {
21
+ iframe: {
22
+ url: string;
23
+ };
24
+ chromatic: {
25
+ disableSnapshot: boolean;
26
+ };
27
+ };
28
+ };
29
+ export default _default;
30
+ export declare const onClick: StoryObj<{
31
+ handleClick: ReturnType<typeof fn>;
32
+ }>;
33
+ export declare const href: StoryObj;
34
+ export declare const as: StoryObj;
35
+ export declare const className: StoryObj;
@@ -0,0 +1,54 @@
1
+ import React from "react";
2
+ import { expect, fn, userEvent } from "@storybook/test";
3
+ import Card from "../index.js";
4
+ export default {
5
+ title: "Components/Card/tests",
6
+ component: Card,
7
+ parameters: {
8
+ iframe: {
9
+ url: "https://reshaped.so/docs/components/card",
10
+ },
11
+ chromatic: { disableSnapshot: true },
12
+ },
13
+ };
14
+ export const onClick = {
15
+ name: "onClick",
16
+ args: {
17
+ handleClick: fn(),
18
+ },
19
+ render: (args) => <Card onClick={args.handleClick}>Trigger</Card>,
20
+ play: async ({ canvas, args }) => {
21
+ const { handleClick } = args;
22
+ const el = canvas.getAllByRole("button")[0];
23
+ await userEvent.click(el);
24
+ expect(handleClick).toHaveBeenCalledTimes(1);
25
+ expect(handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: el }));
26
+ },
27
+ };
28
+ export const href = {
29
+ name: "href",
30
+ render: () => <Card href="https://reshaped.so">Trigger</Card>,
31
+ play: async ({ canvas }) => {
32
+ const el = canvas.getByRole("link");
33
+ expect(el).toHaveAttribute("href", "https://reshaped.so");
34
+ },
35
+ };
36
+ export const as = {
37
+ name: "as",
38
+ render: () => <Card as="span" attributes={{ "data-testid": "root" }}/>,
39
+ play: ({ canvas }) => {
40
+ const root = canvas.getByTestId("root");
41
+ expect(root.tagName).toBe("SPAN");
42
+ },
43
+ };
44
+ export const className = {
45
+ name: "className, attributes",
46
+ render: () => (<div data-testid="root">
47
+ <Card className="test-classname" attributes={{ id: "test-id" }}/>
48
+ </div>),
49
+ play: async ({ canvas }) => {
50
+ const root = canvas.getByTestId("root").firstChild;
51
+ expect(root).toHaveClass("test-classname");
52
+ expect(root).toHaveAttribute("id", "test-id");
53
+ },
54
+ };
@@ -37,6 +37,6 @@ const CarouselControl = (props) => {
37
37
  clearTimeout(timer);
38
38
  };
39
39
  }, [scrollPosition, scrollElRef, mounted, isNext]);
40
- return (_jsx("div", { className: controlClassNames, "aria-hidden": "true", children: _jsx(Button, { onClick: onClick, icon: isDisplayedAsNext ? IconChevronRight : IconChevronLeft, rounded: true, variant: "outline", elevated: true, attributes: { "aria-disabled": !visible } }) }));
40
+ return (_jsx("div", { className: controlClassNames, children: _jsx(Button, { onClick: onClick, icon: isDisplayedAsNext ? IconChevronRight : IconChevronLeft, rounded: true, variant: "outline", elevated: true, attributes: { "aria-disabled": !visible, "aria-hidden": true } }) }));
41
41
  };
42
42
  export default CarouselControl;
@@ -3,6 +3,9 @@ declare const _default: {
3
3
  title: string;
4
4
  component: (props: import("./..").CarouselProps) => React.JSX.Element;
5
5
  parameters: {
6
+ a11y: {
7
+ disable: boolean;
8
+ };
6
9
  iframe: {
7
10
  url: string;
8
11
  };
@@ -7,6 +7,10 @@ export default {
7
7
  title: "Components/Carousel",
8
8
  component: Carousel,
9
9
  parameters: {
10
+ // Skip because of the aria-hidden applied to buttons, they're replaced by screen reader navigation
11
+ a11y: {
12
+ disable: true,
13
+ },
10
14
  iframe: {
11
15
  url: "https://reshaped.so/docs/components/carousel",
12
16
  },
@@ -0,0 +1,17 @@
1
+ import { StoryObj } from "@storybook/react";
2
+ declare const _default: {
3
+ title: string;
4
+ component: (props: import("./..").CarouselProps) => import("react").JSX.Element;
5
+ parameters: {
6
+ iframe: {
7
+ url: string;
8
+ };
9
+ chromatic: {
10
+ disableSnapshot: boolean;
11
+ };
12
+ };
13
+ };
14
+ export default _default;
15
+ export declare const render: StoryObj;
16
+ export declare const navigationDisplay: StoryObj;
17
+ export declare const className: StoryObj;
@@ -0,0 +1,52 @@
1
+ import { expect } from "@storybook/test";
2
+ import Carousel from "../index.js";
3
+ export default {
4
+ title: "Components/Carousel/tests",
5
+ component: Carousel,
6
+ parameters: {
7
+ iframe: {
8
+ url: "https://reshaped.so/docs/components/carousel",
9
+ },
10
+ chromatic: { disableSnapshot: true },
11
+ },
12
+ };
13
+ export const render = {
14
+ name: "rendering",
15
+ render: () => (<Carousel attributes={{ "data-testid": "test-id" }}>
16
+ <div>Content</div>
17
+ <div>Content</div>
18
+ </Carousel>),
19
+ play: async ({ canvas }) => {
20
+ const elRoot = canvas.getByTestId("test-id");
21
+ const elItems = canvas.getAllByText("Content");
22
+ const elButtons = elRoot.querySelectorAll("button");
23
+ expect(elRoot).toBeInTheDocument();
24
+ expect(elRoot.tagName).toBe("SECTION");
25
+ expect(elItems).toHaveLength(2);
26
+ expect(elButtons).toHaveLength(2);
27
+ },
28
+ };
29
+ export const navigationDisplay = {
30
+ name: "navigationDisplay",
31
+ render: () => (<Carousel navigationDisplay="hidden" attributes={{ "data-testid": "test-id" }}>
32
+ <div>Content</div>
33
+ </Carousel>),
34
+ play: async ({ canvas }) => {
35
+ const elRoot = canvas.getByTestId("test-id");
36
+ const elButtons = elRoot.querySelectorAll("button");
37
+ expect(elButtons).toHaveLength(0);
38
+ },
39
+ };
40
+ export const className = {
41
+ name: "className, attributes",
42
+ render: () => (<div data-testid="root">
43
+ <Carousel className="test-classname" attributes={{ id: "test-id" }}>
44
+ <div>Content</div>
45
+ </Carousel>
46
+ </div>),
47
+ play: async ({ canvas }) => {
48
+ const root = canvas.getByTestId("root").firstChild;
49
+ expect(root).toHaveClass("test-classname");
50
+ expect(root).toHaveAttribute("id", "test-id");
51
+ },
52
+ };
@@ -0,0 +1,25 @@
1
+ import { StoryObj } from "@storybook/react";
2
+ import { fn } from "@storybook/test";
3
+ declare const _default: {
4
+ title: string;
5
+ component: (props: import("./..").CheckboxProps) => import("react").JSX.Element;
6
+ parameters: {
7
+ iframe: {
8
+ url: string;
9
+ };
10
+ chromatic: {
11
+ disableSnapshot: boolean;
12
+ };
13
+ };
14
+ };
15
+ export default _default;
16
+ export declare const render: StoryObj;
17
+ export declare const checked: StoryObj<{
18
+ handleChange: ReturnType<typeof fn>;
19
+ }>;
20
+ export declare const defaultChecked: StoryObj<{
21
+ handleChange: ReturnType<typeof fn>;
22
+ }>;
23
+ export declare const disabled: StoryObj;
24
+ export declare const indeterminate: StoryObj;
25
+ export declare const className: StoryObj;
@@ -0,0 +1,104 @@
1
+ import { expect, userEvent, fn } from "@storybook/test";
2
+ import Checkbox from "../index.js";
3
+ export default {
4
+ title: "Components/Checkbox/tests",
5
+ component: Checkbox,
6
+ parameters: {
7
+ iframe: {
8
+ url: "https://reshaped.so/docs/components/checkbox",
9
+ },
10
+ chromatic: { disableSnapshot: true },
11
+ },
12
+ };
13
+ export const render = {
14
+ name: "name, value",
15
+ render: () => (<Checkbox name="test-name" value="test-value">
16
+ Content
17
+ </Checkbox>),
18
+ play: async ({ canvas }) => {
19
+ const input = canvas.getByRole("checkbox");
20
+ expect(input).toHaveAttribute("value", "test-value");
21
+ expect(input).toHaveAttribute("name", "test-name");
22
+ expect(input).not.toBeChecked();
23
+ },
24
+ };
25
+ export const checked = {
26
+ name: "checked, controlled",
27
+ args: {
28
+ handleChange: fn(),
29
+ },
30
+ render: (args) => (<Checkbox name="test-name" value="test-value" checked onChange={args.handleChange}>
31
+ Content
32
+ </Checkbox>),
33
+ play: async ({ canvas, args }) => {
34
+ const input = canvas.getByRole("checkbox");
35
+ expect(input).toBeChecked();
36
+ await userEvent.click(input);
37
+ expect(args.handleChange).toHaveBeenCalledTimes(1);
38
+ expect(args.handleChange).toHaveBeenCalledWith({
39
+ name: "test-name",
40
+ value: "test-value",
41
+ checked: false,
42
+ event: expect.objectContaining({ target: input }),
43
+ });
44
+ // Still checked because it's controlled
45
+ expect(input).toBeChecked();
46
+ },
47
+ };
48
+ export const defaultChecked = {
49
+ name: "defaultChecked, uncontrolled",
50
+ args: {
51
+ handleChange: fn(),
52
+ },
53
+ render: (args) => (<Checkbox name="test-name" value="test-value" defaultChecked onChange={args.handleChange}>
54
+ Content
55
+ </Checkbox>),
56
+ play: async ({ canvas, args }) => {
57
+ const input = canvas.getByRole("checkbox");
58
+ expect(input).toBeChecked();
59
+ await userEvent.click(input);
60
+ expect(args.handleChange).toHaveBeenCalledTimes(1);
61
+ expect(args.handleChange).toHaveBeenCalledWith({
62
+ name: "test-name",
63
+ value: "test-value",
64
+ checked: false,
65
+ event: expect.objectContaining({ target: input }),
66
+ });
67
+ expect(input).not.toBeChecked();
68
+ },
69
+ };
70
+ export const disabled = {
71
+ name: "disabled",
72
+ render: () => (<Checkbox name="test-name" value="test-value" disabled>
73
+ Content
74
+ </Checkbox>),
75
+ play: async ({ canvas }) => {
76
+ const input = canvas.getByRole("checkbox");
77
+ expect(input).toBeDisabled();
78
+ },
79
+ };
80
+ export const indeterminate = {
81
+ name: "indeterminate",
82
+ render: () => (<Checkbox name="test-name" value="test-value" indeterminate>
83
+ Content
84
+ </Checkbox>),
85
+ play: async ({ canvas }) => {
86
+ const input = canvas.getByRole("checkbox");
87
+ expect(input.indeterminate).toBeTruthy();
88
+ await userEvent.click(input);
89
+ expect(input.indeterminate).toBeFalsy();
90
+ },
91
+ };
92
+ export const className = {
93
+ name: "className, attributes",
94
+ render: () => (<div data-testid="root">
95
+ <Checkbox className="test-classname" attributes={{ id: "test-id" }}>
96
+ Content
97
+ </Checkbox>
98
+ </div>),
99
+ play: async ({ canvas }) => {
100
+ const root = canvas.getByTestId("root").firstChild;
101
+ expect(root).toHaveClass("test-classname");
102
+ expect(root).toHaveAttribute("id", "test-id");
103
+ },
104
+ };
@@ -0,0 +1,22 @@
1
+ import { StoryObj } from "@storybook/react";
2
+ import { fn } from "@storybook/test";
3
+ declare const _default: {
4
+ title: string;
5
+ component: (props: import("./..").CheckboxGroupProps) => import("react").JSX.Element;
6
+ parameters: {
7
+ iframe: {
8
+ url: string;
9
+ };
10
+ chromatic: {
11
+ disableSnapshot: boolean;
12
+ };
13
+ };
14
+ };
15
+ export default _default;
16
+ export declare const value: StoryObj<{
17
+ handleChange: ReturnType<typeof fn>;
18
+ }>;
19
+ export declare const defaultValue: StoryObj<{
20
+ handleChange: ReturnType<typeof fn>;
21
+ }>;
22
+ export declare const disabled: StoryObj;
@@ -0,0 +1,78 @@
1
+ import { fn, userEvent, expect } from "@storybook/test";
2
+ import CheckboxGroup from "../index.js";
3
+ import Checkbox from "../../Checkbox/index.js";
4
+ export default {
5
+ title: "Components/CheckboxGroup/tests",
6
+ component: CheckboxGroup,
7
+ parameters: {
8
+ iframe: {
9
+ url: "https://reshaped.so/docs/components/checkbox",
10
+ },
11
+ chromatic: { disableSnapshot: true },
12
+ },
13
+ };
14
+ export const value = {
15
+ name: "value, controlled",
16
+ args: {
17
+ handleChange: fn(),
18
+ },
19
+ render: (args) => (<CheckboxGroup name="test-name" value={["1"]} onChange={args.handleChange}>
20
+ {/* checked should be ignored */}
21
+ <Checkbox value="1" checked={false}>
22
+ Content
23
+ </Checkbox>
24
+
25
+ <Checkbox value="2">Content 2</Checkbox>
26
+ </CheckboxGroup>),
27
+ play: async ({ canvas, args }) => {
28
+ const inputs = canvas.getAllByRole("checkbox");
29
+ expect(inputs[0]).toBeChecked();
30
+ await userEvent.click(inputs[1]);
31
+ expect(args.handleChange).toHaveBeenCalledTimes(1);
32
+ expect(args.handleChange).toHaveBeenCalledWith({
33
+ name: "test-name",
34
+ value: ["1", "2"],
35
+ event: expect.objectContaining({ target: inputs[1] }),
36
+ });
37
+ // Still checked because it's controlled
38
+ expect(inputs[0]).toBeChecked();
39
+ expect(inputs[1]).not.toBeChecked();
40
+ },
41
+ };
42
+ export const defaultValue = {
43
+ name: "defaultValue, uncontrolled",
44
+ args: {
45
+ handleChange: fn(),
46
+ },
47
+ render: (args) => (<CheckboxGroup name="test-name" defaultValue={["1"]} onChange={args.handleChange}>
48
+ {/* checked should be ignored */}
49
+ <Checkbox value="1" checked={false}>
50
+ Content
51
+ </Checkbox>
52
+
53
+ <Checkbox value="2">Content 2</Checkbox>
54
+ </CheckboxGroup>),
55
+ play: async ({ canvas, args }) => {
56
+ const inputs = canvas.getAllByRole("checkbox");
57
+ expect(inputs[0]).toBeChecked();
58
+ await userEvent.click(inputs[1]);
59
+ expect(args.handleChange).toHaveBeenCalledTimes(1);
60
+ expect(args.handleChange).toHaveBeenCalledWith({
61
+ name: "test-name",
62
+ value: ["1", "2"],
63
+ event: expect.objectContaining({ target: inputs[1] }),
64
+ });
65
+ expect(inputs[0]).toBeChecked();
66
+ expect(inputs[1]).toBeChecked();
67
+ },
68
+ };
69
+ export const disabled = {
70
+ name: "disabled",
71
+ render: () => (<CheckboxGroup name="test-name" disabled>
72
+ <Checkbox value="test-value">Content</Checkbox>
73
+ </CheckboxGroup>),
74
+ play: async ({ canvas }) => {
75
+ const input = canvas.getByRole("checkbox");
76
+ expect(input).toBeDisabled();
77
+ },
78
+ };
@@ -1 +1 @@
1
- .root{margin:0 auto}
1
+ .root{box-sizing:content-box;margin:0 auto}
@@ -8,6 +8,15 @@ declare const _default: {
8
8
  };
9
9
  };
10
10
  export default _default;
11
- export declare const padding: () => import("react").JSX.Element;
12
- export declare const width: () => import("react").JSX.Element;
13
- export declare const layout: () => import("react").JSX.Element;
11
+ export declare const padding: {
12
+ name: string;
13
+ render: () => import("react").JSX.Element;
14
+ };
15
+ export declare const size: {
16
+ name: string;
17
+ render: () => import("react").JSX.Element;
18
+ };
19
+ export declare const flex: {
20
+ name: string;
21
+ render: () => import("react").JSX.Element;
22
+ };
@@ -9,34 +9,53 @@ export default {
9
9
  },
10
10
  },
11
11
  };
12
- export const padding = () => (<Example>
13
- <Example.Item title="padding: default">
14
- <Container>
15
- <Placeholder />
16
- </Container>
17
- </Example.Item>
18
- <Example.Item title="padding: 0">
19
- <Container padding={0}>
20
- <Placeholder />
21
- </Container>
22
- </Example.Item>
23
- </Example>);
24
- export const width = () => (<Example>
25
- <Example.Item title="width: 1024px">
26
- <Container width="1024px">
27
- <Placeholder />
28
- </Container>
29
- </Example.Item>
30
- <Example.Item title={["responsive width", "[s]: 400px", "[m+]: 600px"]}>
31
- <Container width={{ s: "400px", m: "600px" }}>
32
- <Placeholder />
33
- </Container>
34
- </Example.Item>
35
- </Example>);
36
- export const layout = () => (<Example>
37
- <Example.Item title="center">
38
- <Container align="center" justify="center" height="500px">
39
- <Placeholder />
40
- </Container>
41
- </Example.Item>
42
- </Example>);
12
+ export const padding = {
13
+ name: "padding",
14
+ render: () => (<Example>
15
+ <Example.Item title="padding: default">
16
+ <Container>
17
+ <Placeholder />
18
+ </Container>
19
+ </Example.Item>
20
+ <Example.Item title="padding: 0">
21
+ <Container padding={0}>
22
+ <Placeholder />
23
+ </Container>
24
+ </Example.Item>
25
+ </Example>),
26
+ };
27
+ export const size = {
28
+ name: "width, height, maxHeight",
29
+ render: () => (<Example>
30
+ <Example.Item title="width: 200px, height: 200px">
31
+ <Container width="200px" height="200px">
32
+ <Placeholder h="100%"/>
33
+ </Container>
34
+ </Example.Item>
35
+ <Example.Item title="width: 200px, height: 200px, maxHeight: 100px">
36
+ <Container width="200px" height="200px" maxHeight="100px">
37
+ <Placeholder h="100%"/>
38
+ </Container>
39
+ </Example.Item>
40
+ <Example.Item title="width, height: [s] 100px, [m+] 200px">
41
+ <Container width={{ s: "100px", m: "200px" }} height={{ s: "100px", m: "200px" }}>
42
+ <Placeholder h="100%"/>
43
+ </Container>
44
+ </Example.Item>
45
+ <Example.Item title="width, height: [s] 100px, [m+] 200px, maxHeight: [s] 50px, [m+]: 100px">
46
+ <Container width={{ s: "100px", m: "200px" }} height={{ s: "100px", m: "200px" }} maxHeight={{ s: "50px", m: "100px" }}>
47
+ <Placeholder h="100%"/>
48
+ </Container>
49
+ </Example.Item>
50
+ </Example>),
51
+ };
52
+ export const flex = {
53
+ name: "align, justify",
54
+ render: () => (<Example>
55
+ <Example.Item title="align: center, justify: center">
56
+ <Container align="center" justify="center" height="200px">
57
+ <Placeholder />
58
+ </Container>
59
+ </Example.Item>
60
+ </Example>),
61
+ };
@@ -0,0 +1,15 @@
1
+ import { StoryObj } from "@storybook/react";
2
+ declare const _default: {
3
+ title: string;
4
+ component: (props: import("./..").ContainerProps) => import("react").JSX.Element;
5
+ parameters: {
6
+ iframe: {
7
+ url: string;
8
+ };
9
+ chromatic: {
10
+ disableSnapshot: boolean;
11
+ };
12
+ };
13
+ };
14
+ export default _default;
15
+ export declare const className: StoryObj;
@@ -0,0 +1,26 @@
1
+ import { expect } from "@storybook/test";
2
+ import Container from "../index.js";
3
+ import { Placeholder } from "../../../utilities/storybook/index.js";
4
+ export default {
5
+ title: "Utilities/Container/tests",
6
+ component: Container,
7
+ parameters: {
8
+ iframe: {
9
+ url: "https://reshaped.so/docs/components/action-bar",
10
+ },
11
+ chromatic: { disableSnapshot: true },
12
+ },
13
+ };
14
+ export const className = {
15
+ name: "className, attributes",
16
+ render: () => (<div data-testid="root">
17
+ <Container className="test-classname" attributes={{ id: "test-id" }}>
18
+ <Placeholder />
19
+ </Container>
20
+ </div>),
21
+ play: async ({ canvas }) => {
22
+ const root = canvas.getByTestId("root").firstChild;
23
+ expect(root).toHaveClass("test-classname");
24
+ expect(root).toHaveAttribute("id", "test-id");
25
+ },
26
+ };
@@ -4,29 +4,33 @@ import React from "react";
4
4
  import DropdownMenu from "../DropdownMenu/index.js";
5
5
  import useScrollLock from "../../hooks/useScrollLock.js";
6
6
  import s from "./ContextMenu.module.css";
7
+ import useHandlerRef from "../../hooks/useHandlerRef.js";
7
8
  const ContextMenu = (props) => {
8
- const { position = "end-top", ...dropdownMenuProps } = props;
9
+ const { position = "end-top", onOpen, onClose, ...dropdownMenuProps } = props;
9
10
  const [coordinates, setCoordinates] = React.useState();
10
- const containerRef = React.useRef(null);
11
- const { lockScroll, unlockScroll } = useScrollLock({ containerRef });
11
+ const originRef = React.useRef(null);
12
+ const { lockScroll, unlockScroll } = useScrollLock({ originRef });
13
+ const onOpenRef = useHandlerRef(onOpen);
12
14
  React.useEffect(() => {
13
- const containerEl = containerRef.current;
14
- if (!containerEl)
15
+ const originEl = originRef.current;
16
+ if (!originEl)
15
17
  return;
16
18
  const handleContextMenu = (e) => {
17
19
  e.preventDefault();
18
20
  setCoordinates({ x: e.clientX, y: e.clientY });
19
21
  lockScroll();
22
+ onOpenRef.current?.();
20
23
  };
21
- containerEl.addEventListener("contextmenu", handleContextMenu);
22
- return () => containerEl.removeEventListener("contextmenu", handleContextMenu);
23
- }, [lockScroll]);
24
+ originEl.addEventListener("contextmenu", handleContextMenu);
25
+ return () => originEl.removeEventListener("contextmenu", handleContextMenu);
26
+ }, [lockScroll, onOpenRef]);
24
27
  React.useEffect(() => {
25
28
  return () => unlockScroll();
26
29
  }, [unlockScroll]);
27
- return (_jsx("div", { className: s.root, ref: containerRef, children: _jsx(DropdownMenu, { ...dropdownMenuProps, position: position, originCoordinates: coordinates, active: !!coordinates, onClose: () => {
30
+ return (_jsx("div", { className: s.root, ref: originRef, children: _jsx(DropdownMenu, { ...dropdownMenuProps, position: position, originCoordinates: coordinates, active: !!coordinates, onClose: () => {
28
31
  setCoordinates(undefined);
29
32
  unlockScroll();
33
+ onClose?.();
30
34
  } }) }));
31
35
  };
32
36
  ContextMenu.Content = DropdownMenu.Content;