@lobehub/ui 3.1.2 → 3.2.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.
@@ -11,11 +11,6 @@ type TooltipFloatingProps = {
11
11
  floatingStyles: CSSProperties;
12
12
  hotkey?: TooltipProps['hotkey'];
13
13
  hotkeyProps?: TooltipProps['hotkeyProps'];
14
- /**
15
- * Enable Framer Motion layout/position tweening when provided.
16
- * Useful for TooltipGroup where the floating position changes frequently.
17
- */
18
- layoutId?: string;
19
14
  open: boolean;
20
15
  placement?: Placement;
21
16
  setFloating: (node: HTMLElement | null) => void;
@@ -23,8 +18,5 @@ type TooltipFloatingProps = {
23
18
  title?: ReactNode;
24
19
  zIndex?: TooltipProps['zIndex'];
25
20
  };
26
- declare const TooltipFloating: {
27
- ({ open, title, placement, floatingStyles, setFloating, floatingProps, arrow, arrowRef, context, hotkey, hotkeyProps, layoutId, className, classNames, styles: styleProps, zIndex, }: TooltipFloatingProps): import("react/jsx-runtime").JSX.Element;
28
- displayName: string;
29
- };
21
+ declare const TooltipFloating: ({ open, title, placement, floatingStyles, setFloating, floatingProps, arrow, arrowRef, context, hotkey, hotkeyProps, className, classNames, styles: styleProps, zIndex, }: TooltipFloatingProps) => import("react/jsx-runtime").JSX.Element;
30
22
  export default TooltipFloating;
@@ -6,8 +6,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
6
6
  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; }
7
7
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
8
  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); }
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
15
  import { FloatingArrow } from '@floating-ui/react';
10
- import { useMemo } from 'react';
16
+ import React, { useLayoutEffect, useMemo, useState } from 'react';
11
17
  import { Flexbox } from 'react-layout-kit';
12
18
  import Hotkey from "../Hotkey";
13
19
  import { AnimatePresence, LazyMotion, m } from "../motion";
@@ -26,7 +32,6 @@ var TooltipFloating = function TooltipFloating(_ref) {
26
32
  context = _ref.context,
27
33
  hotkey = _ref.hotkey,
28
34
  hotkeyProps = _ref.hotkeyProps,
29
- layoutId = _ref.layoutId,
30
35
  className = _ref.className,
31
36
  classNames = _ref.classNames,
32
37
  styleProps = _ref.styles,
@@ -59,43 +64,47 @@ var TooltipFloating = function TooltipFloating(_ref) {
59
64
  }
60
65
  }
61
66
  }, [placement]);
67
+ var _useState = useState(false),
68
+ _useState2 = _slicedToArray(_useState, 2),
69
+ openNextTick = _useState2[0],
70
+ setOpenNextTick = _useState2[1];
71
+ useLayoutEffect(function () {
72
+ if (!open) {
73
+ setOpenNextTick(false);
74
+ return;
75
+ }
76
+ var rafId = requestAnimationFrame(function () {
77
+ setOpenNextTick(true);
78
+ });
79
+ return function () {
80
+ cancelAnimationFrame(rafId);
81
+ };
82
+ }, [open]);
62
83
  return /*#__PURE__*/_jsx(LazyMotion, {
63
84
  children: /*#__PURE__*/_jsx(AnimatePresence, {
64
- children: open && title && /*#__PURE__*/_jsx(m.div, _objectSpread(_objectSpread({
65
- animate: {
66
- opacity: 1
67
- },
68
- className: cx(styles.tooltip, classNames === null || classNames === void 0 ? void 0 : classNames.container, classNames === null || classNames === void 0 ? void 0 : classNames.root, className),
69
- exit: {
70
- opacity: 0
71
- },
72
- initial: {
73
- opacity: 0
74
- },
85
+ children: open && title && /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
86
+ className: cx(styles.tooltip, openNextTick && styles.tooltipLayout, classNames === null || classNames === void 0 ? void 0 : classNames.container, classNames === null || classNames === void 0 ? void 0 : classNames.root, className),
75
87
  ref: setFloating,
76
88
  role: "tooltip",
77
89
  style: styleProps !== null && styleProps !== void 0 && styleProps.root ? _objectSpread(_objectSpread(_objectSpread({}, floatingStyles), {}, {
78
90
  zIndex: zIndex
79
91
  }, styleProps.container), styleProps.root) : _objectSpread(_objectSpread({}, floatingStyles), {}, {
80
92
  zIndex: zIndex
81
- }, styleProps === null || styleProps === void 0 ? void 0 : styleProps.container),
82
- transition: {
83
- duration: 0.12,
84
- ease: [0.4, 0, 0.2, 1]
85
- }
93
+ }, styleProps === null || styleProps === void 0 ? void 0 : styleProps.container)
86
94
  }, floatingProps), {}, {
87
95
  children: /*#__PURE__*/_jsxs(m.div, {
88
96
  animate: {
97
+ opacity: 1,
89
98
  scale: 1
90
99
  },
91
100
  exit: {
101
+ opacity: 0,
92
102
  scale: 0.98
93
103
  },
94
104
  initial: {
105
+ opacity: 0,
95
106
  scale: 0.96
96
107
  },
97
- layout: layoutId ? 'position' : undefined,
98
- layoutId: layoutId,
99
108
  style: {
100
109
  transformOrigin: transformOrigin
101
110
  },
@@ -131,5 +140,4 @@ var TooltipFloating = function TooltipFloating(_ref) {
131
140
  })
132
141
  });
133
142
  };
134
- TooltipFloating.displayName = 'TooltipFloating';
135
143
  export default TooltipFloating;
@@ -1,6 +1,6 @@
1
- import { type ReactNode } from 'react';
1
+ import { type FC, type ReactNode } from 'react';
2
2
  type TooltipGroupProps = {
3
3
  children: ReactNode;
4
4
  };
5
- declare const TooltipGroup: import("react").NamedExoticComponent<TooltipGroupProps>;
5
+ declare const TooltipGroup: FC<TooltipGroupProps>;
6
6
  export default TooltipGroup;
@@ -7,23 +7,19 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
7
7
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
8
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
9
  import { arrow as arrowMiddleware, autoUpdate, flip, offset, shift, useFloating } from '@floating-ui/react';
10
- import { memo, useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
10
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
11
11
  import { antdPlacementToFloating } from "./antdPlacementToFloating";
12
12
  import TooltipFloating from "./TooltipFloating";
13
13
  import TooltipPortal from "./TooltipPortal";
14
14
  import { TooltipGroupContext } from "./groupContext";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
- var TooltipGroup = /*#__PURE__*/memo(function (_ref) {
17
+ var TooltipGroup = function TooltipGroup(_ref) {
18
18
  var _active$item$portalle;
19
19
  var children = _ref.children;
20
20
  var arrowRef = useRef(null);
21
21
  var openTimerRef = useRef(null);
22
22
  var closeTimerRef = useRef(null);
23
- var internalGroupId = useId();
24
- var motionLayoutId = useMemo(function () {
25
- return "lobe-ui-tooltip-group:".concat(internalGroupId);
26
- }, [internalGroupId]);
27
23
  var _useState = useState(null),
28
24
  _useState2 = _slicedToArray(_useState, 2),
29
25
  active = _useState2[0],
@@ -139,7 +135,6 @@ var TooltipGroup = /*#__PURE__*/memo(function (_ref) {
139
135
  floatingStyles: floatingStyles,
140
136
  hotkey: active === null || active === void 0 ? void 0 : active.item.hotkey,
141
137
  hotkeyProps: active === null || active === void 0 ? void 0 : active.item.hotkeyProps,
142
- layoutId: motionLayoutId,
143
138
  open: open,
144
139
  placement: floatingPlacement,
145
140
  setFloating: refs.setFloating,
@@ -154,6 +149,5 @@ var TooltipGroup = /*#__PURE__*/memo(function (_ref) {
154
149
  children: floatingNode
155
150
  }) : floatingNode)]
156
151
  });
157
- });
158
- TooltipGroup.displayName = 'TooltipGroup';
152
+ };
159
153
  export default TooltipGroup;
@@ -2,4 +2,5 @@ export declare const useStyles: (props?: unknown) => import("antd-style").Return
2
2
  arrow: import("antd-style").SerializedStyles;
3
3
  content: import("antd-style").SerializedStyles;
4
4
  tooltip: import("antd-style").SerializedStyles;
5
+ tooltipLayout: import("antd-style").SerializedStyles;
5
6
  }>;
@@ -1,4 +1,4 @@
1
- var _templateObject, _templateObject2, _templateObject3;
1
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
2
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
3
  import { createStyles } from 'antd-style';
4
4
  export var useStyles = createStyles(function (_ref) {
@@ -7,6 +7,7 @@ export var useStyles = createStyles(function (_ref) {
7
7
  return {
8
8
  arrow: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n fill: ", ";\n "])), token.colorText),
9
9
  content: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n\n min-height: unset;\n padding: 8px;\n border-radius: ", "px;\n\n color: ", ";\n word-break: normal;\n\n background-color: ", ";\n "])), token.borderRadiusSM, token.colorBgLayout, token.colorText),
10
- tooltip: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n pointer-events: none;\n\n /* Keep the class name for backwards compatibility and user overrides */\n position: relative;\n z-index: 114514;\n filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 12%));\n "])))
10
+ tooltip: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n pointer-events: none;\n\n /* Keep the class name for backwards compatibility and user overrides */\n position: relative;\n z-index: 114514;\n filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 12%));\n "]))),
11
+ tooltipLayout: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n transition: all 0.2s ease-in-out;\n "])))
11
12
  };
12
13
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",