@yuntijs/ui 1.0.0-beta.8 → 1.0.0-beta.80

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 (239) hide show
  1. package/es/Alert/index.d.ts +13 -0
  2. package/es/Alert/index.js +25 -0
  3. package/es/Alert/style.d.ts +4 -0
  4. package/es/Alert/style.js +13 -0
  5. package/es/App/index.d.ts +7 -0
  6. package/es/App/index.js +19 -0
  7. package/es/ButtonGroup/index.d.ts +24 -0
  8. package/es/ButtonGroup/index.js +66 -0
  9. package/es/Card/index.d.ts +1 -0
  10. package/es/Card/index.js +1 -0
  11. package/es/CardList/Item/index.d.ts +4 -0
  12. package/es/CardList/Item/index.js +43 -0
  13. package/es/CardList/Item/style.d.ts +0 -0
  14. package/es/CardList/Item/style.js +0 -0
  15. package/es/CardList/index.d.ts +2 -0
  16. package/es/CardList/index.js +39 -0
  17. package/es/ChatInputArea/desktop/ChatInputArea.d.ts +19 -0
  18. package/es/ChatInputArea/desktop/ChatInputArea.js +72 -0
  19. package/es/ChatInputArea/index.d.ts +6 -0
  20. package/es/ChatInputArea/index.js +6 -0
  21. package/es/ChatItem/components/MessageContent.d.ts +21 -0
  22. package/es/ChatItem/components/MessageContent.js +59 -0
  23. package/es/ChatItem/index.d.ts +4 -0
  24. package/es/ChatItem/index.js +120 -0
  25. package/es/ChatItem/style.d.ts +24 -0
  26. package/es/ChatItem/style.js +38 -0
  27. package/es/ChatItem/type.d.ts +82 -0
  28. package/es/ChatItem/type.js +1 -0
  29. package/es/CollapseGroup/index.d.ts +4 -0
  30. package/es/CollapseGroup/index.js +23 -0
  31. package/es/CollapseGroup/style.d.ts +3 -0
  32. package/es/CollapseGroup/style.js +11 -0
  33. package/es/ConfigProvider/index.d.ts +3 -0
  34. package/es/ConfigProvider/index.js +17 -11
  35. package/es/Descriptions/index.d.ts +14 -0
  36. package/es/Descriptions/index.js +31 -0
  37. package/es/Descriptions/style.d.ts +4 -0
  38. package/es/Descriptions/style.js +24 -0
  39. package/es/Divider/index.d.ts +38 -0
  40. package/es/Divider/index.js +66 -0
  41. package/es/Divider/style.d.ts +3 -0
  42. package/es/Divider/style.js +12 -0
  43. package/es/DragPanel/index.d.ts +10 -0
  44. package/es/DragPanel/index.js +97 -0
  45. package/es/DragPanel/style.d.ts +7 -0
  46. package/es/DragPanel/style.js +15 -0
  47. package/es/Drawer/index.d.ts +13 -0
  48. package/es/Drawer/index.js +20 -0
  49. package/es/Drawer/style.d.ts +4 -0
  50. package/es/Drawer/style.js +16 -0
  51. package/es/Dropdown/index.d.ts +14 -0
  52. package/es/Dropdown/index.js +59 -0
  53. package/es/Dropdown/style.d.ts +7 -0
  54. package/es/Dropdown/style.js +13 -0
  55. package/es/EditableMessage/index.d.ts +75 -0
  56. package/es/EditableMessage/index.js +99 -0
  57. package/es/Form/collapse-list/index.d.ts +40 -0
  58. package/es/Form/collapse-list/index.js +209 -0
  59. package/es/Form/collapse-list/style.d.ts +5 -0
  60. package/es/Form/collapse-list/style.js +13 -0
  61. package/es/Form/index.d.ts +8 -0
  62. package/es/Form/index.js +5 -0
  63. package/es/FormHelper/autoFocus.d.ts +10 -0
  64. package/es/FormHelper/autoFocus.js +38 -0
  65. package/es/FormHelper/index.d.ts +13 -0
  66. package/es/FormHelper/index.js +41 -0
  67. package/es/Highlighter/FullFeatured.d.ts +18 -0
  68. package/es/Highlighter/FullFeatured.js +102 -0
  69. package/es/Highlighter/SyntaxHighlighter/index.d.ts +7 -0
  70. package/es/Highlighter/SyntaxHighlighter/index.js +51 -0
  71. package/es/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
  72. package/es/Highlighter/SyntaxHighlighter/style.js +16 -0
  73. package/es/Highlighter/index.d.ts +50 -0
  74. package/es/Highlighter/index.js +77 -0
  75. package/es/Highlighter/style.d.ts +9 -0
  76. package/es/Highlighter/style.js +23 -0
  77. package/es/Highlighter/theme.d.ts +1 -0
  78. package/es/Highlighter/theme.js +1661 -0
  79. package/es/LogViewer/index.d.ts +10 -0
  80. package/es/LogViewer/index.js +141 -0
  81. package/es/LogViewer/style.d.ts +6 -0
  82. package/es/LogViewer/style.js +16 -0
  83. package/es/LogViewer/types.d.ts +235 -0
  84. package/es/LogViewer/types.js +1 -0
  85. package/es/Mentions/constants.d.ts +6 -0
  86. package/es/Mentions/constants.js +28 -0
  87. package/es/Mentions/hooks.d.ts +20 -0
  88. package/es/Mentions/hooks.js +133 -0
  89. package/es/Mentions/index.d.ts +19 -0
  90. package/es/Mentions/index.js +136 -0
  91. package/es/Mentions/plugins/custom-text/node.d.ts +11 -0
  92. package/es/Mentions/plugins/custom-text/node.js +72 -0
  93. package/es/Mentions/plugins/mention-node/component.d.ts +6 -0
  94. package/es/Mentions/plugins/mention-node/component.js +64 -0
  95. package/es/Mentions/plugins/mention-node/index.d.ts +9 -0
  96. package/es/Mentions/plugins/mention-node/index.js +32 -0
  97. package/es/Mentions/plugins/mention-node/node.d.ts +23 -0
  98. package/es/Mentions/plugins/mention-node/node.js +97 -0
  99. package/es/Mentions/plugins/mention-node/replacement.d.ts +5 -0
  100. package/es/Mentions/plugins/mention-node/replacement.js +42 -0
  101. package/es/Mentions/plugins/mention-node/style.d.ts +8 -0
  102. package/es/Mentions/plugins/mention-node/style.js +47 -0
  103. package/es/Mentions/plugins/mention-node/utils.d.ts +4 -0
  104. package/es/Mentions/plugins/mention-node/utils.js +5 -0
  105. package/es/Mentions/plugins/mention-picker/hooks.d.ts +5 -0
  106. package/es/Mentions/plugins/mention-picker/hooks.js +39 -0
  107. package/es/Mentions/plugins/mention-picker/index.d.ts +36 -0
  108. package/es/Mentions/plugins/mention-picker/index.js +87 -0
  109. package/es/Mentions/plugins/mention-picker/menu-item.d.ts +11 -0
  110. package/es/Mentions/plugins/mention-picker/menu-item.js +71 -0
  111. package/es/Mentions/plugins/mention-picker/menu.d.ts +9 -0
  112. package/es/Mentions/plugins/mention-picker/menu.js +30 -0
  113. package/es/Mentions/plugins/mention-picker/style.d.ts +11 -0
  114. package/es/Mentions/plugins/mention-picker/style.js +19 -0
  115. package/es/Mentions/plugins/mention-picker/utils.d.ts +22 -0
  116. package/es/Mentions/plugins/mention-picker/utils.js +39 -0
  117. package/es/Mentions/plugins/on-blur-or-focus-block.d.ts +7 -0
  118. package/es/Mentions/plugins/on-blur-or-focus-block.js +36 -0
  119. package/es/Mentions/provider.d.ts +12 -0
  120. package/es/Mentions/provider.js +15 -0
  121. package/es/Mentions/style.d.ts +11 -0
  122. package/es/Mentions/style.js +22 -0
  123. package/es/Mentions/types.d.ts +17 -0
  124. package/es/Mentions/types.js +1 -0
  125. package/es/Mentions/utils.d.ts +9 -0
  126. package/es/Mentions/utils.js +95 -0
  127. package/es/Modal/index.d.ts +19 -0
  128. package/es/Modal/index.js +36 -0
  129. package/es/Modal/style.d.ts +4 -0
  130. package/es/Modal/style.js +17 -0
  131. package/es/MonacoEditor/base/controller.d.ts +17 -0
  132. package/es/MonacoEditor/base/controller.js +49 -0
  133. package/es/MonacoEditor/base/helper.d.ts +65 -0
  134. package/es/MonacoEditor/base/helper.js +324 -0
  135. package/es/MonacoEditor/base/index.d.ts +35 -0
  136. package/es/MonacoEditor/base/index.js +236 -0
  137. package/es/MonacoEditor/base/monaco.d.ts +6 -0
  138. package/es/MonacoEditor/base/monaco.js +64 -0
  139. package/es/MonacoEditor/base/style.d.ts +12 -0
  140. package/es/MonacoEditor/base/style.js +26 -0
  141. package/es/MonacoEditor/index.d.ts +2 -4
  142. package/es/MonacoEditor/index.js +26 -62
  143. package/es/MonacoEditor/style.js +3 -2
  144. package/es/Page/Breadcrumb/index.d.ts +9 -0
  145. package/es/Page/Breadcrumb/index.js +56 -0
  146. package/es/Page/Content/index.d.ts +4 -0
  147. package/es/Page/Content/index.js +59 -0
  148. package/es/Page/Content/style.d.ts +3 -0
  149. package/es/Page/Content/style.js +12 -0
  150. package/es/Page/Footer/index.d.ts +2 -0
  151. package/es/Page/Footer/index.js +6 -0
  152. package/es/Page/Header/Icon.d.ts +17 -0
  153. package/es/Page/Header/Icon.js +42 -0
  154. package/es/Page/Header/index.d.ts +43 -0
  155. package/es/Page/Header/index.js +202 -0
  156. package/es/Page/Header/style.d.ts +12 -0
  157. package/es/Page/Header/style.js +21 -0
  158. package/es/Page/Page.d.ts +9 -0
  159. package/es/Page/Page.js +49 -0
  160. package/es/Page/PageContext.d.ts +15 -0
  161. package/es/Page/PageContext.js +21 -0
  162. package/es/Page/Title/index.d.ts +5 -0
  163. package/es/Page/Title/index.js +18 -0
  164. package/es/Page/Title/style.d.ts +3 -0
  165. package/es/Page/Title/style.js +10 -0
  166. package/es/Page/index.d.ts +18 -0
  167. package/es/Page/index.js +15 -0
  168. package/es/Page/style.d.ts +3 -0
  169. package/es/Page/style.js +10 -0
  170. package/es/ProCard/Card/index.d.ts +6 -0
  171. package/es/ProCard/Card/index.js +25 -0
  172. package/es/ProCard/Card/style.d.ts +7 -0
  173. package/es/ProCard/Card/style.js +15 -0
  174. package/es/ProCard/Content/index.d.ts +4 -0
  175. package/es/ProCard/Content/index.js +24 -0
  176. package/es/ProCard/Content/style.d.ts +3 -0
  177. package/es/ProCard/Content/style.js +10 -0
  178. package/es/ProCard/Descriptions/index.d.ts +4 -0
  179. package/es/ProCard/Descriptions/index.js +28 -0
  180. package/es/ProCard/Descriptions/style.d.ts +3 -0
  181. package/es/ProCard/Descriptions/style.js +12 -0
  182. package/es/ProCard/Header/index.d.ts +15 -0
  183. package/es/ProCard/Header/index.js +86 -0
  184. package/es/ProCard/Header/style.d.ts +12 -0
  185. package/es/ProCard/Header/style.js +21 -0
  186. package/es/ProCard/index.d.ts +13 -0
  187. package/es/ProCard/index.js +8 -0
  188. package/es/Radio/index.d.ts +36 -0
  189. package/es/Radio/index.js +26 -0
  190. package/es/Radio/style.d.ts +4 -0
  191. package/es/Radio/style.js +66 -0
  192. package/es/SelectCard/index.d.ts +33 -0
  193. package/es/SelectCard/index.js +132 -0
  194. package/es/SelectCard/style.d.ts +10 -0
  195. package/es/SelectCard/style.js +42 -0
  196. package/es/SliderInput/index.js +2 -2
  197. package/es/Status/index.d.ts +7 -0
  198. package/es/Status/index.js +39 -0
  199. package/es/Status/style.d.ts +4 -0
  200. package/es/Status/style.js +14 -0
  201. package/es/Table/collapse/index.d.ts +8 -0
  202. package/es/Table/collapse/index.js +39 -0
  203. package/es/Table/collapse/style.d.ts +3 -0
  204. package/es/Table/collapse/style.js +11 -0
  205. package/es/Table/index.d.ts +20 -0
  206. package/es/Table/index.js +56 -0
  207. package/es/Typography/index.d.ts +32 -0
  208. package/es/Typography/index.js +77 -0
  209. package/es/WaveformIcon/index.d.ts +9 -0
  210. package/es/WaveformIcon/index.js +51 -0
  211. package/es/hooks/languageMap.d.ts +1 -0
  212. package/es/hooks/languageMap.js +1 -0
  213. package/es/hooks/useHighlight.d.ts +5 -0
  214. package/es/hooks/useHighlight.js +78 -0
  215. package/es/index.d.ts +38 -1
  216. package/es/index.js +52 -1
  217. package/es/notification/index.d.ts +24 -0
  218. package/es/notification/index.js +237 -0
  219. package/es/notification/style.d.ts +2 -0
  220. package/es/notification/style.js +28 -0
  221. package/es/styles/colors/colors.d.ts +39 -0
  222. package/es/styles/colors/colors.js +86 -0
  223. package/es/styles/colors/generateColorPalette.d.ts +11 -0
  224. package/es/styles/colors/generateColorPalette.js +31 -0
  225. package/es/styles/colors/neutralColors.d.ts +9 -0
  226. package/es/styles/colors/neutralColors.js +32 -0
  227. package/es/styles/index.d.ts +4 -0
  228. package/es/styles/index.js +4 -0
  229. package/es/useSpeechSynthes/const/polyfill.d.ts +3 -0
  230. package/es/useSpeechSynthes/const/polyfill.js +21 -0
  231. package/es/useSpeechSynthes/index.d.ts +13 -0
  232. package/es/useSpeechSynthes/index.js +69 -0
  233. package/es/utils/constants.d.ts +1 -0
  234. package/es/utils/constants.js +1 -0
  235. package/es/utils/tools.d.ts +1 -0
  236. package/es/utils/tools.js +1 -0
  237. package/package.json +30 -9
  238. package/umd/index.min.js +1 -1
  239. package/umd/index.min.js.map +1 -1
@@ -0,0 +1,14 @@
1
+ import { DropDownProps as AntDropDownProps, Dropdown as AntDropdown } from 'antd';
2
+ import React from 'react';
3
+ export interface DropdownProps extends AntDropDownProps {
4
+ menuExtra?: {
5
+ position?: 'top' | 'bottom';
6
+ divider?: boolean;
7
+ content: React.ReactNode;
8
+ };
9
+ }
10
+ export type DropDownProps = DropdownProps;
11
+ export type { DropdownButtonProps, DropdownButtonType } from 'antd/es/dropdown';
12
+ export declare const Dropdown: React.FC<DropdownProps> & {
13
+ Button: typeof AntDropdown.Button;
14
+ };
@@ -0,0 +1,59 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["menuExtra", "dropdownRender"];
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import { Dropdown as AntDropdown, Flex } from 'antd';
7
+ import React, { useCallback } from 'react';
8
+ import { useStyles } from "./style";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ var YuntiDropdown = function YuntiDropdown(_ref) {
12
+ var menuExtra = _ref.menuExtra,
13
+ dropdownRender = _ref.dropdownRender,
14
+ props = _objectWithoutProperties(_ref, _excluded);
15
+ var _ref2 = menuExtra || {},
16
+ _ref2$position = _ref2.position,
17
+ position = _ref2$position === void 0 ? 'top' : _ref2$position,
18
+ _ref2$divider = _ref2.divider,
19
+ divider = _ref2$divider === void 0 ? false : _ref2$divider,
20
+ content = _ref2.content;
21
+ var _useStyles = useStyles({
22
+ divider: divider,
23
+ position: position
24
+ }),
25
+ styles = _useStyles.styles;
26
+ var handleDropdownRender = useCallback(function (menu) {
27
+ var borderLessMenu = /*#__PURE__*/React.cloneElement(menu, {
28
+ style: {
29
+ boxShadow: 'none',
30
+ border: 'none'
31
+ }
32
+ });
33
+ if (!content) {
34
+ if (dropdownRender) {
35
+ return /*#__PURE__*/_jsx(Flex, {
36
+ className: styles.menuWrapper,
37
+ vertical: true,
38
+ children: dropdownRender(borderLessMenu)
39
+ });
40
+ }
41
+ return menu;
42
+ }
43
+ var extra = /*#__PURE__*/_jsx(Flex, {
44
+ align: "center",
45
+ className: styles.menuExtra,
46
+ children: content
47
+ });
48
+ return /*#__PURE__*/_jsxs(Flex, {
49
+ className: styles.menuWrapper,
50
+ vertical: true,
51
+ children: [position === 'top' && extra, borderLessMenu, position === 'bottom' && extra]
52
+ });
53
+ }, [content, dropdownRender, position, styles.menuExtra, styles.menuWrapper]);
54
+ return /*#__PURE__*/_jsx(AntDropdown, _objectSpread({
55
+ dropdownRender: handleDropdownRender
56
+ }, props));
57
+ };
58
+ export var Dropdown = YuntiDropdown;
59
+ Dropdown.Button = AntDropdown.Button;
@@ -0,0 +1,7 @@
1
+ export declare const useStyles: (props?: {
2
+ divider?: boolean | undefined;
3
+ position?: "bottom" | "top" | undefined;
4
+ } | undefined) => import("antd-style").ReturnStyles<{
5
+ menuWrapper: import("antd-style").SerializedStyles;
6
+ menuExtra: import("antd-style").SerializedStyles;
7
+ }>;
@@ -0,0 +1,13 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref, _ref2) {
5
+ var css = _ref.css,
6
+ token = _ref.token;
7
+ var divider = _ref2.divider,
8
+ position = _ref2.position;
9
+ return {
10
+ menuWrapper: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n "])), token.colorBgElevated, token.borderRadiusLG, token.boxShadowSecondary),
11
+ menuExtra: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 10px 16px 4px;\n ", "\n "])), divider && (position === 'top' ? css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border-bottom: 1px solid ", ";\n "])), token.colorSplit) : css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n border-top: 1px solid ", ";\n "])), token.colorSplit)))
12
+ };
13
+ });
@@ -0,0 +1,75 @@
1
+ import { MarkdownProps, type MessageInputProps, type MessageModalProps } from '@lobehub/ui';
2
+ import { CSSProperties } from 'react';
3
+ export interface EditableMessageProps {
4
+ /**
5
+ * @title The class name for the Markdown and MessageInput component
6
+ */
7
+ classNames?: {
8
+ /**
9
+ * @title The class name for the MessageInput component
10
+ */
11
+ input?: string;
12
+ /**
13
+ * @title The class name for the Markdown component
14
+ */
15
+ markdown?: string;
16
+ textarea?: string;
17
+ };
18
+ editButtonSize?: MessageInputProps['editButtonSize'];
19
+ /**
20
+ * @title Whether the component is in edit mode or not
21
+ * @default false
22
+ */
23
+ editing?: boolean;
24
+ fontSize?: number;
25
+ fullFeaturedCodeBlock?: boolean;
26
+ height?: MessageInputProps['height'];
27
+ inputType?: MessageInputProps['type'];
28
+ model?: {
29
+ extra?: MessageModalProps['extra'];
30
+ footer?: MessageModalProps['footer'];
31
+ };
32
+ /**
33
+ * @title Callback function when the value changes
34
+ * @param value - The new value
35
+ */
36
+ onChange?: (value: string) => void;
37
+ /**
38
+ * @title Callback function when the editing state changes
39
+ * @param editing - Whether the component is in edit mode or not
40
+ */
41
+ onEditingChange?: (editing: boolean) => void;
42
+ /**
43
+ * @title Callback function when the modal open state changes
44
+ * @param open - Whether the modal is open or not
45
+ */
46
+ onOpenChange?: (open: boolean) => void;
47
+ /**
48
+ * @title Whether the modal is open or not
49
+ * @default false
50
+ */
51
+ openModal?: boolean;
52
+ placeholder?: string;
53
+ /**
54
+ * @title Whether to show the edit button when the text value is empty
55
+ * @default false
56
+ */
57
+ showEditWhenEmpty?: boolean;
58
+ styles?: {
59
+ /**
60
+ * @title The style for the MessageInput component
61
+ */
62
+ input?: CSSProperties;
63
+ /**
64
+ * @title The style for the Markdown component
65
+ */
66
+ markdown?: CSSProperties;
67
+ };
68
+ text?: MessageModalProps['text'];
69
+ /**
70
+ * @title The current text value
71
+ */
72
+ value: string;
73
+ markdownProps?: Omit<MarkdownProps, 'children'>;
74
+ }
75
+ export declare const EditableMessage: import("react").NamedExoticComponent<EditableMessageProps>;
@@ -0,0 +1,99 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ import { Markdown, MessageInput, MessageModal } from '@lobehub/ui';
8
+ import { memo } from 'react';
9
+ import useControlledState from 'use-merge-value';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { Fragment as _Fragment } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ export var EditableMessage = /*#__PURE__*/memo(function (_ref) {
14
+ var value = _ref.value,
15
+ onChange = _ref.onChange,
16
+ _ref$classNames = _ref.classNames,
17
+ classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
18
+ onEditingChange = _ref.onEditingChange,
19
+ editing = _ref.editing,
20
+ openModal = _ref.openModal,
21
+ onOpenChange = _ref.onOpenChange,
22
+ placeholder = _ref.placeholder,
23
+ _ref$showEditWhenEmpt = _ref.showEditWhenEmpty,
24
+ showEditWhenEmpty = _ref$showEditWhenEmpt === void 0 ? false : _ref$showEditWhenEmpt,
25
+ stylesProps = _ref.styles,
26
+ height = _ref.height,
27
+ inputType = _ref.inputType,
28
+ editButtonSize = _ref.editButtonSize,
29
+ text = _ref.text,
30
+ fullFeaturedCodeBlock = _ref.fullFeaturedCodeBlock,
31
+ model = _ref.model,
32
+ fontSize = _ref.fontSize,
33
+ markdownProps = _ref.markdownProps;
34
+ var _useControlledState = useControlledState(false, {
35
+ onChange: onEditingChange,
36
+ value: editing
37
+ }),
38
+ _useControlledState2 = _slicedToArray(_useControlledState, 2),
39
+ isEdit = _useControlledState2[0],
40
+ setTyping = _useControlledState2[1];
41
+ var _useControlledState3 = useControlledState(false, {
42
+ onChange: onOpenChange,
43
+ value: openModal
44
+ }),
45
+ _useControlledState4 = _slicedToArray(_useControlledState3, 2),
46
+ expand = _useControlledState4[0],
47
+ setExpand = _useControlledState4[1];
48
+ var isAutoSize = height === 'auto';
49
+ var input = /*#__PURE__*/_jsx(MessageInput, {
50
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.input,
51
+ classNames: {
52
+ textarea: classNames === null || classNames === void 0 ? void 0 : classNames.textarea
53
+ },
54
+ defaultValue: value,
55
+ editButtonSize: editButtonSize,
56
+ height: height,
57
+ onCancel: function onCancel() {
58
+ return setTyping(false);
59
+ },
60
+ onConfirm: function onConfirm(text) {
61
+ onChange === null || onChange === void 0 || onChange(text);
62
+ setTyping(false);
63
+ },
64
+ placeholder: placeholder,
65
+ style: stylesProps === null || stylesProps === void 0 ? void 0 : stylesProps.input,
66
+ text: text,
67
+ textareaClassname: classNames === null || classNames === void 0 ? void 0 : classNames.input,
68
+ type: inputType
69
+ });
70
+ if (!value && showEditWhenEmpty) return input;
71
+ return /*#__PURE__*/_jsxs(_Fragment, {
72
+ children: [!expand && isEdit ? input : /*#__PURE__*/_jsx(Markdown, _objectSpread(_objectSpread({
73
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.markdown,
74
+ fontSize: fontSize,
75
+ fullFeaturedCodeBlock: fullFeaturedCodeBlock,
76
+ style: _objectSpread({
77
+ height: isAutoSize ? 'unset' : height
78
+ }, stylesProps === null || stylesProps === void 0 ? void 0 : stylesProps.markdown),
79
+ variant: 'chat'
80
+ }, markdownProps), {}, {
81
+ children: value || placeholder || ''
82
+ })), expand && /*#__PURE__*/_jsx(MessageModal, {
83
+ editing: isEdit,
84
+ extra: model === null || model === void 0 ? void 0 : model.extra,
85
+ footer: model === null || model === void 0 ? void 0 : model.footer,
86
+ height: height,
87
+ onChange: onChange,
88
+ onEditingChange: setTyping,
89
+ onOpenChange: function onOpenChange(e) {
90
+ setExpand(e);
91
+ setTyping(false);
92
+ },
93
+ open: expand,
94
+ placeholder: placeholder,
95
+ text: text,
96
+ value: value
97
+ })]
98
+ });
99
+ });
@@ -0,0 +1,40 @@
1
+ import type { FormItemProps, FormListFieldData, TableColumnProps } from 'antd';
2
+ import { FormListProps as AntFormListProps } from 'antd/es/form';
3
+ import React from 'react';
4
+ import { CollapseGroupProps } from '../../CollapseGroup';
5
+ export interface FormCollapseListColumnItem extends Omit<FormItemProps, 'dependencies' | 'rules' | 'tooltip' | 'labelAlign' | 'labelCol' | 'colon' | 'children'> {
6
+ render?: (field: FormListFieldData, index: number) => React.ReactElement;
7
+ rules?: FormItemProps['rules'] | ((field: FormListFieldData, index: number) => FormItemProps['rules']);
8
+ dependencies?: FormItemProps['dependencies'] | ((field: FormListFieldData, index: number) => FormItemProps['dependencies']);
9
+ }
10
+ export interface FormListOperationAddParams {
11
+ defaultValue?: any;
12
+ insertIndex?: number;
13
+ }
14
+ export interface FormCollapseListColumn extends FormCollapseListColumnItem, Pick<TableColumnProps<any>, 'align' | 'ellipsis' | 'fixed' | 'responsive' | 'shouldCellUpdate' | 'width'> {
15
+ }
16
+ export interface FormCollapseListProps extends Omit<AntFormListProps, 'name' | 'children'>, Pick<CollapseGroupProps, 'className' | 'extra' | 'expandIcon' | 'icon' | 'title' | 'variant' | 'defaultActive' | 'style'> {
17
+ /** 字段名 */
18
+ name?: FormItemProps['name'];
19
+ /** 表单列为空时展示的空内容 */
20
+ empty?: React.ReactNode;
21
+ /** 表单列配置 */
22
+ columns?: FormCollapseListColumn[];
23
+ /** 新增表单项的参数 */
24
+ addParams?: FormListOperationAddParams | (() => FormListOperationAddParams);
25
+ /** 是否禁用 */
26
+ disabled?: boolean;
27
+ /** 只读模式 */
28
+ readOnly?: boolean;
29
+ /** 默认添加一个 field */
30
+ addOneFieldDefault?: boolean;
31
+ /** 当只有一个 field 时禁用移除 */
32
+ disableRemoveWhenOneField?: boolean;
33
+ /** 限制最大 fields 数量 */
34
+ maxFileds?: number;
35
+ /** 删除时调用,返回 false 时取消删除 */
36
+ onRemove?: (values: any) => boolean | void | Promise<boolean | void>;
37
+ /** 是否启用表单项删除按钮,默认为启用 */
38
+ fieldRemoveButton?: boolean;
39
+ }
40
+ export declare const FormCollapseList: React.FC<FormCollapseListProps>;
@@ -0,0 +1,209 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["extra", "expandIcon", "icon", "title", "variant", "defaultActive", "empty", "columns", "disabled", "readOnly", "addOneFieldDefault", "disableRemoveWhenOneField", "maxFileds", "name", "addParams", "className", "onRemove", "fieldRemoveButton", "style"],
6
+ _excluded2 = ["label", "name", "render", "dependencies", "rules", "align", "ellipsis", "fixed", "responsive", "shouldCellUpdate", "width"],
7
+ _excluded3 = ["key", "name"];
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ import { PlusOutlined } from '@ant-design/icons';
12
+ import { Icon } from '@lobehub/ui';
13
+ import { Button, Flex, Form, Table, Tooltip } from 'antd';
14
+ import { Trash2 } from 'lucide-react';
15
+ import React, { useCallback, useEffect, useRef } from 'react';
16
+ import { CollapseGroup } from "../../CollapseGroup";
17
+ import { useStyles } from "./style";
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ export var FormCollapseList = function FormCollapseList(_ref) {
20
+ var extra = _ref.extra,
21
+ expandIcon = _ref.expandIcon,
22
+ icon = _ref.icon,
23
+ title = _ref.title,
24
+ variant = _ref.variant,
25
+ defaultActive = _ref.defaultActive,
26
+ _ref$empty = _ref.empty,
27
+ empty = _ref$empty === void 0 ? '点击右上角 + 添加 ' : _ref$empty,
28
+ _ref$columns = _ref.columns,
29
+ columns = _ref$columns === void 0 ? [] : _ref$columns,
30
+ disabled = _ref.disabled,
31
+ readOnly = _ref.readOnly,
32
+ addOneFieldDefault = _ref.addOneFieldDefault,
33
+ disableRemoveWhenOneField = _ref.disableRemoveWhenOneField,
34
+ maxFileds = _ref.maxFileds,
35
+ name = _ref.name,
36
+ addParams = _ref.addParams,
37
+ className = _ref.className,
38
+ onRemove = _ref.onRemove,
39
+ _ref$fieldRemoveButto = _ref.fieldRemoveButton,
40
+ fieldRemoveButton = _ref$fieldRemoveButto === void 0 ? true : _ref$fieldRemoveButto,
41
+ style = _ref.style,
42
+ formListProps = _objectWithoutProperties(_ref, _excluded);
43
+ var _useStyles = useStyles(),
44
+ styles = _useStyles.styles;
45
+ var listAdd = useRef();
46
+ var form = Form.useFormInstance();
47
+ var fieldsWatch = Form.useWatch(name, form);
48
+ var getAddParams = useCallback(function () {
49
+ if (!addParams) {
50
+ return [];
51
+ }
52
+ var params = typeof addParams === 'function' ? addParams() : addParams;
53
+ return [params.defaultValue, params.insertIndex];
54
+ }, [addParams]);
55
+ var handleOnRemove = useCallback(function (fieldName) {
56
+ var values = form.getFieldValue([name, fieldName]);
57
+ return onRemove === null || onRemove === void 0 ? void 0 : onRemove(values);
58
+ }, [form, name, onRemove]);
59
+ useEffect(function () {
60
+ var _form$getFieldValue;
61
+ if (addOneFieldDefault && (!(form !== null && form !== void 0 && form.getFieldValue(name)) || (form === null || form === void 0 || (_form$getFieldValue = form.getFieldValue(name)) === null || _form$getFieldValue === void 0 ? void 0 : _form$getFieldValue.length) === 0)) {
62
+ var _listAdd$current;
63
+ (_listAdd$current = listAdd.current) === null || _listAdd$current === void 0 || _listAdd$current.call.apply(_listAdd$current, [listAdd].concat(_toConsumableArray(getAddParams())));
64
+ }
65
+ }, [addOneFieldDefault, getAddParams, form, name]);
66
+ return /*#__PURE__*/_jsx(CollapseGroup, {
67
+ extra: extra === undefined ? name && !readOnly && /*#__PURE__*/_jsx(Tooltip, {
68
+ title: maxFileds && "\u6700\u591A\u6DFB\u52A0 ".concat(maxFileds, " \u9879"),
69
+ children: /*#__PURE__*/_jsx(Button, {
70
+ disabled: disabled || !!(maxFileds && (fieldsWatch === null || fieldsWatch === void 0 ? void 0 : fieldsWatch.length) === maxFileds),
71
+ icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
72
+ onClick: function onClick(e) {
73
+ var _listAdd$current2;
74
+ e.stopPropagation();
75
+ (_listAdd$current2 = listAdd.current) === null || _listAdd$current2 === void 0 || _listAdd$current2.call.apply(_listAdd$current2, [listAdd].concat(_toConsumableArray(getAddParams())));
76
+ },
77
+ size: "small",
78
+ type: "text"
79
+ })
80
+ }) : extra,
81
+ className: className,
82
+ expandIcon: expandIcon,
83
+ icon: icon,
84
+ title: title,
85
+ variant: variant,
86
+ defaultActive: defaultActive,
87
+ style: style,
88
+ children: name ? /*#__PURE__*/_jsx(Form.List, _objectSpread(_objectSpread({
89
+ name: name
90
+ }, formListProps), {}, {
91
+ children: function children(fields, _ref2) {
92
+ var add = _ref2.add,
93
+ remove = _ref2.remove;
94
+ listAdd.current = add;
95
+
96
+ // @Todo: support sort
97
+ return /*#__PURE__*/_jsx(Table, {
98
+ className: styles.list,
99
+ columns: [].concat(_toConsumableArray(columns.map(function (_ref3) {
100
+ var label = _ref3.label,
101
+ itemName = _ref3.name,
102
+ fieldRender = _ref3.render,
103
+ dependencies = _ref3.dependencies,
104
+ rules = _ref3.rules,
105
+ align = _ref3.align,
106
+ ellipsis = _ref3.ellipsis,
107
+ fixed = _ref3.fixed,
108
+ responsive = _ref3.responsive,
109
+ shouldCellUpdate = _ref3.shouldCellUpdate,
110
+ width = _ref3.width,
111
+ itemProps = _objectWithoutProperties(_ref3, _excluded2);
112
+ return {
113
+ title: label,
114
+ dataIndex: itemName,
115
+ align: align,
116
+ ellipsis: ellipsis,
117
+ fixed: fixed,
118
+ responsive: responsive,
119
+ shouldCellUpdate: shouldCellUpdate,
120
+ width: width,
121
+ render: function render(_text, _record, index) {
122
+ var _fields$index = fields[index],
123
+ key = _fields$index.key,
124
+ name = _fields$index.name,
125
+ restField = _objectWithoutProperties(_fields$index, _excluded3);
126
+ var children = fieldRender === null || fieldRender === void 0 ? void 0 : fieldRender(fields[index], index);
127
+ if (!children && !itemProps.noStyle) {
128
+ return /*#__PURE__*/_jsx(Flex, {
129
+ align: "center",
130
+ className: styles.noFormItem,
131
+ children: "\u65E0\u9700\u8BBE\u7F6E"
132
+ });
133
+ }
134
+ if (!itemName) {
135
+ return /*#__PURE__*/_jsx(Flex, {
136
+ align: "center",
137
+ className: styles.noFormItem,
138
+ children: children
139
+ });
140
+ }
141
+ var chidrenProps = {
142
+ readOnly: readOnly,
143
+ disabled: disabled
144
+ };
145
+ if (readOnly === true) {
146
+ chidrenProps.showCount = false;
147
+ chidrenProps.variant = 'borderless';
148
+ chidrenProps.placeholder = '-';
149
+ }
150
+ return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread(_objectSpread({}, restField), {}, {
151
+ dependencies: typeof dependencies === 'function' ? dependencies(fields[index], index) : dependencies,
152
+ name: [name, itemName],
153
+ rules: typeof rules === 'function' ? rules(fields[index], index) : rules
154
+ }, itemProps), {}, {
155
+ children: children && /*#__PURE__*/React.cloneElement(children, chidrenProps)
156
+ }), key);
157
+ }
158
+ };
159
+ })), [!readOnly && fieldRemoveButton !== false && {
160
+ title: '',
161
+ dataIndex: 'del',
162
+ render: function render(_text, _record, index) {
163
+ var fieldName = fields[index].name;
164
+ return /*#__PURE__*/_jsx(Form.Item, {
165
+ children: /*#__PURE__*/_jsx(Button, {
166
+ disabled: disabled || disableRemoveWhenOneField && fields.length === 1,
167
+ icon: /*#__PURE__*/_jsx(Icon, {
168
+ icon: Trash2
169
+ }),
170
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
171
+ var isRemove;
172
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
173
+ while (1) switch (_context.prev = _context.next) {
174
+ case 0:
175
+ _context.next = 2;
176
+ return handleOnRemove(fieldName);
177
+ case 2:
178
+ isRemove = _context.sent;
179
+ if (isRemove !== false) {
180
+ remove(fieldName);
181
+ }
182
+ case 4:
183
+ case "end":
184
+ return _context.stop();
185
+ }
186
+ }, _callee);
187
+ })),
188
+ type: "text"
189
+ })
190
+ });
191
+ }
192
+ }]).filter(function (c) {
193
+ return !!c;
194
+ }),
195
+ dataSource: fields,
196
+ locale: {
197
+ emptyText: empty
198
+ },
199
+ pagination: false,
200
+ rowHoverable: false,
201
+ size: "small"
202
+ });
203
+ }
204
+ })) : /*#__PURE__*/_jsx("div", {
205
+ className: styles.empty,
206
+ children: empty
207
+ })
208
+ });
209
+ };
@@ -0,0 +1,5 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ empty: import("antd-style").SerializedStyles;
3
+ list: import("antd-style").SerializedStyles;
4
+ noFormItem: import("antd-style").SerializedStyles;
5
+ }>;
@@ -0,0 +1,13 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css,
6
+ token = _ref.token,
7
+ prefixCls = _ref.prefixCls;
8
+ return {
9
+ empty: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: ", "px ", "px;\n color: ", ";\n "])), token.paddingXS, token.paddingSM, token.colorTextTertiary),
10
+ list: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &.", "-table-wrapper {\n .", "-table {\n &-thead {\n & > tr > th {\n font-weight: normal;\n color: ", ";\n background-color: unset;\n &::before {\n display: none;\n }\n }\n }\n &-tbody {\n & > tr:last-child {\n & > td {\n border-bottom-color: transparent;\n }\n }\n }\n &-cell {\n vertical-align: top;\n }\n }\n }\n .", "-form {\n &-item {\n margin-bottom: 0;\n }\n }\n "])), prefixCls, prefixCls, token.colorTextTertiary, prefixCls),
11
+ noFormItem: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n height: ", "px;\n color: ", ";\n "])), token.controlHeight, token.colorTextTertiary)
12
+ };
13
+ });
@@ -0,0 +1,8 @@
1
+ import { Form as AntForm } from 'antd';
2
+ import { FormCollapseList } from './collapse-list';
3
+ export * from './collapse-list';
4
+ export type { FormInstance, FormItemProps, FormListFieldData, FormListOperation, FormProps, FormRule, } from 'antd';
5
+ export type FormType = typeof AntForm & {
6
+ CollapseList: typeof FormCollapseList;
7
+ };
8
+ export declare const Form: FormType;
@@ -0,0 +1,5 @@
1
+ import { Form as AntForm } from 'antd';
2
+ import { FormCollapseList } from "./collapse-list";
3
+ export * from "./collapse-list";
4
+ export var Form = AntForm;
5
+ Form.CollapseList = FormCollapseList;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ type RefOrDomOrId<T> = HTMLElement | string | React.Ref<T>;
3
+ type F = any;
4
+ /**
5
+ * Passing a ref, id, or DOM element to obtain and set the focus state of the first non-disabled and non-readonly input or textarea.
6
+ * @param {RefOrDomOrId} refOrDomOrId - 支持类型 HTMLElement | string | React.Ref<T>
7
+ * @returns void
8
+ */
9
+ export declare const useAutoFocus: (refOrDomOrId?: RefOrDomOrId<F>) => void;
10
+ export {};
@@ -0,0 +1,38 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useState } from 'react';
3
+ var getDom = function getDom(refOrDomOrId) {
4
+ return typeof refOrDomOrId === 'string' ? document.querySelector("#".concat(refOrDomOrId)) : (refOrDomOrId === null || refOrDomOrId === void 0 ? void 0 : refOrDomOrId.current) || refOrDomOrId;
5
+ };
6
+
7
+ // https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input#input_%E7%B1%BB%E5%9E%8B
8
+ var disabled = ':not([disabled]):not([readonly])';
9
+ var queryInputTypes = ['text', 'password', 'search', 'tel', 'url', 'number', 'email', ''].map(function (item) {
10
+ return "input[type=\"".concat(item, "\"]").concat(disabled);
11
+ }).join(', ') + ", input:not([type])".concat(disabled, ", textarea").concat(disabled);
12
+ var setAutoFocus = function setAutoFocus(refOrDomOrId) {
13
+ var _dom$querySelector;
14
+ var dom = getDom(refOrDomOrId);
15
+ if (!dom) return;
16
+ var input = (_dom$querySelector = dom.querySelector) === null || _dom$querySelector === void 0 ? void 0 : _dom$querySelector.call(dom, queryInputTypes);
17
+ if (!(input !== null && input !== void 0 && input.focus)) return;
18
+ input.focus();
19
+ return true;
20
+ };
21
+
22
+ /**
23
+ * Passing a ref, id, or DOM element to obtain and set the focus state of the first non-disabled and non-readonly input or textarea.
24
+ * @param {RefOrDomOrId} refOrDomOrId - 支持类型 HTMLElement | string | React.Ref<T>
25
+ * @returns void
26
+ */
27
+ export var useAutoFocus = function useAutoFocus(refOrDomOrId) {
28
+ var _useState = useState(false),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ focused = _useState2[0],
31
+ setFocused = _useState2[1];
32
+ React.useEffect(function () {
33
+ if (focused || !refOrDomOrId) return;
34
+ var setRes = setAutoFocus(refOrDomOrId);
35
+ if (!setRes) return;
36
+ setFocused(true);
37
+ }, [refOrDomOrId, focused, setFocused]);
38
+ };
@@ -0,0 +1,13 @@
1
+ import React, { ComponentType, FC } from 'react';
2
+ export { useAutoFocus } from './autoFocus';
3
+ export type FormHelperProps = {
4
+ children: React.ReactNode;
5
+ autoFocus?: boolean;
6
+ id?: string;
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ };
10
+ declare const FormHelper: React.FC<FormHelperProps>;
11
+ type FormHelperConfig = Omit<FormHelperProps, 'children'>;
12
+ export declare const withFormHelper: (formHelperConfig?: FormHelperConfig) => <P extends Record<string, never>>(WrappedComponent: React.ComponentType<P>) => React.FC<P>;
13
+ export { FormHelper };