@lobehub/ui 4.12.2 → 4.13.1
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/es/Accordion/Accordion.d.mts +2 -2
- package/es/Accordion/AccordionItem.d.mts +2 -2
- package/es/ActionIcon/ActionIcon.d.mts +2 -2
- package/es/Alert/Alert.d.mts +2 -2
- package/es/Alert/Alert.mjs +1 -1
- package/es/Alert/Alert.mjs.map +1 -1
- package/es/Avatar/AvatarGroup/index.d.mts +2 -2
- package/es/Burger/Burger.d.mts +2 -2
- package/es/CodeEditor/CodeEditor.d.mts +2 -2
- package/es/Collapse/Collapse.d.mts +2 -2
- package/es/ConfigProvider/index.d.mts +2 -2
- package/es/ContextMenu/ContextMenuHost.d.mts +2 -2
- package/es/ContextMenu/ContextMenuHost.mjs +1 -1
- package/es/CopyButton/CopyButton.d.mts +2 -2
- package/es/DatePicker/DatePicker.d.mts +2 -2
- package/es/DraggablePanel/DraggablePanel.mjs +1 -1
- package/es/DraggablePanel/components/DraggablePanelBody.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelContainer.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelFooter.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelHeader.d.mts +2 -2
- package/es/DraggableSideNav/DraggableSideNav.d.mts +2 -2
- package/es/DraggableSideNav/DraggableSideNav.mjs +1 -1
- package/es/Drawer/Drawer.d.mts +2 -2
- package/es/Dropdown/Dropdown.d.mts +2 -2
- package/es/DropdownMenu/DropdownMenu.d.mts +2 -2
- package/es/DropdownMenu/DropdownMenu.mjs +3 -3
- package/es/EditableText/EditableText.d.mts +2 -2
- package/es/EmojiPicker/EmojiPicker.d.mts +2 -2
- package/es/Flex/FlexBasic.d.mts +2 -2
- package/es/FontLoader/index.d.mts +2 -2
- package/es/Footer/Footer.d.mts +2 -2
- package/es/Form/components/FormGroup.d.mts +2 -2
- package/es/Form/components/FormItem.d.mts +2 -2
- package/es/Form/components/FormSubmitFooter.d.mts +2 -2
- package/es/FormModal/FormModal.d.mts +2 -2
- package/es/Header/Header.d.mts +2 -2
- package/es/Highlighter/Highlighter.d.mts +2 -2
- package/es/Highlighter/SyntaxHighlighter/index.d.mts +2 -2
- package/es/Hotkey/Hotkey.d.mts +2 -2
- package/es/HotkeyInput/HotkeyInput.d.mts +2 -2
- package/es/Icon/Icon.d.mts +2 -2
- package/es/Icon/components/IconProvider.d.mts +3 -3
- package/es/Image/PreviewGroup.d.mts +2 -2
- package/es/ImageSelect/ImageSelect.d.mts +2 -2
- package/es/Input/Input.d.mts +2 -2
- package/es/Input/InputNumber.d.mts +2 -2
- package/es/Layout/components/LayoutFooter.d.mts +2 -2
- package/es/Layout/components/LayoutHeader.d.mts +2 -2
- package/es/Layout/components/LayoutMain.d.mts +2 -2
- package/es/Layout/components/LayoutSidebar.d.mts +2 -2
- package/es/Layout/components/LayoutSidebarInner.d.mts +2 -2
- package/es/Layout/components/LayoutToc.d.mts +2 -2
- package/es/List/ListItem/index.d.mts +2 -2
- package/es/Markdown/Markdown.d.mts +2 -2
- package/es/Markdown/Typography.d.mts +2 -2
- package/es/Markdown/components/SearchResultCards/index.d.mts +2 -2
- package/es/MaskShadow/MaskShadow.d.mts +2 -2
- package/es/Menu/Menu.d.mts +2 -2
- package/es/Mermaid/Mermaid.d.mts +2 -2
- package/es/Mermaid/SyntaxMermaid/index.d.mts +2 -2
- package/es/Modal/Modal.d.mts +2 -2
- package/es/Modal/ModalProvider.d.mts +2 -2
- package/es/MotionProvider/index.d.mts +2 -2
- package/es/Popover/Popover.mjs +1 -1
- package/es/Popover/Popover.mjs.map +1 -1
- package/es/Popover/PopoverGroup.mjs +6 -2
- package/es/Popover/PopoverGroup.mjs.map +1 -1
- package/es/Popover/PopoverInGroup.mjs +1 -1
- package/es/Popover/PopoverPortal.mjs +1 -1
- package/es/Popover/PopoverPortal.mjs.map +1 -1
- package/es/Popover/PopoverStandalone.mjs +2 -2
- package/es/Popover/context.d.mts +2 -2
- package/es/Popover/context.mjs +3 -1
- package/es/Popover/context.mjs.map +1 -1
- package/es/Popover/type.d.mts +4 -0
- package/es/SearchBar/SearchBar.d.mts +2 -2
- package/es/Segmented/Segmented.d.mts +2 -2
- package/es/Select/Select.d.mts +2 -2
- package/es/SideNav/SideNav.d.mts +2 -2
- package/es/SliderWithInput/SliderWithInput.d.mts +2 -2
- package/es/SortableList/components/DragHandle.d.mts +2 -2
- package/es/SortableList/components/SortableItem.d.mts +2 -2
- package/es/ThemeProvider/ThemeProvider.d.mts +2 -2
- package/es/Toc/Toc.d.mts +2 -2
- package/es/Tooltip/ArrowIcon.mjs +22 -0
- package/es/Tooltip/ArrowIcon.mjs.map +1 -0
- package/es/Tooltip/Tooltip.mjs +3 -3
- package/es/Tooltip/Tooltip.mjs.map +1 -1
- package/es/Tooltip/TooltipContent.mjs +24 -0
- package/es/Tooltip/TooltipContent.mjs.map +1 -0
- package/es/Tooltip/TooltipGroup.d.mts +2 -5
- package/es/Tooltip/TooltipGroup.mjs +90 -178
- package/es/Tooltip/TooltipGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipInGroup.mjs +54 -52
- package/es/Tooltip/TooltipInGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipPortal.mjs +4 -7
- package/es/Tooltip/TooltipPortal.mjs.map +1 -1
- package/es/Tooltip/TooltipStandalone.mjs +149 -83
- package/es/Tooltip/TooltipStandalone.mjs.map +1 -1
- package/es/Tooltip/groupContext.mjs +4 -2
- package/es/Tooltip/groupContext.mjs.map +1 -1
- package/es/Tooltip/index.d.mts +1 -1
- package/es/Tooltip/style.mjs +203 -32
- package/es/Tooltip/style.mjs.map +1 -1
- package/es/Tooltip/type.d.mts +30 -3
- package/es/Tooltip/useMergedTooltipProps.mjs +17 -6
- package/es/Tooltip/useMergedTooltipProps.mjs.map +1 -1
- package/es/Video/index.d.mts +2 -2
- package/es/awesome/AuroraBackground/AuroraBackground.d.mts +2 -2
- package/es/awesome/Giscus/Giscus.d.mts +2 -2
- package/es/awesome/GradientButton/GradientButton.d.mts +2 -2
- package/es/awesome/GridBackground/GridBackground.d.mts +2 -2
- package/es/awesome/GridBackground/GridBackground.mjs +1 -1
- package/es/awesome/GridBackground/GridShowcase.d.mts +2 -2
- package/es/awesome/Hero/Hero.d.mts +2 -2
- package/es/awesome/Spline/Spine.d.mts +2 -2
- package/es/awesome/Spotlight/Spotlight.d.mts +2 -2
- package/es/awesome/SpotlightCard/SpotlightCard.d.mts +2 -2
- package/es/awesome/TypewriterEffect/TypewriterEffect.d.mts +2 -2
- package/es/brand/LobeChat/index.d.mts +2 -2
- package/es/brand/LobeHub/index.d.mts +2 -2
- package/es/brand/LogoThree/LogoSpline.d.mts +2 -2
- package/es/brand/LogoThree/index.d.mts +2 -2
- package/es/chat/BackBottom/BackBottom.d.mts +2 -2
- package/es/chat/BackBottom/BackBottom.mjs +1 -1
- package/es/chat/ChatInputArea/components/ChatInputAreaInner.d.mts +2 -2
- package/es/chat/ChatList/ChatList.d.mts +2 -2
- package/es/chat/EditableMessage/EditableMessage.d.mts +2 -2
- package/es/chat/EditableMessageList/EditableMessageList.d.mts +2 -2
- package/es/chat/MessageInput/MessageInput.d.mts +2 -2
- package/es/chat/MessageModal/MessageModal.d.mts +2 -2
- package/es/color/ColorScales/index.d.mts +2 -2
- package/es/color/CssVar/index.d.mts +2 -2
- package/es/hooks/usePortalContainer.mjs +1 -1
- package/es/i18n/context.d.mts +2 -2
- package/es/icons/lucideExtra/BotPromptIcon.d.mts +2 -2
- package/es/icons/lucideExtra/CreateBotIcon.d.mts +2 -2
- package/es/icons/lucideExtra/DiscordIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GlobeOffIcon.d.mts +2 -2
- package/es/icons/lucideExtra/GroupBotIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GroupBotSquareIcon.d.mts +2 -2
- package/es/icons/lucideExtra/LeftClickIcon.d.mts +2 -2
- package/es/icons/lucideExtra/LeftDoubleClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/McpIcon.d.mts +3 -3
- package/es/icons/lucideExtra/ProviderIcon.d.mts +3 -3
- package/es/icons/lucideExtra/RightClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/RightDoubleClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/ShapesUploadIcon.d.mts +3 -3
- package/es/icons/lucideExtra/TreeDownRightIcon.d.mts +3 -3
- package/es/icons/lucideExtra/TreeUpDownRightIcon.d.mts +3 -3
- package/es/index.mjs +1 -1
- package/es/mdx/Mdx/index.d.mts +2 -2
- package/es/mobile/ChatInputArea/ChatInputArea.mjs +1 -1
- package/es/mobile/ChatInputArea/components/ChatSendButton.d.mts +2 -2
- package/es/mobile/TabBar/TabBar.d.mts +2 -2
- package/es/storybook/StoryBook/index.d.mts +2 -2
- package/es/utils/placement.d.mts +1 -1
- package/package.json +1 -1
- package/es/Tooltip/TooltipFloating.mjs +0 -119
- package/es/Tooltip/TooltipFloating.mjs.map +0 -1
- package/es/Tooltip/groupContext.d.mts +0 -14
- package/es/Tooltip/useTooltipFloating.mjs +0 -55
- package/es/Tooltip/useTooltipFloating.mjs.map +0 -1
- package/es/Tooltip/useTooltipReference.mjs +0 -56
- package/es/Tooltip/useTooltipReference.mjs.map +0 -1
- package/es/Tooltip/useTooltipTrigger.mjs +0 -18
- package/es/Tooltip/useTooltipTrigger.mjs.map +0 -1
- package/es/Tooltip/utils.mjs +0 -36
- package/es/Tooltip/utils.mjs.map +0 -1
- package/es/utils/composeEventHandlers.mjs +0 -28
- package/es/utils/composeEventHandlers.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react98 from "react";
|
|
2
|
+
import * as lucide_react7 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/McpIcon.d.ts
|
|
5
|
-
declare const McpIcon:
|
|
5
|
+
declare const McpIcon: react98.ForwardRefExoticComponent<Omit<lucide_react7.LucideProps, "ref"> & react98.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { McpIcon };
|
|
8
8
|
//# sourceMappingURL=McpIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react100 from "react";
|
|
2
|
+
import * as lucide_react8 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/ProviderIcon.d.ts
|
|
5
|
-
declare const ProviderIcon:
|
|
5
|
+
declare const ProviderIcon: react100.ForwardRefExoticComponent<Omit<lucide_react8.LucideProps, "ref"> & react100.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ProviderIcon };
|
|
8
8
|
//# sourceMappingURL=ProviderIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react102 from "react";
|
|
2
|
+
import * as lucide_react9 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/RightClickIcon.d.ts
|
|
5
|
-
declare const RightClickIcon:
|
|
5
|
+
declare const RightClickIcon: react102.ForwardRefExoticComponent<Omit<lucide_react9.LucideProps, "ref"> & react102.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { RightClickIcon };
|
|
8
8
|
//# sourceMappingURL=RightClickIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react104 from "react";
|
|
2
|
+
import * as lucide_react10 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/RightDoubleClickIcon.d.ts
|
|
5
|
-
declare const RightDoubleClickIcon:
|
|
5
|
+
declare const RightDoubleClickIcon: react104.ForwardRefExoticComponent<Omit<lucide_react10.LucideProps, "ref"> & react104.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { RightDoubleClickIcon };
|
|
8
8
|
//# sourceMappingURL=RightDoubleClickIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react106 from "react";
|
|
2
|
+
import * as lucide_react11 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/ShapesUploadIcon.d.ts
|
|
5
|
-
declare const ShapesUploadIcon:
|
|
5
|
+
declare const ShapesUploadIcon: react106.ForwardRefExoticComponent<Omit<lucide_react11.LucideProps, "ref"> & react106.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ShapesUploadIcon };
|
|
8
8
|
//# sourceMappingURL=ShapesUploadIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react108 from "react";
|
|
2
|
+
import * as lucide_react12 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/TreeDownRightIcon.d.ts
|
|
5
|
-
declare const TreeDownRightIcon:
|
|
5
|
+
declare const TreeDownRightIcon: react108.ForwardRefExoticComponent<Omit<lucide_react12.LucideProps, "ref"> & react108.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { TreeDownRightIcon };
|
|
8
8
|
//# sourceMappingURL=TreeDownRightIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react110 from "react";
|
|
2
|
+
import * as lucide_react13 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/TreeUpDownRightIcon.d.ts
|
|
5
|
-
declare const TreeUpDownRightIcon:
|
|
5
|
+
declare const TreeUpDownRightIcon: react110.ForwardRefExoticComponent<Omit<lucide_react13.LucideProps, "ref"> & react110.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { TreeUpDownRightIcon };
|
|
8
8
|
//# sourceMappingURL=TreeUpDownRightIcon.d.mts.map
|
package/es/index.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { staticStylish } from "./styles/theme/customStylishStatic.mjs";
|
|
|
11
11
|
import { generateCustomToken } from "./styles/theme/customToken.mjs";
|
|
12
12
|
import { generateColorNeutralPalette, generateColorPalette } from "./styles/theme/generateColorPalette.mjs";
|
|
13
13
|
import Block_default from "./Block/Block.mjs";
|
|
14
|
+
import { placementMap, toFloatingUIPlacement } from "./utils/placement.mjs";
|
|
14
15
|
import { KeyMapEnum } from "./Hotkey/const.mjs";
|
|
15
16
|
import { IconProvider } from "./Icon/components/IconProvider.mjs";
|
|
16
17
|
import Icon_default from "./Icon/Icon.mjs";
|
|
@@ -21,7 +22,6 @@ import Meta_default from "./ThemeProvider/Meta.mjs";
|
|
|
21
22
|
import FontLoader_default from "./FontLoader/index.mjs";
|
|
22
23
|
import { CLASSNAMES } from "./styles/classNames.mjs";
|
|
23
24
|
import ThemeProvider_default from "./ThemeProvider/ThemeProvider.mjs";
|
|
24
|
-
import { placementMap, toFloatingUIPlacement } from "./utils/placement.mjs";
|
|
25
25
|
import Tooltip_default from "./Tooltip/Tooltip.mjs";
|
|
26
26
|
import TooltipGroup_default from "./Tooltip/TooltipGroup.mjs";
|
|
27
27
|
import Text_default from "./Text/Text.mjs";
|
package/es/mdx/Mdx/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypographyProps } from "../../Markdown/type.mjs";
|
|
2
2
|
import "../../Markdown/index.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react68 from "react";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
import { Pluggable } from "unified";
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ interface MdxProps extends Omit<TypographyProps, 'children'> {
|
|
|
18
18
|
remarkPlugins?: Pluggable[];
|
|
19
19
|
variant?: 'normal' | 'chat';
|
|
20
20
|
}
|
|
21
|
-
declare const Mdx:
|
|
21
|
+
declare const Mdx: react68.NamedExoticComponent<MdxProps>;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { Mdx, MdxProps };
|
|
24
24
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -8,8 +8,8 @@ import { styles } from "./style.mjs";
|
|
|
8
8
|
import { memo, useCallback, useEffect, useRef, useState } from "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { cx } from "antd-style";
|
|
11
|
-
import { useSize } from "ahooks";
|
|
12
11
|
import { ChevronDown, ChevronUp } from "lucide-react";
|
|
12
|
+
import { useSize } from "ahooks";
|
|
13
13
|
|
|
14
14
|
//#region src/mobile/ChatInputArea/ChatInputArea.tsx
|
|
15
15
|
const ChatInputArea = memo(({ ref, className, style, topAddons, textAreaLeftAddons, textAreaRightAddons, bottomAddons, expand = false, setExpand, onSend, onInput, loading, value, safeArea }) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ChatSendButtonProps } from "../type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react116 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/mobile/ChatInputArea/components/ChatSendButton.d.ts
|
|
5
|
-
declare const ChatSendButton:
|
|
5
|
+
declare const ChatSendButton: react116.NamedExoticComponent<ChatSendButtonProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ChatSendButton };
|
|
8
8
|
//# sourceMappingURL=ChatSendButton.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TabBarProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react114 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/mobile/TabBar/TabBar.d.ts
|
|
5
|
-
declare const TabBar:
|
|
5
|
+
declare const TabBar: react114.NamedExoticComponent<TabBarProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { TabBar };
|
|
8
8
|
//# sourceMappingURL=TabBar.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FlexboxProps } from "../../Flex/type.mjs";
|
|
2
2
|
import "../../Flex/index.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react0 from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { useControls, useCreateStore } from "leva";
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ interface StoryBookProps extends FlexboxProps {
|
|
|
10
10
|
noPadding?: boolean;
|
|
11
11
|
ref?: Ref<HTMLDivElement>;
|
|
12
12
|
}
|
|
13
|
-
declare const StoryBook:
|
|
13
|
+
declare const StoryBook: react0.NamedExoticComponent<StoryBookProps>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { StoryBook, StoryBookProps, useControls, useCreateStore };
|
|
16
16
|
//# sourceMappingURL=index.d.mts.map
|
package/es/utils/placement.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useMotionComponent } from "../MotionProvider/index.mjs";
|
|
4
|
-
import FlexBasic_default from "../Flex/FlexBasic.mjs";
|
|
5
|
-
import Hotkey_default from "../Hotkey/Hotkey.mjs";
|
|
6
|
-
import { styles } from "./style.mjs";
|
|
7
|
-
import { useMemo } from "react";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { cx } from "antd-style";
|
|
10
|
-
import { AnimatePresence } from "motion/react";
|
|
11
|
-
import { FloatingArrow } from "@floating-ui/react";
|
|
12
|
-
import { useDebounce } from "ahooks";
|
|
13
|
-
|
|
14
|
-
//#region src/Tooltip/TooltipFloating.tsx
|
|
15
|
-
const tooltipAnimateState = {
|
|
16
|
-
opacity: 1,
|
|
17
|
-
scale: 1,
|
|
18
|
-
y: 0
|
|
19
|
-
};
|
|
20
|
-
const tooltipExitState = {
|
|
21
|
-
opacity: 0,
|
|
22
|
-
scale: .98,
|
|
23
|
-
y: 4
|
|
24
|
-
};
|
|
25
|
-
const tooltipInitialState = {
|
|
26
|
-
opacity: 0,
|
|
27
|
-
scale: .96,
|
|
28
|
-
y: 6
|
|
29
|
-
};
|
|
30
|
-
const tooltipTransition = {
|
|
31
|
-
duration: .14,
|
|
32
|
-
ease: [
|
|
33
|
-
.4,
|
|
34
|
-
0,
|
|
35
|
-
.2,
|
|
36
|
-
1
|
|
37
|
-
]
|
|
38
|
-
};
|
|
39
|
-
const contentAnimateState = { opacity: 1 };
|
|
40
|
-
const contentExitState = { opacity: 0 };
|
|
41
|
-
const contentInitialState = { opacity: 0 };
|
|
42
|
-
const contentTransition = { duration: .3 };
|
|
43
|
-
const TooltipFloating = ({ open, title, placement, floatingStyles, setFloating, floatingProps, arrow: arrow$1, arrowRef, context, hotkey, hotkeyProps, isInitialShow, layoutAnimation = true, className, classNames, styles: styleProps, zIndex }) => {
|
|
44
|
-
const basePlacement = String(placement || "top").split("-")[0];
|
|
45
|
-
const transformOrigin = useMemo(() => {
|
|
46
|
-
switch (basePlacement) {
|
|
47
|
-
case "top": return "bottom center";
|
|
48
|
-
case "bottom": return "top center";
|
|
49
|
-
case "left": return "center right";
|
|
50
|
-
case "right": return "center left";
|
|
51
|
-
default: return "center";
|
|
52
|
-
}
|
|
53
|
-
}, [basePlacement]);
|
|
54
|
-
const hasTransform = useDebounce(Boolean(floatingStyles?.transform), {
|
|
55
|
-
leading: false,
|
|
56
|
-
wait: 16
|
|
57
|
-
});
|
|
58
|
-
const Motion = useMotionComponent();
|
|
59
|
-
const TooltipContent = hotkey ? /* @__PURE__ */ jsxs(FlexBasic_default, {
|
|
60
|
-
align: "center",
|
|
61
|
-
gap: 8,
|
|
62
|
-
horizontal: true,
|
|
63
|
-
justify: "space-between",
|
|
64
|
-
children: [/* @__PURE__ */ jsx("span", { children: title }), /* @__PURE__ */ jsx(Hotkey_default, {
|
|
65
|
-
inverseTheme: true,
|
|
66
|
-
keys: hotkey,
|
|
67
|
-
...hotkeyProps
|
|
68
|
-
})]
|
|
69
|
-
}) : title;
|
|
70
|
-
return /* @__PURE__ */ jsx(AnimatePresence, { children: open && title && /* @__PURE__ */ jsx("div", {
|
|
71
|
-
className: cx(styles.tooltip, layoutAnimation && hasTransform && styles.tooltipLayout, classNames?.container, classNames?.root, className),
|
|
72
|
-
ref: setFloating,
|
|
73
|
-
role: "tooltip",
|
|
74
|
-
style: styleProps?.root ? {
|
|
75
|
-
...floatingStyles,
|
|
76
|
-
zIndex,
|
|
77
|
-
...styleProps.container,
|
|
78
|
-
...styleProps.root
|
|
79
|
-
} : {
|
|
80
|
-
...floatingStyles,
|
|
81
|
-
zIndex,
|
|
82
|
-
...styleProps?.container
|
|
83
|
-
},
|
|
84
|
-
...floatingProps,
|
|
85
|
-
children: /* @__PURE__ */ jsxs(Motion.div, {
|
|
86
|
-
animate: tooltipAnimateState,
|
|
87
|
-
exit: tooltipExitState,
|
|
88
|
-
initial: tooltipInitialState,
|
|
89
|
-
style: { transformOrigin },
|
|
90
|
-
transition: tooltipTransition,
|
|
91
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
92
|
-
className: cx(styles.content, classNames?.content),
|
|
93
|
-
style: styleProps?.content,
|
|
94
|
-
children: layoutAnimation ? /* @__PURE__ */ jsx(AnimatePresence, {
|
|
95
|
-
mode: "popLayout",
|
|
96
|
-
children: /* @__PURE__ */ jsx(Motion.div, {
|
|
97
|
-
animate: contentAnimateState,
|
|
98
|
-
exit: contentExitState,
|
|
99
|
-
initial: isInitialShow ? false : contentInitialState,
|
|
100
|
-
transition: contentTransition,
|
|
101
|
-
children: TooltipContent
|
|
102
|
-
}, String(title))
|
|
103
|
-
}) : TooltipContent
|
|
104
|
-
}), arrow$1 && context && /* @__PURE__ */ jsx(FloatingArrow, {
|
|
105
|
-
className: cx(styles.arrow, classNames?.arrow),
|
|
106
|
-
context,
|
|
107
|
-
height: 6,
|
|
108
|
-
ref: arrowRef,
|
|
109
|
-
style: styleProps?.arrow,
|
|
110
|
-
width: 12
|
|
111
|
-
})]
|
|
112
|
-
})
|
|
113
|
-
}, "tooltip") });
|
|
114
|
-
};
|
|
115
|
-
var TooltipFloating_default = TooltipFloating;
|
|
116
|
-
|
|
117
|
-
//#endregion
|
|
118
|
-
export { TooltipFloating_default as default };
|
|
119
|
-
//# sourceMappingURL=TooltipFloating.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipFloating.mjs","names":["tooltipAnimateState: Target","tooltipExitState: Target","tooltipInitialState: Target","tooltipTransition: Transition","contentAnimateState: Target","contentExitState: Target","contentInitialState: Target","contentTransition: Transition","Flexbox","Hotkey","arrow"],"sources":["../../src/Tooltip/TooltipFloating.tsx"],"sourcesContent":["'use client';\n\nimport type { FloatingContext, Placement } from '@floating-ui/react';\nimport { FloatingArrow } from '@floating-ui/react';\nimport { useDebounce } from 'ahooks';\nimport { cx } from 'antd-style';\nimport { AnimatePresence, type Target, type Transition } from 'motion/react';\nimport type { CSSProperties, ReactNode, RefObject } from 'react';\nimport { useMemo } from 'react';\n\nimport { Flexbox } from '@/Flex';\nimport Hotkey from '@/Hotkey';\nimport { useMotionComponent } from '@/MotionProvider';\n\nimport { styles } from './style';\nimport type { TooltipProps } from './type';\n\n// Tooltip container animation\nconst tooltipAnimateState: Target = { opacity: 1, scale: 1, y: 0 };\nconst tooltipExitState: Target = { opacity: 0, scale: 0.98, y: 4 };\nconst tooltipInitialState: Target = { opacity: 0, scale: 0.96, y: 6 };\nconst tooltipTransition: Transition = { duration: 0.14, ease: [0.4, 0, 0.2, 1] };\n\n// Tooltip content animation (for switching between tooltips)\nconst contentAnimateState: Target = { opacity: 1 };\nconst contentExitState: Target = { opacity: 0 };\nconst contentInitialState: Target = { opacity: 0 };\nconst contentTransition: Transition = { duration: 0.3 };\n\ntype TooltipFloatingProps = {\n arrow?: boolean;\n arrowRef?: RefObject<SVGSVGElement | null>;\n\n className?: TooltipProps['className'];\n classNames?: TooltipProps['classNames'];\n context?: FloatingContext;\n\n floatingProps?: Record<string, any>;\n floatingStyles: CSSProperties;\n\n hotkey?: TooltipProps['hotkey'];\n\n hotkeyProps?: TooltipProps['hotkeyProps'];\n /**\n * @description Whether this is the initial show (first appearance, not switching between tooltips)\n */\n isInitialShow?: boolean;\n\n /**\n * @description Whether to enable layout animation when switching between tooltips\n * @default true\n */\n layoutAnimation?: boolean;\n open: boolean;\n placement?: Placement;\n\n setFloating: (node: HTMLElement | null) => void;\n styles?: TooltipProps['styles'];\n title?: ReactNode;\n zIndex?: TooltipProps['zIndex'];\n};\n\nconst TooltipFloating = ({\n open,\n title,\n placement,\n\n floatingStyles,\n setFloating,\n floatingProps,\n arrow,\n arrowRef,\n context,\n hotkey,\n hotkeyProps,\n isInitialShow,\n layoutAnimation = true,\n\n className,\n classNames,\n styles: styleProps,\n zIndex,\n}: TooltipFloatingProps) => {\n const basePlacement = String(placement || 'top').split('-')[0];\n\n const transformOrigin = useMemo(() => {\n switch (basePlacement) {\n case 'top': {\n return 'bottom center';\n }\n case 'bottom': {\n return 'top center';\n }\n case 'left': {\n return 'center right';\n }\n case 'right': {\n return 'center left';\n }\n default: {\n return 'center';\n }\n }\n }, [basePlacement]);\n\n const hasTransform = useDebounce(Boolean(floatingStyles?.transform), {\n leading: false,\n wait: 16,\n });\n\n const Motion = useMotionComponent();\n\n const TooltipContent = hotkey ? (\n <Flexbox align={'center'} gap={8} horizontal justify={'space-between'}>\n <span>{title}</span>\n <Hotkey inverseTheme keys={hotkey} {...hotkeyProps} />\n </Flexbox>\n ) : (\n title\n );\n return (\n <AnimatePresence>\n {open && title && (\n <div\n className={cx(\n styles.tooltip,\n layoutAnimation && hasTransform && styles.tooltipLayout,\n classNames?.container,\n classNames?.root,\n className,\n )}\n key=\"tooltip\"\n ref={setFloating as any}\n role=\"tooltip\"\n style={\n styleProps?.root\n ? {\n ...floatingStyles,\n zIndex,\n ...styleProps.container,\n ...styleProps.root,\n }\n : {\n ...floatingStyles,\n zIndex,\n ...styleProps?.container,\n }\n }\n {...floatingProps}\n >\n <Motion.div\n animate={tooltipAnimateState}\n exit={tooltipExitState}\n initial={tooltipInitialState}\n style={{ transformOrigin }}\n transition={tooltipTransition}\n >\n <div className={cx(styles.content, classNames?.content)} style={styleProps?.content}>\n {layoutAnimation ? (\n <AnimatePresence mode=\"popLayout\">\n <Motion.div\n animate={contentAnimateState}\n exit={contentExitState}\n initial={isInitialShow ? false : contentInitialState}\n key={String(title)}\n transition={contentTransition}\n >\n {TooltipContent}\n </Motion.div>\n </AnimatePresence>\n ) : (\n TooltipContent\n )}\n </div>\n {arrow && context && (\n <FloatingArrow\n className={cx(styles.arrow, classNames?.arrow)}\n context={context}\n height={6}\n ref={arrowRef as any}\n style={styleProps?.arrow}\n width={12}\n />\n )}\n </Motion.div>\n </div>\n )}\n </AnimatePresence>\n );\n};\n\nexport default TooltipFloating;\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAMA,sBAA8B;CAAE,SAAS;CAAG,OAAO;CAAG,GAAG;CAAG;AAClE,MAAMC,mBAA2B;CAAE,SAAS;CAAG,OAAO;CAAM,GAAG;CAAG;AAClE,MAAMC,sBAA8B;CAAE,SAAS;CAAG,OAAO;CAAM,GAAG;CAAG;AACrE,MAAMC,oBAAgC;CAAE,UAAU;CAAM,MAAM;EAAC;EAAK;EAAG;EAAK;EAAE;CAAE;AAGhF,MAAMC,sBAA8B,EAAE,SAAS,GAAG;AAClD,MAAMC,mBAA2B,EAAE,SAAS,GAAG;AAC/C,MAAMC,sBAA8B,EAAE,SAAS,GAAG;AAClD,MAAMC,oBAAgC,EAAE,UAAU,IAAK;AAmCvD,MAAM,mBAAmB,EACvB,MACA,OACA,WAEA,gBACA,aACA,eACA,gBACA,UACA,SACA,QACA,aACA,eACA,kBAAkB,MAElB,WACA,YACA,QAAQ,YACR,aAC0B;CAC1B,MAAM,gBAAgB,OAAO,aAAa,MAAM,CAAC,MAAM,IAAI,CAAC;CAE5D,MAAM,kBAAkB,cAAc;AACpC,UAAQ,eAAR;GACE,KAAK,MACH,QAAO;GAET,KAAK,SACH,QAAO;GAET,KAAK,OACH,QAAO;GAET,KAAK,QACH,QAAO;GAET,QACE,QAAO;;IAGV,CAAC,cAAc,CAAC;CAEnB,MAAM,eAAe,YAAY,QAAQ,gBAAgB,UAAU,EAAE;EACnE,SAAS;EACT,MAAM;EACP,CAAC;CAEF,MAAM,SAAS,oBAAoB;CAEnC,MAAM,iBAAiB,SACrB,qBAACC;EAAQ,OAAO;EAAU,KAAK;EAAG;EAAW,SAAS;aACpD,oBAAC,oBAAM,QAAa,EACpB,oBAACC;GAAO;GAAa,MAAM;GAAQ,GAAI;IAAe;GAC9C,GAEV;AAEF,QACE,oBAAC,6BACE,QAAQ,SACP,oBAAC;EACC,WAAW,GACT,OAAO,SACP,mBAAmB,gBAAgB,OAAO,eAC1C,YAAY,WACZ,YAAY,MACZ,UACD;EAED,KAAK;EACL,MAAK;EACL,OACE,YAAY,OACR;GACE,GAAG;GACH;GACA,GAAG,WAAW;GACd,GAAG,WAAW;GACf,GACD;GACE,GAAG;GACH;GACA,GAAG,YAAY;GAChB;EAEP,GAAI;YAEJ,qBAAC,OAAO;GACN,SAAS;GACT,MAAM;GACN,SAAS;GACT,OAAO,EAAE,iBAAiB;GAC1B,YAAY;cAEZ,oBAAC;IAAI,WAAW,GAAG,OAAO,SAAS,YAAY,QAAQ;IAAE,OAAO,YAAY;cACzE,kBACC,oBAAC;KAAgB,MAAK;eACpB,oBAAC,OAAO;MACN,SAAS;MACT,MAAM;MACN,SAAS,gBAAgB,QAAQ;MAEjC,YAAY;gBAEX;QAHI,OAAO,MAAM,CAIP;MACG,GAElB;KAEE,EACLC,WAAS,WACR,oBAAC;IACC,WAAW,GAAG,OAAO,OAAO,YAAY,MAAM;IACrC;IACT,QAAQ;IACR,KAAK;IACL,OAAO,YAAY;IACnB,OAAO;KACP;IAEO;IArDT,UAsDA,GAEQ;;AAItB,8BAAe"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TooltipProps } from "./type.mjs";
|
|
2
|
-
import "react";
|
|
3
|
-
|
|
4
|
-
//#region src/Tooltip/groupContext.d.ts
|
|
5
|
-
type TooltipGroupSharedProps = Omit<TooltipProps, 'children' | 'defaultOpen' | 'open' | 'ref' | 'title'> & {
|
|
6
|
-
/**
|
|
7
|
-
* @description Whether to enable layout animation when switching between tooltips
|
|
8
|
-
* @default true
|
|
9
|
-
*/
|
|
10
|
-
layoutAnimation?: boolean;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
export { TooltipGroupSharedProps };
|
|
14
|
-
//# sourceMappingURL=groupContext.d.mts.map
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { toFloatingUIPlacement } from "../utils/placement.mjs";
|
|
2
|
-
import { useMemo, useRef } from "react";
|
|
3
|
-
import { arrow, autoUpdate, flip, offset, shift, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole } from "@floating-ui/react";
|
|
4
|
-
|
|
5
|
-
//#region src/Tooltip/useTooltipFloating.ts
|
|
6
|
-
const useTooltipFloating = ({ arrow: arrow$1, placement, openDelay, closeDelay, mouseEnterDelay, mouseLeaveDelay, disabled, open, onOpenChange }) => {
|
|
7
|
-
const arrowRef = useRef(null);
|
|
8
|
-
const floatingPlacement = useMemo(() => toFloatingUIPlacement(placement), [placement]);
|
|
9
|
-
const { context, floatingStyles, refs } = useFloating({
|
|
10
|
-
middleware: useMemo(() => {
|
|
11
|
-
const base = [
|
|
12
|
-
offset(8),
|
|
13
|
-
flip(),
|
|
14
|
-
shift({ padding: 8 })
|
|
15
|
-
];
|
|
16
|
-
if (arrow$1) base.push(arrow({ element: arrowRef }));
|
|
17
|
-
return base;
|
|
18
|
-
}, [arrow$1]),
|
|
19
|
-
onOpenChange,
|
|
20
|
-
open,
|
|
21
|
-
placement: floatingPlacement,
|
|
22
|
-
whileElementsMounted: autoUpdate
|
|
23
|
-
});
|
|
24
|
-
const { getFloatingProps, getReferenceProps } = useInteractions([
|
|
25
|
-
useHover(context, {
|
|
26
|
-
delay: useMemo(() => ({
|
|
27
|
-
close: closeDelay ?? (mouseLeaveDelay !== void 0 ? mouseLeaveDelay * 1e3 : 100),
|
|
28
|
-
open: openDelay ?? (mouseEnterDelay !== void 0 ? mouseEnterDelay * 1e3 : 400)
|
|
29
|
-
}), [
|
|
30
|
-
closeDelay,
|
|
31
|
-
mouseEnterDelay,
|
|
32
|
-
mouseLeaveDelay,
|
|
33
|
-
openDelay
|
|
34
|
-
]),
|
|
35
|
-
enabled: !disabled,
|
|
36
|
-
move: false
|
|
37
|
-
}),
|
|
38
|
-
useFocus(context, { enabled: !disabled }),
|
|
39
|
-
useDismiss(context, { enabled: !disabled }),
|
|
40
|
-
useRole(context, { role: "tooltip" })
|
|
41
|
-
]);
|
|
42
|
-
return {
|
|
43
|
-
arrowRef,
|
|
44
|
-
context,
|
|
45
|
-
floatingPlacement,
|
|
46
|
-
floatingStyles,
|
|
47
|
-
getFloatingProps,
|
|
48
|
-
getReferenceProps,
|
|
49
|
-
refs
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
export { useTooltipFloating };
|
|
55
|
-
//# sourceMappingURL=useTooltipFloating.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltipFloating.mjs","names":["arrow","arrowMiddleware"],"sources":["../../src/Tooltip/useTooltipFloating.ts"],"sourcesContent":["import {\n arrow as arrowMiddleware,\n autoUpdate,\n flip,\n offset,\n shift,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useRole,\n} from '@floating-ui/react';\nimport type { FloatingContext, Placement } from '@floating-ui/react';\nimport { useMemo, useRef } from 'react';\nimport type { CSSProperties, RefObject } from 'react';\n\nimport { toFloatingUIPlacement } from '@/utils/placement';\n\nimport type { TooltipPlacement } from './type';\n\ntype UseTooltipFloatingReturn = {\n arrowRef: RefObject<SVGSVGElement | null>;\n context: FloatingContext;\n floatingPlacement: Placement;\n floatingStyles: CSSProperties;\n getFloatingProps: ReturnType<typeof useInteractions>['getFloatingProps'];\n getReferenceProps: ReturnType<typeof useInteractions>['getReferenceProps'];\n refs: ReturnType<typeof useFloating>['refs'];\n};\n\nexport const useTooltipFloating = ({\n arrow,\n placement,\n openDelay,\n closeDelay,\n mouseEnterDelay,\n mouseLeaveDelay,\n disabled,\n open,\n onOpenChange,\n}: {\n arrow?: boolean;\n closeDelay?: number;\n disabled?: boolean;\n mouseEnterDelay?: number;\n mouseLeaveDelay?: number;\n onOpenChange: (open: boolean) => void;\n open: boolean;\n openDelay?: number;\n placement: TooltipPlacement;\n}): UseTooltipFloatingReturn => {\n const arrowRef = useRef<SVGSVGElement | null>(null);\n\n const floatingPlacement = useMemo(() => toFloatingUIPlacement(placement), [placement]);\n\n const middleware = useMemo(() => {\n const base = [offset(8), flip(), shift({ padding: 8 })];\n if (arrow) base.push(arrowMiddleware({ element: arrowRef }));\n return base;\n }, [arrow]);\n\n const { context, floatingStyles, refs } = useFloating({\n middleware,\n onOpenChange,\n open,\n placement: floatingPlacement,\n whileElementsMounted: autoUpdate,\n });\n\n const resolvedDelay = useMemo(\n () => ({\n close: closeDelay ?? (mouseLeaveDelay !== undefined ? mouseLeaveDelay * 1000 : 100),\n open: openDelay ?? (mouseEnterDelay !== undefined ? mouseEnterDelay * 1000 : 400),\n }),\n [closeDelay, mouseEnterDelay, mouseLeaveDelay, openDelay],\n );\n\n const hover = useHover(context, {\n delay: resolvedDelay,\n enabled: !disabled,\n move: false,\n });\n const focus = useFocus(context, { enabled: !disabled });\n const dismiss = useDismiss(context, { enabled: !disabled });\n const role = useRole(context, { role: 'tooltip' });\n\n const { getFloatingProps, getReferenceProps } = useInteractions([hover, focus, dismiss, role]);\n\n return {\n arrowRef,\n context,\n floatingPlacement,\n floatingStyles,\n getFloatingProps,\n getReferenceProps,\n refs,\n };\n};\n"],"mappings":";;;;;AA+BA,MAAa,sBAAsB,EACjC,gBACA,WACA,WACA,YACA,iBACA,iBACA,UACA,MACA,mBAW8B;CAC9B,MAAM,WAAW,OAA6B,KAAK;CAEnD,MAAM,oBAAoB,cAAc,sBAAsB,UAAU,EAAE,CAAC,UAAU,CAAC;CAQtF,MAAM,EAAE,SAAS,gBAAgB,SAAS,YAAY;EACpD,YAPiB,cAAc;GAC/B,MAAM,OAAO;IAAC,OAAO,EAAE;IAAE,MAAM;IAAE,MAAM,EAAE,SAAS,GAAG,CAAC;IAAC;AACvD,OAAIA,QAAO,MAAK,KAAKC,MAAgB,EAAE,SAAS,UAAU,CAAC,CAAC;AAC5D,UAAO;KACN,CAACD,QAAM,CAAC;EAIT;EACA;EACA,WAAW;EACX,sBAAsB;EACvB,CAAC;CAmBF,MAAM,EAAE,kBAAkB,sBAAsB,gBAAgB;EATlD,SAAS,SAAS;GAC9B,OAToB,eACb;IACL,OAAO,eAAe,oBAAoB,SAAY,kBAAkB,MAAO;IAC/E,MAAM,cAAc,oBAAoB,SAAY,kBAAkB,MAAO;IAC9E,GACD;IAAC;IAAY;IAAiB;IAAiB;IAAU,CAC1D;GAIC,SAAS,CAAC;GACV,MAAM;GACP,CAAC;EACY,SAAS,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC;EACvC,WAAW,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC;EAC9C,QAAQ,SAAS,EAAE,MAAM,WAAW,CAAC;EAE2C,CAAC;AAE9F,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { isElementHidden } from "./utils.mjs";
|
|
2
|
-
import { cloneElement, isValidElement, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { mergeRefs } from "react-merge-refs";
|
|
4
|
-
|
|
5
|
-
//#region src/Tooltip/useTooltipReference.ts
|
|
6
|
-
const useTooltipReference = ({ trigger, ref, getReferenceProps, setReference, mergedOpen, setOpen }) => {
|
|
7
|
-
const [referenceEl, setReferenceEl] = useState(null);
|
|
8
|
-
const previousReferenceRef = useRef(null);
|
|
9
|
-
const previousConnectedRef = useRef(false);
|
|
10
|
-
const referenceConnected = Boolean(referenceEl && !isElementHidden(referenceEl));
|
|
11
|
-
const referenceNode = useMemo(() => {
|
|
12
|
-
if (!isValidElement(trigger)) return trigger;
|
|
13
|
-
const originalRef = trigger.ref;
|
|
14
|
-
const setReferenceNode = (node) => {
|
|
15
|
-
const resolved = node instanceof HTMLElement ? node : null;
|
|
16
|
-
setReferenceEl((prev) => prev === resolved ? prev : resolved);
|
|
17
|
-
};
|
|
18
|
-
return cloneElement(trigger, getReferenceProps({
|
|
19
|
-
...trigger.props,
|
|
20
|
-
ref: mergeRefs([
|
|
21
|
-
originalRef,
|
|
22
|
-
setReference,
|
|
23
|
-
setReferenceNode,
|
|
24
|
-
ref
|
|
25
|
-
])
|
|
26
|
-
}));
|
|
27
|
-
}, [
|
|
28
|
-
getReferenceProps,
|
|
29
|
-
ref,
|
|
30
|
-
setReference,
|
|
31
|
-
trigger
|
|
32
|
-
]);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const previousReference = previousReferenceRef.current;
|
|
35
|
-
const previousConnected = previousConnectedRef.current;
|
|
36
|
-
const referenceChanged = previousReference && previousReference !== referenceEl;
|
|
37
|
-
const previousDisconnected = previousReference ? isElementHidden(previousReference) : false;
|
|
38
|
-
if (mergedOpen && (referenceChanged && previousDisconnected || previousConnected && !referenceConnected)) setOpen(false);
|
|
39
|
-
previousReferenceRef.current = referenceEl;
|
|
40
|
-
previousConnectedRef.current = referenceConnected;
|
|
41
|
-
}, [
|
|
42
|
-
mergedOpen,
|
|
43
|
-
referenceConnected,
|
|
44
|
-
referenceEl,
|
|
45
|
-
setOpen
|
|
46
|
-
]);
|
|
47
|
-
return {
|
|
48
|
-
referenceConnected,
|
|
49
|
-
referenceEl,
|
|
50
|
-
referenceNode
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
export { useTooltipReference };
|
|
56
|
-
//# sourceMappingURL=useTooltipReference.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltipReference.mjs","names":[],"sources":["../../src/Tooltip/useTooltipReference.ts"],"sourcesContent":["import React, { type Ref, useEffect, useMemo, useRef, useState } from 'react';\nimport { cloneElement, isValidElement } from 'react';\nimport { mergeRefs } from 'react-merge-refs';\n\nimport { isElementHidden } from './utils';\n\nexport const useTooltipReference = ({\n trigger,\n ref,\n getReferenceProps,\n setReference,\n mergedOpen,\n setOpen,\n}: {\n getReferenceProps: (props: any) => any;\n mergedOpen: boolean;\n ref?: Ref<HTMLElement>;\n setOpen: (open: boolean) => void;\n setReference: (node: HTMLElement | null) => void;\n trigger: React.ReactElement | React.ReactNode;\n}) => {\n const [referenceEl, setReferenceEl] = useState<HTMLElement | null>(null);\n const previousReferenceRef = useRef<HTMLElement | null>(null);\n const previousConnectedRef = useRef(false);\n\n const referenceConnected = Boolean(referenceEl && !isElementHidden(referenceEl));\n\n const referenceNode = useMemo(() => {\n if (!isValidElement(trigger)) return trigger;\n\n const originalRef = (trigger as any).ref;\n const setReferenceNode = (node: unknown) => {\n const resolved = node instanceof HTMLElement ? node : null;\n setReferenceEl((prev) => (prev === resolved ? prev : resolved));\n };\n\n return cloneElement(\n trigger as any,\n getReferenceProps({\n ...(trigger.props as any),\n ref: mergeRefs([originalRef, setReference, setReferenceNode, ref]),\n }),\n );\n }, [getReferenceProps, ref, setReference, trigger]);\n\n // Watch for trigger removal outside React renders.\n useEffect(() => {\n const previousReference = previousReferenceRef.current;\n const previousConnected = previousConnectedRef.current;\n const referenceChanged = previousReference && previousReference !== referenceEl;\n const previousDisconnected = previousReference ? isElementHidden(previousReference) : false;\n\n if (\n mergedOpen &&\n ((referenceChanged && previousDisconnected) || (previousConnected && !referenceConnected))\n ) {\n setOpen(false);\n }\n\n previousReferenceRef.current = referenceEl;\n previousConnectedRef.current = referenceConnected;\n }, [mergedOpen, referenceConnected, referenceEl, setOpen]);\n\n return {\n referenceConnected,\n referenceEl,\n referenceNode,\n };\n};\n"],"mappings":";;;;;AAMA,MAAa,uBAAuB,EAClC,SACA,KACA,mBACA,cACA,YACA,cAQI;CACJ,MAAM,CAAC,aAAa,kBAAkB,SAA6B,KAAK;CACxE,MAAM,uBAAuB,OAA2B,KAAK;CAC7D,MAAM,uBAAuB,OAAO,MAAM;CAE1C,MAAM,qBAAqB,QAAQ,eAAe,CAAC,gBAAgB,YAAY,CAAC;CAEhF,MAAM,gBAAgB,cAAc;AAClC,MAAI,CAAC,eAAe,QAAQ,CAAE,QAAO;EAErC,MAAM,cAAe,QAAgB;EACrC,MAAM,oBAAoB,SAAkB;GAC1C,MAAM,WAAW,gBAAgB,cAAc,OAAO;AACtD,mBAAgB,SAAU,SAAS,WAAW,OAAO,SAAU;;AAGjE,SAAO,aACL,SACA,kBAAkB;GAChB,GAAI,QAAQ;GACZ,KAAK,UAAU;IAAC;IAAa;IAAc;IAAkB;IAAI,CAAC;GACnE,CAAC,CACH;IACA;EAAC;EAAmB;EAAK;EAAc;EAAQ,CAAC;AAGnD,iBAAgB;EACd,MAAM,oBAAoB,qBAAqB;EAC/C,MAAM,oBAAoB,qBAAqB;EAC/C,MAAM,mBAAmB,qBAAqB,sBAAsB;EACpE,MAAM,uBAAuB,oBAAoB,gBAAgB,kBAAkB,GAAG;AAEtF,MACE,eACE,oBAAoB,wBAA0B,qBAAqB,CAAC,oBAEtE,SAAQ,MAAM;AAGhB,uBAAqB,UAAU;AAC/B,uBAAqB,UAAU;IAC9B;EAAC;EAAY;EAAoB;EAAa;EAAQ,CAAC;AAE1D,QAAO;EACL;EACA;EACA;EACD"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { isValidElement, useMemo } from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/Tooltip/useTooltipTrigger.tsx
|
|
5
|
-
const useTooltipTrigger = (children) => {
|
|
6
|
-
return useMemo(() => {
|
|
7
|
-
if (!isValidElement(children)) return /* @__PURE__ */ jsx("span", { children });
|
|
8
|
-
if (typeof children.type === "string" && Boolean(children.props?.disabled)) return /* @__PURE__ */ jsx("span", {
|
|
9
|
-
style: { display: "inline-flex" },
|
|
10
|
-
children
|
|
11
|
-
});
|
|
12
|
-
return children;
|
|
13
|
-
}, [children]);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { useTooltipTrigger };
|
|
18
|
-
//# sourceMappingURL=useTooltipTrigger.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltipTrigger.mjs","names":[],"sources":["../../src/Tooltip/useTooltipTrigger.tsx"],"sourcesContent":["import { type ReactNode, isValidElement, useMemo } from 'react';\n\nexport const useTooltipTrigger = (children: ReactNode) => {\n const trigger = useMemo(() => {\n if (!isValidElement(children)) return <span>{children}</span>;\n\n const needsWrapper =\n typeof children.type === 'string' && Boolean((children.props as any)?.disabled);\n\n if (needsWrapper) return <span style={{ display: 'inline-flex' }}>{children}</span>;\n\n return children;\n }, [children]);\n\n return trigger;\n};\n"],"mappings":";;;;AAEA,MAAa,qBAAqB,aAAwB;AAYxD,QAXgB,cAAc;AAC5B,MAAI,CAAC,eAAe,SAAS,CAAE,QAAO,oBAAC,UAAM,WAAgB;AAK7D,MAFE,OAAO,SAAS,SAAS,YAAY,QAAS,SAAS,OAAe,SAAS,CAE/D,QAAO,oBAAC;GAAK,OAAO,EAAE,SAAS,eAAe;GAAG;IAAgB;AAEnF,SAAO;IACN,CAAC,SAAS,CAAC"}
|
package/es/Tooltip/utils.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//#region src/Tooltip/utils.ts
|
|
2
|
-
const isElementHidden = (el) => {
|
|
3
|
-
if (!el) return true;
|
|
4
|
-
if (!el.isConnected) return true;
|
|
5
|
-
return el.getClientRects().length === 0;
|
|
6
|
-
};
|
|
7
|
-
const observeElementVisibility = (el, onChange) => {
|
|
8
|
-
const update = () => onChange(!isElementHidden(el));
|
|
9
|
-
update();
|
|
10
|
-
const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
|
|
11
|
-
resizeObserver?.observe(el);
|
|
12
|
-
const mutationObserver = typeof MutationObserver !== "undefined" ? new MutationObserver(update) : null;
|
|
13
|
-
if (mutationObserver) {
|
|
14
|
-
const options = {
|
|
15
|
-
attributeFilter: [
|
|
16
|
-
"style",
|
|
17
|
-
"class",
|
|
18
|
-
"hidden"
|
|
19
|
-
],
|
|
20
|
-
attributes: true
|
|
21
|
-
};
|
|
22
|
-
let node = el;
|
|
23
|
-
while (node) {
|
|
24
|
-
mutationObserver.observe(node, options);
|
|
25
|
-
node = node.parentElement;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return () => {
|
|
29
|
-
resizeObserver?.disconnect();
|
|
30
|
-
mutationObserver?.disconnect();
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { isElementHidden, observeElementVisibility };
|
|
36
|
-
//# sourceMappingURL=utils.mjs.map
|
package/es/Tooltip/utils.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":["node: HTMLElement | null"],"sources":["../../src/Tooltip/utils.ts"],"sourcesContent":["export const isElementHidden = (el?: HTMLElement | null) => {\n if (!el) return true;\n if (!el.isConnected) return true;\n return el.getClientRects().length === 0;\n};\n\nexport const observeElementVisibility = (el: HTMLElement, onChange: (visible: boolean) => void) => {\n const update = () => onChange(!isElementHidden(el));\n\n update();\n\n const resizeObserver = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(update) : null;\n resizeObserver?.observe(el);\n\n const mutationObserver =\n typeof MutationObserver !== 'undefined' ? new MutationObserver(update) : null;\n\n if (mutationObserver) {\n const options = { attributeFilter: ['style', 'class', 'hidden'], attributes: true };\n let node: HTMLElement | null = el;\n while (node) {\n mutationObserver.observe(node, options);\n node = node.parentElement;\n }\n }\n\n return () => {\n resizeObserver?.disconnect();\n mutationObserver?.disconnect();\n };\n};\n"],"mappings":";AAAA,MAAa,mBAAmB,OAA4B;AAC1D,KAAI,CAAC,GAAI,QAAO;AAChB,KAAI,CAAC,GAAG,YAAa,QAAO;AAC5B,QAAO,GAAG,gBAAgB,CAAC,WAAW;;AAGxC,MAAa,4BAA4B,IAAiB,aAAyC;CACjG,MAAM,eAAe,SAAS,CAAC,gBAAgB,GAAG,CAAC;AAEnD,SAAQ;CAER,MAAM,iBAAiB,OAAO,mBAAmB,cAAc,IAAI,eAAe,OAAO,GAAG;AAC5F,iBAAgB,QAAQ,GAAG;CAE3B,MAAM,mBACJ,OAAO,qBAAqB,cAAc,IAAI,iBAAiB,OAAO,GAAG;AAE3E,KAAI,kBAAkB;EACpB,MAAM,UAAU;GAAE,iBAAiB;IAAC;IAAS;IAAS;IAAS;GAAE,YAAY;GAAM;EACnF,IAAIA,OAA2B;AAC/B,SAAO,MAAM;AACX,oBAAiB,QAAQ,MAAM,QAAQ;AACvC,UAAO,KAAK;;;AAIhB,cAAa;AACX,kBAAgB,YAAY;AAC5B,oBAAkB,YAAY"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region src/utils/composeEventHandlers.ts
|
|
2
|
-
/**
|
|
3
|
-
* Composes two event handlers together, calling the external handler first,
|
|
4
|
-
* then the internal handler if the event hasn't been prevented.
|
|
5
|
-
*
|
|
6
|
-
* @template E - The event type
|
|
7
|
-
* @param theirHandler - The external event handler (may be undefined)
|
|
8
|
-
* @param ourHandler - The internal event handler
|
|
9
|
-
* @returns A composed event handler that calls both handlers in sequence
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* <button
|
|
14
|
-
* onClick={composeEventHandlers(externalOnClick, (e) => {
|
|
15
|
-
* // Internal handler logic
|
|
16
|
-
* })}
|
|
17
|
-
* />
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
const composeEventHandlers = (theirHandler, ourHandler) => (event) => {
|
|
21
|
-
theirHandler?.(event);
|
|
22
|
-
if (event?.defaultPrevented) return;
|
|
23
|
-
ourHandler(event);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
export { composeEventHandlers };
|
|
28
|
-
//# sourceMappingURL=composeEventHandlers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"composeEventHandlers.mjs","names":[],"sources":["../../src/utils/composeEventHandlers.ts"],"sourcesContent":["/**\n * Composes two event handlers together, calling the external handler first,\n * then the internal handler if the event hasn't been prevented.\n *\n * @template E - The event type\n * @param theirHandler - The external event handler (may be undefined)\n * @param ourHandler - The internal event handler\n * @returns A composed event handler that calls both handlers in sequence\n *\n * @example\n * ```tsx\n * <button\n * onClick={composeEventHandlers(externalOnClick, (e) => {\n * // Internal handler logic\n * })}\n * />\n * ```\n */\nexport const composeEventHandlers =\n <E>(\n theirHandler: ((event: E) => void) | undefined,\n ourHandler: (event: E) => void,\n ): ((event: E) => void) =>\n (event) => {\n theirHandler?.(event);\n // @ts-ignore - compatible with React SyntheticEvent shape\n if (event?.defaultPrevented) return;\n ourHandler(event);\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAa,wBAET,cACA,gBAED,UAAU;AACT,gBAAe,MAAM;AAErB,KAAI,OAAO,iBAAkB;AAC7B,YAAW,MAAM"}
|