{"version":3,"sources":["../../../src/components/SplitButton/useSplitButton.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useId, slot } from '@fluentui/react-utilities';\nimport { Button } from '../Button/Button';\nimport { MenuButton } from '../MenuButton/MenuButton';\nimport type {\n  SplitButtonBaseProps,\n  SplitButtonBaseState,\n  SplitButtonProps,\n  SplitButtonState,\n} from './SplitButton.types';\n\n/**\n * Given user props, defines default props for the SplitButton and returns processed state.\n * @param props - User provided props to the SplitButton component.\n * @param ref - User provided ref to be passed to the SplitButton component.\n */\nexport const useSplitButton_unstable = (props: SplitButtonProps, ref: React.Ref<HTMLDivElement>): SplitButtonState => {\n  const { appearance = 'secondary', icon, menuIcon, shape = 'rounded', size = 'medium', ...rest } = props;\n  const baseState = useSplitButtonBase_unstable(rest, ref);\n\n  const menuButtonShorthand = slot.optional(props.menuButton, {\n    defaultProps: {\n      ...baseState.menuButton,\n      appearance,\n      disabledFocusable: baseState.disabledFocusable,\n      menuIcon,\n      shape,\n      size,\n    },\n    renderByDefault: true,\n    elementType: MenuButton,\n  });\n  const primaryActionButtonShorthand = slot.optional(props.primaryActionButton, {\n    defaultProps: {\n      ...baseState.primaryActionButton,\n      appearance,\n      disabledFocusable: baseState.disabledFocusable,\n      icon,\n      iconPosition: baseState.iconPosition,\n      shape,\n      size,\n    },\n    renderByDefault: true,\n    elementType: Button,\n  });\n\n  return {\n    ...baseState,\n    // Props passed at the top-level\n    appearance,\n    shape,\n    size,\n    // Slots definition\n    components: { root: 'div', menuButton: MenuButton, primaryActionButton: Button },\n    menuButton: menuButtonShorthand,\n    primaryActionButton: primaryActionButtonShorthand,\n  };\n};\n\n/**\n * Base hook for SplitButton component, which manages design-agnostic state related to slots\n * structure and ARIA attributes, without design-specific props such as `appearance`, `shape`, or\n * `size`.\n *\n * Concrete wrappers recreate child slots from these base prop defaults before rendering.\n *\n * @param props - User provided props to the SplitButton component.\n * @param ref - User provided ref to be passed to the SplitButton component.\n */\nexport const useSplitButtonBase_unstable = (\n  props: SplitButtonBaseProps,\n  ref: React.Ref<HTMLDivElement>,\n): SplitButtonBaseState => {\n  const {\n    children,\n    disabled = false,\n    disabledFocusable = false,\n    icon,\n    iconPosition = 'before',\n    menuButton,\n    menuIcon,\n    primaryActionButton,\n    ...rest\n  } = props;\n  const baseId = useId('splitButton-');\n\n  const menuButtonShorthand = slot.optional(menuButton, {\n    defaultProps: {\n      disabled,\n    },\n    renderByDefault: true,\n    elementType: 'button',\n  });\n\n  const primaryActionButtonShorthand = slot.optional(primaryActionButton, {\n    defaultProps: {\n      children,\n      disabled,\n      id: baseId + '__primaryActionButton',\n    },\n    renderByDefault: true,\n    elementType: 'button',\n  });\n\n  // Resolve menu button's aria-labelledby to be labelled by the primary action button if no label was provided by the\n  // user.\n  if (\n    menuButtonShorthand &&\n    primaryActionButtonShorthand &&\n    !menuButtonShorthand['aria-label'] &&\n    !menuButtonShorthand['aria-labelledby']\n  ) {\n    menuButtonShorthand['aria-labelledby'] = primaryActionButtonShorthand.id;\n  }\n\n  return {\n    disabled,\n    disabledFocusable,\n    iconPosition,\n    // Slots definition\n    components: { root: 'div', menuButton: 'button', primaryActionButton: 'button' },\n    root: slot.always({ ref, ...rest }, { elementType: 'div' }),\n    menuButton: menuButtonShorthand,\n    primaryActionButton: primaryActionButtonShorthand,\n  };\n};\n"],"names":["useId","slot","Button","MenuButton","useSplitButton_unstable","props","ref","appearance","icon","menuIcon","shape","size","rest","baseState","useSplitButtonBase_unstable","menuButtonShorthand","optional","menuButton","defaultProps","disabledFocusable","renderByDefault","elementType","primaryActionButtonShorthand","primaryActionButton","iconPosition","components","root","children","disabled","baseId","id","always"],"mappings":"AAAA;;;;;;;;;;;;QAuEac;;;QArDAV;;;;gCAfe,4BAA4B;wBACjC,sBAAmB;4BACf,8BAA2B;AAa/C,gCAAgC,CAACC,OAAyBC;IAC/D,MAAM,EAAEC,aAAa,WAAW,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,QAAQ,SAAS,EAAEC,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