@react-spectrum/s2
Version:
Spectrum 2 UI components in React
87 lines (76 loc) • 3.51 kB
JavaScript
require("./Avatar.css");
var $053b76ed3d29e13b$exports = require("./Image.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $1YWJ0$reactjsxruntime = require("react/jsx-runtime");
var $1YWJ0$react = require("react");
var $1YWJ0$reactariautils = require("@react-aria/utils");
var $1YWJ0$reactspectrumutils = require("@react-spectrum/utils");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "AvatarContext", () => $38071d9ce246d4cf$export$a20dad690e1279e2);
$parcel$export(module.exports, "Avatar", () => $38071d9ce246d4cf$export$e2255cf6045e8d47);
/*
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
const $38071d9ce246d4cf$var$imageStyles = function anonymous(props, overrides) {
let rules = " ";
let flexShrink = false;
let flexGrow = false;
let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z)[^\s]+/g);
for (let p of matches){
if (p[1] === "_v") flexShrink = true;
if (p[1] === "_u") flexGrow = true;
rules += p[0];
}
rules += ' og91';
rules += ' ng91';
rules += ' kg91';
rules += ' jg91';
rules += ' Zm91';
rules += ' Fn91';
if (!flexShrink) rules += ' _va91';
if (!flexGrow) rules += ' _ua91';
rules += ' __ca91';
if (props.isOverBackground) rules += ' _Lf91';
else rules += ' _Le91';
rules += ' OEzkoQe91';
if (props.isLarge) rules += ' _Mc91';
else rules += ' _Mb91';
return rules;
};
const $38071d9ce246d4cf$export$a20dad690e1279e2 = /*#__PURE__*/ (0, $1YWJ0$react.createContext)(null);
const $38071d9ce246d4cf$export$e2255cf6045e8d47 = /*#__PURE__*/ (0, $1YWJ0$react.forwardRef)(function Avatar(props, ref) {
[props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $38071d9ce246d4cf$export$a20dad690e1279e2);
let domRef = (0, $1YWJ0$reactspectrumutils.useDOMRef)(ref);
let { alt: alt = '', src: src, UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className = '', size: size = 24, isOverBackground: isOverBackground, slot: slot = 'avatar', ...otherProps } = props;
const domProps = (0, $1YWJ0$reactariautils.filterDOMProps)(otherProps);
let remSize = size / 16 + 'rem';
let isLarge = size >= 64;
return /*#__PURE__*/ (0, $1YWJ0$reactjsxruntime.jsx)((0, $053b76ed3d29e13b$exports.Image), {
...domProps,
ref: domRef,
slot: slot,
alt: alt,
UNSAFE_style: {
...UNSAFE_style,
width: remSize,
height: remSize
},
UNSAFE_className: UNSAFE_className,
styles: $38071d9ce246d4cf$var$imageStyles({
isOverBackground: isOverBackground,
isLarge: isLarge
}, props.styles),
src: src
});
});
//# sourceMappingURL=Avatar.cjs.map