@lobehub/ui 1.168.20 → 1.169.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.
@@ -0,0 +1,20 @@
1
+ import { type DrawerProps as AntdDrawerProps } from 'antd';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+ export interface DrawProps extends Omit<AntdDrawerProps, 'styles' | 'classNames'> {
4
+ classNames?: AntdDrawerProps['classNames'] & {
5
+ bodyContent?: string;
6
+ extra?: string;
7
+ title?: string;
8
+ };
9
+ containerMaxWidth?: number;
10
+ noHeader?: boolean;
11
+ sidebar?: ReactNode;
12
+ sidebarWidth?: number;
13
+ styles?: AntdDrawerProps['styles'] & {
14
+ bodyContent?: CSSProperties;
15
+ extra?: CSSProperties;
16
+ title?: CSSProperties;
17
+ };
18
+ }
19
+ declare const Draw: import("react").NamedExoticComponent<DrawProps>;
20
+ export default Draw;
@@ -0,0 +1,166 @@
1
+ 'use client';
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ var _excluded = ["onClose", "containerMaxWidth", "classNames", "title", "placement", "styles", "children", "height", "width", "extra", "noHeader", "sidebarWidth", "sidebar"];
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
+ import { Drawer as AntdDraw } from 'antd';
13
+ import { useTheme } from 'antd-style';
14
+ import { XIcon } from 'lucide-react';
15
+ import { memo, useMemo } from 'react';
16
+ import { Flexbox } from 'react-layout-kit';
17
+ import ActionIcon from "../ActionIcon";
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ import { Fragment as _Fragment } from "react/jsx-runtime";
21
+ var Draw = /*#__PURE__*/memo(function (_ref) {
22
+ var onClose = _ref.onClose,
23
+ _ref$containerMaxWidt = _ref.containerMaxWidth,
24
+ containerMaxWidth = _ref$containerMaxWidt === void 0 ? 1024 : _ref$containerMaxWidt,
25
+ classNames = _ref.classNames,
26
+ title = _ref.title,
27
+ placement = _ref.placement,
28
+ styles = _ref.styles,
29
+ children = _ref.children,
30
+ height = _ref.height,
31
+ width = _ref.width,
32
+ extra = _ref.extra,
33
+ noHeader = _ref.noHeader,
34
+ _ref$sidebarWidth = _ref.sidebarWidth,
35
+ sidebarWidth = _ref$sidebarWidth === void 0 ? 280 : _ref$sidebarWidth,
36
+ sidebar = _ref.sidebar,
37
+ rest = _objectWithoutProperties(_ref, _excluded);
38
+ var theme = useTheme();
39
+ var headerBorder = useMemo(function () {
40
+ if (height === '100%' || width === '100%' || height === '100vh' || width === '100vw') return {};
41
+ switch (placement) {
42
+ case 'top':
43
+ {
44
+ return {
45
+ borderBottom: "1px solid ".concat(theme.colorBorder)
46
+ };
47
+ }
48
+ case 'bottom':
49
+ {
50
+ return {
51
+ borderTop: "1px solid ".concat(theme.colorBorder)
52
+ };
53
+ }
54
+ case 'left':
55
+ {
56
+ return {
57
+ borderRight: "1px solid ".concat(theme.colorBorder)
58
+ };
59
+ }
60
+ case 'right':
61
+ {
62
+ return {
63
+ borderLeft: "1px solid ".concat(theme.colorBorder)
64
+ };
65
+ }
66
+ default:
67
+ {
68
+ return {};
69
+ }
70
+ }
71
+ }, [placement, height, width, theme.colorBorder]);
72
+ var extraNode = /*#__PURE__*/_jsxs(Flexbox, {
73
+ align: 'center',
74
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.extra,
75
+ gap: 4,
76
+ horizontal: true,
77
+ justify: 'flex-end',
78
+ style: _objectSpread({
79
+ position: 'absolute',
80
+ right: 4,
81
+ top: 4
82
+ }, styles === null || styles === void 0 ? void 0 : styles.extra),
83
+ children: [extra, /*#__PURE__*/_jsx(ActionIcon, {
84
+ icon: XIcon,
85
+ onClick: onClose,
86
+ size: 'site'
87
+ })]
88
+ });
89
+ return /*#__PURE__*/_jsx(AntdDraw, _objectSpread(_objectSpread({
90
+ classNames: classNames,
91
+ closable: false,
92
+ extra: noHeader ? undefined : extraNode,
93
+ height: height,
94
+ keyboard: true,
95
+ onClose: onClose,
96
+ placement: placement,
97
+ styles: _objectSpread(_objectSpread({}, styles), {}, {
98
+ body: _objectSpread({
99
+ background: 'transparent',
100
+ padding: '0 4px'
101
+ }, styles === null || styles === void 0 ? void 0 : styles.body),
102
+ content: _objectSpread({
103
+ background: sidebar ? "linear-gradient(to right, ".concat(theme.colorBgContainer, " 49.9%, ").concat(theme.colorBgLayout, " 50%)") : theme.colorBgContainer
104
+ }, styles === null || styles === void 0 ? void 0 : styles.content),
105
+ header: _objectSpread({
106
+ background: 'transparent',
107
+ display: noHeader ? 'none' : undefined,
108
+ padding: 4
109
+ }, styles === null || styles === void 0 ? void 0 : styles.header),
110
+ wrapper: _objectSpread(_objectSpread({
111
+ background: theme.colorBgContainer
112
+ }, headerBorder), styles === null || styles === void 0 ? void 0 : styles.wrapper)
113
+ }),
114
+ title: /*#__PURE__*/_jsx(Flexbox, {
115
+ align: 'center',
116
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.title,
117
+ horizontal: true,
118
+ justify: 'flex-start',
119
+ paddingBlock: 8,
120
+ paddingInline: 16,
121
+ style: _objectSpread({
122
+ justifySelf: 'center',
123
+ maxWidth: containerMaxWidth,
124
+ width: '100%'
125
+ }, styles === null || styles === void 0 ? void 0 : styles.title),
126
+ children: title
127
+ }),
128
+ width: width
129
+ }, rest), {}, {
130
+ children: /*#__PURE__*/_jsxs(Flexbox, {
131
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.bodyContent,
132
+ height: '100%',
133
+ horizontal: !!sidebar,
134
+ paddingBlock: sidebar ? undefined : 12,
135
+ paddingInline: sidebar ? undefined : 16,
136
+ style: _objectSpread({
137
+ justifySelf: 'center',
138
+ maxWidth: containerMaxWidth,
139
+ width: '100%'
140
+ }, styles === null || styles === void 0 ? void 0 : styles.bodyContent),
141
+ children: [noHeader && extraNode, sidebar ? /*#__PURE__*/_jsxs(_Fragment, {
142
+ children: [/*#__PURE__*/_jsx(Flexbox, {
143
+ paddingBlock: 12,
144
+ paddingInline: 16,
145
+ style: {
146
+ background: theme.colorBgContainer,
147
+ borderRight: "1px solid ".concat(theme.colorBorderSecondary),
148
+ height: '100%'
149
+ },
150
+ width: sidebarWidth,
151
+ children: sidebar
152
+ }), /*#__PURE__*/_jsx(Flexbox, {
153
+ flex: 1,
154
+ paddingBlock: 12,
155
+ paddingInline: 16,
156
+ style: {
157
+ background: theme.colorBgLayout,
158
+ height: '100%'
159
+ },
160
+ children: children
161
+ })]
162
+ }) : children]
163
+ })
164
+ }));
165
+ });
166
+ export default Draw;
@@ -127,7 +127,7 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
127
127
  return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
128
128
  align: 'center',
129
129
  className: cx(s, className),
130
- gap: 2,
130
+ gap: isPure ? 6 : 2,
131
131
  horizontal: true,
132
132
  style: _objectSpread({
133
133
  visibility: visibility
@@ -13,6 +13,7 @@ export { default as DraggablePanelBody, type DraggablePanelBodyProps, } from './
13
13
  export { default as DraggablePanelContainer, type DraggablePanelContainerProps, } from './DraggablePanel/components/DraggablePanelContainer';
14
14
  export { default as DraggablePanelFooter, type DraggablePanelFooterProps, } from './DraggablePanel/components/DraggablePanelFooter';
15
15
  export { default as DraggablePanelHeader, type DraggablePanelHeaderProps, } from './DraggablePanel/components/DraggablePanelHeader';
16
+ export { default as Draw, type DrawProps } from './Draw';
16
17
  export { default as EditableText, type EditableTextProps } from './EditableText';
17
18
  export { default as EmojiPicker, type EmojiPickerProps } from './EmojiPicker';
18
19
  export { default as EmptyCard, type EmptyCardProps } from './EmptyCard';
package/es/components.js CHANGED
@@ -13,6 +13,7 @@ export { default as DraggablePanelBody } from "./DraggablePanel/components/Dragg
13
13
  export { default as DraggablePanelContainer } from "./DraggablePanel/components/DraggablePanelContainer";
14
14
  export { default as DraggablePanelFooter } from "./DraggablePanel/components/DraggablePanelFooter";
15
15
  export { default as DraggablePanelHeader } from "./DraggablePanel/components/DraggablePanelHeader";
16
+ export { default as Draw } from "./Draw";
16
17
  export { default as EditableText } from "./EditableText";
17
18
  export { default as EmojiPicker } from "./EmojiPicker";
18
19
  export { default as EmptyCard } from "./EmptyCard";
@@ -35,13 +35,12 @@ export var useMermaid = function useMermaid(id, content) {
35
35
  _useState2 = _slicedToArray(_useState, 2),
36
36
  validContent = _useState2[0],
37
37
  setValidContent = _useState2[1];
38
- console.log(id, content);
39
38
 
40
39
  // 为长内容生成哈希键
41
40
  var cacheKey = useMemo(function () {
42
41
  var hash = content.length < MD5_LENGTH_THRESHOLD ? content : Md5.hashStr(content);
43
- return "mermaid-".concat(hash);
44
- }, [content]);
42
+ return "mermaid-".concat(id, "-").concat(hash);
43
+ }, [content, id]);
45
44
  return useSWR(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
46
45
  var mermaidInstance, isValid, _yield$mermaidInstanc, svg;
47
46
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -69,7 +68,7 @@ export var useMermaid = function useMermaid(id, content) {
69
68
  case 10:
70
69
  isValid = _context.sent;
71
70
  if (!isValid) {
72
- _context.next = 22;
71
+ _context.next = 21;
73
72
  break;
74
73
  }
75
74
  _context.next = 14;
@@ -77,27 +76,26 @@ export var useMermaid = function useMermaid(id, content) {
77
76
  case 14:
78
77
  _yield$mermaidInstanc = _context.sent;
79
78
  svg = _yield$mermaidInstanc.svg;
80
- console.log(svg);
81
79
  setValidContent(svg);
82
80
  // 缓存验证结果
83
81
  mermaidCache.set(cacheKey, true);
84
82
  return _context.abrupt("return", svg);
85
- case 22:
83
+ case 21:
86
84
  throw new Error('Mermaid 语法无效');
87
- case 23:
88
- _context.next = 29;
85
+ case 22:
86
+ _context.next = 28;
89
87
  break;
90
- case 25:
91
- _context.prev = 25;
88
+ case 24:
89
+ _context.prev = 24;
92
90
  _context.t0 = _context["catch"](2);
93
91
  console.error('Mermaid 解析错误:', _context.t0);
94
92
  // 返回最近一次有效的内容,或空字符串
95
93
  return _context.abrupt("return", validContent || '');
96
- case 29:
94
+ case 28:
97
95
  case "end":
98
96
  return _context.stop();
99
97
  }
100
- }, _callee, null, [[2, 25]]);
98
+ }, _callee, null, [[2, 24]]);
101
99
  })), {
102
100
  dedupingInterval: 3000,
103
101
  errorRetryCount: 2,
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { DivProps } from "../../types";
3
- export interface StoryBookProps extends DivProps {
2
+ import { FlexboxProps } from 'react-layout-kit';
3
+ export interface StoryBookProps extends FlexboxProps {
4
4
  /**
5
5
  * @description The Leva store instance to be used by the component
6
6
  * @type levaStore
@@ -11,6 +11,6 @@ export interface StoryBookProps extends DivProps {
11
11
  */
12
12
  noPadding?: boolean;
13
13
  }
14
- export declare const StoryBook: import("react").NamedExoticComponent<StoryBookProps>;
14
+ export declare const StoryBook: import("react").ForwardRefExoticComponent<StoryBookProps & import("react").RefAttributes<HTMLDivElement>>;
15
15
  export default StoryBook;
16
16
  export { useControls, useCreateStore } from 'leva';
@@ -11,13 +11,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
11
11
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
12
  import { useResponsive } from 'antd-style';
13
13
  import { LevaPanel } from 'leva';
14
- import { memo } from 'react';
14
+ import { forwardRef } from 'react';
15
15
  import { Flexbox } from 'react-layout-kit';
16
16
  import DraggablePanel from "../../DraggablePanel";
17
17
  import { useStyles } from "./style";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
20
- export var StoryBook = /*#__PURE__*/memo(function (_ref) {
20
+ export var StoryBook = /*#__PURE__*/forwardRef(function (_ref, ref) {
21
21
  var levaStore = _ref.levaStore,
22
22
  noPadding = _ref.noPadding,
23
23
  className = _ref.className,
@@ -32,7 +32,8 @@ export var StoryBook = /*#__PURE__*/memo(function (_ref) {
32
32
  align: 'stretch',
33
33
  className: cx(styles.editor, className),
34
34
  horizontal: !mobile,
35
- justify: 'stretch'
35
+ justify: 'stretch',
36
+ ref: ref
36
37
  }, rest), {}, {
37
38
  children: [/*#__PURE__*/_jsx(Flexbox, {
38
39
  align: 'center',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.168.20",
3
+ "version": "1.169.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",