{"version":3,"sources":["../src/components/AvatarGroupItem/useAvatarGroupItem.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { Avatar } from '../Avatar/Avatar';\nimport { AvatarGroupContext, useAvatarGroupContext_unstable } from '../../contexts/AvatarGroupContext';\nimport { defaultAvatarGroupSize } from '../AvatarGroup/useAvatarGroup';\nimport { slot } from '@fluentui/react-utilities';\nimport { useHasParentContext } from '@fluentui/react-context-selector';\nimport type {\n  AvatarGroupItemBaseProps,\n  AvatarGroupItemBaseState,\n  AvatarGroupItemProps,\n  AvatarGroupItemState,\n} from './AvatarGroupItem.types';\n\n/**\n * Create the state required to render AvatarGroupItem.\n *\n * The returned state can be modified with hooks such as useAvatarGroupItemStyles_unstable,\n * before being passed to renderAvatarGroupItem_unstable.\n *\n * @param props - props from this instance of AvatarGroupItem\n * @param ref - reference to root HTMLElement of AvatarGroupItem\n */\nexport const useAvatarGroupItem_unstable = (\n  props: AvatarGroupItemProps,\n  ref: React.Ref<HTMLElement>,\n): AvatarGroupItemState => {\n  const state = useAvatarGroupItemBase_unstable(props, ref);\n  const groupSize = useAvatarGroupContext_unstable(ctx => ctx.size);\n  const size = groupSize ?? defaultAvatarGroupSize;\n\n  return {\n    size,\n    ...state,\n    components: {\n      // eslint-disable-next-line @typescript-eslint/no-deprecated\n      ...state.components,\n      avatar: Avatar,\n    },\n    avatar: slot.always(props.avatar, {\n      defaultProps: { size, color: 'colorful', ...state.avatar },\n      elementType: Avatar,\n    }),\n  };\n};\n\n/**\n * Create the base state required to render AvatarGroupItem, without default slot props or component types.\n *\n * The returned state can be modified with hooks such as useAvatarGroupItemStyles_unstable,\n * before being passed to renderAvatarGroupItem_unstable.\n *\n * @param props - props from this instance of AvatarGroupItem\n * @param ref - reference to root HTMLElement of AvatarGroupItem\n * @returns AvatarGroupItem state without default slot props or component types\n */\nexport const useAvatarGroupItemBase_unstable = (\n  props: AvatarGroupItemBaseProps,\n  ref: React.Ref<HTMLElement>,\n): AvatarGroupItemBaseState => {\n  const groupIsOverflow = useAvatarGroupContext_unstable(ctx => ctx.isOverflow);\n  const layout = useAvatarGroupContext_unstable(ctx => ctx.layout);\n  // Since the primary slot is not an intrinsic element, getPartitionedNativeProps cannot be used here.\n  const { style, className, overflowLabel, ...avatarSlotProps } = props;\n  const hasAvatarGroupContext = useHasParentContext(AvatarGroupContext);\n\n  if (process.env.NODE_ENV !== 'production' && !hasAvatarGroupContext) {\n    // eslint-disable-next-line no-console\n    console.warn('AvatarGroupItem must only be used inside an AvatarGroup component.');\n  }\n\n  return {\n    isOverflowItem: groupIsOverflow,\n    layout,\n    components: {\n      root: groupIsOverflow ? 'li' : 'div',\n      avatar: 'span',\n      overflowLabel: 'span',\n    },\n    root: slot.always(props.root, {\n      defaultProps: {\n        style,\n        className,\n      },\n      elementType: groupIsOverflow ? 'li' : 'div',\n    }),\n    avatar: slot.always(props.avatar, {\n      defaultProps: {\n        ref,\n        ...avatarSlotProps,\n      },\n      elementType: 'span',\n    }),\n    overflowLabel: slot.always(overflowLabel, {\n      defaultProps: {\n        // Avatar already has its aria-label set to the name, this will prevent the name to be read twice.\n        'aria-hidden': true,\n        children: props.name,\n      },\n      elementType: 'span',\n    }),\n  };\n};\n"],"names":["Avatar","AvatarGroupContext","useAvatarGroupContext_unstable","defaultAvatarGroupSize","slot","useHasParentContext","useAvatarGroupItem_unstable","props","ref","state","useAvatarGroupItemBase_unstable","groupSize","ctx","size","components","avatar","always","defaultProps","color","elementType","groupIsOverflow","isOverflow","layout","style","className","overflowLabel","avatarSlotProps","hasAvatarGroupContext","process","env","NODE_ENV","console","warn","isOverflowItem","root","children","name"],"mappings":"AAAA;;;;;;;;;;;;mCAyDaU;eAAAA;;+BAjCAJ;;;;wBArBU,sBAAmB;oCACyB,uCAAoC;gCAChE,mCAAgC;gCAClD,4BAA4B;sCACb,mCAAmC;AAiBhE,MAAMA,8BAA8B,CACzCC,OACAC;IAEA,MAAMC,QAAQC,gCAAgCH,OAAOC;IACrD,MAAMG,g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