@para-ui/core 4.0.30 → 4.0.32

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 (70) hide show
  1. package/AutoButton/index.d.ts +41 -0
  2. package/AutoButton/index.js +213 -0
  3. package/AutoButton/lang/en_US.d.ts +4 -0
  4. package/AutoButton/lang/index.d.ts +9 -0
  5. package/AutoButton/lang/zh_CN.d.ts +4 -0
  6. package/Badge/index.d.ts +3 -1
  7. package/Badge/index.js +15 -5
  8. package/Card/index.d.ts +53 -0
  9. package/Card/index.js +218 -0
  10. package/Card/lang/en_US.d.ts +5 -0
  11. package/Card/lang/index.d.ts +11 -0
  12. package/Card/lang/zh_CN.d.ts +5 -0
  13. package/Cascader/index.js +5 -6
  14. package/ComboSelect/index.js +4 -5
  15. package/DragVerify/index.js +7 -2
  16. package/DynamicMultiBox/index.js +4 -5
  17. package/Form/index.js +5 -6
  18. package/FormItem/index.js +5 -6
  19. package/FunctionModal/index.js +2 -2
  20. package/Image/index.js +3 -4
  21. package/InputCode/index.d.ts +82 -0
  22. package/InputCode/index.js +392 -0
  23. package/InputCode/inputCodeCard/index.d.ts +10 -0
  24. package/InputCode/inputCodeInput/index.d.ts +10 -0
  25. package/InputCode/lang/en_US.d.ts +7 -0
  26. package/InputCode/lang/index.d.ts +15 -0
  27. package/InputCode/lang/zh_CN.d.ts +7 -0
  28. package/PopMenu/index.js +16 -5
  29. package/README.md +15 -0
  30. package/RangeInput/index.d.ts +4 -0
  31. package/RangeInput/index.js +32 -8
  32. package/Selector/index.js +1 -2
  33. package/SelectorPicker/index.js +1 -2
  34. package/SortBox/index.d.ts +29 -0
  35. package/SortBox/index.js +84 -0
  36. package/Table/index.js +470 -409
  37. package/Timeline/index.js +13 -20
  38. package/Tooltip/index.js +26 -27
  39. package/Transfer/index.js +1 -2
  40. package/Tree/index.js +4 -5
  41. package/Upload/ImageUpload/index.d.ts +2 -7
  42. package/Upload/index.js +110 -34
  43. package/Upload/interface.d.ts +18 -0
  44. package/_verture/{Portal-5bf66fed.js → Portal-42560ff0.js} +2 -2
  45. package/_verture/{index-28edf318.js → index-44152845.js} +2 -2
  46. package/_verture/{index-8ec857b4.js → index-519d0a1f.js} +3 -4
  47. package/_verture/{index-33866394.js → index-b037486c.js} +1 -1
  48. package/_verture/{slicedToArray-a8206399.js → slicedToArray-75fa4188.js} +15 -2
  49. package/_verture/{toConsumableArray-8f4c9589.js → toConsumableArray-c7a8028f.js} +1 -1
  50. package/index.d.ts +8 -0
  51. package/index.js +14 -10
  52. package/locale/en-US.d.ts +13 -0
  53. package/locale/index.d.ts +26 -0
  54. package/locale/index.js +26 -0
  55. package/locale/zh-CN.d.ts +13 -0
  56. package/package.json +1 -1
  57. package/umd/AutoButton.js +43 -0
  58. package/umd/Badge.js +1 -1
  59. package/umd/Card.js +1 -0
  60. package/umd/DragVerify.js +1 -1
  61. package/umd/FunctionModal.js +3 -3
  62. package/umd/InputCode.js +43 -0
  63. package/umd/Modal.js +2 -2
  64. package/umd/PopMenu.js +2 -2
  65. package/umd/RangeInput.js +2 -2
  66. package/umd/SortBox.js +41 -0
  67. package/umd/Upload.js +4 -4
  68. package/umd/locale.js +1 -1
  69. package/_verture/unsupportedIterableToArray-cb478f24.js +0 -16
  70. /package/_verture/{modalContext-c57b51b7.js → modalContext-10f0c5aa.js} +0 -0
@@ -185,13 +185,16 @@ const DragVerify = props => {
185
185
  };
186
186
  };
187
187
  moveDom.ontouchstart = touchE => {
188
- if (constData.current.padding) return;
188
+ touchE.preventDefault();
189
+ if (constData.current.padding) return false;
189
190
  const e = touchE.touches[0];
190
191
  sliderBox.classList.add("".concat(prefixCls, "-move"));
191
192
  // 鼠标移动
192
193
  document.ontouchmove = touchEvent => {
194
+ touchEvent.preventDefault();
193
195
  const event = touchEvent.touches[0];
194
196
  moveFunc(event, e);
197
+ return false;
195
198
  };
196
199
  // 鼠标抬起
197
200
  document.ontouchend = () => {
@@ -199,6 +202,7 @@ const DragVerify = props => {
199
202
  document.ontouchend = null;
200
203
  endFunc();
201
204
  };
205
+ return false;
202
206
  };
203
207
  };
204
208
  /** 复位 */
@@ -259,7 +263,8 @@ const DragVerify = props => {
259
263
  className: "slider-move-mask"
260
264
  }, {
261
265
  children: jsxs("div", Object.assign({
262
- className: "slider-move-box"
266
+ className: "slider-move-box",
267
+ draggable: false
263
268
  }, {
264
269
  children: [jsx(DoubleRight, {
265
270
  className: 'svg-right'
@@ -52,6 +52,8 @@ import '@para-ui/icons/Up';
52
52
  import '../MultiBox/index.js';
53
53
  import '@para-ui/icons/Internet';
54
54
  import '../Table/index.js';
55
+ import '../_verture/defineProperty-f0e15205.js';
56
+ import '../_verture/slicedToArray-75fa4188.js';
55
57
  import '../Button/index.js';
56
58
  import '@para-ui/icons/ScreenF';
57
59
  import '@para-ui/icons/UpTriangleF';
@@ -70,11 +72,8 @@ import 'rc-pagination';
70
72
  import '@para-ui/icons/Right';
71
73
  import '@para-ui/icons/DoubleLeft';
72
74
  import '@para-ui/icons/DoubleRight';
73
- import '../_verture/index-28edf318.js';
74
- import '../_verture/toConsumableArray-8f4c9589.js';
75
- import '../_verture/unsupportedIterableToArray-cb478f24.js';
76
- import '../_verture/defineProperty-f0e15205.js';
77
- import '../_verture/slicedToArray-a8206399.js';
75
+ import '../_verture/index-44152845.js';
76
+ import '../_verture/toConsumableArray-c7a8028f.js';
78
77
  import '../_verture/index-8ac46bd9.js';
79
78
  import '../_verture/typeof-6ec38efd.js';
80
79
  import 'rc-tree';
package/Form/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { DeepClone } from '@paraview/lib';
3
3
  import React__default from 'react';
4
- import { F as FormItem, l as localeJson, v as validate } from '../_verture/index-33866394.js';
4
+ import { F as FormItem, l as localeJson, v as validate } from '../_verture/index-b037486c.js';
5
5
  import { $ as $prefixCls } from '../_verture/constant-5317fc89.js';
6
6
  import { u as useFormatMessage } from '../_verture/useFormatMessage-1fc7c957.js';
7
7
  import '../TextField/index.js';
@@ -28,8 +28,7 @@ import '../_verture/index-bde7aabe.js';
28
28
  import 'rc-dropdown';
29
29
  import '../_verture/usePopupContainer-635f66f4.js';
30
30
  import 'dayjs';
31
- import '../_verture/slicedToArray-a8206399.js';
32
- import '../_verture/unsupportedIterableToArray-cb478f24.js';
31
+ import '../_verture/slicedToArray-75fa4188.js';
33
32
  import '../RadioGroup/index.js';
34
33
  import '../Radio/index.js';
35
34
  import '../Select/index.js';
@@ -52,6 +51,7 @@ import 'rc-input-number';
52
51
  import '@para-ui/icons/Up';
53
52
  import '../ComboSelect/index.js';
54
53
  import '../Table/index.js';
54
+ import '../_verture/defineProperty-f0e15205.js';
55
55
  import '@para-ui/icons/ScreenF';
56
56
  import '@para-ui/icons/UpTriangleF';
57
57
  import '@para-ui/icons/DownTriangleF';
@@ -69,9 +69,8 @@ import 'rc-pagination';
69
69
  import '@para-ui/icons/Right';
70
70
  import '@para-ui/icons/DoubleLeft';
71
71
  import '@para-ui/icons/DoubleRight';
72
- import '../_verture/index-28edf318.js';
73
- import '../_verture/toConsumableArray-8f4c9589.js';
74
- import '../_verture/defineProperty-f0e15205.js';
72
+ import '../_verture/index-44152845.js';
73
+ import '../_verture/toConsumableArray-c7a8028f.js';
75
74
  import '../_verture/index-8ac46bd9.js';
76
75
  import '../_verture/typeof-6ec38efd.js';
77
76
  import 'rc-tree';
package/FormItem/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'react/jsx-runtime';
2
2
  import 'react';
3
- export { F as default } from '../_verture/index-33866394.js';
3
+ export { F as default } from '../_verture/index-b037486c.js';
4
4
  import 'clsx';
5
5
  import '../Label/index.js';
6
6
  import '../_verture/constant-5317fc89.js';
@@ -27,8 +27,7 @@ import '../_verture/usePopupContainer-635f66f4.js';
27
27
  import 'dayjs';
28
28
  import '../Help/index.js';
29
29
  import '@para-ui/icons/Help';
30
- import '../_verture/slicedToArray-a8206399.js';
31
- import '../_verture/unsupportedIterableToArray-cb478f24.js';
30
+ import '../_verture/slicedToArray-75fa4188.js';
32
31
  import '../RadioGroup/index.js';
33
32
  import '../Radio/index.js';
34
33
  import '../Select/index.js';
@@ -52,6 +51,7 @@ import 'rc-input-number';
52
51
  import '@para-ui/icons/Up';
53
52
  import '../ComboSelect/index.js';
54
53
  import '../Table/index.js';
54
+ import '../_verture/defineProperty-f0e15205.js';
55
55
  import '@para-ui/icons/ScreenF';
56
56
  import '@para-ui/icons/UpTriangleF';
57
57
  import '@para-ui/icons/DownTriangleF';
@@ -69,9 +69,8 @@ import 'rc-pagination';
69
69
  import '@para-ui/icons/Right';
70
70
  import '@para-ui/icons/DoubleLeft';
71
71
  import '@para-ui/icons/DoubleRight';
72
- import '../_verture/index-28edf318.js';
73
- import '../_verture/toConsumableArray-8f4c9589.js';
74
- import '../_verture/defineProperty-f0e15205.js';
72
+ import '../_verture/index-44152845.js';
73
+ import '../_verture/toConsumableArray-c7a8028f.js';
75
74
  import '../_verture/index-8ac46bd9.js';
76
75
  import '../_verture/typeof-6ec38efd.js';
77
76
  import 'rc-tree';
@@ -1,5 +1,5 @@
1
- import { u as useModal } from '../_verture/modalContext-c57b51b7.js';
2
- export { F as FunctionModalProvider, u as default, a as useClose } from '../_verture/modalContext-c57b51b7.js';
1
+ import { u as useModal } from '../_verture/modalContext-10f0c5aa.js';
2
+ export { F as FunctionModalProvider, u as default, a as useClose } from '../_verture/modalContext-10f0c5aa.js';
3
3
  import '../_verture/tslib.es6-55ed4bd2.js';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
package/Image/index.js CHANGED
@@ -2,13 +2,13 @@ import { _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
4
  import React__default, { useState, useRef, useEffect, useContext, useMemo } from 'react';
5
- import { i as warningOnce, d as wrapperRaf, _ as _objectSpread2, w as warning, c as clsx, P as Portal, K as KeyCode, b as _objectWithoutProperties, a as _extends, j as useMergedState } from '../_verture/Portal-5bf66fed.js';
5
+ import { i as warningOnce, d as wrapperRaf, _ as _objectSpread2, w as warning, c as clsx, P as Portal, K as KeyCode, b as _objectWithoutProperties, a as _extends, j as useMergedState } from '../_verture/Portal-42560ff0.js';
6
6
  import { _ as _typeof, a as _defineProperty } from '../_verture/defineProperty-f0e15205.js';
7
- import { _ as _slicedToArray } from '../_verture/slicedToArray-a8206399.js';
7
+ import { _ as _slicedToArray } from '../_verture/slicedToArray-75fa4188.js';
8
8
  import Dialog from 'rc-dialog';
9
9
  import ReactDOM from 'react-dom';
10
10
  import CSSMotion from 'rc-motion';
11
- import { _ as _toConsumableArray } from '../_verture/toConsumableArray-8f4c9589.js';
11
+ import { _ as _toConsumableArray } from '../_verture/toConsumableArray-c7a8028f.js';
12
12
  import { $ as $prefixCls } from '../_verture/constant-5317fc89.js';
13
13
  import Sort from '@para-ui/icons/Sort';
14
14
  import Switch from '@para-ui/icons/Switch';
@@ -21,7 +21,6 @@ import RightCircleF from '@para-ui/icons/RightCircleF';
21
21
  import CloseCircleF from '@para-ui/icons/CloseCircleF';
22
22
  import PreviewOpen from '@para-ui/icons/PreviewOpen';
23
23
  import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
24
- import '../_verture/unsupportedIterableToArray-cb478f24.js';
25
24
 
26
25
  /* eslint-disable no-nested-ternary */
27
26
  function getClientSize() {
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @author linhd
3
+ * @date 2024/8/16 16:33
4
+ * @description 验证码
5
+ */
6
+ import React, { ReactNode } from 'react';
7
+ import { HelperTextDetailProps } from "../HelperText";
8
+ import InputCodeCard from './inputCodeCard';
9
+ import InputCodeInput from './inputCodeInput';
10
+ import './index.scss';
11
+ import { TextFieldProps } from "../TextField";
12
+ import { LabelTooltipProps } from "../Label";
13
+ export interface InputCodeCardProps extends HelperTextDetailProps {
14
+ /** 样式class */
15
+ className?: string;
16
+ /** style */
17
+ style?: React.CSSProperties;
18
+ /** 大小 */
19
+ size?: 'small' | 'medium' | 'large';
20
+ /** 类型 */
21
+ type?: 'card' | 'underline';
22
+ /** 卡片数量 */
23
+ cardNumber?: number;
24
+ /** 分隔符 没值 不带 */
25
+ separator?: ReactNode;
26
+ /** 辅助文案 */
27
+ sendText?: ReactNode;
28
+ /** 倒计时 */
29
+ countdown?: number;
30
+ /** 倒计时开始计时,不等于undefined就开始计时 */
31
+ refreshCountdown?: number | undefined;
32
+ /** 默认值 不受控 */
33
+ defaultValue?: string[];
34
+ /** 默认值 受控 */
35
+ value?: string[];
36
+ /** 输入框props */
37
+ inputProps?: (index: number) => TextFieldProps;
38
+ onChange?: (val: string[]) => void;
39
+ /** 最后一个输入框完成输入 */
40
+ onFinish?: (val: string) => void;
41
+ /** 重新发送 */
42
+ onReset?: () => Promise<boolean> | boolean;
43
+ [name: string]: any;
44
+ }
45
+ export interface InputCodeInputProps extends HelperTextDetailProps {
46
+ /** 样式class */
47
+ className?: string;
48
+ /** style */
49
+ style?: React.CSSProperties;
50
+ /** 大小 */
51
+ size?: 'small' | 'medium' | 'large';
52
+ /** 类型 */
53
+ type?: 'btnIntegrated' | 'btnSplit';
54
+ /** 标题 */
55
+ label?: ReactNode;
56
+ /** label 提示信息 */
57
+ labelTooltip?: LabelTooltipProps;
58
+ /** 提示语 */
59
+ placeholder?: ReactNode;
60
+ /** 是否必填 */
61
+ required?: boolean;
62
+ /** 倒计时 */
63
+ countdown?: number;
64
+ /** 默认值 不受控 */
65
+ defaultValue?: string;
66
+ /** 默认值 受控 */
67
+ value?: string;
68
+ /** 获取验证码宽度 */
69
+ getCodeWidth?: string;
70
+ /** 输入框props */
71
+ inputProps?: TextFieldProps;
72
+ onChange?: (val: string) => void;
73
+ /** 获取验证码事件 */
74
+ onGetCode?: () => Promise<boolean> | boolean;
75
+ [name: string]: any;
76
+ }
77
+ type MergedInputCode = {
78
+ Card: typeof InputCodeCard;
79
+ Input: typeof InputCodeInput;
80
+ };
81
+ export declare const InputCode: MergedInputCode;
82
+ export default InputCode;
@@ -0,0 +1,392 @@
1
+ import { a as __awaiter } from '../_verture/tslib.es6-55ed4bd2.js';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState, useRef, useEffect, Fragment } from 'react';
4
+ import { $ as $prefixCls } from '../_verture/constant-5317fc89.js';
5
+ import clsx from 'clsx';
6
+ import { u as useFormatMessage } from '../_verture/useFormatMessage-1fc7c957.js';
7
+ import HelperText from '../HelperText/index.js';
8
+ import { TextField } from '../TextField/index.js';
9
+ import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
10
+ import Label from '../Label/index.js';
11
+ import { Button } from '../Button/index.js';
12
+ import AutoTips from '../AutoTips/index.js';
13
+ import '../_verture/index-ca413216.js';
14
+ import '@paraview/lib';
15
+ import '@para-ui/icons/PreviewClose';
16
+ import '@para-ui/icons/PreviewOpen';
17
+ import '@para-ui/icons/CloseCircleF';
18
+ import '../Loading/index.js';
19
+ import '@para-ui/icons/LoadingF';
20
+ import '../Tooltip/index.js';
21
+ import 'rc-tooltip';
22
+ import 'rc-tooltip/lib/placements';
23
+ import '@para-ui/icons/Forbid';
24
+ import '../_verture/useGlobalProps-4ae1a007.js';
25
+ import '../_verture/index-bde7aabe.js';
26
+ import 'rc-dropdown';
27
+ import '../_verture/usePopupContainer-635f66f4.js';
28
+ import 'dayjs';
29
+ import '../Help/index.js';
30
+ import '@para-ui/icons/Help';
31
+ import '@para-ui/icons/Down';
32
+
33
+ var en = {
34
+ retrievedAgain: '{second} seconds to retrieve again',
35
+ reset: 'resend',
36
+ getCode: 'Get Code',
37
+ secondCountdown: '{second}s'
38
+ };
39
+
40
+ var zh = {
41
+ retrievedAgain: '{second}秒后可重新获取',
42
+ reset: '重新发送',
43
+ getCode: '获取验证码',
44
+ secondCountdown: '{second}秒'
45
+ };
46
+
47
+ var localeJson = {
48
+ zh: zh,
49
+ en: en
50
+ };
51
+
52
+ var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-input-code.paraui-v4-input-code-card {\n text-align: center;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .tip {\n margin-bottom: 20px;\n text-align: center;\n font-size: 14px;\n color: rgb(29, 33, 38);\n line-height: 20px;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .tip > span .countdown {\n display: inline-block;\n min-width: 20px;\n text-align: center;\n text-decoration: underline;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .tip > .reset-code {\n color: rgb(46, 101, 230);\n cursor: pointer;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .tip > .reset-code:hover {\n color: rgb(87, 131, 235);\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .content {\n display: inline-block;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .content > .content-card {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .content > .content-card > .card-input {\n width: 40px;\n height: 40px;\n margin-right: 10px;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .content > .content-card > .card-input > .text-field-content {\n height: 40px;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .content > .content-card > .card-input > .text-field-content > .text-field-content-within > .text-field-content-within-input {\n height: 38px;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .content > .content-card > .card-input > .text-field-content > .text-field-content-within > .text-field-content-within-input > input {\n text-align: center;\n font-size: 20px;\n padding: 0;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .content > .content-card > .separator {\n margin-right: 10px;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card > .content > .paraui-v4-helper-text {\n text-align: left;\n}\n.paraui-v4-input-code.paraui-v4-input-code-card.paraui-v4-input-code-card-underline > .content > .content-card > .card-input > .text-field-content {\n border-left: none;\n border-top: none;\n border-right: none;\n border-radius: 0;\n}";
53
+ styleInject(css_248z$2);
54
+
55
+ const InputCodeCard = props => {
56
+ const {
57
+ className,
58
+ style,
59
+ type = 'card',
60
+ size = 'large',
61
+ cardNumber = 6,
62
+ separator = '-',
63
+ defaultValue,
64
+ value,
65
+ countdown = 60,
66
+ refreshCountdown,
67
+ error = false,
68
+ hideErrorDom,
69
+ helperText,
70
+ sendText,
71
+ inputProps,
72
+ onChange,
73
+ onFinish,
74
+ onReset
75
+ } = props;
76
+ const intl = useFormatMessage('InputCode', localeJson);
77
+ const [valueCom, setValueCom] = useState(new Array(cardNumber).fill(''));
78
+ const [countdownCom, setCountdownCom] = useState(countdown);
79
+ const [countdownLoading, setCountdownLoading] = useState(false);
80
+ const comRef = useRef(null);
81
+ const constData = useRef({
82
+ countdown,
83
+ countdownCom
84
+ });
85
+ constData.current.countdownCom = countdownCom;
86
+ useEffect(() => {
87
+ if (props.defaultValue !== undefined) {
88
+ setValueCom(props.defaultValue);
89
+ }
90
+ onFocusDom(0);
91
+ return () => {
92
+ clearInterval(constData.current.timer);
93
+ };
94
+ }, []);
95
+ useEffect(() => {
96
+ if (value !== undefined) {
97
+ setValueCom(value);
98
+ }
99
+ }, [value]);
100
+ useEffect(() => {
101
+ if (refreshCountdown !== undefined && refreshCountdown !== null) {
102
+ startCountdown();
103
+ }
104
+ }, [refreshCountdown]);
105
+ // 倒计时
106
+ const startCountdown = () => {
107
+ clearInterval(constData.current.timer);
108
+ constData.current.countdownCom = constData.current.countdown;
109
+ setCountdownCom(constData.current.countdownCom);
110
+ onFocusDom(0);
111
+ setCountdownLoading(true);
112
+ constData.current.timer = setInterval(() => {
113
+ constData.current.countdownCom--;
114
+ setCountdownCom(constData.current.countdownCom);
115
+ if (constData.current.countdownCom === 0) {
116
+ clearInterval(constData.current.timer);
117
+ setCountdownLoading(false);
118
+ }
119
+ }, 1000);
120
+ };
121
+ // 得到焦点
122
+ const onFocusDom = index => {
123
+ if (!comRef.current) return;
124
+ const inputDom = comRef.current.querySelector(".card-input-".concat(index, " input"));
125
+ inputDom.focus();
126
+ };
127
+ const changeInput = index => event => {
128
+ let val = event.target.value.trim();
129
+ val = val[val.length - 1] || '';
130
+ valueCom[index] = val;
131
+ if (props.value === undefined) {
132
+ setValueCom([...valueCom]);
133
+ }
134
+ onChange && onChange([...valueCom]);
135
+ if (index === cardNumber - 1) {
136
+ // 最后一个
137
+ const str = valueCom.join('');
138
+ if (str.length === cardNumber) onFinish && onFinish(str);
139
+ } else {
140
+ if (val !== '') onFocusDom(++index);
141
+ }
142
+ };
143
+ const onKeydown = index => event => {
144
+ var _a;
145
+ if (event.keyCode === 8 && index !== 0 && ((_a = event.target) === null || _a === void 0 ? void 0 : _a.value) === '') {
146
+ onFocusDom(index - 1);
147
+ }
148
+ };
149
+ const handleContent = () => {
150
+ const evenNUmber = cardNumber % 2;
151
+ return jsx("div", Object.assign({
152
+ className: 'content-card'
153
+ }, {
154
+ children: new Array(cardNumber).fill(1).map((item, index) => {
155
+ return jsxs(Fragment, {
156
+ children: [jsx(TextField, Object.assign({}, inputProps === null || inputProps === void 0 ? void 0 : inputProps(index), {
157
+ className: "card-input card-input-".concat(index),
158
+ error: error,
159
+ hideErrorDom: true,
160
+ value: valueCom[index],
161
+ onChange: changeInput(index),
162
+ onKeydown: onKeydown(index)
163
+ })), separator && evenNUmber === 0 && index + 1 === cardNumber / 2 && jsx("div", Object.assign({
164
+ className: 'separator'
165
+ }, {
166
+ children: separator
167
+ }))]
168
+ }, index);
169
+ })
170
+ }));
171
+ };
172
+ const onResetCom = () => __awaiter(void 0, void 0, void 0, function* () {
173
+ if (constData.current.reqLoading) return;
174
+ constData.current.reqLoading = true;
175
+ const bol = yield onReset === null || onReset === void 0 ? void 0 : onReset();
176
+ constData.current.reqLoading = false;
177
+ if (bol) {
178
+ startCountdown();
179
+ }
180
+ });
181
+ return jsxs("div", Object.assign({
182
+ className: clsx(className, "".concat($prefixCls, "-input-code"), "".concat($prefixCls, "-input-code-card"), "".concat($prefixCls, "-input-code-card-").concat(size), "".concat($prefixCls, "-input-code-card-").concat(type), {
183
+ ["".concat($prefixCls, "-input-code-card-countdown")]: countdownLoading,
184
+ ["".concat($prefixCls, "-input-code-card-error")]: error
185
+ }),
186
+ style: style,
187
+ ref: comRef
188
+ }, {
189
+ children: [refreshCountdown !== undefined && refreshCountdown !== null && jsxs("div", Object.assign({
190
+ className: 'tip'
191
+ }, {
192
+ children: [jsx("span", {
193
+ children: sendText
194
+ }), countdownLoading ? jsx("span", {
195
+ children: intl({
196
+ id: 'retrievedAgain'
197
+ }, {
198
+ second: jsx("span", Object.assign({
199
+ className: 'countdown'
200
+ }, {
201
+ children: countdownCom
202
+ }), 'countdown')
203
+ })
204
+ }) : jsx("span", Object.assign({
205
+ className: 'reset-code',
206
+ onClick: onResetCom
207
+ }, {
208
+ children: intl({
209
+ id: 'reset'
210
+ })
211
+ }))]
212
+ })), jsxs("div", Object.assign({
213
+ className: 'content'
214
+ }, {
215
+ children: [handleContent(), jsx(HelperText, {
216
+ error: error,
217
+ helperText: helperText,
218
+ hideErrorDom: hideErrorDom
219
+ })]
220
+ }))]
221
+ }));
222
+ };
223
+
224
+ var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-input-code.paraui-v4-input-code-input > .content {\n display: flex;\n}\n.paraui-v4-input-code.paraui-v4-input-code-input > .content > .get-code {\n margin-left: 10px;\n text-align: center;\n}\n.paraui-v4-input-code.paraui-v4-input-code-input > .content > .content-input {\n flex: 1;\n overflow: hidden;\n}\n.paraui-v4-input-code.paraui-v4-input-code-input > .content > .content-input .text-field-content-after {\n padding: 0;\n}\n.paraui-v4-input-code.paraui-v4-input-code-input > .content > .content-input .text-field-content-after .get-code-input {\n padding: 0 10px;\n color: rgb(46, 101, 230);\n cursor: pointer;\n text-align: center;\n}\n.paraui-v4-input-code.paraui-v4-input-code-input > .content > .content-input .text-field-content-after .get-code-input:hover {\n color: rgb(87, 131, 235);\n}\n.paraui-v4-input-code.paraui-v4-input-code-input > .content > .content-input > .paraui-v4-helper-text {\n display: none;\n}\n.paraui-v4-input-code.paraui-v4-input-code-input.paraui-v4-input-code-input-countdown > .content .text-field-content-after .get-code-input {\n color: rgb(92, 101, 115);\n cursor: not-allowed;\n}\n.paraui-v4-input-code.paraui-v4-input-code-input.paraui-v4-input-code-input-countdown > .content .text-field-content-after .get-code-input:hover {\n color: rgb(92, 101, 115);\n}";
225
+ styleInject(css_248z$1);
226
+
227
+ const InputCodeInput = props => {
228
+ const {
229
+ className,
230
+ style,
231
+ size,
232
+ type = 'btnIntegrated',
233
+ label,
234
+ labelTooltip,
235
+ placeholder,
236
+ required,
237
+ error = false,
238
+ hideErrorDom,
239
+ helperText,
240
+ countdown = 60,
241
+ defaultValue,
242
+ value,
243
+ onGetCode,
244
+ getCodeWidth = '100px',
245
+ inputProps,
246
+ onChange
247
+ } = props;
248
+ const intl = useFormatMessage('InputCode', localeJson);
249
+ const [valueCom, setValueCom] = useState('');
250
+ const [countdownCom, setCountdownCom] = useState(countdown);
251
+ const [countdownLoading, setCountdownLoading] = useState(false);
252
+ const comRef = useRef(null);
253
+ const constData = useRef({
254
+ countdown,
255
+ countdownCom
256
+ });
257
+ useEffect(() => {
258
+ if (props.defaultValue !== undefined) {
259
+ setValueCom(props.defaultValue);
260
+ }
261
+ return () => {
262
+ clearInterval(constData.current.timer);
263
+ };
264
+ }, []);
265
+ useEffect(() => {
266
+ if (value !== undefined) {
267
+ setValueCom(value);
268
+ }
269
+ }, [value]);
270
+ // 倒计时
271
+ const startCountdown = () => {
272
+ clearInterval(constData.current.timer);
273
+ constData.current.countdownCom = constData.current.countdown;
274
+ setCountdownCom(constData.current.countdownCom);
275
+ setCountdownLoading(true);
276
+ constData.current.timer = setInterval(() => {
277
+ constData.current.countdownCom--;
278
+ setCountdownCom(constData.current.countdownCom);
279
+ if (constData.current.countdownCom === 0) {
280
+ clearInterval(constData.current.timer);
281
+ setCountdownLoading(false);
282
+ }
283
+ }, 1000);
284
+ };
285
+ /** 处理标题 */
286
+ const renderLabel = () => {
287
+ if (label || required) {
288
+ return jsx(Label, Object.assign({
289
+ label: label,
290
+ required: required
291
+ }, labelTooltip));
292
+ }
293
+ };
294
+ /** 获取验证码事件 */
295
+ const getCodeFunc = () => __awaiter(void 0, void 0, void 0, function* () {
296
+ if (constData.current.reqLoading) return;
297
+ constData.current.reqLoading = true;
298
+ const bol = yield onGetCode === null || onGetCode === void 0 ? void 0 : onGetCode();
299
+ constData.current.reqLoading = false;
300
+ if (bol) {
301
+ startCountdown();
302
+ }
303
+ });
304
+ const handleCodeText = () => {
305
+ if (countdownLoading) {
306
+ return intl({
307
+ id: 'secondCountdown'
308
+ }, {
309
+ second: countdownCom
310
+ });
311
+ }
312
+ return intl({
313
+ id: "getCode"
314
+ });
315
+ };
316
+ /** 渲染输入框按钮 */
317
+ const addonAfterRender = () => {
318
+ if (type === 'btnSplit') return undefined;
319
+ return jsx("div", Object.assign({
320
+ className: 'get-code-input',
321
+ style: {
322
+ width: getCodeWidth
323
+ },
324
+ onClick: getCodeFunc
325
+ }, {
326
+ children: jsx(AutoTips, {
327
+ children: handleCodeText()
328
+ })
329
+ }));
330
+ };
331
+ /** 改变输入框 */
332
+ const onChangeInput = event => {
333
+ const val = event.target.value.trim();
334
+ if (props.value === undefined) {
335
+ setValueCom(val);
336
+ }
337
+ onChange && onChange(val);
338
+ };
339
+ /** 渲染内容 */
340
+ const renderContent = () => {
341
+ return jsxs("div", Object.assign({
342
+ className: 'content'
343
+ }, {
344
+ children: [jsx(TextField, Object.assign({}, inputProps, {
345
+ className: 'content-input',
346
+ size: size,
347
+ error: error,
348
+ hideErrorDom: true,
349
+ placeholder: placeholder,
350
+ addonAfter: addonAfterRender(),
351
+ value: valueCom,
352
+ onChange: onChangeInput
353
+ })), type === 'btnSplit' && jsx(Button, Object.assign({
354
+ size: size,
355
+ className: 'get-code',
356
+ style: {
357
+ width: getCodeWidth
358
+ },
359
+ disabled: countdownLoading,
360
+ onClick: getCodeFunc
361
+ }, {
362
+ children: jsx(AutoTips, {
363
+ children: handleCodeText()
364
+ })
365
+ }))]
366
+ }));
367
+ };
368
+ return jsxs("div", Object.assign({
369
+ className: clsx(className, "".concat($prefixCls, "-input-code"), "".concat($prefixCls, "-input-code-input"), "".concat($prefixCls, "-input-code-input-").concat(size), "".concat($prefixCls, "-input-code-input-").concat(type), {
370
+ ["".concat($prefixCls, "-input-code-input-countdown")]: countdownLoading,
371
+ ["".concat($prefixCls, "-input-code-input-error")]: error
372
+ }),
373
+ style: style,
374
+ ref: comRef
375
+ }, {
376
+ children: [renderLabel(), renderContent(), jsx(HelperText, {
377
+ error: error,
378
+ helperText: helperText,
379
+ hideErrorDom: hideErrorDom
380
+ })]
381
+ }));
382
+ };
383
+
384
+ var css_248z = "@charset \"UTF-8\";\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/";
385
+ styleInject(css_248z);
386
+
387
+ const InputCode = {
388
+ Card: InputCodeCard,
389
+ Input: InputCodeInput
390
+ };
391
+
392
+ export { InputCode, InputCode as default };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @author linhd
3
+ * @date 2024/8/16 16:33
4
+ * @description 验证码
5
+ */
6
+ import { FunctionComponent } from 'react';
7
+ import { InputCodeCardProps } from "../index";
8
+ import './index.scss';
9
+ export declare const InputCodeCard: FunctionComponent<InputCodeCardProps>;
10
+ export default InputCodeCard;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @author linhd
3
+ * @date 2024/8/16 16:33
4
+ * @description 验证码
5
+ */
6
+ import { FunctionComponent } from 'react';
7
+ import { InputCodeInputProps } from "../index";
8
+ import './index.scss';
9
+ export declare const InputCodeInput: FunctionComponent<InputCodeInputProps>;
10
+ export default InputCodeInput;
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ retrievedAgain: string;
3
+ reset: string;
4
+ getCode: string;
5
+ secondCountdown: string;
6
+ };
7
+ export default _default;