Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit ca16e61

Browse files
committed
feat(ts): solve some ts issues
1 parent fe146ef commit ca16e61

File tree

12 files changed

+1958
-2273
lines changed

12 files changed

+1958
-2273
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: ci
33
on:
44
pull_request:
55
branches:
6-
- master
6+
- 0.x
77
- next
88
- dev
99

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release
22
on:
33
push:
44
branches:
5-
- master
5+
- 0.x
66
- next
77
jobs:
88
release:

dev/typescript/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ import {
5656
CheckboxInput,
5757
RadioInput,
5858
InputBase,
59+
email,
60+
pattern,
5961
} from '../../src';
60-
import { email, pattern } from '@/core/utils';
6162
6263
export default defineComponent({
6364
name: 'app',

dev/typescript/main.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ import { createApp } from 'vue';
33
import App from './App.vue';
44
import './styles/main.scss';
55

6-
import { createDynamicForms } from '../../src';
6+
// import { createDynamicForms } from '../../src';
7+
import { createDynamicForms } from '../../dist/as-dynamic-forms.esm';
78

89
const VueDynamicForms = createDynamicForms({
9-
theme: 'material',
10+
autoValidate: true,
11+
form: {
12+
customClass: 'plugin-options-class-added',
13+
method: 'POST',
14+
netlify: false,
15+
netlifyHoneypot: null,
16+
},
1017
});
1118

1219
export const app = createApp(App);

dev/vue/App.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ import {
3434
EmailInput,
3535
FormValidation,
3636
PasswordInput,
37+
email,
38+
pattern,
3739
TextAreaInput,
38-
} from '../../dist/as-dynamic-forms.esm';
39-
import { email, pattern } from '@/core/utils';
40+
} from '../../src';
4041
4142
export default defineComponent({
4243
name: 'app',

dev/vue/styles/_vendors.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$input-border-radius: 50px; */
99
// @import '../../src/styles/themes/default.scss';
1010

11-
@import '@/styles/themes/default.scss';
11+
/* @import '@/styles/themes/default.scss'; */
1212

1313
// Third-party
1414

package-lock.json

Lines changed: 1907 additions & 2243 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"release": {
1818
"branches": [
19-
"master",
19+
"0.x",
2020
"next"
2121
]
2222
},
@@ -41,13 +41,13 @@
4141
"vue": "^3.0.0"
4242
},
4343
"devDependencies": {
44-
"@microsoft/api-extractor": "^7.9.19",
44+
"@microsoft/api-extractor": "^7.9.22",
4545
"@rollup/plugin-buble": "^0.21.3",
46-
"@rollup/plugin-commonjs": "^15.0.0",
46+
"@rollup/plugin-commonjs": "^15.1.0",
4747
"@rollup/plugin-node-resolve": "^9.0.0",
4848
"@rollup/plugin-replace": "^2.3.3",
49-
"@typescript-eslint/eslint-plugin": "^4.1.1",
50-
"@typescript-eslint/parser": "^4.1.1",
49+
"@typescript-eslint/eslint-plugin": "^4.2.0",
50+
"@typescript-eslint/parser": "^4.2.0",
5151
"@vue/cli-plugin-babel": "4.5.6",
5252
"@vue/cli-plugin-eslint": "4.5.6",
5353
"@vue/cli-plugin-typescript": "~4.5.6",
@@ -61,14 +61,14 @@
6161
"babel-eslint": "10.1.0",
6262
"babel-jest": "26.3.0",
6363
"chalk": "^4.1.0",
64-
"eslint": "7.9.0",
64+
"eslint": "7.10.0",
6565
"eslint-plugin-prettier": "^3.1.4",
6666
"eslint-plugin-vue": "^7.0.0-0",
6767
"node-sass": "4.14.1",
6868
"prettier": "2.1.2",
69-
"rollup": "^2.27.1",
69+
"rollup": "^2.28.2",
7070
"rollup-plugin-terser": "^7.0.2",
71-
"rollup-plugin-typescript2": "^0.27.2",
71+
"rollup-plugin-typescript2": "^0.27.3",
7272
"rollup-plugin-vue": "^6.0.0-beta.10",
7373
"sass-loader": "10.0.2",
7474
"semantic-release": "17.1.2",
@@ -77,6 +77,9 @@
7777
"typescript": "~4.0.3",
7878
"vue": "^3.0.0",
7979
"vue-select": "3.10.8",
80-
"vuepress": "1.5.4"
80+
"vuepress": "1.6.0"
81+
},
82+
"dependencies": {
83+
"rollup-plugin-scss": "^2.6.0"
8184
}
8285
}

src/composables/input-events.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ export function useInputEvents(
44
control: FormControl<any> | undefined,
55
emit: any,
66
) {
7-
function onChange($event: any) {
7+
function onChange($event: any): void {
88
if (control) {
99
control.value = $event.target.value;
1010
control.dirty = true;
1111
}
1212
emit('changed', $event.target.value);
1313
}
14-
function onCheck($event: any) {
14+
function onCheck($event: any): void {
1515
if (control) {
1616
control.value = $event.target.checked;
1717
control.dirty = true;
1818
}
1919
emit('changed', $event.target.checked);
2020
}
21-
function onFocus() {
21+
function onFocus(): void {
2222
emit('focus');
2323
}
24-
function onBlur() {
24+
function onBlur(): void {
2525
emit('blur');
2626
if (control) {
2727
control.touched = true;

src/core/models.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,10 @@ export class FormControl<T> extends InputBase<T> {
127127
});
128128
}
129129
}
130+
131+
export interface FormOptions {
132+
customClass?: string;
133+
method?: string;
134+
netlify?: boolean;
135+
netlifyHoneypot?: string;
136+
}

src/core/utils/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const { assign, entries, values, keys } = Object;
22

3-
export const slugify = (text: string) =>
3+
export const slugify = (text: string): string =>
44
text
55
.toString()
66
.toLowerCase()

src/core/utils/validators.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
export const isEmptyInputValue = value =>
1+
import { FormControl } from '../models';
2+
3+
export const isEmptyInputValue = (value: any) =>
24
value == null || value === '' || value.length === 0;
35

46
const EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
57
const URL_REGEXP = /^((?:(https?):\/\/)?((?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9][0-9]|[0-9])\.(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9][0-9]|[0-9])\.)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9][0-9]|[0-9])\.)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9][0-9]|[0-9]))|(?:(?:(?:\w+\.){1,2}[\w]{2,3})))(?::(\d+))?((?:\/[\w]+)*)(?:\/|(\/[\w]+\.[\w]{3,4})|(\?(?:([\w]+=[\w]+)&)*([\w]+=[\w]+))?|\?(?:(wsdl|wadl))))$/;
68

7-
export const required = control =>
9+
export const required = (control: FormControl<any>) =>
810
isEmptyInputValue(control.value) ? { required: true } : null;
911

10-
export const min = min => control => {
12+
export const min = (min: number) => (control: FormControl<any>) => {
1113
if (isEmptyInputValue(control.value) || isEmptyInputValue(min)) {
1214
return null; // don't validate empty values to allow optional controls
1315
}
@@ -18,7 +20,7 @@ export const min = min => control => {
1820
: null;
1921
};
2022

21-
export const max = max => control => {
23+
export const max = (max: number) => (control: FormControl<any>) => {
2224
if (isEmptyInputValue(control.value) || isEmptyInputValue(max)) {
2325
return null; // don't validate empty values to allow optional controls
2426
}
@@ -30,21 +32,21 @@ export const max = max => control => {
3032
: null;
3133
};
3234

33-
export const email = control => {
35+
export const email = (control: FormControl<any>) => {
3436
if (isEmptyInputValue(control.value)) {
3537
return null; // don't validate empty values to allow optional controls
3638
}
3739
return EMAIL_REGEXP.test(control.value) ? null : { email: true };
3840
};
3941

40-
export const url = control => {
42+
export const url = (control: FormControl<any>) => {
4143
if (isEmptyInputValue(control.value)) {
4244
return null; // don't validate empty values to allow optional controls
4345
}
4446
return URL_REGEXP.test(control.value) ? null : { email: true };
4547
};
4648

47-
export const minLength = minLength => control => {
49+
export const minLength = (minLength: number) => (control: FormControl<any>) => {
4850
if (isEmptyInputValue(control.value)) {
4951
return null; // don't validate empty values to allow optional controls
5052
}
@@ -54,7 +56,7 @@ export const minLength = minLength => control => {
5456
: null;
5557
};
5658

57-
export const maxLength = maxLength => control => {
59+
export const maxLength = (maxLength: number) => (control: FormControl<any>) => {
5860
const length = control.value ? control.value.length : 0;
5961
return length > maxLength
6062
? { maxlength: { requiredLength: maxLength, actualLength: length } }

0 commit comments

Comments
 (0)