@lobehub/ui 1.168.18 → 1.168.19

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,4 +1,4 @@
1
- export declare const useStyles: (props?: "block" | "ghost" | "pure" | undefined) => import("antd-style").ReturnStyles<{
1
+ export declare const useStyles: (props?: "block" | "pure" | "ghost" | undefined) => import("antd-style").ReturnStyles<{
2
2
  button: string;
3
3
  container: string;
4
4
  header: import("antd-style").SerializedStyles;
@@ -13,6 +13,7 @@ export interface HotkeyProps extends Omit<FlexboxProps, 'children'> {
13
13
  descStyle?: CSSProperties;
14
14
  kbdStyle?: CSSProperties;
15
15
  };
16
+ variant?: 'default' | 'pure';
16
17
  }
17
18
  declare const Hotkey: import("react").NamedExoticComponent<HotkeyProps>;
18
19
  export default Hotkey;
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- var _excluded = ["classNames", "styles", "keys", "inverseTheme", "isApple", "compact", "className", "style"];
3
+ var _excluded = ["variant", "classNames", "styles", "keys", "inverseTheme", "isApple", "compact", "className", "style"];
4
4
  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); }
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; }
@@ -94,7 +94,9 @@ var mappingKey = function mappingKey(isAppleDevice) {
94
94
  })), KeyMapEnum.Comma, ','), KeyMapEnum.Period, '.'), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref, KeyMapEnum.Slash, '/'), KeyMapEnum.Semicolon, ';'), KeyMapEnum.Quote, "'"), KeyMapEnum.Backquote, '`'), KeyMapEnum.Backslash, '\\'), KeyMapEnum.BracketLeft, '['), KeyMapEnum.BracketRight, ']'), KeyMapEnum.Minus, '-'), KeyMapEnum.Equal, '=');
95
95
  };
96
96
  var Hotkey = /*#__PURE__*/memo(function (_ref2) {
97
- var classNames = _ref2.classNames,
97
+ var _ref2$variant = _ref2.variant,
98
+ variant = _ref2$variant === void 0 ? 'default' : _ref2$variant,
99
+ classNames = _ref2.classNames,
98
100
  styles = _ref2.styles,
99
101
  keys = _ref2.keys,
100
102
  inverseTheme = _ref2.inverseTheme,
@@ -106,6 +108,7 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
106
108
  var _useStyles = useStyles(inverseTheme),
107
109
  cx = _useStyles.cx,
108
110
  s = _useStyles.styles;
111
+ var isPure = variant === 'pure';
109
112
  var _useState = useState(splitKeysByPlus(keys)),
110
113
  _useState2 = _slicedToArray(_useState, 2),
111
114
  keysGroup = _useState2[0],
@@ -130,7 +133,12 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
130
133
  visibility: visibility
131
134
  }, style)
132
135
  }, rest), {}, {
133
- children: compact ? /*#__PURE__*/_jsx(Flexbox, {
136
+ children: isPure ? keysGroup.map(function (key, index) {
137
+ var _mapping$key;
138
+ return /*#__PURE__*/_jsx("span", {
139
+ children: (_mapping$key = mapping[key]) !== null && _mapping$key !== void 0 ? _mapping$key : startCase(key)
140
+ }, index);
141
+ }) : compact ? /*#__PURE__*/_jsx(Flexbox, {
134
142
  align: 'center',
135
143
  as: 'kbd',
136
144
  className: classNames === null || classNames === void 0 ? void 0 : classNames.descClassName,
@@ -138,17 +146,17 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
138
146
  horizontal: true,
139
147
  style: styles === null || styles === void 0 ? void 0 : styles.kbdStyle,
140
148
  children: keysGroup.map(function (key, index) {
141
- var _mapping$key;
149
+ var _mapping$key2;
142
150
  return /*#__PURE__*/_jsx("div", {
143
- children: (_mapping$key = mapping[key]) !== null && _mapping$key !== void 0 ? _mapping$key : startCase(key)
151
+ children: (_mapping$key2 = mapping[key]) !== null && _mapping$key2 !== void 0 ? _mapping$key2 : startCase(key)
144
152
  }, index);
145
153
  })
146
154
  }) : keysGroup.map(function (key, index) {
147
- var _mapping$key2;
155
+ var _mapping$key3;
148
156
  return /*#__PURE__*/_jsx("kbd", {
149
157
  className: classNames === null || classNames === void 0 ? void 0 : classNames.descClassName,
150
158
  style: styles === null || styles === void 0 ? void 0 : styles.kbdStyle,
151
- children: (_mapping$key2 = mapping[key]) !== null && _mapping$key2 !== void 0 ? _mapping$key2 : startCase(key)
159
+ children: (_mapping$key3 = mapping[key]) !== null && _mapping$key3 !== void 0 ? _mapping$key3 : startCase(key)
152
160
  }, index);
153
161
  })
154
162
  }));
@@ -5,5 +5,5 @@ import { rgba } from 'polished';
5
5
  export var useStyles = createStyles(function (_ref, inverseTheme) {
6
6
  var css = _ref.css,
7
7
  token = _ref.token;
8
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n kbd {\n overflow: hidden;\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n min-width: 16px;\n height: 22px;\n padding-block: 0;\n padding-inline: 8px;\n\n font-family: ", ";\n font-size: 12px;\n line-height: 1.1;\n color: ", ";\n text-align: center;\n white-space: nowrap;\n\n background: ", ";\n border: none;\n border-radius: ", "px;\n }\n "])), token.fontFamily, inverseTheme ? token.colorTextTertiary : token.colorTextSecondary, inverseTheme ? rgba(token.colorTextTertiary, 0.15) : token.colorFillTertiary, token.borderRadiusSM);
8
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n\n kbd {\n overflow: hidden;\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n min-width: 16px;\n height: 22px;\n padding-block: 0;\n padding-inline: 8px;\n\n font-family: ", ";\n font-size: 12px;\n line-height: 1.1;\n color: inherit;\n text-align: center;\n white-space: nowrap;\n\n background: ", ";\n border: none;\n border-radius: ", "px;\n }\n "])), inverseTheme ? token.colorTextTertiary : token.colorTextSecondary, token.fontFamily, inverseTheme ? rgba(token.colorTextTertiary, 0.15) : token.colorFillTertiary, token.borderRadiusSM);
9
9
  });
@@ -10,6 +10,7 @@ export declare const KeyMapEnum: {
10
10
  readonly Down: "down";
11
11
  readonly Enter: "enter";
12
12
  readonly Equal: "equal";
13
+ readonly Esc: "esc";
13
14
  readonly Left: "left";
14
15
  readonly LeftClick: "left-click";
15
16
  readonly LeftDoubleClick: "left-double-click";
package/es/Hotkey/type.js CHANGED
@@ -16,6 +16,7 @@ export var KeyMapEnum = {
16
16
  Enter: 'enter',
17
17
  Equal: 'equal',
18
18
  // =
19
+ Esc: 'esc',
19
20
  Left: 'left',
20
21
  LeftClick: 'left-click',
21
22
  LeftDoubleClick: 'left-double-click',
@@ -1,4 +1,4 @@
1
- export declare const useStyles: (props?: "block" | "ghost" | "pure" | undefined) => import("antd-style").ReturnStyles<{
1
+ export declare const useStyles: (props?: "block" | "pure" | "ghost" | undefined) => import("antd-style").ReturnStyles<{
2
2
  button: string;
3
3
  container: string;
4
4
  header: import("antd-style").SerializedStyles;
@@ -19,14 +19,14 @@ import { Button } from 'antd';
19
19
  import { memo, useState } from 'react';
20
20
  import { useHotkeys } from 'react-hotkeys-hook';
21
21
  import { Flexbox } from 'react-layout-kit';
22
- import Hotkey from "../../Hotkey";
23
22
  import { KeyMapEnum } from "../../Hotkey/type";
24
23
  import { combineKeys } from "../../Hotkey/utils";
25
24
  import { TextArea } from "../../Input";
25
+ import Tooltip from "../../Tooltip";
26
26
  import { useStyles } from "./style";
27
27
  import { jsx as _jsx } from "react/jsx-runtime";
28
- import { jsxs as _jsxs } from "react/jsx-runtime";
29
28
  import { Fragment as _Fragment } from "react/jsx-runtime";
29
+ import { jsxs as _jsxs } from "react/jsx-runtime";
30
30
  var MessageInput = /*#__PURE__*/memo(function (_ref) {
31
31
  var text = _ref.text,
32
32
  _ref$type = _ref.type,
@@ -53,15 +53,38 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
53
53
  var _useStyles = useStyles(),
54
54
  cx = _useStyles.cx,
55
55
  styles = _useStyles.styles;
56
- var hotkey = combineKeys([KeyMapEnum.Mod, KeyMapEnum.Enter]);
56
+ var confirmHotkey = combineKeys([KeyMapEnum.Mod, KeyMapEnum.Enter]);
57
+ var confirmText = (text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm';
58
+ var cancelHotkey = combineKeys([KeyMapEnum.Esc]);
59
+ var cancelText = (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel';
57
60
  var isAutoSize = height === 'auto';
58
- useHotkeys(hotkey, function () {
61
+ var handleConfirm = function handleConfirm() {
59
62
  return onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(temporaryValue);
60
- }, {
63
+ };
64
+ var handleCancel = function handleCancel() {
65
+ return onCancel === null || onCancel === void 0 ? void 0 : onCancel();
66
+ };
67
+ useHotkeys(confirmHotkey, handleConfirm, {
68
+ enableOnFormTags: true,
69
+ enabled: shortcut,
70
+ preventDefault: true
71
+ });
72
+ useHotkeys(cancelHotkey, handleCancel, {
61
73
  enableOnFormTags: true,
62
74
  enabled: shortcut,
63
75
  preventDefault: true
64
76
  });
77
+ var confirmButton = /*#__PURE__*/_jsx(Button, {
78
+ onClick: handleConfirm,
79
+ size: editButtonSize,
80
+ type: "primary",
81
+ children: confirmText
82
+ });
83
+ var cancllButton = /*#__PURE__*/_jsx(Button, {
84
+ onClick: handleCancel,
85
+ size: editButtonSize,
86
+ children: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel'
87
+ });
65
88
  return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
66
89
  gap: 16,
67
90
  style: _objectSpread({
@@ -92,21 +115,15 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
92
115
  size: "small"
93
116
  }, buttonProps), index);
94
117
  }) : /*#__PURE__*/_jsxs(_Fragment, {
95
- children: [/*#__PURE__*/_jsxs(Button, {
96
- onClick: function onClick() {
97
- return onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(temporaryValue);
98
- },
99
- size: editButtonSize,
100
- type: "primary",
101
- children: [(text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm', shortcut && /*#__PURE__*/_jsx(Hotkey, {
102
- inverseTheme: true,
103
- keys: combineKeys([KeyMapEnum.Mod, KeyMapEnum.Enter])
104
- })]
105
- }), /*#__PURE__*/_jsx(Button, {
106
- onClick: onCancel,
107
- size: editButtonSize,
108
- children: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel'
109
- })]
118
+ children: [shortcut ? /*#__PURE__*/_jsx(Tooltip, {
119
+ hotkey: confirmHotkey,
120
+ title: confirmText,
121
+ children: confirmButton
122
+ }) : confirmButton, shortcut ? /*#__PURE__*/_jsx(Tooltip, {
123
+ hotkey: cancelHotkey,
124
+ title: cancelText,
125
+ children: cancllButton
126
+ }) : cancllButton]
110
127
  })
111
128
  })]
112
129
  }));
@@ -1,4 +1,10 @@
1
1
  import { SWRResponse } from 'swr';
2
2
  export declare const FALLBACK_LANG = "txt";
3
+ declare const highlightCache: Map<string, string>;
4
+ declare const MD5_LENGTH_THRESHOLD = 10000;
5
+ declare const loadShiki: () => Promise<(code: string, options: import("@shikijs/types").CodeToHastOptions<import("shiki/dist/langs.mjs").BundledLanguage, import("shiki/dist/themes.mjs").BundledTheme>) => Promise<string>>;
6
+ declare const shikiPromise: Promise<(code: string, options: import("@shikijs/types").CodeToHastOptions<import("shiki/dist/langs.mjs").BundledLanguage, import("shiki/dist/themes.mjs").BundledTheme>) => Promise<string>>;
7
+ declare const escapeHtml: (str: string) => string;
3
8
  export declare const useHighlight: (text: string, lang: string, enableTransformer?: boolean) => SWRResponse<string, Error>;
4
9
  export { default as languageMap } from './languageMap';
10
+ export { escapeHtml, highlightCache, loadShiki, MD5_LENGTH_THRESHOLD, shikiPromise };
@@ -150,4 +150,5 @@ export var useHighlight = function useHighlight(text, lang, enableTransformer) {
150
150
  revalidateOnReconnect: false
151
151
  });
152
152
  };
153
- export { default as languageMap } from "./languageMap";
153
+ export { default as languageMap } from "./languageMap";
154
+ export { escapeHtml, highlightCache, loadShiki, MD5_LENGTH_THRESHOLD, shikiPromise };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.168.18",
3
+ "version": "1.168.19",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",