UNPKG

@react-spectrum/s2

Version:
86 lines (76 loc) 3.65 kB
import "./Avatar.css"; import {centerBaselineBefore as $1f4b04be3f24aae3$export$179e9489a09b14ac} from "./CenterBaseline.mjs"; import {Image as $dbd6f0b2503b938c$export$3e431a229df88919} from "./Image.mjs"; import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs"; import {jsx as $lGIgj$jsx} from "react/jsx-runtime"; import {createContext as $lGIgj$createContext, forwardRef as $lGIgj$forwardRef} from "react"; import {filterDOMProps as $lGIgj$filterDOMProps} from "@react-aria/utils"; import {useDOMRef as $lGIgj$useDOMRef} from "@react-spectrum/utils"; /* * 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 $3ffa2cd930156220$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|_6)[^\s]+/g); for (let p of matches){ if (p[1] === "_v") flexShrink = true; if (p[1] === "_u") flexGrow = true; rules += p[0]; } rules += ' sd1'; rules += ' eb1'; rules += ' og1'; rules += ' ng1'; rules += ' kg1'; rules += ' jg1'; rules += ' Zm1'; rules += ' Fn1'; if (!flexShrink) rules += ' _va1'; if (!flexGrow) rules += ' _ua1'; rules += ' __ca1'; if (props.isOverBackground) rules += ' _Lf1'; else rules += ' _Le1'; rules += ' OEzkoQe1'; if (props.isLarge) rules += ' _Mc1'; else rules += ' _Mb1'; return rules; }; const $3ffa2cd930156220$export$a20dad690e1279e2 = /*#__PURE__*/ (0, $lGIgj$createContext)(null); const $3ffa2cd930156220$export$e2255cf6045e8d47 = /*#__PURE__*/ (0, $lGIgj$forwardRef)(function Avatar(props, ref) { [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $3ffa2cd930156220$export$a20dad690e1279e2); let domRef = (0, $lGIgj$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, $lGIgj$filterDOMProps)(otherProps); // In the docs build, we need to be able to simulate font scaling. let remSize = `${size / 16}rem`; let isLarge = size >= 64; return /*#__PURE__*/ (0, $lGIgj$jsx)((0, $dbd6f0b2503b938c$export$3e431a229df88919), { ...domProps, ref: domRef, slot: slot, alt: alt, UNSAFE_style: { ...UNSAFE_style, width: remSize, height: remSize }, UNSAFE_className: UNSAFE_className + ' ' + (0, $1f4b04be3f24aae3$export$179e9489a09b14ac), styles: $3ffa2cd930156220$var$imageStyles({ isOverBackground: isOverBackground, isLarge: isLarge }, props.styles), src: src }); }); export {$3ffa2cd930156220$export$a20dad690e1279e2 as AvatarContext, $3ffa2cd930156220$export$e2255cf6045e8d47 as Avatar}; //# sourceMappingURL=Avatar.mjs.map