UNPKG

@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

32 lines 5.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ListRowHeaderPriority = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const text_1 = require("../../../components/text/text"); const component_1 = require("../../../components/text/types/component"); const type_1 = require("../../button/types/type"); const elementOrIcon_1 = require("../../elementOrIcon/elementOrIcon"); const useContent_1 = require("../hooks/useContent"); const table_styled_1 = require("../table.styled"); const listDivider_1 = require("./listDivider"); const ListRowHeaderPriority = (props) => { const { rowHeader, divider, dividerValue, getExpandedAria, getValue, getCellTokenValue, handleShowExpandedContent, hasExpandedContentRow, showExpandedContent, rowVariant, } = (0, useContent_1.useContent)({ ...props }); return ((0, jsx_runtime_1.jsxs)(table_styled_1.ListRowContainerHeaderPriorityStyled, { hasDivider: !!dividerValue(), lineSeparatorLineStyles: props.lineSeparatorLineStyles, styles: props.styles, children: [rowHeader && ((0, jsx_runtime_1.jsx)(table_styled_1.ListHeaderItemStylesStyled, { customAlign: rowHeader?.config?.alignHeader?.[props.device] || rowHeader?.config?.alignHeader, customBackgroundColor: rowHeader?.config?.backgroundColor, customWidth: rowHeader?.config?.width, flexWidth: rowHeader?.config?.flexWidth, index: props.index, lineSeparatorBottomOnHeader: props.lineSeparatorBottomOnHeader, lineSeparatorLineStyles: props.lineSeparatorLineStyles, lineSeparatorTopOnHeader: props.lineSeparatorTopOnHeader, styles: props.styles.header?.[rowHeader.variant], children: (0, jsx_runtime_1.jsx)(text_1.Text, { component: component_1.TextComponentType.SPAN, customTypography: props.styles.header?.[rowHeader.variant]?.typography, children: rowHeader.label }) })), (0, jsx_runtime_1.jsx)(listDivider_1.ListDivider, { divider: dividerValue(), dividerStyles: props.styles.divider }), (0, jsx_runtime_1.jsx)(table_styled_1.ListRowHeaderPriorityStyled, { styles: props.styles, children: props.headers .filter(header => header.id !== divider?.id) .map((header, indexHeader) => { const hasExpandedIcon = indexHeader === 0; return ((0, jsx_runtime_1.jsxs)("li", { children: [header.label && ((0, jsx_runtime_1.jsx)(table_styled_1.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], lineSeparatorBottomOnHeader: props.lineSeparatorBottomOnHeader, lineSeparatorLineStyles: props.lineSeparatorLineStyles, styles: props.styles.header?.[props.headerVariant], children: (0, jsx_runtime_1.jsx)(text_1.Text, { component: component_1.TextComponentType.SPAN, customTypography: props.styles.header?.[props.headerVariant]?.typography, children: header.label }) })), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)(table_styled_1.ListItemHeaderPriorityStyled, { borderPosition: props.value.rowBorderPosition, customAlign: getCellTokenValue({ headerValue: header, token: 'align' }) || header?.config?.alignValue?.[props.device] || header?.config?.alignValue || header?.config?.alignHeader?.[props.device] || header?.config?.alignHeader, customBackgroundColor: getCellTokenValue({ headerValue: header, token: 'backgroundColor' }) ?? props.value.backgroundColor, customWidth: header?.config?.width, "data-testid": `${props.dataTestId}-item-list-${indexHeader}`, flexWidth: header?.config?.flexWidth, hasSomeExpandedContent: props.hasSomeExpandedContent, lineSeparatorLineStyles: props.lineSeparatorLineStyles, styles: props.styles.bodyRows?.[rowVariant], children: [hasExpandedIcon && hasExpandedContentRow && ((0, jsx_runtime_1.jsx)(table_styled_1.TableExpandedButton, { "aria-label": getExpandedAria(), styles: props.styles.bodyRows?.[rowVariant], type: type_1.ButtonType.BUTTON, onClick: () => { props.onExpandedContentOpen?.(!showExpandedContent, getValue(header), indexHeader); handleShowExpandedContent(!showExpandedContent); }, children: (0, jsx_runtime_1.jsx)(elementOrIcon_1.ElementOrIcon, { customIconStyles: props.styles.bodyRows?.[rowVariant]?.accordionIcon, rotate: showExpandedContent ? '180deg' : '0deg', ...props.accordionIcon }) })), getValue(header), hasExpandedIcon && hasExpandedContentRow && ((0, jsx_runtime_1.jsx)(table_styled_1.ListItemExpandedStyled, { showExpandedContent: showExpandedContent, styles: props.styles.bodyRows?.[rowVariant], children: showExpandedContent && props.value.expandedContent ? props.value.expandedContent[props.device] : props.expandedContentHelpMessage }))] }) })] }, indexHeader)); }) })] })); }; exports.ListRowHeaderPriority = ListRowHeaderPriority; //# sourceMappingURL=listRowHeaderPriority.js.map