'use client'; import * as React from 'react'; import { useButtonContext } from '../../contexts/ButtonContext'; import { useARIAButtonProps } from '@fluentui/react-aria'; import { slot } from '@fluentui/react-utilities'; /** * Given user props, defines default props for the Button, calls useButtonState, and returns processed state. * @param props - User provided props to the Button component. * @param ref - User provided ref to be passed to the Button component. */ export const useButton_unstable = (props, ref)=>{ const { size: contextSize } = useButtonContext(); const { appearance = 'secondary', shape = 'rounded', size = contextSize !== null && contextSize !== void 0 ? contextSize : 'medium', ...buttonProps } = props; const state = useButtonBase_unstable(buttonProps, ref); return { appearance, shape, size, ...state }; }; /** * Base hook for Button component, which manages state related to slots structure and ARIA attributes. * * @param props - User provided props to the Button component. * @param ref - User provided ref to be passed to the Button component. */ export const useButtonBase_unstable = (props, ref)=>{ const { icon, iconPosition = 'before', ...buttonProps } = props; const iconShorthand = slot.optional(icon, { elementType: 'span' }); var _props_disabled, _props_disabledFocusable; return { disabled: (_props_disabled = props.disabled) !== null && _props_disabled !== void 0 ? _props_disabled : false, disabledFocusable: (_props_disabledFocusable = props.disabledFocusable) !== null && _props_disabledFocusable !== void 0 ? _props_disabledFocusable : false, iconPosition, iconOnly: Boolean((iconShorthand === null || iconShorthand === void 0 ? void 0 : iconShorthand.children) && !props.children), components: { root: 'button', icon: 'span' }, root: slot.always(useARIAButtonProps(buttonProps.as, buttonProps), { elementType: 'button', defaultProps: { ref: ref, type: props.as !== 'a' ? 'button' : undefined } }), icon: iconShorthand }; };