@lobehub/ui 1.166.0 → 1.166.1

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,3 @@
1
+ /// <reference types="react" />
2
+ declare const Controls: import("react").MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
3
+ export default Controls;
@@ -0,0 +1,49 @@
1
+ import { AlignVerticalSpaceAroundIcon, MinusIcon, PlusIcon } from 'lucide-react';
2
+ import { memo } from 'react';
3
+ import { Flexbox } from 'react-layout-kit';
4
+ import { useControls } from 'react-zoom-pan-pinch';
5
+ import ActionIcon from "../ActionIcon";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ var Controls = /*#__PURE__*/memo(function () {
9
+ var _useControls = useControls(),
10
+ zoomIn = _useControls.zoomIn,
11
+ zoomOut = _useControls.zoomOut,
12
+ resetTransform = _useControls.resetTransform;
13
+ return /*#__PURE__*/_jsxs(Flexbox, {
14
+ gap: 4,
15
+ horizontal: true,
16
+ style: {
17
+ bottom: 8,
18
+ position: 'absolute',
19
+ right: 8,
20
+ zIndex: 1
21
+ },
22
+ children: [/*#__PURE__*/_jsx(ActionIcon, {
23
+ active: true,
24
+ glass: true,
25
+ icon: PlusIcon,
26
+ onClick: function onClick() {
27
+ return zoomIn();
28
+ },
29
+ size: 'small'
30
+ }), /*#__PURE__*/_jsx(ActionIcon, {
31
+ active: true,
32
+ glass: true,
33
+ icon: MinusIcon,
34
+ onClick: function onClick() {
35
+ return zoomOut();
36
+ },
37
+ size: 'small'
38
+ }), /*#__PURE__*/_jsx(ActionIcon, {
39
+ active: true,
40
+ glass: true,
41
+ icon: AlignVerticalSpaceAroundIcon,
42
+ onClick: function onClick() {
43
+ return resetTransform();
44
+ },
45
+ size: 'small'
46
+ })]
47
+ });
48
+ });
49
+ export default Controls;
@@ -1,5 +1,5 @@
1
1
  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); }
2
- var _excluded = ["showLanguage", "content", "children", "className", "copyable", "actionsRender", "style", "enablePanZoom", "fileName"];
2
+ var _excluded = ["showLanguage", "content", "children", "className", "copyable", "actionsRender", "style", "fileName"];
3
3
  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; }
4
4
  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; }
5
5
  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; }
@@ -13,56 +13,14 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
13
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
14
  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; }
15
15
  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; }
16
- import { AlignVerticalSpaceAroundIcon, ChevronDown, ChevronRight, MinusIcon, PlusIcon } from 'lucide-react';
16
+ import { ChevronDown, ChevronRight } from 'lucide-react';
17
17
  import { memo, useState } from 'react';
18
18
  import { Flexbox } from 'react-layout-kit';
19
- import { TransformComponent, TransformWrapper, useControls } from 'react-zoom-pan-pinch';
20
19
  import ActionIcon from "../ActionIcon";
21
20
  import CopyButton from "../CopyButton";
22
21
  import { useStyles } from "./style";
23
22
  import { jsx as _jsx } from "react/jsx-runtime";
24
23
  import { jsxs as _jsxs } from "react/jsx-runtime";
25
- var Controls = function Controls() {
26
- var _useControls = useControls(),
27
- zoomIn = _useControls.zoomIn,
28
- zoomOut = _useControls.zoomOut,
29
- resetTransform = _useControls.resetTransform;
30
- return /*#__PURE__*/_jsxs(Flexbox, {
31
- gap: 4,
32
- horizontal: true,
33
- style: {
34
- bottom: 8,
35
- position: 'absolute',
36
- right: 8,
37
- zIndex: 1
38
- },
39
- children: [/*#__PURE__*/_jsx(ActionIcon, {
40
- active: true,
41
- glass: true,
42
- icon: PlusIcon,
43
- onClick: function onClick() {
44
- return zoomIn();
45
- },
46
- size: 'small'
47
- }), /*#__PURE__*/_jsx(ActionIcon, {
48
- active: true,
49
- glass: true,
50
- icon: MinusIcon,
51
- onClick: function onClick() {
52
- return zoomOut();
53
- },
54
- size: 'small'
55
- }), /*#__PURE__*/_jsx(ActionIcon, {
56
- active: true,
57
- glass: true,
58
- icon: AlignVerticalSpaceAroundIcon,
59
- onClick: function onClick() {
60
- return resetTransform();
61
- },
62
- size: 'small'
63
- })]
64
- });
65
- };
66
24
  export var MermaidFullFeatured = /*#__PURE__*/memo(function (_ref) {
67
25
  var showLanguage = _ref.showLanguage,
68
26
  content = _ref.content,
@@ -71,8 +29,6 @@ export var MermaidFullFeatured = /*#__PURE__*/memo(function (_ref) {
71
29
  copyable = _ref.copyable,
72
30
  actionsRender = _ref.actionsRender,
73
31
  style = _ref.style,
74
- _ref$enablePanZoom = _ref.enablePanZoom,
75
- enablePanZoom = _ref$enablePanZoom === void 0 ? true : _ref$enablePanZoom,
76
32
  _ref$fileName = _ref.fileName,
77
33
  fileName = _ref$fileName === void 0 ? 'Mermaid' : _ref$fileName,
78
34
  rest = _objectWithoutProperties(_ref, _excluded);
@@ -138,13 +94,7 @@ export var MermaidFullFeatured = /*#__PURE__*/memo(function (_ref) {
138
94
  height: 0,
139
95
  overflow: 'hidden'
140
96
  },
141
- children: enablePanZoom ? /*#__PURE__*/_jsxs(TransformWrapper, {
142
- initialScale: 1,
143
- children: [expand && /*#__PURE__*/_jsx(Controls, {}), /*#__PURE__*/_jsx(TransformComponent, {
144
- wrapperClass: styles.zoomPanContainer,
145
- children: children
146
- })]
147
- }) : children
97
+ children: children
148
98
  })]
149
99
  }));
150
100
  });
@@ -1,5 +1,5 @@
1
1
  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); }
2
- var _excluded = ["children", "copyButtonSize", "fullFeatured", "copyable", "showLanguage", "style", "type", "className", "bodyRender", "actionsRender"];
2
+ var _excluded = ["children", "copyButtonSize", "fullFeatured", "copyable", "showLanguage", "style", "type", "enablePanZoom", "className", "bodyRender", "actionsRender"];
3
3
  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; }
4
4
  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; }
5
5
  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; }
@@ -28,6 +28,7 @@ var Mermaid = /*#__PURE__*/memo(function (_ref) {
28
28
  style = _ref.style,
29
29
  _ref$type = _ref.type,
30
30
  type = _ref$type === void 0 ? 'block' : _ref$type,
31
+ enablePanZoom = _ref.enablePanZoom,
31
32
  className = _ref.className,
32
33
  bodyRender = _ref.bodyRender,
33
34
  actionsRender = _ref.actionsRender,
@@ -36,7 +37,9 @@ var Mermaid = /*#__PURE__*/memo(function (_ref) {
36
37
  cx = _useStyles.cx,
37
38
  styles = _useStyles.styles;
38
39
  var tirmedChildren = children.trim();
39
- var MermaidRender = useMermaid(tirmedChildren);
40
+ var MermaidRender = useMermaid(tirmedChildren, {
41
+ enablePanZoom: fullFeatured ? true : enablePanZoom
42
+ });
40
43
  var originalActions = copyable && /*#__PURE__*/_jsx(CopyButton, {
41
44
  content: children,
42
45
  placement: "left",
@@ -58,6 +61,7 @@ var Mermaid = /*#__PURE__*/memo(function (_ref) {
58
61
  className: className,
59
62
  content: tirmedChildren,
60
63
  copyable: copyable,
64
+ enablePanZoom: enablePanZoom,
61
65
  showLanguage: showLanguage,
62
66
  style: style,
63
67
  type: type
@@ -76,9 +80,9 @@ var Mermaid = /*#__PURE__*/memo(function (_ref) {
76
80
  gap: 4,
77
81
  horizontal: true,
78
82
  children: actions
79
- }), showLanguage && /*#__PURE__*/_jsx(Tag, {
83
+ }), !enablePanZoom && showLanguage && /*#__PURE__*/_jsx(Tag, {
80
84
  className: styles.lang,
81
- children: "mermaid"
85
+ children: "Mermaid"
82
86
  }), /*#__PURE__*/_jsx("div", {
83
87
  className: styles.scroller,
84
88
  children: body
@@ -5,5 +5,4 @@ export declare const useStyles: (props?: "block" | "ghost" | "pure" | undefined)
5
5
  lang: string;
6
6
  scroller: import("antd-style").SerializedStyles;
7
7
  select: import("antd-style").SerializedStyles;
8
- zoomPanContainer: import("antd-style").SerializedStyles;
9
8
  }>;
@@ -1,4 +1,4 @@
1
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
1
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
2
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
3
  import { createStyles } from 'antd-style';
4
4
  export var useStyles = createStyles(function (_ref, type) {
@@ -17,7 +17,6 @@ export var useStyles = createStyles(function (_ref, type) {
17
17
  header: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n padding-block: 4px;\n padding-inline: 8px;\n background: ", ";\n "])), token.colorFillQuaternary),
18
18
  lang: cx(langHoverCls, stylish.blur, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 2;\n inset-block-end: 8px;\n inset-inline-end: 0;\n\n font-family: ", ";\n color: ", ";\n\n opacity: 0;\n\n transition: opacity 0.1s;\n "])), token.fontFamilyCode, token.colorTextSecondary)),
19
19
  scroller: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: auto;\n width: 100%;\n height: 100%;\n "]))),
20
- select: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n user-select: none;\n\n position: absolute;\n inset-inline-start: 50%;\n transform: translateX(-50%);\n\n min-width: 100px;\n\n font-size: 14px;\n color: ", ";\n text-align: center;\n .", "-select-selection-item {\n min-width: 100px;\n padding-inline-end: 0 !important;\n color: ", ";\n text-align: center;\n }\n "])), token.colorTextDescription, prefixCls, token.colorTextDescription),
21
- zoomPanContainer: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: 100%;\n min-height: 240px;\n "])))
20
+ select: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n user-select: none;\n\n position: absolute;\n inset-inline-start: 50%;\n transform: translateX(-50%);\n\n min-width: 100px;\n\n font-size: 14px;\n color: ", ";\n text-align: center;\n .", "-select-selection-item {\n min-width: 100px;\n padding-inline-end: 0 !important;\n color: ", ";\n text-align: center;\n }\n "])), token.colorTextDescription, prefixCls, token.colorTextDescription)
22
21
  };
23
22
  });
@@ -1 +1,3 @@
1
- export declare const useMermaid: (content: string) => () => import("react/jsx-runtime").JSX.Element;
1
+ export declare const useMermaid: (content: string, { enablePanZoom }?: {
2
+ enablePanZoom?: boolean | undefined;
3
+ }) => () => import("react/jsx-runtime").JSX.Element;
@@ -11,8 +11,14 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import { useTheme } from 'antd-style';
12
12
  import mermaid from 'mermaid';
13
13
  import { useCallback, useEffect, useState } from 'react';
14
+ import { Center } from 'react-layout-kit';
15
+ import { TransformComponent, TransformWrapper } from 'react-zoom-pan-pinch';
16
+ import Controls from "./Controls";
14
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
19
  export var useMermaid = function useMermaid(content) {
20
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
21
+ enablePanZoom = _ref.enablePanZoom;
16
22
  var _useState = useState(),
17
23
  _useState2 = _slicedToArray(_useState, 2),
18
24
  mermaidContent = _useState2[0],
@@ -28,8 +34,8 @@ export var useMermaid = function useMermaid(content) {
28
34
  startOnLoad: true,
29
35
  theme: theme.isDarkMode ? 'dark' : 'neutral',
30
36
  themeVariables: {
31
- errorBkgColor: theme.colorErrorBg,
32
- errorTextColor: theme.colorErrorText,
37
+ errorBkgColor: theme.colorTextDescription,
38
+ errorTextColor: theme.colorTextDescription,
33
39
  fontFamily: theme.fontFamily,
34
40
  fontSize: 14,
35
41
  lineColor: theme.colorTextSecondary,
@@ -55,7 +61,7 @@ export var useMermaid = function useMermaid(content) {
55
61
  mermaid.contentLoaded();
56
62
  }, [mermaidContent, theme.isDarkMode]);
57
63
  var checkSyntax = /*#__PURE__*/function () {
58
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(textStr) {
64
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(textStr) {
59
65
  return _regeneratorRuntime().wrap(function _callee$(_context) {
60
66
  while (1) switch (_context.prev = _context.next) {
61
67
  case 0:
@@ -81,23 +87,33 @@ export var useMermaid = function useMermaid(content) {
81
87
  }, _callee, null, [[0, 7]]);
82
88
  }));
83
89
  return function checkSyntax(_x) {
84
- return _ref.apply(this, arguments);
90
+ return _ref2.apply(this, arguments);
85
91
  };
86
92
  }();
87
93
  useEffect(function () {
88
94
  checkSyntax(content);
89
95
  }, [content]);
90
96
  return useCallback(function () {
91
- return /*#__PURE__*/_jsx("pre", {
97
+ if (enablePanZoom) {
98
+ return /*#__PURE__*/_jsxs(TransformWrapper, {
99
+ children: [/*#__PURE__*/_jsx(Controls, {}), /*#__PURE__*/_jsx(TransformComponent, {
100
+ contentClass: 'mermaid',
101
+ contentStyle: {
102
+ padding: 16
103
+ },
104
+ wrapperStyle: {
105
+ minHeight: 240,
106
+ width: '100%'
107
+ },
108
+ children: mermaidContent
109
+ })]
110
+ });
111
+ }
112
+ return /*#__PURE__*/_jsx(Center, {
113
+ as: 'pre',
92
114
  className: 'mermaid',
93
- style: {
94
- alignItems: 'center',
95
- display: 'flex',
96
- fontSize: 14,
97
- justifyContent: 'center',
98
- overflow: 'auto'
99
- },
115
+ padding: 16,
100
116
  children: mermaidContent
101
117
  });
102
- }, [mermaidContent, theme.isDarkMode]);
118
+ }, [mermaidContent, theme.isDarkMode, enablePanZoom]);
103
119
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.166.0",
3
+ "version": "1.166.1",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",