@josercl/form-maker 1.0.0-alpha19 → 1.1.0-beta03
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/index.js +32 -30
- package/lib/components/FormMaker.vue +152 -148
- package/lib/components/FormMakerInput.vue +45 -47
- package/lib/components/inputs/{TextInput.vue → BasicInput.vue} +10 -17
- package/lib/components/inputs/CheckboxInput.vue +49 -63
- package/lib/components/inputs/FileInput.vue +14 -22
- package/lib/components/inputs/FormInputMixin.js +3 -5
- package/lib/components/inputs/RadioInput.vue +16 -23
- package/lib/components/inputs/SelectInput.vue +40 -24
- package/lib/components/inputs/TextAreaInput.vue +10 -17
- package/lib/components/texts/FormMakerInputError.vue +5 -0
- package/lib/components/texts/FormMakerInputHelp.vue +5 -0
- package/lib/components/texts/FormMakerInputLabel.vue +15 -0
- package/lib/utils.js +7 -1
- package/package.json +22 -25
- package/umd/index.umd.js +1 -1097
- package/commonjs/index.common.js +0 -1087
- package/lib/components/inputs/FormMakerInputError.vue +0 -15
- package/lib/components/inputs/FormMakerInputHelp.vue +0 -15
- package/lib/components/inputs/FormMakerInputLabel.vue +0 -19
- package/umd/index.umd.min.js +0 -1
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { FormInputMixin } from './FormInputMixin';
|
|
3
|
+
|
|
4
|
+
defineProps(FormInputMixin.props);
|
|
5
|
+
const emit = defineEmits(FormInputMixin.emits);
|
|
6
|
+
|
|
7
|
+
const handleFileSelect = event => {
|
|
8
|
+
if (event.target.files.length) {
|
|
9
|
+
const file = event.target.files[0];
|
|
10
|
+
emit('update:modelValue', file);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
</script>
|
|
14
|
+
|
|
1
15
|
<template>
|
|
2
16
|
<input
|
|
3
17
|
v-bind="$props"
|
|
@@ -5,25 +19,3 @@
|
|
|
5
19
|
@change="handleFileSelect"
|
|
6
20
|
>
|
|
7
21
|
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
import { FormInputMixin } from './FormInputMixin';
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
name: 'FileInput',
|
|
14
|
-
mixins: [ FormInputMixin ],
|
|
15
|
-
emits: [ 'update:modelValue' ],
|
|
16
|
-
setup(props, { emit }) {
|
|
17
|
-
const handleFileSelect = event => {
|
|
18
|
-
if (event.target.files.length) {
|
|
19
|
-
const file = event.target.files[0];
|
|
20
|
-
emit('update:modelValue', file);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
handleFileSelect,
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
</script>
|
|
@@ -23,9 +23,9 @@ export const injectFormClasses = () => {
|
|
|
23
23
|
export const getFormInputComputeds = props => {
|
|
24
24
|
const { label, error, helpText } = toRefs(props);
|
|
25
25
|
|
|
26
|
-
const hasErrors = computed(() =>
|
|
27
|
-
const hasLabel = computed(() =>
|
|
28
|
-
const hasHelpText = computed(() =>
|
|
26
|
+
const hasErrors = computed(() => Boolean(error.value));
|
|
27
|
+
const hasLabel = computed(() => Boolean(label.value));
|
|
28
|
+
const hasHelpText = computed(() => Boolean(helpText.value));
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
31
|
hasErrors,
|
|
@@ -47,7 +47,5 @@ export const FormInputMixin = {
|
|
|
47
47
|
name: { type: String, default: null },
|
|
48
48
|
placeholder: { type: String, default: null },
|
|
49
49
|
type: { type: String, default: 'text' },
|
|
50
|
-
options: { type: Array, default: () => [] },
|
|
51
|
-
optionGroups: { type: Object, default: () => ({}) },
|
|
52
50
|
},
|
|
53
51
|
};
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { FormInputMixin } from './FormInputMixin';
|
|
3
|
+
|
|
4
|
+
defineProps({
|
|
5
|
+
...FormInputMixin.props,
|
|
6
|
+
options: {
|
|
7
|
+
type: Array,
|
|
8
|
+
default: () => [],
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const emit = defineEmits(FormInputMixin.emits);
|
|
13
|
+
|
|
14
|
+
const handleClick = e => emit('update:modelValue', e.target.value);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
1
17
|
<template>
|
|
2
18
|
<div
|
|
3
19
|
v-for="(option, i) in options"
|
|
@@ -15,26 +31,3 @@
|
|
|
15
31
|
</label>
|
|
16
32
|
</div>
|
|
17
33
|
</template>
|
|
18
|
-
|
|
19
|
-
<script>
|
|
20
|
-
import { FormInputMixin } from './FormInputMixin';
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
name: 'RadioInput',
|
|
24
|
-
emits: [ 'update:modelValue' ],
|
|
25
|
-
mixins: [ FormInputMixin ],
|
|
26
|
-
props: {
|
|
27
|
-
label: {
|
|
28
|
-
type: String,
|
|
29
|
-
default: null,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
setup(props, { emit }) {
|
|
33
|
-
const handleClick = e => emit('update:modelValue', e.target.value);
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
handleClick,
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
</script>
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { FormInputMixin } from './FormInputMixin';
|
|
4
|
+
import setupVModel from '../../utils';
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
...FormInputMixin.props,
|
|
8
|
+
options: {
|
|
9
|
+
type: Array,
|
|
10
|
+
default: () => [],
|
|
11
|
+
},
|
|
12
|
+
optionGroups: {
|
|
13
|
+
type: Object,
|
|
14
|
+
default: () => ({}),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const emit = defineEmits(FormInputMixin.emits);
|
|
19
|
+
|
|
20
|
+
const value = setupVModel(props, emit);
|
|
21
|
+
|
|
22
|
+
const hasGroups = Object.keys(props.optionGroups).length > 0;
|
|
23
|
+
|
|
24
|
+
const fixedOptions = computed(() => props.options.map(o => {
|
|
25
|
+
if (typeof o === 'object') {
|
|
26
|
+
return o;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
label: o,
|
|
30
|
+
value: o,
|
|
31
|
+
};
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
console.log(fixedOptions.value);
|
|
35
|
+
</script>
|
|
36
|
+
|
|
1
37
|
<template>
|
|
2
38
|
<select
|
|
3
39
|
:id="id"
|
|
@@ -13,16 +49,16 @@
|
|
|
13
49
|
:label="key"
|
|
14
50
|
>
|
|
15
51
|
<option
|
|
16
|
-
v-for="(optLabel,
|
|
17
|
-
:key="`option_${
|
|
18
|
-
:value="
|
|
52
|
+
v-for="(optLabel, optValue) in opts"
|
|
53
|
+
:key="`option_${optValue}`"
|
|
54
|
+
:value="optValue"
|
|
19
55
|
>
|
|
20
56
|
{{ optLabel }}
|
|
21
57
|
</option>
|
|
22
58
|
</optgroup>
|
|
23
59
|
</template>
|
|
24
60
|
<option
|
|
25
|
-
v-for="(option,i) in
|
|
61
|
+
v-for="(option,i) in fixedOptions"
|
|
26
62
|
v-else
|
|
27
63
|
:key="`option_${i}`"
|
|
28
64
|
:value="option.value"
|
|
@@ -31,23 +67,3 @@
|
|
|
31
67
|
</option>
|
|
32
68
|
</select>
|
|
33
69
|
</template>
|
|
34
|
-
|
|
35
|
-
<script>
|
|
36
|
-
import setupVModel from '../../utils';
|
|
37
|
-
import { FormInputMixin } from './FormInputMixin';
|
|
38
|
-
|
|
39
|
-
export default {
|
|
40
|
-
name: 'SelectInput',
|
|
41
|
-
mixins: [ FormInputMixin ],
|
|
42
|
-
setup(props, { emit }) {
|
|
43
|
-
const value = setupVModel(props, emit);
|
|
44
|
-
|
|
45
|
-
const hasGroups = Object.keys(props.optionGroups).length > 0;
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
value,
|
|
49
|
-
hasGroups,
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
</script>
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import setupVModel from '../../utils';
|
|
3
|
+
import { FormInputMixin } from './FormInputMixin';
|
|
4
|
+
|
|
5
|
+
const props = defineProps(FormInputMixin.props);
|
|
6
|
+
const emit = defineEmits(FormInputMixin.emits);
|
|
7
|
+
|
|
8
|
+
const value = setupVModel(props, emit);
|
|
9
|
+
</script>
|
|
10
|
+
|
|
1
11
|
<template>
|
|
2
12
|
<textarea
|
|
3
13
|
:id="id"
|
|
@@ -7,20 +17,3 @@
|
|
|
7
17
|
:placeholder="placeholder"
|
|
8
18
|
/>
|
|
9
19
|
</template>
|
|
10
|
-
|
|
11
|
-
<script>
|
|
12
|
-
import setupVModel from '../../utils';
|
|
13
|
-
import { FormInputMixin } from './FormInputMixin';
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
name: 'TextAreaInput',
|
|
17
|
-
mixins: [ FormInputMixin ],
|
|
18
|
-
setup(props, { emit }) {
|
|
19
|
-
const value = setupVModel(props, emit);
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
value,
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { h } from 'vue';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
props: {
|
|
6
|
+
id: {
|
|
7
|
+
type: String,
|
|
8
|
+
default: null,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
setup(props, { slots, attrs }) {
|
|
12
|
+
return () => h('label', { ...attrs, for: props.id }, slots.default());
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
</script>
|
package/lib/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed } from 'vue';
|
|
1
|
+
import { computed, h } from 'vue';
|
|
2
2
|
|
|
3
3
|
const setupVModel = (props, emit, propName = 'modelValue') => computed({
|
|
4
4
|
get: () => props[propName],
|
|
@@ -6,3 +6,9 @@ const setupVModel = (props, emit, propName = 'modelValue') => computed({
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export default setupVModel;
|
|
9
|
+
|
|
10
|
+
export const simpleComponent = () => ({
|
|
11
|
+
setup(props, { slots, attrs }) {
|
|
12
|
+
return () => h('div', attrs, slots.default());
|
|
13
|
+
},
|
|
14
|
+
});
|
package/package.json
CHANGED
|
@@ -1,47 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@josercl/form-maker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0-beta03",
|
|
4
4
|
"description": "Form generator using vue 3",
|
|
5
5
|
"author": "Jose Carrero <josercl@gmail.com>",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"build": "
|
|
10
|
-
"build-docs": "
|
|
11
|
-
"
|
|
12
|
-
"lint": "
|
|
7
|
+
"docs": "vite -c docs.config.js dev --port 9090",
|
|
8
|
+
"dev": "vite -c dev.config.js dev",
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"build-docs": "vite -c docs.config.js build",
|
|
11
|
+
"preview": "vite -c docs.config.js preview --port 5050",
|
|
12
|
+
"lint": "eslint --ext .vue,.js lib/ docs/ dev/ index.js --fix"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"index.js",
|
|
16
16
|
"lib/**",
|
|
17
|
-
"umd/*.js"
|
|
18
|
-
"umd/*.map",
|
|
19
|
-
"commonjs/*.js",
|
|
20
|
-
"commonjs/*.map"
|
|
17
|
+
"umd/*.js"
|
|
21
18
|
],
|
|
22
19
|
"homepage": "https://josercl.gitlab.io/form-maker",
|
|
23
20
|
"dependencies": {
|
|
24
|
-
"
|
|
25
|
-
"vue": "^3.0.0"
|
|
21
|
+
"vue": "^3.2.31"
|
|
26
22
|
},
|
|
27
23
|
"devDependencies": {
|
|
24
|
+
"@babel/core": "^7.17.5",
|
|
25
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
28
26
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
29
27
|
"@fortawesome/free-brands-svg-icons": "^5.15.1",
|
|
30
28
|
"@fortawesome/free-regular-svg-icons": "^5.15.1",
|
|
31
29
|
"@fortawesome/vue-fontawesome": "^3.0.0-2",
|
|
32
|
-
"@tailwindcss/
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@vue/
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"eslint": "^6.7.2",
|
|
40
|
-
"eslint-plugin-import": "^2.20.2",
|
|
41
|
-
"eslint-plugin-vue": "^7.0.0-0",
|
|
30
|
+
"@tailwindcss/forms": "^0.4.0",
|
|
31
|
+
"@tailwindcss/typography": "^0.5.2",
|
|
32
|
+
"@vitejs/plugin-vue": "^2.2.2",
|
|
33
|
+
"@vue/eslint-config-airbnb": "^6.0.0",
|
|
34
|
+
"autoprefixer": "^10.4.2",
|
|
35
|
+
"eslint": "^8.10.0",
|
|
36
|
+
"eslint-plugin-vue": "^8.5.0",
|
|
42
37
|
"highlight.js": "^10.2.1",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
38
|
+
"postcss": "^8.4.7",
|
|
39
|
+
"tailwindcss": "^3.0.23",
|
|
40
|
+
"vite": "^2.8.4",
|
|
41
|
+
"vue-router": "^4.0.12"
|
|
45
42
|
},
|
|
46
43
|
"keywords": [
|
|
47
44
|
"vue 3",
|