@aloudata/aloudata-design 2.15.2 → 2.15.4

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.
@@ -183,12 +183,18 @@ var BaseSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
183
183
  }
184
184
  });
185
185
  }, [displayMenu, isMultipleMode, onToggleOpen, onOptionSelect]);
186
+ var onSelectClick = React.useCallback(function (e) {
187
+ if (disabled) {
188
+ return;
189
+ }
190
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
191
+ }, [disabled, onClick]);
186
192
  return /*#__PURE__*/React.createElement("div", {
187
193
  className: mergedClassName,
188
194
  style: _objectSpread(_objectSpread({}, widthStyle), style),
189
195
  ref: selectRef,
190
196
  id: id,
191
- onClick: onClick,
197
+ onClick: onSelectClick,
192
198
  onMouseEnter: function onMouseEnter() {
193
199
  setIsHover(true);
194
200
  },
@@ -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, focus, maxLength, validateValue, onError, readonly, }: IProps) => React.JSX.Element;
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 = 2;
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
- var _useState = useState(false),
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];
@@ -35,6 +35,9 @@ var RenameInput = function RenameInput(_ref) {
35
35
  _useState4 = _slicedToArray(_useState3, 2),
36
36
  value = _useState4[0],
37
37
  setValue = _useState4[1];
38
+ useEffect(function () {
39
+ setValue(propsValue);
40
+ }, [propsValue]);
38
41
  var divRef = useRef(null);
39
42
  var inputRef = useRef(null);
40
43
  var handleBlur = useCallback(function () {
@@ -50,10 +53,23 @@ var RenameInput = function RenameInput(_ref) {
50
53
  }
51
54
  }, [width, value, isEdit]);
52
55
  useEffect(function () {
53
- if (focus && inputRef.current) {
54
- inputRef.current.select();
56
+ if (isEdit) {
57
+ setValue(propsValue);
58
+ }
59
+ }, [isEdit, propsValue]);
60
+ useEffect(function () {
61
+ if (propsIsEdit) {
62
+ setIsEdit(true);
63
+ setTimeout(function () {
64
+ if (inputRef.current) {
65
+ inputRef.current.focus();
66
+ inputRef.current.select();
67
+ }
68
+ }, 100);
69
+ } else {
70
+ setIsEdit(false);
55
71
  }
56
- }, [focus]);
72
+ }, [propsIsEdit]);
57
73
  if (isEdit && !readonly) {
58
74
  return /*#__PURE__*/React.createElement("div", {
59
75
  className: "ald-rename-input"
@@ -76,7 +92,6 @@ var RenameInput = function RenameInput(_ref) {
76
92
  }
77
93
  setIsEdit(false);
78
94
  },
79
- autoFocus: focus,
80
95
  onFocus: function onFocus() {
81
96
  var _inputRef$current2;
82
97
  (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.select();
@@ -104,12 +119,12 @@ var RenameInput = function RenameInput(_ref) {
104
119
  return /*#__PURE__*/React.createElement("div", {
105
120
  className: classNames(className, 'ald-rename-input-text'),
106
121
  style: fontStyle,
107
- onMouseEnter: function onMouseEnter() {
122
+ onMouseMove: function onMouseMove() {
108
123
  setIsEdit(true);
124
+ setValue(propsValue);
109
125
  },
110
126
  onClick: function onClick() {
111
127
  var _inputRef$current6;
112
- setValue(propsValue);
113
128
  (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : _inputRef$current6.select();
114
129
  }
115
130
  }, propsValue);
@@ -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: 24px;
26
+ height: 22px;
24
27
  border: 0;
25
28
  padding: 2px;
26
29
  font-size: 13px;