@lobehub/ui 1.164.7 → 1.164.8
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/CodeEditor/index.js +1 -1
- package/es/Swatches/index.js +2 -2
- package/es/chat/EditableMessage/index.js +1 -0
- package/es/chat/MessageInput/index.d.ts +1 -0
- package/es/chat/MessageInput/index.js +27 -4
- package/es/utils/platform.d.ts +1 -0
- package/es/utils/platform.js +1 -0
- package/package.json +1 -1
package/es/CodeEditor/index.js
CHANGED
|
@@ -16,6 +16,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
16
16
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
17
17
|
import { Flexbox } from 'react-layout-kit';
|
|
18
18
|
import { useStyles } from "./style";
|
|
19
|
+
import { isMacLike } from "../utils/platform";
|
|
19
20
|
import SyntaxHighlighter from "../Highlighter/SyntaxHighlighter";
|
|
20
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
22
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -29,7 +30,6 @@ var KEYCODE_BACK_QUOTE = 192;
|
|
|
29
30
|
var HISTORY_LIMIT = 100;
|
|
30
31
|
var HISTORY_TIME_GAP = 3000;
|
|
31
32
|
var isWindows = typeof window !== 'undefined' && 'navigator' in window && /win/i.test(navigator.platform);
|
|
32
|
-
var isMacLike = typeof window !== 'undefined' && 'navigator' in window && /(mac|iphone|ipod|ipad)/i.test(navigator.platform);
|
|
33
33
|
var getLines = function getLines(text, position) {
|
|
34
34
|
return text.slice(0, Math.max(0, position)).split('\n');
|
|
35
35
|
};
|
package/es/Swatches/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var Swatches = /*#__PURE__*/memo(function (_ref) {
|
|
|
30
30
|
style: {
|
|
31
31
|
background: theme.colorBgContainer
|
|
32
32
|
}
|
|
33
|
-
}), colors.map(function (c) {
|
|
33
|
+
}), colors.map(function (c, index) {
|
|
34
34
|
var isActive = c === activeColor;
|
|
35
35
|
return /*#__PURE__*/_jsx(Flexbox, {
|
|
36
36
|
className: cx(styles.container, isActive && styles.active),
|
|
@@ -40,7 +40,7 @@ var Swatches = /*#__PURE__*/memo(function (_ref) {
|
|
|
40
40
|
style: {
|
|
41
41
|
background: c
|
|
42
42
|
}
|
|
43
|
-
}, c);
|
|
43
|
+
}, "".concat(c, "_").concat(index));
|
|
44
44
|
})]
|
|
45
45
|
});
|
|
46
46
|
});
|
|
@@ -72,6 +72,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
72
72
|
setTyping(false);
|
|
73
73
|
},
|
|
74
74
|
placeholder: placeholder,
|
|
75
|
+
shortcut: true,
|
|
75
76
|
style: stylesProps === null || stylesProps === void 0 ? void 0 : stylesProps.input,
|
|
76
77
|
text: text,
|
|
77
78
|
textareaClassname: classNames === null || classNames === void 0 ? void 0 : classNames.input,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
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 = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "style", "editButtonSize", "classNames"];
|
|
4
|
+
var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "style", "editButtonSize", "classNames", "shortcut"];
|
|
5
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
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
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; }
|
|
@@ -16,13 +16,16 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
16
16
|
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; }
|
|
17
17
|
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; }
|
|
18
18
|
import { Button } from 'antd';
|
|
19
|
+
import { ChevronUpIcon, CommandIcon, CornerDownLeft } from 'lucide-react';
|
|
19
20
|
import { memo, useState } from 'react';
|
|
20
21
|
import { Flexbox } from 'react-layout-kit';
|
|
22
|
+
import Icon from "../../Icon";
|
|
21
23
|
import { TextArea } from "../../Input";
|
|
24
|
+
import { isMacLike } from "../../utils/platform";
|
|
22
25
|
import { useStyles } from "./style";
|
|
23
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
25
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
29
|
var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
27
30
|
var text = _ref.text,
|
|
28
31
|
_ref$type = _ref.type,
|
|
@@ -40,6 +43,7 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
40
43
|
_ref$editButtonSize = _ref.editButtonSize,
|
|
41
44
|
editButtonSize = _ref$editButtonSize === void 0 ? 'middle' : _ref$editButtonSize,
|
|
42
45
|
classNames = _ref.classNames,
|
|
46
|
+
shortcut = _ref.shortcut,
|
|
43
47
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
44
48
|
var _useState = useState(defaultValue || ''),
|
|
45
49
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -66,6 +70,11 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
66
70
|
onChange: function onChange(e) {
|
|
67
71
|
return setValue(e.target.value);
|
|
68
72
|
},
|
|
73
|
+
onPressEnter: shortcut ? function (e) {
|
|
74
|
+
if (isMacLike ? e.metaKey : e.ctrlKey) {
|
|
75
|
+
onConfirm === null || onConfirm === void 0 || onConfirm(temporaryValue);
|
|
76
|
+
}
|
|
77
|
+
} : undefined,
|
|
69
78
|
placeholder: placeholder,
|
|
70
79
|
resize: false,
|
|
71
80
|
style: textareaStyle,
|
|
@@ -79,13 +88,27 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
79
88
|
size: "small"
|
|
80
89
|
}, buttonProps), index);
|
|
81
90
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
82
|
-
children: [/*#__PURE__*/
|
|
91
|
+
children: [/*#__PURE__*/_jsxs(Button, {
|
|
83
92
|
onClick: function onClick() {
|
|
84
93
|
onConfirm === null || onConfirm === void 0 || onConfirm(temporaryValue);
|
|
85
94
|
},
|
|
86
95
|
size: editButtonSize,
|
|
87
96
|
type: "primary",
|
|
88
|
-
children: (text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm'
|
|
97
|
+
children: [(text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm', shortcut && /*#__PURE__*/_jsxs(Flexbox, {
|
|
98
|
+
gap: 4,
|
|
99
|
+
horizontal: true,
|
|
100
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
101
|
+
icon: isMacLike ? CommandIcon : ChevronUpIcon,
|
|
102
|
+
size: {
|
|
103
|
+
fontSize: 12
|
|
104
|
+
}
|
|
105
|
+
}), /*#__PURE__*/_jsx(Icon, {
|
|
106
|
+
icon: CornerDownLeft,
|
|
107
|
+
size: {
|
|
108
|
+
fontSize: 12
|
|
109
|
+
}
|
|
110
|
+
})]
|
|
111
|
+
})]
|
|
89
112
|
}), /*#__PURE__*/_jsx(Button, {
|
|
90
113
|
onClick: onCancel,
|
|
91
114
|
size: editButtonSize,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isMacLike: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var isMacLike = typeof window !== 'undefined' && 'navigator' in window && /(mac|iphone|ipod|ipad)/i.test(navigator.platform);
|