reshaped 3.9.0-canary.0 → 3.9.0-canary.2

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 (318) hide show
  1. package/dist/bundle.css +1 -1
  2. package/dist/bundle.js +10 -10
  3. package/dist/cli/theming/index.js +4 -4
  4. package/dist/cli/theming/reshaped.config.js +1 -1
  5. package/dist/components/Accordion/Accordion.types.d.ts +1 -1
  6. package/dist/components/Accordion/AccordionControlled.js +2 -2
  7. package/dist/components/Accordion/AccordionTrigger.js +2 -2
  8. package/dist/components/Accordion/index.d.ts +1 -1
  9. package/dist/components/Accordion/index.js +1 -1
  10. package/dist/components/ActionBar/ActionBar.js +1 -1
  11. package/dist/components/ActionBar/ActionBar.types.d.ts +1 -1
  12. package/dist/components/Actionable/Actionable.js +1 -1
  13. package/dist/components/Alert/Alert.js +1 -1
  14. package/dist/components/Alert/Alert.types.d.ts +1 -1
  15. package/dist/components/Autocomplete/Autocomplete.js +4 -4
  16. package/dist/components/Autocomplete/Autocomplete.types.d.ts +2 -2
  17. package/dist/components/Avatar/Avatar.js +2 -2
  18. package/dist/components/Badge/Badge.js +4 -4
  19. package/dist/components/Badge/Badge.types.d.ts +1 -1
  20. package/dist/components/Breadcrumbs/Breadcrumbs.js +3 -3
  21. package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +1 -1
  22. package/dist/components/Breadcrumbs/BreadcrumbsItem.js +1 -1
  23. package/dist/components/Button/Button.js +2 -2
  24. package/dist/components/Button/Button.module.css +1 -1
  25. package/dist/components/Button/Button.types.d.ts +3 -3
  26. package/dist/components/Calendar/Calendar.types.d.ts +7 -1
  27. package/dist/components/Calendar/CalendarControlled.js +4 -4
  28. package/dist/components/Calendar/CalendarControls.js +2 -2
  29. package/dist/components/Calendar/CalendarDate.js +5 -5
  30. package/dist/components/Calendar/CalendarMonth.js +3 -3
  31. package/dist/components/Calendar/CalendarYear.js +1 -1
  32. package/dist/components/Calendar/useCalendarKeyboardNavigation.js +1 -1
  33. package/dist/components/Card/Card.js +2 -2
  34. package/dist/components/Card/Card.module.css +1 -1
  35. package/dist/components/Card/Card.types.d.ts +1 -1
  36. package/dist/components/Carousel/Carousel.js +4 -4
  37. package/dist/components/Carousel/Carousel.types.d.ts +1 -1
  38. package/dist/components/Carousel/CarouselControl.d.ts +1 -1
  39. package/dist/components/Carousel/CarouselControl.js +3 -3
  40. package/dist/components/Checkbox/Checkbox.js +3 -3
  41. package/dist/components/CheckboxGroup/CheckboxGroup.types.d.ts +1 -1
  42. package/dist/components/Container/Container.js +1 -1
  43. package/dist/components/Container/Container.types.d.ts +1 -1
  44. package/dist/components/ContextMenu/ContextMenu.js +1 -1
  45. package/dist/components/Dismissible/Dismissible.js +1 -1
  46. package/dist/components/Divider/Divider.d.ts +1 -1
  47. package/dist/components/Divider/Divider.js +1 -1
  48. package/dist/components/DropdownMenu/DropdownMenu.js +6 -6
  49. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +3 -3
  50. package/dist/components/FileUpload/FileUpload.js +2 -2
  51. package/dist/components/FileUpload/FileUpload.types.d.ts +1 -1
  52. package/dist/components/Flyout/Flyout.constants.d.ts +1 -3
  53. package/dist/components/Flyout/Flyout.constants.js +1 -3
  54. package/dist/components/Flyout/Flyout.js +1 -1
  55. package/dist/components/Flyout/FlyoutContent.js +4 -4
  56. package/dist/components/Flyout/FlyoutControlled.js +11 -13
  57. package/dist/components/Flyout/index.d.ts +1 -1
  58. package/dist/components/Flyout/index.js +1 -1
  59. package/dist/components/Flyout/useFlyout.d.ts +1 -1
  60. package/dist/components/Flyout/useFlyout.js +1 -1
  61. package/dist/components/Flyout/utilities/cooldown.js +1 -2
  62. package/dist/components/Flyout/utilities/flyout.d.ts +1 -1
  63. package/dist/components/Flyout/utilities/flyout.js +1 -1
  64. package/dist/components/FormControl/FormControlCaption.js +1 -1
  65. package/dist/components/FormControl/FormControlLabel.js +1 -1
  66. package/dist/components/FormControl/index.d.ts +2 -2
  67. package/dist/components/FormControl/index.js +2 -2
  68. package/dist/components/Grid/Grid.js +1 -1
  69. package/dist/components/Grid/Grid.types.d.ts +2 -2
  70. package/dist/components/Icon/Icon.js +1 -1
  71. package/dist/components/Icon/Icon.module.css +1 -1
  72. package/dist/components/Image/Image.js +1 -1
  73. package/dist/components/Image/Image.types.d.ts +1 -1
  74. package/dist/components/Link/Link.js +1 -1
  75. package/dist/components/MenuItem/MenuItem.js +1 -1
  76. package/dist/components/MenuItem/MenuItem.types.d.ts +2 -2
  77. package/dist/components/Modal/Modal.js +7 -7
  78. package/dist/components/Modal/Modal.types.d.ts +1 -1
  79. package/dist/components/NumberField/NumberFieldControlled.js +7 -7
  80. package/dist/components/Overlay/Overlay.js +8 -8
  81. package/dist/components/PinField/PinFieldControlled.js +4 -4
  82. package/dist/components/Popover/Popover.js +3 -3
  83. package/dist/components/Popover/Popover.types.d.ts +1 -1
  84. package/dist/components/Progress/Progress.module.css +1 -1
  85. package/dist/components/Radio/Radio.js +3 -3
  86. package/dist/components/RadioGroup/RadioGroup.types.d.ts +1 -1
  87. package/dist/components/Reshaped/Reshaped.css +1 -1
  88. package/dist/components/Reshaped/Reshaped.js +4 -4
  89. package/dist/components/Reshaped/Reshaped.types.d.ts +1 -1
  90. package/dist/components/Resizable/Resizable.js +2 -2
  91. package/dist/components/Resizable/Resizable.types.d.ts +1 -1
  92. package/dist/components/Resizable/ResizableHandle.js +1 -1
  93. package/dist/components/ScrollArea/ScrollArea.js +4 -4
  94. package/dist/components/Select/Select.types.d.ts +3 -3
  95. package/dist/components/Select/SelectCustomControlled.js +6 -3
  96. package/dist/components/Select/SelectEndContent.js +1 -1
  97. package/dist/components/Select/SelectGroup.js +1 -1
  98. package/dist/components/Select/SelectNative.js +2 -2
  99. package/dist/components/Select/SelectRoot.js +1 -1
  100. package/dist/components/Select/SelectTrigger.js +1 -1
  101. package/dist/components/Select/index.d.ts +1 -1
  102. package/dist/components/Select/index.js +1 -1
  103. package/dist/components/Skeleton/Skeleton.js +1 -1
  104. package/dist/components/Slider/SliderControlled.js +7 -7
  105. package/dist/components/Slider/SliderThumb.js +3 -3
  106. package/dist/components/Stepper/Stepper.js +4 -4
  107. package/dist/components/Switch/Switch.js +1 -1
  108. package/dist/components/Table/Table.js +2 -2
  109. package/dist/components/Tabs/Tabs.types.d.ts +1 -1
  110. package/dist/components/Tabs/TabsItem.js +2 -2
  111. package/dist/components/Tabs/TabsList.js +8 -8
  112. package/dist/components/Tabs/TabsPanel.js +2 -2
  113. package/dist/components/Text/Text.js +1 -1
  114. package/dist/components/Text/Text.module.css +1 -1
  115. package/dist/components/TextArea/TextArea.js +1 -1
  116. package/dist/components/TextArea/TextArea.types.d.ts +1 -1
  117. package/dist/components/TextField/TextField.js +2 -2
  118. package/dist/components/TextField/TextField.types.d.ts +2 -2
  119. package/dist/components/Theme/GlobalColorMode.js +1 -1
  120. package/dist/components/Theme/Theme.js +2 -2
  121. package/dist/components/Theme/Theme.module.css +1 -1
  122. package/dist/components/Timeline/Timeline.js +1 -1
  123. package/dist/components/Toast/Toast.js +2 -2
  124. package/dist/components/Toast/Toast.types.d.ts +1 -1
  125. package/dist/components/Toast/ToastContainer.js +3 -3
  126. package/dist/components/Toast/ToastProvider.js +1 -1
  127. package/dist/components/Toast/ToastRegion.js +2 -2
  128. package/dist/components/ToggleButtonGroup/ToggleButtonGroup.types.d.ts +1 -1
  129. package/dist/components/ToggleButtonGroup/ToggleButtonGroupControlled.js +1 -1
  130. package/dist/components/Tooltip/Tooltip.js +5 -3
  131. package/dist/components/View/View.js +2 -2
  132. package/dist/components/View/View.types.d.ts +1 -1
  133. package/dist/components/_private/Expandable/Expandable.js +2 -2
  134. package/dist/components/_private/Portal/Portal.js +1 -1
  135. package/dist/config/tailwind.js +2 -2
  136. package/dist/hooks/_private/useDrag.js +4 -4
  137. package/dist/hooks/_private/useFadeSide.js +1 -1
  138. package/dist/hooks/useOnClickOutside.js +2 -4
  139. package/dist/hooks/useResponsiveClientValue.js +1 -1
  140. package/dist/styles/mixin.js +1 -1
  141. package/dist/tests/ThemesPlayground.js +16 -16
  142. package/dist/themes/_generator/definitions/slate.js +1 -1
  143. package/dist/themes/_generator/tokens/color/utilities/generateColors.d.ts +1 -1
  144. package/dist/themes/_generator/tokens/color/utilities/generateMetaColors.d.ts +1 -1
  145. package/dist/themes/_generator/tokens/color/utilities/generateMetaColors.js +1 -1
  146. package/dist/themes/_generator/tokens/css.js +2 -2
  147. package/dist/themes/_generator/tokens/font/font.types.d.ts +2 -2
  148. package/dist/themes/_generator/tokens/transforms.js +1 -1
  149. package/dist/themes/_generator/tokens/types.d.ts +3 -3
  150. package/dist/themes/_generator/transform.d.ts +1 -1
  151. package/dist/themes/_generator/transform.js +3 -3
  152. package/dist/themes/figma/theme.css +1 -1
  153. package/dist/themes/fragments/twitter/theme.css +1 -1
  154. package/dist/themes/index.d.ts +1 -1
  155. package/dist/themes/reshaped/theme.css +1 -1
  156. package/dist/themes/slate/theme.css +1 -1
  157. package/dist/types/config.d.ts +1 -1
  158. package/dist/utilities/a11y/TrapFocus.js +4 -4
  159. package/dist/utilities/scroll/lock.js +1 -1
  160. package/dist/utilities/scroll/lockStandard.js +1 -1
  161. package/dist/utilities/storybook/Example.js +1 -1
  162. package/package.json +42 -35
  163. package/dist/components/Accordion/tests/Accordion.stories.d.ts +0 -44
  164. package/dist/components/Accordion/tests/Accordion.stories.js +0 -204
  165. package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +0 -40
  166. package/dist/components/ActionBar/tests/ActionBar.stories.js +0 -223
  167. package/dist/components/Actionable/tests/Actionable.stories.d.ts +0 -41
  168. package/dist/components/Actionable/tests/Actionable.stories.js +0 -220
  169. package/dist/components/Alert/tests/Alert.stories.d.ts +0 -24
  170. package/dist/components/Alert/tests/Alert.stories.js +0 -78
  171. package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +0 -32
  172. package/dist/components/Autocomplete/tests/Autocomplete.stories.js +0 -246
  173. package/dist/components/Avatar/tests/Avatar.stories.d.ts +0 -31
  174. package/dist/components/Avatar/tests/Avatar.stories.js +0 -176
  175. package/dist/components/Badge/tests/Badge.stories.d.ts +0 -55
  176. package/dist/components/Badge/tests/Badge.stories.js +0 -328
  177. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +0 -40
  178. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +0 -187
  179. package/dist/components/Button/tests/Button.stories.d.ts +0 -79
  180. package/dist/components/Button/tests/Button.stories.js +0 -789
  181. package/dist/components/Calendar/tests/Calendar.stories.d.ts +0 -29
  182. package/dist/components/Calendar/tests/Calendar.stories.js +0 -255
  183. package/dist/components/Card/tests/Card.stories.d.ts +0 -52
  184. package/dist/components/Card/tests/Card.stories.js +0 -125
  185. package/dist/components/Carousel/tests/Carousel.stories.d.ts +0 -34
  186. package/dist/components/Carousel/tests/Carousel.stories.js +0 -224
  187. package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +0 -30
  188. package/dist/components/Checkbox/tests/Checkbox.stories.js +0 -171
  189. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +0 -19
  190. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +0 -83
  191. package/dist/components/Container/tests/Container.stories.d.ts +0 -24
  192. package/dist/components/Container/tests/Container.stories.js +0 -75
  193. package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +0 -26
  194. package/dist/components/ContextMenu/tests/ContextMenu.stories.js +0 -70
  195. package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +0 -25
  196. package/dist/components/Dismissible/tests/Dismissible.stories.js +0 -97
  197. package/dist/components/Divider/tests/Divider.stories.d.ts +0 -20
  198. package/dist/components/Divider/tests/Divider.stories.js +0 -120
  199. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +0 -53
  200. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +0 -278
  201. package/dist/components/FileUpload/tests/FileUpload.stories.d.ts +0 -31
  202. package/dist/components/FileUpload/tests/FileUpload.stories.js +0 -140
  203. package/dist/components/Flyout/tests/Flyout.stories.d.ts +0 -103
  204. package/dist/components/Flyout/tests/Flyout.stories.js +0 -738
  205. package/dist/components/FormControl/tests/FormControl.stories.d.ts +0 -31
  206. package/dist/components/FormControl/tests/FormControl.stories.js +0 -143
  207. package/dist/components/Grid/tests/Grid.stories.d.ts +0 -38
  208. package/dist/components/Grid/tests/Grid.stories.js +0 -245
  209. package/dist/components/Hidden/tests/Hidden.stories.d.ts +0 -16
  210. package/dist/components/Hidden/tests/Hidden.stories.js +0 -48
  211. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +0 -16
  212. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +0 -28
  213. package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +0 -13
  214. package/dist/components/Hotkey/tests/Hotkey.stories.js +0 -53
  215. package/dist/components/Icon/tests/Icon.stories.d.ts +0 -25
  216. package/dist/components/Icon/tests/Icon.stories.js +0 -113
  217. package/dist/components/Image/tests/Image.stories.d.ts +0 -41
  218. package/dist/components/Image/tests/Image.stories.js +0 -196
  219. package/dist/components/Link/tests/Link.stories.d.ts +0 -42
  220. package/dist/components/Link/tests/Link.stories.js +0 -155
  221. package/dist/components/Loader/tests/Loader.stories.d.ts +0 -21
  222. package/dist/components/Loader/tests/Loader.stories.js +0 -68
  223. package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +0 -59
  224. package/dist/components/MenuItem/tests/MenuItem.stories.js +0 -236
  225. package/dist/components/Modal/tests/Modal.stories.d.ts +0 -64
  226. package/dist/components/Modal/tests/Modal.stories.js +0 -410
  227. package/dist/components/NumberField/tests/NumberField.stories.d.ts +0 -28
  228. package/dist/components/NumberField/tests/NumberField.stories.js +0 -258
  229. package/dist/components/Overlay/tests/Overlay.stories.d.ts +0 -28
  230. package/dist/components/Overlay/tests/Overlay.stories.js +0 -202
  231. package/dist/components/Pagination/tests/Pagination.stories.d.ts +0 -24
  232. package/dist/components/Pagination/tests/Pagination.stories.js +0 -105
  233. package/dist/components/PinField/tests/PinField.stories.d.ts +0 -34
  234. package/dist/components/PinField/tests/PinField.stories.js +0 -209
  235. package/dist/components/Popover/tests/Popover.stories.d.ts +0 -69
  236. package/dist/components/Popover/tests/Popover.stories.js +0 -340
  237. package/dist/components/Progress/tests/Progress.stories.d.ts +0 -30
  238. package/dist/components/Progress/tests/Progress.stories.js +0 -102
  239. package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.d.ts +0 -19
  240. package/dist/components/ProgressIndicator/tests/ProgressIndicator.stories.js +0 -92
  241. package/dist/components/Radio/tests/Radio.stories.d.ts +0 -35
  242. package/dist/components/Radio/tests/Radio.stories.js +0 -162
  243. package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +0 -19
  244. package/dist/components/RadioGroup/tests/RadioGroup.stories.js +0 -77
  245. package/dist/components/Reshaped/tests/Reshaped.stories.d.ts +0 -34
  246. package/dist/components/Reshaped/tests/Reshaped.stories.js +0 -108
  247. package/dist/components/Resizable/tests/Resizable.stories.d.ts +0 -38
  248. package/dist/components/Resizable/tests/Resizable.stories.js +0 -185
  249. package/dist/components/Scrim/tests/Scrim.stories.d.ts +0 -20
  250. package/dist/components/Scrim/tests/Scrim.stories.js +0 -67
  251. package/dist/components/ScrollArea/tests/ScrollArea.stories.d.ts +0 -37
  252. package/dist/components/ScrollArea/tests/ScrollArea.stories.js +0 -244
  253. package/dist/components/Select/tests/Select.stories.d.ts +0 -53
  254. package/dist/components/Select/tests/Select.stories.js +0 -616
  255. package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +0 -20
  256. package/dist/components/Skeleton/tests/Skeleton.stories.js +0 -63
  257. package/dist/components/Slider/tests/Slider.stories.d.ts +0 -47
  258. package/dist/components/Slider/tests/Slider.stories.js +0 -279
  259. package/dist/components/Stepper/tests/Stepper.stories.d.ts +0 -31
  260. package/dist/components/Stepper/tests/Stepper.stories.js +0 -135
  261. package/dist/components/Switch/tests/Switch.stories.d.ts +0 -22
  262. package/dist/components/Switch/tests/Switch.stories.js +0 -137
  263. package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -13
  264. package/dist/components/Switch/tests/Switch.test.stories.js +0 -11
  265. package/dist/components/Table/tests/Table.stories.d.ts +0 -42
  266. package/dist/components/Table/tests/Table.stories.js +0 -348
  267. package/dist/components/Tabs/tests/Tabs.stories.d.ts +0 -62
  268. package/dist/components/Tabs/tests/Tabs.stories.js +0 -539
  269. package/dist/components/Text/tests/Text.stories.d.ts +0 -48
  270. package/dist/components/Text/tests/Text.stories.js +0 -201
  271. package/dist/components/TextArea/tests/TextArea.stories.d.ts +0 -53
  272. package/dist/components/TextArea/tests/TextArea.stories.js +0 -204
  273. package/dist/components/TextField/tests/TextField.stories.d.ts +0 -54
  274. package/dist/components/TextField/tests/TextField.stories.js +0 -252
  275. package/dist/components/Theme/tests/Theme.stories.d.ts +0 -25
  276. package/dist/components/Theme/tests/Theme.stories.js +0 -171
  277. package/dist/components/Timeline/tests/Timeline.stories.d.ts +0 -22
  278. package/dist/components/Timeline/tests/Timeline.stories.js +0 -86
  279. package/dist/components/Toast/tests/Toast.stories.d.ts +0 -41
  280. package/dist/components/Toast/tests/Toast.stories.js +0 -432
  281. package/dist/components/ToggleButton/tests/ToggleButton.stories.d.ts +0 -27
  282. package/dist/components/ToggleButton/tests/ToggleButton.stories.js +0 -97
  283. package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.d.ts +0 -27
  284. package/dist/components/ToggleButtonGroup/tests/ToggleButtonGroup.stories.js +0 -169
  285. package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +0 -28
  286. package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -182
  287. package/dist/components/View/tests/View.stories.d.ts +0 -141
  288. package/dist/components/View/tests/View.stories.js +0 -1329
  289. package/dist/components/_private/Portal/tests/Portal.stories.d.ts +0 -6
  290. package/dist/components/_private/Portal/tests/Portal.stories.js +0 -17
  291. package/dist/hooks/tests/useDrag.stories.d.ts +0 -31
  292. package/dist/hooks/tests/useDrag.stories.js +0 -147
  293. package/dist/hooks/tests/useElementId.stories.d.ts +0 -11
  294. package/dist/hooks/tests/useElementId.stories.js +0 -23
  295. package/dist/hooks/tests/useHandlerRef.stories.d.ts +0 -14
  296. package/dist/hooks/tests/useHandlerRef.stories.js +0 -44
  297. package/dist/hooks/tests/useHotkeys.stories.d.ts +0 -43
  298. package/dist/hooks/tests/useHotkeys.stories.js +0 -158
  299. package/dist/hooks/tests/useKeyboardArrowNavigation.stories.d.ts +0 -15
  300. package/dist/hooks/tests/useKeyboardArrowNavigation.stories.js +0 -128
  301. package/dist/hooks/tests/useKeyboardMode.stories.d.ts +0 -11
  302. package/dist/hooks/tests/useKeyboardMode.stories.js +0 -42
  303. package/dist/hooks/tests/useOnClickOutside.stories.d.ts +0 -23
  304. package/dist/hooks/tests/useOnClickOutside.stories.js +0 -111
  305. package/dist/hooks/tests/useRTL.stories.d.ts +0 -11
  306. package/dist/hooks/tests/useRTL.stories.js +0 -23
  307. package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +0 -18
  308. package/dist/hooks/tests/useResponsiveClientValue.stories.js +0 -30
  309. package/dist/hooks/tests/useScrollLock.stories.d.ts +0 -14
  310. package/dist/hooks/tests/useScrollLock.stories.js +0 -97
  311. package/dist/hooks/tests/useToggle.stories.d.ts +0 -13
  312. package/dist/hooks/tests/useToggle.stories.js +0 -59
  313. package/dist/tests/ShadowDOM.stories.d.ts +0 -6
  314. package/dist/tests/ShadowDOM.stories.js +0 -110
  315. package/dist/tests/themes.stories.d.ts +0 -16
  316. package/dist/tests/themes.stories.js +0 -327
  317. package/dist/utilities/a11y/tests/TrapFocus.stories.d.ts +0 -14
  318. package/dist/utilities/a11y/tests/TrapFocus.stories.js +0 -615
@@ -1,738 +0,0 @@
1
- import React from "react";
2
- import { createRoot } from "react-dom/client";
3
- import { userEvent, waitFor, within, expect, fn } from "storybook/test";
4
- import { Example } from "../../../utilities/storybook/index.js";
5
- import Reshaped from "../../Reshaped/index.js";
6
- import View from "../../View/index.js";
7
- import Theme from "../../Theme/index.js";
8
- import Button from "../../Button/index.js";
9
- import Flyout from "../index.js";
10
- import TextField from "../../TextField/index.js";
11
- import Select from "../../Select/index.js";
12
- import Switch from "../../Switch/index.js";
13
- import { sleep } from "../../../utilities/helpers.js";
14
- import Modal from "../../Modal/index.js";
15
- export default { title: "Utility components/Flyout" };
16
- const Content = (props) => (<div style={{
17
- background: "var(--rs-color-background-elevation-overlay)",
18
- padding: "var(--rs-unit-x4)",
19
- height: props.height === false ? undefined : props.height || 150,
20
- width: props.width === false ? undefined : props.width || 160,
21
- borderRadius: "var(--rs-radius-medium)",
22
- border: "1px solid var(--rs-color-border-neutral-faded)",
23
- boxSizing: "border-box",
24
- }}>
25
- {props.children || "Content"}
26
- </div>);
27
- const Demo = (props) => {
28
- const { position = "bottom-start", children, text, contentHeight, contentWidth, ...rest } = props;
29
- return (<Flyout position={position} {...rest}>
30
- <Flyout.Trigger>
31
- {(attributes) => <Button attributes={attributes}>{text || position}</Button>}
32
- </Flyout.Trigger>
33
- <Flyout.Content attributes={{
34
- style: {
35
- background: "var(--rs-color-background-elevation-overlay)",
36
- padding: "var(--rs-unit-x4)",
37
- height: contentHeight === false ? undefined : contentHeight || 150,
38
- width: contentWidth === false ? undefined : contentWidth || 160,
39
- borderRadius: "var(--rs-radius-medium)",
40
- border: "1px solid var(--rs-color-border-neutral-faded)",
41
- boxSizing: "border-box",
42
- },
43
- }}>
44
- {children || "Content"}
45
- </Flyout.Content>
46
- </Flyout>);
47
- };
48
- export const position = {
49
- name: "position",
50
- render: () => {
51
- return (<View gap={4} padding={50} align="center" justify="center" height="100vh" width="120%">
52
- <View gap={4} direction="row">
53
- <Demo position="top-start" defaultActive/>
54
- <Demo position="top"/>
55
- <Demo position="top-end"/>
56
- </View>
57
-
58
- <View gap={4} direction="row">
59
- <Demo position="end-top"/>
60
- <Demo position="end"/>
61
- <Demo position="end-bottom"/>
62
- </View>
63
-
64
- <View gap={4} direction="row">
65
- <Demo position="start-top"/>
66
- <Demo position="start"/>
67
- <Demo position="start-bottom"/>
68
- </View>
69
-
70
- <View gap={4} direction="row">
71
- <Demo position="bottom-start"/>
72
- <Demo position="bottom"/>
73
- <Demo position="bottom-end"/>
74
- </View>
75
- </View>);
76
- },
77
- };
78
- export const defaultActive = {
79
- name: "defaultActive, uncontrolled",
80
- args: {
81
- handleOpen: fn(),
82
- handleClose: fn(),
83
- },
84
- render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} defaultActive>
85
- <Flyout.Trigger>
86
- {(attributes) => <Button attributes={attributes}>Trigger</Button>}
87
- </Flyout.Trigger>
88
- <Flyout.Content>
89
- <Content />
90
- </Flyout.Content>
91
- </Flyout>),
92
- play: async ({ canvasElement, args }) => {
93
- const canvas = within(canvasElement.ownerDocument.body);
94
- const trigger = canvas.getAllByRole("button")[0];
95
- let item = canvas.getByText("Content");
96
- await sleep(500);
97
- await userEvent.click(document.body);
98
- await waitFor(() => {
99
- expect(args.handleClose).toHaveBeenCalledTimes(1);
100
- expect(args.handleClose).toHaveBeenCalledWith({ reason: "outside-click" });
101
- expect(item).not.toBeInTheDocument();
102
- });
103
- await userEvent.click(trigger);
104
- await waitFor(() => {
105
- expect(args.handleOpen).toHaveBeenCalledTimes(1);
106
- expect(args.handleOpen).toHaveBeenCalledWith();
107
- });
108
- item = canvas.getByText("Content");
109
- expect(item).toBeInTheDocument();
110
- },
111
- };
112
- export const active = {
113
- name: "active, controlled",
114
- args: {
115
- handleOpen: fn(),
116
- handleClose: fn(),
117
- },
118
- render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} active>
119
- <Flyout.Trigger>
120
- {(attributes) => <Button attributes={attributes}>Trigger</Button>}
121
- </Flyout.Trigger>
122
- <Flyout.Content>
123
- <Content />
124
- </Flyout.Content>
125
- </Flyout>),
126
- play: async ({ canvasElement, args }) => {
127
- const canvas = within(canvasElement.ownerDocument.body);
128
- const item = canvas.getByText("Content");
129
- await userEvent.click(document.body);
130
- await waitFor(() => {
131
- expect(args.handleClose).toHaveBeenCalledTimes(1);
132
- expect(args.handleClose).toHaveBeenCalledWith({ reason: "outside-click" });
133
- });
134
- expect(item).toBeInTheDocument();
135
- },
136
- };
137
- export const activeFalse = {
138
- name: "active: false, controlled",
139
- args: {
140
- handleOpen: fn(),
141
- handleClose: fn(),
142
- },
143
- render: (args) => (<Flyout onOpen={args.handleOpen} onClose={args.handleClose} active={false}>
144
- <Flyout.Trigger>
145
- {(attributes) => <Button attributes={attributes}>Trigger</Button>}
146
- </Flyout.Trigger>
147
- <Flyout.Content>
148
- <Content />
149
- </Flyout.Content>
150
- </Flyout>),
151
- play: async ({ canvasElement, args }) => {
152
- const canvas = within(canvasElement.ownerDocument.body);
153
- const trigger = canvas.getAllByRole("button")[0];
154
- await userEvent.click(trigger);
155
- await waitFor(() => {
156
- expect(args.handleOpen).toHaveBeenCalledTimes(1);
157
- expect(args.handleOpen).toHaveBeenCalledWith();
158
- });
159
- const item = canvas.queryByText("Content");
160
- expect(item).not.toBeInTheDocument();
161
- },
162
- };
163
- const modeContent = (<View direction="row" gap={2}>
164
- <Button onClick={() => { }}>Action 1</Button>
165
- <Button onClick={() => { }}>Action 2</Button>
166
- <Button onClick={() => { }}>Action 3</Button>
167
- </View>);
168
- export const modes = {
169
- name: "triggerType, trapFocusMode",
170
- render: () => {
171
- return (<Example>
172
- <Example.Item title="triggerType: click">
173
- <View direction="row" gap={4}>
174
- <Demo position="bottom-start" trapFocusMode="dialog" text="dialog">
175
- {modeContent}
176
- </Demo>
177
- <Demo position="bottom-start" trapFocusMode="action-menu" text="action-menu">
178
- {modeContent}
179
- </Demo>
180
- <Demo position="bottom-start" trapFocusMode="action-bar" text="action-bar">
181
- {modeContent}
182
- </Demo>
183
- <Demo position="bottom-start" trapFocusMode="content-menu" text="content-menu">
184
- {modeContent}
185
- </Demo>
186
- <Demo position="bottom-start" trapFocusMode={false} text="false">
187
- {modeContent}
188
- </Demo>
189
- </View>
190
- </Example.Item>
191
-
192
- <Example.Item title="triggerType: hover">
193
- <View direction="row" gap={4}>
194
- <Demo position="bottom-start" trapFocusMode="dialog" triggerType="hover" text="dialog">
195
- {modeContent}
196
- </Demo>
197
- <Demo position="bottom-start" trapFocusMode="action-menu" triggerType="hover" text="action-menu">
198
- {modeContent}
199
- </Demo>
200
- <Demo position="bottom-start" trapFocusMode="action-bar" triggerType="hover" text="action-bar">
201
- {modeContent}
202
- </Demo>
203
- <Demo position="bottom-start" trapFocusMode="content-menu" triggerType="hover" text="content-menu">
204
- {modeContent}
205
- </Demo>
206
- </View>
207
- </Example.Item>
208
- </Example>);
209
- },
210
- };
211
- export const positionFallbacks = {
212
- name: "fallbackPositions",
213
- render: () => {
214
- return (<Example>
215
- <Example.Item title="position: top, default fallbacks">
216
- <View justify="center" align="center">
217
- <Demo position="top"/>
218
- </View>
219
- </Example.Item>
220
- <Example.Item title="position: top, fallbackPositions: [start]">
221
- <View justify="center" align="center">
222
- <Demo position="top" fallbackPositions={["start"]} contentHeight={200} defaultActive/>
223
- </View>
224
- </Example.Item>
225
- <Example.Item title="position: top, fallbackPositions: false">
226
- <View justify="center" align="center">
227
- <Demo position="top" fallbackPositions={false} contentHeight={400}/>
228
- </View>
229
- </Example.Item>
230
- </Example>);
231
- },
232
- };
233
- const FallbackAdjustLayoutControls = ({ containerRef, large, }) => {
234
- const contentHeight = large ? "2000px" : "200px";
235
- const contentWidth = large ? "2000px" : "300px";
236
- return (<>
237
- {/* Left side */}
238
- <View position="absolute" insetStart={4} insetTop={10} gap={2}>
239
- <Demo contentHeight={contentHeight} position="end" fallbackAdjustLayout fallbackPositions={false} containerRef={containerRef}/>
240
- <Demo contentHeight={contentHeight} position="end-bottom" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
241
- </View>
242
-
243
- <View position="absolute" insetStart={4} insetTop={80} gap={2}>
244
- <Demo position="top" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
245
- <Demo position="top-end" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
246
- <Demo position="bottom-end" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
247
- <Demo position="bottom" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
248
- </View>
249
-
250
- <View position="absolute" insetBottom={4} insetStart={4} gap={2}>
251
- <Demo contentHeight={contentHeight} position="end-top" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
252
- <Demo contentHeight={contentHeight} position="end" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
253
- </View>
254
-
255
- {/* Right side */}
256
-
257
- <View position="absolute" insetTop={10} insetEnd={4} gap={2}>
258
- <Demo contentHeight={contentHeight} position="start" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
259
- <Demo contentHeight={contentHeight} position="start-bottom" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
260
- </View>
261
-
262
- <View position="absolute" insetEnd={4} insetTop={80} gap={2}>
263
- <Demo position="top-start" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
264
- <Demo position="top" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
265
- <Demo position="bottom-start" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
266
- <Demo position="bottom" fallbackPositions={false} fallbackAdjustLayout contentWidth={contentWidth} containerRef={containerRef}/>
267
- </View>
268
-
269
- <View position="absolute" insetBottom={4} insetEnd={4} gap={2}>
270
- <Demo contentHeight={contentHeight} position="start-top" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
271
- <Demo contentHeight={contentHeight} position="start" fallbackPositions={false} fallbackAdjustLayout containerRef={containerRef}/>
272
- </View>
273
- </>);
274
- };
275
- export const fallbackAdjustLayout = {
276
- name: "fallbackAdjustLayout",
277
- render: () => {
278
- return (<Demo contentHeight={false} position="bottom-start" width="200px" fallbackAdjustLayout defaultActive>
279
- <div style={{ height: "600px" }}>Content</div>
280
- </Demo>);
281
- },
282
- };
283
- export const fallbackAdjustLayoutShift = {
284
- name: "fallbackAdjustLayout, shift",
285
- render: () => {
286
- const containerRef = React.useRef(null);
287
- return (<View gap={10}>
288
- <View height="95vh" width="100%" align="center" justify="center">
289
- <View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" padding={4} paddingBlock={15} overflow="auto">
290
- <FallbackAdjustLayoutControls />
291
- <View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
292
- </View>
293
- </View>
294
-
295
- <View height="95vh" width="100%" align="center" justify="center">
296
- <View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" attributes={{ ref: containerRef }} padding={4} paddingBlock={15} overflow="auto">
297
- <FallbackAdjustLayoutControls containerRef={containerRef}/>
298
- <View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
299
- </View>
300
- </View>
301
-
302
- <FallbackAdjustLayoutControls />
303
- <div style={{ height: "100vh", width: "250%" }}/>
304
- </View>);
305
- },
306
- };
307
- export const fallbackAdjustLayoutSize = {
308
- name: "fallbackAdjustLayout, size",
309
- render: () => {
310
- const containerRef = React.useRef(null);
311
- return (<View gap={10}>
312
- <View height="95vh" width="100%" align="center" justify="center">
313
- <View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" padding={4} paddingBlock={15} overflow="auto">
314
- <FallbackAdjustLayoutControls large/>
315
- <View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
316
- </View>
317
- </View>
318
-
319
- <View height="95vh" width="100%" align="center" justify="center">
320
- <View backgroundColor="neutral-faded" borderRadius="medium" height="1000px" width="600px" attributes={{ ref: containerRef }} padding={4} paddingBlock={15} overflow="auto">
321
- <FallbackAdjustLayoutControls containerRef={containerRef} large/>
322
- <View height="150%" width="150%" attributes={{ style: { pointerEvents: "none" } }}/>
323
- </View>
324
- </View>
325
-
326
- <FallbackAdjustLayoutControls large/>
327
- <div style={{ height: "100vh", width: "250%" }}/>
328
- </View>);
329
- },
330
- };
331
- export const originCoordinates = {
332
- name: "originCoordinates",
333
- render: () => {
334
- return (<View gap={4} direction="row">
335
- <Demo position="bottom-start" originCoordinates={{ x: 150, y: 150 }} defaultActive/>
336
- </View>);
337
- },
338
- };
339
- export const width = {
340
- name: "width",
341
- render: () => (<Example>
342
- <Example.Item title="width: 300px">
343
- <Demo width="300px" position="bottom"/>
344
- </Example.Item>
345
-
346
- <Example.Item title="width: trigger">
347
- <Demo width="trigger" contentWidth={false} defaultActive/>
348
- </Example.Item>
349
- </Example>),
350
- };
351
- export const contentGap = {
352
- name: "contentGap",
353
- render: () => <Demo contentGap={10} defaultActive/>,
354
- };
355
- export const contentShift = {
356
- name: "contentShift",
357
- render: () => <Demo contentShift={10} defaultActive/>,
358
- };
359
- export const disableContentHover = {
360
- name: "disableContentHover",
361
- render: () => <Demo triggerType="hover" disableContentHover/>,
362
- // Can't trigger real mouse move from trigger to content in play function, so testing it manually
363
- };
364
- export const disableCloseOnOutsideClick = {
365
- name: "disableCloseOnOutsideClick",
366
- render: () => <Demo disableCloseOnOutsideClick/>,
367
- play: async ({ canvasElement }) => {
368
- const canvas = within(canvasElement.ownerDocument.body);
369
- const trigger = canvas.getAllByRole("button")[0];
370
- await userEvent.click(trigger);
371
- await waitFor(() => {
372
- const content = canvas.getByText("Content");
373
- expect(content).toBeVisible();
374
- });
375
- await userEvent.click(document.body);
376
- await sleep(500);
377
- const content = canvas.getByText("Content");
378
- expect(content).toBeVisible();
379
- },
380
- };
381
- export const disableHideAnimation = {
382
- name: "disableHideAnimation",
383
- render: () => <Demo disableHideAnimation defaultActive/>,
384
- };
385
- export const disabled = {
386
- name: "disabled",
387
- args: {
388
- handleOpen: fn(),
389
- },
390
- render: () => (<Flyout disabled>
391
- <Flyout.Trigger>
392
- {(attributes) => <Button attributes={attributes}>Trigger</Button>}
393
- </Flyout.Trigger>
394
- <Flyout.Content>
395
- <Content />
396
- </Flyout.Content>
397
- </Flyout>),
398
- play: async ({ canvasElement, args }) => {
399
- const canvas = within(canvasElement.ownerDocument.body);
400
- const button = canvas.getAllByRole("button")[0];
401
- await userEvent.click(button);
402
- expect(args.handleOpen).toHaveBeenCalledTimes(0);
403
- },
404
- };
405
- export const containerRef = {
406
- name: "containerRef",
407
- render: () => {
408
- const portalRef = React.useRef(null);
409
- const portalRef2 = React.useRef(null);
410
- const portalRef3 = React.useRef(null);
411
- return (<View gap={4} direction="row">
412
- <View grow backgroundColor="neutral-faded" borderRadius="small" height={80} attributes={{ ref: portalRef, "data-testid": "container" }} justify="end" align="start" padding={4}>
413
- <Demo containerRef={portalRef} position="bottom-start" defaultActive/>
414
- </View>
415
- <View grow backgroundColor="neutral-faded" borderRadius="small" height={80} attributes={{ ref: portalRef2 }} justify="start" align="end" padding={4}>
416
- <Demo containerRef={portalRef2} position="top-end"/>
417
- </View>
418
- <View width={50} backgroundColor="neutral-faded" borderRadius="small" height={80} attributes={{ ref: portalRef3 }} padding={4} overflow="auto">
419
- <View height={120} width="120%" justify="center" align="center">
420
- <Demo containerRef={portalRef3} position="bottom-end"/>
421
- </View>
422
- </View>
423
- </View>);
424
- },
425
- play: async ({ canvasElement }) => {
426
- const canvas = within(canvasElement.ownerDocument.body);
427
- const containerEl = canvas.getByTestId("container");
428
- const contentEl = canvas.getAllByText("Content")[0];
429
- expect(containerEl).toContainElement(contentEl);
430
- },
431
- };
432
- export const positionRef = {
433
- name: "positionRef",
434
- render: () => {
435
- const ref = React.useRef(null);
436
- return (<View gap={10}>
437
- <View.Item>
438
- <Flyout position="bottom" positionRef={ref} width="trigger" active>
439
- <Flyout.Trigger>
440
- {(attributes) => <Button attributes={attributes}>Trigger</Button>}
441
- </Flyout.Trigger>
442
- <Flyout.Content attributes={{
443
- style: {
444
- background: "var(--rs-color-background-elevation-overlay)",
445
- padding: "var(--rs-unit-x4)",
446
- borderRadius: "var(--rs-radius-medium)",
447
- border: "1px solid var(--rs-color-border-neutral-faded)",
448
- boxSizing: "border-box",
449
- },
450
- }}>
451
- Content
452
- </Flyout.Content>
453
- </Flyout>
454
- </View.Item>
455
-
456
- <Button onClick={() => { }} ref={ref}>
457
- Trigger 2
458
- </Button>
459
- </View>);
460
- },
461
- };
462
- export const initialFocusRef = {
463
- name: "initialFocusRef",
464
- render: () => {
465
- const initialFocusRef = React.useRef(null);
466
- return (<Demo initialFocusRef={initialFocusRef}>
467
- <View gap={4}>
468
- <Button onClick={() => { }}>Action 1</Button>
469
- <TextField name="foo" inputAttributes={{ ref: initialFocusRef }}/>
470
- </View>
471
- </Demo>);
472
- },
473
- play: async ({ canvasElement }) => {
474
- const canvas = within(canvasElement.ownerDocument.body);
475
- const trigger = canvas.getAllByRole("button")[0];
476
- await userEvent.click(trigger);
477
- await waitFor(() => {
478
- const input = canvas.getByRole("textbox");
479
- expect(input).toBe(document.activeElement);
480
- });
481
- },
482
- };
483
- export const instanceRef = {
484
- name: "instanceRef",
485
- args: {
486
- handleOpen: fn(),
487
- handleClose: fn(),
488
- },
489
- render: (args) => {
490
- const flyoutRef = React.useRef(null);
491
- return (<View direction="row" gap={4}>
492
- <Demo instanceRef={flyoutRef} disableCloseOnOutsideClick onOpen={args.handleOpen} onClose={args.handleClose}/>
493
-
494
- <Button onClick={() => flyoutRef.current?.open()}>Open</Button>
495
- <Button onClick={() => flyoutRef.current?.close()}>Close</Button>
496
- </View>);
497
- },
498
- play: async ({ canvasElement, args }) => {
499
- const canvas = within(canvasElement.ownerDocument.body);
500
- const openTrigger = canvas.getAllByRole("button")[1];
501
- const closeTrigger = canvas.getAllByRole("button")[2];
502
- await userEvent.click(openTrigger);
503
- await waitFor(() => {
504
- expect(args.handleOpen).toHaveBeenCalledTimes(1);
505
- expect(args.handleOpen).toHaveBeenCalledWith();
506
- });
507
- await sleep(500);
508
- await userEvent.click(closeTrigger);
509
- await waitFor(() => {
510
- expect(args.handleClose).toHaveBeenCalledTimes(1);
511
- expect(args.handleClose).toHaveBeenCalledWith({});
512
- });
513
- },
514
- };
515
- export const contentAttributes = {
516
- name: "content: className, attributes",
517
- render: () => {
518
- return (<Flyout position="bottom" defaultActive>
519
- <Flyout.Trigger>
520
- {(attributes) => <Button attributes={attributes}>Trigger</Button>}
521
- </Flyout.Trigger>
522
- <Flyout.Content attributes={{ "data-testid": "test-id" }} className="test-classname">
523
- <Content />
524
- </Flyout.Content>
525
- </Flyout>);
526
- },
527
- play: async ({ canvasElement }) => {
528
- const canvas = within(canvasElement.ownerDocument.body);
529
- const content = canvas.getByTestId("test-id");
530
- expect(content).toHaveClass("test-classname");
531
- },
532
- };
533
- /*
534
- * Test edge cases
535
- */
536
- class CustomElement extends window.HTMLElement {
537
- constructor() {
538
- super();
539
- this.attachShadow({ mode: "open" });
540
- if (!this.shadowRoot)
541
- return;
542
- const node = (<Reshaped>
543
- <Demo defaultActive>
544
- Content
545
- <div id="test-id"/>
546
- </Demo>
547
- </Reshaped>);
548
- const root = createRoot(this.shadowRoot);
549
- root.render(node);
550
- }
551
- }
552
- if (!window.customElements.get("custom-element-flyout")) {
553
- window.customElements.define("custom-element-flyout", CustomElement);
554
- }
555
- export const testShadowDom = {
556
- name: "test: shadow dom",
557
- // @ts-ignore
558
- render: () => <custom-element-flyout />,
559
- };
560
- export const testInsideFixed = {
561
- name: "test: inside position fixed",
562
- render: () => (<React.Fragment>
563
- <View position="fixed" insetBottom={2} insetStart={2} insetEnd={2} backgroundColor="elevation-overlay" borderColor="neutral-faded" borderRadius="small" padding={4} zIndex={10} attributes={{ "data-testid": "container" }} height={20}>
564
- <Demo defaultActive position="top-start"/>
565
- </View>
566
- <View paddingTop={18} gap={4}>
567
- <View height={200} backgroundColor="neutral-faded" borderRadius="small"/>
568
- <View height={200} backgroundColor="neutral-faded" borderRadius="small"/>
569
- </View>
570
- </React.Fragment>),
571
- play: ({ canvas }) => {
572
- const container = canvas.getByTestId("container");
573
- const content = canvas.getByText("Content");
574
- expect(container).toContainElement(content);
575
- },
576
- };
577
- export const testInsideSticky = {
578
- name: "test: inside position sticky",
579
- render: () => (<React.Fragment>
580
- <View position="sticky" insetTop={4} insetStart={0} insetEnd={0} backgroundColor="elevation-overlay" borderColor="neutral-faded" borderRadius="small" padding={4} zIndex={10} attributes={{ "data-testid": "container" }}>
581
- <Demo defaultActive/>
582
- </View>
583
- <View gap={4} paddingTop={2}>
584
- <View height={200} backgroundColor="neutral-faded" borderRadius="small"/>
585
- <View height={200} backgroundColor="neutral-faded" borderRadius="small"/>
586
- </View>
587
- </React.Fragment>),
588
- play: ({ canvas }) => {
589
- const container = canvas.getByTestId("container");
590
- const content = canvas.getByText("Content");
591
- expect(container).toContainElement(content);
592
- },
593
- };
594
- export const testInsideScrollable = {
595
- name: "test: inside scrollable",
596
- render: () => {
597
- const containerRef = React.useRef(null);
598
- return (<View padding={20}>
599
- <View height={30} overflow="auto" backgroundColor="neutral-faded" borderRadius="small">
600
- <View height={50} attributes={{ ref: containerRef }} padding={20} paddingBottom={30}>
601
- <Demo position="bottom"/>
602
- </View>
603
- </View>
604
- </View>);
605
- },
606
- };
607
- export const testInsideModal = {
608
- name: "test: inside modal",
609
- render: () => {
610
- return (<Modal active position="end">
611
- <View gap={4} align="start">
612
- <Modal.Title>Title</Modal.Title>
613
- <Demo position="bottom-start"/>
614
- <View height={300} width={25} backgroundColor="neutral-faded"/>
615
- <Demo position="start"/>
616
- <View height={300} width={25} backgroundColor="neutral-faded"/>
617
- <Demo position="bottom-start"/>
618
- </View>
619
- </Modal>);
620
- },
621
- };
622
- export const testDynamicBounds = {
623
- name: "test: auto position update",
624
- render: () => {
625
- const [left, setLeft] = React.useState(50);
626
- const [top, setTop] = React.useState(50);
627
- const [size, setSize] = React.useState("medium");
628
- const flyoutRef = React.useRef(null);
629
- React.useEffect(() => {
630
- flyoutRef.current?.updatePosition();
631
- }, [left, top]);
632
- return (<View gap={4}>
633
- <View direction="row" gap={2}>
634
- <Button onClick={() => setLeft((prev) => prev - 10)}>Left</Button>
635
- <Button onClick={() => setLeft((prev) => prev + 10)}>Right</Button>
636
- <Button onClick={() => setTop((prev) => prev - 10)}>Up</Button>
637
- <Button onClick={() => setTop((prev) => prev + 10)}>Down</Button>
638
- <Button onClick={() => {
639
- setLeft(50);
640
- setTop(50);
641
- }}>
642
- Center
643
- </Button>
644
- <Button onClick={() => setSize("large")}>Large button</Button>
645
- <Button onClick={() => setSize("medium")}>Small button</Button>
646
- </View>
647
- <View height={100}>
648
- <Flyout position="bottom" instanceRef={flyoutRef} disableCloseOnOutsideClick defaultActive>
649
- <Flyout.Trigger>
650
- {(attributes) => (<div style={{ position: "absolute", left: `${left}%`, top: `${top}%` }}>
651
- <Button color="primary" attributes={attributes} size={size}>
652
- Open
653
- </Button>
654
- </div>)}
655
- </Flyout.Trigger>
656
- <Flyout.Content>
657
- <Content />
658
- </Flyout.Content>
659
- </Flyout>
660
- </View>
661
- </View>);
662
- },
663
- };
664
- export const testScopedTheming = {
665
- name: "test: content uses scope theme",
666
- render: () => (<View gap={3} align="start">
667
- <Button color="primary">Slate button</Button>
668
- <Theme name="reshaped">
669
- <Flyout triggerType="click" active position="bottom-start">
670
- <Flyout.Trigger>
671
- {(attributes) => (<Button color="primary" attributes={attributes}>
672
- Reshaped button
673
- </Button>)}
674
- </Flyout.Trigger>
675
- <Flyout.Content>
676
- <Content>
677
- <View gap={1}>
678
- <View.Item>Portal content, rendered in body</View.Item>
679
- <Button color="primary">Reshaped button</Button>
680
- </View>
681
- </Content>
682
- </Flyout.Content>
683
- </Flyout>
684
- </Theme>
685
- </View>),
686
- };
687
- export const testWithoutFocusable = {
688
- name: "test: without focusable content",
689
- render: () => <Demo position="bottom-start"/>,
690
- play: async ({ canvasElement }) => {
691
- const canvas = within(canvasElement.ownerDocument.body);
692
- const trigger = canvas.getAllByRole("button")[0];
693
- await userEvent.click(trigger);
694
- await waitFor(() => {
695
- const content = canvas.getByText("Content");
696
- expect(content).toBeVisible();
697
- });
698
- expect(document.activeElement).toBe(trigger);
699
- },
700
- };
701
- export const testChangeSize = {
702
- name: "test: size updates",
703
- render: () => {
704
- const [position, setPosition] = React.useState("bottom-start");
705
- const [updatedHeight, setUpdatedHeight] = React.useState(false);
706
- return (<>
707
- <View direction="row" gap={4} align="center">
708
- <Select name="position" options={[
709
- "bottom-start",
710
- "bottom",
711
- "bottom-end",
712
- "top-start",
713
- "top",
714
- "top-end",
715
- "start-top",
716
- "start",
717
- "start-bottom",
718
- "end-top",
719
- "end",
720
- "end-bottom",
721
- ].map((p) => ({ label: p, value: p }))} onChange={(args) => setPosition(args.value)} value={position}/>
722
- <Switch name="height" onChange={(args) => setUpdatedHeight(args.checked)}>
723
- Change height
724
- </Switch>
725
- </View>
726
- <div style={{
727
- position: "fixed",
728
- top: "50%",
729
- left: "50%",
730
- transform: "translate(-50%, -50%)",
731
- }}>
732
- <Demo position={position} disableCloseOnOutsideClick active contentHeight={false}>
733
- <View backgroundColor="neutral-faded" borderRadius="small" height={updatedHeight ? 50 : 25} attributes={{ style: { transition: "0.2s ease-in-out" } }}/>
734
- </Demo>
735
- </div>
736
- </>);
737
- },
738
- };