Private
Public Access
1
0
Files
power-apps-codeapps-blog-part2/node_modules/@fluentui/react-breadcrumb/lib/components/BreadcrumbItem/useBreadcrumbItem.js

40 lines
1.3 KiB
JavaScript

'use client';
import * as React from 'react';
import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
import { useBreadcrumbContext_unstable } from '../Breadcrumb/BreadcrumbContext';
/**
* Create the state required to render BreadcrumbItem.
*
* The returned state can be modified with hooks such as useBreadcrumbItemStyles_unstable,
* before being passed to renderBreadcrumbItem_unstable.
*
* @param props - props from this instance of BreadcrumbItem
* @param ref - reference to root HTMLElement of BreadcrumbItem
*/ export const useBreadcrumbItem_unstable = (props, ref)=>{
const { size } = useBreadcrumbContext_unstable();
const state = useBreadcrumbItemBase_unstable(props, ref);
return {
...state,
size
};
};
/**
* Base hook for BreadcrumbItem component, which manages state related to slots structure
* without design props. Note: size is provided via BreadcrumbContext in the full hook.
*
* @param props - props from this instance of BreadcrumbItem
* @param ref - reference to root HTMLElement of BreadcrumbItem
*/ export const useBreadcrumbItemBase_unstable = (props, ref)=>{
return {
components: {
root: 'li'
},
root: slot.always(getIntrinsicElementProps('li', {
ref,
...props
}), {
elementType: 'li'
})
};
};