@mythpe/quasar-ui-qui 0.4.95 → 0.4.97

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.95",
3
+ "version": "0.4.97",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -23,6 +23,7 @@ type P = {
23
23
  label?: Props['label'];
24
24
  placeholder?: Props['placeholder'];
25
25
  viewMode?: Props['viewMode'];
26
+ viewModeKey?: Props['viewModeKey'];
26
27
  viewModeValue?: Props['viewModeValue'];
27
28
  service?: Props['service'];
28
29
  guest?: Props['guest'];
@@ -42,6 +43,7 @@ const props = withDefaults(defineProps<P>(), {
42
43
  label: undefined,
43
44
  placeholder: undefined,
44
45
  viewMode: !1,
46
+ viewModeKey: undefined,
45
47
  viewModeValue: undefined,
46
48
  service: undefined,
47
49
  guest: undefined,
@@ -193,6 +195,7 @@ defineOptions({ name: 'MAxios', inheritAttrs: !1 })
193
195
  :placeholder="placeholder"
194
196
  :required="required"
195
197
  :view-mode="viewMode"
198
+ :view-mode-key="viewModeKey"
196
199
  :view-mode-value="viewModeValue"
197
200
  axios-mode
198
201
  no-filter
@@ -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 { MSelectProps as Props } from '../../types'
16
16
  import { computed, reactive, ref, toValue, useTemplateRef } from 'vue'
17
17
  import { useBindInput, useMyth } from '../../composable'
@@ -35,6 +35,7 @@ type P = {
35
35
  required?: Props['required'];
36
36
  rules?: Props['rules'];
37
37
  viewMode?: Props['viewMode'];
38
+ viewModeKey?: Props['viewModeKey'];
38
39
  viewModeValue?: Props['viewModeValue'];
39
40
  autocomplete?: Props['autocomplete'];
40
41
  topLabel?: Props['topLabel'];
@@ -83,6 +84,7 @@ const props = withDefaults(defineProps<P>(), {
83
84
  required: undefined,
84
85
  rules: undefined,
85
86
  viewMode: !1,
87
+ viewModeKey: undefined,
86
88
  viewModeValue: undefined,
87
89
  autocomplete: undefined,
88
90
  topLabel: undefined,
@@ -187,25 +189,43 @@ const listeners = {
187
189
  }
188
190
  const input = useTemplateRef<InstanceType<typeof QSelect> | InstanceType<typeof QField>>('input')
189
191
  const scopes = reactive(inputScope)
192
+
193
+ const viewModeAttribute = useFieldValue(() => props.viewModeKey || props.name)
190
194
  const getViewModeValue = computed(() => {
195
+ if (!props.viewMode) {
196
+ return undefined
197
+ }
191
198
  if (props.viewMode && props.loading) {
192
199
  return '...'
193
200
  }
194
- if (props.viewModeValue === undefined) {
195
- const i = getOptions.value.find((e) => {
196
- if (typeof props.optionValue === 'function') {
197
- return e[props.optionValue(e)] === value.value
198
- }
199
- return e[props.optionValue] === value.value
201
+ if (props.viewModeValue !== undefined) {
202
+ return props.viewModeValue
203
+ }
204
+ if (props.viewModeKey) {
205
+ return viewModeAttribute.value
206
+ }
207
+ if (props.loading) {
208
+ return '...'
209
+ }
210
+ if (props.multiple) {
211
+ const opts = getOptions.value?.filter((opt) => {
212
+ const k = props.optionValue === undefined ? 'value' : (typeof props.optionValue === 'function' ? props.optionValue(opt) : props.optionValue)
213
+ return value.value?.includes?.(opt[k])
214
+ }).map((opt) => {
215
+ const k = props.optionLabel === undefined ? 'label' : (typeof props.optionLabel === 'function' ? props.optionLabel(opt) : props.optionLabel)
216
+ return opt[k]
200
217
  })
201
- if (i) {
202
- if (typeof props.optionLabel === 'function') {
203
- return props.optionLabel(i)
204
- }
205
- return i[props.optionLabel]
206
- }
218
+ return opts?.length ? opts?.join(', ') : '-'
207
219
  }
208
- return value.value || '-'
220
+ const opt = getOptions.value?.find((e) => {
221
+ const k = props.optionValue === undefined ? 'value' : (typeof props.optionValue === 'function' ? props.optionValue(e) : props.optionValue)
222
+ return e[k] === value.value
223
+ })
224
+ if (opt) {
225
+ const k = props.optionLabel === undefined ? 'label' : (typeof props.optionLabel === 'function' ? props.optionLabel(opt) : props.optionLabel)
226
+ return opt[k]
227
+ }
228
+ return undefined
209
229
  })
210
230
  defineExpose<typeof scopes & {
211
231
  input: typeof input,
@@ -369,23 +389,18 @@ defineOptions({
369
389
  </template>
370
390
  <template
371
391
  v-if="multiple"
372
- #before-options="boProps"
392
+ #before-options
373
393
  >
374
- <slot
375
- name="before-options"
376
- v-bind="boProps"
377
- >
378
- <MContainer>
379
- <MRow class="full-width">
380
- <MBtn
381
- :class="{'full-width': $q.screen.lt.sm}"
382
- :label="__('labels.done')"
383
- :size="$q.screen.xs ? 'lg' : undefined"
384
- @click="onDoneOptions()"
385
- />
386
- </MRow>
387
- </MContainer>
388
- </slot>
394
+ <MContainer>
395
+ <MRow class="full-width">
396
+ <MBtn
397
+ :class="{'full-width': $q.screen.lt.sm}"
398
+ :label="__('labels.done')"
399
+ :size="$q.screen.xs ? 'lg' : undefined"
400
+ @click="onDoneOptions()"
401
+ />
402
+ </MRow>
403
+ </MContainer>
389
404
  </template>
390
405
  <template
391
406
  v-for="(_,slot) in $slots as Readonly<QSelectSlots>"