@modelforms/fontawesome-vuetify 1.0.3 → 1.0.4
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/components/form/Form.vue +2 -2
- package/components/form/area/Area.vue +7 -2
- package/components/form/complete/Complete.vue +20 -12
- package/components/form/date/Date.vue +10 -3
- package/components/form/functions/complete.ts +6 -4
- package/components/form/functions/helper.ts +11 -0
- package/components/form/functions/init.ts +4 -0
- package/components/form/functions/rules.ts +6 -12
- package/components/form/models/{h-model.ts → completeModels.ts} +1 -5
- package/components/form/models/{model.ts → formModels.ts} +8 -2
- package/components/form/models/resources.ts +16 -0
- package/components/form/number/Number.vue +9 -3
- package/components/form/text/Text.vue +6 -1
- package/components/index.d.ts +1 -1
- package/components/test/form.test.ts +1 -1
- package/dist/index.amd.ts +15 -15
- package/dist/index.cjs.ts +15 -15
- package/package.json +1 -1
- package/components/form/models/references.ts +0 -4
package/components/form/Form.vue
CHANGED
|
@@ -76,8 +76,8 @@ import Number from './../form/number/Number.vue';
|
|
|
76
76
|
import Date from './../form/date/Date.vue';
|
|
77
77
|
import Complete from './../form/complete/Complete.vue';
|
|
78
78
|
import Area from './../form/area/Area.vue';
|
|
79
|
-
import { GridModel } from './models/
|
|
80
|
-
import { button, event } from './models/
|
|
79
|
+
import { GridModel } from './models/formModels';
|
|
80
|
+
import { button, event } from './models/resources';
|
|
81
81
|
|
|
82
82
|
export default{
|
|
83
83
|
components: {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
<v-container fluid>
|
|
3
3
|
<v-textarea
|
|
4
4
|
:v-model="model"
|
|
5
|
-
:model-value="value"
|
|
6
5
|
:rules="rule"
|
|
7
6
|
:label="label"
|
|
7
|
+
:model-value="value"
|
|
8
8
|
@blur="blur($event)"
|
|
9
9
|
counter
|
|
10
10
|
></v-textarea>
|
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
|
+
import { initComponent } from '../functions/init';
|
|
15
16
|
import { setRule } from '../functions/rules';
|
|
16
|
-
import { valueEvent } from '
|
|
17
|
+
import { valueEvent } from '../models/resources';
|
|
17
18
|
|
|
18
19
|
export default{
|
|
20
|
+
name: "AreaControl",
|
|
19
21
|
props: {
|
|
20
22
|
value: {
|
|
21
23
|
type: String,
|
|
@@ -36,6 +38,9 @@ export default{
|
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
40
|
emits: [valueEvent],
|
|
41
|
+
setup(data){
|
|
42
|
+
initComponent(data, name);
|
|
43
|
+
},
|
|
39
44
|
data() {
|
|
40
45
|
return {
|
|
41
46
|
rule: setRule(this.rules)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<template> <v-container fluid>
|
|
2
2
|
<v-autocomplete
|
|
3
3
|
ref="template"
|
|
4
|
-
menu-icon=""
|
|
5
4
|
:v-model="model"
|
|
6
|
-
:filter-keys="['title']"
|
|
7
5
|
:items="items"
|
|
8
6
|
:item-title="title"
|
|
9
7
|
:label="label"
|
|
10
8
|
:rules="rule"
|
|
11
|
-
v-bind:model-value="value"
|
|
12
9
|
:search="value"
|
|
13
10
|
:multiple="multiple"
|
|
11
|
+
:filter-keys="filterKeys"
|
|
12
|
+
:menu-icon="defaultIcon"
|
|
13
|
+
v-bind:model-value="value"
|
|
14
14
|
@update:search="select($event)"
|
|
15
15
|
@blur="blur($event)">
|
|
16
16
|
<template v-if="arrowDown" #append-inner>
|
|
@@ -36,15 +36,19 @@
|
|
|
36
36
|
|
|
37
37
|
<script lang="ts">
|
|
38
38
|
import { faArrowAltCircleDown, faSquare } from '@fortawesome/free-regular-svg-icons';
|
|
39
|
+
import { faCheck } from '@fortawesome/free-solid-svg-icons';
|
|
39
40
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
40
41
|
import { setRule } from '../functions/rules';
|
|
41
|
-
import {
|
|
42
|
-
import { faCheck } from '@fortawesome/free-solid-svg-icons';
|
|
42
|
+
import { RowItem, RowProps } from '../models/completeModels';
|
|
43
43
|
import { useTemplateRef } from 'vue';
|
|
44
44
|
import { addItem, removeItem } from '../functions/complete';
|
|
45
|
-
import { valueEvent } from '
|
|
45
|
+
import { empty, defaultIcon, valueEvent, filterKeys, template } from '../models/resources';
|
|
46
|
+
import { CompleteItems } from '../models/formModels';
|
|
47
|
+
import { initComponent } from '../functions/init';
|
|
48
|
+
import { findFirst } from '../functions/helper';
|
|
46
49
|
|
|
47
50
|
export default{
|
|
51
|
+
name: "CompleteControl",
|
|
48
52
|
props: {
|
|
49
53
|
value: {
|
|
50
54
|
type: String,
|
|
@@ -84,6 +88,9 @@
|
|
|
84
88
|
this.initAriaRows();
|
|
85
89
|
}
|
|
86
90
|
},
|
|
91
|
+
setup(data){
|
|
92
|
+
initComponent(data, name);
|
|
93
|
+
},
|
|
87
94
|
data() {
|
|
88
95
|
return {
|
|
89
96
|
selected: [] as CompleteItems[],
|
|
@@ -95,14 +102,15 @@
|
|
|
95
102
|
arrowDown: faArrowAltCircleDown,
|
|
96
103
|
square: faSquare,
|
|
97
104
|
check: faCheck,
|
|
98
|
-
search:
|
|
99
|
-
|
|
105
|
+
search: empty,
|
|
106
|
+
defaultIcon: defaultIcon,
|
|
107
|
+
filterKeys: filterKeys,
|
|
108
|
+
template: template
|
|
100
109
|
}
|
|
101
110
|
},
|
|
102
111
|
methods: {
|
|
103
112
|
select(event) {
|
|
104
113
|
if(event.length!) {
|
|
105
|
-
console.log(event)
|
|
106
114
|
this.value = event;
|
|
107
115
|
this.$emit(valueEvent, this.items.find(item => item[this.title!] == event));
|
|
108
116
|
}
|
|
@@ -142,9 +150,9 @@
|
|
|
142
150
|
changeRow(value: CompleteItems, index) {
|
|
143
151
|
for(let item of this.rows){
|
|
144
152
|
if(item.id == index){
|
|
145
|
-
item.row
|
|
146
|
-
item.icon
|
|
147
|
-
item.active
|
|
153
|
+
findFirst(item.row)(value);
|
|
154
|
+
findFirst(item.icon)(value);
|
|
155
|
+
findFirst(item.active)(value);
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
},
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
<v-container fluid>
|
|
3
3
|
<v-date-input
|
|
4
4
|
:v-model="model"
|
|
5
|
-
:model-value="value"
|
|
6
5
|
:rules="rule"
|
|
7
6
|
:label="label"
|
|
7
|
+
:model-value="value"
|
|
8
|
+
:prepend-icon="defaultIcon"
|
|
8
9
|
@save="select($event)">
|
|
9
10
|
<template v-if="faCalendar" #append-inner>
|
|
10
11
|
<FontAwesomeIcon :icon="faCalendar" />
|
|
@@ -17,9 +18,11 @@
|
|
|
17
18
|
import { faCalendar } from '@fortawesome/free-regular-svg-icons';
|
|
18
19
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
19
20
|
import { setRule } from '../functions/rules';
|
|
20
|
-
import { valueEvent } from '
|
|
21
|
+
import { defaultIcon, valueEvent } from '../models/resources';
|
|
22
|
+
import { initComponent } from '../functions/init';
|
|
21
23
|
|
|
22
24
|
export default {
|
|
25
|
+
name: "DateControl",
|
|
23
26
|
components: {
|
|
24
27
|
FontAwesomeIcon
|
|
25
28
|
},
|
|
@@ -43,10 +46,14 @@ export default {
|
|
|
43
46
|
}
|
|
44
47
|
},
|
|
45
48
|
emits: [valueEvent],
|
|
49
|
+
setup(data){
|
|
50
|
+
initComponent(data, name);
|
|
51
|
+
},
|
|
46
52
|
data() {
|
|
47
53
|
return {
|
|
48
54
|
rule: setRule(this.rules),
|
|
49
|
-
faCalendar: faCalendar
|
|
55
|
+
faCalendar: faCalendar,
|
|
56
|
+
defaultIcon: defaultIcon
|
|
50
57
|
}
|
|
51
58
|
},
|
|
52
59
|
methods: {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { CompleteItems } from "../models/
|
|
1
|
+
import { CompleteItems } from "../models/formModels";
|
|
2
|
+
import { empty, searchError } from "../models/resources";
|
|
3
|
+
import { componentType } from "./init";
|
|
2
4
|
|
|
3
5
|
export const removeItem = (search: string, value: CompleteItems) => {
|
|
4
6
|
if(search == null || search == undefined){
|
|
5
|
-
search =
|
|
7
|
+
search = empty;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
let lastIndex = search.indexOf(', ' + value.title);
|
|
@@ -27,12 +29,12 @@ export const removeItem = (search: string, value: CompleteItems) => {
|
|
|
27
29
|
return result;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
new Error(
|
|
32
|
+
new Error(`${searchError} ${componentType.component}`);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export const addItem = (compare: string, value: CompleteItems, first = true) => {
|
|
34
36
|
if(value.title == undefined){
|
|
35
|
-
return
|
|
37
|
+
return empty;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
if(!first){
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { index, ruleError } from "../models/resources";
|
|
2
|
+
import { componentType } from "./init";
|
|
3
|
+
import { findFirst, findLast } from './helper';
|
|
4
|
+
|
|
1
5
|
export const setRule = (rules: any) => {
|
|
2
6
|
if(rules.length > 0){
|
|
3
7
|
let rule = parseRules(rules);
|
|
@@ -7,10 +11,9 @@ export const setRule = (rules: any) => {
|
|
|
7
11
|
}
|
|
8
12
|
}
|
|
9
13
|
|
|
10
|
-
const index = 1;
|
|
11
14
|
const parseRules = (rules: string[]) => {
|
|
12
15
|
for(let rule of rules){
|
|
13
|
-
let parts = rule.split(
|
|
16
|
+
let parts = rule.split(":");
|
|
14
17
|
|
|
15
18
|
let rules = getRules(findLast(parts), parts[index]).map((value) => {
|
|
16
19
|
var entries = Object.keys(value);
|
|
@@ -26,17 +29,8 @@ const parseRules = (rules: string[]) => {
|
|
|
26
29
|
return findFirst(rules);
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
new Error(
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const findLast = (entries: string[]) => {
|
|
34
|
-
return entries[entries.length - index];
|
|
35
|
-
}
|
|
32
|
+
new Error(`${ruleError} ${componentType.component}`);
|
|
36
33
|
|
|
37
|
-
const findFirst = (entires: any[]) => {
|
|
38
|
-
for(let entry of entires){
|
|
39
|
-
return entry;
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
|
|
3
3
|
export class GridModel {
|
|
4
4
|
name: string = "";
|
|
@@ -11,6 +11,12 @@ export class Row{
|
|
|
11
11
|
cols: Col[] = [];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export class CompleteItems{
|
|
15
|
+
title?: '';
|
|
16
|
+
abbr?: 0
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
14
20
|
class Col{
|
|
15
21
|
name: string = "";
|
|
16
22
|
type: "text" | "number" | "date" | "complete" | "area" = "text";
|
|
@@ -26,4 +32,4 @@ class Complete{
|
|
|
26
32
|
itemValue: CompleteItems[] = [];
|
|
27
33
|
multiple?: boolean = false;
|
|
28
34
|
title: "title" | "abbr" = "title";
|
|
29
|
-
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const button = 'SUBMIT';
|
|
2
|
+
export const event = 'submit';
|
|
3
|
+
export const valueEvent = 'value';
|
|
4
|
+
|
|
5
|
+
export const searchError = 'Wrong search parameter type!';
|
|
6
|
+
export const ruleError = 'Wrong rule parameter type! ';
|
|
7
|
+
|
|
8
|
+
export const empty = '';
|
|
9
|
+
|
|
10
|
+
export const defaultIcon = '';
|
|
11
|
+
|
|
12
|
+
export const controlVariant = 'hidden';
|
|
13
|
+
export const filterKeys = ['title'];
|
|
14
|
+
|
|
15
|
+
export const template = {};
|
|
16
|
+
export const index = 1;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
:rules="rule"
|
|
7
7
|
:label="label"
|
|
8
8
|
:precision="2"
|
|
9
|
-
control-variant="
|
|
9
|
+
:control-variant="controlVariant"
|
|
10
10
|
@blur="blur($event)">
|
|
11
11
|
</v-number-input>
|
|
12
12
|
</v-container>
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
<script lang="ts">
|
|
16
16
|
import { setRule } from '../functions/rules';
|
|
17
|
-
import {
|
|
17
|
+
import { initComponent } from '../functions/init';
|
|
18
|
+
import { controlVariant, valueEvent } from '../models/resources';
|
|
18
19
|
|
|
19
20
|
export default {
|
|
21
|
+
name: "NumberControl",
|
|
20
22
|
props: {
|
|
21
23
|
value: {
|
|
22
24
|
type: Number,
|
|
@@ -37,9 +39,13 @@ export default {
|
|
|
37
39
|
}
|
|
38
40
|
},
|
|
39
41
|
emits: [valueEvent],
|
|
42
|
+
setup(data){
|
|
43
|
+
initComponent(data, name);
|
|
44
|
+
},
|
|
40
45
|
data() {
|
|
41
46
|
return {
|
|
42
|
-
rule: setRule(this.rules)
|
|
47
|
+
rule: setRule(this.rules),
|
|
48
|
+
controlVariant: controlVariant
|
|
43
49
|
}
|
|
44
50
|
},
|
|
45
51
|
methods: {
|
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
|
+
import { initComponent } from '../functions/init';
|
|
15
16
|
import { setRule } from '../functions/rules';
|
|
16
|
-
import { valueEvent } from '
|
|
17
|
+
import { valueEvent } from '../models/resources';
|
|
17
18
|
|
|
18
19
|
export default {
|
|
20
|
+
name: "TextControl",
|
|
19
21
|
props: {
|
|
20
22
|
value: {
|
|
21
23
|
type: String,
|
|
@@ -36,6 +38,9 @@ export default {
|
|
|
36
38
|
}
|
|
37
39
|
},
|
|
38
40
|
emits: [valueEvent],
|
|
41
|
+
setup(data){
|
|
42
|
+
initComponent(data, name);
|
|
43
|
+
},
|
|
39
44
|
data() {
|
|
40
45
|
return {
|
|
41
46
|
rule: setRule(this.rules)
|
package/components/index.d.ts
CHANGED