UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

30 lines (28 loc) 908 B
import { useValidChildren } from "../../utils/children.js"; import { utils_exports } from "../../utils/index.js"; import { useCallback, useMemo } from "react"; //#region src/components/avatar/use-avatar-group.ts const useAvatarGroup = ({ children, max, reverse,...rest } = {}) => { const validChildren = useValidChildren(children); const excess = !(0, utils_exports.isUndefined)(max) ? validChildren.length - max : 0; const getRootProps = useCallback((props) => ({ ...rest, ...props, role: "group" }), [rest]); return { children: useMemo(() => { const omittedChildren = !(0, utils_exports.isUndefined)(max) ? validChildren.slice(0, max) : [...validChildren]; return reverse ? omittedChildren.reverse() : omittedChildren; }, [ max, validChildren, reverse ]), excess, getRootProps }; }; //#endregion export { useAvatarGroup }; //# sourceMappingURL=use-avatar-group.js.map