@atlaskit/rovo-agent-components
Version:
This package host public components related to rovo agents, the components here are needed for other public atlaskit packages
79 lines • 4.99 kB
JavaScript
/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import "./index.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import { useIntl } from 'react-intl';
import { AVATAR_SIZES } from '@atlaskit/avatar';
import { fg } from '@atlaskit/platform-feature-flags';
import { Box } from '@atlaskit/primitives/compiled';
import { GeneratedAvatar } from './generated-avatars';
import { messages } from './messages';
export var AGENT_AVATAR_CLIP_PATH = "polygon(45% 1.33975%, 46.5798% 0.60307%, 48.26352% 0.15192%, 50% 0%, 51.73648% 0.15192%, 53.4202% 0.60307%, 55% 1.33975%, 89.64102% 21.33975%, 91.06889% 22.33956%, 92.30146% 23.57212%, 93.30127% 25%, 94.03794% 26.5798%, 94.48909% 28.26352%, 94.64102% 30%, 94.64102% 70%, 94.48909% 71.73648%, 94.03794% 73.4202%, 93.30127% 75%, 92.30146% 76.42788%, 91.06889% 77.66044%, 89.64102% 78.66025%, 55% 98.66025%, 53.4202% 99.39693%, 51.73648% 99.84808%, 50% 100%, 48.26352% 99.84808%, 46.5798% 99.39693%, 45% 98.66025%, 10.35898% 78.66025%, 8.93111% 77.66044%, 7.69854% 76.42788%, 6.69873% 75%, 5.96206% 73.4202%, 5.51091% 71.73648%, 5.35898% 70%, 5.35898% 30%, 5.51091% 28.26352%, 5.96206% 26.5798%, 6.69873% 25%, 7.69854% 23.57212%, 8.93111% 22.33956%, 10.35898% 21.33975%)";
var styles = {
agentAvatar: "_1e0c1txw _1bah1h6o _4cvr1h6o _mkrz1k6g",
image: "_5ral1dfr _4t3i1osq _1bsb1osq",
avatarContentContainer: "_1bsb1osq _4t3i1osq _1e0c1txw _1bah1h6o _4cvr1h6o"
};
var stylesCompiled = {
innerShape: "_4t3i1lk2 _1bsb1lk2 _mkrz1k6g"
};
/**
* Agent avatar components that handles rendering correct avatar for different variations of agent types
*
* @param agentNamedId - This is agent.external_config_reference, this value exists for OOTB (out of the box) agents. This id is the first priority to generate avatar because each OOTB agents have its own fixed avatar
* @param agentIdentityAccountId - This is Atlassian identity account ID for the agent(aaid). This id is prioritised to generate random avatar for non OOTB agents
* @param agentId - This is agent.id
*/
export var AgentAvatar = function AgentAvatar(_ref) {
var imageUrl = _ref.imageUrl,
_ref$size = _ref.size,
size = _ref$size === void 0 ? 'medium' : _ref$size,
label = _ref.label,
name = _ref.name,
agentId = _ref.agentId,
agentIdentityAccountId = _ref.agentIdentityAccountId,
agentNamedId = _ref.agentNamedId,
_ref$showBorder = _ref.showBorder,
showBorder = _ref$showBorder === void 0 ? true : _ref$showBorder,
isRovoDev = _ref.isRovoDev,
isForgeAgent = _ref.isForgeAgent,
forgeAgentIconUrl = _ref.forgeAgentIconUrl;
var _useIntl = useIntl(),
formatMessage = _useIntl.formatMessage;
var imgUrl = isForgeAgent && forgeAgentIconUrl ? forgeAgentIconUrl : imageUrl;
return /*#__PURE__*/React.createElement(Box, {
"aria-label": label,
xcss: styles.agentAvatar,
style: _objectSpread(_objectSpread({
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values
height: AVATAR_SIZES[size],
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/ui-styling-standard/no-imported-style-values
width: AVATAR_SIZES[size]
}, showBorder ? {
backgroundColor: '#fff'
} : {}), fg('rovo_chat_bugfix_agent_avatar_squish') ? {
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
minHeight: AVATAR_SIZES[size],
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
minWidth: AVATAR_SIZES[size]
} : {})
}, /*#__PURE__*/React.createElement("div", {
className: ax([stylesCompiled.innerShape])
}, /*#__PURE__*/React.createElement(Box, {
xcss: styles.avatarContentContainer
}, imgUrl ? /*#__PURE__*/React.createElement(Box, {
as: "img",
xcss: styles.image,
src: imgUrl,
alt: name || label || formatMessage(messages.agentAvatarLabel)
}) : /*#__PURE__*/React.createElement(GeneratedAvatar, {
agentId: agentId,
agentNamedId: agentNamedId,
agentIdentityAccountId: agentIdentityAccountId,
isRovoDev: isRovoDev,
size: size
}))));
};