@uiw/react-avatar
Advanced tools
Comparing version 4.21.19 to 4.21.20
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"]; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -11,41 +9,29 @@ value: true | ||
exports["default"] = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _reactIcon = _interopRequireDefault(require("@uiw/react-icon")); | ||
var _utils = require("@uiw/utils"); | ||
var _jsxRuntime = require("react/jsx-runtime"); | ||
var _excluded = ["prefixCls", "shape", "size", "className", "src", "alt", "icon", "onError"]; | ||
var _default = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) { | ||
var _props$prefixCls = props.prefixCls, | ||
prefixCls = _props$prefixCls === void 0 ? 'w-avatar' : _props$prefixCls, | ||
_props$shape = props.shape, | ||
shape = _props$shape === void 0 ? 'circle' : _props$shape, | ||
_props$size = props.size, | ||
size = _props$size === void 0 ? 'default' : _props$size, | ||
className = props.className, | ||
src = props.src, | ||
alt = props.alt, | ||
icon = props.icon, | ||
_props$onError = props.onError, | ||
_onError = _props$onError === void 0 ? _utils.noop : _props$onError, | ||
resetProps = (0, _objectWithoutProperties2["default"])(props, _excluded); | ||
prefixCls = _props$prefixCls === void 0 ? 'w-avatar' : _props$prefixCls, | ||
_props$shape = props.shape, | ||
shape = _props$shape === void 0 ? 'circle' : _props$shape, | ||
_props$size = props.size, | ||
size = _props$size === void 0 ? 'default' : _props$size, | ||
className = props.className, | ||
src = props.src, | ||
alt = props.alt, | ||
icon = props.icon, | ||
_props$onError = props.onError, | ||
_onError = _props$onError === void 0 ? _utils.noop : _props$onError, | ||
resetProps = (0, _objectWithoutProperties2["default"])(props, _excluded); | ||
var children = props.children; | ||
var _useState = (0, _react.useState)(true), | ||
_useState2 = (0, _slicedToArray2["default"])(_useState, 2), | ||
isImgExist = _useState2[0], | ||
setIsImgExist = _useState2[1]; | ||
_useState2 = (0, _slicedToArray2["default"])(_useState, 2), | ||
isImgExist = _useState2[0], | ||
setIsImgExist = _useState2[1]; | ||
var cls = [prefixCls, className, size ? "".concat(prefixCls, "-").concat(size) : null, shape ? "".concat(prefixCls, "-").concat(shape) : null, src ? "".concat(prefixCls, "-image") : null].filter(Boolean).join(' ').trim(); | ||
@@ -55,3 +41,2 @@ (0, _react.useEffect)(function () { | ||
}, [props.src]); | ||
if (isImgExist && src) { | ||
@@ -63,3 +48,2 @@ children = /*#__PURE__*/(0, _jsxRuntime.jsx)("img", { | ||
var errorFlag = _onError ? _onError(evn) : undefined; | ||
if (errorFlag !== false) { | ||
@@ -77,3 +61,2 @@ setIsImgExist(false); | ||
} | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, resetProps), {}, { | ||
@@ -85,5 +68,4 @@ className: cls, | ||
}); | ||
exports["default"] = _default; | ||
module.exports = exports.default; | ||
//# sourceMappingURL=index.js.map |
@@ -13,13 +13,12 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
var { | ||
prefixCls = 'w-avatar', | ||
shape = 'circle', | ||
size = 'default', | ||
className, | ||
src, | ||
alt, | ||
icon, | ||
onError: _onError = noop | ||
} = props, | ||
resetProps = _objectWithoutPropertiesLoose(props, _excluded); | ||
prefixCls = 'w-avatar', | ||
shape = 'circle', | ||
size = 'default', | ||
className, | ||
src, | ||
alt, | ||
icon, | ||
onError: _onError = noop | ||
} = props, | ||
resetProps = _objectWithoutPropertiesLoose(props, _excluded); | ||
var children = props.children; | ||
@@ -31,3 +30,2 @@ var [isImgExist, setIsImgExist] = useState(true); | ||
}, [props.src]); | ||
if (isImgExist && src) { | ||
@@ -39,3 +37,2 @@ children = /*#__PURE__*/_jsx("img", { | ||
var errorFlag = _onError ? _onError(evn) : undefined; | ||
if (errorFlag !== false) { | ||
@@ -53,3 +50,2 @@ setIsImgExist(false); | ||
} | ||
return /*#__PURE__*/_jsx("span", _extends({}, resetProps, { | ||
@@ -56,0 +52,0 @@ className: cls, |
{ | ||
"name": "@uiw/react-avatar", | ||
"version": "4.21.19", | ||
"version": "4.21.20", | ||
"description": "Avatar component", | ||
@@ -47,5 +47,5 @@ "author": "Kenny Wong <wowohoo@qq.com>", | ||
"dependencies": { | ||
"@uiw/react-icon": "^4.21.19", | ||
"@uiw/utils": "^4.21.19" | ||
"@uiw/react-icon": "^4.21.20", | ||
"@uiw/utils": "^4.21.20" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24677
Updated@uiw/react-icon@^4.21.20
Updated@uiw/utils@^4.21.20