@westartcom/bread-quasar-fields 0.0.10 → 0.0.12
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/fields/BooleanField.vue +144 -139
- package/fields/CheckboxField.vue +6 -0
- package/fields/DateField.vue +6 -0
- package/fields/DateTimeField.vue +7 -1
- package/fields/EmailField.vue +6 -0
- package/fields/NumberField.vue +6 -0
- package/fields/RadioField.vue +7 -0
- package/fields/TelField.vue +6 -0
- package/fields/TextField.vue +6 -0
- package/fields/TextareaField.vue +6 -0
- package/package.json +1 -1
package/fields/BooleanField.vue
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
2
|
+
<div class="field-wrap boolean" :id="id">
|
|
3
|
+
<div class="field-description" v-if="field.description">{{ field.description }}</div>
|
|
4
|
+
|
|
5
|
+
<div class="field-wrap-inner">
|
|
6
|
+
<template v-if="stylingFormat === 'toggle'">
|
|
7
|
+
<q-toggle
|
|
8
|
+
size="lg"
|
|
9
|
+
color="positive"
|
|
10
|
+
:label="field.label"
|
|
11
|
+
left-label
|
|
12
|
+
:disable="disable"
|
|
13
|
+
unchecked-icon="fa-solid fa-xmark"
|
|
14
|
+
checked-icon="fa-solid fa-check"
|
|
15
|
+
v-model="internalValue" />
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<template v-else>
|
|
19
|
+
<div class="field-label-wrap">
|
|
20
|
+
<div class="field">
|
|
21
|
+
<label v-if="field.label || field.extra_data.alternative_label" :for="id + '-input'">
|
|
22
|
+
<input
|
|
23
|
+
:id="id + '-input'"
|
|
24
|
+
type="checkbox"
|
|
25
|
+
hidden="true"
|
|
26
|
+
:disabled="disable"
|
|
27
|
+
v-model="internalValue">
|
|
28
|
+
|
|
29
|
+
<i class="icon fa-solid fa-square-check fa-fw" v-if="internalValue"></i>
|
|
30
|
+
<i class="icon fa-solid fa-square fa-fw" v-if="!internalValue"></i>
|
|
31
|
+
|
|
32
|
+
{{ field.extra_data.alternative_label ?? field.label }}<span class="required-asterix" v-if="field.required"> *</span>
|
|
33
|
+
</label>
|
|
34
|
+
</div>
|
|
35
35
|
</div>
|
|
36
|
+
</template>
|
|
37
|
+
</div>
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class="validation-errors" v-if="invalid && internalErrors && internalErrors.length">
|
|
40
|
-
<span class="error danger-txt-color" v-for="(error, index) in internalErrors" :key="index + 'error'">{{ error }}</span>
|
|
41
|
-
</div>
|
|
39
|
+
<div class="validation-errors" v-if="invalid && internalErrors && internalErrors.length">
|
|
40
|
+
<span class="error danger-txt-color" v-for="(error, index) in internalErrors" :key="index + 'error'">{{ error }}</span>
|
|
42
41
|
</div>
|
|
42
|
+
</div>
|
|
43
43
|
</template>
|
|
44
44
|
|
|
45
45
|
<script lang="ts">
|
|
@@ -49,128 +49,133 @@ import { FieldType } from '@westartcom/bread-quasar-fields/enums/FieldType';
|
|
|
49
49
|
import { InputType } from '@westartcom/bread-quasar-fields/enums/InputType';
|
|
50
50
|
|
|
51
51
|
interface BoolFieldDefinition extends ModelFieldDefinition<FieldType.BOOL, InputType.BOOL> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
default: boolean;
|
|
53
|
+
extra_data: {
|
|
54
|
+
styling_format: 'checkbox' | 'toggle'
|
|
55
|
+
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export default defineComponent({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
modelValue: [Boolean, Number, String],
|
|
69
|
-
errors: Array as PropType<string[]>
|
|
59
|
+
props: {
|
|
60
|
+
id: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: true
|
|
63
|
+
},
|
|
64
|
+
disable: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
required: false,
|
|
67
|
+
default: false
|
|
70
68
|
},
|
|
69
|
+
field: {
|
|
70
|
+
type: Object as PropType<BoolFieldDefinition>,
|
|
71
|
+
required: true
|
|
72
|
+
},
|
|
73
|
+
modelValue: [Boolean, Number, String],
|
|
74
|
+
errors: Array as PropType<string[]>
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
emits: [
|
|
78
|
+
'update:modelValue',
|
|
79
|
+
'update:invalid'
|
|
80
|
+
],
|
|
81
|
+
|
|
82
|
+
components: {
|
|
83
|
+
CheckboxBlankOutlineIcon: defineAsyncComponent(() => import('@westartcom/bread-quasar-fields/icons/CheckboxBlankOutlineIcon.vue')),
|
|
84
|
+
CheckboxMarkedIcon: defineAsyncComponent(() => import('@westartcom/bread-quasar-fields/icons/CheckboxMarkedIcon.vue'))
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
data() {
|
|
88
|
+
return {
|
|
89
|
+
invalid: null as boolean | null,
|
|
90
|
+
internalValue: false,
|
|
91
|
+
internalErrors: [] as string[]
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
mounted() {
|
|
96
|
+
if (this.modelValue !== null && typeof this.modelValue !== 'undefined') {
|
|
97
|
+
this.internalValue = (!(!this.modelValue || this.modelValue === '0'));
|
|
98
|
+
} else if (this.field.default) {
|
|
99
|
+
this.internalValue = this.field.default;
|
|
100
|
+
}
|
|
71
101
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'update:invalid'
|
|
75
|
-
],
|
|
102
|
+
this.validate(this.internalValue);
|
|
103
|
+
},
|
|
76
104
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
105
|
+
computed: {
|
|
106
|
+
stylingFormat: function(): 'checkbox' | 'toggle' {
|
|
107
|
+
return (this.field?.extra_data?.styling_format) ? this.field.extra_data.styling_format : 'checkbox';
|
|
108
|
+
}
|
|
109
|
+
},
|
|
81
110
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
111
|
+
watch: {
|
|
112
|
+
modelValue: function(val) {
|
|
113
|
+
if (val !== this.internalValue) {
|
|
114
|
+
this.internalValue = !!(val);
|
|
115
|
+
}
|
|
88
116
|
},
|
|
89
117
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
} else if (this.field.default) {
|
|
94
|
-
this.internalValue = this.field.default;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this.validate(this.internalValue);
|
|
118
|
+
internalValue: function(val) {
|
|
119
|
+
this.validate(val);
|
|
120
|
+
this.$emit('update:modelValue', val);
|
|
98
121
|
},
|
|
99
122
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
123
|
+
errors: {
|
|
124
|
+
handler: function(val) {
|
|
125
|
+
this.internalErrors = val;
|
|
126
|
+
},
|
|
127
|
+
deep: true
|
|
104
128
|
},
|
|
105
129
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
internalValue: function(val) {
|
|
114
|
-
this.validate(val);
|
|
115
|
-
this.$emit('update:modelValue', val);
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
errors: {
|
|
119
|
-
handler: function(val) {
|
|
120
|
-
this.internalErrors = val;
|
|
121
|
-
},
|
|
122
|
-
deep: true
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
internalErrors: {
|
|
126
|
-
handler: function(val) {
|
|
127
|
-
this.invalid = !!(val && val.length);
|
|
128
|
-
},
|
|
129
|
-
deep: true
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
invalid: function(val) {
|
|
133
|
-
this.$emit('update:invalid', val);
|
|
134
|
-
}
|
|
130
|
+
internalErrors: {
|
|
131
|
+
handler: function(val) {
|
|
132
|
+
this.invalid = !!(val && val.length);
|
|
133
|
+
},
|
|
134
|
+
deep: true
|
|
135
135
|
},
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
invalid: function(val) {
|
|
138
|
+
this.$emit('update:invalid', val);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
methods: {
|
|
143
|
+
validate: function(val) {
|
|
144
|
+
this.invalid = this.field.required && !val;
|
|
141
145
|
}
|
|
146
|
+
}
|
|
142
147
|
});
|
|
143
148
|
</script>
|
|
144
149
|
|
|
145
150
|
<style scoped lang="scss">
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
.btn {
|
|
152
|
-
border-radius: 0;
|
|
153
|
-
|
|
154
|
-
&:first-of-type {
|
|
155
|
-
border-bottom-left-radius: var(--global-radius);
|
|
156
|
-
border-top-left-radius: var(--global-radius);
|
|
157
|
-
}
|
|
158
|
-
&:last-of-type {
|
|
159
|
-
border-bottom-right-radius: var(--global-radius);
|
|
160
|
-
border-top-right-radius: var(--global-radius);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
151
|
+
.toggle {
|
|
152
|
+
display: flex;
|
|
153
|
+
max-width: var(--max-input-width);
|
|
154
|
+
width: 100%;
|
|
164
155
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
user-select: none;
|
|
168
|
-
cursor: pointer;
|
|
169
|
-
display: inline-flex;
|
|
170
|
-
align-items: flex-end;
|
|
156
|
+
.btn {
|
|
157
|
+
border-radius: 0;
|
|
171
158
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
159
|
+
&:first-of-type {
|
|
160
|
+
border-bottom-left-radius: var(--global-radius);
|
|
161
|
+
border-top-left-radius: var(--global-radius);
|
|
162
|
+
}
|
|
163
|
+
&:last-of-type {
|
|
164
|
+
border-bottom-right-radius: var(--global-radius);
|
|
165
|
+
border-top-right-radius: var(--global-radius);
|
|
175
166
|
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.field > label {
|
|
171
|
+
margin-right: var(--global-spacing);
|
|
172
|
+
user-select: none;
|
|
173
|
+
cursor: pointer;
|
|
174
|
+
display: inline-flex;
|
|
175
|
+
align-items: flex-end;
|
|
176
|
+
|
|
177
|
+
:deep(svg) {
|
|
178
|
+
margin-right: var(--global-spacing-half);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
176
181
|
</style>
|
package/fields/CheckboxField.vue
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
:id="id + '-' + optionValue + '-radio-input'"
|
|
20
20
|
type="checkbox"
|
|
21
21
|
hidden="true"
|
|
22
|
+
:disabled="disable"
|
|
22
23
|
:value="optionValue"
|
|
23
24
|
v-model="internalValue">
|
|
24
25
|
|
|
@@ -57,6 +58,11 @@ export default defineComponent({
|
|
|
57
58
|
type: String,
|
|
58
59
|
required: true
|
|
59
60
|
},
|
|
61
|
+
disable: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
required: false,
|
|
64
|
+
default: false
|
|
65
|
+
},
|
|
60
66
|
field: {
|
|
61
67
|
type: Object as PropType<CheckboxFieldDefinition>,
|
|
62
68
|
required: true
|
package/fields/DateField.vue
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
:maxlength="(field.extra_data && field.extra_data.max) ? field.extra_data.max : null"
|
|
13
13
|
:minlength="(field.extra_data && field.extra_data.min) ? field.extra_data.min : null"
|
|
14
14
|
v-model="internalValue"
|
|
15
|
+
:disable="disable"
|
|
15
16
|
:rules="(field.required) ? [val => !!val || 'Field is required'] : []"
|
|
16
17
|
:hint="field.description"
|
|
17
18
|
outlined>
|
|
@@ -48,6 +49,11 @@ export default defineComponent({
|
|
|
48
49
|
type: String,
|
|
49
50
|
required: true
|
|
50
51
|
},
|
|
52
|
+
disable: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
required: false,
|
|
55
|
+
default: false
|
|
56
|
+
},
|
|
51
57
|
field: {
|
|
52
58
|
type: Object as PropType<DateFieldDefinition>,
|
|
53
59
|
required: true
|
package/fields/DateTimeField.vue
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
:placeholder="field.placeholder"
|
|
12
12
|
type="datetime-local"
|
|
13
13
|
class="field"
|
|
14
|
+
:disabled="disable"
|
|
14
15
|
:class="{'invalid': (invalid && internalErrors && internalErrors.length)}"
|
|
15
16
|
:max="formatDate(((field.extra_data && field.extra_data.max) ? field.extra_data.max : null), 'YYYY-MM-DDTHH:mm')"
|
|
16
17
|
:min="formatDate(((field.extra_data && field.extra_data.min) ? field.extra_data.min : null), 'YYYY-MM-DDTHH:mm')"
|
|
@@ -33,7 +34,12 @@ export default {
|
|
|
33
34
|
id: String,
|
|
34
35
|
field: Object,
|
|
35
36
|
modelValue: String,
|
|
36
|
-
errors: Array
|
|
37
|
+
errors: Array,
|
|
38
|
+
disable: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
required: false,
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
37
43
|
},
|
|
38
44
|
|
|
39
45
|
emits: [
|
package/fields/EmailField.vue
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
:maxlength="(field.extra_data && field.extra_data.max) ? field.extra_data.max : null"
|
|
13
13
|
:minlength="(field.extra_data && field.extra_data.min) ? field.extra_data.min : null"
|
|
14
14
|
v-model="internalValue"
|
|
15
|
+
:disable="disable"
|
|
15
16
|
:rules="(field.required) ? [val => !!val || $i18n.get('validation.required', { attribute: field.label as string })] : []"
|
|
16
17
|
:hint="field.description"
|
|
17
18
|
:errors="internalErrors"
|
|
@@ -41,6 +42,11 @@ export default defineComponent({
|
|
|
41
42
|
type: String,
|
|
42
43
|
required: true
|
|
43
44
|
},
|
|
45
|
+
disable: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
required: false,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
44
50
|
field: {
|
|
45
51
|
type: Object as PropType<EmailFieldDefinition>,
|
|
46
52
|
required: true
|
package/fields/NumberField.vue
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
:maxlength="(field.extra_data && field.extra_data.max) ? field.extra_data.max : null"
|
|
13
13
|
:minlength="(field.extra_data && field.extra_data.min) ? field.extra_data.min : null"
|
|
14
14
|
v-model="internalValue"
|
|
15
|
+
:disable="disable"
|
|
15
16
|
:rules="(field.required) ? [val => !!val || 'Field is required'] : []"
|
|
16
17
|
:hint="field.description"
|
|
17
18
|
outlined>
|
|
@@ -40,6 +41,11 @@ export default defineComponent({
|
|
|
40
41
|
type: String,
|
|
41
42
|
required: true
|
|
42
43
|
},
|
|
44
|
+
disable: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
required: false,
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
43
49
|
field: {
|
|
44
50
|
type: Object as PropType<NumberFieldDefinition>,
|
|
45
51
|
required: true
|
package/fields/RadioField.vue
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
:key="id + '-' + optionValue + '-radio-input'"
|
|
15
15
|
type="button"
|
|
16
16
|
class="btn expand"
|
|
17
|
+
:disabled="disable"
|
|
17
18
|
@click="internalValue = optionValue"
|
|
18
19
|
:class="{
|
|
19
20
|
'normal-filled': (internalValue === optionValue && !invalid),
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
:id="id + '-' + optionValue + '-radio-input'"
|
|
36
37
|
type="radio"
|
|
37
38
|
:value="optionValue"
|
|
39
|
+
:disabled="disable"
|
|
38
40
|
v-model="internalValue">
|
|
39
41
|
|
|
40
42
|
{{ label }}
|
|
@@ -73,6 +75,11 @@ export default defineComponent({
|
|
|
73
75
|
type: String,
|
|
74
76
|
required: true
|
|
75
77
|
},
|
|
78
|
+
disable: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
required: false,
|
|
81
|
+
default: false
|
|
82
|
+
},
|
|
76
83
|
field: {
|
|
77
84
|
type: Object as PropType<RadioFieldDefinition>,
|
|
78
85
|
required: true
|
package/fields/TelField.vue
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
:class="{'invalid': (invalid && internalErrors && internalErrors.length)}"
|
|
12
12
|
:maxlength="255"
|
|
13
13
|
v-model="internalValue"
|
|
14
|
+
:disable="disable"
|
|
14
15
|
:rules="(field.required) ? [val => !!val || 'Field is required'] : []"
|
|
15
16
|
:hint="field.description"
|
|
16
17
|
outlined>
|
|
@@ -40,6 +41,11 @@ export default defineComponent({
|
|
|
40
41
|
type: String,
|
|
41
42
|
required: true
|
|
42
43
|
},
|
|
44
|
+
disable: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
required: false,
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
43
49
|
field: {
|
|
44
50
|
type: Object as PropType<TelFieldDefinition>,
|
|
45
51
|
required: true
|
package/fields/TextField.vue
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
:maxlength="(field.extra_data && field.extra_data.max) ? field.extra_data.max : null"
|
|
13
13
|
:minlength="(field.extra_data && field.extra_data.min) ? field.extra_data.min : null"
|
|
14
14
|
v-model="internalValue"
|
|
15
|
+
:disable="disable"
|
|
15
16
|
:rules="(field.required) ? [val => !!val || 'Field is required'] : []"
|
|
16
17
|
:hint="field.description"
|
|
17
18
|
outlined>
|
|
@@ -44,6 +45,11 @@ export default defineComponent({
|
|
|
44
45
|
type: String,
|
|
45
46
|
required: true
|
|
46
47
|
},
|
|
48
|
+
disable: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
required: false,
|
|
51
|
+
default: false
|
|
52
|
+
},
|
|
47
53
|
field: {
|
|
48
54
|
type: Object as PropType<TextFieldDefinition>,
|
|
49
55
|
required: true
|
package/fields/TextareaField.vue
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
:maxlength="(field.extra_data && field.extra_data.max) ? field.extra_data.max : null"
|
|
13
13
|
:minlength="(field.extra_data && field.extra_data.min) ? field.extra_data.min : null"
|
|
14
14
|
v-model="internalValue"
|
|
15
|
+
:disable="disable"
|
|
15
16
|
:rules="(field.required) ? [val => !!val || 'Field is required'] : []"
|
|
16
17
|
:hint="field.description"
|
|
17
18
|
outlined>
|
|
@@ -46,6 +47,11 @@ export default defineComponent({
|
|
|
46
47
|
type: String,
|
|
47
48
|
required: true
|
|
48
49
|
},
|
|
50
|
+
disable: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
required: false,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
49
55
|
field: {
|
|
50
56
|
type: Object as PropType<TextareaFieldDefinition>,
|
|
51
57
|
required: true
|