@zohodesk/components 1.2.10 → 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 +6 -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/MultiSelect/props/propTypes.js +140 -138
- package/es/Select/props/propTypes.js +3 -1
- 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/lib/MultiSelect/props/propTypes.js +146 -141
- package/lib/Select/props/propTypes.js +12 -2
- 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/package.json +4 -4
- package/result.json +1 -1
|
@@ -171,7 +171,9 @@ export const GroupSelect_propTypes = {
|
|
|
171
171
|
dataSelectorId: PropTypes.string,
|
|
172
172
|
isDefaultSelectValue: PropTypes.bool
|
|
173
173
|
};
|
|
174
|
-
export const SelectWithAvatar_propTypes = {
|
|
174
|
+
export const SelectWithAvatar_propTypes = { ...Select_propTypes,
|
|
175
|
+
textBoxClass: PropTypes.string,
|
|
176
|
+
imageField: PropTypes.string,
|
|
175
177
|
animationStyle: PropTypes.string,
|
|
176
178
|
avatarPalette: PropTypes.string,
|
|
177
179
|
borderColor: PropTypes.oneOf(['transparent', 'default']),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useState
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useEffectCallOnlyAfterState } from '@zohodesk/hooks';
|
|
2
3
|
import { Accordion_defaultProps } from '../../Accordion/props/defaultProps';
|
|
3
4
|
import { Accordion_propTypes } from '../../Accordion/props/propTypes';
|
|
4
5
|
export default function Accordion(props) {
|
|
@@ -29,7 +30,7 @@ export default function Accordion(props) {
|
|
|
29
30
|
!disableInternalState && setSelectedItem(selectedItem);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
useEffectCallOnlyAfterState(() => {
|
|
33
34
|
if (!disableInternalState) {
|
|
34
35
|
setSelectedItem(propSelectedItem);
|
|
35
36
|
}
|
|
@@ -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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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: () =>
|
|
44
|
+
getTooltipContainer: () => containerElement.current
|
|
32
45
|
});
|
|
33
|
-
}
|
|
46
|
+
}, []);
|
|
34
47
|
|
|
35
|
-
mouseOverDispatch(e) {
|
|
36
|
-
if (
|
|
37
|
-
|
|
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 (
|
|
43
|
-
|
|
54
|
+
function removeTimeout() {
|
|
55
|
+
if (timer.current) {
|
|
56
|
+
timer.current = clearTimeout(timer.current);
|
|
44
57
|
}
|
|
45
58
|
}
|
|
46
59
|
|
|
47
|
-
handleOver(e) {
|
|
48
|
-
if (
|
|
49
|
-
|
|
60
|
+
function handleOver(e) {
|
|
61
|
+
if (timer.current) {
|
|
62
|
+
timer.current = clearTimeout(timer.current);
|
|
50
63
|
}
|
|
51
64
|
|
|
52
|
-
|
|
65
|
+
timer.current = setTimeout(() => mouseOverDispatch(e), tooltipDebounce.current);
|
|
53
66
|
}
|
|
54
67
|
|
|
55
|
-
getContainerRef(ref) {
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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__) {
|
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 = [];
|