@aloudata/aloudata-design 2.15.2-beta.1 → 2.15.3
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.
|
@@ -6,11 +6,15 @@ interface IProps {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
width?: number;
|
|
8
8
|
fontStyle?: CSSProperties;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated 如果要控制编辑态请使用 isEdit
|
|
11
|
+
*/
|
|
9
12
|
focus?: boolean;
|
|
13
|
+
isEdit?: boolean;
|
|
10
14
|
maxLength?: number;
|
|
11
15
|
distance?: [left: number, right: number];
|
|
12
16
|
validateValue?: (value: string) => boolean;
|
|
13
17
|
readonly?: boolean;
|
|
14
18
|
}
|
|
15
|
-
declare const RenameInput: ({ value: propsValue, onConfirm, className, width, fontStyle,
|
|
19
|
+
declare const RenameInput: ({ value: propsValue, onConfirm, className, width, fontStyle, maxLength, validateValue, onError, readonly, isEdit: propsIsEdit, }: IProps) => React.JSX.Element;
|
|
16
20
|
export default RenameInput;
|
|
@@ -13,21 +13,21 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
13
13
|
import classNames from 'classnames';
|
|
14
14
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
15
15
|
var defaultWidth = 20;
|
|
16
|
-
var PADDING_WIDTH =
|
|
16
|
+
var PADDING_WIDTH = 4;
|
|
17
17
|
var RenameInput = function RenameInput(_ref) {
|
|
18
18
|
var propsValue = _ref.value,
|
|
19
19
|
onConfirm = _ref.onConfirm,
|
|
20
20
|
className = _ref.className,
|
|
21
21
|
width = _ref.width,
|
|
22
22
|
fontStyle = _ref.fontStyle,
|
|
23
|
-
_ref$focus = _ref.focus,
|
|
24
|
-
focus = _ref$focus === void 0 ? false : _ref$focus,
|
|
25
23
|
maxLength = _ref.maxLength,
|
|
26
24
|
validateValue = _ref.validateValue,
|
|
27
25
|
onError = _ref.onError,
|
|
28
26
|
_ref$readonly = _ref.readonly,
|
|
29
|
-
readonly = _ref$readonly === void 0 ? false : _ref$readonly
|
|
30
|
-
|
|
27
|
+
readonly = _ref$readonly === void 0 ? false : _ref$readonly,
|
|
28
|
+
_ref$isEdit = _ref.isEdit,
|
|
29
|
+
propsIsEdit = _ref$isEdit === void 0 ? false : _ref$isEdit;
|
|
30
|
+
var _useState = useState(propsIsEdit),
|
|
31
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
32
|
isEdit = _useState2[0],
|
|
33
33
|
setIsEdit = _useState2[1];
|
|
@@ -53,7 +53,12 @@ var RenameInput = function RenameInput(_ref) {
|
|
|
53
53
|
}
|
|
54
54
|
}, [width, value, isEdit]);
|
|
55
55
|
useEffect(function () {
|
|
56
|
-
if (
|
|
56
|
+
if (isEdit) {
|
|
57
|
+
setValue(propsValue);
|
|
58
|
+
}
|
|
59
|
+
}, [isEdit, propsValue]);
|
|
60
|
+
useEffect(function () {
|
|
61
|
+
if (propsIsEdit) {
|
|
57
62
|
setIsEdit(true);
|
|
58
63
|
setTimeout(function () {
|
|
59
64
|
if (inputRef.current) {
|
|
@@ -61,8 +66,10 @@ var RenameInput = function RenameInput(_ref) {
|
|
|
61
66
|
inputRef.current.select();
|
|
62
67
|
}
|
|
63
68
|
}, 100);
|
|
69
|
+
} else {
|
|
70
|
+
setIsEdit(false);
|
|
64
71
|
}
|
|
65
|
-
}, [
|
|
72
|
+
}, [propsIsEdit]);
|
|
66
73
|
if (isEdit && !readonly) {
|
|
67
74
|
return /*#__PURE__*/React.createElement("div", {
|
|
68
75
|
className: "ald-rename-input"
|
|
@@ -85,7 +92,6 @@ var RenameInput = function RenameInput(_ref) {
|
|
|
85
92
|
}
|
|
86
93
|
setIsEdit(false);
|
|
87
94
|
},
|
|
88
|
-
autoFocus: focus,
|
|
89
95
|
onFocus: function onFocus() {
|
|
90
96
|
var _inputRef$current2;
|
|
91
97
|
(_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.select();
|
|
@@ -113,8 +119,9 @@ var RenameInput = function RenameInput(_ref) {
|
|
|
113
119
|
return /*#__PURE__*/React.createElement("div", {
|
|
114
120
|
className: classNames(className, 'ald-rename-input-text'),
|
|
115
121
|
style: fontStyle,
|
|
116
|
-
|
|
122
|
+
onMouseMove: function onMouseMove() {
|
|
117
123
|
setIsEdit(true);
|
|
124
|
+
setValue(propsValue);
|
|
118
125
|
},
|
|
119
126
|
onClick: function onClick() {
|
|
120
127
|
var _inputRef$current6;
|
|
@@ -16,11 +16,14 @@
|
|
|
16
16
|
align-items: center;
|
|
17
17
|
padding: 2px;
|
|
18
18
|
border: 1px solid transparent;
|
|
19
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
|
20
|
+
'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
|
|
21
|
+
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
.ald-rename-input-wrapper {
|
|
22
25
|
box-sizing: border-box;
|
|
23
|
-
height:
|
|
26
|
+
height: 22px;
|
|
24
27
|
border: 0;
|
|
25
28
|
padding: 2px;
|
|
26
29
|
font-size: 13px;
|