@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
35 lines • 5.18 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from 'react';
import { Text } from '../../../components/text/text';
import { TextComponentType } from '../../../components/text/types/component';
import { ButtonType } from '../../button/types/type';
import { ElementOrIcon } from '../../elementOrIcon/elementOrIcon';
import { useContent } from '../hooks/useContent';
import { ListHeaderItemStylesStyled, ListItemExpandedStyled, ListItemHeaderPriorityStyled, ListRowContainerHeaderPriorityStyled, ListRowHeaderPriorityStyled, TableExpandedButton, } from '../table.styled';
export const ListColumnHeaderPriority = (props) => {
return (_jsx(React.Fragment, { children: props.headers
// By now you can't have a divider in a column header priority
.filter(header => !header.config?.hasDivider)
.map((header, indexHeader) => {
return (_jsxs(ListRowContainerHeaderPriorityStyled, {
// By now you can't have a divider in a column header priority
hasDivider: false, lineSeparatorLineStyles: props.lineSeparatorLineStyles, styles: props.styles, children: [header.label && (_jsx(ListHeaderItemStylesStyled, { "aria-hidden": header.config?.['aria-hidden'], customAlign: header?.config?.alignHeader?.[props.device] || header?.config?.alignHeader, customBackgroundColor: header?.config?.backgroundColor, customWidth: header?.config?.width, flexWidth: header?.config?.flexWidth, hidden: props.hiddenHeaderOn?.[props.device], index: indexHeader, lineSeparatorBottomOnHeader: props.lineSeparatorBottomOnHeader, lineSeparatorLineStyles: props.lineSeparatorLineStyles, lineSeparatorTopOnHeader: props.lineSeparatorTopOnHeader, styles: props.styles.header?.[props.headerVariant], children: _jsx(Text, { component: TextComponentType.SPAN, customTypography: props.styles.header?.[props.headerVariant]?.typography, children: header.label }) })), _jsx(ListRowHeaderPriorityStyled, { styles: props.styles, children: props.values.map((value, indexValue) => {
return (_jsx(ListColumnHeaderValue, { ...props, hasExpandedIcon: indexValue === 0, header: header, indexHeader: indexHeader, value: value }, indexValue));
}) })] }, indexHeader));
}) }));
};
const ListColumnHeaderValue = (props) => {
const { rowHeader, getExpandedAria, getValue, getCellTokenValue, handleShowExpandedContent, hasExpandedContentRow, showExpandedContent, rowVariant, } = useContent({ ...props });
return (_jsxs("li", { children: [rowHeader && (_jsx(ListHeaderItemStylesStyled, { customAlign: rowHeader?.config?.alignHeader?.[props.device] || rowHeader?.config?.alignHeader, customBackgroundColor: rowHeader?.config?.backgroundColor, customWidth: rowHeader?.config?.width, flexWidth: rowHeader?.config?.flexWidth, hidden: props.hiddenHeaderOn?.[props.device], lineSeparatorBottomOnHeader: props.lineSeparatorBottomOnHeader, lineSeparatorLineStyles: props.lineSeparatorLineStyles, styles: props.styles.header?.[rowHeader.variant], children: _jsx(Text, { component: TextComponentType.SPAN, customTypography: props.styles.header?.[rowHeader.variant]?.typography, children: rowHeader.label }) })), _jsx("ul", { children: _jsxs(ListItemHeaderPriorityStyled, { borderPosition: props.value.rowBorderPosition, customAlign: getCellTokenValue({ headerValue: props.header, token: 'align' }) ||
props.header?.config?.alignValue?.[props.device] ||
props.header?.config?.alignValue ||
props.header?.config?.alignHeader?.[props.device] ||
props.header?.config?.alignHeader, customBackgroundColor: getCellTokenValue({ headerValue: props.header, token: 'backgroundColor' }) ??
props.value.backgroundColor, customWidth: props.header?.config?.width, flexWidth: props.header?.config?.flexWidth, hasSomeExpandedContent: props.hasSomeExpandedContent, lineSeparatorLineStyles: props.lineSeparatorLineStyles, styles: props.styles.bodyRows?.[rowVariant], children: [props.hasExpandedIcon && hasExpandedContentRow && (_jsx(TableExpandedButton, { "aria-label": getExpandedAria(), styles: props.styles.bodyRows?.[rowVariant], type: ButtonType.BUTTON, onClick: () => {
props.onExpandedContentOpen?.(!showExpandedContent, getValue(props.header), props.indexHeader);
handleShowExpandedContent(!showExpandedContent);
}, children: _jsx(ElementOrIcon, { customIconStyles: props.styles.bodyRows?.[rowVariant]?.accordionIcon, rotate: showExpandedContent ? '180deg' : '0deg', ...props.accordionIcon }) })), getValue(props.header), props.hasExpandedIcon && hasExpandedContentRow && (_jsx(ListItemExpandedStyled, { showExpandedContent: showExpandedContent, styles: props.styles.bodyRows?.[rowVariant], children: showExpandedContent && props.value.expandedContent
? props.value.expandedContent[props.device]
: props.expandedContentHelpMessage }))] }) })] }));
};
//# sourceMappingURL=listColumnHeaderPriority.js.map