@lobehub/ui 1.125.4 → 1.125.6

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.
@@ -1,13 +1,15 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
5
  var _excluded = ["renderMessagesExtra", "showTitle", "onActionsClick", "onAvatarsClick", "onMessageChange", "type", "text", "renderMessages", "renderErrorMessages", "renderActions", "loading", "groupNav", "renderItems"];
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
7
  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
8
  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
9
  import { App } from 'antd';
8
- import copy from 'copy-to-clipboard';
9
10
  import { memo, useCallback, useMemo, useState } from 'react';
10
11
  import ChatItem from "../ChatItem";
12
+ import { copyToClipboard } from "../utils/copyToClipboard";
11
13
  import ActionsBar from "./ActionsBar";
12
14
  import { jsx as _jsx } from "react/jsx-runtime";
13
15
  var Item = /*#__PURE__*/memo(function (props) {
@@ -78,21 +80,34 @@ var Item = /*#__PURE__*/memo(function (props) {
78
80
  if (renderActions !== null && renderActions !== void 0 && renderActions[item.role]) RenderFunction = renderActions[item.role];
79
81
  if (renderActions !== null && renderActions !== void 0 && renderActions['default']) RenderFunction = renderActions['default'];
80
82
  if (!RenderFunction) RenderFunction = ActionsBar;
81
- var handleActionClick = function handleActionClick(action, data) {
82
- switch (action.key) {
83
- case 'copy':
84
- {
85
- copy(data.content);
86
- message.success((text === null || text === void 0 ? void 0 : text.copySuccess) || 'Copy Success');
87
- break;
83
+ var handleActionClick = /*#__PURE__*/function () {
84
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(action, data) {
85
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
86
+ while (1) switch (_context.prev = _context.next) {
87
+ case 0:
88
+ _context.t0 = action.key;
89
+ _context.next = _context.t0 === 'copy' ? 3 : _context.t0 === 'edit' ? 7 : 8;
90
+ break;
91
+ case 3:
92
+ _context.next = 5;
93
+ return copyToClipboard(data.content);
94
+ case 5:
95
+ message.success((text === null || text === void 0 ? void 0 : text.copySuccess) || 'Copy Success');
96
+ return _context.abrupt("break", 8);
97
+ case 7:
98
+ setEditing(true);
99
+ case 8:
100
+ onActionsClick === null || onActionsClick === void 0 || onActionsClick(action, data);
101
+ case 9:
102
+ case "end":
103
+ return _context.stop();
88
104
  }
89
- case 'edit':
90
- {
91
- setEditing(true);
92
- }
93
- }
94
- onActionsClick === null || onActionsClick === void 0 || onActionsClick(action, data);
95
- };
105
+ }, _callee);
106
+ }));
107
+ return function handleActionClick(_x, _x2) {
108
+ return _ref5.apply(this, arguments);
109
+ };
110
+ }();
96
111
  return /*#__PURE__*/_jsx(RenderFunction, _objectSpread(_objectSpread({}, data), {}, {
97
112
  onActionClick: function onActionClick(actionKey) {
98
113
  return handleActionClick === null || handleActionClick === void 0 ? void 0 : handleActionClick(actionKey, data);
@@ -1,7 +1,9 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
1
3
  import { Space, message } from 'antd';
2
- import copy from 'copy-to-clipboard';
3
4
  import { memo } from 'react';
4
5
  import { Flexbox } from 'react-layout-kit';
6
+ import { copyToClipboard } from "../utils/copyToClipboard";
5
7
  import { alphaBg, useStyles } from "./style";
6
8
  import { jsx as _jsx } from "react/jsx-runtime";
7
9
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -49,11 +51,22 @@ var ScaleRow = /*#__PURE__*/memo(function (_ref) {
49
51
  if (index === 0 || index === 12) return false;
50
52
  return /*#__PURE__*/_jsx("div", {
51
53
  className: styles.scaleBox,
52
- onClick: function onClick() {
53
- var content = "token.".concat(name).concat(index).concat(isAlpha ? 'A' : '', " /* ").concat(color, " */");
54
- copy(content);
55
- message.success(content);
56
- },
54
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
55
+ var content;
56
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
57
+ while (1) switch (_context.prev = _context.next) {
58
+ case 0:
59
+ content = "token.".concat(name).concat(index).concat(isAlpha ? 'A' : '', " /* ").concat(color, " */");
60
+ _context.next = 3;
61
+ return copyToClipboard(content);
62
+ case 3:
63
+ message.success(content);
64
+ case 4:
65
+ case "end":
66
+ return _context.stop();
67
+ }
68
+ }, _callee);
69
+ })),
57
70
  style: style,
58
71
  title: color,
59
72
  children: /*#__PURE__*/_jsx(Flexbox, {
@@ -1,13 +1,15 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
4
  var _excluded = ["content", "className", "placement", "size"];
4
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; }
5
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; }
6
- import copy from 'copy-to-clipboard';
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
8
  import { Copy } from 'lucide-react';
8
9
  import { memo } from 'react';
9
10
  import ActionIcon from "../ActionIcon";
10
11
  import { useCopied } from "../hooks/useCopied";
12
+ import { copyToClipboard } from "../utils/copyToClipboard";
11
13
  import { jsx as _jsx } from "react/jsx-runtime";
12
14
  var CopyButton = /*#__PURE__*/memo(function (_ref) {
13
15
  var content = _ref.content,
@@ -24,10 +26,20 @@ var CopyButton = /*#__PURE__*/memo(function (_ref) {
24
26
  className: className,
25
27
  glass: true,
26
28
  icon: Copy,
27
- onClick: function onClick() {
28
- copy(content);
29
- setCopied();
30
- },
29
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
30
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
31
+ while (1) switch (_context.prev = _context.next) {
32
+ case 0:
33
+ _context.next = 2;
34
+ return copyToClipboard(content);
35
+ case 2:
36
+ setCopied();
37
+ case 3:
38
+ case "end":
39
+ return _context.stop();
40
+ }
41
+ }, _callee);
42
+ })),
31
43
  placement: placement,
32
44
  size: size,
33
45
  title: copied ? '✅ Success' : 'Copy'
@@ -19,7 +19,7 @@ var useStyles = createStyles(function (_ref) {
19
19
  });
20
20
  var EditableMessage = /*#__PURE__*/memo(function (_ref2) {
21
21
  var value = _ref2.value,
22
- _onChange = _ref2.onChange,
22
+ onChange = _ref2.onChange,
23
23
  _ref2$classNames = _ref2.classNames,
24
24
  classNames = _ref2$classNames === void 0 ? {} : _ref2$classNames,
25
25
  onEditingChange = _ref2.onEditingChange,
@@ -66,7 +66,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref2) {
66
66
  return setTyping(false);
67
67
  },
68
68
  onConfirm: function onConfirm(text) {
69
- _onChange === null || _onChange === void 0 || _onChange(text);
69
+ onChange === null || onChange === void 0 || onChange(text);
70
70
  setTyping(false);
71
71
  },
72
72
  placeholder: placeholder,
@@ -86,14 +86,12 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref2) {
86
86
  overflowY: 'auto'
87
87
  }, stylesProps === null || stylesProps === void 0 ? void 0 : stylesProps.markdown),
88
88
  children: value || placeholder || ''
89
- }), /*#__PURE__*/_jsx(MessageModal, {
89
+ }), expand && /*#__PURE__*/_jsx(MessageModal, {
90
90
  editing: isEdit,
91
91
  extra: model === null || model === void 0 ? void 0 : model.extra,
92
92
  footer: model === null || model === void 0 ? void 0 : model.footer,
93
93
  height: height,
94
- onChange: function onChange(text) {
95
- return _onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
96
- },
94
+ onChange: onChange,
97
95
  onEditingChange: setTyping,
98
96
  onOpenChange: function onOpenChange(e) {
99
97
  setExpand(e);
@@ -0,0 +1 @@
1
+ export declare const copyToClipboard: (text: string) => Promise<void>;
@@ -0,0 +1,34 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ export var copyToClipboard = /*#__PURE__*/function () {
4
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
5
+ var textArea;
6
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
7
+ while (1) switch (_context.prev = _context.next) {
8
+ case 0:
9
+ _context.prev = 0;
10
+ _context.next = 3;
11
+ return navigator.clipboard.writeText(text);
12
+ case 3:
13
+ _context.next = 14;
14
+ break;
15
+ case 5:
16
+ _context.prev = 5;
17
+ _context.t0 = _context["catch"](0);
18
+ textArea = document.createElement('textarea');
19
+ textArea.value = text;
20
+ document.body.append(textArea);
21
+ textArea.focus();
22
+ textArea.select();
23
+ document.execCommand('copy');
24
+ textArea.remove();
25
+ case 14:
26
+ case "end":
27
+ return _context.stop();
28
+ }
29
+ }, _callee, null, [[0, 5]]);
30
+ }));
31
+ return function copyToClipboard(_x) {
32
+ return _ref.apply(this, arguments);
33
+ };
34
+ }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.125.4",
3
+ "version": "1.125.6",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -83,7 +83,6 @@
83
83
  "@splinetool/runtime": "^0.9",
84
84
  "ahooks": "^3",
85
85
  "chroma-js": "^2",
86
- "copy-to-clipboard": "^3",
87
86
  "dayjs": "^1",
88
87
  "emoji-mart": "^5",
89
88
  "emoji-regex": "^10",