@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.
- package/build/cjs/index.js +1 -1
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +7 -7
- package/build/esm/Accordion/Accordion.js +22 -17
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts +5 -5
- package/build/esm/Accordion/AccordionBody.js +23 -15
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts +6 -6
- package/build/esm/Accordion/AccordionHeader.js +45 -31
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts +7 -7
- package/build/esm/Accordion/AccordionItem.js +16 -16
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +4 -4
- package/build/esm/Accordion/context.js +12 -10
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +6 -6
- package/build/esm/CheckBox/CheckBox.js +19 -12
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/ComboBox/Combobox.d.ts +10 -10
- package/build/esm/ComboBox/Combobox.js +52 -46
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxButton.js +19 -20
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.d.ts +10 -10
- package/build/esm/ComboBox/ComboboxInput.js +52 -50
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.d.ts +5 -5
- package/build/esm/ComboBox/ComboboxLabel.js +11 -12
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.d.ts +6 -6
- package/build/esm/ComboBox/ComboboxList.js +15 -17
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.d.ts +7 -7
- package/build/esm/ComboBox/ComboboxOption.js +31 -34
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxPopover.js +15 -17
- package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
- package/build/esm/ComboBox/context.d.ts +13 -13
- package/build/esm/ComboBox/context.js +6 -5
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +4 -4
- package/build/esm/ComboBox/hooks.js +82 -115
- package/build/esm/ComboBox/hooks.js.map +1 -1
- package/build/esm/ComboBox/makeHash.js +3 -3
- package/build/esm/ComboBox/makeHash.js.map +1 -1
- package/build/esm/FocusLock/FocusLock.d.ts +7 -7
- package/build/esm/FocusLock/FocusLock.js +17 -16
- package/build/esm/FocusLock/FocusLock.js.map +1 -1
- package/build/esm/FocusLock/tabUtils.js +4 -4
- package/build/esm/FocusLock/tabUtils.js.map +1 -1
- package/build/esm/FocusLock/useFocusLock.d.ts +4 -4
- package/build/esm/FocusLock/useFocusLock.js +10 -11
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +6 -6
- package/build/esm/List/List.js +5 -6
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.d.ts +6 -6
- package/build/esm/List/ListItem.js +5 -6
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.js +3 -3
- package/build/esm/List/context.js.map +1 -1
- package/build/esm/Menu/Menu.d.ts +6 -6
- package/build/esm/Menu/Menu.js +29 -21
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +10 -10
- package/build/esm/Menu/MenuButton.js +27 -24
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +6 -6
- package/build/esm/Menu/MenuItem.js +23 -24
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +5 -5
- package/build/esm/Menu/MenuList.js +61 -45
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts +6 -6
- package/build/esm/Menu/MenuPopover.js +8 -10
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +2 -2
- package/build/esm/Menu/context.js +11 -8
- package/build/esm/Menu/context.js.map +1 -1
- package/build/esm/Modal/Modal.d.ts +6 -7
- package/build/esm/Modal/Modal.js +11 -10
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +6 -6
- package/build/esm/Modal/ModalBackdrop.js +20 -19
- package/build/esm/Modal/ModalBackdrop.js.map +1 -1
- package/build/esm/Popper/Popper.d.ts +8 -8
- package/build/esm/Popper/Popper.js +46 -37
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +5 -5
- package/build/esm/Popper/PopperArrow.js +8 -9
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.d.ts +1 -1
- package/build/esm/Popper/context.js +5 -3
- package/build/esm/Popper/context.js.map +1 -1
- package/build/esm/Portal/Portal.d.ts +1 -1
- package/build/esm/Portal/Portal.js +6 -5
- package/build/esm/Portal/Portal.js.map +1 -1
- package/build/esm/RadioButton/RadioButton.d.ts +7 -7
- package/build/esm/RadioButton/RadioButton.js +12 -13
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +8 -8
- package/build/esm/RadioButton/RadioGroup.js +22 -16
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +2 -2
- package/build/esm/RadioButton/context.js +6 -5
- package/build/esm/RadioButton/context.js.map +1 -1
- package/build/esm/SkipNav/SkipNav.d.ts +6 -6
- package/build/esm/SkipNav/SkipNav.js +5 -6
- package/build/esm/SkipNav/SkipNav.js.map +1 -1
- package/build/esm/Spinner/Spinner.d.ts +7 -7
- package/build/esm/Spinner/Spinner.js +41 -31
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.d.ts +6 -6
- package/build/esm/Spinner/SpinnerButton.js +11 -12
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.d.ts +2 -2
- package/build/esm/Spinner/context.js +6 -5
- package/build/esm/Spinner/context.js.map +1 -1
- package/build/esm/Tabs/Tab.d.ts +6 -6
- package/build/esm/Tabs/Tab.js +29 -29
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.d.ts +6 -6
- package/build/esm/Tabs/TabList.js +24 -21
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +6 -6
- package/build/esm/Tabs/TabPanel.js +12 -12
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.d.ts +5 -5
- package/build/esm/Tabs/TabPanels.js +13 -12
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.d.ts +6 -6
- package/build/esm/Tabs/Tabs.js +27 -14
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.d.ts +3 -3
- package/build/esm/Tabs/context.js +12 -10
- package/build/esm/Tabs/context.js.map +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +7 -7
- package/build/esm/Tooltip/Tooltip.js +18 -16
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/stateMachine.js +56 -80
- package/build/esm/Tooltip/stateMachine.js.map +1 -1
- package/build/esm/Tooltip/useTooltip.d.ts +7 -7
- package/build/esm/Tooltip/useTooltip.js +32 -30
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/useAutoFocus.d.ts +2 -2
- package/build/esm/hooks/useAutoFocus.js +1 -1
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.d.ts +1 -1
- package/build/esm/hooks/useChildrenCounter.js +6 -4
- package/build/esm/hooks/useChildrenCounter.js.map +1 -1
- package/build/esm/hooks/useControlledState.d.ts +3 -7
- package/build/esm/hooks/useControlledState.js +7 -2
- package/build/esm/hooks/useControlledState.js.map +1 -1
- package/build/esm/hooks/useFocusReturn.d.ts +1 -1
- package/build/esm/hooks/useFocusReturn.js +6 -6
- package/build/esm/hooks/useFocusReturn.js.map +1 -1
- package/build/esm/hooks/useFocusState.d.ts +3 -3
- package/build/esm/hooks/useFocusState.js +13 -9
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +5 -5
- package/build/esm/hooks/useGestureHandlers.js +59 -63
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useMeasure.d.ts +2 -2
- package/build/esm/hooks/useMeasure.js +13 -7
- package/build/esm/hooks/useMeasure.js.map +1 -1
- package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
- package/build/esm/hooks/useOnClickOutside.js +5 -4
- package/build/esm/hooks/useOnClickOutside.js.map +1 -1
- package/build/esm/hooks/useOnKeyDown.js +4 -3
- package/build/esm/hooks/useOnKeyDown.js.map +1 -1
- package/build/esm/hooks/useReducerMachine.d.ts +1 -1
- package/build/esm/hooks/useReducerMachine.js +13 -10
- package/build/esm/hooks/useReducerMachine.js.map +1 -1
- package/build/esm/hooks/useRemoveBodyScroll.js +4 -4
- package/build/esm/hooks/useRemoveBodyScroll.js.map +1 -1
- package/build/esm/hooks/useScope.d.ts +1 -1
- package/build/esm/hooks/useScope.js +10 -12
- package/build/esm/hooks/useScope.js.map +1 -1
- package/build/esm/hooks/useThrottle.js +10 -5
- package/build/esm/hooks/useThrottle.js.map +1 -1
- package/build/esm/utils/assignRef.d.ts +1 -1
- package/build/esm/utils/assignRef.js +7 -3
- package/build/esm/utils/assignRef.js.map +1 -1
- package/build/esm/utils/createSubscription.js +7 -5
- package/build/esm/utils/createSubscription.js.map +1 -1
- package/build/esm/utils/rubberBandClamp.js +5 -2
- package/build/esm/utils/rubberBandClamp.js.map +1 -1
- package/build/esm/utils/wrapEvent.d.ts +3 -3
- package/build/esm/utils/wrapEvent.js +7 -3
- package/build/esm/utils/wrapEvent.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Accordion/Accordion.story.tsx +1 -0
- package/src/Accordion/Accordion.tsx +15 -7
- package/src/Accordion/AccordionBody.tsx +7 -8
- package/src/Accordion/AccordionHeader.tsx +35 -33
- package/src/Accordion/AccordionItem.tsx +15 -7
- package/src/Accordion/context.ts +5 -3
- package/src/CheckBox/CheckBox.tsx +6 -6
- package/src/ComboBox/ComboBox.story.tsx +5 -5
- package/src/ComboBox/Combobox.tsx +12 -17
- package/src/ComboBox/ComboboxButton.tsx +16 -15
- package/src/ComboBox/ComboboxInput.tsx +19 -10
- package/src/ComboBox/ComboboxLabel.tsx +5 -4
- package/src/ComboBox/ComboboxList.tsx +6 -6
- package/src/ComboBox/ComboboxOption.tsx +11 -7
- package/src/ComboBox/ComboboxPopover.tsx +14 -8
- package/src/ComboBox/context.ts +14 -12
- package/src/ComboBox/hooks.tsx +9 -11
- package/src/FocusLock/FocusLock.tsx +14 -7
- package/src/FocusLock/useFocusLock.ts +5 -3
- package/src/List/List.tsx +5 -5
- package/src/List/ListItem.tsx +5 -5
- package/src/Menu/Menu.story.tsx +7 -6
- package/src/Menu/Menu.tsx +16 -8
- package/src/Menu/MenuButton.tsx +15 -16
- package/src/Menu/MenuItem.tsx +15 -10
- package/src/Menu/MenuList.tsx +8 -12
- package/src/Menu/MenuPopover.tsx +7 -5
- package/src/Menu/context.ts +10 -4
- package/src/Modal/Modal.story.tsx +1 -0
- package/src/Modal/Modal.tsx +12 -6
- package/src/Modal/ModalBackdrop.tsx +15 -9
- package/src/Modal/NavDrawer.story.tsx +3 -3
- package/src/Popper/Popper.story.tsx +3 -4
- package/src/Popper/Popper.tsx +13 -12
- package/src/Popper/PopperArrow.tsx +5 -4
- package/src/Popper/context.ts +2 -1
- package/src/Portal/Portal.tsx +1 -1
- package/src/RadioButton/RadioButton.story.tsx +1 -0
- package/src/RadioButton/RadioButton.tsx +14 -7
- package/src/RadioButton/RadioGroup.tsx +14 -10
- package/src/RadioButton/context.ts +2 -4
- package/src/SkipNav/SkipNav.tsx +5 -5
- package/src/Spinner/Spinner.story.tsx +1 -0
- package/src/Spinner/Spinner.tsx +14 -9
- package/src/Spinner/SpinnerButton.tsx +12 -6
- package/src/Spinner/context.ts +2 -3
- package/src/Tabs/Tab.story.tsx +1 -0
- package/src/Tabs/Tab.tsx +16 -11
- package/src/Tabs/TabList.tsx +6 -5
- package/src/Tabs/TabPanel.tsx +6 -5
- package/src/Tabs/TabPanels.tsx +4 -4
- package/src/Tabs/Tabs.tsx +6 -7
- package/src/Tabs/context.ts +4 -4
- package/src/Tooltip/Tooltip.story.tsx +3 -2
- package/src/Tooltip/Tooltip.tsx +11 -9
- package/src/Tooltip/stateMachine.ts +1 -1
- package/src/Tooltip/useTooltip.ts +19 -10
- package/src/hooks/useAutoFocus.ts +3 -1
- package/src/hooks/useChildrenCounter.ts +2 -1
- package/src/hooks/useControlledState.ts +7 -8
- package/src/hooks/useFocusReturn.ts +2 -1
- package/src/hooks/useFocusState.ts +4 -2
- package/src/hooks/useGestureHandlers.ts +11 -7
- package/src/hooks/useMeasure.ts +2 -1
- package/src/hooks/useOnClickOutside.ts +2 -2
- package/src/hooks/useReducerMachine.ts +2 -1
- package/src/hooks/useScope.ts +2 -1
- package/src/utils/assignRef.ts +1 -1
- 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
|
-
|
|
8
|
+
|
|
3
9
|
import { useSpinnerContext } from './context';
|
|
4
10
|
import { wrapEvent } from '../utils';
|
|
5
11
|
|
|
6
12
|
export interface SpinnerButtonProps
|
|
7
|
-
extends Omit<
|
|
8
|
-
as?:
|
|
9
|
-
innerAs?:
|
|
10
|
-
children?:
|
|
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:
|
|
29
|
+
const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
24
30
|
const delta = type === 'next' ? 1 : -1;
|
|
25
31
|
|
|
26
32
|
spinnerContext.onChange &&
|
package/src/Spinner/context.ts
CHANGED
|
@@ -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;
|
package/src/Tabs/Tab.story.tsx
CHANGED
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
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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:
|
|
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 =
|
|
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:
|
|
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
|
|
package/src/Tabs/TabList.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|
|
15
|
-
as?:
|
|
16
|
-
innerAs?:
|
|
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?:
|
|
20
|
+
children?: ReactNode;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export const TabList = forwardRef<HTMLDivElement, TabListProps>(
|
package/src/Tabs/TabPanel.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
1
2
|
import { forwardRef } from 'react';
|
|
2
|
-
|
|
3
|
+
|
|
3
4
|
import { useTabsContext } from './context';
|
|
4
5
|
|
|
5
|
-
export interface TabPanelProps extends
|
|
6
|
-
as?:
|
|
7
|
-
innerAs?:
|
|
8
|
-
children?:
|
|
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
|
|
package/src/Tabs/TabPanels.tsx
CHANGED
|
@@ -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?:
|
|
6
|
-
innerAs?:
|
|
5
|
+
as?: ElementType<any>;
|
|
6
|
+
innerAs?: ElementType<any>;
|
|
7
7
|
lazy?: boolean;
|
|
8
|
-
children?:
|
|
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
|
-
|
|
3
|
+
|
|
3
4
|
import { TabsProvider } from './context';
|
|
4
5
|
import { useControlledState } from '../hooks';
|
|
5
6
|
|
|
6
7
|
export interface TabsProps {
|
|
7
|
-
as?:
|
|
8
|
-
innerAs?:
|
|
9
|
-
children?:
|
|
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;
|
package/src/Tabs/context.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
1
2
|
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
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
|
|
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 {
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
12
|
-
as?:
|
|
13
|
-
innerAs?:
|
|
14
|
-
children?:
|
|
15
|
-
label:
|
|
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 {
|
|
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 =
|
|
28
|
+
export type ChildProps = HTMLAttributes<HTMLElement> &
|
|
20
29
|
RefAttributes<HTMLElement>;
|
|
21
30
|
|
|
22
|
-
export interface InjectedTooltipProps
|
|
23
|
-
|
|
24
|
-
anchorEl: React.RefObject<HTMLElement>;
|
|
31
|
+
export interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {
|
|
32
|
+
anchorEl: RefObject<HTMLElement>;
|
|
25
33
|
visible: boolean;
|
|
26
|
-
children?:
|
|
34
|
+
children?: ReactNode;
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
export function useTooltip(
|
|
30
38
|
childProps: ChildProps,
|
|
31
|
-
childRef:
|
|
32
|
-
tooltipProps:
|
|
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:
|
|
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 &&
|
|
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:
|
|
8
|
+
elementRef: MutableRefObject<HTMLElement | null>
|
|
7
9
|
) {
|
|
8
10
|
useEffect(() => {
|
|
9
11
|
if (open) {
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';
|
|
1
2
|
import { useRef, useState } from 'react';
|
|
2
|
-
|
|
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
|
|
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:
|
|
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,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?:
|
|
7
|
-
onBlur?:
|
|
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:
|
|
30
|
-
onTouchStart: (e:
|
|
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?:
|
|
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:
|
|
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:
|
|
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:
|
|
258
|
+
containerRef: MutableRefObject<HTMLElement | null> | undefined,
|
|
255
259
|
onGesture: (e: GestureHandlersState) => void,
|
|
256
260
|
options: GestureHandlerOptions = {}
|
|
257
261
|
) => {
|
package/src/hooks/useMeasure.ts
CHANGED
|
@@ -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:
|
|
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:
|
|
5
|
+
ref: RefObject<any>,
|
|
6
6
|
handler: (e: PointerEvent) => void,
|
|
7
7
|
active = true
|
|
8
8
|
) {
|
package/src/hooks/useScope.ts
CHANGED
package/src/utils/assignRef.ts
CHANGED
package/src/utils/wrapEvent.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import type { SyntheticEvent } from 'react';
|
|
2
|
+
|
|
1
3
|
export type CustomEventHandler<
|
|
2
|
-
E extends
|
|
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> {
|