@ant-design/agentic-ui 2.0.17 → 2.0.20
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/dist/Bubble/FileView.js +1 -1
- package/dist/Bubble/type.d.ts +2 -2
- package/dist/ChatBootPage/ButtonTabStyle.js +2 -2
- package/dist/ChatBootPage/CaseReply.d.ts +10 -2
- package/dist/ChatBootPage/CaseReply.js +20 -2
- package/dist/ChatBootPage/CaseReplyStyle.js +51 -9
- package/dist/Components/ActionIconBox/index.js +102 -46
- package/dist/Components/Button/ToggleButton/index.js +3 -3
- package/dist/Components/Button/ToggleButton/style.js +1 -1
- package/dist/Components/GradientText/index.d.ts +8 -0
- package/dist/Components/GradientText/index.js +32 -0
- package/dist/Components/GradientText/style.d.ts +5 -0
- package/dist/Components/GradientText/style.js +76 -0
- package/dist/Components/TextAnimate/index.d.ts +56 -0
- package/dist/Components/TextAnimate/index.js +388 -0
- package/dist/Components/TextAnimate/style.d.ts +5 -0
- package/dist/Components/TextAnimate/style.js +53 -0
- package/dist/Components/TypingAnimation/index.d.ts +19 -0
- package/dist/Components/TypingAnimation/index.js +182 -0
- package/dist/Components/TypingAnimation/style.d.ts +5 -0
- package/dist/Components/TypingAnimation/style.js +59 -0
- package/dist/Components/lotties/ShinyText/index.d.ts +69 -0
- package/dist/Components/lotties/ShinyText/index.js +60 -0
- package/dist/Components/lotties/ShinyText/style.d.ts +5 -0
- package/dist/Components/lotties/ShinyText/style.js +84 -0
- package/dist/Components/lotties/index.d.ts +1 -2
- package/dist/Components/lotties/index.js +1 -2
- package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +6 -32
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/style.js +1 -1
- package/dist/MarkdownInputField/AttachmentButton/index.js +5 -3
- package/dist/MarkdownInputField/FileMapView/FileMapViewItem.d.ts +2 -2
- package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +166 -152
- package/dist/MarkdownInputField/FileMapView/index.d.ts +3 -3
- package/dist/MarkdownInputField/FileMapView/index.js +12 -26
- package/dist/MarkdownInputField/FileMapView/style.js +8 -3
- package/dist/MarkdownInputField/MarkdownInputField.js +156 -174
- package/dist/MarkdownInputField/QuickActions/index.js +6 -0
- package/dist/MarkdownInputField/VoiceInput/index.js +2 -1
- package/dist/MarkdownInputField/style.js +5 -9
- package/dist/WelcomeMessage/index.d.ts +12 -2
- package/dist/WelcomeMessage/index.js +40 -4
- package/dist/WelcomeMessage/style.js +1 -0
- package/dist/Workspace/File/FileComponent.js +23 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +4 -4
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/Components/TextAnimate/index.tsx
|
|
34
|
+
import { ConfigProvider } from "antd";
|
|
35
|
+
import classNames from "classnames";
|
|
36
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
37
|
+
import { isString } from "lodash";
|
|
38
|
+
import toArray from "rc-util/lib/Children/toArray";
|
|
39
|
+
import React, { memo, useContext } from "react";
|
|
40
|
+
import { useTextAnimateStyle } from "./style";
|
|
41
|
+
var staggerTimings = {
|
|
42
|
+
text: 0.06,
|
|
43
|
+
word: 0.05,
|
|
44
|
+
character: 0.03,
|
|
45
|
+
line: 0.06,
|
|
46
|
+
mix: 0.06
|
|
47
|
+
};
|
|
48
|
+
var defaultContainerVariants = {
|
|
49
|
+
hidden: { opacity: 1 },
|
|
50
|
+
show: {
|
|
51
|
+
opacity: 1,
|
|
52
|
+
transition: {
|
|
53
|
+
delayChildren: 0,
|
|
54
|
+
staggerChildren: 0.05
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
exit: {
|
|
58
|
+
opacity: 0,
|
|
59
|
+
transition: {
|
|
60
|
+
staggerChildren: 0.05,
|
|
61
|
+
staggerDirection: -1
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var defaultItemVariants = {
|
|
66
|
+
hidden: { opacity: 0 },
|
|
67
|
+
show: {
|
|
68
|
+
opacity: 1
|
|
69
|
+
},
|
|
70
|
+
exit: {
|
|
71
|
+
opacity: 0
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var defaultItemAnimationVariants = {
|
|
75
|
+
fadeIn: {
|
|
76
|
+
container: defaultContainerVariants,
|
|
77
|
+
item: {
|
|
78
|
+
hidden: { opacity: 0, y: 20 },
|
|
79
|
+
show: {
|
|
80
|
+
opacity: 1,
|
|
81
|
+
y: 0,
|
|
82
|
+
transition: {
|
|
83
|
+
duration: 0.3
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
exit: {
|
|
87
|
+
opacity: 0,
|
|
88
|
+
y: 20,
|
|
89
|
+
transition: { duration: 0.3 }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
blurIn: {
|
|
94
|
+
container: defaultContainerVariants,
|
|
95
|
+
item: {
|
|
96
|
+
hidden: { opacity: 0, filter: "blur(10px)" },
|
|
97
|
+
show: {
|
|
98
|
+
opacity: 1,
|
|
99
|
+
filter: "blur(0px)",
|
|
100
|
+
transition: {
|
|
101
|
+
duration: 0.3
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
exit: {
|
|
105
|
+
opacity: 0,
|
|
106
|
+
filter: "blur(10px)",
|
|
107
|
+
transition: { duration: 0.3 }
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
blurInUp: {
|
|
112
|
+
container: defaultContainerVariants,
|
|
113
|
+
item: {
|
|
114
|
+
hidden: { opacity: 0, filter: "blur(10px)", y: 20 },
|
|
115
|
+
show: {
|
|
116
|
+
opacity: 1,
|
|
117
|
+
filter: "blur(0px)",
|
|
118
|
+
y: 0,
|
|
119
|
+
transition: {
|
|
120
|
+
y: { duration: 0.3 },
|
|
121
|
+
opacity: { duration: 0.4 },
|
|
122
|
+
filter: { duration: 0.3 }
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
exit: {
|
|
126
|
+
opacity: 0,
|
|
127
|
+
filter: "blur(10px)",
|
|
128
|
+
y: 20,
|
|
129
|
+
transition: {
|
|
130
|
+
y: { duration: 0.3 },
|
|
131
|
+
opacity: { duration: 0.4 },
|
|
132
|
+
filter: { duration: 0.3 }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
blurInDown: {
|
|
138
|
+
container: defaultContainerVariants,
|
|
139
|
+
item: {
|
|
140
|
+
hidden: { opacity: 0, filter: "blur(10px)", y: -20 },
|
|
141
|
+
show: {
|
|
142
|
+
opacity: 1,
|
|
143
|
+
filter: "blur(0px)",
|
|
144
|
+
y: 0,
|
|
145
|
+
transition: {
|
|
146
|
+
y: { duration: 0.3 },
|
|
147
|
+
opacity: { duration: 0.4 },
|
|
148
|
+
filter: { duration: 0.3 }
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
slideUp: {
|
|
154
|
+
container: defaultContainerVariants,
|
|
155
|
+
item: {
|
|
156
|
+
hidden: { y: 20, opacity: 0 },
|
|
157
|
+
show: {
|
|
158
|
+
y: 0,
|
|
159
|
+
opacity: 1,
|
|
160
|
+
transition: {
|
|
161
|
+
duration: 0.3
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
exit: {
|
|
165
|
+
y: -20,
|
|
166
|
+
opacity: 0,
|
|
167
|
+
transition: {
|
|
168
|
+
duration: 0.3
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
slideDown: {
|
|
174
|
+
container: defaultContainerVariants,
|
|
175
|
+
item: {
|
|
176
|
+
hidden: { y: -20, opacity: 0 },
|
|
177
|
+
show: {
|
|
178
|
+
y: 0,
|
|
179
|
+
opacity: 1,
|
|
180
|
+
transition: { duration: 0.3 }
|
|
181
|
+
},
|
|
182
|
+
exit: {
|
|
183
|
+
y: 20,
|
|
184
|
+
opacity: 0,
|
|
185
|
+
transition: { duration: 0.3 }
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
slideLeft: {
|
|
190
|
+
container: defaultContainerVariants,
|
|
191
|
+
item: {
|
|
192
|
+
hidden: { x: 20, opacity: 0 },
|
|
193
|
+
show: {
|
|
194
|
+
x: 0,
|
|
195
|
+
opacity: 1,
|
|
196
|
+
transition: { duration: 0.3 }
|
|
197
|
+
},
|
|
198
|
+
exit: {
|
|
199
|
+
x: -20,
|
|
200
|
+
opacity: 0,
|
|
201
|
+
transition: { duration: 0.3 }
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
slideRight: {
|
|
206
|
+
container: defaultContainerVariants,
|
|
207
|
+
item: {
|
|
208
|
+
hidden: { x: -20, opacity: 0 },
|
|
209
|
+
show: {
|
|
210
|
+
x: 0,
|
|
211
|
+
opacity: 1,
|
|
212
|
+
transition: { duration: 0.3 }
|
|
213
|
+
},
|
|
214
|
+
exit: {
|
|
215
|
+
x: 20,
|
|
216
|
+
opacity: 0,
|
|
217
|
+
transition: { duration: 0.3 }
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
scaleUp: {
|
|
222
|
+
container: defaultContainerVariants,
|
|
223
|
+
item: {
|
|
224
|
+
hidden: { scale: 0.5, opacity: 0 },
|
|
225
|
+
show: {
|
|
226
|
+
scale: 1,
|
|
227
|
+
opacity: 1,
|
|
228
|
+
transition: {
|
|
229
|
+
duration: 0.3,
|
|
230
|
+
scale: {
|
|
231
|
+
type: "spring",
|
|
232
|
+
damping: 15,
|
|
233
|
+
stiffness: 300
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
exit: {
|
|
238
|
+
scale: 0.5,
|
|
239
|
+
opacity: 0,
|
|
240
|
+
transition: { duration: 0.3 }
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
scaleDown: {
|
|
245
|
+
container: defaultContainerVariants,
|
|
246
|
+
item: {
|
|
247
|
+
hidden: { scale: 1.5, opacity: 0 },
|
|
248
|
+
show: {
|
|
249
|
+
scale: 1,
|
|
250
|
+
opacity: 1,
|
|
251
|
+
transition: {
|
|
252
|
+
duration: 0.3,
|
|
253
|
+
scale: {
|
|
254
|
+
type: "spring",
|
|
255
|
+
damping: 15,
|
|
256
|
+
stiffness: 300
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
exit: {
|
|
261
|
+
scale: 1.5,
|
|
262
|
+
opacity: 0,
|
|
263
|
+
transition: { duration: 0.3 }
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
var resolveSegments = (children, by) => {
|
|
269
|
+
if (!isString(children))
|
|
270
|
+
return toArray(children);
|
|
271
|
+
switch (by) {
|
|
272
|
+
case "word":
|
|
273
|
+
return children.split(/(\s+)/);
|
|
274
|
+
case "character":
|
|
275
|
+
return children.split("");
|
|
276
|
+
case "line":
|
|
277
|
+
return children.split("\n");
|
|
278
|
+
case "text":
|
|
279
|
+
default:
|
|
280
|
+
return [children];
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
var TextAnimateBase = (_a) => {
|
|
284
|
+
var _b = _a, {
|
|
285
|
+
children,
|
|
286
|
+
delay = 0,
|
|
287
|
+
duration = 0.3,
|
|
288
|
+
variants,
|
|
289
|
+
className,
|
|
290
|
+
segmentClassName,
|
|
291
|
+
as: Component = "p",
|
|
292
|
+
startOnView = true,
|
|
293
|
+
once = false,
|
|
294
|
+
by = "word",
|
|
295
|
+
animation = "fadeIn",
|
|
296
|
+
accessible = true
|
|
297
|
+
} = _b, props = __objRest(_b, [
|
|
298
|
+
"children",
|
|
299
|
+
"delay",
|
|
300
|
+
"duration",
|
|
301
|
+
"variants",
|
|
302
|
+
"className",
|
|
303
|
+
"segmentClassName",
|
|
304
|
+
"as",
|
|
305
|
+
"startOnView",
|
|
306
|
+
"once",
|
|
307
|
+
"by",
|
|
308
|
+
"animation",
|
|
309
|
+
"accessible"
|
|
310
|
+
]);
|
|
311
|
+
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
|
|
312
|
+
const prefixCls = getPrefixCls("text-animate");
|
|
313
|
+
const { wrapSSR, hashId } = useTextAnimateStyle(prefixCls);
|
|
314
|
+
const MotionComponent = motion(Component);
|
|
315
|
+
const segments = resolveSegments(children, by);
|
|
316
|
+
const staggerChildren = segments.length > 0 ? duration / segments.length : 0;
|
|
317
|
+
const finalVariants = variants ? {
|
|
318
|
+
container: {
|
|
319
|
+
hidden: { opacity: 0 },
|
|
320
|
+
show: {
|
|
321
|
+
opacity: 1,
|
|
322
|
+
transition: {
|
|
323
|
+
opacity: { duration: 0.01, delay },
|
|
324
|
+
delayChildren: delay,
|
|
325
|
+
staggerChildren
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
exit: {
|
|
329
|
+
opacity: 0,
|
|
330
|
+
transition: {
|
|
331
|
+
staggerChildren,
|
|
332
|
+
staggerDirection: -1
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
item: variants
|
|
337
|
+
} : animation ? {
|
|
338
|
+
container: __spreadProps(__spreadValues({}, defaultItemAnimationVariants[animation].container), {
|
|
339
|
+
show: __spreadProps(__spreadValues({}, defaultItemAnimationVariants[animation].container.show), {
|
|
340
|
+
transition: {
|
|
341
|
+
delayChildren: delay,
|
|
342
|
+
staggerChildren
|
|
343
|
+
}
|
|
344
|
+
}),
|
|
345
|
+
exit: __spreadProps(__spreadValues({}, defaultItemAnimationVariants[animation].container.exit), {
|
|
346
|
+
transition: {
|
|
347
|
+
staggerChildren,
|
|
348
|
+
staggerDirection: -1
|
|
349
|
+
}
|
|
350
|
+
})
|
|
351
|
+
}),
|
|
352
|
+
item: defaultItemAnimationVariants[animation].item
|
|
353
|
+
} : { container: defaultContainerVariants, item: defaultItemVariants };
|
|
354
|
+
return wrapSSR(
|
|
355
|
+
/* @__PURE__ */ React.createElement(AnimatePresence, { mode: "popLayout" }, /* @__PURE__ */ React.createElement(
|
|
356
|
+
MotionComponent,
|
|
357
|
+
__spreadValues({
|
|
358
|
+
variants: finalVariants.container,
|
|
359
|
+
initial: "hidden",
|
|
360
|
+
whileInView: startOnView ? "show" : void 0,
|
|
361
|
+
animate: startOnView ? void 0 : "show",
|
|
362
|
+
exit: "exit",
|
|
363
|
+
className: classNames(prefixCls, hashId, className),
|
|
364
|
+
viewport: { once },
|
|
365
|
+
"aria-label": accessible && isString(children) ? children : void 0
|
|
366
|
+
}, props),
|
|
367
|
+
segments.map((segment, i) => /* @__PURE__ */ React.createElement(
|
|
368
|
+
motion.span,
|
|
369
|
+
{
|
|
370
|
+
key: `${by}-${isString(segment) ? segment : segment == null ? void 0 : segment.key}-${i}`,
|
|
371
|
+
variants: finalVariants.item,
|
|
372
|
+
custom: i * staggerTimings[by],
|
|
373
|
+
className: classNames(
|
|
374
|
+
`${prefixCls}-item-${by}`,
|
|
375
|
+
hashId,
|
|
376
|
+
segmentClassName
|
|
377
|
+
),
|
|
378
|
+
"aria-hidden": accessible ? true : void 0
|
|
379
|
+
},
|
|
380
|
+
segment
|
|
381
|
+
))
|
|
382
|
+
))
|
|
383
|
+
);
|
|
384
|
+
};
|
|
385
|
+
var TextAnimate = memo(TextAnimateBase);
|
|
386
|
+
export {
|
|
387
|
+
TextAnimate
|
|
388
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// src/Components/TextAnimate/style.ts
|
|
22
|
+
import {
|
|
23
|
+
useEditorStyleRegister
|
|
24
|
+
} from "../../Hooks/useStyle";
|
|
25
|
+
var genStyle = (token) => {
|
|
26
|
+
return {
|
|
27
|
+
[token.componentCls]: {
|
|
28
|
+
whiteSpace: "pre-wrap",
|
|
29
|
+
["&-item"]: {
|
|
30
|
+
display: "inline-block",
|
|
31
|
+
whiteSpace: "pre-wrap"
|
|
32
|
+
},
|
|
33
|
+
["&-item-character"]: {
|
|
34
|
+
whiteSpace: "pre-wrap"
|
|
35
|
+
},
|
|
36
|
+
["&-item-line"]: {
|
|
37
|
+
display: "block",
|
|
38
|
+
whiteSpace: "normal"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var useTextAnimateStyle = (prefixCls) => {
|
|
44
|
+
return useEditorStyleRegister("text-animate", (token) => {
|
|
45
|
+
const textAnimateToken = __spreadProps(__spreadValues({}, token), {
|
|
46
|
+
componentCls: `.${prefixCls}`
|
|
47
|
+
});
|
|
48
|
+
return [genStyle(textAnimateToken)];
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
useTextAnimateStyle
|
|
53
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MotionProps } from 'framer-motion';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface TypingAnimationProps extends MotionProps {
|
|
4
|
+
children?: string;
|
|
5
|
+
words?: string[];
|
|
6
|
+
className?: string;
|
|
7
|
+
duration?: number;
|
|
8
|
+
typeSpeed?: number;
|
|
9
|
+
deleteSpeed?: number;
|
|
10
|
+
delay?: number;
|
|
11
|
+
pauseDelay?: number;
|
|
12
|
+
loop?: boolean;
|
|
13
|
+
as?: React.ElementType;
|
|
14
|
+
startOnView?: boolean;
|
|
15
|
+
showCursor?: boolean;
|
|
16
|
+
blinkCursor?: boolean;
|
|
17
|
+
cursorStyle?: 'line' | 'block' | 'underscore';
|
|
18
|
+
}
|
|
19
|
+
export declare function TypingAnimation({ children, words, className, duration, typeSpeed, deleteSpeed, delay, pauseDelay, loop, as: Component, startOnView, showCursor, blinkCursor, cursorStyle, ...props }: TypingAnimationProps): React.JSX.Element;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/Components/TypingAnimation/index.tsx
|
|
31
|
+
import { ConfigProvider } from "antd";
|
|
32
|
+
import classNames from "classnames";
|
|
33
|
+
import { motion, useInView } from "framer-motion";
|
|
34
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
35
|
+
import { useTypingAnimationStyle } from "./style";
|
|
36
|
+
function TypingAnimation(_a) {
|
|
37
|
+
var _b = _a, {
|
|
38
|
+
children,
|
|
39
|
+
words,
|
|
40
|
+
className,
|
|
41
|
+
duration = 100,
|
|
42
|
+
typeSpeed,
|
|
43
|
+
deleteSpeed,
|
|
44
|
+
delay = 0,
|
|
45
|
+
pauseDelay = 1e3,
|
|
46
|
+
loop = false,
|
|
47
|
+
as: Component = "span",
|
|
48
|
+
startOnView = true,
|
|
49
|
+
showCursor = true,
|
|
50
|
+
blinkCursor = true,
|
|
51
|
+
cursorStyle = "line"
|
|
52
|
+
} = _b, props = __objRest(_b, [
|
|
53
|
+
"children",
|
|
54
|
+
"words",
|
|
55
|
+
"className",
|
|
56
|
+
"duration",
|
|
57
|
+
"typeSpeed",
|
|
58
|
+
"deleteSpeed",
|
|
59
|
+
"delay",
|
|
60
|
+
"pauseDelay",
|
|
61
|
+
"loop",
|
|
62
|
+
"as",
|
|
63
|
+
"startOnView",
|
|
64
|
+
"showCursor",
|
|
65
|
+
"blinkCursor",
|
|
66
|
+
"cursorStyle"
|
|
67
|
+
]);
|
|
68
|
+
const MotionComponent = motion(Component, {
|
|
69
|
+
forwardMotionProps: true
|
|
70
|
+
});
|
|
71
|
+
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
|
|
72
|
+
const prefixCls = getPrefixCls("typing-animation");
|
|
73
|
+
const { wrapSSR, hashId } = useTypingAnimationStyle(prefixCls);
|
|
74
|
+
const [displayedText, setDisplayedText] = useState("");
|
|
75
|
+
const [currentWordIndex, setCurrentWordIndex] = useState(0);
|
|
76
|
+
const [currentCharIndex, setCurrentCharIndex] = useState(0);
|
|
77
|
+
const [phase, setPhase] = useState("typing");
|
|
78
|
+
const elementRef = useRef(null);
|
|
79
|
+
const isInView = useInView(elementRef, {
|
|
80
|
+
amount: 0.3,
|
|
81
|
+
once: true
|
|
82
|
+
});
|
|
83
|
+
const wordsToAnimate = useMemo(
|
|
84
|
+
() => words || (children ? [children] : []),
|
|
85
|
+
[words, children]
|
|
86
|
+
);
|
|
87
|
+
const hasMultipleWords = wordsToAnimate.length > 1;
|
|
88
|
+
const typingSpeed = typeSpeed || duration;
|
|
89
|
+
const deletingSpeed = deleteSpeed || typingSpeed / 2;
|
|
90
|
+
const shouldStart = startOnView ? isInView : true;
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!shouldStart || wordsToAnimate.length === 0)
|
|
93
|
+
return;
|
|
94
|
+
const timeoutDelay = delay > 0 && displayedText === "" ? delay : phase === "typing" ? typingSpeed : phase === "deleting" ? deletingSpeed : pauseDelay;
|
|
95
|
+
const timeout = setTimeout(() => {
|
|
96
|
+
const currentWord = wordsToAnimate[currentWordIndex] || "";
|
|
97
|
+
const graphemes = Array.from(currentWord);
|
|
98
|
+
switch (phase) {
|
|
99
|
+
case "typing":
|
|
100
|
+
if (currentCharIndex < graphemes.length) {
|
|
101
|
+
setDisplayedText(graphemes.slice(0, currentCharIndex + 1).join(""));
|
|
102
|
+
setCurrentCharIndex(currentCharIndex + 1);
|
|
103
|
+
} else {
|
|
104
|
+
if (hasMultipleWords || loop) {
|
|
105
|
+
const isLastWord = currentWordIndex === wordsToAnimate.length - 1;
|
|
106
|
+
if (!isLastWord || loop) {
|
|
107
|
+
setPhase("pause");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
case "pause":
|
|
113
|
+
setPhase("deleting");
|
|
114
|
+
break;
|
|
115
|
+
case "deleting":
|
|
116
|
+
if (currentCharIndex > 0) {
|
|
117
|
+
setDisplayedText(graphemes.slice(0, currentCharIndex - 1).join(""));
|
|
118
|
+
setCurrentCharIndex(currentCharIndex - 1);
|
|
119
|
+
} else {
|
|
120
|
+
const nextIndex = (currentWordIndex + 1) % wordsToAnimate.length;
|
|
121
|
+
setCurrentWordIndex(nextIndex);
|
|
122
|
+
setPhase("typing");
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}, timeoutDelay);
|
|
127
|
+
return () => clearTimeout(timeout);
|
|
128
|
+
}, [
|
|
129
|
+
shouldStart,
|
|
130
|
+
phase,
|
|
131
|
+
currentCharIndex,
|
|
132
|
+
currentWordIndex,
|
|
133
|
+
displayedText,
|
|
134
|
+
wordsToAnimate,
|
|
135
|
+
hasMultipleWords,
|
|
136
|
+
loop,
|
|
137
|
+
typingSpeed,
|
|
138
|
+
deletingSpeed,
|
|
139
|
+
pauseDelay,
|
|
140
|
+
delay
|
|
141
|
+
]);
|
|
142
|
+
const currentWordGraphemes = Array.from(
|
|
143
|
+
wordsToAnimate[currentWordIndex] || ""
|
|
144
|
+
);
|
|
145
|
+
const isComplete = !loop && currentWordIndex === wordsToAnimate.length - 1 && currentCharIndex >= currentWordGraphemes.length && phase !== "deleting";
|
|
146
|
+
const shouldShowCursor = showCursor && !isComplete && (hasMultipleWords || loop || currentCharIndex < currentWordGraphemes.length);
|
|
147
|
+
const getCursorChar = () => {
|
|
148
|
+
switch (cursorStyle) {
|
|
149
|
+
case "block":
|
|
150
|
+
return "▌";
|
|
151
|
+
case "underscore":
|
|
152
|
+
return "_";
|
|
153
|
+
case "line":
|
|
154
|
+
default:
|
|
155
|
+
return "|";
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
return wrapSSR(
|
|
159
|
+
/* @__PURE__ */ React.createElement(
|
|
160
|
+
MotionComponent,
|
|
161
|
+
__spreadValues({
|
|
162
|
+
ref: elementRef,
|
|
163
|
+
className: classNames(prefixCls, hashId, className)
|
|
164
|
+
}, props),
|
|
165
|
+
displayedText,
|
|
166
|
+
shouldShowCursor && /* @__PURE__ */ React.createElement(
|
|
167
|
+
"span",
|
|
168
|
+
{
|
|
169
|
+
className: classNames(
|
|
170
|
+
`${prefixCls}-cursor`,
|
|
171
|
+
hashId,
|
|
172
|
+
blinkCursor && `${prefixCls}-cursor-blinking`
|
|
173
|
+
)
|
|
174
|
+
},
|
|
175
|
+
getCursorChar()
|
|
176
|
+
)
|
|
177
|
+
)
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
TypingAnimation
|
|
182
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
// src/Components/TypingAnimation/style.ts
|
|
22
|
+
import { Keyframes } from "@ant-design/cssinjs";
|
|
23
|
+
import {
|
|
24
|
+
useEditorStyleRegister
|
|
25
|
+
} from "../../Hooks/useStyle";
|
|
26
|
+
var animation = new Keyframes("animation", {
|
|
27
|
+
"0%": {
|
|
28
|
+
opacity: 0
|
|
29
|
+
},
|
|
30
|
+
"100%": {
|
|
31
|
+
opacity: 1
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var genStyle = (token) => {
|
|
35
|
+
return {
|
|
36
|
+
[token.componentCls]: {
|
|
37
|
+
["&-cursor"]: {
|
|
38
|
+
display: "inline-block"
|
|
39
|
+
},
|
|
40
|
+
["&-cursor-blinking"]: {
|
|
41
|
+
animationName: animation,
|
|
42
|
+
animationDuration: "1s",
|
|
43
|
+
animationTimingFunction: "steps(1, end)",
|
|
44
|
+
animationIterationCount: "infinite"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
var useTypingAnimationStyle = (prefixCls) => {
|
|
50
|
+
return useEditorStyleRegister("typing-animation", (token) => {
|
|
51
|
+
const typingAnimationToken = __spreadProps(__spreadValues({}, token), {
|
|
52
|
+
componentCls: `.${prefixCls}`
|
|
53
|
+
});
|
|
54
|
+
return [genStyle(typingAnimationToken)];
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
useTypingAnimationStyle
|
|
59
|
+
};
|