reshaped 3.3.11 → 3.3.13

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 (253) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.d.ts +1 -1
  4. package/dist/bundle.js +16 -17
  5. package/dist/cjs/themes/_generator/utilities/generateColors.d.ts +1 -1
  6. package/dist/cjs/themes/_generator/utilities/generateColors.js +3 -2
  7. package/dist/cjs/themes/_generator/utilities/tests/color.test.js +32 -31
  8. package/dist/cjs/themes/slate/theme.css +1 -1
  9. package/dist/components/Accordion/tests/Accordion.stories.d.ts +30 -8
  10. package/dist/components/Accordion/tests/Accordion.stories.js +172 -119
  11. package/dist/components/ActionBar/tests/ActionBar.stories.d.ts +12 -3
  12. package/dist/components/ActionBar/tests/ActionBar.stories.js +51 -36
  13. package/dist/components/ActionBar/tests/ActionBar.test.stories.d.ts +15 -0
  14. package/dist/components/ActionBar/tests/ActionBar.test.stories.js +26 -0
  15. package/dist/components/Actionable/Actionable.js +1 -1
  16. package/dist/components/Actionable/tests/Actionable.stories.d.ts +19 -5
  17. package/dist/components/Actionable/tests/Actionable.stories.js +88 -63
  18. package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +32 -0
  19. package/dist/components/Actionable/tests/Actionable.test.stories.js +130 -0
  20. package/dist/components/Alert/Alert.js +1 -1
  21. package/dist/components/Alert/tests/Alert.stories.d.ts +12 -3
  22. package/dist/components/Alert/tests/Alert.stories.js +51 -86
  23. package/dist/components/Alert/tests/Alert.test.stories.d.ts +15 -0
  24. package/dist/components/Alert/tests/Alert.test.stories.js +26 -0
  25. package/dist/components/Autocomplete/Autocomplete.js +9 -2
  26. package/dist/components/Autocomplete/tests/Autocomplete.stories.d.ts +6 -2
  27. package/dist/components/Autocomplete/tests/Autocomplete.stories.js +94 -111
  28. package/dist/components/Autocomplete/tests/Autocomplete.test.stories.d.ts +23 -0
  29. package/dist/components/Autocomplete/tests/Autocomplete.test.stories.js +86 -0
  30. package/dist/components/Avatar/Avatar.js +1 -1
  31. package/dist/components/Avatar/tests/Avatar.stories.d.ts +14 -4
  32. package/dist/components/Avatar/tests/Avatar.stories.js +94 -80
  33. package/dist/components/Avatar/tests/Avatar.test.stories.d.ts +17 -0
  34. package/dist/components/Avatar/tests/Avatar.test.stories.js +39 -0
  35. package/dist/components/Badge/tests/Badge.stories.d.ts +33 -8
  36. package/dist/components/Badge/tests/Badge.stories.js +238 -212
  37. package/dist/components/Badge/tests/Badge.test.stories.d.ts +20 -0
  38. package/dist/components/Badge/tests/Badge.test.stories.js +44 -0
  39. package/dist/components/Breadcrumbs/Breadcrumbs.js +2 -2
  40. package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +1 -0
  41. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +24 -5
  42. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +114 -95
  43. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +23 -0
  44. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +76 -0
  45. package/dist/components/Button/Button.js +5 -2
  46. package/dist/components/Button/Button.module.css +1 -1
  47. package/dist/components/Button/Button.types.d.ts +1 -0
  48. package/dist/components/Button/tests/Button.stories.d.ts +2 -2
  49. package/dist/components/Button/tests/Button.stories.js +77 -74
  50. package/dist/components/Button/tests/Button.test.stories.d.ts +27 -0
  51. package/dist/components/Button/tests/Button.test.stories.js +112 -0
  52. package/dist/components/Calendar/tests/Calendar.test.stories.d.ts +26 -0
  53. package/dist/components/Calendar/tests/Calendar.test.stories.js +161 -0
  54. package/dist/components/Card/tests/Card.stories.d.ts +0 -1
  55. package/dist/components/Card/tests/Card.stories.js +0 -11
  56. package/dist/components/Card/tests/Card.test.stories.d.ts +35 -0
  57. package/dist/components/Card/tests/Card.test.stories.js +54 -0
  58. package/dist/components/Carousel/Carousel.js +52 -4
  59. package/dist/components/Carousel/Carousel.types.d.ts +4 -0
  60. package/dist/components/Carousel/CarouselControl.js +1 -1
  61. package/dist/components/Carousel/tests/Carousel.stories.d.ts +23 -4
  62. package/dist/components/Carousel/tests/Carousel.stories.js +199 -102
  63. package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +25 -0
  64. package/dist/components/Checkbox/tests/Checkbox.test.stories.js +104 -0
  65. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +22 -0
  66. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +78 -0
  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/index.d.ts +1 -1
  178. package/dist/components/Table/tests/Table.stories.d.ts +5 -5
  179. package/dist/components/Table/tests/Table.test.stories.d.ts +25 -0
  180. package/dist/components/Table/tests/Table.test.stories.js +93 -0
  181. package/dist/components/Tabs/tests/Tabs.stories.js +4 -4
  182. package/dist/components/Tabs/tests/Tabs.test.stories.d.ts +28 -0
  183. package/dist/components/Tabs/tests/Tabs.test.stories.js +128 -0
  184. package/dist/components/Text/tests/Text.stories.d.ts +28 -7
  185. package/dist/components/Text/tests/Text.stories.js +148 -125
  186. package/dist/components/Text/tests/Text.test.stories.d.ts +18 -0
  187. package/dist/components/Text/tests/Text.test.stories.js +49 -0
  188. package/dist/components/TextArea/TextArea.module.css +1 -1
  189. package/dist/components/TextArea/tests/TextArea.stories.js +1 -1
  190. package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +29 -0
  191. package/dist/components/TextArea/tests/TextArea.test.stories.js +99 -0
  192. package/dist/components/TextField/tests/TextField.stories.js +1 -1
  193. package/dist/components/TextField/tests/TextField.test.stories.d.ts +29 -0
  194. package/dist/components/TextField/tests/TextField.test.stories.js +99 -0
  195. package/dist/components/Theme/tests/Theme.test.stories.d.ts +24 -0
  196. package/dist/components/Theme/tests/Theme.test.stories.js +133 -0
  197. package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +18 -0
  198. package/dist/components/Timeline/tests/Timeline.test.stories.js +32 -0
  199. package/dist/components/Toast/tests/Toast.test.stories.d.ts +16 -0
  200. package/dist/components/Toast/tests/Toast.test.stories.js +101 -0
  201. package/dist/components/Tooltip/tests/Tooltip.stories.js +0 -14
  202. package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +19 -0
  203. package/dist/components/Tooltip/tests/Tooltip.test.stories.js +40 -0
  204. package/dist/components/View/View.js +1 -2
  205. package/dist/components/View/tests/View.stories.d.ts +112 -28
  206. package/dist/components/View/tests/View.stories.js +1092 -1012
  207. package/dist/components/View/tests/View.test.stories.d.ts +20 -0
  208. package/dist/components/View/tests/View.test.stories.js +50 -0
  209. package/dist/components/_private/Flyout/FlyoutContent.js +1 -1
  210. package/dist/components/_private/Flyout/tests/Flyout.stories.js +4 -4
  211. package/dist/components/_private/Flyout/tests/Flyout.test.stories.d.ts +28 -0
  212. package/dist/components/_private/Flyout/tests/Flyout.test.stories.js +205 -0
  213. package/dist/components/_private/Portal/tests/Portal.stories.js +1 -1
  214. package/dist/hooks/_private/useSingletonHotkeys.d.ts +3 -3
  215. package/dist/hooks/_private/useSingletonHotkeys.js +1 -1
  216. package/dist/hooks/tests/useDrag.stories.js +1 -0
  217. package/dist/hooks/tests/useDrag.test.stories.d.ts +26 -0
  218. package/dist/hooks/tests/useDrag.test.stories.js +120 -0
  219. package/dist/hooks/tests/useElementId.stories.d.ts +6 -0
  220. package/dist/hooks/tests/useElementId.stories.js +19 -0
  221. package/dist/hooks/tests/useHotkeys.test.stories.d.ts +39 -0
  222. package/dist/hooks/tests/useHotkeys.test.stories.js +119 -0
  223. package/dist/hooks/tests/useRTL.stories.d.ts +6 -0
  224. package/dist/hooks/tests/useRTL.stories.js +25 -0
  225. package/dist/hooks/tests/useResponsiveClientValue.stories.d.ts +9 -1
  226. package/dist/hooks/tests/useResponsiveClientValue.stories.js +22 -9
  227. package/dist/hooks/tests/useScrollLock.stories.d.ts +6 -0
  228. package/dist/hooks/tests/useScrollLock.stories.js +22 -0
  229. package/dist/hooks/tests/useToggle.stories.d.ts +8 -0
  230. package/dist/hooks/tests/useToggle.stories.js +54 -0
  231. package/dist/hooks/useHotkeys.js +0 -2
  232. package/dist/hooks/useScrollLock.d.ts +1 -0
  233. package/dist/hooks/useScrollLock.js +7 -3
  234. package/dist/index.d.ts +1 -1
  235. package/dist/tests/ShadowDOM.stories.js +1 -1
  236. package/dist/themes/_generator/tests/themes.stories.d.ts +3 -0
  237. package/dist/themes/_generator/tests/themes.stories.js +7 -11
  238. package/dist/themes/_generator/utilities/generateColors.d.ts +1 -1
  239. package/dist/themes/_generator/utilities/generateColors.js +3 -2
  240. package/dist/themes/slate/theme.css +1 -1
  241. package/dist/utilities/helpers.d.ts +1 -0
  242. package/dist/utilities/helpers.js +3 -0
  243. package/dist/utilities/scroll/lock.d.ts +1 -0
  244. package/dist/utilities/scroll/lock.js +3 -3
  245. package/dist/utilities/scroll/lockSafari.d.ts +1 -1
  246. package/dist/utilities/scroll/lockSafari.js +4 -5
  247. package/dist/utilities/scroll/lockStandard.d.ts +4 -1
  248. package/dist/utilities/scroll/lockStandard.js +7 -2
  249. package/dist/utilities/storybook/Example.js +1 -2
  250. package/package.json +42 -41
  251. package/dist/components/Theme/tests/Theme.stories.d.ts +0 -13
  252. package/dist/components/Theme/tests/Theme.stories.js +0 -80
  253. 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
+ };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import React from "react";
4
- import { classNames, responsiveVariables, responsiveClassNames, debounceHandler, } from "../../utilities/helpers.js";
4
+ import { classNames, responsiveVariables, responsiveClassNames, throttleHandler, } from "../../utilities/helpers.js";
5
5
  import View from "../View/index.js";
6
6
  import useRTL from "../../hooks/useRTL.js";
7
7
  import useIsomorphicLayoutEffect from "../../hooks/useIsomorphicLayoutEffect.js";
@@ -9,7 +9,9 @@ import CarouselControl from "./CarouselControl.js";
9
9
  import * as T from "./Carousel.types.js";
10
10
  import s from "./Carousel.module.css";
11
11
  const Carousel = (props) => {
12
- const { children, gap = 3, visibleItems, bleed, navigationDisplay, instanceRef, className, attributes, } = props;
12
+ const { children, gap = 3, visibleItems, bleed, navigationDisplay, onChange, instanceRef, className, attributes, } = props;
13
+ const currentIndexRef = React.useRef(0);
14
+ const itemRefs = React.useRef([]);
13
15
  const [mounted, setMounted] = React.useState(false);
14
16
  const [scrollPosition, setScrollPosition] = React.useState(0);
15
17
  const [isRTL] = useRTL();
@@ -21,9 +23,20 @@ const Carousel = (props) => {
21
23
  });
22
24
  }
23
25
  const rootClassNames = classNames(s.root, className, ...responsiveClassNames(s, "--bleed", typeof bleed === "number" ? true : bleedClassNames));
24
- const handleScroll = debounceHandler((event) => {
26
+ const handleItemRef = (el, index) => {
27
+ itemRefs.current[index] = el;
28
+ // TODO: Enable in React v19 since it introduced refs cleanup
29
+ // return () => {
30
+ // itemRefs.current[index] = null;
31
+ // };
32
+ };
33
+ const handleScroll = throttleHandler((event) => {
25
34
  const el = event.target;
35
+ const firstVisibleIndex = getFirstVisibleIndex();
26
36
  setScrollPosition(el.scrollLeft);
37
+ if (currentIndexRef.current !== firstVisibleIndex)
38
+ onChange?.({ index: firstVisibleIndex });
39
+ currentIndexRef.current = firstVisibleIndex;
27
40
  }, 16);
28
41
  const getItemsGap = () => {
29
42
  const style = getComputedStyle(scrollElRef.current);
@@ -31,6 +44,40 @@ const Carousel = (props) => {
31
44
  const xGap = style.gap.split(" ")[0];
32
45
  return Number(xGap.replace("px", ""));
33
46
  };
47
+ const getFirstVisibleIndex = () => {
48
+ let resultIndex = 0;
49
+ let sizeCalc = 0;
50
+ const scrollEl = scrollElRef.current;
51
+ if (!scrollEl)
52
+ return resultIndex;
53
+ const scrollValue = isRTL ? -scrollEl.scrollLeft : scrollEl.scrollLeft;
54
+ const gap = getItemsGap();
55
+ itemRefs.current.some((el, index) => {
56
+ if (!el)
57
+ return false;
58
+ const visible = sizeCalc + el.clientWidth / 2 >= scrollValue;
59
+ if (visible) {
60
+ resultIndex = index;
61
+ return true;
62
+ }
63
+ sizeCalc += el?.clientWidth + gap;
64
+ return false;
65
+ });
66
+ return resultIndex;
67
+ };
68
+ const navigateTo = (index) => {
69
+ const scrollEl = scrollElRef.current;
70
+ const el = itemRefs.current[index];
71
+ if (!el)
72
+ return;
73
+ scrollEl.scrollTo({
74
+ // Browsers mirror offsetLeft value but we need to also keep the target element on the other side of the container
75
+ // so adding addition calculations for the width of the content outside the target el
76
+ left: isRTL ? el.offsetLeft - (scrollEl.clientWidth - el.clientWidth) : el.offsetLeft,
77
+ top: 0,
78
+ behavior: "smooth",
79
+ });
80
+ };
34
81
  const navigateRight = () => {
35
82
  const scrollEl = scrollElRef.current;
36
83
  scrollEl.scrollBy({
@@ -52,6 +99,7 @@ const Carousel = (props) => {
52
99
  React.useImperativeHandle(instanceRef, () => ({
53
100
  navigateBack,
54
101
  navigateForward,
102
+ navigateTo,
55
103
  }));
56
104
  /**
57
105
  * Changing flag here since scroll ref changing won't rerender the controls and show them after SSR
@@ -63,6 +111,6 @@ const Carousel = (props) => {
63
111
  ...responsiveVariables("--rs-carousel-items", visibleItems),
64
112
  ...responsiveVariables("--rs-carousel-bleed", bleed),
65
113
  ...attributes?.style,
66
- }, children: [navigationDisplay !== "hidden" && (_jsxs(_Fragment, { children: [_jsx(CarouselControl, { isRTL: isRTL, type: T.ControlType.back, scrollElRef: scrollElRef, scrollPosition: scrollPosition, onClick: navigateBack, mounted: mounted }), _jsx(CarouselControl, { isRTL: isRTL, type: T.ControlType.forward, scrollElRef: scrollElRef, scrollPosition: scrollPosition, onClick: navigateForward, mounted: mounted })] })), _jsx(View, { as: "ul", direction: "row", wrap: false, gap: gap, className: s.scroll, attributes: { ref: scrollElRef, onScroll: handleScroll }, children: React.Children.map(children, (child) => (_jsx(View.Item, { className: s.item, as: "li", children: child }))) })] }));
114
+ }, children: [navigationDisplay !== "hidden" && (_jsxs(_Fragment, { children: [_jsx(CarouselControl, { isRTL: isRTL, type: T.ControlType.back, scrollElRef: scrollElRef, scrollPosition: scrollPosition, onClick: navigateBack, mounted: mounted }), _jsx(CarouselControl, { isRTL: isRTL, type: T.ControlType.forward, scrollElRef: scrollElRef, scrollPosition: scrollPosition, onClick: navigateForward, mounted: mounted })] })), _jsx(View, { as: "ul", direction: "row", wrap: false, gap: gap, className: s.scroll, attributes: { ref: scrollElRef, onScroll: handleScroll }, children: React.Children.map(children, (child, index) => (_jsx(View.Item, { className: s.item, as: "li", attributes: { ref: (el) => handleItemRef(el, index) }, children: child }))) })] }));
67
115
  };
68
116
  export default Carousel;
@@ -3,6 +3,7 @@ import type * as G from "../../types/global";
3
3
  export type Instance = {
4
4
  navigateBack: () => void;
5
5
  navigateForward: () => void;
6
+ navigateTo: (index: number) => void;
6
7
  } | undefined;
7
8
  export declare enum ControlType {
8
9
  back = "back",
@@ -23,6 +24,9 @@ export type Props = {
23
24
  bleed?: G.Responsive<number>;
24
25
  navigationDisplay?: "hidden";
25
26
  instanceRef?: React.Ref<Instance>;
27
+ onChange?: (args: {
28
+ index: number;
29
+ }) => void;
26
30
  className?: G.ClassName;
27
31
  attributes?: G.Attributes<"div">;
28
32
  };
@@ -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;
@@ -1,15 +1,34 @@
1
1
  import React from "react";
2
+ import { StoryObj } from "@storybook/react";
3
+ import { fn } from "@storybook/test";
2
4
  declare const _default: {
3
5
  title: string;
4
6
  component: (props: import("./..").CarouselProps) => React.JSX.Element;
5
7
  parameters: {
8
+ a11y: {
9
+ disable: boolean;
10
+ };
6
11
  iframe: {
7
12
  url: string;
8
13
  };
9
14
  };
10
15
  };
11
16
  export default _default;
12
- export declare const visibleItems: () => React.JSX.Element;
13
- export declare const gap: () => React.JSX.Element;
14
- export declare const bleed: () => React.JSX.Element;
15
- export declare const navigation: () => React.JSX.Element;
17
+ export declare const base: StoryObj;
18
+ export declare const visibleItems: {
19
+ name: string;
20
+ render: () => React.JSX.Element;
21
+ };
22
+ export declare const gap: {
23
+ name: string;
24
+ render: () => React.JSX.Element;
25
+ };
26
+ export declare const bleed: {
27
+ name: string;
28
+ render: () => React.JSX.Element;
29
+ };
30
+ export declare const navigationDisplay: StoryObj;
31
+ export declare const instanceRef: StoryObj<{
32
+ handleChange: ReturnType<typeof fn>;
33
+ }>;
34
+ export declare const className: StoryObj;
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { expect, fn, userEvent, waitFor } from "@storybook/test";
2
3
  import { Example, Placeholder } from "../../../utilities/storybook/index.js";
3
4
  import Carousel from "../index.js";
4
5
  import Button from "../../Button/index.js";
@@ -7,121 +8,217 @@ export default {
7
8
  title: "Components/Carousel",
8
9
  component: Carousel,
9
10
  parameters: {
11
+ // Skip because of the aria-hidden applied to buttons, they're replaced by screen reader navigation
12
+ a11y: {
13
+ disable: true,
14
+ },
10
15
  iframe: {
11
16
  url: "https://reshaped.so/docs/components/carousel",
12
17
  },
13
18
  },
14
19
  };
15
- export const visibleItems = () => (<Example>
16
- <Example.Item title="visibleItems: 3">
17
- <Carousel visibleItems={3}>
18
- <Placeholder h={100}/>
19
- <Placeholder h={100}/>
20
- <Placeholder h={100}/>
21
- <Placeholder h={100}/>
22
- <Placeholder h={100}/>
23
- <Placeholder h={100}/>
24
- </Carousel>
25
- </Example.Item>
20
+ export const base = {
21
+ name: "base",
22
+ render: () => (<Carousel attributes={{ "data-testid": "test-id" }} visibleItems={3}>
23
+ <Placeholder h={100}>Content</Placeholder>
24
+ <Placeholder h={100}>Content</Placeholder>
25
+ <Placeholder h={100}>Content</Placeholder>
26
+ <Placeholder h={100}>Content</Placeholder>
27
+ <Placeholder h={100}>Content</Placeholder>
28
+ <Placeholder h={100}>Content</Placeholder>
29
+ </Carousel>),
30
+ play: async ({ canvas }) => {
31
+ const root = canvas.getByTestId("test-id");
32
+ const items = canvas.getAllByText("Content");
33
+ const buttons = root.querySelectorAll("button");
34
+ expect(root).toBeInTheDocument();
35
+ expect(root.tagName).toBe("SECTION");
36
+ expect(items).toHaveLength(6);
37
+ expect(buttons).toHaveLength(2);
38
+ },
39
+ };
40
+ export const visibleItems = {
41
+ name: "visibleItems",
42
+ render: () => (<Example>
43
+ <Example.Item title="visibleItems: 3">
44
+ <Carousel visibleItems={3}>
45
+ <Placeholder h={100}/>
46
+ <Placeholder h={100}/>
47
+ <Placeholder h={100}/>
48
+ <Placeholder h={100}/>
49
+ <Placeholder h={100}/>
50
+ <Placeholder h={100}/>
51
+ </Carousel>
52
+ </Example.Item>
26
53
 
27
- <Example.Item title={["responsive visibleItems", "[s] 2", "[m+] 3"]}>
28
- <Carousel visibleItems={{ s: 2, m: 3 }}>
29
- <Placeholder h={100}/>
30
- <Placeholder h={100}/>
31
- <Placeholder h={100}/>
32
- <Placeholder h={100}/>
33
- <Placeholder h={100}/>
34
- <Placeholder h={100}/>
35
- </Carousel>
36
- </Example.Item>
54
+ <Example.Item title={["responsive visibleItems", "s: 2, m+ 3"]}>
55
+ <Carousel visibleItems={{ s: 2, m: 3 }}>
56
+ <Placeholder h={100}/>
57
+ <Placeholder h={100}/>
58
+ <Placeholder h={100}/>
59
+ <Placeholder h={100}/>
60
+ <Placeholder h={100}/>
61
+ <Placeholder h={100}/>
62
+ </Carousel>
63
+ </Example.Item>
37
64
 
38
- <Example.Item title="visibleItems: auto">
39
- <Carousel>
40
- <Placeholder h={100}/>
41
- <Placeholder h={100} w={200}/>
42
- <Placeholder h={100} w={300}/>
43
- <Placeholder h={100}/>
44
- <Placeholder h={100}/>
45
- <Placeholder h={100}/>
46
- </Carousel>
47
- </Example.Item>
48
- </Example>);
49
- export const gap = () => (<Example>
50
- <Example.Item title="gap: 2, visibleItems 3">
51
- <Carousel visibleItems={3} gap={2}>
52
- <Placeholder h={100}/>
53
- <Placeholder h={100}/>
54
- <Placeholder h={100}/>
55
- <Placeholder h={100}/>
56
- <Placeholder h={100}/>
57
- <Placeholder h={100}/>
58
- </Carousel>
59
- </Example.Item>
65
+ <Example.Item title="visibleItems: auto">
66
+ <Carousel>
67
+ <Placeholder h={100}/>
68
+ <Placeholder h={100} w={200}/>
69
+ <Placeholder h={100} w={300}/>
70
+ <Placeholder h={100}/>
71
+ <Placeholder h={100}/>
72
+ <Placeholder h={100}/>
73
+ </Carousel>
74
+ </Example.Item>
75
+ </Example>),
76
+ };
77
+ export const gap = {
78
+ name: "gap",
79
+ render: () => (<Example>
80
+ <Example.Item title="gap: 2, visibleItems 3">
81
+ <Carousel visibleItems={3} gap={2}>
82
+ <Placeholder h={100}/>
83
+ <Placeholder h={100}/>
84
+ <Placeholder h={100}/>
85
+ <Placeholder h={100}/>
86
+ <Placeholder h={100}/>
87
+ <Placeholder h={100}/>
88
+ </Carousel>
89
+ </Example.Item>
60
90
 
61
- <Example.Item title={["responsive gap, visibleItems: 3", "[s] 2", "[l] 8"]}>
62
- <Carousel visibleItems={3} gap={{ s: 2, l: 8 }}>
63
- <Placeholder h={100}/>
64
- <Placeholder h={100}/>
65
- <Placeholder h={100}/>
66
- <Placeholder h={100}/>
67
- <Placeholder h={100}/>
68
- <Placeholder h={100}/>
69
- </Carousel>
70
- </Example.Item>
71
- </Example>);
72
- export const bleed = () => (<Example>
73
- <Example.Item title="bleed: 4, visibleItems: 3">
74
- <Carousel visibleItems={3} bleed={4}>
75
- <Placeholder h={100}/>
76
- <Placeholder h={100}/>
77
- <Placeholder h={100}/>
78
- <Placeholder h={100}/>
79
- <Placeholder h={100}/>
80
- <Placeholder h={100}/>
81
- </Carousel>
82
- </Example.Item>
91
+ <Example.Item title={["gap: responsive, visibleItems: 3", "s: 2, l: 8"]}>
92
+ <Carousel visibleItems={3} gap={{ s: 2, l: 8 }}>
93
+ <Placeholder h={100}/>
94
+ <Placeholder h={100}/>
95
+ <Placeholder h={100}/>
96
+ <Placeholder h={100}/>
97
+ <Placeholder h={100}/>
98
+ <Placeholder h={100}/>
99
+ </Carousel>
100
+ </Example.Item>
101
+ </Example>),
102
+ };
103
+ export const bleed = {
104
+ name: "bleed",
105
+ render: () => (<Example>
106
+ <Example.Item title="bleed: 4, visibleItems: 3">
107
+ <Carousel visibleItems={3} bleed={4}>
108
+ <Placeholder h={100}/>
109
+ <Placeholder h={100}/>
110
+ <Placeholder h={100}/>
111
+ <Placeholder h={100}/>
112
+ <Placeholder h={100}/>
113
+ <Placeholder h={100}/>
114
+ </Carousel>
115
+ </Example.Item>
83
116
 
84
- <Example.Item title={["responsive bleed, visibleItems: 3", "[s] 4, [l+] 0"]}>
85
- <Carousel visibleItems={3} bleed={{ s: 4, l: 0 }}>
86
- <Placeholder h={100}/>
87
- <Placeholder h={100}/>
88
- <Placeholder h={100}/>
89
- <Placeholder h={100}/>
90
- <Placeholder h={100}/>
91
- <Placeholder h={100}/>
92
- </Carousel>
93
- </Example.Item>
94
- </Example>);
95
- const RefDemo = () => {
96
- const carouselRef = React.useRef(null);
97
- return (<View gap={3}>
98
- <View gap={3} direction="row">
99
- <Button onClick={() => carouselRef.current?.navigateBack()}>Back</Button>
100
- <Button onClick={() => carouselRef.current?.navigateForward()}>Forward</Button>
101
- </View>
102
- <Carousel visibleItems={2} instanceRef={carouselRef} navigationDisplay="hidden">
117
+ <Example.Item title={["responsive bleed, visibleItems: 3", "[s] 4, [l+] 0"]}>
118
+ <Carousel visibleItems={3} bleed={{ s: 4, l: 0 }}>
119
+ <Placeholder h={100}/>
120
+ <Placeholder h={100}/>
121
+ <Placeholder h={100}/>
122
+ <Placeholder h={100}/>
123
+ <Placeholder h={100}/>
124
+ <Placeholder h={100}/>
125
+ </Carousel>
126
+ </Example.Item>
127
+ </Example>),
128
+ };
129
+ export const navigationDisplay = {
130
+ name: "navigationDisplay",
131
+ render: () => (<Example>
132
+ <Example.Item title="navigationDisplay: hidden">
133
+ <Carousel visibleItems={3} navigationDisplay="hidden" attributes={{ "data-testid": "test-id" }}>
134
+ <Placeholder h={100}/>
135
+ <Placeholder h={100}/>
136
+ <Placeholder h={100}/>
137
+ <Placeholder h={100}/>
138
+ <Placeholder h={100}/>
139
+ <Placeholder h={100}/>
140
+ </Carousel>
141
+ </Example.Item>
142
+ </Example>),
143
+ play: async ({ canvas }) => {
144
+ const root = canvas.getByTestId("test-id");
145
+ const buttons = root.querySelectorAll("button");
146
+ expect(buttons).toHaveLength(0);
147
+ },
148
+ };
149
+ export const instanceRef = {
150
+ name: "instanceRef, onChange",
151
+ args: {
152
+ handleChange: fn(),
153
+ },
154
+ render: (args) => {
155
+ const carouselRef = React.useRef(null);
156
+ const [index, setIndex] = React.useState(0);
157
+ return (<Example>
158
+ <Example.Item title="instanceRef, onChange">
159
+ <View gap={3}>
160
+ <View gap={3} direction="row" align="center">
161
+ <Button onClick={() => carouselRef.current?.navigateBack()}>Back</Button>
162
+ <Button onClick={() => carouselRef.current?.navigateForward()}>Forward</Button>
163
+ <Button onClick={() => carouselRef.current?.navigateTo(3)}>To 3</Button>
164
+ <View.Item>Index: {index}</View.Item>
165
+ </View>
166
+ <Carousel visibleItems={2} instanceRef={carouselRef} navigationDisplay="hidden" onChange={(changeArgs) => {
167
+ args.handleChange(changeArgs);
168
+ setIndex(changeArgs.index);
169
+ }}>
170
+ <Placeholder h={100}>Item 0</Placeholder>
171
+ <Placeholder h={100}>Item 1</Placeholder>
172
+ <Placeholder h={100}>Item 2</Placeholder>
173
+ <Placeholder h={100}>Item 3</Placeholder>
174
+ <Placeholder h={100}>Item 4</Placeholder>
175
+ <Placeholder h={100}>Item 5</Placeholder>
176
+ </Carousel>
177
+ </View>
178
+ </Example.Item>
179
+ </Example>);
180
+ },
181
+ play: async ({ canvas, args }) => {
182
+ const buttons = canvas.getAllByRole("button");
183
+ const backButton = buttons[0];
184
+ const forwardButton = buttons[1];
185
+ const toButton = buttons[2];
186
+ await userEvent.click(forwardButton);
187
+ await waitFor(() => {
188
+ expect(args.handleChange).toHaveBeenCalledWith({ index: 1 });
189
+ expect(args.handleChange).toHaveBeenCalledWith({ index: 2 });
190
+ expect(args.handleChange).not.toHaveBeenCalledWith({ index: 3 });
191
+ });
192
+ args.handleChange.mockClear();
193
+ await userEvent.click(backButton);
194
+ await waitFor(() => {
195
+ expect(args.handleChange).toHaveBeenCalledWith({ index: 0 });
196
+ expect(args.handleChange).toHaveBeenCalledWith({ index: 1 });
197
+ });
198
+ args.handleChange.mockClear();
199
+ await userEvent.click(toButton);
200
+ await waitFor(() => {
201
+ expect(args.handleChange).toHaveBeenCalledWith({ index: 1 });
202
+ expect(args.handleChange).toHaveBeenCalledWith({ index: 2 });
203
+ expect(args.handleChange).toHaveBeenCalledWith({ index: 3 });
204
+ });
205
+ },
206
+ };
207
+ export const className = {
208
+ name: "className, attributes",
209
+ render: () => (<div data-testid="root">
210
+ <Carousel visibleItems={2} className="test-classname" attributes={{ id: "test-id" }}>
211
+ <Placeholder h={100}>Item 0</Placeholder>
103
212
  <Placeholder h={100}>Item 1</Placeholder>
104
213
  <Placeholder h={100}>Item 2</Placeholder>
105
214
  <Placeholder h={100}>Item 3</Placeholder>
106
215
  <Placeholder h={100}>Item 4</Placeholder>
107
216
  <Placeholder h={100}>Item 5</Placeholder>
108
- <Placeholder h={100}>Item 6</Placeholder>
109
217
  </Carousel>
110
- </View>);
218
+ </div>),
219
+ play: async ({ canvas }) => {
220
+ const root = canvas.getByTestId("root").firstChild;
221
+ expect(root).toHaveClass("test-classname");
222
+ expect(root).toHaveAttribute("id", "test-id");
223
+ },
111
224
  };
112
- export const navigation = () => (<Example>
113
- <Example.Item title="navigation: hidden">
114
- <Carousel visibleItems={3} navigationDisplay="hidden">
115
- <Placeholder h={100}/>
116
- <Placeholder h={100}/>
117
- <Placeholder h={100}/>
118
- <Placeholder h={100}/>
119
- <Placeholder h={100}/>
120
- <Placeholder h={100}/>
121
- </Carousel>
122
- </Example.Item>
123
-
124
- <Example.Item title="navigation: external">
125
- <RefDemo />
126
- </Example.Item>
127
- </Example>);
@@ -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;