Skip to content

Commit 022db25

Browse files
author
Nikita K
authored
Merge pull request #2 from kakuevn/develop
Develop
2 parents 125e55a + 820940d commit 022db25

23 files changed

+4028
-1106
lines changed

.eslintrc.json

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
{
2-
"parser": "@typescript-eslint/parser",
3-
"parserOptions": {
4-
"jsx": true,
5-
"useJSXTextNode": true
6-
},
7-
"extends": [ "plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint" ],
8-
"plugins": [ "@typescript-eslint" ],
9-
"rules": {
10-
"@typescript-eslint/explicit-function-return-type": "off",
11-
"react-hooks/rules-of-hooks": "error",
12-
"react-hooks/exhaustive-deps": "warn"
13-
}
2+
"parser": "@typescript-eslint/parser",
3+
"parserOptions": {
4+
"jsx": true,
5+
"useJSXTextNode": true
6+
},
7+
"extends": [
8+
"plugin:react/recommended",
9+
"plugin:@typescript-eslint/recommended",
10+
"prettier",
11+
"prettier/@typescript-eslint"
12+
],
13+
"plugins": ["@typescript-eslint", "react-hooks"],
14+
"rules": {
15+
"@typescript-eslint/explicit-function-return-type": "off",
16+
"react-hooks/rules-of-hooks": "warn",
17+
"react-hooks/exhaustive-deps": "warn",
18+
"@typescript-eslint/explicit-member-accessibility": "off",
19+
"array-type": "off"
20+
}
1421
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ typings/
4444
# Optional npm cache directory
4545
.npm
4646
.vs
47+
.netlify
4748

4849
# Optional eslint cache
4950
.eslintcache

README.md

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,88 @@
1-
# React npm package starter
1+
# React Multi Fields Input component
22

3-
This is a starter project for custom React components
3+
React Multi Fields Input component comes with zero styles to allow you style it in accordance to your style guidelines.
44

5-
## Start
5+
Example:
66

7-
To start the development run
7+
![react-multi-fields-input component](/assets/rmfi-example.png)
88

9+
```js
10+
const inputs = [
11+
{
12+
type: 'number',
13+
maxLength: 2,
14+
placeholder: '00'
15+
},
16+
{
17+
type: 'number',
18+
maxLength: 2,
19+
placeholder: '00'
20+
},
21+
{
22+
type: 'number',
23+
maxLength: 2,
24+
placeholder: '00'
25+
}
26+
];
27+
28+
<MultiFieldsInput
29+
label="Sort Code"
30+
name="codeSort"
31+
inputs={inputs}
32+
value="202020"
33+
isValid={false}
34+
onBlur={() => {}}
35+
onChange={() => {}}
36+
/>;
937
```
10-
yarn install
11-
npm i -g @storybook/cli
12-
getstorybook
13-
```
1438

15-
and then `yarn start`. In a separate terminal run `yarn run storybook` to test the component.
39+
See more live examples on the [website](https://react-multi-fields-input.netlify.com/).
1640

17-
## Build
41+
## Props
1842

19-
To build the project run
43+
MultiFieldsInput component accepts the following props:
2044

45+
```js static
46+
{
47+
inputs: Inputs[];
48+
name: string;
49+
onBlur(target: Target): void;
50+
onChange(target: Target): void;
51+
isValid?: boolean;
52+
value?: string;
53+
autoFocus?: boolean;
54+
}
2155
```
22-
yarn run build
23-
yarn link
56+
57+
`inputs` is an array of objects that are constructed of
58+
59+
```js static
60+
{
61+
type: 'number' | 'text';
62+
maxLength: number;
63+
placeholder: string;
64+
min?: number;
65+
max?: number;
66+
}
2467
```
2568

26-
`yarn link` will be used to dev-test the component in any project while developing it
69+
The object that is being returned `onBlur` and `onChange`:
2770

28-
## Deploy to npm
71+
```js static
72+
{ name: '', value: ''}
73+
```
2974

30-
To deploy the ready React components run
75+
## Develop
3176

77+
``
78+
yarn
79+
yarn start
3280
```
33-
yarn login
34-
yarn publish
81+
82+
Optional: To enable styles in styleguidist, uncomment `.scss` styles import on line 5 in `src/components/index.tsx`.
83+
84+
When done
85+
3586
```
87+
yarn build
88+
```

assets/rmfi-example.png

2.8 KB
Loading

babel.config.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

dist/index.js

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 90 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,92 @@
11
{
2-
"name": "react-multi-fields-input",
3-
"version": "0.1.0",
4-
"main": "dist/index.js",
5-
"author": "kakuevn <n.kakuev@gmail.com>",
6-
"license": "MIT",
7-
"scripts": {
8-
"dev": "webpack --colors --progress --watch",
9-
"build": "webpack --colors --progress -p",
10-
"eslint": "eslint './src/**/*.{ts,tsx}'",
11-
"eslint:fix": "eslint src --fix",
12-
"start": "npm-run-all --parallel dev test:watch",
13-
"test": "jest",
14-
"test:watch": "jest --watch"
15-
},
16-
"jest": {
17-
"testURL": "http://localhost/",
18-
"moduleDirectories": [
19-
"node_modules",
20-
"shared"
21-
],
22-
"transformIgnorePatterns": [
23-
"/node_modules/(?!(our-react-components-.*?\\.js$))"
24-
],
25-
"moduleNameMapper": {
26-
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js"
27-
},
28-
"transform": {
29-
"^.+\\.(js|jsx)$": "babel-jest"
30-
}
31-
},
32-
"dependencies": {
33-
"@types/react": "^16.8.14",
34-
"@types/react-dom": "^16.8.4",
35-
"react": "^16.8.6",
36-
"react-dom": "^16.8.6",
37-
"webpack": "^4.30.0"
38-
},
39-
"devDependencies": {
40-
"@typescript-eslint/eslint-plugin": "^1.7.0",
41-
"@typescript-eslint/parser": "^1.7.0",
42-
"awesome-typescript-loader": "^5.2.1",
43-
"babel-jest": "^24.7.1",
44-
"eslint": "^5.16.0",
45-
"eslint-config-prettier": "^4.2.0",
46-
"eslint-formatter-friendly": "^6.0.0",
47-
"eslint-loader": "^2.1.2",
48-
"eslint-plugin-react-hooks": "^1.6.0",
49-
"file-loader": "^3.0.1",
50-
"jest": "^24.7.1",
51-
"npm-run-all": "^4.1.5",
52-
"prettier": "^1.17.0",
53-
"source-map-loader": "^0.2.4",
54-
"typescript": "^3.4.5",
55-
"uglifyjs-webpack-plugin": "^2.1.2",
56-
"webpack-cli": "^3.3.1"
57-
}
2+
"name": "react-multi-fields-input",
3+
"version": "0.1.0",
4+
"main": "dist/index.js",
5+
"author": "kakuevn <n.kakuev@gmail.com>",
6+
"license": "MIT",
7+
"scripts": {
8+
"dev": "cross-env NODE_ENV=development webpack --colors --progress --watch",
9+
"build": "cross-env NODE_ENV=production webpack -p",
10+
"eslint": "eslint ./src/**/*",
11+
"eslint:fix": "eslint src --fix",
12+
"test": "jest",
13+
"test:watch": "jest --watch",
14+
"sg:serve": "styleguidist server",
15+
"sg:build": "styleguidist build",
16+
"deploy": "netlify deploy",
17+
"deploy:prod": "netlify deploy --prod",
18+
"start": "npm-run-all --parallel dev sg:serve test:watch"
19+
},
20+
"jest": {
21+
"testURL": "http://localhost/",
22+
"moduleFileExtensions": [
23+
"ts",
24+
"tsx",
25+
"js"
26+
],
27+
"moduleNameMapper": {
28+
"\\.(css|less|sass|scss)$": "<rootDir>src/__mocks__/styleMock.js"
29+
},
30+
"transform": {
31+
"^.+\\.(ts|tsx)$": "ts-jest"
32+
},
33+
"globals": {
34+
"ts-jest": {
35+
"tsConfigFile": "tsconfig.json",
36+
"diagnostics": false
37+
}
38+
},
39+
"testMatch": [
40+
"**/__tests__/*.+(ts|tsx|js)"
41+
],
42+
"setupFiles": [
43+
"./src/setupTests.ts"
44+
]
45+
},
46+
"dependencies": {
47+
"@types/classnames": "^2.2.7",
48+
"@types/react": "^16.8.14",
49+
"@types/react-dom": "^16.8.4",
50+
"@types/styled-components": "4.1.8",
51+
"classnames": "^2.2.6",
52+
"cross-env": "^5.2.0",
53+
"react": "^16.8.6",
54+
"react-dom": "^16.8.6",
55+
"styled-components": "^4.2.0",
56+
"webpack": "^4.30.0"
57+
},
58+
"devDependencies": {
59+
"@babel/core": "7.0.0",
60+
"@types/enzyme": "^3.9.1",
61+
"@types/jest": "^24.0.12",
62+
"@types/sinon": "^7.0.11",
63+
"@typescript-eslint/eslint-plugin": "^1.7.0",
64+
"@typescript-eslint/parser": "^1.7.0",
65+
"awesome-typescript-loader": "^5.2.1",
66+
"css-loader": "^2.1.1",
67+
"enzyme": "^3.9.0",
68+
"enzyme-adapter-react-16": "^1.12.1",
69+
"enzyme-to-json": "^3.3.5",
70+
"eslint": "^5.16.0",
71+
"eslint-config-prettier": "^4.2.0",
72+
"eslint-formatter-friendly": "^6.0.0",
73+
"eslint-loader": "^2.1.2",
74+
"eslint-plugin-react": "^7.13.0",
75+
"eslint-plugin-react-hooks": "^1.6.0",
76+
"file-loader": "^3.0.1",
77+
"jest": "^24.7.1",
78+
"node-sass": "^4.12.0",
79+
"npm-run-all": "^4.1.5",
80+
"prettier": "^1.17.0",
81+
"react-docgen-typescript": "^1.12.4",
82+
"react-styleguidist": "^9.0.9",
83+
"sass-loader": "^7.1.0",
84+
"sinon": "^7.3.2",
85+
"source-map-loader": "^0.2.4",
86+
"style-loader": "^0.23.1",
87+
"ts-jest": "^24.0.2",
88+
"typescript": "^3.4.5",
89+
"uglifyjs-webpack-plugin": "^2.1.2",
90+
"webpack-cli": "^3.3.1"
91+
}
5892
}

src/__mocks__/styleMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`MultiFieldsInput Renders correctly 1`] = `ShallowWrapper {}`;

0 commit comments

Comments
 (0)