@basic-ui/core 0.0.40 → 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.map +1 -1
- package/build/esm/Accordion/Accordion.d.ts +7 -7
- package/build/esm/Accordion/Accordion.js +0 -1
- package/build/esm/Accordion/Accordion.js.map +1 -1
- package/build/esm/Accordion/AccordionBody.d.ts +5 -5
- package/build/esm/Accordion/AccordionBody.js +0 -1
- package/build/esm/Accordion/AccordionBody.js.map +1 -1
- package/build/esm/Accordion/AccordionHeader.d.ts +6 -6
- package/build/esm/Accordion/AccordionHeader.js +0 -1
- package/build/esm/Accordion/AccordionHeader.js.map +1 -1
- package/build/esm/Accordion/AccordionItem.d.ts +7 -7
- package/build/esm/Accordion/AccordionItem.js +0 -1
- package/build/esm/Accordion/AccordionItem.js.map +1 -1
- package/build/esm/Accordion/context.d.ts +3 -3
- package/build/esm/Accordion/context.js +0 -0
- package/build/esm/Accordion/context.js.map +1 -1
- package/build/esm/Accordion/index.js +0 -0
- package/build/esm/Accordion/scopeQuery.js +0 -0
- package/build/esm/CheckBox/CheckBox.d.ts +6 -6
- package/build/esm/CheckBox/CheckBox.js +0 -1
- package/build/esm/CheckBox/CheckBox.js.map +1 -1
- package/build/esm/CheckBox/index.js +0 -0
- package/build/esm/ComboBox/Combobox.d.ts +10 -10
- package/build/esm/ComboBox/Combobox.js +0 -1
- package/build/esm/ComboBox/Combobox.js.map +1 -1
- package/build/esm/ComboBox/ComboboxButton.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxButton.js +0 -1
- package/build/esm/ComboBox/ComboboxButton.js.map +1 -1
- package/build/esm/ComboBox/ComboboxInput.d.ts +10 -10
- package/build/esm/ComboBox/ComboboxInput.js +0 -1
- package/build/esm/ComboBox/ComboboxInput.js.map +1 -1
- package/build/esm/ComboBox/ComboboxLabel.d.ts +5 -5
- package/build/esm/ComboBox/ComboboxLabel.js +0 -1
- package/build/esm/ComboBox/ComboboxLabel.js.map +1 -1
- package/build/esm/ComboBox/ComboboxList.d.ts +6 -6
- package/build/esm/ComboBox/ComboboxList.js +0 -1
- package/build/esm/ComboBox/ComboboxList.js.map +1 -1
- package/build/esm/ComboBox/ComboboxOption.d.ts +7 -7
- package/build/esm/ComboBox/ComboboxOption.js +0 -1
- package/build/esm/ComboBox/ComboboxOption.js.map +1 -1
- package/build/esm/ComboBox/ComboboxPopover.d.ts +8 -8
- package/build/esm/ComboBox/ComboboxPopover.js +0 -1
- package/build/esm/ComboBox/ComboboxPopover.js.map +1 -1
- package/build/esm/ComboBox/cities.js +0 -0
- package/build/esm/ComboBox/context.d.ts +10 -10
- package/build/esm/ComboBox/context.js +0 -0
- package/build/esm/ComboBox/context.js.map +1 -1
- package/build/esm/ComboBox/hooks.d.ts +3 -3
- package/build/esm/ComboBox/hooks.js +0 -0
- package/build/esm/ComboBox/hooks.js.map +1 -1
- package/build/esm/ComboBox/index.js +0 -0
- package/build/esm/ComboBox/makeHash.js +0 -0
- package/build/esm/ComboBox/scopeQuery.js +0 -0
- package/build/esm/FocusLock/FocusLock.d.ts +7 -7
- package/build/esm/FocusLock/FocusLock.js +0 -1
- package/build/esm/FocusLock/FocusLock.js.map +1 -1
- package/build/esm/FocusLock/index.js +0 -0
- package/build/esm/FocusLock/tabUtils.js +0 -0
- package/build/esm/FocusLock/useFocusLock.d.ts +4 -4
- package/build/esm/FocusLock/useFocusLock.js +0 -0
- package/build/esm/FocusLock/useFocusLock.js.map +1 -1
- package/build/esm/List/List.d.ts +6 -6
- package/build/esm/List/List.js +0 -1
- package/build/esm/List/List.js.map +1 -1
- package/build/esm/List/ListItem.d.ts +6 -6
- package/build/esm/List/ListItem.js +0 -1
- package/build/esm/List/ListItem.js.map +1 -1
- package/build/esm/List/context.js +0 -0
- package/build/esm/List/index.js +0 -0
- package/build/esm/Menu/Menu.d.ts +6 -6
- package/build/esm/Menu/Menu.js +0 -1
- package/build/esm/Menu/Menu.js.map +1 -1
- package/build/esm/Menu/MenuButton.d.ts +10 -10
- package/build/esm/Menu/MenuButton.js +0 -1
- package/build/esm/Menu/MenuButton.js.map +1 -1
- package/build/esm/Menu/MenuItem.d.ts +6 -6
- package/build/esm/Menu/MenuItem.js +0 -1
- package/build/esm/Menu/MenuItem.js.map +1 -1
- package/build/esm/Menu/MenuList.d.ts +5 -5
- package/build/esm/Menu/MenuList.js +0 -1
- package/build/esm/Menu/MenuList.js.map +1 -1
- package/build/esm/Menu/MenuPopover.d.ts +5 -5
- package/build/esm/Menu/MenuPopover.js +0 -1
- package/build/esm/Menu/MenuPopover.js.map +1 -1
- package/build/esm/Menu/context.d.ts +2 -2
- package/build/esm/Menu/context.js +0 -0
- package/build/esm/Menu/context.js.map +1 -1
- package/build/esm/Menu/index.js +0 -0
- package/build/esm/Menu/scope.js +0 -0
- package/build/esm/Modal/Modal.d.ts +6 -7
- package/build/esm/Modal/Modal.js +0 -1
- package/build/esm/Modal/Modal.js.map +1 -1
- package/build/esm/Modal/ModalBackdrop.d.ts +6 -6
- package/build/esm/Modal/ModalBackdrop.js +0 -1
- package/build/esm/Modal/ModalBackdrop.js.map +1 -1
- package/build/esm/Modal/index.js +0 -0
- package/build/esm/Popper/Popper.d.ts +7 -7
- package/build/esm/Popper/Popper.js +0 -1
- package/build/esm/Popper/Popper.js.map +1 -1
- package/build/esm/Popper/PopperArrow.d.ts +5 -5
- package/build/esm/Popper/PopperArrow.js +0 -1
- package/build/esm/Popper/PopperArrow.js.map +1 -1
- package/build/esm/Popper/context.js +0 -0
- package/build/esm/Popper/index.js +0 -0
- package/build/esm/Portal/Portal.js +0 -0
- package/build/esm/Portal/index.js +0 -0
- package/build/esm/RadioButton/RadioButton.d.ts +6 -6
- package/build/esm/RadioButton/RadioButton.js +0 -1
- package/build/esm/RadioButton/RadioButton.js.map +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +7 -7
- package/build/esm/RadioButton/RadioGroup.js +0 -1
- package/build/esm/RadioButton/RadioGroup.js.map +1 -1
- package/build/esm/RadioButton/context.d.ts +2 -2
- package/build/esm/RadioButton/context.js +0 -0
- package/build/esm/RadioButton/context.js.map +1 -1
- package/build/esm/RadioButton/index.js +0 -0
- package/build/esm/SkipNav/SkipNav.d.ts +6 -6
- package/build/esm/SkipNav/SkipNav.js +0 -1
- package/build/esm/SkipNav/SkipNav.js.map +1 -1
- package/build/esm/SkipNav/index.js +0 -0
- package/build/esm/Spinner/Spinner.d.ts +7 -7
- package/build/esm/Spinner/Spinner.js +0 -1
- package/build/esm/Spinner/Spinner.js.map +1 -1
- package/build/esm/Spinner/SpinnerButton.d.ts +6 -6
- package/build/esm/Spinner/SpinnerButton.js +0 -1
- package/build/esm/Spinner/SpinnerButton.js.map +1 -1
- package/build/esm/Spinner/context.d.ts +2 -2
- package/build/esm/Spinner/context.js +0 -0
- package/build/esm/Spinner/context.js.map +1 -1
- package/build/esm/Spinner/index.js +0 -0
- package/build/esm/Tabs/Tab.d.ts +6 -6
- package/build/esm/Tabs/Tab.js +0 -1
- package/build/esm/Tabs/Tab.js.map +1 -1
- package/build/esm/Tabs/TabList.d.ts +6 -6
- package/build/esm/Tabs/TabList.js +0 -1
- package/build/esm/Tabs/TabList.js.map +1 -1
- package/build/esm/Tabs/TabPanel.d.ts +6 -6
- package/build/esm/Tabs/TabPanel.js +0 -1
- package/build/esm/Tabs/TabPanel.js.map +1 -1
- package/build/esm/Tabs/TabPanels.d.ts +5 -5
- package/build/esm/Tabs/TabPanels.js +0 -1
- package/build/esm/Tabs/TabPanels.js.map +1 -1
- package/build/esm/Tabs/Tabs.d.ts +6 -6
- package/build/esm/Tabs/Tabs.js +0 -1
- package/build/esm/Tabs/Tabs.js.map +1 -1
- package/build/esm/Tabs/context.d.ts +2 -2
- package/build/esm/Tabs/context.js +0 -0
- package/build/esm/Tabs/context.js.map +1 -1
- package/build/esm/Tabs/index.js +0 -0
- package/build/esm/Tabs/scopeQuery.js +0 -0
- package/build/esm/Tooltip/Tooltip.d.ts +7 -8
- package/build/esm/Tooltip/Tooltip.js +1 -1
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/Tooltip/index.js +0 -0
- package/build/esm/Tooltip/stateMachine.js +0 -0
- package/build/esm/Tooltip/useTooltip.d.ts +7 -7
- package/build/esm/Tooltip/useTooltip.js +0 -0
- package/build/esm/Tooltip/useTooltip.js.map +1 -1
- package/build/esm/hooks/index.js +0 -0
- package/build/esm/hooks/useAutoFocus.d.ts +2 -2
- package/build/esm/hooks/useAutoFocus.js +0 -0
- package/build/esm/hooks/useAutoFocus.js.map +1 -1
- package/build/esm/hooks/useChildrenCounter.js +0 -0
- package/build/esm/hooks/useControlledState.d.ts +2 -6
- package/build/esm/hooks/useControlledState.js +0 -0
- package/build/esm/hooks/useControlledState.js.map +1 -1
- package/build/esm/hooks/useFocusReturn.js +0 -0
- package/build/esm/hooks/useFocusState.d.ts +3 -3
- package/build/esm/hooks/useFocusState.js +0 -0
- package/build/esm/hooks/useFocusState.js.map +1 -1
- package/build/esm/hooks/useGestureHandlers.d.ts +5 -5
- package/build/esm/hooks/useGestureHandlers.js +0 -0
- package/build/esm/hooks/useGestureHandlers.js.map +1 -1
- package/build/esm/hooks/useMeasure.d.ts +2 -2
- package/build/esm/hooks/useMeasure.js +0 -0
- package/build/esm/hooks/useMeasure.js.map +1 -1
- package/build/esm/hooks/useOnClickOutside.d.ts +2 -2
- package/build/esm/hooks/useOnClickOutside.js +0 -0
- package/build/esm/hooks/useOnClickOutside.js.map +1 -1
- package/build/esm/hooks/useOnKeyDown.js +0 -0
- package/build/esm/hooks/useReducerMachine.js +0 -0
- package/build/esm/hooks/useRemoveBodyScroll.js +0 -0
- package/build/esm/hooks/useScope.js +0 -0
- package/build/esm/hooks/useThrottle.js +0 -0
- package/build/esm/index.js +0 -0
- package/build/esm/utils/assignRef.js +0 -0
- package/build/esm/utils/clamp.js +0 -0
- package/build/esm/utils/createSubscription.js +0 -0
- package/build/esm/utils/getCircularIndex.js +0 -0
- package/build/esm/utils/index.js +0 -0
- package/build/esm/utils/rubberBandClamp.js +0 -0
- package/build/esm/utils/wrapEvent.d.ts +3 -3
- package/build/esm/utils/wrapEvent.js +0 -0
- 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.tsx +12 -6
- package/src/Accordion/AccordionBody.tsx +4 -5
- package/src/Accordion/AccordionHeader.tsx +30 -27
- package/src/Accordion/AccordionItem.tsx +12 -6
- package/src/Accordion/context.ts +3 -2
- package/src/CheckBox/CheckBox.tsx +5 -6
- package/src/ComboBox/ComboBox.story.tsx +3 -3
- package/src/ComboBox/Combobox.tsx +5 -8
- package/src/ComboBox/ComboboxButton.tsx +13 -7
- package/src/ComboBox/ComboboxInput.tsx +18 -10
- package/src/ComboBox/ComboboxLabel.tsx +4 -4
- package/src/ComboBox/ComboboxList.tsx +5 -6
- package/src/ComboBox/ComboboxOption.tsx +11 -7
- package/src/ComboBox/ComboboxPopover.tsx +13 -8
- package/src/ComboBox/context.ts +10 -9
- package/src/ComboBox/hooks.tsx +3 -2
- package/src/FocusLock/FocusLock.tsx +13 -7
- package/src/FocusLock/useFocusLock.ts +4 -3
- package/src/List/List.tsx +5 -5
- package/src/List/ListItem.tsx +5 -5
- package/src/Menu/Menu.story.tsx +2 -2
- package/src/Menu/Menu.tsx +13 -7
- package/src/Menu/MenuButton.tsx +12 -9
- package/src/Menu/MenuItem.tsx +14 -10
- package/src/Menu/MenuList.tsx +5 -5
- package/src/Menu/MenuPopover.tsx +4 -4
- package/src/Menu/context.ts +9 -4
- package/src/Modal/Modal.tsx +10 -6
- package/src/Modal/ModalBackdrop.tsx +14 -9
- package/src/Popper/Popper.tsx +6 -6
- package/src/Popper/PopperArrow.tsx +4 -4
- package/src/RadioButton/RadioButton.tsx +11 -6
- package/src/RadioButton/RadioGroup.tsx +11 -9
- package/src/RadioButton/context.ts +2 -4
- package/src/SkipNav/SkipNav.tsx +5 -5
- package/src/Spinner/Spinner.tsx +13 -9
- package/src/Spinner/SpinnerButton.tsx +11 -6
- package/src/Spinner/context.ts +2 -3
- package/src/Tabs/Tab.tsx +13 -8
- package/src/Tabs/TabList.tsx +5 -5
- package/src/Tabs/TabPanel.tsx +5 -5
- package/src/Tabs/TabPanels.tsx +4 -4
- package/src/Tabs/Tabs.tsx +5 -7
- package/src/Tabs/context.ts +2 -3
- package/src/Tooltip/Tooltip.story.tsx +1 -1
- package/src/Tooltip/Tooltip.tsx +13 -7
- package/src/Tooltip/useTooltip.ts +15 -9
- package/src/hooks/useAutoFocus.ts +2 -1
- package/src/hooks/useControlledState.ts +4 -7
- package/src/hooks/useFocusState.ts +3 -2
- package/src/hooks/useGestureHandlers.ts +11 -7
- package/src/hooks/useMeasure.ts +2 -1
- package/src/hooks/useOnClickOutside.ts +2 -2
- package/src/utils/wrapEvent.ts +4 -5
|
@@ -1,15 +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 * as React from 'react';
|
|
3
9
|
|
|
4
10
|
import { assignMultipleRefs } from '../utils/assignRef';
|
|
5
11
|
import { wrapEvent } from '../utils/wrapEvent';
|
|
6
12
|
|
|
7
|
-
export interface ModalBackdropProps
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
innerAs?: React.ElementType<any>;
|
|
13
|
+
export interface ModalBackdropProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
as?: ElementType<any>;
|
|
15
|
+
innerAs?: ElementType<any>;
|
|
11
16
|
onClose?: () => void;
|
|
12
|
-
style?:
|
|
17
|
+
style?: CSSProperties;
|
|
13
18
|
disableCloseOnClick?: boolean;
|
|
14
19
|
disableEscapeKeyDown?: boolean;
|
|
15
20
|
}
|
|
@@ -31,7 +36,7 @@ export const ModalBackdrop = forwardRef<HTMLDivElement, ModalBackdropProps>(
|
|
|
31
36
|
const ref = useRef();
|
|
32
37
|
const mouseDownTargetRef = useRef<EventTarget | null>(null);
|
|
33
38
|
|
|
34
|
-
const handleClick = (e:
|
|
39
|
+
const handleClick = (e: MouseEvent<HTMLDivElement>) => {
|
|
35
40
|
// Ignore the events not coming from the "backdrop"
|
|
36
41
|
// We don't want to close the dialog when clicking the dialog content.
|
|
37
42
|
if (e.target !== e.currentTarget) {
|
|
@@ -48,11 +53,11 @@ export const ModalBackdrop = forwardRef<HTMLDivElement, ModalBackdropProps>(
|
|
|
48
53
|
e.stopPropagation();
|
|
49
54
|
};
|
|
50
55
|
|
|
51
|
-
const handleMouseDown = (e:
|
|
56
|
+
const handleMouseDown = (e: MouseEvent<HTMLDivElement>) => {
|
|
52
57
|
mouseDownTargetRef.current = e.target;
|
|
53
58
|
};
|
|
54
59
|
|
|
55
|
-
const handleKeyDown = (e:
|
|
60
|
+
const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
56
61
|
if (e.key === 'Escape') {
|
|
57
62
|
!disableEscapeKeyDown && onClose?.();
|
|
58
63
|
e.stopPropagation();
|
package/src/Popper/Popper.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HTMLAttributes, ElementType, RefObject, ReactNode } from 'react';
|
|
1
2
|
import {
|
|
2
3
|
forwardRef,
|
|
3
4
|
useRef,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
useMemo,
|
|
7
8
|
memo,
|
|
8
9
|
} from 'react';
|
|
9
|
-
import * as React from 'react';
|
|
10
10
|
import type {
|
|
11
11
|
Placement,
|
|
12
12
|
Modifier,
|
|
@@ -32,11 +32,11 @@ export type OffsetsFunction = (arg0: {
|
|
|
32
32
|
placement: Placement;
|
|
33
33
|
}) => [number | null | undefined, number | null | undefined];
|
|
34
34
|
|
|
35
|
-
export interface PopperProps extends
|
|
36
|
-
as?:
|
|
37
|
-
innerAs?:
|
|
38
|
-
anchorEl:
|
|
39
|
-
children?:
|
|
35
|
+
export interface PopperProps extends HTMLAttributes<HTMLDivElement> {
|
|
36
|
+
as?: ElementType<any>;
|
|
37
|
+
innerAs?: ElementType<any>;
|
|
38
|
+
anchorEl: RefObject<HTMLElement>;
|
|
39
|
+
children?: ReactNode;
|
|
40
40
|
placement?: Placement;
|
|
41
41
|
strategy?: PositioningStrategy;
|
|
42
42
|
modifiers?: Array<Partial<Modifier<any, any>>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes } from 'react';
|
|
1
2
|
import { forwardRef } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import { usePopperContext } from './context';
|
|
5
5
|
import { assignRef } from '../utils/assignRef';
|
|
6
6
|
|
|
7
|
-
export interface PopperArrowProps extends
|
|
8
|
-
as?:
|
|
9
|
-
innerAs?:
|
|
7
|
+
export interface PopperArrowProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
as?: ElementType<any>;
|
|
9
|
+
innerAs?: ElementType<any>;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const PopperArrow = forwardRef<HTMLDivElement, PopperArrowProps>(
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
ElementType,
|
|
4
|
+
InputHTMLAttributes,
|
|
5
|
+
ReactNode,
|
|
6
|
+
} from 'react';
|
|
1
7
|
import { forwardRef } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
8
|
|
|
4
9
|
import type { RadioValue } from './context';
|
|
5
10
|
import { useRadioGroupContext } from './context';
|
|
6
11
|
import { wrapEvent } from '../utils';
|
|
7
12
|
|
|
8
13
|
export interface RadioButtonProps
|
|
9
|
-
extends Omit<
|
|
10
|
-
as?:
|
|
11
|
-
innerAs?:
|
|
12
|
-
children?:
|
|
14
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value'> {
|
|
15
|
+
as?: ElementType<any>;
|
|
16
|
+
innerAs?: ElementType<any>;
|
|
17
|
+
children?: ReactNode;
|
|
13
18
|
checked?: boolean;
|
|
14
19
|
value: RadioValue;
|
|
15
20
|
}
|
|
@@ -26,7 +31,7 @@ export const RadioButton = forwardRef<HTMLInputElement, RadioButtonProps>(
|
|
|
26
31
|
} = props;
|
|
27
32
|
const radioGroupContext = useRadioGroupContext();
|
|
28
33
|
|
|
29
|
-
const handleChange = (e:
|
|
34
|
+
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
30
35
|
radioGroupContext?.onChange?.(e, valueProp);
|
|
31
36
|
};
|
|
32
37
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
ElementType,
|
|
4
|
+
HTMLAttributes,
|
|
5
|
+
ReactNode,
|
|
6
|
+
} from 'react';
|
|
1
7
|
import { forwardRef, useId } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
8
|
|
|
4
9
|
import type { RadioValue } from './context';
|
|
5
10
|
import { RadioGroupProvider } from './context';
|
|
@@ -7,19 +12,16 @@ import { useControlledState } from '../hooks';
|
|
|
7
12
|
|
|
8
13
|
export interface RadioGroupProps
|
|
9
14
|
extends Omit<
|
|
10
|
-
|
|
15
|
+
HTMLAttributes<HTMLDivElement>,
|
|
11
16
|
'onChange' | 'value' | 'defaultValue'
|
|
12
17
|
> {
|
|
13
|
-
as?:
|
|
14
|
-
innerAs?:
|
|
15
|
-
children?:
|
|
18
|
+
as?: ElementType<any>;
|
|
19
|
+
innerAs?: ElementType<any>;
|
|
20
|
+
children?: ReactNode;
|
|
16
21
|
value?: RadioValue;
|
|
17
22
|
defaultValue?: RadioValue;
|
|
18
23
|
name?: string;
|
|
19
|
-
onChange?: (
|
|
20
|
-
e: React.ChangeEvent<HTMLInputElement>,
|
|
21
|
-
value: RadioValue
|
|
22
|
-
) => void;
|
|
24
|
+
onChange?: (e: ChangeEvent<HTMLInputElement>, value: RadioValue) => void;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
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
|
|
package/src/SkipNav/SkipNav.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
1
2
|
import { forwardRef } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
export interface SkipNavProps extends
|
|
5
|
-
as?:
|
|
6
|
-
innerAs?:
|
|
7
|
-
children?:
|
|
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>(
|
package/src/Spinner/Spinner.tsx
CHANGED
|
@@ -1,23 +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 * as React from 'react';
|
|
3
9
|
|
|
4
10
|
import { SpinnerProvider } from './context';
|
|
5
11
|
import { clamp as clampFunc } from '../utils/clamp';
|
|
6
12
|
import { wrapEvent, assignMultipleRefs } from '../utils';
|
|
7
13
|
|
|
8
14
|
export interface SpinnerProps
|
|
9
|
-
extends Omit<
|
|
10
|
-
as?:
|
|
11
|
-
innerAs?:
|
|
12
|
-
children?:
|
|
15
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
16
|
+
as?: ElementType<any>;
|
|
17
|
+
innerAs?: ElementType<any>;
|
|
18
|
+
children?: ReactNode;
|
|
13
19
|
value?: number;
|
|
14
20
|
minValue?: number;
|
|
15
21
|
maxValue?: number;
|
|
16
22
|
stepSize?: number;
|
|
17
23
|
onChange?: (
|
|
18
|
-
e:
|
|
19
|
-
| React.MouseEvent<HTMLButtonElement>
|
|
20
|
-
| React.KeyboardEvent<HTMLDivElement>,
|
|
24
|
+
e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLDivElement>,
|
|
21
25
|
value: number
|
|
22
26
|
) => void;
|
|
23
27
|
}
|
|
@@ -41,7 +45,7 @@ export const Spinner = forwardRef<HTMLDivElement, SpinnerProps>(
|
|
|
41
45
|
|
|
42
46
|
const clamp = (value: number) => clampFunc(value, minValue, maxValue);
|
|
43
47
|
|
|
44
|
-
const handleKeyDown = (e:
|
|
48
|
+
const handleKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
45
49
|
let nextValue = value;
|
|
46
50
|
switch (e.key) {
|
|
47
51
|
case 'ArrowUp':
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ButtonHTMLAttributes,
|
|
3
|
+
ElementType,
|
|
4
|
+
MouseEvent,
|
|
5
|
+
ReactNode,
|
|
6
|
+
} from 'react';
|
|
1
7
|
import { forwardRef } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
8
|
|
|
4
9
|
import { useSpinnerContext } from './context';
|
|
5
10
|
import { wrapEvent } from '../utils';
|
|
6
11
|
|
|
7
12
|
export interface SpinnerButtonProps
|
|
8
|
-
extends Omit<
|
|
9
|
-
as?:
|
|
10
|
-
innerAs?:
|
|
11
|
-
children?:
|
|
13
|
+
extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
14
|
+
as?: ElementType<any>;
|
|
15
|
+
innerAs?: ElementType<any>;
|
|
16
|
+
children?: ReactNode;
|
|
12
17
|
type: 'next' | 'previous';
|
|
13
18
|
}
|
|
14
19
|
|
|
@@ -21,7 +26,7 @@ export const SpinnerButton = forwardRef<HTMLButtonElement, SpinnerButtonProps>(
|
|
|
21
26
|
throw new Error('Missing <Spinner /> in component tree');
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
const handleClick = (e:
|
|
29
|
+
const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
25
30
|
const delta = type === 'next' ? 1 : -1;
|
|
26
31
|
|
|
27
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.tsx
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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 * as React from 'react';
|
|
3
9
|
|
|
4
10
|
import { useTabsContext, useTabListContext } from './context';
|
|
5
11
|
import { assignMultipleRefs, getCircularIndex, wrapEvent } from '../utils';
|
|
@@ -24,11 +30,10 @@ function getNextIndex(
|
|
|
24
30
|
return null;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
|
-
export interface TabProps
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
children?: React.ReactNode;
|
|
33
|
+
export interface TabProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
34
|
+
as?: ElementType<any>;
|
|
35
|
+
innerAs?: ElementType<any>;
|
|
36
|
+
children?: ReactNode;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
export const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(
|
|
@@ -51,7 +56,7 @@ export const Tab = forwardRef<HTMLButtonElement, TabProps>(function Tab(
|
|
|
51
56
|
throw new Error('Missing <Tabs /> or <TabList /> in the component tree');
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
const handleKeyDown = (e:
|
|
59
|
+
const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {
|
|
55
60
|
const right = tabListContext.vertical ? 'ArrowDown' : 'ArrowRight';
|
|
56
61
|
const left = tabListContext.vertical ? 'ArrowUp' : 'ArrowLeft';
|
|
57
62
|
const first = 'Home';
|
|
@@ -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,18 +7,17 @@ import {
|
|
|
6
7
|
cloneElement,
|
|
7
8
|
useId,
|
|
8
9
|
} from 'react';
|
|
9
|
-
import * as React from 'react';
|
|
10
10
|
|
|
11
11
|
import { TabListProvider, useTabsContext } from './context';
|
|
12
12
|
import { useScope } from '../hooks';
|
|
13
13
|
import { assignMultipleRefs } from '../utils';
|
|
14
14
|
|
|
15
|
-
export interface TabListProps extends
|
|
16
|
-
as?:
|
|
17
|
-
innerAs?:
|
|
15
|
+
export interface TabListProps extends HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
as?: ElementType<any>;
|
|
17
|
+
innerAs?: ElementType<any>;
|
|
18
18
|
manualActivation?: boolean;
|
|
19
19
|
vertical?: boolean;
|
|
20
|
-
children?:
|
|
20
|
+
children?: ReactNode;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const TabList = forwardRef<HTMLDivElement, TabListProps>(
|
package/src/Tabs/TabPanel.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
1
2
|
import { forwardRef } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import { useTabsContext } from './context';
|
|
5
5
|
|
|
6
|
-
export interface TabPanelProps extends
|
|
7
|
-
as?:
|
|
8
|
-
innerAs?:
|
|
9
|
-
children?:
|
|
6
|
+
export interface TabPanelProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
as?: ElementType<any>;
|
|
8
|
+
innerAs?: ElementType<any>;
|
|
9
|
+
children?: ReactNode;
|
|
10
10
|
lazy?: boolean;
|
|
11
11
|
}
|
|
12
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 * 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,17 +1,15 @@
|
|
|
1
|
+
import type { ElementType, KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
1
2
|
import { forwardRef, Fragment, useState } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import { TabsProvider } from './context';
|
|
5
5
|
import { useControlledState } from '../hooks';
|
|
6
6
|
|
|
7
7
|
export interface TabsProps {
|
|
8
|
-
as?:
|
|
9
|
-
innerAs?:
|
|
10
|
-
children?:
|
|
8
|
+
as?: ElementType<any>;
|
|
9
|
+
innerAs?: ElementType<any>;
|
|
10
|
+
children?: ReactNode;
|
|
11
11
|
onChange?: (
|
|
12
|
-
e:
|
|
13
|
-
| React.MouseEvent<HTMLButtonElement>
|
|
14
|
-
| React.KeyboardEvent<HTMLButtonElement>,
|
|
12
|
+
e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,
|
|
15
13
|
value: number
|
|
16
14
|
) => void;
|
|
17
15
|
index?: number;
|
package/src/Tabs/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
|
import type { Scope } from '../hooks/useScope';
|
|
@@ -6,9 +7,7 @@ import type { Scope } from '../hooks/useScope';
|
|
|
6
7
|
export interface TabsContextProps {
|
|
7
8
|
currentIndex: number;
|
|
8
9
|
onChange?: (
|
|
9
|
-
e:
|
|
10
|
-
| React.MouseEvent<HTMLButtonElement>
|
|
11
|
-
| React.KeyboardEvent<HTMLButtonElement>,
|
|
10
|
+
e: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,
|
|
12
11
|
value: number
|
|
13
12
|
) => void;
|
|
14
13
|
tabListId: string | null;
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ElementType,
|
|
3
|
+
HTMLAttributes,
|
|
4
|
+
ReactElement,
|
|
5
|
+
ReactNode,
|
|
6
|
+
RefAttributes,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import { forwardRef, cloneElement, Children } from 'react';
|
|
3
9
|
|
|
4
10
|
import { useTooltip } from './useTooltip';
|
|
5
11
|
export type { InjectedTooltipProps } from './useTooltip';
|
|
6
12
|
|
|
7
|
-
export interface TooltipProps extends
|
|
8
|
-
as?:
|
|
9
|
-
innerAs?:
|
|
10
|
-
children?:
|
|
11
|
-
label:
|
|
13
|
+
export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
as?: ElementType<any>;
|
|
15
|
+
innerAs?: ElementType<any>;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
label: ReactNode;
|
|
12
18
|
disabled?: boolean;
|
|
13
19
|
}
|
|
14
20
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
HTMLAttributes,
|
|
3
|
+
KeyboardEvent,
|
|
4
|
+
ReactNode,
|
|
5
|
+
Ref,
|
|
6
|
+
RefAttributes,
|
|
7
|
+
RefObject,
|
|
8
|
+
} from 'react';
|
|
2
9
|
import { useRef, useEffect, useState, useId } from 'react';
|
|
3
10
|
|
|
4
11
|
import { assignMultipleRefs } from '../utils/assignRef';
|
|
@@ -18,20 +25,19 @@ import {
|
|
|
18
25
|
Visible,
|
|
19
26
|
} from './stateMachine';
|
|
20
27
|
|
|
21
|
-
export type ChildProps =
|
|
28
|
+
export type ChildProps = HTMLAttributes<HTMLElement> &
|
|
22
29
|
RefAttributes<HTMLElement>;
|
|
23
30
|
|
|
24
|
-
export interface InjectedTooltipProps
|
|
25
|
-
|
|
26
|
-
anchorEl: React.RefObject<HTMLElement>;
|
|
31
|
+
export interface InjectedTooltipProps extends HTMLAttributes<HTMLElement> {
|
|
32
|
+
anchorEl: RefObject<HTMLElement>;
|
|
27
33
|
visible: boolean;
|
|
28
|
-
children?:
|
|
34
|
+
children?: ReactNode;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
export function useTooltip(
|
|
32
38
|
childProps: ChildProps,
|
|
33
|
-
childRef:
|
|
34
|
-
tooltipProps:
|
|
39
|
+
childRef: Ref<HTMLElement> | undefined,
|
|
40
|
+
tooltipProps: HTMLAttributes<HTMLElement> & { label?: ReactNode }
|
|
35
41
|
): [ChildProps, InjectedTooltipProps] {
|
|
36
42
|
const {
|
|
37
43
|
onMouseEnter,
|
|
@@ -86,7 +92,7 @@ export function useTooltip(
|
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
|
|
89
|
-
function handleKeyDown(event:
|
|
95
|
+
function handleKeyDown(event: KeyboardEvent<HTMLElement>) {
|
|
90
96
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
91
97
|
send(SelectWithKeyboard);
|
|
92
98
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
1
2
|
import { useEffect } from 'react';
|
|
2
3
|
|
|
3
4
|
import { focusOnChildNode } from '../FocusLock/tabUtils';
|
|
4
5
|
|
|
5
6
|
export function useAutoFocus(
|
|
6
7
|
open: boolean,
|
|
7
|
-
elementRef:
|
|
8
|
+
elementRef: MutableRefObject<HTMLElement | null>
|
|
8
9
|
) {
|
|
9
10
|
useEffect(() => {
|
|
10
11
|
if (open) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction, SyntheticEvent } from 'react';
|
|
1
2
|
import { useRef, useState } from 'react';
|
|
2
3
|
|
|
3
4
|
import type { CustomEventHandler } from '../utils';
|
|
@@ -5,20 +6,16 @@ import { wrapEvent } from '../utils';
|
|
|
5
6
|
|
|
6
7
|
export function useControlledState<
|
|
7
8
|
V,
|
|
8
|
-
E extends
|
|
9
|
+
E extends SyntheticEvent<any>,
|
|
9
10
|
H extends unknown[]
|
|
10
11
|
>(
|
|
11
12
|
valueProp: V | undefined,
|
|
12
13
|
onChangeProp: CustomEventHandler<E, H> | undefined,
|
|
13
14
|
defaultValue: V,
|
|
14
15
|
defaultOnChange: (
|
|
15
|
-
setValue:
|
|
16
|
+
setValue: Dispatch<SetStateAction<V>>
|
|
16
17
|
) => CustomEventHandler<E, H>
|
|
17
|
-
): [
|
|
18
|
-
V,
|
|
19
|
-
CustomEventHandler<E, H> | undefined,
|
|
20
|
-
React.Dispatch<React.SetStateAction<V>>
|
|
21
|
-
] {
|
|
18
|
+
): [V, CustomEventHandler<E, H> | undefined, Dispatch<SetStateAction<V>>] {
|
|
22
19
|
const isControlled = useRef(valueProp !== undefined);
|
|
23
20
|
const [valueState, setValueState] = useState<V>(defaultValue);
|
|
24
21
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { FocusEventHandler } from 'react';
|
|
1
2
|
import { useState } from 'react';
|
|
2
3
|
|
|
3
4
|
import { wrapEvent } from '../utils/wrapEvent';
|
|
4
5
|
|
|
5
6
|
export function useFocusState<T>(
|
|
6
7
|
props: {
|
|
7
|
-
onFocus?:
|
|
8
|
-
onBlur?:
|
|
8
|
+
onFocus?: FocusEventHandler<T>;
|
|
9
|
+
onBlur?: FocusEventHandler<T>;
|
|
9
10
|
} = {}
|
|
10
11
|
) {
|
|
11
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,
|