@mythpe/quasar-ui-qui 0.2.45 → 0.2.46

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.2.45",
3
+ "version": "0.2.46",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -16,6 +16,7 @@ import { computed, onMounted, toValue, useTemplateRef, watch } from 'vue'
16
16
  import { useFieldValue, useSetFieldValue } from 'vee-validate'
17
17
  import MSelect from './MSelect.vue'
18
18
  import { useMyth } from '../../composable'
19
+ import { extend } from 'quasar'
19
20
 
20
21
  type P = {
21
22
  name: Props['name'];
@@ -29,6 +30,8 @@ type P = {
29
30
  params?: Props['params'];
30
31
  lazy?: Props['lazy'];
31
32
  useChoice?: Props['useChoice'];
33
+ byId?: Props['byId'];
34
+ searchLength?: Props['searchLength'];
32
35
  }
33
36
 
34
37
  const props = withDefaults(defineProps<P>(), {
@@ -42,7 +45,9 @@ const props = withDefaults(defineProps<P>(), {
42
45
  requestWith: undefined,
43
46
  params: () => ({}),
44
47
  lazy: () => !1,
45
- useChoice: undefined
48
+ useChoice: undefined,
49
+ byId: undefined,
50
+ searchLength: undefined
46
51
  })
47
52
  const modelValue = defineModel<Props['modelValue']>({ required: !1, default: undefined })
48
53
  type Emits = {
@@ -59,6 +64,7 @@ const isGuest = computed(() => {
59
64
  const v = toValue(props.guest)
60
65
  return v !== undefined && v !== null && v !== !1
61
66
  })
67
+ const getSearchLength = computed(() => parseInt(props.searchLength?.toString() || '0') || 3)
62
68
  const prepare = async (fromWatch = !1, merge = {}) => {
63
69
  if (!props.service || loading.value) {
64
70
  return
@@ -81,15 +87,18 @@ const prepare = async (fromWatch = !1, merge = {}) => {
81
87
  if (!method) {
82
88
  throw Error(`No service: ${props.service}`)
83
89
  }
84
- const params: any = {
85
- ...merge,
86
- requestWith: undefined,
87
- search: search.value,
90
+ const _params: any = {
91
+ search: props.byId ? undefined : search.value,
88
92
  itemsPerPage: -1,
89
93
  page: 1,
90
- staticRequest: 1,
91
- ...(toValue(props.params) || {})
94
+ staticRequest: 1
92
95
  }
96
+ if (props.byId) {
97
+ _params.filter = {
98
+ id: parseInt(search.value?.toString() || '') || undefined
99
+ }
100
+ }
101
+ const params = extend<any>(!0, {}, _params, merge, toValue(props.params))
93
102
  if (props.requestWith) {
94
103
  params.requestWith = toValue(props.requestWith)
95
104
  }
@@ -116,6 +125,9 @@ const listeners = {
116
125
  if (!val && fieldValue.value) {
117
126
  return
118
127
  }
128
+ if (val?.toString?.()?.length < getSearchLength.value) {
129
+ return
130
+ }
119
131
  prepare()
120
132
  },
121
133
  model: (v: MSelectModelEmit) => emit('model', v)
@@ -164,7 +164,6 @@ const onDoneOptions = () => {
164
164
  const listeners = {
165
165
  blur: (v: any) => handleBlur(v, !0),
166
166
  'update:modelValue': (v: Props['modelValue']) => {
167
- console.log('update:modelValue: ', v)
168
167
  handleChange(v, !!errorMessage.value)
169
168
  if (!props.emitValue) {
170
169
  emit('model', { value: v, model: v })
@@ -175,7 +174,6 @@ const listeners = {
175
174
  }
176
175
  },
177
176
  inputValue: (v: string) => {
178
- console.log('inputValue: ', v)
179
177
  search.value = v?.toString() || ''
180
178
  },
181
179
  filter: filterFn
@@ -33,6 +33,14 @@ export interface MAxiosProps extends Omit<MSelectProps, 'options' | 'axiosMode'>
33
33
  * Do fetch asynchronous
34
34
  */
35
35
  lazy?: boolean;
36
+ /**
37
+ * Apply searching only by id.
38
+ */
39
+ byId?: boolean;
40
+ /**
41
+ * Set the length on search
42
+ */
43
+ searchLength?: number | string;
36
44
  }
37
45
 
38
46
  export interface MAxiosSlots extends MSelectSlots {