@zohodesk/components 1.0.0-temp-169 → 1.0.0-temp-171

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 (216) hide show
  1. package/.cli/PropLessFiles.html +1 -1
  2. package/.cli/PropValidationExcludeFilesArray.js +1 -13
  3. package/.cli/propValidation_report.html +1 -1
  4. package/README.md +19 -0
  5. package/assets/Appearance/dark/mode/Component_DarkMode.module.css +1 -0
  6. package/assets/Appearance/light/mode/Component_LightMode.module.css +1 -0
  7. package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +1 -0
  8. package/coverage/Avatar/Avatar.js.html +649 -0
  9. package/coverage/Avatar/Avatar.module.css.html +556 -0
  10. package/coverage/Avatar/index.html +131 -0
  11. package/coverage/Avatar/props/defaultProps.js.html +136 -0
  12. package/coverage/Avatar/props/index.html +131 -0
  13. package/coverage/Avatar/props/propTypes.js.html +166 -0
  14. package/coverage/AvatarTeam/AvatarTeam.js.html +340 -0
  15. package/coverage/AvatarTeam/AvatarTeam.module.css.html +610 -0
  16. package/coverage/AvatarTeam/index.html +131 -0
  17. package/coverage/AvatarTeam/props/defaultProps.js.html +136 -0
  18. package/coverage/AvatarTeam/props/index.html +131 -0
  19. package/coverage/AvatarTeam/props/propTypes.js.html +169 -0
  20. package/coverage/Button/Button.js.html +1 -1
  21. package/coverage/Button/css/Button.module.css.html +1 -1
  22. package/coverage/Button/css/cssJSLogic.js.html +1 -1
  23. package/coverage/Button/css/index.html +1 -1
  24. package/coverage/Button/index.html +1 -1
  25. package/coverage/Button/props/defaultProps.js.html +1 -1
  26. package/coverage/Button/props/index.html +1 -1
  27. package/coverage/Button/props/propTypes.js.html +1 -1
  28. package/coverage/Buttongroup/Buttongroup.js.html +1 -1
  29. package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
  30. package/coverage/Buttongroup/index.html +1 -1
  31. package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
  32. package/coverage/Buttongroup/props/index.html +1 -1
  33. package/coverage/Buttongroup/props/propTypes.js.html +1 -1
  34. package/coverage/Label/Label.js.html +253 -0
  35. package/coverage/Label/Label.module.css.html +241 -0
  36. package/coverage/Label/LabelColors.module.css.html +145 -0
  37. package/coverage/Label/index.html +146 -0
  38. package/coverage/Label/props/defaultProps.js.html +118 -0
  39. package/coverage/Label/props/index.html +131 -0
  40. package/coverage/Label/props/propTypes.js.html +145 -0
  41. package/coverage/Layout/Box.js.html +367 -0
  42. package/coverage/Layout/Container.js.html +439 -0
  43. package/coverage/Layout/Layout.module.css.html +1090 -0
  44. package/coverage/Layout/index.html +176 -0
  45. package/coverage/Layout/index.js.html +118 -0
  46. package/coverage/Layout/props/defaultProps.js.html +136 -0
  47. package/coverage/Layout/props/index.html +131 -0
  48. package/coverage/Layout/props/propTypes.js.html +262 -0
  49. package/coverage/Layout/utils.js.html +199 -0
  50. package/coverage/Provider/AvatarSize.js.html +124 -0
  51. package/coverage/Provider/CssProvider.js.html +133 -0
  52. package/coverage/Provider/index.html +131 -0
  53. package/coverage/Radio/Radio.js.html +415 -0
  54. package/coverage/Radio/Radio.module.css.html +403 -0
  55. package/coverage/Radio/index.html +131 -0
  56. package/coverage/Radio/props/defaultProps.js.html +127 -0
  57. package/coverage/Radio/props/index.html +131 -0
  58. package/coverage/Radio/props/propTypes.js.html +187 -0
  59. package/coverage/Ribbon/Ribbon.js.html +229 -0
  60. package/coverage/Ribbon/Ribbon.module.css.html +1210 -0
  61. package/coverage/Ribbon/index.html +131 -0
  62. package/coverage/Ribbon/props/defaultProps.js.html +112 -0
  63. package/coverage/Ribbon/props/index.html +131 -0
  64. package/coverage/Ribbon/props/propTypes.js.html +121 -0
  65. package/coverage/RippleEffect/RippleEffect.js.html +172 -0
  66. package/coverage/RippleEffect/RippleEffect.module.css.html +415 -0
  67. package/coverage/RippleEffect/index.html +131 -0
  68. package/coverage/RippleEffect/props/defaultProps.js.html +112 -0
  69. package/coverage/RippleEffect/props/index.html +131 -0
  70. package/coverage/RippleEffect/props/propTypes.js.html +121 -0
  71. package/coverage/Stencils/Stencils.js.html +163 -0
  72. package/coverage/Stencils/Stencils.module.css.html +319 -0
  73. package/coverage/Stencils/index.html +131 -0
  74. package/coverage/Stencils/props/defaultProps.js.html +103 -0
  75. package/coverage/Stencils/props/index.html +131 -0
  76. package/coverage/Stencils/props/propTypes.js.html +109 -0
  77. package/coverage/Switch/Switch.js.html +379 -0
  78. package/coverage/Switch/Switch.module.css.html +481 -0
  79. package/coverage/Switch/index.html +131 -0
  80. package/coverage/Switch/props/defaultProps.js.html +118 -0
  81. package/coverage/Switch/props/index.html +131 -0
  82. package/coverage/Switch/props/propTypes.js.html +172 -0
  83. package/coverage/common/avatarsizes.module.css.html +229 -0
  84. package/coverage/common/common.module.css.html +1519 -0
  85. package/coverage/common/index.html +131 -0
  86. package/coverage/coverage-final.json +55 -10
  87. package/coverage/coverage-summary.json +56 -11
  88. package/coverage/index.html +311 -11
  89. package/coverage/utils/dummyFunction.js.html +1 -1
  90. package/coverage/utils/getInitial.js.html +139 -0
  91. package/coverage/utils/index.html +25 -10
  92. package/es/Avatar/__tests__/Avatar.spec.js +181 -0
  93. package/es/Avatar/__tests__/__snapshots__/Avatar.spec.js.snap +591 -0
  94. package/es/AvatarTeam/__tests__/AvatarTeam.spec.js +138 -0
  95. package/es/AvatarTeam/__tests__/__snapshots__/AvatarTeam.spec.js.snap +704 -0
  96. package/es/DateTime/DateTime.module.css +12 -1
  97. package/es/Label/__tests__/Label.spec.js +99 -0
  98. package/es/Label/__tests__/__snapshots__/Label.spec.js.snap +312 -0
  99. package/es/ListItem/ListContainer.js +1 -1
  100. package/es/MultiSelect/Suggestions.js +2 -1
  101. package/es/MultiSelect/props/propTypes.js +140 -138
  102. package/es/Radio/__tests__/Radio.spec.js +241 -0
  103. package/es/Radio/__tests__/__snapshots__/Radio.spec.js.snap +1837 -0
  104. package/es/Ribbon/__tests__/Ribbon.spec.js +52 -0
  105. package/es/Ribbon/__tests__/__snapshots__/Ribbon.spec.js.snap +374 -0
  106. package/es/RippleEffect/__tests__/RippleEffect.spec.js +69 -0
  107. package/es/RippleEffect/__tests__/__snapshots__/RippleEffect.spec.js.snap +171 -0
  108. package/es/Select/Select.js +4 -3
  109. package/es/Select/props/propTypes.js +3 -1
  110. package/es/Stencils/__tests__/Stencils.spec.js +46 -0
  111. package/es/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +89 -0
  112. package/es/Switch/__tests__/Switch.spec.js +156 -0
  113. package/es/Switch/__tests__/__snapshots__/Switch.spec.js.snap +831 -0
  114. package/es/TextBox/TextBox.module.css +4 -5
  115. package/es/Textarea/Textarea.module.css +4 -3
  116. package/es/v1/AppContainer/AppContainer.js +75 -92
  117. package/es/v1/Card/Card.js +143 -177
  118. package/es/v1/Card/index.js +4 -0
  119. package/es/v1/DateTime/CalendarView.js +43 -10
  120. package/es/v1/DateTime/DateTime.js +8 -4
  121. package/es/v1/DateTime/DateTimePopupFooter.js +2 -2
  122. package/es/v1/DateTime/DateTimePopupHeader.js +1 -1
  123. package/es/v1/DateTime/DateWidget.js +8 -4
  124. package/es/v1/DateTime/DaysRow.js +1 -1
  125. package/es/v1/DateTime/Time.js +2 -2
  126. package/es/v1/DateTime/YearView.js +2 -2
  127. package/es/v1/DateTime/props/defaultProps.js +57 -0
  128. package/es/v1/DateTime/props/propTypes.js +195 -0
  129. package/es/v1/DropDown/DropDown.js +31 -52
  130. package/es/v1/DropDown/DropDownHeading.js +29 -37
  131. package/es/v1/DropDown/DropDownItem.js +38 -58
  132. package/es/v1/DropDown/DropDownSearch.js +41 -49
  133. package/es/v1/DropDown/DropDownSeparator.js +7 -10
  134. package/es/v1/ListItem/ListItemWithAvatar.js +7 -8
  135. package/es/v1/MultiSelect/MultiSelect.js +1 -0
  136. package/es/v1/MultiSelect/MultiSelectWithAvatar.js +1 -0
  137. package/es/v1/Provider/AvatarSize.js +13 -0
  138. package/es/v1/Provider/Config.js +18 -0
  139. package/es/v1/Provider/CssProvider.js +16 -0
  140. package/es/v1/Provider/IdProvider.js +66 -0
  141. package/es/v1/Provider/LibraryContext.js +37 -0
  142. package/es/v1/Provider/LibraryContextInit.js +3 -0
  143. package/es/v1/Provider/NumberGenerator/NumberGenerator.js +136 -0
  144. package/es/v1/Provider/ZindexProvider.js +57 -0
  145. package/es/v1/Provider/index.js +4 -0
  146. package/es/v1/Tag/Tag.js +6 -2
  147. package/es/v1/TextBox/TextBox.js +10 -10
  148. package/es/v1/Typography/Typography.js +4 -4
  149. package/es/v1/Typography/css/Typography.module.css +33 -0
  150. package/es/v1/Typography/css/cssJSLogic.js +14 -8
  151. package/es/v1/Typography/props/defaultProps.js +4 -4
  152. package/es/v1/Typography/props/propTypes.js +8 -5
  153. package/lib/Avatar/__tests__/Avatar.spec.js +188 -0
  154. package/lib/Avatar/__tests__/__snapshots__/Avatar.spec.js.snap +591 -0
  155. package/lib/AvatarTeam/__tests__/AvatarTeam.spec.js +145 -0
  156. package/lib/AvatarTeam/__tests__/__snapshots__/AvatarTeam.spec.js.snap +704 -0
  157. package/lib/DateTime/DateTime.module.css +12 -1
  158. package/lib/Label/__tests__/Label.spec.js +106 -0
  159. package/lib/Label/__tests__/__snapshots__/Label.spec.js.snap +312 -0
  160. package/lib/ListItem/ListContainer.js +1 -1
  161. package/lib/MultiSelect/Suggestions.js +2 -1
  162. package/lib/MultiSelect/props/propTypes.js +146 -141
  163. package/lib/Radio/__tests__/Radio.spec.js +250 -0
  164. package/lib/Radio/__tests__/__snapshots__/Radio.spec.js.snap +1837 -0
  165. package/lib/Ribbon/__tests__/Ribbon.spec.js +59 -0
  166. package/lib/Ribbon/__tests__/__snapshots__/Ribbon.spec.js.snap +374 -0
  167. package/lib/RippleEffect/__tests__/RippleEffect.spec.js +76 -0
  168. package/lib/RippleEffect/__tests__/__snapshots__/RippleEffect.spec.js.snap +171 -0
  169. package/lib/Select/Select.js +4 -3
  170. package/lib/Select/props/propTypes.js +12 -2
  171. package/lib/Stencils/__tests__/Stencils.spec.js +53 -0
  172. package/lib/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +89 -0
  173. package/lib/Switch/__tests__/Switch.spec.js +163 -0
  174. package/lib/Switch/__tests__/__snapshots__/Switch.spec.js.snap +831 -0
  175. package/lib/TextBox/TextBox.module.css +4 -5
  176. package/lib/Textarea/Textarea.module.css +4 -3
  177. package/lib/v1/AppContainer/AppContainer.js +87 -138
  178. package/lib/v1/Card/Card.js +190 -286
  179. package/lib/v1/Card/index.js +37 -0
  180. package/lib/v1/DateTime/CalendarView.js +44 -10
  181. package/lib/v1/DateTime/DateTime.js +8 -4
  182. package/lib/v1/DateTime/DateTimePopupFooter.js +2 -2
  183. package/lib/v1/DateTime/DateTimePopupHeader.js +1 -1
  184. package/lib/v1/DateTime/DateWidget.js +8 -4
  185. package/lib/v1/DateTime/DaysRow.js +1 -1
  186. package/lib/v1/DateTime/Time.js +2 -2
  187. package/lib/v1/DateTime/YearView.js +2 -2
  188. package/lib/v1/DateTime/props/defaultProps.js +70 -0
  189. package/lib/v1/DateTime/props/propTypes.js +227 -0
  190. package/lib/v1/DropDown/DropDown.js +34 -130
  191. package/lib/v1/DropDown/DropDownHeading.js +29 -75
  192. package/lib/v1/DropDown/DropDownItem.js +50 -102
  193. package/lib/v1/DropDown/DropDownSearch.js +50 -89
  194. package/lib/v1/DropDown/DropDownSeparator.js +8 -48
  195. package/lib/v1/ListItem/ListItemWithAvatar.js +14 -9
  196. package/lib/v1/MultiSelect/MultiSelect.js +3 -1
  197. package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +3 -1
  198. package/lib/v1/Provider/AvatarSize.js +24 -0
  199. package/lib/v1/Provider/Config.js +27 -0
  200. package/lib/v1/Provider/CssProvider.js +27 -0
  201. package/lib/v1/Provider/IdProvider.js +79 -0
  202. package/lib/v1/Provider/LibraryContext.js +76 -0
  203. package/lib/v1/Provider/LibraryContextInit.js +15 -0
  204. package/lib/v1/Provider/NumberGenerator/NumberGenerator.js +174 -0
  205. package/lib/v1/Provider/ZindexProvider.js +69 -0
  206. package/lib/v1/Provider/index.js +81 -0
  207. package/lib/v1/Tag/Tag.js +7 -4
  208. package/lib/v1/TextBox/TextBox.js +8 -9
  209. package/lib/v1/Typography/Typography.js +3 -3
  210. package/lib/v1/Typography/css/Typography.module.css +33 -0
  211. package/lib/v1/Typography/css/cssJSLogic.js +8 -5
  212. package/lib/v1/Typography/props/defaultProps.js +4 -4
  213. package/lib/v1/Typography/props/propTypes.js +8 -5
  214. package/package.json +11 -11
  215. package/result.json +1 -1
  216. package/unittest/index.html +1 -1
@@ -13,6 +13,7 @@
13
13
  /* Variable:Ignore */
14
14
  --textbox_letter_spacing: 0.1px;
15
15
  --textbox_padding: 0;
16
+ --textbox_cursor: auto;
16
17
  --textbox_line_height: 35px;
17
18
 
18
19
  /* textbox placeholder default variable */
@@ -25,7 +26,7 @@
25
26
  appearance: none;
26
27
  letter-spacing: var(--textbox_letter_spacing);
27
28
  border: var(--textbox_border_width);
28
- cursor: text;
29
+ cursor: var(--textbox_cursor);
29
30
  }
30
31
  .basic::placeholder {
31
32
  color: var(--textbox_placeholder_text_color);
@@ -59,11 +60,9 @@
59
60
  .basic:disabled,
60
61
  .container:disabled,
61
62
  .container:disabled:hover {
63
+ --textbox_cursor: not-allowed;
62
64
  --textbox_text_color: var(--zdt_textbox_disabled_text);
63
65
  }
64
- .basic:disabled, .container:disabled, .container:disabled:hover {
65
- cursor: not-allowed;
66
- }
67
66
  .container:disabled,
68
67
  .container:disabled:hover {
69
68
  --textbox_bg_color: none;
@@ -81,7 +80,7 @@
81
80
  color: var(--textbox_placeholder_text_color);
82
81
  }
83
82
  .pointer {
84
- cursor: pointer;
83
+ --textbox_cursor: pointer;
85
84
  }
86
85
  /* Need Border */
87
86
  .border, .effect:hover, .effect:focus {
@@ -2,6 +2,7 @@
2
2
  /* textarea default variables */
3
3
  --textarea_border_width: 0;
4
4
  --textarea_border_color: none;
5
+ --textarea_cursor: auto;
5
6
  --textarea_text_color: var(--zdt_textarea_default_text);
6
7
  --textarea_font_size: var(--zd_font_size14);
7
8
  --textarea_line_height: 22px;
@@ -19,7 +20,7 @@
19
20
  outline: 0;
20
21
  letter-spacing: 0.1px;
21
22
  color: var(--textarea_text_color);
22
- cursor:text;
23
+ cursor: var(--textarea_cursor);
23
24
  }
24
25
  .basic, .noBorder {
25
26
  border-width: var(--textarea_border_width);
@@ -37,11 +38,11 @@
37
38
  color: var(--textarea_placeholder_text_color);
38
39
  }
39
40
  .basic:disabled {
41
+ --textarea_cursor: not-allowed;
40
42
  --textarea_text_color: var(--zdt_textarea_default_text);
41
- cursor: not-allowed;
42
43
  }
43
44
  .readonly {
44
- cursor: not-allowed;
45
+ --textarea_cursor: not-allowed;
45
46
  }
46
47
  .resizeX {
47
48
  composes: resizeX from '../common/common.module.css';
@@ -1,6 +1,6 @@
1
1
  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); }
2
2
 
3
- import React from 'react';
3
+ import React, { useEffect, useRef, useLayoutEffect } from 'react';
4
4
  import { defaultProps } from '../../AppContainer/props/defaultProps';
5
5
  import { propTypes } from '../../AppContainer/props/propTypes';
6
6
  import { Container, Box } from '../Layout';
@@ -17,116 +17,99 @@ import '../../common/a11y.module.css';
17
17
  import '../../common/boxShadow.module.css';
18
18
  import style from '../../AppContainer/AppContainer.module.css';
19
19
  import { getLibraryConfig, setLibraryConfig } from '../../Provider/Config';
20
- export default class AppContainer extends React.Component {
21
- constructor(props) {
22
- super(props);
23
- this.setTooltipRef = this.setTooltipRef.bind(this);
24
- this.handleOver = this.handleOver.bind(this);
25
- this.mouseOverDispatch = this.mouseOverDispatch.bind(this);
26
- this.removeTimeout = this.removeTimeout.bind(this);
27
- this.getContainerRef = this.getContainerRef.bind(this);
28
- this.timer = null;
29
- this.tooltipDebounce = getLibraryConfig('tooltipDebounce');
20
+ export default function AppContainer(props) {
21
+ let {
22
+ className,
23
+ children,
24
+ tagName,
25
+ dataId,
26
+ dataSelectorId,
27
+ tooltipClass,
28
+ tooltipParentClass,
29
+ needTooltip,
30
+ customProps,
31
+ eleRef
32
+ } = props;
33
+ let {
34
+ ContainerProps = {},
35
+ TooltipProps = {},
36
+ ExtraProps = {}
37
+ } = customProps;
38
+ const tooltipRef = useRef(null);
39
+ const containerElement = useRef(null);
40
+ const timer = useRef(null);
41
+ const tooltipDebounce = useRef(getLibraryConfig('tooltipDebounce'));
42
+ useLayoutEffect(() => {
30
43
  setLibraryConfig({
31
- getTooltipContainer: () => this.containerElement
44
+ getTooltipContainer: () => containerElement.current
32
45
  });
33
- }
46
+ }, []);
34
47
 
35
- mouseOverDispatch(e) {
36
- if (this.tooltipRef) {
37
- this.tooltipRef.handleOver(e, this.containerElement);
48
+ function mouseOverDispatch(e) {
49
+ if (tooltipRef.current) {
50
+ tooltipRef.current.handleOver(e, containerElement.current);
38
51
  }
39
52
  }
40
53
 
41
- removeTimeout() {
42
- if (this.timer) {
43
- this.timer = clearTimeout(this.timer);
54
+ function removeTimeout() {
55
+ if (timer.current) {
56
+ timer.current = clearTimeout(timer.current);
44
57
  }
45
58
  }
46
59
 
47
- handleOver(e) {
48
- if (this.timer) {
49
- this.timer = clearTimeout(this.timer);
60
+ function handleOver(e) {
61
+ if (timer.current) {
62
+ timer.current = clearTimeout(timer.current);
50
63
  }
51
64
 
52
- this.timer = setTimeout(() => this.mouseOverDispatch(e), this.tooltipDebounce);
65
+ timer.current = setTimeout(() => mouseOverDispatch(e), tooltipDebounce.current);
53
66
  }
54
67
 
55
- getContainerRef(ref) {
56
- let {
57
- eleRef
58
- } = this.props;
59
- this.containerElement = ref;
68
+ function getContainerRef(ref) {
69
+ containerElement.current = ref;
60
70
  eleRef && eleRef(ref);
61
71
  }
62
72
 
63
- setTooltipRef(ref) {
64
- this.tooltipRef = ref;
65
- }
66
-
67
- componentDidMount() {
68
- let {
69
- needTooltip
70
- } = this.props;
71
-
72
- if (this.containerElement && needTooltip) {
73
- this.containerElement.addEventListener('mouseover', this.handleOver, false);
74
- this.containerElement.addEventListener('mouseout', this.removeTimeout, false);
75
- this.tooltipRef.observeElement();
76
- }
73
+ function setTooltipRef(ref) {
74
+ tooltipRef.current = ref;
77
75
  }
78
76
 
79
- componentWillUnmount() {
80
- let {
81
- needTooltip
82
- } = this.props;
83
-
84
- if (this.containerElement && needTooltip) {
85
- this.containerElement.removeEventListener('mouseover', this.handleOver, false);
86
- this.containerElement.addEventListener('mouseout', this.removeTimeout, false);
87
- this.tooltipRef.unObserveElement();
88
- setLibraryConfig({
89
- getTooltipContainer: () => null
90
- });
77
+ useEffect(() => {
78
+ if (containerElement.current && needTooltip) {
79
+ containerElement.current.addEventListener('mouseover', handleOver, false);
80
+ containerElement.current.addEventListener('mouseout', removeTimeout, false);
81
+ tooltipRef.current.observeElement();
91
82
  }
92
- }
93
-
94
- render() {
95
- let {
96
- className,
97
- children,
98
- tagName,
99
- dataId,
100
- dataSelectorId,
101
- tooltipClass,
102
- tooltipParentClass,
103
- needTooltip,
104
- customProps
105
- } = this.props;
106
- let {
107
- ContainerProps = {},
108
- TooltipProps = {},
109
- ExtraProps = {}
110
- } = customProps;
111
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Container, _extends({
112
- className: `${style.container} ${className}`,
113
- dataId: dataId,
114
- dataSelectorId: dataSelectorId,
115
- tagName: tagName,
116
- eleRef: this.getContainerRef
117
- }, ContainerProps, ExtraProps), /*#__PURE__*/React.createElement(Box, {
118
- flexible: true
119
- }, children)), needTooltip ? /*#__PURE__*/React.createElement("div", _extends({}, ExtraProps, {
120
- className: `${style.container} ${style.tooltip} ${tooltipParentClass}`,
121
- "data-id": `${dataId}_tooltip`,
122
- "data-test-id": `${dataId}_tooltip`,
123
- "data-selector-id": `${dataSelectorId}_tooltip`
124
- }), /*#__PURE__*/React.createElement(Tooltip, _extends({
125
- ref: this.setTooltipRef,
126
- customClass: tooltipClass
127
- }, TooltipProps))) : null);
128
- }
129
-
83
+ }, []);
84
+ useEffect(() => {
85
+ return () => {
86
+ if (containerElement.current && needTooltip) {
87
+ containerElement.current.removeEventListener('mouseover', handleOver, false);
88
+ containerElement.current.addEventListener('mouseout', removeTimeout, false);
89
+ tooltipRef.current.unObserveElement();
90
+ setLibraryConfig({
91
+ getTooltipContainer: () => null
92
+ });
93
+ }
94
+ };
95
+ }, []);
96
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Container, _extends({
97
+ className: `${style.container} ${className}`,
98
+ dataId: dataId,
99
+ dataSelectorId: dataSelectorId,
100
+ tagName: tagName,
101
+ eleRef: getContainerRef
102
+ }, ContainerProps, ExtraProps), /*#__PURE__*/React.createElement(Box, {
103
+ flexible: true
104
+ }, children)), needTooltip ? /*#__PURE__*/React.createElement("div", _extends({}, ExtraProps, {
105
+ className: `${style.container} ${style.tooltip} ${tooltipParentClass}`,
106
+ "data-id": `${dataId}_tooltip`,
107
+ "data-test-id": `${dataId}_tooltip`,
108
+ "data-selector-id": `${dataSelectorId}_tooltip`
109
+ }), /*#__PURE__*/React.createElement(Tooltip, _extends({
110
+ ref: setTooltipRef,
111
+ customClass: tooltipClass
112
+ }, TooltipProps))) : null);
130
113
  }
131
114
  AppContainer.propTypes = propTypes;
132
115
  AppContainer.defaultProps = defaultProps; // if (__DOCS__) {
@@ -1,4 +1,5 @@
1
- import React, { Component } from 'react';
1
+ import React, { useRef, useState } from 'react';
2
+ import { useEffectCallOnlyAfterState } from '@zohodesk/hooks';
2
3
  import { CardHeader_propTypes, CardContent_propTypes, Card_propTypes, CardFooter_propTypes } from '../../Card/props/propTypes';
3
4
  import { Card_defaultProps, CardHeader_defaultProps, CardContent_defaultProps, CardFooter_defaultProps } from '../../Card/props/defaultProps';
4
5
  import { Container, Box } from '../Layout';
@@ -14,99 +15,97 @@ scroll logic move to virtualizer list
14
15
 
15
16
  /* performance handling pending in card component moving to ref instead of setState */
16
17
 
17
- export class CardHeader extends Component {
18
- constructor(props) {
19
- super(props);
20
- this.getCardHeaderDom = this.getCardHeaderDom.bind(this);
21
- this.cardHeader = null;
18
+ export function CardHeader(props) {
19
+ let {
20
+ isScroll,
21
+ children,
22
+ dataId,
23
+ dataSelectorId,
24
+ customClass
25
+ } = props;
26
+ const cardHeader = useRef(null);
27
+
28
+ function getCardHeaderDom(ele) {
29
+ cardHeader.current = ele;
22
30
  }
23
31
 
24
- getCardHeaderDom(ele) {
25
- this.cardHeader = ele;
26
- }
27
-
28
- setScrollClassName() {
29
- if (!this.cardHeader) {
32
+ function setScrollClassName() {
33
+ if (!cardHeader.current) {
30
34
  return null;
31
35
  }
32
36
  }
33
37
 
34
- render() {
35
- let {
36
- isScroll,
37
- children,
38
- dataId,
39
- dataSelectorId,
40
- customClass
41
- } = this.props;
42
- return /*#__PURE__*/React.createElement(Box, {
43
- className: `${isScroll ? style.scroll : style.notScroll} ${customClass}`,
44
- eleRef: this.getCardHeaderDom,
45
- dataId: dataId,
46
- dataSelectorId: dataSelectorId
47
- }, children);
48
- }
49
-
38
+ return /*#__PURE__*/React.createElement(Box, {
39
+ className: `${isScroll ? style.scroll : style.notScroll} ${customClass}`,
40
+ eleRef: getCardHeaderDom,
41
+ dataId: dataId,
42
+ dataSelectorId: dataSelectorId
43
+ }, children);
50
44
  }
51
45
  CardHeader.propTypes = CardHeader_propTypes;
52
46
  CardHeader.defaultProps = CardHeader_defaultProps;
53
- export class CardContent extends Component {
54
- render() {
55
- let {
56
- onScroll,
57
- eleRef,
58
- children,
59
- scroll,
60
- isScrollAttribute,
61
- dataId,
62
- dataSelectorId,
63
- shrink,
64
- customClass,
65
- preventParentScroll
66
- } = this.props;
67
- return /*#__PURE__*/React.createElement(Box, {
68
- flexible: true,
69
- onScroll: onScroll,
70
- eleRef: eleRef,
71
- scroll: scroll,
72
- preventParentScroll: preventParentScroll,
73
- isScrollAttribute: isScrollAttribute,
74
- dataId: dataId,
75
- shrink: shrink,
76
- className: customClass,
77
- dataSelectorId: dataSelectorId
78
- }, children);
79
- }
80
-
47
+ export function CardContent(props) {
48
+ let {
49
+ onScroll,
50
+ eleRef,
51
+ children,
52
+ scroll,
53
+ isScrollAttribute,
54
+ dataId,
55
+ dataSelectorId,
56
+ shrink,
57
+ customClass,
58
+ preventParentScroll
59
+ } = props;
60
+ return /*#__PURE__*/React.createElement(Box, {
61
+ flexible: true,
62
+ onScroll: onScroll,
63
+ eleRef: eleRef,
64
+ scroll: scroll,
65
+ preventParentScroll: preventParentScroll,
66
+ isScrollAttribute: isScrollAttribute,
67
+ dataId: dataId,
68
+ shrink: shrink,
69
+ className: customClass,
70
+ dataSelectorId: dataSelectorId
71
+ }, children);
81
72
  }
82
73
  CardContent.propTypes = CardContent_propTypes;
83
74
  CardContent.defaultProps = CardContent_defaultProps;
84
- export default class Card extends Component {
85
- constructor(props) {
86
- super(props);
87
- this.state = {
88
- isScroll: false
89
- };
90
- let {
91
- from,
92
- limit
93
- } = props;
94
- this.from = from;
95
- this.limit = limit;
96
- this.to = from + 3 * limit;
97
- this.isFetching = false;
98
- this.lastScrollTop = 0;
99
- this.onScroll = this.onScroll.bind(this); //this.onSetScroll = debounce(this.setScroll.bind(this, true), 10, true);
100
- //this.onClearScroll = debounce(this.setScroll.bind(this, false), 500);
101
- }
102
-
103
- UNSAFE_componentWillReceiveProps(nextProps) {
104
- if (this.from !== nextProps.from) {
105
- this.from = nextProps.from;
106
- }
107
- }
108
-
109
- onScroll(e) {
75
+ export default function Card(props) {
76
+ let {
77
+ onClick,
78
+ children,
79
+ isScrollAttribute,
80
+ dataId,
81
+ eleRef,
82
+ customClass = '',
83
+ htmlId,
84
+ a11y,
85
+ from,
86
+ limit,
87
+ fetchData,
88
+ noMoreData,
89
+ scrollAt,
90
+ noNeedUpScroll,
91
+ isPercentageScroll,
92
+ onScroll
93
+ } = props;
94
+ let {
95
+ role
96
+ } = a11y;
97
+ const [isScroll, setScroll] = useState(false);
98
+ const fromRef = useRef(from);
99
+ const limitRef = useRef(limit);
100
+ const to = useRef(from + 3 * limit);
101
+ const lastScrollTop = useRef(0);
102
+ const isFetching = useRef(false);
103
+ const scrollDirection = useRef(null);
104
+ useEffectCallOnlyAfterState(() => {
105
+ fromRef.current = from;
106
+ }, [from]);
107
+
108
+ function onCardScroll(e) {
110
109
  let scrollContainerObj = e.currentTarget;
111
110
  let {
112
111
  scrollHeight
@@ -117,56 +116,45 @@ export default class Card extends Component {
117
116
  let {
118
117
  offsetHeight
119
118
  } = scrollContainerObj;
120
- let {
121
- onScroll
122
- } = this.props;
123
119
  onScroll && onScroll(e);
124
- let {
125
- fetchData,
126
- noMoreData,
127
- scrollAt,
128
- noNeedUpScroll,
129
- // isScrollShadow,
130
- isPercentageScroll
131
- } = this.props;
132
120
 
133
- if (scrollTop > this.lastScrollTop) {
134
- this.scrollDirection = 'down';
121
+ if (scrollTop > lastScrollTop.current) {
122
+ scrollDirection.current = 'down';
135
123
  } else {
136
- this.scrollDirection = 'up';
124
+ scrollDirection.current = 'up';
137
125
  }
138
126
 
139
- this.lastScrollTop = scrollTop;
127
+ lastScrollTop.current = scrollTop;
140
128
 
141
- if (fetchData && !this.isFetching) {
142
- if (this.scrollDirection === 'down' && !noMoreData) {
129
+ if (fetchData && !isFetching.current) {
130
+ if (scrollDirection.current === 'down' && !noMoreData) {
143
131
  const scrollingPercentage = (scrollTop + offsetHeight) / (scrollHeight - scrollAt) * 100;
144
132
  const prefetch = isPercentageScroll ? scrollingPercentage >= getLibraryConfig('scrollFetchLimit') : scrollHeight - scrollAt <= scrollTop + offsetHeight;
145
133
 
146
134
  if (prefetch) {
147
- this.isFetching = true;
148
- fetchData(this.from + this.limit, this.limit + this.to, this.scrollDirection).then(() => {
149
- this.to = this.limit + this.to;
150
- this.isFetching = false;
135
+ isFetching.current = true;
136
+ fetchData(fromRef.current + limitRef.current, limitRef.current + to.current, scrollDirection.current).then(() => {
137
+ to.current = limitRef.current + to.current;
138
+ isFetching.current = false;
151
139
  }, () => {
152
- this.isFetching = false;
140
+ isFetching.current = false;
153
141
  });
154
142
  }
155
143
  } else {
156
- if (0 >= scrollTop - scrollAt && this.from !== 0 && !noNeedUpScroll) {
157
- this.isFetching = true;
158
- fetchData(this.from - this.limit, this.to - this.limit, this.scrollDirection).then(() => {
159
- this.to = this.to - this.limit;
160
- this.isFetching = false;
144
+ if (0 >= scrollTop - scrollAt && fromRef.current !== 0 && !noNeedUpScroll) {
145
+ isFetching.current = true;
146
+ fetchData(fromRef.current - limitRef.current, to.current - limitRef.current, scrollDirection.current).then(() => {
147
+ to.current = to.current - limitRef.current;
148
+ isFetching.current = false;
161
149
  }, () => {
162
- this.isFetching = false;
150
+ isFetching.current = false;
163
151
  });
164
152
  }
165
153
  }
166
154
  }
167
155
 
168
156
  if (fetchData && !noNeedUpScroll) {
169
- if (this.from !== 0 && scrollTop === 0 && !noNeedUpScroll) {
157
+ if (fromRef.current !== 0 && scrollTop === 0 && !noNeedUpScroll) {
170
158
  scrollContainerObj.scrollTop = scrollTop + offsetHeight / 3;
171
159
  } else if (scrollHeight === scrollTop + offsetHeight && !noMoreData) {
172
160
  scrollContainerObj.scrollTop = scrollTop - offsetHeight / 2;
@@ -187,59 +175,40 @@ export default class Card extends Component {
187
175
  // }
188
176
 
189
177
 
190
- render() {
191
- let {
192
- onClick,
193
- children,
194
- isScrollAttribute,
195
- dataId,
196
- eleRef,
197
- customClass = '',
198
- htmlId,
199
- a11y
200
- } = this.props;
201
- let {
202
- isScroll
203
- } = this.state;
204
- let {
205
- role
206
- } = a11y;
207
- return /*#__PURE__*/React.createElement(Container, {
208
- className: `${customClass}`,
209
- isScrollAttribute: isScrollAttribute,
210
- onClick: onClick,
211
- dataId: dataId,
212
- eleRef: eleRef
213
- }, React.Children.map(children, child => {
214
- if (!child) {
215
- return child;
216
- }
217
-
218
- if (child.type === CardHeader || this.props.childTypes && child.type === this.props.childTypes.cardHeader) {
219
- return /*#__PURE__*/React.cloneElement(child, {
220
- isScroll
221
- });
222
- } else if (child.type === CardContent || this.props.childTypes && child.type === this.props.childTypes.cardContent) {
223
- return /*#__PURE__*/React.createElement(Box, {
224
- id: htmlId,
225
- role: role,
226
- flexible: true,
227
- scroll: child.props.scroll,
228
- preventParentScroll: child.props.preventParentScroll,
229
- onScroll: this.onScroll,
230
- eleRef: child.props.eleRef,
231
- isScrollAttribute: child.props.isScrollAttribute,
232
- dataId: child.props.dataId,
233
- shrink: child.props.shrink,
234
- className: child.props.customClass,
235
- dataSelectorId: child.props.dataSelectorId
236
- }, child.props.children);
237
- }
238
-
178
+ return /*#__PURE__*/React.createElement(Container, {
179
+ className: `${customClass}`,
180
+ isScrollAttribute: isScrollAttribute,
181
+ onClick: onClick,
182
+ dataId: dataId,
183
+ eleRef: eleRef
184
+ }, React.Children.map(children, child => {
185
+ if (!child) {
239
186
  return child;
240
- }));
241
- }
187
+ }
188
+
189
+ if (child.type === CardHeader || props.childTypes && child.type === props.childTypes.cardHeader) {
190
+ return /*#__PURE__*/React.cloneElement(child, {
191
+ isScroll
192
+ });
193
+ } else if (child.type === CardContent || props.childTypes && child.type === props.childTypes.cardContent) {
194
+ return /*#__PURE__*/React.createElement(Box, {
195
+ id: htmlId,
196
+ role: role,
197
+ flexible: true,
198
+ scroll: child.props.scroll,
199
+ preventParentScroll: child.props.preventParentScroll,
200
+ onScroll: onCardScroll,
201
+ eleRef: child.props.eleRef,
202
+ isScrollAttribute: child.props.isScrollAttribute,
203
+ dataId: child.props.dataId,
204
+ shrink: child.props.shrink,
205
+ className: child.props.customClass,
206
+ dataSelectorId: child.props.dataSelectorId
207
+ }, child.props.children);
208
+ }
242
209
 
210
+ return child;
211
+ }));
243
212
  }
244
213
  Card.propTypes = Card_propTypes;
245
214
  Card.defaultProps = Card_defaultProps; // if (__DOCS__) {
@@ -251,21 +220,18 @@ Card.defaultProps = Card_defaultProps; // if (__DOCS__) {
251
220
  // };
252
221
  // }
253
222
 
254
- export class CardFooter extends Component {
255
- render() {
256
- let {
257
- children,
258
- dataId,
259
- customClass,
260
- dataSelectorId
261
- } = this.props;
262
- return /*#__PURE__*/React.createElement(Box, {
263
- className: `${customClass}`,
264
- dataId: dataId,
265
- dataSelectorId: dataSelectorId
266
- }, children);
267
- }
268
-
223
+ export function CardFooter(props) {
224
+ let {
225
+ children,
226
+ dataId,
227
+ customClass,
228
+ dataSelectorId
229
+ } = props;
230
+ return /*#__PURE__*/React.createElement(Box, {
231
+ className: `${customClass}`,
232
+ dataId: dataId,
233
+ dataSelectorId: dataSelectorId
234
+ }, children);
269
235
  }
270
236
  CardFooter.propTypes = CardFooter_propTypes;
271
237
  CardFooter.defaultProps = CardFooter_defaultProps;
@@ -0,0 +1,4 @@
1
+ export { default as Card } from './Card';
2
+ export { CardHeader } from './Card';
3
+ export { CardContent } from './Card';
4
+ export { CardFooter } from './Card';