@lobehub/ui 4.4.5 → 4.5.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.
Files changed (162) hide show
  1. package/es/Accordion/Accordion.d.mts +2 -2
  2. package/es/Accordion/AccordionItem.d.mts +2 -2
  3. package/es/Accordion/AccordionItem.mjs +2 -1
  4. package/es/Accordion/AccordionItem.mjs.map +1 -1
  5. package/es/ActionIcon/ActionIcon.d.mts +2 -2
  6. package/es/Alert/Alert.d.mts +2 -2
  7. package/es/AutoComplete/Select.d.mts +2 -2
  8. package/es/Avatar/AvatarGroup/index.d.mts +2 -2
  9. package/es/Burger/Burger.d.mts +2 -2
  10. package/es/CodeEditor/CodeEditor.d.mts +2 -2
  11. package/es/Collapse/Collapse.d.mts +2 -2
  12. package/es/ConfigProvider/index.d.mts +2 -2
  13. package/es/ContextMenu/ContextMenuHost.d.mts +8 -0
  14. package/es/ContextMenu/ContextMenuHost.mjs +66 -0
  15. package/es/ContextMenu/ContextMenuHost.mjs.map +1 -0
  16. package/es/ContextMenu/imperative.d.mts +2 -0
  17. package/es/ContextMenu/index.d.mts +4 -0
  18. package/es/ContextMenu/index.d.ts +1 -0
  19. package/es/ContextMenu/index.js +1 -0
  20. package/es/ContextMenu/index.mjs +4 -0
  21. package/es/ContextMenu/renderItems.mjs +141 -0
  22. package/es/ContextMenu/renderItems.mjs.map +1 -0
  23. package/es/ContextMenu/store.d.mts +10 -0
  24. package/es/ContextMenu/store.mjs +74 -0
  25. package/es/ContextMenu/store.mjs.map +1 -0
  26. package/es/ContextMenu/style.mjs +151 -0
  27. package/es/ContextMenu/style.mjs.map +1 -0
  28. package/es/CopyButton/CopyButton.d.mts +2 -2
  29. package/es/DatePicker/DatePicker.d.mts +2 -2
  30. package/es/DraggablePanel/components/DraggablePanelBody.d.mts +2 -2
  31. package/es/DraggablePanel/components/DraggablePanelContainer.d.mts +2 -2
  32. package/es/DraggablePanel/components/DraggablePanelFooter.d.mts +2 -2
  33. package/es/DraggablePanel/components/DraggablePanelHeader.d.mts +2 -2
  34. package/es/DraggableSideNav/DraggableSideNav.d.mts +2 -2
  35. package/es/Drawer/Drawer.d.mts +2 -2
  36. package/es/Dropdown/Dropdown.d.mts +2 -2
  37. package/es/EditableText/EditableText.d.mts +2 -2
  38. package/es/EmojiPicker/EmojiPicker.d.mts +2 -2
  39. package/es/Flex/FlexBasic.d.mts +2 -2
  40. package/es/FontLoader/index.d.mts +2 -2
  41. package/es/Footer/Footer.d.mts +2 -2
  42. package/es/Form/components/FormGroup.d.mts +2 -2
  43. package/es/Form/components/FormItem.d.mts +2 -2
  44. package/es/Form/components/FormSubmitFooter.d.mts +2 -2
  45. package/es/FormModal/FormModal.d.mts +2 -2
  46. package/es/GuideCard/GuideCard.d.mts +2 -2
  47. package/es/Header/Header.d.mts +2 -2
  48. package/es/Highlighter/FullFeatured.mjs +2 -1
  49. package/es/Highlighter/FullFeatured.mjs.map +1 -1
  50. package/es/Highlighter/Highlighter.d.mts +2 -2
  51. package/es/Highlighter/LangSelect.mjs +2 -1
  52. package/es/Highlighter/LangSelect.mjs.map +1 -1
  53. package/es/Highlighter/SyntaxHighlighter/index.d.mts +2 -2
  54. package/es/Hotkey/Hotkey.d.mts +2 -2
  55. package/es/HotkeyInput/HotkeyInput.d.mts +2 -2
  56. package/es/Icon/Icon.d.mts +2 -2
  57. package/es/Icon/components/IconProvider.d.mts +3 -3
  58. package/es/Image/PreviewGroup.d.mts +2 -2
  59. package/es/ImageSelect/ImageSelect.d.mts +2 -2
  60. package/es/Input/Input.d.mts +2 -2
  61. package/es/Input/InputNumber.d.mts +2 -2
  62. package/es/Input/InputOPT.d.mts +2 -2
  63. package/es/Input/InputPassword.d.mts +2 -2
  64. package/es/Input/TextArea.d.mts +2 -2
  65. package/es/Layout/components/LayoutFooter.d.mts +2 -2
  66. package/es/Layout/components/LayoutHeader.d.mts +2 -2
  67. package/es/Layout/components/LayoutMain.d.mts +2 -2
  68. package/es/Layout/components/LayoutSidebarInner.d.mts +2 -2
  69. package/es/Layout/components/LayoutToc.d.mts +2 -2
  70. package/es/List/ListItem/index.d.mts +2 -2
  71. package/es/List/ListItem/index.mjs +2 -4
  72. package/es/List/ListItem/index.mjs.map +1 -1
  73. package/es/Markdown/Markdown.d.mts +2 -2
  74. package/es/Markdown/Typography.d.mts +2 -2
  75. package/es/Markdown/components/SearchResultCards/index.d.mts +2 -2
  76. package/es/MaskShadow/MaskShadow.d.mts +2 -2
  77. package/es/Menu/Menu.d.mts +2 -2
  78. package/es/Mermaid/FullFeatured.mjs +2 -1
  79. package/es/Mermaid/FullFeatured.mjs.map +1 -1
  80. package/es/Mermaid/Mermaid.d.mts +2 -2
  81. package/es/Mermaid/SyntaxMermaid/index.d.mts +2 -2
  82. package/es/Modal/Modal.d.mts +2 -2
  83. package/es/Modal/ModalProvider.d.mts +13 -0
  84. package/es/Modal/ModalProvider.mjs +23 -0
  85. package/es/Modal/ModalProvider.mjs.map +1 -0
  86. package/es/Modal/ModalStackItem.mjs +44 -0
  87. package/es/Modal/ModalStackItem.mjs.map +1 -0
  88. package/es/Modal/RawModalStackItem.mjs +32 -0
  89. package/es/Modal/RawModalStackItem.mjs.map +1 -0
  90. package/es/Modal/imperative.d.mts +16 -0
  91. package/es/Modal/imperative.mjs +201 -0
  92. package/es/Modal/imperative.mjs.map +1 -0
  93. package/es/Modal/index.d.mts +4 -2
  94. package/es/Modal/index.mjs +3 -1
  95. package/es/Modal/type.d.mts +30 -1
  96. package/es/MotionProvider/index.d.mts +2 -2
  97. package/es/SearchBar/SearchBar.d.mts +2 -2
  98. package/es/Segmented/Segmented.d.mts +2 -2
  99. package/es/Select/Select.d.mts +2 -2
  100. package/es/SideNav/SideNav.d.mts +2 -2
  101. package/es/SliderWithInput/SliderWithInput.d.mts +2 -2
  102. package/es/SortableList/components/DragHandle.d.mts +2 -2
  103. package/es/SortableList/components/SortableItem.d.mts +2 -2
  104. package/es/ThemeProvider/ThemeProvider.d.mts +2 -2
  105. package/es/Toc/Toc.d.mts +2 -2
  106. package/es/Tooltip/TooltipPortal.mjs +1 -2
  107. package/es/Tooltip/TooltipPortal.mjs.map +1 -1
  108. package/es/Video/index.d.mts +2 -2
  109. package/es/awesome/AuroraBackground/AuroraBackground.d.mts +2 -2
  110. package/es/awesome/BottomGradientButton/BottomGradientButton.d.mts +2 -2
  111. package/es/awesome/Features/Features.d.mts +2 -2
  112. package/es/awesome/Giscus/Giscus.d.mts +2 -2
  113. package/es/awesome/GradientButton/GradientButton.d.mts +2 -2
  114. package/es/awesome/GridBackground/GridBackground.d.mts +2 -2
  115. package/es/awesome/GridBackground/GridShowcase.d.mts +2 -2
  116. package/es/awesome/Hero/Hero.d.mts +2 -2
  117. package/es/awesome/Spline/Spine.d.mts +2 -2
  118. package/es/awesome/Spotlight/Spotlight.d.mts +2 -2
  119. package/es/awesome/SpotlightCard/SpotlightCard.d.mts +2 -2
  120. package/es/awesome/TypewriterEffect/TypewriterEffect.d.mts +2 -2
  121. package/es/brand/LobeChat/index.d.mts +2 -2
  122. package/es/brand/LobeHub/index.d.mts +2 -2
  123. package/es/brand/LogoThree/LogoSpline.d.mts +2 -2
  124. package/es/brand/LogoThree/index.d.mts +2 -2
  125. package/es/chat/BackBottom/BackBottom.d.mts +2 -2
  126. package/es/chat/ChatInputArea/components/ChatInputAreaInner.d.mts +2 -2
  127. package/es/chat/ChatItem/ChatItem.d.mts +2 -2
  128. package/es/chat/ChatList/ChatList.d.mts +2 -2
  129. package/es/chat/EditableMessage/EditableMessage.d.mts +2 -2
  130. package/es/chat/EditableMessageList/EditableMessageList.d.mts +2 -2
  131. package/es/chat/MessageInput/MessageInput.d.mts +2 -2
  132. package/es/chat/MessageModal/MessageModal.d.mts +2 -2
  133. package/es/color/ColorScales/index.d.mts +2 -2
  134. package/es/color/CssVar/index.d.mts +2 -2
  135. package/es/hooks/useIsClient.mjs +15 -0
  136. package/es/hooks/useIsClient.mjs.map +1 -0
  137. package/es/i18n/context.d.mts +2 -2
  138. package/es/icons/lucideExtra/BotPromptIcon.d.mts +2 -2
  139. package/es/icons/lucideExtra/CreateBotIcon.d.mts +3 -3
  140. package/es/icons/lucideExtra/DiscordIcon.d.mts +2 -2
  141. package/es/icons/lucideExtra/GlobeOffIcon.d.mts +2 -2
  142. package/es/icons/lucideExtra/GroupBotIcon.d.mts +2 -2
  143. package/es/icons/lucideExtra/GroupBotSquareIcon.d.mts +3 -3
  144. package/es/icons/lucideExtra/LeftClickIcon.d.mts +3 -3
  145. package/es/icons/lucideExtra/LeftDoubleClickIcon.d.mts +3 -3
  146. package/es/icons/lucideExtra/McpIcon.d.mts +3 -3
  147. package/es/icons/lucideExtra/ProviderIcon.d.mts +2 -2
  148. package/es/icons/lucideExtra/RightClickIcon.d.mts +3 -3
  149. package/es/icons/lucideExtra/RightDoubleClickIcon.d.mts +3 -3
  150. package/es/icons/lucideExtra/ShapesUploadIcon.d.mts +3 -3
  151. package/es/icons/lucideExtra/TreeDownRightIcon.d.mts +2 -2
  152. package/es/icons/lucideExtra/TreeUpDownRightIcon.d.mts +3 -3
  153. package/es/index.d.mts +9 -3
  154. package/es/index.mjs +6 -1
  155. package/es/mdx/Mdx/index.d.mts +2 -2
  156. package/es/mobile/ChatHeader/ChatHeaderTitle.d.mts +2 -2
  157. package/es/mobile/ChatInputArea/components/ChatSendButton.d.mts +2 -2
  158. package/es/mobile/TabBar/TabBar.d.mts +2 -2
  159. package/es/storybook/StoryBook/index.d.mts +2 -2
  160. package/es/utils/dom.mjs +12 -0
  161. package/es/utils/dom.mjs.map +1 -0
  162. package/package.json +2 -1
@@ -0,0 +1,201 @@
1
+ 'use client';
2
+
3
+ import { useIsClient } from "../hooks/useIsClient.mjs";
4
+ import { ModalStackItem } from "./ModalStackItem.mjs";
5
+ import { RawModalStackItem } from "./RawModalStackItem.mjs";
6
+ import { memo, useState, useSyncExternalStore } from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ import { createPortal } from "react-dom";
9
+
10
+ //#region src/Modal/imperative.tsx
11
+ const MODAL_PORTAL_ATTR = "data-lobe-ui-modal-portal";
12
+ const containerMap = /* @__PURE__ */ new WeakMap();
13
+ let modalStack = [];
14
+ let modalSeed = 0;
15
+ const listeners = /* @__PURE__ */ new Set();
16
+ const rawDestroyTimers = /* @__PURE__ */ new Map();
17
+ const notify = () => {
18
+ listeners.forEach((listener) => listener());
19
+ };
20
+ const subscribe = (listener) => {
21
+ listeners.add(listener);
22
+ return () => listeners.delete(listener);
23
+ };
24
+ const getSnapshot = () => modalStack;
25
+ const getServerSnapshot = () => [];
26
+ const getOrCreateContainer = (root) => {
27
+ const cached = containerMap.get(root);
28
+ if (cached && cached.isConnected) return cached;
29
+ const el = document.createElement("div");
30
+ el.setAttribute(MODAL_PORTAL_ATTR, "true");
31
+ root.append(el);
32
+ containerMap.set(root, el);
33
+ return el;
34
+ };
35
+ const resolveRoot = (root) => {
36
+ if (root) return root;
37
+ return document.body;
38
+ };
39
+ const ModalPortal = ({ children, root }) => {
40
+ const [container, setContainer] = useState(() => {
41
+ const resolved = resolveRoot(root);
42
+ if (!resolved) return null;
43
+ return getOrCreateContainer(resolved);
44
+ });
45
+ if (!container) setContainer(getOrCreateContainer(document.body));
46
+ if (!container) return null;
47
+ return createPortal(children, container);
48
+ };
49
+ const updateModal = (id, nextProps) => {
50
+ let changed = false;
51
+ modalStack = modalStack.map((item) => {
52
+ if (item.id !== id) return item;
53
+ if (item.kind !== "modal") return item;
54
+ changed = true;
55
+ return {
56
+ ...item,
57
+ props: {
58
+ ...item.props,
59
+ ...nextProps
60
+ }
61
+ };
62
+ });
63
+ if (changed) notify();
64
+ };
65
+ const updateRawProps = (id, nextProps) => {
66
+ let changed = false;
67
+ modalStack = modalStack.map((item) => {
68
+ if (item.id !== id) return item;
69
+ if (item.kind !== "raw") return item;
70
+ changed = true;
71
+ return {
72
+ ...item,
73
+ props: {
74
+ ...item.props,
75
+ ...nextProps
76
+ }
77
+ };
78
+ });
79
+ if (changed) notify();
80
+ };
81
+ const setRawOpen = (id, open) => {
82
+ let changed = false;
83
+ modalStack = modalStack.map((item) => {
84
+ if (item.id !== id) return item;
85
+ if (item.kind !== "raw") return item;
86
+ if (item.open === open) return item;
87
+ changed = true;
88
+ return {
89
+ ...item,
90
+ open
91
+ };
92
+ });
93
+ if (open) {
94
+ const timer = rawDestroyTimers.get(id);
95
+ if (timer) {
96
+ clearTimeout(timer);
97
+ rawDestroyTimers.delete(id);
98
+ }
99
+ }
100
+ if (changed) notify();
101
+ };
102
+ const closeModal = (id) => {
103
+ const target = modalStack.find((item) => item.id === id);
104
+ if (!target) return;
105
+ if (target.kind === "modal") {
106
+ updateModal(id, { open: false });
107
+ return;
108
+ }
109
+ setRawOpen(id, false);
110
+ if (!(target.options?.destroyOnClose ?? true)) return;
111
+ const delay = target.options?.destroyDelay ?? 200;
112
+ const existing = rawDestroyTimers.get(id);
113
+ if (existing) clearTimeout(existing);
114
+ const timer = window.setTimeout(() => {
115
+ rawDestroyTimers.delete(id);
116
+ destroyModal(id);
117
+ }, delay);
118
+ rawDestroyTimers.set(id, timer);
119
+ };
120
+ const destroyModal = (id) => {
121
+ const timer = rawDestroyTimers.get(id);
122
+ if (timer) {
123
+ clearTimeout(timer);
124
+ rawDestroyTimers.delete(id);
125
+ }
126
+ const nextStack = modalStack.filter((item) => item.id !== id);
127
+ if (nextStack.length === modalStack.length) return;
128
+ modalStack = nextStack;
129
+ notify();
130
+ };
131
+ const ModalStack = memo(({ stack }) => {
132
+ if (!useIsClient()) return null;
133
+ return stack.map((item) => {
134
+ if (item.kind === "modal") return /* @__PURE__ */ jsx(ModalStackItem, {
135
+ id: item.id,
136
+ onClose: closeModal,
137
+ onDestroy: destroyModal,
138
+ onUpdate: updateModal,
139
+ props: item.props
140
+ }, item.id);
141
+ return /* @__PURE__ */ jsx(RawModalStackItem, {
142
+ component: item.component,
143
+ id: item.id,
144
+ onClose: closeModal,
145
+ onUpdate: updateRawProps,
146
+ open: item.open,
147
+ options: item.options,
148
+ props: item.props
149
+ }, item.id);
150
+ });
151
+ });
152
+ ModalStack.displayName = "ModalStack";
153
+ const ModalHost = ({ root }) => {
154
+ const stack = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
155
+ if (!useIsClient()) return null;
156
+ if (stack.length === 0) return null;
157
+ return /* @__PURE__ */ jsx(ModalPortal, {
158
+ root,
159
+ children: /* @__PURE__ */ jsx(ModalStack, { stack })
160
+ });
161
+ };
162
+ const createModal = (props) => {
163
+ const id = `modal-${Date.now()}-${modalSeed++}`;
164
+ modalStack = [...modalStack, {
165
+ id,
166
+ kind: "modal",
167
+ props: {
168
+ ...props,
169
+ open: props.open ?? true
170
+ }
171
+ }];
172
+ notify();
173
+ return {
174
+ close: () => closeModal(id),
175
+ destroy: () => destroyModal(id),
176
+ setCanDismissByClickOutside: (value) => updateModal(id, { maskClosable: value }),
177
+ update: (nextProps) => updateModal(id, nextProps)
178
+ };
179
+ };
180
+ function createRawModal(component, props, options) {
181
+ const id = `modal-${Date.now()}-${modalSeed++}`;
182
+ modalStack = [...modalStack, {
183
+ component,
184
+ id,
185
+ kind: "raw",
186
+ open: true,
187
+ options,
188
+ props
189
+ }];
190
+ notify();
191
+ return {
192
+ close: () => closeModal(id),
193
+ destroy: () => destroyModal(id),
194
+ setCanDismissByClickOutside: (value) => updateRawProps(id, { maskClosable: value }),
195
+ update: (nextProps) => updateRawProps(id, nextProps)
196
+ };
197
+ }
198
+
199
+ //#endregion
200
+ export { ModalHost, createModal, createRawModal };
201
+ //# sourceMappingURL=imperative.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imperative.mjs","names":["modalStack: TModalStackItem[]"],"sources":["../../src/Modal/imperative.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable no-redeclare */\n'use client';\n\nimport type { ReactNode } from 'react';\nimport { memo, useState, useSyncExternalStore } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { useIsClient } from '@/hooks/useIsClient';\n\nimport { ModalStackItem } from './ModalStackItem';\nimport { RawModalStackItem } from './RawModalStackItem';\nimport type {\n ImperativeModalProps,\n ModalInstance,\n RawModalComponent,\n RawModalComponentProps,\n RawModalInstance,\n RawModalKeyOptions,\n RawModalOptions,\n} from './type';\n\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable no-redeclare */\n\n/* eslint-disable @typescript-eslint/no-use-before-define */\n/* eslint-disable no-redeclare */\n\ntype ModalStackItemBase = {\n id: string;\n};\n\ntype ModalStackItemModal = ModalStackItemBase & {\n kind: 'modal';\n props: ImperativeModalProps;\n};\n\ntype ModalStackItemRaw = ModalStackItemBase & {\n component: RawModalComponent;\n kind: 'raw';\n open: boolean;\n options?: RawModalOptions<PropertyKey, PropertyKey>;\n props: Record<string, unknown>;\n};\n\ntype TModalStackItem = ModalStackItemModal | ModalStackItemRaw;\n\ntype ModalStackProps = {\n stack: TModalStackItem[];\n};\n\nexport type ModalHostProps = {\n root?: HTMLElement | ShadowRoot | null;\n};\n\nconst MODAL_PORTAL_ATTR = 'data-lobe-ui-modal-portal';\n\n// Reuse one portal container per root (document.body by default).\nconst containerMap = new WeakMap<object, HTMLElement>();\n\nlet modalStack: TModalStackItem[] = [];\nlet modalSeed = 0;\nconst listeners = new Set<() => void>();\nconst rawDestroyTimers = new Map<string, number>();\n\nconst notify = () => {\n listeners.forEach((listener) => listener());\n};\n\nconst subscribe = (listener: () => void) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n};\n\nconst getSnapshot = () => modalStack;\nconst getServerSnapshot = () => [];\n\nconst getOrCreateContainer = (root: HTMLElement | ShadowRoot): HTMLElement => {\n const cached = containerMap.get(root);\n if (cached && cached.isConnected) return cached;\n\n const el = document.createElement('div');\n el.setAttribute(MODAL_PORTAL_ATTR, 'true');\n root.append(el);\n containerMap.set(root, el);\n return el;\n};\n\nconst resolveRoot = (root?: HTMLElement | ShadowRoot | null): HTMLElement | ShadowRoot | null => {\n if (root) return root;\n return document.body;\n};\n\nconst ModalPortal = ({\n children,\n root,\n}: {\n children: ReactNode;\n root?: HTMLElement | ShadowRoot | null;\n}) => {\n const [container, setContainer] = useState<HTMLElement | null>(() => {\n const resolved = resolveRoot(root);\n if (!resolved) return null;\n return getOrCreateContainer(resolved);\n });\n\n if (!container) {\n setContainer(getOrCreateContainer(document.body));\n }\n\n if (!container) return null;\n return createPortal(children, container);\n};\n\nconst updateModal = (id: string, nextProps: Partial<ImperativeModalProps>) => {\n let changed = false;\n modalStack = modalStack.map((item) => {\n if (item.id !== id) return item;\n if (item.kind !== 'modal') return item;\n changed = true;\n return {\n ...item,\n props: { ...item.props, ...nextProps },\n };\n });\n\n if (changed) notify();\n};\n\nconst updateRawProps = (id: string, nextProps: Record<string, unknown>) => {\n let changed = false;\n modalStack = modalStack.map((item) => {\n if (item.id !== id) return item;\n if (item.kind !== 'raw') return item;\n changed = true;\n return {\n ...item,\n props: { ...item.props, ...nextProps },\n };\n });\n\n if (changed) notify();\n};\n\nconst setRawOpen = (id: string, open: boolean) => {\n let changed = false;\n modalStack = modalStack.map((item) => {\n if (item.id !== id) return item;\n if (item.kind !== 'raw') return item;\n if (item.open === open) return item;\n changed = true;\n return { ...item, open };\n });\n\n if (open) {\n const timer = rawDestroyTimers.get(id);\n if (timer) {\n clearTimeout(timer);\n rawDestroyTimers.delete(id);\n }\n }\n\n if (changed) notify();\n};\n\nconst closeModal = (id: string) => {\n const target = modalStack.find((item) => item.id === id);\n if (!target) return;\n\n if (target.kind === 'modal') {\n updateModal(id, { open: false });\n return;\n }\n\n setRawOpen(id, false);\n\n const shouldDestroy = target.options?.destroyOnClose ?? true;\n if (!shouldDestroy) return;\n\n const delay = target.options?.destroyDelay ?? 200;\n const existing = rawDestroyTimers.get(id);\n if (existing) clearTimeout(existing);\n const timer = window.setTimeout(() => {\n rawDestroyTimers.delete(id);\n destroyModal(id);\n }, delay);\n rawDestroyTimers.set(id, timer);\n};\n\nconst destroyModal = (id: string) => {\n const timer = rawDestroyTimers.get(id);\n if (timer) {\n clearTimeout(timer);\n rawDestroyTimers.delete(id);\n }\n const nextStack = modalStack.filter((item) => item.id !== id);\n if (nextStack.length === modalStack.length) return;\n modalStack = nextStack;\n notify();\n};\n\nconst ModalStack = memo(({ stack }: ModalStackProps) => {\n const isClient = useIsClient();\n if (!isClient) return null;\n return stack.map((item) => {\n if (item.kind === 'modal') {\n return (\n <ModalStackItem\n id={item.id}\n key={item.id}\n onClose={closeModal}\n onDestroy={destroyModal}\n onUpdate={updateModal}\n props={item.props}\n />\n );\n }\n\n return (\n <RawModalStackItem\n component={item.component}\n id={item.id}\n key={item.id}\n onClose={closeModal}\n onUpdate={updateRawProps}\n open={item.open}\n options={item.options}\n props={item.props}\n />\n );\n });\n});\n\nModalStack.displayName = 'ModalStack';\n\nexport const ModalHost = ({ root }: ModalHostProps) => {\n const stack = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n const isClient = useIsClient();\n if (!isClient) return null;\n if (stack.length === 0) return null;\n\n return (\n <ModalPortal root={root}>\n <ModalStack stack={stack} />\n </ModalPortal>\n );\n};\n\nexport const createModal = (props: ImperativeModalProps): ModalInstance => {\n const id = `modal-${Date.now()}-${modalSeed++}`;\n modalStack = [\n ...modalStack,\n { id, kind: 'modal', props: { ...props, open: props.open ?? true } },\n ];\n notify();\n\n return {\n close: () => closeModal(id),\n destroy: () => destroyModal(id),\n setCanDismissByClickOutside: (value) => updateModal(id, { maskClosable: value }),\n update: (nextProps) => updateModal(id, nextProps),\n };\n};\n\nexport function createRawModal<P extends RawModalComponentProps>(\n component: RawModalComponent<P>,\n props: Omit<P, 'open' | 'onClose'>,\n options?: RawModalOptions,\n): RawModalInstance<P>;\nexport function createRawModal<\n P extends Record<string, unknown>,\n OpenKey extends keyof P,\n CloseKey extends keyof P,\n>(\n component: RawModalComponent<P>,\n props: Omit<P, OpenKey | CloseKey>,\n options: RawModalKeyOptions<OpenKey, CloseKey>,\n): RawModalInstance<P, OpenKey, CloseKey>;\nexport function createRawModal<\n P extends Record<string, unknown>,\n OpenKey extends keyof P,\n CloseKey extends keyof P,\n>(\n component: RawModalComponent<P>,\n props: Omit<P, OpenKey | CloseKey>,\n options?: RawModalOptions<OpenKey, CloseKey>,\n): RawModalInstance<P, OpenKey, CloseKey> {\n const id = `modal-${Date.now()}-${modalSeed++}`;\n modalStack = [\n ...modalStack,\n {\n component,\n id,\n kind: 'raw',\n open: true,\n options,\n props: props as Record<string, unknown>,\n },\n ];\n notify();\n\n return {\n close: () => closeModal(id),\n destroy: () => destroyModal(id),\n setCanDismissByClickOutside: (value) => updateRawProps(id, { maskClosable: value }),\n update: (nextProps) => updateRawProps(id, nextProps as Record<string, unknown>),\n };\n}\n"],"mappings":"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"}
@@ -1,3 +1,5 @@
1
- import { ModalProps } from "./type.mjs";
1
+ import { ImperativeModalProps, ModalContextValue, ModalInstance, ModalProps, RawModalComponent, RawModalComponentProps, RawModalInstance, RawModalKeyOptions, RawModalOptions } from "./type.mjs";
2
+ import { ModalHost, ModalHostProps, createModal, createRawModal } from "./imperative.mjs";
2
3
  import { Modal } from "./Modal.mjs";
3
- export { ModalProps, Modal as default };
4
+ import { ModalProvider, useModalContext } from "./ModalProvider.mjs";
5
+ export { ImperativeModalProps, ModalContextValue, ModalHost, type ModalHostProps, ModalInstance, ModalProps, ModalProvider, RawModalComponent, RawModalComponentProps, RawModalInstance, RawModalKeyOptions, RawModalOptions, createModal, createRawModal, Modal as default, useModalContext };
@@ -1,3 +1,5 @@
1
1
  import Modal_default from "./Modal.mjs";
2
+ import { ModalProvider, useModalContext } from "./ModalProvider.mjs";
3
+ import { ModalHost, createModal, createRawModal } from "./imperative.mjs";
2
4
 
3
- export { Modal_default as default };
5
+ export { ModalHost, ModalProvider, createModal, createRawModal, Modal_default as default, useModalContext };
@@ -1,3 +1,4 @@
1
+ import { ComponentType } from "react";
1
2
  import { ModalProps } from "antd";
2
3
 
3
4
  //#region src/Modal/type.d.ts
@@ -9,6 +10,34 @@ type ModalProps$1 = Omit<ModalProps, 'okType' | 'wrapClassName'> & {
9
10
  mobile?: number;
10
11
  };
11
12
  };
13
+ type ModalContextValue = {
14
+ close: () => void;
15
+ setCanDismissByClickOutside: (value: boolean) => void;
16
+ };
17
+ type ModalInstance = ModalContextValue & {
18
+ destroy: () => void;
19
+ update: (nextProps: Partial<ImperativeModalProps>) => void;
20
+ };
21
+ type ImperativeModalProps = ModalProps$1;
22
+ type RawModalComponentProps = {
23
+ onClose: () => void;
24
+ open: boolean;
25
+ };
26
+ type RawModalComponent<P = any> = ComponentType<P>;
27
+ type RawModalOptions<OpenKey extends PropertyKey = 'open', CloseKey extends PropertyKey = 'onClose'> = {
28
+ destroyDelay?: number;
29
+ destroyOnClose?: boolean;
30
+ onCloseKey?: CloseKey;
31
+ openKey?: OpenKey;
32
+ };
33
+ type RawModalKeyOptions<OpenKey extends PropertyKey = 'open', CloseKey extends PropertyKey = 'onClose'> = RawModalOptions<OpenKey, CloseKey> & {
34
+ onCloseKey: CloseKey;
35
+ openKey: OpenKey;
36
+ };
37
+ type RawModalInstance<P extends Record<string, unknown> = Record<string, unknown>, OpenKey extends PropertyKey = 'open', CloseKey extends PropertyKey = 'onClose'> = ModalContextValue & {
38
+ destroy: () => void;
39
+ update: (nextProps: Partial<Omit<P, Extract<OpenKey, keyof P> | Extract<CloseKey, keyof P>>>) => void;
40
+ };
12
41
  //#endregion
13
- export { ModalProps$1 as ModalProps };
42
+ export { ImperativeModalProps, ModalContextValue, ModalInstance, ModalProps$1 as ModalProps, RawModalComponent, RawModalComponentProps, RawModalInstance, RawModalKeyOptions, RawModalOptions };
14
43
  //# sourceMappingURL=type.d.mts.map
@@ -1,4 +1,4 @@
1
- import * as react65 from "react";
1
+ import * as react1 from "react";
2
2
  import { Context, ReactNode } from "react";
3
3
  import * as motion_react0 from "motion/react";
4
4
  import * as m from "motion/react-m";
@@ -6,7 +6,7 @@ import * as m from "motion/react-m";
6
6
  //#region src/MotionProvider/index.d.ts
7
7
  type MotionComponentType = typeof motion_react0.motion | typeof m;
8
8
  declare const MotionComponent: Context<MotionComponentType>;
9
- declare const MotionProvider: react65.NamedExoticComponent<{
9
+ declare const MotionProvider: react1.NamedExoticComponent<{
10
10
  children: ReactNode;
11
11
  motion: MotionComponentType;
12
12
  }>;
@@ -1,8 +1,8 @@
1
1
  import { SearchBarProps } from "./type.mjs";
2
- import * as react6 from "react";
2
+ import * as react39 from "react";
3
3
 
4
4
  //#region src/SearchBar/SearchBar.d.ts
5
- declare const SearchBar: react6.NamedExoticComponent<SearchBarProps>;
5
+ declare const SearchBar: react39.NamedExoticComponent<SearchBarProps>;
6
6
  //#endregion
7
7
  export { SearchBar };
8
8
  //# sourceMappingURL=SearchBar.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { SegmentedProps } from "./type.mjs";
2
- import * as react3 from "react";
2
+ import * as react38 from "react";
3
3
 
4
4
  //#region src/Segmented/Segmented.d.ts
5
- declare const Segmented: react3.NamedExoticComponent<SegmentedProps>;
5
+ declare const Segmented: react38.NamedExoticComponent<SegmentedProps>;
6
6
  //#endregion
7
7
  export { Segmented };
8
8
  //# sourceMappingURL=Segmented.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { SelectProps } from "./type.mjs";
2
- import * as react4 from "react";
2
+ import * as react35 from "react";
3
3
 
4
4
  //#region src/Select/Select.d.ts
5
- declare const Input: react4.NamedExoticComponent<SelectProps>;
5
+ declare const Input: react35.NamedExoticComponent<SelectProps>;
6
6
  //#endregion
7
7
  export { Input };
8
8
  //# sourceMappingURL=Select.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { SideNavProps } from "./type.mjs";
2
- import * as react2 from "react";
2
+ import * as react37 from "react";
3
3
 
4
4
  //#region src/SideNav/SideNav.d.ts
5
- declare const SideNav: react2.NamedExoticComponent<SideNavProps>;
5
+ declare const SideNav: react37.NamedExoticComponent<SideNavProps>;
6
6
  //#endregion
7
7
  export { SideNav };
8
8
  //# sourceMappingURL=SideNav.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { SliderWithInputProps } from "./type.mjs";
2
- import * as react1 from "react";
2
+ import * as react34 from "react";
3
3
 
4
4
  //#region src/SliderWithInput/SliderWithInput.d.ts
5
- declare const SliderWithInput: react1.NamedExoticComponent<SliderWithInputProps>;
5
+ declare const SliderWithInput: react34.NamedExoticComponent<SliderWithInputProps>;
6
6
  //#endregion
7
7
  export { SliderWithInput };
8
8
  //# sourceMappingURL=SliderWithInput.d.mts.map
@@ -1,9 +1,9 @@
1
1
  import { ActionIconProps } from "../../ActionIcon/type.mjs";
2
2
  import "../../ActionIcon/index.mjs";
3
- import * as react73 from "react";
3
+ import * as react106 from "react";
4
4
 
5
5
  //#region src/SortableList/components/DragHandle.d.ts
6
- declare const DragHandle: react73.NamedExoticComponent<ActionIconProps>;
6
+ declare const DragHandle: react106.NamedExoticComponent<ActionIconProps>;
7
7
  //#endregion
8
8
  export { DragHandle };
9
9
  //# sourceMappingURL=DragHandle.d.mts.map
@@ -1,6 +1,6 @@
1
1
  import { FlexboxProps } from "../../Flex/type.mjs";
2
2
  import "../../Flex/index.mjs";
3
- import * as react71 from "react";
3
+ import * as react104 from "react";
4
4
  import "@dnd-kit/core";
5
5
 
6
6
  //#region src/SortableList/components/SortableItem.d.ts
@@ -9,7 +9,7 @@ interface SortableItemProps extends Omit<FlexboxProps, 'id'> {
9
9
  id: string | number;
10
10
  variant?: 'borderless' | 'filled' | 'outlined';
11
11
  }
12
- declare const SortableItem: react71.NamedExoticComponent<SortableItemProps>;
12
+ declare const SortableItem: react104.NamedExoticComponent<SortableItemProps>;
13
13
  //#endregion
14
14
  export { SortableItem };
15
15
  //# sourceMappingURL=SortableItem.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { ThemeProviderProps } from "./type.mjs";
2
- import * as react0 from "react";
2
+ import * as react27 from "react";
3
3
 
4
4
  //#region src/ThemeProvider/ThemeProvider.d.ts
5
- declare const ThemeProvider: react0.NamedExoticComponent<ThemeProviderProps>;
5
+ declare const ThemeProvider: react27.NamedExoticComponent<ThemeProviderProps>;
6
6
  //#endregion
7
7
  export { ThemeProvider };
8
8
  //# sourceMappingURL=ThemeProvider.d.mts.map
package/es/Toc/Toc.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { TocProps } from "./type.mjs";
2
- import * as react0 from "react";
2
+ import * as react28 from "react";
3
3
 
4
4
  //#region src/Toc/Toc.d.ts
5
- declare const Toc: react0.NamedExoticComponent<TocProps>;
5
+ declare const Toc: react28.NamedExoticComponent<TocProps>;
6
6
  //#endregion
7
7
  export { Toc };
8
8
  //# sourceMappingURL=Toc.d.mts.map
@@ -29,7 +29,6 @@ const getOrCreateContainer = (root) => {
29
29
  };
30
30
  const resolveRoot = (root) => {
31
31
  if (root) return root;
32
- if (typeof document === "undefined") return null;
33
32
  return document.body;
34
33
  };
35
34
  const TooltipPortal = ({ children, root }) => {
@@ -45,5 +44,5 @@ const TooltipPortal = ({ children, root }) => {
45
44
  var TooltipPortal_default = TooltipPortal;
46
45
 
47
46
  //#endregion
48
- export { TooltipPortal_default as default };
47
+ export { TOOLTIP_CONTAINER_ATTR, TooltipPortal_default as default };
49
48
  //# sourceMappingURL=TooltipPortal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"TooltipPortal.mjs","names":[],"sources":["../../src/Tooltip/TooltipPortal.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { useEffect, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { LOBE_THEME_APP_ID } from '@/ThemeProvider';\n\ntype TooltipPortalProps = {\n children: ReactNode;\n root?: HTMLElement | ShadowRoot | null;\n};\n\nconst PORTAL_ATTR = 'data-lobe-ui-tooltip-portal';\nexport const TOOLTIP_CONTAINER_ATTR = 'data-lobe-ui-tooltip-container';\n\n// Reuse one portal container per root (document.body by default).\nconst containerMap = new WeakMap<object, HTMLElement>();\n\nconst getOrCreateContainer = (root: HTMLElement | ShadowRoot): HTMLElement => {\n // try ThemeProvider's App root\n const resolvedRoot = (() => {\n if (typeof document === 'undefined') return root;\n if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot) return root;\n\n const isBody = root === document.body;\n if (!isBody) return root;\n const themeApp = document.querySelector<HTMLElement>(`#${LOBE_THEME_APP_ID}`);\n if (themeApp) return themeApp;\n const tooltipContainer = document.querySelector<HTMLElement>(\n `[${TOOLTIP_CONTAINER_ATTR}=\"true\"]`,\n );\n if (tooltipContainer) return tooltipContainer;\n\n return root;\n })();\n\n const cached = containerMap.get(resolvedRoot);\n if (cached && cached.isConnected) return cached;\n\n const el = document.createElement('div');\n el.setAttribute(PORTAL_ATTR, 'true');\n resolvedRoot.append(el);\n containerMap.set(resolvedRoot, el);\n return el;\n};\n\nconst resolveRoot = (root?: HTMLElement | ShadowRoot | null): HTMLElement | ShadowRoot | null => {\n if (root) return root;\n if (typeof document === 'undefined') return null;\n return document.body;\n};\n\nconst TooltipPortal = ({ children, root }: TooltipPortalProps) => {\n const [container, setContainer] = useState<HTMLElement | null>(null);\n\n // Never mutate DOM / create portal container during render.\n // Create it after mount to avoid SSR/hydration side effects.\n useEffect(() => {\n const resolved = resolveRoot(root);\n if (!resolved) return;\n setContainer(getOrCreateContainer(resolved));\n }, [root]);\n\n if (!container) return null;\n return createPortal(children, container);\n};\n\nexport default TooltipPortal;\n"],"mappings":";;;;;;;AAaA,MAAM,cAAc;AACpB,MAAa,yBAAyB;AAGtC,MAAM,+BAAe,IAAI,SAA8B;AAEvD,MAAM,wBAAwB,SAAgD;CAE5E,MAAM,sBAAsB;AAC1B,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,MAAI,OAAO,eAAe,eAAe,gBAAgB,WAAY,QAAO;AAG5E,MAAI,EADW,SAAS,SAAS,MACpB,QAAO;EACpB,MAAM,WAAW,SAAS,cAA2B,IAAI,oBAAoB;AAC7E,MAAI,SAAU,QAAO;EACrB,MAAM,mBAAmB,SAAS,cAChC,IAAI,uBAAuB,UAC5B;AACD,MAAI,iBAAkB,QAAO;AAE7B,SAAO;KACL;CAEJ,MAAM,SAAS,aAAa,IAAI,aAAa;AAC7C,KAAI,UAAU,OAAO,YAAa,QAAO;CAEzC,MAAM,KAAK,SAAS,cAAc,MAAM;AACxC,IAAG,aAAa,aAAa,OAAO;AACpC,cAAa,OAAO,GAAG;AACvB,cAAa,IAAI,cAAc,GAAG;AAClC,QAAO;;AAGT,MAAM,eAAe,SAA4E;AAC/F,KAAI,KAAM,QAAO;AACjB,KAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,QAAO,SAAS;;AAGlB,MAAM,iBAAiB,EAAE,UAAU,WAA+B;CAChE,MAAM,CAAC,WAAW,gBAAgB,SAA6B,KAAK;AAIpE,iBAAgB;EACd,MAAM,WAAW,YAAY,KAAK;AAClC,MAAI,CAAC,SAAU;AACf,eAAa,qBAAqB,SAAS,CAAC;IAC3C,CAAC,KAAK,CAAC;AAEV,KAAI,CAAC,UAAW,QAAO;AACvB,QAAO,aAAa,UAAU,UAAU;;AAG1C,4BAAe"}
1
+ {"version":3,"file":"TooltipPortal.mjs","names":[],"sources":["../../src/Tooltip/TooltipPortal.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { useEffect, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { LOBE_THEME_APP_ID } from '@/ThemeProvider';\n\ntype TooltipPortalProps = {\n children: ReactNode;\n root?: HTMLElement | ShadowRoot | null;\n};\n\nconst PORTAL_ATTR = 'data-lobe-ui-tooltip-portal';\nexport const TOOLTIP_CONTAINER_ATTR = 'data-lobe-ui-tooltip-container';\n\n// Reuse one portal container per root (document.body by default).\nconst containerMap = new WeakMap<object, HTMLElement>();\n\nconst getOrCreateContainer = (root: HTMLElement | ShadowRoot): HTMLElement => {\n // try ThemeProvider's App root\n const resolvedRoot = (() => {\n if (typeof document === 'undefined') return root;\n if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot) return root;\n\n const isBody = root === document.body;\n if (!isBody) return root;\n const themeApp = document.querySelector<HTMLElement>(`#${LOBE_THEME_APP_ID}`);\n if (themeApp) return themeApp;\n const tooltipContainer = document.querySelector<HTMLElement>(\n `[${TOOLTIP_CONTAINER_ATTR}=\"true\"]`,\n );\n if (tooltipContainer) return tooltipContainer;\n\n return root;\n })();\n\n const cached = containerMap.get(resolvedRoot);\n if (cached && cached.isConnected) return cached;\n\n const el = document.createElement('div');\n el.setAttribute(PORTAL_ATTR, 'true');\n resolvedRoot.append(el);\n containerMap.set(resolvedRoot, el);\n return el;\n};\n\nconst resolveRoot = (root?: HTMLElement | ShadowRoot | null): HTMLElement | ShadowRoot | null => {\n if (root) return root;\n return document.body;\n};\n\nconst TooltipPortal = ({ children, root }: TooltipPortalProps) => {\n const [container, setContainer] = useState<HTMLElement | null>(null);\n\n // Never mutate DOM / create portal container during render.\n // Create it after mount to avoid SSR/hydration side effects.\n useEffect(() => {\n const resolved = resolveRoot(root);\n if (!resolved) return;\n setContainer(getOrCreateContainer(resolved));\n }, [root]);\n\n if (!container) return null;\n return createPortal(children, container);\n};\n\nexport default TooltipPortal;\n"],"mappings":";;;;;;;AAaA,MAAM,cAAc;AACpB,MAAa,yBAAyB;AAGtC,MAAM,+BAAe,IAAI,SAA8B;AAEvD,MAAM,wBAAwB,SAAgD;CAE5E,MAAM,sBAAsB;AAC1B,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,MAAI,OAAO,eAAe,eAAe,gBAAgB,WAAY,QAAO;AAG5E,MAAI,EADW,SAAS,SAAS,MACpB,QAAO;EACpB,MAAM,WAAW,SAAS,cAA2B,IAAI,oBAAoB;AAC7E,MAAI,SAAU,QAAO;EACrB,MAAM,mBAAmB,SAAS,cAChC,IAAI,uBAAuB,UAC5B;AACD,MAAI,iBAAkB,QAAO;AAE7B,SAAO;KACL;CAEJ,MAAM,SAAS,aAAa,IAAI,aAAa;AAC7C,KAAI,UAAU,OAAO,YAAa,QAAO;CAEzC,MAAM,KAAK,SAAS,cAAc,MAAM;AACxC,IAAG,aAAa,aAAa,OAAO;AACpC,cAAa,OAAO,GAAG;AACvB,cAAa,IAAI,cAAc,GAAG;AAClC,QAAO;;AAGT,MAAM,eAAe,SAA4E;AAC/F,KAAI,KAAM,QAAO;AACjB,QAAO,SAAS;;AAGlB,MAAM,iBAAiB,EAAE,UAAU,WAA+B;CAChE,MAAM,CAAC,WAAW,gBAAgB,SAA6B,KAAK;AAIpE,iBAAgB;EACd,MAAM,WAAW,YAAY,KAAK;AAClC,MAAI,CAAC,SAAU;AACf,eAAa,qBAAqB,SAAS,CAAC;IAC3C,CAAC,KAAK,CAAC;AAEV,KAAI,CAAC,UAAW,QAAO;AACvB,QAAO,aAAa,UAAU,UAAU;;AAG1C,4BAAe"}
@@ -1,7 +1,7 @@
1
1
  import { FlexboxProps } from "../Flex/type.mjs";
2
2
  import "../Flex/index.mjs";
3
3
  import { VideoProps as VideoProps$1 } from "../types/index.mjs";
4
- import * as react66 from "react";
4
+ import * as react2 from "react";
5
5
  import { CSSProperties, Ref } from "react";
6
6
 
7
7
  //#region src/Video/index.d.ts
@@ -39,7 +39,7 @@ interface VideoProps extends VideoProps$1, Pick<FlexboxProps, 'width' | 'height'
39
39
  };
40
40
  variant?: 'borderless' | 'filled' | 'outlined';
41
41
  }
42
- declare const Video: react66.NamedExoticComponent<VideoProps>;
42
+ declare const Video: react2.NamedExoticComponent<VideoProps>;
43
43
  //#endregion
44
44
  export { Video, VideoProps };
45
45
  //# sourceMappingURL=index.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { AuroraBackgroundProps } from "./type.mjs";
2
- import * as react110 from "react";
2
+ import * as react128 from "react";
3
3
 
4
4
  //#region src/awesome/AuroraBackground/AuroraBackground.d.ts
5
- declare const AuroraBackground: react110.NamedExoticComponent<AuroraBackgroundProps>;
5
+ declare const AuroraBackground: react128.NamedExoticComponent<AuroraBackgroundProps>;
6
6
  //#endregion
7
7
  export { AuroraBackground };
8
8
  //# sourceMappingURL=AuroraBackground.d.mts.map
@@ -1,9 +1,9 @@
1
1
  import { ButtonProps } from "../../Button/type.mjs";
2
2
  import "../../Button/index.mjs";
3
- import * as react111 from "react";
3
+ import * as react129 from "react";
4
4
 
5
5
  //#region src/awesome/BottomGradientButton/BottomGradientButton.d.ts
6
- declare const BottomGradientButton: react111.NamedExoticComponent<ButtonProps>;
6
+ declare const BottomGradientButton: react129.NamedExoticComponent<ButtonProps>;
7
7
  //#endregion
8
8
  export { BottomGradientButton };
9
9
  //# sourceMappingURL=BottomGradientButton.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { FeaturesProps } from "./type.mjs";
2
- import * as react112 from "react";
2
+ import * as react130 from "react";
3
3
 
4
4
  //#region src/awesome/Features/Features.d.ts
5
- declare const Features: react112.NamedExoticComponent<FeaturesProps>;
5
+ declare const Features: react130.NamedExoticComponent<FeaturesProps>;
6
6
  //#endregion
7
7
  export { Features };
8
8
  //# sourceMappingURL=Features.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { GiscusProps } from "./type.mjs";
2
- import * as react113 from "react";
2
+ import * as react136 from "react";
3
3
 
4
4
  //#region src/awesome/Giscus/Giscus.d.ts
5
- declare const Giscus: react113.NamedExoticComponent<GiscusProps>;
5
+ declare const Giscus: react136.NamedExoticComponent<GiscusProps>;
6
6
  //#endregion
7
7
  export { Giscus };
8
8
  //# sourceMappingURL=Giscus.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { GradientButtonProps } from "./type.mjs";
2
- import * as react114 from "react";
2
+ import * as react126 from "react";
3
3
 
4
4
  //#region src/awesome/GradientButton/GradientButton.d.ts
5
- declare const GradientButton: react114.NamedExoticComponent<GradientButtonProps>;
5
+ declare const GradientButton: react126.NamedExoticComponent<GradientButtonProps>;
6
6
  //#endregion
7
7
  export { GradientButton };
8
8
  //# sourceMappingURL=GradientButton.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { GridBackgroundProps } from "./type.mjs";
2
- import * as react115 from "react";
2
+ import * as react131 from "react";
3
3
 
4
4
  //#region src/awesome/GridBackground/GridBackground.d.ts
5
- declare const GridBackground: react115.NamedExoticComponent<GridBackgroundProps>;
5
+ declare const GridBackground: react131.NamedExoticComponent<GridBackgroundProps>;
6
6
  //#endregion
7
7
  export { GridBackground };
8
8
  //# sourceMappingURL=GridBackground.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { GridShowcaseProps } from "./type.mjs";
2
- import * as react116 from "react";
2
+ import * as react132 from "react";
3
3
 
4
4
  //#region src/awesome/GridBackground/GridShowcase.d.ts
5
- declare const GridShowcase: react116.NamedExoticComponent<GridShowcaseProps>;
5
+ declare const GridShowcase: react132.NamedExoticComponent<GridShowcaseProps>;
6
6
  //#endregion
7
7
  export { GridShowcase };
8
8
  //# sourceMappingURL=GridShowcase.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { HeroProps } from "./type.mjs";
2
- import * as react117 from "react";
2
+ import * as react135 from "react";
3
3
 
4
4
  //#region src/awesome/Hero/Hero.d.ts
5
- declare const Hero: react117.NamedExoticComponent<HeroProps>;
5
+ declare const Hero: react135.NamedExoticComponent<HeroProps>;
6
6
  //#endregion
7
7
  export { Hero };
8
8
  //# sourceMappingURL=Hero.d.mts.map
@@ -1,9 +1,9 @@
1
1
  import { SplineProps } from "./type.mjs";
2
- import * as react118 from "react";
2
+ import * as react137 from "react";
3
3
  import "@splinetool/runtime";
4
4
 
5
5
  //#region src/awesome/Spline/Spine.d.ts
6
- declare const Spline: react118.NamedExoticComponent<SplineProps>;
6
+ declare const Spline: react137.NamedExoticComponent<SplineProps>;
7
7
  //#endregion
8
8
  export { Spline };
9
9
  //# sourceMappingURL=Spine.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { SpotlightProps } from "./type.mjs";
2
- import * as react119 from "react";
2
+ import * as react133 from "react";
3
3
 
4
4
  //#region src/awesome/Spotlight/Spotlight.d.ts
5
- declare const Spotlight: react119.NamedExoticComponent<SpotlightProps>;
5
+ declare const Spotlight: react133.NamedExoticComponent<SpotlightProps>;
6
6
  //#endregion
7
7
  export { Spotlight };
8
8
  //# sourceMappingURL=Spotlight.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { SpotlightCardProps } from "./type.mjs";
2
- import * as react120 from "react";
2
+ import * as react134 from "react";
3
3
 
4
4
  //#region src/awesome/SpotlightCard/SpotlightCard.d.ts
5
- declare const SpotlightCard: react120.NamedExoticComponent<SpotlightCardProps<any>>;
5
+ declare const SpotlightCard: react134.NamedExoticComponent<SpotlightCardProps<any>>;
6
6
  //#endregion
7
7
  export { SpotlightCard };
8
8
  //# sourceMappingURL=SpotlightCard.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { TypewriterEffectProps } from "./type.mjs";
2
- import * as react109 from "react";
2
+ import * as react127 from "react";
3
3
 
4
4
  //#region src/awesome/TypewriterEffect/TypewriterEffect.d.ts
5
- declare const TypewriterEffect: react109.NamedExoticComponent<TypewriterEffectProps>;
5
+ declare const TypewriterEffect: react127.NamedExoticComponent<TypewriterEffectProps>;
6
6
  //#endregion
7
7
  export { TypewriterEffect };
8
8
  //# sourceMappingURL=TypewriterEffect.d.mts.map
@@ -1,5 +1,5 @@
1
1
  import { DivProps } from "../../types/index.mjs";
2
- import * as react57 from "react";
2
+ import * as react23 from "react";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/brand/LobeChat/index.d.ts
@@ -8,7 +8,7 @@ interface LobeChatProps extends DivProps {
8
8
  size?: number;
9
9
  type?: '3d' | 'flat' | 'mono' | 'text' | 'combine';
10
10
  }
11
- declare const LobeChat: react57.NamedExoticComponent<LobeChatProps>;
11
+ declare const LobeChat: react23.NamedExoticComponent<LobeChatProps>;
12
12
  //#endregion
13
13
  export { LobeChat, LobeChatProps };
14
14
  //# sourceMappingURL=index.d.mts.map