Skip to content

Commit 0f55dbc

Browse files
committed
last review & cleanup
1 parent 7662c4b commit 0f55dbc

3 files changed

Lines changed: 30 additions & 35 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "react-step-builder",
33
"description": "Unopinionated multi step interface builder.",
44
"author": "Samet Mutevelli <mutevellisamet@gmail.com> (https://sametmutevelli.com)",
5-
"version": "2.0.3",
5+
"version": "2.0.4",
66
"private": false,
77
"main": "src/dist/index",
88
"types": "src/dist/index.d.ts",

src/lib-ts/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/first */
21
import React, {
32
ComponentType,
43
DetailedHTMLProps,
@@ -27,7 +26,7 @@ type StepsProps = {
2726
children: ReactElement<StepProps> | ReactElement<StepProps>[];
2827
};
2928

30-
type BeforeStepChange = (...data: any[]) => any;
29+
type BeforeStepChange = () => any;
3130

3231
interface StepProps {
3332
title?: string;
@@ -40,11 +39,14 @@ interface StepProps {
4039
type EventType = React.ChangeEvent<HTMLInputElement> &
4140
React.ChangeEvent<HTMLTextAreaElement>;
4241

43-
type AllSteps = { order: number; title?: string }[];
42+
type AllSteps = { order: number; title: string }[];
4443
type OrderCheckFn = () => boolean;
4544
type MoveFn = () => void;
4645
type JumpFn = (step: number) => void;
47-
type GetState = (key: keyof State, defaultValue: State[keyof State]) => any;
46+
type GetState = (
47+
key: keyof State,
48+
defaultValue: State[keyof State],
49+
) => InputValue | CheckboxValue;
4850
type SetState = (key: keyof State, value: State[keyof State]) => void;
4951
type HandleChange = (event: EventType) => void;
5052

@@ -109,7 +111,7 @@ const StepsContext = React.createContext<StepsContext>({
109111
state: {},
110112
handleChange: (event) => {},
111113
setState: (key, value) => {},
112-
getState: (key, defaultValue) => {},
114+
getState: (key, defaultValue) => "" || false || defaultValue,
113115
next: () => {},
114116
prev: () => {},
115117
jump: (id) => {},
@@ -242,7 +244,7 @@ export function Step<T extends StepProps>(props: T) {
242244
}, [current, order, beforeStepChange]);
243245

244246
if (order === current) {
245-
const newProps: Partial<StepProps> = Object.assign({}, props);
247+
const newProps: Partial<T> = Object.assign({}, props);
246248
delete newProps.component;
247249

248250
const defaultTitle = "Step " + order;

tsconfig.json

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
{
2-
"compilerOptions": {
3-
"target": "es6",
4-
"module": "esnext",
5-
"jsx": "react",
6-
"declaration": true,
7-
"declarationMap": true,
8-
"sourceMap": true,
9-
"outDir": "src/lib",
10-
"strict": true,
11-
"esModuleInterop": true,
12-
"skipLibCheck": true,
13-
"forceConsistentCasingInFileNames": true,
14-
"lib": [
15-
"dom",
16-
"dom.iterable",
17-
"esnext"
18-
],
19-
"allowJs": true,
20-
"allowSyntheticDefaultImports": true,
21-
"moduleResolution": "node",
22-
"resolveJsonModule": true,
23-
"isolatedModules": true,
24-
"noEmit": true
25-
},
26-
"include": [
27-
"src/lib-ts/**/*.ts",
28-
"src/lib-ts/**/*.tsx"
29-
]
2+
"compilerOptions": {
3+
"target": "es6",
4+
"module": "esnext",
5+
"jsx": "react",
6+
"declaration": true,
7+
"declarationMap": true,
8+
"sourceMap": true,
9+
"outDir": "src/lib",
10+
"strict": true,
11+
"esModuleInterop": true,
12+
"skipLibCheck": true,
13+
"forceConsistentCasingInFileNames": true,
14+
"lib": ["dom", "dom.iterable", "esnext"],
15+
"allowJs": true,
16+
"allowSyntheticDefaultImports": true,
17+
"moduleResolution": "node",
18+
"resolveJsonModule": true,
19+
"isolatedModules": true,
20+
"noEmit": false
21+
},
22+
"include": ["src/lib-ts/**/*.ts", "src/lib-ts/**/*.tsx"]
3023
}

0 commit comments

Comments
 (0)