@lobehub/ui 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/ActionIcon/index.d.ts +10 -5
- package/es/ActionIcon/index.js +15 -7
- package/es/ActionIcon/style.d.ts +4 -1
- package/es/ActionIcon/style.js +5 -3
- package/es/CopyButton/index.d.ts +34 -0
- package/es/CopyButton/index.js +49 -0
- package/es/DraggablePanel/index.d.ts +4 -4
- package/es/DraggablePanel/index.js +4 -4
- package/es/DraggablePanel/style.js +2 -2
- package/es/DraggablePanel/utils.d.ts +1 -1
- package/es/EditableText/ControlInput.d.ts +9 -0
- package/es/EditableText/ControlInput.js +88 -0
- package/es/EditableText/index.d.ts +5 -0
- package/es/EditableText/index.js +35 -0
- package/es/Highlighter/SyntaxHighlighter/Prism.d.ts +7 -0
- package/es/Highlighter/SyntaxHighlighter/Prism.js +40 -0
- package/es/Highlighter/SyntaxHighlighter/index.d.ts +5 -0
- package/es/Highlighter/SyntaxHighlighter/index.js +58 -0
- package/es/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
- package/es/Highlighter/SyntaxHighlighter/style.js +15 -0
- package/es/Highlighter/index.d.ts +36 -0
- package/es/Highlighter/index.js +42 -0
- package/es/Highlighter/style.d.ts +5 -0
- package/es/Highlighter/style.js +18 -0
- package/es/Icon/index.d.ts +2 -3
- package/es/Icon/index.js +2 -2
- package/es/Logo/Divider.d.ts +3 -3
- package/es/Logo/Divider.js +6 -4
- package/es/Logo/Logo3D.d.ts +3 -3
- package/es/Logo/Logo3D.js +6 -4
- package/es/Logo/LogoFlat.d.ts +3 -3
- package/es/Logo/LogoFlat.js +6 -4
- package/es/Logo/LogoHighContrast.d.ts +3 -3
- package/es/Logo/LogoHighContrast.js +6 -4
- package/es/Logo/LogoText.d.ts +3 -3
- package/es/Logo/LogoText.js +6 -4
- package/es/Logo/index.d.ts +3 -3
- package/es/Logo/index.js +5 -5
- package/es/Logo/style.js +1 -1
- package/es/Markdown/Code.d.ts +3 -0
- package/es/Markdown/Code.js +12 -0
- package/es/Markdown/CodeBlock.d.ts +3 -0
- package/es/Markdown/CodeBlock.js +27 -0
- package/es/Markdown/index.d.ts +13 -0
- package/es/Markdown/index.js +28 -0
- package/es/Markdown/style.d.ts +4 -0
- package/es/Markdown/style.js +12 -0
- package/es/MessageInput/index.d.ts +35 -0
- package/es/MessageInput/index.js +63 -0
- package/es/SearchBar/index.d.ts +5 -0
- package/es/SearchBar/index.js +27 -0
- package/es/SideNav/index.d.ts +6 -6
- package/es/SideNav/index.js +17 -20
- package/es/SideNav/style.d.ts +1 -0
- package/es/SideNav/style.js +8 -0
- package/es/Snippet/index.d.ts +29 -0
- package/es/Snippet/index.js +39 -0
- package/es/Snippet/style.d.ts +1 -0
- package/es/Snippet/style.js +9 -0
- package/es/StroyBook/index.d.ts +3 -4
- package/es/StroyBook/index.js +14 -7
- package/es/StroyBook/style.d.ts +4 -1
- package/es/StroyBook/style.js +7 -5
- package/es/Swatches/index.d.ts +8 -0
- package/es/Swatches/index.js +44 -0
- package/es/TabsNav/index.d.ts +3 -3
- package/es/TabsNav/index.js +4 -4
- package/es/ThemeProvider/GlobalStyle.js +1 -1
- package/es/ThemeProvider/index.d.ts +15 -0
- package/es/ThemeSwitch/index.d.ts +5 -5
- package/es/ThemeSwitch/index.js +5 -9
- package/es/Tooltip/index.d.ts +5 -0
- package/es/Tooltip/index.js +20 -0
- package/es/Tooltip/style.d.ts +3 -0
- package/es/Tooltip/style.js +10 -0
- package/es/hooks/useCopied.d.ts +4 -0
- package/es/hooks/useCopied.js +26 -0
- package/es/hooks/useHighlight.d.ts +36 -0
- package/es/hooks/useHighlight.js +63 -0
- package/es/index.d.ts +9 -0
- package/es/index.js +10 -1
- package/es/styles/theme/base.d.ts +2 -0
- package/es/styles/theme/base.js +15 -0
- package/es/styles/theme/dark.js +6 -14
- package/es/styles/theme/light.js +11 -12
- package/es/types/index.d.ts +14 -5
- package/lib/ActionIcon/index.d.ts +10 -5
- package/lib/ActionIcon/index.js +39 -50
- package/lib/ActionIcon/style.d.ts +4 -1
- package/lib/ActionIcon/style.js +29 -22
- package/lib/CopyButton/index.d.ts +34 -0
- package/lib/CopyButton/index.js +70 -0
- package/lib/DraggablePanel/index.d.ts +4 -4
- package/lib/DraggablePanel/index.js +160 -158
- package/lib/DraggablePanel/style.js +1 -2
- package/lib/DraggablePanel/utils.d.ts +1 -1
- package/lib/EditableText/ControlInput.d.ts +9 -0
- package/lib/EditableText/ControlInput.js +101 -0
- package/lib/EditableText/index.d.ts +5 -0
- package/lib/EditableText/index.js +52 -0
- package/lib/Highlighter/SyntaxHighlighter/Prism.d.ts +7 -0
- package/lib/Highlighter/SyntaxHighlighter/Prism.js +41 -0
- package/lib/Highlighter/SyntaxHighlighter/index.d.ts +5 -0
- package/lib/Highlighter/SyntaxHighlighter/index.js +55 -0
- package/lib/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
- package/lib/Highlighter/SyntaxHighlighter/style.js +58 -0
- package/lib/Highlighter/index.d.ts +36 -0
- package/lib/Highlighter/index.js +62 -0
- package/lib/Highlighter/style.d.ts +5 -0
- package/lib/Highlighter/style.js +107 -0
- package/lib/Icon/index.d.ts +2 -3
- package/lib/Icon/index.js +3 -13
- package/lib/Logo/Divider.d.ts +3 -3
- package/lib/Logo/Divider.js +5 -15
- package/lib/Logo/Logo3D.d.ts +3 -3
- package/lib/Logo/Logo3D.js +4 -14
- package/lib/Logo/LogoFlat.d.ts +3 -3
- package/lib/Logo/LogoFlat.js +18 -28
- package/lib/Logo/LogoHighContrast.d.ts +3 -3
- package/lib/Logo/LogoHighContrast.js +4 -14
- package/lib/Logo/LogoText.d.ts +3 -3
- package/lib/Logo/LogoText.js +5 -15
- package/lib/Logo/index.d.ts +3 -3
- package/lib/Logo/index.js +11 -18
- package/lib/Logo/style.js +1 -1
- package/lib/Markdown/Code.d.ts +3 -0
- package/lib/Markdown/Code.js +33 -0
- package/lib/Markdown/CodeBlock.d.ts +3 -0
- package/lib/Markdown/CodeBlock.js +64 -0
- package/lib/Markdown/index.d.ts +13 -0
- package/lib/Markdown/index.js +48 -0
- package/lib/Markdown/style.d.ts +4 -0
- package/lib/Markdown/style.js +64 -0
- package/lib/MessageInput/index.d.ts +35 -0
- package/lib/MessageInput/index.js +58 -0
- package/lib/SearchBar/index.d.ts +5 -0
- package/lib/SearchBar/index.js +42 -0
- package/lib/SideNav/index.d.ts +6 -6
- package/lib/SideNav/index.js +7 -31
- package/lib/SideNav/style.d.ts +1 -0
- package/lib/SideNav/style.js +46 -0
- package/lib/Snippet/index.d.ts +29 -0
- package/lib/Snippet/index.js +47 -0
- package/lib/Snippet/style.d.ts +1 -0
- package/lib/Snippet/style.js +71 -0
- package/lib/StroyBook/index.d.ts +3 -4
- package/lib/StroyBook/index.js +20 -13
- package/lib/StroyBook/style.d.ts +4 -1
- package/lib/StroyBook/style.js +49 -43
- package/lib/Swatches/index.d.ts +8 -0
- package/lib/Swatches/index.js +68 -0
- package/lib/TabsNav/index.d.ts +3 -3
- package/lib/TabsNav/index.js +5 -15
- package/lib/ThemeProvider/GlobalStyle.js +7 -5
- package/lib/ThemeProvider/index.d.ts +15 -0
- package/lib/ThemeSwitch/index.d.ts +5 -5
- package/lib/ThemeSwitch/index.js +15 -32
- package/lib/Tooltip/index.d.ts +5 -0
- package/lib/Tooltip/index.js +34 -0
- package/lib/Tooltip/style.d.ts +3 -0
- package/lib/Tooltip/style.js +51 -0
- package/lib/hooks/useCopied.d.ts +4 -0
- package/lib/hooks/useCopied.js +44 -0
- package/lib/hooks/useHighlight.d.ts +36 -0
- package/lib/hooks/useHighlight.js +76 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +29 -0
- package/lib/styles/theme/base.d.ts +2 -0
- package/lib/styles/theme/base.js +43 -0
- package/lib/styles/theme/dark.js +5 -12
- package/lib/styles/theme/light.js +10 -10
- package/lib/types/index.d.ts +14 -5
- package/package.json +12 -4
- package/es/ThemeProvider/token.d.ts +0 -3
- package/es/ThemeProvider/token.js +0 -45
- package/es/types/index.js +0 -1
- package/lib/ThemeProvider/token.d.ts +0 -3
- package/lib/ThemeProvider/token.js +0 -73
- package/lib/types/index.js +0 -17
package/es/ActionIcon/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { LucideIcon } from 'lucide-react';
|
|
3
|
-
import
|
|
4
|
-
export declare type ActionIconSize = 'large' | 'normal' | 'small' | {
|
|
3
|
+
import { DivProps } from "../types";
|
|
4
|
+
export declare type ActionIconSize = 'large' | 'normal' | 'small' | 'site' | {
|
|
5
5
|
blockSize?: number;
|
|
6
6
|
fontSize?: number;
|
|
7
7
|
strokeWidth?: number;
|
|
@@ -23,6 +23,11 @@ export interface ActionIconProps extends DivProps {
|
|
|
23
23
|
* @type LucideIcon
|
|
24
24
|
*/
|
|
25
25
|
icon: LucideIcon;
|
|
26
|
+
/**
|
|
27
|
+
* @description Glass blur style
|
|
28
|
+
* @default 'false'
|
|
29
|
+
*/
|
|
30
|
+
glass?: boolean;
|
|
26
31
|
}
|
|
27
|
-
declare const
|
|
28
|
-
export default
|
|
32
|
+
declare const ActionIcon: import("react").NamedExoticComponent<ActionIconProps>;
|
|
33
|
+
export default ActionIcon;
|
package/es/ActionIcon/index.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "active", "icon", "size", "style"];
|
|
3
|
+
var _excluded = ["className", "active", "icon", "size", "style", "glass"];
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
import { Icon } from "./..";
|
|
7
|
-
import
|
|
7
|
+
import { memo } from 'react';
|
|
8
8
|
import { useStyles } from "./style";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
var ActionIcon = function
|
|
10
|
+
var ActionIcon = /*#__PURE__*/memo(function (_ref) {
|
|
11
11
|
var className = _ref.className,
|
|
12
12
|
active = _ref.active,
|
|
13
13
|
icon = _ref.icon,
|
|
14
14
|
_ref$size = _ref.size,
|
|
15
15
|
size = _ref$size === void 0 ? 'normal' : _ref$size,
|
|
16
16
|
style = _ref.style,
|
|
17
|
+
glass = _ref.glass,
|
|
17
18
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
|
-
var _useStyles = useStyles(
|
|
19
|
+
var _useStyles = useStyles({
|
|
20
|
+
active: Boolean(active),
|
|
21
|
+
glass: Boolean(glass)
|
|
22
|
+
}),
|
|
19
23
|
styles = _useStyles.styles,
|
|
20
24
|
cx = _useStyles.cx;
|
|
21
25
|
var blockSize;
|
|
@@ -33,6 +37,10 @@ var ActionIcon = function ActionIcon(_ref) {
|
|
|
33
37
|
blockSize = 28;
|
|
34
38
|
borderRadius = 5;
|
|
35
39
|
break;
|
|
40
|
+
case 'site':
|
|
41
|
+
blockSize = 34;
|
|
42
|
+
borderRadius = 5;
|
|
43
|
+
break;
|
|
36
44
|
default:
|
|
37
45
|
blockSize = (size === null || size === void 0 ? void 0 : size.blockSize) || 36;
|
|
38
46
|
borderRadius = (size === null || size === void 0 ? void 0 : size.borderRadius) || 5;
|
|
@@ -47,9 +55,9 @@ var ActionIcon = function ActionIcon(_ref) {
|
|
|
47
55
|
}, style)
|
|
48
56
|
}, props), {}, {
|
|
49
57
|
children: /*#__PURE__*/_jsx(Icon, {
|
|
50
|
-
size: size,
|
|
58
|
+
size: size === 'site' ? 'small' : size,
|
|
51
59
|
icon: icon
|
|
52
60
|
})
|
|
53
61
|
}));
|
|
54
|
-
};
|
|
55
|
-
export default
|
|
62
|
+
});
|
|
63
|
+
export default ActionIcon;
|
package/es/ActionIcon/style.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export declare const useStyles: (props?:
|
|
1
|
+
export declare const useStyles: (props?: {
|
|
2
|
+
active: boolean;
|
|
3
|
+
glass: boolean;
|
|
4
|
+
} | undefined) => import("antd-style").ReturnStyles<{
|
|
2
5
|
block: import("antd-style").SerializedStyles;
|
|
3
6
|
}>;
|
package/es/ActionIcon/style.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject;
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
|
-
export var useStyles = createStyles(function (_ref,
|
|
4
|
+
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
5
5
|
var css = _ref.css,
|
|
6
6
|
token = _ref.token;
|
|
7
|
+
var active = _ref2.active,
|
|
8
|
+
glass = _ref2.glass;
|
|
7
9
|
return {
|
|
8
|
-
block: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
10
|
+
block: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n color: ", ";\n\n background: ", ";\n\n transition: color 600ms ", ",\n background-color 100ms ", ";\n\n ", "\n\n &:hover {\n color: ", ";\n background-color: ", ";\n }\n\n &:active {\n color: ", ";\n background-color: ", ";\n }\n "])), active ? token.colorText : token.colorTextQuaternary, active ? token.colorFillTertiary : 'transparent', token.motionEaseOut, token.motionEaseOut, glass && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n backdrop-filter: saturate(180%) blur(10px);\n "]))), token.colorText, active ? token.colorFillSecondary : token.colorFillTertiary, token.colorText, token.colorFill)
|
|
9
11
|
};
|
|
10
12
|
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ActionIconSize, TooltipProps } from "../index";
|
|
2
|
+
import { DivProps } from "../types";
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
export interface CopyButtonProps extends DivProps {
|
|
5
|
+
/**
|
|
6
|
+
* @description The text content to be copied
|
|
7
|
+
*/
|
|
8
|
+
content: string;
|
|
9
|
+
/**
|
|
10
|
+
* @description The size of the icon
|
|
11
|
+
* @enum ['large', 'normal', 'small', 'site']
|
|
12
|
+
* @default 'site'
|
|
13
|
+
*/
|
|
14
|
+
size?: ActionIconSize;
|
|
15
|
+
/**
|
|
16
|
+
* @description Additional class name
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* @description The placement of the tooltip
|
|
21
|
+
* @enum ['top', 'left', 'right', 'bottom', 'topLeft', 'topRight', 'bottomLeft', 'bottomRight', 'leftTop', 'leftBottom', 'rightTop', 'rightBottom']
|
|
22
|
+
* @default 'right'
|
|
23
|
+
*/
|
|
24
|
+
placement?: TooltipProps['placement'];
|
|
25
|
+
/**
|
|
26
|
+
* @description A function that returns the children to be rendered
|
|
27
|
+
|
|
28
|
+
*/
|
|
29
|
+
render?: (props: {
|
|
30
|
+
handleCopy: () => void;
|
|
31
|
+
}) => ReactNode;
|
|
32
|
+
}
|
|
33
|
+
declare const CopyButton: ({ content, className, placement, size, render, ...props }: CopyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export default CopyButton;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["content", "className", "placement", "size", "render"];
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
import { useCopied } from "../hooks/useCopied";
|
|
7
|
+
import { ActionIcon, Tooltip } from "./..";
|
|
8
|
+
import copy from 'copy-to-clipboard';
|
|
9
|
+
import { Copy } from 'lucide-react';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
var CopyButton = function CopyButton(_ref) {
|
|
13
|
+
var content = _ref.content,
|
|
14
|
+
className = _ref.className,
|
|
15
|
+
_ref$placement = _ref.placement,
|
|
16
|
+
placement = _ref$placement === void 0 ? 'right' : _ref$placement,
|
|
17
|
+
_ref$size = _ref.size,
|
|
18
|
+
size = _ref$size === void 0 ? 'site' : _ref$size,
|
|
19
|
+
render = _ref.render,
|
|
20
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
var _useCopied = useCopied(),
|
|
22
|
+
copied = _useCopied.copied,
|
|
23
|
+
setCopied = _useCopied.setCopied;
|
|
24
|
+
var handleCopy = function handleCopy() {
|
|
25
|
+
copy(content);
|
|
26
|
+
setCopied();
|
|
27
|
+
};
|
|
28
|
+
var children = render ? render({
|
|
29
|
+
handleCopy: handleCopy
|
|
30
|
+
}) : /*#__PURE__*/_jsx(ActionIcon, _objectSpread(_objectSpread({}, props), {}, {
|
|
31
|
+
icon: Copy,
|
|
32
|
+
className: className,
|
|
33
|
+
size: size,
|
|
34
|
+
glass: true,
|
|
35
|
+
onClick: function onClick() {
|
|
36
|
+
copy(content);
|
|
37
|
+
setCopied();
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
41
|
+
arrow: false,
|
|
42
|
+
placement: placement,
|
|
43
|
+
title: copied ? /*#__PURE__*/_jsx(_Fragment, {
|
|
44
|
+
children: "\u2705 Success"
|
|
45
|
+
}) : 'Copy',
|
|
46
|
+
children: children
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
export default CopyButton;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { NumberSize, Size } from 're-resizable';
|
|
3
|
-
import React from 'react';
|
|
4
3
|
import type { Props as RndProps } from 'react-rnd';
|
|
4
|
+
import { DivProps } from "../types";
|
|
5
5
|
export declare type placementType = 'right' | 'left' | 'top' | 'bottom';
|
|
6
6
|
export interface DraggablePanelProps extends DivProps {
|
|
7
7
|
/**
|
|
@@ -82,5 +82,5 @@ export interface DraggablePanelProps extends DivProps {
|
|
|
82
82
|
*/
|
|
83
83
|
hanlderStyle?: React.CSSProperties;
|
|
84
84
|
}
|
|
85
|
-
declare const
|
|
86
|
-
export default
|
|
85
|
+
declare const DraggablePanel: import("react").NamedExoticComponent<DraggablePanelProps>;
|
|
86
|
+
export default DraggablePanel;
|
|
@@ -5,7 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
import { useHover } from 'ahooks';
|
|
6
6
|
import { ChevronDown, ChevronLeft, ChevronRight, ChevronUp } from 'lucide-react';
|
|
7
7
|
import { Resizable } from 're-resizable';
|
|
8
|
-
import
|
|
8
|
+
import { memo, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
import { Center } from 'react-layout-kit';
|
|
10
10
|
import useControlledState from 'use-merge-value';
|
|
11
11
|
import { useStyle } from "./style";
|
|
@@ -14,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
var DEFAULT_HEIGHT = 180;
|
|
16
16
|
var DEFAULT_WIDTH = 280;
|
|
17
|
-
var DraggablePanel = function
|
|
17
|
+
var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
|
|
18
18
|
var _ref$pin = _ref.pin,
|
|
19
19
|
pin = _ref$pin === void 0 ? 'true' : _ref$pin,
|
|
20
20
|
_ref$mode = _ref.mode,
|
|
@@ -193,5 +193,5 @@ var DraggablePanel = function DraggablePanel(_ref) {
|
|
|
193
193
|
style: _defineProperty({}, "border".concat(arrowPlacement, "Width"), 1),
|
|
194
194
|
children: [expandable && showExpand && handler, destroyOnClose ? isExpand && inner : inner]
|
|
195
195
|
});
|
|
196
|
-
};
|
|
197
|
-
export default
|
|
196
|
+
});
|
|
197
|
+
export default DraggablePanel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
2
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19;
|
|
3
3
|
import { createStyles, css, cx } from 'antd-style';
|
|
4
|
-
var offset =
|
|
4
|
+
var offset = 16;
|
|
5
5
|
var toggleLength = 40;
|
|
6
6
|
var toggleShort = 16;
|
|
7
7
|
export var useStyle = createStyles(function (_ref, prefix) {
|
|
@@ -20,7 +20,7 @@ export var useStyle = createStyles(function (_ref, prefix) {
|
|
|
20
20
|
toggleRight: cx("".concat(prefix, "-toggle"), "".concat(prefix, "-toggle-right"), commonToggle, css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n right: -", "px;\n width: ", "px;\n height: 100%;\n > div {\n top: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-top: -20px;\n\n border-radius: 0 4px 4px 0;\n }\n "])), offset, toggleShort, toggleShort, toggleLength)),
|
|
21
21
|
toggleTop: cx("".concat(prefix, "-toggle"), "".concat(prefix, "-toggle-top"), commonToggle, css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n top: -", "px;\n width: 100%;\n height: ", "px;\n\n > div {\n left: 50%;\n\n width: ", "px;\n height: ", "px;\n margin-left: -20px;\n\n border-radius: 4px 4px 0 0;\n }\n "])), offset, toggleShort, toggleLength, toggleShort)),
|
|
22
22
|
toggleBottom: cx("".concat(prefix, "-toggle"), "".concat(prefix, "-toggle-bottom"), commonToggle, css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n bottom: -", "px;\n width: 100%;\n height: ", "px;\n\n > div {\n left: 50%;\n\n width: ", "px;\n height: 16px;\n margin-left: -20px;\n\n border-radius: 0 0 4px 4px;\n }\n "])), offset, toggleShort, toggleLength)),
|
|
23
|
-
panel: cx("".concat(prefix, "-fixed"), css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n overflow: hidden;\n
|
|
23
|
+
panel: cx("".concat(prefix, "-fixed"), css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n overflow: hidden;\n transition: all 0.2s ", ";\n "])), token.motionEaseOut)),
|
|
24
24
|
handlerIcon: css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ", ";\n "])), token.motionEaseOut),
|
|
25
25
|
leftHandle: cx(css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n ", ";\n\n &::before {\n left: 50%;\n width: 2px;\n height: 100%;\n }\n "])), commonHandle), "".concat(prefix, "-left-handle")),
|
|
26
26
|
rightHandle: cx(css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n ", ";\n &::before {\n right: 50%;\n width: 2px;\n height: 100%;\n }\n "])), commonHandle), "".concat(prefix, "-right-handle")),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { placementType } from './index';
|
|
2
|
-
export declare const revesePlacement: (placement: placementType) => "
|
|
2
|
+
export declare const revesePlacement: (placement: placementType) => "top" | "left" | "right" | "bottom";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InputProps } from 'antd';
|
|
3
|
+
export interface ControlInputProps extends Omit<InputProps, 'onChange' | 'value' | 'onAbort'> {
|
|
4
|
+
onChange?: (value: string) => void;
|
|
5
|
+
onValueChanging?: (value: string) => void;
|
|
6
|
+
value?: string;
|
|
7
|
+
onChangeEnd?: (value: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const ControlInput: import("react").NamedExoticComponent<ControlInputProps>;
|
|
@@ -0,0 +1,88 @@
|
|
|
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 = ["value", "onChange", "onValueChanging", "onChangeEnd"];
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
import { Button, ConfigProvider, Input } from 'antd';
|
|
8
|
+
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
12
|
+
var value = _ref.value,
|
|
13
|
+
onChange = _ref.onChange,
|
|
14
|
+
onValueChanging = _ref.onValueChanging,
|
|
15
|
+
onChangeEnd = _ref.onChangeEnd,
|
|
16
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
17
|
+
var _useState = useState(value || ''),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
input = _useState2[0],
|
|
20
|
+
setInput = _useState2[1];
|
|
21
|
+
var inputRef = useRef(null);
|
|
22
|
+
var isChineseInput = useRef(false);
|
|
23
|
+
var isFocusing = useRef(false);
|
|
24
|
+
var updateValue = useCallback(function () {
|
|
25
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(input);
|
|
26
|
+
}, [input]);
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
if (typeof value !== 'undefined') setInput(value);
|
|
29
|
+
}, [value]);
|
|
30
|
+
return /*#__PURE__*/_jsx(Input, _objectSpread(_objectSpread({
|
|
31
|
+
ref: inputRef
|
|
32
|
+
}, props), {}, {
|
|
33
|
+
value: input,
|
|
34
|
+
onCompositionStart: function onCompositionStart() {
|
|
35
|
+
isChineseInput.current = true;
|
|
36
|
+
},
|
|
37
|
+
onCompositionEnd: function onCompositionEnd() {
|
|
38
|
+
isChineseInput.current = false;
|
|
39
|
+
},
|
|
40
|
+
onFocus: function onFocus() {
|
|
41
|
+
isFocusing.current = true;
|
|
42
|
+
},
|
|
43
|
+
onBlur: function onBlur() {
|
|
44
|
+
isFocusing.current = false;
|
|
45
|
+
onChangeEnd === null || onChangeEnd === void 0 ? void 0 : onChangeEnd(input);
|
|
46
|
+
},
|
|
47
|
+
onChange: function onChange(e) {
|
|
48
|
+
setInput(e.target.value);
|
|
49
|
+
onValueChanging === null || onValueChanging === void 0 ? void 0 : onValueChanging(e.target.value);
|
|
50
|
+
},
|
|
51
|
+
onPressEnter: function onPressEnter(e) {
|
|
52
|
+
if (!e.shiftKey && !isChineseInput.current) {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
updateValue();
|
|
55
|
+
isFocusing.current = false;
|
|
56
|
+
onChangeEnd === null || onChangeEnd === void 0 ? void 0 : onChangeEnd(input);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
suffix: value === input ? /*#__PURE__*/_jsx("span", {}) : /*#__PURE__*/_jsxs(ConfigProvider, {
|
|
60
|
+
theme: {
|
|
61
|
+
token: {
|
|
62
|
+
fontSize: 14
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
66
|
+
type: 'link',
|
|
67
|
+
size: 'small',
|
|
68
|
+
onClick: function onClick() {
|
|
69
|
+
setInput(value);
|
|
70
|
+
},
|
|
71
|
+
style: {
|
|
72
|
+
padding: 0
|
|
73
|
+
},
|
|
74
|
+
children: "\u91CD\u7F6E"
|
|
75
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
76
|
+
type: 'link',
|
|
77
|
+
size: 'small',
|
|
78
|
+
style: {
|
|
79
|
+
padding: 0
|
|
80
|
+
},
|
|
81
|
+
onClick: function onClick() {
|
|
82
|
+
updateValue();
|
|
83
|
+
},
|
|
84
|
+
children: "\u4FDD\u5B58 \u21B5"
|
|
85
|
+
})]
|
|
86
|
+
})
|
|
87
|
+
}));
|
|
88
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { EditOutlined } from '@ant-design/icons';
|
|
3
|
+
import { Tooltip } from 'antd';
|
|
4
|
+
import { memo, useState } from 'react';
|
|
5
|
+
import { Flexbox } from 'react-layout-kit';
|
|
6
|
+
import { ControlInput } from "./ControlInput";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
var EditableText = /*#__PURE__*/memo(function (_ref) {
|
|
10
|
+
var value = _ref.value,
|
|
11
|
+
onChange = _ref.onChange;
|
|
12
|
+
var _useState = useState(false),
|
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
+
edited = _useState2[0],
|
|
15
|
+
setEdited = _useState2[1];
|
|
16
|
+
return edited ? /*#__PURE__*/_jsx(ControlInput, {
|
|
17
|
+
value: value,
|
|
18
|
+
onChangeEnd: function onChangeEnd() {
|
|
19
|
+
setEdited(false);
|
|
20
|
+
},
|
|
21
|
+
onChange: onChange
|
|
22
|
+
}) : /*#__PURE__*/_jsxs(Flexbox, {
|
|
23
|
+
horizontal: true,
|
|
24
|
+
gap: 8,
|
|
25
|
+
children: [value, /*#__PURE__*/_jsx(Tooltip, {
|
|
26
|
+
title: '编辑',
|
|
27
|
+
children: /*#__PURE__*/_jsx(EditOutlined, {
|
|
28
|
+
onClick: function onClick() {
|
|
29
|
+
setEdited(!edited);
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
})]
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
export default EditableText;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { Highlight, themes } from 'prism-react-renderer';
|
|
5
|
+
import { memo } from 'react';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export var Prism = /*#__PURE__*/memo(function (_ref) {
|
|
8
|
+
var children = _ref.children,
|
|
9
|
+
language = _ref.language,
|
|
10
|
+
isDarkMode = _ref.isDarkMode;
|
|
11
|
+
return /*#__PURE__*/_jsx(Highlight, {
|
|
12
|
+
theme: isDarkMode ? themes.jettwaveDark : themes.jettwaveLight,
|
|
13
|
+
code: children,
|
|
14
|
+
language: language,
|
|
15
|
+
children: function children(_ref2) {
|
|
16
|
+
var className = _ref2.className,
|
|
17
|
+
style = _ref2.style,
|
|
18
|
+
tokens = _ref2.tokens,
|
|
19
|
+
getLineProps = _ref2.getLineProps,
|
|
20
|
+
getTokenProps = _ref2.getTokenProps;
|
|
21
|
+
return /*#__PURE__*/_jsx("pre", {
|
|
22
|
+
className: className,
|
|
23
|
+
style: style,
|
|
24
|
+
children: tokens.map(function (line, i) {
|
|
25
|
+
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, getLineProps({
|
|
26
|
+
line: line,
|
|
27
|
+
key: i
|
|
28
|
+
})), {}, {
|
|
29
|
+
children: line.map(function (token, key) {
|
|
30
|
+
return /*#__PURE__*/_jsx("span", _objectSpread({}, getTokenProps({
|
|
31
|
+
token: token,
|
|
32
|
+
key: key
|
|
33
|
+
})), i);
|
|
34
|
+
})
|
|
35
|
+
}), i);
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { HighlighterProps } from '../index';
|
|
3
|
+
export declare type SyntaxHighlighterProps = Pick<HighlighterProps, 'language' | 'children' | 'theme'>;
|
|
4
|
+
declare const SyntaxHighlighter: import("react").NamedExoticComponent<SyntaxHighlighterProps>;
|
|
5
|
+
export default SyntaxHighlighter;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useHighlight } from "../../hooks/useHighlight";
|
|
3
|
+
import { Loading3QuartersOutlined as Loading } from '@ant-design/icons';
|
|
4
|
+
import { memo, useEffect } from 'react';
|
|
5
|
+
import { Center } from 'react-layout-kit';
|
|
6
|
+
import { shallow } from 'zustand/shallow';
|
|
7
|
+
import { Prism } from "./Prism";
|
|
8
|
+
import { useThemeMode } from 'antd-style';
|
|
9
|
+
import { useStyles } from "./style";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
|
|
14
|
+
var children = _ref.children,
|
|
15
|
+
language = _ref.language,
|
|
16
|
+
appearance = _ref.theme;
|
|
17
|
+
var _useStyles = useStyles(),
|
|
18
|
+
styles = _useStyles.styles,
|
|
19
|
+
theme = _useStyles.theme;
|
|
20
|
+
var _useThemeMode = useThemeMode(),
|
|
21
|
+
isDarkMode = _useThemeMode.isDarkMode;
|
|
22
|
+
var isDarkTheme = appearance ? appearance === 'dark' : isDarkMode;
|
|
23
|
+
var _useHighlight = useHighlight(function (s) {
|
|
24
|
+
return [s.codeToHtml, !s.highlighter];
|
|
25
|
+
}, shallow),
|
|
26
|
+
_useHighlight2 = _slicedToArray(_useHighlight, 2),
|
|
27
|
+
codeToHtml = _useHighlight2[0],
|
|
28
|
+
isLoading = _useHighlight2[1];
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
useHighlight.getState().initHighlighter();
|
|
31
|
+
}, []);
|
|
32
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
33
|
+
children: [isLoading ? /*#__PURE__*/_jsx("div", {
|
|
34
|
+
className: styles.prism,
|
|
35
|
+
children: /*#__PURE__*/_jsx(Prism, {
|
|
36
|
+
language: language,
|
|
37
|
+
isDarkMode: isDarkTheme,
|
|
38
|
+
children: children
|
|
39
|
+
})
|
|
40
|
+
}) : /*#__PURE__*/_jsx("div", {
|
|
41
|
+
dangerouslySetInnerHTML: {
|
|
42
|
+
__html: codeToHtml(children, language, isDarkTheme) || ''
|
|
43
|
+
},
|
|
44
|
+
className: styles.shiki
|
|
45
|
+
}), isLoading && /*#__PURE__*/_jsxs(Center, {
|
|
46
|
+
horizontal: true,
|
|
47
|
+
gap: 8,
|
|
48
|
+
className: styles.loading,
|
|
49
|
+
children: [/*#__PURE__*/_jsx(Loading, {
|
|
50
|
+
spin: true,
|
|
51
|
+
style: {
|
|
52
|
+
color: theme.colorTextTertiary
|
|
53
|
+
}
|
|
54
|
+
}), "shiki rendering..."]
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
export default SyntaxHighlighter;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
var prefix = "".concat(prefixCls, "-highlighter");
|
|
10
|
+
return {
|
|
11
|
+
shiki: cx("".concat(prefix, "-shiki"), css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .shiki {\n overflow-x: scroll;\n background: none !important;\n }\n "])))),
|
|
12
|
+
prism: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n pre {\n overflow-x: scroll;\n font-family: ", " !important;\n }\n "])), token.fontFamilyCode),
|
|
13
|
+
loading: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n right: 0;\n color: ", ";\n padding: 4px 8px;\n backdrop-filter: saturate(180%) blur(10px);\n border-radius: ", ";\n "])), token.colorTextTertiary, token.borderRadiusSM)
|
|
14
|
+
};
|
|
15
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DivProps } from "../types";
|
|
3
|
+
import SyntaxHighlighter, { type SyntaxHighlighterProps } from './SyntaxHighlighter';
|
|
4
|
+
export { SyntaxHighlighter, SyntaxHighlighterProps };
|
|
5
|
+
export interface HighlighterProps extends DivProps {
|
|
6
|
+
/**
|
|
7
|
+
* @description The code content to be highlighted
|
|
8
|
+
*/
|
|
9
|
+
children: string;
|
|
10
|
+
/**
|
|
11
|
+
* @description The language of the code content
|
|
12
|
+
*/
|
|
13
|
+
language: string;
|
|
14
|
+
/**
|
|
15
|
+
* @description Whether to show language tag
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
showLanguage?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @description Whether to show the copy button
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
copyable?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @description The theme of the code block
|
|
26
|
+
* @default 'light'
|
|
27
|
+
*/
|
|
28
|
+
theme?: 'dark' | 'light';
|
|
29
|
+
/**
|
|
30
|
+
* @description The type of the code block
|
|
31
|
+
* @default 'block'
|
|
32
|
+
*/
|
|
33
|
+
type?: 'ghost' | 'block' | 'prue';
|
|
34
|
+
}
|
|
35
|
+
export declare const Highlighter: import("react").NamedExoticComponent<HighlighterProps>;
|
|
36
|
+
export default Highlighter;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import CopyButton from "../CopyButton";
|
|
3
|
+
import SyntaxHighlighter from "./SyntaxHighlighter";
|
|
4
|
+
import { useStyles } from "./style";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
export { SyntaxHighlighter };
|
|
8
|
+
export var Highlighter = /*#__PURE__*/memo(function (_ref) {
|
|
9
|
+
var children = _ref.children,
|
|
10
|
+
language = _ref.language,
|
|
11
|
+
className = _ref.className,
|
|
12
|
+
style = _ref.style,
|
|
13
|
+
theme = _ref.theme,
|
|
14
|
+
_ref$copyable = _ref.copyable,
|
|
15
|
+
copyable = _ref$copyable === void 0 ? true : _ref$copyable,
|
|
16
|
+
_ref$showLanguage = _ref.showLanguage,
|
|
17
|
+
showLanguage = _ref$showLanguage === void 0 ? true : _ref$showLanguage,
|
|
18
|
+
_ref$type = _ref.type,
|
|
19
|
+
type = _ref$type === void 0 ? 'block' : _ref$type;
|
|
20
|
+
var _useStyles = useStyles(type),
|
|
21
|
+
styles = _useStyles.styles,
|
|
22
|
+
cx = _useStyles.cx;
|
|
23
|
+
var container = cx(styles.container, className);
|
|
24
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
25
|
+
"data-code-type": "highlighter",
|
|
26
|
+
className: container,
|
|
27
|
+
style: style,
|
|
28
|
+
children: [copyable && /*#__PURE__*/_jsx(CopyButton, {
|
|
29
|
+
placement: "left",
|
|
30
|
+
content: children,
|
|
31
|
+
className: styles.button
|
|
32
|
+
}), showLanguage && language && /*#__PURE__*/_jsx("div", {
|
|
33
|
+
className: styles.lang,
|
|
34
|
+
children: language.toLowerCase()
|
|
35
|
+
}), /*#__PURE__*/_jsx(SyntaxHighlighter, {
|
|
36
|
+
theme: theme,
|
|
37
|
+
language: language === null || language === void 0 ? void 0 : language.toLowerCase(),
|
|
38
|
+
children: children.trim()
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
export default Highlighter;
|