@qsxy/element-plus-react 1.0.1 → 1.0.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.
Files changed (256) hide show
  1. package/dist/Alert/Alert.d.ts +7 -0
  2. package/dist/Alert/Alert.js +98 -0
  3. package/dist/Alert/index.d.ts +2 -0
  4. package/dist/Alert/index.js +1 -0
  5. package/dist/Alert/typings.d.ts +45 -0
  6. package/dist/Alert/typings.js +1 -0
  7. package/dist/Calendar/Calendar.js +12 -3
  8. package/dist/Calendar/Footer.js +4 -2
  9. package/dist/Calendar/QuarterPanel.d.ts +4 -0
  10. package/dist/Calendar/QuarterPanel.js +109 -0
  11. package/dist/Calendar/WeekPanel.js +1 -1
  12. package/dist/Calendar/typings.d.ts +1 -1
  13. package/dist/Card/Card.js +13 -6
  14. package/dist/Card/typings.d.ts +1 -1
  15. package/dist/Cascader/Cascader.js +1 -1
  16. package/dist/Cascader/useCascader.d.ts +0 -14
  17. package/dist/Cascader/useCascader.js +33 -32
  18. package/dist/Checkbox/Checkbox.js +3 -2
  19. package/dist/ConfigProvider/ConfigProvider.js +2 -24
  20. package/dist/ConfigProvider/ConfigProviderContext.js +1 -1
  21. package/dist/ConfigProvider/typings.d.ts +1 -1
  22. package/dist/Container/Main.d.ts +1 -1
  23. package/dist/Container/typings.d.ts +1 -1
  24. package/dist/DatePicker/DatePicker.js +38 -12
  25. package/dist/DatePicker/DateRangePicker.js +27 -9
  26. package/dist/DatePicker/main.js +1 -1
  27. package/dist/DatePicker/typings.d.ts +1 -1
  28. package/dist/DateTimePicker/DateTimePicker.js +2 -2
  29. package/dist/Dialog/Dialog.js +5 -12
  30. package/dist/Input/Input.js +190 -149
  31. package/dist/Input/InputRange.js +1 -1
  32. package/dist/Input/TextArea.js +87 -12
  33. package/dist/Input/typings.d.ts +56 -5
  34. package/dist/Input/useComposition.d.ts +23 -0
  35. package/dist/Input/useComposition.js +63 -0
  36. package/dist/Input/utils.d.ts +7 -0
  37. package/dist/Input/utils.js +95 -0
  38. package/dist/InputNumber/InputNumber.js +351 -141
  39. package/dist/InputNumber/typings.d.ts +16 -2
  40. package/dist/Loading/Loading.js +5 -2
  41. package/dist/Menu/Menu.js +25 -1
  42. package/dist/Menu/MenuItem.js +4 -2
  43. package/dist/Menu/SubMenu.js +2 -2
  44. package/dist/Menu/SubMenuCollapseTransition.js +14 -9
  45. package/dist/Menu/typings.d.ts +2 -1
  46. package/dist/Message/Message.js +51 -23
  47. package/dist/Message/index.js +8 -10
  48. package/dist/Message/typings.d.ts +8 -5
  49. package/dist/MessageBox/MessageBox.js +52 -30
  50. package/dist/MessageBox/index.d.ts +2 -1
  51. package/dist/MessageBox/index.js +4 -2
  52. package/dist/MessageBox/typings.d.ts +3 -0
  53. package/dist/Notification/Notification.js +26 -19
  54. package/dist/Select/Option.js +30 -14
  55. package/dist/Select/SelectContext.d.ts +5 -5
  56. package/dist/Select/SelectContext.js +2 -1
  57. package/dist/Select/SelectCore.d.ts +2 -2
  58. package/dist/Select/SelectCore.js +172 -449
  59. package/dist/Select/SelectDropdown.js +85 -155
  60. package/dist/Select/index.d.ts +1 -1
  61. package/dist/Select/typings.d.ts +52 -22
  62. package/dist/Select/useSelect.d.ts +128 -0
  63. package/dist/Select/useSelect.js +524 -0
  64. package/dist/Space/Space.d.ts +4 -0
  65. package/dist/Space/Space.js +128 -0
  66. package/dist/Space/SpaceItem.d.ts +7 -0
  67. package/dist/Space/SpaceItem.js +14 -0
  68. package/dist/Space/index.d.ts +3 -0
  69. package/dist/Space/index.js +2 -0
  70. package/dist/Space/typings.d.ts +26 -0
  71. package/dist/Space/typings.js +1 -0
  72. package/dist/Space/useSpace.d.ts +7 -0
  73. package/dist/Space/useSpace.js +104 -0
  74. package/dist/Statistic/Statistic.d.ts +4 -0
  75. package/dist/Statistic/Statistic.js +92 -0
  76. package/dist/Statistic/index.d.ts +2 -0
  77. package/dist/Statistic/index.js +1 -0
  78. package/dist/Statistic/typings.d.ts +28 -0
  79. package/dist/Statistic/typings.js +1 -0
  80. package/dist/Switch/Switch.js +2 -2
  81. package/dist/Table/Table.js +3 -0
  82. package/dist/Table/typings.d.ts +2 -0
  83. package/dist/Table/util.js +6 -5
  84. package/dist/Tag/Tag.js +22 -17
  85. package/dist/Tag/typings.d.ts +1 -1
  86. package/dist/Text/Text.d.ts +4 -0
  87. package/dist/Text/Text.js +84 -0
  88. package/dist/Text/index.d.ts +2 -0
  89. package/dist/Text/index.js +1 -0
  90. package/dist/Text/typings.d.ts +15 -0
  91. package/dist/Text/typings.js +1 -0
  92. package/dist/TimePicker/TimePicker.js +2 -2
  93. package/dist/Tree/CollapseTransition.d.ts +7 -0
  94. package/dist/Tree/CollapseTransition.js +60 -0
  95. package/dist/Tree/Tree.d.ts +3 -140
  96. package/dist/Tree/Tree.js +350 -77
  97. package/dist/Tree/TreeContext.d.ts +9 -0
  98. package/dist/Tree/TreeContext.js +14 -0
  99. package/dist/Tree/TreeNode.d.ts +5 -3
  100. package/dist/Tree/TreeNode.js +321 -331
  101. package/dist/Tree/TreeNodeContent.d.ts +9 -0
  102. package/dist/Tree/TreeNodeContent.js +22 -0
  103. package/dist/Tree/index.d.ts +3 -8
  104. package/dist/Tree/index.js +1 -4
  105. package/dist/Tree/model/node.d.ts +62 -0
  106. package/dist/Tree/model/node.js +601 -0
  107. package/dist/Tree/model/tree-store.d.ts +52 -0
  108. package/dist/Tree/model/tree-store.js +510 -0
  109. package/dist/Tree/model/useDragNode.d.ts +30 -0
  110. package/dist/Tree/model/useDragNode.js +293 -0
  111. package/dist/Tree/model/useKeydown.d.ts +0 -0
  112. package/dist/Tree/model/useKeydown.js +104 -0
  113. package/dist/Tree/model/useNodeExpandEventBroadcast.d.ts +15 -0
  114. package/dist/Tree/model/useNodeExpandEventBroadcast.js +54 -0
  115. package/dist/Tree/model/util.d.ts +7 -0
  116. package/dist/Tree/model/util.js +24 -0
  117. package/dist/Tree/typings.d.ts +225 -114
  118. package/dist/TreeSelect/TreeSelect.d.ts +2 -10
  119. package/dist/TreeSelect/TreeSelect.js +90 -566
  120. package/dist/TreeSelect/TreeSelectOption.d.ts +6 -0
  121. package/dist/TreeSelect/TreeSelectOption.js +62 -0
  122. package/dist/TreeSelect/cacheOptions.d.ts +9 -0
  123. package/dist/TreeSelect/cacheOptions.js +22 -0
  124. package/dist/TreeSelect/index.d.ts +0 -1
  125. package/dist/TreeSelect/typings.d.ts +11 -63
  126. package/dist/TreeSelect/useSelect.d.ts +125 -0
  127. package/dist/TreeSelect/useSelect.js +104 -0
  128. package/dist/TreeSelect/useTree.d.ts +130 -0
  129. package/dist/TreeSelect/useTree.js +285 -0
  130. package/dist/TreeSelect/utils.d.ts +10 -0
  131. package/dist/TreeSelect/utils.js +38 -0
  132. package/dist/Upload/UploadContent.js +2 -0
  133. package/dist/Upload/ajax.js +3 -0
  134. package/dist/Upload/typings.d.ts +4 -0
  135. package/dist/Util/aria.d.ts +25 -0
  136. package/dist/Util/aria.js +118 -0
  137. package/dist/Util/base.d.ts +5 -0
  138. package/dist/Util/base.js +140 -1
  139. package/dist/config/Constants.d.ts +3 -0
  140. package/dist/config/Constants.js +8 -0
  141. package/dist/hooks/index.d.ts +1 -0
  142. package/dist/hooks/index.js +1 -0
  143. package/dist/hooks/popperPropsUtils.js +1 -1
  144. package/dist/hooks/treePropsUtils.d.ts +3 -3
  145. package/dist/hooks/treePropsUtils.js +2 -2
  146. package/dist/hooks/useCalcInputWidth.d.ts +8 -0
  147. package/dist/{Tree/useUnmount.js → hooks/useCalcInputWidth.js} +23 -27
  148. package/dist/hooks/useComposition.d.ts +16 -0
  149. package/dist/hooks/useComposition.js +39 -0
  150. package/dist/hooks/useConfigProvider.d.ts +27 -0
  151. package/dist/hooks/useConfigProvider.js +78 -0
  152. package/dist/hooks/useCursor.d.ts +2 -0
  153. package/dist/hooks/useCursor.js +52 -0
  154. package/dist/hooks/useFocusController.d.ts +27 -0
  155. package/dist/hooks/useFocusController.js +72 -0
  156. package/dist/hooks/useResizeObserver.js +6 -6
  157. package/dist/index.css +1 -1
  158. package/dist/index.d.ts +18 -11
  159. package/dist/index.js +11 -5
  160. package/dist/locale/en.d.ts +15 -0
  161. package/dist/locale/en.js +15 -0
  162. package/dist/locale/zhCn.d.ts +15 -0
  163. package/dist/locale/zhCn.js +15 -0
  164. package/package.json +1 -1
  165. package/theme-chalk/alert.scss +115 -0
  166. package/theme-chalk/aside.scss +8 -8
  167. package/theme-chalk/button-group.scss +80 -80
  168. package/theme-chalk/button.scss +304 -304
  169. package/theme-chalk/calendar/date-table.scss +164 -164
  170. package/theme-chalk/calendar/index.scss +1 -0
  171. package/theme-chalk/calendar/quarter-table.scss +78 -0
  172. package/theme-chalk/checkbox.scss +34 -0
  173. package/theme-chalk/color/index.scss +20 -20
  174. package/theme-chalk/common/transition.scss +142 -142
  175. package/theme-chalk/common/var.scss +1 -1
  176. package/theme-chalk/container.scss +14 -14
  177. package/theme-chalk/dark/css-vars.scss +39 -39
  178. package/theme-chalk/dark/var.scss +225 -225
  179. package/theme-chalk/date-picker.scss +12 -12
  180. package/theme-chalk/drawer.scss +1 -0
  181. package/theme-chalk/footer.scss +12 -12
  182. package/theme-chalk/header.scss +12 -12
  183. package/theme-chalk/index.scss +4 -0
  184. package/theme-chalk/input/input-range.scss +2 -1
  185. package/theme-chalk/input/input.scss +298 -437
  186. package/theme-chalk/input/input.scss--bak +578 -0
  187. package/theme-chalk/input-number.bak +172 -0
  188. package/theme-chalk/input-number.scss +192 -172
  189. package/theme-chalk/link.scss +87 -87
  190. package/theme-chalk/main.scss +14 -14
  191. package/theme-chalk/menu.scss +353 -353
  192. package/theme-chalk/message.scss +104 -178
  193. package/theme-chalk/mixins/_button.scss +224 -224
  194. package/theme-chalk/mixins/_col.scss +33 -33
  195. package/theme-chalk/mixins/_var.scss +67 -67
  196. package/theme-chalk/mixins/config.scss +5 -5
  197. package/theme-chalk/mixins/function.scss +99 -99
  198. package/theme-chalk/mixins/mixins.scss +240 -240
  199. package/theme-chalk/mixins/utils.scss +39 -39
  200. package/theme-chalk/notification.bak +156 -0
  201. package/theme-chalk/notification.scss +109 -156
  202. package/theme-chalk/popper.scss +104 -104
  203. package/theme-chalk/radio-button.scss +169 -169
  204. package/theme-chalk/select/index.scss +222 -191
  205. package/theme-chalk/select/index.scss--bak +247 -0
  206. package/theme-chalk/select/option-group.scss +2 -2
  207. package/theme-chalk/select/option.scss +2 -2
  208. package/theme-chalk/select/select-dropdown.scss +2 -2
  209. package/theme-chalk/space.scss +20 -0
  210. package/theme-chalk/statistic.scss +35 -0
  211. package/theme-chalk/switch.scss +300 -300
  212. package/theme-chalk/tag.scss +150 -172
  213. package/theme-chalk/tag.scss--bak +203 -0
  214. package/theme-chalk/text.scss +48 -0
  215. package/theme-chalk/transition.scss +34 -4
  216. package/theme-chalk/tree-select.scss +41 -25
  217. package/theme-chalk/tree.scss +136 -0
  218. package/theme-chalk/var.scss +83 -83
  219. package/dist/Tree/DirectoryTree.d.ts +0 -15
  220. package/dist/Tree/DirectoryTree.js +0 -183
  221. package/dist/Tree/DropIndicator.d.ts +0 -8
  222. package/dist/Tree/DropIndicator.js +0 -34
  223. package/dist/Tree/Indent.d.ts +0 -9
  224. package/dist/Tree/Indent.js +0 -25
  225. package/dist/Tree/MotionTreeNode.d.ts +0 -14
  226. package/dist/Tree/MotionTreeNode.js +0 -125
  227. package/dist/Tree/NodeList.d.ts +0 -50
  228. package/dist/Tree/NodeList.js +0 -301
  229. package/dist/Tree/RCTree.d.ts +0 -248
  230. package/dist/Tree/RCTree.js +0 -1216
  231. package/dist/Tree/contextTypes.d.ts +0 -69
  232. package/dist/Tree/contextTypes.js +0 -9
  233. package/dist/Tree/typings.tsx--bak +0 -245
  234. package/dist/Tree/useUnmount.d.ts +0 -5
  235. package/dist/Tree/util.d.ts +0 -51
  236. package/dist/Tree/util.js +0 -303
  237. package/dist/Tree/utils/conductUtil.d.ts +0 -17
  238. package/dist/Tree/utils/conductUtil.js +0 -209
  239. package/dist/Tree/utils/dictUtil.d.ts +0 -13
  240. package/dist/Tree/utils/dictUtil.js +0 -75
  241. package/dist/Tree/utils/diffUtil.d.ts +0 -7
  242. package/dist/Tree/utils/diffUtil.js +0 -48
  243. package/dist/Tree/utils/dropIndicator.d.ts +0 -11
  244. package/dist/Tree/utils/dropIndicator.js +0 -36
  245. package/dist/Tree/utils/iconUtil.d.ts +0 -5
  246. package/dist/Tree/utils/iconUtil.js +0 -62
  247. package/dist/Tree/utils/keyUtil.d.ts +0 -2
  248. package/dist/Tree/utils/keyUtil.js +0 -3
  249. package/dist/Tree/utils/motion.d.ts +0 -10
  250. package/dist/Tree/utils/motion.js +0 -54
  251. package/dist/Tree/utils/pickAttrs.d.ts +0 -11
  252. package/dist/Tree/utils/pickAttrs.js +0 -51
  253. package/dist/Tree/utils/treeUtil.d.ts +0 -86
  254. package/dist/Tree/utils/treeUtil.js +0 -364
  255. package/dist/TreeSelect/Utils.d.ts +0 -3
  256. package/dist/TreeSelect/Utils.js +0 -20
@@ -1,6 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
3
- var _excluded = ["name", "title", "prefix", "suffix", "prepend", "append", "error", "warning", "debounceInput", "debounceTime", "placeholder", "readOnly", "plain", "classPrefix", "onChange", "onClear", "showPassword", "onFocus", "onBlur", "maxLength", "showWordLimit", "hiddenValue", "defaultValue"];
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19;
3
+ var _excluded = ["name", "title", "prefix", "suffix", "prepend", "append", "error", "warning", "debounceInput", "debounceTime", "placeholder", "readOnly", "plain", "classPrefix", "onInput", "onChange", "onClear", "showPassword", "onFocus", "onBlur", "maxLength", "showWordLimit", "hiddenValue", "defaultValue", "formatter"];
4
4
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -16,22 +16,28 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
16
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
18
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
19
- import { useDebounceFn } from 'ahooks';
20
19
  import classNames from 'classnames';
21
- import { addClass, addStyle, hasClass, removeClass } from 'dom-lib';
20
+ import { addStyle, hasClass } from 'dom-lib';
22
21
  import isObject from 'lodash/isObject';
23
- import React, { cloneElement, forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
22
+ import React, { cloneElement, forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState } from 'react';
23
+ import { useTranslation } from 'react-i18next';
24
+ import { useConfigProvider } from "../ConfigProvider/ConfigProviderContext";
24
25
  import Icon from "../Icon/Icon";
25
26
  import { isNotEmpty, mergeDefaultProps } from "../Util";
26
27
  import { partitionHTMLProps, useClassNames, useControlled, useDisabled, useSize } from "../hooks";
27
- import InputGroup from "./InputGroup";
28
28
  import InputRange from "./InputRange";
29
29
  import TextArea from "./TextArea";
30
30
  function InternalInput(props, ref) {
31
31
  var _this = this;
32
+ var _useConfigProvider = useConfigProvider(),
33
+ locale = _useConfigProvider.locale;
34
+ var _useTranslation = useTranslation(),
35
+ t = _useTranslation.t;
32
36
  props = mergeDefaultProps({
33
37
  type: 'text',
34
- placeholder: '请输入',
38
+ placeholder: t('el.input.placeholder', {
39
+ lng: locale
40
+ }),
35
41
  clearable: true,
36
42
  debounceTime: 200,
37
43
  defaultValue: ''
@@ -52,6 +58,7 @@ function InternalInput(props, ref) {
52
58
  plain = _props.plain,
53
59
  _props$classPrefix = _props.classPrefix,
54
60
  classPrefix = _props$classPrefix === void 0 ? 'input' : _props$classPrefix,
61
+ onInput = _props.onInput,
55
62
  onChange = _props.onChange,
56
63
  onClear = _props.onClear,
57
64
  showPassword = _props.showPassword,
@@ -61,11 +68,14 @@ function InternalInput(props, ref) {
61
68
  showWordLimit = _props.showWordLimit,
62
69
  hiddenValue = _props.hiddenValue,
63
70
  defaultValue = _props.defaultValue,
71
+ formatter = _props.formatter,
64
72
  rest = _objectWithoutProperties(_props, _excluded);
65
73
  var _useClassNames = useClassNames(classPrefix),
66
74
  b = _useClassNames.b,
67
75
  e = _useClassNames.e,
68
76
  m = _useClassNames.m,
77
+ be = _useClassNames.be,
78
+ bm = _useClassNames.bm,
69
79
  is = _useClassNames.is;
70
80
  var _partitionHTMLProps = partitionHTMLProps(rest),
71
81
  _partitionHTMLProps2 = _slicedToArray(_partitionHTMLProps, 1),
@@ -78,11 +88,15 @@ function InternalInput(props, ref) {
78
88
  _useState2 = _slicedToArray(_useState, 2),
79
89
  type = _useState2[0],
80
90
  setType = _useState2[1];
91
+ var _useState3 = useState(false),
92
+ _useState4 = _slicedToArray(_useState3, 2),
93
+ focused = _useState4[0],
94
+ setFocused = _useState4[1];
81
95
  var disabled = useDisabled(props.disabled);
82
96
  var size = useSize(props.size);
83
97
  var containerRef = useRef(null);
84
98
  var inputRef = useRef(null);
85
- var contentRef = useRef(null);
99
+ var wrapperRef = useRef(null);
86
100
  var clearRef = useRef(null);
87
101
  var suffixRef = useRef(null);
88
102
  // 搜索框是否输入完毕
@@ -90,6 +104,15 @@ function InternalInput(props, ref) {
90
104
 
91
105
  // const containerRef = useMemo(() => props.containerRef ?? rootRef, [props.containerRef]);
92
106
 
107
+ /** 格式化的数据 */
108
+ var formatValue = useMemo(function () {
109
+ var val = value;
110
+ if (formatter) {
111
+ val = formatter(val);
112
+ }
113
+ return val;
114
+ }, [formatter, value]);
115
+
93
116
  /** 是否可清空 */
94
117
  var clearable = useMemo(function () {
95
118
  // 只读不显示清除按钮只有input组件适用,加上了那些引用input组件就无法显示清空按钮了,这里添加说明,下次别再添加了
@@ -168,12 +191,16 @@ function InternalInput(props, ref) {
168
191
  addStyle(clearRef.current, 'display', 'none');
169
192
  }
170
193
  hideClear();
171
- if (!readOnly && !disabled) {
172
- var _inputRef$current;
173
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
174
- }
175
194
  onClear === null || onClear === void 0 || onClear(event);
176
195
  onChange === null || onChange === void 0 || onChange('', event);
196
+ if (requestAnimationFrame) {
197
+ requestAnimationFrame(function () {
198
+ if (!readOnly && !disabled) {
199
+ var _inputRef$current;
200
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
201
+ }
202
+ });
203
+ }
177
204
  }, [disabled, hideClear, onChange, onClear, readOnly, setValue]);
178
205
 
179
206
  /** 后缀点击事件 */
@@ -185,38 +212,57 @@ function InternalInput(props, ref) {
185
212
 
186
213
  /** 输入事件 */
187
214
  var handleInput = useCallback(function (event) {
188
- if (inputOver.current) {
189
- // 让搜索变成异步的
190
- setValue(event.target.value);
191
- if (clearRef.current && clearable && isNotEmpty(event.target.value)) {
192
- showClear(event.target.value);
193
- } else {
194
- hideClear();
195
- }
196
- onChange === null || onChange === void 0 || onChange(event.target.value, event);
215
+ // console.log('handleInput', event.target.value);
216
+ // if (inputOver.current) {
217
+ // }
218
+ // 让搜索变成异步的
219
+ setValue(event.target.value);
220
+ if (clearRef.current && clearable && isNotEmpty(event.target.value)) {
221
+ showClear(event.target.value);
222
+ } else {
223
+ hideClear();
197
224
  }
225
+ onChange === null || onChange === void 0 || onChange(event.target.value, event);
198
226
  }, [setValue, clearable, onChange, showClear, hideClear]);
199
- var _useDebounceFn = useDebounceFn(handleInput, {
200
- wait: debounceTime
201
- }),
202
- handleDebounceInput = _useDebounceFn.run;
203
- var handleComposition = useCallback(function (event) {
204
- var _type = event.type;
205
- if (_type === 'compositionstart') {
206
- inputOver.current = false;
207
- } else if (_type === 'compositionend') {
208
- inputOver.current = true;
209
- handleInput(event);
210
- }
211
- }, [handleInput]);
212
- useEffect(function () {
213
- var input = inputRef.current;
214
- if (input && debounceInput) {
215
- input.addEventListener('compositionstart', handleComposition);
216
- input.addEventListener('compositionupdate', handleComposition);
217
- input.addEventListener('compositionend', handleComposition);
218
- }
219
- }, [debounceInput, handleComposition]);
227
+ var handleChange = useCallback(function (event) {
228
+ // console.log('handleChange', event.target.value);
229
+ setValue(event.target.value);
230
+ onChange === null || onChange === void 0 || onChange(event.target.value, event);
231
+ }, [setValue, onChange]);
232
+
233
+ // const { run: handleDebounceInput } = useDebounceFn(handleInput, { wait: debounceTime });
234
+
235
+ // const handleComposition = useCallback(
236
+ // (event: any) => {
237
+ // const _type = event.type;
238
+ // // console.log(_type);
239
+ // if (_type === 'compositionstart') {
240
+ // inputOver.current = false;
241
+ // } else if (_type === 'compositionend') {
242
+ // inputOver.current = true;
243
+ // handleInput(event);
244
+ // }
245
+ // },
246
+ // [handleInput],
247
+ // );
248
+
249
+ // useEffect(() => {
250
+ // const input = inputRef.current;
251
+ // if (input) {
252
+ // input.addEventListener('compositionstart', handleComposition);
253
+ // input.addEventListener('compositionupdate', handleComposition);
254
+ // input.addEventListener('compositionend', handleComposition);
255
+ // }
256
+ // }, [handleComposition]);
257
+
258
+ // useEffect(() => {
259
+ // requestAnimationFrame(() => {
260
+ // if (inputRef.current) {
261
+ // inputRef.current.value = formatValue as string;
262
+ // }
263
+ // });
264
+ // }, []);
265
+
220
266
  useImperativeHandle(ref, function () {
221
267
  return {
222
268
  ref: containerRef,
@@ -247,7 +293,7 @@ function InternalInput(props, ref) {
247
293
  var _nodeType2;
248
294
  var nodeType = prefix === null || prefix === void 0 ? void 0 : prefix.type;
249
295
  nodeType = ((_nodeType2 = nodeType) === null || _nodeType2 === void 0 ? void 0 : _nodeType2.displayName) || nodeType;
250
- if (nodeType.toString().startsWith('Icon')) {
296
+ if (nodeType.toString().startsWith('ElIcon')) {
251
297
  var _prefix$props;
252
298
  return /*#__PURE__*/cloneElement(prefix, _objectSpread(_objectSpread({}, prefix.props), {}, {
253
299
  className: classNames((_prefix$props = prefix.props) === null || _prefix$props === void 0 ? void 0 : _prefix$props.className, e(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["icon"]))))
@@ -258,115 +304,110 @@ function InternalInput(props, ref) {
258
304
  }
259
305
  return null;
260
306
  }, [type, prefix, e]);
261
- var content = useMemo(function () {
262
- return type === 'hidden' ? /*#__PURE__*/React.createElement("input", _extends({
263
- ref: inputRef,
264
- type: "hidden",
265
- name: name,
266
- value: value,
267
- disabled: disabled,
268
- onChange: debounceInput ? handleDebounceInput : handleInput,
269
- onClick: props.onClick,
270
- className: props.className,
271
- style: props.innerStyle
272
- }, htmlInputProps)) : /*#__PURE__*/React.createElement("div", {
273
- className: classNames(e(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["wrapper"]))), is({
274
- error: error,
275
- warning: warning
276
- })),
277
- ref: contentRef,
278
- onMouseEnter: function onMouseEnter() {
279
- return showClear(value);
280
- },
281
- onMouseLeave: function onMouseLeave() {
282
- if (!hasClass(contentRef.current, is('focus'))) {
283
- hideClear();
284
- }
285
- }
286
- }, ['text', 'password'].includes(type) && preffixSlot && /*#__PURE__*/React.createElement("span", {
287
- className: e(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["prefix"])))
288
- }, /*#__PURE__*/React.createElement("span", {
289
- className: e(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["prefix-inner"])))
290
- }, preffixSlot, " ")), /*#__PURE__*/React.createElement("input", _extends({
291
- ref: inputRef,
292
- type: type,
293
- name: name,
294
- title: title,
295
- value: hiddenValue ? '' : value,
296
- className: e(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["inner"]))),
297
- style: props.innerStyle,
298
- placeholder: placeholder,
299
- autoComplete: "off",
300
- readOnly: readOnly,
307
+ var inputValue = useMemo(function () {
308
+ if (hiddenValue) {
309
+ return '';
310
+ }
311
+ return focused ? value : formatValue;
312
+ }, [focused, formatValue, hiddenValue, value]);
313
+ return /*#__PURE__*/React.createElement("div", {
314
+ ref: containerRef,
315
+ className: classNames(b(), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, bm('group', 'prepend'), prepend), bm('group', 'append'), append), m(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["prefix"]))), preffixSlot), m(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["suffix"]))), suffixSlot || clearable), m(size), size), b(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["hidden"]))), type === 'hidden'), is({
301
316
  disabled: disabled,
302
- maxLength: maxLength,
303
- onInput: handleInput,
304
- onClick: props.onClick,
305
- onFocus: function onFocus(event) {
306
- if (contentRef.current) {
307
- addClass(contentRef.current, is('focus'));
308
- }
309
- showClear(value);
310
- _onFocus === null || _onFocus === void 0 || _onFocus.call(_this, event);
311
- },
312
- onBlur: function onBlur(event) {
313
- if (contentRef.current) {
314
- removeClass(contentRef.current, is('focus'));
315
- }
317
+ plain: plain
318
+ }), props.className),
319
+ style: props.style,
320
+ onClick: function onClick(event) {
321
+ return event.stopPropagation();
322
+ }
323
+ }, prepend ? /*#__PURE__*/React.createElement("div", {
324
+ className: be('group', 'prepend')
325
+ }, prepend) : null, /*#__PURE__*/React.createElement("div", {
326
+ ref: wrapperRef,
327
+ className: classNames(e(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["wrapper"]))), is({
328
+ error: error,
329
+ warning: warning,
330
+ focus: focused
331
+ })),
332
+ onMouseEnter: function onMouseEnter() {
333
+ return showClear(value);
334
+ },
335
+ onMouseLeave: function onMouseLeave() {
336
+ if (!hasClass(wrapperRef.current, is('focus'))) {
316
337
  hideClear();
317
- _onBlur === null || _onBlur === void 0 || _onBlur.call(_this, event);
318
- }
319
- }, htmlInputProps)), /*#__PURE__*/React.createElement("span", {
320
- ref: clearRef,
321
- key: "clearIcon",
322
- className: e(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["suffix"]))),
323
- style: {
324
- display: 'none'
325
- },
326
- onClick: handelClear
327
- }, /*#__PURE__*/React.createElement("span", {
328
- className: e(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["suffix-inner"])))
329
- }, /*#__PURE__*/React.createElement(Icon, {
330
- prefix: "fal",
331
- name: "circle-xmark",
332
- className: classNames(e(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["icon"]))), e(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["clear"])))),
333
- onMouseDown: function onMouseDown(event) {
334
- event.preventDefault();
335
- event.stopPropagation();
336
338
  }
337
- }))), suffixSlot && /*#__PURE__*/React.createElement("span", {
338
- ref: suffixRef,
339
- key: "suffixSlot",
340
- className: classNames(e(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["suffix"]))), _defineProperty({}, b('click', false), suffixCanClick)),
341
- onClick: onClickSuffix
342
- }, /*#__PURE__*/React.createElement("span", {
343
- className: e(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["suffix-inner"])))
344
- }, suffixSlot)));
345
- }, [type, name, value, disabled, debounceInput, handleDebounceInput, handleInput, props.onClick, props.className, props.innerStyle, htmlInputProps, e, is, error, warning, preffixSlot, title, hiddenValue, placeholder, readOnly, maxLength, handelClear, suffixSlot, b, suffixCanClick, onClickSuffix, showClear, hideClear, _onFocus, _onBlur]);
346
- if (append || prepend) {
347
- return /*#__PURE__*/React.createElement(InputGroup, {
348
- prepend: prepend,
349
- append: append,
350
- ref: containerRef,
351
- className: classNames(_defineProperty({}, m(size), size), is({
352
- disabled: disabled,
353
- plain: plain
354
- }), b(), props.className),
355
- style: props.style
356
- }, content);
357
- } else {
358
- return /*#__PURE__*/React.createElement("div", {
359
- ref: containerRef,
360
- className: classNames(b(), _defineProperty(_defineProperty(_defineProperty({}, m(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["prefix"]))), preffixSlot), m(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["suffix"]))), suffixSlot || clearable), m(size), size), is({
361
- disabled: disabled,
362
- plain: plain
363
- }), props.className),
364
- style: append || prepend ? {} : props.style,
365
- onClick: function onClick(event) {
366
- return event.stopPropagation();
367
- }
368
- }, content);
369
- }
339
+ }
340
+ }, ['text', 'password'].includes(type) && preffixSlot && /*#__PURE__*/React.createElement("span", {
341
+ className: e(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["prefix"])))
342
+ }, /*#__PURE__*/React.createElement("span", {
343
+ className: e(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["prefix-inner"])))
344
+ }, preffixSlot)), /*#__PURE__*/React.createElement("input", _extends({
345
+ ref: inputRef,
346
+ type: type,
347
+ name: name,
348
+ title: title,
349
+ value: inputValue,
350
+ className: e(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["inner"]))),
351
+ style: props.innerStyle,
352
+ placeholder: placeholder,
353
+ autoComplete: "off",
354
+ readOnly: readOnly,
355
+ disabled: disabled,
356
+ maxLength: maxLength,
357
+ onInput: handleInput
358
+ // onChange={handleChange}
359
+ // onCompositionStart={handleComposition}
360
+ // onCompositionUpdate={handleComposition}
361
+ // onCompositionEnd={handleComposition}
362
+ ,
363
+ onClick: props.onClick,
364
+ onFocus: function onFocus(event) {
365
+ // inputRef.current.value = value as string;
366
+ // if (wrapperRef.current) {
367
+ // addClass(wrapperRef.current, is('focus'));
368
+ // }
369
+ setFocused(true);
370
+ showClear(value);
371
+ _onFocus === null || _onFocus === void 0 || _onFocus.call(_this, event);
372
+ },
373
+ onBlur: function onBlur(event) {
374
+ // inputRef.current.value = formatValue as string;
375
+ // if (wrapperRef.current) {
376
+ // removeClass(wrapperRef.current, is('focus'));
377
+ // }
378
+ setFocused(false);
379
+ hideClear();
380
+ _onBlur === null || _onBlur === void 0 || _onBlur.call(_this, event);
381
+ // handleChange(event);
382
+ }
383
+ }, htmlInputProps)), /*#__PURE__*/React.createElement("span", {
384
+ ref: clearRef,
385
+ key: "clearIcon",
386
+ className: e(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["suffix"]))),
387
+ style: {
388
+ display: 'none'
389
+ },
390
+ onClick: handelClear
391
+ }, /*#__PURE__*/React.createElement("span", {
392
+ className: e(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["suffix-inner"])))
393
+ }, /*#__PURE__*/React.createElement(Icon, {
394
+ prefix: "fal",
395
+ name: "circle-xmark",
396
+ className: classNames(e(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["icon"]))), e(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["clear"])))),
397
+ onMouseDown: function onMouseDown(event) {
398
+ event.preventDefault();
399
+ event.stopPropagation();
400
+ }
401
+ }))), suffixSlot && /*#__PURE__*/React.createElement("span", {
402
+ ref: suffixRef,
403
+ key: "suffixSlot",
404
+ className: classNames(e(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["suffix"]))), _defineProperty({}, b('click', false), suffixCanClick)),
405
+ onClick: onClickSuffix
406
+ }, /*#__PURE__*/React.createElement("span", {
407
+ className: e(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["suffix-inner"])))
408
+ }, suffixSlot))), append ? /*#__PURE__*/React.createElement("div", {
409
+ className: be('group', 'append')
410
+ }, append) : null);
370
411
  }
371
412
  var ForwardInput = /*#__PURE__*/forwardRef(InternalInput);
372
413
  var Input = ForwardInput;
@@ -271,7 +271,7 @@ var InputRange = /*#__PURE__*/forwardRef(function (props, ref) {
271
271
  var _ref;
272
272
  return /*#__PURE__*/React.createElement("div", {
273
273
  className: classNames(b(_templateObject || (_templateObject = _taggedTemplateLiteral(["range-editor"]))), b('input-range', false), be('input', 'wrapper', false), be('tooltip', 'trigger', false), is({
274
- active: active || focus,
274
+ focus: active || focus,
275
275
  disabled: disabled,
276
276
  warning: warning,
277
277
  error: error
@@ -1,10 +1,16 @@
1
- var _excluded = ["name", "title", "error", "placeholder", "readOnly", "plain", "rows", "classPrefix", "onFocus", "onBlur", "onChange", "warning", "maxLength", "showWordLimit"];
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["name", "title", "error", "placeholder", "readOnly", "plain", "rows", "classPrefix", "onFocus", "onBlur", "onChange", "warning", "maxLength", "showWordLimit", "resize", "autosize", "inputStyle"];
2
3
  var _this = this,
3
4
  _templateObject,
4
5
  _templateObject2,
5
6
  _templateObject3;
6
7
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
7
8
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
9
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
14
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
15
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
16
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -14,15 +20,19 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
20
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
21
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
22
  import classNames from 'classnames';
17
- import React, { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
23
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
18
24
  import { mergeDefaultProps } from "../Util";
19
25
  import { partitionHTMLProps, useClassNames, useControlled, useDisabled } from "../hooks";
26
+ import { useResizeObserver } from "../hooks/useResizeObserver";
27
+ import { calcTextareaHeight } from "./utils";
20
28
  var TextArea = /*#__PURE__*/forwardRef(function (props, ref) {
21
29
  props = mergeDefaultProps({
22
30
  placeholder: '请输入',
23
31
  style: {
24
32
  width: '100%'
25
- }
33
+ },
34
+ autosize: true,
35
+ inputStyle: {}
26
36
  }, props);
27
37
  var _props = props,
28
38
  name = _props.name,
@@ -40,6 +50,9 @@ var TextArea = /*#__PURE__*/forwardRef(function (props, ref) {
40
50
  warning = _props.warning,
41
51
  maxLength = _props.maxLength,
42
52
  showWordLimit = _props.showWordLimit,
53
+ resize = _props.resize,
54
+ autosize = _props.autosize,
55
+ inputStyle = _props.inputStyle,
43
56
  rest = _objectWithoutProperties(_props, _excluded);
44
57
  var _useClassNames = useClassNames(classPrefix),
45
58
  b = _useClassNames.b,
@@ -54,20 +67,78 @@ var TextArea = /*#__PURE__*/forwardRef(function (props, ref) {
54
67
  _useState2 = _slicedToArray(_useState, 2),
55
68
  focus = _useState2[0],
56
69
  setFocus = _useState2[1];
70
+ var _useState3 = useState({}),
71
+ _useState4 = _slicedToArray(_useState3, 2),
72
+ textareaCalcStyle = _useState4[0],
73
+ setTextareaCalcStyle = _useState4[1];
57
74
  var disabled = useDisabled(props.disabled);
58
75
  var containerRef = useRef(null);
59
- var inputRef = useRef(null);
76
+ var textareaRef = useRef(null);
77
+ var countRef = useRef(null);
60
78
  var _partitionHTMLProps = partitionHTMLProps(rest),
61
79
  _partitionHTMLProps2 = _slicedToArray(_partitionHTMLProps, 1),
62
80
  htmlInputProps = _partitionHTMLProps2[0];
81
+ var isWordLimitVisible = useMemo(function () {
82
+ return showWordLimit && !!maxLength && !disabled && !readOnly;
83
+ }, [showWordLimit, maxLength, disabled, readOnly]);
63
84
  var handleInput = useCallback(function (event) {
64
85
  setValue(event.target.value);
65
86
  onChange === null || onChange === void 0 || onChange(event.target.value);
66
87
  }, [onChange, setValue]);
88
+ var resizeTextarea = useCallback(function () {
89
+ if (!textareaRef.current) {
90
+ return;
91
+ }
92
+ if (autosize) {
93
+ var minRows = typeof autosize !== 'boolean' ? autosize.minRows : rows;
94
+ var maxRows = typeof autosize !== 'boolean' ? autosize.maxRows : undefined;
95
+ var textareaStyle = calcTextareaHeight(textareaRef.current, minRows, maxRows);
96
+ setTextareaCalcStyle(function (prev) {
97
+ return _objectSpread(_objectSpread({}, prev), textareaStyle);
98
+ });
99
+ } else {
100
+ setTextareaCalcStyle(function (prev) {
101
+ return _objectSpread(_objectSpread({}, prev), {}, {
102
+ minHeight: calcTextareaHeight(textareaRef.current).minHeight
103
+ });
104
+ });
105
+ }
106
+ }, [autosize]);
107
+ var createOnceInitResize = useCallback(function () {
108
+ var isInit = false;
109
+ return function () {
110
+ var _textareaRef$current;
111
+ if (isInit || !autosize) {
112
+ return;
113
+ }
114
+ var isElHidden = ((_textareaRef$current = textareaRef.current) === null || _textareaRef$current === void 0 ? void 0 : _textareaRef$current.offsetParent) === null;
115
+ if (!isElHidden) {
116
+ setTimeout(resizeTextarea);
117
+ isInit = true;
118
+ }
119
+ };
120
+ }, [autosize, resizeTextarea]);
121
+ var onceInitSizeTextarea = createOnceInitResize();
122
+ useResizeObserver(textareaRef, function (entries) {
123
+ onceInitSizeTextarea();
124
+ if (!isWordLimitVisible || resize !== 'both') {
125
+ return;
126
+ }
127
+ var entry = entries[0];
128
+ var width = entry.contentRect.width;
129
+ if (countRef.current) {
130
+ countRef.current.style.right = "calc(100% - ".concat(width + 15 + 6, "px)");
131
+ }
132
+ });
133
+ useEffect(function () {
134
+ if (autosize) {
135
+ resizeTextarea();
136
+ }
137
+ }, [value]);
67
138
  useImperativeHandle(ref, function () {
68
139
  return {
69
140
  get input() {
70
- return inputRef.current;
141
+ return textareaRef.current;
71
142
  },
72
143
  getValue: function getValue() {
73
144
  return value;
@@ -82,12 +153,12 @@ var TextArea = /*#__PURE__*/forwardRef(function (props, ref) {
82
153
  onChange === null || onChange === void 0 || onChange('');
83
154
  },
84
155
  focus: function focus() {
85
- var _inputRef$current;
86
- return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
156
+ var _textareaRef$current2;
157
+ return (_textareaRef$current2 = textareaRef.current) === null || _textareaRef$current2 === void 0 ? void 0 : _textareaRef$current2.focus();
87
158
  },
88
159
  blur: function blur() {
89
- var _inputRef$current2;
90
- return (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.blur();
160
+ var _textareaRef$current3;
161
+ return (_textareaRef$current3 = textareaRef.current) === null || _textareaRef$current3 === void 0 ? void 0 : _textareaRef$current3.blur();
91
162
  }
92
163
  };
93
164
  });
@@ -100,6 +171,7 @@ var TextArea = /*#__PURE__*/forwardRef(function (props, ref) {
100
171
  style: props.style,
101
172
  ref: containerRef
102
173
  }, /*#__PURE__*/React.createElement("textarea", _extends({
174
+ ref: textareaRef,
103
175
  rows: rows,
104
176
  name: name,
105
177
  title: title,
@@ -108,13 +180,15 @@ var TextArea = /*#__PURE__*/forwardRef(function (props, ref) {
108
180
  error: error,
109
181
  warning: warning
110
182
  })),
111
- style: props.innerStyle,
183
+ style: _objectSpread(_objectSpread({
184
+ minHeight: 31,
185
+ resize: disabled ? 'none' : resize
186
+ }, textareaCalcStyle), inputStyle),
112
187
  placeholder: placeholder,
113
188
  readOnly: readOnly,
114
189
  disabled: disabled,
115
190
  maxLength: maxLength,
116
191
  onChange: handleInput,
117
- ref: inputRef,
118
192
  onFocus: useCallback(function (event) {
119
193
  setFocus(true);
120
194
  onFocus === null || onFocus === void 0 || onFocus.call(_this, event);
@@ -124,8 +198,9 @@ var TextArea = /*#__PURE__*/forwardRef(function (props, ref) {
124
198
  onBlur === null || onBlur === void 0 || onBlur.call(_this, event);
125
199
  }, [onBlur])
126
200
  }, htmlInputProps)), maxLength && showWordLimit ? /*#__PURE__*/React.createElement("span", {
201
+ ref: countRef,
127
202
  className: e(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["count"])))
128
203
  }, typeof value === 'string' ? value.length : 0, " / ", maxLength) : null);
129
204
  });
130
- TextArea.displayName = 'TextArea';
205
+ TextArea.displayName = 'ElTextArea';
131
206
  export default TextArea;