@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,13 +1,19 @@
1
+ import type {
2
+ ButtonHTMLAttributes,
3
+ ElementType,
4
+ MouseEvent,
5
+ ReactNode,
6
+ } from 'react';
1
7
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
8
+
3
9
  import { useSpinnerContext } from './context';
4
10
  import { wrapEvent } from '../utils';
5
11
 
6
12
  export interface SpinnerButtonProps
7
- extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
8
- as?: React.ElementType<any>;
9
- innerAs?: React.ElementType<any>;
10
- children?: React.ReactNode;
13
+ extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
14
+ as?: ElementType<any>;
15
+ innerAs?: ElementType<any>;
16
+ children?: ReactNode;
11
17
  type: 'next' | 'previous';
12
18
  }
13
19
 
@@ -20,7 +26,7 @@ export const SpinnerButton = forwardRef<HTMLButtonElement, SpinnerButtonProps>(
20
26
  throw new Error('Missing <Spinner /> in component tree');
21
27
  }
22
28
 
23
- const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
29
+ const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
24
30
  const delta = type === 'next' ? 1 : -1;
25
31
 
26
32
  spinnerContext.onChange &&
@@ -1,3 +1,4 @@
1
+ import type { KeyboardEvent, MouseEvent } from 'react';
1
2
  import { createContext, useContext } from 'react';
2
3
 
3
4
  // Spinner Component
@@ -7,9 +8,7 @@ export interface SpinnerContextProps {
7
8
  maxValue: number;
8
9
  stepSize: number;
9
10
  onChange?: (
10
- e:
11
- | React.MouseEvent<HTMLButtonElement>
12
- | React.KeyboardEvent<HTMLDivElement>,
11
+ e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>,
13
12
  value: number
14
13
  ) => void;
15
14
  clamp: (value: number) => number;
@@ -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,12 @@
1
+ import type {
2
+ ButtonHTMLAttributes,
3
+ ElementType,
4
+ KeyboardEvent,
5
+ MouseEvent,
6
+ ReactNode,
7
+ } from 'react';
1
8
  import { forwardRef, useRef } from 'react';
2
- import type * as React from 'react';
9
+
3
10
  import { useTabsContext, useTabListContext } from './context';
4
11
  import { assignMultipleRefs, getCircularIndex, wrapEvent } from '../utils';
5
12
  import { scopeQuery } from './scopeQuery';
@@ -23,11 +30,10 @@ function getNextIndex(
23
30
  return null;
24
31
  }
25
32
 
26
- export interface TabProps
27
- extends React.ButtonHTMLAttributes<HTMLButtonElement> {
28
- as?: React.ElementType<any>;
29
- innerAs?: React.ElementType<any>;
30
- children?: React.ReactNode;
33
+ export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
34
+ as?: ElementType<any>;
35
+ innerAs?: ElementType<any>;
36
+ children?: ReactNode;
31
37
  }
32
38
 
33
39
  export const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(
@@ -50,7 +56,7 @@ export const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(
50
56
  throw new Error('Missing <Tabs /> or <TabList /> in the component tree');
51
57
  }
52
58
 
53
- const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {
59
+ const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {
54
60
  const right = tabListContext.vertical ? 'ArrowDown' : 'ArrowRight';
55
61
  const left = tabListContext.vertical ? 'ArrowUp' : 'ArrowLeft';
56
62
  const first = 'Home';
@@ -59,9 +65,8 @@ export const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(
59
65
  const navigateIndex = (desiredIndex: number, isLast: boolean) => {
60
66
  const delta = e.key === right || e.key === first ? 1 : -1;
61
67
 
62
- const allTabs = tabListContext.tabsScope.current.queryAllNodes(
63
- scopeQuery
64
- );
68
+ const allTabs =
69
+ tabListContext.tabsScope.current.queryAllNodes(scopeQuery);
65
70
  const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;
66
71
 
67
72
  const nextIndex = getNextIndex(
@@ -94,7 +99,7 @@ export const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(
94
99
  }
95
100
  };
96
101
 
97
- const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
102
+ const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
98
103
  const allTabs = tabListContext.tabsScope.current.queryAllNodes(scopeQuery);
99
104
  const currentIndex = ref.current ? allTabs.indexOf(ref.current) : -1;
100
105
 
@@ -1,3 +1,4 @@
1
+ import type { HTMLAttributes, ElementType, ReactNode } from 'react';
1
2
  import {
2
3
  forwardRef,
3
4
  useRef,
@@ -6,17 +7,17 @@ import {
6
7
  cloneElement,
7
8
  useId,
8
9
  } from 'react';
9
- import type * as React from 'react';
10
+
10
11
  import { TabListProvider, useTabsContext } from './context';
11
12
  import { useScope } from '../hooks';
12
13
  import { assignMultipleRefs } from '../utils';
13
14
 
14
- export interface TabListProps extends React.HTMLAttributes<HTMLDivElement> {
15
- as?: React.ElementType<any>;
16
- innerAs?: React.ElementType<any>;
15
+ export interface TabListProps extends HTMLAttributes<HTMLDivElement> {
16
+ as?: ElementType<any>;
17
+ innerAs?: ElementType<any>;
17
18
  manualActivation?: boolean;
18
19
  vertical?: boolean;
19
- children?: React.ReactNode;
20
+ children?: ReactNode;
20
21
  }
21
22
 
22
23
  export const TabList = forwardRef<HTMLDivElement, TabListProps>(
@@ -1,11 +1,12 @@
1
+ import type { ElementType, HTMLAttributes, ReactNode } from 'react';
1
2
  import { forwardRef } from 'react';
2
- import type * as React from 'react';
3
+
3
4
  import { useTabsContext } from './context';
4
5
 
5
- export interface TabPanelProps extends React.HTMLAttributes<HTMLDivElement> {
6
- as?: React.ElementType<any>;
7
- innerAs?: React.ElementType<any>;
8
- children?: React.ReactNode;
6
+ export interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
7
+ as?: ElementType<any>;
8
+ innerAs?: ElementType<any>;
9
+ children?: ReactNode;
9
10
  lazy?: boolean;
10
11
  }
11
12
 
@@ -1,11 +1,11 @@
1
+ import type { ElementType, ReactNode } from 'react';
1
2
  import { forwardRef, Fragment, Children, cloneElement } from 'react';
2
- import type * as React from 'react';
3
3
 
4
4
  export interface TabPanelsProps {
5
- as?: React.ElementType<any>;
6
- innerAs?: React.ElementType<any>;
5
+ as?: ElementType<any>;
6
+ innerAs?: ElementType<any>;
7
7
  lazy?: boolean;
8
- children?: React.ReactNode;
8
+ children?: ReactNode;
9
9
  }
10
10
 
11
11
  export const TabPanels = forwardRef<HTMLDivElement, TabPanelsProps>(
package/src/Tabs/Tabs.tsx CHANGED
@@ -1,16 +1,15 @@
1
+ import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';
1
2
  import { forwardRef, Fragment, useState } from 'react';
2
- import type * as React from 'react';
3
+
3
4
  import { TabsProvider } from './context';
4
5
  import { useControlledState } from '../hooks';
5
6
 
6
7
  export interface TabsProps {
7
- as?: React.ElementType<any>;
8
- innerAs?: React.ElementType<any>;
9
- children?: React.ReactNode;
8
+ as?: ElementType<any>;
9
+ innerAs?: ElementType<any>;
10
+ children?: ReactNode;
10
11
  onChange?: (
11
- e:
12
- | React.MouseEvent<HTMLButtonElement>
13
- | React.KeyboardEvent<HTMLButtonElement>,
12
+ e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,
14
13
  value: number
15
14
  ) => void;
16
15
  index?: number;
@@ -1,13 +1,13 @@
1
+ import type { KeyboardEvent, MouseEvent } from 'react';
1
2
  import { createContext, useContext } from 'react';
2
- import { Scope } from '../hooks/useScope';
3
+
4
+ import type { Scope } from '../hooks/useScope';
3
5
 
4
6
  // Tabs Component
5
7
  export interface TabsContextProps {
6
8
  currentIndex: number;
7
9
  onChange?: (
8
- e:
9
- | React.MouseEvent<HTMLButtonElement>
10
- | React.KeyboardEvent<HTMLButtonElement>,
10
+ e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,
11
11
  value: number
12
12
  ) => void;
13
13
  tabListId: string | null;
@@ -1,7 +1,8 @@
1
- import React, { useRef, forwardRef } from 'react';
1
+ import { 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,18 +1,20 @@
1
- import React, {
2
- forwardRef,
3
- cloneElement,
4
- Children,
1
+ import type {
2
+ ElementType,
3
+ HTMLAttributes,
5
4
  ReactElement,
5
+ ReactNode,
6
6
  RefAttributes,
7
7
  } from 'react';
8
+ import { forwardRef, cloneElement, Children } from 'react';
9
+
8
10
  import { useTooltip } from './useTooltip';
9
11
  export type { InjectedTooltipProps } from './useTooltip';
10
12
 
11
- export interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {
12
- as?: React.ElementType<any>;
13
- innerAs?: React.ElementType<any>;
14
- children?: React.ReactNode;
15
- label: React.ReactNode;
13
+ export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
14
+ as?: ElementType<any>;
15
+ innerAs?: ElementType<any>;
16
+ children?: ReactNode;
17
+ label: ReactNode;
16
18
  disabled?: boolean;
17
19
  }
18
20
 
@@ -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,4 +1,13 @@
1
- import { useRef, RefAttributes, useEffect, useState, useId } from 'react';
1
+ import type {
2
+ HTMLAttributes,
3
+ KeyboardEvent,
4
+ ReactNode,
5
+ Ref,
6
+ RefAttributes,
7
+ RefObject,
8
+ } from 'react';
9
+ import { useRef, useEffect, useState, useId } from 'react';
10
+
2
11
  import { assignMultipleRefs } from '../utils/assignRef';
3
12
  import { wrapEvent } from '../utils/wrapEvent';
4
13
  import {
@@ -16,20 +25,19 @@ import {
16
25
  Visible,
17
26
  } from './stateMachine';
18
27
 
19
- export type ChildProps = React.HTMLAttributes<HTMLElement> &
28
+ export type ChildProps = HTMLAttributes<HTMLElement> &
20
29
  RefAttributes<HTMLElement>;
21
30
 
22
- export interface InjectedTooltipProps
23
- extends React.HTMLAttributes<HTMLElement> {
24
- anchorEl: React.RefObject<HTMLElement>;
31
+ export interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {
32
+ anchorEl: RefObject<HTMLElement>;
25
33
  visible: boolean;
26
- children?: React.ReactNode;
34
+ children?: ReactNode;
27
35
  }
28
36
 
29
37
  export function useTooltip(
30
38
  childProps: ChildProps,
31
- childRef: React.Ref<HTMLElement> | undefined,
32
- tooltipProps: React.HTMLAttributes<HTMLElement> & { label?: React.ReactNode }
39
+ childRef: Ref<HTMLElement> | undefined,
40
+ tooltipProps: HTMLAttributes<HTMLElement> & { label?: ReactNode }
33
41
  ): [ChildProps, InjectedTooltipProps] {
34
42
  const {
35
43
  onMouseEnter,
@@ -84,7 +92,7 @@ export function useTooltip(
84
92
  }
85
93
  }
86
94
 
87
- function handleKeyDown(event: React.KeyboardEvent<HTMLElement>) {
95
+ function handleKeyDown(event: KeyboardEvent<HTMLElement>) {
88
96
  if (event.key === 'Enter' || event.key === ' ') {
89
97
  send(SelectWithKeyboard);
90
98
  }
@@ -103,7 +111,8 @@ export function useTooltip(
103
111
  {
104
112
  ...childProps,
105
113
  ref: assignMultipleRefs(childRef, anchorEl),
106
- ...(visible && { 'aria-describedby': tooltipId }),
114
+ ...(visible &&
115
+ !childProps['aria-label'] && { 'aria-describedby': tooltipId }),
107
116
  onMouseEnter: wrapEvent(onMouseEnter, handleMouseEnter),
108
117
  onMouseLeave: wrapEvent(onMouseLeave, handleMouseLeave),
109
118
  onMouseMove: wrapEvent(onMouseMove, handleMouseMove),
@@ -1,9 +1,11 @@
1
+ import type { MutableRefObject } from 'react';
1
2
  import { useEffect } from 'react';
3
+
2
4
  import { focusOnChildNode } from '../FocusLock/tabUtils';
3
5
 
4
6
  export function useAutoFocus(
5
7
  open: boolean,
6
- elementRef: React.MutableRefObject<HTMLElement | null>
8
+ elementRef: MutableRefObject<HTMLElement | null>
7
9
  ) {
8
10
  useEffect(() => {
9
11
  if (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,22 +1,21 @@
1
+ import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';
1
2
  import { useRef, useState } from 'react';
2
- import { wrapEvent, CustomEventHandler } from '../utils';
3
+
4
+ import type { CustomEventHandler } from '../utils';
5
+ import { wrapEvent } from '../utils';
3
6
 
4
7
  export function useControlledState<
5
8
  V,
6
- E extends React.SyntheticEvent<any>,
9
+ E extends SyntheticEvent<any>,
7
10
  H extends unknown[]
8
11
  >(
9
12
  valueProp: V | undefined,
10
13
  onChangeProp: CustomEventHandler<E, H> | undefined,
11
14
  defaultValue: V,
12
15
  defaultOnChange: (
13
- setValue: React.Dispatch<React.SetStateAction<V>>
16
+ setValue: Dispatch<SetStateAction<V>>
14
17
  ) => CustomEventHandler<E, H>
15
- ): [
16
- V,
17
- CustomEventHandler<E, H> | undefined,
18
- React.Dispatch<React.SetStateAction<V>>
19
- ] {
18
+ ): [V, CustomEventHandler<E, H> | undefined, Dispatch<SetStateAction<V>>] {
20
19
  const isControlled = useRef(valueProp !== undefined);
21
20
  const [valueState, setValueState] = useState<V>(defaultValue);
22
21
 
@@ -1,4 +1,5 @@
1
- import { MutableRefObject, useEffect, useRef } from 'react';
1
+ import type { MutableRefObject } from 'react';
2
+ import { useEffect, useRef } from 'react';
2
3
 
3
4
  export function useFocusReturn(
4
5
  open: boolean,
@@ -1,10 +1,12 @@
1
+ import type { FocusEventHandler } from 'react';
1
2
  import { useState } from 'react';
3
+
2
4
  import { wrapEvent } from '../utils/wrapEvent';
3
5
 
4
6
  export function useFocusState<T>(
5
7
  props: {
6
- onFocus?: React.FocusEventHandler<T>;
7
- onBlur?: React.FocusEventHandler<T>;
8
+ onFocus?: FocusEventHandler<T>;
9
+ onBlur?: FocusEventHandler<T>;
8
10
  } = {}
9
11
  ) {
10
12
  const { onFocus, onBlur } = props;
@@ -1,5 +1,9 @@
1
+ import type {
2
+ MutableRefObject,
3
+ MouseEvent as ReactMouseEvent,
4
+ TouchEvent as ReactTouchEvent,
5
+ } from 'react';
1
6
  import { useRef } from 'react';
2
- import type * as React from 'react';
3
7
 
4
8
  export interface GestureHandlersState {
5
9
  target: null | EventTarget;
@@ -26,8 +30,8 @@ type SetStateFunc<S> = (
26
30
  ) => void;
27
31
 
28
32
  export interface GestureHandlersReturn {
29
- onMouseDown: (e: React.MouseEvent<HTMLElement>) => void;
30
- onTouchStart: (e: React.TouchEvent<HTMLElement>) => void;
33
+ onMouseDown: (e: ReactMouseEvent<HTMLElement>) => void;
34
+ onTouchStart: (e: ReactTouchEvent<HTMLElement>) => void;
31
35
  }
32
36
 
33
37
  export interface GestureHandlerOptions {
@@ -59,7 +63,7 @@ const VELOCITY_DEPR_FACTOR = FRAMERATE_CONST * 2;
59
63
 
60
64
  export function gestureHandlers(
61
65
  set: SetStateFunc<GestureHandlersState>,
62
- containerRef?: React.MutableRefObject<HTMLElement | null>,
66
+ containerRef?: MutableRefObject<HTMLElement | null>,
63
67
  options: GestureHandlerOptions = {}
64
68
  ): GestureHandlersReturn {
65
69
  const { ensureTargetIsContainer = false, minTouchDelta = 0 } = options;
@@ -192,7 +196,7 @@ export function gestureHandlers(
192
196
  handleMove(e.touches.item(0) as any);
193
197
  }
194
198
 
195
- function handleTouchStart(e: React.TouchEvent<HTMLElement>) {
199
+ function handleTouchStart(e: ReactTouchEvent<HTMLElement>) {
196
200
  // making sure we're not dragging the element when more than one finger press the screen
197
201
  const { touches } = e;
198
202
  if (touches.length > 1) {
@@ -221,7 +225,7 @@ export function gestureHandlers(
221
225
  }
222
226
 
223
227
  // Mouse handlers
224
- function handleMouseDown(e: React.MouseEvent<HTMLElement>) {
228
+ function handleMouseDown(e: ReactMouseEvent<HTMLElement>) {
225
229
  if (
226
230
  ensureTargetIsContainer &&
227
231
  containerRef &&
@@ -251,7 +255,7 @@ export function gestureHandlers(
251
255
  }
252
256
 
253
257
  export const useGestureHandlers = (
254
- containerRef: React.MutableRefObject<HTMLElement | null> | undefined,
258
+ containerRef: MutableRefObject<HTMLElement | null> | undefined,
255
259
  onGesture: (e: GestureHandlersState) => void,
256
260
  options: GestureHandlerOptions = {}
257
261
  ) => {
@@ -1,7 +1,8 @@
1
+ import type { MutableRefObject } from 'react';
1
2
  import { useRef, useState, useEffect } from 'react';
2
3
  import ResizeObserver from 'resize-observer-polyfill';
3
4
 
4
- export function useMeasure(ref: React.MutableRefObject<HTMLElement | null>) {
5
+ export function useMeasure(ref: MutableRefObject<HTMLElement | null>) {
5
6
  const ro = useRef<ResizeObserver | null>(null);
6
7
  const [bounds, setBounds] = useState({
7
8
  left: 0,
@@ -1,8 +1,8 @@
1
+ import type { RefObject } from 'react';
1
2
  import { useEffect, useCallback } from 'react';
2
- import type * as React from 'react';
3
3
 
4
4
  export function useOnClickOutside(
5
- ref: React.RefObject<any>,
5
+ ref: RefObject<any>,
6
6
  handler: (e: PointerEvent) => void,
7
7
  active = true
8
8
  ) {
@@ -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,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,12 +1,11 @@
1
+ import type { SyntheticEvent } from 'react';
2
+
1
3
  export type CustomEventHandler<
2
- E extends React.SyntheticEvent<any>,
4
+ E extends SyntheticEvent<any>,
3
5
  H extends unknown[]
4
6
  > = (e: E, ...args: H) => void;
5
7
 
6
- export function wrapEvent<
7
- E extends React.SyntheticEvent<any>,
8
- H extends unknown[]
9
- >(
8
+ export function wrapEvent<E extends SyntheticEvent<any>, H extends unknown[]>(
10
9
  theirHandler: CustomEventHandler<E, H> | undefined,
11
10
  ourHandler: CustomEventHandler<E, H>
12
11
  ): CustomEventHandler<E, H> {