@lobehub/ui 4.14.0 → 4.15.0
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/AutoComplete/Select.d.mts +2 -2
- 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/CopyButton/CopyButton.d.mts +2 -2
- package/es/DatePicker/DatePicker.d.mts +2 -2
- 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/Drawer/Drawer.d.mts +2 -2
- package/es/Dropdown/Dropdown.d.mts +2 -2
- package/es/DropdownMenu/DropdownMenu.d.mts +2 -2
- 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/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/PopoverGroup.mjs +18 -9
- package/es/Popover/PopoverGroup.mjs.map +1 -1
- package/es/Popover/PopoverStandalone.mjs +3 -2
- package/es/Popover/PopoverStandalone.mjs.map +1 -1
- package/es/Popover/context.d.mts +2 -2
- package/es/Popover/groupContext.d.mts +10 -0
- package/es/Popover/groupContext.mjs.map +1 -1
- package/es/Popover/index.d.mts +2 -2
- package/es/Popover/style.mjs +11 -2
- package/es/Popover/style.mjs.map +1 -1
- package/es/Popover/type.d.mts +10 -2
- 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/TooltipGroup.mjs +18 -9
- package/es/Tooltip/TooltipGroup.mjs.map +1 -1
- package/es/Tooltip/TooltipStandalone.mjs +3 -2
- package/es/Tooltip/TooltipStandalone.mjs.map +1 -1
- package/es/Tooltip/index.d.mts +1 -1
- package/es/Tooltip/style.mjs +7 -0
- package/es/Tooltip/style.mjs.map +1 -1
- package/es/Tooltip/type.d.mts +21 -2
- package/es/Video/index.d.mts +2 -2
- package/es/awesome/AuroraBackground/AuroraBackground.d.mts +2 -2
- package/es/awesome/BottomGradientButton/BottomGradientButton.d.mts +2 -2
- package/es/awesome/Features/Features.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/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/ChatItem/ChatItem.d.mts +2 -2
- package/es/color/ColorScales/index.d.mts +2 -2
- package/es/color/CssVar/index.d.mts +2 -2
- package/es/i18n/context.d.mts +2 -2
- package/es/icons/lucideExtra/BotPromptIcon.d.mts +2 -2
- package/es/icons/lucideExtra/CreateBotIcon.d.mts +3 -3
- package/es/icons/lucideExtra/DiscordIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GlobeOffIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GroupBotIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GroupBotSquareIcon.d.mts +3 -3
- package/es/icons/lucideExtra/LeftClickIcon.d.mts +3 -3
- 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/mdx/Mdx/index.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/destroyOnInvalidActiveTriggerElement.mjs +88 -0
- package/es/utils/destroyOnInvalidActiveTriggerElement.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react99 from "react";
|
|
2
|
+
import * as lucide_react8 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/GroupBotSquareIcon.d.ts
|
|
5
|
-
declare const GroupBotSquareIcon:
|
|
5
|
+
declare const GroupBotSquareIcon: react99.ForwardRefExoticComponent<Omit<lucide_react8.LucideProps, "ref"> & react99.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { GroupBotSquareIcon };
|
|
8
8
|
//# sourceMappingURL=GroupBotSquareIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react103 from "react";
|
|
2
|
+
import * as lucide_react10 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/LeftClickIcon.d.ts
|
|
5
|
-
declare const LeftClickIcon:
|
|
5
|
+
declare const LeftClickIcon: react103.ForwardRefExoticComponent<Omit<lucide_react10.LucideProps, "ref"> & react103.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { LeftClickIcon };
|
|
8
8
|
//# sourceMappingURL=LeftClickIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react87 from "react";
|
|
2
|
+
import * as lucide_react2 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/LeftDoubleClickIcon.d.ts
|
|
5
|
-
declare const LeftDoubleClickIcon:
|
|
5
|
+
declare const LeftDoubleClickIcon: react87.ForwardRefExoticComponent<Omit<lucide_react2.LucideProps, "ref"> & react87.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { LeftDoubleClickIcon };
|
|
8
8
|
//# sourceMappingURL=LeftDoubleClickIcon.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as react95 from "react";
|
|
2
|
+
import * as lucide_react6 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/McpIcon.d.ts
|
|
5
|
-
declare const McpIcon:
|
|
5
|
+
declare const McpIcon: react95.ForwardRefExoticComponent<Omit<lucide_react6.LucideProps, "ref"> & react95.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 react97 from "react";
|
|
2
|
+
import * as lucide_react7 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/ProviderIcon.d.ts
|
|
5
|
-
declare const ProviderIcon:
|
|
5
|
+
declare const ProviderIcon: react97.ForwardRefExoticComponent<Omit<lucide_react7.LucideProps, "ref"> & react97.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 react101 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: react101.ForwardRefExoticComponent<Omit<lucide_react9.LucideProps, "ref"> & react101.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 react105 from "react";
|
|
2
|
+
import * as lucide_react11 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/RightDoubleClickIcon.d.ts
|
|
5
|
-
declare const RightDoubleClickIcon:
|
|
5
|
+
declare const RightDoubleClickIcon: react105.ForwardRefExoticComponent<Omit<lucide_react11.LucideProps, "ref"> & react105.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 react107 from "react";
|
|
2
|
+
import * as lucide_react12 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/ShapesUploadIcon.d.ts
|
|
5
|
-
declare const ShapesUploadIcon:
|
|
5
|
+
declare const ShapesUploadIcon: react107.ForwardRefExoticComponent<Omit<lucide_react12.LucideProps, "ref"> & react107.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 react109 from "react";
|
|
2
|
+
import * as lucide_react13 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/TreeDownRightIcon.d.ts
|
|
5
|
-
declare const TreeDownRightIcon:
|
|
5
|
+
declare const TreeDownRightIcon: react109.ForwardRefExoticComponent<Omit<lucide_react13.LucideProps, "ref"> & react109.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 react91 from "react";
|
|
2
|
+
import * as lucide_react4 from "lucide-react";
|
|
3
3
|
|
|
4
4
|
//#region src/icons/lucideExtra/TreeUpDownRightIcon.d.ts
|
|
5
|
-
declare const TreeUpDownRightIcon:
|
|
5
|
+
declare const TreeUpDownRightIcon: react91.ForwardRefExoticComponent<Omit<lucide_react4.LucideProps, "ref"> & react91.RefAttributes<SVGSVGElement>>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { TreeUpDownRightIcon };
|
|
8
8
|
//# sourceMappingURL=TreeUpDownRightIcon.d.mts.map
|
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 react9 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: react9.NamedExoticComponent<MdxProps>;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { Mdx, MdxProps };
|
|
24
24
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TabBarProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react113 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/mobile/TabBar/TabBar.d.ts
|
|
5
|
-
declare const TabBar:
|
|
5
|
+
declare const TabBar: react113.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 react8 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: react8.NamedExoticComponent<StoryBookProps>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { StoryBook, StoryBookProps, useControls, useCreateStore };
|
|
16
16
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useLayoutEffect } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/destroyOnInvalidActiveTriggerElement.ts
|
|
4
|
+
const isInvalidTriggerElement = (el) => {
|
|
5
|
+
if (!el) return true;
|
|
6
|
+
if (!el.isConnected) return true;
|
|
7
|
+
try {
|
|
8
|
+
let current = el;
|
|
9
|
+
while (current) {
|
|
10
|
+
if (getComputedStyle(current).display === "none") return true;
|
|
11
|
+
current = current.parentElement;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Destroys (hard reset) a group popup (Tooltip/Popover) when its active trigger element becomes
|
|
20
|
+
* disconnected from the DOM or is effectively hidden via `display: none`.
|
|
21
|
+
*
|
|
22
|
+
* We intentionally poll while open to also catch CSS-driven visibility changes that won't
|
|
23
|
+
* necessarily trigger DOM mutation observers.
|
|
24
|
+
*/
|
|
25
|
+
const useDestroyOnInvalidActiveTriggerElement = (store, destroy, options) => {
|
|
26
|
+
const enabled = options?.enabled ?? true;
|
|
27
|
+
const openReactive = store.useState?.("open") ?? Boolean(store.state.open);
|
|
28
|
+
const shouldWatch = enabled && openReactive;
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
if (!shouldWatch) return;
|
|
31
|
+
let raf = 0;
|
|
32
|
+
const loop = () => {
|
|
33
|
+
if (isInvalidTriggerElement(store.state.activeTriggerElement ?? null)) {
|
|
34
|
+
destroy();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
raf = window.requestAnimationFrame(loop);
|
|
38
|
+
};
|
|
39
|
+
loop();
|
|
40
|
+
return () => window.cancelAnimationFrame(raf);
|
|
41
|
+
}, [
|
|
42
|
+
destroy,
|
|
43
|
+
shouldWatch,
|
|
44
|
+
store
|
|
45
|
+
]);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* UI-only fallback: If the positioner ends up at viewport (0,0), hide it to avoid a visible flash
|
|
49
|
+
* in the corner. This doesn't replace "destroy on invalid trigger"; it's purely a visual guard.
|
|
50
|
+
*/
|
|
51
|
+
const useHidePopupWhenPositionerAtOrigin = (store, options) => {
|
|
52
|
+
const enabled = options?.enabled ?? true;
|
|
53
|
+
const threshold = options?.threshold ?? .5;
|
|
54
|
+
const openReactive = store.useState?.("open") ?? Boolean(store.state.open);
|
|
55
|
+
const positionerElementReactive = store.useState?.("positionerElement") ?? store.state.positionerElement ?? null;
|
|
56
|
+
useLayoutEffect(() => {
|
|
57
|
+
const positionerEl = store.state.positionerElement ?? positionerElementReactive;
|
|
58
|
+
if (!enabled || !openReactive || !positionerEl) {
|
|
59
|
+
if (positionerEl) delete positionerEl.dataset.zeroOrigin;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let raf = 0;
|
|
63
|
+
const loop = () => {
|
|
64
|
+
const current = store.state.positionerElement ?? positionerEl;
|
|
65
|
+
if (!current) return;
|
|
66
|
+
const rect = current.getBoundingClientRect();
|
|
67
|
+
if (Math.abs(rect.left) <= threshold && Math.abs(rect.top) <= threshold) current.dataset.zeroOrigin = "true";
|
|
68
|
+
else delete current.dataset.zeroOrigin;
|
|
69
|
+
raf = window.requestAnimationFrame(loop);
|
|
70
|
+
};
|
|
71
|
+
loop();
|
|
72
|
+
return () => {
|
|
73
|
+
window.cancelAnimationFrame(raf);
|
|
74
|
+
const current = store.state.positionerElement ?? positionerEl;
|
|
75
|
+
if (current) delete current.dataset.zeroOrigin;
|
|
76
|
+
};
|
|
77
|
+
}, [
|
|
78
|
+
enabled,
|
|
79
|
+
openReactive,
|
|
80
|
+
positionerElementReactive,
|
|
81
|
+
store,
|
|
82
|
+
threshold
|
|
83
|
+
]);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { useDestroyOnInvalidActiveTriggerElement, useHidePopupWhenPositionerAtOrigin };
|
|
88
|
+
//# sourceMappingURL=destroyOnInvalidActiveTriggerElement.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroyOnInvalidActiveTriggerElement.mjs","names":["current: Element | null"],"sources":["../../src/utils/destroyOnInvalidActiveTriggerElement.ts"],"sourcesContent":["import { useLayoutEffect } from 'react';\n\ntype PopupStoreLike = {\n // Base UI store's `useState` has a strongly-typed key union; we keep it loose here on purpose.\n state: {\n activeTriggerElement?: Element | null;\n open?: boolean;\n positionerElement?: HTMLElement | null;\n };\n useState?: (...args: any[]) => unknown;\n};\n\nconst isInvalidTriggerElement = (el: Element | null): boolean => {\n if (!el) return true;\n\n if (!el.isConnected) return true;\n\n // \"display: none\" on self or an ancestor effectively hides the trigger.\n // `getComputedStyle` can throw in some edge cases (e.g. non-Element in old envs),\n // so we guard it defensively.\n try {\n // Check self and all ancestors for display: none\n let current: Element | null = el;\n while (current) {\n if (getComputedStyle(current).display === 'none') {\n return true;\n }\n current = current.parentElement;\n }\n return false;\n } catch {\n return false;\n }\n};\n\n/**\n * Destroys (hard reset) a group popup (Tooltip/Popover) when its active trigger element becomes\n * disconnected from the DOM or is effectively hidden via `display: none`.\n *\n * We intentionally poll while open to also catch CSS-driven visibility changes that won't\n * necessarily trigger DOM mutation observers.\n */\nexport const useDestroyOnInvalidActiveTriggerElement = (\n store: PopupStoreLike,\n destroy: () => void,\n options?: {\n /**\n * @default true\n */\n enabled?: boolean;\n },\n) => {\n const enabled = options?.enabled ?? true;\n\n // Subscribe with `useState` (reactive), but read from `state` (immediate) inside the loop.\n // Base UI note: `state` updates immediately, while `useState` reflects updates before the next render.\n const openReactive =\n (store.useState?.('open') as boolean | undefined) ?? Boolean(store.state.open);\n const shouldWatch = enabled && openReactive;\n\n // Use layout effect so the first check runs right after React commits DOM updates.\n // Then keep watching via rAF while open to also capture CSS-driven visibility changes.\n useLayoutEffect(() => {\n if (!shouldWatch) return;\n\n let raf = 0;\n\n const loop = () => {\n if (isInvalidTriggerElement(store.state.activeTriggerElement ?? null)) {\n destroy();\n return;\n }\n raf = window.requestAnimationFrame(loop);\n };\n\n loop();\n return () => window.cancelAnimationFrame(raf);\n }, [destroy, shouldWatch, store]);\n};\n\n/**\n * UI-only fallback: If the positioner ends up at viewport (0,0), hide it to avoid a visible flash\n * in the corner. This doesn't replace \"destroy on invalid trigger\"; it's purely a visual guard.\n */\nexport const useHidePopupWhenPositionerAtOrigin = (\n store: PopupStoreLike,\n options?: {\n /**\n * @default true\n */\n enabled?: boolean;\n /**\n * Pixel threshold to consider the element \"at origin\".\n * @default 0.5\n */\n threshold?: number;\n },\n) => {\n const enabled = options?.enabled ?? true;\n const threshold = options?.threshold ?? 0.5;\n\n const openReactive =\n (store.useState?.('open') as boolean | undefined) ?? Boolean(store.state.open);\n const positionerElementReactive =\n (store.useState?.('positionerElement') as HTMLElement | null | undefined) ??\n store.state.positionerElement ??\n null;\n\n useLayoutEffect(() => {\n const positionerEl = store.state.positionerElement ?? positionerElementReactive;\n\n if (!enabled || !openReactive || !positionerEl) {\n if (positionerEl) delete positionerEl.dataset.zeroOrigin;\n return;\n }\n\n let raf = 0;\n const loop = () => {\n const current = store.state.positionerElement ?? positionerEl;\n if (!current) return;\n\n const rect = current.getBoundingClientRect();\n const atOrigin = Math.abs(rect.left) <= threshold && Math.abs(rect.top) <= threshold;\n if (atOrigin) current.dataset.zeroOrigin = 'true';\n else delete current.dataset.zeroOrigin;\n\n raf = window.requestAnimationFrame(loop);\n };\n\n loop();\n return () => {\n window.cancelAnimationFrame(raf);\n const current = store.state.positionerElement ?? positionerEl;\n if (current) delete current.dataset.zeroOrigin;\n };\n }, [enabled, openReactive, positionerElementReactive, store, threshold]);\n};\n"],"mappings":";;;AAYA,MAAM,2BAA2B,OAAgC;AAC/D,KAAI,CAAC,GAAI,QAAO;AAEhB,KAAI,CAAC,GAAG,YAAa,QAAO;AAK5B,KAAI;EAEF,IAAIA,UAA0B;AAC9B,SAAO,SAAS;AACd,OAAI,iBAAiB,QAAQ,CAAC,YAAY,OACxC,QAAO;AAET,aAAU,QAAQ;;AAEpB,SAAO;SACD;AACN,SAAO;;;;;;;;;;AAWX,MAAa,2CACX,OACA,SACA,YAMG;CACH,MAAM,UAAU,SAAS,WAAW;CAIpC,MAAM,eACH,MAAM,WAAW,OAAO,IAA4B,QAAQ,MAAM,MAAM,KAAK;CAChF,MAAM,cAAc,WAAW;AAI/B,uBAAsB;AACpB,MAAI,CAAC,YAAa;EAElB,IAAI,MAAM;EAEV,MAAM,aAAa;AACjB,OAAI,wBAAwB,MAAM,MAAM,wBAAwB,KAAK,EAAE;AACrE,aAAS;AACT;;AAEF,SAAM,OAAO,sBAAsB,KAAK;;AAG1C,QAAM;AACN,eAAa,OAAO,qBAAqB,IAAI;IAC5C;EAAC;EAAS;EAAa;EAAM,CAAC;;;;;;AAOnC,MAAa,sCACX,OACA,YAWG;CACH,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,YAAY,SAAS,aAAa;CAExC,MAAM,eACH,MAAM,WAAW,OAAO,IAA4B,QAAQ,MAAM,MAAM,KAAK;CAChF,MAAM,4BACH,MAAM,WAAW,oBAAoB,IACtC,MAAM,MAAM,qBACZ;AAEF,uBAAsB;EACpB,MAAM,eAAe,MAAM,MAAM,qBAAqB;AAEtD,MAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,cAAc;AAC9C,OAAI,aAAc,QAAO,aAAa,QAAQ;AAC9C;;EAGF,IAAI,MAAM;EACV,MAAM,aAAa;GACjB,MAAM,UAAU,MAAM,MAAM,qBAAqB;AACjD,OAAI,CAAC,QAAS;GAEd,MAAM,OAAO,QAAQ,uBAAuB;AAE5C,OADiB,KAAK,IAAI,KAAK,KAAK,IAAI,aAAa,KAAK,IAAI,KAAK,IAAI,IAAI,UAC7D,SAAQ,QAAQ,aAAa;OACtC,QAAO,QAAQ,QAAQ;AAE5B,SAAM,OAAO,sBAAsB,KAAK;;AAG1C,QAAM;AACN,eAAa;AACX,UAAO,qBAAqB,IAAI;GAChC,MAAM,UAAU,MAAM,MAAM,qBAAqB;AACjD,OAAI,QAAS,QAAO,QAAQ,QAAQ;;IAErC;EAAC;EAAS;EAAc;EAA2B;EAAO;EAAU,CAAC"}
|