Skip to content

Commit e47a679

Browse files
committed
types with exports
1 parent 16d8a77 commit e47a679

11 files changed

+226
-69
lines changed

.storybook/stories/Types/column-hiding.story.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,16 @@ import { Meta } from '@storybook/addon-docs/blocks';
88
export type ColumnHideProps = {
99
hideKey: string;
1010
};
11+
```
12+
13+
Access all feature related types:
14+
15+
```javascript
16+
import * as TYPES from '@table-library/react-table-library/types/hide';
17+
```
18+
19+
Access **all** types:
20+
21+
```javascript
22+
import * as TYPES from '@table-library/react-table-library/types';
1123
```

.storybook/stories/Types/compact-table.story.mdx

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,59 @@ import { Meta } from '@storybook/addon-docs/blocks';
55
# Compact Table
66

77
```javascript
8+
import { TableNode, TableProps, RowProps } from '@table-library/react-table-library/types/table';
9+
import { ColumnSortProps } from '@table-library/react-table-library/types/sort';
10+
import { ColumnSelectProps } from '@table-library/react-table-library/types/select';
11+
import { ColumnTreeProps } from '@table-library/react-table-library/types/tree';
12+
import { ColumnResizeProps } from '@table-library/react-table-library/types/resize';
13+
import { ColumnHideProps } from '@table-library/react-table-library/types/hide';
14+
815
export type Column = {
9-
label: string,
10-
renderCell: (node: TableNode) => React.ReactNode,
11-
resize?: ColumnResizeProps,
12-
sort?: ColumnSortProps,
13-
select?: ColumnSelectProps,
14-
tree?: ColumnTreeProps,
15-
pin?: boolean,
16-
hide?: ColumnHideProps,
17-
cellProps?: Record<string, any>,
16+
label: string;
17+
renderCell: (node: TableNode) => React.ReactNode;
18+
resize?: ColumnResizeProps;
19+
sort?: ColumnSortProps;
20+
select?: ColumnSelectProps;
21+
tree?: ColumnTreeProps;
22+
pin?: boolean;
23+
hide?: ColumnHideProps;
24+
cellProps?: Record<string, any>;
1825
};
1926

2027
export type VirtualizedOptions = {
21-
rowHeight: number | ((item: TableNode, index: number) => number),
22-
itemCount?: number,
28+
rowHeight: number | ((item: TableNode, index: number) => number);
29+
itemCount?: number;
2330
};
2431

2532
export type TableOptions = {
26-
renderBeforeTable?: () => React.ReactNode,
27-
renderAfterTable?: () => React.ReactNode,
33+
renderBeforeTable?: () => React.ReactNode;
34+
renderAfterTable?: () => React.ReactNode;
2835
};
2936

3037
export type RowOptions = {
31-
renderBeforeRow?: (node: TableNode) => React.ReactNode,
32-
renderAfterRow?: (node: TableNode) => React.ReactNode,
38+
renderBeforeRow?: (node: TableNode) => React.ReactNode;
39+
renderAfterRow?: (node: TableNode) => React.ReactNode;
3340
};
3441

3542
export type RowPropsAsObject = Omit<RowProps, 'item' | 'children'>;
3643

3744
export type CompactTableProps = TableProps & {
38-
columns: Column[],
39-
tableOptions?: TableOptions,
40-
rowProps?: RowPropsAsObject,
41-
rowOptions?: RowOptions,
42-
virtualizedOptions?: VirtualizedOptions,
45+
columns: Column[];
46+
tableOptions?: TableOptions;
47+
rowProps?: RowPropsAsObject;
48+
rowOptions?: RowOptions;
49+
virtualizedOptions?: VirtualizedOptions;
4350
};
4451
```
52+
53+
Access all feature related types:
54+
55+
```javascript
56+
import * as TYPES from '@table-library/react-table-library/types/compact';
57+
```
58+
59+
Access **all** types:
60+
61+
```javascript
62+
import * as TYPES from '@table-library/react-table-library/types';
63+
```

.storybook/stories/Types/composed-table.story.mdx

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,84 @@ import { Meta } from '@storybook/addon-docs/blocks';
55
# Composed Table
66

77
```javascript
8+
import * as React from 'react';
9+
10+
import { Nullish } from '@table-library/react-table-library/types/common';
11+
import { Theme } from '@table-library/react-table-library/types/theme';
12+
import { Layout } from '@table-library/react-table-library/types/layout';
13+
import { ColumnResizeProps } from '@table-library/react-table-library/types/resize';
14+
import { Select } from '@table-library/react-table-library/types/select';
15+
import { Tree } from '@table-library/react-table-library/types/tree';
16+
import { Sort } from '@table-library/react-table-library/types/sort';
17+
import { Pagination } from '@table-library/react-table-library/types/pagination';
18+
819
export type RestProps = Record<string, any>;
920

1021
export type OnClick = (node: TableNode, event: React.SyntheticEvent | React.KeyboardEvent) => void;
1122

1223
export type CellProps = {
13-
className?: string,
14-
hide?: boolean,
15-
pin?: boolean,
16-
stiff?: boolean,
17-
onClick?: (event: React.SyntheticEvent) => void,
18-
children: React.ReactNode,
24+
className?: string;
25+
hide?: boolean;
26+
pin?: boolean;
27+
stiff?: boolean;
28+
onClick?: (event: React.SyntheticEvent) => void;
29+
children: React.ReactNode;
1930
} & RestProps;
2031

2132
export type HeaderCellProps = {
22-
index?: number,
23-
hideKey?: string,
24-
className?: string,
25-
hide?: boolean,
26-
pin?: boolean,
27-
stiff?: boolean,
28-
resize?: ColumnResizeProps,
29-
children: React.ReactNode,
33+
index?: number;
34+
hideKey?: string;
35+
className?: string;
36+
hide?: boolean;
37+
pin?: boolean;
38+
stiff?: boolean;
39+
resize?: ColumnResizeProps;
40+
children: React.ReactNode;
3041
} & RestProps;
3142

3243
export type RowProps = {
33-
item: TableNode,
34-
className?: string,
35-
disabled?: boolean,
36-
onClick?: OnClick,
37-
onDoubleClick?: OnClick,
38-
children: React.ReactNode,
44+
item: TableNode;
45+
className?: string;
46+
disabled?: boolean;
47+
onClick?: OnClick;
48+
onDoubleClick?: OnClick;
49+
children: React.ReactNode;
3950
} & RestProps;
4051

4152
export type BodyProps = {
42-
children: React.ReactNode,
53+
children: React.ReactNode;
4354
} & RestProps;
4455

4556
export type HeaderRowProps = {
46-
className?: string,
47-
children: React.ReactNode,
57+
className?: string;
58+
children: React.ReactNode;
4859
} & RestProps;
4960

5061
export type HeaderProps = {
51-
children: React.ReactNode,
62+
children: React.ReactNode;
5263
} & RestProps;
5364

5465
export type TableProps = {
55-
data: Data,
56-
theme?: Theme,
57-
layout?: Layout,
58-
sort?: Sort,
59-
pagination?: Pagination,
60-
select?: Select,
61-
tree?: Tree,
62-
onInit?: OnInitFunction,
63-
children?: (nodes: TableNode[]) => React.ReactNode,
66+
data: Data;
67+
theme?: Theme;
68+
layout?: Layout;
69+
sort?: Sort;
70+
pagination?: Pagination;
71+
select?: Select;
72+
tree?: Tree;
73+
onInit?: OnInitFunction;
74+
children?: (nodes: TableNode[]) => React.ReactNode;
6475
} & RestProps;
76+
```
77+
78+
Access all feature related types:
79+
80+
```javascript
81+
import * as TYPES from '@table-library/react-table-library/types/table';
82+
```
83+
84+
Access **all** types:
85+
86+
```javascript
87+
import * as TYPES from '@table-library/react-table-library/types';
6588
```

.storybook/stories/Types/data.story.mdx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,27 @@ Either table component needs to receive the following `Data` type as `data` prop
88

99
```javascript
1010
export type TableNode = {
11-
id: string,
12-
nodes?: TableNode[],
13-
[prop: string]: any,
11+
id: string;
12+
nodes?: TableNode[] | Nullish;
13+
[prop: string]: any;
1414
};
1515

1616
export type Data = {
17-
pageInfo?: any,
18-
nodes: TableNode[],
17+
pageInfo?: any;
18+
nodes: TableNode[];
1919
};
2020
```
2121

2222
The `pageInfo` property is optional and can be used for **server-side** features such as pagination or infinite scrolling. The implementation details (e.g. [paginated tree table](https://www.robinwieruch.de/react-tree-list/)) of it are up to you, but check out the server-side features (e.g. pagination) of this table library to get an example of it.
23+
24+
Access all feature related types:
25+
26+
```javascript
27+
import * as TYPES from '@table-library/react-table-library/types/table';
28+
```
29+
30+
Access **all** types:
31+
32+
```javascript
33+
import * as TYPES from '@table-library/react-table-library/types';
34+
```

.storybook/stories/Types/layout.story.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,16 @@ export type Layout = {
1111
hiddenColumns: string[];
1212
fullHeight?: boolean;
1313
};
14+
```
15+
16+
Access all feature related types:
17+
18+
```javascript
19+
import * as TYPES from '@table-library/react-table-library/types/layout';
20+
```
21+
22+
Access **all** types:
23+
24+
```javascript
25+
import * as TYPES from '@table-library/react-table-library/types';
1426
```

.storybook/stories/Types/pagination.story.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,16 @@ export type Pagination = {
2929
};
3030

3131
export type Pages = Record<string, TableNode[]>;
32+
```
33+
34+
Access all feature related types:
35+
36+
```javascript
37+
import * as TYPES from '@table-library/react-table-library/types/pagination';
38+
```
39+
40+
Access **all** types:
41+
42+
```javascript
43+
import * as TYPES from '@table-library/react-table-library/types';
3244
```

.storybook/stories/Types/resize.story.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,16 @@ type ColumnResizePropsObject = {
1212
};
1313

1414
export type ColumnResizeProps = ColumnResizePropsObject | boolean;
15+
```
16+
17+
Access all feature related types:
18+
19+
```javascript
20+
import * as TYPES from '@table-library/react-table-library/types/resize';
21+
```
22+
23+
Access **all** types:
24+
25+
```javascript
26+
import * as TYPES from '@table-library/react-table-library/types';
1527
```

.storybook/stories/Types/select.story.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,16 @@ export type Select = {
5656
CellSelect: React.FunctionComponent<CellSelectProps>;
5757
};
5858
};
59+
```
60+
61+
Access all feature related types:
62+
63+
```javascript
64+
import * as TYPES from '@table-library/react-table-library/types/select';
65+
```
66+
67+
Access **all** types:
68+
69+
```javascript
70+
import * as TYPES from '@table-library/react-table-library/types';
5971
```

.storybook/stories/Types/sort.story.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { Meta } from '@storybook/addon-docs/blocks';
55
# Sort
66

77
```javascript
8+
import * as React from 'react';
9+
10+
import { Nullish, State, Modifier } from '@table-library/react-table-library/types/common';
11+
import { TableNode } from '@table-library/react-table-library/types/table';
12+
813
export enum SortIconPositions {
914
Prefix,
1015
Suffix,
@@ -73,4 +78,16 @@ export type Sort = {
7378
HeaderCellSort: React.FunctionComponent<HeaderCellSortProps>;
7479
};
7580
};
81+
```
82+
83+
Access all feature related types:
84+
85+
```javascript
86+
import * as TYPES from '@table-library/react-table-library/types/sort';
87+
```
88+
89+
Access **all** types:
90+
91+
```javascript
92+
import * as TYPES from '@table-library/react-table-library/types';
7693
```

.storybook/stories/Types/theme.story.mdx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,27 @@ import { Meta } from '@storybook/addon-docs/blocks';
66

77
```javascript
88
export type Theme = {
9-
Table?: string,
10-
Header?: string,
11-
Body?: string,
12-
BaseRow?: string,
13-
HeaderRow?: string,
14-
Row?: string,
15-
BaseCell?: string,
16-
HeaderCell?: string,
17-
Cell?: string,
9+
Table?: string;
10+
Header?: string;
11+
Body?: string;
12+
BaseRow?: string;
13+
HeaderRow?: string;
14+
Row?: string;
15+
BaseCell?: string;
16+
HeaderCell?: string;
17+
Cell?: string;
1818
};
19-
```
19+
```
20+
21+
Access all feature related types:
22+
23+
```javascript
24+
import * as TYPES from '@table-library/react-table-library/types/theme';
25+
```
26+
27+
Access **all** types:
28+
29+
```javascript
30+
import * as TYPES from '@table-library/react-table-library/types';
31+
```
32+

0 commit comments

Comments
 (0)