@zohodesk/components 1.0.0-temp-219.3 → 1.0.0-temp-229.1

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 (46) hide show
  1. package/.cli/config/variables/variableMapping.json +8 -1
  2. package/.cli/propValidation_report.html +1 -1
  3. package/README.md +13 -0
  4. package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +11 -0
  5. package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +11 -0
  6. package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +11 -0
  7. package/es/AppContainer/AppContainer.js +5 -4
  8. package/es/Card/Card.js +39 -10
  9. package/es/Card/props/defaultProps.js +2 -1
  10. package/es/Card/props/propTypes.js +2 -1
  11. package/es/CheckBox/CheckBox.js +2 -9
  12. package/es/Label/Label.js +2 -9
  13. package/es/Provider/LibraryContext.js +7 -3
  14. package/es/deprecated/Switch/Switch.js +94 -0
  15. package/es/deprecated/Switch/props/defaultProps.js +11 -0
  16. package/es/deprecated/Switch/props/propTypes.js +28 -0
  17. package/es/v1/Switch/Switch.js +122 -78
  18. package/es/v1/Switch/__tests__/Switch.spec.js +30 -0
  19. package/es/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +135 -0
  20. package/es/v1/Switch/contants/index.js +24 -0
  21. package/es/v1/Switch/css/Switch_v1.module.css +134 -0
  22. package/es/v1/Switch/css/cssJSLogic.js +48 -0
  23. package/es/v1/Switch/props/defaultProps.js +8 -8
  24. package/es/v1/Switch/props/propTypes.js +30 -22
  25. package/es/v1/Switch/useSwitch.js +33 -0
  26. package/lib/AppContainer/AppContainer.js +7 -6
  27. package/lib/Card/Card.js +54 -25
  28. package/lib/Card/props/defaultProps.js +2 -1
  29. package/lib/Card/props/propTypes.js +2 -1
  30. package/lib/CheckBox/CheckBox.js +2 -9
  31. package/lib/Label/Label.js +2 -9
  32. package/lib/Provider/LibraryContext.js +7 -3
  33. package/lib/deprecated/Switch/Switch.js +108 -0
  34. package/lib/deprecated/Switch/props/defaultProps.js +18 -0
  35. package/lib/deprecated/Switch/props/propTypes.js +39 -0
  36. package/lib/v1/Switch/Switch.js +130 -79
  37. package/lib/v1/Switch/__tests__/Switch.spec.js +37 -0
  38. package/lib/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +135 -0
  39. package/lib/v1/Switch/contants/index.js +34 -0
  40. package/lib/v1/Switch/css/Switch_v1.module.css +134 -0
  41. package/lib/v1/Switch/css/cssJSLogic.js +37 -0
  42. package/lib/v1/Switch/props/defaultProps.js +10 -10
  43. package/lib/v1/Switch/props/propTypes.js +32 -24
  44. package/lib/v1/Switch/useSwitch.js +56 -0
  45. package/package.json +10 -8
  46. package/result.json +1 -1
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import Switch from "../Switch";
4
+ describe('Switch', () => {
5
+ test('rendering the defult props', () => {
6
+ const {
7
+ asFragment
8
+ } = render( /*#__PURE__*/React.createElement(Switch, null));
9
+ expect(asFragment()).toMatchSnapshot();
10
+ });
11
+ test('rendering the Switch with Checked', () => {
12
+ const {
13
+ asFragment
14
+ } = render( /*#__PURE__*/React.createElement(Switch, {
15
+ id: "switch",
16
+ isChecked: true
17
+ }));
18
+ expect(asFragment()).toMatchSnapshot();
19
+ });
20
+ test('rendering the Switch with Disabled', () => {
21
+ const {
22
+ asFragment
23
+ } = render( /*#__PURE__*/React.createElement(Switch, {
24
+ id: "switch",
25
+ isChecked: true,
26
+ isDisabled: true
27
+ }));
28
+ expect(asFragment()).toMatchSnapshot();
29
+ });
30
+ });
@@ -0,0 +1,135 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Switch rendering the Switch with Checked 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="inlineFlex row alignItems_center container medium checked enabled"
7
+ data-id="flex"
8
+ data-test-id="flex"
9
+ >
10
+ <div
11
+ class="noShrink trackWrapper"
12
+ data-id="flex"
13
+ data-test-id="flex"
14
+ >
15
+ <input
16
+ checked=""
17
+ class="track"
18
+ id="switch"
19
+ role="switch"
20
+ type="checkbox"
21
+ value=""
22
+ />
23
+ <svg
24
+ class="thumb commonSvg"
25
+ xmlns="http://www.w3.org/2000/svg"
26
+ >
27
+ <circle
28
+ cx="50%"
29
+ cy="50%"
30
+ r="42.85%"
31
+ />
32
+ </svg>
33
+ <svg
34
+ class="onLabel commonSvg"
35
+ xmlns="http://www.w3.org/2000/svg"
36
+ >
37
+ <rect
38
+ height="100%"
39
+ rx="50%"
40
+ width="100%"
41
+ />
42
+ </svg>
43
+ </div>
44
+ </div>
45
+ </DocumentFragment>
46
+ `;
47
+
48
+ exports[`Switch rendering the Switch with Disabled 1`] = `
49
+ <DocumentFragment>
50
+ <div
51
+ class="inlineFlex row alignItems_center container medium checked disabled"
52
+ data-id="flex"
53
+ data-test-id="flex"
54
+ >
55
+ <div
56
+ class="noShrink trackWrapper"
57
+ data-id="flex"
58
+ data-test-id="flex"
59
+ >
60
+ <input
61
+ aria-disabled="true"
62
+ checked=""
63
+ class="track"
64
+ id="switch"
65
+ role="switch"
66
+ type="checkbox"
67
+ value=""
68
+ />
69
+ <svg
70
+ class="thumb commonSvg"
71
+ xmlns="http://www.w3.org/2000/svg"
72
+ >
73
+ <circle
74
+ cx="50%"
75
+ cy="50%"
76
+ r="42.85%"
77
+ />
78
+ </svg>
79
+ <svg
80
+ class="onLabel commonSvg"
81
+ xmlns="http://www.w3.org/2000/svg"
82
+ >
83
+ <rect
84
+ height="100%"
85
+ rx="50%"
86
+ width="100%"
87
+ />
88
+ </svg>
89
+ </div>
90
+ </div>
91
+ </DocumentFragment>
92
+ `;
93
+
94
+ exports[`Switch rendering the defult props 1`] = `
95
+ <DocumentFragment>
96
+ <div
97
+ class="inlineFlex row alignItems_center container medium unChecked enabled"
98
+ data-id="flex"
99
+ data-test-id="flex"
100
+ >
101
+ <div
102
+ class="noShrink trackWrapper"
103
+ data-id="flex"
104
+ data-test-id="flex"
105
+ >
106
+ <input
107
+ class="track"
108
+ role="switch"
109
+ type="checkbox"
110
+ value=""
111
+ />
112
+ <svg
113
+ class="thumb commonSvg"
114
+ xmlns="http://www.w3.org/2000/svg"
115
+ >
116
+ <circle
117
+ cx="50%"
118
+ cy="50%"
119
+ r="42.85%"
120
+ />
121
+ </svg>
122
+ <svg
123
+ class="offLabel commonSvg"
124
+ xmlns="http://www.w3.org/2000/svg"
125
+ >
126
+ <circle
127
+ cx="50%"
128
+ cy="50%"
129
+ r="37.5%"
130
+ />
131
+ </svg>
132
+ </div>
133
+ </div>
134
+ </DocumentFragment>
135
+ `;
@@ -0,0 +1,24 @@
1
+ export const OFF_LABEL_RADIUS = {
2
+ small: '35.7%',
3
+ medium: '37.5%',
4
+ large: '38.9%',
5
+ xlarge: '40%'
6
+ };
7
+ export const THUMB_RADIUS = {
8
+ small: '40%',
9
+ medium: '42.85%',
10
+ large: '44.45%',
11
+ xlarge: '45.45%'
12
+ };
13
+ export const ITEMS_DIRECTION = {
14
+ start: 'row',
15
+ end: 'rowReverse',
16
+ top: 'column',
17
+ bottom: 'columnReverse'
18
+ };
19
+ export const ALIGN_ITEMS = {
20
+ start: 'center',
21
+ end: 'center',
22
+ top: 'start',
23
+ bottom: 'start'
24
+ };
@@ -0,0 +1,134 @@
1
+ .container {
2
+ --local-switch-cursor: pointer;
3
+ --local-switch-offLabel-stroke: var(--zdt_v1_switch_offLabel);
4
+ gap: var(--zd_size6) ;
5
+ }
6
+ .small {
7
+ --local-switch-track-width: var(--zd_size22);
8
+ --local-switch-track-height: var(--zd_size12);
9
+ --local-switch-track-border-radius: 8px;
10
+ --local-switch-thumb-size: var(--zd_size10);
11
+ --local-switch-onLabel-height: var(--zd_size6);
12
+ --local-switch-onLabel-left: var(--zd_size5);
13
+ --local-switch-offLabel-size: var(--zd_size7);
14
+ --local-switch-offLabel-right: var(--zd_size2);
15
+ --local-switch-onLabel-scaleX: 1.2;
16
+ }
17
+ .medium {
18
+ --local-switch-track-width: var(--zd_size28);
19
+ --local-switch-track-height: var(--zd_size16);
20
+ --local-switch-track-border-radius: 16px;
21
+ --local-switch-thumb-size: var(--zd_size14);
22
+ --local-switch-onLabel-height: var(--zd_size8);
23
+ --local-switch-onLabel-left: var(--zd_size6);
24
+ --local-switch-offLabel-size: var(--zd_size8);
25
+ --local-switch-offLabel-right: var(--zd_size3);
26
+ --local-switch-onLabel-scaleX: 1.4;
27
+ }
28
+ .large {
29
+ --local-switch-track-width: var(--zd_size34);
30
+ --local-switch-track-height: var(--zd_size20);
31
+ --local-switch-track-border-radius: 10px;
32
+ --local-switch-thumb-size: var(--zd_size18);
33
+ --local-switch-onLabel-height: var(--zd_size10);
34
+ --local-switch-onLabel-left: var(--zd_size7);
35
+ --local-switch-offLabel-size: var(--zd_size9);
36
+ --local-switch-offLabel-right: var(--zd_size4);
37
+ --local-switch-onLabel-scaleX: 1.6;
38
+ }
39
+ .xlarge {
40
+ --local-switch-track-width: var(--zd_size40);
41
+ --local-switch-track-height: var(--zd_size24);
42
+ --local-switch-track-border-radius: 12px;
43
+ --local-switch-thumb-size: var(--zd_size22);
44
+ --local-switch-onLabel-height: var(--zd_size12);
45
+ --local-switch-onLabel-left: var(--zd_size8);
46
+ --local-switch-offLabel-size: var(--zd_size10);
47
+ --local-switch-offLabel-right: var(--zd_size5);
48
+ --local-switch-onLabel-scaleX: 1.8;
49
+ }
50
+ .disabled, .readonly {
51
+ --local-switch-cursor: not-allowed;
52
+ }
53
+ .checked.enabled > .trackWrapper:hover {
54
+ --local-switch-track-background-color: var(--zdt_v1_switch_track_on_hover_bg);
55
+ }
56
+ .unChecked.enabled > .trackWrapper:hover {
57
+ --local-switch-track-background-color: var(--zdt_v1_switch_track_off_hover_bg);
58
+ }
59
+ .enabled > .trackWrapper:hover {
60
+ --local-switch-offLabel-stroke: var(--zdt_v1_switch_offLabel_hover);
61
+ }
62
+ .trackWrapper {
63
+ position: relative;
64
+ }
65
+ .disabled > .trackWrapper {
66
+ opacity: 0.4;
67
+ }
68
+ .track {
69
+ appearance: none;
70
+ display: block;
71
+ position: relative;
72
+ height: var(--local-switch-track-height);
73
+ width: var(--local-switch-track-width);
74
+ margin: 0 ;
75
+ border-radius: var(--local-switch-track-border-radius);
76
+ background-color: var(--local-switch-track-background-color);
77
+ cursor: var(--local-switch-cursor);
78
+ }
79
+ .commonSvg {
80
+ display: block;
81
+ position: absolute;
82
+ pointer-events: none;
83
+ top: 50% ;
84
+ }
85
+ .thumb {
86
+ transition: transform var(--zd_transition2) cubic-bezier(0.4, 0, 0.2, 1);
87
+ fill: var(--zdt_v1_switch_thumb_bg);
88
+ height: var(--local-switch-thumb-size);
89
+ width: var(--local-switch-thumb-size);
90
+ transform: translateX(var(--local-switch-thumb-translateX)) translateY(-50%);
91
+ }
92
+ [dir=ltr] .thumb {
93
+ left: var(--zd_size1) ;
94
+ }
95
+ [dir=rtl] .thumb {
96
+ right: var(--zd_size1) ;
97
+ }
98
+ .label {
99
+ max-width: 100% ;
100
+ cursor: var(--local-switch-cursor);
101
+ }
102
+ .onLabel {
103
+ height: var(--local-switch-onLabel-height);
104
+ fill: var(--zdt_v1_switch_onLabel);
105
+ width: var(--zd_size1) ;
106
+ transform: translateY(-50%) scaleX(var(--local-switch-onLabel-scaleX));
107
+ }
108
+ [dir=ltr] .onLabel {
109
+ left: var(--local-switch-onLabel-left);
110
+ }
111
+ [dir=rtl] .onLabel {
112
+ right: var(--local-switch-onLabel-left);
113
+ }
114
+ .offLabel {
115
+ height: var(--local-switch-offLabel-size);
116
+ width: var(--local-switch-offLabel-size);
117
+ fill: transparent;
118
+ stroke: var(--local-switch-offLabel-stroke);
119
+ transform: translateY(-50%);
120
+ }
121
+ [dir=ltr] .offLabel {
122
+ right: var(--local-switch-offLabel-right);
123
+ }
124
+ [dir=rtl] .offLabel {
125
+ left: var(--local-switch-offLabel-right);
126
+ }
127
+ .checked {
128
+ --local-switch-track-background-color: var(--zdt_v1_switch_track_on_bg);
129
+ --local-switch-thumb-translateX: calc(var(--local-switch-track-width) - var(--local-switch-thumb-size) - 2px)
130
+ }
131
+ .unChecked {
132
+ --local-switch-track-background-color: var(--zdt_v1_switch_track_off_bg);
133
+ --local-switch-thumb-translateX: 0;
134
+ }
@@ -0,0 +1,48 @@
1
+ import compileClassNames from '@zohodesk/utils/es/compileClassNames';
2
+ export default function cssJSLogic(_ref) {
3
+ let {
4
+ props,
5
+ style
6
+ } = _ref;
7
+ const {
8
+ size,
9
+ isChecked,
10
+ isDisabled,
11
+ isReadOnly
12
+ } = props;
13
+ let containerClass = compileClassNames({
14
+ [style.container]: true,
15
+ [style[size]]: !!style[size],
16
+ [style.checked]: isChecked,
17
+ [style.unChecked]: !isChecked,
18
+ [style.disabled]: isDisabled,
19
+ [style.enabled]: !isDisabled,
20
+ [style.readonly]: isReadOnly
21
+ });
22
+ let trackClass = compileClassNames({
23
+ [style.track]: true
24
+ });
25
+ let labelClass = compileClassNames({
26
+ [style.label]: true
27
+ });
28
+ let trackWrapperClass = compileClassNames({
29
+ [style.trackWrapper]: true
30
+ });
31
+ let thumbClass = compileClassNames({
32
+ [style.thumb]: true,
33
+ [style.commonSvg]: true
34
+ });
35
+ let labelIndicationClass = compileClassNames({
36
+ [style.onLabel]: isChecked,
37
+ [style.offLabel]: !isChecked,
38
+ [style.commonSvg]: true
39
+ });
40
+ return {
41
+ containerClass,
42
+ trackClass,
43
+ labelClass,
44
+ trackWrapperClass,
45
+ thumbClass,
46
+ labelIndicationClass
47
+ };
48
+ }
@@ -1,11 +1,11 @@
1
- export const defaultProps = {
2
- checked: false,
3
- disabled: false,
4
- labelPalette: 'primary',
5
- labelSize: 'medium',
1
+ export default {
6
2
  size: 'medium',
7
- isReadOnly: false,
8
- customClass: {},
3
+ hasStateIndication: true,
4
+ labelPlacement: 'start',
5
+ labelSize: 'medium',
9
6
  customProps: {},
10
- dataSelectorId: 'switch'
7
+ tagAttributes: {},
8
+ a11yAttributes: {},
9
+ i18nKeys: {},
10
+ customStyle: {}
11
11
  };
@@ -1,28 +1,36 @@
1
1
  import PropTypes from 'prop-types';
2
- export const propTypes = {
3
- checked: PropTypes.bool,
4
- dataId: PropTypes.string,
5
- dataSelectorId: PropTypes.string,
6
- disableTitle: PropTypes.string,
7
- disabled: PropTypes.bool,
8
- id: PropTypes.string.isRequired,
9
- isReadOnly: PropTypes.bool,
10
- labelPalette: PropTypes.oneOf(['default', 'primary', 'secondary', 'danger', 'mandatory']),
11
- labelSize: PropTypes.oneOf(['small', 'medium', 'large']),
2
+ export default {
12
3
  name: PropTypes.string,
4
+ value: PropTypes.string,
5
+ id: PropTypes.string,
6
+ size: PropTypes.oneOf(['small', 'medium', 'large', 'xlarge']),
7
+ isChecked: PropTypes.bool,
8
+ isDefaultChecked: PropTypes.bool,
9
+ isDisabled: PropTypes.bool,
10
+ isReadOnly: PropTypes.bool,
13
11
  onChange: PropTypes.func,
14
- size: PropTypes.oneOf(['small', 'medium']),
15
- text: PropTypes.string,
12
+ hasStateIndication: PropTypes.bool,
13
+ label: PropTypes.string,
14
+ labelPlacement: PropTypes.oneOf(['start', 'end', 'top', 'bottom']),
15
+ labelSize: PropTypes.oneOf(['xsmall', 'small', 'medium', 'large']),
16
16
  title: PropTypes.string,
17
- value: PropTypes.bool,
18
- customClass: PropTypes.shape({
19
- customSwitchWrap: PropTypes.string,
20
- customSwitch: PropTypes.string,
21
- customSwitchSize: PropTypes.string,
22
- customLabel: PropTypes.string
23
- }),
24
17
  customProps: PropTypes.shape({
25
- SwitchProps: PropTypes.object,
26
- LabelProps: PropTypes.object
27
- })
18
+ container: PropTypes.object,
19
+ label: PropTypes.object
20
+ }),
21
+ tagAttributes: PropTypes.shape({
22
+ container: PropTypes.object,
23
+ switch: PropTypes.object
24
+ }),
25
+ a11yAttributes: PropTypes.shape({
26
+ container: PropTypes.object,
27
+ switch: PropTypes.object,
28
+ label: PropTypes.object
29
+ }),
30
+ i18nKeys: PropTypes.shape({
31
+ readOnlyAriaLabel: PropTypes.string
32
+ }),
33
+ customId: PropTypes.string,
34
+ testId: PropTypes.string,
35
+ customStyle: PropTypes.object
28
36
  };
@@ -0,0 +1,33 @@
1
+ import { useState } from "react";
2
+
3
+ const useSwitch = props => {
4
+ const {
5
+ isChecked: isCheckedProp,
6
+ isDefaultChecked,
7
+ onChange,
8
+ isReadOnly,
9
+ isDisabled
10
+ } = props;
11
+ const isControlled = isCheckedProp !== undefined;
12
+ const [internalChecked, setInternalChecked] = useState(isDefaultChecked);
13
+ const isChecked = isControlled ? isCheckedProp : internalChecked;
14
+
15
+ const handleChange = e => {
16
+ if (isReadOnly || isDisabled) return;
17
+
18
+ if (!isControlled) {
19
+ setInternalChecked(!isChecked);
20
+ }
21
+
22
+ onChange?.({
23
+ isChecked: !isChecked
24
+ }, e);
25
+ };
26
+
27
+ return {
28
+ isChecked,
29
+ handleChange
30
+ };
31
+ };
32
+
33
+ export default useSwitch;
@@ -148,14 +148,15 @@ var AppContainer = /*#__PURE__*/function (_React$Component) {
148
148
 
149
149
  if (this.containerElement && needTooltip) {
150
150
  this.containerElement.removeEventListener('mouseover', this.handleOver, false);
151
- this.containerElement.addEventListener('mouseout', this.removeTimeout, false);
151
+ this.containerElement.removeEventListener('mouseout', this.removeTimeout, false);
152
152
  this.tooltipRef.unObserveElement();
153
- (0, _Config.setLibraryConfig)({
154
- getTooltipContainer: function getTooltipContainer() {
155
- return null;
156
- }
157
- });
158
153
  }
154
+
155
+ (0, _Config.setLibraryConfig)({
156
+ getTooltipContainer: function getTooltipContainer() {
157
+ return null;
158
+ }
159
+ });
159
160
  }
160
161
  }, {
161
162
  key: "render",
package/lib/Card/Card.js CHANGED
@@ -175,7 +175,9 @@ var Card = /*#__PURE__*/function (_Component3) {
175
175
  _this2.to = from + 3 * limit;
176
176
  _this2.isFetching = false;
177
177
  _this2.lastScrollTop = 0;
178
- _this2.onScroll = _this2.onScroll.bind(_assertThisInitialized(_this2)); //this.onSetScroll = debounce(this.setScroll.bind(this, true), 10, true);
178
+ _this2.onScroll = _this2.onScroll.bind(_assertThisInitialized(_this2));
179
+ _this2.setScrollRef = _this2.setScrollRef.bind(_assertThisInitialized(_this2));
180
+ _this2.childEleRef = null; //this.onSetScroll = debounce(this.setScroll.bind(this, true), 10, true);
179
181
  //this.onClearScroll = debounce(this.setScroll.bind(this, false), 500);
180
182
 
181
183
  return _this2;
@@ -204,7 +206,10 @@ var Card = /*#__PURE__*/function (_Component3) {
204
206
  noMoreData = _this$props3.noMoreData,
205
207
  scrollAt = _this$props3.scrollAt,
206
208
  noNeedUpScroll = _this$props3.noNeedUpScroll,
207
- isPercentageScroll = _this$props3.isPercentageScroll;
209
+ isPercentageScroll = _this$props3.isPercentageScroll,
210
+ isRecentOnBottom = _this$props3.isRecentOnBottom;
211
+ var scrollLimitHeight = scrollHeight - scrollAt;
212
+ var currentVisibleBottom = scrollTop + offsetHeight;
208
213
 
209
214
  if (scrollTop > this.lastScrollTop) {
210
215
  this.scrollDirection = 'down';
@@ -215,9 +220,12 @@ var Card = /*#__PURE__*/function (_Component3) {
215
220
  this.lastScrollTop = scrollTop;
216
221
 
217
222
  if (fetchData && !this.isFetching) {
218
- if (this.scrollDirection === 'down' && !noMoreData) {
219
- var scrollingPercentage = (scrollTop + offsetHeight) / (scrollHeight - scrollAt) * 100;
220
- var prefetch = isPercentageScroll ? scrollingPercentage >= (0, _Config.getLibraryConfig)('scrollFetchLimit') : scrollHeight - scrollAt <= scrollTop + offsetHeight;
223
+ var fetchDirection = isRecentOnBottom ? 'up' : 'down';
224
+
225
+ if (this.scrollDirection === fetchDirection && !noMoreData) {
226
+ var scrollingPercentage = currentVisibleBottom / scrollLimitHeight * 100;
227
+ var scrolledUpPercentage = (scrollHeight - scrollTop) / scrollLimitHeight * 100;
228
+ var prefetch = isRecentOnBottom ? isPercentageScroll ? scrolledUpPercentage >= (0, _Config.getLibraryConfig)('scrollFetchLimit') : scrollTop <= scrollAt : isPercentageScroll ? scrollingPercentage >= (0, _Config.getLibraryConfig)('scrollFetchLimit') : scrollLimitHeight <= currentVisibleBottom;
221
229
 
222
230
  if (prefetch) {
223
231
  this.isFetching = true;
@@ -229,7 +237,9 @@ var Card = /*#__PURE__*/function (_Component3) {
229
237
  });
230
238
  }
231
239
  } else {
232
- if (0 >= scrollTop - scrollAt && this.from !== 0 && !noNeedUpScroll) {
240
+ var _prefetch = isRecentOnBottom ? scrollLimitHeight <= currentVisibleBottom : 0 >= scrollTop - scrollAt;
241
+
242
+ if (_prefetch && this.from !== 0 && !noNeedUpScroll) {
233
243
  this.isFetching = true;
234
244
  fetchData(this.from - this.limit, this.to - this.limit, this.scrollDirection).then(function () {
235
245
  _this3.to = _this3.to - _this3.limit;
@@ -242,9 +252,12 @@ var Card = /*#__PURE__*/function (_Component3) {
242
252
  }
243
253
 
244
254
  if (fetchData && !noNeedUpScroll) {
245
- if (this.from !== 0 && scrollTop === 0 && !noNeedUpScroll) {
246
- scrollContainerObj.scrollTop = scrollTop + offsetHeight / 3;
247
- } else if (scrollHeight === scrollTop + offsetHeight && !noMoreData) {
255
+ var topFetch = isRecentOnBottom ? !noMoreData : !noNeedUpScroll;
256
+ var bottomFetch = isRecentOnBottom ? !noNeedUpScroll : !noMoreData;
257
+
258
+ if (this.from !== 0 && scrollTop === 0 && topFetch) {
259
+ scrollContainerObj.scrollTop = currentVisibleBottom / 3;
260
+ } else if (scrollHeight === currentVisibleBottom && bottomFetch) {
248
261
  scrollContainerObj.scrollTop = scrollTop - offsetHeight / 2;
249
262
  }
250
263
  } // if (isScrollShadow) {
@@ -262,21 +275,36 @@ var Card = /*#__PURE__*/function (_Component3) {
262
275
  // }
263
276
  // }
264
277
 
278
+ }, {
279
+ key: "setScrollRef",
280
+ value: function setScrollRef(el) {
281
+ var _this$props4 = this.props,
282
+ scrollAt = _this$props4.scrollAt,
283
+ isRecentOnBottom = _this$props4.isRecentOnBottom;
284
+
285
+ if (el && isRecentOnBottom) {
286
+ requestAnimationFrame(function () {
287
+ el.scrollTop = el.scrollHeight + Number(scrollAt);
288
+ });
289
+ }
290
+
291
+ this.childEleRef && this.childEleRef(el);
292
+ }
265
293
  }, {
266
294
  key: "render",
267
295
  value: function render() {
268
296
  var _this4 = this;
269
297
 
270
- var _this$props4 = this.props,
271
- onClick = _this$props4.onClick,
272
- children = _this$props4.children,
273
- isScrollAttribute = _this$props4.isScrollAttribute,
274
- dataId = _this$props4.dataId,
275
- eleRef = _this$props4.eleRef,
276
- _this$props4$customCl = _this$props4.customClass,
277
- customClass = _this$props4$customCl === void 0 ? '' : _this$props4$customCl,
278
- htmlId = _this$props4.htmlId,
279
- a11y = _this$props4.a11y;
298
+ var _this$props5 = this.props,
299
+ onClick = _this$props5.onClick,
300
+ children = _this$props5.children,
301
+ isScrollAttribute = _this$props5.isScrollAttribute,
302
+ dataId = _this$props5.dataId,
303
+ eleRef = _this$props5.eleRef,
304
+ _this$props5$customCl = _this$props5.customClass,
305
+ customClass = _this$props5$customCl === void 0 ? '' : _this$props5$customCl,
306
+ htmlId = _this$props5.htmlId,
307
+ a11y = _this$props5.a11y;
280
308
  var isScroll = this.state.isScroll;
281
309
  var role = a11y.role;
282
310
  return /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
@@ -295,6 +323,7 @@ var Card = /*#__PURE__*/function (_Component3) {
295
323
  isScroll: isScroll
296
324
  });
297
325
  } else if (child.type === CardContent || _this4.props.childTypes && child.type === _this4.props.childTypes.cardContent) {
326
+ _this4.childEleRef = child.props.eleRef;
298
327
  return /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
299
328
  id: htmlId,
300
329
  role: role,
@@ -302,7 +331,7 @@ var Card = /*#__PURE__*/function (_Component3) {
302
331
  scroll: child.props.scroll,
303
332
  preventParentScroll: child.props.preventParentScroll,
304
333
  onScroll: _this4.onScroll,
305
- eleRef: child.props.eleRef,
334
+ eleRef: _this4.setScrollRef,
306
335
  isScrollAttribute: child.props.isScrollAttribute,
307
336
  dataId: child.props.dataId,
308
337
  shrink: child.props.shrink,
@@ -344,11 +373,11 @@ var CardFooter = /*#__PURE__*/function (_Component4) {
344
373
  _createClass(CardFooter, [{
345
374
  key: "render",
346
375
  value: function render() {
347
- var _this$props5 = this.props,
348
- children = _this$props5.children,
349
- dataId = _this$props5.dataId,
350
- customClass = _this$props5.customClass,
351
- dataSelectorId = _this$props5.dataSelectorId;
376
+ var _this$props6 = this.props,
377
+ children = _this$props6.children,
378
+ dataId = _this$props6.dataId,
379
+ customClass = _this$props6.customClass,
380
+ dataSelectorId = _this$props6.dataSelectorId;
352
381
  return /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
353
382
  className: "".concat(customClass),
354
383
  dataId: dataId,
@@ -10,7 +10,8 @@ var Card_defaultProps = {
10
10
  onClick: null,
11
11
  scrollAt: '10',
12
12
  a11y: {},
13
- isPercentageScroll: false
13
+ isPercentageScroll: false,
14
+ isRecentOnBottom: false
14
15
  };
15
16
  exports.Card_defaultProps = Card_defaultProps;
16
17
  var CardHeader_defaultProps = {
@@ -50,7 +50,8 @@ var Card_propTypes = {
50
50
  role: _propTypes["default"].string
51
51
  }),
52
52
  isPercentageScroll: _propTypes["default"].bool,
53
- eleRef: _propTypes["default"].func
53
+ eleRef: _propTypes["default"].func,
54
+ isRecentOnBottom: _propTypes["default"].bool
54
55
  };
55
56
  exports.Card_propTypes = Card_propTypes;
56
57
  var CardFooter_propTypes = {