@westartcom/bread-quasar-fields 0.0.11 → 0.0.13

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,47 +1,45 @@
1
1
  <template>
2
- <div class="field-wrap" :id="id">
3
- <div class="field-wrap-inner">
4
- <template v-if="stylingFormat === 'toggle'">
5
- <q-toggle
6
- size="lg"
7
- color="positive"
8
- :label="field.label"
9
- left-label
10
- :disable="disable"
11
- unchecked-icon="fa-solid fa-xmark"
12
- checked-icon="fa-solid fa-check"
13
- v-model="internalValue" />
14
- </template>
15
-
16
- <template v-else>
17
- <div class="field-label-wrap">
18
- <div class="field">
19
- <label v-if="field.label" :for="id + '-input'">
20
- <checkbox-marked-icon class="icon-2x" v-if="internalValue"></checkbox-marked-icon>
21
- <checkbox-blank-outline-icon class="icon-2x" v-else></checkbox-blank-outline-icon>
22
-
23
- <input
24
- :name="field.name"
25
- :id="id + '-input'"
26
- type="checkbox"
27
- style="display: none;"
28
- :disabled="disable"
29
- :class="{'invalid': (invalid && internalErrors && internalErrors.length)}"
30
- v-model="internalValue">
31
-
32
- {{ field.label }}<span class="required-asterix" v-if="field.required"> *</span>
33
- </label>
34
- </div>
35
- </div>
36
- </template>
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>
37
35
  </div>
36
+ </template>
37
+ </div>
38
38
 
39
- <div class="field-description" v-if="field.description">{{ field.description }}</div>
40
-
41
- <div class="validation-errors" v-if="invalid && internalErrors && internalErrors.length">
42
- <span class="error danger-txt-color" v-for="(error, index) in internalErrors" :key="index + 'error'">{{ error }}</span>
43
- </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>
44
41
  </div>
42
+ </div>
45
43
  </template>
46
44
 
47
45
  <script lang="ts">
@@ -51,133 +49,133 @@ import { FieldType } from '@westartcom/bread-quasar-fields/enums/FieldType';
51
49
  import { InputType } from '@westartcom/bread-quasar-fields/enums/InputType';
52
50
 
53
51
  interface BoolFieldDefinition extends ModelFieldDefinition<FieldType.BOOL, InputType.BOOL> {
54
- default: boolean;
55
- extra_data: {
56
- styling_format: 'checkbox' | 'toggle'
57
- }
52
+ default: boolean;
53
+ extra_data: {
54
+ styling_format: 'checkbox' | 'toggle'
55
+ }
58
56
  }
59
57
 
60
58
  export default defineComponent({
61
- props: {
62
- id: {
63
- type: String,
64
- required: true
65
- },
66
- disable: {
67
- type: Boolean,
68
- required: false,
69
- default: false
70
- },
71
- field: {
72
- type: Object as PropType<BoolFieldDefinition>,
73
- required: true
74
- },
75
- modelValue: [Boolean, Number, String],
76
- 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
77
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
+ }
78
101
 
79
- emits: [
80
- 'update:modelValue',
81
- 'update:invalid'
82
- ],
102
+ this.validate(this.internalValue);
103
+ },
83
104
 
84
- components: {
85
- CheckboxBlankOutlineIcon: defineAsyncComponent(() => import('@westartcom/bread-quasar-fields/icons/CheckboxBlankOutlineIcon.vue')),
86
- CheckboxMarkedIcon: defineAsyncComponent(() => import('@westartcom/bread-quasar-fields/icons/CheckboxMarkedIcon.vue'))
87
- },
105
+ computed: {
106
+ stylingFormat: function(): 'checkbox' | 'toggle' {
107
+ return (this.field?.extra_data?.styling_format) ? this.field.extra_data.styling_format : 'checkbox';
108
+ }
109
+ },
88
110
 
89
- data() {
90
- return {
91
- invalid: null as boolean | null,
92
- internalValue: false,
93
- internalErrors: [] as string[]
94
- };
111
+ watch: {
112
+ modelValue: function(val) {
113
+ if (val !== this.internalValue) {
114
+ this.internalValue = !!(val);
115
+ }
95
116
  },
96
117
 
97
- mounted() {
98
- if (this.modelValue !== null && typeof this.modelValue !== 'undefined') {
99
- this.internalValue = (!(!this.modelValue || this.modelValue === '0'));
100
- } else if (this.field.default) {
101
- this.internalValue = this.field.default;
102
- }
103
-
104
- this.validate(this.internalValue);
118
+ internalValue: function(val) {
119
+ this.validate(val);
120
+ this.$emit('update:modelValue', val);
105
121
  },
106
122
 
107
- computed: {
108
- stylingFormat: function(): 'checkbox' | 'toggle' {
109
- return (this.field?.extra_data?.styling_format) ? this.field.extra_data.styling_format : 'checkbox';
110
- }
123
+ errors: {
124
+ handler: function(val) {
125
+ this.internalErrors = val;
126
+ },
127
+ deep: true
111
128
  },
112
129
 
113
- watch: {
114
- modelValue: function(val) {
115
- if (val !== this.internalValue) {
116
- this.internalValue = !!(val);
117
- }
118
- },
119
-
120
- internalValue: function(val) {
121
- this.validate(val);
122
- this.$emit('update:modelValue', val);
123
- },
124
-
125
- errors: {
126
- handler: function(val) {
127
- this.internalErrors = val;
128
- },
129
- deep: true
130
- },
131
-
132
- internalErrors: {
133
- handler: function(val) {
134
- this.invalid = !!(val && val.length);
135
- },
136
- deep: true
137
- },
138
-
139
- invalid: function(val) {
140
- this.$emit('update:invalid', val);
141
- }
130
+ internalErrors: {
131
+ handler: function(val) {
132
+ this.invalid = !!(val && val.length);
133
+ },
134
+ deep: true
142
135
  },
143
136
 
144
- methods: {
145
- validate: function(val) {
146
- this.invalid = this.field.required && !val;
147
- }
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;
148
145
  }
146
+ }
149
147
  });
150
148
  </script>
151
149
 
152
150
  <style scoped lang="scss">
153
- .toggle {
154
- display: flex;
155
- max-width: var(--max-input-width);
156
- width: 100%;
157
-
158
- .btn {
159
- border-radius: 0;
160
-
161
- &:first-of-type {
162
- border-bottom-left-radius: var(--global-radius);
163
- border-top-left-radius: var(--global-radius);
164
- }
165
- &:last-of-type {
166
- border-bottom-right-radius: var(--global-radius);
167
- border-top-right-radius: var(--global-radius);
168
- }
169
- }
170
- }
151
+ .toggle {
152
+ display: flex;
153
+ max-width: var(--max-input-width);
154
+ width: 100%;
171
155
 
172
- .field > label {
173
- margin-right: var(--global-spacing);
174
- user-select: none;
175
- cursor: pointer;
176
- display: inline-flex;
177
- align-items: flex-end;
156
+ .btn {
157
+ border-radius: 0;
178
158
 
179
- :deep(svg) {
180
- margin-right: var(--global-spacing-half);
181
- }
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);
182
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
+ }
183
181
  </style>
@@ -116,39 +116,40 @@
116
116
  {{ option[displayField] }}
117
117
  </template>
118
118
  </q-chip>
119
- <!-- <div class="selected-options-multiple table-list" v-if="multiValueStyle === 'table' && selectedOptions.length && field.extra_data.multiple">-->
120
- <!-- <div class="labels table-header" v-if="showLabels">-->
121
- <!-- <div class="label column" v-for="(label, displayField) of field.extra_data.display_field_labels" :key="displayField">-->
122
- <!-- {{ label }}-->
123
- <!-- </div>-->
124
- <!-- </div>-->
125
- <!-- <div class="selected-option-row table-row" v-for="option in selectedOptions" :key="option.id">-->
126
- <!-- <template v-if="showLabels">-->
127
- <!-- <slot name="selected-option-label" :option="option" :display-fields="displayFields">-->
128
- <!-- <div class="selected-option-label column" v-for="(label, displayField) of field.extra_data.display_field_labels" :key="displayField">{{ option[displayField] }}</div>-->
129
- <!-- </slot>-->
130
- <!-- </template>-->
131
- <!-- <template v-else>-->
132
- <!-- <div class="selected-option-label text-weight-bold column">-->
133
- <!-- <slot name="selected-option-label" :option="option" :display-fields="displayFields">-->
134
- <!-- <template v-for="displayField in displayFields">-->
135
- <!-- {{ option[displayField] }}-->
136
- <!-- </template>-->
137
- <!-- </slot>-->
138
- <!-- </div>-->
139
- <!-- </template>-->
140
- <!-- <div class="column actions">-->
141
- <!-- <slot name="selected-option-actions" :option="option" />-->
142
- <!-- <q-btn-->
143
- <!-- flat-->
144
- <!-- round-->
145
- <!-- icon="fa-solid fa-trash"-->
146
- <!-- color="negative"-->
147
- <!-- :title="$i18n.get('actions.remove')"-->
148
- <!-- @click="removeOption(option)"></q-btn>-->
149
- <!-- </div>-->
150
- <!-- </div>-->
151
- <!-- </div>-->
119
+
120
+ <div class="selected-options-multiple table-list" v-if="multiValueStyle === 'table' && selectedOptions.length && field.extra_data.multiple">
121
+ <div class="labels table-header" v-if="showLabels">
122
+ <div class="label column" v-for="(label, displayField) of field.extra_data.display_field_labels" :key="displayField">
123
+ {{ label }}
124
+ </div>
125
+ </div>
126
+ <div class="selected-option-row table-row" v-for="option in selectedOptions" :key="option.id">
127
+ <template v-if="showLabels">
128
+ <slot name="selected-option-label" :option="option" :display-fields="displayFields">
129
+ <div class="selected-option-label column" v-for="(label, displayField) of field.extra_data.display_field_labels" :key="displayField">{{ option[displayField] }}</div>
130
+ </slot>
131
+ </template>
132
+ <template v-else>
133
+ <div class="selected-option-label text-weight-bold column">
134
+ <slot name="selected-option-label" :option="option" :display-fields="displayFields">
135
+ <template v-for="displayField in displayFields">
136
+ {{ option[displayField] }}
137
+ </template>
138
+ </slot>
139
+ </div>
140
+ </template>
141
+ <div class="column actions">
142
+ <slot name="selected-option-actions" :option="option" />
143
+ <q-btn
144
+ flat
145
+ round
146
+ icon="fa-solid fa-trash"
147
+ color="negative"
148
+ :title="$i18n.get('actions.remove')"
149
+ @click="removeOption(option)"></q-btn>
150
+ </div>
151
+ </div>
152
+ </div>
152
153
 
153
154
  <div class="selected-options-multiple tags" v-else-if="multiValueStyle === 'tags' && selectedOptions.length && field.extra_data.multiple">
154
155
  <div class="selected-option-tag" v-for="option in selectedOptions" :key="option.id">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@westartcom/bread-quasar-fields",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Quasar compatible fields for bread package",
5
5
  "main": "index.js",
6
6
  "scripts": {