@lobehub/ui 3.4.5 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/es/Accordion/Accordion.d.mts +2 -2
- package/es/Accordion/AccordionItem.d.mts +2 -2
- package/es/Accordion/AccordionItem.mjs +5 -5
- package/es/Accordion/AccordionItem.mjs.map +1 -1
- package/es/ActionIcon/ActionIcon.d.mts +2 -2
- package/es/Alert/Alert.d.mts +2 -2
- package/es/AutoComplete/Select.d.mts +2 -2
- package/es/Avatar/AvatarGroup/index.d.mts +2 -2
- package/es/Burger/Burger.d.mts +2 -2
- package/es/CodeEditor/CodeEditor.d.mts +2 -2
- package/es/Collapse/Collapse.d.mts +2 -2
- package/es/ConfigProvider/index.d.mts +10 -4
- package/es/ConfigProvider/index.mjs +28 -6
- package/es/ConfigProvider/index.mjs.map +1 -1
- package/es/CopyButton/CopyButton.d.mts +2 -2
- package/es/DatePicker/DatePicker.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelBody.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelContainer.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelFooter.d.mts +2 -2
- package/es/DraggablePanel/components/DraggablePanelHeader.d.mts +2 -2
- package/es/DraggableSideNav/DraggableSideNav.d.mts +2 -2
- package/es/Drawer/Drawer.d.mts +2 -2
- package/es/Dropdown/Dropdown.d.mts +2 -2
- package/es/EditableText/EditableText.d.mts +2 -2
- package/es/EmojiPicker/AvatarUploader.mjs +10 -4
- package/es/EmojiPicker/AvatarUploader.mjs.map +1 -1
- package/es/EmojiPicker/EmojiPicker.d.mts +2 -2
- package/es/EmojiPicker/EmojiPicker.mjs +9 -3
- package/es/EmojiPicker/EmojiPicker.mjs.map +1 -1
- package/es/Flex/FlexBasic.d.mts +2 -2
- package/es/Footer/Footer.d.mts +2 -2
- package/es/Form/components/FormGroup.d.mts +2 -2
- package/es/Form/components/FormItem.d.mts +2 -2
- package/es/Form/components/FormSubmitFooter.d.mts +2 -2
- package/es/Form/components/FormSubmitFooter.mjs +20 -8
- package/es/Form/components/FormSubmitFooter.mjs.map +1 -1
- package/es/FormModal/FormModal.d.mts +2 -2
- package/es/GuideCard/GuideCard.d.mts +2 -2
- package/es/Header/Header.d.mts +2 -2
- package/es/Highlighter/Highlighter.d.mts +2 -2
- package/es/Highlighter/SyntaxHighlighter/index.d.mts +2 -2
- package/es/Hotkey/Hotkey.d.mts +2 -2
- package/es/HotkeyInput/HotkeyInput.d.mts +2 -2
- package/es/HotkeyInput/HotkeyInput.mjs +13 -6
- package/es/HotkeyInput/HotkeyInput.mjs.map +1 -1
- package/es/Icon/Icon.d.mts +2 -2
- package/es/Icon/components/IconProvider.d.mts +3 -3
- package/es/Image/PreviewGroup.d.mts +2 -2
- package/es/ImageSelect/ImageSelect.d.mts +2 -2
- package/es/Input/Input.d.mts +2 -2
- package/es/Input/InputNumber.d.mts +2 -2
- package/es/Input/InputOPT.d.mts +2 -2
- package/es/Input/InputPassword.d.mts +2 -2
- package/es/Input/TextArea.d.mts +2 -2
- package/es/Layout/components/LayoutFooter.d.mts +2 -2
- package/es/Layout/components/LayoutHeader.d.mts +2 -2
- package/es/Layout/components/LayoutMain.d.mts +2 -2
- package/es/Layout/components/LayoutSidebar.d.mts +2 -2
- package/es/Layout/components/LayoutSidebarInner.d.mts +2 -2
- package/es/Layout/components/LayoutToc.d.mts +2 -2
- package/es/List/ListItem/index.d.mts +2 -2
- package/es/Markdown/Markdown.d.mts +2 -2
- package/es/Markdown/Typography.d.mts +2 -2
- package/es/Markdown/components/SearchResultCards/index.d.mts +2 -2
- package/es/MaskShadow/MaskShadow.d.mts +2 -2
- package/es/Menu/Menu.d.mts +2 -2
- package/es/Mermaid/Mermaid.d.mts +2 -2
- package/es/Mermaid/SyntaxMermaid/index.d.mts +2 -2
- package/es/Modal/Modal.d.mts +2 -2
- package/es/MotionProvider/index.d.mts +15 -0
- package/es/MotionProvider/index.d.ts +1 -0
- package/es/MotionProvider/index.js +1 -0
- package/es/MotionProvider/index.mjs +22 -0
- package/es/MotionProvider/index.mjs.map +1 -0
- package/es/Provider.d.mts +2 -0
- package/es/Segmented/Segmented.d.mts +2 -2
- package/es/Select/Select.d.mts +2 -2
- package/es/SideNav/SideNav.d.mts +2 -2
- package/es/SliderWithInput/SliderWithInput.d.mts +2 -2
- package/es/SortableList/components/DragHandle.d.mts +2 -2
- package/es/SortableList/components/SortableItem.d.mts +2 -2
- package/es/ThemeProvider/ThemeProvider.d.mts +2 -2
- package/es/ThemeProvider/ThemeProvider.mjs +11 -4
- package/es/ThemeProvider/ThemeProvider.mjs.map +1 -1
- package/es/ThemeProvider/type.d.mts +4 -0
- package/es/Toc/Toc.d.mts +2 -2
- package/es/Tooltip/Tooltip.mjs +1 -1
- package/es/Tooltip/Tooltip.mjs.map +1 -1
- package/es/Tooltip/TooltipFloating.mjs.map +1 -1
- package/es/Video/index.d.mts +2 -2
- package/es/_virtual/rolldown_runtime.mjs +18 -0
- package/es/awesome/AuroraBackground/AuroraBackground.d.mts +2 -2
- package/es/awesome/BottomGradientButton/BottomGradientButton.d.mts +2 -2
- package/es/awesome/Features/Features.d.mts +2 -2
- package/es/awesome/Giscus/Giscus.d.mts +2 -2
- package/es/awesome/GradientButton/GradientButton.d.mts +2 -2
- package/es/awesome/GridBackground/GridBackground.d.mts +2 -2
- package/es/awesome/GridBackground/GridShowcase.d.mts +2 -2
- package/es/awesome/Hero/Hero.d.mts +2 -2
- package/es/awesome/Spotlight/Spotlight.d.mts +2 -2
- package/es/awesome/SpotlightCard/SpotlightCard.d.mts +2 -2
- package/es/awesome/TypewriterEffect/TypewriterEffect.d.mts +2 -2
- package/es/awesome/TypewriterEffect/TypewriterEffect.mjs +5 -4
- package/es/awesome/TypewriterEffect/TypewriterEffect.mjs.map +1 -1
- package/es/brand/BrandLoading/{style-CB0aumHV.css → style-Cof4dJBw.css} +1 -1
- package/es/brand/BrandLoading/{style-CB0aumHV.css.map → style-Cof4dJBw.css.map} +1 -1
- package/es/brand/LobeChat/index.d.mts +2 -2
- package/es/brand/LobeHub/index.d.mts +2 -2
- package/es/brand/LogoThree/LogoSpline.d.mts +2 -2
- package/es/brand/LogoThree/index.d.mts +2 -2
- package/es/chat/BackBottom/BackBottom.d.mts +2 -2
- package/es/chat/ChatInputArea/components/ChatInputAreaInner.d.mts +2 -2
- package/es/chat/ChatItem/ChatItem.d.mts +2 -2
- package/es/chat/ChatItem/ChatItem.mjs +8 -3
- package/es/chat/ChatItem/ChatItem.mjs.map +1 -1
- package/es/chat/ChatList/ChatList.d.mts +2 -2
- package/es/chat/EditableMessage/EditableMessage.d.mts +2 -2
- package/es/chat/EditableMessageList/EditableMessageList.d.mts +2 -2
- package/es/chat/EditableMessageList/EditableMessageList.mjs +17 -7
- package/es/chat/EditableMessageList/EditableMessageList.mjs.map +1 -1
- package/es/chat/EditableMessageList/type.d.mts +9 -0
- package/es/chat/MessageInput/MessageInput.d.mts +2 -2
- package/es/chat/MessageModal/MessageModal.d.mts +2 -2
- package/es/chat/MessageModal/MessageModal.mjs +27 -22
- package/es/chat/MessageModal/MessageModal.mjs.map +1 -1
- package/es/chat/TokenTag/TokenTag.mjs +7 -1
- package/es/chat/TokenTag/TokenTag.mjs.map +1 -1
- package/es/color/ColorScales/index.d.mts +2 -2
- package/es/i18n/context.d.mts +17 -0
- package/es/i18n/context.mjs +18 -0
- package/es/i18n/context.mjs.map +1 -0
- package/es/i18n/index.d.mts +6 -0
- package/es/i18n/index.d.ts +1 -0
- package/es/i18n/index.js +1 -0
- package/es/i18n/index.mjs +6 -0
- package/es/i18n/resources/en/chat.d.mts +11 -0
- package/es/i18n/resources/en/chat.mjs +12 -0
- package/es/i18n/resources/en/chat.mjs.map +1 -0
- package/es/i18n/resources/en/common.d.mts +10 -0
- package/es/i18n/resources/en/common.mjs +11 -0
- package/es/i18n/resources/en/common.mjs.map +1 -0
- package/es/i18n/resources/en/editableMessage.d.mts +13 -0
- package/es/i18n/resources/en/editableMessage.mjs +14 -0
- package/es/i18n/resources/en/editableMessage.mjs.map +1 -0
- package/es/i18n/resources/en/emojiPicker.d.mts +12 -0
- package/es/i18n/resources/en/emojiPicker.mjs +13 -0
- package/es/i18n/resources/en/emojiPicker.mjs.map +1 -0
- package/es/i18n/resources/en/form.d.mts +10 -0
- package/es/i18n/resources/en/form.mjs +11 -0
- package/es/i18n/resources/en/form.mjs.map +1 -0
- package/es/i18n/resources/en/hotkey.d.mts +10 -0
- package/es/i18n/resources/en/hotkey.mjs +11 -0
- package/es/i18n/resources/en/hotkey.mjs.map +1 -0
- package/es/i18n/resources/en/index.d.mts +16 -0
- package/es/i18n/resources/en/index.mjs +25 -0
- package/es/i18n/resources/en/index.mjs.map +1 -0
- package/es/i18n/resources/en/messageModal.d.mts +9 -0
- package/es/i18n/resources/en/messageModal.mjs +10 -0
- package/es/i18n/resources/en/messageModal.mjs.map +1 -0
- package/es/i18n/resources/en/sideNav.d.mts +21 -0
- package/es/i18n/resources/en/sideNav.mjs +22 -0
- package/es/i18n/resources/en/sideNav.mjs.map +1 -0
- package/es/i18n/resources/index.d.mts +3 -0
- package/es/i18n/resources/index.mjs +4 -0
- package/es/i18n/resources/zhCn/chat.d.mts +11 -0
- package/es/i18n/resources/zhCn/chat.mjs +12 -0
- package/es/i18n/resources/zhCn/chat.mjs.map +1 -0
- package/es/i18n/resources/zhCn/common.d.mts +10 -0
- package/es/i18n/resources/zhCn/common.mjs +11 -0
- package/es/i18n/resources/zhCn/common.mjs.map +1 -0
- package/es/i18n/resources/zhCn/editableMessage.d.mts +13 -0
- package/es/i18n/resources/zhCn/editableMessage.mjs +14 -0
- package/es/i18n/resources/zhCn/editableMessage.mjs.map +1 -0
- package/es/i18n/resources/zhCn/emojiPicker.d.mts +12 -0
- package/es/i18n/resources/zhCn/emojiPicker.mjs +13 -0
- package/es/i18n/resources/zhCn/emojiPicker.mjs.map +1 -0
- package/es/i18n/resources/zhCn/form.d.mts +10 -0
- package/es/i18n/resources/zhCn/form.mjs +11 -0
- package/es/i18n/resources/zhCn/form.mjs.map +1 -0
- package/es/i18n/resources/zhCn/hotkey.d.mts +10 -0
- package/es/i18n/resources/zhCn/hotkey.mjs +11 -0
- package/es/i18n/resources/zhCn/hotkey.mjs.map +1 -0
- package/es/i18n/resources/zhCn/index.d.mts +16 -0
- package/es/i18n/resources/zhCn/index.mjs +25 -0
- package/es/i18n/resources/zhCn/index.mjs.map +1 -0
- package/es/i18n/resources/zhCn/messageModal.d.mts +9 -0
- package/es/i18n/resources/zhCn/messageModal.mjs +10 -0
- package/es/i18n/resources/zhCn/messageModal.mjs.map +1 -0
- package/es/i18n/resources/zhCn/sideNav.d.mts +21 -0
- package/es/i18n/resources/zhCn/sideNav.mjs +22 -0
- package/es/i18n/resources/zhCn/sideNav.mjs.map +1 -0
- package/es/i18n/types.d.mts +28 -0
- package/es/i18n/useTranslation.d.mts +10 -0
- package/es/i18n/useTranslation.mjs +22 -0
- package/es/i18n/useTranslation.mjs.map +1 -0
- package/es/icons/lucideExtra/BotPromptIcon.d.mts +2 -2
- package/es/icons/lucideExtra/CreateBotIcon.d.mts +3 -3
- package/es/icons/lucideExtra/DiscordIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GlobeOffIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GroupBotIcon.d.mts +3 -3
- package/es/icons/lucideExtra/GroupBotSquareIcon.d.mts +3 -3
- package/es/icons/lucideExtra/LeftClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/LeftDoubleClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/McpIcon.d.mts +3 -3
- package/es/icons/lucideExtra/ProviderIcon.d.mts +3 -3
- package/es/icons/lucideExtra/RightClickIcon.d.mts +2 -2
- package/es/icons/lucideExtra/RightDoubleClickIcon.d.mts +3 -3
- package/es/icons/lucideExtra/ShapesUploadIcon.d.mts +3 -3
- package/es/icons/lucideExtra/TreeDownRightIcon.d.mts +3 -3
- package/es/icons/lucideExtra/TreeUpDownRightIcon.d.mts +3 -3
- package/es/index.d.mts +5 -1
- package/es/index.mjs +4 -1
- package/es/mdx/Mdx/index.d.mts +2 -2
- package/es/mobile/ChatHeader/ChatHeaderTitle.d.mts +2 -2
- package/es/mobile/ChatInputArea/components/ChatSendButton.d.mts +2 -2
- package/es/mobile/TabBar/TabBar.d.mts +2 -2
- package/es/motion/LazyMotion.d.mts +2 -2
- package/es/storybook/StoryBook/index.d.mts +2 -2
- 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
|
|
2
|
+
import * as react0 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Accordion/Accordion.d.ts
|
|
5
|
-
declare const Accordion:
|
|
5
|
+
declare const Accordion: react0.NamedExoticComponent<AccordionProps & react0.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
|
|
2
|
+
import * as react2 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Accordion/AccordionItem.d.ts
|
|
5
|
-
declare const AccordionItem:
|
|
5
|
+
declare const AccordionItem: react2.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(
|
|
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,WA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AAU,UACX;cAEA;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
|
+
{"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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AAO;IACP,MAAM;IACN,KAAK;IACL;IACA,OAAO,EACL,UAAU,UACX;eAEA,WACA;KACO,EACV,oBAACA;IAAQ,OAAO;IAAU,MAAM;IAAQ,KAAK;IAAG;cAC7C;KACO,IACT,GAEH,8CACE,oBAACA;IACC,OAAO;IACP,MAAM;IACN,KAAK;IACL;IACA,OAAO,EACL,UAAU,UACX;cAEA;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
|
|
2
|
+
import * as react30 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/ActionIcon/ActionIcon.d.ts
|
|
5
|
-
declare const ActionIcon:
|
|
5
|
+
declare const ActionIcon: react30.NamedExoticComponent<ActionIconProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ActionIcon };
|
|
8
8
|
//# sourceMappingURL=ActionIcon.d.mts.map
|
package/es/Alert/Alert.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AlertProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react44 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Alert/Alert.d.ts
|
|
5
|
-
declare const Alert:
|
|
5
|
+
declare const Alert: react44.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
|
|
2
|
+
import * as react45 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/AutoComplete/Select.d.ts
|
|
5
|
-
declare const AutoComplete:
|
|
5
|
+
declare const AutoComplete: react45.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
|
|
2
|
+
import * as react43 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Avatar/AvatarGroup/index.d.ts
|
|
5
|
-
declare const AvatarGroup:
|
|
5
|
+
declare const AvatarGroup: react43.NamedExoticComponent<AvatarGroupProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { AvatarGroup };
|
|
8
8
|
//# sourceMappingURL=index.d.mts.map
|
package/es/Burger/Burger.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BurgerProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react28 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Burger/Burger.d.ts
|
|
5
|
-
declare const Burger:
|
|
5
|
+
declare const Burger: react28.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
|
|
2
|
+
import * as react29 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/CodeEditor/CodeEditor.d.ts
|
|
5
|
-
declare const CodeEditor:
|
|
5
|
+
declare const CodeEditor: react29.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
|
|
2
|
+
import * as react27 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Collapse/Collapse.d.ts
|
|
5
|
-
declare const Collapse:
|
|
5
|
+
declare const Collapse: react27.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 { TranslationResources } from "../i18n/types.mjs";
|
|
1
3
|
import { CDN, CdnApi } from "../utils/genCdnUrl.mjs";
|
|
2
|
-
import * as
|
|
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
|
-
|
|
15
|
+
interface ConfigProviderProps {
|
|
14
16
|
children: ReactNode;
|
|
15
|
-
config
|
|
16
|
-
|
|
17
|
+
config?: Config;
|
|
18
|
+
locale?: string;
|
|
19
|
+
motion: MotionComponentType;
|
|
20
|
+
resources?: TranslationResources[] | Record<string, TranslationResources>;
|
|
21
|
+
}
|
|
22
|
+
declare const ConfigProvider: react66.NamedExoticComponent<ConfigProviderProps>;
|
|
17
23
|
type CdnFn = ({
|
|
18
24
|
pkg,
|
|
19
25
|
version,
|
|
@@ -1,15 +1,36 @@
|
|
|
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, useMemo } 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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const I18nContextInternal = createContext({
|
|
11
|
+
locale: "en",
|
|
12
|
+
t: (key) => key
|
|
13
|
+
});
|
|
14
|
+
const ConfigProvider = memo(({ children, config, locale, resources, motion }) => {
|
|
15
|
+
return /* @__PURE__ */ jsx(I18nContextInternal, {
|
|
16
|
+
value: useMemo(() => {
|
|
17
|
+
const currentLocale = locale || "en";
|
|
18
|
+
const currentResources = resources || [];
|
|
19
|
+
const resourceList = Array.isArray(currentResources) ? currentResources : Object.values(currentResources);
|
|
20
|
+
const mergedResources = Object.assign({}, ...resourceList);
|
|
21
|
+
const t = (key) => mergedResources[key] || key;
|
|
22
|
+
return {
|
|
23
|
+
locale: currentLocale,
|
|
24
|
+
t
|
|
25
|
+
};
|
|
26
|
+
}, [locale, resources]),
|
|
27
|
+
children: /* @__PURE__ */ jsx(ConfigContext, {
|
|
28
|
+
value: config ?? null,
|
|
29
|
+
children: /* @__PURE__ */ jsx(MotionComponent, {
|
|
30
|
+
value: motion,
|
|
31
|
+
children
|
|
32
|
+
})
|
|
33
|
+
})
|
|
13
34
|
});
|
|
14
35
|
});
|
|
15
36
|
const cdnFallback = ({ pkg, version, path }) => genCdnUrl({
|
|
@@ -29,8 +50,9 @@ const useCdnFn = () => {
|
|
|
29
50
|
});
|
|
30
51
|
return config?.customCdnFn || cdnFallback;
|
|
31
52
|
};
|
|
53
|
+
const useI18n = () => use(I18nContextInternal);
|
|
32
54
|
var ConfigProvider_default = ConfigProvider;
|
|
33
55
|
|
|
34
56
|
//#endregion
|
|
35
|
-
export { ConfigContext, ConfigProvider_default as default, useCdnFn };
|
|
57
|
+
export { ConfigContext, I18nContextInternal, ConfigProvider_default as default, useCdnFn, useI18n };
|
|
36
58
|
//# 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
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["cdnFallback: CdnFn"],"sources":["../../src/ConfigProvider/index.tsx"],"sourcesContent":["'use client';\n\nimport { ElementType, ReactNode, createContext, memo, use, useMemo } from 'react';\n\nimport { MotionComponent, type MotionComponentType } from '@/MotionProvider';\nimport type { I18nContextValue, TranslationKey, TranslationResources } 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?: TranslationResources[] | Record<string, TranslationResources>;\n}\n\nconst ConfigProvider = memo<ConfigProviderProps>(\n ({ children, config, locale, resources, motion }) => {\n const i18nValue = useMemo((): I18nContextValue => {\n const currentLocale = locale || 'en';\n const currentResources = resources || [];\n const resourceList = Array.isArray(currentResources)\n ? currentResources\n : Object.values(currentResources);\n const mergedResources = Object.assign({}, ...resourceList);\n const t = (key: TranslationKey): string => mergedResources[key] || key;\n return { locale: currentLocale, t };\n }, [locale, resources]);\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":";;;;;;;;AAgBA,MAAa,gBAAgB,cAA6B,KAAK;AAG/D,MAAM,sBAAsB,cAAgC;CAC1D,QAAQ;CACR,IAAI,QAAwB;CAC7B,CAAC;AAWF,MAAM,iBAAiB,MACpB,EAAE,UAAU,QAAQ,QAAQ,WAAW,aAAa;AAYnD,QACE,oBAAC;EAAoB,OAZL,cAAgC;GAChD,MAAM,gBAAgB,UAAU;GAChC,MAAM,mBAAmB,aAAa,EAAE;GACxC,MAAM,eAAe,MAAM,QAAQ,iBAAiB,GAChD,mBACA,OAAO,OAAO,iBAAiB;GACnC,MAAM,kBAAkB,OAAO,OAAO,EAAE,EAAE,GAAG,aAAa;GAC1D,MAAM,KAAK,QAAgC,gBAAgB,QAAQ;AACnE,UAAO;IAAE,QAAQ;IAAe;IAAG;KAClC,CAAC,QAAQ,UAAU,CAAC;YAInB,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
|
|
2
|
+
import * as react0 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/CopyButton/CopyButton.d.ts
|
|
5
|
-
declare const CopyButton:
|
|
5
|
+
declare const CopyButton: react0.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
|
|
2
|
+
import * as react42 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/DatePicker/DatePicker.d.ts
|
|
5
|
-
declare const DatePicker:
|
|
5
|
+
declare const DatePicker: react42.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
|
|
2
|
+
import * as react37 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/DraggablePanel/components/DraggablePanelBody.d.ts
|
|
5
5
|
type DraggablePanelBodyProps = DivProps;
|
|
6
|
-
declare const DraggablePanelBody:
|
|
6
|
+
declare const DraggablePanelBody: react37.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
|
|
2
|
+
import * as react38 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/DraggablePanel/components/DraggablePanelContainer.d.ts
|
|
5
5
|
type DraggablePanelContainerProps = DivProps;
|
|
6
|
-
declare const DraggablePanelContainer:
|
|
6
|
+
declare const DraggablePanelContainer: react38.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
|
|
2
|
+
import * as react39 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/DraggablePanel/components/DraggablePanelFooter.d.ts
|
|
5
5
|
type DraggablePanelFooterProps = DivProps;
|
|
6
|
-
declare const DraggablePanelFooter:
|
|
6
|
+
declare const DraggablePanelFooter: react39.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
|
|
2
|
+
import * as react40 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:
|
|
12
|
+
declare const DraggablePanelHeader: react40.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
|
|
2
|
+
import * as react41 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/DraggableSideNav/DraggableSideNav.d.ts
|
|
5
|
-
declare const DraggableSideNav:
|
|
5
|
+
declare const DraggableSideNav: react41.NamedExoticComponent<DraggableSideNavProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { DraggableSideNav };
|
|
8
8
|
//# sourceMappingURL=DraggableSideNav.d.mts.map
|
package/es/Drawer/Drawer.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DrawerProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react36 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Drawer/Drawer.d.ts
|
|
5
|
-
declare const Drawer:
|
|
5
|
+
declare const Drawer: react36.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
|
|
2
|
+
import * as react35 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/Dropdown/Dropdown.d.ts
|
|
5
|
-
declare const Dropdown:
|
|
5
|
+
declare const Dropdown: react35.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
|
|
2
|
+
import * as react34 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/EditableText/EditableText.d.ts
|
|
5
|
-
declare const EditableText:
|
|
5
|
+
declare const EditableText: react34.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(
|
|
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:
|
|
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:
|
|
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
|
|
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,cAAc,mBAAmB,SAAS,GAAG;CACpD,MAAM,QAAQ,UAAU;CACxB,MAAM,EAAE,MAAM,eAAeA,oBAAoB;CAEjD,MAAM,oBAAoB,OAAO,iBAAiB,EAAE,4BAA4B;CAChF,MAAM,kBAAkB,OAAO,eAAe,EAAE,0BAA0B;CAC1E,MAAM,gBAAgB,OAAO,aAAa,EAAE,wBAAwB;CAEpE,MAAM,eAAe,aAClB,SAAmB;AAMlB,MAAI,EAJF,KAAK,SAAS,gBACd,KAAK,SAAS,eACd,KAAK,SAAS,eACd,KAAK,SAAS,eACC;AACf,WAAQ,MAAM,kBAAkB;AAChC;;AAEF,SAAO,0BAA0B,WAAW;AAC1C,mBAAgB,OAAO;IACvB,CAAC,KAAK;IAEV,CAAC,kBAAkB,CACpB;CAED,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,qBAACC;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;gBAAqB;OAAuB;KAC/D,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;MACM;KACD;IACH;GAEH;EAGf;AAED,eAAe,cAAc;AAE7B,6BAAe"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EmojiPickerProps } from "./type.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react33 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/EmojiPicker/EmojiPicker.d.ts
|
|
5
|
-
declare const EmojiPicker:
|
|
5
|
+
declare const EmojiPicker: react33.NamedExoticComponent<EmojiPickerProps>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { EmojiPicker };
|
|
8
8
|
//# sourceMappingURL=EmojiPicker.d.mts.map
|