@lobehub/ui 1.3.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/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/ContextMenu/types/menuItem.js +1 -0
- package/es/DraggablePanel/index.d.ts +7 -1
- package/es/DraggablePanel/index.js +6 -7
- package/es/DraggablePanel/utils.d.ts +1 -1
- 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/index.d.ts +3 -0
- package/es/index.js +3 -0
- 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/ContextMenu/types/menuItem.js +17 -0
- package/lib/DraggablePanel/index.d.ts +7 -1
- package/lib/DraggablePanel/index.js +17 -19
- package/lib/DraggablePanel/utils.d.ts +1 -1
- 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/index.d.ts +3 -0
- package/lib/index.js +9 -0
- package/package.json +3 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 卡片列表项的属性
|
|
4
|
+
*/
|
|
5
|
+
export interface ListItemProps {
|
|
6
|
+
/**
|
|
7
|
+
* 是否处于激活状态
|
|
8
|
+
*/
|
|
9
|
+
active: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 是否处于加载状态
|
|
12
|
+
*/
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 标题
|
|
16
|
+
*/
|
|
17
|
+
title: string;
|
|
18
|
+
/**
|
|
19
|
+
* 描述信息
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 日期时间戳
|
|
24
|
+
*/
|
|
25
|
+
date?: number;
|
|
26
|
+
/**
|
|
27
|
+
* 点击事件回调函数
|
|
28
|
+
*/
|
|
29
|
+
onClick?: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* 鼠标悬停状态变化事件回调函数
|
|
32
|
+
* @param hover - 是否悬停
|
|
33
|
+
*/
|
|
34
|
+
onHoverChange?: (hover: boolean) => void;
|
|
35
|
+
/**
|
|
36
|
+
* 渲染操作区域的 React 节点
|
|
37
|
+
*/
|
|
38
|
+
renderActions?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* 头像的 React 节点
|
|
41
|
+
*/
|
|
42
|
+
avatar?: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* 自定义样式类名
|
|
45
|
+
*/
|
|
46
|
+
className?: string;
|
|
47
|
+
/**
|
|
48
|
+
* 自定义样式对象
|
|
49
|
+
*/
|
|
50
|
+
style?: CSSProperties;
|
|
51
|
+
/**
|
|
52
|
+
* 是否显示操作区域
|
|
53
|
+
*/
|
|
54
|
+
showAction?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 自定义样式类名对象
|
|
57
|
+
* @property time - 时间的样式类名
|
|
58
|
+
*/
|
|
59
|
+
classNames?: {
|
|
60
|
+
time?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
declare const ListItem: import("react").ForwardRefExoticComponent<ListItemProps & HTMLAttributes<any> & import("react").RefAttributes<HTMLElement>>;
|
|
64
|
+
export default ListItem;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
4
|
+
var _excluded = ["active", "avatar", "loading", "description", "date", "title", "onHoverChange", "renderActions", "className", "style", "showAction", "classNames"];
|
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
import { LoadingOutlined, MessageOutlined } from '@ant-design/icons';
|
|
9
|
+
import { createStyles } from 'antd-style';
|
|
10
|
+
import { forwardRef } from 'react';
|
|
11
|
+
import { Flexbox } from 'react-layout-kit';
|
|
12
|
+
import { convertAlphaToSolid } from "../../utils/colorUtils";
|
|
13
|
+
import { getChatItemTime } from "./time";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
var useStyles = createStyles(function (_ref) {
|
|
17
|
+
var css = _ref.css,
|
|
18
|
+
cx = _ref.cx,
|
|
19
|
+
token = _ref.token;
|
|
20
|
+
var textOverlay = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --overlay-background: ", ";\n\n position: absolute;\n z-index: 10;\n top: 0;\n right: 0;\n\n width: 32px;\n height: 44px;\n\n background: linear-gradient(to right, transparent, var(--overlay-background));\n "])), token.colorBgLayout);
|
|
21
|
+
var overlayColor = convertAlphaToSolid(token.colorFillContent, token.colorBgLayout);
|
|
22
|
+
var hoverOverlay = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " {\n --overlay-background: ", ";\n }\n "])), cx(textOverlay), overlayColor);
|
|
23
|
+
return {
|
|
24
|
+
container: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n cursor: pointer;\n color: ", ";\n border-radius: 8px;\n\n &:hover {\n background: ", ";\n ", "\n }\n "])), token.colorTextTertiary, token.colorFillContent, hoverOverlay),
|
|
25
|
+
active: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: ", ";\n background: ", ";\n\n ", "\n "])), token.colorText, token.colorFillContent, hoverOverlay),
|
|
26
|
+
content: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n flex: 1;\n "]))),
|
|
27
|
+
title: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n\n width: 100%;\n\n font-size: 0.9em;\n text-overflow: ellipsis;\n white-space: nowrap;\n "]))),
|
|
28
|
+
time: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n font-size: 12px;\n color: ", ";\n "])), token.colorTextPlaceholder),
|
|
29
|
+
desc: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n overflow: hidden;\n\n width: 100%;\n margin-top: 2px;\n\n font-size: 0.75em;\n text-overflow: ellipsis;\n white-space: nowrap;\n\n opacity: 0.5;\n "]))),
|
|
30
|
+
textOverlay: textOverlay
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 卡片列表项的属性
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
var ListItem = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
39
|
+
var active = _ref2.active,
|
|
40
|
+
avatar = _ref2.avatar,
|
|
41
|
+
loading = _ref2.loading,
|
|
42
|
+
description = _ref2.description,
|
|
43
|
+
date = _ref2.date,
|
|
44
|
+
title = _ref2.title,
|
|
45
|
+
onHoverChange = _ref2.onHoverChange,
|
|
46
|
+
renderActions = _ref2.renderActions,
|
|
47
|
+
className = _ref2.className,
|
|
48
|
+
style = _ref2.style,
|
|
49
|
+
showAction = _ref2.showAction,
|
|
50
|
+
_ref2$classNames = _ref2.classNames,
|
|
51
|
+
classNames = _ref2$classNames === void 0 ? {} : _ref2$classNames,
|
|
52
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
53
|
+
var _useStyles = useStyles(),
|
|
54
|
+
styles = _useStyles.styles,
|
|
55
|
+
cx = _useStyles.cx;
|
|
56
|
+
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
57
|
+
ref: ref,
|
|
58
|
+
horizontal: true,
|
|
59
|
+
paddingBlock: 8,
|
|
60
|
+
gap: 8,
|
|
61
|
+
paddingInline: '12px 8px',
|
|
62
|
+
align: 'flex-start',
|
|
63
|
+
distribution: 'space-between',
|
|
64
|
+
className: cx(styles.container, active && styles.active, className),
|
|
65
|
+
style: style
|
|
66
|
+
}, props), {}, {
|
|
67
|
+
onMouseEnter: function onMouseEnter() {
|
|
68
|
+
onHoverChange === null || onHoverChange === void 0 ? void 0 : onHoverChange(true);
|
|
69
|
+
},
|
|
70
|
+
onMouseLeave: function onMouseLeave() {
|
|
71
|
+
onHoverChange === null || onHoverChange === void 0 ? void 0 : onHoverChange(false);
|
|
72
|
+
},
|
|
73
|
+
children: [avatar !== null && avatar !== void 0 ? avatar : /*#__PURE__*/_jsx(MessageOutlined, {
|
|
74
|
+
style: {
|
|
75
|
+
marginTop: 4
|
|
76
|
+
}
|
|
77
|
+
}), /*#__PURE__*/_jsxs(Flexbox, {
|
|
78
|
+
className: styles.content,
|
|
79
|
+
children: [/*#__PURE__*/_jsx(Flexbox, {
|
|
80
|
+
horizontal: true,
|
|
81
|
+
distribution: 'space-between',
|
|
82
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
83
|
+
className: styles.title,
|
|
84
|
+
children: title
|
|
85
|
+
})
|
|
86
|
+
}), description && /*#__PURE__*/_jsx("div", {
|
|
87
|
+
className: styles.desc,
|
|
88
|
+
children: description
|
|
89
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
90
|
+
className: styles.textOverlay
|
|
91
|
+
})]
|
|
92
|
+
}), loading ? /*#__PURE__*/_jsx(LoadingOutlined, {
|
|
93
|
+
spin: true
|
|
94
|
+
}) : showAction ? /*#__PURE__*/_jsx(Flexbox, {
|
|
95
|
+
horizontal: true,
|
|
96
|
+
gap: 4,
|
|
97
|
+
style: {
|
|
98
|
+
display: showAction ? undefined : 'none'
|
|
99
|
+
},
|
|
100
|
+
onClick: function onClick(e) {
|
|
101
|
+
e.stopPropagation();
|
|
102
|
+
},
|
|
103
|
+
children: renderActions
|
|
104
|
+
}) : date && /*#__PURE__*/_jsx("div", {
|
|
105
|
+
className: cx(styles.time, classNames.time),
|
|
106
|
+
children: getChatItemTime(date)
|
|
107
|
+
})]
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
110
|
+
export default ListItem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import 'dayjs/locale/zh-cn';
|
|
3
|
+
dayjs.locale('zh-cn');
|
|
4
|
+
export var getChatItemTime = function getChatItemTime(updateAt) {
|
|
5
|
+
var time = dayjs(updateAt);
|
|
6
|
+
var diff = dayjs().day() - time.day();
|
|
7
|
+
if (time.isSame(dayjs(), 'day')) return time.format('HH:mm');
|
|
8
|
+
if (diff === 1) return '昨天';
|
|
9
|
+
return time.format('MM-DD');
|
|
10
|
+
};
|
package/es/List/index.js
ADDED
package/es/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { default as ActionIcon, type ActionIconProps, type ActionIconSize } from './ActionIcon';
|
|
2
|
+
export { default as Avatar, type AvatarProps } from './Avatar';
|
|
3
|
+
export { default as ContextMenu, type ContextMenuProps } from './ContextMenu';
|
|
2
4
|
export { default as CopyButton, type CopyButtonProps } from './CopyButton';
|
|
3
5
|
export { default as DraggablePanel, type DraggablePanelProps } from './DraggablePanel';
|
|
4
6
|
export { default as EditableText, type EditableTextProps } from './EditableText';
|
|
5
7
|
export { default as Highlighter, SyntaxHighlighter, type HighlighterProps, type SyntaxHighlighterProps, } from './Highlighter';
|
|
6
8
|
export { default as Icon, type IconProps, type IconSize } from './Icon';
|
|
9
|
+
export { default as List } from './List';
|
|
7
10
|
export { default as Logo, type LogoProps } from './Logo';
|
|
8
11
|
export { default as Markdown, type MarkdownProps } from './Markdown';
|
|
9
12
|
export { default as MessageInput, type MessageInputProps } from './MessageInput';
|
package/es/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { default as ActionIcon } from "./ActionIcon";
|
|
2
|
+
export { default as Avatar } from "./Avatar";
|
|
3
|
+
export { default as ContextMenu } from "./ContextMenu";
|
|
2
4
|
export { default as CopyButton } from "./CopyButton";
|
|
3
5
|
export { default as DraggablePanel } from "./DraggablePanel";
|
|
4
6
|
export { default as EditableText } from "./EditableText";
|
|
5
7
|
export { default as Highlighter, SyntaxHighlighter } from "./Highlighter";
|
|
6
8
|
export { default as Icon } from "./Icon";
|
|
9
|
+
export { default as List } from "./List";
|
|
7
10
|
export { default as Logo } from "./Logo";
|
|
8
11
|
export { default as Markdown } from "./Markdown";
|
|
9
12
|
export { default as MessageInput } from "./MessageInput";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/Avatar/index.tsx
|
|
20
|
+
var Avatar_exports = {};
|
|
21
|
+
__export(Avatar_exports, {
|
|
22
|
+
default: () => Avatar_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Avatar_exports);
|
|
25
|
+
var import_antd = require("antd");
|
|
26
|
+
var import_antd_style = require("antd-style");
|
|
27
|
+
var import_react_layout_kit = require("react-layout-kit");
|
|
28
|
+
var useStyles = (0, import_antd_style.createStyles)(({ css, token }) => ({
|
|
29
|
+
container: css`
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
|
|
32
|
+
> * {
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
border: css`
|
|
37
|
+
border: 1px solid ${token.colorBorder};
|
|
38
|
+
`
|
|
39
|
+
}));
|
|
40
|
+
var Avatar = ({ avatar, title, size = 40, shape = "circle", background }) => {
|
|
41
|
+
const { styles, theme } = useStyles();
|
|
42
|
+
const backgroundColor = background ?? theme.colorBgContainer;
|
|
43
|
+
const isImage = avatar && ["/", "http", "data:"].some((i) => avatar.startsWith(i));
|
|
44
|
+
return /* @__PURE__ */ React.createElement(
|
|
45
|
+
import_react_layout_kit.Center,
|
|
46
|
+
{
|
|
47
|
+
style: {
|
|
48
|
+
width: size,
|
|
49
|
+
height: size,
|
|
50
|
+
borderRadius: shape === "circle" ? "50%" : 6,
|
|
51
|
+
backgroundColor,
|
|
52
|
+
borderWidth: isImage ? 1 : 0
|
|
53
|
+
},
|
|
54
|
+
className: styles.container
|
|
55
|
+
},
|
|
56
|
+
!avatar ? /* @__PURE__ */ React.createElement(import_antd.Avatar, { shape, size }, title == null ? void 0 : title.slice(0, 2)) : isImage ? /* @__PURE__ */ React.createElement(import_antd.Avatar, { shape, size, src: avatar, className: styles.border }) : /* @__PURE__ */ React.createElement(
|
|
57
|
+
import_react_layout_kit.Center,
|
|
58
|
+
{
|
|
59
|
+
className: styles.border,
|
|
60
|
+
style: {
|
|
61
|
+
width: size,
|
|
62
|
+
height: size,
|
|
63
|
+
fontSize: size / 2,
|
|
64
|
+
borderRadius: shape === "circle" ? "50%" : 6,
|
|
65
|
+
backgroundColor
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
avatar
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
var Avatar_default = Avatar;
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const CommandIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const ControlIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const ShiftIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const AltIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/ContextMenu/MenuItem/icons.tsx
|
|
20
|
+
var icons_exports = {};
|
|
21
|
+
__export(icons_exports, {
|
|
22
|
+
AltIcon: () => AltIcon,
|
|
23
|
+
CommandIcon: () => CommandIcon,
|
|
24
|
+
ControlIcon: () => ControlIcon,
|
|
25
|
+
ShiftIcon: () => ShiftIcon
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(icons_exports);
|
|
28
|
+
var strokeWidth = 2.2;
|
|
29
|
+
var iconSize = "13px";
|
|
30
|
+
var CommandIcon = () => /* @__PURE__ */ React.createElement(
|
|
31
|
+
"svg",
|
|
32
|
+
{
|
|
33
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
34
|
+
width: iconSize,
|
|
35
|
+
height: iconSize,
|
|
36
|
+
viewBox: "0 0 24 24",
|
|
37
|
+
fill: "none",
|
|
38
|
+
stroke: "currentColor",
|
|
39
|
+
strokeWidth,
|
|
40
|
+
strokeLinecap: "round",
|
|
41
|
+
strokeLinejoin: "round"
|
|
42
|
+
},
|
|
43
|
+
/* @__PURE__ */ React.createElement("path", { d: "M18 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3V6a3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3h12a3 3 0 0 0 3-3 3 3 0 0 0-3-3z" })
|
|
44
|
+
);
|
|
45
|
+
var ControlIcon = () => /* @__PURE__ */ React.createElement(
|
|
46
|
+
"svg",
|
|
47
|
+
{
|
|
48
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
49
|
+
width: iconSize,
|
|
50
|
+
height: iconSize,
|
|
51
|
+
viewBox: "0 0 24 24",
|
|
52
|
+
fill: "none",
|
|
53
|
+
stroke: "currentColor",
|
|
54
|
+
strokeWidth,
|
|
55
|
+
strokeLinecap: "round",
|
|
56
|
+
strokeLinejoin: "round",
|
|
57
|
+
className: "lucide lucide-chevron-up"
|
|
58
|
+
},
|
|
59
|
+
/* @__PURE__ */ React.createElement("polyline", { points: "18 15 12 9 6 15" })
|
|
60
|
+
);
|
|
61
|
+
var ShiftIcon = () => /* @__PURE__ */ React.createElement(
|
|
62
|
+
"svg",
|
|
63
|
+
{
|
|
64
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
65
|
+
width: iconSize,
|
|
66
|
+
height: iconSize,
|
|
67
|
+
viewBox: "0 0 24 24",
|
|
68
|
+
fill: "none",
|
|
69
|
+
stroke: "currentColor",
|
|
70
|
+
strokeWidth,
|
|
71
|
+
strokeLinecap: "round",
|
|
72
|
+
strokeLinejoin: "round",
|
|
73
|
+
className: "lucide lucide-chevron-up"
|
|
74
|
+
},
|
|
75
|
+
/* @__PURE__ */ React.createElement("path", { d: "M9 18v-6H5l7-7 7 7h-4v6H9z" })
|
|
76
|
+
);
|
|
77
|
+
var AltIcon = () => /* @__PURE__ */ React.createElement(
|
|
78
|
+
"svg",
|
|
79
|
+
{
|
|
80
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
81
|
+
width: iconSize,
|
|
82
|
+
height: iconSize,
|
|
83
|
+
viewBox: "0 0 24 24",
|
|
84
|
+
fill: "none",
|
|
85
|
+
stroke: "currentColor",
|
|
86
|
+
strokeWidth,
|
|
87
|
+
strokeLinecap: "round",
|
|
88
|
+
strokeLinejoin: "round",
|
|
89
|
+
className: "lucide lucide-chevron-up"
|
|
90
|
+
},
|
|
91
|
+
/* @__PURE__ */ React.createElement("path", { d: "M3 3h6l6 18h6" }),
|
|
92
|
+
/* @__PURE__ */ React.createElement("path", { d: "M14 3h7" })
|
|
93
|
+
);
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
AltIcon,
|
|
97
|
+
CommandIcon,
|
|
98
|
+
ControlIcon,
|
|
99
|
+
ShiftIcon
|
|
100
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface MenuItemProps {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
active?: boolean;
|
|
6
|
+
selected?: boolean;
|
|
7
|
+
nested?: boolean;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
shortcut?: string[];
|
|
10
|
+
}
|
|
11
|
+
declare const MenuItem: import("react").ForwardRefExoticComponent<MenuItemProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
export default MenuItem;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/ContextMenu/MenuItem/index.tsx
|
|
20
|
+
var MenuItem_exports = {};
|
|
21
|
+
__export(MenuItem_exports, {
|
|
22
|
+
default: () => MenuItem_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(MenuItem_exports);
|
|
25
|
+
var import_lucide_react = require("lucide-react");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_react_layout_kit = require("react-layout-kit");
|
|
28
|
+
var import_icons = require("./icons");
|
|
29
|
+
var import_style = require("./style");
|
|
30
|
+
var KEYBOARD_ICON_MAP = {
|
|
31
|
+
meta: /* @__PURE__ */ React.createElement(import_icons.CommandIcon, null),
|
|
32
|
+
control: /* @__PURE__ */ React.createElement(import_icons.ControlIcon, null),
|
|
33
|
+
shift: /* @__PURE__ */ React.createElement(import_icons.ShiftIcon, null),
|
|
34
|
+
alt: /* @__PURE__ */ React.createElement(import_icons.AltIcon, null),
|
|
35
|
+
enter: "↵"
|
|
36
|
+
};
|
|
37
|
+
var CODE_MAP = {
|
|
38
|
+
meta: "meta",
|
|
39
|
+
command: "meta",
|
|
40
|
+
cmd: "meta",
|
|
41
|
+
ctl: "control",
|
|
42
|
+
control: "control",
|
|
43
|
+
shift: "shift",
|
|
44
|
+
alt: "alt"
|
|
45
|
+
};
|
|
46
|
+
var MenuItem = (0, import_react.forwardRef)(
|
|
47
|
+
({ label, icon, disabled, nested, shortcut, active, selected, ...props }, ref) => {
|
|
48
|
+
const { styles, cx } = (0, import_style.useStyles)();
|
|
49
|
+
return /* @__PURE__ */ React.createElement(
|
|
50
|
+
"button",
|
|
51
|
+
{
|
|
52
|
+
type: "button",
|
|
53
|
+
...props,
|
|
54
|
+
ref,
|
|
55
|
+
role: "menuitem",
|
|
56
|
+
disabled,
|
|
57
|
+
className: cx(styles.item, {
|
|
58
|
+
[styles.selected]: selected,
|
|
59
|
+
[styles.active]: active
|
|
60
|
+
})
|
|
61
|
+
},
|
|
62
|
+
/* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { horizontal: true, gap: 8 }, icon && /* @__PURE__ */ React.createElement("span", null, icon), label),
|
|
63
|
+
nested ? /* @__PURE__ */ React.createElement("span", { "aria-hidden": true }, /* @__PURE__ */ React.createElement(import_lucide_react.ChevronRightIcon, { className: styles.arrow })) : shortcut ? /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { horizontal: true, align: "center" }, shortcut.map((c) => {
|
|
64
|
+
const code = CODE_MAP[c.toLowerCase()];
|
|
65
|
+
return /* @__PURE__ */ React.createElement("kbd", { className: styles.kbd, key: c }, code ? KEYBOARD_ICON_MAP[code] : c.toUpperCase());
|
|
66
|
+
})) : null
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
var MenuItem_default = MenuItem;
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/ContextMenu/MenuItem/style.ts
|
|
20
|
+
var style_exports = {};
|
|
21
|
+
__export(style_exports, {
|
|
22
|
+
useStyles: () => useStyles
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(style_exports);
|
|
25
|
+
var import_antd_style = require("antd-style");
|
|
26
|
+
var useStyles = (0, import_antd_style.createStyles)(({ css, cx, token }, prefixCls) => {
|
|
27
|
+
const selected = css`
|
|
28
|
+
font-weight: bold;
|
|
29
|
+
color: ${token.colorPrimaryText};
|
|
30
|
+
background: ${token.colorPrimaryBg};
|
|
31
|
+
&:hover {
|
|
32
|
+
color: ${token.colorPrimaryTextHover};
|
|
33
|
+
background: ${token.colorPrimaryBgHover};
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
return {
|
|
37
|
+
item: cx(
|
|
38
|
+
`${prefixCls}-item`,
|
|
39
|
+
css`
|
|
40
|
+
all: unset;
|
|
41
|
+
|
|
42
|
+
user-select: none;
|
|
43
|
+
scroll-margin: 50px;
|
|
44
|
+
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: space-between;
|
|
48
|
+
|
|
49
|
+
box-sizing: inherit;
|
|
50
|
+
width: 100%;
|
|
51
|
+
padding: 12px 10px;
|
|
52
|
+
|
|
53
|
+
font-family: ${token.fontFamily};
|
|
54
|
+
font-weight: normal;
|
|
55
|
+
line-height: 1;
|
|
56
|
+
color: ${token.colorText};
|
|
57
|
+
|
|
58
|
+
background: transparent;
|
|
59
|
+
border-radius: 5px;
|
|
60
|
+
&:hover {
|
|
61
|
+
background: ${token.colorFillTertiary};
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
),
|
|
65
|
+
selected: cx(`${prefixCls}-item-selected`, selected),
|
|
66
|
+
active: cx(
|
|
67
|
+
`${prefixCls}-item-active`,
|
|
68
|
+
css`
|
|
69
|
+
background: ${token.colorFillTertiary};
|
|
70
|
+
`
|
|
71
|
+
),
|
|
72
|
+
arrow: css`
|
|
73
|
+
color: ${token.colorTextTertiary};
|
|
74
|
+
`,
|
|
75
|
+
kbd: css`
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
|
|
80
|
+
width: 18px;
|
|
81
|
+
height: 20px;
|
|
82
|
+
|
|
83
|
+
font-family: ${token.fontFamily};
|
|
84
|
+
font-size: 14px;
|
|
85
|
+
color: ${token.colorTextQuaternary};
|
|
86
|
+
|
|
87
|
+
border-radius: 2px;
|
|
88
|
+
`
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
useStyles
|
|
94
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTMLProps } from 'react';
|
|
2
|
+
import { MenuItemType } from './types';
|
|
3
|
+
export interface ContextMenuProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
items: MenuItemType[];
|
|
6
|
+
container?: HTMLElement;
|
|
7
|
+
}
|
|
8
|
+
declare const ContextMenu: import("react").ForwardRefExoticComponent<Omit<ContextMenuProps & HTMLProps<HTMLButtonElement>, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
export default ContextMenu;
|