@lobehub/ui 1.128.5 → 1.128.7

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/README.md CHANGED
@@ -63,7 +63,7 @@ $ bun add @lobehub/ui
63
63
  ### Compile with NextJS
64
64
 
65
65
  > \[!NOTE]\
66
- > By work correct with nextjs ssr, add `transpilePackages: ['@lobehub/ui']` to `next.config.js`. For example:
66
+ > By work correct with nextjs page router SSR, add `transpilePackages: ['@lobehub/ui']` to `next.config.js`. For example:
67
67
 
68
68
  ```js
69
69
  // next.config.js
@@ -3,9 +3,10 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  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; }
4
4
  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; }
5
5
  import { useHover } from 'ahooks';
6
+ import { ConfigProvider } from 'antd';
6
7
  import { ChevronDown, ChevronLeft, ChevronRight, ChevronUp } from 'lucide-react';
7
8
  import { Resizable } from 're-resizable';
8
- import { memo, useEffect, useMemo, useRef, useState } from 'react';
9
+ import { memo, useContext, useEffect, useMemo, useRef, useState } from 'react';
9
10
  import { Center } from 'react-layout-kit';
10
11
  import useControlledState from 'use-merge-value';
11
12
  import { useStyles } from "./style";
@@ -46,10 +47,21 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
46
47
  destroyOnClose = _ref.destroyOnClose,
47
48
  hanlderStyle = _ref.hanlderStyle,
48
49
  _ref$classNames = _ref.classNames,
49
- classNames = _ref$classNames === void 0 ? {} : _ref$classNames;
50
+ classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
51
+ dir = _ref.dir;
50
52
  var reference = useRef();
51
53
  var isHovering = useHover(reference);
52
54
  var isVertical = placement === 'top' || placement === 'bottom';
55
+
56
+ // inherit direction from Ant Design ConfigProvider
57
+ var _useContext = useContext(ConfigProvider.ConfigContext),
58
+ antdDirection = _useContext.direction;
59
+ var direction = dir !== null && dir !== void 0 ? dir : antdDirection;
60
+ var internalPlacement = placement;
61
+ // reverse the placement when dir is rtl
62
+ if (direction === 'rtl' && ['left', 'right'].includes(placement)) {
63
+ internalPlacement = internalPlacement === 'left' ? 'right' : 'left';
64
+ }
53
65
  var _useStyles = useStyles(headerHeight),
54
66
  styles = _useStyles.styles,
55
67
  cx = _useStyles.cx;
@@ -79,8 +91,8 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
79
91
  var canResizing = resize !== false && isExpand;
80
92
  var resizeHandleClassNames = useMemo(function () {
81
93
  if (!canResizing) return {};
82
- return _defineProperty({}, revesePlacement(placement), styles["".concat(revesePlacement(placement), "Handle")]);
83
- }, [canResizing, placement]);
94
+ return _defineProperty({}, revesePlacement(internalPlacement), styles["".concat(revesePlacement(internalPlacement), "Handle")]);
95
+ }, [canResizing, internalPlacement]);
84
96
  var resizing = _objectSpread(_defineProperty({
85
97
  bottom: false,
86
98
  bottomLeft: false,
@@ -90,7 +102,7 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
90
102
  top: false,
91
103
  topLeft: false,
92
104
  topRight: false
93
- }, revesePlacement(placement), true), resize);
105
+ }, revesePlacement(internalPlacement), true), resize);
94
106
  var defaultSize = useMemo(function () {
95
107
  if (isVertical) return _objectSpread({
96
108
  height: DEFAULT_HEIGHT,
@@ -120,7 +132,7 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
120
132
  }
121
133
  };
122
134
  var _useMemo = useMemo(function () {
123
- switch (placement) {
135
+ switch (internalPlacement) {
124
136
  case 'top':
125
137
  {
126
138
  return {
@@ -150,7 +162,7 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
150
162
  };
151
163
  }
152
164
  }
153
- }, [styles, placement]),
165
+ }, [styles, internalPlacement]),
154
166
  Arrow = _useMemo.Arrow,
155
167
  arrowPlacement = _useMemo.className;
156
168
  var handler = /*#__PURE__*/_jsx(Center
@@ -214,7 +226,8 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
214
226
  return /*#__PURE__*/_jsxs("aside", {
215
227
  className: cx(styles.container,
216
228
  // @ts-ignore
217
- styles[mode === 'fixed' ? 'fixed' : "".concat(placement, "Float")], className),
229
+ styles[mode === 'fixed' ? 'fixed' : "".concat(internalPlacement, "Float")], className),
230
+ dir: dir,
218
231
  ref: reference,
219
232
  style: isExpand ? _defineProperty({}, "border".concat(arrowPlacement, "Width"), 1) : {},
220
233
  children: [expandable && showExpand && handler, destroyOnClose ? isExpand && inner : inner]
@@ -16,7 +16,7 @@ export interface FormGroupProps extends CollapseProps {
16
16
  children: ReactNode;
17
17
  defaultActive?: boolean;
18
18
  extra?: ReactNode;
19
- icon?: IconProps['icon'];
19
+ icon?: IconProps['icon'] | ReactNode;
20
20
  itemsType?: ItemsType;
21
21
  title?: string;
22
22
  variant?: FormVariant;
@@ -56,9 +56,9 @@ var FormGroup = /*#__PURE__*/memo(function (_ref2) {
56
56
  className: styles.title,
57
57
  gap: 8,
58
58
  horizontal: true,
59
- children: [icon && /*#__PURE__*/_jsx(Icon, {
59
+ children: [icon && typeof icon === 'function' ? /*#__PURE__*/_jsx(Icon, {
60
60
  icon: icon
61
- }), title]
61
+ }) : icon, title]
62
62
  });
63
63
  if (itemsType === 'flat') {
64
64
  if (mobile) return /*#__PURE__*/_jsx(Flexbox, {
@@ -10,6 +10,6 @@ export var useStyles = createStyles(function (_ref) {
10
10
  icon: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorTextPlaceholder),
11
11
  input: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n padding: 0 8px 0 12px;\n "]))),
12
12
  search: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n "]))),
13
- tag: cx(stylish.blur, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n pointer-events: none;\n\n position: absolute;\n z-index: 5;\n top: 50%;\n right: 0;\n transform: translateY(-50%);\n\n color: ", ";\n "])), token.colorTextDescription))
13
+ tag: cx(stylish.blur, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n pointer-events: none;\n\n position: absolute;\n z-index: 5;\n inset-block-start: 50%;\n inset-inline-end: 12px;\n transform: translateY(-50%);\n\n color: ", ";\n "])), token.colorTextDescription))
14
14
  };
15
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.128.5",
3
+ "version": "1.128.7",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",