@lobehub/ui 1.164.7 → 1.164.9

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.
@@ -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
  };
@@ -1,7 +1,8 @@
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 = ["children"];
4
+ var _excluded = ["className", "children"];
5
+ var _templateObject;
5
6
  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
7
  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
8
  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; }
@@ -9,13 +10,27 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
9
10
  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
11
  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
12
  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; }
13
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
14
+ import { createStyles } from 'antd-style';
12
15
  import { memo } from 'react';
13
16
  import { Flexbox } from 'react-layout-kit';
14
17
  import { jsx as _jsx } from "react/jsx-runtime";
15
- var FormFooter = /*#__PURE__*/memo(function (_ref) {
16
- var children = _ref.children,
17
- rest = _objectWithoutProperties(_ref, _excluded);
18
+ var useStyles = createStyles(function (_ref) {
19
+ var css = _ref.css,
20
+ responsive = _ref.responsive;
21
+ return {
22
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", " {\n padding: 16px;\n }\n "])), responsive.mobile)
23
+ };
24
+ });
25
+ var FormFooter = /*#__PURE__*/memo(function (_ref2) {
26
+ var className = _ref2.className,
27
+ children = _ref2.children,
28
+ rest = _objectWithoutProperties(_ref2, _excluded);
29
+ var _useStyles = useStyles(),
30
+ cx = _useStyles.cx,
31
+ styles = _useStyles.styles;
18
32
  return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
33
+ className: cx(styles.container, className),
19
34
  gap: 8,
20
35
  horizontal: true,
21
36
  justify: 'flex-end'
@@ -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,
@@ -29,6 +29,7 @@ export interface MessageInputProps extends DivProps {
29
29
  * @param text - The text input by the user.
30
30
  */
31
31
  renderButtons?: (text: string) => ButtonProps[];
32
+ shortcut?: boolean;
32
33
  text?: {
33
34
  cancel?: string;
34
35
  confirm?: string;
@@ -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__*/_jsx(Button, {
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.164.7",
3
+ "version": "1.164.9",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",