UNPKG

seti-ramesesv1

Version:

Reusable components and context for Next.js apps

40 lines (37 loc) 1.43 kB
import resolveComponentProps from '../resolveComponentProps/resolveComponentProps.js'; import mergeSlotProps from '../mergeSlotProps/mergeSlotProps.js'; import useForkRef from '../useForkRef/useForkRef.js'; import appendOwnerState from '../appendOwnerState/appendOwnerState.js'; /** * @ignore - do not document. * Builds the props to be passed into the slot of an unstyled component. * It merges the internal props of the component with the ones supplied by the user, allowing to customize the behavior. * If the slot component is not a host component, it also merges in the `ownerState`. * * @param parameters.getSlotProps - A function that returns the props to be passed to the slot component. */ function useSlotProps(parameters) { const { elementType, externalSlotProps, ownerState, skipResolvingSlotProps = false, ...other } = parameters; const resolvedComponentsProps = skipResolvingSlotProps ? {} : resolveComponentProps(externalSlotProps, ownerState); const { props: mergedProps, internalRef } = mergeSlotProps({ ...other, externalSlotProps: resolvedComponentsProps }); const ref = useForkRef(internalRef, resolvedComponentsProps?.ref, parameters.additionalProps?.ref); const props = appendOwnerState(elementType, { ...mergedProps, ref }, ownerState); return props; } export { useSlotProps as default }; //# sourceMappingURL=useSlotProps.js.map