@basic-ui/core 0.0.36 → 0.0.39

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 (348) hide show
  1. package/build/cjs/index.js +84 -83
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/Accordion/Accordion.d.ts +1 -1
  4. package/build/esm/Accordion/Accordion.js +23 -17
  5. package/build/esm/Accordion/Accordion.js.map +1 -1
  6. package/build/esm/Accordion/AccordionBody.d.ts +1 -1
  7. package/build/esm/Accordion/AccordionBody.js +24 -15
  8. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  9. package/build/esm/Accordion/AccordionHeader.d.ts +1 -1
  10. package/build/esm/Accordion/AccordionHeader.js +46 -31
  11. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  12. package/build/esm/Accordion/AccordionItem.d.ts +1 -1
  13. package/build/esm/Accordion/AccordionItem.js +18 -18
  14. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  15. package/build/esm/Accordion/context.d.ts +1 -1
  16. package/build/esm/Accordion/context.js +12 -10
  17. package/build/esm/Accordion/context.js.map +1 -1
  18. package/build/esm/Accordion/index.d.ts +0 -0
  19. package/build/esm/Accordion/index.js +0 -0
  20. package/build/esm/Accordion/index.js.map +0 -0
  21. package/build/esm/Accordion/scopeQuery.d.ts +0 -0
  22. package/build/esm/Accordion/scopeQuery.js +0 -0
  23. package/build/esm/Accordion/scopeQuery.js.map +0 -0
  24. package/build/esm/CheckBox/CheckBox.d.ts +1 -1
  25. package/build/esm/CheckBox/CheckBox.js +20 -12
  26. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  27. package/build/esm/CheckBox/index.d.ts +0 -0
  28. package/build/esm/CheckBox/index.js +0 -0
  29. package/build/esm/CheckBox/index.js.map +0 -0
  30. package/build/esm/ComboBox/Combobox.d.ts +1 -1
  31. package/build/esm/ComboBox/Combobox.js +55 -48
  32. package/build/esm/ComboBox/Combobox.js.map +1 -1
  33. package/build/esm/ComboBox/ComboboxButton.d.ts +1 -1
  34. package/build/esm/ComboBox/ComboboxButton.js +20 -20
  35. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  36. package/build/esm/ComboBox/ComboboxInput.d.ts +1 -1
  37. package/build/esm/ComboBox/ComboboxInput.js +53 -50
  38. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  39. package/build/esm/ComboBox/ComboboxLabel.d.ts +1 -1
  40. package/build/esm/ComboBox/ComboboxLabel.js +12 -12
  41. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  42. package/build/esm/ComboBox/ComboboxList.d.ts +1 -1
  43. package/build/esm/ComboBox/ComboboxList.js +16 -17
  44. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  45. package/build/esm/ComboBox/ComboboxOption.d.ts +1 -1
  46. package/build/esm/ComboBox/ComboboxOption.js +32 -34
  47. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  48. package/build/esm/ComboBox/ComboboxPopover.d.ts +1 -1
  49. package/build/esm/ComboBox/ComboboxPopover.js +16 -17
  50. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  51. package/build/esm/ComboBox/cities.d.ts +0 -0
  52. package/build/esm/ComboBox/cities.js +0 -0
  53. package/build/esm/ComboBox/cities.js.map +0 -0
  54. package/build/esm/ComboBox/context.d.ts +3 -3
  55. package/build/esm/ComboBox/context.js +6 -5
  56. package/build/esm/ComboBox/context.js.map +1 -1
  57. package/build/esm/ComboBox/hooks.d.ts +1 -1
  58. package/build/esm/ComboBox/hooks.js +82 -115
  59. package/build/esm/ComboBox/hooks.js.map +1 -1
  60. package/build/esm/ComboBox/index.d.ts +0 -0
  61. package/build/esm/ComboBox/index.js +0 -0
  62. package/build/esm/ComboBox/index.js.map +0 -0
  63. package/build/esm/ComboBox/makeHash.d.ts +0 -0
  64. package/build/esm/ComboBox/makeHash.js +3 -3
  65. package/build/esm/ComboBox/makeHash.js.map +1 -1
  66. package/build/esm/ComboBox/scopeQuery.d.ts +0 -0
  67. package/build/esm/ComboBox/scopeQuery.js +0 -0
  68. package/build/esm/ComboBox/scopeQuery.js.map +0 -0
  69. package/build/esm/FocusLock/FocusLock.d.ts +1 -1
  70. package/build/esm/FocusLock/FocusLock.js +18 -16
  71. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  72. package/build/esm/FocusLock/index.d.ts +0 -0
  73. package/build/esm/FocusLock/index.js +0 -0
  74. package/build/esm/FocusLock/index.js.map +0 -0
  75. package/build/esm/FocusLock/tabUtils.d.ts +1 -0
  76. package/build/esm/FocusLock/tabUtils.js +14 -2
  77. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  78. package/build/esm/FocusLock/useFocusLock.d.ts +0 -0
  79. package/build/esm/FocusLock/useFocusLock.js +14 -22
  80. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  81. package/build/esm/List/List.d.ts +1 -1
  82. package/build/esm/List/List.js +6 -6
  83. package/build/esm/List/List.js.map +1 -1
  84. package/build/esm/List/ListItem.d.ts +1 -1
  85. package/build/esm/List/ListItem.js +6 -6
  86. package/build/esm/List/ListItem.js.map +1 -1
  87. package/build/esm/List/context.d.ts +0 -0
  88. package/build/esm/List/context.js +3 -3
  89. package/build/esm/List/context.js.map +1 -1
  90. package/build/esm/List/index.d.ts +0 -0
  91. package/build/esm/List/index.js +0 -0
  92. package/build/esm/List/index.js.map +0 -0
  93. package/build/esm/Menu/Menu.d.ts +1 -1
  94. package/build/esm/Menu/Menu.js +31 -23
  95. package/build/esm/Menu/Menu.js.map +1 -1
  96. package/build/esm/Menu/MenuButton.d.ts +1 -1
  97. package/build/esm/Menu/MenuButton.js +29 -25
  98. package/build/esm/Menu/MenuButton.js.map +1 -1
  99. package/build/esm/Menu/MenuItem.d.ts +1 -1
  100. package/build/esm/Menu/MenuItem.js +26 -27
  101. package/build/esm/Menu/MenuItem.js.map +1 -1
  102. package/build/esm/Menu/MenuList.d.ts +1 -1
  103. package/build/esm/Menu/MenuList.js +62 -45
  104. package/build/esm/Menu/MenuList.js.map +1 -1
  105. package/build/esm/Menu/MenuPopover.d.ts +2 -2
  106. package/build/esm/Menu/MenuPopover.js +9 -10
  107. package/build/esm/Menu/MenuPopover.js.map +1 -1
  108. package/build/esm/Menu/context.d.ts +1 -1
  109. package/build/esm/Menu/context.js +11 -8
  110. package/build/esm/Menu/context.js.map +1 -1
  111. package/build/esm/Menu/index.d.ts +0 -0
  112. package/build/esm/Menu/index.js +0 -0
  113. package/build/esm/Menu/index.js.map +0 -0
  114. package/build/esm/Menu/scope.d.ts +0 -0
  115. package/build/esm/Menu/scope.js +0 -0
  116. package/build/esm/Menu/scope.js.map +0 -0
  117. package/build/esm/Modal/Modal.d.ts +2 -2
  118. package/build/esm/Modal/Modal.js +14 -12
  119. package/build/esm/Modal/Modal.js.map +1 -1
  120. package/build/esm/Modal/ModalBackdrop.d.ts +1 -1
  121. package/build/esm/Modal/ModalBackdrop.js +21 -19
  122. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  123. package/build/esm/Modal/index.d.ts +0 -0
  124. package/build/esm/Modal/index.js +0 -0
  125. package/build/esm/Modal/index.js.map +0 -0
  126. package/build/esm/Popper/Popper.d.ts +2 -2
  127. package/build/esm/Popper/Popper.js +51 -36
  128. package/build/esm/Popper/Popper.js.map +1 -1
  129. package/build/esm/Popper/PopperArrow.d.ts +1 -1
  130. package/build/esm/Popper/PopperArrow.js +9 -9
  131. package/build/esm/Popper/PopperArrow.js.map +1 -1
  132. package/build/esm/Popper/context.d.ts +1 -1
  133. package/build/esm/Popper/context.js +5 -3
  134. package/build/esm/Popper/context.js.map +1 -1
  135. package/build/esm/Popper/index.d.ts +0 -0
  136. package/build/esm/Popper/index.js +0 -0
  137. package/build/esm/Popper/index.js.map +0 -0
  138. package/build/esm/Portal/Portal.d.ts +1 -1
  139. package/build/esm/Portal/Portal.js +6 -5
  140. package/build/esm/Portal/Portal.js.map +1 -1
  141. package/build/esm/Portal/index.d.ts +0 -0
  142. package/build/esm/Portal/index.js +0 -0
  143. package/build/esm/Portal/index.js.map +0 -0
  144. package/build/esm/RadioButton/RadioButton.d.ts +2 -2
  145. package/build/esm/RadioButton/RadioButton.js +13 -13
  146. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  147. package/build/esm/RadioButton/RadioGroup.d.ts +2 -2
  148. package/build/esm/RadioButton/RadioGroup.js +25 -18
  149. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  150. package/build/esm/RadioButton/context.d.ts +0 -0
  151. package/build/esm/RadioButton/context.js +6 -5
  152. package/build/esm/RadioButton/context.js.map +1 -1
  153. package/build/esm/RadioButton/index.d.ts +0 -0
  154. package/build/esm/RadioButton/index.js +0 -0
  155. package/build/esm/RadioButton/index.js.map +0 -0
  156. package/build/esm/SkipNav/SkipNav.d.ts +1 -1
  157. package/build/esm/SkipNav/SkipNav.js +6 -6
  158. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  159. package/build/esm/SkipNav/index.d.ts +0 -0
  160. package/build/esm/SkipNav/index.js +0 -0
  161. package/build/esm/SkipNav/index.js.map +0 -0
  162. package/build/esm/Spinner/Spinner.d.ts +1 -1
  163. package/build/esm/Spinner/Spinner.js +42 -31
  164. package/build/esm/Spinner/Spinner.js.map +1 -1
  165. package/build/esm/Spinner/SpinnerButton.d.ts +1 -1
  166. package/build/esm/Spinner/SpinnerButton.js +12 -12
  167. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  168. package/build/esm/Spinner/context.d.ts +0 -0
  169. package/build/esm/Spinner/context.js +6 -5
  170. package/build/esm/Spinner/context.js.map +1 -1
  171. package/build/esm/Spinner/index.d.ts +0 -0
  172. package/build/esm/Spinner/index.js +0 -0
  173. package/build/esm/Spinner/index.js.map +0 -0
  174. package/build/esm/Tabs/Tab.d.ts +1 -1
  175. package/build/esm/Tabs/Tab.js +30 -29
  176. package/build/esm/Tabs/Tab.js.map +1 -1
  177. package/build/esm/Tabs/TabList.d.ts +1 -1
  178. package/build/esm/Tabs/TabList.js +27 -23
  179. package/build/esm/Tabs/TabList.js.map +1 -1
  180. package/build/esm/Tabs/TabPanel.d.ts +1 -1
  181. package/build/esm/Tabs/TabPanel.js +13 -12
  182. package/build/esm/Tabs/TabPanel.js.map +1 -1
  183. package/build/esm/Tabs/TabPanels.d.ts +1 -1
  184. package/build/esm/Tabs/TabPanels.js +14 -12
  185. package/build/esm/Tabs/TabPanels.js.map +1 -1
  186. package/build/esm/Tabs/Tabs.d.ts +1 -1
  187. package/build/esm/Tabs/Tabs.js +28 -14
  188. package/build/esm/Tabs/Tabs.js.map +1 -1
  189. package/build/esm/Tabs/context.d.ts +1 -1
  190. package/build/esm/Tabs/context.js +12 -10
  191. package/build/esm/Tabs/context.js.map +1 -1
  192. package/build/esm/Tabs/index.d.ts +0 -0
  193. package/build/esm/Tabs/index.js +0 -0
  194. package/build/esm/Tabs/index.js.map +0 -0
  195. package/build/esm/Tabs/scopeQuery.d.ts +0 -0
  196. package/build/esm/Tabs/scopeQuery.js +0 -0
  197. package/build/esm/Tabs/scopeQuery.js.map +0 -0
  198. package/build/esm/Tooltip/Tooltip.d.ts +2 -1
  199. package/build/esm/Tooltip/Tooltip.js +17 -15
  200. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  201. package/build/esm/Tooltip/index.d.ts +0 -0
  202. package/build/esm/Tooltip/index.js +0 -0
  203. package/build/esm/Tooltip/index.js.map +0 -0
  204. package/build/esm/Tooltip/stateMachine.d.ts +0 -0
  205. package/build/esm/Tooltip/stateMachine.js +56 -80
  206. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  207. package/build/esm/Tooltip/useTooltip.d.ts +1 -1
  208. package/build/esm/Tooltip/useTooltip.js +32 -31
  209. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  210. package/build/esm/hooks/index.d.ts +0 -1
  211. package/build/esm/hooks/index.js +0 -1
  212. package/build/esm/hooks/index.js.map +1 -1
  213. package/build/esm/hooks/useAutoFocus.d.ts +0 -0
  214. package/build/esm/hooks/useAutoFocus.js +6 -2
  215. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  216. package/build/esm/hooks/useChildrenCounter.d.ts +1 -1
  217. package/build/esm/hooks/useChildrenCounter.js +6 -4
  218. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  219. package/build/esm/hooks/useControlledState.d.ts +1 -1
  220. package/build/esm/hooks/useControlledState.js +7 -2
  221. package/build/esm/hooks/useControlledState.js.map +1 -1
  222. package/build/esm/hooks/useFocusReturn.d.ts +2 -1
  223. package/build/esm/hooks/useFocusReturn.js +25 -14
  224. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  225. package/build/esm/hooks/useFocusState.d.ts +0 -0
  226. package/build/esm/hooks/useFocusState.js +13 -9
  227. package/build/esm/hooks/useFocusState.js.map +1 -1
  228. package/build/esm/hooks/useGestureHandlers.d.ts +0 -0
  229. package/build/esm/hooks/useGestureHandlers.js +59 -63
  230. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  231. package/build/esm/hooks/useMeasure.d.ts +0 -0
  232. package/build/esm/hooks/useMeasure.js +13 -7
  233. package/build/esm/hooks/useMeasure.js.map +1 -1
  234. package/build/esm/hooks/useOnClickOutside.d.ts +0 -0
  235. package/build/esm/hooks/useOnClickOutside.js +5 -4
  236. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  237. package/build/esm/hooks/useOnKeyDown.d.ts +0 -0
  238. package/build/esm/hooks/useOnKeyDown.js +4 -3
  239. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  240. package/build/esm/hooks/useReducerMachine.d.ts +1 -1
  241. package/build/esm/hooks/useReducerMachine.js +13 -10
  242. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  243. package/build/esm/hooks/useRemoveBodyScroll.d.ts +0 -0
  244. package/build/esm/hooks/useRemoveBodyScroll.js +14 -21
  245. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  246. package/build/esm/hooks/useScope.d.ts +1 -1
  247. package/build/esm/hooks/useScope.js +10 -12
  248. package/build/esm/hooks/useScope.js.map +1 -1
  249. package/build/esm/hooks/useThrottle.d.ts +0 -0
  250. package/build/esm/hooks/useThrottle.js +10 -5
  251. package/build/esm/hooks/useThrottle.js.map +1 -1
  252. package/build/esm/index.d.ts +0 -0
  253. package/build/esm/index.js +0 -0
  254. package/build/esm/index.js.map +0 -0
  255. package/build/esm/utils/assignRef.d.ts +1 -1
  256. package/build/esm/utils/assignRef.js +7 -3
  257. package/build/esm/utils/assignRef.js.map +1 -1
  258. package/build/esm/utils/clamp.d.ts +0 -0
  259. package/build/esm/utils/clamp.js +0 -0
  260. package/build/esm/utils/clamp.js.map +0 -0
  261. package/build/esm/utils/createSubscription.d.ts +0 -0
  262. package/build/esm/utils/createSubscription.js +7 -5
  263. package/build/esm/utils/createSubscription.js.map +1 -1
  264. package/build/esm/utils/getCircularIndex.d.ts +0 -0
  265. package/build/esm/utils/getCircularIndex.js +0 -0
  266. package/build/esm/utils/getCircularIndex.js.map +0 -0
  267. package/build/esm/utils/index.d.ts +0 -0
  268. package/build/esm/utils/index.js +0 -0
  269. package/build/esm/utils/index.js.map +0 -0
  270. package/build/esm/utils/rubberBandClamp.d.ts +0 -0
  271. package/build/esm/utils/rubberBandClamp.js +5 -2
  272. package/build/esm/utils/rubberBandClamp.js.map +1 -1
  273. package/build/esm/utils/wrapEvent.d.ts +0 -0
  274. package/build/esm/utils/wrapEvent.js +7 -3
  275. package/build/esm/utils/wrapEvent.js.map +1 -1
  276. package/build/tsconfig.tsbuildinfo +1 -7151
  277. package/package.json +13 -13
  278. package/src/Accordion/Accordion.story.tsx +6 -4
  279. package/src/Accordion/Accordion.tsx +4 -2
  280. package/src/Accordion/AccordionBody.tsx +4 -4
  281. package/src/Accordion/AccordionHeader.tsx +7 -8
  282. package/src/Accordion/AccordionItem.tsx +5 -4
  283. package/src/Accordion/context.ts +2 -1
  284. package/src/CheckBox/CheckBox.tsx +2 -1
  285. package/src/ComboBox/ComboBox.story.tsx +11 -9
  286. package/src/ComboBox/Combobox.tsx +9 -11
  287. package/src/ComboBox/ComboboxButton.tsx +4 -9
  288. package/src/ComboBox/ComboboxInput.tsx +2 -1
  289. package/src/ComboBox/ComboboxLabel.tsx +2 -1
  290. package/src/ComboBox/ComboboxList.tsx +2 -1
  291. package/src/ComboBox/ComboboxOption.tsx +1 -1
  292. package/src/ComboBox/ComboboxPopover.tsx +2 -1
  293. package/src/ComboBox/context.ts +4 -3
  294. package/src/ComboBox/hooks.tsx +6 -9
  295. package/src/FocusLock/FocusLock.tsx +2 -1
  296. package/src/FocusLock/tabUtils.ts +12 -0
  297. package/src/FocusLock/useFocusLock.ts +5 -11
  298. package/src/List/List.story.tsx +5 -4
  299. package/src/List/List.tsx +1 -1
  300. package/src/List/ListItem.tsx +1 -1
  301. package/src/Menu/Menu.story.tsx +15 -13
  302. package/src/Menu/Menu.tsx +5 -4
  303. package/src/Menu/MenuButton.tsx +7 -11
  304. package/src/Menu/MenuItem.tsx +6 -7
  305. package/src/Menu/MenuList.tsx +4 -8
  306. package/src/Menu/MenuPopover.tsx +4 -2
  307. package/src/Menu/context.ts +2 -1
  308. package/src/Modal/Modal.story.tsx +35 -19
  309. package/src/Modal/Modal.tsx +6 -4
  310. package/src/Modal/ModalBackdrop.tsx +2 -1
  311. package/src/Modal/NavDrawer.story.tsx +8 -7
  312. package/src/Popper/Popper.story.tsx +15 -19
  313. package/src/Popper/Popper.tsx +12 -7
  314. package/src/Popper/PopperArrow.tsx +2 -1
  315. package/src/Popper/context.ts +2 -1
  316. package/src/Portal/Portal.tsx +1 -1
  317. package/src/RadioButton/RadioButton.story.tsx +13 -9
  318. package/src/RadioButton/RadioButton.tsx +4 -2
  319. package/src/RadioButton/RadioGroup.tsx +6 -4
  320. package/src/SkipNav/SkipNav.tsx +1 -1
  321. package/src/Spinner/Spinner.story.tsx +6 -5
  322. package/src/Spinner/Spinner.tsx +2 -1
  323. package/src/Spinner/SpinnerButton.tsx +2 -1
  324. package/src/Tabs/Tab.story.tsx +10 -8
  325. package/src/Tabs/Tab.tsx +4 -4
  326. package/src/Tabs/TabList.tsx +11 -3
  327. package/src/Tabs/TabPanel.tsx +2 -1
  328. package/src/Tabs/TabPanels.tsx +1 -1
  329. package/src/Tabs/Tabs.tsx +2 -1
  330. package/src/Tabs/context.ts +2 -1
  331. package/src/Tooltip/Tooltip.story.tsx +8 -6
  332. package/src/Tooltip/Tooltip.tsx +3 -7
  333. package/src/Tooltip/stateMachine.ts +1 -1
  334. package/src/Tooltip/useTooltip.ts +4 -3
  335. package/src/hooks/index.ts +0 -1
  336. package/src/hooks/useAutoFocus.ts +9 -1
  337. package/src/hooks/useChildrenCounter.ts +2 -1
  338. package/src/hooks/useControlledState.ts +3 -1
  339. package/src/hooks/useFocusReturn.ts +33 -13
  340. package/src/hooks/useFocusState.ts +1 -0
  341. package/src/hooks/useReducerMachine.ts +2 -1
  342. package/src/hooks/useRemoveBodyScroll.ts +10 -18
  343. package/src/hooks/useScope.ts +2 -1
  344. package/src/utils/assignRef.ts +1 -1
  345. package/build/esm/hooks/useId.d.ts +0 -3
  346. package/build/esm/hooks/useId.js +0 -16
  347. package/build/esm/hooks/useId.js.map +0 -1
  348. package/src/hooks/useId.ts +0 -18
@@ -1,11 +1,13 @@
1
1
  import { useState } from 'react';
2
- import { storiesOf } from '@storybook/react';
3
2
  import { useSpring, animated } from 'react-spring';
3
+
4
4
  import { Modal, ModalBackdrop } from './';
5
5
  import { Portal } from '../Portal';
6
6
  import './styles.css';
7
7
 
8
- const stories = storiesOf('Components/Modal', module);
8
+ export default {
9
+ title: 'components/Modal',
10
+ };
9
11
 
10
12
  const LoremIpsum = ({ numOfParagraphs = 20 }) => {
11
13
  const content = [];
@@ -81,7 +83,7 @@ const Wrapper = ({ children }) => {
81
83
  );
82
84
  };
83
85
 
84
- const SimpleModalControlled = () => {
86
+ const SimpleModalControlledExample = () => {
85
87
  const [open, setOpen] = useState(false);
86
88
 
87
89
  const handleClose = () => {
@@ -90,7 +92,9 @@ const SimpleModalControlled = () => {
90
92
 
91
93
  return (
92
94
  <>
93
- <button onClick={() => setOpen(!open)}>Open modal</button>
95
+ <button id="open-modal" onClick={() => setOpen(!open)}>
96
+ Open modal
97
+ </button>
94
98
  {open && (
95
99
  <Portal>
96
100
  <ModalBackdrop onClose={handleClose}>
@@ -106,18 +110,22 @@ const SimpleModalControlled = () => {
106
110
  );
107
111
  };
108
112
 
109
- const NestedModalControlled = () => {
113
+ const NestedModalControlledExample = () => {
110
114
  const [open, setOpen] = useState(false);
111
115
  const [open2, setOpen2] = useState(false);
112
116
 
113
117
  return (
114
118
  <>
115
- <button onClick={() => setOpen(!open)}>Open modal</button>
119
+ <button id="open-modal" onClick={() => setOpen(!open)}>
120
+ Open modal
121
+ </button>
116
122
  {open && (
117
123
  <Portal>
118
124
  <ModalBackdrop onClose={() => setOpen(false)}>
119
125
  <Modal trapFocus={true}>
120
- <button onClick={() => setOpen2(true)}>Open another modal</button>
126
+ <button id="open-another-modal" onClick={() => setOpen2(true)}>
127
+ Open another modal
128
+ </button>
121
129
  {open2 && (
122
130
  <Portal>
123
131
  <ModalBackdrop onClose={() => setOpen2(false)}>
@@ -129,7 +137,13 @@ const NestedModalControlled = () => {
129
137
  </Portal>
130
138
  )}
131
139
  <LoremIpsum numOfParagraphs={1} />
132
- <button onClick={() => setOpen(false)}>Close</button>
140
+ <button
141
+ autoFocus
142
+ id="close-button"
143
+ onClick={() => setOpen(false)}
144
+ >
145
+ Close
146
+ </button>
133
147
  </Modal>
134
148
  </ModalBackdrop>
135
149
  </Portal>
@@ -138,7 +152,7 @@ const NestedModalControlled = () => {
138
152
  );
139
153
  };
140
154
 
141
- const SimpleModalControlledAnimated = () => {
155
+ const SimpleModalControlledAnimatedExample = () => {
142
156
  const [open, setOpen] = useState(false);
143
157
  const [pointerEvents, setPointerEvents] = useState('none');
144
158
  const [{ scale, opacity }, set] = useSpring(() => ({
@@ -186,7 +200,9 @@ const SimpleModalControlledAnimated = () => {
186
200
 
187
201
  return (
188
202
  <>
189
- <button onClick={handleOpen}>Open modal</button>
203
+ <button id="open-modal" onClick={handleOpen}>
204
+ Open modal
205
+ </button>
190
206
  {open && (
191
207
  <Portal>
192
208
  <animated.div
@@ -223,20 +239,20 @@ const SimpleModalControlledAnimated = () => {
223
239
  );
224
240
  };
225
241
 
226
- stories.add('Simple modal, controlled', () => (
242
+ export const SimpleModalControlled = () => (
227
243
  <Wrapper>
228
- <SimpleModalControlled />
244
+ <SimpleModalControlledExample />
229
245
  </Wrapper>
230
- ));
246
+ );
231
247
 
232
- stories.add('Nested modal, controlled', () => (
248
+ export const NestedModalControlled = () => (
233
249
  <Wrapper>
234
- <NestedModalControlled />
250
+ <NestedModalControlledExample />
235
251
  </Wrapper>
236
- ));
252
+ );
237
253
 
238
- stories.add('Simple modal, controlled, animated', () => (
254
+ export const SimpleModalControlledAnimated = () => (
239
255
  <Wrapper>
240
- <SimpleModalControlledAnimated />
256
+ <SimpleModalControlledAnimatedExample />
241
257
  </Wrapper>
242
- ));
258
+ );
@@ -1,5 +1,7 @@
1
- import { ReactNode, forwardRef, useRef } from 'react';
2
- import type * as React from 'react';
1
+ import type { ReactNode } from 'react';
2
+ import { forwardRef, useRef } from 'react';
3
+ import * as React from 'react';
4
+
3
5
  import { useAutoFocus, useFocusReturn, useRemoveBodyScroll } from '../hooks';
4
6
  import { FocusLock } from '../FocusLock';
5
7
  import { assignMultipleRefs } from '../utils';
@@ -19,7 +21,7 @@ export const Modal = forwardRef<HTMLDivElement, ModalProps>(
19
21
  ) => {
20
22
  const modalRef = useRef<HTMLDivElement>(null);
21
23
 
22
- useFocusReturn(trapFocus);
24
+ useFocusReturn(trapFocus, modalRef);
23
25
  useRemoveBodyScroll(trapFocus);
24
26
  useAutoFocus(trapFocus, modalRef);
25
27
 
@@ -31,7 +33,7 @@ export const Modal = forwardRef<HTMLDivElement, ModalProps>(
31
33
  role="dialog"
32
34
  aria-modal="true"
33
35
  style={style}
34
- tabIndex={0}
36
+ tabIndex={-1}
35
37
  {...otherProps}
36
38
  >
37
39
  {children}
@@ -1,5 +1,6 @@
1
1
  import { useRef, forwardRef } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
+
3
4
  import { assignMultipleRefs } from '../utils/assignRef';
4
5
  import { wrapEvent } from '../utils/wrapEvent';
5
6
 
@@ -1,11 +1,13 @@
1
1
  import { useState } from 'react';
2
- import { storiesOf } from '@storybook/react';
3
2
  import { useSpring, animated } from 'react-spring';
3
+
4
4
  import { Modal, ModalBackdrop } from './';
5
5
  import { Portal } from '../Portal';
6
6
  import './styles.css';
7
7
 
8
- const stories = storiesOf('Components/Modal/NavDrawer', module);
8
+ export default {
9
+ title: 'components/Modal/NavDrawer',
10
+ };
9
11
 
10
12
  const LoremIpsum = ({ numOfParagraphs = 20 }) => {
11
13
  const content = [];
@@ -64,9 +66,8 @@ const Wrapper = ({ children }) => {
64
66
 
65
67
  const SimpleModalControlledAnimated = () => {
66
68
  const [open, setOpen] = useState(false);
67
- const [pointerEvents, setPointerEvents] = useState<PointerEventsProperty>(
68
- 'none'
69
- );
69
+ const [pointerEvents, setPointerEvents] =
70
+ useState<PointerEventsProperty>('none');
70
71
  const [{ transformX, opacity }, set] = useSpring(() => ({
71
72
  transformX: -120,
72
73
  opacity: 0,
@@ -150,8 +151,8 @@ const SimpleModalControlledAnimated = () => {
150
151
  );
151
152
  };
152
153
 
153
- stories.add('NavDrawer, controlled, animated', () => (
154
+ export const ControlledAnimated = () => (
154
155
  <Wrapper>
155
156
  <SimpleModalControlledAnimated />
156
157
  </Wrapper>
157
- ));
158
+ );
@@ -1,11 +1,13 @@
1
1
  import { useRef, useState, useEffect } from 'react';
2
2
  import { useSpring, animated } from 'react-spring';
3
- import { storiesOf } from '@storybook/react';
3
+
4
4
  import { Popper } from './Popper';
5
5
  import { PopperArrow } from './PopperArrow';
6
6
  import './styles.css';
7
7
 
8
- const stories = storiesOf('Components/Popper', module);
8
+ export default {
9
+ title: 'components/Popper',
10
+ };
9
11
 
10
12
  const noop = () => {
11
13
  // noop function to be used on onRest, as a cleanup
@@ -159,9 +161,7 @@ function Menu() {
159
161
  );
160
162
  }
161
163
 
162
- const PopperFixedExample = ({ showAll = false, showArrow = false }) => {
163
- const ref = useRef<any>(null);
164
-
164
+ const PopperFixedExample = () => {
165
165
  return (
166
166
  <>
167
167
  <div
@@ -188,7 +188,7 @@ const PopperFixedExample = ({ showAll = false, showArrow = false }) => {
188
188
  );
189
189
  };
190
190
 
191
- const JumpingPopper = () => {
191
+ const JumpingPopperExample = () => {
192
192
  const [currentPopperIndex, setCurrentPopperIndex] = useState(0);
193
193
  const ref1 = useRef();
194
194
  const ref2 = useRef();
@@ -227,7 +227,7 @@ const JumpingPopper = () => {
227
227
  );
228
228
  };
229
229
 
230
- const RerenderingPopper = () => {
230
+ const RerenderingPopperExample = () => {
231
231
  const [value, setValue] = useState('');
232
232
  const ref = useRef<HTMLButtonElement>(null);
233
233
  return (
@@ -248,20 +248,16 @@ const RerenderingPopper = () => {
248
248
  );
249
249
  };
250
250
 
251
- stories.add('Single point', () => <PopperExample />);
251
+ export const SinglePoint = () => <PopperExample />;
252
252
 
253
- stories.add('All points', () => <PopperExample showAll={true} />);
253
+ export const AllPoints = () => <PopperExample showAll={true} />;
254
254
 
255
- stories.add('Single point, with arrow', () => (
256
- <PopperExample showArrow={true} />
257
- ));
255
+ export const SinglePointWithArrow = () => <PopperExample showArrow={true} />;
258
256
 
259
- stories.add('All points, with arrow', () => (
257
+ export const AllPointsWithArrow = () => (
260
258
  <PopperExample showAll={true} showArrow={true} />
261
- ));
259
+ );
262
260
 
263
- stories.add('Fixed popper, all points', () => (
264
- <PopperFixedExample showAll={true} />
265
- ));
266
- stories.add('Re-rendering popper', () => <RerenderingPopper />);
267
- stories.add('Jumping popper', () => <JumpingPopper />);
261
+ export const FixedPopperAllPoints = () => <PopperFixedExample />;
262
+ export const RerenderingPopper = () => <RerenderingPopperExample />;
263
+ export const JumpingPopper = () => <JumpingPopperExample />;
@@ -6,22 +6,23 @@ import {
6
6
  useMemo,
7
7
  memo,
8
8
  } from 'react';
9
- import type * as React from 'react';
10
- import { assignMultipleRefs } from '../utils/assignRef';
11
- import { PopperProvider, PopperContextProps } from './context';
12
- import { Portal } from '../Portal';
13
-
14
- import {
9
+ import * as React from 'react';
10
+ import type {
15
11
  Placement,
16
12
  Modifier,
17
13
  PositioningStrategy,
18
14
  Instance,
19
15
  Rect,
20
- createPopper,
21
16
  } from '@popperjs/core';
17
+ import { createPopper } from '@popperjs/core';
22
18
  import type { OffsetModifier } from '@popperjs/core/lib/modifiers/offset';
23
19
  import type { ArrowModifier } from '@popperjs/core/lib/modifiers/arrow';
24
20
 
21
+ import { assignMultipleRefs } from '../utils/assignRef';
22
+ import type { PopperContextProps } from './context';
23
+ import { PopperProvider } from './context';
24
+ import { Portal } from '../Portal';
25
+
25
26
  const useEnhancedEffect =
26
27
  typeof window !== 'undefined' ? useLayoutEffect : useEffect;
27
28
 
@@ -123,6 +124,10 @@ export const Popper = memo(
123
124
  };
124
125
  }, [anchorEl, modifiers, placement, strategy, defaultModifiers]);
125
126
 
127
+ useEnhancedEffect(() => {
128
+ popperEngineInstance.current?.forceUpdate();
129
+ }, [props.hidden || props['aria-hidden']]);
130
+
126
131
  const contextValue: PopperContextProps = {
127
132
  arrowRef,
128
133
  };
@@ -1,5 +1,6 @@
1
1
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
+
3
4
  import { usePopperContext } from './context';
4
5
  import { assignRef } from '../utils/assignRef';
5
6
 
@@ -1,4 +1,5 @@
1
- import { createContext, MutableRefObject, useContext } from 'react';
1
+ import type { MutableRefObject } from 'react';
2
+ import { createContext, useContext } from 'react';
2
3
 
3
4
  export interface PopperContextProps {
4
5
  arrowRef: MutableRefObject<HTMLSpanElement | null>;
@@ -1,4 +1,4 @@
1
- import { FC, ReactNode } from 'react';
1
+ import type { FC, ReactNode } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
 
4
4
  export interface PortalProps {
@@ -1,9 +1,13 @@
1
1
  import { useState } from 'react';
2
+
2
3
  import { RadioButton, RadioGroup } from './';
3
- import { storiesOf } from '@storybook/react';
4
4
  // import './styles.css';
5
5
 
6
- const Uncontrolled = (props: { initialValue?: string }) => {
6
+ export default {
7
+ title: 'components/RadioButton',
8
+ };
9
+
10
+ const UncontrolledExample = (props: { initialValue?: string }) => {
7
11
  return (
8
12
  <RadioGroup defaultValue={props.initialValue}>
9
13
  <label>
@@ -30,7 +34,7 @@ const Uncontrolled = (props: { initialValue?: string }) => {
30
34
  );
31
35
  };
32
36
 
33
- const Controlled = () => {
37
+ const ControlledExample = () => {
34
38
  const [value, setValue] = useState(undefined);
35
39
 
36
40
  return (
@@ -64,10 +68,10 @@ const Controlled = () => {
64
68
  );
65
69
  };
66
70
 
67
- const stories = storiesOf('Components/RadioButton', module);
71
+ export const Uncontrolled = () => <UncontrolledExample />;
72
+
73
+ export const UncontrolledWithInitialValue = () => (
74
+ <UncontrolledExample initialValue={'highly disagree'} />
75
+ );
68
76
 
69
- stories.add('uncontrolled', () => <Uncontrolled />);
70
- stories.add('uncontrolled, initial value set', () => (
71
- <Uncontrolled initialValue={'highly disagree'} />
72
- ));
73
- stories.add('controlled', () => <Controlled />);
77
+ export const Controlled = () => <ControlledExample />;
@@ -1,6 +1,8 @@
1
1
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
3
- import { RadioValue, useRadioGroupContext } from './context';
2
+ import * as React from 'react';
3
+
4
+ import type { RadioValue } from './context';
5
+ import { useRadioGroupContext } from './context';
4
6
  import { wrapEvent } from '../utils';
5
7
 
6
8
  export interface RadioButtonProps
@@ -1,7 +1,9 @@
1
- import { forwardRef } from 'react';
2
- import type * as React from 'react';
3
- import { RadioGroupProvider, RadioValue } from './context';
4
- import { useControlledState, useId } from '../hooks';
1
+ import { forwardRef, useId } from 'react';
2
+ import * as React from 'react';
3
+
4
+ import type { RadioValue } from './context';
5
+ import { RadioGroupProvider } from './context';
6
+ import { useControlledState } from '../hooks';
5
7
 
6
8
  export interface RadioGroupProps
7
9
  extends Omit<
@@ -1,5 +1,5 @@
1
1
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
3
 
4
4
  export interface SkipNavProps extends React.HTMLAttributes<HTMLDivElement> {
5
5
  as?: React.ElementType<any>;
@@ -1,9 +1,11 @@
1
1
  import { useState } from 'react';
2
+
2
3
  import { Spinner, SpinnerButton } from './';
3
- import { storiesOf } from '@storybook/react';
4
4
  import './styles.css';
5
5
 
6
- const stories = storiesOf('Components/Spinner', module);
6
+ export default {
7
+ title: 'components/Spinner',
8
+ };
7
9
 
8
10
  const Example = ({ vertical = false }) => {
9
11
  const [value, setValue] = useState(0);
@@ -25,6 +27,5 @@ const Example = ({ vertical = false }) => {
25
27
  );
26
28
  };
27
29
 
28
- stories.add('horizontal', () => <Example />);
29
-
30
- stories.add('vertical', () => <Example vertical={true} />);
30
+ export const Horizontal = () => <Example />;
31
+ export const Vertical = () => <Example vertical={true} />;
@@ -1,5 +1,6 @@
1
1
  import { forwardRef, useState, useRef } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
+
3
4
  import { SpinnerProvider } from './context';
4
5
  import { clamp as clampFunc } from '../utils/clamp';
5
6
  import { wrapEvent, assignMultipleRefs } from '../utils';
@@ -1,5 +1,6 @@
1
1
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
+
3
4
  import { useSpinnerContext } from './context';
4
5
  import { wrapEvent } from '../utils';
5
6
 
@@ -1,9 +1,11 @@
1
1
  import { useState } from 'react';
2
+
2
3
  import { Tab, TabPanel, TabPanels, Tabs, TabList } from './';
3
- import { storiesOf } from '@storybook/react';
4
4
  import './styles.css';
5
5
 
6
- const stories = storiesOf('Components/Tab', module);
6
+ export default {
7
+ title: 'components/Tab',
8
+ };
7
9
 
8
10
  export const ExampleHorizontal = ({ manualActivation = false }) => {
9
11
  const [index, setIndex] = useState(0);
@@ -67,12 +69,12 @@ export const ExampleVertical = ({ manualActivation = false }) => {
67
69
  );
68
70
  };
69
71
 
70
- stories.add('horizontal, controlled', () => <ExampleHorizontal />);
71
- stories.add('horizontal, controlled, manual activation', () => (
72
+ export const HorizontalControlled = () => <ExampleHorizontal />;
73
+ export const HorizontalControlledManualActivation = () => (
72
74
  <ExampleHorizontal manualActivation={true} />
73
- ));
75
+ );
74
76
 
75
- stories.add('vertical, controlled', () => <ExampleVertical />);
76
- stories.add('vertical, controlled, manual activation', () => (
77
+ export const VerticalControlled = () => <ExampleVertical />;
78
+ export const VerticalControlledManualActivation = () => (
77
79
  <ExampleVertical manualActivation={true} />
78
- ));
80
+ );
package/src/Tabs/Tab.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { forwardRef, useRef } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
+
3
4
  import { useTabsContext, useTabListContext } from './context';
4
5
  import { assignMultipleRefs, getCircularIndex, wrapEvent } from '../utils';
5
6
  import { scopeQuery } from './scopeQuery';
@@ -59,9 +60,8 @@ export const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(
59
60
  const navigateIndex = (desiredIndex: number, isLast: boolean) => {
60
61
  const delta = e.key === right || e.key === first ? 1 : -1;
61
62
 
62
- const allTabs = tabListContext.tabsScope.current.queryAllNodes(
63
- scopeQuery
64
- );
63
+ const allTabs =
64
+ tabListContext.tabsScope.current.queryAllNodes(scopeQuery);
65
65
  const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;
66
66
 
67
67
  const nextIndex = getNextIndex(
@@ -1,7 +1,15 @@
1
- import { forwardRef, useRef, useEffect, Children, cloneElement } from 'react';
2
- import type * as React from 'react';
1
+ import {
2
+ forwardRef,
3
+ useRef,
4
+ useEffect,
5
+ Children,
6
+ cloneElement,
7
+ useId,
8
+ } from 'react';
9
+ import * as React from 'react';
10
+
3
11
  import { TabListProvider, useTabsContext } from './context';
4
- import { useScope, useId } from '../hooks';
12
+ import { useScope } from '../hooks';
5
13
  import { assignMultipleRefs } from '../utils';
6
14
 
7
15
  export interface TabListProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -1,5 +1,6 @@
1
1
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
+
3
4
  import { useTabsContext } from './context';
4
5
 
5
6
  export interface TabPanelProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -1,5 +1,5 @@
1
1
  import { forwardRef, Fragment, Children, cloneElement } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
3
 
4
4
  export interface TabPanelsProps {
5
5
  as?: React.ElementType<any>;
package/src/Tabs/Tabs.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { forwardRef, Fragment, useState } from 'react';
2
- import type * as React from 'react';
2
+ import * as React from 'react';
3
+
3
4
  import { TabsProvider } from './context';
4
5
  import { useControlledState } from '../hooks';
5
6
 
@@ -1,5 +1,6 @@
1
1
  import { createContext, useContext } from 'react';
2
- import { Scope } from '../hooks/useScope';
2
+
3
+ import type { Scope } from '../hooks/useScope';
3
4
 
4
5
  // Tabs Component
5
6
  export interface TabsContextProps {
@@ -1,10 +1,14 @@
1
1
  import React, { useRef, forwardRef } from 'react';
2
+
2
3
  import { Tooltip } from './';
3
- import { storiesOf } from '@storybook/react';
4
4
  import { Popper } from '../Popper/Popper';
5
- import { InjectedTooltipProps } from './useTooltip';
5
+ import type { InjectedTooltipProps } from './useTooltip';
6
6
  import './styles.css';
7
7
 
8
+ export default {
9
+ title: 'components/Tooltip',
10
+ };
11
+
8
12
  const StyledTooltip = forwardRef<HTMLDivElement, InjectedTooltipProps>(
9
13
  ({ children, anchorEl, ...props }, ref) => {
10
14
  return (
@@ -53,7 +57,5 @@ const ExampleWithHidingButton = () => {
53
57
  );
54
58
  };
55
59
 
56
- const stories = storiesOf('Components/Tooltip', module);
57
-
58
- stories.add('controlled', () => <Example />);
59
- stories.add('with hiding button', () => <ExampleWithHidingButton />);
60
+ export const Controlled = () => <Example />;
61
+ export const WithHidingButton = () => <ExampleWithHidingButton />;
@@ -1,10 +1,6 @@
1
- import React, {
2
- forwardRef,
3
- cloneElement,
4
- Children,
5
- ReactElement,
6
- RefAttributes,
7
- } from 'react';
1
+ import type { ReactElement, RefAttributes } from 'react';
2
+ import React, { forwardRef, cloneElement, Children } from 'react';
3
+
8
4
  import { useTooltip } from './useTooltip';
9
5
  export type { InjectedTooltipProps } from './useTooltip';
10
6
 
@@ -1,5 +1,5 @@
1
1
  import { createSubscription } from '../utils/createSubscription';
2
- import { StateChart as GenericStateChart } from '../hooks/useReducerMachine';
2
+ import type { StateChart as GenericStateChart } from '../hooks/useReducerMachine';
3
3
 
4
4
  ////////////////////////////////////////////////////////////////////////////////
5
5
  // Timeouts:
@@ -1,7 +1,8 @@
1
- import { useRef, RefAttributes, useEffect, useState } from 'react';
1
+ import type { RefAttributes } from 'react';
2
+ import { useRef, useEffect, useState, useId } from 'react';
3
+
2
4
  import { assignMultipleRefs } from '../utils/assignRef';
3
5
  import { wrapEvent } from '../utils/wrapEvent';
4
- import { useId } from '../hooks/useId';
5
6
  import {
6
7
  send,
7
8
  state,
@@ -43,7 +44,7 @@ export function useTooltip(
43
44
  } = childProps;
44
45
  const anchorEl = useRef<HTMLElement>(null);
45
46
  const [visible, setVisible] = useState(false);
46
- const id = useId('');
47
+ const id = useId();
47
48
 
48
49
  useEffect(() => {
49
50
  subscription.subscribe(() => {
@@ -3,7 +3,6 @@ export * from './useControlledState';
3
3
  export * from './useChildrenCounter';
4
4
  export * from './useFocusReturn';
5
5
  export * from './useFocusState';
6
- export * from './useId';
7
6
  export * from './useOnClickOutside';
8
7
  export * from './useOnKeyDown';
9
8
  export * from './useReducerMachine';