@basic-ui/core 0.0.37 → 0.0.40

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 (324) hide show
  1. package/build/cjs/index.js +85 -84
  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.map +0 -0
  20. package/build/esm/Accordion/scopeQuery.d.ts +0 -0
  21. package/build/esm/Accordion/scopeQuery.js.map +0 -0
  22. package/build/esm/CheckBox/CheckBox.d.ts +1 -1
  23. package/build/esm/CheckBox/CheckBox.js +20 -12
  24. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  25. package/build/esm/CheckBox/index.d.ts +0 -0
  26. package/build/esm/CheckBox/index.js.map +0 -0
  27. package/build/esm/ComboBox/Combobox.d.ts +1 -1
  28. package/build/esm/ComboBox/Combobox.js +55 -48
  29. package/build/esm/ComboBox/Combobox.js.map +1 -1
  30. package/build/esm/ComboBox/ComboboxButton.d.ts +1 -1
  31. package/build/esm/ComboBox/ComboboxButton.js +20 -20
  32. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  33. package/build/esm/ComboBox/ComboboxInput.d.ts +1 -1
  34. package/build/esm/ComboBox/ComboboxInput.js +53 -50
  35. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  36. package/build/esm/ComboBox/ComboboxLabel.d.ts +1 -1
  37. package/build/esm/ComboBox/ComboboxLabel.js +12 -12
  38. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  39. package/build/esm/ComboBox/ComboboxList.d.ts +1 -1
  40. package/build/esm/ComboBox/ComboboxList.js +16 -17
  41. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  42. package/build/esm/ComboBox/ComboboxOption.d.ts +1 -1
  43. package/build/esm/ComboBox/ComboboxOption.js +32 -34
  44. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  45. package/build/esm/ComboBox/ComboboxPopover.d.ts +1 -1
  46. package/build/esm/ComboBox/ComboboxPopover.js +16 -17
  47. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  48. package/build/esm/ComboBox/cities.d.ts +0 -0
  49. package/build/esm/ComboBox/cities.js.map +0 -0
  50. package/build/esm/ComboBox/context.d.ts +3 -3
  51. package/build/esm/ComboBox/context.js +6 -5
  52. package/build/esm/ComboBox/context.js.map +1 -1
  53. package/build/esm/ComboBox/hooks.d.ts +1 -1
  54. package/build/esm/ComboBox/hooks.js +82 -115
  55. package/build/esm/ComboBox/hooks.js.map +1 -1
  56. package/build/esm/ComboBox/index.d.ts +0 -0
  57. package/build/esm/ComboBox/index.js.map +0 -0
  58. package/build/esm/ComboBox/makeHash.d.ts +0 -0
  59. package/build/esm/ComboBox/makeHash.js +3 -3
  60. package/build/esm/ComboBox/makeHash.js.map +1 -1
  61. package/build/esm/ComboBox/scopeQuery.d.ts +0 -0
  62. package/build/esm/ComboBox/scopeQuery.js.map +0 -0
  63. package/build/esm/FocusLock/FocusLock.d.ts +1 -1
  64. package/build/esm/FocusLock/FocusLock.js +18 -16
  65. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  66. package/build/esm/FocusLock/index.d.ts +0 -0
  67. package/build/esm/FocusLock/index.js.map +0 -0
  68. package/build/esm/FocusLock/tabUtils.d.ts +1 -0
  69. package/build/esm/FocusLock/tabUtils.js +14 -2
  70. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  71. package/build/esm/FocusLock/useFocusLock.d.ts +0 -0
  72. package/build/esm/FocusLock/useFocusLock.js +14 -22
  73. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  74. package/build/esm/List/List.d.ts +1 -1
  75. package/build/esm/List/List.js +6 -6
  76. package/build/esm/List/List.js.map +1 -1
  77. package/build/esm/List/ListItem.d.ts +1 -1
  78. package/build/esm/List/ListItem.js +6 -6
  79. package/build/esm/List/ListItem.js.map +1 -1
  80. package/build/esm/List/context.d.ts +0 -0
  81. package/build/esm/List/context.js +3 -3
  82. package/build/esm/List/context.js.map +1 -1
  83. package/build/esm/List/index.d.ts +0 -0
  84. package/build/esm/List/index.js.map +0 -0
  85. package/build/esm/Menu/Menu.d.ts +1 -1
  86. package/build/esm/Menu/Menu.js +31 -23
  87. package/build/esm/Menu/Menu.js.map +1 -1
  88. package/build/esm/Menu/MenuButton.d.ts +1 -1
  89. package/build/esm/Menu/MenuButton.js +29 -25
  90. package/build/esm/Menu/MenuButton.js.map +1 -1
  91. package/build/esm/Menu/MenuItem.d.ts +1 -1
  92. package/build/esm/Menu/MenuItem.js +26 -27
  93. package/build/esm/Menu/MenuItem.js.map +1 -1
  94. package/build/esm/Menu/MenuList.d.ts +1 -1
  95. package/build/esm/Menu/MenuList.js +62 -45
  96. package/build/esm/Menu/MenuList.js.map +1 -1
  97. package/build/esm/Menu/MenuPopover.d.ts +2 -2
  98. package/build/esm/Menu/MenuPopover.js +9 -10
  99. package/build/esm/Menu/MenuPopover.js.map +1 -1
  100. package/build/esm/Menu/context.d.ts +1 -1
  101. package/build/esm/Menu/context.js +11 -8
  102. package/build/esm/Menu/context.js.map +1 -1
  103. package/build/esm/Menu/index.d.ts +0 -0
  104. package/build/esm/Menu/index.js.map +0 -0
  105. package/build/esm/Menu/scope.d.ts +0 -0
  106. package/build/esm/Menu/scope.js.map +0 -0
  107. package/build/esm/Modal/Modal.d.ts +2 -2
  108. package/build/esm/Modal/Modal.js +14 -12
  109. package/build/esm/Modal/Modal.js.map +1 -1
  110. package/build/esm/Modal/ModalBackdrop.d.ts +1 -1
  111. package/build/esm/Modal/ModalBackdrop.js +21 -19
  112. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  113. package/build/esm/Modal/index.d.ts +0 -0
  114. package/build/esm/Modal/index.js.map +0 -0
  115. package/build/esm/Popper/Popper.d.ts +2 -2
  116. package/build/esm/Popper/Popper.js +51 -36
  117. package/build/esm/Popper/Popper.js.map +1 -1
  118. package/build/esm/Popper/PopperArrow.d.ts +1 -1
  119. package/build/esm/Popper/PopperArrow.js +9 -9
  120. package/build/esm/Popper/PopperArrow.js.map +1 -1
  121. package/build/esm/Popper/context.d.ts +1 -1
  122. package/build/esm/Popper/context.js +5 -3
  123. package/build/esm/Popper/context.js.map +1 -1
  124. package/build/esm/Popper/index.d.ts +0 -0
  125. package/build/esm/Popper/index.js.map +0 -0
  126. package/build/esm/Portal/Portal.d.ts +1 -1
  127. package/build/esm/Portal/Portal.js +6 -5
  128. package/build/esm/Portal/Portal.js.map +1 -1
  129. package/build/esm/Portal/index.d.ts +0 -0
  130. package/build/esm/Portal/index.js.map +0 -0
  131. package/build/esm/RadioButton/RadioButton.d.ts +2 -2
  132. package/build/esm/RadioButton/RadioButton.js +13 -13
  133. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  134. package/build/esm/RadioButton/RadioGroup.d.ts +2 -2
  135. package/build/esm/RadioButton/RadioGroup.js +25 -18
  136. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  137. package/build/esm/RadioButton/context.d.ts +0 -0
  138. package/build/esm/RadioButton/context.js +6 -5
  139. package/build/esm/RadioButton/context.js.map +1 -1
  140. package/build/esm/RadioButton/index.d.ts +0 -0
  141. package/build/esm/RadioButton/index.js.map +0 -0
  142. package/build/esm/SkipNav/SkipNav.d.ts +1 -1
  143. package/build/esm/SkipNav/SkipNav.js +6 -6
  144. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  145. package/build/esm/SkipNav/index.d.ts +0 -0
  146. package/build/esm/SkipNav/index.js.map +0 -0
  147. package/build/esm/Spinner/Spinner.d.ts +1 -1
  148. package/build/esm/Spinner/Spinner.js +42 -31
  149. package/build/esm/Spinner/Spinner.js.map +1 -1
  150. package/build/esm/Spinner/SpinnerButton.d.ts +1 -1
  151. package/build/esm/Spinner/SpinnerButton.js +12 -12
  152. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  153. package/build/esm/Spinner/context.d.ts +0 -0
  154. package/build/esm/Spinner/context.js +6 -5
  155. package/build/esm/Spinner/context.js.map +1 -1
  156. package/build/esm/Spinner/index.d.ts +0 -0
  157. package/build/esm/Spinner/index.js.map +0 -0
  158. package/build/esm/Tabs/Tab.d.ts +1 -1
  159. package/build/esm/Tabs/Tab.js +30 -29
  160. package/build/esm/Tabs/Tab.js.map +1 -1
  161. package/build/esm/Tabs/TabList.d.ts +1 -1
  162. package/build/esm/Tabs/TabList.js +27 -23
  163. package/build/esm/Tabs/TabList.js.map +1 -1
  164. package/build/esm/Tabs/TabPanel.d.ts +1 -1
  165. package/build/esm/Tabs/TabPanel.js +13 -12
  166. package/build/esm/Tabs/TabPanel.js.map +1 -1
  167. package/build/esm/Tabs/TabPanels.d.ts +1 -1
  168. package/build/esm/Tabs/TabPanels.js +14 -12
  169. package/build/esm/Tabs/TabPanels.js.map +1 -1
  170. package/build/esm/Tabs/Tabs.d.ts +1 -1
  171. package/build/esm/Tabs/Tabs.js +28 -14
  172. package/build/esm/Tabs/Tabs.js.map +1 -1
  173. package/build/esm/Tabs/context.d.ts +1 -1
  174. package/build/esm/Tabs/context.js +12 -10
  175. package/build/esm/Tabs/context.js.map +1 -1
  176. package/build/esm/Tabs/index.d.ts +0 -0
  177. package/build/esm/Tabs/index.js.map +0 -0
  178. package/build/esm/Tabs/scopeQuery.d.ts +0 -0
  179. package/build/esm/Tabs/scopeQuery.js.map +0 -0
  180. package/build/esm/Tooltip/Tooltip.d.ts +2 -1
  181. package/build/esm/Tooltip/Tooltip.js +17 -15
  182. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  183. package/build/esm/Tooltip/index.d.ts +0 -0
  184. package/build/esm/Tooltip/index.js.map +0 -0
  185. package/build/esm/Tooltip/stateMachine.d.ts +0 -0
  186. package/build/esm/Tooltip/stateMachine.js +56 -80
  187. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  188. package/build/esm/Tooltip/useTooltip.d.ts +1 -1
  189. package/build/esm/Tooltip/useTooltip.js +33 -32
  190. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  191. package/build/esm/hooks/index.d.ts +0 -1
  192. package/build/esm/hooks/index.js +0 -1
  193. package/build/esm/hooks/index.js.map +1 -1
  194. package/build/esm/hooks/useAutoFocus.d.ts +0 -0
  195. package/build/esm/hooks/useAutoFocus.js +6 -2
  196. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  197. package/build/esm/hooks/useChildrenCounter.d.ts +1 -1
  198. package/build/esm/hooks/useChildrenCounter.js +6 -4
  199. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  200. package/build/esm/hooks/useControlledState.d.ts +1 -1
  201. package/build/esm/hooks/useControlledState.js +7 -2
  202. package/build/esm/hooks/useControlledState.js.map +1 -1
  203. package/build/esm/hooks/useFocusReturn.d.ts +2 -1
  204. package/build/esm/hooks/useFocusReturn.js +25 -14
  205. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  206. package/build/esm/hooks/useFocusState.d.ts +0 -0
  207. package/build/esm/hooks/useFocusState.js +13 -9
  208. package/build/esm/hooks/useFocusState.js.map +1 -1
  209. package/build/esm/hooks/useGestureHandlers.d.ts +0 -0
  210. package/build/esm/hooks/useGestureHandlers.js +59 -63
  211. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  212. package/build/esm/hooks/useId.d.ts +0 -0
  213. package/build/esm/hooks/useId.js +0 -0
  214. package/build/esm/hooks/useId.js.map +0 -0
  215. package/build/esm/hooks/useMeasure.d.ts +0 -0
  216. package/build/esm/hooks/useMeasure.js +13 -7
  217. package/build/esm/hooks/useMeasure.js.map +1 -1
  218. package/build/esm/hooks/useOnClickOutside.d.ts +0 -0
  219. package/build/esm/hooks/useOnClickOutside.js +5 -4
  220. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  221. package/build/esm/hooks/useOnKeyDown.d.ts +0 -0
  222. package/build/esm/hooks/useOnKeyDown.js +4 -3
  223. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  224. package/build/esm/hooks/useReducerMachine.d.ts +1 -1
  225. package/build/esm/hooks/useReducerMachine.js +13 -10
  226. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  227. package/build/esm/hooks/useRemoveBodyScroll.d.ts +0 -0
  228. package/build/esm/hooks/useRemoveBodyScroll.js +14 -21
  229. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  230. package/build/esm/hooks/useScope.d.ts +1 -1
  231. package/build/esm/hooks/useScope.js +10 -12
  232. package/build/esm/hooks/useScope.js.map +1 -1
  233. package/build/esm/hooks/useThrottle.d.ts +0 -0
  234. package/build/esm/hooks/useThrottle.js +10 -5
  235. package/build/esm/hooks/useThrottle.js.map +1 -1
  236. package/build/esm/index.d.ts +0 -0
  237. package/build/esm/index.js.map +0 -0
  238. package/build/esm/utils/assignRef.d.ts +1 -1
  239. package/build/esm/utils/assignRef.js +7 -3
  240. package/build/esm/utils/assignRef.js.map +1 -1
  241. package/build/esm/utils/clamp.d.ts +0 -0
  242. package/build/esm/utils/clamp.js.map +0 -0
  243. package/build/esm/utils/createSubscription.d.ts +0 -0
  244. package/build/esm/utils/createSubscription.js +7 -5
  245. package/build/esm/utils/createSubscription.js.map +1 -1
  246. package/build/esm/utils/getCircularIndex.d.ts +0 -0
  247. package/build/esm/utils/getCircularIndex.js.map +0 -0
  248. package/build/esm/utils/index.d.ts +0 -0
  249. package/build/esm/utils/index.js.map +0 -0
  250. package/build/esm/utils/rubberBandClamp.d.ts +0 -0
  251. package/build/esm/utils/rubberBandClamp.js +5 -2
  252. package/build/esm/utils/rubberBandClamp.js.map +1 -1
  253. package/build/esm/utils/wrapEvent.d.ts +0 -0
  254. package/build/esm/utils/wrapEvent.js +7 -3
  255. package/build/esm/utils/wrapEvent.js.map +1 -1
  256. package/build/tsconfig.tsbuildinfo +1 -7069
  257. package/package.json +13 -13
  258. package/src/Accordion/Accordion.story.tsx +1 -0
  259. package/src/Accordion/Accordion.tsx +4 -2
  260. package/src/Accordion/AccordionBody.tsx +4 -4
  261. package/src/Accordion/AccordionHeader.tsx +7 -8
  262. package/src/Accordion/AccordionItem.tsx +5 -4
  263. package/src/Accordion/context.ts +2 -1
  264. package/src/CheckBox/CheckBox.tsx +2 -1
  265. package/src/ComboBox/ComboBox.story.tsx +2 -1
  266. package/src/ComboBox/Combobox.tsx +9 -11
  267. package/src/ComboBox/ComboboxButton.tsx +4 -9
  268. package/src/ComboBox/ComboboxInput.tsx +2 -1
  269. package/src/ComboBox/ComboboxLabel.tsx +2 -1
  270. package/src/ComboBox/ComboboxList.tsx +2 -1
  271. package/src/ComboBox/ComboboxOption.tsx +1 -1
  272. package/src/ComboBox/ComboboxPopover.tsx +2 -1
  273. package/src/ComboBox/context.ts +4 -3
  274. package/src/ComboBox/hooks.tsx +6 -9
  275. package/src/FocusLock/FocusLock.tsx +2 -1
  276. package/src/FocusLock/tabUtils.ts +12 -0
  277. package/src/FocusLock/useFocusLock.ts +5 -11
  278. package/src/List/List.tsx +1 -1
  279. package/src/List/ListItem.tsx +1 -1
  280. package/src/Menu/Menu.story.tsx +6 -5
  281. package/src/Menu/Menu.tsx +5 -4
  282. package/src/Menu/MenuButton.tsx +7 -11
  283. package/src/Menu/MenuItem.tsx +6 -7
  284. package/src/Menu/MenuList.tsx +4 -8
  285. package/src/Menu/MenuPopover.tsx +4 -2
  286. package/src/Menu/context.ts +2 -1
  287. package/src/Modal/Modal.story.tsx +20 -5
  288. package/src/Modal/Modal.tsx +6 -4
  289. package/src/Modal/ModalBackdrop.tsx +2 -1
  290. package/src/Modal/NavDrawer.story.tsx +3 -3
  291. package/src/Popper/Popper.story.tsx +3 -4
  292. package/src/Popper/Popper.tsx +12 -7
  293. package/src/Popper/PopperArrow.tsx +2 -1
  294. package/src/Popper/context.ts +2 -1
  295. package/src/Portal/Portal.tsx +1 -1
  296. package/src/RadioButton/RadioButton.story.tsx +1 -0
  297. package/src/RadioButton/RadioButton.tsx +4 -2
  298. package/src/RadioButton/RadioGroup.tsx +6 -4
  299. package/src/SkipNav/SkipNav.tsx +1 -1
  300. package/src/Spinner/Spinner.story.tsx +1 -0
  301. package/src/Spinner/Spinner.tsx +2 -1
  302. package/src/Spinner/SpinnerButton.tsx +2 -1
  303. package/src/Tabs/Tab.story.tsx +1 -0
  304. package/src/Tabs/Tab.tsx +4 -4
  305. package/src/Tabs/TabList.tsx +11 -3
  306. package/src/Tabs/TabPanel.tsx +2 -1
  307. package/src/Tabs/TabPanels.tsx +1 -1
  308. package/src/Tabs/Tabs.tsx +2 -1
  309. package/src/Tabs/context.ts +2 -1
  310. package/src/Tooltip/Tooltip.story.tsx +2 -1
  311. package/src/Tooltip/Tooltip.tsx +3 -7
  312. package/src/Tooltip/stateMachine.ts +1 -1
  313. package/src/Tooltip/useTooltip.ts +6 -4
  314. package/src/hooks/index.ts +0 -1
  315. package/src/hooks/useAutoFocus.ts +9 -1
  316. package/src/hooks/useChildrenCounter.ts +2 -1
  317. package/src/hooks/useControlledState.ts +3 -1
  318. package/src/hooks/useFocusReturn.ts +33 -13
  319. package/src/hooks/useFocusState.ts +1 -0
  320. package/src/hooks/useReducerMachine.ts +2 -1
  321. package/src/hooks/useRemoveBodyScroll.ts +10 -18
  322. package/src/hooks/useScope.ts +2 -1
  323. package/src/utils/assignRef.ts +1 -1
  324. package/src/hooks/useId.ts +0 -18
@@ -1,5 +1,6 @@
1
1
  import { useState } from 'react';
2
2
  import { useSpring, animated } from 'react-spring';
3
+
3
4
  import { Modal, ModalBackdrop } from './';
4
5
  import { Portal } from '../Portal';
5
6
  import './styles.css';
@@ -65,9 +66,8 @@ const Wrapper = ({ children }) => {
65
66
 
66
67
  const SimpleModalControlledAnimated = () => {
67
68
  const [open, setOpen] = useState(false);
68
- const [pointerEvents, setPointerEvents] = useState<PointerEventsProperty>(
69
- 'none'
70
- );
69
+ const [pointerEvents, setPointerEvents] =
70
+ useState<PointerEventsProperty>('none');
71
71
  const [{ transformX, opacity }, set] = useSpring(() => ({
72
72
  transformX: -120,
73
73
  opacity: 0,
@@ -1,5 +1,6 @@
1
1
  import { useRef, useState, useEffect } from 'react';
2
2
  import { useSpring, animated } from 'react-spring';
3
+
3
4
  import { Popper } from './Popper';
4
5
  import { PopperArrow } from './PopperArrow';
5
6
  import './styles.css';
@@ -160,9 +161,7 @@ function Menu() {
160
161
  );
161
162
  }
162
163
 
163
- const PopperFixedExample = ({ showAll = false, showArrow = false }) => {
164
- const ref = useRef<any>(null);
165
-
164
+ const PopperFixedExample = () => {
166
165
  return (
167
166
  <>
168
167
  <div
@@ -259,6 +258,6 @@ export const AllPointsWithArrow = () => (
259
258
  <PopperExample showAll={true} showArrow={true} />
260
259
  );
261
260
 
262
- export const FixedPopperAllPoints = () => <PopperFixedExample showAll={true} />;
261
+ export const FixedPopperAllPoints = () => <PopperFixedExample />;
263
262
  export const RerenderingPopper = () => <RerenderingPopperExample />;
264
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,4 +1,5 @@
1
1
  import { useState } from 'react';
2
+
2
3
  import { RadioButton, RadioGroup } from './';
3
4
  // import './styles.css';
4
5
 
@@ -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,4 +1,5 @@
1
1
  import { useState } from 'react';
2
+
2
3
  import { Spinner, SpinnerButton } from './';
3
4
  import './styles.css';
4
5
 
@@ -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,4 +1,5 @@
1
1
  import { useState } from 'react';
2
+
2
3
  import { Tab, TabPanel, TabPanels, Tabs, TabList } from './';
3
4
  import './styles.css';
4
5
 
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,7 +1,8 @@
1
1
  import React, { useRef, forwardRef } from 'react';
2
+
2
3
  import { Tooltip } from './';
3
4
  import { Popper } from '../Popper/Popper';
4
- import { InjectedTooltipProps } from './useTooltip';
5
+ import type { InjectedTooltipProps } from './useTooltip';
5
6
  import './styles.css';
6
7
 
7
8
  export default {
@@ -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(() => {
@@ -104,7 +105,8 @@ export function useTooltip(
104
105
  {
105
106
  ...childProps,
106
107
  ref: assignMultipleRefs(childRef, anchorEl),
107
- ...(visible && { 'aria-describedby': tooltipId }),
108
+ ...(visible &&
109
+ !childProps['aria-label'] && { 'aria-describedby': tooltipId }),
108
110
  onMouseEnter: wrapEvent(onMouseEnter, handleMouseEnter),
109
111
  onMouseLeave: wrapEvent(onMouseLeave, handleMouseLeave),
110
112
  onMouseMove: wrapEvent(onMouseMove, handleMouseMove),
@@ -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';
@@ -1,12 +1,20 @@
1
1
  import { useEffect } from 'react';
2
2
 
3
+ import { focusOnChildNode } from '../FocusLock/tabUtils';
4
+
3
5
  export function useAutoFocus(
4
6
  open: boolean,
5
7
  elementRef: React.MutableRefObject<HTMLElement | null>
6
8
  ) {
7
9
  useEffect(() => {
8
10
  if (open) {
9
- elementRef.current && elementRef.current.focus();
11
+ // We will only autoFocus on the first child if the currently active element isn't already trapped inside the modal
12
+ if (
13
+ elementRef.current &&
14
+ !elementRef.current.contains(document.activeElement)
15
+ ) {
16
+ focusOnChildNode(elementRef.current, 0);
17
+ }
10
18
  }
11
19
  // eslint-disable-next-line react-hooks/exhaustive-deps
12
20
  }, [open]);
@@ -1,4 +1,5 @@
1
- import { MutableRefObject, useEffect } from 'react';
1
+ import type { MutableRefObject } from 'react';
2
+ import { useEffect } from 'react';
2
3
 
3
4
  export function useChildrenCounterParent<T>(
4
5
  itemsRef: MutableRefObject<T[] & { isNewRender?: boolean }>
@@ -1,5 +1,7 @@
1
1
  import { useRef, useState } from 'react';
2
- import { wrapEvent, CustomEventHandler } from '../utils';
2
+
3
+ import type { CustomEventHandler } from '../utils';
4
+ import { wrapEvent } from '../utils';
3
5
 
4
6
  export function useControlledState<
5
7
  V,
@@ -1,23 +1,43 @@
1
+ import type { MutableRefObject } from 'react';
1
2
  import { useEffect, useRef } from 'react';
2
3
 
3
- export function useFocusReturn(open: boolean) {
4
- const previousFocusRef = useRef<Element | null>(null);
4
+ export function useFocusReturn(
5
+ open: boolean,
6
+ rootEl: MutableRefObject<HTMLElement | null>
7
+ ) {
8
+ const previousFocusRef = useRef<HTMLElement | null>(
9
+ (() => {
10
+ if (
11
+ open &&
12
+ typeof document !== 'undefined' &&
13
+ document.activeElement instanceof HTMLElement
14
+ ) {
15
+ return document.activeElement;
16
+ }
17
+ return null;
18
+ })()
19
+ );
5
20
 
6
21
  useEffect(() => {
7
22
  if (open) {
8
23
  // once opened, keep track of the element that triggered
9
24
  // the Modal opening
10
- previousFocusRef.current = document.activeElement;
11
- }
25
+ if (
26
+ !previousFocusRef.current &&
27
+ document.activeElement instanceof HTMLElement &&
28
+ !rootEl.current?.contains(document.activeElement)
29
+ ) {
30
+ previousFocusRef.current = document.activeElement;
31
+ }
12
32
 
13
- return () => {
14
- // on unmount, return focus to that element
15
- const previousFocus = previousFocusRef.current;
16
- requestAnimationFrame(() => {
17
- if (previousFocus) {
18
- (previousFocus as HTMLElement).focus();
33
+ const rootElement = rootEl.current;
34
+ const previousElement = previousFocusRef.current;
35
+ return () => {
36
+ // on unmount, return focus to that element
37
+ if (previousElement && !rootElement?.contains(document.activeElement)) {
38
+ previousElement.focus({ preventScroll: true });
19
39
  }
20
- });
21
- };
22
- }, [open]);
40
+ };
41
+ }
42
+ }, [open, rootEl]);
23
43
  }
@@ -1,4 +1,5 @@
1
1
  import { useState } from 'react';
2
+
2
3
  import { wrapEvent } from '../utils/wrapEvent';
3
4
 
4
5
  export function useFocusState<T>(
@@ -1,4 +1,5 @@
1
- import { useReducer, Reducer } from 'react';
1
+ import type { Reducer } from 'react';
2
+ import { useReducer } from 'react';
2
3
 
3
4
  export interface StateChart<STypes extends string, ATypes extends string> {
4
5
  initial: STypes;
@@ -1,37 +1,29 @@
1
1
  import { useEffect } from 'react';
2
2
 
3
+ let scrollBodyCount = 0;
3
4
  export function useRemoveBodyScroll(open: boolean) {
4
5
  useEffect(() => {
5
6
  if (open) {
6
- const locksCount = ((window as any).__SCROLL_BODY_COUNT__ || 0) + 1;
7
+ scrollBodyCount += 1;
7
8
 
8
9
  // calculate scrollbar width if mounting the first scroll lock
9
10
  let scrollBarWidth = 0;
10
- if (locksCount === 1) {
11
+ if (scrollBodyCount === 1) {
11
12
  scrollBarWidth = window.innerWidth - document.body.clientWidth;
12
13
  }
13
14
 
14
15
  document.body.style.overflow = 'hidden';
15
16
  if (scrollBarWidth > 0) {
16
- document.body.style.paddingRight = `${scrollBarWidth}px`;
17
+ document.body.style.marginRight = `${scrollBarWidth}px`;
17
18
  }
18
19
 
19
- // save current lock count in global object
20
- (window as any).__SCROLL_BODY_COUNT__ = locksCount;
21
- }
22
-
23
- return () => {
24
- if (open) {
25
- const locksCount = (window as any).__SCROLL_BODY_COUNT__ - 1;
26
-
27
- if (locksCount === 0) {
20
+ return () => {
21
+ scrollBodyCount -= 1;
22
+ if (scrollBodyCount === 0) {
28
23
  document.body.style.overflow = '';
29
- document.body.style.paddingRight = '';
24
+ document.body.style.marginRight = '';
30
25
  }
31
-
32
- // save current lock count in global object
33
- (window as any).__SCROLL_BODY_COUNT__ = locksCount;
34
- }
35
- };
26
+ };
27
+ }
36
28
  }, [open]);
37
29
  }
@@ -1,4 +1,5 @@
1
- import { useRef, MutableRefObject } from 'react';
1
+ import type { MutableRefObject } from 'react';
2
+ import { useRef } from 'react';
2
3
 
3
4
  export type ScopeMatcherFn = (
4
5
  nodeType: string,
@@ -1,4 +1,4 @@
1
- import { LegacyRef, MutableRefObject, Ref, RefCallback } from 'react';
1
+ import type { LegacyRef, MutableRefObject, Ref, RefCallback } from 'react';
2
2
 
3
3
  export function assignRef<T>(
4
4
  ref: LegacyRef<T> | MutableRefObject<T> | Ref<T> | null | undefined,
@@ -1,18 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- // Could use UUID but if we hit 9,007,199,254,740,991 unique components over
4
- // the lifetime of the app before it gets reloaded, I mean ... come on.
5
- // I don't even know what xillion that is.
6
- // /me googles
7
- // Oh duh, quadrillion. Nine quadrillion components. I think we're okay.
8
- let id = 0;
9
- const genId = () => `${++id}`;
10
-
11
- export function useId(): string | undefined;
12
- export function useId(preferredId: string): string;
13
- export function useId(preferredId: string | undefined): string | undefined;
14
- export function useId(preferredId?: string): string | undefined {
15
- const [id, setId] = useState<string | undefined>(preferredId);
16
- useEffect(() => setId(genId()), []);
17
- return id;
18
- }