@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
@@ -6,6 +6,8 @@ import Tooltip_default from "../Tooltip/Tooltip.mjs";
6
6
  import ActionIcon_default from "../ActionIcon/ActionIcon.mjs";
7
7
  import Avatar_default from "../Avatar/index.mjs";
8
8
  import Tabs_default from "../Tabs/Tabs.mjs";
9
+ import emojiPicker_default from "../i18n/resources/en/emojiPicker.mjs";
10
+ import { useTranslation } from "../i18n/useTranslation.mjs";
9
11
  import AvatarUploader_default from "./AvatarUploader.mjs";
10
12
  import { useStyles } from "./style.mjs";
11
13
  import { memo, useRef, useState } from "react";
@@ -21,6 +23,7 @@ import Picker from "@emoji-mart/react";
21
23
  const DEFAULT_AVATAR = "🤖";
22
24
  const EmojiPicker = memo(({ value, defaultAvatar = DEFAULT_AVATAR, onChange, locale = "en-US", allowUpload, allowDelete, texts, onDelete, compressSize = 256, customEmojis, className, loading, onUpload, customTabs = [], popupClassName, popupStyle, customRender, open, defaultOpen = false, onOpenChange, popupProps, shape, ...rest }) => {
23
25
  const ref = useRef(null);
26
+ const { t } = useTranslation(emojiPicker_default);
24
27
  const [visible, setVisible] = useMergeState(defaultOpen, {
25
28
  defaultValue: defaultOpen,
26
29
  onChange: onOpenChange,
@@ -41,11 +44,14 @@ const EmojiPicker = memo(({ value, defaultAvatar = DEFAULT_AVATAR, onChange, loc
41
44
  setAva(emoji);
42
45
  setVisible(false);
43
46
  };
47
+ const emojiText = texts?.emoji ?? t("emojiPicker.emoji");
48
+ const uploadText = texts?.upload ?? t("emojiPicker.upload");
49
+ const deleteText = texts?.delete ?? t("emojiPicker.delete");
44
50
  const items = [
45
51
  {
46
52
  key: "emoji",
47
53
  label: /* @__PURE__ */ jsx(Tooltip_default, {
48
- title: texts?.emoji || "Emoji",
54
+ title: emojiText,
49
55
  children: /* @__PURE__ */ jsx(Icon_default, {
50
56
  icon: SmileIcon,
51
57
  size: {
@@ -58,7 +64,7 @@ const EmojiPicker = memo(({ value, defaultAvatar = DEFAULT_AVATAR, onChange, loc
58
64
  allowUpload && {
59
65
  key: "upload",
60
66
  label: /* @__PURE__ */ jsx(Tooltip_default, {
61
- title: texts?.upload || "Upload",
67
+ title: uploadText,
62
68
  children: /* @__PURE__ */ jsx(Icon_default, {
63
69
  icon: UploadIcon,
64
70
  size: {
@@ -107,7 +113,7 @@ const EmojiPicker = memo(({ value, defaultAvatar = DEFAULT_AVATAR, onChange, loc
107
113
  blockSize: 32,
108
114
  size: 18
109
115
  },
110
- title: texts?.delete || "Delete"
116
+ title: deleteText
111
117
  })]
112
118
  }),
113
119
  tab === "emoji" && /* @__PURE__ */ jsx(Picker, {
@@ -1 +1 @@
1
- {"version":3,"file":"EmojiPicker.mjs","names":["items: TabsProps['items']","Tooltip","Icon","tab","Flexbox","Tabs","ActionIcon","AvatarUploader","Avatar"],"sources":["../../src/EmojiPicker/EmojiPicker.tsx"],"sourcesContent":["'use client';\n\nimport data from '@emoji-mart/data';\nimport Picker from '@emoji-mart/react';\nimport { Popover } from 'antd';\nimport { SmileIcon, TrashIcon, UploadIcon } from 'lucide-react';\nimport { memo, useRef, useState } from 'react';\nimport useSWR from 'swr';\nimport useMergeState from 'use-merge-value';\n\nimport ActionIcon from '@/ActionIcon';\nimport Avatar from '@/Avatar';\nimport { Flexbox } from '@/Flex';\nimport Icon from '@/Icon';\nimport Tabs, { TabsProps } from '@/Tabs';\nimport Tooltip from '@/Tooltip';\n\nimport AvatarUploader from './AvatarUploader';\nimport { useStyles } from './style';\nimport type { EmojiPickerProps } from './type';\n\nconst DEFAULT_AVATAR = '🤖';\n\nconst EmojiPicker = memo<EmojiPickerProps>(\n ({\n value,\n defaultAvatar = DEFAULT_AVATAR,\n onChange,\n locale = 'en-US',\n allowUpload,\n allowDelete,\n texts,\n onDelete,\n compressSize = 256,\n customEmojis,\n className,\n loading,\n onUpload,\n customTabs = [],\n popupClassName,\n popupStyle,\n customRender,\n open,\n defaultOpen = false,\n onOpenChange,\n popupProps,\n shape,\n ...rest\n }) => {\n const ref = useRef<HTMLDivElement>(null);\n const [visible, setVisible] = useMergeState(defaultOpen, {\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n value: open,\n });\n const [tab, setTab] = useState<'emoji' | 'upload'>('emoji');\n\n const { cx, styles, theme } = useStyles();\n\n const { data: i18n } = useSWR(\n locale,\n async () => await import(`@emoji-mart/data/i18n/${locale.split('-')[0]}.json`),\n { revalidateOnFocus: false, revalidateOnMount: false },\n );\n\n const [ava, setAva] = useMergeState(defaultAvatar, {\n defaultValue: defaultAvatar,\n onChange,\n value,\n });\n\n const handleAvatarChange = (emoji: string) => {\n setAva(emoji);\n setVisible(false);\n };\n\n const items: TabsProps['items'] = [\n {\n key: 'emoji',\n label: (\n <Tooltip title={texts?.emoji || 'Emoji'}>\n <Icon icon={SmileIcon} size={{ size: 20, strokeWidth: 2.5 }} />\n </Tooltip>\n ),\n },\n allowUpload && {\n key: 'upload',\n label: (\n <Tooltip title={texts?.upload || 'Upload'}>\n <Icon icon={UploadIcon} size={{ size: 20, strokeWidth: 2.5 }} />\n </Tooltip>\n ),\n },\n ...customTabs.map((tab) => ({ key: tab.value, label: tab.label })),\n ].filter(Boolean) as TabsProps['items'];\n\n const showTabs = allowDelete || (items && items.length > 1);\n\n const content = (\n <Flexbox\n className={cx(styles.picker, popupClassName)}\n ref={ref}\n style={{ minWidth: 310, paddingTop: showTabs ? 4 : 0, ...popupStyle }}\n >\n {showTabs && (\n <Flexbox\n align={'center'}\n className={styles.tabs}\n horizontal\n justify={'space-between'}\n paddingInline={10}\n >\n <Tabs\n activeKey={tab}\n compact\n items={items}\n onChange={(key) => setTab(key as any)}\n size={'small'}\n />\n {allowDelete && (\n <ActionIcon\n icon={TrashIcon}\n onClick={() => {\n handleAvatarChange(defaultAvatar);\n onDelete?.();\n }}\n size={{\n blockSize: 32,\n size: 18,\n }}\n title={texts?.delete || 'Delete'}\n />\n )}\n </Flexbox>\n )}\n {tab === 'emoji' && (\n <Picker\n custom={customEmojis}\n data={data}\n i18n={i18n}\n icons={'outline'}\n locale={locale.split('-')[0]}\n navPosition={showTabs ? 'bottom' : 'top'}\n onEmojiSelect={(e: any) => handleAvatarChange(e.src || e.native)}\n previewPosition={'none'}\n skinTonePosition={'none'}\n theme={theme.isDarkMode ? 'dark' : 'light'}\n />\n )}\n {tab === 'upload' && (\n <AvatarUploader\n compressSize={compressSize}\n onChange={handleAvatarChange}\n onUpload={onUpload}\n shape={shape}\n texts={texts}\n />\n )}\n {customTabs.map(\n (item) =>\n tab === item.value && (\n <Flexbox key={item.value} padding={10}>\n {item.render(handleAvatarChange)}\n </Flexbox>\n ),\n )}\n </Flexbox>\n );\n\n return (\n <Popover\n arrow={false}\n content={content}\n defaultOpen={defaultOpen}\n onOpenChange={(v) => {\n if (loading) return;\n setVisible(v);\n }}\n open={visible}\n placement={'bottom'}\n rootClassName={styles.popover}\n trigger={['click']}\n {...popupProps}\n >\n {customRender ? (\n customRender(ava)\n ) : (\n <Avatar\n avatar={ava}\n className={cx(styles.root, className)}\n loading={loading}\n shape={shape}\n {...rest}\n />\n )}\n </Popover>\n );\n },\n);\n\nEmojiPicker.displayName = 'EmojiPicker';\n\nexport default EmojiPicker;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,iBAAiB;AAEvB,MAAM,cAAc,MACjB,EACC,OACA,gBAAgB,gBAChB,UACA,SAAS,SACT,aACA,aACA,OACA,UACA,eAAe,KACf,cACA,WACA,SACA,UACA,aAAa,EAAE,EACf,gBACA,YACA,cACA,MACA,cAAc,OACd,cACA,YACA,OACA,GAAG,WACC;CACJ,MAAM,MAAM,OAAuB,KAAK;CACxC,MAAM,CAAC,SAAS,cAAc,cAAc,aAAa;EACvD,cAAc;EACd,UAAU;EACV,OAAO;EACR,CAAC;CACF,MAAM,CAAC,KAAK,UAAU,SAA6B,QAAQ;CAE3D,MAAM,EAAE,IAAI,QAAQ,UAAU,WAAW;CAEzC,MAAM,EAAE,MAAM,SAAS,OACrB,QACA,YAAY,MAAM,OAAO,yBAAyB,OAAO,MAAM,IAAI,CAAC,GAAG,SACvE;EAAE,mBAAmB;EAAO,mBAAmB;EAAO,CACvD;CAED,MAAM,CAAC,KAAK,UAAU,cAAc,eAAe;EACjD,cAAc;EACd;EACA;EACD,CAAC;CAEF,MAAM,sBAAsB,UAAkB;AAC5C,SAAO,MAAM;AACb,aAAW,MAAM;;CAGnB,MAAMA,QAA4B;EAChC;GACE,KAAK;GACL,OACE,oBAACC;IAAQ,OAAO,OAAO,SAAS;cAC9B,oBAACC;KAAK,MAAM;KAAW,MAAM;MAAE,MAAM;MAAI,aAAa;MAAK;MAAI;KACvD;GAEb;EACD,eAAe;GACb,KAAK;GACL,OACE,oBAACD;IAAQ,OAAO,OAAO,UAAU;cAC/B,o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GAAI;YAEH,eACC,aAAa,IAAI,GAEjB,oBAACI;GACC,QAAQ;GACR,WAAW,GAAG,OAAO,MAAM,UAAU;GAC5B;GACF;GACP,GAAI;IACJ;GAEI;EAGf;AAED,YAAY,cAAc;AAE1B,0BAAe"}
1
+ {"version":3,"file":"EmojiPicker.mjs","names":["emojiPickerMessages","items: TabsProps['items']","Tooltip","Icon","tab","Flexbox","Tabs","ActionIcon","AvatarUploader","Avatar"],"sources":["../../src/EmojiPicker/EmojiPicker.tsx"],"sourcesContent":["'use client';\n\nimport data from '@emoji-mart/data';\nimport Picker from '@emoji-mart/react';\nimport { Popover } from 'antd';\nimport { SmileIcon, TrashIcon, UploadIcon } from 'lucide-react';\nimport { memo, useRef, useState } from 'react';\nimport useSWR from 'swr';\nimport useMergeState from 'use-merge-value';\n\nimport ActionIcon from '@/ActionIcon';\nimport Avatar from '@/Avatar';\nimport { Flexbox } from '@/Flex';\nimport Icon from '@/Icon';\nimport Tabs, { TabsProps } from '@/Tabs';\nimport Tooltip from '@/Tooltip';\nimport emojiPickerMessages from '@/i18n/resources/en/emojiPicker';\nimport { useTranslation } from '@/i18n/useTranslation';\n\nimport AvatarUploader from './AvatarUploader';\nimport { useStyles } from './style';\nimport type { EmojiPickerProps } from './type';\n\nconst DEFAULT_AVATAR = '🤖';\n\nconst EmojiPicker = memo<EmojiPickerProps>(\n ({\n value,\n defaultAvatar = DEFAULT_AVATAR,\n onChange,\n locale = 'en-US',\n allowUpload,\n allowDelete,\n texts,\n onDelete,\n compressSize = 256,\n customEmojis,\n className,\n loading,\n onUpload,\n customTabs = [],\n popupClassName,\n popupStyle,\n customRender,\n open,\n defaultOpen = false,\n onOpenChange,\n popupProps,\n shape,\n ...rest\n }) => {\n const ref = useRef<HTMLDivElement>(null);\n const { t } = useTranslation(emojiPickerMessages);\n const [visible, setVisible] = useMergeState(defaultOpen, {\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n value: open,\n });\n const [tab, setTab] = useState<'emoji' | 'upload'>('emoji');\n\n const { cx, styles, theme } = useStyles();\n\n const { data: i18n } = useSWR(\n locale,\n async () => await import(`@emoji-mart/data/i18n/${locale.split('-')[0]}.json`),\n { revalidateOnFocus: false, revalidateOnMount: false },\n );\n\n const [ava, setAva] = useMergeState(defaultAvatar, {\n defaultValue: defaultAvatar,\n onChange,\n value,\n });\n\n const handleAvatarChange = (emoji: string) => {\n setAva(emoji);\n setVisible(false);\n };\n\n const emojiText = texts?.emoji ?? t('emojiPicker.emoji');\n const uploadText = texts?.upload ?? t('emojiPicker.upload');\n const deleteText = texts?.delete ?? t('emojiPicker.delete');\n\n const items: TabsProps['items'] = [\n {\n key: 'emoji',\n label: (\n <Tooltip title={emojiText}>\n <Icon icon={SmileIcon} size={{ size: 20, strokeWidth: 2.5 }} />\n </Tooltip>\n ),\n },\n allowUpload && {\n key: 'upload',\n label: (\n <Tooltip title={uploadText}>\n <Icon icon={UploadIcon} size={{ size: 20, strokeWidth: 2.5 }} />\n </Tooltip>\n ),\n },\n ...customTabs.map((tab) => ({ key: tab.value, label: tab.label })),\n ].filter(Boolean) as TabsProps['items'];\n\n const showTabs = allowDelete || (items && items.length > 1);\n\n const content = (\n <Flexbox\n className={cx(styles.picker, popupClassName)}\n ref={ref}\n style={{ minWidth: 310, paddingTop: showTabs ? 4 : 0, ...popupStyle }}\n >\n {showTabs && (\n <Flexbox\n align={'center'}\n className={styles.tabs}\n horizontal\n justify={'space-between'}\n paddingInline={10}\n >\n <Tabs\n activeKey={tab}\n compact\n items={items}\n onChange={(key) => setTab(key as any)}\n size={'small'}\n />\n {allowDelete && (\n <ActionIcon\n icon={TrashIcon}\n onClick={() => {\n handleAvatarChange(defaultAvatar);\n onDelete?.();\n }}\n size={{\n blockSize: 32,\n size: 18,\n }}\n title={deleteText}\n />\n )}\n </Flexbox>\n )}\n {tab === 'emoji' && (\n <Picker\n custom={customEmojis}\n data={data}\n i18n={i18n}\n icons={'outline'}\n locale={locale.split('-')[0]}\n navPosition={showTabs ? 'bottom' : 'top'}\n onEmojiSelect={(e: any) => handleAvatarChange(e.src || e.native)}\n previewPosition={'none'}\n skinTonePosition={'none'}\n theme={theme.isDarkMode ? 'dark' : 'light'}\n />\n )}\n {tab === 'upload' && (\n <AvatarUploader\n compressSize={compressSize}\n onChange={handleAvatarChange}\n onUpload={onUpload}\n shape={shape}\n texts={texts}\n />\n )}\n {customTabs.map(\n (item) =>\n tab === item.value && (\n <Flexbox key={item.value} padding={10}>\n {item.render(handleAvatarChange)}\n </Flexbox>\n ),\n )}\n </Flexbox>\n );\n\n return (\n <Popover\n arrow={false}\n content={content}\n defaultOpen={defaultOpen}\n onOpenChange={(v) => {\n if (loading) return;\n setVisible(v);\n }}\n open={visible}\n placement={'bottom'}\n rootClassName={styles.popover}\n trigger={['click']}\n {...popupProps}\n >\n {customRender ? (\n customRender(ava)\n ) : (\n <Avatar\n avatar={ava}\n className={cx(styles.root, className)}\n loading={loading}\n shape={shape}\n {...rest}\n />\n )}\n </Popover>\n );\n },\n);\n\nEmojiPicker.displayName = 'EmojiPicker';\n\nexport default EmojiPicker;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,iBAAiB;AAEvB,MAAM,cAAc,MACjB,EACC,OACA,gBAAgB,gBAChB,UACA,SAAS,SACT,aACA,aACA,OACA,UACA,eAAe,KACf,cACA,WACA,SACA,UACA,aAAa,EAAE,EACf,gBACA,YACA,cACA,MACA,cAAc,OACd,cACA,YACA,OACA,GAAG,WACC;CACJ,MAAM,MAAM,OAAuB,KAAK;CACxC,MAAM,EAAE,MAAM,eAAeA,oBAAoB;CACjD,MAAM,CAAC,SAAS,cAAc,cAAc,aAAa;EACvD,cAAc;EACd,UAAU;EACV,OAAO;EACR,CAAC;CACF,MAAM,CAAC,KAAK,UAAU,SAA6B,QAAQ;CAE3D,MAAM,EAAE,IAAI,QAAQ,UAAU,WAAW;CAEzC,MAAM,EAAE,MAAM,SAAS,OACrB,QACA,YAAY,MAAM,OAAO,yBAAyB,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MAEI;IAEX,QAAQ,WACP,oBAAC;KACC,QAAQ;KACF;KACA;KACN,OAAO;KACP,QAAQ,OAAO,MAAM,IAAI,CAAC;KAC1B,aAAa,WAAW,WAAW;KACnC,gBAAgB,MAAW,mBAAmB,EAAE,OAAO,EAAE,OAAO;KAChE,iBAAiB;KACjB,kBAAkB;KAClB,OAAO,MAAM,aAAa,SAAS;MACnC;IAEH,QAAQ,YACP,oBAACC;KACe;KACd,UAAU;KACA;KACH;KACA;MACP;IAEH,WAAW,KACT,SACC,QAAQ,KAAK,SACX,oBAACH;KAAyB,SAAS;eAChC,KAAK,OAAO,mBAAmB;OADpB,KAAK,MAET,CAEf;;IACO;EAOK;EACb,eAAe,MAAM;AACnB,OAAI,QAAS;AACb,cAAW,EAAE;;EAEf,MAAM;EACN,WAAW;EACX,eAAe,OAAO;EACtB,SAAS,CAAC,QAAQ;EAClB,GAAI;YAEH,eACC,aAAa,IAAI,GAEjB,oBAACI;GACC,QAAQ;GACR,WAAW,GAAG,OAAO,MAAM,UAAU;GAC5B;GACF;GACP,GAAI;IACJ;GAEI;EAGf;AAED,YAAY,cAAc;AAE1B,0BAAe"}
@@ -1,8 +1,8 @@
1
1
  import { FlexBasicProps } from "./type.mjs";
2
- import * as react51 from "react";
2
+ import * as react41 from "react";
3
3
 
4
4
  //#region src/Flex/FlexBasic.d.ts
5
- declare const _default: react51.NamedExoticComponent<FlexBasicProps>;
5
+ declare const _default: react41.NamedExoticComponent<FlexBasicProps>;
6
6
  //#endregion
7
7
  export { _default };
8
8
  //# sourceMappingURL=FlexBasic.d.mts.map
@@ -1,10 +1,10 @@
1
- import * as react64 from "react";
1
+ import * as react65 from "react";
2
2
 
3
3
  //#region src/FontLoader/index.d.ts
4
4
  interface FontLoaderProps {
5
5
  url: string;
6
6
  }
7
- declare const FontLoader: react64.NamedExoticComponent<FontLoaderProps>;
7
+ declare const FontLoader: react65.NamedExoticComponent<FontLoaderProps>;
8
8
  //#endregion
9
9
  export { FontLoader, FontLoaderProps };
10
10
  //# sourceMappingURL=index.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { FooterProps } from "./type.mjs";
2
- import * as react57 from "react";
2
+ import * as react13 from "react";
3
3
 
4
4
  //#region src/Footer/Footer.d.ts
5
- declare const Footer: react57.NamedExoticComponent<FooterProps>;
5
+ declare const Footer: react13.NamedExoticComponent<FooterProps>;
6
6
  //#endregion
7
7
  export { Footer };
8
8
  //# sourceMappingURL=Footer.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { FormGroupProps } from "../type.mjs";
2
- import * as react52 from "react";
2
+ import * as react10 from "react";
3
3
 
4
4
  //#region src/Form/components/FormGroup.d.ts
5
- declare const FormGroup: react52.NamedExoticComponent<FormGroupProps>;
5
+ declare const FormGroup: react10.NamedExoticComponent<FormGroupProps>;
6
6
  //#endregion
7
7
  export { FormGroup };
8
8
  //# sourceMappingURL=FormGroup.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { FormItemProps } from "../type.mjs";
2
- import * as react53 from "react";
2
+ import * as react11 from "react";
3
3
 
4
4
  //#region src/Form/components/FormItem.d.ts
5
- declare const FormItem: react53.NamedExoticComponent<FormItemProps>;
5
+ declare const FormItem: react11.NamedExoticComponent<FormItemProps>;
6
6
  //#endregion
7
7
  export { FormItem };
8
8
  //# sourceMappingURL=FormItem.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { FormSubmitFooterProps } from "../type.mjs";
2
- import * as react54 from "react";
2
+ import * as react12 from "react";
3
3
 
4
4
  //#region src/Form/components/FormSubmitFooter.d.ts
5
- declare const FormSubmitFooter: react54.NamedExoticComponent<FormSubmitFooterProps>;
5
+ declare const FormSubmitFooter: react12.NamedExoticComponent<FormSubmitFooterProps>;
6
6
  //#endregion
7
7
  export { FormSubmitFooter };
8
8
  //# sourceMappingURL=FormSubmitFooter.d.mts.map
@@ -1,23 +1,27 @@
1
1
  'use client';
2
2
 
3
+ import { MotionComponent } from "../../MotionProvider/index.mjs";
3
4
  import FlexBasic_default from "../../Flex/FlexBasic.mjs";
4
5
  import Icon_default from "../../Icon/Icon.mjs";
5
6
  import Button_default from "../../Button/Button.mjs";
7
+ import { useTranslation } from "../../i18n/useTranslation.mjs";
6
8
  import { useSubmitFooterStyles } from "../style.mjs";
7
9
  import { useFormContext } from "./FormProvider.mjs";
10
+ import form_default from "../../i18n/resources/en/form.mjs";
8
11
  import { merge, removeUndefined } from "./merge.mjs";
9
- import { memo, useEffect, useMemo, useState } from "react";
12
+ import { memo, use, useEffect, useMemo, useState } from "react";
10
13
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
11
14
  import { Form } from "antd";
12
- import { motion } from "motion/react";
13
15
  import { InfoIcon } from "lucide-react";
14
16
  import isEqual from "fast-deep-equal";
15
17
 
16
18
  //#region src/Form/components/FormSubmitFooter.tsx
17
19
  const FormSubmitFooter = memo(({ enableReset = true, buttonProps, float, onReset, saveButtonProps, resetButtonProps, enableUnsavedWarning, children, texts, className, ...rest }) => {
20
+ const Motion = use(MotionComponent);
18
21
  const { form, initialValues, submitLoading } = useFormContext();
19
22
  const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
20
23
  const values = Form.useWatch([], form) || {};
24
+ const { t } = useTranslation(form_default);
21
25
  const { cx, styles, theme } = useSubmitFooterStyles();
22
26
  const v = useMemo(() => removeUndefined(values), [values]);
23
27
  const initialV = useMemo(() => removeUndefined(initialValues), [initialValues]);
@@ -29,8 +33,12 @@ const FormSubmitFooter = memo(({ enableReset = true, buttonProps, float, onReset
29
33
  initialV,
30
34
  submitLoading
31
35
  ]);
36
+ const unsavedWarningText = texts?.unSavedWarning ?? t("form.unsavedWarning");
37
+ const unsavedText = texts?.unSaved ?? t("form.unsavedChanges");
38
+ const resetText = texts?.reset ?? t("form.reset");
39
+ const submitText = texts?.submit ?? t("form.submit");
32
40
  const fn = (e) => {
33
- if (hasUnsavedChanges) e.returnValue = texts?.unSavedWarning || "You have unsaved changes. Are you sure you want to leave?";
41
+ if (hasUnsavedChanges) e.returnValue = unsavedWarningText;
34
42
  else delete e.returnValue;
35
43
  };
36
44
  useEffect(() => {
@@ -38,7 +46,11 @@ const FormSubmitFooter = memo(({ enableReset = true, buttonProps, float, onReset
38
46
  if (typeof window === "undefined" || !hasUnsavedChanges) return;
39
47
  window.addEventListener("beforeunload", fn);
40
48
  return () => window.removeEventListener("beforeunload", fn);
41
- }, [enableUnsavedWarning, hasUnsavedChanges]);
49
+ }, [
50
+ enableUnsavedWarning,
51
+ hasUnsavedChanges,
52
+ unsavedWarningText
53
+ ]);
42
54
  const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
43
55
  (float || hasUnsavedChanges) && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Icon_default, {
44
56
  color: theme.colorTextDescription,
@@ -52,7 +64,7 @@ const FormSubmitFooter = memo(({ enableReset = true, buttonProps, float, onReset
52
64
  fontSize: 12,
53
65
  marginRight: float ? 16 : 4
54
66
  },
55
- children: texts?.unSaved || "Unsaved changes"
67
+ children: unsavedText
56
68
  })] }),
57
69
  children,
58
70
  enableReset && (float || hasUnsavedChanges) && /* @__PURE__ */ jsx(Button_default, {
@@ -65,7 +77,7 @@ const FormSubmitFooter = memo(({ enableReset = true, buttonProps, float, onReset
65
77
  variant: "filled",
66
78
  ...buttonProps,
67
79
  ...resetButtonProps,
68
- children: texts?.reset || "Reset"
80
+ children: resetText
69
81
  }),
70
82
  /* @__PURE__ */ jsx(Button_default, {
71
83
  htmlType: "submit",
@@ -74,7 +86,7 @@ const FormSubmitFooter = memo(({ enableReset = true, buttonProps, float, onReset
74
86
  type: "primary",
75
87
  ...buttonProps,
76
88
  ...saveButtonProps,
77
- children: texts?.submit || "Submit"
89
+ children: submitText
78
90
  })
79
91
  ] });
80
92
  if (!float) return /* @__PURE__ */ jsx(FlexBasic_default, {
@@ -86,7 +98,7 @@ const FormSubmitFooter = memo(({ enableReset = true, buttonProps, float, onReset
86
98
  ...rest,
87
99
  children: content
88
100
  });
89
- return /* @__PURE__ */ jsx(motion.div, {
101
+ return /* @__PURE__ */ jsx(Motion.div, {
90
102
  animate: hasUnsavedChanges ? "visible" : "hidden",
91
103
  className: styles.floatFooter,
92
104
  initial: "hidden",
@@ -1 +1 @@
1
- {"version":3,"file":"FormSubmitFooter.mjs","names":["useStyles","Icon","Button","Flexbox"],"sources":["../../../src/Form/components/FormSubmitFooter.tsx"],"sourcesContent":["'use client';\n\nimport { Form } from 'antd';\nimport isEqual from 'fast-deep-equal';\nimport { InfoIcon } from 'lucide-react';\nimport { motion } from 'motion/react';\nimport { memo, useEffect, useMemo, useState } from 'react';\n\nimport Button from '@/Button';\nimport { Flexbox } from '@/Flex';\nimport Icon from '@/Icon';\n\nimport { useSubmitFooterStyles as useStyles } from '../style';\nimport type { FormSubmitFooterProps } from '../type';\nimport { useFormContext } from './FormProvider';\nimport { merge, removeUndefined } from './merge';\n\nconst FormSubmitFooter = memo<FormSubmitFooterProps>(\n ({\n enableReset = true,\n buttonProps,\n float,\n onReset,\n saveButtonProps,\n resetButtonProps,\n enableUnsavedWarning,\n children,\n texts,\n className,\n ...rest\n }) => {\n const { form, initialValues, submitLoading } = useFormContext();\n const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);\n const values = Form.useWatch([], form) || {};\n\n const { cx, styles, theme } = useStyles();\n\n const v = useMemo(() => removeUndefined(values), [values]);\n\n const initialV = useMemo(() => removeUndefined(initialValues), [initialValues]);\n\n const mergedV = useMemo(() => merge(initialV, v), [v, initialV]);\n\n useEffect(() => {\n setHasUnsavedChanges(!isEqual(mergedV, initialV));\n }, [mergedV, initialV, submitLoading]);\n\n const fn = (e: BeforeUnloadEvent) => {\n if (hasUnsavedChanges) {\n e.returnValue =\n texts?.unSavedWarning || 'You have unsaved changes. Are you sure you want to leave?';\n } else {\n delete e.returnValue;\n }\n };\n\n useEffect(() => {\n if (!enableUnsavedWarning) return;\n if (typeof window === 'undefined' || !hasUnsavedChanges) return;\n // 添加离开页面的提示\n window.addEventListener('beforeunload', fn);\n return () => window.removeEventListener('beforeunload', fn);\n }, [enableUnsavedWarning, hasUnsavedChanges]);\n\n const content = (\n <>\n {(float || hasUnsavedChanges) && (\n <>\n <Icon\n color={theme.colorTextDescription}\n icon={InfoIcon}\n size={12}\n style={{ marginLeft: 8 }}\n />\n <span\n style={{\n color: theme.colorTextDescription,\n flex: 'none',\n fontSize: 12,\n marginRight: float ? 16 : 4,\n }}\n >\n {texts?.unSaved || 'Unsaved changes'}\n </span>\n </>\n )}\n {children}\n {enableReset && (float || hasUnsavedChanges) && (\n <Button\n htmlType=\"button\"\n onClick={() => {\n onReset?.(v, initialV);\n form?.resetFields();\n }}\n shape={float ? 'round' : undefined}\n variant={'filled'}\n {...buttonProps}\n {...resetButtonProps}\n >\n {texts?.reset || 'Reset'}\n </Button>\n )}\n <Button\n htmlType=\"submit\"\n loading={submitLoading}\n shape={float ? 'round' : undefined}\n type=\"primary\"\n {...buttonProps}\n {...saveButtonProps}\n >\n {texts?.submit || 'Submit'}\n </Button>\n </>\n );\n\n if (!float)\n return (\n <Flexbox\n align={'center'}\n className={cx(styles.footer, className)}\n gap={8}\n horizontal\n justify={'flex-end'}\n {...rest}\n >\n {content}\n </Flexbox>\n );\n\n return (\n <motion.div\n animate={hasUnsavedChanges ? 'visible' : 'hidden'}\n className={styles.floatFooter}\n initial={'hidden'}\n transition={{ duration: 0.1, ease: 'easeOut' }}\n variants={{\n hidden: {\n opacity: 0,\n x: '-50%',\n y: 20,\n },\n visible: {\n opacity: 1,\n x: '-50%',\n y: 0,\n },\n }}\n >\n <Flexbox\n align={'center'}\n className={className}\n gap={8}\n horizontal\n justify={'center'}\n {...rest}\n >\n {content}\n </Flexbox>\n </motion.div>\n );\n },\n);\n\nFormSubmitFooter.displayName = 'FormSubmitFooter';\n\nexport default FormSubmitFooter;\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,MAAM,mBAAmB,MACtB,EACC,cAAc,MACd,aACA,OACA,SACA,iBACA,kBACA,sB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OAAO,SAAS;IACV;EAEX,oBAACA;GACC,UAAS;GACT,SAAS;GACT,OAAO,QAAQ,UAAU;GACzB,MAAK;GACL,GAAI;GACJ,GAAI;aAEH,OAAO,UAAU;IACX;KACR;AAGL,KAAI,CAAC,MACH,QACE,oBAACC;EACC,OAAO;EACP,WAAW,GAAG,OAAO,QAAQ,UAAU;EACvC,KAAK;EACL;EACA,SAAS;EACT,GAAI;YAEH;GACO;AAGd,QACE,oBAAC,OAAO;EACN,SAAS,oBAAoB,YAAY;EACzC,WAAW,OAAO;EAClB,SAAS;EACT,YAAY;GAAE,UAAU;GAAK,MAAM;GAAW;EAC9C,UAAU;GACR,QAAQ;IACN,SAAS;IACT,GAAG;IACH,GAAG;IACJ;GACD,SAAS;IACP,SAAS;IACT,GAAG;IACH,GAAG;IACJ;GACF;YAED,oBAACA;GACC,OAAO;GACI;GACX,KAAK;GACL;GACA,SAAS;GACT,GAAI;aAEH;IACO;GACC;EAGlB;AAED,iBAAiB,cAAc;AAE/B,+BAAe"}
1
+ {"version":3,"file":"FormSubmitFooter.mjs","names":["formMessages","useStyles","Icon","Button","Flexbox"],"sources":["../../../src/Form/components/FormSubmitFooter.tsx"],"sourcesContent":["'use client';\n\nimport { Form } from 'antd';\nimport isEqual from 'fast-deep-equal';\nimport { InfoIcon } from 'lucide-react';\nimport { memo, use, useEffect, useMemo, useState } from 'react';\n\nimport Button from '@/Button';\nimport { Flexbox } from '@/Flex';\nimport Icon from '@/Icon';\nimport { MotionComponent } from '@/MotionProvider';\nimport formMessages from '@/i18n/resources/en/form';\nimport { useTranslation } from '@/i18n/useTranslation';\n\nimport { useSubmitFooterStyles as useStyles } from '../style';\nimport type { FormSubmitFooterProps } from '../type';\nimport { useFormContext } from './FormProvider';\nimport { merge, removeUndefined } from './merge';\n\nconst FormSubmitFooter = memo<FormSubmitFooterProps>(\n ({\n enableReset = true,\n buttonProps,\n float,\n onReset,\n saveButtonProps,\n resetButtonProps,\n enableUnsavedWarning,\n children,\n texts,\n className,\n ...rest\n }) => {\n const Motion = use(MotionComponent);\n const { form, initialValues, submitLoading } = useFormContext();\n const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);\n const values = Form.useWatch([], form) || {};\n const { t } = useTranslation(formMessages);\n\n const { cx, styles, theme } = useStyles();\n\n const v = useMemo(() => removeUndefined(values), [values]);\n\n const initialV = useMemo(() => removeUndefined(initialValues), [initialValues]);\n\n const mergedV = useMemo(() => merge(initialV, v), [v, initialV]);\n\n useEffect(() => {\n setHasUnsavedChanges(!isEqual(mergedV, initialV));\n }, [mergedV, initialV, submitLoading]);\n\n const unsavedWarningText = texts?.unSavedWarning ?? t('form.unsavedWarning');\n const unsavedText = texts?.unSaved ?? t('form.unsavedChanges');\n const resetText = texts?.reset ?? t('form.reset');\n const submitText = texts?.submit ?? t('form.submit');\n\n const fn = (e: BeforeUnloadEvent) => {\n if (hasUnsavedChanges) {\n e.returnValue = unsavedWarningText;\n } else {\n delete e.returnValue;\n }\n };\n\n useEffect(() => {\n if (!enableUnsavedWarning) return;\n if (typeof window === 'undefined' || !hasUnsavedChanges) return;\n // 添加离开页面的提示\n window.addEventListener('beforeunload', fn);\n return () => window.removeEventListener('beforeunload', fn);\n }, [enableUnsavedWarning, hasUnsavedChanges, unsavedWarningText]);\n\n const content = (\n <>\n {(float || hasUnsavedChanges) && (\n <>\n <Icon\n color={theme.colorTextDescription}\n icon={InfoIcon}\n size={12}\n style={{ marginLeft: 8 }}\n />\n <span\n style={{\n color: theme.colorTextDescription,\n flex: 'none',\n fontSize: 12,\n marginRight: float ? 16 : 4,\n }}\n >\n {unsavedText}\n </span>\n </>\n )}\n {children}\n {enableReset && (float || hasUnsavedChanges) && (\n <Button\n htmlType=\"button\"\n onClick={() => {\n onReset?.(v, initialV);\n form?.resetFields();\n }}\n shape={float ? 'round' : undefined}\n variant={'filled'}\n {...buttonProps}\n {...resetButtonProps}\n >\n {resetText}\n </Button>\n )}\n <Button\n htmlType=\"submit\"\n loading={submitLoading}\n shape={float ? 'round' : undefined}\n type=\"primary\"\n {...buttonProps}\n {...saveButtonProps}\n >\n {submitText}\n </Button>\n </>\n );\n\n if (!float)\n return (\n <Flexbox\n align={'center'}\n className={cx(styles.footer, className)}\n gap={8}\n horizontal\n justify={'flex-end'}\n {...rest}\n >\n {content}\n </Flexbox>\n );\n\n return (\n <Motion.div\n animate={hasUnsavedChanges ? 'visible' : 'hidden'}\n className={styles.floatFooter}\n initial={'hidden'}\n transition={{ duration: 0.1, ease: 'easeOut' }}\n variants={{\n hidden: {\n opacity: 0,\n x: '-50%',\n y: 20,\n },\n visible: {\n opacity: 1,\n x: '-50%',\n y: 0,\n },\n }}\n >\n <Flexbox\n align={'center'}\n className={className}\n gap={8}\n horizontal\n justify={'center'}\n {...rest}\n >\n {content}\n </Flexbox>\n </Motion.div>\n );\n },\n);\n\nFormSubmitFooter.displayName = 'FormSubmitFooter';\n\nexport default FormSubmitFooter;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,mBAAmB,MACtB,EACC,cAAc,MACd,aACA,OACA,SACA,iBACA,kBACA,sBACA,UACA,OACA,WACA,GAAG,WACC;CACJ,MAAM,SAAS,IAAI,gBAAgB;CACnC,MAAM,EAAE,MAAM,eAAe,kBAAkB,gBAAgB;CAC/D,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,MAAM;CACjE,MAAM,SAAS,KAAK,SAAS,EAAE,EAAE,KAAK,IAAI,EAAE;CAC5C,MAAM,EAAE,MAAM,eAAeA,aAAa;CAE1C,MAAM,EAAE,IAAI,QAAQ,UAAUC,uBAAW;CAEzC,MAAM,IAAI,cAAc,gBAAgB,OAAO,EAAE,CAAC,OAAO,CAAC;CAE1D,MAAM,WAAW,cAAc,gBAAgB,cAAc,EAAE,CAAC,cAAc,CAAC;CAE/E,MAAM,UAAU,cAAc,MAAM,UAAU,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC;AAEhE,iBAAgB;AACd,uBAAqB,CAAC,QAAQ,SAAS,SAAS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;EACT,YAAY;GAAE,UAAU;GAAK,MAAM;GAAW;EAC9C,UAAU;GACR,QAAQ;IACN,SAAS;IACT,GAAG;IACH,GAAG;IACJ;GACD,SAAS;IACP,SAAS;IACT,GAAG;IACH,GAAG;IACJ;GACF;YAED,oBAACA;GACC,OAAO;GACI;GACX,KAAK;GACL;GACA,SAAS;GACT,GAAI;aAEH;IACO;GACC;EAGlB;AAED,iBAAiB,cAAc;AAE/B,+BAAe"}
@@ -1,8 +1,8 @@
1
1
  import { FormModalProps } from "./type.mjs";
2
- import * as react56 from "react";
2
+ import * as react9 from "react";
3
3
 
4
4
  //#region src/FormModal/FormModal.d.ts
5
- declare const FormModal: react56.NamedExoticComponent<FormModalProps>;
5
+ declare const FormModal: react9.NamedExoticComponent<FormModalProps>;
6
6
  //#endregion
7
7
  export { FormModal };
8
8
  //# sourceMappingURL=FormModal.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { GuideCardProps } from "./type.mjs";
2
- import * as react118 from "react";
2
+ import * as react129 from "react";
3
3
 
4
4
  //#region src/GuideCard/GuideCard.d.ts
5
- declare const GuideCard: react118.NamedExoticComponent<GuideCardProps>;
5
+ declare const GuideCard: react129.NamedExoticComponent<GuideCardProps>;
6
6
  //#endregion
7
7
  export { GuideCard };
8
8
  //# sourceMappingURL=GuideCard.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { HeaderProps } from "./type.mjs";
2
- import * as react50 from "react";
2
+ import * as react38 from "react";
3
3
 
4
4
  //#region src/Header/Header.d.ts
5
- declare const Header: react50.NamedExoticComponent<HeaderProps>;
5
+ declare const Header: react38.NamedExoticComponent<HeaderProps>;
6
6
  //#endregion
7
7
  export { Header };
8
8
  //# sourceMappingURL=Header.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { HighlighterProps } from "./type.mjs";
2
- import * as react48 from "react";
2
+ import * as react33 from "react";
3
3
 
4
4
  //#region src/Highlighter/Highlighter.d.ts
5
- declare const Highlighter: react48.NamedExoticComponent<HighlighterProps>;
5
+ declare const Highlighter: react33.NamedExoticComponent<HighlighterProps>;
6
6
  //#endregion
7
7
  export { Highlighter };
8
8
  //# sourceMappingURL=Highlighter.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { SyntaxHighlighterProps } from "../type.mjs";
2
- import * as react49 from "react";
2
+ import * as react34 from "react";
3
3
 
4
4
  //#region src/Highlighter/SyntaxHighlighter/index.d.ts
5
- declare const SyntaxHighlighter: react49.NamedExoticComponent<SyntaxHighlighterProps>;
5
+ declare const SyntaxHighlighter: react34.NamedExoticComponent<SyntaxHighlighterProps>;
6
6
  //#endregion
7
7
  export { SyntaxHighlighter };
8
8
  //# sourceMappingURL=index.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { HotkeyProps } from "./type.mjs";
2
- import * as react47 from "react";
2
+ import * as react40 from "react";
3
3
 
4
4
  //#region src/Hotkey/Hotkey.d.ts
5
- declare const Hotkey: react47.NamedExoticComponent<HotkeyProps>;
5
+ declare const Hotkey: react40.NamedExoticComponent<HotkeyProps>;
6
6
  //#endregion
7
7
  export { Hotkey };
8
8
  //# sourceMappingURL=Hotkey.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { HotkeyInputProps } from "./type.mjs";
2
- import * as react46 from "react";
2
+ import * as react39 from "react";
3
3
 
4
4
  //#region src/HotkeyInput/HotkeyInput.d.ts
5
- declare const HotkeyInput: react46.NamedExoticComponent<HotkeyInputProps>;
5
+ declare const HotkeyInput: react39.NamedExoticComponent<HotkeyInputProps>;
6
6
  //#endregion
7
7
  export { HotkeyInput };
8
8
  //# sourceMappingURL=HotkeyInput.d.mts.map
@@ -4,6 +4,8 @@ import FlexBasic_default from "../Flex/FlexBasic.mjs";
4
4
  import { NORMATIVE_MODIFIER, checkIsAppleDevice, splitKeysByPlus } from "../Hotkey/utils.mjs";
5
5
  import Hotkey_default from "../Hotkey/Hotkey.mjs";
6
6
  import ActionIcon_default from "../ActionIcon/ActionIcon.mjs";
7
+ import { useTranslation } from "../i18n/useTranslation.mjs";
8
+ import hotkey_default from "../i18n/resources/en/hotkey.mjs";
7
9
  import { useStyles } from "./style.mjs";
8
10
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
9
11
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -14,12 +16,13 @@ import { isEqual } from "lodash-es";
14
16
  import { useHotkeys, useRecordHotkeys } from "react-hotkeys-hook";
15
17
 
16
18
  //#region src/HotkeyInput/HotkeyInput.tsx
17
- const HotkeyInput = memo(({ value = "", defaultValue = "", resetValue = "", onChange, onConflict, placeholder = "Press keys to record shortcut", disabled, shadow, allowReset = true, style, className, hotkeyConflicts = [], variant, texts, isApple, onBlur, onReset, onFocus }) => {
19
+ const HotkeyInput = memo(({ value = "", defaultValue = "", resetValue = "", onChange, onConflict, placeholder, disabled, shadow, allowReset = true, style, className, hotkeyConflicts = [], variant, texts, isApple, onBlur, onReset, onFocus }) => {
18
20
  const [isFocused, setIsFocused] = useState(false);
19
21
  const [hasConflict, setHasConflict] = useState(false);
20
22
  const [hasInvalidCombination, setHasInvalidCombination] = useState(false);
21
23
  const inputRef = useRef(null);
22
24
  const { cx, styles, theme } = useStyles();
25
+ const { t } = useTranslation(hotkey_default);
23
26
  const isAppleDevice = useMemo(() => checkIsAppleDevice(isApple), [isApple]);
24
27
  const [hotkeyValue, setHotkeyValue] = useMergeState(defaultValue, {
25
28
  defaultValue,
@@ -151,6 +154,10 @@ const HotkeyInput = memo(({ value = "", defaultValue = "", resetValue = "", onCh
151
154
  if (disabled || isFocused) return;
152
155
  inputRef.current?.focus();
153
156
  };
157
+ const placeholderText = placeholder ?? t("hotkey.placeholder");
158
+ const resetTitle = texts?.reset ?? t("hotkey.reset");
159
+ const conflictText = texts?.conflicts ?? t("hotkey.conflict");
160
+ const invalidText = texts?.invalidCombination ?? t("hotkey.invalidCombination");
154
161
  return /* @__PURE__ */ jsxs(FlexBasic_default, {
155
162
  className,
156
163
  gap: 8,
@@ -176,10 +183,10 @@ const HotkeyInput = memo(({ value = "", defaultValue = "", resetValue = "", onCh
176
183
  style: { pointerEvents: "none" },
177
184
  children: isRecording ? /* @__PURE__ */ jsx("span", {
178
185
  className: styles.placeholder,
179
- children: keys.length > 0 ? /* @__PURE__ */ jsx(Hotkey_default, { keys: keysString }) : placeholder
186
+ children: keys.length > 0 ? /* @__PURE__ */ jsx(Hotkey_default, { keys: keysString }) : placeholderText
180
187
  }) : hotkeyValue ? /* @__PURE__ */ jsx(Hotkey_default, { keys: hotkeyValue }) : /* @__PURE__ */ jsx("span", {
181
188
  className: styles.placeholder,
182
- children: placeholder
189
+ children: placeholderText
183
190
  })
184
191
  }),
185
192
  /* @__PURE__ */ jsx("input", {
@@ -195,18 +202,18 @@ const HotkeyInput = memo(({ value = "", defaultValue = "", resetValue = "", onCh
195
202
  icon: Undo2Icon,
196
203
  onClick: handleReset,
197
204
  size: "small",
198
- title: texts?.reset || "Reset to default",
205
+ title: resetTitle,
199
206
  variant: "filled"
200
207
  })
201
208
  ]
202
209
  }),
203
210
  hasConflict && /* @__PURE__ */ jsx("div", {
204
211
  className: styles.errorText,
205
- children: texts?.conflicts || "This shortcut conflicts with an existing one."
212
+ children: conflictText
206
213
  }),
207
214
  hasInvalidCombination && /* @__PURE__ */ jsx("div", {
208
215
  className: styles.errorText,
209
- children: texts?.invalidCombination || "Shortcut must include a modifier key (Ctrl, Alt, Shift) and only one regular key."
216
+ children: invalidText
210
217
  })
211
218
  ]
212
219
  });
@@ -1 +1 @@
1
- {"version":3,"file":"HotkeyInput.mjs","names":["useControlledState","modifiers: string[]","normalKeys: string[]","normalizedKey: any","Flexbox","Hotkey","ActionIcon"],"sources":["../../src/HotkeyInput/HotkeyInput.tsx"],"sourcesContent":["'use client';\n\nimport type { InputRef } from 'antd';\nimport { cva } from 'class-variance-authority';\nimport { isEqual } from 'lodash-es';\nimport { Undo2Icon } from 'lucide-react';\nimport {\n type FocusEvent,\n type MouseEvent,\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useHotkeys, useRecordHotkeys } from 'react-hotkeys-hook';\nimport useControlledState from 'use-merge-value';\n\nimport ActionIcon from '@/ActionIcon';\nimport { Flexbox } from '@/Flex';\nimport Hotkey from '@/Hotkey';\nimport { NORMATIVE_MODIFIER, checkIsAppleDevice, splitKeysByPlus } from '@/Hotkey/utils';\n\nimport { useStyles } from './style';\nimport type { HotkeyInputProps } from './type';\n\nconst HotkeyInput = memo<HotkeyInputProps>(\n ({\n value = '',\n defaultValue = '',\n resetValue = '',\n onChange,\n onConflict,\n placeholder = 'Press keys to record shortcut',\n disabled,\n shadow,\n allowReset = true,\n style,\n className,\n hotkeyConflicts = [],\n variant,\n texts,\n isApple,\n onBlur,\n onReset,\n onFocus,\n }) => {\n const [isFocused, setIsFocused] = useState(false);\n const [hasConflict, setHasConflict] = useState(false);\n const [hasInvalidCombination, setHasInvalidCombination] = useState(false);\n const inputRef = useRef<InputRef>(null);\n const { cx, styles, theme } = useStyles();\n const isAppleDevice = useMemo(() => checkIsAppleDevice(isApple), [isApple]);\n const [hotkeyValue, setHotkeyValue] = useControlledState(defaultValue, {\n defaultValue,\n onChange,\n value,\n });\n\n const variants = useMemo(\n () =>\n cva(styles.root, {\n defaultVariants: {\n disabled: false,\n error: false,\n shadow: false,\n variant: 'outlined',\n },\n /* eslint-disable sort-keys-fix/sort-keys-fix */\n variants: {\n variant: {\n filled: styles.filled,\n outlined: styles.outlined,\n borderless: styles.borderless,\n },\n shadow: {\n false: null,\n true: styles.shadow,\n },\n focused: {\n false: null,\n true: styles.focused,\n },\n error: {\n fales: null,\n true: styles.error,\n },\n disabled: {\n false: null,\n true: styles.disabled,\n },\n },\n /* eslint-enable sort-keys-fix/sort-keys-fix */\n }),\n [styles],\n );\n\n // 使用 useRecordHotkeys 处理快捷键录入\n const [recordedKeys, { start, stop, isRecording, resetKeys }] = useRecordHotkeys();\n\n useHotkeys(\n '*',\n () => {\n inputRef.current?.blur();\n },\n {\n enableOnContentEditable: true,\n enableOnFormTags: true,\n enabled: isRecording && !disabled,\n keydown: false,\n keyup: true,\n preventDefault: true,\n },\n );\n\n // 处理按键,保证格式正确:修饰键在前,最多一个非修饰键在后\n const formatKeys = useCallback((keysSet: Set<string>) => {\n const modifiers: string[] = [];\n const normalKeys: string[] = [];\n\n for (const key of keysSet) {\n // 处理不同表示的修饰键\n const normalizedKey: any = key.toLowerCase();\n if (NORMATIVE_MODIFIER.includes(normalizedKey)) {\n // 统一修饰键表示\n if (\n (!isAppleDevice && normalizedKey === 'ctrl') ||\n (isAppleDevice && normalizedKey === 'meta')\n ) {\n if (!modifiers.includes('mod')) modifiers.push('mod');\n } else if (!modifiers.includes(normalizedKey)) {\n modifiers.push(normalizedKey);\n }\n } else {\n normalKeys.push(key);\n }\n }\n\n // 至少需要一个修饰键\n if (modifiers.length === 0 && normalKeys.length > 0) {\n return { isValid: false, keys: [] };\n }\n\n // 只允许一个非修饰键,如果有多个,只保留最后一个\n const finalKey = normalKeys.length > 0 ? [normalKeys.at(-1)] : [];\n const shortcuts = [modifiers, finalKey];\n\n return {\n // 组合必须包含至少一个按键\n isValid: shortcuts.every((k) => k.length > 0),\n keys: shortcuts.flat(),\n };\n }, []);\n\n // 获取格式化后的按键字符串\n const { isValid, keys } = formatKeys(recordedKeys);\n const keysString = keys.join('+');\n\n // 检查快捷键冲突\n const checkHotkeyConflict = useCallback(\n (newHotkey: string): boolean => {\n return hotkeyConflicts\n .filter((conflictKey) => conflictKey !== resetValue)\n .some((conflictKey) => {\n const newKeys = splitKeysByPlus(newHotkey);\n const conflictKeys = splitKeysByPlus(conflictKey);\n return isEqual(newKeys, conflictKeys);\n });\n },\n [hotkeyConflicts],\n );\n\n // 当按键组合完成时处理结果\n useEffect(() => {\n if (recordedKeys.size > 0 && !isRecording) {\n if (!isValid) {\n setHasInvalidCombination(true);\n setHasConflict(false);\n return;\n }\n\n setHasInvalidCombination(false);\n const newKeysString = keysString;\n\n // 检查冲突\n const conflict = checkHotkeyConflict(newKeysString);\n if (conflict) {\n setHasConflict(true);\n onConflict?.(newKeysString);\n } else {\n setHasConflict(false);\n setHotkeyValue?.(newKeysString);\n }\n }\n }, [\n recordedKeys,\n isRecording,\n isValid,\n keysString,\n checkHotkeyConflict,\n setHotkeyValue,\n onConflict,\n ]);\n\n // 处理输入框焦点\n const handleFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (disabled) return;\n setIsFocused(true);\n setHasConflict(false);\n setHasInvalidCombination(false);\n start(); // 开始记录\n onFocus?.(e);\n };\n\n const handleBlur = (e: FocusEvent<HTMLInputElement>) => {\n setIsFocused(false);\n stop(); // 停止记录\n onBlur?.(e);\n };\n\n // 重置功能\n const handleReset = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setHotkeyValue?.(resetValue);\n resetKeys();\n setHasConflict(false);\n setHasInvalidCombination(false);\n setIsFocused(false);\n stop(); // 停止记录\n onReset?.(hotkeyValue, resetValue);\n };\n\n const handleClick = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n if (disabled || isFocused) return;\n inputRef.current?.focus();\n };\n\n return (\n <Flexbox\n className={className}\n gap={8}\n style={{\n position: 'relative',\n ...style,\n }}\n >\n <Flexbox\n align={'center'}\n className={cx(\n variants({\n disabled,\n error: hasConflict || hasInvalidCombination,\n focused: isFocused,\n shadow,\n variant: variant || (theme.isDarkMode ? 'filled' : 'outlined'),\n }),\n )}\n horizontal\n justify={'space-between'}\n onClick={handleClick}\n >\n <div style={{ pointerEvents: 'none' }}>\n {isRecording ? (\n <span className={styles.placeholder}>\n {keys.length > 0 ? <Hotkey keys={keysString} /> : placeholder}\n </span>\n ) : hotkeyValue ? (\n <Hotkey keys={hotkeyValue} />\n ) : (\n <span className={styles.placeholder}>{placeholder}</span>\n )}\n </div>\n\n {/* 隐藏的输入框,用于接收焦点 */}\n <input\n className={styles.hiddenInput}\n disabled={disabled}\n onBlur={handleBlur}\n onFocus={handleFocus}\n readOnly\n ref={inputRef as any}\n style={{ pointerEvents: 'none' }}\n />\n\n {!isFocused && allowReset && hotkeyValue && hotkeyValue !== resetValue && !disabled && (\n <ActionIcon\n icon={Undo2Icon}\n onClick={handleReset}\n size={'small'}\n title={texts?.reset || 'Reset to default'}\n variant={'filled'}\n />\n )}\n </Flexbox>\n {hasConflict && (\n <div className={styles.errorText}>\n {texts?.conflicts || 'This shortcut conflicts with an existing one.'}\n </div>\n )}\n {hasInvalidCombination && (\n <div className={styles.errorText}>\n {texts?.invalidCombination ||\n 'Shortcut must include a modifier key (Ctrl, Alt, Shift) and only one regular key.'}\n </div>\n )}\n </Flexbox>\n );\n },\n);\n\nHotkeyInput.displayName = 'HotkeyInput';\n\nexport default HotkeyInput;\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,MAAM,cAAc,MACjB,EACC,QAAQ,IACR,eAAe,IACf,aAAa,IACb,UACA,YACA,cAAc,iCACd,UACA,QACA,aAAa,MACb,OACA,WACA,kBAAkB,EAAE,EACpB,SACA,OACA,SACA,QACA,SACA,cACI;CACJ,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,aAAa,kBAAkB,SAAS,MAAM;CACrD,MAAM,CAAC,uBAAuB,4BAA4B,SAAS,MAAM;CACzE,MAAM,WAAW,OAAiB,KAAK;CACvC,MAAM,EAAE,IAAI,QAAQ,UAAU,WAAW;CACzC,MAAM,gBAAgB,cAAc,mBAAmB,QAAQ,EAAE,CAAC,QAAQ,CAAC;CAC3E,MAAM,CAAC,aAAa,kBAAkBA,cAAmB,cAAc;EACrE;EACA;EACA;EACD,CAAC;CAEF,MAAM,WAAW,cAEb,IAAI,OAAO,MAAM;EACf,iBAAiB;GACf,UAAU;GACV,OAAO;GACP,QAAQ;GACR,SAAS;GACV;EAED,UAAU;GACR,SAAS;IACP,QAAQ,OAAO;IACf,UAAU,OAAO;IACjB,YAAY,OAAO;IACpB;GACD,QAAQ;IACN,OAAO;IACP,MAAM,OAAO;IACd;GACD,SAAS;IACP,OAAO;IACP,MA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OAAO;iBACrB,KAAK,SAAS,IAAI,oBAACC,kBAAO,MAAM,aAAc,GAAG;QAC7C,GACL,cACF,oBAACA,kBAAO,MAAM,cAAe,GAE7B,oBAAC;OAAK,WAAW,OAAO;iBAAc;QAAmB;OAEvD;KAGN,oBAAC;MACC,WAAW,OAAO;MACR;MACV,QAAQ;MACR,SAAS;MACT;MACA,KAAK;MACL,OAAO,EAAE,eAAe,QAAQ;OAChC;KAED,CAAC,aAAa,cAAc,eAAe,gBAAgB,cAAc,CAAC,YACzE,oBAACC;MACC,MAAM;MACN,SAAS;MACT,MAAM;MACN,OAAO,OAAO,SAAS;MACvB,SAAS;OACT;;KAEI;GACT,eACC,oBAAC;IAAI,WAAW,OAAO;cACpB,OAAO,aAAa;KACjB;GAEP,yBACC,oBAAC;IAAI,WAAW,OAAO;cACpB,OAAO,sBACN;KACE;;GAEA;EAGf;AAED,YAAY,cAAc;AAE1B,0BAAe"}
1
+ {"version":3,"file":"HotkeyInput.mjs","names":["hotkeyMessages","useControlledState","modifiers: string[]","normalKeys: string[]","normalizedKey: any","Flexbox","Hotkey","ActionIcon"],"sources":["../../src/HotkeyInput/HotkeyInput.tsx"],"sourcesContent":["'use client';\n\nimport type { InputRef } from 'antd';\nimport { cva } from 'class-variance-authority';\nimport { isEqual } from 'lodash-es';\nimport { Undo2Icon } from 'lucide-react';\nimport {\n type FocusEvent,\n type MouseEvent,\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useHotkeys, useRecordHotkeys } from 'react-hotkeys-hook';\nimport useControlledState from 'use-merge-value';\n\nimport ActionIcon from '@/ActionIcon';\nimport { Flexbox } from '@/Flex';\nimport Hotkey from '@/Hotkey';\nimport { NORMATIVE_MODIFIER, checkIsAppleDevice, splitKeysByPlus } from '@/Hotkey/utils';\nimport hotkeyMessages from '@/i18n/resources/en/hotkey';\nimport { useTranslation } from '@/i18n/useTranslation';\n\nimport { useStyles } from './style';\nimport type { HotkeyInputProps } from './type';\n\nconst HotkeyInput = memo<HotkeyInputProps>(\n ({\n value = '',\n defaultValue = '',\n resetValue = '',\n onChange,\n onConflict,\n placeholder,\n disabled,\n shadow,\n allowReset = true,\n style,\n className,\n hotkeyConflicts = [],\n variant,\n texts,\n isApple,\n onBlur,\n onReset,\n onFocus,\n }) => {\n const [isFocused, setIsFocused] = useState(false);\n const [hasConflict, setHasConflict] = useState(false);\n const [hasInvalidCombination, setHasInvalidCombination] = useState(false);\n const inputRef = useRef<InputRef>(null);\n const { cx, styles, theme } = useStyles();\n const { t } = useTranslation(hotkeyMessages);\n const isAppleDevice = useMemo(() => checkIsAppleDevice(isApple), [isApple]);\n const [hotkeyValue, setHotkeyValue] = useControlledState(defaultValue, {\n defaultValue,\n onChange,\n value,\n });\n\n const variants = useMemo(\n () =>\n cva(styles.root, {\n defaultVariants: {\n disabled: false,\n error: false,\n shadow: false,\n variant: 'outlined',\n },\n /* eslint-disable sort-keys-fix/sort-keys-fix */\n variants: {\n variant: {\n filled: styles.filled,\n outlined: styles.outlined,\n borderless: styles.borderless,\n },\n shadow: {\n false: null,\n true: styles.shadow,\n },\n focused: {\n false: null,\n true: styles.focused,\n },\n error: {\n fales: null,\n true: styles.error,\n },\n disabled: {\n false: null,\n true: styles.disabled,\n },\n },\n /* eslint-enable sort-keys-fix/sort-keys-fix */\n }),\n [styles],\n );\n\n // 使用 useRecordHotkeys 处理快捷键录入\n const [recordedKeys, { start, stop, isRecording, resetKeys }] = useRecordHotkeys();\n\n useHotkeys(\n '*',\n () => {\n inputRef.current?.blur();\n },\n {\n enableOnContentEditable: true,\n enableOnFormTags: true,\n enabled: isRecording && !disabled,\n keydown: false,\n keyup: true,\n preventDefault: true,\n },\n );\n\n // 处理按键,保证格式正确:修饰键在前,最多一个非修饰键在后\n const formatKeys = useCallback((keysSet: Set<string>) => {\n const modifiers: string[] = [];\n const normalKeys: string[] = [];\n\n for (const key of keysSet) {\n // 处理不同表示的修饰键\n const normalizedKey: any = key.toLowerCase();\n if (NORMATIVE_MODIFIER.includes(normalizedKey)) {\n // 统一修饰键表示\n if (\n (!isAppleDevice && normalizedKey === 'ctrl') ||\n (isAppleDevice && normalizedKey === 'meta')\n ) {\n if (!modifiers.includes('mod')) modifiers.push('mod');\n } else if (!modifiers.includes(normalizedKey)) {\n modifiers.push(normalizedKey);\n }\n } else {\n normalKeys.push(key);\n }\n }\n\n // 至少需要一个修饰键\n if (modifiers.length === 0 && normalKeys.length > 0) {\n return { isValid: false, keys: [] };\n }\n\n // 只允许一个非修饰键,如果有多个,只保留最后一个\n const finalKey = normalKeys.length > 0 ? [normalKeys.at(-1)] : [];\n const shortcuts = [modifiers, finalKey];\n\n return {\n // 组合必须包含至少一个按键\n isValid: shortcuts.every((k) => k.length > 0),\n keys: shortcuts.flat(),\n };\n }, []);\n\n // 获取格式化后的按键字符串\n const { isValid, keys } = formatKeys(recordedKeys);\n const keysString = keys.join('+');\n\n // 检查快捷键冲突\n const checkHotkeyConflict = useCallback(\n (newHotkey: string): boolean => {\n return hotkeyConflicts\n .filter((conflictKey) => conflictKey !== resetValue)\n .some((conflictKey) => {\n const newKeys = splitKeysByPlus(newHotkey);\n const conflictKeys = splitKeysByPlus(conflictKey);\n return isEqual(newKeys, conflictKeys);\n });\n },\n [hotkeyConflicts],\n );\n\n // 当按键组合完成时处理结果\n useEffect(() => {\n if (recordedKeys.size > 0 && !isRecording) {\n if (!isValid) {\n setHasInvalidCombination(true);\n setHasConflict(false);\n return;\n }\n\n setHasInvalidCombination(false);\n const newKeysString = keysString;\n\n // 检查冲突\n const conflict = checkHotkeyConflict(newKeysString);\n if (conflict) {\n setHasConflict(true);\n onConflict?.(newKeysString);\n } else {\n setHasConflict(false);\n setHotkeyValue?.(newKeysString);\n }\n }\n }, [\n recordedKeys,\n isRecording,\n isValid,\n keysString,\n checkHotkeyConflict,\n setHotkeyValue,\n onConflict,\n ]);\n\n // 处理输入框焦点\n const handleFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (disabled) return;\n setIsFocused(true);\n setHasConflict(false);\n setHasInvalidCombination(false);\n start(); // 开始记录\n onFocus?.(e);\n };\n\n const handleBlur = (e: FocusEvent<HTMLInputElement>) => {\n setIsFocused(false);\n stop(); // 停止记录\n onBlur?.(e);\n };\n\n // 重置功能\n const handleReset = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setHotkeyValue?.(resetValue);\n resetKeys();\n setHasConflict(false);\n setHasInvalidCombination(false);\n setIsFocused(false);\n stop(); // 停止记录\n onReset?.(hotkeyValue, resetValue);\n };\n\n const handleClick = (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n if (disabled || isFocused) return;\n inputRef.current?.focus();\n };\n\n const placeholderText = placeholder ?? t('hotkey.placeholder');\n const resetTitle = texts?.reset ?? t('hotkey.reset');\n const conflictText = texts?.conflicts ?? t('hotkey.conflict');\n const invalidText = texts?.invalidCombination ?? t('hotkey.invalidCombination');\n\n return (\n <Flexbox\n className={className}\n gap={8}\n style={{\n position: 'relative',\n ...style,\n }}\n >\n <Flexbox\n align={'center'}\n className={cx(\n variants({\n disabled,\n error: hasConflict || hasInvalidCombination,\n focused: isFocused,\n shadow,\n variant: variant || (theme.isDarkMode ? 'filled' : 'outlined'),\n }),\n )}\n horizontal\n justify={'space-between'}\n onClick={handleClick}\n >\n <div style={{ pointerEvents: 'none' }}>\n {isRecording ? (\n <span className={styles.placeholder}>\n {keys.length > 0 ? <Hotkey keys={keysString} /> : placeholderText}\n </span>\n ) : hotkeyValue ? (\n <Hotkey keys={hotkeyValue} />\n ) : (\n <span className={styles.placeholder}>{placeholderText}</span>\n )}\n </div>\n\n {/* 隐藏的输入框,用于接收焦点 */}\n <input\n className={styles.hiddenInput}\n disabled={disabled}\n onBlur={handleBlur}\n onFocus={handleFocus}\n readOnly\n ref={inputRef as any}\n style={{ pointerEvents: 'none' }}\n />\n\n {!isFocused && allowReset && hotkeyValue && hotkeyValue !== resetValue && !disabled && (\n <ActionIcon\n icon={Undo2Icon}\n onClick={handleReset}\n size={'small'}\n title={resetTitle}\n variant={'filled'}\n />\n )}\n </Flexbox>\n {hasConflict && <div className={styles.errorText}>{conflictText}</div>}\n {hasInvalidCombination && <div className={styles.errorText}>{invalidText}</div>}\n </Flexbox>\n );\n },\n);\n\nHotkeyInput.displayName = 'HotkeyInput';\n\nexport default HotkeyInput;\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,MAAM,cAAc,MACjB,EACC,QAAQ,IACR,eAAe,IACf,aAAa,IACb,UACA,YACA,aACA,UACA,QACA,aAAa,MACb,OACA,WACA,kBAAkB,EAAE,EACpB,SACA,OACA,SACA,QACA,SACA,cACI;CACJ,MAAM,CAAC,WAAW,gBAAgB,SAAS,MAAM;CACjD,MAAM,CAAC,aAAa,kBAAkB,SAAS,MAAM;CACrD,MAAM,CAAC,uBAAuB,4BAA4B,SAAS,MAAM;CACzE,MAAM,WAAW,OAAiB,KAAK;CACvC,MAAM,EAAE,IAAI,QAAQ,UAAU,WAAW;CACzC,MAAM,EAAE,MAAM,eAAeA,eAAe;CAC5C,MAAM,gBAAgB,cAAc,mBAAmB,QAAQ,EAAE,CAAC,QAAQ,CAAC;CAC3E,MAAM,CAAC,aAAa,kBAAkBC,cAAmB,cAAc;EACrE;EACA;EACA;EACD,CAAC;CAEF,MAAM,WAAW,cAEb,IAAI,OAAO,MAAM;EACf,iBAAiB;GACf,UAAU;GACV,OAAO;GACP,QAAQ;GACR,SAAS;GACV;EAED,UAAU;GACR,SAAS;IACP,QAAQ,OAAO;IACf,UAAU,OAAO;IACjB,YAAY,OAAO;IACpB;GACD,QAAQ;IACN,OAAO;IACP,MAAM,OAAO;IACd;GACD,SAAS;IACP,OAAO;IACP,MAAM,OAAO;IACd;GACD,OAAO;IACL,OAAO;IACP,MAAM,OAAO;IACd;GACD,UAAU;IACR,OAAO;IACP,MAAM,OAAO;IACd;GACF;EAEF,CAAC,EACJ,CAAC,OAAO,CACT;CAGD,MAAM,CAAC,cAAc,EAAE,OAAO,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,OAAO;iBACrB,KAAK,SAAS,IAAI,oBAACC,kBAAO,MAAM,aAAc,GAAG;QAC7C,GACL,cACF,oBAACA,kBAAO,MAAM,cAAe,GAE7B,oBAAC;OAAK,WAAW,OAAO;iBAAc;QAAuB;OAE3D;KAGN,oBAAC;MACC,WAAW,OAAO;MACR;MACV,QAAQ;MACR,SAAS;MACT;MACA,KAAK;MACL,OAAO,EAAE,eAAe,QAAQ;OAChC;KAED,CAAC,aAAa,cAAc,eAAe,gBAAgB,cAAc,CAAC,YACzE,oBAACC;MACC,MAAM;MACN,SAAS;MACT,MAAM;MACN,OAAO;MACP,SAAS;OACT;;KAEI;GACT,eAAe,oBAAC;IAAI,WAAW,OAAO;cAAY;KAAmB;GACrE,yBAAyB,oBAAC;IAAI,WAAW,OAAO;cAAY;KAAkB;;GACvE;EAGf;AAED,YAAY,cAAc;AAE1B,0BAAe"}
@@ -1,8 +1,8 @@
1
1
  import { IconProps } from "./type.mjs";
2
- import * as react45 from "react";
2
+ import * as react37 from "react";
3
3
 
4
4
  //#region src/Icon/Icon.d.ts
5
- declare const Icon: react45.NamedExoticComponent<IconProps>;
5
+ declare const Icon: react37.NamedExoticComponent<IconProps>;
6
6
  //#endregion
7
7
  export { Icon };
8
8
  //# sourceMappingURL=Icon.d.mts.map
@@ -1,11 +1,11 @@
1
1
  import { IconProps } from "../type.mjs";
2
- import * as react43 from "react";
2
+ import * as react35 from "react";
3
3
  import { ReactNode } from "react";
4
4
 
5
5
  //#region src/Icon/components/IconProvider.d.ts
6
6
  type IconContentConfig = Omit<IconProps, 'icon' | 'ref'>;
7
- declare const IconContext: react43.Context<IconContentConfig>;
8
- declare const IconProvider: react43.NamedExoticComponent<{
7
+ declare const IconContext: react35.Context<IconContentConfig>;
8
+ declare const IconProvider: react35.NamedExoticComponent<{
9
9
  children: ReactNode;
10
10
  config?: IconContentConfig;
11
11
  }>;
@@ -1,8 +1,8 @@
1
1
  import { PreviewGroupProps } from "./type.mjs";
2
- import * as react40 from "react";
2
+ import * as react26 from "react";
3
3
 
4
4
  //#region src/Image/PreviewGroup.d.ts
5
- declare const PreviewGroup: react40.NamedExoticComponent<PreviewGroupProps>;
5
+ declare const PreviewGroup: react26.NamedExoticComponent<PreviewGroupProps>;
6
6
  //#endregion
7
7
  export { PreviewGroup };
8
8
  //# sourceMappingURL=PreviewGroup.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { ImageSelectProps } from "./type.mjs";
2
- import * as react103 from "react";
2
+ import * as react106 from "react";
3
3
 
4
4
  //#region src/ImageSelect/ImageSelect.d.ts
5
- declare const ImageSelect: react103.NamedExoticComponent<ImageSelectProps>;
5
+ declare const ImageSelect: react106.NamedExoticComponent<ImageSelectProps>;
6
6
  //#endregion
7
7
  export { ImageSelect };
8
8
  //# sourceMappingURL=ImageSelect.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { InputProps } from "./type.mjs";
2
- import * as react119 from "react";
2
+ import * as react131 from "react";
3
3
 
4
4
  //#region src/Input/Input.d.ts
5
- declare const Input: react119.NamedExoticComponent<InputProps>;
5
+ declare const Input: react131.NamedExoticComponent<InputProps>;
6
6
  //#endregion
7
7
  export { Input };
8
8
  //# sourceMappingURL=Input.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { InputNumberProps } from "./type.mjs";
2
- import * as react120 from "react";
2
+ import * as react130 from "react";
3
3
 
4
4
  //#region src/Input/InputNumber.d.ts
5
- declare const InputNumber: react120.NamedExoticComponent<InputNumberProps>;
5
+ declare const InputNumber: react130.NamedExoticComponent<InputNumberProps>;
6
6
  //#endregion
7
7
  export { InputNumber };
8
8
  //# sourceMappingURL=InputNumber.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { InputOPTProps } from "./type.mjs";
2
- import * as react121 from "react";
2
+ import * as react132 from "react";
3
3
 
4
4
  //#region src/Input/InputOPT.d.ts
5
- declare const InputOPT: react121.NamedExoticComponent<InputOPTProps>;
5
+ declare const InputOPT: react132.NamedExoticComponent<InputOPTProps>;
6
6
  //#endregion
7
7
  export { InputOPT };
8
8
  //# sourceMappingURL=InputOPT.d.mts.map
@@ -1,8 +1,8 @@
1
1
  import { InputPasswordProps } from "./type.mjs";
2
- import * as react122 from "react";
2
+ import * as react134 from "react";
3
3
 
4
4
  //#region src/Input/InputPassword.d.ts
5
- declare const InputPassword: react122.NamedExoticComponent<InputPasswordProps>;
5
+ declare const InputPassword: react134.NamedExoticComponent<InputPasswordProps>;
6
6
  //#endregion
7
7
  export { InputPassword };
8
8
  //# sourceMappingURL=InputPassword.d.mts.map