@josercl/form-maker 1.0.0-alpha18 → 1.1.0-beta02

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.
@@ -1,15 +1,12 @@
1
+ <script setup>
2
+ defineProps({
3
+ text: {
4
+ type: String,
5
+ default: null,
6
+ },
7
+ });
8
+ </script>
9
+
1
10
  <template>
2
11
  <div>{{ text }}</div>
3
12
  </template>
4
-
5
- <script>
6
- export default {
7
- name: 'FormMakerInputError',
8
- props: {
9
- text: {
10
- type: String,
11
- default: null,
12
- },
13
- },
14
- };
15
- </script>
@@ -1,15 +1,12 @@
1
+ <script setup>
2
+ defineProps({
3
+ text: {
4
+ type: String,
5
+ default: null,
6
+ },
7
+ });
8
+ </script>
9
+
1
10
  <template>
2
11
  <div>{{ text }}</div>
3
12
  </template>
4
-
5
- <script>
6
- export default {
7
- name: 'FormMakerInputHelp',
8
- props: {
9
- text: {
10
- type: String,
11
- default: null,
12
- },
13
- },
14
- };
15
- </script>
@@ -1,19 +1,16 @@
1
+ <script setup>
2
+ defineProps({
3
+ text: {
4
+ type: String,
5
+ default: null,
6
+ },
7
+ id: {
8
+ type: String,
9
+ default: null,
10
+ },
11
+ });
12
+ </script>
13
+
1
14
  <template>
2
15
  <label :for="id">{{ text }}</label>
3
16
  </template>
4
-
5
- <script>
6
- export default {
7
- name: 'FormMakerInputLabel',
8
- props: {
9
- text: {
10
- type: String,
11
- default: null,
12
- },
13
- id: {
14
- type: String,
15
- default: null,
16
- },
17
- },
18
- };
19
- </script>
@@ -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, value) in opts"
17
- :key="`option_${value}`"
18
- :value="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 options"
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>
package/lib/utils.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,47 +1,44 @@
1
1
  {
2
2
  "name": "@josercl/form-maker",
3
- "version": "1.0.0-alpha18",
3
+ "version": "1.1.0-beta02",
4
4
  "description": "Form generator using vue 3",
5
5
  "author": "Jose Carrero <josercl@gmail.com>",
6
6
  "scripts": {
7
- "build:umd": "vue-cli-service build --target lib --formats umd,umd-min --dest umd --filename index --name FormMaker index.js",
8
- "build:common": "vue-cli-service build --target lib --formats commonjs --dest commonjs --filename index --name FormMaker index.js",
9
- "build": "npm run build:umd && npm run build:common",
10
- "build-docs": "vue-cli-service build",
11
- "serve": "vue-cli-service serve",
12
- "lint": "vue-cli-service lint --ext .js,.vue lib/ docs/ index.js"
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"
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
- "core-js": "^3.6.5",
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/typography": "^0.2.0",
33
- "@vue/cli-plugin-babel": "~4.5.0",
34
- "@vue/cli-plugin-eslint": "^4.5.8",
35
- "@vue/cli-service": "~4.5.0",
36
- "@vue/compiler-sfc": "^3.0.0",
37
- "@vue/eslint-config-airbnb": "^5.0.2",
38
- "babel-eslint": "^10.1.0",
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
- "tailwindcss": "^1.9.6",
44
- "vue-router": "^4.0.0-rc.1"
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",