@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
|
@@ -5,9 +5,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports["default"] =
|
|
8
|
+
exports["default"] = AppContainer;
|
|
9
9
|
|
|
10
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
12
|
var _defaultProps = require("../../AppContainer/props/defaultProps");
|
|
13
13
|
|
|
@@ -43,163 +43,112 @@ var _Config = require("../../Provider/Config");
|
|
|
43
43
|
|
|
44
44
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
45
45
|
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
49
|
-
|
|
50
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
51
|
-
|
|
52
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
53
|
-
|
|
54
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
55
|
-
|
|
56
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
57
|
-
|
|
58
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
59
|
-
|
|
60
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
46
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
61
47
|
|
|
62
|
-
function
|
|
48
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
63
49
|
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
67
|
-
|
|
68
|
-
var AppContainer = /*#__PURE__*/function (_React$Component) {
|
|
69
|
-
_inherits(AppContainer, _React$Component);
|
|
70
|
-
|
|
71
|
-
var _super = _createSuper(AppContainer);
|
|
72
|
-
|
|
73
|
-
function AppContainer(props) {
|
|
74
|
-
var _this;
|
|
75
|
-
|
|
76
|
-
_classCallCheck(this, AppContainer);
|
|
50
|
+
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); }
|
|
77
51
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
52
|
+
function AppContainer(props) {
|
|
53
|
+
var className = props.className,
|
|
54
|
+
children = props.children,
|
|
55
|
+
tagName = props.tagName,
|
|
56
|
+
dataId = props.dataId,
|
|
57
|
+
dataSelectorId = props.dataSelectorId,
|
|
58
|
+
tooltipClass = props.tooltipClass,
|
|
59
|
+
tooltipParentClass = props.tooltipParentClass,
|
|
60
|
+
needTooltip = props.needTooltip,
|
|
61
|
+
customProps = props.customProps,
|
|
62
|
+
eleRef = props.eleRef;
|
|
63
|
+
var _customProps$Containe = customProps.ContainerProps,
|
|
64
|
+
ContainerProps = _customProps$Containe === void 0 ? {} : _customProps$Containe,
|
|
65
|
+
_customProps$TooltipP = customProps.TooltipProps,
|
|
66
|
+
TooltipProps = _customProps$TooltipP === void 0 ? {} : _customProps$TooltipP,
|
|
67
|
+
_customProps$ExtraPro = customProps.ExtraProps,
|
|
68
|
+
ExtraProps = _customProps$ExtraPro === void 0 ? {} : _customProps$ExtraPro;
|
|
69
|
+
var tooltipRef = (0, _react.useRef)(null);
|
|
70
|
+
var containerElement = (0, _react.useRef)(null);
|
|
71
|
+
var timer = (0, _react.useRef)(null);
|
|
72
|
+
var tooltipDebounce = (0, _react.useRef)((0, _Config.getLibraryConfig)('tooltipDebounce'));
|
|
73
|
+
(0, _react.useLayoutEffect)(function () {
|
|
86
74
|
(0, _Config.setLibraryConfig)({
|
|
87
75
|
getTooltipContainer: function getTooltipContainer() {
|
|
88
|
-
return
|
|
76
|
+
return containerElement.current;
|
|
89
77
|
}
|
|
90
78
|
});
|
|
91
|
-
|
|
79
|
+
}, []);
|
|
80
|
+
|
|
81
|
+
function mouseOverDispatch(e) {
|
|
82
|
+
if (tooltipRef.current) {
|
|
83
|
+
tooltipRef.current.handleOver(e, containerElement.current);
|
|
84
|
+
}
|
|
92
85
|
}
|
|
93
86
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (this.tooltipRef) {
|
|
98
|
-
this.tooltipRef.handleOver(e, this.containerElement);
|
|
99
|
-
}
|
|
87
|
+
function removeTimeout() {
|
|
88
|
+
if (timer.current) {
|
|
89
|
+
timer.current = clearTimeout(timer.current);
|
|
100
90
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function handleOver(e) {
|
|
94
|
+
if (timer.current) {
|
|
95
|
+
timer.current = clearTimeout(timer.current);
|
|
107
96
|
}
|
|
108
|
-
}, {
|
|
109
|
-
key: "handleOver",
|
|
110
|
-
value: function handleOver(e) {
|
|
111
|
-
var _this2 = this;
|
|
112
97
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
98
|
+
timer.current = setTimeout(function () {
|
|
99
|
+
return mouseOverDispatch(e);
|
|
100
|
+
}, tooltipDebounce.current);
|
|
101
|
+
}
|
|
116
102
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.tooltipRef = ref;
|
|
132
|
-
}
|
|
133
|
-
}, {
|
|
134
|
-
key: "componentDidMount",
|
|
135
|
-
value: function componentDidMount() {
|
|
136
|
-
var needTooltip = this.props.needTooltip;
|
|
137
|
-
|
|
138
|
-
if (this.containerElement && needTooltip) {
|
|
139
|
-
this.containerElement.addEventListener('mouseover', this.handleOver, false);
|
|
140
|
-
this.containerElement.addEventListener('mouseout', this.removeTimeout, false);
|
|
141
|
-
this.tooltipRef.observeElement();
|
|
142
|
-
}
|
|
103
|
+
function getContainerRef(ref) {
|
|
104
|
+
containerElement.current = ref;
|
|
105
|
+
eleRef && eleRef(ref);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function setTooltipRef(ref) {
|
|
109
|
+
tooltipRef.current = ref;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
(0, _react.useEffect)(function () {
|
|
113
|
+
if (containerElement.current && needTooltip) {
|
|
114
|
+
containerElement.current.addEventListener('mouseover', handleOver, false);
|
|
115
|
+
containerElement.current.addEventListener('mouseout', removeTimeout, false);
|
|
116
|
+
tooltipRef.current.observeElement();
|
|
143
117
|
}
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.containerElement.addEventListener('mouseout', this.removeTimeout, false);
|
|
152
|
-
this.tooltipRef.unObserveElement();
|
|
118
|
+
}, []);
|
|
119
|
+
(0, _react.useEffect)(function () {
|
|
120
|
+
return function () {
|
|
121
|
+
if (containerElement.current && needTooltip) {
|
|
122
|
+
containerElement.current.removeEventListener('mouseover', handleOver, false);
|
|
123
|
+
containerElement.current.addEventListener('mouseout', removeTimeout, false);
|
|
124
|
+
tooltipRef.current.unObserveElement();
|
|
153
125
|
(0, _Config.setLibraryConfig)({
|
|
154
126
|
getTooltipContainer: function getTooltipContainer() {
|
|
155
127
|
return null;
|
|
156
128
|
}
|
|
157
129
|
});
|
|
158
130
|
}
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Layout.Container, _extends({
|
|
180
|
-
className: "".concat(_AppContainerModule["default"].container, " ").concat(className),
|
|
181
|
-
dataId: dataId,
|
|
182
|
-
dataSelectorId: dataSelectorId,
|
|
183
|
-
tagName: tagName,
|
|
184
|
-
eleRef: this.getContainerRef
|
|
185
|
-
}, ContainerProps, ExtraProps), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
186
|
-
flexible: true
|
|
187
|
-
}, children)), needTooltip ? /*#__PURE__*/_react["default"].createElement("div", _extends({}, ExtraProps, {
|
|
188
|
-
className: "".concat(_AppContainerModule["default"].container, " ").concat(_AppContainerModule["default"].tooltip, " ").concat(tooltipParentClass),
|
|
189
|
-
"data-id": "".concat(dataId, "_tooltip"),
|
|
190
|
-
"data-test-id": "".concat(dataId, "_tooltip"),
|
|
191
|
-
"data-selector-id": "".concat(dataSelectorId, "_tooltip")
|
|
192
|
-
}), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], _extends({
|
|
193
|
-
ref: this.setTooltipRef,
|
|
194
|
-
customClass: tooltipClass
|
|
195
|
-
}, TooltipProps))) : null);
|
|
196
|
-
}
|
|
197
|
-
}]);
|
|
131
|
+
};
|
|
132
|
+
}, []);
|
|
133
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Layout.Container, _extends({
|
|
134
|
+
className: "".concat(_AppContainerModule["default"].container, " ").concat(className),
|
|
135
|
+
dataId: dataId,
|
|
136
|
+
dataSelectorId: dataSelectorId,
|
|
137
|
+
tagName: tagName,
|
|
138
|
+
eleRef: getContainerRef
|
|
139
|
+
}, ContainerProps, ExtraProps), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
140
|
+
flexible: true
|
|
141
|
+
}, children)), needTooltip ? /*#__PURE__*/_react["default"].createElement("div", _extends({}, ExtraProps, {
|
|
142
|
+
className: "".concat(_AppContainerModule["default"].container, " ").concat(_AppContainerModule["default"].tooltip, " ").concat(tooltipParentClass),
|
|
143
|
+
"data-id": "".concat(dataId, "_tooltip"),
|
|
144
|
+
"data-test-id": "".concat(dataId, "_tooltip"),
|
|
145
|
+
"data-selector-id": "".concat(dataSelectorId, "_tooltip")
|
|
146
|
+
}), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], _extends({
|
|
147
|
+
ref: setTooltipRef,
|
|
148
|
+
customClass: tooltipClass
|
|
149
|
+
}, TooltipProps))) : null);
|
|
150
|
+
}
|
|
198
151
|
|
|
199
|
-
return AppContainer;
|
|
200
|
-
}(_react["default"].Component);
|
|
201
|
-
|
|
202
|
-
exports["default"] = AppContainer;
|
|
203
152
|
AppContainer.propTypes = _propTypes.propTypes;
|
|
204
153
|
AppContainer.defaultProps = _defaultProps.defaultProps; // if (__DOCS__) {
|
|
205
154
|
// AppContainer.docs = {
|
package/lib/v1/Avatar/Avatar.js
CHANGED
|
@@ -7,7 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _hooks = require("@zohodesk/hooks");
|
|
11
13
|
|
|
12
14
|
var _defaultProps = require("../../Avatar/props/defaultProps");
|
|
13
15
|
|
|
@@ -21,39 +23,31 @@ var _AvatarModule = _interopRequireDefault(require("../../Avatar/Avatar.module.c
|
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
24
30
|
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); }
|
|
25
31
|
|
|
26
32
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
27
33
|
|
|
28
34
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
29
35
|
|
|
30
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
31
|
-
|
|
32
36
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
33
37
|
|
|
34
38
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
35
39
|
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
39
|
-
|
|
40
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
41
|
-
|
|
42
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
40
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
43
41
|
|
|
44
|
-
function
|
|
42
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
45
43
|
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
49
|
-
|
|
50
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
44
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
51
45
|
|
|
52
|
-
function
|
|
46
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
53
47
|
|
|
54
|
-
function
|
|
48
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
55
49
|
|
|
56
|
-
function
|
|
50
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
57
51
|
|
|
58
52
|
/*
|
|
59
53
|
1. need to change name into firstName lastName
|
|
@@ -61,186 +55,136 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
61
55
|
3. prop high priority to arrange firstName lastName
|
|
62
56
|
4. team pass name as lastName and pass pattern via prop
|
|
63
57
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
src = _this$props.src,
|
|
101
|
-
alternateSrc = _this$props.alternateSrc;
|
|
102
|
-
var isLoaded = this.state.isLoaded;
|
|
58
|
+
function Avatar(props) {
|
|
59
|
+
var src = props.src,
|
|
60
|
+
name = props.name,
|
|
61
|
+
size = props.size,
|
|
62
|
+
palette = props.palette,
|
|
63
|
+
onClick = props.onClick,
|
|
64
|
+
title = props.title,
|
|
65
|
+
shape = props.shape,
|
|
66
|
+
needTitle = props.needTitle,
|
|
67
|
+
dataId = props.dataId,
|
|
68
|
+
initial = props.initial,
|
|
69
|
+
needBorder = props.needBorder,
|
|
70
|
+
borderOnActive = props.borderOnActive,
|
|
71
|
+
borderOnHover = props.borderOnHover,
|
|
72
|
+
textPalette = props.textPalette,
|
|
73
|
+
customClass = props.customClass,
|
|
74
|
+
alternateSrc = props.alternateSrc,
|
|
75
|
+
isAnimate = props.isAnimate,
|
|
76
|
+
dataSelectorId = props.dataSelectorId,
|
|
77
|
+
customProps = props.customProps,
|
|
78
|
+
needInnerBorder = props.needInnerBorder,
|
|
79
|
+
needDefaultBorder = props.needDefaultBorder;
|
|
80
|
+
var _customProps$AvatarPr = customProps.AvatarProps,
|
|
81
|
+
AvatarProps = _customProps$AvatarPr === void 0 ? {} : _customProps$AvatarPr;
|
|
82
|
+
|
|
83
|
+
var _useState = (0, _react.useState)(false),
|
|
84
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
85
|
+
isLoaded = _useState2[0],
|
|
86
|
+
setLoaded = _useState2[1];
|
|
87
|
+
|
|
88
|
+
var putInvalidImageURLJSON = function putInvalidImageURLJSON() {
|
|
89
|
+
var _validImgArr = _toConsumableArray(Avatar.validImageURLs);
|
|
90
|
+
|
|
91
|
+
var _invalidImgArr = _toConsumableArray(Avatar.invalidImageURLs); // if (alternateSrc) {
|
|
92
|
+
// _validImgArr.push(alternateSrc);
|
|
93
|
+
// }
|
|
103
94
|
|
|
104
|
-
var _validImgArr = _toConsumableArray(Avatar.validImageURLs);
|
|
105
95
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
96
|
+
var validIndex = _validImgArr.indexOf(src);
|
|
97
|
+
|
|
98
|
+
if (validIndex !== -1) {
|
|
99
|
+
_validImgArr.splice(validIndex, 1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_invalidImgArr.push(src);
|
|
109
103
|
|
|
104
|
+
Avatar.invalidImageURLs = _invalidImgArr;
|
|
105
|
+
Avatar.validImageURLs = _validImgArr;
|
|
106
|
+
setLoaded(function (isLoaded) {
|
|
107
|
+
return !isLoaded;
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
var putValidImageURLJSON = function putValidImageURLJSON() {
|
|
112
|
+
var validImgArr = Avatar.validImageURLs;
|
|
113
|
+
var invalidImgArr = Avatar.invalidImageURLs;
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
115
|
+
if (src && validImgArr.indexOf(src) === -1 && invalidImgArr.indexOf(src) === -1) {
|
|
116
|
+
var _validImgArr = _toConsumableArray(validImgArr);
|
|
116
117
|
|
|
117
|
-
|
|
118
|
+
_validImgArr.push(src);
|
|
118
119
|
|
|
119
|
-
Avatar.invalidImageURLs = _invalidImgArr;
|
|
120
120
|
Avatar.validImageURLs = _validImgArr;
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
setLoaded(function (isLoaded) {
|
|
122
|
+
return !isLoaded;
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
value: function putValidImageURLJSON() {
|
|
128
|
-
var src = this.props.src;
|
|
129
|
-
var isLoaded = this.state.isLoaded;
|
|
130
|
-
var validImgArr = Avatar.validImageURLs;
|
|
131
|
-
var invalidImgArr = Avatar.invalidImageURLs;
|
|
132
|
-
|
|
133
|
-
if (src && validImgArr.indexOf(src) === -1 && invalidImgArr.indexOf(src) === -1) {
|
|
134
|
-
var _validImgArr = _toConsumableArray(validImgArr);
|
|
135
|
-
|
|
136
|
-
_validImgArr.push(src);
|
|
137
|
-
|
|
138
|
-
Avatar.validImageURLs = _validImgArr;
|
|
139
|
-
this.setState({
|
|
140
|
-
isLoaded: !isLoaded
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/* this will cause error if user name already have some space need to move firstName lastName user preference pattern*/
|
|
145
|
-
|
|
146
|
-
}, {
|
|
147
|
-
key: "getInitialByFullName",
|
|
148
|
-
value: function getInitialByFullName() {
|
|
149
|
-
var fullName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
150
|
-
fullName = (fullName || '').trim();
|
|
151
|
-
var nameList = fullName.split(' ');
|
|
152
|
-
|
|
153
|
-
if (nameList.length === 1) {
|
|
154
|
-
return (0, _getInitial.getInitial)('', nameList[0]);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return (0, _getInitial.getInitial)(nameList[0], nameList[1]);
|
|
158
|
-
} // componentDidMount() {
|
|
159
|
-
// const { src } = this.props;
|
|
160
|
-
// const validImgArr = Avatar.validImageURLs;
|
|
161
|
-
// if (validImgArr.indexOf(src) === -1) {
|
|
162
|
-
// let _validImgArr = [...validImgArr];
|
|
163
|
-
// _validImgArr.push(src);
|
|
164
|
-
// }
|
|
165
|
-
// }
|
|
125
|
+
};
|
|
126
|
+
/* this will cause error if user name already have some space need to move firstName lastName user preference pattern*/
|
|
166
127
|
|
|
167
|
-
}, {
|
|
168
|
-
key: "render",
|
|
169
|
-
value: function render() {
|
|
170
|
-
var _this$props2 = this.props,
|
|
171
|
-
src = _this$props2.src,
|
|
172
|
-
name = _this$props2.name,
|
|
173
|
-
size = _this$props2.size,
|
|
174
|
-
palette = _this$props2.palette,
|
|
175
|
-
onClick = _this$props2.onClick,
|
|
176
|
-
title = _this$props2.title,
|
|
177
|
-
shape = _this$props2.shape,
|
|
178
|
-
needTitle = _this$props2.needTitle,
|
|
179
|
-
dataId = _this$props2.dataId,
|
|
180
|
-
initial = _this$props2.initial,
|
|
181
|
-
needBorder = _this$props2.needBorder,
|
|
182
|
-
borderOnActive = _this$props2.borderOnActive,
|
|
183
|
-
borderOnHover = _this$props2.borderOnHover,
|
|
184
|
-
textPalette = _this$props2.textPalette,
|
|
185
|
-
customClass = _this$props2.customClass,
|
|
186
|
-
alternateSrc = _this$props2.alternateSrc,
|
|
187
|
-
isAnimate = _this$props2.isAnimate,
|
|
188
|
-
dataSelectorId = _this$props2.dataSelectorId,
|
|
189
|
-
customProps = _this$props2.customProps,
|
|
190
|
-
needInnerBorder = _this$props2.needInnerBorder,
|
|
191
|
-
needDefaultBorder = _this$props2.needDefaultBorder;
|
|
192
|
-
var _customProps$AvatarPr = customProps.AvatarProps,
|
|
193
|
-
AvatarProps = _customProps$AvatarPr === void 0 ? {} : _customProps$AvatarPr;
|
|
194
|
-
var textStyle = textPalette ? _AvatarModule["default"][textPalette] : palette === 'secondary' ? _AvatarModule["default"].white : _AvatarModule["default"].black;
|
|
195
|
-
var shapeStyle = shape === 'circle' ? 'circle' : "square_".concat(size);
|
|
196
|
-
initial = initial || this.getInitialByFullName(name);
|
|
197
|
-
var isInvalidImageList = Avatar.invalidImageURLs.indexOf(src) !== -1; //let isValidImageList = Avatar.validImageURLs.indexOf(src) !== -1;
|
|
198
|
-
|
|
199
|
-
var showAvatar = src && !isInvalidImageList;
|
|
200
|
-
var showInitial = !showAvatar || showAvatar && isInvalidImageList;
|
|
201
|
-
var showAlternateAvatar = alternateSrc ? showInitial : false;
|
|
202
|
-
var border = borderOnHover || onClick;
|
|
203
|
-
var showDefaultBorder = src && !isInvalidImageList && needDefaultBorder;
|
|
204
|
-
var borderStyle = (showDefaultBorder || !src || !showAvatar || showInitial) && needBorder ? "".concat(_AvatarModule["default"].border, " ").concat(borderOnActive ? _AvatarModule["default"].borderOnActive : border ? _AvatarModule["default"].borderOnHover : '', " ") : '';
|
|
205
|
-
borderStyle = showAlternateAvatar ? '' : borderStyle;
|
|
206
|
-
return /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
207
|
-
className: "".concat(_AvatarModule["default"].avatar, " ").concat(_AvatarModule["default"][size], " ").concat((0, _AvatarSize["default"])(size), " ").concat(_AvatarModule["default"][shapeStyle], " ").concat(_AvatarModule["default"][palette], " ").concat(textStyle, " ").concat(borderStyle, " ").concat(customClass ? customClass : ''),
|
|
208
|
-
"data-title": needTitle ? title ? title : name : null,
|
|
209
|
-
"data-id": dataId,
|
|
210
|
-
"data-test-id": dataId,
|
|
211
|
-
onClick: onClick,
|
|
212
|
-
"data-selector-id": dataSelectorId
|
|
213
|
-
}, AvatarProps), showInitial && !showAlternateAvatar && /*#__PURE__*/_react["default"].createElement("span", {
|
|
214
|
-
className: "".concat(_AvatarModule["default"].initial),
|
|
215
|
-
"data-id": "".concat(dataId, "_AvatarInitial"),
|
|
216
|
-
"data-test-id": "".concat(dataId, "_AvatarInitial"),
|
|
217
|
-
"data-selector-id": "".concat(dataSelectorId, "_AvatarInitial")
|
|
218
|
-
}, initial), (showAvatar || showAlternateAvatar) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("img", {
|
|
219
|
-
className: "".concat(_AvatarModule["default"].image, " ").concat(isAnimate ? _AvatarModule["default"].animate : '', " ").concat(needInnerBorder ? _AvatarModule["default"].innerBorder : ''),
|
|
220
|
-
"data-id": "".concat(dataId, "_AvatarImg"),
|
|
221
|
-
"data-test-id": "".concat(dataId, "_AvatarImg"),
|
|
222
|
-
"data-selector-id": "".concat(dataSelectorId, "_AvatarImg"),
|
|
223
|
-
name: name,
|
|
224
|
-
onError: this.putInvalidImageURLJSON,
|
|
225
|
-
onLoad: this.putValidImageURLJSON,
|
|
226
|
-
src: showAlternateAvatar ? alternateSrc : src,
|
|
227
|
-
alt: name
|
|
228
|
-
}), showDefaultBorder ? null : /*#__PURE__*/_react["default"].createElement("span", {
|
|
229
|
-
className: "".concat(_AvatarModule["default"].shadow, " ").concat(textStyle, " ")
|
|
230
|
-
})));
|
|
231
|
-
}
|
|
232
|
-
}]);
|
|
233
128
|
|
|
234
|
-
|
|
235
|
-
|
|
129
|
+
var getInitialByFullName = function getInitialByFullName() {
|
|
130
|
+
var fullName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
131
|
+
fullName = (fullName || '').trim();
|
|
132
|
+
var nameList = fullName.split(' ');
|
|
133
|
+
|
|
134
|
+
if (nameList.length === 1) {
|
|
135
|
+
return (0, _getInitial.getInitial)('', nameList[0]);
|
|
136
|
+
}
|
|
236
137
|
|
|
237
|
-
|
|
138
|
+
return (0, _getInitial.getInitial)(nameList[0], nameList[1]);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
(0, _hooks.useEffectCallOnlyAfterState)(function () {
|
|
142
|
+
setLoaded(function (isLoaded) {
|
|
143
|
+
return !isLoaded;
|
|
144
|
+
});
|
|
145
|
+
}, [src]);
|
|
146
|
+
var textStyle = textPalette ? _AvatarModule["default"][textPalette] : palette === 'secondary' ? _AvatarModule["default"].white : _AvatarModule["default"].black;
|
|
147
|
+
var shapeStyle = shape === 'circle' ? 'circle' : "square_".concat(size);
|
|
148
|
+
initial = initial || getInitialByFullName(name);
|
|
149
|
+
var isInvalidImageList = Avatar.invalidImageURLs.indexOf(src) !== -1; //let isValidImageList = Avatar.validImageURLs.indexOf(src) !== -1;
|
|
150
|
+
|
|
151
|
+
var showAvatar = src && !isInvalidImageList;
|
|
152
|
+
var showInitial = !showAvatar || showAvatar && isInvalidImageList;
|
|
153
|
+
var showAlternateAvatar = alternateSrc ? showInitial : false;
|
|
154
|
+
var border = borderOnHover || onClick;
|
|
155
|
+
var showDefaultBorder = src && !isInvalidImageList && needDefaultBorder;
|
|
156
|
+
var borderStyle = (showDefaultBorder || !src || !showAvatar || showInitial) && needBorder ? "".concat(_AvatarModule["default"].border, " ").concat(borderOnActive ? _AvatarModule["default"].borderOnActive : border ? _AvatarModule["default"].borderOnHover : '', " ") : '';
|
|
157
|
+
borderStyle = showAlternateAvatar ? '' : borderStyle;
|
|
158
|
+
return /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
159
|
+
className: "".concat(_AvatarModule["default"].avatar, " ").concat(_AvatarModule["default"][size], " ").concat((0, _AvatarSize["default"])(size), " ").concat(_AvatarModule["default"][shapeStyle], " ").concat(_AvatarModule["default"][palette], " ").concat(textStyle, " ").concat(borderStyle, " ").concat(customClass ? customClass : ''),
|
|
160
|
+
"data-title": needTitle ? title ? title : name : null,
|
|
161
|
+
"data-id": dataId,
|
|
162
|
+
"data-test-id": dataId,
|
|
163
|
+
onClick: onClick,
|
|
164
|
+
"data-selector-id": dataSelectorId
|
|
165
|
+
}, AvatarProps), showInitial && !showAlternateAvatar && /*#__PURE__*/_react["default"].createElement("span", {
|
|
166
|
+
className: "".concat(_AvatarModule["default"].initial),
|
|
167
|
+
"data-id": "".concat(dataId, "_AvatarInitial"),
|
|
168
|
+
"data-test-id": "".concat(dataId, "_AvatarInitial"),
|
|
169
|
+
"data-selector-id": "".concat(dataSelectorId, "_AvatarInitial")
|
|
170
|
+
}, initial), (showAvatar || showAlternateAvatar) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("img", {
|
|
171
|
+
className: "".concat(_AvatarModule["default"].image, " ").concat(isAnimate ? _AvatarModule["default"].animate : '', " ").concat(needInnerBorder ? _AvatarModule["default"].innerBorder : ''),
|
|
172
|
+
"data-id": "".concat(dataId, "_AvatarImg"),
|
|
173
|
+
"data-test-id": "".concat(dataId, "_AvatarImg"),
|
|
174
|
+
"data-selector-id": "".concat(dataSelectorId, "_AvatarImg"),
|
|
175
|
+
name: name,
|
|
176
|
+
onError: putInvalidImageURLJSON,
|
|
177
|
+
onLoad: putValidImageURLJSON,
|
|
178
|
+
src: showAlternateAvatar ? alternateSrc : src,
|
|
179
|
+
alt: name
|
|
180
|
+
}), showDefaultBorder ? null : /*#__PURE__*/_react["default"].createElement("span", {
|
|
181
|
+
className: "".concat(_AvatarModule["default"].shadow, " ").concat(textStyle, " ")
|
|
182
|
+
})));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
var _default = Avatar;
|
|
186
|
+
exports["default"] = _default;
|
|
238
187
|
Avatar.defaultProps = _defaultProps.defaultProps;
|
|
239
188
|
Avatar.propTypes = _propTypes.propTypes;
|
|
240
189
|
Avatar.invalidImageURLs = [];
|
|
241
|
-
Avatar.validImageURLs = [];
|
|
242
|
-
// Avatar.docs = {
|
|
243
|
-
// componentGroup: 'Avatar Group',
|
|
244
|
-
// folderName: 'Style Guide'
|
|
245
|
-
// };
|
|
246
|
-
// }
|
|
190
|
+
Avatar.validImageURLs = [];
|