@yuntijs/ui 1.0.0-beta.9 → 1.0.0-beta.91

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 (241) hide show
  1. package/es/App/index.d.ts +7 -0
  2. package/es/App/index.js +19 -0
  3. package/es/ButtonGroup/index.d.ts +24 -0
  4. package/es/ButtonGroup/index.js +66 -0
  5. package/es/Card/index.d.ts +1 -0
  6. package/es/Card/index.js +1 -0
  7. package/es/CardList/Item/index.d.ts +4 -0
  8. package/es/CardList/Item/index.js +43 -0
  9. package/es/CardList/Item/style.d.ts +0 -0
  10. package/es/CardList/Item/style.js +0 -0
  11. package/es/CardList/index.d.ts +2 -0
  12. package/es/CardList/index.js +39 -0
  13. package/es/ChatInputArea/desktop/ChatInputArea.d.ts +19 -0
  14. package/es/ChatInputArea/desktop/ChatInputArea.js +72 -0
  15. package/es/ChatInputArea/index.d.ts +6 -0
  16. package/es/ChatInputArea/index.js +6 -0
  17. package/es/ChatItem/components/Actions.d.ts +10 -0
  18. package/es/ChatItem/components/Actions.js +23 -0
  19. package/es/ChatItem/components/MessageContent.d.ts +21 -0
  20. package/es/ChatItem/components/MessageContent.js +59 -0
  21. package/es/ChatItem/index.d.ts +4 -0
  22. package/es/ChatItem/index.js +120 -0
  23. package/es/ChatItem/style.d.ts +25 -0
  24. package/es/ChatItem/style.js +39 -0
  25. package/es/ChatItem/type.d.ts +86 -0
  26. package/es/ChatItem/type.js +1 -0
  27. package/es/CollapseGroup/index.d.ts +4 -0
  28. package/es/CollapseGroup/index.js +23 -0
  29. package/es/CollapseGroup/style.d.ts +3 -0
  30. package/es/CollapseGroup/style.js +11 -0
  31. package/es/ConfigProvider/index.d.ts +3 -0
  32. package/es/ConfigProvider/index.js +17 -11
  33. package/es/Descriptions/index.d.ts +14 -0
  34. package/es/Descriptions/index.js +31 -0
  35. package/es/Descriptions/style.d.ts +4 -0
  36. package/es/Descriptions/style.js +24 -0
  37. package/es/Divider/index.d.ts +38 -0
  38. package/es/Divider/index.js +66 -0
  39. package/es/Divider/style.d.ts +3 -0
  40. package/es/Divider/style.js +12 -0
  41. package/es/DragPanel/index.d.ts +10 -0
  42. package/es/DragPanel/index.js +97 -0
  43. package/es/DragPanel/style.d.ts +7 -0
  44. package/es/DragPanel/style.js +15 -0
  45. package/es/Drawer/index.d.ts +13 -0
  46. package/es/Drawer/index.js +20 -0
  47. package/es/Drawer/style.d.ts +4 -0
  48. package/es/Drawer/style.js +16 -0
  49. package/es/Dropdown/index.d.ts +14 -0
  50. package/es/Dropdown/index.js +59 -0
  51. package/es/Dropdown/style.d.ts +7 -0
  52. package/es/Dropdown/style.js +13 -0
  53. package/es/EditableMessage/index.d.ts +75 -0
  54. package/es/EditableMessage/index.js +99 -0
  55. package/es/Form/collapse-list/index.d.ts +40 -0
  56. package/es/Form/collapse-list/index.js +209 -0
  57. package/es/Form/collapse-list/style.d.ts +5 -0
  58. package/es/Form/collapse-list/style.js +13 -0
  59. package/es/Form/index.d.ts +8 -0
  60. package/es/Form/index.js +5 -0
  61. package/es/FormHelper/autoFocus.d.ts +10 -0
  62. package/es/FormHelper/autoFocus.js +38 -0
  63. package/es/FormHelper/index.d.ts +13 -0
  64. package/es/FormHelper/index.js +41 -0
  65. package/es/Highlighter/FullFeatured.d.ts +18 -0
  66. package/es/Highlighter/FullFeatured.js +102 -0
  67. package/es/Highlighter/SyntaxHighlighter/index.d.ts +7 -0
  68. package/es/Highlighter/SyntaxHighlighter/index.js +51 -0
  69. package/es/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
  70. package/es/Highlighter/SyntaxHighlighter/style.js +16 -0
  71. package/es/Highlighter/index.d.ts +50 -0
  72. package/es/Highlighter/index.js +77 -0
  73. package/es/Highlighter/style.d.ts +9 -0
  74. package/es/Highlighter/style.js +23 -0
  75. package/es/Highlighter/theme.d.ts +1 -0
  76. package/es/Highlighter/theme.js +1661 -0
  77. package/es/JsonViewer/index.d.ts +21 -0
  78. package/es/JsonViewer/index.js +121 -0
  79. package/es/JsonViewer/style.d.ts +7 -0
  80. package/es/JsonViewer/style.js +19 -0
  81. package/es/LogViewer/index.d.ts +10 -0
  82. package/es/LogViewer/index.js +141 -0
  83. package/es/LogViewer/style.d.ts +6 -0
  84. package/es/LogViewer/style.js +16 -0
  85. package/es/LogViewer/types.d.ts +235 -0
  86. package/es/LogViewer/types.js +1 -0
  87. package/es/Mentions/constants.d.ts +6 -0
  88. package/es/Mentions/constants.js +28 -0
  89. package/es/Mentions/hooks.d.ts +20 -0
  90. package/es/Mentions/hooks.js +133 -0
  91. package/es/Mentions/index.d.ts +23 -0
  92. package/es/Mentions/index.js +157 -0
  93. package/es/Mentions/plugins/OnBlurBlockPlugin.d.ts +7 -0
  94. package/es/Mentions/plugins/OnBlurBlockPlugin.js +35 -0
  95. package/es/Mentions/plugins/custom-text/node.d.ts +11 -0
  96. package/es/Mentions/plugins/custom-text/node.js +72 -0
  97. package/es/Mentions/plugins/editable.d.ts +4 -0
  98. package/es/Mentions/plugins/editable.js +13 -0
  99. package/es/Mentions/plugins/mention-node/component.d.ts +6 -0
  100. package/es/Mentions/plugins/mention-node/component.js +64 -0
  101. package/es/Mentions/plugins/mention-node/index.d.ts +9 -0
  102. package/es/Mentions/plugins/mention-node/index.js +32 -0
  103. package/es/Mentions/plugins/mention-node/node.d.ts +22 -0
  104. package/es/Mentions/plugins/mention-node/node.js +100 -0
  105. package/es/Mentions/plugins/mention-node/replacement.d.ts +5 -0
  106. package/es/Mentions/plugins/mention-node/replacement.js +43 -0
  107. package/es/Mentions/plugins/mention-node/style.d.ts +8 -0
  108. package/es/Mentions/plugins/mention-node/style.js +47 -0
  109. package/es/Mentions/plugins/mention-node/utils.d.ts +4 -0
  110. package/es/Mentions/plugins/mention-node/utils.js +10 -0
  111. package/es/Mentions/plugins/mention-picker/hooks.d.ts +5 -0
  112. package/es/Mentions/plugins/mention-picker/hooks.js +65 -0
  113. package/es/Mentions/plugins/mention-picker/index.d.ts +39 -0
  114. package/es/Mentions/plugins/mention-picker/index.js +137 -0
  115. package/es/Mentions/plugins/mention-picker/menu-item.d.ts +12 -0
  116. package/es/Mentions/plugins/mention-picker/menu-item.js +73 -0
  117. package/es/Mentions/plugins/mention-picker/menu.d.ts +10 -0
  118. package/es/Mentions/plugins/mention-picker/menu.js +31 -0
  119. package/es/Mentions/plugins/mention-picker/style.d.ts +11 -0
  120. package/es/Mentions/plugins/mention-picker/style.js +19 -0
  121. package/es/Mentions/plugins/mention-picker/utils.d.ts +31 -0
  122. package/es/Mentions/plugins/mention-picker/utils.js +66 -0
  123. package/es/Mentions/provider.d.ts +12 -0
  124. package/es/Mentions/provider.js +15 -0
  125. package/es/Mentions/style.d.ts +11 -0
  126. package/es/Mentions/style.js +22 -0
  127. package/es/Mentions/types.d.ts +12 -0
  128. package/es/Mentions/types.js +1 -0
  129. package/es/Mentions/utils.d.ts +9 -0
  130. package/es/Mentions/utils.js +95 -0
  131. package/es/Modal/index.d.ts +19 -0
  132. package/es/Modal/index.js +36 -0
  133. package/es/Modal/style.d.ts +4 -0
  134. package/es/Modal/style.js +17 -0
  135. package/es/MonacoEditor/base/controller.d.ts +17 -0
  136. package/es/MonacoEditor/base/controller.js +49 -0
  137. package/es/MonacoEditor/base/helper.d.ts +65 -0
  138. package/es/MonacoEditor/base/helper.js +324 -0
  139. package/es/MonacoEditor/base/index.d.ts +39 -0
  140. package/es/MonacoEditor/base/index.js +238 -0
  141. package/es/MonacoEditor/base/monaco.d.ts +6 -0
  142. package/es/MonacoEditor/base/monaco.js +64 -0
  143. package/es/MonacoEditor/{style.d.ts → base/style.d.ts} +4 -1
  144. package/es/MonacoEditor/base/style.js +43 -0
  145. package/es/MonacoEditor/index.d.ts +5 -4
  146. package/es/MonacoEditor/index.js +26 -62
  147. package/es/Page/Breadcrumb/index.d.ts +9 -0
  148. package/es/Page/Breadcrumb/index.js +56 -0
  149. package/es/Page/Content/index.d.ts +4 -0
  150. package/es/Page/Content/index.js +59 -0
  151. package/es/Page/Content/style.d.ts +3 -0
  152. package/es/Page/Content/style.js +12 -0
  153. package/es/Page/Footer/index.d.ts +2 -0
  154. package/es/Page/Footer/index.js +6 -0
  155. package/es/Page/Header/Icon.d.ts +17 -0
  156. package/es/Page/Header/Icon.js +42 -0
  157. package/es/Page/Header/index.d.ts +43 -0
  158. package/es/Page/Header/index.js +202 -0
  159. package/es/Page/Header/style.d.ts +12 -0
  160. package/es/Page/Header/style.js +21 -0
  161. package/es/Page/Page.d.ts +9 -0
  162. package/es/Page/Page.js +49 -0
  163. package/es/Page/PageContext.d.ts +15 -0
  164. package/es/Page/PageContext.js +21 -0
  165. package/es/Page/Title/index.d.ts +5 -0
  166. package/es/Page/Title/index.js +18 -0
  167. package/es/Page/Title/style.d.ts +3 -0
  168. package/es/Page/Title/style.js +10 -0
  169. package/es/Page/index.d.ts +18 -0
  170. package/es/Page/index.js +15 -0
  171. package/es/Page/style.d.ts +3 -0
  172. package/es/Page/style.js +10 -0
  173. package/es/ProCard/Card/index.d.ts +6 -0
  174. package/es/ProCard/Card/index.js +25 -0
  175. package/es/ProCard/Card/style.d.ts +7 -0
  176. package/es/ProCard/Card/style.js +15 -0
  177. package/es/ProCard/Content/index.d.ts +4 -0
  178. package/es/ProCard/Content/index.js +24 -0
  179. package/es/ProCard/Content/style.d.ts +3 -0
  180. package/es/ProCard/Content/style.js +10 -0
  181. package/es/ProCard/Descriptions/index.d.ts +4 -0
  182. package/es/ProCard/Descriptions/index.js +28 -0
  183. package/es/ProCard/Descriptions/style.d.ts +3 -0
  184. package/es/ProCard/Descriptions/style.js +12 -0
  185. package/es/ProCard/Header/index.d.ts +15 -0
  186. package/es/ProCard/Header/index.js +86 -0
  187. package/es/ProCard/Header/style.d.ts +12 -0
  188. package/es/ProCard/Header/style.js +21 -0
  189. package/es/ProCard/index.d.ts +13 -0
  190. package/es/ProCard/index.js +8 -0
  191. package/es/SelectCard/index.d.ts +33 -0
  192. package/es/SelectCard/index.js +132 -0
  193. package/es/SelectCard/style.d.ts +10 -0
  194. package/es/SelectCard/style.js +42 -0
  195. package/es/SliderInput/index.js +2 -2
  196. package/es/Status/index.d.ts +7 -0
  197. package/es/Status/index.js +39 -0
  198. package/es/Status/style.d.ts +4 -0
  199. package/es/Status/style.js +14 -0
  200. package/es/Table/collapse/index.d.ts +9 -0
  201. package/es/Table/collapse/index.js +39 -0
  202. package/es/Table/collapse/style.d.ts +3 -0
  203. package/es/Table/collapse/style.js +11 -0
  204. package/es/Table/index.d.ts +20 -0
  205. package/es/Table/index.js +56 -0
  206. package/es/Typography/index.d.ts +32 -0
  207. package/es/Typography/index.js +77 -0
  208. package/es/WaveformIcon/index.d.ts +9 -0
  209. package/es/WaveformIcon/index.js +51 -0
  210. package/es/hooks/languageMap.d.ts +1 -0
  211. package/es/hooks/languageMap.js +1 -0
  212. package/es/hooks/useHighlight.d.ts +5 -0
  213. package/es/hooks/useHighlight.js +78 -0
  214. package/es/index.d.ts +38 -3
  215. package/es/index.js +48 -3
  216. package/es/notification/index.d.ts +24 -0
  217. package/es/notification/index.js +237 -0
  218. package/es/notification/style.d.ts +2 -0
  219. package/es/notification/style.js +28 -0
  220. package/es/styles/colors/colors.d.ts +39 -0
  221. package/es/styles/colors/colors.js +86 -0
  222. package/es/styles/colors/generateColorPalette.d.ts +11 -0
  223. package/es/styles/colors/generateColorPalette.js +31 -0
  224. package/es/styles/colors/neutralColors.d.ts +9 -0
  225. package/es/styles/colors/neutralColors.js +32 -0
  226. package/es/styles/index.d.ts +4 -0
  227. package/es/styles/index.js +4 -0
  228. package/es/useSpeechSynthes/const/polyfill.d.ts +3 -0
  229. package/es/useSpeechSynthes/const/polyfill.js +21 -0
  230. package/es/useSpeechSynthes/index.d.ts +13 -0
  231. package/es/useSpeechSynthes/index.js +69 -0
  232. package/es/utils/constants.d.ts +1 -0
  233. package/es/utils/constants.js +1 -0
  234. package/es/utils/tools.d.ts +1 -0
  235. package/es/utils/tools.js +1 -0
  236. package/package.json +31 -9
  237. package/umd/index.min.css +2 -0
  238. package/umd/index.min.css.map +1 -0
  239. package/umd/index.min.js +1 -1
  240. package/umd/index.min.js.map +1 -1
  241. package/es/MonacoEditor/style.js +0 -24
@@ -0,0 +1,18 @@
1
+ import { ReactNode } from 'react';
2
+ import { DivProps } from "../types";
3
+ export interface FullFeaturedHighlighterProps extends DivProps {
4
+ allowChangeLanguage?: boolean;
5
+ /**
6
+ * @description The code content to be highlighted
7
+ */
8
+ children: string;
9
+ fileName?: string;
10
+ icon?: ReactNode;
11
+ /**
12
+ * @description The language of the code content
13
+ */
14
+ language: string;
15
+ contentStyle?: React.CSSProperties;
16
+ }
17
+ export declare const FullFeaturedHighlighter: import("react").NamedExoticComponent<FullFeaturedHighlighterProps>;
18
+ export * from './SyntaxHighlighter';
@@ -0,0 +1,102 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ var _excluded = ["children", "language", "className", "style", "allowChangeLanguage", "fileName", "icon", "contentStyle"];
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 { ActionIcon, CopyButton } from '@lobehub/ui';
8
+ import { Select } from 'antd';
9
+ import { ChevronDown, ChevronRight } from 'lucide-react';
10
+ import { memo, useState } from 'react';
11
+ import { Flexbox } from 'react-layout-kit';
12
+ import { languageMap } from "../hooks/useHighlight";
13
+ import { SyntaxHighlighter } from "./SyntaxHighlighter";
14
+ import { useStyles } from "./style";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ var options = languageMap.map(function (item) {
18
+ return {
19
+ label: item,
20
+ value: item.toLowerCase()
21
+ };
22
+ });
23
+ export var FullFeaturedHighlighter = /*#__PURE__*/memo(function (_ref) {
24
+ var children = _ref.children,
25
+ _ref$language = _ref.language,
26
+ language = _ref$language === void 0 ? 'markdown' : _ref$language,
27
+ className = _ref.className,
28
+ style = _ref.style,
29
+ _ref$allowChangeLangu = _ref.allowChangeLanguage,
30
+ allowChangeLanguage = _ref$allowChangeLangu === void 0 ? false : _ref$allowChangeLangu,
31
+ fileName = _ref.fileName,
32
+ icon = _ref.icon,
33
+ contentStyle = _ref.contentStyle,
34
+ rest = _objectWithoutProperties(_ref, _excluded);
35
+ var _useState = useState(true),
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ expand = _useState2[0],
38
+ setExpand = _useState2[1];
39
+ var _useState3 = useState(language || 'markdown'),
40
+ _useState4 = _slicedToArray(_useState3, 2),
41
+ lang = _useState4[0],
42
+ setLang = _useState4[1];
43
+ var _useStyles = useStyles('block'),
44
+ styles = _useStyles.styles,
45
+ cx = _useStyles.cx;
46
+ var container = cx(styles.container, className);
47
+ return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
48
+ className: container,
49
+ "data-code-type": "highlighter",
50
+ style: style
51
+ }, rest), {}, {
52
+ children: [/*#__PURE__*/_jsxs(Flexbox, {
53
+ align: 'center',
54
+ className: styles.header,
55
+ horizontal: true,
56
+ justify: 'space-between',
57
+ children: [/*#__PURE__*/_jsx(ActionIcon, {
58
+ icon: expand ? ChevronDown : ChevronRight,
59
+ onClick: function onClick() {
60
+ return setExpand(!expand);
61
+ },
62
+ size: {
63
+ blockSize: 24,
64
+ fontSize: 14,
65
+ strokeWidth: 3
66
+ }
67
+ }), allowChangeLanguage && !fileName ? /*#__PURE__*/_jsx(Select, {
68
+ className: styles.select,
69
+ onSelect: setLang,
70
+ options: options,
71
+ size: 'small',
72
+ suffixIcon: false,
73
+ value: lang.toLowerCase(),
74
+ variant: 'borderless'
75
+ }) : /*#__PURE__*/_jsxs(Flexbox, {
76
+ align: 'center',
77
+ className: styles.select,
78
+ gap: 2,
79
+ horizontal: true,
80
+ children: [icon, /*#__PURE__*/_jsx("span", {
81
+ children: fileName || lang
82
+ })]
83
+ }), /*#__PURE__*/_jsx(CopyButton, {
84
+ content: children,
85
+ placement: "left",
86
+ size: {
87
+ blockSize: 24,
88
+ fontSize: 14,
89
+ strokeWidth: 2
90
+ }
91
+ })]
92
+ }), /*#__PURE__*/_jsx(SyntaxHighlighter, {
93
+ language: lang === null || lang === void 0 ? void 0 : lang.toLowerCase(),
94
+ style: expand ? contentStyle : _objectSpread(_objectSpread({}, contentStyle), {}, {
95
+ height: 0,
96
+ overflow: 'hidden'
97
+ }),
98
+ children: children
99
+ })]
100
+ }));
101
+ });
102
+ export * from "./SyntaxHighlighter";
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { DivProps } from "../../types";
3
+ export interface SyntaxHighlighterProps extends DivProps {
4
+ children: string;
5
+ language: string;
6
+ }
7
+ export declare const SyntaxHighlighter: import("react").NamedExoticComponent<SyntaxHighlighterProps>;
@@ -0,0 +1,51 @@
1
+ import { Icon } from '@lobehub/ui';
2
+ import { useThemeMode } from 'antd-style';
3
+ import { Loader2 } from 'lucide-react';
4
+ import { memo } from 'react';
5
+ import { Flexbox } from 'react-layout-kit';
6
+ import { useHighlight } from "../../hooks/useHighlight";
7
+ import { useStyles } from "./style";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { Fragment as _Fragment } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ export var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
12
+ var children = _ref.children,
13
+ language = _ref.language,
14
+ className = _ref.className,
15
+ style = _ref.style;
16
+ var _useStyles = useStyles(),
17
+ styles = _useStyles.styles,
18
+ cx = _useStyles.cx;
19
+ var _useThemeMode = useThemeMode(),
20
+ isDarkMode = _useThemeMode.isDarkMode;
21
+ var _useHighlight = useHighlight(children.trim(), language, isDarkMode),
22
+ data = _useHighlight.data,
23
+ isLoading = _useHighlight.isLoading;
24
+ return /*#__PURE__*/_jsxs(_Fragment, {
25
+ children: [isLoading || !data ? /*#__PURE__*/_jsx("div", {
26
+ className: cx(styles.unshiki, className),
27
+ style: style,
28
+ children: /*#__PURE__*/_jsx("pre", {
29
+ children: /*#__PURE__*/_jsx("div", {
30
+ children: children.trim()
31
+ })
32
+ })
33
+ }) : /*#__PURE__*/_jsx("div", {
34
+ className: cx(styles.shiki, className),
35
+ dangerouslySetInnerHTML: {
36
+ __html: data
37
+ },
38
+ style: style
39
+ }), isLoading && /*#__PURE__*/_jsx(Flexbox, {
40
+ align: 'center',
41
+ className: styles.loading,
42
+ gap: 8,
43
+ horizontal: true,
44
+ justify: 'center',
45
+ children: /*#__PURE__*/_jsx(Icon, {
46
+ icon: Loader2,
47
+ spin: true
48
+ })
49
+ })]
50
+ });
51
+ });
@@ -0,0 +1,5 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ loading: string;
3
+ shiki: string;
4
+ unshiki: import("antd-style").SerializedStyles;
5
+ }>;
@@ -0,0 +1,16 @@
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
+ cx = _ref.cx,
8
+ prefixCls = _ref.prefixCls,
9
+ stylish = _ref.stylish;
10
+ var prefix = "".concat(prefixCls, "-highlighter");
11
+ return {
12
+ loading: cx(stylish.blur, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 10;\n inset-block-start: 0;\n inset-inline-end: 0;\n\n height: 34px;\n padding-block: 0;\n padding-inline: 8px;\n\n font-family: ", ";\n color: ", ";\n\n border-radius: ", ";\n "])), token.fontFamilyCode, token.colorTextTertiary, token.borderRadius)),
13
+ shiki: cx("".concat(prefix, "-shiki"), css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n overflow: auto;\n margin: 0;\n padding: 0;\n\n .shiki {\n overflow: unset;\n margin: 0;\n padding: 0;\n background: none !important;\n\n code {\n display: block;\n\n .line {\n display: inline-block;\n\n width: calc(100% + 32px);\n margin-block: 0;\n margin-inline: -16px;\n padding-block: 0;\n padding-inline: 16px;\n }\n }\n\n &.has-focused {\n .line:not(.focused) {\n opacity: 0.5;\n }\n }\n\n .highlighted {\n background: ", ";\n\n &.warning {\n background: ", ";\n }\n\n &.error {\n background: ", ";\n }\n }\n\n .highlighted-word {\n padding-block: 0.1em;\n padding-inline: 0.2em;\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n .diff {\n &.remove {\n background: ", ";\n\n &::before {\n content: '-';\n\n position: absolute;\n inset-inline-start: 4px;\n\n display: inline-block;\n\n color: ", ";\n }\n }\n\n &.add {\n background: ", ";\n\n &::before {\n content: '+';\n\n position: absolute;\n inset-inline-start: 4px;\n\n display: inline-block;\n\n color: ", ";\n }\n }\n }\n }\n "])), token.colorFillTertiary, token.colorWarningBg, token.colorErrorBg, token.colorFillTertiary, token.colorBorderSecondary, token.borderRadius, token.colorErrorBg, token.colorErrorText, token.colorSuccessBg, token.colorSuccessText)),
14
+ unshiki: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow: auto;\n margin: 0;\n padding: 0;\n color: ", ";\n "])), token.colorTextDescription)
15
+ };
16
+ });
@@ -0,0 +1,50 @@
1
+ import { type CopyButtonProps } from '@lobehub/ui';
2
+ import React, { ReactNode } from 'react';
3
+ import { DivProps } from "../types";
4
+ export interface HighlighterProps extends DivProps {
5
+ allowChangeLanguage?: boolean;
6
+ /**
7
+ * @description The code content to be highlighted
8
+ */
9
+ children: string;
10
+ copyButtonSize?: CopyButtonProps['size'];
11
+ /**
12
+ * @description Whether to show the copy button
13
+ * @default true
14
+ */
15
+ copyable?: boolean;
16
+ fileName?: string;
17
+ fullFeatured?: boolean;
18
+ icon?: ReactNode;
19
+ /**
20
+ * @description The language of the code content
21
+ */
22
+ language: string;
23
+ /**
24
+ * @description Whether to show language tag
25
+ * @default true
26
+ */
27
+ showLanguage?: boolean;
28
+ /**
29
+ * @description Whether add spotlight background
30
+ * @default false
31
+ */
32
+ spotlight?: boolean;
33
+ /**
34
+ * @description The type of the code block
35
+ * @default 'block'
36
+ */
37
+ type?: 'ghost' | 'block' | 'pure';
38
+ /**
39
+ * @description The style of the code content
40
+ */
41
+ contentStyle?: React.CSSProperties;
42
+ /**
43
+ * @description Control text wrap
44
+ * @default false
45
+ */
46
+ wrap?: boolean;
47
+ }
48
+ export declare const Highlighter: React.NamedExoticComponent<HighlighterProps>;
49
+ export * from './FullFeatured';
50
+ export * from './SyntaxHighlighter';
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["fullFeatured", "copyButtonSize", "children", "language", "className", "style", "copyable", "showLanguage", "type", "spotlight", "allowChangeLanguage", "fileName", "icon", "contentStyle", "wrap"];
6
+ 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; }
7
+ 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; }
8
+ import { CopyButton, Spotlight, Tag } from '@lobehub/ui';
9
+ import React, { memo } from 'react';
10
+ import { FullFeaturedHighlighter } from "./FullFeatured";
11
+ import { SyntaxHighlighter } from "./SyntaxHighlighter";
12
+ import { useStyles } from "./style";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ export var Highlighter = /*#__PURE__*/memo(function (_ref) {
16
+ var fullFeatured = _ref.fullFeatured,
17
+ _ref$copyButtonSize = _ref.copyButtonSize,
18
+ copyButtonSize = _ref$copyButtonSize === void 0 ? 'site' : _ref$copyButtonSize,
19
+ children = _ref.children,
20
+ language = _ref.language,
21
+ className = _ref.className,
22
+ style = _ref.style,
23
+ _ref$copyable = _ref.copyable,
24
+ copyable = _ref$copyable === void 0 ? true : _ref$copyable,
25
+ _ref$showLanguage = _ref.showLanguage,
26
+ showLanguage = _ref$showLanguage === void 0 ? true : _ref$showLanguage,
27
+ _ref$type = _ref.type,
28
+ type = _ref$type === void 0 ? 'block' : _ref$type,
29
+ spotlight = _ref.spotlight,
30
+ allowChangeLanguage = _ref.allowChangeLanguage,
31
+ fileName = _ref.fileName,
32
+ icon = _ref.icon,
33
+ contentStyle = _ref.contentStyle,
34
+ wrap = _ref.wrap,
35
+ rest = _objectWithoutProperties(_ref, _excluded);
36
+ var _useStyles = useStyles(type),
37
+ styles = _useStyles.styles,
38
+ cx = _useStyles.cx;
39
+ var container = cx(styles.container, !wrap && styles.nowrap, className);
40
+ if (fullFeatured) return /*#__PURE__*/_jsx(FullFeaturedHighlighter, _objectSpread(_objectSpread({
41
+ allowChangeLanguage: allowChangeLanguage,
42
+ className: className,
43
+ contentStyle: contentStyle,
44
+ fileName: fileName,
45
+ icon: icon,
46
+ language: language,
47
+ style: style
48
+ }, rest), {}, {
49
+ children: children
50
+ }));
51
+ return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
52
+ className: container,
53
+ "data-code-type": "highlighter",
54
+ style: style
55
+ }, rest), {}, {
56
+ children: [spotlight && /*#__PURE__*/_jsx(Spotlight, {
57
+ size: 240
58
+ }), copyable && /*#__PURE__*/_jsx(CopyButton, {
59
+ className: styles.button,
60
+ content: children,
61
+ placement: "left",
62
+ size: copyButtonSize
63
+ }), showLanguage && language && /*#__PURE__*/_jsx(Tag, {
64
+ className: styles.lang,
65
+ children: language.toLowerCase()
66
+ }), /*#__PURE__*/_jsx("div", {
67
+ className: styles.scroller,
68
+ children: /*#__PURE__*/_jsx(SyntaxHighlighter, {
69
+ language: language === null || language === void 0 ? void 0 : language.toLowerCase(),
70
+ style: contentStyle,
71
+ children: children
72
+ })
73
+ })]
74
+ }));
75
+ });
76
+ export * from "./FullFeatured";
77
+ export * from "./SyntaxHighlighter";
@@ -0,0 +1,9 @@
1
+ export declare const useStyles: (props?: "ghost" | "block" | "pure" | undefined) => import("antd-style").ReturnStyles<{
2
+ button: string;
3
+ container: string;
4
+ header: import("antd-style").SerializedStyles;
5
+ lang: string;
6
+ nowrap: import("antd-style").SerializedStyles;
7
+ scroller: import("antd-style").SerializedStyles;
8
+ select: import("antd-style").SerializedStyles;
9
+ }>;
@@ -0,0 +1,23 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref, type) {
5
+ var token = _ref.token,
6
+ css = _ref.css,
7
+ cx = _ref.cx,
8
+ prefixCls = _ref.prefixCls,
9
+ stylish = _ref.stylish;
10
+ var prefix = "".concat(prefixCls, "-highlighter");
11
+ var buttonHoverCls = "".concat(prefix, "-hover-btn");
12
+ var langHoverCls = "".concat(prefix, "-hover-lang");
13
+ var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n\n &:hover {\n background-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, type === 'block' ? token.colorFillTertiary : token.colorFillQuaternary);
14
+ return {
15
+ button: cx(buttonHoverCls, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 2;\n inset-block-start: ", ";\n inset-inline-end: ", ";\n\n opacity: 0;\n "])), type === 'pure' ? 0 : '12px', type === 'pure' ? 0 : '12px')),
16
+ container: cx(prefix, type !== 'pure' && typeStylish, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n\n &:hover {\n .", " {\n opacity: 1;\n }\n\n .", " {\n opacity: 1;\n }\n }\n\n .prism-code {\n background: none !important;\n }\n\n pre {\n overflow: auto hidden;\n\n margin: 0 !important;\n padding: ", " !important;\n\n white-space: break-spaces;\n\n background: none !important;\n }\n\n code {\n background: transparent !important;\n }\n "])), token.borderRadius, token.motionEaseOut, buttonHoverCls, langHoverCls, type === 'pure' ? 0 : "16px")),
17
+ header: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding-block: 4px;\n padding-inline: 8px;\n background: ", ";\n "])), token.colorFillQuaternary),
18
+ lang: cx(langHoverCls, stylish.blur, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 2;\n inset-block-end: 12px;\n inset-inline-end: 4px;\n\n font-family: ", ";\n color: ", ";\n\n opacity: 0;\n\n transition: opacity 0.1s;\n "])), token.fontFamilyCode, token.colorTextSecondary)),
19
+ nowrap: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n code {\n text-wrap: nowrap !important;\n }\n "]))),
20
+ scroller: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n overflow: auto;\n width: 100%;\n height: 100%;\n "]))),
21
+ select: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n user-select: none;\n font-size: 14px;\n color: ", ";\n .", "-select-selection-item {\n min-width: 100px;\n padding-inline-end: 0 !important;\n color: ", ";\n text-align: center;\n }\n "])), token.colorTextDescription, prefixCls, token.colorTextDescription)
22
+ };
23
+ });
@@ -0,0 +1 @@
1
+ export declare const themeConfig: any;