@basic-ui/core 0.0.38 → 0.0.41

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 (266) hide show
  1. package/build/cjs/index.js +1 -1
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/Accordion/Accordion.d.ts +7 -7
  4. package/build/esm/Accordion/Accordion.js +22 -17
  5. package/build/esm/Accordion/Accordion.js.map +1 -1
  6. package/build/esm/Accordion/AccordionBody.d.ts +5 -5
  7. package/build/esm/Accordion/AccordionBody.js +23 -15
  8. package/build/esm/Accordion/AccordionBody.js.map +1 -1
  9. package/build/esm/Accordion/AccordionHeader.d.ts +6 -6
  10. package/build/esm/Accordion/AccordionHeader.js +45 -31
  11. package/build/esm/Accordion/AccordionHeader.js.map +1 -1
  12. package/build/esm/Accordion/AccordionItem.d.ts +7 -7
  13. package/build/esm/Accordion/AccordionItem.js +16 -16
  14. package/build/esm/Accordion/AccordionItem.js.map +1 -1
  15. package/build/esm/Accordion/context.d.ts +4 -4
  16. package/build/esm/Accordion/context.js +12 -10
  17. package/build/esm/Accordion/context.js.map +1 -1
  18. package/build/esm/CheckBox/CheckBox.d.ts +6 -6
  19. package/build/esm/CheckBox/CheckBox.js +19 -12
  20. package/build/esm/CheckBox/CheckBox.js.map +1 -1
  21. package/build/esm/ComboBox/Combobox.d.ts +10 -10
  22. package/build/esm/ComboBox/Combobox.js +52 -46
  23. package/build/esm/ComboBox/Combobox.js.map +1 -1
  24. package/build/esm/ComboBox/ComboboxButton.d.ts +8 -8
  25. package/build/esm/ComboBox/ComboboxButton.js +19 -20
  26. package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
  27. package/build/esm/ComboBox/ComboboxInput.d.ts +10 -10
  28. package/build/esm/ComboBox/ComboboxInput.js +52 -50
  29. package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
  30. package/build/esm/ComboBox/ComboboxLabel.d.ts +5 -5
  31. package/build/esm/ComboBox/ComboboxLabel.js +11 -12
  32. package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
  33. package/build/esm/ComboBox/ComboboxList.d.ts +6 -6
  34. package/build/esm/ComboBox/ComboboxList.js +15 -17
  35. package/build/esm/ComboBox/ComboboxList.js.map +1 -1
  36. package/build/esm/ComboBox/ComboboxOption.d.ts +7 -7
  37. package/build/esm/ComboBox/ComboboxOption.js +31 -34
  38. package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
  39. package/build/esm/ComboBox/ComboboxPopover.d.ts +8 -8
  40. package/build/esm/ComboBox/ComboboxPopover.js +15 -17
  41. package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
  42. package/build/esm/ComboBox/context.d.ts +13 -13
  43. package/build/esm/ComboBox/context.js +6 -5
  44. package/build/esm/ComboBox/context.js.map +1 -1
  45. package/build/esm/ComboBox/hooks.d.ts +4 -4
  46. package/build/esm/ComboBox/hooks.js +82 -115
  47. package/build/esm/ComboBox/hooks.js.map +1 -1
  48. package/build/esm/ComboBox/makeHash.js +3 -3
  49. package/build/esm/ComboBox/makeHash.js.map +1 -1
  50. package/build/esm/FocusLock/FocusLock.d.ts +7 -7
  51. package/build/esm/FocusLock/FocusLock.js +17 -16
  52. package/build/esm/FocusLock/FocusLock.js.map +1 -1
  53. package/build/esm/FocusLock/tabUtils.js +4 -4
  54. package/build/esm/FocusLock/tabUtils.js.map +1 -1
  55. package/build/esm/FocusLock/useFocusLock.d.ts +4 -4
  56. package/build/esm/FocusLock/useFocusLock.js +10 -11
  57. package/build/esm/FocusLock/useFocusLock.js.map +1 -1
  58. package/build/esm/List/List.d.ts +6 -6
  59. package/build/esm/List/List.js +5 -6
  60. package/build/esm/List/List.js.map +1 -1
  61. package/build/esm/List/ListItem.d.ts +6 -6
  62. package/build/esm/List/ListItem.js +5 -6
  63. package/build/esm/List/ListItem.js.map +1 -1
  64. package/build/esm/List/context.js +3 -3
  65. package/build/esm/List/context.js.map +1 -1
  66. package/build/esm/Menu/Menu.d.ts +6 -6
  67. package/build/esm/Menu/Menu.js +29 -21
  68. package/build/esm/Menu/Menu.js.map +1 -1
  69. package/build/esm/Menu/MenuButton.d.ts +10 -10
  70. package/build/esm/Menu/MenuButton.js +27 -24
  71. package/build/esm/Menu/MenuButton.js.map +1 -1
  72. package/build/esm/Menu/MenuItem.d.ts +6 -6
  73. package/build/esm/Menu/MenuItem.js +23 -24
  74. package/build/esm/Menu/MenuItem.js.map +1 -1
  75. package/build/esm/Menu/MenuList.d.ts +5 -5
  76. package/build/esm/Menu/MenuList.js +61 -45
  77. package/build/esm/Menu/MenuList.js.map +1 -1
  78. package/build/esm/Menu/MenuPopover.d.ts +6 -6
  79. package/build/esm/Menu/MenuPopover.js +8 -10
  80. package/build/esm/Menu/MenuPopover.js.map +1 -1
  81. package/build/esm/Menu/context.d.ts +2 -2
  82. package/build/esm/Menu/context.js +11 -8
  83. package/build/esm/Menu/context.js.map +1 -1
  84. package/build/esm/Modal/Modal.d.ts +6 -7
  85. package/build/esm/Modal/Modal.js +11 -10
  86. package/build/esm/Modal/Modal.js.map +1 -1
  87. package/build/esm/Modal/ModalBackdrop.d.ts +6 -6
  88. package/build/esm/Modal/ModalBackdrop.js +20 -19
  89. package/build/esm/Modal/ModalBackdrop.js.map +1 -1
  90. package/build/esm/Popper/Popper.d.ts +8 -8
  91. package/build/esm/Popper/Popper.js +46 -37
  92. package/build/esm/Popper/Popper.js.map +1 -1
  93. package/build/esm/Popper/PopperArrow.d.ts +5 -5
  94. package/build/esm/Popper/PopperArrow.js +8 -9
  95. package/build/esm/Popper/PopperArrow.js.map +1 -1
  96. package/build/esm/Popper/context.d.ts +1 -1
  97. package/build/esm/Popper/context.js +5 -3
  98. package/build/esm/Popper/context.js.map +1 -1
  99. package/build/esm/Portal/Portal.d.ts +1 -1
  100. package/build/esm/Portal/Portal.js +6 -5
  101. package/build/esm/Portal/Portal.js.map +1 -1
  102. package/build/esm/RadioButton/RadioButton.d.ts +7 -7
  103. package/build/esm/RadioButton/RadioButton.js +12 -13
  104. package/build/esm/RadioButton/RadioButton.js.map +1 -1
  105. package/build/esm/RadioButton/RadioGroup.d.ts +8 -8
  106. package/build/esm/RadioButton/RadioGroup.js +22 -16
  107. package/build/esm/RadioButton/RadioGroup.js.map +1 -1
  108. package/build/esm/RadioButton/context.d.ts +2 -2
  109. package/build/esm/RadioButton/context.js +6 -5
  110. package/build/esm/RadioButton/context.js.map +1 -1
  111. package/build/esm/SkipNav/SkipNav.d.ts +6 -6
  112. package/build/esm/SkipNav/SkipNav.js +5 -6
  113. package/build/esm/SkipNav/SkipNav.js.map +1 -1
  114. package/build/esm/Spinner/Spinner.d.ts +7 -7
  115. package/build/esm/Spinner/Spinner.js +41 -31
  116. package/build/esm/Spinner/Spinner.js.map +1 -1
  117. package/build/esm/Spinner/SpinnerButton.d.ts +6 -6
  118. package/build/esm/Spinner/SpinnerButton.js +11 -12
  119. package/build/esm/Spinner/SpinnerButton.js.map +1 -1
  120. package/build/esm/Spinner/context.d.ts +2 -2
  121. package/build/esm/Spinner/context.js +6 -5
  122. package/build/esm/Spinner/context.js.map +1 -1
  123. package/build/esm/Tabs/Tab.d.ts +6 -6
  124. package/build/esm/Tabs/Tab.js +29 -29
  125. package/build/esm/Tabs/Tab.js.map +1 -1
  126. package/build/esm/Tabs/TabList.d.ts +6 -6
  127. package/build/esm/Tabs/TabList.js +24 -21
  128. package/build/esm/Tabs/TabList.js.map +1 -1
  129. package/build/esm/Tabs/TabPanel.d.ts +6 -6
  130. package/build/esm/Tabs/TabPanel.js +12 -12
  131. package/build/esm/Tabs/TabPanel.js.map +1 -1
  132. package/build/esm/Tabs/TabPanels.d.ts +5 -5
  133. package/build/esm/Tabs/TabPanels.js +13 -12
  134. package/build/esm/Tabs/TabPanels.js.map +1 -1
  135. package/build/esm/Tabs/Tabs.d.ts +6 -6
  136. package/build/esm/Tabs/Tabs.js +27 -14
  137. package/build/esm/Tabs/Tabs.js.map +1 -1
  138. package/build/esm/Tabs/context.d.ts +3 -3
  139. package/build/esm/Tabs/context.js +12 -10
  140. package/build/esm/Tabs/context.js.map +1 -1
  141. package/build/esm/Tooltip/Tooltip.d.ts +7 -7
  142. package/build/esm/Tooltip/Tooltip.js +18 -16
  143. package/build/esm/Tooltip/Tooltip.js.map +1 -1
  144. package/build/esm/Tooltip/stateMachine.js +56 -80
  145. package/build/esm/Tooltip/stateMachine.js.map +1 -1
  146. package/build/esm/Tooltip/useTooltip.d.ts +7 -7
  147. package/build/esm/Tooltip/useTooltip.js +32 -30
  148. package/build/esm/Tooltip/useTooltip.js.map +1 -1
  149. package/build/esm/hooks/useAutoFocus.d.ts +2 -2
  150. package/build/esm/hooks/useAutoFocus.js +1 -1
  151. package/build/esm/hooks/useAutoFocus.js.map +1 -1
  152. package/build/esm/hooks/useChildrenCounter.d.ts +1 -1
  153. package/build/esm/hooks/useChildrenCounter.js +6 -4
  154. package/build/esm/hooks/useChildrenCounter.js.map +1 -1
  155. package/build/esm/hooks/useControlledState.d.ts +3 -7
  156. package/build/esm/hooks/useControlledState.js +7 -2
  157. package/build/esm/hooks/useControlledState.js.map +1 -1
  158. package/build/esm/hooks/useFocusReturn.d.ts +1 -1
  159. package/build/esm/hooks/useFocusReturn.js +6 -6
  160. package/build/esm/hooks/useFocusReturn.js.map +1 -1
  161. package/build/esm/hooks/useFocusState.d.ts +3 -3
  162. package/build/esm/hooks/useFocusState.js +13 -9
  163. package/build/esm/hooks/useFocusState.js.map +1 -1
  164. package/build/esm/hooks/useGestureHandlers.d.ts +5 -5
  165. package/build/esm/hooks/useGestureHandlers.js +59 -63
  166. package/build/esm/hooks/useGestureHandlers.js.map +1 -1
  167. package/build/esm/hooks/useMeasure.d.ts +2 -2
  168. package/build/esm/hooks/useMeasure.js +13 -7
  169. package/build/esm/hooks/useMeasure.js.map +1 -1
  170. package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
  171. package/build/esm/hooks/useOnClickOutside.js +5 -4
  172. package/build/esm/hooks/useOnClickOutside.js.map +1 -1
  173. package/build/esm/hooks/useOnKeyDown.js +4 -3
  174. package/build/esm/hooks/useOnKeyDown.js.map +1 -1
  175. package/build/esm/hooks/useReducerMachine.d.ts +1 -1
  176. package/build/esm/hooks/useReducerMachine.js +13 -10
  177. package/build/esm/hooks/useReducerMachine.js.map +1 -1
  178. package/build/esm/hooks/useRemoveBodyScroll.js +4 -4
  179. package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
  180. package/build/esm/hooks/useScope.d.ts +1 -1
  181. package/build/esm/hooks/useScope.js +10 -12
  182. package/build/esm/hooks/useScope.js.map +1 -1
  183. package/build/esm/hooks/useThrottle.js +10 -5
  184. package/build/esm/hooks/useThrottle.js.map +1 -1
  185. package/build/esm/utils/assignRef.d.ts +1 -1
  186. package/build/esm/utils/assignRef.js +7 -3
  187. package/build/esm/utils/assignRef.js.map +1 -1
  188. package/build/esm/utils/createSubscription.js +7 -5
  189. package/build/esm/utils/createSubscription.js.map +1 -1
  190. package/build/esm/utils/rubberBandClamp.js +5 -2
  191. package/build/esm/utils/rubberBandClamp.js.map +1 -1
  192. package/build/esm/utils/wrapEvent.d.ts +3 -3
  193. package/build/esm/utils/wrapEvent.js +7 -3
  194. package/build/esm/utils/wrapEvent.js.map +1 -1
  195. package/build/tsconfig-build.tsbuildinfo +1 -0
  196. package/build/tsconfig.tsbuildinfo +1 -1
  197. package/package.json +3 -3
  198. package/src/Accordion/Accordion.story.tsx +1 -0
  199. package/src/Accordion/Accordion.tsx +15 -7
  200. package/src/Accordion/AccordionBody.tsx +7 -8
  201. package/src/Accordion/AccordionHeader.tsx +35 -33
  202. package/src/Accordion/AccordionItem.tsx +15 -7
  203. package/src/Accordion/context.ts +5 -3
  204. package/src/CheckBox/CheckBox.tsx +6 -6
  205. package/src/ComboBox/ComboBox.story.tsx +5 -5
  206. package/src/ComboBox/Combobox.tsx +12 -17
  207. package/src/ComboBox/ComboboxButton.tsx +16 -15
  208. package/src/ComboBox/ComboboxInput.tsx +19 -10
  209. package/src/ComboBox/ComboboxLabel.tsx +5 -4
  210. package/src/ComboBox/ComboboxList.tsx +6 -6
  211. package/src/ComboBox/ComboboxOption.tsx +11 -7
  212. package/src/ComboBox/ComboboxPopover.tsx +14 -8
  213. package/src/ComboBox/context.ts +14 -12
  214. package/src/ComboBox/hooks.tsx +9 -11
  215. package/src/FocusLock/FocusLock.tsx +14 -7
  216. package/src/FocusLock/useFocusLock.ts +5 -3
  217. package/src/List/List.tsx +5 -5
  218. package/src/List/ListItem.tsx +5 -5
  219. package/src/Menu/Menu.story.tsx +7 -6
  220. package/src/Menu/Menu.tsx +16 -8
  221. package/src/Menu/MenuButton.tsx +15 -16
  222. package/src/Menu/MenuItem.tsx +15 -10
  223. package/src/Menu/MenuList.tsx +8 -12
  224. package/src/Menu/MenuPopover.tsx +7 -5
  225. package/src/Menu/context.ts +10 -4
  226. package/src/Modal/Modal.story.tsx +1 -0
  227. package/src/Modal/Modal.tsx +12 -6
  228. package/src/Modal/ModalBackdrop.tsx +15 -9
  229. package/src/Modal/NavDrawer.story.tsx +3 -3
  230. package/src/Popper/Popper.story.tsx +3 -4
  231. package/src/Popper/Popper.tsx +13 -12
  232. package/src/Popper/PopperArrow.tsx +5 -4
  233. package/src/Popper/context.ts +2 -1
  234. package/src/Portal/Portal.tsx +1 -1
  235. package/src/RadioButton/RadioButton.story.tsx +1 -0
  236. package/src/RadioButton/RadioButton.tsx +14 -7
  237. package/src/RadioButton/RadioGroup.tsx +14 -10
  238. package/src/RadioButton/context.ts +2 -4
  239. package/src/SkipNav/SkipNav.tsx +5 -5
  240. package/src/Spinner/Spinner.story.tsx +1 -0
  241. package/src/Spinner/Spinner.tsx +14 -9
  242. package/src/Spinner/SpinnerButton.tsx +12 -6
  243. package/src/Spinner/context.ts +2 -3
  244. package/src/Tabs/Tab.story.tsx +1 -0
  245. package/src/Tabs/Tab.tsx +16 -11
  246. package/src/Tabs/TabList.tsx +6 -5
  247. package/src/Tabs/TabPanel.tsx +6 -5
  248. package/src/Tabs/TabPanels.tsx +4 -4
  249. package/src/Tabs/Tabs.tsx +6 -7
  250. package/src/Tabs/context.ts +4 -4
  251. package/src/Tooltip/Tooltip.story.tsx +3 -2
  252. package/src/Tooltip/Tooltip.tsx +11 -9
  253. package/src/Tooltip/stateMachine.ts +1 -1
  254. package/src/Tooltip/useTooltip.ts +19 -10
  255. package/src/hooks/useAutoFocus.ts +3 -1
  256. package/src/hooks/useChildrenCounter.ts +2 -1
  257. package/src/hooks/useControlledState.ts +7 -8
  258. package/src/hooks/useFocusReturn.ts +2 -1
  259. package/src/hooks/useFocusState.ts +4 -2
  260. package/src/hooks/useGestureHandlers.ts +11 -7
  261. package/src/hooks/useMeasure.ts +2 -1
  262. package/src/hooks/useOnClickOutside.ts +2 -2
  263. package/src/hooks/useReducerMachine.ts +2 -1
  264. package/src/hooks/useScope.ts +2 -1
  265. package/src/utils/assignRef.ts +1 -1
  266. package/src/utils/wrapEvent.ts +4 -5
@@ -1,7 +1,8 @@
1
+ import type { MouseEvent } from 'react';
1
2
  import { useState } from 'react';
2
- import type * as React from 'react';
3
- import { Menu, MenuButton, MenuItem, MenuList, MenuPopover } from './';
4
3
  import { animated, useSpring } from 'react-spring';
4
+
5
+ import { Menu, MenuButton, MenuItem, MenuList, MenuPopover } from './';
5
6
  import './styles.css';
6
7
 
7
8
  export default {
@@ -13,7 +14,7 @@ const noop = () => {
13
14
  };
14
15
 
15
16
  const Wrapper = ({ children }) => {
16
- const handleLinkClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
17
+ const handleLinkClick = (e: MouseEvent<HTMLAnchorElement>) => {
17
18
  console.log('Clicked ' + e.currentTarget.innerText);
18
19
  e.preventDefault();
19
20
  };
@@ -91,10 +92,10 @@ const MenuControlledWithAnimation = () => {
91
92
  <MenuList
92
93
  as={animated.ul}
93
94
  style={{
94
- opacity: (opacity as unknown) as number,
95
- transform: (scale.to(
95
+ opacity: opacity as unknown as number,
96
+ transform: scale.to(
96
97
  (x) => `scale(${x}, ${x * x})`
97
- ) as unknown) as string,
98
+ ) as unknown as string,
98
99
  }}
99
100
  >
100
101
  <MenuItem>Dog</MenuItem>
package/src/Menu/Menu.tsx CHANGED
@@ -1,17 +1,25 @@
1
+ import type {
2
+ KeyboardEvent,
3
+ MouseEvent,
4
+ PointerEvent,
5
+ ReactNode,
6
+ ElementType,
7
+ } from 'react';
1
8
  import { forwardRef, useRef, Fragment, useId } from 'react';
2
- import type * as React from 'react';
3
- import { MenuProvider, MenuContextProps } from './context';
9
+
10
+ import type { MenuContextProps } from './context';
11
+ import { MenuProvider } from './context';
4
12
  import { useControlledState } from '../hooks';
5
13
 
6
14
  export interface MenuProps {
7
- as?: React.ElementType<any>;
8
- innerAs?: React.ElementType<any>;
9
- children?: React.ReactNode;
15
+ as?: ElementType<any>;
16
+ innerAs?: ElementType<any>;
17
+ children?: ReactNode;
10
18
  onChange?: (
11
19
  e:
12
- | React.KeyboardEvent<HTMLElement>
13
- | React.MouseEvent<HTMLElement>
14
- | React.PointerEvent<HTMLElement>,
20
+ | KeyboardEvent<HTMLElement>
21
+ | MouseEvent<HTMLElement>
22
+ | PointerEvent<HTMLElement>,
15
23
  isOpen: boolean
16
24
  ) => void;
17
25
  open?: boolean;
@@ -1,15 +1,19 @@
1
+ import type {
2
+ ButtonHTMLAttributes,
3
+ ElementType,
4
+ KeyboardEvent,
5
+ MouseEvent,
6
+ } from 'react';
1
7
  import { forwardRef, useId } from 'react';
2
- import type * as React from 'react';
8
+
3
9
  import { useMenuContext } from './context';
4
10
  import { wrapEvent } from '../utils/wrapEvent';
5
11
 
6
- export type MenuButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
7
- as?: React.ElementType<any>;
8
- innerAs?: React.ElementType<any>;
12
+ export type MenuButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
13
+ as?: ElementType<any>;
14
+ innerAs?: ElementType<any>;
9
15
  onClick?: (
10
- e:
11
- | React.MouseEvent<HTMLButtonElement>
12
- | React.KeyboardEvent<HTMLButtonElement>
16
+ e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>
13
17
  ) => void;
14
18
  };
15
19
 
@@ -23,18 +27,13 @@ export const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(
23
27
  disabled,
24
28
  ...otherProps
25
29
  } = props;
26
- const {
27
- menuListIdRef,
28
- openWithArrowKeyRef,
29
- open,
30
- buttonRef,
31
- onChange,
32
- } = useMenuContext();
30
+ const { menuListIdRef, openWithArrowKeyRef, open, buttonRef, onChange } =
31
+ useMenuContext();
33
32
 
34
33
  const buttonIdGenerated = useId();
35
34
  const buttonId = preferredId || buttonIdGenerated;
36
35
 
37
- const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {
36
+ const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {
38
37
  if (disabled) {
39
38
  return;
40
39
  }
@@ -54,7 +53,7 @@ export const MenuButton = forwardRef<HTMLButtonElement, MenuButtonProps>(
54
53
  }
55
54
  };
56
55
 
57
- const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
56
+ const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
58
57
  if (disabled) {
59
58
  return;
60
59
  }
@@ -1,14 +1,21 @@
1
+ import type {
2
+ LiHTMLAttributes,
3
+ ElementType,
4
+ MouseEvent,
5
+ KeyboardEvent,
6
+ KeyboardEventHandler,
7
+ } from 'react';
1
8
  import { forwardRef, useRef, useId } from 'react';
2
- import type * as React from 'react';
9
+
3
10
  import { useMenuContext, useMenuListContext } from './context';
4
11
  import { assignMultipleRefs } from '../utils/assignRef';
5
12
  import { wrapEvent } from '../utils';
6
13
 
7
- export interface MenuItemProps extends React.LiHTMLAttributes<HTMLLIElement> {
8
- as?: React.ElementType<any>;
9
- innerAs?: React.ElementType<any>;
14
+ export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
15
+ as?: ElementType<any>;
16
+ innerAs?: ElementType<any>;
10
17
  onSelect?: (
11
- e: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>
18
+ e: MouseEvent<HTMLLIElement> | KeyboardEvent<HTMLLIElement>
12
19
  ) => void;
13
20
  disabled?: boolean;
14
21
  }
@@ -34,16 +41,14 @@ export const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(
34
41
 
35
42
  const handleSelect = wrapEvent(
36
43
  onSelect,
37
- (
38
- e: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLLIElement>
39
- ) => {
44
+ (e: KeyboardEvent<HTMLLIElement> | MouseEvent<HTMLLIElement>) => {
40
45
  onChange && onChange(e, false);
41
46
  buttonRef.current?.focus();
42
47
  e.preventDefault();
43
48
  }
44
49
  );
45
50
 
46
- const handleClick = (e: React.MouseEvent<HTMLLIElement>) => {
51
+ const handleClick = (e: MouseEvent<HTMLLIElement>) => {
47
52
  if (!disabled) {
48
53
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
49
54
  onNavigate && onNavigate(ref.current!);
@@ -51,7 +56,7 @@ export const MenuItem = forwardRef<any, MenuItemProps>(function MenuItem(
51
56
  }
52
57
  };
53
58
 
54
- const handleKeyDown: React.KeyboardEventHandler<HTMLLIElement> = (e) => {
59
+ const handleKeyDown: KeyboardEventHandler<HTMLLIElement> = (e) => {
55
60
  switch (e.key) {
56
61
  case 'Enter':
57
62
  case ' ':
@@ -1,3 +1,4 @@
1
+ import type { HTMLAttributes, ElementType, KeyboardEvent } from 'react';
1
2
  import {
2
3
  forwardRef,
3
4
  useEffect,
@@ -5,7 +6,7 @@ import {
5
6
  useState,
6
7
  useLayoutEffect,
7
8
  } from 'react';
8
- import type * as React from 'react';
9
+
9
10
  import { useMenuContext, MenuListProvider } from './context';
10
11
  import { assignMultipleRefs } from '../utils/assignRef';
11
12
  import { useOnClickOutside } from '../hooks/useOnClickOutside';
@@ -16,9 +17,9 @@ import { getCircularIndex, wrapEvent } from '../utils';
16
17
  const useEnhancedEffect =
17
18
  typeof window !== 'undefined' ? useLayoutEffect : useEffect;
18
19
 
19
- export interface MenuListProps extends React.HTMLAttributes<HTMLUListElement> {
20
- as?: React.ElementType<any>;
21
- innerAs?: React.ElementType<any>;
20
+ export interface MenuListProps extends HTMLAttributes<HTMLUListElement> {
21
+ as?: ElementType<any>;
22
+ innerAs?: ElementType<any>;
22
23
  defaultActiveItemValue?: string;
23
24
  }
24
25
 
@@ -32,13 +33,8 @@ export const MenuList = forwardRef<HTMLUListElement, MenuListProps>(
32
33
  ...otherProps
33
34
  } = props;
34
35
 
35
- const {
36
- menuListIdRef,
37
- buttonRef,
38
- onChange,
39
- openWithArrowKeyRef,
40
- open,
41
- } = useMenuContext();
36
+ const { menuListIdRef, buttonRef, onChange, openWithArrowKeyRef, open } =
37
+ useMenuContext();
42
38
 
43
39
  const [navigationItem, setNavigationItem] = useState<
44
40
  HTMLElement | undefined
@@ -105,7 +101,7 @@ export const MenuList = forwardRef<HTMLUListElement, MenuListProps>(
105
101
  true
106
102
  );
107
103
 
108
- function handleKeyDown(e: React.KeyboardEvent<HTMLUListElement>) {
104
+ function handleKeyDown(e: KeyboardEvent<HTMLUListElement>) {
109
105
  switch (e.key) {
110
106
  case 'Escape':
111
107
  case 'Tab': {
@@ -1,12 +1,14 @@
1
+ import type { ElementType, ReactNode } from 'react';
1
2
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
3
- import { Popper, PopperProps } from '../Popper';
3
+
4
+ import type { PopperProps } from '../Popper';
5
+ import { Popper } from '../Popper';
4
6
  import { useMenuContext } from './context';
5
7
 
6
8
  export interface MenuPopoverProps extends Omit<PopperProps, 'anchorEl'> {
7
- as?: React.ElementType<any>;
8
- innerAs?: React.ElementType<any>;
9
- children?: React.ReactNode;
9
+ as?: ElementType<any>;
10
+ innerAs?: ElementType<any>;
11
+ children?: ReactNode;
10
12
  }
11
13
 
12
14
  export const MenuPopover = forwardRef<HTMLDivElement, MenuPopoverProps>(
@@ -1,4 +1,10 @@
1
- import { createContext, useContext, MutableRefObject } from 'react';
1
+ import type {
2
+ KeyboardEvent,
3
+ MouseEvent,
4
+ MutableRefObject,
5
+ PointerEvent,
6
+ } from 'react';
7
+ import { createContext, useContext } from 'react';
2
8
 
3
9
  export type ItemObject = { text: string; value: any; id: string | undefined };
4
10
 
@@ -9,9 +15,9 @@ export interface MenuContextProps {
9
15
  openWithArrowKeyRef: MutableRefObject<string | null>;
10
16
  onChange?: (
11
17
  e:
12
- | React.KeyboardEvent<HTMLElement>
13
- | React.MouseEvent<HTMLElement>
14
- | React.PointerEvent<HTMLElement>,
18
+ | KeyboardEvent<HTMLElement>
19
+ | MouseEvent<HTMLElement>
20
+ | PointerEvent<HTMLElement>,
15
21
  isOpen: boolean
16
22
  ) => void;
17
23
  open: boolean;
@@ -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';
@@ -1,14 +1,20 @@
1
- import { ReactNode, forwardRef, useRef } from 'react';
2
- import type * as React from 'react';
1
+ import type {
2
+ CSSProperties,
3
+ ElementType,
4
+ HTMLAttributes,
5
+ ReactNode,
6
+ } from 'react';
7
+ import { forwardRef, useRef } from 'react';
8
+
3
9
  import { useAutoFocus, useFocusReturn, useRemoveBodyScroll } from '../hooks';
4
10
  import { FocusLock } from '../FocusLock';
5
11
  import { assignMultipleRefs } from '../utils';
6
12
 
7
- export interface ModalProps extends React.HTMLAttributes<HTMLDivElement> {
8
- as?: React.ElementType<any>;
9
- innerAs?: React.ElementType<any>;
13
+ export interface ModalProps extends HTMLAttributes<HTMLDivElement> {
14
+ as?: ElementType<any>;
15
+ innerAs?: ElementType<any>;
10
16
  children?: ReactNode;
11
- style?: React.CSSProperties;
17
+ style?: CSSProperties;
12
18
  trapFocus?: boolean;
13
19
  }
14
20
 
@@ -1,14 +1,20 @@
1
+ import type {
2
+ HTMLAttributes,
3
+ ElementType,
4
+ CSSProperties,
5
+ MouseEvent,
6
+ KeyboardEvent,
7
+ } from 'react';
1
8
  import { useRef, forwardRef } from 'react';
2
- import type * as React from 'react';
9
+
3
10
  import { assignMultipleRefs } from '../utils/assignRef';
4
11
  import { wrapEvent } from '../utils/wrapEvent';
5
12
 
6
- export interface ModalBackdropProps
7
- extends React.HTMLAttributes<HTMLDivElement> {
8
- as?: React.ElementType<any>;
9
- innerAs?: React.ElementType<any>;
13
+ export interface ModalBackdropProps extends HTMLAttributes<HTMLDivElement> {
14
+ as?: ElementType<any>;
15
+ innerAs?: ElementType<any>;
10
16
  onClose?: () => void;
11
- style?: React.CSSProperties;
17
+ style?: CSSProperties;
12
18
  disableCloseOnClick?: boolean;
13
19
  disableEscapeKeyDown?: boolean;
14
20
  }
@@ -30,7 +36,7 @@ export const ModalBackdrop = forwardRef<HTMLDivElement, ModalBackdropProps>(
30
36
  const ref = useRef();
31
37
  const mouseDownTargetRef = useRef<EventTarget | null>(null);
32
38
 
33
- const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
39
+ const handleClick = (e: MouseEvent<HTMLDivElement>) => {
34
40
  // Ignore the events not coming from the "backdrop"
35
41
  // We don't want to close the dialog when clicking the dialog content.
36
42
  if (e.target !== e.currentTarget) {
@@ -47,11 +53,11 @@ export const ModalBackdrop = forwardRef<HTMLDivElement, ModalBackdropProps>(
47
53
  e.stopPropagation();
48
54
  };
49
55
 
50
- const handleMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {
56
+ const handleMouseDown = (e: MouseEvent<HTMLDivElement>) => {
51
57
  mouseDownTargetRef.current = e.target;
52
58
  };
53
59
 
54
- const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
60
+ const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
55
61
  if (e.key === 'Escape') {
56
62
  !disableEscapeKeyDown && onClose?.();
57
63
  e.stopPropagation();
@@ -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 />;
@@ -1,3 +1,4 @@
1
+ import type { HTMLAttributes, ElementType, RefObject, ReactNode } from 'react';
1
2
  import {
2
3
  forwardRef,
3
4
  useRef,
@@ -6,22 +7,22 @@ import {
6
7
  useMemo,
7
8
  memo,
8
9
  } 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 {
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
 
@@ -31,11 +32,11 @@ export type OffsetsFunction = (arg0: {
31
32
  placement: Placement;
32
33
  }) => [number | null | undefined, number | null | undefined];
33
34
 
34
- export interface PopperProps extends React.HTMLAttributes<HTMLDivElement> {
35
- as?: React.ElementType<any>;
36
- innerAs?: React.ElementType<any>;
37
- anchorEl: React.RefObject<HTMLElement>;
38
- children?: React.ReactNode;
35
+ export interface PopperProps extends HTMLAttributes<HTMLDivElement> {
36
+ as?: ElementType<any>;
37
+ innerAs?: ElementType<any>;
38
+ anchorEl: RefObject<HTMLElement>;
39
+ children?: ReactNode;
39
40
  placement?: Placement;
40
41
  strategy?: PositioningStrategy;
41
42
  modifiers?: Array<Partial<Modifier<any, any>>>;
@@ -1,11 +1,12 @@
1
+ import type { ElementType, HTMLAttributes } from 'react';
1
2
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
3
+
3
4
  import { usePopperContext } from './context';
4
5
  import { assignRef } from '../utils/assignRef';
5
6
 
6
- export interface PopperArrowProps extends React.HTMLAttributes<HTMLDivElement> {
7
- as?: React.ElementType<any>;
8
- innerAs?: React.ElementType<any>;
7
+ export interface PopperArrowProps extends HTMLAttributes<HTMLDivElement> {
8
+ as?: ElementType<any>;
9
+ innerAs?: ElementType<any>;
9
10
  }
10
11
 
11
12
  export const PopperArrow = forwardRef<HTMLDivElement, PopperArrowProps>(
@@ -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,13 +1,20 @@
1
+ import type {
2
+ ChangeEvent,
3
+ ElementType,
4
+ InputHTMLAttributes,
5
+ ReactNode,
6
+ } from 'react';
1
7
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
3
- import { RadioValue, useRadioGroupContext } from './context';
8
+
9
+ import type { RadioValue } from './context';
10
+ import { useRadioGroupContext } from './context';
4
11
  import { wrapEvent } from '../utils';
5
12
 
6
13
  export interface RadioButtonProps
7
- extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value'> {
8
- as?: React.ElementType<any>;
9
- innerAs?: React.ElementType<any>;
10
- children?: React.ReactNode;
14
+ extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value'> {
15
+ as?: ElementType<any>;
16
+ innerAs?: ElementType<any>;
17
+ children?: ReactNode;
11
18
  checked?: boolean;
12
19
  value: RadioValue;
13
20
  }
@@ -24,7 +31,7 @@ export const RadioButton = forwardRef<HTMLInputElement, RadioButtonProps>(
24
31
  } = props;
25
32
  const radioGroupContext = useRadioGroupContext();
26
33
 
27
- const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
34
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
28
35
  radioGroupContext?.onChange?.(e, valueProp);
29
36
  };
30
37
 
@@ -1,23 +1,27 @@
1
+ import type {
2
+ ChangeEvent,
3
+ ElementType,
4
+ HTMLAttributes,
5
+ ReactNode,
6
+ } from 'react';
1
7
  import { forwardRef, useId } from 'react';
2
- import type * as React from 'react';
3
- import { RadioGroupProvider, RadioValue } from './context';
8
+
9
+ import type { RadioValue } from './context';
10
+ import { RadioGroupProvider } from './context';
4
11
  import { useControlledState } from '../hooks';
5
12
 
6
13
  export interface RadioGroupProps
7
14
  extends Omit<
8
- React.HTMLAttributes<HTMLDivElement>,
15
+ HTMLAttributes<HTMLDivElement>,
9
16
  'onChange' | 'value' | 'defaultValue'
10
17
  > {
11
- as?: React.ElementType<any>;
12
- innerAs?: React.ElementType<any>;
13
- children?: React.ReactNode;
18
+ as?: ElementType<any>;
19
+ innerAs?: ElementType<any>;
20
+ children?: ReactNode;
14
21
  value?: RadioValue;
15
22
  defaultValue?: RadioValue;
16
23
  name?: string;
17
- onChange?: (
18
- e: React.ChangeEvent<HTMLInputElement>,
19
- value: RadioValue
20
- ) => void;
24
+ onChange?: (e: ChangeEvent<HTMLInputElement>, value: RadioValue) => void;
21
25
  }
22
26
 
23
27
  export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(
@@ -1,3 +1,4 @@
1
+ import type { ChangeEvent } from 'react';
1
2
  import { createContext, useContext } from 'react';
2
3
 
3
4
  export type RadioValue = string | number | boolean;
@@ -5,10 +6,7 @@ export type RadioValue = string | number | boolean;
5
6
  // RadioGroup Component
6
7
  export interface RadioGroupContextProps {
7
8
  value: RadioValue | undefined;
8
- onChange?: (
9
- e: React.ChangeEvent<HTMLInputElement>,
10
- value: RadioValue
11
- ) => void;
9
+ onChange?: (e: ChangeEvent<HTMLInputElement>, value: RadioValue) => void;
12
10
  name: string | undefined;
13
11
  }
14
12
 
@@ -1,10 +1,10 @@
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
1
2
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
3
3
 
4
- export interface SkipNavProps extends React.HTMLAttributes<HTMLDivElement> {
5
- as?: React.ElementType<any>;
6
- innerAs?: React.ElementType<any>;
7
- children?: React.ReactNode;
4
+ export interface SkipNavProps extends HTMLAttributes<HTMLDivElement> {
5
+ as?: ElementType<any>;
6
+ innerAs?: ElementType<any>;
7
+ children?: ReactNode;
8
8
  }
9
9
 
10
10
  export const SkipNav = forwardRef<HTMLDivElement, SkipNavProps>(
@@ -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,22 +1,27 @@
1
+ import type {
2
+ HTMLAttributes,
3
+ ElementType,
4
+ ReactNode,
5
+ MouseEvent,
6
+ KeyboardEvent,
7
+ } from 'react';
1
8
  import { forwardRef, useState, useRef } from 'react';
2
- import type * as React from 'react';
9
+
3
10
  import { SpinnerProvider } from './context';
4
11
  import { clamp as clampFunc } from '../utils/clamp';
5
12
  import { wrapEvent, assignMultipleRefs } from '../utils';
6
13
 
7
14
  export interface SpinnerProps
8
- extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
9
- as?: React.ElementType<any>;
10
- innerAs?: React.ElementType<any>;
11
- children?: React.ReactNode;
15
+ extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
16
+ as?: ElementType<any>;
17
+ innerAs?: ElementType<any>;
18
+ children?: ReactNode;
12
19
  value?: number;
13
20
  minValue?: number;
14
21
  maxValue?: number;
15
22
  stepSize?: number;
16
23
  onChange?: (
17
- e:
18
- | React.MouseEvent<HTMLButtonElement>
19
- | React.KeyboardEvent<HTMLDivElement>,
24
+ e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>,
20
25
  value: number
21
26
  ) => void;
22
27
  }
@@ -40,7 +45,7 @@ export const Spinner = forwardRef<HTMLDivElement, SpinnerProps>(
40
45
 
41
46
  const clamp = (value: number) => clampFunc(value, minValue, maxValue);
42
47
 
43
- const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
48
+ const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
44
49
  let nextValue = value;
45
50
  switch (e.key) {
46
51
  case 'ArrowUp':