@lobehub/ui 1.2.0 → 1.4.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/Avatar/index.d.ts +10 -0
- package/es/Avatar/index.js +61 -0
- package/es/ContextMenu/MenuItem/icons.d.ts +4 -0
- package/es/ContextMenu/MenuItem/icons.js +73 -0
- package/es/ContextMenu/MenuItem/index.d.ts +12 -0
- package/es/ContextMenu/MenuItem/index.js +73 -0
- package/es/ContextMenu/MenuItem/style.d.ts +7 -0
- package/es/ContextMenu/MenuItem/style.js +16 -0
- package/es/ContextMenu/index.d.ts +9 -0
- package/es/ContextMenu/index.js +265 -0
- package/es/ContextMenu/style.d.ts +4 -0
- package/es/ContextMenu/style.js +12 -0
- package/es/ContextMenu/types/index.d.ts +5 -0
- package/es/ContextMenu/types/index.js +2 -0
- package/es/ContextMenu/types/menuItem.d.ts +21 -0
- package/es/CopyButton/index.d.ts +34 -0
- package/es/CopyButton/index.js +49 -0
- package/es/DraggablePanel/index.d.ts +10 -4
- package/es/DraggablePanel/index.js +10 -11
- package/es/DraggablePanel/style.js +2 -2
- 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/List/ListItem/index.d.ts +64 -0
- package/es/List/ListItem/index.js +110 -0
- package/es/List/ListItem/time.d.ts +2 -0
- package/es/List/ListItem/time.js +10 -0
- package/es/List/index.d.ts +5 -0
- package/es/List/index.js +5 -0
- 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 +12 -0
- package/es/index.js +13 -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/Avatar/index.d.ts +10 -0
- package/lib/Avatar/index.js +74 -0
- package/lib/ContextMenu/MenuItem/icons.d.ts +4 -0
- package/lib/ContextMenu/MenuItem/icons.js +100 -0
- package/lib/ContextMenu/MenuItem/index.d.ts +12 -0
- package/lib/ContextMenu/MenuItem/index.js +72 -0
- package/lib/ContextMenu/MenuItem/style.d.ts +7 -0
- package/lib/ContextMenu/MenuItem/style.js +94 -0
- package/lib/ContextMenu/index.d.ts +9 -0
- package/lib/ContextMenu/index.js +254 -0
- package/lib/ContextMenu/style.d.ts +4 -0
- package/lib/ContextMenu/style.js +88 -0
- package/lib/ContextMenu/types/index.d.ts +5 -0
- package/lib/ContextMenu/types/index.js +19 -0
- package/lib/ContextMenu/types/menuItem.d.ts +21 -0
- package/lib/{types/index.js → ContextMenu/types/menuItem.js} +3 -3
- package/lib/CopyButton/index.d.ts +34 -0
- package/lib/CopyButton/index.js +70 -0
- package/lib/DraggablePanel/index.d.ts +10 -4
- package/lib/DraggablePanel/index.js +147 -147
- package/lib/DraggablePanel/style.js +1 -2
- 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/List/ListItem/index.d.ts +64 -0
- package/lib/List/ListItem/index.js +157 -0
- package/lib/List/ListItem/time.d.ts +2 -0
- package/lib/List/ListItem/time.js +50 -0
- package/lib/List/index.d.ts +5 -0
- package/lib/List/index.js +41 -0
- 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 +12 -0
- package/lib/index.js +38 -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 +14 -4
- package/es/ThemeProvider/token.d.ts +0 -3
- package/es/ThemeProvider/token.js +0 -45
- package/lib/ThemeProvider/token.d.ts +0 -3
- package/lib/ThemeProvider/token.js +0 -73
- /package/es/{types/index.js → ContextMenu/types/menuItem.js} +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref, prefixCls) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
cx = _ref.cx,
|
|
7
|
+
token = _ref.token;
|
|
8
|
+
return {
|
|
9
|
+
container: cx(prefixCls, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n user-select: none;\n scrollbar-width: none;\n\n overflow-y: auto;\n overscroll-behavior: contain;\n\n box-sizing: border-box;\n width: 200px;\n padding: 5px;\n\n font-size: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: 8px;\n outline: 0;\n box-shadow: ", ";\n\n &::-webkit-scrollbar {\n display: none;\n }\n "])), token.fontSize, token.colorBgContainer, token.colorBorder, token.boxShadowSecondary)),
|
|
10
|
+
button: cx("".concat(prefixCls, "-button"), css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n all: unset;\n\n cursor: default;\n user-select: none;\n\n padding: 12px 10px;\n\n font-size: ", "px;\n line-height: 1;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n\n -webkit-tap-highlight-color: transparent;\n\n &:hover {\n background: ", ";\n border-color: transparent;\n }\n\n &:focus-visible {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", ";\n }\n "])), token.fontSize, token.colorText, token.colorBgContainer, token.colorBorder, token.borderRadius, token.colorPrimaryBg, token.colorPrimary, token.colorPrimaryBg))
|
|
11
|
+
};
|
|
12
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface CommonType {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface GeneralItemType extends CommonType {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
danger?: boolean;
|
|
11
|
+
shortcut?: ('meta' | 'control' | 'shift' | 'alt' | string)[];
|
|
12
|
+
}
|
|
13
|
+
export interface SubMenuType extends CommonType {
|
|
14
|
+
children: MenuItemType[];
|
|
15
|
+
}
|
|
16
|
+
export interface MenuDividerType {
|
|
17
|
+
type: 'divider';
|
|
18
|
+
dashed?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare type MenuItemType = GeneralItemType | SubMenuType | MenuDividerType;
|
|
21
|
+
export {};
|
|
@@ -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
|
-
import type { DivProps } from "../types";
|
|
2
1
|
import type { NumberSize, Size } from 're-resizable';
|
|
3
|
-
import
|
|
2
|
+
import { ReactNode } 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
|
/**
|
|
@@ -81,6 +81,12 @@ export interface DraggablePanelProps extends DivProps {
|
|
|
81
81
|
* @type CSSProperties
|
|
82
82
|
*/
|
|
83
83
|
hanlderStyle?: React.CSSProperties;
|
|
84
|
+
children: ReactNode;
|
|
85
|
+
className?: string;
|
|
86
|
+
classNames?: {
|
|
87
|
+
handle?: string;
|
|
88
|
+
content?: string;
|
|
89
|
+
};
|
|
84
90
|
}
|
|
85
|
-
declare const
|
|
86
|
-
export default
|
|
91
|
+
declare const DraggablePanel: import("react").NamedExoticComponent<DraggablePanelProps>;
|
|
92
|
+
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,
|
|
@@ -39,7 +39,9 @@ var DraggablePanel = function DraggablePanel(_ref) {
|
|
|
39
39
|
className = _ref.className,
|
|
40
40
|
showHandlerWhenUnexpand = _ref.showHandlerWhenUnexpand,
|
|
41
41
|
destroyOnClose = _ref.destroyOnClose,
|
|
42
|
-
hanlderStyle = _ref.hanlderStyle
|
|
42
|
+
hanlderStyle = _ref.hanlderStyle,
|
|
43
|
+
_ref$classNames = _ref.classNames,
|
|
44
|
+
classNames = _ref$classNames === void 0 ? {} : _ref$classNames;
|
|
43
45
|
var ref = useRef(null);
|
|
44
46
|
var isHovering = useHover(ref);
|
|
45
47
|
var isVertical = placement === 'top' || placement === 'bottom';
|
|
@@ -132,13 +134,10 @@ var DraggablePanel = function DraggablePanel(_ref) {
|
|
|
132
134
|
}, [styles, placement]),
|
|
133
135
|
Arrow = _useMemo.Arrow,
|
|
134
136
|
arrowPlacement = _useMemo.className;
|
|
135
|
-
var handler =
|
|
136
|
-
/*#__PURE__*/
|
|
137
|
-
// @ts-ignore
|
|
138
|
-
_jsx(Center
|
|
137
|
+
var handler = /*#__PURE__*/_jsx(Center
|
|
139
138
|
// @ts-ignore
|
|
140
139
|
, {
|
|
141
|
-
className: cx(styles["toggle".concat(arrowPlacement)]),
|
|
140
|
+
className: cx(styles["toggle".concat(arrowPlacement)], classNames.handle),
|
|
142
141
|
style: {
|
|
143
142
|
opacity: isExpand ? !pin ? 0 : undefined : showHandlerWhenUnexpand ? 1 : 0
|
|
144
143
|
},
|
|
@@ -164,7 +163,7 @@ var DraggablePanel = function DraggablePanel(_ref) {
|
|
|
164
163
|
// @ts-ignore
|
|
165
164
|
_jsx(Resizable, _objectSpread(_objectSpread({}, sizeProps), {}, {
|
|
166
165
|
style: style,
|
|
167
|
-
className: styles.panel,
|
|
166
|
+
className: cx(styles.panel, classNames.content),
|
|
168
167
|
enable: canResizing ? resizing : undefined,
|
|
169
168
|
handleClasses: resizeHandleClassNames,
|
|
170
169
|
onResizeStop: function onResizeStop(e, direction, ref, delta) {
|
|
@@ -193,5 +192,5 @@ var DraggablePanel = function DraggablePanel(_ref) {
|
|
|
193
192
|
style: _defineProperty({}, "border".concat(arrowPlacement, "Width"), 1),
|
|
194
193
|
children: [expandable && showExpand && handler, destroyOnClose ? isExpand && inner : inner]
|
|
195
194
|
});
|
|
196
|
-
};
|
|
197
|
-
export default
|
|
195
|
+
});
|
|
196
|
+
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")),
|
|
@@ -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;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
import { rgba } from 'polished';
|
|
5
|
+
export var useStyles = createStyles(function (_ref, type) {
|
|
6
|
+
var token = _ref.token,
|
|
7
|
+
css = _ref.css,
|
|
8
|
+
cx = _ref.cx,
|
|
9
|
+
prefixCls = _ref.prefixCls;
|
|
10
|
+
var prefix = "".concat(prefixCls, "-highlighter");
|
|
11
|
+
var buttonHoverCls = "".concat(prefix, "-hover-btn");
|
|
12
|
+
var langHoverCls = "".concat(prefix, "-hover-lang");
|
|
13
|
+
return {
|
|
14
|
+
container: cx(prefix, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: auto;\n position: relative;\n transition: background-color 100ms ", ";\n background-color: ", ";\n border-radius: ", "px;\n\n ", "\n\n &:hover {\n background-color: ", ";\n }\n\n .prism-code {\n background: none !important;\n }\n\n pre {\n margin: 0 !important;\n padding: ", " !important;\n background: none !important;\n }\n\n code {\n background: transparent !important;\n }\n\n &:hover {\n .", " {\n opacity: 1;\n }\n\n .", " {\n opacity: 1;\n }\n }\n "])), token.motionEaseOut, type === 'block' ? rgba(token.colorBgElevated, 0.6) : 'transparent', token.borderRadius, type === 'ghost' && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n "])), token.colorBorder), type === 'prue' ? 'transparent' : token.colorFillTertiary, type === 'prue' ? 0 : "16px 24px", buttonHoverCls, langHoverCls)),
|
|
15
|
+
button: cx(buttonHoverCls, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 51;\n top: 8px;\n right: 8px;\n\n opacity: 0;\n "])))),
|
|
16
|
+
lang: cx(langHoverCls, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 50;\n right: 8px;\n bottom: 8px;\n\n color: ", ";\n\n opacity: 0;\n\n transition: opacity 0.1s;\n "])), token.colorTextPlaceholder))
|
|
17
|
+
};
|
|
18
|
+
});
|
package/es/Icon/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { LucideIcon } from 'lucide-react';
|
|
3
|
-
import React from 'react';
|
|
4
3
|
export declare type IconSize = 'large' | 'normal' | 'small' | {
|
|
5
4
|
fontSize?: number;
|
|
6
5
|
strokeWidth?: number;
|
|
@@ -17,5 +16,5 @@ export interface IconProps extends SvgProps {
|
|
|
17
16
|
*/
|
|
18
17
|
icon: LucideIcon;
|
|
19
18
|
}
|
|
20
|
-
declare const _default:
|
|
19
|
+
declare const _default: import("react").NamedExoticComponent<IconProps>;
|
|
21
20
|
export default _default;
|