@bildvitta/quasar-ui-asteroid 2.23.0-beta.3 → 2.23.0-beta.6

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": "@bildvitta/quasar-ui-asteroid",
3
- "version": "2.23.0-beta.3",
3
+ "version": "2.23.0-beta.6",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -112,6 +112,10 @@ export default {
112
112
  }
113
113
  },
114
114
 
115
+ fetching: {
116
+ description: 'Fires when fetching the options.'
117
+ },
118
+
115
119
  input: {
116
120
  description: 'Fires when the result changes.',
117
121
  table: noSummary
@@ -91,7 +91,7 @@ export default {
91
91
 
92
92
  computed: {
93
93
  contentClasses () {
94
- return ['overflow-auto', 'q-mt-xs', 'relative-position', this.$_virtualScrollClassName]
94
+ return ['overflow-auto', 'q-mt-xs', 'relative-position']
95
95
  },
96
96
 
97
97
  contentStyle () {
@@ -109,6 +109,10 @@ export default {
109
109
  }
110
110
  },
111
111
 
112
+ fetching: {
113
+ description: 'Fires when fetching the options.'
114
+ },
115
+
112
116
  input: {
113
117
  description: 'Fires when model changes. Also used by `v-model`.'
114
118
  },
@@ -12,16 +12,19 @@
12
12
  </slot>
13
13
  </template>
14
14
 
15
+ <template #hint>
16
+ <slot name="hint">
17
+ <div v-if="isLoading" class="q-pb-sm">
18
+ Buscando por opções...
19
+ </div>
20
+ </slot>
21
+ </template>
22
+
15
23
  <template #no-option>
16
- <slot name="no-option">
24
+ <slot v-if="!isLoading" name="no-option">
17
25
  <q-item>
18
26
  <q-item-section class="text-grey">
19
- <template v-if="isLoading">
20
- Buscando por {{ label }}...
21
- </template>
22
- <template v-else>
23
- {{ noOptionLabel }}
24
- </template>
27
+ {{ noOptionLabel }}
25
28
  </q-item-section>
26
29
  </q-item>
27
30
  </slot>
@@ -98,10 +101,6 @@ export default {
98
101
  }
99
102
  },
100
103
 
101
- label () {
102
- return this.$attrs.label || ''
103
- },
104
-
105
104
  listeners () {
106
105
  const { input, ...events } = this.$listeners
107
106
 
@@ -148,19 +147,23 @@ export default {
148
147
  return this.hasFetchError || this.$attrs.error
149
148
  },
150
149
 
150
+ hasLoading () {
151
+ return this.isLoading || this.$attrs.loading
152
+ },
153
+
151
154
  attributes () {
152
155
  return {
156
+ bottomSlots: true,
153
157
  emitValue: true,
154
158
  mapOptions: true,
155
159
  outlined: true,
156
160
  clearable: this.isSearchable,
157
- loading: this.isLoading,
158
161
  inputDebounce: this.useLazyLoading ? 500 : 0,
159
- popupContentClass: this.$_virtualScrollClassName,
160
162
  ...this.$attrs,
161
163
  options: this.filteredOptions,
162
164
  useInput: this.isSearchable,
163
- error: this.hasError
165
+ error: this.hasError,
166
+ loading: this.hasLoading
164
167
  }
165
168
  }
166
169
  },
@@ -192,12 +195,16 @@ export default {
192
195
  },
193
196
 
194
197
  methods: {
195
- onFilter (value, update) {
196
- update(() => {
197
- if (this.useLazyLoading && value !== this.search) return this.$_filterOptionsByStore(value)
198
+ async onFilter (value, update) {
199
+ if (this.useLazyLoading && value !== this.search) {
200
+ await this.$_filterOptionsByStore(value)
201
+ }
202
+
203
+ if (!this.useLazyLoading && this.searchable) {
204
+ this.filterOptionsByFuse(value)
205
+ }
198
206
 
199
- if (!this.useLazyLoading && this.searchable) this.filterOptionsByFuse(value)
200
- })
207
+ update()
201
208
  },
202
209
 
203
210
  filterOptionsByFuse (value) {
@@ -1,21 +1,23 @@
1
1
  <template>
2
2
  <qas-search-box v-bind="$attrs" class="q-pa-md" :fuse-options="fuseOptions" :list="sortedOptions">
3
3
  <template #default="{ results }">
4
- <q-item v-for="(item, index) in results" :key="index">
5
- <slot name="item" v-bind="self">
6
- <slot name="item-section" :result="item">
7
- <q-item-section class="items-start text-bold">
8
- <div :class="labelClass" @click="redirectRoute(item)">{{ item.label }}</div>
4
+ <q-list separator>
5
+ <q-item v-for="(item, index) in results" :key="index">
6
+ <slot name="item" v-bind="self">
7
+ <slot name="item-section" :result="item">
8
+ <q-item-section class="items-start text-bold">
9
+ <div :class="labelClass" @click="redirectRoute(item)">{{ item.label }}</div>
10
+ </q-item-section>
11
+ </slot>
12
+
13
+ <q-item-section avatar>
14
+ <slot name="item-action" v-bind="self">
15
+ <qas-btn hide-mobile-label v-bind="setButtonProps(item)" size="sm" @click="handleClick(item)" />
16
+ </slot>
9
17
  </q-item-section>
10
18
  </slot>
11
-
12
- <q-item-section avatar>
13
- <slot name="item-action" v-bind="self">
14
- <qas-btn hide-mobile-label v-bind="setButtonProps(item)" size="sm" @click="handleClick(item)" />
15
- </slot>
16
- </q-item-section>
17
- </slot>
18
- </q-item>
19
+ </q-item>
20
+ </q-list>
19
21
  </template>
20
22
  </qas-search-box>
21
23
  </template>
@@ -1,4 +1,5 @@
1
1
  import { decamelize } from 'humps'
2
+ import { isEqual } from 'lodash'
2
3
 
3
4
  export default {
4
5
  props: {
@@ -54,16 +55,23 @@ export default {
54
55
  ...defaultParams,
55
56
  ...params
56
57
  },
57
- decamelizeFieldName: (decamelizeFieldName ?? true) || decamelizeFieldName
58
+ decamelizeFieldName: decamelizeFieldName === undefined ? true : decamelizeFieldName
58
59
  }
59
60
  },
60
61
 
61
62
  $_hasFilteredOptions () {
62
63
  return !!this.filteredOptions.length
63
- },
64
+ }
65
+ },
64
66
 
65
- $_virtualScrollClassName () {
66
- return `virtual-scroll-${this.name}`
67
+ watch: {
68
+ lazyLoadingProps: {
69
+ handler (value, oldValue) {
70
+ if (isEqual(value, oldValue)) return
71
+
72
+ this.$_resetFilter()
73
+ this.$emit('input', '')
74
+ }
67
75
  }
68
76
  },
69
77
 
@@ -82,17 +90,16 @@ export default {
82
90
  }
83
91
  },
84
92
 
85
- async $_onVirtualScroll ({ index }) {
93
+ async $_onVirtualScroll ({ index, ref }) {
86
94
  const lastIndex = this.filteredOptions.length - 1
87
95
 
88
96
  if (index === lastIndex && this.$_canFetchOptions()) {
89
- const { scrollContainer, top } = this.$_getScrollContainerTop()
90
-
91
97
  await this.$_loadMoreOptions()
92
98
 
93
- setTimeout(() => {
94
- scrollContainer.scrollTo({ top })
95
- }, 100)
99
+ this.$nextTick(() => {
100
+ ref.reset()
101
+ ref.refresh(lastIndex)
102
+ })
96
103
  }
97
104
  },
98
105
 
@@ -114,7 +121,9 @@ export default {
114
121
  if (!this.name) throw new Error(this.$_getMissingPropsMessage('name'))
115
122
 
116
123
  this.hasFetchError = false
124
+
117
125
  this.isLoading = true
126
+ this.$emit('fetching', true)
118
127
 
119
128
  const { url, params, decamelizeFieldName } = this.$_defaultLazyLoadingProps
120
129
 
@@ -148,6 +157,7 @@ export default {
148
157
  return []
149
158
  } finally {
150
159
  this.isLoading = false
160
+ this.$emit('fetching', false)
151
161
  }
152
162
  },
153
163
 
@@ -162,17 +172,6 @@ export default {
162
172
  return hasMorePages && !this.isLoading && !this.isScrolling && this.useLazyLoading
163
173
  },
164
174
 
165
- $_getScrollContainerTop () {
166
- const scrollContainer = document.querySelector(`.${this.$_virtualScrollClassName}`)
167
- const scrollContainerHeight = scrollContainer.offsetHeight
168
- const scrollContainerTop = scrollContainer.scrollTop
169
-
170
- return {
171
- scrollContainer,
172
- top: scrollContainerTop + (scrollContainerHeight / 2)
173
- }
174
- },
175
-
176
175
  $_handleOptions (options) {
177
176
  if (this.labelKey && this.valueKey && this.renameKey) {
178
177
  return options.map(item => this.renameKey(item))