primevue-mirror/components/lib/datatable/style/DataTableStyle.js

158 lines
6.6 KiB
JavaScript
Raw Normal View History

import BaseStyle from 'primevue/base/style';
const classes = {
2024-04-28 21:54:19 +00:00
root: ({ props }) => [
'p-datatable p-component',
{
2024-04-28 21:54:19 +00:00
'p-datatable-hoverable': props.rowHover || props.selectionMode,
'p-datatable-resizable': props.resizableColumns,
'p-datatable-resizable-fit': props.resizableColumns && props.columnResizeMode === 'fit',
'p-datatable-scrollable': props.scrollable,
'p-datatable-flex-scrollable': props.scrollable && props.scrollHeight === 'flex',
'p-datatable-striped': props.stripedRows,
'p-datatable-gridlines': props.showGridlines,
'p-datatable-sm': props.size === 'small',
'p-datatable-lg': props.size === 'large'
}
],
2024-04-28 21:54:19 +00:00
loadingOverlay: 'p-datatable-mask p-component-overlay',
loadingIcon: 'p-datatable-loading-icon',
header: 'p-datatable-header',
2024-04-28 21:54:19 +00:00
paginator: ({ position }) => 'p-datatable-paginator-' + position,
wrapper: 'p-datatable-table-container',
table: ({ props }) => [
'p-datatable-table',
{
'p-datatable-scrollable-table': props.scrollable,
'p-datatable-resizable-table': props.resizableColumns,
'p-datatable-resizable-table-fit': props.resizableColumns && props.columnResizeMode === 'fit'
}
],
thead: 'p-datatable-thead',
headerCell: ({ instance, props, column }) =>
column && !instance.columnProp(column, 'hidden') && (props.rowGroupMode !== 'subheader' || props.groupRowsBy !== instance.columnProp(column, 'field'))
? [
{
2024-04-28 21:54:19 +00:00
'p-datatable-frozen-column': instance.columnProp(column, 'frozen')
}
]
: [
{
2024-04-28 21:54:19 +00:00
'p-datatable-sortable-column': instance.columnProp('sortable'),
'p-datatable-resizable-column': instance.resizableColumns,
'p-datatable-column-sorted': instance.isColumnSorted(),
'p-datatable-frozen-column': instance.columnProp('frozen'),
'p-datatable-reorderable-column': props.reorderableColumns
}
],
2024-04-28 21:54:19 +00:00
columnResizer: 'p-datatable-column-resizer',
headerContent: 'p-datatable-column-header-content',
headerTitle: 'p-datatable-column-title',
sortIcon: 'p-datatable-sortable-column-icon',
sortBadge: 'p-datatable-sortable-column-badge',
columnFilter: ({ props }) => [
2024-04-28 21:54:19 +00:00
'p-datatable-filter',
{
2024-04-28 21:54:19 +00:00
'p-datatable-inline-filter': props.display === 'row',
'p-datatable-popover-filter': props.display === 'menu'
}
],
2024-04-28 21:54:19 +00:00
filterInput: 'p-datatable-filter-element-container',
2024-04-29 08:26:15 +00:00
filterMenuButton: 'p-datatable-column-filter-button',
2024-04-28 21:54:19 +00:00
headerFilterClearButton: 'p-datatable-column-filter-clear-button',
filterOverlay: ({ instance, props }) => [
2024-04-28 21:54:19 +00:00
'p-datatable-filter-overlay p-component',
{
2024-04-28 21:54:19 +00:00
'p-datatable-filter-overlay-popover': props.display === 'menu',
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
2024-04-28 21:54:19 +00:00
filterRowItems: 'p-datatable-filter-constraint-list',
filterRowItem: ({ instance, matchMode }) => [
2024-04-28 21:54:19 +00:00
'p-datatable-filter-constraint',
{
2024-04-28 21:54:19 +00:00
'p-datatable-filter-constraint-selected': matchMode && instance.isRowMatchModeSelected(matchMode.value)
}
],
2024-04-28 21:54:19 +00:00
filterSeparator: 'p-datatable-filter-constraint-separator',
filterOperator: 'p-datatable-filter-operator',
filterOperatorDropdown: 'p-datatable-filter-operator-dropdown',
filterConstraints: 'p-datatable-filter-rule-list',
filterConstraint: 'p-datatable-filter-rule',
filterMatchModeDropdown: 'p-datatable-filter-constraint-dropdown',
filterRemoveButton: 'p-datatable-filter-remove-rule-button',
filterAddRule: 'p-datatable-filter-add-rule-button', //TODO: Remove
filterAddRuleButton: 'p-column-filter-add-button',
2024-04-28 21:54:19 +00:00
filterButtonbar: 'p-datatable-filter-buttonbar',
filterClearButton: 'p-datatable-filter-clear-button',
filterApplyButton: 'p-datatable-filter-apply-button',
tbody: ({ props }) => (props.frozenRow ? 'p-datatable-tbody p-datatable-frozen-tbody' : 'p-datatable-tbody'),
2024-04-28 21:54:19 +00:00
rowgroupHeader: 'p-datatable-row-group-header',
rowGroupToggler: 'p-datatable-row-group-toggle',
rowGroupTogglerIcon: 'p-row-toggler-icon', //TODO: Remove
2024-02-02 20:17:35 +00:00
row: ({ instance, props, index, columnSelectionMode }) => {
let rowStyleClass = [];
if (props.selectionMode) {
2024-04-28 21:54:19 +00:00
rowStyleClass.push('p-datatable-selectable-row');
}
if (props.selection) {
rowStyleClass.push({
2024-04-28 21:54:19 +00:00
'p-datatable-row-selected': columnSelectionMode ? instance.isSelected && instance.$parentInstance.$parentInstance.highlightOnSelect : instance.isSelected
});
}
if (props.contextMenuSelection) {
rowStyleClass.push({
2024-04-28 21:54:19 +00:00
'p-datatable-contextmenu-row-selected': instance.isSelectedWithContextMenu
});
}
rowStyleClass.push(index % 2 === 0 ? 'p-row-even' : 'p-row-odd');
return rowStyleClass;
},
rowExpansion: 'p-datatable-row-expansion',
2024-04-28 21:54:19 +00:00
rowgroupFooter: 'p-datatable-row-group-footer',
emptyMessage: 'p-datatable-emptymessage',
bodyCell: ({ instance }) => [
{
2024-04-28 21:54:19 +00:00
'p-datatable-frozen-column': instance.columnProp('frozen')
}
],
2024-04-28 21:54:19 +00:00
columnTitle: 'p-column-title', //TODO: Remove due to stacked mode
rowReorderIcon: 'p-datatable-reorderable-row-handle',
rowToggler: 'p-datatable-row-toggle',
rowTogglerIcon: 'p-row-toggler-icon', //TODO: Remove
rowEditorInitButton: 'p-datatable-row-editor-init',
rowEditorInitIcon: 'p-row-editor-init-icon', //TODO: Remove
rowEditorSaveButton: 'p-datatable-row-editor-save',
rowEditorSaveIcon: 'p-row-editor-save-icon', //TODO: Remove
rowEditorCancelButton: 'p-datatable-row-editor-cancel',
rowEditorCancelIcon: 'p-row-editor-cancel-icon', //TODO: Remove
tfoot: 'p-datatable-tfoot',
footerCell: ({ instance }) => [
{
2024-04-28 21:54:19 +00:00
'p-datatable-frozen-column': instance.columnProp('frozen')
}
],
virtualScrollerSpacer: 'p-datatable-virtualscroller-spacer',
footer: 'p-datatable-footer',
2024-04-28 21:54:19 +00:00
resizeHelper: 'p-datatable-column-resize-indicator',
reorderIndicatorUp: 'p-datatable-row-reorder-indicator-up',
reorderIndicatorDown: 'p-datatable-row-reorder-indicator-down'
};
const inlineStyles = {
wrapper: { overflow: 'auto' },
thead: { position: 'sticky' },
tfoot: { position: 'sticky' }
};
export default BaseStyle.extend({
name: 'datatable',
classes,
inlineStyles
});