@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.
- package/es/Alert/index.d.ts +13 -0
- package/es/Alert/index.js +25 -0
- package/es/Alert/style.d.ts +4 -0
- package/es/Alert/style.js +13 -0
- package/es/App/index.d.ts +7 -0
- package/es/App/index.js +19 -0
- package/es/ButtonGroup/index.d.ts +24 -0
- package/es/ButtonGroup/index.js +66 -0
- package/es/Card/index.d.ts +1 -0
- package/es/Card/index.js +1 -0
- package/es/CardList/Item/index.d.ts +4 -0
- package/es/CardList/Item/index.js +43 -0
- package/es/CardList/Item/style.d.ts +0 -0
- package/es/CardList/Item/style.js +0 -0
- package/es/CardList/index.d.ts +2 -0
- package/es/CardList/index.js +39 -0
- package/es/ChatInputArea/desktop/ChatInputArea.d.ts +19 -0
- package/es/ChatInputArea/desktop/ChatInputArea.js +72 -0
- package/es/ChatInputArea/index.d.ts +6 -0
- package/es/ChatInputArea/index.js +6 -0
- package/es/ChatItem/components/MessageContent.d.ts +21 -0
- package/es/ChatItem/components/MessageContent.js +59 -0
- package/es/ChatItem/index.d.ts +4 -0
- package/es/ChatItem/index.js +120 -0
- package/es/ChatItem/style.d.ts +24 -0
- package/es/ChatItem/style.js +38 -0
- package/es/ChatItem/type.d.ts +82 -0
- package/es/ChatItem/type.js +1 -0
- package/es/CollapseGroup/index.d.ts +4 -0
- package/es/CollapseGroup/index.js +23 -0
- package/es/CollapseGroup/style.d.ts +3 -0
- package/es/CollapseGroup/style.js +11 -0
- package/es/ConfigProvider/index.d.ts +3 -0
- package/es/ConfigProvider/index.js +17 -11
- package/es/Descriptions/index.d.ts +14 -0
- package/es/Descriptions/index.js +31 -0
- package/es/Descriptions/style.d.ts +4 -0
- package/es/Descriptions/style.js +24 -0
- package/es/Divider/index.d.ts +38 -0
- package/es/Divider/index.js +66 -0
- package/es/Divider/style.d.ts +3 -0
- package/es/Divider/style.js +12 -0
- package/es/DragPanel/index.d.ts +10 -0
- package/es/DragPanel/index.js +97 -0
- package/es/DragPanel/style.d.ts +7 -0
- package/es/DragPanel/style.js +15 -0
- package/es/Drawer/index.d.ts +13 -0
- package/es/Drawer/index.js +20 -0
- package/es/Drawer/style.d.ts +4 -0
- package/es/Drawer/style.js +16 -0
- package/es/Dropdown/index.d.ts +14 -0
- package/es/Dropdown/index.js +59 -0
- package/es/Dropdown/style.d.ts +7 -0
- package/es/Dropdown/style.js +13 -0
- package/es/EditableMessage/index.d.ts +75 -0
- package/es/EditableMessage/index.js +99 -0
- package/es/Form/collapse-list/index.d.ts +40 -0
- package/es/Form/collapse-list/index.js +209 -0
- package/es/Form/collapse-list/style.d.ts +5 -0
- package/es/Form/collapse-list/style.js +13 -0
- package/es/Form/index.d.ts +8 -0
- package/es/Form/index.js +5 -0
- package/es/FormHelper/autoFocus.d.ts +10 -0
- package/es/FormHelper/autoFocus.js +38 -0
- package/es/FormHelper/index.d.ts +13 -0
- package/es/FormHelper/index.js +41 -0
- package/es/Highlighter/FullFeatured.d.ts +18 -0
- package/es/Highlighter/FullFeatured.js +102 -0
- package/es/Highlighter/SyntaxHighlighter/index.d.ts +7 -0
- package/es/Highlighter/SyntaxHighlighter/index.js +51 -0
- package/es/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
- package/es/Highlighter/SyntaxHighlighter/style.js +16 -0
- package/es/Highlighter/index.d.ts +50 -0
- package/es/Highlighter/index.js +77 -0
- package/es/Highlighter/style.d.ts +9 -0
- package/es/Highlighter/style.js +23 -0
- package/es/Highlighter/theme.d.ts +1 -0
- package/es/Highlighter/theme.js +1661 -0
- package/es/LogViewer/index.d.ts +10 -0
- package/es/LogViewer/index.js +141 -0
- package/es/LogViewer/style.d.ts +6 -0
- package/es/LogViewer/style.js +16 -0
- package/es/LogViewer/types.d.ts +235 -0
- package/es/LogViewer/types.js +1 -0
- package/es/Mentions/constants.d.ts +6 -0
- package/es/Mentions/constants.js +28 -0
- package/es/Mentions/hooks.d.ts +20 -0
- package/es/Mentions/hooks.js +133 -0
- package/es/Mentions/index.d.ts +19 -0
- package/es/Mentions/index.js +136 -0
- package/es/Mentions/plugins/custom-text/node.d.ts +11 -0
- package/es/Mentions/plugins/custom-text/node.js +72 -0
- package/es/Mentions/plugins/mention-node/component.d.ts +6 -0
- package/es/Mentions/plugins/mention-node/component.js +64 -0
- package/es/Mentions/plugins/mention-node/index.d.ts +9 -0
- package/es/Mentions/plugins/mention-node/index.js +32 -0
- package/es/Mentions/plugins/mention-node/node.d.ts +23 -0
- package/es/Mentions/plugins/mention-node/node.js +97 -0
- package/es/Mentions/plugins/mention-node/replacement.d.ts +5 -0
- package/es/Mentions/plugins/mention-node/replacement.js +42 -0
- package/es/Mentions/plugins/mention-node/style.d.ts +8 -0
- package/es/Mentions/plugins/mention-node/style.js +47 -0
- package/es/Mentions/plugins/mention-node/utils.d.ts +4 -0
- package/es/Mentions/plugins/mention-node/utils.js +5 -0
- package/es/Mentions/plugins/mention-picker/hooks.d.ts +5 -0
- package/es/Mentions/plugins/mention-picker/hooks.js +39 -0
- package/es/Mentions/plugins/mention-picker/index.d.ts +36 -0
- package/es/Mentions/plugins/mention-picker/index.js +87 -0
- package/es/Mentions/plugins/mention-picker/menu-item.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/menu-item.js +71 -0
- package/es/Mentions/plugins/mention-picker/menu.d.ts +9 -0
- package/es/Mentions/plugins/mention-picker/menu.js +30 -0
- package/es/Mentions/plugins/mention-picker/style.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/style.js +19 -0
- package/es/Mentions/plugins/mention-picker/utils.d.ts +22 -0
- package/es/Mentions/plugins/mention-picker/utils.js +39 -0
- package/es/Mentions/plugins/on-blur-or-focus-block.d.ts +7 -0
- package/es/Mentions/plugins/on-blur-or-focus-block.js +36 -0
- package/es/Mentions/provider.d.ts +12 -0
- package/es/Mentions/provider.js +15 -0
- package/es/Mentions/style.d.ts +11 -0
- package/es/Mentions/style.js +22 -0
- package/es/Mentions/types.d.ts +17 -0
- package/es/Mentions/types.js +1 -0
- package/es/Mentions/utils.d.ts +9 -0
- package/es/Mentions/utils.js +95 -0
- package/es/Modal/index.d.ts +19 -0
- package/es/Modal/index.js +36 -0
- package/es/Modal/style.d.ts +4 -0
- package/es/Modal/style.js +17 -0
- package/es/MonacoEditor/base/controller.d.ts +17 -0
- package/es/MonacoEditor/base/controller.js +49 -0
- package/es/MonacoEditor/base/helper.d.ts +65 -0
- package/es/MonacoEditor/base/helper.js +324 -0
- package/es/MonacoEditor/base/index.d.ts +35 -0
- package/es/MonacoEditor/base/index.js +236 -0
- package/es/MonacoEditor/base/monaco.d.ts +6 -0
- package/es/MonacoEditor/base/monaco.js +64 -0
- package/es/MonacoEditor/base/style.d.ts +12 -0
- package/es/MonacoEditor/base/style.js +26 -0
- package/es/MonacoEditor/index.d.ts +2 -4
- package/es/MonacoEditor/index.js +26 -62
- package/es/MonacoEditor/style.js +3 -2
- package/es/Page/Breadcrumb/index.d.ts +9 -0
- package/es/Page/Breadcrumb/index.js +56 -0
- package/es/Page/Content/index.d.ts +4 -0
- package/es/Page/Content/index.js +59 -0
- package/es/Page/Content/style.d.ts +3 -0
- package/es/Page/Content/style.js +12 -0
- package/es/Page/Footer/index.d.ts +2 -0
- package/es/Page/Footer/index.js +6 -0
- package/es/Page/Header/Icon.d.ts +17 -0
- package/es/Page/Header/Icon.js +42 -0
- package/es/Page/Header/index.d.ts +43 -0
- package/es/Page/Header/index.js +202 -0
- package/es/Page/Header/style.d.ts +12 -0
- package/es/Page/Header/style.js +21 -0
- package/es/Page/Page.d.ts +9 -0
- package/es/Page/Page.js +49 -0
- package/es/Page/PageContext.d.ts +15 -0
- package/es/Page/PageContext.js +21 -0
- package/es/Page/Title/index.d.ts +5 -0
- package/es/Page/Title/index.js +18 -0
- package/es/Page/Title/style.d.ts +3 -0
- package/es/Page/Title/style.js +10 -0
- package/es/Page/index.d.ts +18 -0
- package/es/Page/index.js +15 -0
- package/es/Page/style.d.ts +3 -0
- package/es/Page/style.js +10 -0
- package/es/ProCard/Card/index.d.ts +6 -0
- package/es/ProCard/Card/index.js +25 -0
- package/es/ProCard/Card/style.d.ts +7 -0
- package/es/ProCard/Card/style.js +15 -0
- package/es/ProCard/Content/index.d.ts +4 -0
- package/es/ProCard/Content/index.js +24 -0
- package/es/ProCard/Content/style.d.ts +3 -0
- package/es/ProCard/Content/style.js +10 -0
- package/es/ProCard/Descriptions/index.d.ts +4 -0
- package/es/ProCard/Descriptions/index.js +28 -0
- package/es/ProCard/Descriptions/style.d.ts +3 -0
- package/es/ProCard/Descriptions/style.js +12 -0
- package/es/ProCard/Header/index.d.ts +15 -0
- package/es/ProCard/Header/index.js +86 -0
- package/es/ProCard/Header/style.d.ts +12 -0
- package/es/ProCard/Header/style.js +21 -0
- package/es/ProCard/index.d.ts +13 -0
- package/es/ProCard/index.js +8 -0
- package/es/Radio/index.d.ts +36 -0
- package/es/Radio/index.js +26 -0
- package/es/Radio/style.d.ts +4 -0
- package/es/Radio/style.js +66 -0
- package/es/SelectCard/index.d.ts +33 -0
- package/es/SelectCard/index.js +132 -0
- package/es/SelectCard/style.d.ts +10 -0
- package/es/SelectCard/style.js +42 -0
- package/es/SliderInput/index.js +2 -2
- package/es/Status/index.d.ts +7 -0
- package/es/Status/index.js +39 -0
- package/es/Status/style.d.ts +4 -0
- package/es/Status/style.js +14 -0
- package/es/Table/collapse/index.d.ts +8 -0
- package/es/Table/collapse/index.js +39 -0
- package/es/Table/collapse/style.d.ts +3 -0
- package/es/Table/collapse/style.js +11 -0
- package/es/Table/index.d.ts +20 -0
- package/es/Table/index.js +56 -0
- package/es/Typography/index.d.ts +32 -0
- package/es/Typography/index.js +77 -0
- package/es/WaveformIcon/index.d.ts +9 -0
- package/es/WaveformIcon/index.js +51 -0
- package/es/hooks/languageMap.d.ts +1 -0
- package/es/hooks/languageMap.js +1 -0
- package/es/hooks/useHighlight.d.ts +5 -0
- package/es/hooks/useHighlight.js +78 -0
- package/es/index.d.ts +38 -1
- package/es/index.js +52 -1
- package/es/notification/index.d.ts +24 -0
- package/es/notification/index.js +237 -0
- package/es/notification/style.d.ts +2 -0
- package/es/notification/style.js +28 -0
- package/es/styles/colors/colors.d.ts +39 -0
- package/es/styles/colors/colors.js +86 -0
- package/es/styles/colors/generateColorPalette.d.ts +11 -0
- package/es/styles/colors/generateColorPalette.js +31 -0
- package/es/styles/colors/neutralColors.d.ts +9 -0
- package/es/styles/colors/neutralColors.js +32 -0
- package/es/styles/index.d.ts +4 -0
- package/es/styles/index.js +4 -0
- package/es/useSpeechSynthes/const/polyfill.d.ts +3 -0
- package/es/useSpeechSynthes/const/polyfill.js +21 -0
- package/es/useSpeechSynthes/index.d.ts +13 -0
- package/es/useSpeechSynthes/index.js +69 -0
- package/es/utils/constants.d.ts +1 -0
- package/es/utils/constants.js +1 -0
- package/es/utils/tools.d.ts +1 -0
- package/es/utils/tools.js +1 -0
- package/package.json +30 -9
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
import React, { useRef } from 'react';
|
|
5
|
+
import { useAutoFocus } from "./autoFocus";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export { useAutoFocus } from "./autoFocus";
|
|
8
|
+
// Component
|
|
9
|
+
|
|
10
|
+
var FormHelper = function FormHelper(props) {
|
|
11
|
+
var _props$style;
|
|
12
|
+
var _props$autoFocus = props.autoFocus,
|
|
13
|
+
autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus;
|
|
14
|
+
var ref = useRef(null);
|
|
15
|
+
useAutoFocus(autoFocus ? ref : undefined);
|
|
16
|
+
return /*#__PURE__*/_jsx("div", {
|
|
17
|
+
className: props.className,
|
|
18
|
+
id: props.id,
|
|
19
|
+
ref: ref,
|
|
20
|
+
style: (_props$style = props.style) !== null && _props$style !== void 0 ? _props$style : {
|
|
21
|
+
display: props.className ? undefined : 'contents'
|
|
22
|
+
},
|
|
23
|
+
children: props.children
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// HOC
|
|
28
|
+
|
|
29
|
+
export var withFormHelper = function withFormHelper(formHelperConfig) {
|
|
30
|
+
return function (WrappedComponent) {
|
|
31
|
+
var HocComponent = function HocComponent(props) {
|
|
32
|
+
return /*#__PURE__*/_jsx(FormHelper, _objectSpread(_objectSpread({}, formHelperConfig || {}), {}, {
|
|
33
|
+
children: /*#__PURE__*/_jsx(WrappedComponent, _objectSpread({}, props))
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
var displayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
37
|
+
HocComponent.displayName = "withFormHelper(".concat(displayName, ")");
|
|
38
|
+
return HocComponent;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export { FormHelper };
|
|
@@ -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,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;
|