Skip to content

Commit

Permalink
fix(Table): Solved TS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Pinedo committed Nov 24, 2023
1 parent 8da3740 commit d7e12cd
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 116 deletions.
5 changes: 5 additions & 0 deletions packages/table/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { VirtualItem } from '@tanstack/react-virtual';
import { ColDef } from './declarations';

export const DEFAULT_VIRTUAL_ROW: VirtualItem = {
index: 0,
Expand All @@ -17,3 +18,7 @@ export const DEFAULT_VIRTUAL_COLUMN: VirtualItem = {
lane: 2,
key: 'example',
};

export const DEFAULT_COLDEF: ColDef = {
id: 'col',
};
7 changes: 4 additions & 3 deletions packages/table/src/core/HeaderCell/HeaderCell.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Meta, StoryObj } from '@storybook/react';
import { HeaderCell } from './HeaderCell';
import { DEFAULT_VIRTUAL_COLUMN } from '../../constants';
import { DEFAULT_COLDEF } from '../../constants';

const meta: Meta<typeof HeaderCell> = {
title: 'Components/Table/Header Cell',
Expand All @@ -16,8 +16,9 @@ export const Base: Story = {
(() => {
return (
<HeaderCell
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
headerName={'Column header'}
colDef={DEFAULT_COLDEF}
headerCellWidth={300}
offsetX={30}
/>
);
})(),
Expand Down
1 change: 1 addition & 0 deletions packages/table/src/core/Row/Row.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const Base: Story = {
columnDefs={colDefs}
data={data[0]}
columnVirtualizer={columnVirtualizer}
even
/>
);
})(),
Expand Down
9 changes: 1 addition & 8 deletions packages/table/src/editors/CustomCell.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ColDef } from '../declarations';
import { Cell } from '../core/Cell';
import { CustomCellEditor } from './CustomCellEditorCase';
import { TextRenderer } from '../renderers';
import { DEFAULT_VIRTUAL_COLUMN } from '../constants';

const meta: Meta<typeof Cell> = {
title: 'Components/Table/Cell/Edit/Custom',
Expand Down Expand Up @@ -35,12 +34,6 @@ export const UsingACustomCellEditor: Story = {
editable: true,
};

return (
<Cell
columnDef={customEditorDef}
data={text}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={customEditorDef} data={text} />;
})(),
};
9 changes: 1 addition & 8 deletions packages/table/src/editors/EditBoolean.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ColDef } from '../declarations';
import { EditBoolean } from '.';
import { Cell } from '../core/Cell';
import { TagRenderer } from '../renderers';
import { DEFAULT_VIRTUAL_COLUMN } from '../constants';

const meta: Meta<typeof Cell> = {
title: 'Components/Table/Cell/Edit/Tag',
Expand Down Expand Up @@ -32,12 +31,6 @@ export const BooleanEditor: Story = {
editable: true,
};

return (
<Cell
columnDef={columnEditBoolean}
data={boolean}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnEditBoolean} data={boolean} />;
})(),
};
9 changes: 1 addition & 8 deletions packages/table/src/editors/EditDate.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { EditDate } from '.';
import { Cell } from '../core/Cell';
import { dateFormatter } from '../valueFormatters/date';
import { TextRenderer } from '../renderers';
import { DEFAULT_VIRTUAL_COLUMN } from '../constants';

const meta: Meta<typeof Cell> = {
title: 'Components/Table/Cell/Edit/Date',
Expand Down Expand Up @@ -42,12 +41,6 @@ export const Base: Story = {
editable: true,
};

return (
<Cell
columnDef={columnEditDate}
data={date}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnEditDate} data={date} />;
})(),
};
9 changes: 1 addition & 8 deletions packages/table/src/editors/EditNumber.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ColDef } from '../declarations';
import { EditNumber } from '.';
import { Cell } from '../core/Cell';
import { NumberRenderer } from '../renderers';
import { DEFAULT_VIRTUAL_COLUMN } from '../constants';

const meta: Meta<typeof Cell> = {
title: 'Components/Table/Cell/Edit/Number',
Expand Down Expand Up @@ -34,12 +33,6 @@ export const NumberEditor: Story = {
CellRenderer: NumberRenderer,
editable: true,
};
return (
<Cell
columnDef={columnEditTextNumber}
data={number}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnEditTextNumber} data={number} />;
})(),
};
9 changes: 1 addition & 8 deletions packages/table/src/editors/EditTags.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { EditTags } from '.';
import { Cell } from '../core/Cell';
import { TagProps } from 'packages/core/dist/types/src';
import { TagsRenderer } from '../renderers';
import { DEFAULT_VIRTUAL_COLUMN } from '../constants';

const meta: Meta<typeof Cell> = {
title: 'Components/Table/Cell/Edit/Tags',
Expand Down Expand Up @@ -48,12 +47,6 @@ export const TagsEditor: Story = {
CellRenderer: TagsRenderer,
editable: true,
};
return (
<Cell
columnDef={columnEditTags}
data={tags}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnEditTags} data={tags} />;
})(),
};
17 changes: 2 additions & 15 deletions packages/table/src/editors/EditText.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ColDef } from '../declarations';
import { EditText, EditTextArea } from '.';
import { Cell } from '../core/Cell';
import { TextRenderer } from '../renderers';
import { DEFAULT_VIRTUAL_COLUMN } from '../constants';

const meta: Meta<typeof Cell> = {
title: 'Components/Table/Cell/Edit/Text',
Expand Down Expand Up @@ -35,13 +34,7 @@ export const Base: Story = {
editable: true,
};

return (
<Cell
columnDef={columnEditText}
data={text}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnEditText} data={text} />;
})(),
};

Expand Down Expand Up @@ -71,12 +64,6 @@ export const TextAreaEditor: Story = {
editable: true,
};

return (
<Cell
columnDef={columnEditTextArea}
data={text}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnEditTextArea} data={text} />;
})(),
};
17 changes: 2 additions & 15 deletions packages/table/src/renderers/number/Number.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Cell } from '../../core/Cell';
import { ColDef } from '../../declarations';
import { NumberRenderer } from './Number';
import { linkFormatter } from '../../valueFormatters';
import { DEFAULT_VIRTUAL_COLUMN } from '../../constants';

const data = Holo.of()
.schema({
Expand Down Expand Up @@ -41,25 +40,13 @@ type Story = StoryObj<typeof Cell>;
export const Base: Story = {
render: () =>
(() => {
return (
<Cell
columnDef={column}
data={data[0][column.id]}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={column} data={data[0][column.id]} />;
})(),
};

export const NumberLink: Story = {
render: () =>
(() => {
return (
<Cell
columnDef={columnLink}
data={data[0][columnLink.id]}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnLink} data={data[0][columnLink.id]} />;
})(),
};
15 changes: 2 additions & 13 deletions packages/table/src/renderers/tag/Tag.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Holo } from '@devoinc/holo';
import { Cell } from '../../core/Cell';
import { ColDef } from '../../declarations';
import { TagRenderer } from './Tag';
import { DEFAULT_VIRTUAL_COLUMN } from '../../constants';

const data = Holo.of()
.schema({
Expand Down Expand Up @@ -50,24 +49,14 @@ export const BooleanRenderer: Story = {
render: () =>
(() => {
return (
<Cell
columnDef={columnBoolean}
data={data[0][columnBoolean.id]}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
<Cell columnDef={columnBoolean} data={data[0][columnBoolean.id]} />
);
})(),
};

export const Status: Story = {
render: () =>
(() => {
return (
<Cell
columnDef={columnStatus}
data={data[0][columnStatus.id]}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnStatus} data={data[0][columnStatus.id]} />;
})(),
};
9 changes: 1 addition & 8 deletions packages/table/src/renderers/tags/Tags.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Holo } from '@devoinc/holo';
import { Cell } from '../../core/Cell';
import { ColDef } from '../../declarations';
import { TagsRenderer } from './Tags';
import { DEFAULT_VIRTUAL_COLUMN } from '../../constants';

const data = Holo.of()
.schema({
Expand Down Expand Up @@ -40,12 +39,6 @@ type Story = StoryObj<typeof Cell>;
export const Base: Story = {
render: () =>
(() => {
return (
<Cell
columnDef={column}
data={data[0][column.id]}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={column} data={data[0][column.id]} />;
})(),
};
25 changes: 3 additions & 22 deletions packages/table/src/renderers/text/Text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Cell } from '../../core/Cell';
import { ColDef } from '../../declarations';
import { TextRenderer } from './Text';
import { dateFormatter, linkFormatter } from '../../valueFormatters';
import { DEFAULT_VIRTUAL_COLUMN } from '../../constants';

const data = Holo.of()
.schema({
Expand Down Expand Up @@ -53,38 +52,20 @@ type Story = StoryObj<typeof Cell>;
export const Base: Story = {
render: () =>
(() => {
return (
<Cell
columnDef={column}
data={data[0][column.id]}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={column} data={data[0][column.id]} />;
})(),
};

export const DateFormat: Story = {
render: () =>
(() => {
return (
<Cell
columnDef={columnDate}
data={data[0][columnDate.id]}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnDate} data={data[0][columnDate.id]} />;
})(),
};

export const LinkFormat: Story = {
render: () =>
(() => {
return (
<Cell
columnDef={columnLink}
data={data[0][columnLink.id]}
virtualColumn={DEFAULT_VIRTUAL_COLUMN}
/>
);
return <Cell columnDef={columnLink} data={data[0][columnLink.id]} />;
})(),
};

0 comments on commit d7e12cd

Please sign in to comment.