@mythpe/quasar-ui-qui 0.4.79 → 0.4.81

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythpe/quasar-ui-qui",
3
- "version": "0.4.79",
3
+ "version": "0.4.81",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -11,7 +11,7 @@
11
11
  setup
12
12
  >
13
13
 
14
- import { useField } from 'vee-validate'
14
+ import { useField, useFieldValue } from 'vee-validate'
15
15
  import type { MOptionsOptionContext, MOptionsProps as Props } from '../../types'
16
16
  import { computed, onMounted, reactive, toValue, useTemplateRef } from 'vue'
17
17
  import { QField, QOptionGroup, type QOptionGroupSlots } from 'quasar'
@@ -35,6 +35,7 @@ interface P {
35
35
  rules?: Props['rules'];
36
36
  viewMode?: Props['viewMode'];
37
37
  viewModeValue?: Props['viewModeValue'];
38
+ viewModeKey?: Props['viewModeKey'];
38
39
  topLabel?: Props['topLabel'];
39
40
  color?: Props['color'];
40
41
  type?: Props['type'];
@@ -73,6 +74,7 @@ const props = withDefaults(defineProps<P>(), {
73
74
  rules: undefined,
74
75
  viewMode: !1,
75
76
  viewModeValue: undefined,
77
+ viewModeKey: undefined,
76
78
  topLabel: undefined,
77
79
  color: undefined,
78
80
  type: 'radio',
@@ -169,6 +171,7 @@ const fetchData = async () => {
169
171
  }
170
172
  }
171
173
  }
174
+ const viewModeAttribute = useFieldValue(() => props.viewModeKey || props.name)
172
175
  const customViewModeValue = computed(() => {
173
176
  if (!props.viewMode) {
174
177
  return undefined
@@ -176,14 +179,24 @@ const customViewModeValue = computed(() => {
176
179
  if (props.viewModeValue !== undefined) {
177
180
  return props.viewModeValue
178
181
  }
182
+ if (props.viewModeKey) {
183
+ return viewModeAttribute.value
184
+ }
179
185
  if (loading.value) {
180
186
  return '...'
181
187
  }
188
+ if (props.type === 'checkbox') {
189
+ const opts = options.value?.filter((opt) => {
190
+ const k = props.optionValue === undefined ? 'value' : (typeof props.optionValue === 'function' ? props.optionValue(opt) : props.optionValue)
191
+ return value.value?.includes?.(opt[k])
192
+ }).map((opt) => {
193
+ const k = props.optionLabel === undefined ? 'label' : (typeof props.optionLabel === 'function' ? props.optionLabel(opt) : props.optionLabel)
194
+ return opt[k]
195
+ })
196
+ return opts?.length ? opts.join(', ') : undefined
197
+ }
182
198
  const opt = options.value?.find((e) => {
183
199
  const k = props.optionValue === undefined ? 'value' : (typeof props.optionValue === 'function' ? props.optionValue(e) : props.optionValue)
184
- if (props.type === 'checkbox') {
185
- return value.value?.includes?.(e[k]) || e[k] === value.value
186
- }
187
200
  return e[k] === value.value
188
201
  })
189
202
  if (opt) {
@@ -288,11 +301,11 @@ defineOptions({
288
301
  >
289
302
  <template
290
303
  v-if="viewMode"
291
- #control
304
+ #control="controlScope"
292
305
  >
293
306
  <slot name="control">
294
307
  <MInputFieldControl>
295
- {{ customViewModeValue ?? value }}
308
+ {{ customViewModeValue ?? controlScope.modelValue }}
296
309
  </MInputFieldControl>
297
310
  </slot>
298
311
  </template>