diff --git a/Source/DesignSystem/helpers/DummyContents/DummyDataGridContent.tsx b/Source/DesignSystem/helpers/DummyContents/DummyDataGridContent.tsx deleted file mode 100644 index d528f8acb..000000000 --- a/Source/DesignSystem/helpers/DummyContents/DummyDataGridContent.tsx +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) Aigonix. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -import React from 'react'; - -import { GridColDef } from '@mui/x-data-grid-pro'; - -import { EditCell, EditTextFieldCell, IconButton, StatusIndicator } from '@dolittle/design-system'; - -type DummyRowsProps = { - id: string; - col1?: string; - col2?: string; - col3?: string; - col4?: string; -}; - -export const dummyRows: DummyRowsProps[] = [ - { id: '1', col1: 'Row 1', col2: 'Row 1', col3: 'Row 1', col4: 'Row 1' }, - { id: '2', col1: 'Row 2', col2: 'Row 2', col3: 'Row 2', col4: 'Row 2' }, - { id: '3', col1: 'Row 3', col2: 'Row 3', col3: 'Row 3', col4: 'Row 3' }, - { id: '4', col1: 'Row 4', col2: 'Row 4', col3: 'Row 4', col4: 'Row 4' }, -]; - -export const dummyColumns: GridColDef[] = [ - { - field: 'col1', - headerName: 'Column 1', - sortable: false, - minWidth: 150, - flex: 1, - }, - { - field: 'col2', - headerName: 'Column 2', - sortable: false, - minWidth: 150, - flex: 1, - }, - { - field: 'col3', - headerName: 'Column 3', - sortable: false, - minWidth: 150, - flex: 1, - }, - { - field: 'col4', - headerName: 'Column 4', - sortable: false, - minWidth: 150, - flex: 1, - }, -]; - -export const dummyIconRows: DummyRowsProps[] = [{ id: '1' }]; - -export const dummyIconColumns: GridColDef[] = [ - { - field: 'success', - headerName: 'Status success', - sortable: false, - minWidth: 150, - flex: 1, - headerAlign: 'center', - align: 'center', - renderCell: () => , - }, - { - field: 'warning', - headerName: 'Status warning', - sortable: false, - minWidth: 150, - flex: 1, - headerAlign: 'center', - align: 'center', - renderCell: () => , - }, - { - field: 'error', - headerName: 'Status error', - sortable: false, - minWidth: 150, - flex: 1, - headerAlign: 'center', - align: 'center', - renderCell: () => , - }, - { - field: 'unknown', - headerName: 'Status unknown', - sortable: false, - minWidth: 150, - flex: 1, - headerAlign: 'center', - align: 'center', - renderCell: () => , - }, - { - field: 'download', - headerName: 'Download file', - sortable: false, - minWidth: 150, - flex: 1, - headerAlign: 'center', - align: 'center', - renderCell: () => ( - - ), - }, -]; - -export const dummyEditCellsColumns: GridColDef[] = [ - { - field: 'col1', - headerName: 'Column 1', - sortable: false, - minWidth: 150, - flex: 1, - editable: true, - renderCell: EditCell, - renderEditCell: EditTextFieldCell, - }, - { - field: 'col2', - headerName: 'Column 2', - sortable: false, - minWidth: 150, - flex: 1, - editable: true, - renderCell: EditCell, - renderEditCell: EditTextFieldCell, - }, - { - field: 'col3', - headerName: 'Column 3', - sortable: false, - minWidth: 150, - flex: 1, - editable: true, - renderCell: EditCell, - renderEditCell: EditTextFieldCell, - }, - { - field: 'col4', - headerName: 'Column 4', - sortable: false, - minWidth: 150, - flex: 1, - editable: true, - renderCell: EditCell, - renderEditCell: EditTextFieldCell, - }, -]; diff --git a/Source/DesignSystem/helpers/DummyContents/index.ts b/Source/DesignSystem/helpers/DummyContents/index.ts index 9eb5e649b..2aa78cebe 100644 --- a/Source/DesignSystem/helpers/DummyContents/index.ts +++ b/Source/DesignSystem/helpers/DummyContents/index.ts @@ -3,6 +3,5 @@ export * from './DummyAccordionsContent'; export * from './DummyArray'; -export * from './DummyDataGridContent'; export * from './DummyNavigationItems'; export * from './DummyText'; diff --git a/Source/DesignSystem/molecules/DataGrid/DataGrid.stories.tsx b/Source/DesignSystem/molecules/DataGrid/DataGrid.stories.tsx index 6ecddc9b8..37971615a 100644 --- a/Source/DesignSystem/molecules/DataGrid/DataGrid.stories.tsx +++ b/Source/DesignSystem/molecules/DataGrid/DataGrid.stories.tsx @@ -6,8 +6,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { DataGridProProps } from '@mui/x-data-grid-pro'; -import { dataTableDescription } from './helpers'; -import { dummyColumns, dummyEditCellsColumns, dummyIconColumns, dummyIconRows, dummyRows } from '../../helpers/DummyContents'; +import { dataTableDescription, dummyColumns, dummyIconRows, dummyRows, dummyEditCellColumns, dummyEditCellRows, dummyIconColumns } from './helpers'; import { DataGrid, dataGridDefaultProps } from './DataGrid'; @@ -63,8 +62,8 @@ export const Default: Story = { columns: dummyColumns, checkboxSelection: false, loading: false, - onRowClick: () => action('onRowClick'), - onCellClick: () => action('onCellClick'), + onRowClick: action('Row Clicked!'), + onCellClick: action('Cell Clicked!'), }, }; @@ -79,7 +78,7 @@ IconCells.parameters = { docs: { description: { story: `Icon buttons is found inside their own column in the table that cause a specific action to a specific row of data.
- Use Icon to display a specific icon in the table.` + Use Icon to display a specific status in the table.` }, }, }; @@ -87,9 +86,16 @@ IconCells.parameters = { export const EditableCells: Story = { args: { ...Default.args, - rows: dummyRows, - columns: dummyEditCellsColumns, + rows: dummyEditCellRows, + columns: dummyEditCellColumns, experimentalFeatures: { newEditingApi: true }, + sx: { + // Hack for secret cell active state. Otherwise size is going to be different. + '& .MuiOutlinedInput-root': { + '& .MuiSelect-select': { p: '5px 15px' }, + '& fieldset': { border: 'none' }, + }, + }, }, }; EditableCells.parameters = { @@ -112,7 +118,7 @@ EditableCells.parameters = { // export const ScrollableDataGrid = () => {}; // export const RowEditMode = () => {}; -// TODOS: +// TODO: // Add into description what is needed in every Data Table. // Add sorting guidance. // Add alignment guidance. diff --git a/Source/DesignSystem/molecules/DataGrid/EditCell.tsx b/Source/DesignSystem/molecules/DataGrid/DataGridEditCell.tsx similarity index 76% rename from Source/DesignSystem/molecules/DataGrid/EditCell.tsx rename to Source/DesignSystem/molecules/DataGrid/DataGridEditCell.tsx index 50b7b30fb..36be96e31 100644 --- a/Source/DesignSystem/molecules/DataGrid/EditCell.tsx +++ b/Source/DesignSystem/molecules/DataGrid/DataGridEditCell.tsx @@ -5,7 +5,7 @@ import React from 'react'; import { GridRenderCellParams, useGridApiContext } from '@mui/x-data-grid-pro'; -import { TextField } from '@dolittle/design-system'; +import { TextField } from '../../index'; const textFieldBorderStyles = { '& .MuiOutlinedInput-root': { @@ -21,7 +21,11 @@ const textFieldBorderStyles = { }, }; -export const EditTextFieldCell = (params: GridRenderCellParams) => { +// TODO: Gives an error at the moment. +/** + * Renders a editable text field cell in 'edit' mode in the DataGrid. + */ +export const DataGridEditCellEdit = (params: GridRenderCellParams) => { const { id, value, field } = params; const apiRef = useGridApiContext(); @@ -42,7 +46,10 @@ export const EditTextFieldCell = (params: GridRenderCellParams ); }; -export const EditCell = (params: GridRenderCellParams) => +/** + * Renders a editable text field cell in the 'view' mode in the DataGrid. + */ +export const DataGridEditCellView = (params: GridRenderCellParams) => +