@lobehub/ui 5.40.1 → 5.40.3

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.
Files changed (72) hide show
  1. package/es/CodeEditor/style.mjs +22 -0
  2. package/es/CodeEditor/style.mjs.map +1 -1
  3. package/es/base-ui/AutoComplete/AutoComplete.mjs +2 -0
  4. package/es/base-ui/AutoComplete/AutoComplete.mjs.map +1 -1
  5. package/es/base-ui/ContextMenu/ContextMenuHost.mjs +2 -0
  6. package/es/base-ui/ContextMenu/ContextMenuHost.mjs.map +1 -1
  7. package/es/base-ui/ContextMenu/renderItems.mjs +3 -1
  8. package/es/base-ui/ContextMenu/renderItems.mjs.map +1 -1
  9. package/es/base-ui/DropdownMenu/atoms.d.mts +1 -1
  10. package/es/base-ui/DropdownMenu/atoms.mjs +3 -1
  11. package/es/base-ui/DropdownMenu/atoms.mjs.map +1 -1
  12. package/es/base-ui/Popover/PopoverGroup.mjs +4 -3
  13. package/es/base-ui/Popover/PopoverGroup.mjs.map +1 -1
  14. package/es/base-ui/Popover/atoms.d.mts +1 -1
  15. package/es/base-ui/Popover/atoms.mjs +3 -1
  16. package/es/base-ui/Popover/atoms.mjs.map +1 -1
  17. package/es/base-ui/Select/Select.mjs +0 -1
  18. package/es/base-ui/Select/Select.mjs.map +1 -1
  19. package/es/base-ui/Select/atoms.d.mts +2 -2
  20. package/es/base-ui/Select/atoms.mjs +3 -1
  21. package/es/base-ui/Select/atoms.mjs.map +1 -1
  22. package/es/base-ui/Select/style.mjs +2 -1
  23. package/es/base-ui/Select/style.mjs.map +1 -1
  24. package/es/base-ui/Tooltip/TooltipGroup.mjs +6 -3
  25. package/es/base-ui/Tooltip/TooltipGroup.mjs.map +1 -1
  26. package/es/base-ui/Tooltip/TooltipStandalone.mjs +2 -0
  27. package/es/base-ui/Tooltip/TooltipStandalone.mjs.map +1 -1
  28. package/es/base-ui/floating/collisionPadding.d.mts +7 -0
  29. package/es/base-ui/floating/collisionPadding.mjs +17 -0
  30. package/es/base-ui/floating/collisionPadding.mjs.map +1 -0
  31. package/es/base-ui/index.d.mts +2 -1
  32. package/es/base-ui/index.mjs +2 -1
  33. package/es/icons/lucideExtra/AndroidIcon.d.mts +1 -1
  34. package/es/icons/lucideExtra/AppleIcon.d.mts +1 -1
  35. package/es/icons/lucideExtra/AppstoreIcon.d.mts +1 -1
  36. package/es/icons/lucideExtra/BotPromptIcon.d.mts +1 -1
  37. package/es/icons/lucideExtra/BrainOffIcon.d.mts +1 -1
  38. package/es/icons/lucideExtra/ChromeIcon.d.mts +1 -1
  39. package/es/icons/lucideExtra/CodepenIcon.d.mts +1 -1
  40. package/es/icons/lucideExtra/CodesandboxIcon.d.mts +1 -1
  41. package/es/icons/lucideExtra/CreateBotIcon.d.mts +1 -1
  42. package/es/icons/lucideExtra/DiscordIcon.d.mts +1 -1
  43. package/es/icons/lucideExtra/FacebookIcon.d.mts +1 -1
  44. package/es/icons/lucideExtra/FigmaIcon.d.mts +1 -1
  45. package/es/icons/lucideExtra/FramerIcon.d.mts +1 -1
  46. package/es/icons/lucideExtra/GithubIcon.d.mts +1 -1
  47. package/es/icons/lucideExtra/GitlabIcon.d.mts +1 -1
  48. package/es/icons/lucideExtra/GlobeOffIcon.d.mts +1 -1
  49. package/es/icons/lucideExtra/GooglePlayIcon.d.mts +1 -1
  50. package/es/icons/lucideExtra/GroupBotIcon.d.mts +1 -1
  51. package/es/icons/lucideExtra/GroupBotSquareIcon.d.mts +1 -1
  52. package/es/icons/lucideExtra/InstagramIcon.d.mts +1 -1
  53. package/es/icons/lucideExtra/LeftClickIcon.d.mts +1 -1
  54. package/es/icons/lucideExtra/LeftDoubleClickIcon.d.mts +1 -1
  55. package/es/icons/lucideExtra/LinkedinIcon.d.mts +1 -1
  56. package/es/icons/lucideExtra/McpIcon.d.mts +1 -1
  57. package/es/icons/lucideExtra/NotionIcon.d.mts +1 -1
  58. package/es/icons/lucideExtra/PocketIcon.d.mts +1 -1
  59. package/es/icons/lucideExtra/ProviderIcon.d.mts +1 -1
  60. package/es/icons/lucideExtra/RailSymbolIcon.d.mts +1 -1
  61. package/es/icons/lucideExtra/RedditIcon.d.mts +1 -1
  62. package/es/icons/lucideExtra/RightClickIcon.d.mts +1 -1
  63. package/es/icons/lucideExtra/RightDoubleClickIcon.d.mts +1 -1
  64. package/es/icons/lucideExtra/ShapesUploadIcon.d.mts +1 -1
  65. package/es/icons/lucideExtra/SkillsIcon.d.mts +1 -1
  66. package/es/icons/lucideExtra/SlackIcon.d.mts +1 -1
  67. package/es/icons/lucideExtra/ThinkIcon.d.mts +1 -1
  68. package/es/icons/lucideExtra/TreeDownRightIcon.d.mts +1 -1
  69. package/es/icons/lucideExtra/TreeUpDownRightIcon.d.mts +1 -1
  70. package/es/utils/destroyOnInvalidActiveTriggerElement.mjs +8 -2
  71. package/es/utils/destroyOnInvalidActiveTriggerElement.mjs.map +1 -1
  72. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/CreateBotIcon.d.ts
2
- declare const CreateBotIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const CreateBotIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { CreateBotIcon as default };
5
5
  //# sourceMappingURL=CreateBotIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/DiscordIcon.d.ts
2
- declare const DiscordIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const DiscordIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { DiscordIcon as default };
5
5
  //# sourceMappingURL=DiscordIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/FacebookIcon.d.ts
2
- declare const FacebookIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const FacebookIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { FacebookIcon as default };
5
5
  //# sourceMappingURL=FacebookIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/FigmaIcon.d.ts
2
- declare const FigmaIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const FigmaIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { FigmaIcon as default };
5
5
  //# sourceMappingURL=FigmaIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/FramerIcon.d.ts
2
- declare const FramerIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const FramerIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { FramerIcon as default };
5
5
  //# sourceMappingURL=FramerIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/GithubIcon.d.ts
2
- declare const GithubIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const GithubIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { GithubIcon as default };
5
5
  //# sourceMappingURL=GithubIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/GitlabIcon.d.ts
2
- declare const GitlabIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const GitlabIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { GitlabIcon as default };
5
5
  //# sourceMappingURL=GitlabIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/GlobeOffIcon.d.ts
2
- declare const GlobeOffIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const GlobeOffIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { GlobeOffIcon as default };
5
5
  //# sourceMappingURL=GlobeOffIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/GooglePlayIcon.d.ts
2
- declare const GooglePlayIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const GooglePlayIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { GooglePlayIcon as default };
5
5
  //# sourceMappingURL=GooglePlayIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/GroupBotIcon.d.ts
2
- declare const GroupBotIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const GroupBotIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { GroupBotIcon as default };
5
5
  //# sourceMappingURL=GroupBotIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/GroupBotSquareIcon.d.ts
2
- declare const GroupBotSquareIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const GroupBotSquareIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { GroupBotSquareIcon as default };
5
5
  //# sourceMappingURL=GroupBotSquareIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/InstagramIcon.d.ts
2
- declare const InstagramIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const InstagramIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { InstagramIcon as default };
5
5
  //# sourceMappingURL=InstagramIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/LeftClickIcon.d.ts
2
- declare const LeftClickIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const LeftClickIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { LeftClickIcon as default };
5
5
  //# sourceMappingURL=LeftClickIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/LeftDoubleClickIcon.d.ts
2
- declare const LeftDoubleClickIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const LeftDoubleClickIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { LeftDoubleClickIcon as default };
5
5
  //# sourceMappingURL=LeftDoubleClickIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/LinkedinIcon.d.ts
2
- declare const LinkedinIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const LinkedinIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { LinkedinIcon as default };
5
5
  //# sourceMappingURL=LinkedinIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/McpIcon.d.ts
2
- declare const McpIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const McpIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { McpIcon as default };
5
5
  //# sourceMappingURL=McpIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/NotionIcon.d.ts
2
- declare const NotionIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const NotionIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { NotionIcon as default };
5
5
  //# sourceMappingURL=NotionIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/PocketIcon.d.ts
2
- declare const PocketIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const PocketIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { PocketIcon as default };
5
5
  //# sourceMappingURL=PocketIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/ProviderIcon.d.ts
2
- declare const ProviderIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const ProviderIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { ProviderIcon as default };
5
5
  //# sourceMappingURL=ProviderIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/RailSymbolIcon.d.ts
2
- declare const RailSymbolIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const RailSymbolIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { RailSymbolIcon as default };
5
5
  //# sourceMappingURL=RailSymbolIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/RedditIcon.d.ts
2
- declare const RedditIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const RedditIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { RedditIcon as default };
5
5
  //# sourceMappingURL=RedditIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/RightClickIcon.d.ts
2
- declare const RightClickIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const RightClickIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { RightClickIcon as default };
5
5
  //# sourceMappingURL=RightClickIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/RightDoubleClickIcon.d.ts
2
- declare const RightDoubleClickIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const RightDoubleClickIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { RightDoubleClickIcon as default };
5
5
  //# sourceMappingURL=RightDoubleClickIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/ShapesUploadIcon.d.ts
2
- declare const ShapesUploadIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const ShapesUploadIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { ShapesUploadIcon as default };
5
5
  //# sourceMappingURL=ShapesUploadIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/SkillsIcon.d.ts
2
- declare const SkillsIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const SkillsIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { SkillsIcon as default };
5
5
  //# sourceMappingURL=SkillsIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/SlackIcon.d.ts
2
- declare const SlackIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const SlackIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { SlackIcon as default };
5
5
  //# sourceMappingURL=SlackIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/ThinkIcon.d.ts
2
- declare const ThinkIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const ThinkIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { ThinkIcon as default };
5
5
  //# sourceMappingURL=ThinkIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/TreeDownRightIcon.d.ts
2
- declare const TreeDownRightIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const TreeDownRightIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { TreeDownRightIcon as default };
5
5
  //# sourceMappingURL=TreeDownRightIcon.d.mts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/icons/lucideExtra/TreeUpDownRightIcon.d.ts
2
- declare const TreeUpDownRightIcon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
2
+ declare const TreeUpDownRightIcon: import("lucide-react").LucideIcon;
3
3
  //#endregion
4
4
  export { TreeUpDownRightIcon as default };
5
5
  //# sourceMappingURL=TreeUpDownRightIcon.d.mts.map
@@ -1,5 +1,11 @@
1
- import { useLayoutEffect } from "react";
1
+ import { useCallback, useLayoutEffect, useSyncExternalStore } from "react";
2
2
  //#region src/utils/destroyOnInvalidActiveTriggerElement.ts
3
+ const usePopupHandleStore = (handle) => {
4
+ const typedHandle = handle;
5
+ const subscribe = useCallback((listener) => typedHandle.subscribeStore(listener), [typedHandle]);
6
+ const getSnapshot = useCallback(() => typedHandle.store, [typedHandle]);
7
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
8
+ };
3
9
  const isInvalidTriggerElement = (el) => {
4
10
  if (!el) return true;
5
11
  if (!el.isConnected) return true;
@@ -82,6 +88,6 @@ const useHidePopupWhenPositionerAtOrigin = (store, options) => {
82
88
  ]);
83
89
  };
84
90
  //#endregion
85
- export { useDestroyOnInvalidActiveTriggerElement, useHidePopupWhenPositionerAtOrigin };
91
+ export { useDestroyOnInvalidActiveTriggerElement, useHidePopupWhenPositionerAtOrigin, usePopupHandleStore };
86
92
 
87
93
  //# sourceMappingURL=destroyOnInvalidActiveTriggerElement.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"destroyOnInvalidActiveTriggerElement.mjs","names":[],"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;CAC/D,IAAI,CAAC,IAAI,OAAO;CAEhB,IAAI,CAAC,GAAG,aAAa,OAAO;CAK5B,IAAI;EAEF,IAAI,UAA0B;EAC9B,OAAO,SAAS;GACd,IAAI,iBAAiB,OAAO,CAAC,CAAC,YAAY,QACxC,OAAO;GAET,UAAU,QAAQ;EACpB;EACA,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;AASA,MAAa,2CACX,OACA,SACA,YAMG;CACH,MAAM,UAAU,SAAS,WAAW;CAIpC,MAAM,eACH,MAAM,WAAW,MAAM,KAA6B,QAAQ,MAAM,MAAM,IAAI;CAC/E,MAAM,cAAc,WAAW;CAI/B,sBAAsB;EACpB,IAAI,CAAC,aAAa;EAElB,IAAI,MAAM;EAEV,MAAM,aAAa;GACjB,IAAI,wBAAwB,MAAM,MAAM,wBAAwB,IAAI,GAAG;IACrE,QAAQ;IACR;GACF;GACA,MAAM,OAAO,sBAAsB,IAAI;EACzC;EAEA,KAAK;EACL,aAAa,OAAO,qBAAqB,GAAG;CAC9C,GAAG;EAAC;EAAS;EAAa;CAAK,CAAC;AAClC;;;;;AAMA,MAAa,sCACX,OACA,YAWG;CACH,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,YAAY,SAAS,aAAa;CAExC,MAAM,eACH,MAAM,WAAW,MAAM,KAA6B,QAAQ,MAAM,MAAM,IAAI;CAC/E,MAAM,4BACH,MAAM,WAAW,mBAAmB,KACrC,MAAM,MAAM,qBACZ;CAEF,sBAAsB;EACpB,MAAM,eAAe,MAAM,MAAM,qBAAqB;EAEtD,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,cAAc;GAC9C,IAAI,cAAc,OAAO,aAAa,QAAQ;GAC9C;EACF;EAEA,IAAI,MAAM;EACV,MAAM,aAAa;GACjB,MAAM,UAAU,MAAM,MAAM,qBAAqB;GACjD,IAAI,CAAC,SAAS;GAEd,MAAM,OAAO,QAAQ,sBAAsB;GAE3C,IADiB,KAAK,IAAI,KAAK,IAAI,KAAK,aAAa,KAAK,IAAI,KAAK,GAAG,KAAK,WAC7D,QAAQ,QAAQ,aAAa;QACtC,OAAO,QAAQ,QAAQ;GAE5B,MAAM,OAAO,sBAAsB,IAAI;EACzC;EAEA,KAAK;EACL,aAAa;GACX,OAAO,qBAAqB,GAAG;GAC/B,MAAM,UAAU,MAAM,MAAM,qBAAqB;GACjD,IAAI,SAAS,OAAO,QAAQ,QAAQ;EACtC;CACF,GAAG;EAAC;EAAS;EAAc;EAA2B;EAAO;CAAS,CAAC;AACzE"}
1
+ {"version":3,"file":"destroyOnInvalidActiveTriggerElement.mjs","names":[],"sources":["../../src/utils/destroyOnInvalidActiveTriggerElement.ts"],"sourcesContent":["import { useCallback, useLayoutEffect, useSyncExternalStore } 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\n// Base UI 1.7+ strips `store`/`subscribeStore` from the handle's public typings, but detached\n// triggers still rely on them at runtime: the handle points at an inert fallback store until a\n// Root attaches in an effect, so the store must be read through a subscription, not captured once.\ntype PopupHandleLike = {\n store: PopupStoreLike;\n subscribeStore: (listener: () => void) => () => void;\n};\n\nexport const usePopupHandleStore = (handle: object): PopupStoreLike => {\n const typedHandle = handle as PopupHandleLike;\n const subscribe = useCallback(\n (listener: () => void) => typedHandle.subscribeStore(listener),\n [typedHandle],\n );\n const getSnapshot = useCallback(() => typedHandle.store, [typedHandle]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\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":";;AAoBA,MAAa,uBAAuB,WAAmC;CACrE,MAAM,cAAc;CACpB,MAAM,YAAY,aACf,aAAyB,YAAY,eAAe,QAAQ,GAC7D,CAAC,WAAW,CACd;CACA,MAAM,cAAc,kBAAkB,YAAY,OAAO,CAAC,WAAW,CAAC;CACtE,OAAO,qBAAqB,WAAW,aAAa,WAAW;AACjE;AAEA,MAAM,2BAA2B,OAAgC;CAC/D,IAAI,CAAC,IAAI,OAAO;CAEhB,IAAI,CAAC,GAAG,aAAa,OAAO;CAK5B,IAAI;EAEF,IAAI,UAA0B;EAC9B,OAAO,SAAS;GACd,IAAI,iBAAiB,OAAO,CAAC,CAAC,YAAY,QACxC,OAAO;GAET,UAAU,QAAQ;EACpB;EACA,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;AASA,MAAa,2CACX,OACA,SACA,YAMG;CACH,MAAM,UAAU,SAAS,WAAW;CAIpC,MAAM,eACH,MAAM,WAAW,MAAM,KAA6B,QAAQ,MAAM,MAAM,IAAI;CAC/E,MAAM,cAAc,WAAW;CAI/B,sBAAsB;EACpB,IAAI,CAAC,aAAa;EAElB,IAAI,MAAM;EAEV,MAAM,aAAa;GACjB,IAAI,wBAAwB,MAAM,MAAM,wBAAwB,IAAI,GAAG;IACrE,QAAQ;IACR;GACF;GACA,MAAM,OAAO,sBAAsB,IAAI;EACzC;EAEA,KAAK;EACL,aAAa,OAAO,qBAAqB,GAAG;CAC9C,GAAG;EAAC;EAAS;EAAa;CAAK,CAAC;AAClC;;;;;AAMA,MAAa,sCACX,OACA,YAWG;CACH,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,YAAY,SAAS,aAAa;CAExC,MAAM,eACH,MAAM,WAAW,MAAM,KAA6B,QAAQ,MAAM,MAAM,IAAI;CAC/E,MAAM,4BACH,MAAM,WAAW,mBAAmB,KACrC,MAAM,MAAM,qBACZ;CAEF,sBAAsB;EACpB,MAAM,eAAe,MAAM,MAAM,qBAAqB;EAEtD,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,cAAc;GAC9C,IAAI,cAAc,OAAO,aAAa,QAAQ;GAC9C;EACF;EAEA,IAAI,MAAM;EACV,MAAM,aAAa;GACjB,MAAM,UAAU,MAAM,MAAM,qBAAqB;GACjD,IAAI,CAAC,SAAS;GAEd,MAAM,OAAO,QAAQ,sBAAsB;GAE3C,IADiB,KAAK,IAAI,KAAK,IAAI,KAAK,aAAa,KAAK,IAAI,KAAK,GAAG,KAAK,WAC7D,QAAQ,QAAQ,aAAa;QACtC,OAAO,QAAQ,QAAQ;GAE5B,MAAM,OAAO,sBAAsB,IAAI;EACzC;EAEA,KAAK;EACL,aAAa;GACX,OAAO,qBAAqB,GAAG;GAC/B,MAAM,UAAU,MAAM,MAAM,qBAAqB;GACjD,IAAI,SAAS,OAAO,QAAQ,QAAQ;EACtC;CACF,GAAG;EAAC;EAAS;EAAc;EAA2B;EAAO;CAAS,CAAC;AACzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "5.40.1",
3
+ "version": "5.40.3",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -138,7 +138,7 @@
138
138
  },
139
139
  "dependencies": {
140
140
  "@ant-design/cssinjs": "^2.1.2",
141
- "@base-ui/react": "1.6.0",
141
+ "@base-ui/react": "1.8.0",
142
142
  "@dnd-kit/core": "^6.3.1",
143
143
  "@dnd-kit/modifiers": "^9.0.0",
144
144
  "@dnd-kit/sortable": "^10.0.0",