UNPKG

@yamada-ui/react

Version:

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

32 lines (30 loc) 1.13 kB
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs'); const require_children = require('../../utils/children.cjs'); const require_utils_index = require('../../utils/index.cjs'); let react = require("react"); react = require_rolldown_runtime.__toESM(react); //#region src/components/avatar/use-avatar-group.ts const useAvatarGroup = ({ children, max, reverse,...rest } = {}) => { const validChildren = require_children.useValidChildren(children); const excess = !(0, require_utils_index.utils_exports.isUndefined)(max) ? validChildren.length - max : 0; const getRootProps = (0, react.useCallback)((props) => ({ ...rest, ...props, role: "group" }), [rest]); return { children: (0, react.useMemo)(() => { const omittedChildren = !(0, require_utils_index.utils_exports.isUndefined)(max) ? validChildren.slice(0, max) : [...validChildren]; return reverse ? omittedChildren.reverse() : omittedChildren; }, [ max, validChildren, reverse ]), excess, getRootProps }; }; //#endregion exports.useAvatarGroup = useAvatarGroup; //# sourceMappingURL=use-avatar-group.cjs.map