@lobehub/ui 2.20.0 → 2.20.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.
- package/es/Accordion/AccordionItem.js +4 -23
- package/es/Accordion/type.d.ts +1 -1
- package/es/awesome/TypewriterEffect/TypewriterEffect.js +39 -10
- package/es/awesome/TypewriterEffect/index.d.ts +1 -1
- package/es/awesome/TypewriterEffect/type.d.ts +8 -0
- package/es/awesome/index.d.ts +1 -1
- package/es/styles/theme/token/base.js +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ 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
|
-
import {
|
|
9
|
+
import { LazyMotion, m } from 'framer-motion';
|
|
10
10
|
import { memo, useCallback, useMemo } from 'react';
|
|
11
11
|
import { Flexbox } from 'react-layout-kit';
|
|
12
12
|
import Block from "../Block";
|
|
@@ -114,7 +114,7 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
114
114
|
return _objectSpread({
|
|
115
115
|
animate: isOpen ? 'enter' : 'exit',
|
|
116
116
|
exit: 'exit',
|
|
117
|
-
initial:
|
|
117
|
+
initial: false,
|
|
118
118
|
variants: {
|
|
119
119
|
enter: {
|
|
120
120
|
height: 'auto',
|
|
@@ -138,7 +138,7 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
138
138
|
|
|
139
139
|
// Render content
|
|
140
140
|
var contentElement = useMemo(function () {
|
|
141
|
-
if (disableAnimation) {
|
|
141
|
+
if (disableAnimation || !keepContentMounted) {
|
|
142
142
|
if (keepContentMounted) {
|
|
143
143
|
return /*#__PURE__*/_jsx("div", {
|
|
144
144
|
className: cx('accordion-content', styles.content, classNames === null || classNames === void 0 ? void 0 : classNames.content),
|
|
@@ -162,7 +162,7 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
162
162
|
})
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
-
return
|
|
165
|
+
return /*#__PURE__*/_jsx(LazyMotion, {
|
|
166
166
|
features: loadFeatures,
|
|
167
167
|
children: /*#__PURE__*/_jsx(m.div, _objectSpread(_objectSpread({}, motionProps), {}, {
|
|
168
168
|
style: {
|
|
@@ -178,25 +178,6 @@ var AccordionItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
178
178
|
})
|
|
179
179
|
})
|
|
180
180
|
}))
|
|
181
|
-
}) : /*#__PURE__*/_jsx(AnimatePresence, {
|
|
182
|
-
initial: false,
|
|
183
|
-
children: isOpen && /*#__PURE__*/_jsx(LazyMotion, {
|
|
184
|
-
features: loadFeatures,
|
|
185
|
-
children: /*#__PURE__*/_jsx(m.div, _objectSpread(_objectSpread({}, motionProps), {}, {
|
|
186
|
-
style: {
|
|
187
|
-
overflow: 'hidden'
|
|
188
|
-
},
|
|
189
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
190
|
-
className: cx('accordion-content', styles.content, classNames === null || classNames === void 0 ? void 0 : classNames.content),
|
|
191
|
-
role: "region",
|
|
192
|
-
style: customStyles === null || customStyles === void 0 ? void 0 : customStyles.content,
|
|
193
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
194
|
-
className: styles.contentInner,
|
|
195
|
-
children: children
|
|
196
|
-
})
|
|
197
|
-
})
|
|
198
|
-
}))
|
|
199
|
-
})
|
|
200
181
|
});
|
|
201
182
|
}, [disableAnimation, keepContentMounted, isOpen, cx, styles, classNames, customStyles, children, motionProps]);
|
|
202
183
|
var titleNode = useMemo(function () {
|
package/es/Accordion/type.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ export interface AccordionProps extends Omit<HTMLAttributes<HTMLDivElement>, 'on
|
|
|
107
107
|
indicatorPlacement?: 'end' | 'start';
|
|
108
108
|
/**
|
|
109
109
|
* Keep content mounted when collapsed
|
|
110
|
-
* @default
|
|
110
|
+
* @default true
|
|
111
111
|
*/
|
|
112
112
|
keepContentMounted?: boolean;
|
|
113
113
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
|
-
var _excluded = ["sentences", "as", "typingSpeed", "initialDelay", "pauseDuration", "deletingSpeed", "deletePauseDuration", "loop", "className", "color", "showCursor", "hideCursorWhileTyping", "cursorCharacter", "cursorClassName", "cursorColor", "cursorBlinkDuration", "cursorFade", "cursorStyle", "textColors", "variableSpeed", "onSentenceComplete", "startOnVisible", "reverseMode"];
|
|
4
|
+
var _excluded = ["sentences", "as", "typingSpeed", "initialDelay", "pauseDuration", "deletingSpeed", "deletePauseDuration", "loop", "className", "color", "showCursor", "hideCursorWhileTyping", "cursorCharacter", "cursorClassName", "cursorColor", "cursorBlinkDuration", "cursorFade", "cursorStyle", "textColors", "variableSpeed", "onSentenceComplete", "startOnVisible", "reverseMode", "segmentMode"];
|
|
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; }
|
|
7
7
|
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; }
|
|
@@ -62,6 +62,8 @@ var TypewriterEffect = /*#__PURE__*/memo(function (_ref) {
|
|
|
62
62
|
startOnVisible = _ref$startOnVisible === void 0 ? false : _ref$startOnVisible,
|
|
63
63
|
_ref$reverseMode = _ref.reverseMode,
|
|
64
64
|
reverseMode = _ref$reverseMode === void 0 ? false : _ref$reverseMode,
|
|
65
|
+
_ref$segmentMode = _ref.segmentMode,
|
|
66
|
+
segmentMode = _ref$segmentMode === void 0 ? 'grapheme' : _ref$segmentMode,
|
|
65
67
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
66
68
|
var _useStyles = useStyles(),
|
|
67
69
|
styles = _useStyles.styles,
|
|
@@ -94,6 +96,28 @@ var TypewriterEffect = /*#__PURE__*/memo(function (_ref) {
|
|
|
94
96
|
var textArray = useMemo(function () {
|
|
95
97
|
return Array.isArray(sentences) ? sentences : [sentences];
|
|
96
98
|
}, [sentences]);
|
|
99
|
+
|
|
100
|
+
// Helper function to split text based on segment mode
|
|
101
|
+
var splitText = useCallback(function (text) {
|
|
102
|
+
// Use Intl.Segmenter if available
|
|
103
|
+
if (typeof Intl !== 'undefined' && 'Segmenter' in Intl) {
|
|
104
|
+
var segmenter = new Intl.Segmenter(undefined, {
|
|
105
|
+
granularity: segmentMode
|
|
106
|
+
});
|
|
107
|
+
return Array.from(segmenter.segment(text), function (segment) {
|
|
108
|
+
return segment.segment;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Fallback when Intl.Segmenter is not available
|
|
113
|
+
if (segmentMode === 'word') {
|
|
114
|
+
// Simple word splitting fallback
|
|
115
|
+
return text.split(/(\s+)/).filter(Boolean);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Grapheme fallback
|
|
119
|
+
return Array.from(text);
|
|
120
|
+
}, [segmentMode]);
|
|
97
121
|
var getRandomSpeed = useCallback(function () {
|
|
98
122
|
if (!variableSpeed) return typingSpeed;
|
|
99
123
|
var min = variableSpeed.min,
|
|
@@ -129,7 +153,9 @@ var TypewriterEffect = /*#__PURE__*/memo(function (_ref) {
|
|
|
129
153
|
if (!isVisible) return;
|
|
130
154
|
var timeout;
|
|
131
155
|
var currentText = textArray[currentTextIndex];
|
|
132
|
-
|
|
156
|
+
// Split text based on segment mode
|
|
157
|
+
var textSegments = splitText(currentText);
|
|
158
|
+
var processedText = reverseMode ? textSegments.reverse().join('') : currentText;
|
|
133
159
|
|
|
134
160
|
// Handle delete pause state
|
|
135
161
|
if (isDeletePausing) {
|
|
@@ -161,15 +187,17 @@ var TypewriterEffect = /*#__PURE__*/memo(function (_ref) {
|
|
|
161
187
|
} else {
|
|
162
188
|
timeout = setTimeout(function () {
|
|
163
189
|
setDisplayedText(function (prev) {
|
|
164
|
-
|
|
190
|
+
var segments = splitText(prev);
|
|
191
|
+
return segments.slice(0, -1).join('');
|
|
165
192
|
});
|
|
166
193
|
}, deletingSpeed);
|
|
167
194
|
}
|
|
168
195
|
} else {
|
|
169
|
-
|
|
196
|
+
var processedSegments = splitText(processedText);
|
|
197
|
+
if (currentCharIndex < processedSegments.length) {
|
|
170
198
|
timeout = setTimeout(function () {
|
|
171
199
|
setDisplayedText(function (prev) {
|
|
172
|
-
return prev +
|
|
200
|
+
return prev + processedSegments[currentCharIndex];
|
|
173
201
|
});
|
|
174
202
|
setCurrentCharIndex(function (prev) {
|
|
175
203
|
return prev + 1;
|
|
@@ -191,7 +219,7 @@ var TypewriterEffect = /*#__PURE__*/memo(function (_ref) {
|
|
|
191
219
|
return function () {
|
|
192
220
|
return clearTimeout(timeout);
|
|
193
221
|
};
|
|
194
|
-
}, [currentCharIndex, displayedText, isDeleting, isDeletePausing, typingSpeed, deletingSpeed, deletePauseDuration, pauseDuration, textArray, currentTextIndex, loop, initialDelay, isVisible, reverseMode, variableSpeed, onSentenceComplete, getRandomSpeed]);
|
|
222
|
+
}, [currentCharIndex, displayedText, isDeleting, isDeletePausing, typingSpeed, deletingSpeed, deletePauseDuration, pauseDuration, textArray, currentTextIndex, loop, initialDelay, isVisible, reverseMode, variableSpeed, onSentenceComplete, getRandomSpeed, splitText]);
|
|
195
223
|
var getCursorStyle = function getCursorStyle() {
|
|
196
224
|
if (cursorCharacter) return styles.cursorCustom;
|
|
197
225
|
switch (cursorStyle) {
|
|
@@ -213,8 +241,9 @@ var TypewriterEffect = /*#__PURE__*/memo(function (_ref) {
|
|
|
213
241
|
}
|
|
214
242
|
}
|
|
215
243
|
};
|
|
216
|
-
var
|
|
217
|
-
var
|
|
244
|
+
var currentTextLength = splitText(textArray[currentTextIndex]).length;
|
|
245
|
+
var isTyping = currentCharIndex < currentTextLength && !isDeleting;
|
|
246
|
+
var isAfterTyping = currentCharIndex === currentTextLength && !isDeleting;
|
|
218
247
|
var shouldHideCursor = function () {
|
|
219
248
|
if (hideCursorWhileTyping === true) return true; // 完全隐藏
|
|
220
249
|
if (hideCursorWhileTyping === 'typing') return isTyping || isDeleting; // 打字和删除时隐藏
|
|
@@ -224,8 +253,8 @@ var TypewriterEffect = /*#__PURE__*/memo(function (_ref) {
|
|
|
224
253
|
var textColor = getCurrentTextColor();
|
|
225
254
|
var finalCursorColor = getCurrentCursorColor();
|
|
226
255
|
|
|
227
|
-
// Split displayed text
|
|
228
|
-
var characters = displayedText
|
|
256
|
+
// Split displayed text for animation
|
|
257
|
+
var characters = splitText(displayedText);
|
|
229
258
|
return /*#__PURE__*/createElement(Component, _objectSpread({
|
|
230
259
|
className: cx(styles.container, className),
|
|
231
260
|
ref: containerRef
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { CursorStyle, TypewriterEffectProps } from './type';
|
|
1
|
+
export type { CursorStyle, SegmentMode, TypewriterEffectProps } from './type';
|
|
2
2
|
export { default } from './TypewriterEffect';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ElementType, ReactNode } from 'react';
|
|
2
2
|
export type CursorStyle = 'pipe' | 'underscore' | 'dot' | 'block';
|
|
3
|
+
export type SegmentMode = 'grapheme' | 'word';
|
|
3
4
|
export interface TypewriterEffectProps {
|
|
4
5
|
/**
|
|
5
6
|
* Custom element type for the container
|
|
@@ -85,6 +86,13 @@ export interface TypewriterEffectProps {
|
|
|
85
86
|
* @default false
|
|
86
87
|
*/
|
|
87
88
|
reverseMode?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Segment mode for text splitting
|
|
91
|
+
* - 'grapheme': split by character (emoji-safe)
|
|
92
|
+
* - 'word': split by word
|
|
93
|
+
* @default 'grapheme'
|
|
94
|
+
*/
|
|
95
|
+
segmentMode?: SegmentMode;
|
|
88
96
|
/**
|
|
89
97
|
* Array of sentences to display
|
|
90
98
|
*/
|
package/es/awesome/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export { default as GridBackground, type GridBackgroundProps, GridShowcase, type
|
|
|
7
7
|
export { default as Hero, type HeroAction, type HeroProps } from './Hero';
|
|
8
8
|
export { default as Spotlight, type SpotlightProps } from './Spotlight';
|
|
9
9
|
export { default as SpotlightCard, type SpotlightCardProps } from './SpotlightCard';
|
|
10
|
-
export { type CursorStyle, default as TypewriterEffect, type TypewriterEffectProps, } from './TypewriterEffect';
|
|
10
|
+
export { type CursorStyle, type SegmentMode, default as TypewriterEffect, type TypewriterEffectProps, } from './TypewriterEffect';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var FONT_EMOJI = "\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Apple Color Emoji\",\"Twemoji Mozilla\",\"Noto Color Emoji\",\"Android Emoji\"";
|
|
2
2
|
var FONT_EN = "\"HarmonyOS Sans\",\"Segoe UI\",\"SF Pro Display\",-apple-system,BlinkMacSystemFont,Roboto,Oxygen,Ubuntu,Cantarell,\"Open Sans\",\"Helvetica Neue\",sans-serif";
|
|
3
3
|
var FONT_CN = "\"HarmonyOS Sans SC\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft Yahei UI\",\"Microsoft Yahei\",\"Source Han Sans CN\",sans-serif";
|
|
4
|
-
var FONT_CODE = "Hack,ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas
|
|
4
|
+
var FONT_CODE = "Hack,ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas";
|
|
5
5
|
export var baseToken = {
|
|
6
6
|
borderRadius: 8,
|
|
7
7
|
borderRadiusLG: 12,
|