@pointcloud/pcloud-components 0.1.31 → 0.1.33

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.
Files changed (74) hide show
  1. package/README.md +11 -9
  2. package/dist/esm/AdvancedFilter/FormFilter.d.ts +4 -4
  3. package/dist/esm/AdvancedFilter/index.d.ts +5 -5
  4. package/dist/esm/AdvancedFilter/interface.d.ts +101 -101
  5. package/dist/esm/AnimatedScrollList/index.d.ts +7 -7
  6. package/dist/esm/AnimatedScrollList/interface.d.ts +71 -71
  7. package/dist/esm/AspectRatio/index.d.ts +9 -9
  8. package/dist/esm/AuthComponent/index.d.ts +3 -3
  9. package/dist/esm/AuthComponent/interface.d.ts +24 -24
  10. package/dist/esm/ColorPicker/index.d.ts +17 -17
  11. package/dist/esm/ColorPicker/index.js +1 -1
  12. package/dist/esm/ColorPicker/interface.d.ts +164 -164
  13. package/dist/esm/ConfigProvider/index.d.ts +6 -6
  14. package/dist/esm/ConfigProvider/index.js +7 -13
  15. package/dist/esm/ConfigProvider/interface.d.ts +9 -9
  16. package/dist/esm/ContextMenu/index.d.ts +28 -28
  17. package/dist/esm/DCascader/index.d.ts +24 -24
  18. package/dist/esm/DForm/DItem/index.d.ts +5 -5
  19. package/dist/esm/DForm/DItem/itemType.d.ts +123 -119
  20. package/dist/esm/DForm/DItem/itemsRender.d.ts +47 -45
  21. package/dist/esm/DForm/DItem/itemsRender.js +6 -0
  22. package/dist/esm/DForm/helper.d.ts +8 -8
  23. package/dist/esm/DForm/index.d.ts +29 -29
  24. package/dist/esm/DInput/index.d.ts +19 -19
  25. package/dist/esm/DModal/index.d.ts +18 -18
  26. package/dist/esm/DModal/interface.d.ts +14 -14
  27. package/dist/esm/DRangePicker/index.d.ts +7 -0
  28. package/dist/esm/DRangePicker/index.js +24 -0
  29. package/dist/esm/DRangePicker/index.less +30 -0
  30. package/dist/esm/DRangePicker/interface.d.ts +5 -0
  31. package/dist/esm/DRangePicker/interface.js +1 -0
  32. package/dist/esm/DSelect/index.d.ts +24 -24
  33. package/dist/esm/DTable/index.d.ts +46 -46
  34. package/dist/esm/DTreeSelect/index.d.ts +16 -16
  35. package/dist/esm/DUpload/helper.d.ts +107 -107
  36. package/dist/esm/DUpload/index.d.ts +55 -55
  37. package/dist/esm/ErrorBoundary/index.d.ts +5 -5
  38. package/dist/esm/IPAddress/index.d.ts +20 -20
  39. package/dist/esm/IconFont/index.d.ts +17 -17
  40. package/dist/esm/InfiniteScrollList/index.d.ts +63 -63
  41. package/dist/esm/LabelValue/index.d.ts +16 -16
  42. package/dist/esm/LabelValue/interface.d.ts +39 -39
  43. package/dist/esm/Loading/hooks/useLoading.d.ts +6 -6
  44. package/dist/esm/Loading/index.d.ts +10 -10
  45. package/dist/esm/Loading/interface.d.ts +23 -23
  46. package/dist/esm/Loading/loading.d.ts +7 -7
  47. package/dist/esm/LoginForm/defaultConfig.d.ts +4 -4
  48. package/dist/esm/LoginForm/index.d.ts +21 -21
  49. package/dist/esm/LoginForm/index.js +1 -1
  50. package/dist/esm/ModalForm/index.d.ts +11 -11
  51. package/dist/esm/NoData/index.d.ts +4 -4
  52. package/dist/esm/NoData/interface.d.ts +13 -13
  53. package/dist/esm/OrgTree/index.d.ts +5 -5
  54. package/dist/esm/OrgTree/interface.d.ts +41 -39
  55. package/dist/esm/PictureCard/index.d.ts +16 -16
  56. package/dist/esm/RCropper/handler.d.ts +16 -16
  57. package/dist/esm/RCropper/index.d.ts +4 -4
  58. package/dist/esm/RCropper/interface.d.ts +70 -70
  59. package/dist/esm/RCropper/svgIcons.d.ts +28 -28
  60. package/dist/esm/RCropper/toolbar.d.ts +5 -5
  61. package/dist/esm/RndDrag/index.d.ts +5 -5
  62. package/dist/esm/ScrollNumber/index.d.ts +7 -7
  63. package/dist/esm/SignaturePad/index.d.ts +32 -32
  64. package/dist/esm/TypewriterText/index.d.ts +5 -0
  65. package/dist/esm/TypewriterText/index.js +282 -0
  66. package/dist/esm/TypewriterText/index.less +29 -0
  67. package/dist/esm/TypewriterText/interface.d.ts +42 -0
  68. package/dist/esm/TypewriterText/interface.js +1 -0
  69. package/dist/esm/WordCloud/index.d.ts +10 -10
  70. package/dist/esm/index.d.ts +64 -60
  71. package/dist/esm/index.js +3 -1
  72. package/dist/umd/pcloud-components.min.css +1 -1
  73. package/dist/umd/pcloud-components.min.js +1 -1
  74. package/package.json +121 -112
@@ -1,70 +1,70 @@
1
- /// <reference types="react" />
2
- import type Cropper from 'cropperjs';
3
- import type { CropperGrid, CropperSelection, CropperImage, CropperCanvas, CropperHandle } from 'cropperjs';
4
- export declare type RCropperGrid = Partial<Pick<CropperGrid, 'rows' | 'columns'>>;
5
- export declare type RCropperSelection = Partial<Pick<CropperSelection, 'x' | 'y' | 'width' | 'height' | 'aspectRatio' | 'initialAspectRatio' | 'zoomable' | 'resizable'>>;
6
- export declare type RCropperImage = Partial<Pick<CropperImage, 'rotatable' | 'scalable' | 'skewable' | 'translatable'>>;
7
- export declare type RCropperCanvas = Partial<Pick<CropperCanvas, 'scaleStep' | 'disabled'>>;
8
- export interface RCropperEvents {
9
- onCrop?(_src: string | undefined, _file?: File): void;
10
- onZoom?(imgData: number[] | undefined): void;
11
- onRotate?(imgData: number[] | undefined): void;
12
- onFlip?(imgData: number[] | undefined): void;
13
- onReset?(imgData: number[] | undefined): void;
14
- onCancelCrop?(selectionData: {
15
- x: number;
16
- y: number;
17
- width: number;
18
- height: number;
19
- }): void;
20
- }
21
- export interface RCropperActionHandlers {
22
- handleCrop: () => Promise<void>;
23
- handleZoomIn: () => void;
24
- handleZoomOut: () => void;
25
- handleRotateLeft: () => void;
26
- handleRotateRight: () => void;
27
- handleFlipX: () => void;
28
- handleFlipY: () => void;
29
- handleReset: () => void;
30
- handleCancelCrop: () => void;
31
- }
32
- export interface RCropperRef {
33
- cropper: Cropper | null;
34
- image: CropperImage | null;
35
- canvas: CropperCanvas | null;
36
- selection: CropperSelection | null;
37
- }
38
- export interface RCropperProps extends RCropperEvents {
39
- /**
40
- * 图片的源地址
41
- * @description 可以是本地图片路径或网络图片URL
42
- */
43
- src: string;
44
- alt?: string;
45
- className?: string;
46
- style?: React.CSSProperties;
47
- /**
48
- * 拖拽模式
49
- * @default 'crop'
50
- * @description 'crop' - 裁剪模式, 'move' - 移动模式, 'none' - 禁用拖拽
51
- */
52
- dragMode?: 'crop' | 'move' | 'none';
53
- grid?: RCropperGrid;
54
- /**
55
- * 裁剪区域的配置
56
- * @description 可以设置裁剪区域的宽度、高度、纵横比等属性
57
- */
58
- selection?: RCropperSelection;
59
- /**
60
- * 图片的配置
61
- * @description 可以设置图片的旋转、缩放、倾斜、平移等属性
62
- */
63
- image?: RCropperImage;
64
- /**
65
- * 画布的配置
66
- * @description 可以设置画布的缩放步长、禁用状态等属性
67
- */
68
- canvas?: RCropperCanvas;
69
- }
70
- export declare type RCropperElement = CropperCanvas | CropperGrid | CropperSelection | CropperImage | CropperHandle | null;
1
+ /// <reference types="react" />
2
+ import type Cropper from 'cropperjs';
3
+ import type { CropperGrid, CropperSelection, CropperImage, CropperCanvas, CropperHandle } from 'cropperjs';
4
+ export type RCropperGrid = Partial<Pick<CropperGrid, 'rows' | 'columns'>>;
5
+ export type RCropperSelection = Partial<Pick<CropperSelection, 'x' | 'y' | 'width' | 'height' | 'aspectRatio' | 'initialAspectRatio' | 'zoomable' | 'resizable'>>;
6
+ export type RCropperImage = Partial<Pick<CropperImage, 'rotatable' | 'scalable' | 'skewable' | 'translatable'>>;
7
+ export type RCropperCanvas = Partial<Pick<CropperCanvas, 'scaleStep' | 'disabled'>>;
8
+ export interface RCropperEvents {
9
+ onCrop?(_src: string | undefined, _file?: File): void;
10
+ onZoom?(imgData: number[] | undefined): void;
11
+ onRotate?(imgData: number[] | undefined): void;
12
+ onFlip?(imgData: number[] | undefined): void;
13
+ onReset?(imgData: number[] | undefined): void;
14
+ onCancelCrop?(selectionData: {
15
+ x: number;
16
+ y: number;
17
+ width: number;
18
+ height: number;
19
+ }): void;
20
+ }
21
+ export interface RCropperActionHandlers {
22
+ handleCrop: () => Promise<void>;
23
+ handleZoomIn: () => void;
24
+ handleZoomOut: () => void;
25
+ handleRotateLeft: () => void;
26
+ handleRotateRight: () => void;
27
+ handleFlipX: () => void;
28
+ handleFlipY: () => void;
29
+ handleReset: () => void;
30
+ handleCancelCrop: () => void;
31
+ }
32
+ export interface RCropperRef {
33
+ cropper: Cropper | null;
34
+ image: CropperImage | null;
35
+ canvas: CropperCanvas | null;
36
+ selection: CropperSelection | null;
37
+ }
38
+ export interface RCropperProps extends RCropperEvents {
39
+ /**
40
+ * 图片的源地址
41
+ * @description 可以是本地图片路径或网络图片URL
42
+ */
43
+ src: string;
44
+ alt?: string;
45
+ className?: string;
46
+ style?: React.CSSProperties;
47
+ /**
48
+ * 拖拽模式
49
+ * @default 'crop'
50
+ * @description 'crop' - 裁剪模式, 'move' - 移动模式, 'none' - 禁用拖拽
51
+ */
52
+ dragMode?: 'crop' | 'move' | 'none';
53
+ grid?: RCropperGrid;
54
+ /**
55
+ * 裁剪区域的配置
56
+ * @description 可以设置裁剪区域的宽度、高度、纵横比等属性
57
+ */
58
+ selection?: RCropperSelection;
59
+ /**
60
+ * 图片的配置
61
+ * @description 可以设置图片的旋转、缩放、倾斜、平移等属性
62
+ */
63
+ image?: RCropperImage;
64
+ /**
65
+ * 画布的配置
66
+ * @description 可以设置画布的缩放步长、禁用状态等属性
67
+ */
68
+ canvas?: RCropperCanvas;
69
+ }
70
+ export type RCropperElement = CropperCanvas | CropperGrid | CropperSelection | CropperImage | CropperHandle | null;
@@ -1,28 +1,28 @@
1
- import React from 'react';
2
- export declare const CropIcon: React.FC<{
3
- className?: string;
4
- }>;
5
- export declare const ZoomInIcon: React.FC<{
6
- className?: string;
7
- }>;
8
- export declare const ZoomOutIcon: React.FC<{
9
- className?: string;
10
- }>;
11
- export declare const FlipHIcon: React.FC<{
12
- className?: string;
13
- }>;
14
- export declare const FlipVIcon: React.FC<{
15
- className?: string;
16
- }>;
17
- export declare const RotateLeftIcon: React.FC<{
18
- className?: string;
19
- }>;
20
- export declare const RotateRightIcon: React.FC<{
21
- className?: string;
22
- }>;
23
- export declare const ResetIcon: React.FC<{
24
- className?: string;
25
- }>;
26
- export declare const OkIcon: React.FC<{
27
- className?: string;
28
- }>;
1
+ import React from 'react';
2
+ export declare const CropIcon: React.FC<{
3
+ className?: string;
4
+ }>;
5
+ export declare const ZoomInIcon: React.FC<{
6
+ className?: string;
7
+ }>;
8
+ export declare const ZoomOutIcon: React.FC<{
9
+ className?: string;
10
+ }>;
11
+ export declare const FlipHIcon: React.FC<{
12
+ className?: string;
13
+ }>;
14
+ export declare const FlipVIcon: React.FC<{
15
+ className?: string;
16
+ }>;
17
+ export declare const RotateLeftIcon: React.FC<{
18
+ className?: string;
19
+ }>;
20
+ export declare const RotateRightIcon: React.FC<{
21
+ className?: string;
22
+ }>;
23
+ export declare const ResetIcon: React.FC<{
24
+ className?: string;
25
+ }>;
26
+ export declare const OkIcon: React.FC<{
27
+ className?: string;
28
+ }>;
@@ -1,5 +1,5 @@
1
- import './styles/toolbar.less';
2
- declare const Toolbar: ({ onAction }: {
3
- onAction: any;
4
- }) => import("react/jsx-runtime").JSX.Element;
5
- export default Toolbar;
1
+ import './styles/toolbar.less';
2
+ declare const Toolbar: ({ onAction }: {
3
+ onAction: any;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default Toolbar;
@@ -1,5 +1,5 @@
1
- import { Props } from 'react-rnd';
2
- declare const RndDrag: (props: Props) => import("react/jsx-runtime").JSX.Element;
3
- export default RndDrag;
4
- export type { Props as RndDragProps } from 'react-rnd';
5
- export type { DraggableData, Position, Grid, RndDragCallback, RndDragEvent, RndResizeStartCallback, HandleStyles } from 'react-rnd';
1
+ import { Props } from 'react-rnd';
2
+ declare const RndDrag: (props: Props) => import("react/jsx-runtime").JSX.Element;
3
+ export default RndDrag;
4
+ export type { Props as RndDragProps } from 'react-rnd';
5
+ export type { DraggableData, Position, Grid, RndDragCallback, RndDragEvent, RndResizeStartCallback, HandleStyles } from 'react-rnd';
@@ -1,7 +1,7 @@
1
- import { CountUpProps as ICountUpProps } from 'react-countup';
2
- declare const ScrollNumber: {
3
- (props: ICountUpProps): import("react/jsx-runtime").JSX.Element;
4
- useCountUp: (props: import("react-countup/build/useCountUp").UseCountUpProps) => import("react-countup/build/types").CountUpApi;
5
- };
6
- export declare type ScrollNumberProps = ICountUpProps;
7
- export default ScrollNumber;
1
+ import { CountUpProps as ICountUpProps } from 'react-countup';
2
+ declare const ScrollNumber: {
3
+ (props: ICountUpProps): import("react/jsx-runtime").JSX.Element;
4
+ useCountUp: (props: import("react-countup/build/useCountUp").UseCountUpProps) => import("react-countup/build/types").CountUpApi;
5
+ };
6
+ export type ScrollNumberProps = ICountUpProps;
7
+ export default ScrollNumber;
@@ -1,32 +1,32 @@
1
- /// <reference types="react" />
2
- import './style/index.less';
3
- export interface SignaturePadHandle {
4
- /** 清除画布 */
5
- clear: () => void;
6
- /** 获取签名图片的 base64 数据 */
7
- getDataURL: () => string | undefined;
8
- }
9
- export interface SignaturePadProps extends React.HTMLAttributes<HTMLDivElement> {
10
- /** 画布宽度 */
11
- width?: number;
12
- /** 画布高度 */
13
- height?: number;
14
- /** 线条颜色 */
15
- penColor?: string;
16
- /** 线条粗细 */
17
- penWidth?: number;
18
- /** 背景颜色 */
19
- backgroundColor?: string;
20
- /** 清除按钮文字 */
21
- clearText?: string;
22
- /** 完成按钮文字 */
23
- doneText?: string;
24
- /** 是否显示工具栏 */
25
- showToolbar?: boolean;
26
- /** 签名完成回调 */
27
- onDone?: (_dataUrl: string) => void;
28
- /** 默认的签名图片(base64或图片URL) */
29
- defaultValue?: string;
30
- }
31
- declare const SignaturePad: import("react").ForwardRefExoticComponent<SignaturePadProps & import("react").RefAttributes<SignaturePadHandle>>;
32
- export default SignaturePad;
1
+ /// <reference types="react" />
2
+ import './style/index.less';
3
+ export interface SignaturePadHandle {
4
+ /** 清除画布 */
5
+ clear: () => void;
6
+ /** 获取签名图片的 base64 数据 */
7
+ getDataURL: () => string | undefined;
8
+ }
9
+ export interface SignaturePadProps extends React.HTMLAttributes<HTMLDivElement> {
10
+ /** 画布宽度 */
11
+ width?: number;
12
+ /** 画布高度 */
13
+ height?: number;
14
+ /** 线条颜色 */
15
+ penColor?: string;
16
+ /** 线条粗细 */
17
+ penWidth?: number;
18
+ /** 背景颜色 */
19
+ backgroundColor?: string;
20
+ /** 清除按钮文字 */
21
+ clearText?: string;
22
+ /** 完成按钮文字 */
23
+ doneText?: string;
24
+ /** 是否显示工具栏 */
25
+ showToolbar?: boolean;
26
+ /** 签名完成回调 */
27
+ onDone?: (_dataUrl: string) => void;
28
+ /** 默认的签名图片(base64或图片URL) */
29
+ defaultValue?: string;
30
+ }
31
+ declare const SignaturePad: import("react").ForwardRefExoticComponent<SignaturePadProps & import("react").RefAttributes<SignaturePadHandle>>;
32
+ export default SignaturePad;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { TypewriterTextHandle, TypewriterTextProps } from './interface';
3
+ import './index.less';
4
+ declare const TypewriterText: import("react").ForwardRefExoticComponent<TypewriterTextProps & import("react").RefAttributes<TypewriterTextHandle>>;
5
+ export default TypewriterText;
@@ -0,0 +1,282 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["text", "speed", "deleteSpeed", "backspace", "pauseBeforeDelete", "startDelay", "loop", "cursor", "cursorChar", "cursorBlinkSpeed", "onStep", "onComplete", "className", "style", "children"];
6
+ import { Fragment, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
7
+ import { ConfigContext } from "../ConfigProvider";
8
+ import classNames from 'classnames';
9
+ import "./index.less";
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ var TypewriterText = /*#__PURE__*/forwardRef(function (props, ref) {
13
+ var text = props.text,
14
+ _props$speed = props.speed,
15
+ speed = _props$speed === void 0 ? 50 : _props$speed,
16
+ _props$deleteSpeed = props.deleteSpeed,
17
+ deleteSpeed = _props$deleteSpeed === void 0 ? 30 : _props$deleteSpeed,
18
+ _props$backspace = props.backspace,
19
+ backspace = _props$backspace === void 0 ? false : _props$backspace,
20
+ _props$pauseBeforeDel = props.pauseBeforeDelete,
21
+ pauseBeforeDelete = _props$pauseBeforeDel === void 0 ? 600 : _props$pauseBeforeDel,
22
+ _props$startDelay = props.startDelay,
23
+ startDelay = _props$startDelay === void 0 ? 0 : _props$startDelay,
24
+ _props$loop = props.loop,
25
+ loop = _props$loop === void 0 ? false : _props$loop,
26
+ _props$cursor = props.cursor,
27
+ cursor = _props$cursor === void 0 ? true : _props$cursor,
28
+ _props$cursorChar = props.cursorChar,
29
+ cursorChar = _props$cursorChar === void 0 ? '|' : _props$cursorChar,
30
+ _props$cursorBlinkSpe = props.cursorBlinkSpeed,
31
+ cursorBlinkSpeed = _props$cursorBlinkSpe === void 0 ? 600 : _props$cursorBlinkSpe,
32
+ onStep = props.onStep,
33
+ onComplete = props.onComplete,
34
+ className = props.className,
35
+ style = props.style,
36
+ children = props.children,
37
+ rest = _objectWithoutProperties(props, _excluded);
38
+ var normalizedLoop = useMemo(function () {
39
+ if (loop === true) return true;
40
+ if (typeof loop === 'number' && loop > 0) return Math.floor(loop);
41
+ return false;
42
+ }, [loop]);
43
+ var texts = useMemo(function () {
44
+ var sources = Array.isArray(text) ? text : [text];
45
+ return sources.filter(function (item) {
46
+ return typeof item === 'string';
47
+ }).map(function (item) {
48
+ return item.replace(/\r\n|\r/g, '\n');
49
+ });
50
+ }, [text]);
51
+ var _useContext = useContext(ConfigContext),
52
+ prefixCls = _useContext.prefixCls,
53
+ getPrefixCls = _useContext.getPrefixCls;
54
+ var baseCls = getPrefixCls('typewriter-text');
55
+ var wrapperClass = classNames(_defineProperty({}, "".concat(prefixCls, "-typewriter-text"), !!prefixCls), baseCls, className);
56
+ var cursorClass = classNames(_defineProperty({}, "".concat(prefixCls, "-typewriter-text-cursor"), !!prefixCls), "".concat(baseCls, "-cursor"));
57
+ var _useState = useState(''),
58
+ _useState2 = _slicedToArray(_useState, 2),
59
+ output = _useState2[0],
60
+ setOutput = _useState2[1];
61
+ var textsRef = useRef(texts);
62
+ var timeoutRef = useRef();
63
+ var textIndexRef = useRef(0);
64
+ var charIndexRef = useRef(0);
65
+ var loopCountRef = useRef(0);
66
+ var isDeletingRef = useRef(false);
67
+ var pausedRef = useRef(false);
68
+ var stoppedRef = useRef(false);
69
+ var runStepRef = useRef();
70
+ var optionsRef = useRef({
71
+ speed: speed,
72
+ deleteSpeed: deleteSpeed,
73
+ backspace: backspace,
74
+ pauseBeforeDelete: pauseBeforeDelete,
75
+ startDelay: startDelay,
76
+ loop: normalizedLoop,
77
+ onStep: onStep,
78
+ onComplete: onComplete
79
+ });
80
+ useEffect(function () {
81
+ optionsRef.current = {
82
+ speed: speed,
83
+ deleteSpeed: deleteSpeed,
84
+ backspace: backspace,
85
+ pauseBeforeDelete: pauseBeforeDelete,
86
+ startDelay: startDelay,
87
+ loop: normalizedLoop,
88
+ onStep: onStep,
89
+ onComplete: onComplete
90
+ };
91
+ }, [speed, deleteSpeed, backspace, pauseBeforeDelete, startDelay, normalizedLoop, onStep, onComplete]);
92
+ useEffect(function () {
93
+ textsRef.current = texts;
94
+ }, [texts]);
95
+ var clearTimer = useCallback(function () {
96
+ if (typeof window === 'undefined') return;
97
+ if (timeoutRef.current) {
98
+ window.clearTimeout(timeoutRef.current);
99
+ timeoutRef.current = undefined;
100
+ }
101
+ }, []);
102
+ var getTypingDelay = useCallback(function () {
103
+ var currentSpeed = optionsRef.current.speed;
104
+ if (typeof currentSpeed === 'number') return Math.max(0, currentSpeed);
105
+ var min = Math.max(0, Math.min(currentSpeed.min, currentSpeed.max));
106
+ var max = Math.max(min, currentSpeed.max);
107
+ var gap = max - min;
108
+ if (gap === 0) return min;
109
+ return Math.floor(Math.random() * (gap + 1)) + min;
110
+ }, []);
111
+ var getDeleteDelay = useCallback(function () {
112
+ return Math.max(0, optionsRef.current.deleteSpeed);
113
+ }, []);
114
+ var scheduleNext = useCallback(function (delay) {
115
+ if (typeof window === 'undefined') return;
116
+ clearTimer();
117
+ if (pausedRef.current || stoppedRef.current) return;
118
+ var wait = typeof delay === 'number' ? Math.max(0, delay) : isDeletingRef.current ? getDeleteDelay() : getTypingDelay();
119
+ timeoutRef.current = window.setTimeout(function () {
120
+ var _runStepRef$current;
121
+ (_runStepRef$current = runStepRef.current) === null || _runStepRef$current === void 0 || _runStepRef$current.call(runStepRef);
122
+ }, wait);
123
+ }, [clearTimer, getDeleteDelay, getTypingDelay]);
124
+ var moveToNextText = useCallback(function () {
125
+ var content = textsRef.current;
126
+ if (!content.length) {
127
+ stoppedRef.current = true;
128
+ clearTimer();
129
+ return;
130
+ }
131
+ var isLast = textIndexRef.current >= content.length - 1;
132
+ if (!isLast) {
133
+ textIndexRef.current += 1;
134
+ } else {
135
+ var loopConfig = optionsRef.current.loop;
136
+ var canLoop = loopConfig === true || typeof loopConfig === 'number' && loopConfig > 0 && loopCountRef.current + 1 < loopConfig;
137
+ if (canLoop) {
138
+ loopCountRef.current += 1;
139
+ textIndexRef.current = 0;
140
+ } else {
141
+ stoppedRef.current = true;
142
+ clearTimer();
143
+ return;
144
+ }
145
+ }
146
+ charIndexRef.current = 0;
147
+ isDeletingRef.current = false;
148
+ setOutput('');
149
+ scheduleNext(optionsRef.current.startDelay);
150
+ }, [clearTimer, scheduleNext]);
151
+ var resetTyping = useCallback(function () {
152
+ clearTimer();
153
+ textsRef.current = texts;
154
+ textIndexRef.current = 0;
155
+ charIndexRef.current = 0;
156
+ loopCountRef.current = 0;
157
+ isDeletingRef.current = false;
158
+ pausedRef.current = false;
159
+ stoppedRef.current = false;
160
+ setOutput('');
161
+ if (!texts.length) {
162
+ stoppedRef.current = true;
163
+ return;
164
+ }
165
+ scheduleNext(optionsRef.current.startDelay);
166
+ }, [clearTimer, scheduleNext, texts]);
167
+ var pause = useCallback(function () {
168
+ if (pausedRef.current) return;
169
+ pausedRef.current = true;
170
+ clearTimer();
171
+ }, [clearTimer]);
172
+ var resume = useCallback(function () {
173
+ if (!pausedRef.current) return;
174
+ pausedRef.current = false;
175
+ scheduleNext();
176
+ }, [scheduleNext]);
177
+ var skipTyping = useCallback(function () {
178
+ var _content$textIndexRef, _optionsRef$current$o, _optionsRef$current;
179
+ if (stoppedRef.current) return;
180
+ var content = textsRef.current;
181
+ var currentText = (_content$textIndexRef = content[textIndexRef.current]) !== null && _content$textIndexRef !== void 0 ? _content$textIndexRef : '';
182
+ if (!currentText) {
183
+ moveToNextText();
184
+ return;
185
+ }
186
+ charIndexRef.current = currentText.length;
187
+ setOutput(currentText);
188
+ (_optionsRef$current$o = (_optionsRef$current = optionsRef.current).onStep) === null || _optionsRef$current$o === void 0 || _optionsRef$current$o.call(_optionsRef$current, charIndexRef.current, currentText);
189
+ if (optionsRef.current.backspace) {
190
+ isDeletingRef.current = true;
191
+ scheduleNext(optionsRef.current.pauseBeforeDelete);
192
+ return;
193
+ }
194
+ moveToNextText();
195
+ }, [moveToNextText, scheduleNext]);
196
+ runStepRef.current = function () {
197
+ var _content$textIndexRef2;
198
+ if (stoppedRef.current || pausedRef.current) return;
199
+ var content = textsRef.current;
200
+ if (!content.length) {
201
+ stoppedRef.current = true;
202
+ return;
203
+ }
204
+ var currentText = (_content$textIndexRef2 = content[textIndexRef.current]) !== null && _content$textIndexRef2 !== void 0 ? _content$textIndexRef2 : '';
205
+ if (!isDeletingRef.current) {
206
+ var _optionsRef$current$o3, _optionsRef$current3;
207
+ if (charIndexRef.current < currentText.length) {
208
+ var _optionsRef$current$o2, _optionsRef$current2;
209
+ var nextIndex = charIndexRef.current + 1;
210
+ var nextOutput = currentText.slice(0, nextIndex);
211
+ charIndexRef.current = nextIndex;
212
+ setOutput(nextOutput);
213
+ (_optionsRef$current$o2 = (_optionsRef$current2 = optionsRef.current).onStep) === null || _optionsRef$current$o2 === void 0 || _optionsRef$current$o2.call(_optionsRef$current2, nextIndex, nextOutput);
214
+ scheduleNext();
215
+ return;
216
+ }
217
+ (_optionsRef$current$o3 = (_optionsRef$current3 = optionsRef.current).onComplete) === null || _optionsRef$current$o3 === void 0 || _optionsRef$current$o3.call(_optionsRef$current3);
218
+ if (optionsRef.current.backspace && currentText.length) {
219
+ isDeletingRef.current = true;
220
+ scheduleNext(optionsRef.current.pauseBeforeDelete);
221
+ return;
222
+ }
223
+ moveToNextText();
224
+ return;
225
+ }
226
+ if (charIndexRef.current > 0) {
227
+ var _nextIndex = charIndexRef.current - 1;
228
+ var _nextOutput = currentText.slice(0, _nextIndex);
229
+ charIndexRef.current = _nextIndex;
230
+ setOutput(_nextOutput);
231
+ scheduleNext();
232
+ return;
233
+ }
234
+ isDeletingRef.current = false;
235
+ moveToNextText();
236
+ };
237
+ useEffect(function () {
238
+ resetTyping();
239
+ return function () {
240
+ clearTimer();
241
+ };
242
+ }, [clearTimer, resetTyping]);
243
+ useImperativeHandle(ref, function () {
244
+ return {
245
+ pause: pause,
246
+ resume: resume,
247
+ reset: resetTyping,
248
+ skip: skipTyping
249
+ };
250
+ }, [pause, resume, resetTyping, skipTyping]);
251
+ var shouldRenderCursor = cursor && !stoppedRef.current && !!cursorChar;
252
+ var resolvedCursorBlinkSpeed = Math.max(0, cursorBlinkSpeed);
253
+ var renderedOutput = useMemo(function () {
254
+ if (!output) return output;
255
+ if (!output.includes('\n')) return output;
256
+ var segments = output.split('\n');
257
+ var trailingBreak = output.endsWith('\n');
258
+ return segments.map(function (segment, index) {
259
+ var isLast = index === segments.length - 1;
260
+ var shouldInsertBreak = !isLast || trailingBreak;
261
+ return /*#__PURE__*/_jsxs(Fragment, {
262
+ children: [segment, shouldInsertBreak && /*#__PURE__*/_jsx("br", {})]
263
+ }, "typewriter-line-".concat(index));
264
+ });
265
+ }, [output]);
266
+ return /*#__PURE__*/_jsxs("span", _objectSpread(_objectSpread({
267
+ className: wrapperClass,
268
+ style: _objectSpread({
269
+ whiteSpace: 'pre-wrap'
270
+ }, style)
271
+ }, rest), {}, {
272
+ children: [renderedOutput, shouldRenderCursor && /*#__PURE__*/_jsx("span", {
273
+ className: cursorClass,
274
+ style: {
275
+ animationDuration: "".concat(resolvedCursorBlinkSpeed, "ms")
276
+ },
277
+ children: cursorChar
278
+ }), children]
279
+ }));
280
+ });
281
+ TypewriterText.displayName = 'TypewriterText';
282
+ export default TypewriterText;
@@ -0,0 +1,29 @@
1
+ @import '../commonStyle/index.less';
2
+
3
+ .@{prefix}-typewriter-text {
4
+ position: relative;
5
+ display: inline-block;
6
+ min-height: 1em;
7
+ font-variant-ligatures: none;
8
+
9
+ &-cursor {
10
+ display: inline-block;
11
+ margin-left: 4px;
12
+ animation-name: pc-typewriter-cursor-blink;
13
+ animation-timing-function: steps(1, end);
14
+ animation-iteration-count: infinite;
15
+ animation-fill-mode: both;
16
+ }
17
+ }
18
+
19
+ @keyframes pc-typewriter-cursor-blink {
20
+ 0%,
21
+ 49% {
22
+ opacity: 1;
23
+ }
24
+
25
+ 50%,
26
+ 100% {
27
+ opacity: 0;
28
+ }
29
+ }
@@ -0,0 +1,42 @@
1
+ import type { HTMLAttributes } from 'react';
2
+ export interface TypewriterTextHandle {
3
+ /** 暂停动画 */
4
+ pause: () => void;
5
+ /** 继续动画 */
6
+ resume: () => void;
7
+ /** 重置至第一段文字重新开始 */
8
+ reset: () => void;
9
+ /** 跳过当前段落直接进入下一段 */
10
+ skip: () => void;
11
+ }
12
+ export interface TypewriterTextProps extends HTMLAttributes<HTMLSpanElement> {
13
+ /** 展示文本,支持字符串数组 */
14
+ text: string | string[];
15
+ /** 打字速度,支持随机区间 */
16
+ speed?: number | {
17
+ min: number;
18
+ max: number;
19
+ };
20
+ /** 删除速度 */
21
+ deleteSpeed?: number;
22
+ /** 是否启用回删效果 */
23
+ backspace?: boolean;
24
+ /** 进入回删前的停顿时间,单位 ms */
25
+ pauseBeforeDelete?: number;
26
+ /** 每段文本开始前的停顿时间,单位 ms */
27
+ startDelay?: number;
28
+ /** 循环播放,true 表示无限循环,数字表示循环次数 */
29
+ loop?: boolean | number;
30
+ /** 是否展示光标 */
31
+ cursor?: boolean;
32
+ /** 光标字符 */
33
+ cursorChar?: string | React.ReactNode;
34
+ /** 光标闪烁速度 */
35
+ cursorBlinkSpeed?: number;
36
+ /** 每次新增字符时触发 */
37
+ onStep?: (_index: number, _output: string) => void;
38
+ /** 每段文本输入完成后触发(进入删除之前) */
39
+ onComplete?: () => void;
40
+ /** 控制屏幕阅读器播报行为 */
41
+ ariaLive?: 'off' | 'polite' | 'assertive';
42
+ }
@@ -0,0 +1 @@
1
+ export {};