@appbuckets/react-ui
Version:
Just Another React UI Framework
49 lines (46 loc) • 1.47 kB
JavaScript
import { __rest, __assign } from 'tslib';
import * as React from 'react';
import clsx from 'clsx';
import {
createShorthandFactory,
useElementType,
childrenUtils,
} from '@appbuckets/react-ui-core';
import { useSharedClassName } from '../utils/customHook.js';
import '../BucketTheme/BucketTheme.js';
import { useWithDefaultProps } from '../BucketTheme/BucketContext.js';
/* --------
* Component Render
* -------- */
var TabPanel = function (receivedProps) {
var props = useWithDefaultProps('tabPanel', receivedProps);
var _a = useSharedClassName(props),
className = _a.className,
_b = _a.rest,
active = _b.active,
children = _b.children,
content = _b.content,
rest = __rest(_b, ['active', 'children', 'content']);
/** Get the component element type */
var ElementType = useElementType(TabPanel, receivedProps, props);
/** Build the element class list */
var classes = clsx({ active: active }, 'tab-panel', className);
/** If children are declared, render them */
if (!childrenUtils.isNil(children)) {
return React.createElement(
ElementType,
__assign({}, rest, { className: classes }),
children
);
}
return React.createElement(
ElementType,
__assign({}, rest, { className: classes }),
content
);
};
TabPanel.displayName = 'TabPanel';
TabPanel.create = createShorthandFactory(TabPanel, function (content) {
return { content: content };
});
export { TabPanel as default };