lesca-validate 0.0.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,69 +1,42 @@
1
1
  {
2
2
  "name": "lesca-validate",
3
- "version": "0.0.4",
3
+ "private": false,
4
4
  "description": "check email, phone number, url format.",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "start": "webpack-dev-server --mode development",
8
- "watch": "babel --watch src/lib --out-dir lib --extensions '.ts,.tsx'",
9
- "build": "NODE_ENV=production webpack",
10
- "less": "less-watch-compiler",
11
- "css": "copy-and-watch --watch src/lib/*.css lib/",
12
- "deploy": "gh-pages -d dist",
13
- "tsc": "npx tsc --watch",
14
- "dev": "concurrently \"npm run tsc\" \"npm run less\" \"npm run css\" \"npm run watch\" \"npm run start\"",
15
- "rm": "rm -rf node_modules/ package-lock.json",
16
- "op": "babel src/lib -d lib --copy-files"
17
- },
5
+ "version": "1.0.0",
6
+ "type": "module",
18
7
  "keywords": [
19
8
  "lesca"
20
9
  ],
21
- "license": "MIT",
22
- "devDependencies": {
23
- "@babel/cli": "^7.23.0",
24
- "@babel/core": "^7.23.2",
25
- "@babel/plugin-proposal-class-properties": "^7.18.6",
26
- "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
27
- "@babel/plugin-transform-runtime": "^7.23.2",
28
- "@babel/preset-env": "^7.23.2",
29
- "@babel/preset-react": "^7.22.15",
30
- "@babel/preset-typescript": "^7.23.2",
31
- "@emotion/react": "^11.11.1",
32
- "@emotion/styled": "^11.11.0",
33
- "@mui/icons-material": "^5.14.13",
34
- "@mui/material": "^5.14.13",
35
- "autoprefixer": "^10.4.16",
36
- "babel-loader": "^9.1.3",
37
- "concurrently": "^8.2.1",
38
- "copy-and-watch": "^0.1.6",
39
- "css-loader": "^6.8.1",
40
- "file-loader": "^6.2.0",
41
- "gh-pages": "^6.0.0",
42
- "html-react-parser": "^4.2.5",
43
- "html-webpack-plugin": "^5.5.3",
44
- "less": "^4.2.0",
45
- "less-loader": "^11.1.3",
46
- "less-vars-to-js": "^1.3.0",
47
- "less-watch-compiler": "^1.16.3",
48
- "postcss": "^8.4.31",
49
- "postcss-loader": "^7.3.3",
50
- "prismjs": "^1.29.0",
51
- "react": "^18.2.0",
52
- "react-dom": "^18.2.0",
53
- "style-loader": "^3.3.3",
54
- "ts-loader": "^9.5.0",
55
- "typescript": "^5.2.2",
56
- "webpack": "^5.89.0",
57
- "webpack-cli": "^5.1.4",
58
- "webpack-dev-server": "^4.15.1"
10
+ "files": [
11
+ "lib"
12
+ ],
13
+ "main": "./lib/index.cjs",
14
+ "module": "./lib/index.js",
15
+ "exports": {
16
+ ".": {
17
+ "import": "./lib/index.js"
18
+ }
59
19
  },
60
- "author": "jamehsu1125 <jameshsu1125@gmail.com>",
61
- "homepage": "https://jameshsu1125.github.io/lesca-validate/",
62
- "repository": {
63
- "type": "git",
64
- "url": "git@github.com:jameshsu1125/lesca-validate.git"
20
+ "scripts": {
21
+ "dev": "NODE_ENV=DEV vite --host",
22
+ "build": "NODE_ENV=production tsc -b && vite build",
23
+ "lint": "eslint .",
24
+ "preview": "vite preview",
25
+ "rm": "rm -rf node_modules/ dist/ package-lock.json"
65
26
  },
66
- "dependencies": {
67
- "@babel/runtime": "^7.23.2"
27
+ "dependencies": {},
28
+ "devDependencies": {
29
+ "@eslint/js": "^9.33.0",
30
+ "@types/node": "^24.2.1",
31
+ "eslint": "^9.33.0",
32
+ "globals": "^16.3.0",
33
+ "path": "^0.12.7",
34
+ "prettier": "^3.6.2",
35
+ "prettier-plugin-tailwindcss": "^0.6.14",
36
+ "typescript": "^5.9.2",
37
+ "typescript-eslint": "^8.39.1",
38
+ "vite": "^7.1.2",
39
+ "vite-plugin-css-injected-by-js": "^3.5.2",
40
+ "vite-plugin-dts": "^4.5.4"
68
41
  }
69
42
  }
package/.babelrc DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "presets": [
3
- "@babel/preset-env",
4
- [
5
- "@babel/preset-react",
6
- {
7
- "runtime": "automatic"
8
- }
9
- ],
10
- "@babel/preset-typescript"
11
- ],
12
- "plugins": [
13
- "@babel/plugin-proposal-object-rest-spread",
14
- "@babel/plugin-proposal-class-properties",
15
- "@babel/transform-runtime"
16
- ]
17
- }
package/.gitattributes DELETED
@@ -1,2 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
package/.prettierignore DELETED
@@ -1,11 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
-
6
- # Dependency directories
7
- node_modules/
8
-
9
- # Ignore files
10
- package-lock.json
11
-
package/.prettierrc DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "jsxBracketSameLine": false,
3
- "singleQuote": true,
4
- "useTabs": false,
5
- "jsxSingleQuote": true,
6
- "printWidth": 100,
7
- "trailingComma": "all"
8
- }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 James Hsu
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.
@@ -1,5 +0,0 @@
1
- {
2
- "watchFolder": "src/lib",
3
- "outputFolder": "src/lib",
4
- "mainFile": "style.less"
5
- }
package/lib/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export declare const ValidateEmail: (email: string) => boolean;
2
- export declare const ValidatePhone: (phone: string) => boolean;
3
- export declare const ValidateURL: (str: string) => boolean;
4
- export declare const ValidateYoutubeURL: (url: string) => string | false;
5
- export declare const ValiDateInvoice: (value: String) => boolean;
6
- declare const Validate: {
7
- email: (email: string) => boolean;
8
- phone: (phone: string) => boolean;
9
- url: (str: string) => boolean;
10
- youtubeID: (url: string) => string | false;
11
- invoice: (value: String) => boolean;
12
- };
13
- export default Validate;
package/lib/index.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.ValidateYoutubeURL = exports.ValidateURL = exports.ValidatePhone = exports.ValidateEmail = exports.ValiDateInvoice = void 0;
7
- var _misc = require("./misc");
8
- var ValidateEmail = exports.ValidateEmail = function ValidateEmail(email) {
9
- return String(email).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/) !== null;
10
- };
11
- var ValidatePhone = exports.ValidatePhone = function ValidatePhone(phone) {
12
- return phone !== '' && phone.length === 10 && phone.slice(0, 2) === '09';
13
- };
14
- var ValidateURL = exports.ValidateURL = function ValidateURL(str) {
15
- var pattern = new RegExp('^(https?:\\/\\/)?' + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + '((\\d{1,3}\\.){3}\\d{1,3}))' + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + '(\\?[;&a-z\\d%_.~+=-]*)?' + '(\\#[-a-z\\d_]*)?$', 'i');
16
- return !!pattern.test(str);
17
- };
18
- var ValidateYoutubeURL = exports.ValidateYoutubeURL = function ValidateYoutubeURL(url) {
19
- var pattern = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/;
20
- var result = url.match(pattern);
21
- if (result) return result[1];
22
- return false;
23
- };
24
- var ValiDateInvoice = exports.ValiDateInvoice = function ValiDateInvoice(value) {
25
- var currentValue = String(value);
26
- var length = currentValue.length;
27
- if (length !== 10) return false;
28
- var code = (0, _misc.isEnglish)(currentValue.slice(0, 2));
29
- if (!code) return false;
30
- var num = (0, _misc.isNumber)(currentValue.slice(2));
31
- if (!num) return false;
32
- return true;
33
- };
34
- var Validate = {
35
- email: ValidateEmail,
36
- phone: ValidatePhone,
37
- url: ValidateURL,
38
- youtubeID: ValidateYoutubeURL,
39
- invoice: ValiDateInvoice
40
- };
41
- var _default = exports["default"] = Validate;
package/lib/misc.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function isEnglish(s: String): boolean;
2
- export declare function isNumber(s: String): boolean;
package/lib/misc.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isEnglish = isEnglish;
7
- exports.isNumber = isNumber;
8
- function isEnglish(s) {
9
- var i, charCode;
10
- var result = true;
11
- for (i = s.length; i--;) {
12
- charCode = s.charCodeAt(i);
13
- if (charCode < 65 || charCode > 122) result = false;
14
- }
15
- return result;
16
- }
17
- function isNumber(s) {
18
- var i, charCode;
19
- var result = true;
20
- for (i = s.length; i--;) {
21
- charCode = s.charCodeAt(i);
22
- if (charCode < 48 || charCode > 57) result = false;
23
- }
24
- return result;
25
- }
package/postcss.config.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- plugins: [require('autoprefixer')],
3
- };
@@ -1,19 +0,0 @@
1
- import HTMLReactParser from 'html-react-parser';
2
- import Prism from 'prismjs';
3
- import 'prismjs/themes/prism.css';
4
- import './code.less';
5
-
6
- const Code = ({ code, theme }) => {
7
- return (
8
- <pre>
9
- <code>{HTMLReactParser(Prism.highlight(code, Prism.languages[theme], theme))}</code>
10
- </pre>
11
- );
12
- };
13
-
14
- Code.defaultProps = {
15
- code: `import { useState } from 'react';`,
16
- theme: 'javascript',
17
- };
18
-
19
- export default Code;
@@ -1,7 +0,0 @@
1
- @import url('../theme.less');
2
- pre {
3
- overflow: scroll;
4
- padding: 20px;
5
- outline: dashed 1px (@C4 - 50);
6
- background-color: #fff;
7
- }
@@ -1,33 +0,0 @@
1
- import { Button, ButtonGroup } from '@mui/material';
2
- import { useEffect } from 'react';
3
- import { name } from '../config';
4
- import './navigation.less';
5
-
6
- const Menu = ({ setState, state }) => (
7
- <ButtonGroup variant='contained' size='small' color='success'>
8
- <Button
9
- onClick={() => {
10
- setState('demo');
11
- }}
12
- disabled={state === 'demo'}
13
- >
14
- Demo
15
- </Button>
16
- <Button
17
- onClick={() => {
18
- setState('usage');
19
- }}
20
- disabled={state === 'usage'}
21
- >
22
- Usage
23
- </Button>
24
- </ButtonGroup>
25
- );
26
-
27
- const Navigation = ({ setState, state }) => (
28
- <div className='Navigation'>
29
- <div className='logo'>{name}</div>
30
- <div className='menu'>{/* <Menu setState={setState} state={state} /> */}</div>
31
- </div>
32
- );
33
- export default Navigation;
@@ -1,28 +0,0 @@
1
- @import url('../theme.less');
2
-
3
- .Navigation {
4
- position: fixed;
5
- box-sizing: border-box;
6
- padding: 0 20px;
7
- width: 100%;
8
- height: 70px;
9
- background-color: @C2;
10
-
11
- .logo {
12
- float: left;
13
- height: 100%;
14
- color: #fff;
15
- font-size: 30px;
16
- font-family: 'Titillium Web', sans-serif;
17
- line-height: 70px;
18
- }
19
-
20
- .menu {
21
- display: flex;
22
- float: right;
23
- align-items: center;
24
- flex-direction: column;
25
- justify-content: center;
26
- height: 100%;
27
- }
28
- }
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- name: 'lesca-validate',
3
- description: 'check is validate email, phone number and url format.',
4
- };
package/src/docs/index.js DELETED
@@ -1,35 +0,0 @@
1
- import { Container } from '@mui/material';
2
- import { ThemeProvider } from '@mui/material/styles';
3
- import { useState } from 'react';
4
- import { createRoot } from 'react-dom/client';
5
- import Navigation from './components/navigation';
6
- import Demo from './pages/demo';
7
- import Usage from './pages/usage';
8
- import './styles.less';
9
- import { theme } from './theme';
10
-
11
- const App = () => {
12
- const [state, setState] = useState('demo');
13
-
14
- const appendPage = () => {
15
- switch (state) {
16
- default:
17
- case 'demo':
18
- return <Demo />;
19
-
20
- case 'usage':
21
- return <Usage />;
22
- }
23
- };
24
-
25
- return (
26
- <ThemeProvider theme={theme}>
27
- <Navigation setState={setState} state={state} />
28
- <Container style={{ paddingTop: '70px' }} maxWidth='lg'>
29
- {appendPage()}
30
- </Container>
31
- </ThemeProvider>
32
- );
33
- };
34
-
35
- createRoot(document.getElementById('app')).render(<App />);
@@ -1,5 +0,0 @@
1
- const lessToJs = require('less-vars-to-js');
2
-
3
- module.exports = function (content) {
4
- return `module.exports = ${JSON.stringify(lessToJs(content))}`;
5
- };
@@ -1,120 +0,0 @@
1
- import { Button, ButtonGroup, TextField } from '@mui/material';
2
- import { useRef, useState } from 'react';
3
- import {
4
- ValidateEmail,
5
- ValidatePhone,
6
- ValidateURL,
7
- ValidateYoutubeURL,
8
- ValiDateInvoice,
9
- } from '../../lib';
10
-
11
- const Demo = () => {
12
- const emailRef = useRef();
13
- const phoneRef = useRef();
14
- const urlRef = useRef();
15
- const youtubeRef = useRef();
16
- const invoiceRef = useRef();
17
-
18
- const [emailResult, setEmailResult] = useState();
19
- const [phoneResult, setPhoneResult] = useState();
20
- const [urlResult, setUrlResult] = useState();
21
- const [youtubeResult, setYoutubeResult] = useState();
22
- const [invoiceResult, setInvoiceResult] = useState();
23
-
24
- return (
25
- <div className='Demo'>
26
- <h2>Validate Email</h2>
27
- <TextField inputRef={emailRef} defaultValue='username@host.com' label='email' fullWidth />
28
- <pre>
29
- <code>{JSON.stringify(emailResult ?? 'no result')}</code>
30
- </pre>
31
- <ButtonGroup variant='contained'>
32
- <Button
33
- onClick={() => {
34
- const { value } = emailRef.current;
35
- setEmailResult(ValidateEmail(value));
36
- }}
37
- >
38
- click
39
- </Button>
40
- </ButtonGroup>
41
-
42
- <hr style={{ margin: '10px 0' }} />
43
-
44
- <h2>Validate Phone[Taiwan only]</h2>
45
- <TextField inputRef={phoneRef} defaultValue='0912345678' label='phone' fullWidth />
46
- <pre>
47
- <code>{JSON.stringify(phoneResult ?? 'no result')}</code>
48
- </pre>
49
- <ButtonGroup variant='contained'>
50
- <Button
51
- onClick={() => {
52
- const { value } = phoneRef.current;
53
- setPhoneResult(ValidatePhone(value));
54
- }}
55
- >
56
- click
57
- </Button>
58
- </ButtonGroup>
59
-
60
- <hr style={{ margin: '10px 0' }} />
61
-
62
- <h2>Validate URL Address</h2>
63
- <TextField inputRef={urlRef} defaultValue='https://www.google.com/' label='URL' fullWidth />
64
- <pre>
65
- <code>{JSON.stringify(urlResult ?? 'no result')}</code>
66
- </pre>
67
- <ButtonGroup variant='contained'>
68
- <Button
69
- onClick={() => {
70
- const { value } = urlRef.current;
71
- setUrlResult(ValidateURL(value));
72
- }}
73
- >
74
- click
75
- </Button>
76
- </ButtonGroup>
77
-
78
- <hr style={{ margin: '10px 0' }} />
79
-
80
- <h2>Validate YouTube URL Address</h2>
81
- <TextField
82
- inputRef={youtubeRef}
83
- defaultValue='https://www.youtube.com/watch?v=09839DpTctU'
84
- label='YouTube URL'
85
- fullWidth
86
- />
87
- <pre>
88
- <code>{JSON.stringify(youtubeResult ?? 'no result')}</code>
89
- </pre>
90
- <ButtonGroup variant='contained'>
91
- <Button
92
- onClick={() => {
93
- const { value } = youtubeRef.current;
94
- setYoutubeResult(ValidateYoutubeURL(value));
95
- }}
96
- >
97
- click
98
- </Button>
99
- </ButtonGroup>
100
-
101
- <h2>Validate Invoice Number</h2>
102
- <TextField inputRef={invoiceRef} defaultValue='XS12345678' label='Invoice number' fullWidth />
103
- <pre>
104
- <code>{JSON.stringify(invoiceResult ?? 'no result')}</code>
105
- </pre>
106
- <ButtonGroup variant='contained'>
107
- <Button
108
- onClick={() => {
109
- const { value } = invoiceRef.current;
110
- console.log(ValiDateInvoice(value));
111
- setInvoiceResult(ValiDateInvoice(value));
112
- }}
113
- >
114
- click
115
- </Button>
116
- </ButtonGroup>
117
- </div>
118
- );
119
- };
120
- export default Demo;
@@ -1,25 +0,0 @@
1
- import { Button, ButtonGroup } from '@mui/material';
2
- import { useEffect } from 'react';
3
- import Code from '../components/code';
4
- import { name } from '../config';
5
-
6
- const codes = [{ title: '1. Installation', code: `npm install ${name} --save`, type: 'text' }];
7
-
8
- const Usage = () => {
9
- useEffect(() => {}, []);
10
- return (
11
- <div className='Usage'>
12
- <h2>Usage</h2>
13
- {codes.map((e) => (
14
- <div key={e.title}>
15
- <h3>{e.title}</h3>
16
- <Code code={e.code} theme={e.type} />
17
- </div>
18
- ))}
19
- <ButtonGroup variant='contained'>
20
- <Button>click</Button>
21
- </ButtonGroup>
22
- </div>
23
- );
24
- };
25
- export default Usage;
@@ -1,16 +0,0 @@
1
- @import url('https://fonts.googleapis.com/css2?family=Sora&display=swap&css');
2
- @import url('https://fonts.googleapis.com/css2?family=Titillium+Web&display=swap&css');
3
- @import url('./theme.less');
4
-
5
- body {
6
- margin: 0;
7
- background-color: @C4;
8
- color: @C5;
9
- font-family: 'Titillium Web', sans-serif;
10
-
11
- overscroll-behavior: none;
12
-
13
- .Demo > * {
14
- margin: 5px 0;
15
- }
16
- }
package/src/docs/theme.js DELETED
@@ -1,22 +0,0 @@
1
- import { createTheme } from '@mui/material/styles';
2
- import * as styles from '!!./module/lessVarsLoader!./theme.less';
3
-
4
- export const theme = createTheme({
5
- palette: {
6
- primary: {
7
- main: styles['@C1'],
8
- },
9
- secondary: {
10
- main: styles['@C2'],
11
- },
12
- error: {
13
- main: styles['@C3'],
14
- },
15
- success: {
16
- main: styles['@C4'],
17
- },
18
- warning: {
19
- main: styles['@C5'],
20
- },
21
- },
22
- });
@@ -1,6 +0,0 @@
1
- /* Color Theme Swatches in RGBA */
2
- @C1: rgba(57, 76, 89, 1);
3
- @C2: rgba(92, 121, 140, 1);
4
- @C3: rgba(162, 180, 191, 1);
5
- @C4: rgba(242, 242, 242, 1);
6
- @C5: rgba(12, 12, 12, 1);
package/src/lib/index.ts DELETED
@@ -1,57 +0,0 @@
1
- import { isEnglish, isNumber } from './misc';
2
-
3
- export const ValidateEmail = (email: string) => {
4
- return (
5
- String(email)
6
- .toLowerCase()
7
- .match(
8
- /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
9
- ) !== null
10
- );
11
- };
12
-
13
- export const ValidatePhone = (phone: string) => {
14
- return phone !== '' && phone.length === 10 && phone.slice(0, 2) === '09';
15
- };
16
-
17
- export const ValidateURL = (str: string) => {
18
- var pattern = new RegExp(
19
- '^(https?:\\/\\/)?' +
20
- '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +
21
- '((\\d{1,3}\\.){3}\\d{1,3}))' +
22
- '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' +
23
- '(\\?[;&a-z\\d%_.~+=-]*)?' +
24
- '(\\#[-a-z\\d_]*)?$',
25
- 'i',
26
- );
27
- return !!pattern.test(str);
28
- };
29
-
30
- export const ValidateYoutubeURL = (url: string) => {
31
- const pattern =
32
- /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/;
33
- const result = url.match(pattern);
34
- if (result) return result[1];
35
- return false;
36
- };
37
-
38
- export const ValiDateInvoice = (value: String) => {
39
- const currentValue = String(value);
40
- const { length } = currentValue;
41
- if (length !== 10) return false;
42
- const code = isEnglish(currentValue.slice(0, 2));
43
- if (!code) return false;
44
- const num = isNumber(currentValue.slice(2));
45
- if (!num) return false;
46
- return true;
47
- };
48
-
49
- const Validate = {
50
- email: ValidateEmail,
51
- phone: ValidatePhone,
52
- url: ValidateURL,
53
- youtubeID: ValidateYoutubeURL,
54
- invoice: ValiDateInvoice,
55
- };
56
-
57
- export default Validate;
package/src/lib/misc.ts DELETED
@@ -1,19 +0,0 @@
1
- export function isEnglish(s: String) {
2
- let i, charCode;
3
- let result = true;
4
- for (i = s.length; i--; ) {
5
- charCode = s.charCodeAt(i);
6
- if (charCode < 65 || charCode > 122) result = false;
7
- }
8
- return result;
9
- }
10
-
11
- export function isNumber(s: String) {
12
- let i, charCode;
13
- let result = true;
14
- for (i = s.length; i--; ) {
15
- charCode = s.charCodeAt(i);
16
- if (charCode < 48 || charCode > 57) result = false;
17
- }
18
- return result;
19
- }
@@ -1,38 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-tw">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width,user-scalable=0" />
6
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7
- <title><%= htmlWebpackPlugin.options.title %></title>
8
- <meta property="og:description" content="<%= htmlWebpackPlugin.options.description %>" />
9
- <meta property="og:title" content="<%= htmlWebpackPlugin.options.title %>" />
10
- <meta property="og:image" content="<%= htmlWebpackPlugin.options.url %>img/meta-img.jpg" />
11
- <meta property="og:image:width" content="1280" />
12
- <meta property="og:image:height" content="720" />
13
- <meta property="og:url" content="<%= htmlWebpackPlugin.options.url %>" />
14
- <meta property="og:type" content="website" />
15
- <meta property="fb:app_id" content="171368189560011" />
16
- <meta property="og:site_name" content="<%= htmlWebpackPlugin.options.title %>" />
17
- <link
18
- rel="apple-touch-icon"
19
- href="<%= htmlWebpackPlugin.options.url %>img/apple-touch-icon.jpg"
20
- />
21
- <link rel="image_src" href="<%= htmlWebpackPlugin.options.url %>img/meta-img.jpg" />
22
- <link
23
- href="<%= htmlWebpackPlugin.options.url %>img/favicon.ico"
24
- rel="icon"
25
- type="image/x-icon"
26
- />
27
- <link
28
- rel="stylesheet"
29
- href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
30
- />
31
- <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
32
- <meta name="apple-mobile-web-app-capable" content="no" />
33
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
34
- </head>
35
- <body>
36
- <div id="app"></div>
37
- </body>
38
- </html>
@@ -1,6 +0,0 @@
1
- const config = require('../src/docs/config');
2
- module.exports = {
3
- title: config.name,
4
- description: config.description,
5
- url: 'https://jameshsu1125.github.io/',
6
- };
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compileOnSave": true,
3
- "compilerOptions": {
4
- "outDir": "./lib/",
5
- "target": "es5",
6
- "module": "AMD",
7
- "declaration": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "jsx": "react-jsx",
13
- "moduleResolution": "node",
14
- "allowJs": true,
15
- "noImplicitThis": false,
16
- "paths": {
17
- "*": ["./lib/*"]
18
- }
19
- },
20
- "include": ["src/lib"]
21
- }
package/webpack.config.js DELETED
@@ -1,61 +0,0 @@
1
- const path = require('path');
2
- const HtmlWebpackPlugin = require('html-webpack-plugin');
3
- const template = './template/template.meta';
4
- const Meta = require(template);
5
-
6
- module.exports = {
7
- entry: path.join(__dirname, 'src/docs'),
8
- output: {
9
- path: path.join(__dirname, 'dist'),
10
- filename: 'bundle.js',
11
- },
12
- module: {
13
- rules: [
14
- {
15
- test: /\.(js|jsx)$/,
16
- use: 'babel-loader',
17
- exclude: /node_modules/,
18
- },
19
- {
20
- test: /\.tsx?$/,
21
- use: ['babel-loader', 'ts-loader'],
22
- exclude: /node_modules/,
23
- },
24
- {
25
- test: /\.(less|css)$/,
26
- use: [
27
- 'style-loader',
28
- {
29
- loader: 'css-loader',
30
- options: {
31
- esModule: false,
32
- },
33
- },
34
- 'postcss-loader',
35
- 'less-loader',
36
- ],
37
- },
38
- {
39
- test: /\.(png|jpg|gif|svg)$/,
40
- use: [
41
- {
42
- loader: 'file-loader',
43
- options: { name: 'img/[path][name].[ext]', context: 'src/docs' },
44
- },
45
- ],
46
- },
47
- ],
48
- },
49
- plugins: [
50
- new HtmlWebpackPlugin({
51
- ...Meta,
52
- template: 'template/template.html',
53
- }),
54
- ],
55
- resolve: {
56
- extensions: ['.tsx', '.ts', '.js', '.jsx'],
57
- },
58
- devServer: {
59
- port: 8000,
60
- },
61
- };