Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export interface ModusTableRowAction {
isDisabled?: (row: unknown) => boolean;
}

export interface ModusTableRowActionConfig {
header?: string;
width?: number;
}

export interface ModusTableRowActionClick {
actionId: string;
row: unknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export interface TableContext {

rowActions: TableRowActionWithOverflow[];

rowActionSize: number;

rowActionHeader: string;

rowsExpandable: boolean;

rowSelection: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
ModusTableRowWithId,
ModusTableColumnSort,
ModusTableErrors,
ModusTableRowActionConfig,
} from './models/modus-table.models';
import ColumnDragState from './models/column-drag-state.model';
import {
Expand Down Expand Up @@ -178,6 +179,9 @@ export class ModusTable {
/** (Optional) Actions that can be performed on each row. A maximum of 4 icons will be shown, including overflow menu and expand icons. */
@Prop() rowActions: ModusTableRowAction[] = [];

/** (Optional) The width and header of the rowActionsConfig. */
@Prop() rowActionsConfig: ModusTableRowActionConfig;

/** (Optional) To display expanded rows. */
@Prop() rowsExpandable = false;
@Watch('rowsExpandable') onRowsExpandableChange(newVal: boolean) {
Expand Down Expand Up @@ -526,6 +530,8 @@ export class ModusTable {
rowSelectionChange: this.rowSelectionChange,
rowExpanded: this.rowExpanded,
rowActionClick: this.rowActionClick,
rowActionSize: this.rowActionsConfig?.width,
rowActionHeader: this.rowActionsConfig?.header,
sortChange: this.sortChange,
paginationChange: this.paginationChange,
columnSizingChange: this.columnSizingChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ export const ModusTableHeader: FunctionalComponent<ModusTableHeaderProps> = ({
rowSelection,
componentId,
rowActions,
rowActionSize,
rowActionHeader,
} = context;

const tableHeadClass = { 'show-resize-cursor': getColumnResizing(), 'show-column-reorder-cursor': columnReorder };
const headerGroups: HeaderGroup<unknown>[] = getHeaderGroups();
const rowActionsLength = Math.min(Math.max(rowActions.length * 40, 90), 160);
const rowActionsLength =
rowActionSize && rowActionSize >= 40 ? rowActionSize : Math.min(Math.max(rowActions.length * 40, 90), 160);
const rowActionsHeader = rowActionHeader ? rowActionHeader : 'Row Actions Column';
const rowActionsConfig: {
header?: string;
width?: number;
} = { header: rowActionsHeader, width: rowActionsLength };

return (
<thead class={tableHeadClass}>
Expand All @@ -56,7 +64,11 @@ export const ModusTableHeader: FunctionalComponent<ModusTableHeaderProps> = ({
/>
);
})}
{rowActions.length > 0 && <th class="sticky-right" style={{ width: `${rowActionsLength}px` }}></th>}
{rowActions.length > 0 && (
<th class="sticky-right" style={{ width: `${rowActionsConfig.width}px` }}>
{rowActionsConfig.header}
</th>
)}
</tr>
))}
</thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ export const ModusTableHeaderCheckbox: FunctionalComponent<ModusTableHeaderCheck
rowSelectionOptions,
density,
} = context;
const densityWidths = new Map<string, string>([
['compact', '38px'],
['comfortable', '46px'],
['relaxed', '46px'],
]);

let checkboxSize: 'medium' | 'small' = 'medium';
if (density === 'compact') {
checkboxSize = 'small';
}

const width = densityWidths.get(density) || '46px';
return (
<th class={'row-checkbox sticky-left ' + checkboxSize}>
<th class={'row-checkbox sticky-left ' + checkboxSize} style={{ width: width }}>
{rowSelectionOptions?.multiple && (
<modus-checkbox
ariaLabel="Select all rows"
Expand Down
1 change: 1 addition & 0 deletions stencil-workspace/src/components/modus-table/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
| `pageSizeList` | -- | | `number[]` | `PAGINATION_DEFAULT_SIZES` |
| `pagination` | `pagination` | | `boolean` | `undefined` |
| `rowActions` | -- | (Optional) Actions that can be performed on each row. A maximum of 4 icons will be shown, including overflow menu and expand icons. | `ModusTableRowAction[]` | `[]` |
| `rowActionsConfig` | -- | (Optional) The width and header of the rowActionsConfig. | `ModusTableRowActionConfig` | `undefined` |
| `rowSelection` | `row-selection` | (Optional) To display checkbox. | `boolean` | `false` |
| `rowSelectionOptions` | -- | (Optional) To control multiple row selection. | `ModusTableRowSelectionOptions` | `{ multiple: false, subRowSelection: false, }` |
| `rowsExpandable` | `rows-expandable` | (Optional) To display expanded rows. | `boolean` | `false` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,11 @@ interface ModusTableRowAction {
isDisabled?: (row: unknown) => boolean;
}

interface ModusTableRowActionConfig {
header?: string;
width?: number;
}

interface ModusTableManualPaginationOptions {
currentPageIndex: number;
currentPageSize: number;
Expand Down Expand Up @@ -937,6 +942,7 @@ Users can use keyboard navigation to perform different actions.
| `pageSizeList` | -- | | `number[]` | `PAGINATION_DEFAULT_SIZES` |
| `pagination` | `pagination` | | `boolean` | `undefined` |
| `rowActions` | -- | (Optional) Actions that can be performed on each row. A maximum of 4 icons will be shown, including overflow menu and expand icons. | `ModusTableRowAction[]` | `[]` |
| `rowActionsConfig` | -- | (Optional) The configuration for the row action's column | `ModusTableRowActionConfig` | `undefined` |
| `rowSelection` | `row-selection` | (Optional) To display checkbox. | `boolean` | `false` |
| `rowSelectionOptions` | -- | (Optional) To control multiple row selection. | `ModusTableRowSelectionOptions` | `{ multiple: false, subRowSelection: false, }` |
| `rowsExpandable` | `rows-expandable` | (Optional) To display expanded rows. | `boolean` | `false` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function initializeTable(props) {
displayOptions,
rowSelectionOptions,
rowActions,
rowActionsConfig,
manualPaginationOptions,
manualSortingOptions,
defaultSort,
Expand All @@ -77,6 +78,7 @@ function initializeTable(props) {
modusTable.displayOptions = ${JSON.stringify(displayOptions)};
modusTable.rowSelectionOptions = ${JSON.stringify(rowSelectionOptions)};
modusTable.rowActions = ${JSON.stringify(rowActions)};
modusTable.rowActionsConfig= ${JSON.stringify(rowActionsConfig)};
modusTable.manualPaginationOptions = ${JSON.stringify(manualPaginationOptions)};
modusTable.manualSortingOptions = ${JSON.stringify(manualSortingOptions)};
modusTable.defaultSort = ${JSON.stringify(defaultSort)};
Expand Down Expand Up @@ -329,6 +331,7 @@ const DefaultArgs = {
maxHeight: '',
maxWidth: '',
rowActions: [],
rowActionsConfig: {},
rowSelection: false,
rowSelectionOptions: {},
wrapText: false,
Expand Down Expand Up @@ -506,6 +509,14 @@ export default {
},
type: { required: false },
},
rowActionsConfig: {
name: 'rowActionsConfig',
description: "The configuration for the row action's column ",
table: {
type: { summary: 'ModusTableRowActionConfig' },
},
type: { required: false },
},
maxHeight: {
name: 'maxHeight',
description: 'To display a vertical scrollbar when the height is exceeded.',
Expand Down Expand Up @@ -644,6 +655,7 @@ const Template = ({
maxHeight,
maxWidth,
rowActions,
rowActionsConfig,
rowSelection,
rowSelectionOptions,
manualPaginationOptions,
Expand Down Expand Up @@ -681,6 +693,7 @@ const Template = ({
displayOptions,
rowSelectionOptions,
rowActions,
rowActionsConfig,
manualPaginationOptions,
manualSortingOptions,
defaultSort,
Expand Down Expand Up @@ -982,6 +995,10 @@ LargeDataset.args = {
export const RowActions = Template.bind({});
RowActions.args = {
...DefaultArgs,
rowActionsConfig: {
header: 'Row Actions Column',
width: 160,
},
rowActions: [
{
id: '1',
Expand Down