mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
feat(root): react aria packages upgraded to the latest version
This commit is contained in:
parent
279cba96c8
commit
f51d19b09b
@ -59,7 +59,7 @@
|
||||
"@docusaurus/utils": "2.0.0-beta.3",
|
||||
"@react-bootstrap/babel-preset": "^2.1.0",
|
||||
"@react-types/link": "^3.3.3",
|
||||
"@react-types/shared": "^3.15.0",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"@storybook/react": "^6.5.16",
|
||||
"@swc-node/jest": "^1.5.2",
|
||||
"@swc/core": "^1.3.35",
|
||||
|
||||
@ -51,17 +51,17 @@
|
||||
"@nextui-org/use-aria-accordion-item": "workspace:*",
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@react-aria/accordion": "3.0.0-alpha.15",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-stately/tree": "^3.5.0",
|
||||
"framer-motion": "^10.6.0"
|
||||
"@react-aria/accordion": "3.0.0-alpha.17",
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-stately/tree": "^3.6.0",
|
||||
"framer-motion": "^10.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nextui-org/avatar": "workspace:*",
|
||||
"@nextui-org/test-utils": "workspace:*",
|
||||
"@react-types/accordion": "3.0.0-alpha.12",
|
||||
"@react-types/shared": "^3.17.0",
|
||||
"@react-types/accordion": "3.0.0-alpha.13",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -42,8 +42,8 @@
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/dom-utils": "workspace:*",
|
||||
"@nextui-org/use-image": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nextui-org/shared-icons": "workspace:*",
|
||||
|
||||
@ -43,16 +43,16 @@
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@nextui-org/drip": "workspace:*",
|
||||
"@nextui-org/spinner": "workspace:*",
|
||||
"@react-aria/button": "^3.7.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-aria/focus": "^3.11.0"
|
||||
"@react-aria/button": "^3.7.1",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-aria/focus": "^3.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nextui-org/spinner": "workspace:*",
|
||||
"@nextui-org/shared-icons": "workspace:*",
|
||||
"@react-types/shared": "^3.15.0",
|
||||
"@react-types/button": "^3.6.2",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"@react-types/button": "^3.7.2",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -3,10 +3,10 @@ import type {AriaButtonProps} from "@react-types/button";
|
||||
import type {HTMLNextUIProps, PropGetter} from "@nextui-org/system";
|
||||
import type {ReactNode} from "react";
|
||||
|
||||
import {callAllHandlers, dataAttr, ReactRef} from "@nextui-org/shared-utils";
|
||||
import {dataAttr, ReactRef} from "@nextui-org/shared-utils";
|
||||
import {MouseEventHandler, useCallback} from "react";
|
||||
import {useFocusRing} from "@react-aria/focus";
|
||||
import {mergeProps} from "@react-aria/utils";
|
||||
import {chain, mergeProps} from "@react-aria/utils";
|
||||
import {useDrip} from "@nextui-org/drip";
|
||||
import {useDOMRef} from "@nextui-org/dom-utils";
|
||||
import {button} from "@nextui-org/theme";
|
||||
@ -119,7 +119,7 @@ export function useButton(props: UseButtonProps) {
|
||||
elementType: as,
|
||||
isDisabled,
|
||||
onPress,
|
||||
onClick: callAllHandlers(onClick, handleDrip),
|
||||
onClick: chain(onClick, handleDrip),
|
||||
...otherProps,
|
||||
} as AriaButtonProps,
|
||||
domRef,
|
||||
|
||||
@ -42,13 +42,13 @@
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/dom-utils": "workspace:*",
|
||||
"@nextui-org/drip": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/button": "^3.7.0"
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/button": "^3.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/shared": "^3.17.0",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"@nextui-org/code": "workspace:*",
|
||||
"@nextui-org/link": "workspace:*",
|
||||
"@nextui-org/button": "workspace:*",
|
||||
|
||||
@ -41,21 +41,21 @@
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@nextui-org/dom-utils": "workspace:*",
|
||||
"@react-aria/checkbox": "^3.8.0",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/visually-hidden": "^3.7.0",
|
||||
"@react-stately/checkbox": "^3.4.0",
|
||||
"@react-stately/toggle": "^3.5.0",
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/checkbox": "^3.9.0",
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/visually-hidden": "^3.8.0",
|
||||
"@react-stately/checkbox": "^3.4.1",
|
||||
"@react-stately/toggle": "^3.5.1",
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nextui-org/shared-icons": "workspace:*",
|
||||
"@nextui-org/chip": "workspace:*",
|
||||
"@nextui-org/user": "workspace:*",
|
||||
"@nextui-org/link": "workspace:*",
|
||||
"@react-types/checkbox": "^3.4.2",
|
||||
"@react-types/shared": "^3.17.0",
|
||||
"@react-types/checkbox": "^3.4.3",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -42,13 +42,13 @@
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nextui-org/avatar": "workspace:*",
|
||||
"@react-types/checkbox": "^3.4.2",
|
||||
"@react-types/checkbox": "^3.4.3",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import {MouseEvent, CSSProperties, useRef, useState} from "react";
|
||||
import {MouseEvent, CSSProperties, useState} from "react";
|
||||
import {getUniqueID} from "@nextui-org/shared-utils";
|
||||
|
||||
export type DripInstance = {
|
||||
key: number;
|
||||
key: number | string;
|
||||
style: CSSProperties;
|
||||
};
|
||||
|
||||
export function useDrip() {
|
||||
const [drips, setDrips] = useState<DripInstance[]>([]);
|
||||
const nextKey = useRef(0);
|
||||
|
||||
const onClick = (event: MouseEvent<HTMLElement>) => {
|
||||
const trigger = event.currentTarget;
|
||||
@ -27,11 +27,10 @@ export function useDrip() {
|
||||
setDrips((prev) => [
|
||||
...prev,
|
||||
{
|
||||
key: nextKey.current,
|
||||
key: getUniqueID("drip"),
|
||||
style: dripStyle,
|
||||
},
|
||||
]);
|
||||
nextKey.current++;
|
||||
|
||||
setTimeout(() => {
|
||||
setDrips((prev) => prev.slice(1));
|
||||
|
||||
@ -43,15 +43,15 @@
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@nextui-org/use-aria-field": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-stately/utils": "^3.6.0",
|
||||
"react-textarea-autosize": "^8.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/shared": "^3.15.0",
|
||||
"@react-types/textfield": "^3.7.0",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"@react-types/textfield": "^3.7.1",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -41,12 +41,12 @@
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@react-aria/link": "^3.4.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-aria/focus": "^3.11.0"
|
||||
"@react-aria/link": "^3.5.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-aria/focus": "^3.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/link": "^3.4.0",
|
||||
"@react-types/link": "^3.4.1",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -43,9 +43,9 @@
|
||||
"@nextui-org/dom-utils": "workspace:*",
|
||||
"@nextui-org/shared-icons": "workspace:*",
|
||||
"@nextui-org/use-pagination": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"clean-package": "2.2.0",
|
||||
|
||||
@ -40,20 +40,22 @@
|
||||
"@nextui-org/aria-utils": "workspace:*",
|
||||
"@nextui-org/dom-utils": "workspace:*",
|
||||
"@nextui-org/framer-transitions": "workspace:*",
|
||||
"@nextui-org/button": "workspace:*",
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@react-aria/button": "^3.7.1",
|
||||
"@react-aria/dialog": "^3.5.1",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/overlays": "^3.13.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-stately/overlays": "^3.5.0",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"framer-motion": "^10.6.0"
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/overlays": "^3.14.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-stately/overlays": "^3.5.1",
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"framer-motion": "^10.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nextui-org/button": "workspace:*",
|
||||
"@react-types/overlays": "^3.7.0",
|
||||
"@react-types/overlays": "^3.7.1",
|
||||
"@react-types/button": "^3.7.2",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -3,7 +3,7 @@ import {forwardRef} from "@nextui-org/system";
|
||||
import {DismissButton} from "@react-aria/overlays";
|
||||
import {TRANSITION_VARIANTS} from "@nextui-org/framer-transitions";
|
||||
import {FocusScope} from "@react-aria/focus";
|
||||
import {AnimatePresence, motion} from "framer-motion";
|
||||
import {motion} from "framer-motion";
|
||||
import {getTransformOrigins} from "@nextui-org/aria-utils";
|
||||
|
||||
import {usePopoverContext} from "./popover-context";
|
||||
@ -13,7 +13,7 @@ export interface PopoverContentProps {
|
||||
}
|
||||
|
||||
const PopoverContent = forwardRef<PopoverContentProps, "section">((props, _) => {
|
||||
const {as, children} = props;
|
||||
const {as, children, ...otherProps} = props;
|
||||
|
||||
const {
|
||||
Component: OverlayComponent,
|
||||
@ -29,7 +29,7 @@ const PopoverContent = forwardRef<PopoverContentProps, "section">((props, _) =>
|
||||
|
||||
const Component = as || OverlayComponent || "div";
|
||||
|
||||
const {className, ...otherPopoverProps} = getPopoverProps();
|
||||
const {style, className, ...otherPopoverProps} = getPopoverProps(otherProps);
|
||||
|
||||
const arrowContent = useMemo(() => {
|
||||
if (!showArrow) return null;
|
||||
@ -50,14 +50,29 @@ const PopoverContent = forwardRef<PopoverContentProps, "section">((props, _) =>
|
||||
</FocusScope>
|
||||
);
|
||||
},
|
||||
[Component, disableAnimation, className, arrowContent, onClose],
|
||||
[Component, className, onClose, arrowContent],
|
||||
);
|
||||
|
||||
const animatedContent = useMemo(() => {
|
||||
return (
|
||||
<div {...otherPopoverProps}>
|
||||
const visibility = useMemo(() => {
|
||||
if (disableAnimation) return isOpen ? "visible" : "hidden";
|
||||
|
||||
return "visible";
|
||||
}, [disableAnimation, isOpen]);
|
||||
|
||||
return (
|
||||
<div
|
||||
{...otherPopoverProps}
|
||||
style={{
|
||||
...style,
|
||||
visibility,
|
||||
outline: "none",
|
||||
}}
|
||||
>
|
||||
{disableAnimation ? (
|
||||
<ContentWrapper>{children}</ContentWrapper>
|
||||
) : (
|
||||
<motion.div
|
||||
animate="enter"
|
||||
animate={isOpen ? "enter" : "exit"}
|
||||
exit="exit"
|
||||
initial="exit"
|
||||
style={{
|
||||
@ -68,18 +83,8 @@ const PopoverContent = forwardRef<PopoverContentProps, "section">((props, _) =>
|
||||
>
|
||||
<ContentWrapper>{children}</ContentWrapper>
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
}, [otherPopoverProps, placement, motionProps, ContentWrapper, children]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{disableAnimation && isOpen ? (
|
||||
<ContentWrapper>{children}</ContentWrapper>
|
||||
) : (
|
||||
<AnimatePresence initial={false}>{isOpen ? animatedContent : null}</AnimatePresence>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import {forwardRef} from "@nextui-org/system";
|
||||
import React, {Children, cloneElement} from "react";
|
||||
import {warn} from "@nextui-org/shared-utils";
|
||||
import React, {Children, cloneElement, useMemo} from "react";
|
||||
import {pickChildren} from "@nextui-org/shared-utils";
|
||||
import {useButton} from "@react-aria/button";
|
||||
import {Button} from "@nextui-org/button";
|
||||
import {mergeProps} from "@react-aria/utils";
|
||||
|
||||
import {usePopoverContext} from "./popover-context";
|
||||
@ -14,27 +16,33 @@ export interface PopoverTriggerProps {
|
||||
* such as `button` or `a`.
|
||||
*/
|
||||
const PopoverTrigger = forwardRef<PopoverTriggerProps, "button">((props, _) => {
|
||||
const {getTriggerProps} = usePopoverContext();
|
||||
const {triggerRef, getTriggerProps} = usePopoverContext();
|
||||
|
||||
const {children, ...otherProps} = props;
|
||||
|
||||
let trigger: React.ReactElement;
|
||||
// force a single child
|
||||
const child = useMemo<any>(() => {
|
||||
if (typeof children === "string") return <p>{children}</p>;
|
||||
|
||||
try {
|
||||
/**
|
||||
* Ensure tooltip has only one child node
|
||||
*/
|
||||
const child = Children.only(children) as React.ReactElement & {
|
||||
return Children.only(children) as React.ReactElement & {
|
||||
ref?: React.Ref<any>;
|
||||
};
|
||||
}, [children]);
|
||||
|
||||
trigger = cloneElement(child, getTriggerProps(mergeProps(child.props, otherProps), child.ref));
|
||||
} catch (error) {
|
||||
trigger = <span />;
|
||||
warn("PopoverTrigger must have only one child node. Please, check your code.");
|
||||
}
|
||||
const {onPress, ...rest} = useMemo(() => {
|
||||
return getTriggerProps(mergeProps(child.props, otherProps), child.ref);
|
||||
}, [getTriggerProps, child.props, otherProps, child.ref]);
|
||||
|
||||
return trigger;
|
||||
// validates if contains a NextUI Button as a child
|
||||
const [, triggerChildren] = pickChildren(children, Button);
|
||||
|
||||
const {buttonProps} = useButton({onPress}, triggerRef);
|
||||
|
||||
const hasNextUIButton = useMemo<boolean>(() => {
|
||||
return triggerChildren?.[0] !== undefined;
|
||||
}, [triggerChildren]);
|
||||
|
||||
return cloneElement(child, mergeProps(rest, hasNextUIButton ? {onPress} : buttonProps));
|
||||
});
|
||||
|
||||
PopoverTrigger.displayName = "NextUI.PopoverTrigger";
|
||||
|
||||
@ -19,10 +19,12 @@ const Popover = forwardRef<PopoverProps, "div">((props, ref) => {
|
||||
|
||||
const [trigger, content] = Children.toArray(children);
|
||||
|
||||
const mountOverlay = context.isOpen;
|
||||
|
||||
return (
|
||||
<PopoverProvider value={context}>
|
||||
{trigger}
|
||||
<OverlayContainer>{content}</OverlayContainer>
|
||||
{mountOverlay && <OverlayContainer>{content}</OverlayContainer>}
|
||||
</PopoverProvider>
|
||||
);
|
||||
});
|
||||
|
||||
@ -4,6 +4,7 @@ import type {OverlayPlacement, OverlayOptions} from "@nextui-org/aria-utils";
|
||||
import type {RefObject, Ref} from "react";
|
||||
|
||||
import {useOverlayTriggerState} from "@react-stately/overlays";
|
||||
import {useFocusRing} from "@react-aria/focus";
|
||||
import {
|
||||
AriaOverlayProps,
|
||||
useOverlayTrigger,
|
||||
@ -15,7 +16,6 @@ import {useDialog} from "@react-aria/dialog";
|
||||
import {OverlayTriggerProps} from "@react-types/overlays";
|
||||
import {HTMLNextUIProps, mapPropsVariants, PropGetter} from "@nextui-org/system";
|
||||
import {toReactAriaPlacement, getArrowPlacement} from "@nextui-org/aria-utils";
|
||||
import {useFocusRing} from "@react-aria/focus";
|
||||
import {popover} from "@nextui-org/theme";
|
||||
import {chain, mergeProps, mergeRefs} from "@react-aria/utils";
|
||||
import {createDOMRef} from "@nextui-org/dom-utils";
|
||||
@ -27,6 +27,11 @@ export interface Props extends HTMLNextUIProps<"div", PopoverVariantProps> {
|
||||
* Ref to the DOM node.
|
||||
*/
|
||||
ref?: ReactRef<HTMLElement | null>;
|
||||
/**
|
||||
* A ref for the scrollable region within the overlay.
|
||||
* @default overlayRef
|
||||
*/
|
||||
scrollRef?: RefObject<HTMLElement>;
|
||||
/**
|
||||
* The ref for the element which the overlay positions itself with respect to.
|
||||
*/
|
||||
@ -40,8 +45,6 @@ export interface Props extends HTMLNextUIProps<"div", PopoverVariantProps> {
|
||||
* Type of overlay that is opened by the trigger.
|
||||
*/
|
||||
triggerType?: "dialog" | "menu" | "listbox" | "tree" | "grid";
|
||||
/** Whether the element will be auto focused. */
|
||||
autoFocus?: boolean;
|
||||
/**
|
||||
* The properties passed to the underlying `Collapse` component.
|
||||
*/
|
||||
@ -73,6 +76,7 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
as,
|
||||
children,
|
||||
triggerRef: triggerRefProp,
|
||||
scrollRef,
|
||||
isOpen,
|
||||
defaultOpen,
|
||||
onOpenChange,
|
||||
@ -85,9 +89,8 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
crossOffset = 0,
|
||||
isDismissable = true,
|
||||
shouldCloseOnBlur = true,
|
||||
isKeyboardDismissDisabled = false,
|
||||
isKeyboardDismissDisabled = true,
|
||||
shouldCloseOnInteractOutside,
|
||||
autoFocus = false,
|
||||
motionProps,
|
||||
className,
|
||||
styles,
|
||||
@ -109,8 +112,6 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
createDOMRef(overlayRef),
|
||||
);
|
||||
|
||||
const {isFocusVisible, focusProps} = useFocusRing({autoFocus});
|
||||
|
||||
const state = useOverlayTriggerState({
|
||||
isOpen,
|
||||
defaultOpen,
|
||||
@ -124,10 +125,11 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
);
|
||||
|
||||
const {overlayProps: positionProps, arrowProps, placement} = useOverlayPosition({
|
||||
overlayRef,
|
||||
scrollRef,
|
||||
isOpen: isOpen,
|
||||
targetRef: triggerRef,
|
||||
placement: toReactAriaPlacement(placementProp),
|
||||
overlayRef,
|
||||
offset: showArrow ? offset + 3 : offset,
|
||||
crossOffset,
|
||||
shouldFlip,
|
||||
@ -136,9 +138,9 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
|
||||
const {overlayProps} = useOverlay(
|
||||
{
|
||||
onClose,
|
||||
isOpen: state.isOpen,
|
||||
isDismissable: isDismissable && state.isOpen,
|
||||
onClose: chain(state.close, onClose),
|
||||
isDismissable,
|
||||
shouldCloseOnBlur,
|
||||
isKeyboardDismissDisabled,
|
||||
shouldCloseOnInteractOutside,
|
||||
@ -146,6 +148,8 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
overlayRef,
|
||||
);
|
||||
|
||||
const {isFocusVisible, focusProps} = useFocusRing();
|
||||
|
||||
const {modalProps} = useModal({isDisabled: true});
|
||||
|
||||
const {dialogProps} = useDialog(
|
||||
@ -155,11 +159,6 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
overlayRef,
|
||||
);
|
||||
|
||||
const handleClose = useCallback(() => {
|
||||
onClose?.();
|
||||
state.close();
|
||||
}, [state, onClose]);
|
||||
|
||||
const slots = useMemo(
|
||||
() =>
|
||||
popover({
|
||||
@ -173,7 +172,6 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
|
||||
const getPopoverProps: PropGetter = (props = {}) => ({
|
||||
ref: overlayRef,
|
||||
className: slots.base({class: baseStyles}),
|
||||
...mergeProps(
|
||||
overlayTriggerProps,
|
||||
overlayProps,
|
||||
@ -184,17 +182,20 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
otherProps,
|
||||
props,
|
||||
),
|
||||
className: slots.base({class: clsx(baseStyles, props.className)}),
|
||||
id: popoverId,
|
||||
});
|
||||
|
||||
const getTriggerProps = useCallback<PropGetter>(
|
||||
(props = {}, _ref: Ref<any> | null | undefined = null) => ({
|
||||
...mergeProps(triggerProps, props),
|
||||
ref: mergeRefs(_ref, triggerRef),
|
||||
"aria-describedby": isOpen ? popoverId : undefined,
|
||||
onClick: chain(props.onClick, triggerProps.onPress),
|
||||
}),
|
||||
[isOpen, popoverId, triggerProps, triggerRef],
|
||||
(props = {}, _ref: Ref<any> | null | undefined = null) => {
|
||||
return {
|
||||
...mergeProps(triggerProps, props),
|
||||
ref: mergeRefs(_ref, triggerRef),
|
||||
"aria-controls": popoverId,
|
||||
"aria-haspopup": "dialog",
|
||||
};
|
||||
},
|
||||
[isOpen, popoverId, state, triggerProps, triggerRef],
|
||||
);
|
||||
|
||||
const getArrowProps = useCallback<PropGetter>(
|
||||
@ -211,9 +212,10 @@ export function usePopover(originalProps: UsePopoverProps) {
|
||||
children,
|
||||
styles,
|
||||
showArrow,
|
||||
triggerRef,
|
||||
placement: placementProp,
|
||||
isOpen: state.isOpen,
|
||||
onClose: handleClose,
|
||||
onClose: state.close,
|
||||
disableAnimation: originalProps.disableAnimation ?? false,
|
||||
motionProps,
|
||||
getPopoverProps,
|
||||
|
||||
@ -88,6 +88,11 @@ export default {
|
||||
|
||||
const defaultProps = {
|
||||
...popover.defaultVariants,
|
||||
placement: "top",
|
||||
offset: 7,
|
||||
defaultOpen: false,
|
||||
isDisabled: false,
|
||||
disableAnimation: false,
|
||||
};
|
||||
|
||||
const Template: ComponentStory<typeof Popover> = (args: PopoverProps) => {
|
||||
@ -111,3 +116,10 @@ Default.args = {
|
||||
...defaultProps,
|
||||
showArrow: true,
|
||||
};
|
||||
|
||||
export const DisableAnimation = Template.bind({});
|
||||
DisableAnimation.args = {
|
||||
...defaultProps,
|
||||
showArrow: true,
|
||||
disableAnimation: true,
|
||||
};
|
||||
|
||||
@ -43,12 +43,12 @@
|
||||
"@nextui-org/use-aria-label": "workspace:*",
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@react-aria/i18n": "^3.7.0",
|
||||
"@react-aria/progress": "^3.4.0",
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/i18n": "^3.7.1",
|
||||
"@react-aria/progress": "^3.4.1",
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/progress": "^3.3.0",
|
||||
"@react-types/progress": "^3.4.0",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -21,6 +21,11 @@ export interface Props extends HTMLNextUIProps<"div"> {
|
||||
* Ref to the DOM node.
|
||||
*/
|
||||
ref?: ReactRef<HTMLElement | null>;
|
||||
/**
|
||||
* Whether to show the value label.
|
||||
* @default false
|
||||
*/
|
||||
showValueLabel?: boolean;
|
||||
/**
|
||||
* Classname or List of classes to change the styles of the element.
|
||||
* if `className` is passed, it will be added to the base slot.
|
||||
|
||||
@ -12,11 +12,16 @@ import {useIsMounted} from "@nextui-org/use-is-mounted";
|
||||
|
||||
import {useProgressBar as useAriaProgress} from "./use-aria-progress";
|
||||
|
||||
export interface Props extends HTMLNextUIProps<"div"> {
|
||||
interface Props extends HTMLNextUIProps<"div"> {
|
||||
/**
|
||||
* Ref to the DOM node.
|
||||
*/
|
||||
ref?: ReactRef<HTMLElement | null>;
|
||||
/**
|
||||
* Whether to show the value label.
|
||||
* @default false
|
||||
*/
|
||||
showValueLabel?: boolean;
|
||||
/**
|
||||
* Classname or List of classes to change the styles of the element.
|
||||
* if `className` is passed, it will be added to the base slot.
|
||||
|
||||
@ -41,16 +41,16 @@
|
||||
"@nextui-org/dom-utils": "workspace:*",
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/radio": "^3.5.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-aria/visually-hidden": "^3.7.0",
|
||||
"@react-stately/radio": "^3.7.0"
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/radio": "^3.6.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-aria/visually-hidden": "^3.8.0",
|
||||
"@react-stately/radio": "^3.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/radio": "^3.3.0",
|
||||
"@react-types/shared": "^3.15.0",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"@nextui-org/button": "workspace:*",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
"@nextui-org/dom-utils": "workspace:*",
|
||||
"@nextui-org/use-clipboard": "workspace:*",
|
||||
"@nextui-org/tooltip": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0"
|
||||
"@react-aria/focus": "^3.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"clean-package": "2.2.0",
|
||||
|
||||
@ -41,13 +41,13 @@
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/switch": "^3.4.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-aria/visually-hidden": "^3.7.0",
|
||||
"@react-stately/toggle": "^3.5.0",
|
||||
"@react-types/shared": "^3.17.0"
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/switch": "^3.5.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-aria/visually-hidden": "^3.8.0",
|
||||
"@react-stately/toggle": "^3.5.1",
|
||||
"@react-types/shared": "^3.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"clean-package": "2.2.0",
|
||||
|
||||
@ -43,17 +43,17 @@
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@nextui-org/framer-transitions": "workspace:*",
|
||||
"@react-aria/overlays": "^3.13.0",
|
||||
"@react-aria/tooltip": "^3.4.0",
|
||||
"@react-stately/tooltip": "^3.3.0",
|
||||
"@react-aria/interactions": "^3.14.0",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"framer-motion": "^10.6.0"
|
||||
"@react-aria/overlays": "^3.14.0",
|
||||
"@react-aria/tooltip": "^3.5.0",
|
||||
"@react-stately/tooltip": "^3.4.0",
|
||||
"@react-aria/interactions": "^3.15.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"framer-motion": "^10.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nextui-org/button": "workspace:*",
|
||||
"@react-types/overlays": "^3.7.0",
|
||||
"@react-types/tooltip": "^3.3.0",
|
||||
"@react-types/overlays": "^3.7.1",
|
||||
"@react-types/tooltip": "^3.4.0",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -109,6 +109,7 @@ export function useTooltip(originalProps: UseTooltipProps) {
|
||||
|
||||
const state = useTooltipTriggerState({
|
||||
delay,
|
||||
closeDelay,
|
||||
isDisabled,
|
||||
defaultOpen,
|
||||
onOpenChange,
|
||||
@ -173,7 +174,7 @@ export function useTooltip(originalProps: UseTooltipProps) {
|
||||
const {overlayProps} = useOverlay(
|
||||
{
|
||||
isOpen: isOpen,
|
||||
isDismissable: isDismissable && isOpen,
|
||||
isDismissable,
|
||||
onClose: handleClose,
|
||||
shouldCloseOnBlur,
|
||||
isKeyboardDismissDisabled,
|
||||
|
||||
@ -107,14 +107,11 @@ const DelayTemplate: ComponentStory<typeof Tooltip> = (args: TooltipProps) => (
|
||||
Delay Open (1000ms)
|
||||
</Button>
|
||||
</Tooltip>
|
||||
{/*
|
||||
// TODO: Uncomment when closeDelay is deployed in react-aria
|
||||
// https://github.com/adobe/react-spectrum/pull/4128
|
||||
<Tooltip {...args} closeDelay={3000} content="Tooltip 2">
|
||||
<Tooltip {...args} closeDelay={2000} content="Tooltip 2">
|
||||
<Button color="success" variant="faded">
|
||||
Delay Close (3000ms)
|
||||
Delay Close (2000ms)
|
||||
</Button>
|
||||
</Tooltip> */}
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
@ -42,8 +42,8 @@
|
||||
"@nextui-org/theme": "workspace:*",
|
||||
"@nextui-org/shared-utils": "workspace:*",
|
||||
"@nextui-org/dom-utils": "workspace:*",
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"clean-package": "2.2.0",
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-aria/ssr": "^3.5.0",
|
||||
"@react-aria/overlays": "^3.13.0"
|
||||
"@react-aria/ssr": "^3.6.0",
|
||||
"@react-aria/overlays": "^3.14.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ const popover = tv({
|
||||
"px-4",
|
||||
"py-1",
|
||||
"text-base",
|
||||
"!outline-none",
|
||||
],
|
||||
arrow: [
|
||||
"-z-10",
|
||||
|
||||
@ -34,15 +34,15 @@
|
||||
"postpack": "clean-package restore"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-aria/focus": "^3.11.0",
|
||||
"@react-stately/tree": "^3.5.0",
|
||||
"@react-aria/button": "^3.7.0"
|
||||
"@react-aria/focus": "^3.12.0",
|
||||
"@react-stately/tree": "^3.6.0",
|
||||
"@react-aria/button": "^3.7.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/shared": "^3.17.0",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -36,13 +36,13 @@
|
||||
"dependencies": {
|
||||
"@nextui-org/use-aria-label": "workspace:*",
|
||||
"@nextui-org/use-aria-slot-id": "workspace:*",
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/shared": "^3.15.0",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -34,13 +34,13 @@
|
||||
"postpack": "clean-package restore"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/shared": "^3.17.0",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
},
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
"postpack": "clean-package restore"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-aria/utils": "^3.15.0"
|
||||
"@react-aria/utils": "^3.16.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18"
|
||||
|
||||
@ -38,11 +38,11 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nextui-org/system": "workspace:*",
|
||||
"@react-aria/utils": "^3.15.0",
|
||||
"@react-aria/utils": "^3.16.0",
|
||||
"@react-stately/collections": "^3.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-types/shared": "^3.17.0",
|
||||
"@react-types/shared": "^3.18.0",
|
||||
"@react-types/overlays": "^3.7.0",
|
||||
"clean-package": "2.2.0",
|
||||
"react": "^18.0.0"
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"react": "^18.0.0",
|
||||
"framer-motion": "^10.6.0",
|
||||
"framer-motion": "^10.11.2",
|
||||
"clean-package": "2.2.0"
|
||||
},
|
||||
"clean-package": "../../../clean-package.config.json",
|
||||
|
||||
@ -50,3 +50,7 @@ export function extractProperty<K extends keyof Extractable, D extends keyof Ext
|
||||
|
||||
return result as Extractable[K] | D | string | boolean;
|
||||
}
|
||||
|
||||
export function getUniqueID(prefix: string) {
|
||||
return `${prefix}-${Math.floor(Math.random() * 1000000)}`;
|
||||
}
|
||||
|
||||
1447
pnpm-lock.yaml
generated
1447
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user