@gravity-ui/uikit
Version:
Gravity UI base styling and components
33 lines (32 loc) • 959 B
JavaScript
import * as React from 'react';
import { isPolymorphicComponentProps, isPolymorphicLinkProps } from "../utils/polymorphic.js";
import { Tab } from "./Tab.js";
export function isTabComponentProps(p) {
return isPolymorphicComponentProps(p);
}
export function isTabLinkProps(p) {
return isPolymorphicLinkProps(p);
}
/**
* Finds the first Tab in the subtree (e.g. Tab wrapped in Tooltip) and returns it.
*/
export function getTabNodePropsFromReactNode(node) {
if (!React.isValidElement(node)) {
return undefined;
}
if (node.type === Tab) {
return node.props;
}
const props = node.props;
if (props.children === null) {
return undefined;
}
for (const child of React.Children.toArray(props.children)) {
const nested = getTabNodePropsFromReactNode(child);
if (nested !== undefined) {
return nested;
}
}
return undefined;
}
//# sourceMappingURL=utils.js.map