Private
Public Access
1
0
Files
power-apps-codeapps-blog-part2/node_modules/@fluentui/react-skeleton/lib/components/SkeletonItem/useSkeletonItem.js

44 lines
1.8 KiB
JavaScript

'use client';
import * as React from 'react';
import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
import { useSkeletonContext } from '../../contexts/SkeletonContext';
/**
* Create the state required to render SkeletonItem.
*
* The returned state can be modified with hooks such as useSkeletonItemStyles_unstable,
* before being passed to renderSkeletonItem_unstable.
*
* @param props - props from this instance of SkeletonItem
* @param ref - reference to root HTMLElement of SkeletonItem
*/ export const useSkeletonItem_unstable = (props, ref)=>{
const { animation: contextAnimation, appearance: contextAppearance, size: contextSize, shape: contextShape } = useSkeletonContext();
const { animation = contextAnimation !== null && contextAnimation !== void 0 ? contextAnimation : 'wave', appearance = contextAppearance !== null && contextAppearance !== void 0 ? contextAppearance : 'opaque', size = contextSize !== null && contextSize !== void 0 ? contextSize : 16, shape = contextShape !== null && contextShape !== void 0 ? contextShape : 'rectangle', ...baseProps } = props;
const baseState = useSkeletonItemBase_unstable(baseProps, ref);
return {
...baseState,
animation,
appearance,
size,
shape
};
};
/**
* Base hook for SkeletonItem component, which manages state related to slots structure.
*
* @param props - User provided props to the SkeletonItem component.
* @param ref - User provided ref to be passed to the SkeletonItem component.
*/ export const useSkeletonItemBase_unstable = (props, ref)=>{
const root = slot.always(getIntrinsicElementProps('div', {
ref,
...props
}), {
elementType: 'div'
});
return {
components: {
root: 'div'
},
root
};
};