Skip to content

Commit 290bf6f

Browse files
committed
Reorganize exports
1 parent f2aff46 commit 290bf6f

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Add the package with the package manager of choice to your project:
1212

1313
### TypeScript
1414
```
15-
import { DSVImport, ColumnsType, TablePreview, TextareaInput } from 'react-dsv-import';
15+
import { DSVImport, ColumnsType } from 'react-dsv-import';
1616
1717
type BasicType = { forename: string; surname: string; email: string };
1818
@@ -23,14 +23,14 @@ const columns: ColumnsType<BasicType> = [
2323
];
2424
2525
<DSVImport<BasicType> columns={columns}>
26-
<TextareaInput />
27-
<TablePreview />
26+
<DSVImport.TextareaInput />
27+
<DSVImport.TablePreview />
2828
</DSVImport>
2929
```
3030

3131
### JavaScript
3232
```
33-
import { DSVImport, TablePreview, TextareaInput } from 'react-dsv-import';
33+
import { DSVImport } from 'react-dsv-import';
3434
3535
const columns = [
3636
{ key: 'forename', label: 'Forename' },
@@ -39,8 +39,8 @@ const columns = [
3939
];
4040
4141
<DSVImport columns={columns}>
42-
<TextareaInput />
43-
<TablePreview />
42+
<DSVImport.TextareaInput />
43+
<DSVImport.TablePreview />
4444
</DSVImport>
4545
```
4646

@@ -53,6 +53,7 @@ The most important features of this component are:
5353
- ✅ Type definitions and type safety
5454
- ✅ DSV format detection
5555
- ✅ Fully compositable
56+
- ❌ Automatic testing with >90% coverage
5657
- ❌ Input validation
5758
-[Material UI](https://material-ui.com/) integration
5859
-[ant.design](https://ant.design/) integration

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"react"
88
],
99
"homepage": "https://openscript.github.io/react-dsv-import/",
10-
"version": "0.1.1",
10+
"version": "0.1.2",
1111
"main": "dist/index.js",
1212
"module": "dist/es/index.js",
1313
"types": "dist/index.d.ts",

src/DSVImport.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { DSVImport, ColumnsType, TablePreview, TextareaInput } from './';
2+
import { DSVImport, ColumnsType } from './';
33
import { action } from '@storybook/addon-actions';
44

55
export default { title: 'Usage' };
@@ -17,8 +17,8 @@ const onChangeAction = action('Parsed value has changed');
1717
export const BasicUsage = () => {
1818
return (
1919
<DSVImport<BasicType> columns={columns} onChange={onChangeAction}>
20-
<TextareaInput />
21-
<TablePreview />
20+
<DSVImport.TextareaInput />
21+
<DSVImport.TablePreview />
2222
</DSVImport>
2323
);
2424
};

src/index.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
// composite
2-
export * from './DSVImport';
1+
import { TextareaInput } from './components/inputs/TextareaInput';
2+
import { TablePreview } from './components/previews/TablePreview';
3+
import { DSVImport as Import } from './DSVImport';
34

4-
// components
5-
export * from './components/inputs/TextareaInput';
6-
export * from './components/previews/TablePreview';
5+
import { ColumnsType } from './models/column';
6+
import { PropsWithChildren } from 'react';
77

8-
// features
9-
export { useDSVImport } from './features/context';
8+
interface Props<T> {
9+
onChange?: (value: T[]) => void;
10+
columns: ColumnsType<T>;
11+
}
1012

11-
// models
12-
export * from './models/column';
13+
export function DSVImport<T extends { [key: string]: string }>(props: PropsWithChildren<Props<T>>) {
14+
return Import<T>(props);
15+
}
16+
17+
DSVImport.TextareaInput = TextareaInput;
18+
DSVImport.TablePreview = TablePreview;
19+
20+
export { ColumnsType } from './models/column';

0 commit comments

Comments
 (0)