Skip to content

Commit

Permalink
export modules
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Aug 14, 2019
1 parent 3a70324 commit 291be50
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 37 deletions.
2 changes: 2 additions & 0 deletions src/CheckGroupField/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default as createStyles } from './CheckGroupField.styles';

export { default } from './CheckGroupField';
2 changes: 2 additions & 0 deletions src/CheckLabelField/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default as createStyles } from './CheckLabelField.styles';

export { default } from './CheckLabelField';
2 changes: 2 additions & 0 deletions src/DownshiftMultiSelect/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default as createStyles } from './DownshiftMultiSelect.styles';

export { default } from './DownshiftMultiSelect';
8 changes: 4 additions & 4 deletions src/TabsField/TabsField.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Component = ({
);
};

const TabsForm = ({
const TabsField = ({
initialTab,
name,
tabs,
Expand Down Expand Up @@ -64,7 +64,7 @@ const TabsForm = ({
);
};

TabsForm.propTypes = {
TabsField.propTypes = {
tabs: PropTypes.arrayOf(
PropTypes.shape({
value: PropTypes.string.isRequired,
Expand All @@ -74,10 +74,10 @@ TabsForm.propTypes = {
TabsProps: PropTypes.shape({}),
SingleTabProps: PropTypes.shape({}),
};
TabsForm.defaultProps = {
TabsField.defaultProps = {
initialTab: undefined,
TabsProps: {},
SingleTabProps: {},
};

export default TabsForm;
export default TabsField;
2 changes: 1 addition & 1 deletion src/TabsField/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './TabsForm';
export { default } from './TabsField';
22 changes: 18 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import React from 'react';

const MyComponent = () => <h1>Hello World! This is my component!</h1>;
import InputBaseField from './InputBaseField';
import TextField from './TextField';
import MultiSelectField from './MultiSelectField';
import DownshiftSelectField from './DsSelectField';
import DownshiftMultiSelectField from './DsMultiSelectField';
import CheckGroupField from './CheckGroupField';
import CheckLabelField from './CheckLabelField';
import RadioGroupField from './RadioGroupField';
import TabsField from './TabsField';

module.exports = {
MyComponent,
InputBaseField,
TextField,
MultiSelectField,
DownshiftSelectField,
DownshiftMultiSelectField,
CheckGroupField,
CheckLabelField,
RadioGroupField,
TabsField,
};
4 changes: 2 additions & 2 deletions stories/form.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ storiesOf('Form', module)
.add('Login form', () => <LoginForm />)
.add('Sign Up Form', () => <SignUpForm />)
.add('Language Form', () => <LanguageForm />)
.add('Profile Form', () => <ProfileForm />)
.add('Array Form', () => <ArrayForm />)
.add('Profile Form', () => <ProfileForm />);
// .add('Array Form', () => <ArrayForm />)

// import { Button, Welcome } from '@storybook/react/demo';

Expand Down
13 changes: 3 additions & 10 deletions stories/forms/ArrayForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@ const schema = Yup.object().shape({
});

const ArrayForm = () => (
<Form
initialValues={{ friends: [] }}
validationSchema={schema}
onSubmit={values => console.log('values', values)}
>
<Form initialValues={{ friends: [] }} validationSchema={schema}>
{({ values, errors, touched }) => {
console.log('values', values);
console.log('touched', touched);
console.log('errors', errors);
return (
<FieldArray name={'friends'}>
{arrayHelpers => (
Expand All @@ -51,13 +44,13 @@ const ArrayForm = () => (
type="button"
onClick={() => arrayHelpers.insert(index, '')} // insert an empty string at a position
>
<Add/>
<Add />
</IconButton>
<IconButton
type="button"
onClick={() => arrayHelpers.remove(index)} // remove a friend from the list
>
<Delete/>
<Delete />
</IconButton>
</Box>
))
Expand Down
7 changes: 3 additions & 4 deletions stories/forms/LanguageForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import * as Yup from 'yup';
import Form from './Form';
import TextField from '../../src/TextField';
import TabsForm from '../../src/TabsForm';
import TabsField from '../../src/TabsField';

const validationSchema = Yup.object().shape({
name: Yup.object().shape({
Expand All @@ -20,10 +20,9 @@ const LanguageForm = () => {
th: '',
},
}}
onSubmit={console.log}
validationSchema={validationSchema}
>
<TabsForm
<TabsField
name={'name'}
tabs={[
{ label: 'English', value: 'en' },
Expand All @@ -37,7 +36,7 @@ const LanguageForm = () => {
label={tab}
/>
)}
</TabsForm>
</TabsField>
</Form>
);
};
Expand Down
5 changes: 0 additions & 5 deletions stories/forms/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ const LoginForm = () => (
<Form
validationSchema={validationSchema}
initialValues={{ email: '', password: '' }}
onSubmit={(values, actions) => {
console.log('values', values);
console.log('actions', actions);
actions.setSubmitting(false);
}}
>
<TextField {...TextField.baseProps} name="email" label="Email" required />
<TextField
Expand Down
7 changes: 3 additions & 4 deletions stories/forms/ProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import * as Yup from 'yup';
import Link from '@material-ui/core/Link';
import Form from './Form';
import TabsForm from '../../src/TabsForm';
import TabsField from '../../src/TabsField';
import TextField from '../../src/TextField';
import CheckLabelField from '../../src/CheckLabelField';
import DsSelectField from '../../src/DsSelectField';
Expand Down Expand Up @@ -48,9 +48,8 @@ const ProfileForm = () => (
accepted: false,
}}
validationSchema={validationSchema}
onSubmit={values => console.log(values)}
>
<TabsForm
<TabsField
name={'profile'}
tabs={[
{ label: 'Basic info', value: 'basicInfo' },
Expand Down Expand Up @@ -97,7 +96,7 @@ const ProfileForm = () => (
)}
</>
)}
</TabsForm>
</TabsField>
<CheckLabelField
{...CheckLabelField.baseProps}
name={'accepted'}
Expand Down
3 changes: 0 additions & 3 deletions stories/forms/SignUpForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ const SignUpForm = () => (
confirmedPassword: '',
accepted: false,
}}
onSubmit={values => {
console.log('values', values);
}}
validationSchema={validationSchema}
>
<TextField {...TextField.baseProps} name="email" label="Email" required />
Expand Down

0 comments on commit 291be50

Please sign in to comment.