@mui/joy
Version:
Joy UI is an open-source React component library that implements MUI's own design principles. It's comprehensive and can be used in production out of the box.
153 lines (151 loc) • 5.43 kB
JavaScript
'use client';
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import _extends from "@babel/runtime/helpers/esm/extends";
const _excluded = ["className", "color", "component", "size", "variant", "children", "slots", "slotProps"];
import * as React from 'react';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import { unstable_composeClasses as composeClasses } from '@mui/base';
import { useThemeProps } from '../styles';
import styled from '../styles/styled';
import { getAvatarGroupUtilityClass } from './avatarGroupClasses';
import useSlot from '../utils/useSlot';
import { jsx as _jsx } from "react/jsx-runtime";
export const AvatarGroupContext = /*#__PURE__*/React.createContext(undefined);
if (process.env.NODE_ENV !== 'production') {
AvatarGroupContext.displayName = 'AvatarGroupContext';
}
const useUtilityClasses = () => {
const slots = {
root: ['root']
};
return composeClasses(slots, getAvatarGroupUtilityClass, {});
};
const AvatarGroupGroupRoot = styled('div', {
name: 'JoyAvatarGroup',
slot: 'Root',
overridesResolver: (props, styles) => styles.root
})(({
ownerState,
theme
}) => _extends({}, ownerState.size === 'sm' && {
'--AvatarGroup-gap': '-0.375rem',
'--Avatar-ringSize': '2px'
}, ownerState.size === 'md' && {
'--AvatarGroup-gap': '-0.5rem',
'--Avatar-ringSize': '2px'
}, ownerState.size === 'lg' && {
'--AvatarGroup-gap': '-0.625rem',
'--Avatar-ringSize': '4px'
}, {
'--Avatar-ring': `0 0 0 var(--Avatar-ringSize) var(--Avatar-ringColor, ${theme.vars.palette.background.surface})`,
'--Avatar-marginInlineStart': 'var(--AvatarGroup-gap)',
display: 'flex',
marginInlineStart: 'calc(-1 * var(--AvatarGroup-gap))'
}));
/**
*
* Demos:
*
* - [Avatar](https://mui.com/joy-ui/react-avatar/)
*
* API:
*
* - [AvatarGroup API](https://mui.com/joy-ui/api/avatar-group/)
*/
const AvatarGroup = /*#__PURE__*/React.forwardRef(function AvatarGroup(inProps, ref) {
const props = useThemeProps({
props: inProps,
name: 'JoyAvatarGroup'
});
const {
className,
color,
component = 'div',
size = 'md',
variant,
children,
slots = {},
slotProps = {}
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const ownerState = React.useMemo(() => _extends({}, props, {
color,
component,
size,
variant
}), [color, component, props, size, variant]);
const classes = useUtilityClasses();
const [SlotRoot, rootProps] = useSlot('root', {
ref,
className: clsx(classes.root, className),
elementType: AvatarGroupGroupRoot,
externalForwardedProps: _extends({}, other, {
component,
slots,
slotProps
}),
ownerState
});
return /*#__PURE__*/_jsx(AvatarGroupContext.Provider, {
value: ownerState,
children: /*#__PURE__*/_jsx(SlotRoot, _extends({}, rootProps, {
children: children
}))
});
});
process.env.NODE_ENV !== "production" ? AvatarGroup.propTypes /* remove-proptypes */ = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* Used to render icon or text elements inside the AvatarGroup if `src` is not set.
* This can be an element, or just a string.
*/
children: PropTypes.node,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The color of the component. It supports those theme colors that make sense for this component.
* @default 'neutral'
*/
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['danger', 'neutral', 'primary', 'success', 'warning']), PropTypes.string]),
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
*/
component: PropTypes.elementType,
/**
* The size of the component.
* It accepts theme values between 'sm' and 'lg'.
* @default 'md'
*/
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['lg', 'md', 'sm']), PropTypes.string]),
/**
* The props used for each slot inside.
* @default {}
*/
slotProps: PropTypes.shape({
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
}),
/**
* The components used for each slot inside.
* @default {}
*/
slots: PropTypes.shape({
root: PropTypes.elementType
}),
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
/**
* The [global variant](https://mui.com/joy-ui/main-features/global-variants/) to use.
* @default 'soft'
*/
variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['outlined', 'plain', 'soft', 'solid']), PropTypes.string])
} : void 0;
export default AvatarGroup;