├── .all-contributorsrc
├── .babelrc
├── .eslintrc.json
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── feature_request.md
│ └── question-request.md
└── workflows
│ └── main.yml
├── .gitignore
├── .npmignore
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── LICENSE_996
├── README.md
├── docs
├── locales-example-es5.md
├── locales-example-es6.md
├── v1-v2-v3-doc.md
└── v4-doc.md
├── eslintignore.json
├── example
├── global.d.ts
└── index.tsx
├── index.js
├── jest.config.js
├── package.json
├── postcss.config.js
├── react-inputs-validation.gif
├── src
├── __tests__
│ ├── Checkbox.js
│ ├── Radiobox.js
│ ├── Select.js
│ ├── Textarea.js
│ ├── Textbox.js
│ ├── message.js
│ ├── utils.js
│ └── validator.js
├── css
│ ├── example.css
│ └── icon.css
├── font
│ ├── icomoon.svg
│ ├── icomoon.ttf
│ └── icomoon.woff
├── html
│ └── layout.html
└── js
│ └── Inputs
│ ├── Checkbox.tsx
│ ├── Radiobox.tsx
│ ├── Select.tsx
│ ├── Textarea.tsx
│ ├── Textbox.tsx
│ ├── const.ts
│ ├── global.d.ts
│ ├── index.global.ts
│ ├── index.ts
│ ├── message.ts
│ ├── react-inputs-validation.css
│ ├── utils.ts
│ └── validator.ts
├── stylelint.config.js
├── tea.yaml
├── tsconfig.json
├── tslint.json
└── webpack
├── base.js
├── build_path.js
├── development.config.js
├── production.config.js
├── umd.base.config.js
├── umd.global.config.js
└── umd.local.config.js
/.all-contributorsrc:
--------------------------------------------------------------------------------
1 | {
2 | "files": [
3 | "README.md"
4 | ],
5 | "imageSize": 100,
6 | "commit": false,
7 | "contributors": [
8 | {
9 | "login": "edwardfxiao",
10 | "name": "Edward Xiao",
11 | "avatar_url": "https://avatars3.githubusercontent.com/u/11728228?v=4",
12 | "profile": "https://github.com/edwardfxiao",
13 | "contributions": [
14 | "code",
15 | "doc",
16 | "infra",
17 | "test",
18 | "review"
19 | ]
20 | },
21 | {
22 | "login": "DecentralizedIT",
23 | "name": "Frank Bonnet",
24 | "avatar_url": "https://avatars1.githubusercontent.com/u/31480614?v=4",
25 | "profile": "http://www.dcorp.it",
26 | "contributions": [
27 | "code"
28 | ]
29 | },{
30 | "login": "RokasAniss",
31 | "name": "Rokas Anisas",
32 | "avatar_url": "https://avatars3.githubusercontent.com/u/33621394?v=4",
33 | "profile": "http://rokasanisas.com",
34 | "contributions": [
35 | "code"
36 | ]
37 | }
38 | ],
39 | "contributorsPerLine": 7,
40 | "projectName": "react-inputs-validation",
41 | "projectOwner": "edwardfxiao",
42 | "repoType": "github",
43 | "repoHost": "https://github.com",
44 | "skipCi": true
45 | }
46 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
3 | "env": {
4 | "development": {
5 | "comments": false
6 | },
7 | "production": {
8 | "comments": false
9 | },
10 | "lib": {
11 | "plugins": ["css-modules-transform", "@babel/proposal-class-properties", "@babel/proposal-object-rest-spread"],
12 | "comments": false
13 | },
14 | "test": {
15 | "plugins": ["babel-plugin-rewire"]
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | // Extend existing configuration
3 | // from ESlint and eslint-plugin-react defaults.
4 | "extends": ["eslint:recommended", "plugin:react/recommended"],
5 | // Enable ES6 support. If you want to use custom Babel
6 | // features, you will need to enable a custom parser
7 | // as described in a section below.
8 | "parserOptions": {
9 | "ecmaVersion": 6,
10 | "sourceType": "module",
11 | "ecmaFeatures": {
12 | "experimentalObjectRestSpread": true
13 | }
14 | },
15 | "env": {
16 | "jest": true,
17 | "es6": true,
18 | "browser": true,
19 | "node": true,
20 | "jquery": true
21 | },
22 | // Enable custom plugin known as eslint-plugin-react
23 | "plugins": ["react", "react-hooks"],
24 | "rules": {
25 | // Disable `no-console` rule
26 | "no-console": 0,
27 | // Give a warning if identifiers contain underscores
28 | "no-underscore-dangle": 1,
29 | "no-debugger": 0,
30 | "react-hooks/rules-of-hooks": "error",
31 | "no-empty": [
32 | "error",
33 | {
34 | "allowEmptyCatch": true
35 | }
36 | ]
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 |
5 | ---
6 |
7 | **Describe the bug**
8 | A clear and concise description of what the bug is.
9 |
10 | **To Reproduce**
11 | Steps to reproduce the behavior:
12 | 1. Go to '...'
13 | 2. Click on '....'
14 | 3. Scroll down to '....'
15 | 4. See error
16 |
17 | **Expected behavior**
18 | A clear and concise description of what you expected to happen.
19 |
20 | **Screenshots**
21 | If applicable, add screenshots to help explain your problem.
22 |
23 | **Desktop (please complete the following information):**
24 | - OS: [e.g. iOS]
25 | - Browser [e.g. chrome, safari]
26 | - Version [e.g. 22]
27 |
28 | **Smartphone (please complete the following information):**
29 | - Device: [e.g. iPhone6]
30 | - OS: [e.g. iOS8.1]
31 | - Browser [e.g. stock browser, safari]
32 | - Version [e.g. 22]
33 |
34 | **Additional context**
35 | Add any other context about the problem here.
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 |
5 | ---
6 |
7 | **Is your feature request related to a problem? Please describe.**
8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9 |
10 | **Describe the solution you'd like**
11 | A clear and concise description of what you want to happen.
12 |
13 | **Describe alternatives you've considered**
14 | A clear and concise description of any alternative solutions or features you've considered.
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the feature request here.
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question-request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question request
3 | about: Ask your question here
4 |
5 | ---
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | # This is a basic workflow to help you get started with Actions
2 |
3 | name: CI
4 |
5 | # Controls when the workflow will run
6 | on:
7 | # Triggers the workflow on push or pull request events but only for the master branch
8 | push:
9 | branches: [ master ]
10 | pull_request:
11 | branches: [ master ]
12 |
13 | # Allows you to run this workflow manually from the Actions tab
14 | workflow_dispatch:
15 |
16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
17 | jobs:
18 | # This workflow contains a single job called "build"
19 | build:
20 | # The type of runner that the job will run on
21 | runs-on: ubuntu-latest
22 |
23 | strategy:
24 | matrix:
25 | node-version: [10.x]
26 |
27 | # Steps represent a sequence of tasks that will be executed as part of the job
28 | steps:
29 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
30 | - uses: actions/checkout@v3
31 |
32 | - name: Install dependencies
33 | run: npm i
34 |
35 | - name: Test:coverage
36 | run: npm run test:coverage
37 |
38 | - name: Coveralls
39 | uses: coverallsapp/github-action@master
40 | with:
41 | github-token: ${{ secrets.GITHUB_TOKEN }}
42 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /*.log
3 | /log/*.log
4 | coverage
5 | /notes
6 | /lib
7 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | /coverage
2 | /example
3 | /webpack
4 | /src
5 | /.babelrc
6 | /.eslintrc.json
7 | /eslintignore.json
8 | /.gitignore
9 | /.travis.yml
10 | /jest.config.js
11 | /postcss.config.js
12 | /stylelint.config.js
13 | /tsconfig.json
14 | /tslint.json
15 | /*.gif
16 | /dist
17 | /*.html
18 | /.github
19 | /rev-manifest.json
20 | /docs
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "10"
4 | before_script:
5 | - npm i
6 | script: npm run prepublish
7 | after_script: "cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js"
8 | env:
9 | - REACT=16
10 | notifications:
11 | email:
12 | - email:edwardfhsiao@gmail.com
13 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 4.9.10
2 |
3 | - enable `hidden`, `disabled` props in OptionListItem for ``
4 |
5 | # 4.9.9
6 |
7 | - `customStyleOptionListWrapper` for ``
8 |
9 | # 4.9.8
10 |
11 | - `classNameInputBoxItem` for ``
12 | - `title` and `ellipsis` for `` option item
13 |
14 | # 4.9.7
15 |
16 | - fix bug of cached disabled in `` handleOnItemClick
17 |
18 | # 4.9.6
19 |
20 | - Fix potential bug for ``
21 |
22 | # 4.9.5
23 |
24 | - Remove `zh-CN` as an option to `validationOption.locale` in order to reduce size
25 |
26 | # 4.9.4
27 |
28 | - Add `decimalSeparator` to `` ```validationOption```. e.g. `decimalSeparator: ','` `'0.5' => '0,5'`
29 |
30 | # 4.9.3
31 |
32 | - Add `decimalSeparator` to `` ```validationOption```. e.g. `decimalSeparator: ','` `'0.5' => '0,5'`(forgot to compile)
33 |
34 | # 4.9.2
35 |
36 | - Update readme and for cdnjs updating
37 |
38 | # 4.9.1
39 |
40 | - Remove classname hash
41 |
42 | # 4.9.0
43 |
44 | - Update readme
45 |
46 | # 4.8.9
47 |
48 | - Fix 'undefined' classname for ```__container```
49 |
50 | # 4.8.8
51 |
52 | - Remove lib folder for github
53 |
54 | # 4.8.7
55 |
56 | - Update readme
57 |
58 | # 4.8.6
59 |
60 | - Update peerDependencies
61 |
62 | # 4.8.5
63 |
64 | - Update readme
65 |
66 | # 4.8.4
67 |
68 | - Update readme
69 |
70 | # 4.8.3
71 |
72 | - Minor fix for ``````
73 |
74 | # 4.8.2
75 |
76 | - Minor fix for ``````
77 |
78 | # 4.8.1
79 |
80 | - Add ```icon``` into ``````'s ```optionList``` ```[{id: '1', name: 'Twin Peaks']``` => ```[{id: '1', name: 'Twin Peaks', icon: 'optional']```
81 |
82 | # 4.8.0
83 |
84 | - Replace ```classNameOptionListContainer``` with ```classNameOptionListWrapper``` and provide new ```classNameOptionListContainer``` & change className ```'options-container'``` to ```'options-wrapper'``` in ``````
85 |
86 | # 4.7.0
87 |
88 | - Add ```shouldRenderMsgAsHtml``` to components ```validationOption```, in case you need to render html inside your ```messages``` as stated in issue [#29](https://github.com/edwardfxiao/react-inputs-validation/issues/29)
89 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to react-inputs-validation
2 |
3 | First off, thanks for taking the time to contribute! Here are a little dev FAQ below.
4 |
5 | ### Q: How to development?
6 | **A**: ```npm run dev```
7 |
8 | ### Q: How to compile the ultimate files?
9 | **A**: ```npm run compile```, and the files will be locating in ```/lib``` folder.
10 |
11 |
12 | ### Q: What is the difference between ```umd_local```, ```umd_global``` and ```umd_global_min``` in the script of ```package.json```?
13 | **A**: ```umd_local``` intend to compile / build a not ```window``` exposed variables for ```Textbox```,```Textarea``` ,```Select```, ```Checkbox``` and ```Radiobox```
14 | while ```umd_global``` gives ```window.Textbox = Textbox``` if ```window``` exists.
15 |
16 | Lastly ```umd_global_min``` minifies the assets and generates ```react-inputs-validation.min.js``` and ```react-inputs-validation.min.css```
17 |
18 | They ruled by ```umd.local.config.js``` and ```umd.global.config.js```, which located in ```/src/webpack/``` folder.
19 |
20 | ### Q: What does ```build_gh_page``` do?
21 | **A**: Just for building the gh page
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-present Edward Xiao
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LICENSE_996:
--------------------------------------------------------------------------------
1 | Copyright (c) 2019-present Edward Xiao
2 |
3 | Anti 996 License Version 1.0 (Draft)
4 |
5 | Permission is hereby granted to any individual or legal entity obtaining a copy
6 | of this licensed work (including the source code, documentation and/or related
7 | items, hereinafter collectively referred to as the "licensed work"), free of
8 | charge, to deal with the licensed work for any purpose, including without
9 | limitation, the rights to use, reproduce, modify, prepare derivative works of,
10 | publish, distribute and sublicense the licensed work, subject to the following
11 | conditions:
12 |
13 | 1. The individual or the legal entity must conspicuously display, without
14 | modification, this License on each redistributed or derivative copy of the
15 | Licensed Work.
16 |
17 | 2. The individual or the legal entity must strictly comply with all applicable
18 | laws, regulations, rules and standards of the jurisdiction relating to
19 | labor and employment where the individual is physically located or where
20 | the individual was born or naturalized; or where the legal entity is
21 | registered or is operating (whichever is stricter). In case that the
22 | jurisdiction has no such laws, regulations, rules and standards or its
23 | laws, regulations, rules and standards are unenforceable, the individual
24 | or the legal entity are required to comply with Core International Labor
25 | Standards.
26 |
27 | 3. The individual or the legal entity shall not induce or force its
28 | employee(s), whether full-time or part-time, or its independent
29 | contractor(s), in any methods, to agree in oral or written form,
30 | to directly or indirectly restrict, weaken or relinquish his or
31 | her rights or remedies under such laws, regulations, rules and
32 | standards relating to labor and employment as mentioned above,
33 | no matter whether such written or oral agreement are enforceable
34 | under the laws of the said jurisdiction, nor shall such individual
35 | or the legal entity limit, in any methods, the rights of its employee(s)
36 | or independent contractor(s) from reporting or complaining to the copyright
37 | holder or relevant authorities monitoring the compliance of the license
38 | about its violation(s) of the said license.
39 |
40 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
42 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT
43 | HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
44 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION
45 | WITH THE LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.
46 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # react-inputs-validation
2 |
3 | [](#contributors-)
4 |
5 | [](https://badge.fury.io/js/react-inputs-validation)   [](https://www.npmjs.com/package/react-inputs-validation) [](http://packagequality.com/#?package=react-inputs-validation) [](https://coveralls.io/github/edwardfxiao/react-inputs-validation?branch=master)  [](https://gitter.im/react-inputs-validation/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://raw.githubusercontent.com/edwardfxiao/react-inputs-validation/master/LICENSE) [](https://github.com/996icu/996.ICU/blob/master/LICENSE) [](https://996.icu)
6 |
7 | A react component for form inputs validation. Online demo examples.
8 | #
9 |
10 | - [How to use](#how-to-use)
11 | - [Usage](#usage)
12 | - [Live examples](#live-examples)
13 | - [Codesandbox examples](#codesandbox-examples)
14 | - [Basic usage examples](#basic-usage-examples)
15 | - [Documentation](#documentation)
16 | - [1.x, 2.x, 3.x](/docs/v1-v2-v3-doc.md)
17 | - [4.x](/docs/v4-doc.md)
18 | - [About intl locales support](/docs/v4-doc.md#custom-error-message) (Under `Common questions`)
19 | - [Browser support](#browser-support)
20 | - [Donation](#donation)
21 | - [Contributors](#contributors)
22 |
23 |
24 | # How to use
25 |
26 | ### Usage
27 |
28 | #### By NPM
29 | ```sh
30 | npm install react-inputs-validation --save
31 | ```
32 | ```js
33 | import { Textbox, Radiobox, Checkbox, Select, Textarea } from 'react-inputs-validation';
34 | import 'react-inputs-validation/lib/react-inputs-validation.min.css';
35 | ```
36 |
37 | ##### Make sure you have at least ```react@16.8.6``` installed.
38 | ```js
39 | "peerDependencies": {
40 | "react": ">= 16.8.6",
41 | "react-dom": ">= 16.8.6"
42 | }
43 | ```
44 |
45 | #### By CDN (starting from v4.4.1)
46 | ```html
47 |
48 | ...
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
64 |
65 |
66 |
67 | ```
68 |
69 | # Live examples
70 |
71 | ## Codesandbox Examples
72 | * Example of online demo form playground
73 | * Example of custom control(when ```check: false```)
74 | * Example of custom function(when providing ```customFunc```)
75 | * Example of custom function further control(when providing ```customFunc```)
76 | * Example of custom locales(when providing ```window.REACT_INPUTS_VALIDATION['customErrorMessage']```)
77 | * Example of phone and email validation(handled with ```customFunc```)
78 | * Example of async checking username existence (Async checking for `````` and ```