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

Commit ca2b28a

Browse files
committed
feat(next): try to make stuff work with the build but..
1 parent 451a1ab commit ca2b28a

36 files changed

+25187
-4978
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

dev/typescript/App.vue

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<template>
2+
<div id="app">
3+
<div class="page container">
4+
<h1 class="title m-4">{{ title }}</h1>
5+
<div class="flex justify-between">
6+
<div class="card p-6 mr-4">
7+
<dynamic-form
8+
:form="form"
9+
@submited="handleSubmit"
10+
@changed="valueChanged"
11+
@error="handleError"
12+
/>
13+
<button
14+
class="btn bg-teal-500 text-white hover:bg-teal-700 mt-4"
15+
submit="true"
16+
:form="form?.id"
17+
>
18+
Submit Form
19+
</button>
20+
</div>
21+
<div class="card p-6">
22+
<pre>{{ formValues }}</pre>
23+
</div>
24+
</div>
25+
</div>
26+
</div>
27+
</template>
28+
29+
<script lang="ts">
30+
import { defineComponent, onMounted, reactive, ref } from 'vue';
31+
import {
32+
TextInput,
33+
SelectInput,
34+
DynamicForm,
35+
EmailInput,
36+
FormValidation,
37+
PasswordInput,
38+
TextAreaInput,
39+
} from '../../dist/as-dynamic-forms.common';
40+
import { email, pattern } from '@/core/utils';
41+
42+
export default defineComponent({
43+
name: 'app',
44+
setup() {
45+
const title = ref('Vue Dynamic Forms');
46+
const formValues = reactive({});
47+
const form = reactive<DynamicForm>({
48+
id: 'example-form',
49+
fields: [
50+
new TextInput({
51+
label: 'Name',
52+
value: 'Alvaro',
53+
}),
54+
new EmailInput({
55+
label: 'Email',
56+
validations: [new FormValidation(email, 'Email format is incorrect')],
57+
}),
58+
new PasswordInput({
59+
label: 'Password',
60+
validations: [
61+
new FormValidation(
62+
pattern(
63+
'^(?=.*[a-z])(?=.*[A-Z])(?=.*)(?=.*[#$^+=!*()@%&]).{8,10}$',
64+
),
65+
'Password must contain at least 1 Uppercase, 1 Lowercase, 1 number, 1 special character and min 8 characters max 10',
66+
),
67+
],
68+
}),
69+
new SelectInput<string>({
70+
label: 'Games',
71+
customClass: 'w-1/2',
72+
options: [
73+
{
74+
key: 'the-last-of-us',
75+
value: 'The Last of Us II',
76+
},
77+
{
78+
key: 'death-stranding',
79+
value: 'Death Stranding',
80+
},
81+
{
82+
key: 'nier-automata',
83+
value: 'Nier Automata',
84+
},
85+
],
86+
}),
87+
new TextAreaInput({
88+
label: 'Bio',
89+
cols: 20,
90+
rows: 5,
91+
}),
92+
],
93+
});
94+
function handleSubmit(values) {
95+
console.log('Values Submitted', values);
96+
}
97+
function valueChanged(values) {
98+
Object.assign(formValues, values);
99+
}
100+
function handleError(errors) {
101+
console.error(errors);
102+
}
103+
onMounted(() =>
104+
setTimeout(() => {
105+
form.fields[0].label = 'RockNRoll';
106+
form.fields[0].value = 'James Bond';
107+
}, 2000),
108+
);
109+
return {
110+
title,
111+
form,
112+
handleSubmit,
113+
valueChanged,
114+
formValues,
115+
handleError,
116+
};
117+
},
118+
});
119+
</script>
120+
<style lang="scss"></style>
File renamed without changes.

dev/vue/main.ts renamed to dev/typescript/main.ts

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

6-
import { createDynamicForms } from '../../src/index';
6+
import { createDynamicForms } from '../../dist/as-dynamic-forms.common';
77

88
const VueDynamicForms = createDynamicForms({
99
theme: 'material',
1010
});
1111

1212
export const app = createApp(App);
1313

14-
app.use(VueDynamicForms).mount('#app');
14+
app.use(VueDynamicForms);
15+
16+
app.mount('#app');
File renamed without changes.
File renamed without changes.
File renamed without changes.

dev/vue/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../dist

dev/vue/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?

dev/vue/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../dist

0 commit comments

Comments
 (0)