@lobehub/ui 3.4.6 → 4.1.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 (219) hide show
  1. package/README.md +48 -0
  2. package/es/Accordion/Accordion.d.mts +2 -2
  3. package/es/Accordion/AccordionItem.d.mts +2 -2
  4. package/es/Accordion/AccordionItem.mjs +5 -5
  5. package/es/Accordion/AccordionItem.mjs.map +1 -1
  6. package/es/ActionIcon/ActionIcon.d.mts +2 -2
  7. package/es/Alert/Alert.d.mts +2 -2
  8. package/es/AutoComplete/Select.d.mts +2 -2
  9. package/es/Avatar/AvatarGroup/index.d.mts +2 -2
  10. package/es/Burger/Burger.d.mts +2 -2
  11. package/es/CodeEditor/CodeEditor.d.mts +2 -2
  12. package/es/Collapse/Collapse.d.mts +2 -2
  13. package/es/ConfigProvider/index.d.mts +10 -4
  14. package/es/ConfigProvider/index.mjs +54 -6
  15. package/es/ConfigProvider/index.mjs.map +1 -1
  16. package/es/CopyButton/CopyButton.d.mts +2 -2
  17. package/es/DatePicker/DatePicker.d.mts +2 -2
  18. package/es/DraggablePanel/components/DraggablePanelBody.d.mts +2 -2
  19. package/es/DraggablePanel/components/DraggablePanelContainer.d.mts +2 -2
  20. package/es/DraggablePanel/components/DraggablePanelFooter.d.mts +2 -2
  21. package/es/DraggablePanel/components/DraggablePanelHeader.d.mts +2 -2
  22. package/es/DraggableSideNav/DraggableSideNav.d.mts +2 -2
  23. package/es/Drawer/Drawer.d.mts +2 -2
  24. package/es/Dropdown/Dropdown.d.mts +2 -2
  25. package/es/EditableText/EditableText.d.mts +2 -2
  26. package/es/EmojiPicker/AvatarUploader.mjs +10 -4
  27. package/es/EmojiPicker/AvatarUploader.mjs.map +1 -1
  28. package/es/EmojiPicker/EmojiPicker.d.mts +2 -2
  29. package/es/EmojiPicker/EmojiPicker.mjs +9 -3
  30. package/es/EmojiPicker/EmojiPicker.mjs.map +1 -1
  31. package/es/Flex/FlexBasic.d.mts +2 -2
  32. package/es/FontLoader/index.d.mts +2 -2
  33. package/es/Footer/Footer.d.mts +2 -2
  34. package/es/Form/components/FormGroup.d.mts +2 -2
  35. package/es/Form/components/FormItem.d.mts +2 -2
  36. package/es/Form/components/FormSubmitFooter.d.mts +2 -2
  37. package/es/Form/components/FormSubmitFooter.mjs +20 -8
  38. package/es/Form/components/FormSubmitFooter.mjs.map +1 -1
  39. package/es/FormModal/FormModal.d.mts +2 -2
  40. package/es/GuideCard/GuideCard.d.mts +2 -2
  41. package/es/Header/Header.d.mts +2 -2
  42. package/es/Highlighter/Highlighter.d.mts +2 -2
  43. package/es/Highlighter/SyntaxHighlighter/index.d.mts +2 -2
  44. package/es/Hotkey/Hotkey.d.mts +2 -2
  45. package/es/HotkeyInput/HotkeyInput.d.mts +2 -2
  46. package/es/HotkeyInput/HotkeyInput.mjs +13 -6
  47. package/es/HotkeyInput/HotkeyInput.mjs.map +1 -1
  48. package/es/Icon/Icon.d.mts +2 -2
  49. package/es/Icon/components/IconProvider.d.mts +3 -3
  50. package/es/Image/PreviewGroup.d.mts +2 -2
  51. package/es/ImageSelect/ImageSelect.d.mts +2 -2
  52. package/es/Input/Input.d.mts +2 -2
  53. package/es/Input/InputNumber.d.mts +2 -2
  54. package/es/Input/InputOPT.d.mts +2 -2
  55. package/es/Input/InputPassword.d.mts +2 -2
  56. package/es/Input/TextArea.d.mts +2 -2
  57. package/es/Layout/components/LayoutFooter.d.mts +2 -2
  58. package/es/Layout/components/LayoutHeader.d.mts +2 -2
  59. package/es/Layout/components/LayoutMain.d.mts +2 -2
  60. package/es/Layout/components/LayoutSidebar.d.mts +2 -2
  61. package/es/Layout/components/LayoutSidebarInner.d.mts +2 -2
  62. package/es/Layout/components/LayoutToc.d.mts +2 -2
  63. package/es/List/ListItem/index.d.mts +2 -2
  64. package/es/Markdown/Markdown.d.mts +2 -2
  65. package/es/Markdown/Typography.d.mts +2 -2
  66. package/es/Markdown/components/SearchResultCards/index.d.mts +2 -2
  67. package/es/MaskShadow/MaskShadow.d.mts +2 -2
  68. package/es/Menu/Menu.d.mts +2 -2
  69. package/es/Mermaid/Mermaid.d.mts +2 -2
  70. package/es/Mermaid/SyntaxMermaid/index.d.mts +2 -2
  71. package/es/Modal/Modal.d.mts +2 -2
  72. package/es/MotionProvider/index.d.mts +15 -0
  73. package/es/MotionProvider/index.d.ts +1 -0
  74. package/es/MotionProvider/index.js +1 -0
  75. package/es/MotionProvider/index.mjs +22 -0
  76. package/es/MotionProvider/index.mjs.map +1 -0
  77. package/es/Provider.d.mts +2 -0
  78. package/es/SearchBar/SearchBar.d.mts +2 -2
  79. package/es/Segmented/Segmented.d.mts +2 -2
  80. package/es/Select/Select.d.mts +2 -2
  81. package/es/SideNav/SideNav.d.mts +2 -2
  82. package/es/SliderWithInput/SliderWithInput.d.mts +2 -2
  83. package/es/SortableList/components/DragHandle.d.mts +2 -2
  84. package/es/SortableList/components/SortableItem.d.mts +2 -2
  85. package/es/ThemeProvider/ThemeProvider.d.mts +2 -2
  86. package/es/ThemeProvider/ThemeProvider.mjs +11 -4
  87. package/es/ThemeProvider/ThemeProvider.mjs.map +1 -1
  88. package/es/ThemeProvider/type.d.mts +4 -0
  89. package/es/Toc/Toc.d.mts +2 -2
  90. package/es/Video/index.d.mts +2 -2
  91. package/es/_virtual/rolldown_runtime.mjs +18 -0
  92. package/es/awesome/AuroraBackground/AuroraBackground.d.mts +2 -2
  93. package/es/awesome/BottomGradientButton/BottomGradientButton.d.mts +2 -2
  94. package/es/awesome/Features/Features.d.mts +2 -2
  95. package/es/awesome/Giscus/Giscus.d.mts +2 -2
  96. package/es/awesome/GradientButton/GradientButton.d.mts +2 -2
  97. package/es/awesome/GridBackground/GridBackground.d.mts +2 -2
  98. package/es/awesome/GridBackground/GridShowcase.d.mts +2 -2
  99. package/es/awesome/Hero/Hero.d.mts +2 -2
  100. package/es/awesome/Spotlight/Spotlight.d.mts +2 -2
  101. package/es/awesome/SpotlightCard/SpotlightCard.d.mts +2 -2
  102. package/es/awesome/TypewriterEffect/TypewriterEffect.d.mts +2 -2
  103. package/es/awesome/TypewriterEffect/TypewriterEffect.mjs +5 -4
  104. package/es/awesome/TypewriterEffect/TypewriterEffect.mjs.map +1 -1
  105. package/es/brand/BrandLoading/{style-CB0aumHV.css → style-Cof4dJBw.css} +1 -1
  106. package/es/brand/BrandLoading/{style-CB0aumHV.css.map → style-Cof4dJBw.css.map} +1 -1
  107. package/es/brand/LobeChat/index.d.mts +2 -2
  108. package/es/brand/LobeHub/index.d.mts +2 -2
  109. package/es/brand/LogoThree/LogoSpline.d.mts +2 -2
  110. package/es/brand/LogoThree/index.d.mts +2 -2
  111. package/es/chat/BackBottom/BackBottom.d.mts +2 -2
  112. package/es/chat/ChatInputArea/components/ChatInputAreaInner.d.mts +2 -2
  113. package/es/chat/ChatItem/ChatItem.d.mts +2 -2
  114. package/es/chat/ChatItem/ChatItem.mjs +8 -3
  115. package/es/chat/ChatItem/ChatItem.mjs.map +1 -1
  116. package/es/chat/ChatList/ChatList.d.mts +2 -2
  117. package/es/chat/EditableMessage/EditableMessage.d.mts +2 -2
  118. package/es/chat/EditableMessageList/EditableMessageList.d.mts +2 -2
  119. package/es/chat/EditableMessageList/EditableMessageList.mjs +17 -7
  120. package/es/chat/EditableMessageList/EditableMessageList.mjs.map +1 -1
  121. package/es/chat/EditableMessageList/type.d.mts +9 -0
  122. package/es/chat/MessageInput/MessageInput.d.mts +2 -2
  123. package/es/chat/MessageModal/MessageModal.d.mts +2 -2
  124. package/es/chat/MessageModal/MessageModal.mjs +27 -22
  125. package/es/chat/MessageModal/MessageModal.mjs.map +1 -1
  126. package/es/chat/TokenTag/TokenTag.mjs +7 -1
  127. package/es/chat/TokenTag/TokenTag.mjs.map +1 -1
  128. package/es/color/ColorScales/index.d.mts +2 -2
  129. package/es/i18n/context.d.mts +17 -0
  130. package/es/i18n/context.mjs +18 -0
  131. package/es/i18n/context.mjs.map +1 -0
  132. package/es/i18n/index.d.mts +6 -0
  133. package/es/i18n/index.d.ts +1 -0
  134. package/es/i18n/index.js +1 -0
  135. package/es/i18n/index.mjs +6 -0
  136. package/es/i18n/resources/en/chat.d.mts +11 -0
  137. package/es/i18n/resources/en/chat.mjs +12 -0
  138. package/es/i18n/resources/en/chat.mjs.map +1 -0
  139. package/es/i18n/resources/en/common.d.mts +10 -0
  140. package/es/i18n/resources/en/common.mjs +11 -0
  141. package/es/i18n/resources/en/common.mjs.map +1 -0
  142. package/es/i18n/resources/en/editableMessage.d.mts +13 -0
  143. package/es/i18n/resources/en/editableMessage.mjs +14 -0
  144. package/es/i18n/resources/en/editableMessage.mjs.map +1 -0
  145. package/es/i18n/resources/en/emojiPicker.d.mts +12 -0
  146. package/es/i18n/resources/en/emojiPicker.mjs +13 -0
  147. package/es/i18n/resources/en/emojiPicker.mjs.map +1 -0
  148. package/es/i18n/resources/en/form.d.mts +10 -0
  149. package/es/i18n/resources/en/form.mjs +11 -0
  150. package/es/i18n/resources/en/form.mjs.map +1 -0
  151. package/es/i18n/resources/en/hotkey.d.mts +10 -0
  152. package/es/i18n/resources/en/hotkey.mjs +11 -0
  153. package/es/i18n/resources/en/hotkey.mjs.map +1 -0
  154. package/es/i18n/resources/en/index.d.mts +16 -0
  155. package/es/i18n/resources/en/index.mjs +25 -0
  156. package/es/i18n/resources/en/index.mjs.map +1 -0
  157. package/es/i18n/resources/en/messageModal.d.mts +9 -0
  158. package/es/i18n/resources/en/messageModal.mjs +10 -0
  159. package/es/i18n/resources/en/messageModal.mjs.map +1 -0
  160. package/es/i18n/resources/en/sideNav.d.mts +21 -0
  161. package/es/i18n/resources/en/sideNav.mjs +22 -0
  162. package/es/i18n/resources/en/sideNav.mjs.map +1 -0
  163. package/es/i18n/resources/index.d.mts +3 -0
  164. package/es/i18n/resources/index.mjs +4 -0
  165. package/es/i18n/resources/zhCn/chat.d.mts +11 -0
  166. package/es/i18n/resources/zhCn/chat.mjs +12 -0
  167. package/es/i18n/resources/zhCn/chat.mjs.map +1 -0
  168. package/es/i18n/resources/zhCn/common.d.mts +10 -0
  169. package/es/i18n/resources/zhCn/common.mjs +11 -0
  170. package/es/i18n/resources/zhCn/common.mjs.map +1 -0
  171. package/es/i18n/resources/zhCn/editableMessage.d.mts +13 -0
  172. package/es/i18n/resources/zhCn/editableMessage.mjs +14 -0
  173. package/es/i18n/resources/zhCn/editableMessage.mjs.map +1 -0
  174. package/es/i18n/resources/zhCn/emojiPicker.d.mts +12 -0
  175. package/es/i18n/resources/zhCn/emojiPicker.mjs +13 -0
  176. package/es/i18n/resources/zhCn/emojiPicker.mjs.map +1 -0
  177. package/es/i18n/resources/zhCn/form.d.mts +10 -0
  178. package/es/i18n/resources/zhCn/form.mjs +11 -0
  179. package/es/i18n/resources/zhCn/form.mjs.map +1 -0
  180. package/es/i18n/resources/zhCn/hotkey.d.mts +10 -0
  181. package/es/i18n/resources/zhCn/hotkey.mjs +11 -0
  182. package/es/i18n/resources/zhCn/hotkey.mjs.map +1 -0
  183. package/es/i18n/resources/zhCn/index.d.mts +16 -0
  184. package/es/i18n/resources/zhCn/index.mjs +25 -0
  185. package/es/i18n/resources/zhCn/index.mjs.map +1 -0
  186. package/es/i18n/resources/zhCn/messageModal.d.mts +9 -0
  187. package/es/i18n/resources/zhCn/messageModal.mjs +10 -0
  188. package/es/i18n/resources/zhCn/messageModal.mjs.map +1 -0
  189. package/es/i18n/resources/zhCn/sideNav.d.mts +21 -0
  190. package/es/i18n/resources/zhCn/sideNav.mjs +22 -0
  191. package/es/i18n/resources/zhCn/sideNav.mjs.map +1 -0
  192. package/es/i18n/types.d.mts +30 -0
  193. package/es/i18n/useTranslation.d.mts +10 -0
  194. package/es/i18n/useTranslation.mjs +22 -0
  195. package/es/i18n/useTranslation.mjs.map +1 -0
  196. package/es/icons/lucideExtra/BotPromptIcon.d.mts +2 -2
  197. package/es/icons/lucideExtra/CreateBotIcon.d.mts +2 -2
  198. package/es/icons/lucideExtra/DiscordIcon.d.mts +3 -3
  199. package/es/icons/lucideExtra/GlobeOffIcon.d.mts +3 -3
  200. package/es/icons/lucideExtra/GroupBotIcon.d.mts +3 -3
  201. package/es/icons/lucideExtra/GroupBotSquareIcon.d.mts +3 -3
  202. package/es/icons/lucideExtra/LeftClickIcon.d.mts +3 -3
  203. package/es/icons/lucideExtra/LeftDoubleClickIcon.d.mts +3 -3
  204. package/es/icons/lucideExtra/McpIcon.d.mts +3 -3
  205. package/es/icons/lucideExtra/ProviderIcon.d.mts +3 -3
  206. package/es/icons/lucideExtra/RightClickIcon.d.mts +3 -3
  207. package/es/icons/lucideExtra/RightDoubleClickIcon.d.mts +2 -2
  208. package/es/icons/lucideExtra/ShapesUploadIcon.d.mts +3 -3
  209. package/es/icons/lucideExtra/TreeDownRightIcon.d.mts +3 -3
  210. package/es/icons/lucideExtra/TreeUpDownRightIcon.d.mts +3 -3
  211. package/es/index.d.mts +5 -1
  212. package/es/index.mjs +4 -1
  213. package/es/mdx/Mdx/index.d.mts +2 -2
  214. package/es/mobile/ChatHeader/ChatHeaderTitle.d.mts +2 -2
  215. package/es/mobile/ChatInputArea/components/ChatSendButton.d.mts +2 -2
  216. package/es/mobile/TabBar/TabBar.d.mts +2 -2
  217. package/es/motion/LazyMotion.d.mts +2 -2
  218. package/es/storybook/StoryBook/index.d.mts +2 -2
  219. package/package.json +27 -1
package/README.md CHANGED
@@ -39,6 +39,8 @@ Lobe UI is an open-source UI component library for building _AIGC_ web apps
39
39
  - [📦 Installation](#-installation)
40
40
  - [Compile with NextJS](#compile-with-nextjs)
41
41
  - [🤯 Usage](#-usage)
42
+ - [I18n](#i18n)
43
+ - [ConfigProvider (Motion)](#configprovider-motion)
42
44
  - [⌨️ Local Development](#️-local-development)
43
45
  - [🤝 Contributing](#-contributing)
44
46
  - [🩷 Sponsor](#-sponsor)
@@ -101,6 +103,52 @@ export default () => (
101
103
  )
102
104
  ```
103
105
 
106
+ ### I18n
107
+
108
+ Use the i18n provider with resource bundles. Component `texts` props always take priority.
109
+
110
+ ```tsx
111
+ import { I18nProvider } from '@lobehub/ui';
112
+ import formMessages from '@lobehub/ui/i18n/resources/form';
113
+ import hotkeyMessages from '@lobehub/ui/i18n/resources/hotkey';
114
+
115
+ <I18nProvider resources={[formMessages, hotkeyMessages]}>
116
+ <App />
117
+ </I18nProvider>;
118
+ ```
119
+
120
+ ### ConfigProvider (Motion)
121
+
122
+ You must pass a motion component via `ConfigProvider` (or `ThemeProvider`).
123
+ If your app uses `LazyMotion`, pass `m`:
124
+
125
+ ```tsx
126
+ import { ConfigProvider } from '@lobehub/ui';
127
+ import { motion } from 'motion/react';
128
+
129
+ export default () => (
130
+ <ConfigProvider motion={motion}>
131
+ <App />
132
+ </ConfigProvider>
133
+ );
134
+ ```
135
+
136
+ If your app uses `LazyMotion`:
137
+
138
+ ```tsx
139
+ import { ConfigProvider } from '@lobehub/ui';
140
+ import { LazyMotion, domAnimation } from 'motion/react';
141
+ import * as m from 'motion/react-m';
142
+
143
+ export default () => (
144
+ <LazyMotion features={domAnimation}>
145
+ <ConfigProvider motion={m}>
146
+ <App />
147
+ </ConfigProvider>
148
+ </LazyMotion>
149
+ );
150
+ ```
151
+
104
152
  <div align="right">
105
153
 
106
154
  [![][back-to-top]](#readme-top)
@@ -1,8 +1,8 @@
1
1
  import { AccordionProps } from "./type.mjs";
2
- import * as react60 from "react";
2
+ import * as react7 from "react";
3
3
 
4
4
  //#region src/Accordion/Accordion.d.ts
5
- declare const Accordion: react60.NamedExoticComponent<AccordionProps & react60.RefAttributes<HTMLDivElement>>;
5
+ declare const Accordion: react7.NamedExoticComponent<AccordionProps & react7.RefAttributes<HTMLDivElement>>;
6
6
  //#endregion
7
7
  export { Accordion };
8
8
  //# sourceMappingURL=Accordion.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { AccordionItemProps } from "./type.mjs";
2
- import * as react62 from "react";
2
+ import * as react6 from "react";
3
3
 
4
4
  //#region src/Accordion/AccordionItem.d.ts
5
- declare const AccordionItem: react62.NamedExoticComponent<AccordionItemProps>;
5
+ declare const AccordionItem: react6.NamedExoticComponent<AccordionItemProps>;
6
6
  //#endregion
7
7
  export { AccordionItem };
8
8
  //# sourceMappingURL=AccordionItem.d.mts.map
@@ -1,14 +1,13 @@
1
1
  'use client';
2
2
 
3
+ import { MotionComponent } from "../MotionProvider/index.mjs";
3
4
  import { useAccordionContext } from "./context.mjs";
4
5
  import { useStyles } from "./style.mjs";
5
6
  import FlexBasic_default from "../Flex/FlexBasic.mjs";
6
7
  import Block_default from "../Block/Block.mjs";
7
- import { LazyMotion } from "../motion/LazyMotion.mjs";
8
- import { m } from "../motion/index.mjs";
9
8
  import Text_default from "../Text/Text.mjs";
10
9
  import ArrowIcon_default from "./ArrowIcon.mjs";
11
- import { memo, useCallback, useMemo } from "react";
10
+ import { memo, use, useCallback, useMemo } from "react";
12
11
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
12
 
14
13
  //#region src/Accordion/AccordionItem.tsx
@@ -104,6 +103,7 @@ const AccordionItem = memo(({ itemKey, title, children, action, disabled = false
104
103
  },
105
104
  ...contextMotionProps
106
105
  }), [isOpen, contextMotionProps]);
106
+ const m = use(MotionComponent);
107
107
  const contentElement = useMemo(() => {
108
108
  if (disableAnimation || !keepContentMounted) {
109
109
  if (keepContentMounted) return /* @__PURE__ */ jsx("div", {
@@ -128,7 +128,7 @@ const AccordionItem = memo(({ itemKey, title, children, action, disabled = false
128
128
  })
129
129
  });
130
130
  }
131
- return /* @__PURE__ */ jsx(LazyMotion, { children: /* @__PURE__ */ jsx(m.div, {
131
+ return /* @__PURE__ */ jsx(m.div, {
132
132
  ...motionProps,
133
133
  style: { overflow: "hidden" },
134
134
  children: /* @__PURE__ */ jsx("div", {
@@ -140,7 +140,7 @@ const AccordionItem = memo(({ itemKey, title, children, action, disabled = false
140
140
  children
141
141
  })
142
142
  })
143
- }) });
143
+ });
144
144
  }, [
145
145
  disableAnimation,
146
146
  keepContentMounted,
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionItem.mjs","names":["ArrowIcon","Text","Flexbox","Block"],"sources":["../../src/Accordion/AccordionItem.tsx"],"sourcesContent":["'use client';\n\nimport { KeyboardEvent, memo, useCallback, useMemo } from 'react';\n\nimport Block from '@/Block';\nimport { Flexbox } from '@/Flex';\nimport Text from '@/Text';\nimport { LazyMotion, m } from '@/motion';\n\nimport ArrowIcon from './ArrowIcon';\nimport { useAccordionContext } from './context';\nimport { useStyles } from './style';\nimport type { AccordionItemProps } from './type';\n\nconst AccordionItem = memo<AccordionItemProps>(\n ({\n itemKey,\n title,\n children,\n action,\n disabled = false,\n hideIndicator: itemHideIndicator,\n indicatorPlacement: itemIndicatorPlacement,\n indicator: customIndicator,\n classNames,\n paddingInline = 16,\n paddingBlock = 8,\n padding,\n ref,\n variant: customVariant,\n styles: customStyles,\n headerWrapper,\n }) => {\n const { cx, styles } = useStyles();\n const context = useAccordionContext();\n\n const {\n isExpanded,\n onToggle,\n hideIndicator: contextHideIndicator,\n indicatorPlacement: contextIndicatorPlacement,\n keepContentMounted,\n disableAnimation,\n motionProps: contextMotionProps,\n variant = 'filled',\n } = context;\n\n const isOpen = isExpanded(itemKey);\n const hideIndicatorFinal = itemHideIndicator ?? contextHideIndicator ?? false;\n const indicatorPlacementFinal = itemIndicatorPlacement ?? contextIndicatorPlacement ?? 'start';\n\n const handleToggle = useCallback(() => {\n if (!disabled) {\n onToggle(itemKey);\n }\n }, [disabled, itemKey, onToggle]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (disabled) return;\n\n switch (e.key) {\n case 'Enter':\n case ' ': {\n e.preventDefault();\n handleToggle();\n break;\n }\n }\n },\n [disabled, handleToggle],\n );\n\n // Build indicator\n const indicator = useMemo(() => {\n if (hideIndicatorFinal) return null;\n\n if (customIndicator) {\n if (typeof customIndicator === 'function') {\n return (\n <span\n aria-hidden=\"true\"\n className={cx(styles.indicator, classNames?.indicator)}\n style={customStyles?.indicator}\n >\n {customIndicator({ isDisabled: disabled, isOpen })}\n </span>\n );\n }\n return (\n <span\n aria-hidden=\"true\"\n className={cx(styles.indicator, classNames?.indicator)}\n style={customStyles?.indicator}\n >\n {customIndicator}\n </span>\n );\n }\n\n return (\n <span\n aria-hidden=\"true\"\n className={cx(styles.indicator, classNames?.indicator)}\n style={customStyles?.indicator}\n >\n <ArrowIcon className={cx(styles.icon, isOpen && styles.iconRotate)} />\n </span>\n );\n }, [\n hideIndicatorFinal,\n customIndicator,\n disabled,\n isOpen,\n cx,\n styles,\n classNames,\n customStyles,\n ]);\n\n // Animation variants\n const motionProps = useMemo(\n () => ({\n animate: isOpen ? 'enter' : 'exit',\n exit: 'exit',\n initial: false,\n variants: {\n enter: {\n height: 'auto',\n opacity: 1,\n transition: {\n duration: 0.2,\n ease: [0.4, 0, 0.2, 1],\n },\n },\n exit: {\n height: 0,\n opacity: 0,\n transition: {\n duration: 0.2,\n ease: [0.4, 0, 0.2, 1],\n },\n },\n },\n ...contextMotionProps,\n }),\n [isOpen, contextMotionProps],\n );\n\n // Render content\n const contentElement = useMemo(() => {\n if (disableAnimation || !keepContentMounted) {\n if (keepContentMounted) {\n return (\n <div\n className={cx('accordion-content', styles.content, classNames?.content)}\n role=\"region\"\n style={{\n display: isOpen ? 'block' : 'none',\n ...customStyles?.content,\n }}\n >\n <div className={styles.contentInner}>{children}</div>\n </div>\n );\n }\n\n return (\n isOpen && (\n <div\n className={cx('accordion-content', styles.content, classNames?.content)}\n role=\"region\"\n style={customStyles?.content}\n >\n <div className={styles.contentInner}>{children}</div>\n </div>\n )\n );\n }\n\n return (\n <LazyMotion>\n <m.div {...motionProps} style={{ overflow: 'hidden' }}>\n <div\n className={cx('accordion-content', styles.content, classNames?.content)}\n role=\"region\"\n style={customStyles?.content}\n >\n <div className={styles.contentInner}>{children}</div>\n </div>\n </m.div>\n </LazyMotion>\n );\n }, [\n disableAnimation,\n keepContentMounted,\n isOpen,\n cx,\n styles,\n classNames,\n customStyles,\n children,\n motionProps,\n ]);\n\n const titleNode = useMemo(\n () =>\n typeof title === 'string' ? (\n <Text className={classNames?.title} ellipsis style={customStyles?.title}>\n {title}\n </Text>\n ) : (\n title\n ),\n [title, classNames?.title, customStyles?.title],\n );\n\n const actionNode = useMemo(\n () =>\n action && (\n <Flexbox\n align={'center'}\n className={cx('accordion-action', styles.action, classNames?.action)}\n flex={'none'}\n gap={4}\n horizontal\n onClick={(e) => e.stopPropagation()}\n style={customStyles?.action}\n >\n {action}\n </Flexbox>\n ),\n [action, cx, styles, classNames?.action, customStyles?.action],\n );\n\n const headerElement = useMemo(() => {\n const header = (\n <Block\n className={cx('accordion-header', styles.header, classNames?.header)}\n clickable={!disabled}\n gap={4}\n horizontal\n justify={'space-between'}\n onClick={handleToggle}\n onKeyDown={handleKeyDown}\n padding={padding}\n paddingBlock={paddingBlock}\n paddingInline={paddingInline}\n ref={ref}\n style={{\n alignItems: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.5 : undefined,\n overflow: 'hidden',\n width: '100%',\n ...customStyles?.header,\n }}\n variant={customVariant || variant}\n >\n {indicatorPlacementFinal === 'start' ? (\n <>\n <Flexbox\n align={'center'}\n flex={1}\n gap={2}\n horizontal\n style={{\n overflow: 'hidden',\n }}\n >\n {titleNode}\n {indicator}\n </Flexbox>\n <Flexbox align={'center'} flex={'none'} gap={4} horizontal>\n {actionNode}\n </Flexbox>\n </>\n ) : (\n <>\n <Flexbox\n align={'center'}\n flex={1}\n gap={2}\n horizontal\n style={{\n overflow: 'hidden',\n }}\n >\n {titleNode}\n </Flexbox>\n <Flexbox align={'center'} flex={'none'} gap={4} horizontal>\n {actionNode}\n {indicator}\n </Flexbox>\n </>\n )}\n </Block>\n );\n if (headerWrapper) {\n return headerWrapper(header);\n }\n return header;\n }, [\n cx,\n styles,\n classNames,\n disabled,\n handleToggle,\n handleKeyDown,\n padding,\n paddingBlock,\n paddingInline,\n ref,\n customVariant,\n variant,\n indicatorPlacementFinal,\n titleNode,\n indicator,\n actionNode,\n headerWrapper,\n ]);\n\n return (\n <div\n className={cx('accordion-item', styles.item, classNames?.base)}\n style={customStyles?.base}\n >\n {headerElement}\n {contentElement}\n </div>\n );\n },\n);\n\nAccordionItem.displayName = 'AccordionItem';\n\nexport default AccordionItem;\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,gBAAgB,MACnB,EACC,SACA,OACA,UACA,QACA,WAAW,OACX,eAAe,mBACf,oBAAoB,wBACpB,WAAW,iBACX,YACA,gBAAgB,IAChB,eAAe,GACf,SACA,KACA,SAAS,eACT,QAAQ,cACR,oBACI;CACJ,MAAM,EAAE,IAAI,WAAW,WAAW;CAGlC,MAAM,EACJ,YACA,UACA,eAAe,sBACf,oBAAoB,2BACpB,oBACA,kBACA,aAAa,oBACb,UAAU,aAVI,qBAAqB;CAarC,MAAM,SAAS,WAAW,QAAQ;CAClC,MAAM,qBAAqB,qBAAqB,wBAAwB;CACxE,MAAM,0BAA0B,0BAA0B,6BAA6B;CAEvF,MAAM,eAAe,kBAAkB;AACrC,MAAI,CAAC,SACH,UAAS,QAAQ;IAElB;EAAC;EAAU;EAAS;EAAS,CAAC;CAEjC,MAAM,gBAAgB,aACnB,MAAqB;AACpB,MAAI,SAAU;AAEd,UAAQ,EAAE,KAAV;GACE,KAAK;GACL,KAAK;AACH,MAAE,gBAAgB;AAClB,kBAAc;AACd;;IAIN,CAAC,UAAU,aAAa,CACzB;CAGD,MAAM,YAAY,cAAc;AAC9B,MAAI,mBAAoB,QAAO;AAE/B,MAAI,iBAAiB;AACnB,OAAI,OAAO,oBAAoB,WAC7B,QACE,oBAAC;IACC,eAAY;IACZ,WAAW,GAAG,OAAO,WAAW,YAAY,UAAU;IACtD,OAAO,cAAc;cAEpB,gBAAgB;KAAE,YAAY;KAAU;KAAQ,CAAC;KAC7C;AAGX,UACE,oBAAC;IACC,eAAY;IACZ,WAAW,GAAG,OAAO,WAAW,YAAY,UAAU;IACtD,OAAO,cAAc;cAEpB;KACI;;AAIX,SACE,oBAAC;GACC,eAAY;GACZ,W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ACA;EACA;EACA;EACD,CAAC;AAEF,QACE,qBAAC;EACC,WAAW,GAAG,kBAAkB,OAAO,MAAM,YAAY,KAAK;EAC9D,OAAO,cAAc;aAEpB,eACA;GACG;EAGX;AAED,cAAc,cAAc;AAE5B,4BAAe"}
1
+ {"version":3,"file":"AccordionItem.mjs","names":["ArrowIcon","Text","Flexbox","Block"],"sources":["../../src/Accordion/AccordionItem.tsx"],"sourcesContent":["'use client';\n\nimport { KeyboardEvent, memo, use, useCallback, useMemo } from 'react';\n\nimport Block from '@/Block';\nimport { Flexbox } from '@/Flex';\nimport { MotionComponent } from '@/MotionProvider';\nimport Text from '@/Text';\n\nimport ArrowIcon from './ArrowIcon';\nimport { useAccordionContext } from './context';\nimport { useStyles } from './style';\nimport type { AccordionItemProps } from './type';\n\nconst AccordionItem = memo<AccordionItemProps>(\n ({\n itemKey,\n title,\n children,\n action,\n disabled = false,\n hideIndicator: itemHideIndicator,\n indicatorPlacement: itemIndicatorPlacement,\n indicator: customIndicator,\n classNames,\n paddingInline = 16,\n paddingBlock = 8,\n padding,\n ref,\n variant: customVariant,\n styles: customStyles,\n headerWrapper,\n }) => {\n const { cx, styles } = useStyles();\n const context = useAccordionContext();\n\n const {\n isExpanded,\n onToggle,\n hideIndicator: contextHideIndicator,\n indicatorPlacement: contextIndicatorPlacement,\n keepContentMounted,\n disableAnimation,\n motionProps: contextMotionProps,\n variant = 'filled',\n } = context;\n\n const isOpen = isExpanded(itemKey);\n const hideIndicatorFinal = itemHideIndicator ?? contextHideIndicator ?? false;\n const indicatorPlacementFinal = itemIndicatorPlacement ?? contextIndicatorPlacement ?? 'start';\n\n const handleToggle = useCallback(() => {\n if (!disabled) {\n onToggle(itemKey);\n }\n }, [disabled, itemKey, onToggle]);\n\n const handleKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (disabled) return;\n\n switch (e.key) {\n case 'Enter':\n case ' ': {\n e.preventDefault();\n handleToggle();\n break;\n }\n }\n },\n [disabled, handleToggle],\n );\n\n // Build indicator\n const indicator = useMemo(() => {\n if (hideIndicatorFinal) return null;\n\n if (customIndicator) {\n if (typeof customIndicator === 'function') {\n return (\n <span\n aria-hidden=\"true\"\n className={cx(styles.indicator, classNames?.indicator)}\n style={customStyles?.indicator}\n >\n {customIndicator({ isDisabled: disabled, isOpen })}\n </span>\n );\n }\n return (\n <span\n aria-hidden=\"true\"\n className={cx(styles.indicator, classNames?.indicator)}\n style={customStyles?.indicator}\n >\n {customIndicator}\n </span>\n );\n }\n\n return (\n <span\n aria-hidden=\"true\"\n className={cx(styles.indicator, classNames?.indicator)}\n style={customStyles?.indicator}\n >\n <ArrowIcon className={cx(styles.icon, isOpen && styles.iconRotate)} />\n </span>\n );\n }, [\n hideIndicatorFinal,\n customIndicator,\n disabled,\n isOpen,\n cx,\n styles,\n classNames,\n customStyles,\n ]);\n\n // Animation variants\n const motionProps = useMemo(\n () => ({\n animate: isOpen ? 'enter' : 'exit',\n exit: 'exit',\n initial: false,\n variants: {\n enter: {\n height: 'auto',\n opacity: 1,\n transition: {\n duration: 0.2,\n ease: [0.4, 0, 0.2, 1],\n },\n },\n exit: {\n height: 0,\n opacity: 0,\n transition: {\n duration: 0.2,\n ease: [0.4, 0, 0.2, 1],\n },\n },\n },\n ...contextMotionProps,\n }),\n [isOpen, contextMotionProps],\n );\n\n const m = use(MotionComponent);\n\n // Render content\n const contentElement = useMemo(() => {\n if (disableAnimation || !keepContentMounted) {\n if (keepContentMounted) {\n return (\n <div\n className={cx('accordion-content', styles.content, classNames?.content)}\n role=\"region\"\n style={{\n display: isOpen ? 'block' : 'none',\n ...customStyles?.content,\n }}\n >\n <div className={styles.contentInner}>{children}</div>\n </div>\n );\n }\n\n return (\n isOpen && (\n <div\n className={cx('accordion-content', styles.content, classNames?.content)}\n role=\"region\"\n style={customStyles?.content}\n >\n <div className={styles.contentInner}>{children}</div>\n </div>\n )\n );\n }\n\n return (\n <m.div {...motionProps} style={{ overflow: 'hidden' }}>\n <div\n className={cx('accordion-content', styles.content, classNames?.content)}\n role=\"region\"\n style={customStyles?.content}\n >\n <div className={styles.contentInner}>{children}</div>\n </div>\n </m.div>\n );\n }, [\n disableAnimation,\n keepContentMounted,\n isOpen,\n cx,\n styles,\n classNames,\n customStyles,\n children,\n motionProps,\n ]);\n\n const titleNode = useMemo(\n () =>\n typeof title === 'string' ? (\n <Text className={classNames?.title} ellipsis style={customStyles?.title}>\n {title}\n </Text>\n ) : (\n title\n ),\n [title, classNames?.title, customStyles?.title],\n );\n\n const actionNode = useMemo(\n () =>\n action && (\n <Flexbox\n align={'center'}\n className={cx('accordion-action', styles.action, classNames?.action)}\n flex={'none'}\n gap={4}\n horizontal\n onClick={(e) => e.stopPropagation()}\n style={customStyles?.action}\n >\n {action}\n </Flexbox>\n ),\n [action, cx, styles, classNames?.action, customStyles?.action],\n );\n\n const headerElement = useMemo(() => {\n const header = (\n <Block\n className={cx('accordion-header', styles.header, classNames?.header)}\n clickable={!disabled}\n gap={4}\n horizontal\n justify={'space-between'}\n onClick={handleToggle}\n onKeyDown={handleKeyDown}\n padding={padding}\n paddingBlock={paddingBlock}\n paddingInline={paddingInline}\n ref={ref}\n style={{\n alignItems: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.5 : undefined,\n overflow: 'hidden',\n width: '100%',\n ...customStyles?.header,\n }}\n variant={customVariant || variant}\n >\n {indicatorPlacementFinal === 'start' ? (\n <>\n <Flexbox\n align={'center'}\n flex={1}\n gap={2}\n horizontal\n style={{\n overflow: 'hidden',\n }}\n >\n {titleNode}\n {indicator}\n </Flexbox>\n <Flexbox align={'center'} flex={'none'} gap={4} horizontal>\n {actionNode}\n </Flexbox>\n </>\n ) : (\n <>\n <Flexbox\n align={'center'}\n flex={1}\n gap={2}\n horizontal\n style={{\n overflow: 'hidden',\n }}\n >\n {titleNode}\n </Flexbox>\n <Flexbox align={'center'} flex={'none'} gap={4} horizontal>\n {actionNode}\n {indicator}\n </Flexbox>\n </>\n )}\n </Block>\n );\n if (headerWrapper) {\n return headerWrapper(header);\n }\n return header;\n }, [\n cx,\n styles,\n classNames,\n disabled,\n handleToggle,\n handleKeyDown,\n padding,\n paddingBlock,\n paddingInline,\n ref,\n customVariant,\n variant,\n indicatorPlacementFinal,\n titleNode,\n indicator,\n actionNode,\n headerWrapper,\n ]);\n\n return (\n <div\n className={cx('accordion-item', styles.item, classNames?.base)}\n style={customStyles?.base}\n >\n {headerElement}\n {contentElement}\n </div>\n );\n },\n);\n\nAccordionItem.displayName = 'AccordionItem';\n\nexport default AccordionItem;\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,gBAAgB,MACnB,EACC,SACA,OACA,UACA,QACA,WAAW,OACX,eAAe,mBACf,oBAAoB,wBACpB,WAAW,iBACX,YACA,gBAAgB,IAChB,eAAe,GACf,SACA,KACA,SAAS,eACT,QAAQ,cACR,oBACI;CACJ,MAAM,EAAE,IAAI,WAAW,WAAW;CAGlC,MAAM,EACJ,YACA,UACA,eAAe,sBACf,oBAAoB,2BACpB,oBACA,kBACA,aAAa,oBACb,UAAU,aAVI,qBAAqB;CAarC,MAAM,SAAS,WAAW,QAAQ;CAClC,MAAM,qBAAqB,qBAAqB,wBAAwB;CACxE,MAAM,0BAA0B,0BAA0B,6BAA6B;CAEvF,MAAM,eAAe,kBAAkB;AACrC,MAAI,CAAC,SACH,UAAS,QAAQ;IAElB;EAAC;EAAU;EAAS;EAAS,CAAC;CAEjC,MAAM,gBAAgB,aACnB,MAAqB;AACpB,MAAI,SAAU;AAEd,UAAQ,EAAE,KAAV;GACE,KAAK;GACL,KAAK;AACH,MAAE,gBAAgB;AAClB,kBAAc;AACd;;IAIN,CAAC,UAAU,aAAa,CACzB;CAGD,MAAM,YAAY,cAAc;AAC9B,MAAI,mBAAoB,QAAO;AAE/B,MAAI,iBAAiB;AACnB,OAAI,OAAO,oBAAoB,WAC7B,QACE,oBAAC;IACC,eAAY;IACZ,WAAW,GAAG,OAAO,WAAW,YAAY,UAAU;IACtD,OAAO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A;KACO,EACV,qBAACA;IAAQ,OAAO;IAAU,MAAM;IAAQ,KAAK;IAAG;eAC7C,YACA;KACO,IACT;IAEC;AAEV,MAAI,cACF,QAAO,cAAc,OAAO;AAE9B,SAAO;IACN;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QACE,qBAAC;EACC,WAAW,GAAG,kBAAkB,OAAO,MAAM,YAAY,KAAK;EAC9D,OAAO,cAAc;aAEpB,eACA;GACG;EAGX;AAED,cAAc,cAAc;AAE5B,4BAAe"}
@@ -1,8 +1,8 @@
1
1
  import { ActionIconProps } from "./type.mjs";
2
- import * as react59 from "react";
2
+ import * as react5 from "react";
3
3
 
4
4
  //#region src/ActionIcon/ActionIcon.d.ts
5
- declare const ActionIcon: react59.NamedExoticComponent<ActionIconProps>;
5
+ declare const ActionIcon: react5.NamedExoticComponent<ActionIconProps>;
6
6
  //#endregion
7
7
  export { ActionIcon };
8
8
  //# sourceMappingURL=ActionIcon.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { AlertProps } from "./type.mjs";
2
- import * as react63 from "react";
2
+ import * as react4 from "react";
3
3
 
4
4
  //#region src/Alert/Alert.d.ts
5
- declare const Alert: react63.NamedExoticComponent<AlertProps>;
5
+ declare const Alert: react4.NamedExoticComponent<AlertProps>;
6
6
  //#endregion
7
7
  export { Alert };
8
8
  //# sourceMappingURL=Alert.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { AutoCompleteProps } from "./type.mjs";
2
- import * as react58 from "react";
2
+ import * as react3 from "react";
3
3
 
4
4
  //#region src/AutoComplete/Select.d.ts
5
- declare const AutoComplete: react58.NamedExoticComponent<AutoCompleteProps>;
5
+ declare const AutoComplete: react3.NamedExoticComponent<AutoCompleteProps>;
6
6
  //#endregion
7
7
  export { AutoComplete };
8
8
  //# sourceMappingURL=Select.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { AvatarGroupProps } from "../type.mjs";
2
- import * as react26 from "react";
2
+ import * as react60 from "react";
3
3
 
4
4
  //#region src/Avatar/AvatarGroup/index.d.ts
5
- declare const AvatarGroup: react26.NamedExoticComponent<AvatarGroupProps>;
5
+ declare const AvatarGroup: react60.NamedExoticComponent<AvatarGroupProps>;
6
6
  //#endregion
7
7
  export { AvatarGroup };
8
8
  //# sourceMappingURL=index.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { BurgerProps } from "./type.mjs";
2
- import * as react20 from "react";
2
+ import * as react59 from "react";
3
3
 
4
4
  //#region src/Burger/Burger.d.ts
5
- declare const Burger: react20.NamedExoticComponent<BurgerProps>;
5
+ declare const Burger: react59.NamedExoticComponent<BurgerProps>;
6
6
  //#endregion
7
7
  export { Burger };
8
8
  //# sourceMappingURL=Burger.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { CodeEditorProps } from "./type.mjs";
2
- import * as react19 from "react";
2
+ import * as react57 from "react";
3
3
 
4
4
  //#region src/CodeEditor/CodeEditor.d.ts
5
- declare const CodeEditor: react19.NamedExoticComponent<CodeEditorProps>;
5
+ declare const CodeEditor: react57.NamedExoticComponent<CodeEditorProps>;
6
6
  //#endregion
7
7
  export { CodeEditor };
8
8
  //# sourceMappingURL=CodeEditor.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { CollapseProps } from "./type.mjs";
2
- import * as react18 from "react";
2
+ import * as react58 from "react";
3
3
 
4
4
  //#region src/Collapse/Collapse.d.ts
5
- declare const Collapse: react18.NamedExoticComponent<CollapseProps>;
5
+ declare const Collapse: react58.NamedExoticComponent<CollapseProps>;
6
6
  //#endregion
7
7
  export { Collapse };
8
8
  //# sourceMappingURL=Collapse.d.mts.map
@@ -1,5 +1,7 @@
1
+ import { MotionComponentType } from "../MotionProvider/index.mjs";
2
+ import { TranslationResourcesInput } from "../i18n/types.mjs";
1
3
  import { CDN, CdnApi } from "../utils/genCdnUrl.mjs";
2
- import * as react65 from "react";
4
+ import * as react66 from "react";
3
5
  import { ElementType, ReactNode } from "react";
4
6
 
5
7
  //#region src/ConfigProvider/index.d.ts
@@ -10,10 +12,14 @@ interface Config {
10
12
  imgUnoptimized?: boolean;
11
13
  proxy?: CDN | 'custom';
12
14
  }
13
- declare const ConfigProvider: react65.NamedExoticComponent<{
15
+ interface ConfigProviderProps {
14
16
  children: ReactNode;
15
- config: Config;
16
- }>;
17
+ config?: Config;
18
+ locale?: string;
19
+ motion: MotionComponentType;
20
+ resources?: TranslationResourcesInput;
21
+ }
22
+ declare const ConfigProvider: react66.NamedExoticComponent<ConfigProviderProps>;
17
23
  type CdnFn = ({
18
24
  pkg,
19
25
  version,
@@ -1,15 +1,62 @@
1
1
  'use client';
2
2
 
3
+ import { MotionComponent } from "../MotionProvider/index.mjs";
3
4
  import { genCdnUrl } from "../utils/genCdnUrl.mjs";
4
- import { createContext, memo, use } from "react";
5
+ import { createContext, memo, use, useEffect, useMemo, useRef, useState } from "react";
5
6
  import { jsx } from "react/jsx-runtime";
6
7
 
7
8
  //#region src/ConfigProvider/index.tsx
8
9
  const ConfigContext = createContext(null);
9
- const ConfigProvider = memo(({ children, config }) => {
10
- return /* @__PURE__ */ jsx(ConfigContext, {
11
- value: config,
12
- children
10
+ const I18nContextInternal = createContext({
11
+ locale: "en",
12
+ t: (key) => key
13
+ });
14
+ const isThenable = (value) => typeof value?.then === "function";
15
+ const ConfigProvider = memo(({ children, config, locale, resources, motion }) => {
16
+ const fallbackLocale = locale ?? "en";
17
+ const [resolvedResources, setResolvedResources] = useState(() => resources && !isThenable(resources) ? resources : void 0);
18
+ const [resolvedLocale, setResolvedLocale] = useState(fallbackLocale);
19
+ const latestRequestId = useRef(0);
20
+ useEffect(() => {
21
+ const requestId = ++latestRequestId.current;
22
+ if (!resources) {
23
+ setResolvedResources(void 0);
24
+ setResolvedLocale(fallbackLocale);
25
+ return;
26
+ }
27
+ if (isThenable(resources)) {
28
+ const targetLocale = fallbackLocale;
29
+ resources.then((nextResources) => {
30
+ if (latestRequestId.current !== requestId) return;
31
+ setResolvedResources(nextResources);
32
+ setResolvedLocale(targetLocale);
33
+ }).catch(() => {
34
+ if (latestRequestId.current !== requestId) return;
35
+ });
36
+ return;
37
+ }
38
+ setResolvedResources(resources);
39
+ setResolvedLocale(fallbackLocale);
40
+ }, [fallbackLocale, resources]);
41
+ const currentResources = isThenable(resources) ? resolvedResources : resources;
42
+ const currentLocale = isThenable(resources) ? resolvedLocale : fallbackLocale;
43
+ return /* @__PURE__ */ jsx(I18nContextInternal, {
44
+ value: useMemo(() => {
45
+ const resourceList = Array.isArray(currentResources) ? currentResources : currentResources ? Object.values(currentResources) : [];
46
+ const mergedResources = Object.assign({}, ...resourceList);
47
+ const t = (key) => mergedResources[key] || key;
48
+ return {
49
+ locale: currentLocale,
50
+ t
51
+ };
52
+ }, [currentLocale, currentResources]),
53
+ children: /* @__PURE__ */ jsx(ConfigContext, {
54
+ value: config ?? null,
55
+ children: /* @__PURE__ */ jsx(MotionComponent, {
56
+ value: motion,
57
+ children
58
+ })
59
+ })
13
60
  });
14
61
  });
15
62
  const cdnFallback = ({ pkg, version, path }) => genCdnUrl({
@@ -29,8 +76,9 @@ const useCdnFn = () => {
29
76
  });
30
77
  return config?.customCdnFn || cdnFallback;
31
78
  };
79
+ const useI18n = () => use(I18nContextInternal);
32
80
  var ConfigProvider_default = ConfigProvider;
33
81
 
34
82
  //#endregion
35
- export { ConfigContext, ConfigProvider_default as default, useCdnFn };
83
+ export { ConfigContext, I18nContextInternal, ConfigProvider_default as default, useCdnFn, useI18n };
36
84
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["cdnFallback: CdnFn"],"sources":["../../src/ConfigProvider/index.tsx"],"sourcesContent":["'use client';\n\nimport { ElementType, ReactNode, createContext, memo, use } from 'react';\n\nimport { CDN, CdnApi, genCdnUrl } from '@/utils/genCdnUrl';\n\nexport interface Config {\n aAs?: ElementType;\n customCdnFn?: CdnFn;\n imgAs?: ElementType;\n imgUnoptimized?: boolean;\n proxy?: CDN | 'custom';\n}\n\nexport const ConfigContext = createContext<Config | null>(null);\n\nconst ConfigProvider = memo<{ children: ReactNode; config: Config }>(({ children, config }) => {\n return <ConfigContext value={config}>{children}</ConfigContext>;\n});\n\n// useCdnFn\nexport type CdnFn = ({ pkg, version, path }: CdnApi) => string;\n\nconst cdnFallback: CdnFn = ({ pkg, version, path }) =>\n genCdnUrl({ path, pkg, proxy: 'aliyun', version });\n\nexport const useCdnFn = (): CdnFn => {\n const config = use(ConfigContext);\n if (!config) return cdnFallback;\n if (config?.proxy !== 'custom')\n return ({ pkg, version, path }) =>\n genCdnUrl({ path, pkg, proxy: config.proxy as any, version });\n return config?.customCdnFn || cdnFallback;\n};\n\nexport default ConfigProvider;\n"],"mappings":";;;;;;;AAcA,MAAa,gBAAgB,cAA6B,KAAK;AAE/D,MAAM,iBAAiB,MAA+C,EAAE,UAAU,aAAa;AAC7F,QAAO,oBAAC;EAAc,OAAO;EAAS;GAAyB;EAC/D;AAKF,MAAMA,eAAsB,EAAE,KAAK,SAAS,WAC1C,UAAU;CAAE;CAAM;CAAK,OAAO;CAAU;CAAS,CAAC;AAEpD,MAAa,iBAAwB;CACnC,MAAM,SAAS,IAAI,cAAc;AACjC,KAAI,CAAC,OAAQ,QAAO;AACpB,KAAI,QAAQ,UAAU,SACpB,SAAQ,EAAE,KAAK,SAAS,WACtB,UAAU;EAAE;EAAM;EAAK,OAAO,OAAO;EAAc;EAAS,CAAC;AACjE,QAAO,QAAQ,eAAe;;AAGhC,6BAAe"}
1
+ {"version":3,"file":"index.mjs","names":["cdnFallback: CdnFn"],"sources":["../../src/ConfigProvider/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n ElementType,\n ReactNode,\n createContext,\n memo,\n use,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { MotionComponent, type MotionComponentType } from '@/MotionProvider';\nimport type {\n I18nContextValue,\n TranslationKey,\n TranslationResourcesInput,\n TranslationResourcesMap,\n} from '@/i18n/types';\nimport { CDN, CdnApi, genCdnUrl } from '@/utils/genCdnUrl';\n\nexport interface Config {\n aAs?: ElementType;\n customCdnFn?: CdnFn;\n imgAs?: ElementType;\n imgUnoptimized?: boolean;\n proxy?: CDN | 'custom';\n}\n\nexport const ConfigContext = createContext<Config | null>(null);\n\n// Internal i18n context\nconst I18nContextInternal = createContext<I18nContextValue>({\n locale: 'en',\n t: (key: TranslationKey) => key,\n});\n\nexport interface ConfigProviderProps {\n children: ReactNode;\n config?: Config;\n // i18n props - flattened at top level\n locale?: string;\n motion: MotionComponentType;\n resources?: TranslationResourcesInput;\n}\n\nconst isThenable = (value: unknown): value is Promise<TranslationResourcesMap> =>\n typeof (value as { then?: unknown })?.then === 'function';\n\nconst ConfigProvider = memo<ConfigProviderProps>(\n ({ children, config, locale, resources, motion }) => {\n const fallbackLocale = locale ?? 'en';\n const [resolvedResources, setResolvedResources] = useState<TranslationResourcesMap | undefined>(\n () => (resources && !isThenable(resources) ? resources : undefined),\n );\n const [resolvedLocale, setResolvedLocale] = useState(fallbackLocale);\n const latestRequestId = useRef(0);\n\n useEffect(() => {\n const requestId = ++latestRequestId.current;\n\n if (!resources) {\n setResolvedResources(undefined);\n setResolvedLocale(fallbackLocale);\n return;\n }\n\n if (isThenable(resources)) {\n const targetLocale = fallbackLocale;\n resources\n .then((nextResources) => {\n if (latestRequestId.current !== requestId) return;\n setResolvedResources(nextResources);\n setResolvedLocale(targetLocale);\n })\n .catch(() => {\n if (latestRequestId.current !== requestId) return;\n });\n return;\n }\n\n setResolvedResources(resources);\n setResolvedLocale(fallbackLocale);\n }, [fallbackLocale, resources]);\n\n const currentResources = isThenable(resources) ? resolvedResources : resources;\n const currentLocale = isThenable(resources) ? resolvedLocale : fallbackLocale;\n\n const i18nValue = useMemo((): I18nContextValue => {\n const resourceList = Array.isArray(currentResources)\n ? currentResources\n : currentResources\n ? Object.values(currentResources)\n : [];\n const mergedResources = Object.assign({}, ...resourceList);\n const t = (key: TranslationKey): string => mergedResources[key] || key;\n return { locale: currentLocale, t };\n }, [currentLocale, currentResources]);\n\n return (\n <I18nContextInternal value={i18nValue}>\n <ConfigContext value={config ?? null}>\n <MotionComponent value={motion}>{children}</MotionComponent>\n </ConfigContext>\n </I18nContextInternal>\n );\n },\n);\n\n// useCdnFn\nexport type CdnFn = ({ pkg, version, path }: CdnApi) => string;\n\nconst cdnFallback: CdnFn = ({ pkg, version, path }) =>\n genCdnUrl({ path, pkg, proxy: 'aliyun', version });\n\nexport const useCdnFn = (): CdnFn => {\n const config = use(ConfigContext);\n if (!config) return cdnFallback;\n if (config?.proxy !== 'custom')\n return ({ pkg, version, path }) =>\n genCdnUrl({ path, pkg, proxy: config.proxy as any, version });\n return config?.customCdnFn || cdnFallback;\n};\n\n// useI18n hook\nexport const useI18n = () => use(I18nContextInternal);\n\n// Export I18nContext for external reference\nexport { I18nContextInternal as I18nContext };\n\nexport default ConfigProvider;\n"],"mappings":";;;;;;;;AA+BA,MAAa,gBAAgB,cAA6B,KAAK;AAG/D,MAAM,sBAAsB,cAAgC;CAC1D,QAAQ;CACR,IAAI,QAAwB;CAC7B,CAAC;AAWF,MAAM,cAAc,UAClB,OAAQ,OAA8B,SAAS;AAEjD,MAAM,iBAAiB,MACpB,EAAE,UAAU,QAAQ,QAAQ,WAAW,aAAa;CACnD,MAAM,iBAAiB,UAAU;CACjC,MAAM,CAAC,mBAAmB,wBAAwB,eACzC,aAAa,CAAC,WAAW,UAAU,GAAG,YAAY,OAC1D;CACD,MAAM,CAAC,gBAAgB,qBAAqB,SAAS,eAAe;CACpE,MAAM,kBAAkB,OAAO,EAAE;AAEjC,iBAAgB;EACd,MAAM,YAAY,EAAE,gBAAgB;AAEpC,MAAI,CAAC,WAAW;AACd,wBAAqB,OAAU;AAC/B,qBAAkB,eAAe;AACjC;;AAGF,MAAI,WAAW,UAAU,EAAE;GACzB,MAAM,eAAe;AACrB,aACG,MAAM,kBAAkB;AACvB,QAAI,gBAAgB,YAAY,UAAW;AAC3C,yBAAqB,cAAc;AACnC,sBAAkB,aAAa;KAC/B,CACD,YAAY;AACX,QAAI,gBAAgB,YAAY,UAAW;KAC3C;AACJ;;AAGF,uBAAqB,UAAU;AAC/B,oBAAkB,eAAe;IAChC,CAAC,gBAAgB,UAAU,CAAC;CAE/B,MAAM,mBAAmB,WAAW,UAAU,GAAG,oBAAoB;CACrE,MAAM,gBAAgB,WAAW,UAAU,GAAG,iBAAiB;AAa/D,QACE,oBAAC;EAAoB,OAZL,cAAgC;GAChD,MAAM,eAAe,MAAM,QAAQ,iBAAiB,GAChD,mBACA,mBACE,OAAO,OAAO,iBAAiB,GAC/B,EAAE;GACR,MAAM,kBAAkB,OAAO,OAAO,EAAE,EAAE,GAAG,aAAa;GAC1D,MAAM,KAAK,QAAgC,gBAAgB,QAAQ;AACnE,UAAO;IAAE,QAAQ;IAAe;IAAG;KAClC,CAAC,eAAe,iBAAiB,CAAC;YAIjC,oBAAC;GAAc,OAAO,UAAU;aAC9B,oBAAC;IAAgB,OAAO;IAAS;KAA2B;IAC9C;GACI;EAG3B;AAKD,MAAMA,eAAsB,EAAE,KAAK,SAAS,WAC1C,UAAU;CAAE;CAAM;CAAK,OAAO;CAAU;CAAS,CAAC;AAEpD,MAAa,iBAAwB;CACnC,MAAM,SAAS,IAAI,cAAc;AACjC,KAAI,CAAC,OAAQ,QAAO;AACpB,KAAI,QAAQ,UAAU,SACpB,SAAQ,EAAE,KAAK,SAAS,WACtB,UAAU;EAAE;EAAM;EAAK,OAAO,OAAO;EAAc;EAAS,CAAC;AACjE,QAAO,QAAQ,eAAe;;AAIhC,MAAa,gBAAgB,IAAI,oBAAoB;AAKrD,6BAAe"}
@@ -1,8 +1,8 @@
1
1
  import { CopyButtonProps } from "./type.mjs";
2
- import * as react17 from "react";
2
+ import * as react56 from "react";
3
3
 
4
4
  //#region src/CopyButton/CopyButton.d.ts
5
- declare const CopyButton: react17.NamedExoticComponent<CopyButtonProps>;
5
+ declare const CopyButton: react56.NamedExoticComponent<CopyButtonProps>;
6
6
  //#endregion
7
7
  export { CopyButton };
8
8
  //# sourceMappingURL=CopyButton.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { DatePickerProps } from "./type.mjs";
2
- import * as react16 from "react";
2
+ import * as react2 from "react";
3
3
 
4
4
  //#region src/DatePicker/DatePicker.d.ts
5
- declare const DatePicker: react16.NamedExoticComponent<DatePickerProps>;
5
+ declare const DatePicker: react2.NamedExoticComponent<DatePickerProps>;
6
6
  //#endregion
7
7
  export { DatePicker };
8
8
  //# sourceMappingURL=DatePicker.d.mts.map
@@ -1,9 +1,9 @@
1
1
  import { DivProps } from "../../types/index.mjs";
2
- import * as react10 from "react";
2
+ import * as react61 from "react";
3
3
 
4
4
  //#region src/DraggablePanel/components/DraggablePanelBody.d.ts
5
5
  type DraggablePanelBodyProps = DivProps;
6
- declare const DraggablePanelBody: react10.NamedExoticComponent<DivProps>;
6
+ declare const DraggablePanelBody: react61.NamedExoticComponent<DivProps>;
7
7
  //#endregion
8
8
  export { DraggablePanelBody, DraggablePanelBodyProps };
9
9
  //# sourceMappingURL=DraggablePanelBody.d.mts.map
@@ -1,9 +1,9 @@
1
1
  import { DivProps } from "../../types/index.mjs";
2
- import * as react11 from "react";
2
+ import * as react63 from "react";
3
3
 
4
4
  //#region src/DraggablePanel/components/DraggablePanelContainer.d.ts
5
5
  type DraggablePanelContainerProps = DivProps;
6
- declare const DraggablePanelContainer: react11.NamedExoticComponent<DivProps>;
6
+ declare const DraggablePanelContainer: react63.NamedExoticComponent<DivProps>;
7
7
  //#endregion
8
8
  export { DraggablePanelContainer, DraggablePanelContainerProps };
9
9
  //# sourceMappingURL=DraggablePanelContainer.d.mts.map
@@ -1,9 +1,9 @@
1
1
  import { DivProps } from "../../types/index.mjs";
2
- import * as react12 from "react";
2
+ import * as react64 from "react";
3
3
 
4
4
  //#region src/DraggablePanel/components/DraggablePanelFooter.d.ts
5
5
  type DraggablePanelFooterProps = DivProps;
6
- declare const DraggablePanelFooter: react12.NamedExoticComponent<DivProps>;
6
+ declare const DraggablePanelFooter: react64.NamedExoticComponent<DivProps>;
7
7
  //#endregion
8
8
  export { DraggablePanelFooter, DraggablePanelFooterProps };
9
9
  //# sourceMappingURL=DraggablePanelFooter.d.mts.map
@@ -1,5 +1,5 @@
1
1
  import { DivProps } from "../../types/index.mjs";
2
- import * as react13 from "react";
2
+ import * as react62 from "react";
3
3
 
4
4
  //#region src/DraggablePanel/components/DraggablePanelHeader.d.ts
5
5
  interface DraggablePanelHeaderProps extends Omit<DivProps, 'children'> {
@@ -9,7 +9,7 @@ interface DraggablePanelHeaderProps extends Omit<DivProps, 'children'> {
9
9
  setPin?: (pin: boolean) => void;
10
10
  title?: string;
11
11
  }
12
- declare const DraggablePanelHeader: react13.NamedExoticComponent<DraggablePanelHeaderProps>;
12
+ declare const DraggablePanelHeader: react62.NamedExoticComponent<DraggablePanelHeaderProps>;
13
13
  //#endregion
14
14
  export { DraggablePanelHeader, DraggablePanelHeaderProps };
15
15
  //# sourceMappingURL=DraggablePanelHeader.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { DraggableSideNavProps } from "./type.mjs";
2
- import * as react15 from "react";
2
+ import * as react55 from "react";
3
3
 
4
4
  //#region src/DraggableSideNav/DraggableSideNav.d.ts
5
- declare const DraggableSideNav: react15.NamedExoticComponent<DraggableSideNavProps>;
5
+ declare const DraggableSideNav: react55.NamedExoticComponent<DraggableSideNavProps>;
6
6
  //#endregion
7
7
  export { DraggableSideNav };
8
8
  //# sourceMappingURL=DraggableSideNav.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { DrawerProps } from "./type.mjs";
2
- import * as react14 from "react";
2
+ import * as react1 from "react";
3
3
 
4
4
  //#region src/Drawer/Drawer.d.ts
5
- declare const Drawer: react14.NamedExoticComponent<DrawerProps>;
5
+ declare const Drawer: react1.NamedExoticComponent<DrawerProps>;
6
6
  //#endregion
7
7
  export { Drawer };
8
8
  //# sourceMappingURL=Drawer.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { DropdownProps } from "./type.mjs";
2
- import * as react9 from "react";
2
+ import * as react0 from "react";
3
3
 
4
4
  //#region src/Dropdown/Dropdown.d.ts
5
- declare const Dropdown: react9.NamedExoticComponent<DropdownProps>;
5
+ declare const Dropdown: react0.NamedExoticComponent<DropdownProps>;
6
6
  //#endregion
7
7
  export { Dropdown };
8
8
  //# sourceMappingURL=Dropdown.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { EditableTextProps } from "./type.mjs";
2
- import * as react7 from "react";
2
+ import * as react45 from "react";
3
3
 
4
4
  //#region src/EditableText/EditableText.d.ts
5
- declare const EditableText: react7.NamedExoticComponent<EditableTextProps>;
5
+ declare const EditableText: react45.NamedExoticComponent<EditableTextProps>;
6
6
  //#endregion
7
7
  export { EditableText };
8
8
  //# sourceMappingURL=EditableText.d.mts.map
@@ -5,6 +5,8 @@ import Center_default from "../Flex/Center.mjs";
5
5
  import Icon_default from "../Icon/Icon.mjs";
6
6
  import Text_default from "../Text/Text.mjs";
7
7
  import Button_default from "../Button/Button.mjs";
8
+ import emojiPicker_default from "../i18n/resources/en/emojiPicker.mjs";
9
+ import { useTranslation } from "../i18n/useTranslation.mjs";
8
10
  import Tag_default from "../Tag/Tag.mjs";
9
11
  import { memo, useCallback, useRef, useState } from "react";
10
12
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -26,15 +28,19 @@ const AvatarUploader = memo(({ shape, onChange, texts, compressSize = 256, onUpl
26
28
  const editor = useRef(null);
27
29
  const [previewImage, setPreviewImage] = useState("");
28
30
  const theme = useTheme();
31
+ const { t } = useTranslation(emojiPicker_default);
32
+ const fileTypeErrorText = texts?.fileTypeError ?? t("emojiPicker.fileTypeError");
33
+ const draggerDescText = texts?.draggerDesc ?? t("emojiPicker.draggerDesc");
34
+ const uploadBtnText = texts?.uploadBtn ?? t("emojiPicker.uploadBtn");
29
35
  const beforeUpload = useCallback((file) => {
30
36
  if (!(file.type === "image/jpeg" || file.type === "image/png" || file.type === "image/gif" || file.type === "image/webp")) {
31
- message.error(texts?.fileTypeError || "You can only upload image file!");
37
+ message.error(fileTypeErrorText);
32
38
  return;
33
39
  }
34
40
  return createUploadImageHandler((avatar) => {
35
41
  setPreviewImage(avatar);
36
42
  })(file);
37
- }, []);
43
+ }, [fileTypeErrorText]);
38
44
  const handleUpload = () => {
39
45
  if (!editor.current) return;
40
46
  const canvasScaled = editor.current.getImageScaledToCanvas();
@@ -66,7 +72,7 @@ const AvatarUploader = memo(({ shape, onChange, texts, compressSize = 256, onUpl
66
72
  }),
67
73
  /* @__PURE__ */ jsx(Text_default, {
68
74
  color: theme.colorTextSecondary,
69
- children: texts?.draggerDesc || "Click or Drag image to this area to upload"
75
+ children: draggerDescText
70
76
  }),
71
77
  /* @__PURE__ */ jsxs(Center_default, {
72
78
  gap: 4,
@@ -107,7 +113,7 @@ const AvatarUploader = memo(({ shape, onChange, texts, compressSize = 256, onUpl
107
113
  fontWeight: 500
108
114
  },
109
115
  type: "primary",
110
- children: texts?.uploadBtn || "Crop and Upload"
116
+ children: uploadBtnText
111
117
  })]
112
118
  })]
113
119
  })]
@@ -1 +1 @@
1
- {"version":3,"file":"AvatarUploader.mjs","names":["Flexbox","Center","Icon","Text","Tag","Button"],"sources":["../../src/EmojiPicker/AvatarUploader.tsx"],"sourcesContent":["'use client';\n\nimport { type GetProp, Upload, type UploadProps, message } from 'antd';\nimport { useTheme } from 'antd-style';\nimport { ChevronLeftIcon, ImageUpIcon } from 'lucide-react';\nimport { memo, useCallback, useRef, useState } from 'react';\nimport AvatarEditor from 'react-avatar-editor';\n\nimport Button from '@/Button';\nimport { Center, Flexbox } from '@/Flex';\nimport Icon from '@/Icon';\nimport Tag from '@/Tag';\nimport Text from '@/Text';\n\nimport { AvatarUploaderProps } from './type';\n\ntype FileType = Parameters<GetProp<UploadProps, 'beforeUpload'>>[0];\n\nconst { Dragger } = Upload;\n\nconst createUploadImageHandler = (onUploadImage: (base64: string) => void) => (file: any) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.addEventListener('load', () => {\n onUploadImage(String(reader.result));\n });\n};\n\nconst AvatarUploader = memo<AvatarUploaderProps>(\n ({ shape, onChange, texts, compressSize = 256, onUpload }) => {\n const editor = useRef<any>(null);\n const [previewImage, setPreviewImage] = useState('');\n const theme = useTheme();\n\n const beforeUpload = useCallback((file: FileType) => {\n const isJpgOrPng =\n file.type === 'image/jpeg' ||\n file.type === 'image/png' ||\n file.type === 'image/gif' ||\n file.type === 'image/webp';\n if (!isJpgOrPng) {\n message.error(texts?.fileTypeError || 'You can only upload image file!');\n return;\n }\n return createUploadImageHandler((avatar) => {\n setPreviewImage(avatar);\n })(file);\n }, []);\n\n const handleUpload = () => {\n if (!editor.current) return;\n const canvasScaled = editor.current.getImageScaledToCanvas() as HTMLCanvasElement;\n const dataUrl = canvasScaled.toDataURL();\n onChange(dataUrl);\n\n if (!onUpload) return;\n\n // 使用 toBlob 直接获取 Blob,然后创建 File 对象\n canvasScaled.toBlob(\n (blob) => {\n if (blob) {\n const file = new File([blob], 'avatar.webp', { type: 'image/webp' });\n onUpload(file);\n }\n },\n 'image/webp',\n 0.95,\n ); // 0.95 是图片质量\n };\n\n return (\n <Flexbox padding={10} style={{ position: 'relative' }} width={'100%'}>\n {!previewImage && (\n <Dragger\n accept={'image'}\n beforeUpload={beforeUpload}\n itemRender={() => void 0}\n maxCount={1}\n multiple={false}\n >\n <Center gap={16} height={compressSize} width={compressSize}>\n <Icon color={theme.colorTextDescription} icon={ImageUpIcon} size={48} />\n <Text color={theme.colorTextSecondary}>\n {texts?.draggerDesc || 'Click or Drag image to this area to upload'}\n </Text>\n <Center gap={4} horizontal>\n <Tag>JPG</Tag>\n <Tag>PNG</Tag>\n <Tag>GIF</Tag>\n <Tag>WEBP</Tag>\n </Center>\n </Center>\n </Dragger>\n )}\n {previewImage && (\n <Center gap={8} style={{ position: 'relative' }} width={'100%'}>\n <AvatarEditor\n border={0}\n borderRadius={shape === 'square' ? undefined : compressSize / 2}\n height={compressSize}\n image={previewImage}\n ref={editor}\n width={compressSize}\n />\n\n <Flexbox gap={8} horizontal style={{ position: 'relative' }} width={'100%'}>\n <Button\n icon={ChevronLeftIcon}\n onClick={() => setPreviewImage('')}\n style={{ flex: 'none' }}\n />\n <Button onClick={handleUpload} style={{ flex: 1, fontWeight: 500 }} type={'primary'}>\n {texts?.uploadBtn || 'Crop and Upload'}\n </Button>\n </Flexbox>\n </Center>\n )}\n </Flexbox>\n );\n },\n);\n\nAvatarUploader.displayName = 'AvatarUploader';\n\nexport default AvatarUploader;\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,EAAE,YAAY;AAEpB,MAAM,4BAA4B,mBAA6C,SAAc;CAC3F,MAAM,SAAS,IAAI,YAAY;AAC/B,QAAO,cAAc,KAAK;AAC1B,QAAO,iBAAiB,cAAc;AACpC,gBAAc,OAAO,OAAO,OAAO,CAAC;GACpC;;AAGJ,MAAM,iBAAiB,MACpB,EAAE,OAAO,UAAU,OAAO,eAAe,KAAK,eAAe;CAC5D,MAAM,SAAS,OAAY,KAAK;CAChC,MAAM,CAAC,cAAc,mBAAmB,SAAS,GAAG;CACpD,MAAM,QAAQ,UAAU;CAExB,MAAM,eAAe,aAAa,SAAmB;AAMnD,MAAI,EAJF,KAAK,SAAS,gBACd,KAAK,SAAS,eACd,KAAK,SAAS,eACd,KAAK,SAAS,eACC;AACf,WAAQ,MAAM,OAAO,iBAAiB,kCAAkC;AACxE;;AAEF,SAAO,0BAA0B,WAAW;AAC1C,mBAAgB,OAAO;IACvB,CAAC,KAAK;IACP,EAAE,CAAC;CAEN,MAAM,qBAAqB;AACzB,MAAI,CAAC,OAAO,QAAS;EACrB,MAAM,eAAe,OAAO,QAAQ,wBAAwB;AAE5D,WADgB,aAAa,WAAW,CACvB;AAEjB,MAAI,CAAC,SAAU;AAGf,eAAa,QACV,SAAS;AACR,OAAI,KAEF,UADa,IAAI,KAAK,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC,CACtD;KAGlB,cACA,IACD;;AAGH,QACE,qBAACA;EAAQ,SAAS;EAAI,OAAO,EAAE,UAAU,YAAY;EAAE,OAAO;aAC3D,CAAC,gBACA,oBAAC;GACC,QAAQ;GACM;GACd,kBAAkB,KAAK;GACvB,UAAU;GACV,UAAU;aAEV,qBAACC;IAAO,KAAK;IAAI,QAAQ;IAAc,OAAO;;KAC5C,oBAACC;MAAK,OAAO,MAAM;MAAsB,MAAM;MAAa,MAAM;OAAM;KACxE,oBAACC;MAAK,OAAO,MAAM;gBAChB,OAAO,eAAe;OAClB;KACP,qBAACF;MAAO,KAAK;MAAG;;OACd,oBAACG,yBAAI,QAAS;OACd,oBAACA,yBAAI,QAAS;OACd,oBAACA,yBAAI,QAAS;OACd,oBAACA,yBAAI,SAAU;;OACR;;KACF;IACD,EAEX,gBACC,qBAACH;GAAO,KAAK;GAAG,OAAO,EAAE,UAAU,YAAY;GAAE,OAAO;cACtD,oBAAC;IACC,QAAQ;IACR,cAAc,UAAU,WAAW,SAAY,eAAe;IAC9D,QAAQ;IACR,OAAO;IACP,KAAK;IACL,OAAO;KACP,EAEF,qBAACD;IAAQ,KAAK;IAAG;IAAW,OAAO,EAAE,UAAU,YAAY;IAAE,OAAO;eAClE,oBAACK;KACC,MAAM;KACN,eAAe,gBAAgB,GAAG;KAClC,OAAO,EAAE,MAAM,QAAQ;MACvB,EACF,oBAACA;KAAO,SAAS;KAAc,OAAO;MAAE,MAAM;MAAG,YAAY;MAAK;KAAE,MAAM;eACvE,OAAO,aAAa;MACd;KACD;IACH;GAEH;EAGf;AAED,eAAe,cAAc;AAE7B,6BAAe"}
1
+ {"version":3,"file":"AvatarUploader.mjs","names":["emojiPickerMessages","Flexbox","Center","Icon","Text","Tag","Button"],"sources":["../../src/EmojiPicker/AvatarUploader.tsx"],"sourcesContent":["'use client';\n\nimport { type GetProp, Upload, type UploadProps, message } from 'antd';\nimport { useTheme } from 'antd-style';\nimport { ChevronLeftIcon, ImageUpIcon } from 'lucide-react';\nimport { memo, useCallback, useRef, useState } from 'react';\nimport AvatarEditor from 'react-avatar-editor';\n\nimport Button from '@/Button';\nimport { Center, Flexbox } from '@/Flex';\nimport Icon from '@/Icon';\nimport Tag from '@/Tag';\nimport Text from '@/Text';\nimport emojiPickerMessages from '@/i18n/resources/en/emojiPicker';\nimport { useTranslation } from '@/i18n/useTranslation';\n\nimport { AvatarUploaderProps } from './type';\n\ntype FileType = Parameters<GetProp<UploadProps, 'beforeUpload'>>[0];\n\nconst { Dragger } = Upload;\n\nconst createUploadImageHandler = (onUploadImage: (base64: string) => void) => (file: any) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.addEventListener('load', () => {\n onUploadImage(String(reader.result));\n });\n};\n\nconst AvatarUploader = memo<AvatarUploaderProps>(\n ({ shape, onChange, texts, compressSize = 256, onUpload }) => {\n const editor = useRef<any>(null);\n const [previewImage, setPreviewImage] = useState('');\n const theme = useTheme();\n const { t } = useTranslation(emojiPickerMessages);\n\n const fileTypeErrorText = texts?.fileTypeError ?? t('emojiPicker.fileTypeError');\n const draggerDescText = texts?.draggerDesc ?? t('emojiPicker.draggerDesc');\n const uploadBtnText = texts?.uploadBtn ?? t('emojiPicker.uploadBtn');\n\n const beforeUpload = useCallback(\n (file: FileType) => {\n const isJpgOrPng =\n file.type === 'image/jpeg' ||\n file.type === 'image/png' ||\n file.type === 'image/gif' ||\n file.type === 'image/webp';\n if (!isJpgOrPng) {\n message.error(fileTypeErrorText);\n return;\n }\n return createUploadImageHandler((avatar) => {\n setPreviewImage(avatar);\n })(file);\n },\n [fileTypeErrorText],\n );\n\n const handleUpload = () => {\n if (!editor.current) return;\n const canvasScaled = editor.current.getImageScaledToCanvas() as HTMLCanvasElement;\n const dataUrl = canvasScaled.toDataURL();\n onChange(dataUrl);\n\n if (!onUpload) return;\n\n // 使用 toBlob 直接获取 Blob,然后创建 File 对象\n canvasScaled.toBlob(\n (blob) => {\n if (blob) {\n const file = new File([blob], 'avatar.webp', { type: 'image/webp' });\n onUpload(file);\n }\n },\n 'image/webp',\n 0.95,\n ); // 0.95 是图片质量\n };\n\n return (\n <Flexbox padding={10} style={{ position: 'relative' }} width={'100%'}>\n {!previewImage && (\n <Dragger\n accept={'image'}\n beforeUpload={beforeUpload}\n itemRender={() => void 0}\n maxCount={1}\n multiple={false}\n >\n <Center gap={16} height={compressSize} width={compressSize}>\n <Icon color={theme.colorTextDescription} icon={ImageUpIcon} size={48} />\n <Text color={theme.colorTextSecondary}>{draggerDescText}</Text>\n <Center gap={4} horizontal>\n <Tag>JPG</Tag>\n <Tag>PNG</Tag>\n <Tag>GIF</Tag>\n <Tag>WEBP</Tag>\n </Center>\n </Center>\n </Dragger>\n )}\n {previewImage && (\n <Center gap={8} style={{ position: 'relative' }} width={'100%'}>\n <AvatarEditor\n border={0}\n borderRadius={shape === 'square' ? undefined : compressSize / 2}\n height={compressSize}\n image={previewImage}\n ref={editor}\n width={compressSize}\n />\n\n <Flexbox gap={8} horizontal style={{ position: 'relative' }} width={'100%'}>\n <Button\n icon={ChevronLeftIcon}\n onClick={() => setPreviewImage('')}\n style={{ flex: 'none' }}\n />\n <Button onClick={handleUpload} style={{ flex: 1, fontWeight: 500 }} type={'primary'}>\n {uploadBtnText}\n </Button>\n </Flexbox>\n </Center>\n )}\n </Flexbox>\n );\n },\n);\n\nAvatarUploader.displayName = 'AvatarUploader';\n\nexport default AvatarUploader;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,MAAM,EAAE,YAAY;AAEpB,MAAM,4BAA4B,mBAA6C,SAAc;CAC3F,MAAM,SAAS,IAAI,YAAY;AAC/B,QAAO,cAAc,KAAK;AAC1B,QAAO,iBAAiB,cAAc;AACpC,gBAAc,OAAO,OAAO,OAAO,CAAC;GACpC;;AAGJ,MAAM,iBAAiB,MACpB,EAAE,OAAO,UAAU,OAAO,eAAe,KAAK,eAAe;CAC5D,MAAM,SAAS,OAAY,KAAK;CAChC,MAAM,CAAC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EAEX,gBACC,qBAACH;GAAO,KAAK;GAAG,OAAO,EAAE,UAAU,YAAY;GAAE,OAAO;cACtD,oBAAC;IACC,QAAQ;IACR,cAAc,UAAU,WAAW,SAAY,eAAe;IAC9D,QAAQ;IACR,OAAO;IACP,KAAK;IACL,OAAO;KACP,EAEF,qBAACD;IAAQ,KAAK;IAAG;IAAW,OAAO,EAAE,UAAU,YAAY;IAAE,OAAO;eAClE,oBAACK;KACC,MAAM;KACN,eAAe,gBAAgB,GAAG;KAClC,OAAO,EAAE,MAAM,QAAQ;MACvB,EACF,oBAACA;KAAO,SAAS;KAAc,OAAO;MAAE,MAAM;MAAG,YAAY;MAAK;KAAE,MAAM;eACvE;MACM;KACD;IACH;GAEH;EAGf;AAED,eAAe,cAAc;AAE7B,6BAAe"}
@@ -1,8 +1,8 @@
1
1
  import { EmojiPickerProps } from "./type.mjs";
2
- import * as react8 from "react";
2
+ import * as react44 from "react";
3
3
 
4
4
  //#region src/EmojiPicker/EmojiPicker.d.ts
5
- declare const EmojiPicker: react8.NamedExoticComponent<EmojiPickerProps>;
5
+ declare const EmojiPicker: react44.NamedExoticComponent<EmojiPickerProps>;
6
6
  //#endregion
7
7
  export { EmojiPicker };
8
8
  //# sourceMappingURL=EmojiPicker.d.mts.map