@lobehub/ui 2.18.0 → 2.18.2

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.
@@ -7,7 +7,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
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
9
  import { AnimatePresence, LazyMotion, m } from 'framer-motion';
10
- import { memo, useCallback } from 'react';
10
+ import { memo, useCallback, useMemo } from 'react';
11
11
  import { Flexbox } from 'react-layout-kit';
12
12
  import Block from "../Block";
13
13
  import Text from "../Text";
@@ -41,7 +41,8 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
41
41
  padding = _ref.padding,
42
42
  ref = _ref.ref,
43
43
  customVariant = _ref.variant,
44
- customStyles = _ref.styles;
44
+ customStyles = _ref.styles,
45
+ headerWrapper = _ref.headerWrapper;
45
46
  var _useStyles = useStyles(),
46
47
  cx = _useStyles.cx,
47
48
  styles = _useStyles.styles;
@@ -77,7 +78,7 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
77
78
  }, [disabled, handleToggle]);
78
79
 
79
80
  // Build indicator
80
- var renderIndicator = function renderIndicator() {
81
+ var indicator = useMemo(function () {
81
82
  if (hideIndicatorFinal) return null;
82
83
  if (customIndicator) {
83
84
  if (typeof customIndicator === 'function') {
@@ -106,35 +107,37 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
106
107
  className: cx(styles.icon, isOpen && styles.iconRotate)
107
108
  })
108
109
  });
109
- };
110
+ }, [hideIndicatorFinal, customIndicator, disabled, isOpen, cx, styles, classNames, customStyles]);
110
111
 
111
112
  // Animation variants
112
- var motionProps = _objectSpread({
113
- animate: isOpen ? 'enter' : 'exit',
114
- exit: 'exit',
115
- initial: 'exit',
116
- variants: {
117
- enter: {
118
- height: 'auto',
119
- opacity: 1,
120
- transition: {
121
- duration: 0.2,
122
- ease: [0.4, 0, 0.2, 1]
123
- }
124
- },
125
- exit: {
126
- height: 0,
127
- opacity: 0,
128
- transition: {
129
- duration: 0.2,
130
- ease: [0.4, 0, 0.2, 1]
113
+ var motionProps = useMemo(function () {
114
+ return _objectSpread({
115
+ animate: isOpen ? 'enter' : 'exit',
116
+ exit: 'exit',
117
+ initial: 'exit',
118
+ variants: {
119
+ enter: {
120
+ height: 'auto',
121
+ opacity: 1,
122
+ transition: {
123
+ duration: 0.2,
124
+ ease: [0.4, 0, 0.2, 1]
125
+ }
126
+ },
127
+ exit: {
128
+ height: 0,
129
+ opacity: 0,
130
+ transition: {
131
+ duration: 0.2,
132
+ ease: [0.4, 0, 0.2, 1]
133
+ }
131
134
  }
132
135
  }
133
- }
134
- }, contextMotionProps);
136
+ }, contextMotionProps);
137
+ }, [isOpen, contextMotionProps]);
135
138
 
136
139
  // Render content
137
- var renderContent = function renderContent() {
140
+ var contentElement = useMemo(function () {
138
141
  if (disableAnimation) {
139
142
  if (keepContentMounted) {
140
143
  return /*#__PURE__*/_jsx("div", {
@@ -195,29 +198,31 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
195
198
  }))
196
199
  })
197
200
  });
198
- };
199
- var titleNode = typeof title === 'string' ? /*#__PURE__*/_jsx(Text, {
200
- className: classNames === null || classNames === void 0 ? void 0 : classNames.title,
201
- ellipsis: true,
202
- style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.title,
203
- children: title
204
- }) : title;
205
- var actionNode = action && /*#__PURE__*/_jsx(Flexbox, {
206
- align: 'center',
207
- className: cx('accordion-action', styles.action, classNames === null || classNames === void 0 ? void 0 : classNames.action),
208
- flex: 'none',
209
- gap: 4,
210
- horizontal: true,
211
- onClick: function onClick(e) {
212
- return e.stopPropagation();
213
- },
214
- style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.action,
215
- children: action
216
- });
217
- return /*#__PURE__*/_jsxs("div", {
218
- className: cx('accordion-item', styles.item, classNames === null || classNames === void 0 ? void 0 : classNames.base),
219
- style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.base,
220
- children: [/*#__PURE__*/_jsx(Block, {
201
+ }, [disableAnimation, keepContentMounted, isOpen, cx, styles, classNames, customStyles, children, motionProps]);
202
+ var titleNode = useMemo(function () {
203
+ return typeof title === 'string' ? /*#__PURE__*/_jsx(Text, {
204
+ className: classNames === null || classNames === void 0 ? void 0 : classNames.title,
205
+ ellipsis: true,
206
+ style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.title,
207
+ children: title
208
+ }) : title;
209
+ }, [title, classNames === null || classNames === void 0 ? void 0 : classNames.title, customStyles === null || customStyles === void 0 ? void 0 : customStyles.title]);
210
+ var actionNode = useMemo(function () {
211
+ return action && /*#__PURE__*/_jsx(Flexbox, {
212
+ align: 'center',
213
+ className: cx('accordion-action', styles.action, classNames === null || classNames === void 0 ? void 0 : classNames.action),
214
+ flex: 'none',
215
+ gap: 4,
216
+ horizontal: true,
217
+ onClick: function onClick(e) {
218
+ return e.stopPropagation();
219
+ },
220
+ style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.action,
221
+ children: action
222
+ });
223
+ }, [action, cx, styles, classNames === null || classNames === void 0 ? void 0 : classNames.action, customStyles === null || customStyles === void 0 ? void 0 : customStyles.action]);
224
+ var headerElement = useMemo(function () {
225
+ var header = /*#__PURE__*/_jsx(Block, {
221
226
  className: cx('accordion-header', styles.header, classNames === null || classNames === void 0 ? void 0 : classNames.header),
222
227
  clickable: !disabled,
223
228
  gap: 4,
@@ -246,7 +251,7 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
246
251
  style: {
247
252
  overflow: 'hidden'
248
253
  },
249
- children: [titleNode, renderIndicator()]
254
+ children: [titleNode, indicator]
250
255
  }), /*#__PURE__*/_jsx(Flexbox, {
251
256
  align: 'center',
252
257
  flex: 'none',
@@ -269,10 +274,19 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
269
274
  flex: 'none',
270
275
  gap: 4,
271
276
  horizontal: true,
272
- children: [actionNode, renderIndicator()]
277
+ children: [actionNode, indicator]
273
278
  })]
274
279
  })
275
- }), renderContent()]
280
+ });
281
+ if (headerWrapper) {
282
+ return headerWrapper(header);
283
+ }
284
+ return header;
285
+ }, [cx, styles, classNames, disabled, handleToggle, handleKeyDown, padding, paddingBlock, paddingInline, ref, customVariant, variant, indicatorPlacementFinal, titleNode, indicator, actionNode, headerWrapper]);
286
+ return /*#__PURE__*/_jsxs("div", {
287
+ className: cx('accordion-item', styles.item, classNames === null || classNames === void 0 ? void 0 : classNames.base),
288
+ style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.base,
289
+ children: [headerElement, contentElement]
276
290
  });
277
291
  });
278
292
  AccordionItem.displayName = 'AccordionItem';
@@ -24,6 +24,7 @@ export interface AccordionItemProps extends Pick<BlockProps, 'padding' | 'paddin
24
24
  * Whether the item is disabled
25
25
  */
26
26
  disabled?: boolean;
27
+ headerWrapper?: (header: ReactNode) => ReactNode;
27
28
  /**
28
29
  * Whether to hide the chevron indicator
29
30
  * @default false
@@ -166,9 +166,11 @@ export function escapeCurrencyDollars(text) {
166
166
  // 2. Inline code: `...`
167
167
  // 3. Display math: $$...$$
168
168
  // 4. Inline math with LaTeX commands: $...\...$ (must contain backslash to distinguish from currency)
169
- // 5. LaTeX bracket notation: \[...\]
170
- // 6. LaTeX parenthesis notation: \(...\)
171
- /(```[\S\s]*?```|`[^\n`]*`|\$\$[\S\s]*?\$\$|(?<!\\)\$(?!\$)(?=[\S\s]*?\\)[\S\s]*?(?<!\\)\$(?!\$)|\\\[[\S\s]*?\\]|\\\(.*?\\\))/g, function (match) {
169
+ // 5. Simple number formulas: $1$, $10$, $100$ (pure digits in math mode)
170
+ // 6. Number lists in math mode: $1,-1,0$ or $1,2,3$ (comma-separated numbers, possibly negative)
171
+ // 7. LaTeX bracket notation: \[...\]
172
+ // 8. LaTeX parenthesis notation: \(...\)
173
+ /(```[\S\s]*?```|`[^\n`]*`|\$\$[\S\s]*?\$\$|(?<!\\)\$(?!\$)(?=[\S\s]*?\\)[\S\s]*?(?<!\\)\$(?!\$)|\$\d+\$|\$-?\d+(?:,-?\d+)+\$|\\\[[\S\s]*?\\]|\\\(.*?\\\))/g, function (match) {
172
174
  return manager.add(match);
173
175
  });
174
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "2.18.0",
3
+ "version": "2.18.2",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",