@wonderflow/react-components 3.0.0-beta.15 → 3.0.0-beta.16
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/dropdown/dropdown.d.ts +2 -2
- package/dropdown/dropdown.js +10 -13
- package/dropdown/dropdown.module.css +1 -1
- package/package.json +1 -1
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
package/dropdown/dropdown.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, ForwardRefExoticComponent } from 'react';
|
|
1
|
+
import { ReactNode, FC, ForwardRefExoticComponent } from 'react';
|
|
2
2
|
import { DropdownMenuProps } from './menu/dropdown-menu';
|
|
3
3
|
import { DropdownItemProps } from './item/dropdown-item';
|
|
4
4
|
import { DropdownItemCheckboxProps } from './item-checkbox/dropdown-item-checkbox';
|
|
@@ -27,7 +27,7 @@ export declare type DropdownProps = PropsWithClass & {
|
|
|
27
27
|
*/
|
|
28
28
|
placement?: AutoPlacement | BasePlacement | VariationPlacement;
|
|
29
29
|
};
|
|
30
|
-
declare type DropdownComponent =
|
|
30
|
+
declare type DropdownComponent = FC<DropdownProps> & {
|
|
31
31
|
Menu: ForwardRefExoticComponent<DropdownMenuProps>;
|
|
32
32
|
Item: ForwardRefExoticComponent<DropdownItemProps>;
|
|
33
33
|
ItemCheckbox: ForwardRefExoticComponent<DropdownItemCheckboxProps>;
|
package/dropdown/dropdown.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Dropdown as DropdownClass, PopUp } from './dropdown.module.css';
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, Children, cloneElement } from 'react';
|
|
3
|
+
import { useKeyPress, useClickAway } from 'ahooks';
|
|
4
|
+
import { PopUp } from './dropdown.module.css';
|
|
6
5
|
import { useUIDSeed } from 'react-uid';
|
|
7
6
|
import { DropdownMenu } from './menu/dropdown-menu';
|
|
8
7
|
import { DropdownItem } from './item/dropdown-item';
|
|
@@ -27,14 +26,13 @@ const DropdownAnimation = {
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
};
|
|
30
|
-
export const Dropdown =
|
|
29
|
+
export const Dropdown = ({ children, trigger, offset = 8, placement = 'auto-start' }) => {
|
|
31
30
|
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
32
31
|
const seedID = useUIDSeed();
|
|
33
|
-
const popupRef = useRef(forwardedRef);
|
|
34
32
|
const [isOpen, setIsOpen] = useState(false);
|
|
35
|
-
const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
|
|
33
|
+
const { getTooltipProps, setTooltipRef, setTriggerRef, tooltipRef, visible } = usePopperTooltip({
|
|
36
34
|
delayShow: 0,
|
|
37
|
-
delayHide:
|
|
35
|
+
delayHide: 0,
|
|
38
36
|
trigger: ['click'],
|
|
39
37
|
visible: isOpen,
|
|
40
38
|
closeOnTriggerHidden: true,
|
|
@@ -43,12 +41,11 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
|
|
|
43
41
|
offset: [0, offset],
|
|
44
42
|
closeOnOutsideClick: false
|
|
45
43
|
});
|
|
46
|
-
const isFocusWithin = useFocusWithin(popupRef);
|
|
47
44
|
useClickAway(() => {
|
|
48
45
|
setIsOpen(false);
|
|
49
|
-
},
|
|
46
|
+
}, tooltipRef);
|
|
50
47
|
useKeyPress('esc', () => setIsOpen(false));
|
|
51
|
-
return (_jsxs(
|
|
48
|
+
return (_jsxs(_Fragment, { children: [Children.map(trigger, (child) => cloneElement(child, {
|
|
52
49
|
ref: setTriggerRef,
|
|
53
50
|
id: seedID('dropdown-trigger'),
|
|
54
51
|
'aria-haspopup': 'true',
|
|
@@ -58,7 +55,7 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
|
|
|
58
55
|
id: seedID('dropdown-menu'),
|
|
59
56
|
'aria-labelledby': seedID('dropdown-trigger')
|
|
60
57
|
})) }, void 0) }, void 0)) }, void 0)] }, void 0));
|
|
61
|
-
}
|
|
58
|
+
};
|
|
62
59
|
Dropdown.displayName = 'Dropdown';
|
|
63
60
|
Dropdown.Menu = DropdownMenu;
|
|
64
61
|
Dropdown.Item = DropdownItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.PopUp{inline-size:max-content;z-index:2}
|
package/package.json
CHANGED
package/themes/dark.css
CHANGED