@lobehub/ui 1.63.0 → 1.64.0

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.
@@ -4,14 +4,16 @@ export interface TokenTagProps extends DivProps {
4
4
  /**
5
5
  * @default 'left'
6
6
  */
7
- displayMode?: 'left' | 'used';
7
+ displayMode?: 'remained' | 'used';
8
8
  /**
9
9
  * @description Maximum value for the token
10
10
  */
11
11
  maxValue: number;
12
12
  text?: {
13
13
  overload?: string;
14
+ remained?: string;
14
15
  tokens?: string;
16
+ used?: string;
15
17
  };
16
18
  /**
17
19
  * @description Current value of the token
@@ -3,7 +3,8 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
3
3
  var _excluded = ["className", "displayMode", "maxValue", "value", "text"];
4
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
- import { forwardRef } from 'react';
6
+ import { useHover } from 'ahooks';
7
+ import { forwardRef, useRef } from 'react';
7
8
  import FluentEmoji from "../FluentEmoji";
8
9
  import { ICON_SIZE, useStyles } from "./style";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -11,11 +12,13 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
11
12
  var TokenTag = /*#__PURE__*/forwardRef(function (_ref, ref) {
12
13
  var className = _ref.className,
13
14
  _ref$displayMode = _ref.displayMode,
14
- displayMode = _ref$displayMode === void 0 ? 'left' : _ref$displayMode,
15
+ displayMode = _ref$displayMode === void 0 ? 'remained' : _ref$displayMode,
15
16
  maxValue = _ref.maxValue,
16
17
  value = _ref.value,
17
18
  text = _ref.text,
18
19
  props = _objectWithoutProperties(_ref, _excluded);
20
+ var reference = useRef(ref);
21
+ var isHovering = useHover(reference);
19
22
  var valueLeft = maxValue - value;
20
23
  var percent = valueLeft / maxValue;
21
24
  var type;
@@ -35,12 +38,12 @@ var TokenTag = /*#__PURE__*/forwardRef(function (_ref, ref) {
35
38
  cx = _useStyles.cx;
36
39
  return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
37
40
  className: cx(styles.container, className),
38
- ref: ref
41
+ ref: reference
39
42
  }, props), {}, {
40
43
  children: [/*#__PURE__*/_jsx(FluentEmoji, {
41
44
  emoji: emoji,
42
45
  size: ICON_SIZE
43
- }), valueLeft > 0 ? (text === null || text === void 0 ? void 0 : text.tokens) || "Tokens ".concat(displayMode === 'left' ? valueLeft : value) : (text === null || text === void 0 ? void 0 : text.overload) || 'Overload']
46
+ }), valueLeft > 0 ? [displayMode === 'remained' ? (text === null || text === void 0 ? void 0 : text.remained) || 'Remained' : (text === null || text === void 0 ? void 0 : text.used) || 'Used', displayMode === 'remained' ? valueLeft : value, isHovering ? (text === null || text === void 0 ? void 0 : text.tokens) || 'Tokens' : ''].join(' ') : (text === null || text === void 0 ? void 0 : text.overload) || 'Overload']
44
47
  }));
45
48
  });
46
49
  export default TokenTag;
@@ -26,6 +26,6 @@ export var useStyles = createStyles(function (_ref, type) {
26
26
  }
27
27
  }
28
28
  return {
29
- container: cx(percentStyle, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n user-select: none;\n\n overflow: hidden;\n display: flex;\n gap: 4px;\n align-items: center;\n\n height: ", "px;\n padding: 0 ", "px 0 ", "px;\n\n font-family: ", ";\n\n background: ", ";\n border-radius: ", "px;\n "])), HEIGHT, (HEIGHT - ICON_SIZE) * 1.2, (HEIGHT - ICON_SIZE) / 2, token.fontFamilyCode, token.colorFillSecondary, HEIGHT / 2))
29
+ container: cx(percentStyle, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n user-select: none;\n\n overflow: hidden;\n display: flex;\n flex: 0;\n gap: 4px;\n align-items: center;\n\n min-width: fit-content;\n height: ", "px;\n padding: 0 ", "px 0 ", "px;\n\n font-family: ", ";\n font-size: 13px;\n line-height: 1;\n\n background: ", ";\n border-radius: ", "px;\n "])), HEIGHT, (HEIGHT - ICON_SIZE) * 1.2, (HEIGHT - ICON_SIZE) / 2, token.fontFamilyCode, token.colorFillSecondary, HEIGHT / 2))
30
30
  };
31
31
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.63.0",
3
+ "version": "1.64.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",