Skip to content

Commit 103b4ef

Browse files
authored
Merge pull request #13 from openscript/develop
Enhance surface types
2 parents 5c50408 + ca55bda commit 103b4ef

18 files changed

+43
-43
lines changed

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.3.0",
10+
"version": "0.3.1",
1111
"main": "dist/index.js",
1212
"module": "dist/es/index.js",
1313
"types": "dist/index.d.ts",

src/DSVImport.stories.tsx

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

@@ -8,7 +8,7 @@ export default { title: 'Usage|Examples' };
88
type BasicType = { forename: string; surname: string; email: string };
99

1010
export const BasicUsage = () => {
11-
const columns: ColumnsType<BasicType> = [
11+
const columns: ColumnType<BasicType>[] = [
1212
{ key: 'forename', label: 'Forename' },
1313
{ key: 'surname', label: 'Surname' },
1414
{ key: 'email', label: 'Email' }
@@ -25,7 +25,7 @@ export const BasicUsage = () => {
2525
BasicUsage.story = { name: 'Basic usage' };
2626

2727
export const UsingOnChangeCallback = () => {
28-
const columns: ColumnsType<BasicType> = [
28+
const columns: ColumnType<BasicType>[] = [
2929
{ key: 'forename', label: 'Forename' },
3030
{ key: 'surname', label: 'Surname' },
3131
{ key: 'email', label: 'Email' }
@@ -58,7 +58,7 @@ const CustomTablePreview = styled(DSVImport.TablePreview)`
5858
`;
5959

6060
export const UsingOnValidationCallback = () => {
61-
const columns: ColumnsType<BasicType> = [
61+
const columns: ColumnType<BasicType>[] = [
6262
{ key: 'forename', label: 'Forename' },
6363
{ key: 'surname', label: 'Surname' },
6464
{ key: 'email', label: 'Email', rules: [{ constraint: { unique: true }, message: 'Duplicates are not allowed' }] }

src/DSVImport.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ColumnsType } from './models/column';
1+
import { ColumnType } from './models/column';
22
import { DSVImport } from '.';
33
import React from 'react';
44
import { render, fireEvent } from '@testing-library/react';
@@ -8,7 +8,7 @@ import { ValidationError } from './models/validation';
88
describe('DSVImport', () => {
99
type TestType = { forename: string; surname: string; email: string };
1010

11-
const columns: ColumnsType<TestType> = [
11+
const columns: ColumnType<TestType>[] = [
1212
{ key: 'forename', label: 'Forename' },
1313
{ key: 'surname', label: 'Surname' },
1414
{ key: 'email', label: 'Email', rules: [{ constraint: { unique: true }, message: 'Contains duplicates' }] }
@@ -17,7 +17,7 @@ describe('DSVImport', () => {
1717
interface Props<T> {
1818
onChange?: (value: T[]) => void;
1919
onValidation?: (errors: ValidationError<T>[]) => void;
20-
columns: ColumnsType<T>;
20+
columns: ColumnType<T>[];
2121
}
2222

2323
const MinimalTextareaInput: React.FC = () => {

src/DSVImport.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { PropsWithChildren, useReducer, useEffect } from 'react';
2-
import { ColumnsType } from './models/column';
2+
import { ColumnType } from './models/column';
33
import { getDSVImportContext, useDSVImport, createReducer } from './features/context';
44
import { createParserMiddleware } from './middlewares/parserMiddleware';
55
import { State } from './models/state';
@@ -33,7 +33,7 @@ const EventListener = <T extends { [key: string]: string }>(props: EventListener
3333
};
3434

3535
export interface Props<T> {
36-
columns: ColumnsType<T>;
36+
columns: ColumnType<T>[];
3737
onChange?: (value: T[]) => void;
3838
onValidation?: (errors: ValidationError<T>[]) => void;
3939
transformers?: Transformer[];

src/components/inputs/TextareaInput.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { render, fireEvent } from '@testing-library/react';
22
import { TextareaInput } from './TextareaInput';
33
import React from 'react';
4-
import { ColumnsType } from '../../models/column';
4+
import { ColumnType } from '../../models/column';
55
import { getDSVImportContext } from '../../features/context';
66
import { State } from '../../models/state';
77

88
describe('TextareaInput', () => {
9-
type TestType = {};
10-
const columns: ColumnsType<TestType> = [];
9+
type TestType = unknown;
10+
const columns: ColumnType<TestType>[] = [];
1111
const state: State<TestType> = { columns };
1212
const Context = getDSVImportContext<TestType>();
1313

src/components/previews/TablePreview.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { render } from '@testing-library/react';
22
import React from 'react';
3-
import { ColumnsType } from '../../models/column';
3+
import { ColumnType } from '../../models/column';
44
import { TablePreview } from './TablePreview';
55
import { State } from '../../models/state';
66
import { getDSVImportContext } from '../../features/context';
77

88
describe('TablePreview', () => {
99
type TestType = { forename: string; surname: string; email: string };
10-
const columns: ColumnsType<TestType> = [
10+
const columns: ColumnType<TestType>[] = [
1111
{ key: 'forename', label: 'Forename' },
1212
{ key: 'surname', label: 'Surname' },
1313
{ key: 'email', label: 'Email' }

src/features/context.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useContext } from 'react';
44
import { renderHook } from '@testing-library/react-hooks';
55

66
describe('context', () => {
7-
type TestType = {};
7+
type TestType = unknown;
88
const defaultState: State<TestType> = { columns: [] };
99

1010
it('should reduce raw data action to state', () => {

src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function DSVImport<T extends { [key: string]: string }>(props: PropsWithC
1010
DSVImport.TextareaInput = TextareaInput;
1111
DSVImport.TablePreview = TablePreview;
1212

13-
export { ColumnsType } from './models/column';
13+
export { ColumnType } from './models/column';
1414
export { useDSVImport } from './features/context';
1515
export { Rule } from './models/rule';
16+
export { Transformer } from './models/transformer';

src/middlewares/middleware.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ColumnsType } from '../models/column';
1+
import { ColumnType } from '../models/column';
22
import { State } from '../models/state';
33
import { applyMiddlewares } from './middleware';
44

55
describe('middleware', () => {
66
type TestType = { forename: string; surname: string; email: string };
7-
const columns: ColumnsType<TestType> = [
7+
const columns: ColumnType<TestType>[] = [
88
{ key: 'forename', label: 'Forename' },
99
{ key: 'surname', label: 'Surname' },
1010
{ key: 'email', label: 'Email' }

src/middlewares/parserMiddleware.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { createParserMiddleware } from './parserMiddleware';
22
import { State } from '../models/state';
3-
import { ColumnsType } from '../models/column';
3+
import { ColumnType } from '../models/column';
44
import { Delimiter } from '../models/delimiter';
55

66
describe('parserMiddleware', () => {
77
type TestType = { forename: string; surname: string; email: string };
8-
const columns: ColumnsType<TestType> = [
8+
const columns: ColumnType<TestType>[] = [
99
{ key: 'forename', label: 'Forename' },
1010
{ key: 'surname', label: 'Surname' },
1111
{ key: 'email', label: 'Email' }

0 commit comments

Comments
 (0)