@engie-group/fluid-design-system-react
Version:
Fluid Design System React
20 lines (18 loc) • 863 B
JavaScript
/**
* Type guard to check if we're rendering the default component for the action. (`actionAsChild` is false)
* @param props - The props to check, they should be of type {@link ActionAsChild}.
* @returns whether or not we are rendering the default action component.
*/
function isDefaultAction(props) {
return !props.actionAsChild;
}
/**
* Type guard to check if we are using the default component (not asChild or actionAsChild).
* @param discriminant Used to discriminate between default and child rendering (mostly asChild props).
* @param props The rest of the destructured props intersection. All common props must be extracted from this object.
* @returns Wether or not we are using the default component.
*/
function isDefaultComponent(discriminant, props) {
return discriminant !== true;
}
export { isDefaultAction, isDefaultComponent };