@zohodesk/components 1.0.0-temp-207 → 1.0.0-temp-208

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 (313) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/es/Accordion/Accordion.js +2 -2
  3. package/es/Accordion/AccordionItem.js +4 -4
  4. package/es/Accordion/__tests__/Accordion.spec.js +1 -1
  5. package/es/Accordion/__tests__/AccordionItem.spec.js +1 -1
  6. package/es/Accordion/index.js +2 -2
  7. package/es/Animation/Animation.js +3 -3
  8. package/es/Animation/__tests__/Animation.spec.js +1 -1
  9. package/es/Animation/utils.js +1 -1
  10. package/es/AppContainer/AppContainer.js +9 -9
  11. package/es/AppContainer/__tests__/AppContainer.spec.js +1 -1
  12. package/es/Avatar/Avatar.js +5 -5
  13. package/es/Avatar/__tests__/Avatar.spec.js +1 -1
  14. package/es/AvatarTeam/AvatarTeam.js +4 -4
  15. package/es/AvatarTeam/__tests__/AvatarTeam.spec.js +1 -1
  16. package/es/Button/Button.js +4 -4
  17. package/es/Button/__tests__/Button.spec.js +1 -1
  18. package/es/Button/index.js +2 -2
  19. package/es/Button/props/defaultProps.js +1 -1
  20. package/es/Buttongroup/Buttongroup.js +3 -3
  21. package/es/Buttongroup/__tests__/Buttongroup.spec.js +1 -1
  22. package/es/Card/Card.js +5 -5
  23. package/es/Card/__tests__/Card.spec.js +1 -1
  24. package/es/Card/index.js +4 -4
  25. package/es/CheckBox/CheckBox.js +6 -6
  26. package/es/CheckBox/__tests__/CheckBox.spec.js +1 -1
  27. package/es/DateTime/CalendarView.js +6 -6
  28. package/es/DateTime/DateTime.js +15 -15
  29. package/es/DateTime/DateTimePopupFooter.js +5 -5
  30. package/es/DateTime/DateTimePopupHeader.js +4 -4
  31. package/es/DateTime/DateWidget.js +17 -17
  32. package/es/DateTime/DaysRow.js +3 -3
  33. package/es/DateTime/Time.js +5 -5
  34. package/es/DateTime/YearView.js +6 -6
  35. package/es/DateTime/__tests__/CalendarView.spec.js +1 -1
  36. package/es/DateTime/__tests__/DateTime.spec.js +1 -1
  37. package/es/DateTime/__tests__/DateTimePopupFooter.spec.js +1 -1
  38. package/es/DateTime/__tests__/DateTimePopupHeader.spec.js +1 -1
  39. package/es/DateTime/__tests__/DateWidget.spec.js +1 -1
  40. package/es/DateTime/__tests__/DaysRow.spec.js +1 -1
  41. package/es/DateTime/__tests__/Time.spec.js +1 -1
  42. package/es/DateTime/__tests__/YearView.spec.js +1 -1
  43. package/es/DateTime/dateFormatUtils/dateFormat.js +4 -4
  44. package/es/DateTime/dateFormatUtils/dayChange.js +2 -2
  45. package/es/DateTime/dateFormatUtils/index.js +3 -3
  46. package/es/DateTime/dateFormatUtils/monthChange.js +2 -2
  47. package/es/DateTime/dateFormatUtils/timeChange.js +2 -2
  48. package/es/DateTime/dateFormatUtils/yearChange.js +2 -2
  49. package/es/DateTime/index.js +1 -1
  50. package/es/DateTime/props/propTypes.js +1 -1
  51. package/es/DateTime/validator.js +2 -2
  52. package/es/DropBox/DropBox.js +9 -9
  53. package/es/DropBox/DropBoxElement/DropBoxElement.js +6 -6
  54. package/es/DropBox/DropBoxElement/__tests__/DropBoxElement.spec.js +1 -1
  55. package/es/DropBox/DropBoxElement/css/cssJSLogic.js +1 -1
  56. package/es/DropBox/DropBoxElement/useDropboxPosCalc.js +1 -1
  57. package/es/DropBox/__tests__/DropBox.spec.js +1 -1
  58. package/es/DropBox/css/cssJSLogic.js +1 -1
  59. package/es/DropBox/props/defaultProps.js +1 -1
  60. package/es/DropBox/props/propTypes.js +1 -1
  61. package/es/DropBox/utils/isMobilePopover.js +1 -1
  62. package/es/DropDown/DropDown.js +4 -4
  63. package/es/DropDown/DropDownHeading.js +3 -3
  64. package/es/DropDown/DropDownItem.js +3 -3
  65. package/es/DropDown/DropDownSearch.js +4 -4
  66. package/es/DropDown/DropDownSeparator.js +2 -2
  67. package/es/DropDown/__tests__/DropDown.spec.js +1 -1
  68. package/es/DropDown/__tests__/DropDownHeading.spec.js +1 -1
  69. package/es/DropDown/__tests__/DropDownItem.spec.js +1 -1
  70. package/es/DropDown/__tests__/DropDownSearch.spec.js +1 -1
  71. package/es/DropDown/__tests__/DropDownSeparator.spec.js +1 -1
  72. package/es/DropDown/index.js +7 -7
  73. package/es/DropDown/props/propTypes.js +1 -1
  74. package/es/Heading/Heading.js +4 -4
  75. package/es/Heading/__tests__/Heading.spec.js +1 -1
  76. package/es/Label/Label.js +4 -4
  77. package/es/Label/__tests__/Label.spec.js +1 -1
  78. package/es/Layout/Box.js +4 -4
  79. package/es/Layout/Container.js +4 -4
  80. package/es/Layout/__tests__/Box.spec.js +1 -1
  81. package/es/Layout/__tests__/Container.spec.js +1 -1
  82. package/es/Layout/index.js +2 -2
  83. package/es/ListItem/ListContainer.js +6 -6
  84. package/es/ListItem/ListItem.js +5 -5
  85. package/es/ListItem/ListItemWithAvatar.js +7 -7
  86. package/es/ListItem/ListItemWithCheckBox.js +6 -6
  87. package/es/ListItem/ListItemWithIcon.js +5 -5
  88. package/es/ListItem/ListItemWithRadio.js +6 -6
  89. package/es/ListItem/__tests__/ListContainer.spec.js +1 -1
  90. package/es/ListItem/__tests__/ListItem.spec.js +1 -1
  91. package/es/ListItem/__tests__/ListItemWithAvatar.spec.js +1 -1
  92. package/es/ListItem/__tests__/ListItemWithCheckBox.spec.js +1 -1
  93. package/es/ListItem/__tests__/ListItemWithIcon.spec.js +1 -1
  94. package/es/ListItem/__tests__/ListItemWithRadio.spec.js +1 -1
  95. package/es/ListItem/index.js +6 -6
  96. package/es/Modal/Modal.js +3 -3
  97. package/es/Modal/__tests__/Modal.spec.js +1 -1
  98. package/es/MultiSelect/AdvancedGroupMultiSelect.js +17 -17
  99. package/es/MultiSelect/AdvancedMultiSelect.js +26 -18
  100. package/es/MultiSelect/EmptyState.js +3 -3
  101. package/es/MultiSelect/MobileHeader/MobileHeader.js +5 -5
  102. package/es/MultiSelect/MobileHeader/__tests__/MobileHeader.spec.js +1 -1
  103. package/es/MultiSelect/MultiSelect.js +20 -20
  104. package/es/MultiSelect/MultiSelectHeader.js +4 -4
  105. package/es/MultiSelect/MultiSelectWithAvatar.js +16 -16
  106. package/es/MultiSelect/SelectedOptions.js +5 -5
  107. package/es/MultiSelect/Suggestions.js +6 -6
  108. package/es/MultiSelect/__tests__/AdvancedGroupMultiSelect.spec.js +1 -1
  109. package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +1 -1
  110. package/es/MultiSelect/__tests__/EmptyState.spec.js +1 -1
  111. package/es/MultiSelect/__tests__/MultiSelect.spec.js +1 -1
  112. package/es/MultiSelect/__tests__/MultiSelectHeader.spec.js +1 -1
  113. package/es/MultiSelect/__tests__/MultiSelectWithAvatar.spec.js +1 -1
  114. package/es/MultiSelect/__tests__/SelectedOptions.spec.js +1 -1
  115. package/es/MultiSelect/__tests__/Suggestions.spec.js +1 -1
  116. package/es/MultiSelect/index.js +4 -4
  117. package/es/MultiSelect/props/defaultProps.js +3 -2
  118. package/es/MultiSelect/props/propTypes.js +5 -1
  119. package/es/PopOver/PopOver.js +6 -6
  120. package/es/PopOver/__tests__/PopOver.spec.js +1 -1
  121. package/es/PopOver/index.js +3 -3
  122. package/es/Popup/Popup.js +3 -3
  123. package/es/Provider/AvatarSize.js +1 -1
  124. package/es/Provider/CssProvider.js +1 -1
  125. package/es/Provider/IdProvider.js +2 -2
  126. package/es/Provider/LibraryContext.js +2 -2
  127. package/es/Provider/ZindexProvider.js +2 -2
  128. package/es/Provider/index.js +4 -4
  129. package/es/Radio/Radio.js +5 -5
  130. package/es/Radio/__tests__/Radio.spec.js +1 -1
  131. package/es/Responsive/CustomResponsive.js +7 -7
  132. package/es/Responsive/ResizeComponent.js +2 -2
  133. package/es/Responsive/Responsive.js +6 -6
  134. package/es/Responsive/index.js +3 -3
  135. package/es/Responsive/utils/index.js +1 -1
  136. package/es/Responsive/windowResizeObserver.js +1 -1
  137. package/es/ResponsiveDropBox/ResponsiveDropBox.js +6 -6
  138. package/es/ResponsiveDropBox/__tests__/ResponsiveDropBox.spec.js +1 -1
  139. package/es/ResponsiveDropBox/props/propTypes.js +1 -1
  140. package/es/Ribbon/Ribbon.js +3 -3
  141. package/es/Ribbon/__tests__/Ribbon.spec.js +1 -1
  142. package/es/RippleEffect/RippleEffect.js +4 -4
  143. package/es/RippleEffect/__tests__/RippleEffect.spec.js +1 -1
  144. package/es/Select/GroupSelect.js +16 -16
  145. package/es/Select/Select.js +15 -15
  146. package/es/Select/SelectWithAvatar.js +17 -17
  147. package/es/Select/SelectWithIcon.js +13 -13
  148. package/es/Select/__tests__/GroupSelect.spec.js +1 -1
  149. package/es/Select/__tests__/Select.spec.js +1 -1
  150. package/es/Select/__tests__/SelectWithAvatar.spec.js +1 -1
  151. package/es/Select/__tests__/SelectWithIcon.spec.js +1 -1
  152. package/es/Select/index.js +4 -4
  153. package/es/Select/props/defaultProps.js +1 -1
  154. package/es/Stencils/Stencils.js +3 -3
  155. package/es/Stencils/__tests__/Stencils.spec.js +1 -1
  156. package/es/Switch/Switch.js +5 -5
  157. package/es/Switch/__tests__/Switch.spec.js +1 -1
  158. package/es/Tab/Tab.js +5 -5
  159. package/es/Tab/TabContent.js +4 -4
  160. package/es/Tab/TabContentWrapper.js +3 -3
  161. package/es/Tab/TabWrapper.js +3 -3
  162. package/es/Tab/Tabs.js +13 -13
  163. package/es/Tab/__tests__/Tab.spec.js +1 -1
  164. package/es/Tab/__tests__/TabContent.spec.js +1 -1
  165. package/es/Tab/__tests__/TabContentWrapper.spec.js +1 -1
  166. package/es/Tab/__tests__/TabWrapper.spec.js +1 -1
  167. package/es/Tab/__tests__/Tabs.spec.js +1 -1
  168. package/es/Tab/index.js +5 -5
  169. package/es/Tag/Tag.js +7 -7
  170. package/es/Tag/__tests__/Tag.spec.js +1 -1
  171. package/es/TextBox/TextBox.js +3 -3
  172. package/es/TextBox/__tests__/TextBox.spec.js +1 -1
  173. package/es/TextBoxIcon/TextBoxIcon.js +6 -6
  174. package/es/TextBoxIcon/__tests__/TextBoxIcon.spec.js +1 -1
  175. package/es/TextBoxIcon/props/propTypes.js +1 -1
  176. package/es/Textarea/Textarea.js +27 -154
  177. package/es/Textarea/Textarea.module.css +4 -55
  178. package/es/Textarea/__tests__/Textarea.spec.js +1 -1
  179. package/es/Textarea/props/propTypes.js +1 -4
  180. package/es/Tooltip/Tooltip.js +6 -6
  181. package/es/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +3 -3
  182. package/es/VelocityAnimation/VelocityAnimation/__tests__/VelocityAnimation.spec.js +1 -1
  183. package/es/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +3 -3
  184. package/es/VelocityAnimation/VelocityAnimationGroup/__tests__/VelocityAnimationGroup.spec.js +1 -1
  185. package/es/VelocityAnimation/index.js +2 -2
  186. package/es/css.js +37 -37
  187. package/es/deprecated/PortalLayer/PortalLayer.js +3 -3
  188. package/es/index.js +39 -39
  189. package/es/semantic/Button/Button.js +3 -3
  190. package/es/semantic/Button/__tests__/Button.spec.js +1 -1
  191. package/es/semantic/index.js +1 -1
  192. package/es/utils/Common.js +1 -1
  193. package/es/utils/ContextOptimizer.js +1 -1
  194. package/es/utils/cssUtils.js +1 -1
  195. package/es/utils/datetime/common.js +1 -1
  196. package/es/utils/dropDownUtils.js +1 -1
  197. package/es/utils/index.js +1 -1
  198. package/es/v1/Accordion/Accordion.js +2 -2
  199. package/es/v1/Accordion/AccordionItem.js +4 -4
  200. package/es/v1/Accordion/index.js +2 -2
  201. package/es/v1/Animation/Animation.js +3 -3
  202. package/es/v1/Animation/utils.js +1 -1
  203. package/es/v1/AppContainer/AppContainer.js +9 -9
  204. package/es/v1/Avatar/Avatar.js +5 -5
  205. package/es/v1/AvatarTeam/AvatarTeam.js +4 -4
  206. package/es/v1/Button/Button.js +4 -4
  207. package/es/v1/Button/props/defaultProps.js +1 -1
  208. package/es/v1/Buttongroup/Buttongroup.js +3 -3
  209. package/es/v1/Card/Card.js +5 -5
  210. package/es/v1/Card/index.js +4 -4
  211. package/es/v1/CheckBox/CheckBox.js +6 -6
  212. package/es/v1/DateTime/CalendarView.js +7 -7
  213. package/es/v1/DateTime/DateTime.js +15 -15
  214. package/es/v1/DateTime/DateTimePopupFooter.js +5 -5
  215. package/es/v1/DateTime/DateTimePopupHeader.js +4 -4
  216. package/es/v1/DateTime/DateWidget.js +17 -17
  217. package/es/v1/DateTime/DaysRow.js +3 -3
  218. package/es/v1/DateTime/Time.js +5 -5
  219. package/es/v1/DateTime/YearView.js +6 -6
  220. package/es/v1/DateTime/index.js +1 -1
  221. package/es/v1/DateTime/props/propTypes.js +1 -1
  222. package/es/v1/DropBox/DropBox.js +9 -9
  223. package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +6 -6
  224. package/es/v1/DropBox/props/defaultProps.js +1 -1
  225. package/es/v1/DropBox/props/propTypes.js +1 -1
  226. package/es/v1/DropBox/utils/isMobilePopover.js +1 -1
  227. package/es/v1/DropDown/DropDown.js +4 -4
  228. package/es/v1/DropDown/DropDownHeading.js +3 -3
  229. package/es/v1/DropDown/DropDownItem.js +3 -3
  230. package/es/v1/DropDown/DropDownSearch.js +4 -4
  231. package/es/v1/DropDown/DropDownSeparator.js +2 -2
  232. package/es/v1/DropDown/props/propTypes.js +1 -1
  233. package/es/v1/Heading/Heading.js +4 -4
  234. package/es/v1/Label/Label.js +4 -4
  235. package/es/v1/Layout/Box.js +4 -4
  236. package/es/v1/Layout/Container.js +4 -4
  237. package/es/v1/Layout/index.js +2 -2
  238. package/es/v1/ListItem/ListContainer.js +6 -6
  239. package/es/v1/ListItem/ListItem.js +5 -5
  240. package/es/v1/ListItem/ListItemWithAvatar.js +7 -7
  241. package/es/v1/ListItem/ListItemWithCheckBox.js +6 -6
  242. package/es/v1/ListItem/ListItemWithIcon.js +5 -5
  243. package/es/v1/ListItem/ListItemWithRadio.js +6 -6
  244. package/es/v1/ListItem/index.js +6 -6
  245. package/es/v1/Modal/Modal.js +3 -3
  246. package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +17 -17
  247. package/es/v1/MultiSelect/AdvancedMultiSelect.js +17 -17
  248. package/es/v1/MultiSelect/EmptyState.js +3 -3
  249. package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +5 -5
  250. package/es/v1/MultiSelect/MultiSelect.js +19 -19
  251. package/es/v1/MultiSelect/MultiSelectHeader.js +4 -4
  252. package/es/v1/MultiSelect/MultiSelectWithAvatar.js +16 -16
  253. package/es/v1/MultiSelect/SelectedOptions.js +5 -5
  254. package/es/v1/MultiSelect/Suggestions.js +6 -6
  255. package/es/v1/MultiSelect/index.js +4 -4
  256. package/es/v1/MultiSelect/props/defaultProps.js +1 -1
  257. package/es/v1/PopOver/PopOver.js +6 -6
  258. package/es/v1/Popup/Popup.js +3 -3
  259. package/es/v1/Radio/Radio.js +5 -5
  260. package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +6 -6
  261. package/es/v1/ResponsiveDropBox/props/propTypes.js +1 -1
  262. package/es/v1/Ribbon/Ribbon.js +3 -3
  263. package/es/v1/RippleEffect/RippleEffect.js +4 -4
  264. package/es/v1/Select/GroupSelect.js +16 -16
  265. package/es/v1/Select/Select.js +15 -15
  266. package/es/v1/Select/SelectWithAvatar.js +17 -17
  267. package/es/v1/Select/SelectWithIcon.js +13 -13
  268. package/es/v1/Select/index.js +4 -4
  269. package/es/v1/Select/props/defaultProps.js +1 -1
  270. package/es/v1/Stencils/Stencils.js +3 -3
  271. package/es/v1/Switch/Switch.js +5 -5
  272. package/es/v1/Tab/Tab.js +5 -5
  273. package/es/v1/Tab/TabContent.js +4 -4
  274. package/es/v1/Tab/TabContentWrapper.js +3 -3
  275. package/es/v1/Tab/TabWrapper.js +3 -3
  276. package/es/v1/Tab/Tabs.js +13 -13
  277. package/es/v1/Tab/index.js +5 -5
  278. package/es/v1/Tag/Tag.js +7 -7
  279. package/es/v1/TextBox/TextBox.js +3 -3
  280. package/es/v1/TextBoxIcon/TextBoxIcon.js +6 -6
  281. package/es/v1/TextBoxIcon/props/propTypes.js +1 -1
  282. package/es/v1/Textarea/Textarea.js +3 -3
  283. package/es/v1/Tooltip/Tooltip.js +6 -6
  284. package/es/v1/Typography/Typography.js +4 -4
  285. package/es/v1/Typography/css/cssJSLogic.js +1 -1
  286. package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +3 -3
  287. package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +3 -3
  288. package/es/v1/semantic/Button/Button.js +3 -3
  289. package/es/v1/semantic/index.js +1 -1
  290. package/lib/MultiSelect/AdvancedMultiSelect.js +10 -2
  291. package/lib/MultiSelect/props/defaultProps.js +2 -1
  292. package/lib/MultiSelect/props/propTypes.js +5 -1
  293. package/lib/Textarea/Textarea.js +43 -188
  294. package/lib/Textarea/Textarea.module.css +4 -55
  295. package/lib/Textarea/props/propTypes.js +1 -4
  296. package/package.json +4 -4
  297. package/result.json +1 -1
  298. package/es/Textarea/TextareaOne.js +0 -349
  299. package/es/Textarea/utils/calculateNodeHeight.js +0 -58
  300. package/es/Textarea/utils/calculateNodeHeightOne.js +0 -66
  301. package/es/Textarea/utils/debounce.js +0 -24
  302. package/es/Textarea/utils/getSizingData.js +0 -27
  303. package/es/Textarea/utils/ownerDocument.js +0 -5
  304. package/es/Textarea/utils/ownerWindow.js +0 -8
  305. package/es/Textarea/utils/updateState.js +0 -30
  306. package/lib/Textarea/TextareaOne.js +0 -422
  307. package/lib/Textarea/utils/calculateNodeHeight.js +0 -69
  308. package/lib/Textarea/utils/calculateNodeHeightOne.js +0 -74
  309. package/lib/Textarea/utils/debounce.js +0 -33
  310. package/lib/Textarea/utils/getSizingData.js +0 -37
  311. package/lib/Textarea/utils/ownerDocument.js +0 -13
  312. package/lib/Textarea/utils/ownerWindow.js +0 -18
  313. package/lib/Textarea/utils/updateState.js +0 -36
@@ -1,349 +0,0 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom";
3
- import { defaultProps } from "./props/defaultProps";
4
- import { propTypes } from "./props/propTypes";
5
- /* eslint css-modules/no-unused-class: [2, { markAsUsed: ['resizeX', 'resizeY', 'noresize', 'resizeboth', 'xsmall', 'small', 'medium', 'large', 'xlarge', 'default', 'primary'] }] */
6
-
7
- import style from "./Textarea.module.css";
8
- import ownerWindow from "./ownerWindow";
9
- import debounce from "./debounce";
10
- const styles = {
11
- shadow: {
12
- // Visibility needed to hide the extra text area on iPads
13
- visibility: "hidden",
14
- // Remove from the content flow
15
- position: "absolute",
16
- // Ignore the scrollbar width
17
- overflow: "hidden",
18
- height: 0,
19
- top: 0,
20
- left: 0,
21
- // Create a new layer, increase the isolation of the computed values
22
- transform: "translateZ(0)"
23
- }
24
- };
25
- export default class Textarea extends React.Component {
26
- constructor(props) {
27
- super(props);
28
- this.onChange = this.onChange.bind(this);
29
- this.onKeyDown = this.onKeyDown.bind(this);
30
- this.onBlur = this.onBlur.bind(this);
31
- this.inputRef = this.inputRef.bind(this);
32
- this.getUpdatedState = this.getUpdatedState.bind(this);
33
- this.isEmpty = this.isEmpty.bind(this);
34
- this.getStyleValue = this.getStyleValue.bind(this);
35
- this.updateState = this.updateState.bind(this);
36
- this.syncHeight = this.syncHeight.bind(this);
37
- this.syncHeightWithFlushSync = this.syncHeightWithFlushSync.bind(this);
38
- this.handleResize = this.handleResize.bind(this);
39
- this.rAFHandleResize = this.rAFHandleResize.bind(this);
40
- this.rAF = null;
41
- this.resizeObserver = null;
42
- this.debounceHandleResize = null;
43
- this.shadowRef = /*#__PURE__*/React.createRef();
44
- this.rendersRef = /*#__PURE__*/React.createRef();
45
- this.state = {
46
- outerHeightStyle: 0,
47
- overflow: false
48
- };
49
- }
50
-
51
- onBlur(e) {
52
- e && e.preventDefault();
53
- let {
54
- onBlur
55
- } = this.props;
56
- onBlur && onBlur(e.target.value, e);
57
- this.syncHeight();
58
- }
59
-
60
- onKeyDown(e) {
61
- let {
62
- onKeyDown
63
- } = this.props;
64
- onKeyDown && onKeyDown(e);
65
- }
66
-
67
- inputRef(e) {
68
- let {
69
- getRef
70
- } = this.props;
71
- this.textareaRef = e;
72
- getRef && getRef(e);
73
- }
74
-
75
- isEmpty(obj) {
76
- return obj === undefined || obj === null || Object.keys(obj).length === 0 || obj.outerHeightStyle === 0 && !obj.overflow;
77
- }
78
-
79
- getStyleValue(value) {
80
- return parseInt(value, 10) || 0;
81
- }
82
-
83
- getUpdatedState() {
84
- const {
85
- minRows = 1,
86
- maxRows = 5,
87
- placeHolder
88
- } = this.props;
89
- const input = this.textareaRef;
90
- const containerWindow = ownerWindow(input);
91
- const computedStyle = containerWindow.getComputedStyle(input); // If input's width is shrunk and it's not visible, don't sync height.
92
-
93
- if (computedStyle.width === "0px") {
94
- return {
95
- outerHeightStyle: 0
96
- };
97
- }
98
-
99
- const inputShallow = this.shadowRef.current;
100
- inputShallow.style.width = computedStyle.width;
101
- inputShallow.value = input.value || placeHolder || "x"; // if (inputShallow.value.slice(-1) === "\n") {
102
- // Certain fonts which overflow the line height will cause the textarea
103
- // to report a different scrollHeight depending on whether the last line
104
- // is empty. Make it non-empty to avoid this issue.
105
- // inputShallow.value += " ";
106
- // }
107
-
108
- const boxSizing = computedStyle.boxSizing;
109
- const padding = this.getStyleValue(computedStyle.paddingBottom) + this.getStyleValue(computedStyle.paddingTop);
110
- const border = this.getStyleValue(computedStyle.borderBottomWidth) + this.getStyleValue(computedStyle.borderTopWidth); // The height of the inner content
111
-
112
- const innerHeight = inputShallow.scrollHeight; // Measure height of a textarea with a single row
113
-
114
- inputShallow.value = "x";
115
- const singleRowHeight = inputShallow.scrollHeight; // The height of the outer content
116
-
117
- let outerHeight = innerHeight;
118
-
119
- if (minRows) {
120
- outerHeight = Math.max(Number(minRows) * singleRowHeight, outerHeight);
121
- }
122
-
123
- if (maxRows) {
124
- outerHeight = Math.min(Number(maxRows) * singleRowHeight, outerHeight);
125
- }
126
-
127
- outerHeight = Math.max(outerHeight, singleRowHeight); // Take the box sizing into account for applying this value as a style.
128
-
129
- const outerHeightStyle = outerHeight + (boxSizing === "border-box" ? padding + border : 0);
130
- const overflow = Math.abs(outerHeight - innerHeight) <= 1;
131
- console.log("outerHeightStyle-->", outerHeightStyle);
132
- return {
133
- outerHeightStyle,
134
- overflow
135
- };
136
- }
137
-
138
- updateState(prevState, newState) {
139
- const {
140
- outerHeightStyle,
141
- overflow
142
- } = newState;
143
- const renders = this.rendersRef; // Need a large enough difference to update the height.
144
- // This prevents infinite rendering loop.
145
-
146
- if (renders.current < 20 && (outerHeightStyle > 0 && Math.abs((prevState.outerHeightStyle || 0) - outerHeightStyle) > 1 || prevState.overflow !== overflow)) {
147
- renders.current += 1;
148
- return {
149
- overflow,
150
- outerHeightStyle
151
- };
152
- } // if (process.env.NODE_ENV !== "production") {
153
- // if (renders.current === 20) {
154
- // console.error(
155
- // [
156
- // "MUI: Too many re-renders. The layout is unstable.",
157
- // "TextareaAutosize limits the number of renders to prevent an infinite loop."
158
- // ].join("\n")
159
- // )
160
- // }
161
- // }
162
-
163
-
164
- return prevState;
165
- }
166
-
167
- syncHeight() {
168
- const newState = this.getUpdatedState();
169
-
170
- if (this.isEmpty(newState)) {
171
- return;
172
- }
173
-
174
- this.setState(prevState => this.updateState(prevState, newState));
175
- }
176
-
177
- onChange(e) {
178
- e && e.preventDefault();
179
- let {
180
- onChange,
181
- text
182
- } = this.props;
183
- this.rendersRef.current = 0;
184
- const isControlled = text !== undefined;
185
-
186
- if (!isControlled) {
187
- this.syncHeight();
188
- }
189
-
190
- onChange && onChange(e.target.value, e);
191
- }
192
-
193
- syncHeightWithFlushSync() {
194
- const newState = this.getUpdatedState();
195
-
196
- if (this.isEmpty(newState)) {
197
- return;
198
- }
199
-
200
- ReactDOM.flushSync(() => {
201
- this.setState(prevState => this.updateState(prevState, newState));
202
- });
203
- }
204
-
205
- handleResize() {
206
- this.rendersRef.current = 0;
207
- this.syncHeightWithFlushSync();
208
- }
209
-
210
- rAFHandleResize() {
211
- cancelAnimationFrame(this.rAF);
212
- this.rAF = requestAnimationFrame(() => {
213
- this.handleResize();
214
- });
215
- }
216
-
217
- componentDidMount() {
218
- const input = this.textareaRef;
219
- const containerWindow = ownerWindow(input);
220
- this.debounceHandleResize = debounce(this.handleResize);
221
- containerWindow.addEventListener("resize", this.debounceHandleResize);
222
-
223
- if (typeof ResizeObserver !== "undefined") {
224
- this.resizeObserver = new ResizeObserver(this.rAFHandleResize);
225
- this.resizeObserver.observe(input);
226
- }
227
- }
228
-
229
- componentWillUnmount() {
230
- const input = this.textareaRef;
231
- const containerWindow = ownerWindow(input);
232
- this.debounceHandleResize.clear();
233
- cancelAnimationFrame(this.rAF);
234
- containerWindow.removeEventListener("resize", this.debounceHandleResize);
235
-
236
- if (this.resizeObserver) {
237
- this.resizeObserver.disconnect();
238
- }
239
- }
240
-
241
- componentDidUpdate(prevProps) {
242
- if (prevProps.text !== this.props.text) {
243
- this.rendersRef.current = 0;
244
- this.syncHeight();
245
- }
246
- }
247
-
248
- render() {
249
- let {
250
- size,
251
- placeHolder,
252
- needBorder,
253
- text,
254
- isDisabled,
255
- resize,
256
- maxLength,
257
- animated,
258
- variant,
259
- getRef,
260
- onFocus,
261
- dataId,
262
- dataSelectorId,
263
- isReadOnly,
264
- needAppearance,
265
- needReadOnlyStyle,
266
- borderColor,
267
- needEffect,
268
- autoFocus,
269
- htmlId,
270
- a11y,
271
- customClass,
272
- maxRows,
273
- minRows = 3,
274
- inlineStyle
275
- } = this.props;
276
- let {
277
- ariaLabel,
278
- ariaLabelledby
279
- } = a11y;
280
- let resizes = {
281
- horizontal: "resizeX",
282
- vertical: "resizeY",
283
- both: "resizeboth",
284
- none: "noresize"
285
- };
286
- let options = {};
287
-
288
- if (isReadOnly) {
289
- options.readOnly = "readOnly";
290
- }
291
-
292
- if (isDisabled) {
293
- options.disabled = "disabled";
294
- }
295
-
296
- if (autoFocus) {
297
- options.autoFocus = true;
298
- }
299
-
300
- let classList = needAppearance ? `${style.container} ${style[size]} ${style[variant]} ${needBorder ? style.needBorder : style.noBorder} ${resize ? style[resizes[resize]] : style[resizes.none]} ${animated ? `${style[`${size}animated`]}` : ""} ${isDisabled && !needEffect || isReadOnly && !needEffect ? "" : style.effect}` : `${style.basic}`;
301
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("textarea", {
302
- "aria-label": ariaLabel,
303
- "aria-labelledby": ariaLabelledby,
304
- className: `${customClass} ${isReadOnly && needReadOnlyStyle ? style.readonly : ""} ${classList} ${style[`borderColor_${borderColor}`]}`,
305
- placeholder: placeHolder,
306
- ...options,
307
- "data-id": dataId,
308
- "data-test-id": dataId,
309
- maxLength: maxLength,
310
- onChange: this.onChange,
311
- onKeyDown: this.onKeyDown,
312
- onFocus: onFocus,
313
- onBlur: this.onBlur,
314
- ref: this.inputRef,
315
- value: text,
316
- id: htmlId,
317
- "data-selector-id": dataSelectorId,
318
- rows: minRows,
319
- style: {
320
- height: this.state.outerHeightStyle,
321
- // Need a large enough difference to allow scrolling.
322
- // This prevents infinite rendering loop.
323
- overflow: this.state.overflow ? "hidden" : undefined,
324
- ...inlineStyle
325
- }
326
- }), /*#__PURE__*/React.createElement("textarea", {
327
- "aria-hidden": true,
328
- readOnly: true,
329
- ref: this.shadowRef,
330
- tabIndex: -1,
331
- className: `${customClass} ${classList} ${style[`borderColor_${borderColor}`]}`,
332
- style: { ...styles.shadow,
333
- ...inlineStyle,
334
- paddingTop: 0,
335
- paddingBottom: 0
336
- }
337
- }));
338
- }
339
-
340
- }
341
- Textarea.defaultProps = defaultProps;
342
- Textarea.propTypes = propTypes; // if (__DOCS__) {
343
- // Textarea.docs = {
344
- // componentGroup: 'Form Elements',
345
- // folderName: 'Style Guide',
346
- // external: true,
347
- // description: ' '
348
- // };
349
- // }
@@ -1,58 +0,0 @@
1
- import getSizingData from "./getSizingData";
2
- export default function calculateNodeHeight(_ref) {
3
- let {
4
- minRows = 1,
5
- maxRows = 5,
6
- textareaEle,
7
- hiddenTextareaEle
8
- } = _ref;
9
- const {
10
- computedStyle,
11
- paddingSize,
12
- borderSize,
13
- boxSizing
14
- } = getSizingData(textareaEle);
15
- const isBorderBox = boxSizing === "border-box"; // If input's width is shrunk and it's not visible, don't sync height.
16
-
17
- if (computedStyle.width === '0px') {
18
- return {
19
- height: 0
20
- };
21
- }
22
-
23
- let hiddenTextarea = hiddenTextareaEle;
24
- hiddenTextarea.style.width = computedStyle.width;
25
- hiddenTextarea.value = textareaEle.value || textareaEle.placeholder || "x";
26
-
27
- if (hiddenTextarea.value.slice(-1) === "\n") {
28
- // // Certain fonts which overflow the line height will cause the textarea
29
- // // to report a different scrollHeight depending on whether the last line
30
- // // is empty. Make it non-empty to avoid this issue.
31
- hiddenTextarea.value += " ";
32
- } // The height of the inner content
33
-
34
-
35
- const innerHeight = hiddenTextarea.scrollHeight; // Measure height of a textarea with a single row
36
-
37
- hiddenTextarea.value = "x";
38
- const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize || parseInt(computedStyle.lineHeight); // The height of the outer content
39
-
40
- let outerHeight = innerHeight;
41
-
42
- if (minRows) {
43
- outerHeight = Math.max(Number(minRows) * singleRowHeight, outerHeight);
44
- }
45
-
46
- if (maxRows) {
47
- outerHeight = Math.min(Number(maxRows) * singleRowHeight, outerHeight);
48
- }
49
-
50
- outerHeight = Math.max(outerHeight, singleRowHeight); // Take the box sizing into account for applying this value as a style.
51
-
52
- const height = outerHeight + (isBorderBox ? paddingSize + borderSize : 0);
53
- const overflow = Math.abs(outerHeight - innerHeight) <= 1;
54
- return {
55
- height,
56
- overflow
57
- };
58
- }
@@ -1,66 +0,0 @@
1
- import getSizingData from "./getSizingData";
2
-
3
- const getHeight = (node, _ref) => {
4
- let {
5
- borderSize,
6
- paddingSize,
7
- isBorderBox
8
- } = _ref;
9
- const height = node.scrollHeight;
10
-
11
- if (isBorderBox) {
12
- // border-box: add border, since height = content + padding + border
13
- return height + borderSize;
14
- } // remove padding, since height = content
15
-
16
-
17
- return height - paddingSize;
18
- };
19
-
20
- export default function calculateNodeHeightOne(_ref2) {
21
- let {
22
- minRows = 1,
23
- maxRows = 5,
24
- textareaEle,
25
- hiddenTextareaEle
26
- } = _ref2;
27
- const {
28
- computedStyle,
29
- paddingSize,
30
- borderSize,
31
- boxSizing
32
- } = getSizingData(hiddenTextareaEle);
33
- const isBorderBox = boxSizing === "border-box"; // If input's width is shrunk and it's not visible, don't sync height.
34
-
35
- if (computedStyle.width === '0px') {
36
- return {
37
- height: 0
38
- };
39
- }
40
-
41
- let hiddenTextarea = hiddenTextareaEle; // The height of the inner content
42
-
43
- let height = getHeight(hiddenTextarea, {
44
- paddingSize,
45
- borderSize,
46
- isBorderBox
47
- });
48
- const innerHeight = getHeight(hiddenTextarea, {
49
- paddingSize,
50
- borderSize,
51
- isBorderBox
52
- }); // measure height of a textarea with a single row
53
-
54
- hiddenTextarea.value = textareaEle.value || textareaEle.placeholder || "x";
55
- hiddenTextarea.style.width = computedStyle.width;
56
- const rowHeight = hiddenTextarea.scrollHeight - paddingSize;
57
- let minHeight = rowHeight * minRows + (isBorderBox ? paddingSize + borderSize : 0);
58
- let maxHeight = rowHeight * maxRows + (isBorderBox ? paddingSize + borderSize : 0);
59
- height = Math.min(maxHeight, Math.max(minHeight, height)); // Take the box sizing into account for applying this value as a style.
60
-
61
- const overflow = Math.abs(height - innerHeight) <= 1;
62
- return {
63
- height,
64
- overflow
65
- };
66
- }
@@ -1,24 +0,0 @@
1
- // Corresponds to 10 frames at 60 Hz.
2
- export default function debounce(func) {
3
- let wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 166;
4
- let timeout;
5
-
6
- function debounced() {
7
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8
- args[_key] = arguments[_key];
9
- }
10
-
11
- const later = () => {
12
- func.apply(this, args);
13
- };
14
-
15
- clearTimeout(timeout);
16
- timeout = setTimeout(later, wait);
17
- }
18
-
19
- debounced.clear = () => {
20
- clearTimeout(timeout);
21
- };
22
-
23
- return debounced;
24
- }
@@ -1,27 +0,0 @@
1
- import ownerWindow from "./ownerWindow";
2
-
3
- const getStyleValue = value => {
4
- return parseInt(value, 10) || 0;
5
- };
6
-
7
- const getSizingData = node => {
8
- const containerWindow = ownerWindow(node);
9
- const computedStyle = containerWindow.getComputedStyle(node);
10
-
11
- if (computedStyle === null) {
12
- return null;
13
- }
14
-
15
- const boxSizing = computedStyle.boxSizing;
16
- const paddingSize = getStyleValue(computedStyle.paddingBottom) + getStyleValue(computedStyle.paddingTop);
17
- const borderSize = getStyleValue(computedStyle.borderBottomWidth) + getStyleValue(computedStyle.borderTopWidth);
18
- return {
19
- boxSizing,
20
- paddingSize,
21
- borderSize,
22
- containerWindow,
23
- computedStyle
24
- };
25
- };
26
-
27
- export default getSizingData;
@@ -1,5 +0,0 @@
1
- const ownerDocument = node => {
2
- return node && node.ownerDocument || document;
3
- };
4
-
5
- export default ownerDocument;
@@ -1,8 +0,0 @@
1
- import ownerDocument from "./ownerDocument";
2
-
3
- const ownerWindow = node => {
4
- const document = ownerDocument(node);
5
- return document.defaultView || window;
6
- };
7
-
8
- export default ownerWindow;
@@ -1,30 +0,0 @@
1
- const updateState = (prevState, newState, renderRef) => {
2
- const {
3
- height,
4
- overflow
5
- } = newState;
6
- const renders = renderRef; // Need a large enough difference to update the height.
7
- // This prevents infinite rendering loop.
8
-
9
- if (renders.current < 20 && (height > 0 && Math.abs((prevState.height || 0) - height) > 1 || prevState.overflow !== overflow)) {
10
- renders.current += 1;
11
- return {
12
- overflow,
13
- height
14
- };
15
- } // if (process.env.NODE_ENV !== "production") {
16
- // if (renders.current === 20) {
17
- // console.error(
18
- // [
19
- // "MUI: Too many re-renders. The layout is unstable.",
20
- // "TextareaAutosize limits the number of renders to prevent an infinite loop."
21
- // ].join("\n")
22
- // )
23
- // }
24
- // }
25
-
26
-
27
- return prevState;
28
- };
29
-
30
- export default updateState;