@zohodesk/components 1.2.9 → 1.2.11
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.
- package/.cli/PropLessFiles.html +1 -1
- package/.cli/PropValidationExcludeFilesArray.js +7 -10
- package/.cli/propValidation_report.html +1 -1
- package/README.md +14 -0
- package/coverage/Button/Button.js.html +1 -1
- package/coverage/Button/css/Button.module.css.html +1 -1
- package/coverage/Button/css/cssJSLogic.js.html +1 -1
- package/coverage/Button/css/index.html +1 -1
- package/coverage/Button/index.html +1 -1
- package/coverage/Button/props/defaultProps.js.html +1 -1
- package/coverage/Button/props/index.html +1 -1
- package/coverage/Button/props/propTypes.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
- package/coverage/Buttongroup/index.html +1 -1
- package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
- package/coverage/Buttongroup/props/index.html +1 -1
- package/coverage/Buttongroup/props/propTypes.js.html +1 -1
- package/coverage/coverage-final.json +10 -10
- package/coverage/coverage-summary.json +10 -10
- package/coverage/index.html +1 -1
- package/coverage/utils/dummyFunction.js.html +1 -1
- package/coverage/utils/index.html +1 -1
- package/es/DateTime/dateFormatUtils/dayChange.js +2 -1
- package/es/DateTime/dateFormatUtils/index.js +1 -1
- package/es/DateTime/dateFormatUtils/monthChange.js +2 -1
- package/es/DateTime/dateFormatUtils/timeChange.js +4 -4
- package/es/DateTime/dateFormatUtils/yearChange.js +2 -1
- package/es/MultiSelect/props/propTypes.js +140 -138
- package/es/Select/GroupSelect.js +2 -5
- package/es/Select/Select.js +2 -5
- package/es/Select/props/propTypes.js +3 -1
- package/es/utils/Common.js +3 -0
- package/es/v1/Accordion/Accordion.js +3 -2
- package/es/v1/AppContainer/AppContainer.js +75 -92
- package/es/v1/Avatar/Avatar.js +84 -134
- package/es/v1/Card/Card.js +143 -177
- package/es/v1/MultiSelect/MultiSelect.js +1 -0
- package/es/v1/MultiSelect/MultiSelectWithAvatar.js +1 -0
- package/es/v1/PopOver/PopOver.js +125 -160
- package/es/v1/Popup/Popup.js +1 -1
- package/es/v1/Provider/AvatarSize.js +13 -0
- package/es/v1/Provider/Config.js +18 -0
- package/es/v1/Provider/CssProvider.js +16 -0
- package/es/v1/Provider/IdProvider.js +66 -0
- package/es/v1/Provider/LibraryContext.js +37 -0
- package/es/v1/Provider/LibraryContextInit.js +3 -0
- package/es/v1/Provider/NumberGenerator/NumberGenerator.js +136 -0
- package/es/v1/Provider/ZindexProvider.js +57 -0
- package/es/v1/Provider/index.js +4 -0
- package/es/v1/Select/GroupSelect.js +2 -5
- package/es/v1/Select/Select.js +2 -5
- package/lib/DateTime/dateFormatUtils/dayChange.js +3 -1
- package/lib/DateTime/dateFormatUtils/index.js +1 -1
- package/lib/DateTime/dateFormatUtils/monthChange.js +3 -1
- package/lib/DateTime/dateFormatUtils/timeChange.js +3 -3
- package/lib/DateTime/dateFormatUtils/yearChange.js +3 -1
- package/lib/MultiSelect/props/propTypes.js +146 -141
- package/lib/Select/GroupSelect.js +1 -2
- package/lib/Select/Select.js +1 -2
- package/lib/Select/props/propTypes.js +12 -2
- package/lib/utils/Common.js +5 -0
- package/lib/v1/Accordion/Accordion.js +3 -1
- package/lib/v1/AppContainer/AppContainer.js +87 -138
- package/lib/v1/Avatar/Avatar.js +130 -186
- package/lib/v1/Card/Card.js +190 -286
- package/lib/v1/MultiSelect/MultiSelect.js +3 -1
- package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +3 -1
- package/lib/v1/PopOver/PopOver.js +160 -256
- package/lib/v1/Popup/Popup.js +1 -1
- package/lib/v1/Provider/AvatarSize.js +24 -0
- package/lib/v1/Provider/Config.js +27 -0
- package/lib/v1/Provider/CssProvider.js +27 -0
- package/lib/v1/Provider/IdProvider.js +79 -0
- package/lib/v1/Provider/LibraryContext.js +76 -0
- package/lib/v1/Provider/LibraryContextInit.js +15 -0
- package/lib/v1/Provider/NumberGenerator/NumberGenerator.js +174 -0
- package/lib/v1/Provider/ZindexProvider.js +69 -0
- package/lib/v1/Provider/index.js +81 -0
- package/lib/v1/Select/GroupSelect.js +1 -2
- package/lib/v1/Select/Select.js +1 -2
- package/package.json +4 -4
- package/result.json +1 -1
package/es/v1/Avatar/Avatar.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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, { useState } from 'react';
|
|
4
|
+
import { useEffectCallOnlyAfterState } from '@zohodesk/hooks';
|
|
4
5
|
import { defaultProps } from '../../Avatar/props/defaultProps';
|
|
5
6
|
import { propTypes } from '../../Avatar/props/propTypes';
|
|
6
7
|
import { getInitial } from '../../utils/getInitial';
|
|
@@ -13,40 +14,36 @@ import style from '../../Avatar/Avatar.module.css';
|
|
|
13
14
|
4. team pass name as lastName and pass pattern via prop
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} = this.props;
|
|
47
|
-
let {
|
|
48
|
-
isLoaded
|
|
49
|
-
} = this.state;
|
|
17
|
+
function Avatar(props) {
|
|
18
|
+
let {
|
|
19
|
+
src,
|
|
20
|
+
name,
|
|
21
|
+
size,
|
|
22
|
+
palette,
|
|
23
|
+
onClick,
|
|
24
|
+
title,
|
|
25
|
+
shape,
|
|
26
|
+
needTitle,
|
|
27
|
+
dataId,
|
|
28
|
+
initial,
|
|
29
|
+
needBorder,
|
|
30
|
+
borderOnActive,
|
|
31
|
+
borderOnHover,
|
|
32
|
+
textPalette,
|
|
33
|
+
customClass,
|
|
34
|
+
alternateSrc,
|
|
35
|
+
isAnimate,
|
|
36
|
+
dataSelectorId,
|
|
37
|
+
customProps,
|
|
38
|
+
needInnerBorder,
|
|
39
|
+
needDefaultBorder
|
|
40
|
+
} = props;
|
|
41
|
+
let {
|
|
42
|
+
AvatarProps = {}
|
|
43
|
+
} = customProps;
|
|
44
|
+
const [isLoaded, setLoaded] = useState(false);
|
|
45
|
+
|
|
46
|
+
const putInvalidImageURLJSON = () => {
|
|
50
47
|
let _validImgArr = [...Avatar.validImageURLs];
|
|
51
48
|
let _invalidImgArr = [...Avatar.invalidImageURLs]; // if (alternateSrc) {
|
|
52
49
|
// _validImgArr.push(alternateSrc);
|
|
@@ -62,18 +59,10 @@ export default class Avatar extends React.Component {
|
|
|
62
59
|
|
|
63
60
|
Avatar.invalidImageURLs = _invalidImgArr;
|
|
64
61
|
Avatar.validImageURLs = _validImgArr;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
putValidImageURLJSON() {
|
|
71
|
-
const {
|
|
72
|
-
src
|
|
73
|
-
} = this.props;
|
|
74
|
-
let {
|
|
75
|
-
isLoaded
|
|
76
|
-
} = this.state;
|
|
62
|
+
setLoaded(isLoaded => !isLoaded);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const putValidImageURLJSON = () => {
|
|
77
66
|
const validImgArr = Avatar.validImageURLs;
|
|
78
67
|
const invalidImgArr = Avatar.invalidImageURLs;
|
|
79
68
|
|
|
@@ -83,15 +72,13 @@ export default class Avatar extends React.Component {
|
|
|
83
72
|
_validImgArr.push(src);
|
|
84
73
|
|
|
85
74
|
Avatar.validImageURLs = _validImgArr;
|
|
86
|
-
|
|
87
|
-
isLoaded: !isLoaded
|
|
88
|
-
});
|
|
75
|
+
setLoaded(isLoaded => !isLoaded);
|
|
89
76
|
}
|
|
90
|
-
}
|
|
77
|
+
};
|
|
91
78
|
/* this will cause error if user name already have some space need to move firstName lastName user preference pattern*/
|
|
92
79
|
|
|
93
80
|
|
|
94
|
-
getInitialByFullName() {
|
|
81
|
+
const getInitialByFullName = function () {
|
|
95
82
|
let fullName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
96
83
|
fullName = (fullName || '').trim();
|
|
97
84
|
let nameList = fullName.split(' ');
|
|
@@ -101,89 +88,52 @@ export default class Avatar extends React.Component {
|
|
|
101
88
|
}
|
|
102
89
|
|
|
103
90
|
return getInitial(nameList[0], nameList[1]);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
let showAvatar = src && !isInvalidImageList;
|
|
147
|
-
let showInitial = !showAvatar || showAvatar && isInvalidImageList;
|
|
148
|
-
const showAlternateAvatar = alternateSrc ? showInitial : false;
|
|
149
|
-
let border = borderOnHover || onClick;
|
|
150
|
-
let showDefaultBorder = src && !isInvalidImageList && needDefaultBorder;
|
|
151
|
-
let borderStyle = (showDefaultBorder || !src || !showAvatar || showInitial) && needBorder ? `${style.border} ${borderOnActive ? style.borderOnActive : border ? style.borderOnHover : ''} ` : '';
|
|
152
|
-
borderStyle = showAlternateAvatar ? '' : borderStyle;
|
|
153
|
-
return /*#__PURE__*/React.createElement("div", _extends({
|
|
154
|
-
className: `${style.avatar} ${style[size]} ${AvatarSize(size)} ${style[shapeStyle]} ${style[palette]} ${textStyle} ${borderStyle} ${customClass ? customClass : ''}`,
|
|
155
|
-
"data-title": needTitle ? title ? title : name : null,
|
|
156
|
-
"data-id": dataId,
|
|
157
|
-
"data-test-id": dataId,
|
|
158
|
-
onClick: onClick,
|
|
159
|
-
"data-selector-id": dataSelectorId
|
|
160
|
-
}, AvatarProps), showInitial && !showAlternateAvatar && /*#__PURE__*/React.createElement("span", {
|
|
161
|
-
className: `${style.initial}`,
|
|
162
|
-
"data-id": `${dataId}_AvatarInitial`,
|
|
163
|
-
"data-test-id": `${dataId}_AvatarInitial`,
|
|
164
|
-
"data-selector-id": `${dataSelectorId}_AvatarInitial`
|
|
165
|
-
}, initial), (showAvatar || showAlternateAvatar) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("img", {
|
|
166
|
-
className: `${style.image} ${isAnimate ? style.animate : ''} ${needInnerBorder ? style.innerBorder : ''}`,
|
|
167
|
-
"data-id": `${dataId}_AvatarImg`,
|
|
168
|
-
"data-test-id": `${dataId}_AvatarImg`,
|
|
169
|
-
"data-selector-id": `${dataSelectorId}_AvatarImg`,
|
|
170
|
-
name: name,
|
|
171
|
-
onError: this.putInvalidImageURLJSON,
|
|
172
|
-
onLoad: this.putValidImageURLJSON,
|
|
173
|
-
src: showAlternateAvatar ? alternateSrc : src,
|
|
174
|
-
alt: name
|
|
175
|
-
}), showDefaultBorder ? null : /*#__PURE__*/React.createElement("span", {
|
|
176
|
-
className: `${style.shadow} ${textStyle} `
|
|
177
|
-
})));
|
|
178
|
-
}
|
|
179
|
-
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
useEffectCallOnlyAfterState(() => {
|
|
94
|
+
setLoaded(isLoaded => !isLoaded);
|
|
95
|
+
}, [src]);
|
|
96
|
+
let textStyle = textPalette ? style[textPalette] : palette === 'secondary' ? style.white : style.black;
|
|
97
|
+
let shapeStyle = shape === 'circle' ? 'circle' : `square_${size}`;
|
|
98
|
+
initial = initial || getInitialByFullName(name);
|
|
99
|
+
let isInvalidImageList = Avatar.invalidImageURLs.indexOf(src) !== -1; //let isValidImageList = Avatar.validImageURLs.indexOf(src) !== -1;
|
|
100
|
+
|
|
101
|
+
let showAvatar = src && !isInvalidImageList;
|
|
102
|
+
let showInitial = !showAvatar || showAvatar && isInvalidImageList;
|
|
103
|
+
const showAlternateAvatar = alternateSrc ? showInitial : false;
|
|
104
|
+
let border = borderOnHover || onClick;
|
|
105
|
+
let showDefaultBorder = src && !isInvalidImageList && needDefaultBorder;
|
|
106
|
+
let borderStyle = (showDefaultBorder || !src || !showAvatar || showInitial) && needBorder ? `${style.border} ${borderOnActive ? style.borderOnActive : border ? style.borderOnHover : ''} ` : '';
|
|
107
|
+
borderStyle = showAlternateAvatar ? '' : borderStyle;
|
|
108
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
109
|
+
className: `${style.avatar} ${style[size]} ${AvatarSize(size)} ${style[shapeStyle]} ${style[palette]} ${textStyle} ${borderStyle} ${customClass ? customClass : ''}`,
|
|
110
|
+
"data-title": needTitle ? title ? title : name : null,
|
|
111
|
+
"data-id": dataId,
|
|
112
|
+
"data-test-id": dataId,
|
|
113
|
+
onClick: onClick,
|
|
114
|
+
"data-selector-id": dataSelectorId
|
|
115
|
+
}, AvatarProps), showInitial && !showAlternateAvatar && /*#__PURE__*/React.createElement("span", {
|
|
116
|
+
className: `${style.initial}`,
|
|
117
|
+
"data-id": `${dataId}_AvatarInitial`,
|
|
118
|
+
"data-test-id": `${dataId}_AvatarInitial`,
|
|
119
|
+
"data-selector-id": `${dataSelectorId}_AvatarInitial`
|
|
120
|
+
}, initial), (showAvatar || showAlternateAvatar) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("img", {
|
|
121
|
+
className: `${style.image} ${isAnimate ? style.animate : ''} ${needInnerBorder ? style.innerBorder : ''}`,
|
|
122
|
+
"data-id": `${dataId}_AvatarImg`,
|
|
123
|
+
"data-test-id": `${dataId}_AvatarImg`,
|
|
124
|
+
"data-selector-id": `${dataSelectorId}_AvatarImg`,
|
|
125
|
+
name: name,
|
|
126
|
+
onError: putInvalidImageURLJSON,
|
|
127
|
+
onLoad: putValidImageURLJSON,
|
|
128
|
+
src: showAlternateAvatar ? alternateSrc : src,
|
|
129
|
+
alt: name
|
|
130
|
+
}), showDefaultBorder ? null : /*#__PURE__*/React.createElement("span", {
|
|
131
|
+
className: `${style.shadow} ${textStyle} `
|
|
132
|
+
})));
|
|
180
133
|
}
|
|
134
|
+
|
|
135
|
+
export default Avatar;
|
|
181
136
|
Avatar.defaultProps = defaultProps;
|
|
182
137
|
Avatar.propTypes = propTypes;
|
|
183
138
|
Avatar.invalidImageURLs = [];
|
|
184
|
-
Avatar.validImageURLs = [];
|
|
185
|
-
// Avatar.docs = {
|
|
186
|
-
// componentGroup: 'Avatar Group',
|
|
187
|
-
// folderName: 'Style Guide'
|
|
188
|
-
// };
|
|
189
|
-
// }
|
|
139
|
+
Avatar.validImageURLs = [];
|
package/es/v1/Card/Card.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import 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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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 >
|
|
134
|
-
|
|
121
|
+
if (scrollTop > lastScrollTop.current) {
|
|
122
|
+
scrollDirection.current = 'down';
|
|
135
123
|
} else {
|
|
136
|
-
|
|
124
|
+
scrollDirection.current = 'up';
|
|
137
125
|
}
|
|
138
126
|
|
|
139
|
-
|
|
127
|
+
lastScrollTop.current = scrollTop;
|
|
140
128
|
|
|
141
|
-
if (fetchData && !
|
|
142
|
-
if (
|
|
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
|
-
|
|
148
|
-
fetchData(
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
140
|
+
isFetching.current = false;
|
|
153
141
|
});
|
|
154
142
|
}
|
|
155
143
|
} else {
|
|
156
|
-
if (0 >= scrollTop - scrollAt &&
|
|
157
|
-
|
|
158
|
-
fetchData(
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
150
|
+
isFetching.current = false;
|
|
163
151
|
});
|
|
164
152
|
}
|
|
165
153
|
}
|
|
166
154
|
}
|
|
167
155
|
|
|
168
156
|
if (fetchData && !noNeedUpScroll) {
|
|
169
|
-
if (
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { MultiSelect_propTypes } from '../../MultiSelect/props/propTypes';
|
|
4
4
|
import { MultiSelect_defaultProps } from '../../MultiSelect/props/defaultProps';
|
|
5
|
+
import { defaultProps as MobileHeader_defaultProps } from '../../MultiSelect/MobileHeader/props/defaultProps';
|
|
5
6
|
/**** Components ****/
|
|
6
7
|
|
|
7
8
|
import Popup from '../Popup/Popup';
|
|
@@ -4,6 +4,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { MultiSelectWithAvatar_propTypes } from '../../MultiSelect/props/propTypes';
|
|
6
6
|
import { MultiSelectWithAvatar_defaultProps } from '../../MultiSelect/props/defaultProps';
|
|
7
|
+
import { defaultProps as MobileHeader_defaultProps } from '../../MultiSelect/MobileHeader/props/defaultProps';
|
|
7
8
|
/**** Components ****/
|
|
8
9
|
|
|
9
10
|
import { MultiSelectComponent } from './MultiSelect';
|