Skip to content

Commit 8862a3b

Browse files
authored
Migrate to TypeScript (#130)
1 parent 2462350 commit 8862a3b

File tree

16 files changed

+463
-2930
lines changed

16 files changed

+463
-2930
lines changed

.babelrc

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

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
99
liberapay: scriptex
1010
issuehunt: scriptex
1111
otechie: # Replace with a single Otechie username
12-
custom: ['paypal.me/scriptex']
12+
custom: ['paypal.me/scriptex', 'revolut.me/scriptex']

.github/workflows/build.yml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
41
name: Build
52

6-
on:
7-
push:
8-
branches: [ master ]
9-
pull_request:
10-
branches: [ master ]
3+
on: [push, pull_request]
114

125
jobs:
13-
build:
14-
15-
runs-on: ubuntu-latest
6+
build:
7+
runs-on: ubuntu-latest
168

17-
strategy:
18-
matrix:
19-
node-version: [10.x, 12.x, 14.x]
9+
strategy:
10+
matrix:
11+
node-version: [14.x, 16.x]
2012

21-
steps:
22-
- uses: actions/checkout@v3
23-
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v3
25-
with:
26-
node-version: ${{ matrix.node-version }}
27-
- run: yarn
28-
- run: yarn build
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- run: yarn
20+
- run: yarn deploy

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ node_modules/
1616
.Trashes
1717
ehthumbs.db
1818
Thumbs.db
19+
20+
dist

.npmignore

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ yarn-debug.log*
66
yarn-error.log*
77

88
# Dependency directory
9-
node_modules/
9+
node_modules
1010

1111
# Misc
1212
.DS_Store
@@ -17,23 +17,24 @@ node_modules/
1717
ehthumbs.db
1818
Thumbs.db
1919

20-
# EditorConfig
20+
# Config folders and files
21+
.github
22+
_config.yml
23+
_.config.yml
2124
.editorconfig
22-
23-
# Git
24-
.gitignore
2525
.gitattributes
26-
27-
# CI
26+
.gitignore
27+
.nvmrc
28+
.prettierignore
29+
.prettierrc
30+
.stylelintignore
31+
.stylelintrc
2832
.travis.yml
29-
30-
# lock files
33+
.whitesource
34+
renovate.json
35+
tsconfig.json
36+
tslint.json
3137
yarn.lock
3238

33-
# Prettier
34-
.prettierrc
35-
.prettierignore
36-
37-
# Config files
38-
.babelrc
39-
renovate.json
39+
!dist
40+
demo

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ node_js:
55
install:
66
- yarn
77
script:
8-
- yarn build
8+
- yarn deploy

.whitesource

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"checkRunSettings": {
66
"vulnerableCheckRunConclusionLevel": "success"
77
}
8-
}
8+
}

README.md

Lines changed: 130 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
1-
[![GitHub release](https://img.shields.io/github/release/scriptex/html5-form-validator.svg)](https://github.com/scriptex/html5-form-validator/releases/latest)
2-
[![GitHub issues](https://img.shields.io/github/issues/scriptex/html5-form-validator.svg)](https://github.com/scriptex/html5-form-validator/issues)
3-
[![GitHub last commit](https://img.shields.io/github/last-commit/scriptex/html5-form-validator.svg)](https://github.com/scriptex/html5-form-validator/commits/master)
4-
[![Github file size](https://img.shields.io/github/size/scriptex/html5-form-validator/dist/index.min.js.svg)](https://github.com/scriptex/html5-form-validator)
5-
[![Build Status](https://travis-ci.com/scriptex/html5-form-validator.svg?branch=master)](https://travis-ci.com/scriptex/html5-form-validator)
6-
[![npm](https://img.shields.io/npm/dt/html5-form-validator.svg)](https://www.npmjs.com/package/html5-form-validator)
7-
[![npm](https://img.shields.io/npm/v/html5-form-validator.svg)](https://www.npmjs.com/package/html5-form-validator)
8-
[![Analytics](https://ga-beacon.appspot.com/UA-83446952-1/github.com/scriptex/html5-form-validator/README.md)](https://github.com/scriptex/html5-form-validator/)
1+
[![Travis CI](https://travis-ci.com/scriptex/html5-form-validator.svg?branch=master)](https://travis-ci.com/scriptex/html5-form-validator)
2+
[![Github Build](https://github.com/scriptex/html5-form-validator/workflows/Build/badge.svg)](https://github.com/scriptex/html5-form-validator/actions?query=workflow%3ABuild)
3+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/34d3d75710534dc6a38c3584a1dcd068)](https://www.codacy.com/gh/scriptex/html5-form-validator/dashboard?utm_source=github.com&utm_medium=referral&utm_content=scriptex/html5-form-validator&utm_campaign=Badge_Grade)
4+
[![Codebeat Badge](https://codebeat.co/badges/d765a4c8-2c0e-44f2-89c3-fa364fdc14e6)](https://codebeat.co/projects/github-com-scriptex-html5-form-validator-master)
5+
[![CodeFactor Badge](https://www.codefactor.io/repository/github/scriptex/html5-form-validator/badge)](https://www.codefactor.io/repository/github/scriptex/html5-form-validator)
6+
[![DeepScan grade](https://deepscan.io/api/teams/3574/projects/5257/branches/40799/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=3574&pid=5257&bid=40799)
7+
[![Analytics](https://ga-beacon-361907.ew.r.appspot.com/UA-83446952-1/github.com/scriptex/html5-form-validator/README.md?pixel)](https://github.com/scriptex/html5-form-validator/)
98

109
# HTML5 Form Validator
1110

12-
The simplest HTML5 forms validator
11+
> The simplest HTML5 forms validator.
12+
13+
This form validator uses the **built-in capabilities** of the browser to validate the required form fields.
14+
15+
All validation messages are shown as they are shown by the browser which means that they are **internationalized** and are **NOT subject to change**.
16+
17+
## Visitor stats
18+
19+
![GitHub stars](https://img.shields.io/github/stars/scriptex/html5-form-validator?style=social)
20+
![GitHub forks](https://img.shields.io/github/forks/scriptex/html5-form-validator?style=social)
21+
![GitHub watchers](https://img.shields.io/github/watchers/scriptex/html5-form-validator?style=social)
22+
![GitHub followers](https://img.shields.io/github/followers/scriptex?style=social)
23+
24+
## Code stats
25+
26+
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/scriptex/html5-form-validator)
27+
![GitHub repo size](https://img.shields.io/github/repo-size/scriptex/html5-form-validator?style=plastic)
28+
![GitHub language count](https://img.shields.io/github/languages/count/scriptex/html5-form-validator?style=plastic)
29+
![GitHub top language](https://img.shields.io/github/languages/top/scriptex/html5-form-validator?style=plastic)
30+
![GitHub last commit](https://img.shields.io/github/last-commit/scriptex/html5-form-validator?style=plastic)
1331

1432
## Install
1533

@@ -23,34 +41,24 @@ or
2341
yarn add html5-form-validator
2442
```
2543

26-
or
27-
28-
just download this repository and link the files located in dist folder
29-
30-
or include it from unpkg.com
31-
32-
```html
33-
<script src="https://unpkg.com/html5-form-validator"></script>
34-
```
35-
3644
## Usage
3745

3846
```javascript
39-
import 'html5-form-validator';
47+
import { HTML5FormValidation } from 'html5-form-validator';
4048
```
4149

4250
Then initialize with default settings:
4351

4452
```javascript
45-
new html5formValidation();
53+
new HTML5FormValidation();
4654
```
4755

4856
or supply your own
4957

5058
```javascript
5159
const form = document.querySelector('#form');
5260

53-
new html5formValidation(form, {
61+
new HTML5FormValidation(form, {
5462
errorElement: 'form__error',
5563
invalidClass: 'is--invalid',
5664
submitHandler(instance) {
@@ -62,20 +70,107 @@ new html5formValidation(form, {
6270

6371
## Options
6472

65-
`errorElement` - The classname of the element that will be added to the dom after the required field. Defaults to `error`.
66-
67-
`invalidClass` - The classname of the required field when it is invalid. Defaults to `invalid`.
68-
69-
`submitHandler` - A function to run on valid form submission. Accepts a single `instance` argument which refers to the constuctor's instance. Defaults to `null`.
70-
71-
`validateOnInput` - Set to false if you want to show visual feedback for invalid fields after the first invalid submission. Defaults to `true`.
72-
73-
## Support this project
74-
75-
[![Tweet](https://img.shields.io/badge/Tweet-Share_this_repository-blue.svg?style=flat-square&logo=twitter&color=38A1F3)](https://twitter.com/intent/tweet?text=Checkout%20this%20awesome%20software%20project%3A&url=https%3A%2F%2Fgithub.com%2Fscriptex%2Fhtml5-form-validator&via=scriptexbg&hashtags=software%2Cgithub%2Ccode%2Cawesome)
76-
[![Donate](https://img.shields.io/badge/Donate-Support_me_on_PayPal-blue.svg?style=flat-square&logo=paypal&color=222d65)](https://www.paypal.me/scriptex)
77-
[![Become a Patron](https://img.shields.io/badge/Become_Patron-Support_me_on_Patreon-blue.svg?style=flat-square&logo=patreon&color=e64413)](https://www.patreon.com/atanas)
73+
| Option | Type | Required | Default | Description |
74+
| ----------------- | ---------- | -------- | ----------- | --------------------------------------------------------------------------------------------------- |
75+
| `errorElement` | `string` | false | `'error'` | The class name of the element that will be added to the DOM after the required field. |
76+
| `invalidClass` | `string` | false | `'invalid'` | The classname of the required field when it is invalid |
77+
| `submitHandler` | `Function` | false | `null` | A function to run on form submission. Accepts a single argument - the HTML5FormValidation instance. |
78+
| `validateOnInput` | `boolean` | false | `true` | Validate as you type. Set to `false` to validate only on submit. |
7879

7980
## LICENSE
8081

8182
MIT
83+
84+
---
85+
86+
<div align="center">
87+
Connect with me:
88+
</div>
89+
90+
<br />
91+
92+
<div align="center">
93+
<a href="https://atanas.info">
94+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/logo.svg" height="20" alt="">
95+
</a>
96+
&nbsp;
97+
<a href="mailto:[email protected]">
98+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/email.svg" height="20" alt="">
99+
</a>
100+
&nbsp;
101+
<a href="https://www.linkedin.com/in/scriptex/">
102+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/linkedin.svg" height="20" alt="">
103+
</a>
104+
&nbsp;
105+
<a href="https://github.com/scriptex">
106+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/github.svg" height="20" alt="">
107+
</a>
108+
&nbsp;
109+
<a href="https://gitlab.com/scriptex">
110+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/gitlab.svg" height="20" alt="">
111+
</a>
112+
&nbsp;
113+
<a href="https://twitter.com/scriptexbg">
114+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/twitter.svg" height="20" alt="">
115+
</a>
116+
&nbsp;
117+
<a href="https://www.npmjs.com/~scriptex">
118+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/npm.svg" height="20" alt="">
119+
</a>
120+
&nbsp;
121+
<a href="https://www.youtube.com/user/scriptex">
122+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/youtube.svg" height="20" alt="">
123+
</a>
124+
&nbsp;
125+
<a href="https://stackoverflow.com/users/4140082/atanas-atanasov">
126+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/stackoverflow.svg" height="20" alt="">
127+
</a>
128+
&nbsp;
129+
<a href="https://codepen.io/scriptex/">
130+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/codepen.svg" width="20" alt="">
131+
</a>
132+
&nbsp;
133+
<a href="https://profile.codersrank.io/user/scriptex">
134+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/codersrank.svg" height="20" alt="">
135+
</a>
136+
&nbsp;
137+
<a href="https://linktr.ee/scriptex">
138+
<img src="https://raw.githubusercontent.com/scriptex/socials/master/styled-assets/linktree.svg" height="20" alt="">
139+
</a>
140+
</div>
141+
142+
---
143+
144+
<div align="center">
145+
Support and sponsor my work:
146+
<br />
147+
<br />
148+
<a href="https://twitter.com/intent/tweet?text=Checkout%20this%20awesome%20developer%20profile%3A&url=https%3A%2F%2Fgithub.com%2Fscriptex&via=scriptexbg&hashtags=software%2Cgithub%2Ccode%2Cawesome" title="Tweet">
149+
<img src="https://img.shields.io/badge/Tweet-Share_my_profile-blue.svg?logo=twitter&color=38A1F3" />
150+
</a>
151+
<a href="https://paypal.me/scriptex" title="Donate on Paypal">
152+
<img src="https://img.shields.io/badge/Donate-Support_me_on_PayPal-blue.svg?logo=paypal&color=222d65" />
153+
</a>
154+
<a href="https://revolut.me/scriptex" title="Donate on Revolut">
155+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/scriptex/scriptex/master/badges/revolut.json" />
156+
</a>
157+
<a href="https://patreon.com/atanas" title="Become a Patron">
158+
<img src="https://img.shields.io/badge/Become_Patron-Support_me_on_Patreon-blue.svg?logo=patreon&color=e64413" />
159+
</a>
160+
<a href="https://ko-fi.com/scriptex" title="Buy Me A Coffee">
161+
<img src="https://img.shields.io/badge/Donate-Buy%20me%20a%20coffee-yellow.svg?logo=ko-fi" />
162+
</a>
163+
<a href="https://liberapay.com/scriptex/donate" title="Donate on Liberapay">
164+
<img src="https://img.shields.io/liberapay/receives/scriptex?label=Donate%20on%20Liberapay&logo=liberapay" />
165+
</a>
166+
167+
<a href="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/scriptex/scriptex/master/badges/bitcoin.json" title="Donate Bitcoin">
168+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/scriptex/scriptex/master/badges/bitcoin.json" />
169+
</a>
170+
<a href="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/scriptex/scriptex/master/badges/etherium.json" title="Donate Etherium">
171+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/scriptex/scriptex/master/badges/etherium.json" />
172+
</a>
173+
<a href="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/scriptex/scriptex/master/badges/shiba-inu.json" title="Donate Shiba Inu">
174+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/scriptex/scriptex/master/badges/shiba-inu.json" />
175+
</a>
176+
</div>

0 commit comments

Comments
 (0)