UNPKG

@atlaskit/avatar-group

Version:

An avatar group displays a number of avatars grouped together in a stack or grid.

86 lines (85 loc) 3.4 kB
/* more-indicator.tsx generated by @compiled/babel-plugin v0.39.1 */ import _extends from "@babel/runtime/helpers/extends"; import "./more-indicator.compiled.css"; import * as React from 'react'; import { ax, ix } from "@compiled/react/runtime"; import { forwardRef, useCallback } from 'react'; import { fg } from '@atlaskit/platform-feature-flags'; const boxShadowCssVar = '--avatar-box-shadow'; const styles = { root: "_19itglyw _12ji1r31 _1qu2glyw _12y31o36 _1reo15vq _18m915vq _v564ieh6 _1e0c1txw _vchh1ntv _1pfhv77o _12l2v77o _6rthv77o _ahbqv77o _1q51ze3t _y4tize3t _85i5ze3t _bozgze3t _4cvr1fhb _1bah1h6o _2lx21bp4 _80omtlke _bfhki8nm _syazi7uo _16qs1nhn _t9ec1aqe _1ejjglyw _mizu1v1w _ra3xnqa1 _1ah3yh40 _128myh40 _irr3plhp _30l3i7uo _1di61gdz _9h8hi7uo _jlxit94y", circle: "_2rko1qll", activeScale: "_1q8w1np6", active: "_bfhk15s3 _16qsdfwd _syaz6x5g _irr3ufnl _30l36x5g _1di6nozp _9h8h6x5g", activeStateScale: "_t9ec1np6", disabled: "_80om13gf _1peq2wxo _1hfkvuon", hexagon: "_mkrz1k6g" }; const widthHeightMap = { xsmall: "_1bsb7vkz _4t3i7vkz", small: "_1bsb1tcg _4t3i1tcg", medium: "_1bsbzwfg _4t3izwfg", large: "_1bsb1ylp _4t3i1ylp", xlarge: "_1bsb16xz _4t3i16xz", xxlarge: "_1bsb1qr7 _4t3i1qr7" }; const borderRadiusMap = { xsmall: "_2rkolb4i _14mjlb4i", small: "_2rkolb4i _14mjlb4i", medium: "_2rkofajl _14mjfajl", large: "_2rkofajl _14mjfajl", xlarge: "_2rko1qi0 _14mj1qi0", xxlarge: "_2rkopb1k _14mjpb1k" }; const fontMap = { small: "_11c8wadc", medium: "_11c8wadc", large: "_11c8wadc", xlarge: "_11c81d4k", xxlarge: "_11c81d4k" }; const MAX_DISPLAY_COUNT = 99; const MoreIndicator = /*#__PURE__*/forwardRef(({ appearance = 'circle', borderColor = "var(--ds-surface, #FFFFFF)", size = 'medium', count = 0, testId, onClick, 'aria-controls': ariaControls, 'aria-expanded': ariaExpanded, 'aria-haspopup': ariaHaspopup, moreIndicatorLabel, buttonProps = {}, isActive }, ref) => { const onClickHander = useCallback((event, analyticsEvent) => { if (buttonProps.onClick) { buttonProps.onClick(event); } onClick(event, analyticsEvent); }, // eslint-disable-next-line react-hooks/exhaustive-deps [buttonProps.onClick, onClick]); const displayCount = count > MAX_DISPLAY_COUNT ? MAX_DISPLAY_COUNT : count; const providedAriaLabel = moreIndicatorLabel || buttonProps['aria-label']; const ariaLabel = providedAriaLabel ? providedAriaLabel : `${displayCount} more people`; return /*#__PURE__*/React.createElement("button", _extends({ type: "submit" }, buttonProps, { onClick: onClickHander, ref: ref, "data-testid": testId, "aria-controls": ariaControls, "aria-expanded": ariaExpanded, "aria-haspopup": ariaHaspopup, "aria-label": ariaLabel, style: { [boxShadowCssVar]: `0 0 0 2px ${borderColor}` }, className: ax([styles.root, !fg('remove_scaling_from_avatar_stack') && styles.activeScale, borderRadiusMap[size], appearance === 'circle' && styles.circle, appearance === 'hexagon' && fg('jira-ai-agent-stack') && styles.hexagon, widthHeightMap[size], fontMap[size], isActive && styles.active, isActive && !fg('remove_scaling_from_avatar_stack') && styles.activeStateScale]) }), "+", displayCount); }); MoreIndicator.displayName = 'MoreIndicator'; // eslint-disable-next-line @repo/internal/react/require-jsdoc export default MoreIndicator;