@bildvitta/quasar-ui-asteroid 3.0.0-beta.9 → 3.0.0
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/dist/api/QasAppBar.json +0 -4
- package/dist/api/QasBtn.json +2 -1
- package/dist/api/QasCard.json +13 -9
- package/dist/api/QasDateTimeInput.json +12 -12
- package/dist/api/QasDialog.json +6 -2
- package/dist/api/QasFilters.json +4 -4
- package/dist/api/QasFormGenerator.json +33 -2
- package/dist/api/QasFormView.json +26 -9
- package/dist/api/QasGridGenerator.json +5 -4
- package/dist/api/QasInput.json +1 -1
- package/dist/api/QasListItems.json +18 -17
- package/dist/api/QasListView.json +21 -7
- package/dist/api/QasNestedFields.json +13 -3
- package/dist/api/QasNumericInput.json +10 -10
- package/dist/api/QasPasswordInput.json +1 -1
- package/dist/api/QasSearchBox.json +80 -1
- package/dist/api/QasSelect.json +79 -6
- package/dist/api/QasSelectList.json +16 -14
- package/dist/api/QasSignaturePad.json +1 -1
- package/dist/api/QasSingleView.json +13 -4
- package/dist/api/QasTabsGenerator.json +5 -2
- package/dist/api/QasUploader.json +5 -0
- package/dist/asteroid.cjs.css +1 -1
- package/dist/asteroid.cjs.js +1463 -663
- package/dist/asteroid.cjs.min.js +2 -2
- package/dist/asteroid.esm.css +1 -1
- package/dist/asteroid.esm.js +1466 -666
- package/dist/asteroid.esm.min.js +2 -2
- package/dist/asteroid.umd.css +1 -1
- package/dist/asteroid.umd.js +1466 -667
- package/dist/asteroid.umd.min.js +2 -2
- package/dist/vetur/asteroid-attributes.json +162 -94
- package/dist/vetur/asteroid-tags.json +54 -37
- package/package.json +1 -1
- package/src/components/actions-menu/QasActionsMenu.vue +2 -8
- package/src/components/app-bar/QasAppBar.vue +16 -12
- package/src/components/app-bar/QasAppBar.yml +0 -4
- package/src/components/avatar/QasAvatar.vue +0 -4
- package/src/components/btn/QasBtn.vue +5 -8
- package/src/components/btn/QasBtn.yml +2 -1
- package/src/components/card/QasCard.vue +18 -9
- package/src/components/card/QasCard.yml +13 -9
- package/src/components/date-time-input/QasDateTimeInput.vue +39 -41
- package/src/components/date-time-input/QasDateTimeInput.yml +11 -12
- package/src/components/delete/QasDelete.vue +15 -1
- package/src/components/dialog/QasDialog.vue +26 -3
- package/src/components/dialog/QasDialog.yml +6 -3
- package/src/components/dialog-router/QasDialogRouter.vue +1 -1
- package/src/components/field/QasField.vue +15 -14
- package/src/components/filters/QasFilters.vue +27 -10
- package/src/components/filters/QasFilters.yml +4 -4
- package/src/components/form-generator/QasFormGenerator.vue +87 -12
- package/src/components/form-generator/QasFormGenerator.yml +16 -2
- package/src/components/form-view/QasFormView.vue +99 -39
- package/src/components/form-view/QasFormView.yml +22 -9
- package/src/components/grid-generator/QasGridGenerator.vue +23 -7
- package/src/components/grid-generator/QasGridGenerator.yml +5 -4
- package/src/components/input/QasInput.vue +37 -21
- package/src/components/input/QasInput.yml +1 -1
- package/src/components/layout/QasLayout.vue +4 -0
- package/src/components/list-items/QasListItems.vue +15 -23
- package/src/components/list-items/QasListItems.yml +14 -15
- package/src/components/list-view/QasListView.vue +45 -24
- package/src/components/list-view/QasListView.yml +19 -7
- package/src/components/map/QasMap.vue +5 -5
- package/src/components/nested-fields/QasNestedFields.vue +29 -21
- package/src/components/nested-fields/QasNestedFields.yml +9 -3
- package/src/components/numeric-input/QasNumericInput.vue +14 -14
- package/src/components/numeric-input/QasNumericInput.yml +10 -10
- package/src/components/page-header/QasPageHeader.vue +14 -11
- package/src/components/password-input/QasPasswordInput.vue +17 -16
- package/src/components/password-input/QasPasswordInput.yml +1 -1
- package/src/components/profile/QasProfile.vue +1 -1
- package/src/components/search-box/QasSearchBox.vue +137 -36
- package/src/components/search-box/QasSearchBox.yml +66 -1
- package/src/components/select/QasSelect.vue +62 -46
- package/src/components/select/QasSelect.yml +63 -6
- package/src/components/select-list/QasSelectList.vue +11 -27
- package/src/components/select-list/QasSelectList.yml +13 -14
- package/src/components/signature-pad/QasSignaturePad.yml +1 -1
- package/src/components/signature-uploader/QasSignatureUploader.vue +7 -5
- package/src/components/single-view/QasSingleView.vue +22 -6
- package/src/components/single-view/QasSingleView.yml +11 -4
- package/src/components/table-generator/QasTableGenerator.vue +11 -1
- package/src/components/tabs-generator/QasTabsGenerator.vue +2 -2
- package/src/components/tabs-generator/QasTabsGenerator.yml +2 -2
- package/src/components/text-truncate/QasTextTruncate.vue +1 -1
- package/src/components/uploader/QasUploader.vue +62 -15
- package/src/components/uploader/QasUploader.yml +5 -0
- package/src/helpers/camelize-fields-name.js +15 -0
- package/src/helpers/filters.js +2 -0
- package/src/helpers/get-normalized-options.js +20 -0
- package/src/helpers/handle-process.js +13 -0
- package/src/helpers/index.js +3 -0
- package/src/mixins/generator.js +10 -2
- package/src/mixins/index.js +2 -0
- package/src/mixins/search-filter.js +227 -0
- package/src/mixins/view.js +32 -12
- package/src/plugins/index.js +4 -2
- package/src/plugins/logger/Logger.js +44 -0
- package/src/plugins/logger/Logger.yml +9 -0
- package/src/vue-plugin.js +6 -3
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { decamelize } from 'humps'
|
|
2
|
+
import { isEqual } from 'lodash'
|
|
3
|
+
import { getNormalizedOptions } from '../helpers'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
props: {
|
|
7
|
+
entity: {
|
|
8
|
+
default: '',
|
|
9
|
+
type: String
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
lazyLoadingProps: {
|
|
13
|
+
default: () => ({}),
|
|
14
|
+
type: Object
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
name: {
|
|
18
|
+
default: '',
|
|
19
|
+
type: String
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
useLazyLoading: {
|
|
23
|
+
type: Boolean
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
fetching: {
|
|
27
|
+
type: Boolean
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
emits: [
|
|
32
|
+
'update:modelValue',
|
|
33
|
+
'update:fetching',
|
|
34
|
+
'fetch-options-success',
|
|
35
|
+
'fetch-options-error'
|
|
36
|
+
],
|
|
37
|
+
|
|
38
|
+
data () {
|
|
39
|
+
return {
|
|
40
|
+
mx_filteredOptions: [],
|
|
41
|
+
mx_hasFetchError: false,
|
|
42
|
+
mx_isFetching: false,
|
|
43
|
+
mx_isScrolling: false,
|
|
44
|
+
mx_search: '',
|
|
45
|
+
mx_fetchCount: 0,
|
|
46
|
+
mx_pagination: {
|
|
47
|
+
page: 1,
|
|
48
|
+
lastPage: null,
|
|
49
|
+
hasCount: true,
|
|
50
|
+
hasNextPage: false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
computed: {
|
|
56
|
+
mx_defaultLazyLoadingProps () {
|
|
57
|
+
const {
|
|
58
|
+
url,
|
|
59
|
+
params,
|
|
60
|
+
decamelizeFieldName
|
|
61
|
+
} = this.lazyLoadingProps
|
|
62
|
+
|
|
63
|
+
const defaultParams = { limit: 48 }
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
url: url || '',
|
|
67
|
+
params: {
|
|
68
|
+
...defaultParams,
|
|
69
|
+
...params
|
|
70
|
+
},
|
|
71
|
+
decamelizeFieldName: decamelizeFieldName === undefined ? true : decamelizeFieldName
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
mx_hasFilteredOptions () {
|
|
76
|
+
return !!this.mx_filteredOptions.length
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
mx_isFilterByFuse () {
|
|
80
|
+
return !this.useLazyLoading
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
watch: {
|
|
85
|
+
lazyLoadingProps: {
|
|
86
|
+
handler (value, oldValue) {
|
|
87
|
+
if (isEqual(value, oldValue)) return
|
|
88
|
+
|
|
89
|
+
this.mx_filterOptionsByStore('')
|
|
90
|
+
this.$emit('update:modelValue', '')
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
methods: {
|
|
96
|
+
async mx_filterOptionsByStore (search) {
|
|
97
|
+
this.mx_resetFilter(search)
|
|
98
|
+
await this.mx_setFetchOptions()
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
mx_resetFilter (search) {
|
|
102
|
+
this.mx_filteredOptions = []
|
|
103
|
+
this.mx_search = search
|
|
104
|
+
this.mx_pagination = {
|
|
105
|
+
page: 1,
|
|
106
|
+
lastPage: null,
|
|
107
|
+
hasCount: true,
|
|
108
|
+
hasNextPage: false
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
async mx_onVirtualScroll ({ index, ref }) {
|
|
113
|
+
const lastIndex = this.mx_filteredOptions.length - 1
|
|
114
|
+
|
|
115
|
+
if (index === lastIndex && this.mx_canFetchOptions()) {
|
|
116
|
+
await this.mx_loadMoreOptions()
|
|
117
|
+
|
|
118
|
+
this.$nextTick(() => {
|
|
119
|
+
ref.reset()
|
|
120
|
+
ref.refresh(lastIndex)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
async mx_loadMoreOptions () {
|
|
126
|
+
this.mx_isScrolling = true
|
|
127
|
+
|
|
128
|
+
const options = await this.mx_fetchOptions()
|
|
129
|
+
this.mx_filteredOptions.push(...options)
|
|
130
|
+
|
|
131
|
+
// this is to prevent the virtual-scroll event to be fired again
|
|
132
|
+
this.$nextTick(() => {
|
|
133
|
+
this.mx_isScrolling = false
|
|
134
|
+
})
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
async mx_fetchOptions () {
|
|
138
|
+
this.mx_fetchCount++
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
if (!this.entity) this.mx_setMissingPropsMessage('entity')
|
|
142
|
+
if (!this.name) this.mx_setMissingPropsMessage('name')
|
|
143
|
+
|
|
144
|
+
this.mx_hasFetchError = false
|
|
145
|
+
this.mx_isFetching = true
|
|
146
|
+
|
|
147
|
+
this.$emit('update:fetching', true)
|
|
148
|
+
|
|
149
|
+
const { url, params, decamelizeFieldName } = this.mx_defaultLazyLoadingProps
|
|
150
|
+
|
|
151
|
+
const { data } = await this.$store.dispatch(`${this.entity}/fetchFieldOptions`, {
|
|
152
|
+
url,
|
|
153
|
+
field: decamelizeFieldName ? decamelize(this.name, { separator: '-' }) : this.name,
|
|
154
|
+
params: {
|
|
155
|
+
...params,
|
|
156
|
+
search: this.mx_search,
|
|
157
|
+
offset: (this.mx_pagination.page - 1) * params.limit
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
const { results, count, hasNextPage } = data
|
|
162
|
+
const hasCount = count !== undefined
|
|
163
|
+
|
|
164
|
+
this.mx_pagination = {
|
|
165
|
+
page: this.mx_pagination.page + 1,
|
|
166
|
+
lastPage: hasCount ? Math.ceil(count / params.limit) : null,
|
|
167
|
+
hasCount,
|
|
168
|
+
hasNextPage
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.$emit('fetch-options-success', data)
|
|
172
|
+
|
|
173
|
+
return this.mx_handleOptions(results)
|
|
174
|
+
} catch (error) {
|
|
175
|
+
this.$qas.logger.group(
|
|
176
|
+
`Mixin: searchFilterMixin - mx_fetchOptions -> exceção da action ${this.entity}/fetchFieldOptions`,
|
|
177
|
+
[error],
|
|
178
|
+
{ error: true }
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
this.mx_hasFetchError = true
|
|
182
|
+
this.$emit('fetch-options-error', error)
|
|
183
|
+
|
|
184
|
+
return []
|
|
185
|
+
} finally {
|
|
186
|
+
this.mx_isFetching = false
|
|
187
|
+
this.$emit('update:fetching', false)
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
async mx_setFetchOptions () {
|
|
192
|
+
this.mx_filteredOptions = await this.mx_fetchOptions()
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
mx_canFetchOptions () {
|
|
196
|
+
const { lastPage, page, hasCount, hasNextPage } = this.mx_pagination
|
|
197
|
+
|
|
198
|
+
const hasMorePages = hasCount ? lastPage && page <= lastPage : hasNextPage
|
|
199
|
+
|
|
200
|
+
return hasMorePages && !this.mx_isFetching && !this.mx_isScrolling && this.useLazyLoading
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
mx_handleOptions (options) {
|
|
204
|
+
if (this.labelKey && this.valueKey) {
|
|
205
|
+
return getNormalizedOptions({
|
|
206
|
+
options,
|
|
207
|
+
label: this.labelKey,
|
|
208
|
+
value: this.valueKey
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return options
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
mx_getMissingPropsMessage (prop) {
|
|
216
|
+
return `A propriedade "${prop}" é obrigatória quando a propriedade "useLazyLoading" está ativa.`
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
mx_setMissingPropsMessage (prop) {
|
|
220
|
+
throw new Error(this.mx_getMissingPropsMessage(prop))
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
mx_getNormalizedFuseResults (results = []) {
|
|
224
|
+
return results.map(({ item }) => item)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
package/src/mixins/view.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { camelizeFieldsName } from '../helpers'
|
|
2
2
|
import { markRaw } from 'vue'
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
props: {
|
|
6
|
-
dialog: {
|
|
7
|
-
type: Boolean
|
|
8
|
-
},
|
|
9
|
-
|
|
10
6
|
entity: {
|
|
11
7
|
required: true,
|
|
12
8
|
type: String
|
|
@@ -34,6 +30,16 @@ export default {
|
|
|
34
30
|
|
|
35
31
|
fetching: {
|
|
36
32
|
type: Boolean
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
useBoundary: {
|
|
36
|
+
default: true,
|
|
37
|
+
type: Boolean
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
beforeFetch: {
|
|
41
|
+
default: null,
|
|
42
|
+
type: Function
|
|
37
43
|
}
|
|
38
44
|
},
|
|
39
45
|
|
|
@@ -49,7 +55,7 @@ export default {
|
|
|
49
55
|
mx_errors: {},
|
|
50
56
|
mx_fields: {},
|
|
51
57
|
mx_metadata: {},
|
|
52
|
-
|
|
58
|
+
mx_cancelBeforeFetch: false,
|
|
53
59
|
mx_isFetching: false
|
|
54
60
|
}
|
|
55
61
|
},
|
|
@@ -62,11 +68,11 @@ export default {
|
|
|
62
68
|
|
|
63
69
|
computed: {
|
|
64
70
|
mx_componentTag () {
|
|
65
|
-
return this.
|
|
71
|
+
return this.useBoundary ? 'q-page' : 'div'
|
|
66
72
|
},
|
|
67
73
|
|
|
68
74
|
mx_componentClass () {
|
|
69
|
-
return
|
|
75
|
+
return this.useBoundary && 'container spaced'
|
|
70
76
|
},
|
|
71
77
|
|
|
72
78
|
mx_hasFooterSlot () {
|
|
@@ -100,11 +106,9 @@ export default {
|
|
|
100
106
|
},
|
|
101
107
|
|
|
102
108
|
mx_setFields (fields = {}) {
|
|
103
|
-
|
|
104
|
-
fields[field].name = camelize(fields[field].name)
|
|
105
|
-
}
|
|
109
|
+
const camelizedFields = camelizeFieldsName(fields)
|
|
106
110
|
|
|
107
|
-
this.mx_fields = markRaw(
|
|
111
|
+
this.mx_fields = markRaw(camelizedFields)
|
|
108
112
|
},
|
|
109
113
|
|
|
110
114
|
mx_setMetadata (metadata = {}) {
|
|
@@ -117,6 +121,22 @@ export default {
|
|
|
117
121
|
|
|
118
122
|
this.$emit(`update:${key}`, models[key])
|
|
119
123
|
}
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
mx_fetchHandler (payload, resolve) {
|
|
127
|
+
const hasBeforeFetch = typeof this.beforeFetch === 'function'
|
|
128
|
+
|
|
129
|
+
if (hasBeforeFetch && !this.mx_cancelBeforeFetch) {
|
|
130
|
+
return this.beforeFetch({
|
|
131
|
+
payload,
|
|
132
|
+
resolve: payload => resolve(payload),
|
|
133
|
+
done: () => {
|
|
134
|
+
this.mx_cancelBeforeFetch = true
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
resolve()
|
|
120
140
|
}
|
|
121
141
|
}
|
|
122
142
|
}
|
package/src/plugins/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import Dialog from './dialog/Dialog.js'
|
|
2
|
+
import Logger from './logger/Logger.js'
|
|
2
3
|
import NotifyError from './notify-error/NotifyError.js'
|
|
3
4
|
import NotifySuccess from './notify-success/NotifySuccess.js'
|
|
4
5
|
import Screen from './screen/Screen.js'
|
|
5
6
|
|
|
6
7
|
export {
|
|
7
8
|
Dialog,
|
|
9
|
+
Logger,
|
|
8
10
|
NotifyError,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
NotifySuccess,
|
|
12
|
+
Screen
|
|
11
13
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
const isDebugEnabled = process.env.DEBUGGING
|
|
3
|
+
|
|
4
|
+
const normalizeMessage = msg => `%c ${msg}`
|
|
5
|
+
const getStyle = isError => (
|
|
6
|
+
`
|
|
7
|
+
background: ${isError ? '#C10015 ' : '#1976d2'};
|
|
8
|
+
font-weight: bold;
|
|
9
|
+
color: white;
|
|
10
|
+
padding: 6px 20px;
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
display: block;
|
|
13
|
+
width: 100%;
|
|
14
|
+
font-size: 12px;
|
|
15
|
+
`
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
group (message, payload = [], { error } = {}) {
|
|
20
|
+
if (!isDebugEnabled) return
|
|
21
|
+
|
|
22
|
+
console.groupCollapsed(normalizeMessage(message), getStyle(error))
|
|
23
|
+
|
|
24
|
+
for (const item of payload) {
|
|
25
|
+
if (typeof item === 'string') {
|
|
26
|
+
console.info(normalizeMessage(item), getStyle(error))
|
|
27
|
+
continue
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.table(item)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.groupEnd()
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
info (message) {
|
|
37
|
+
isDebugEnabled && console.info(normalizeMessage(message), getStyle())
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
error (message) {
|
|
41
|
+
isDebugEnabled && console.info(normalizeMessage(message), getStyle(true))
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/vue-plugin.js
CHANGED
|
@@ -55,7 +55,8 @@ import {
|
|
|
55
55
|
Dialog,
|
|
56
56
|
NotifyError,
|
|
57
57
|
NotifySuccess,
|
|
58
|
-
Screen
|
|
58
|
+
Screen,
|
|
59
|
+
Logger
|
|
59
60
|
} from './plugins'
|
|
60
61
|
|
|
61
62
|
import packageInfo from '../package.json'
|
|
@@ -124,8 +125,9 @@ function install (app) {
|
|
|
124
125
|
app.config.globalProperties.$qas = {
|
|
125
126
|
dialog: Dialog,
|
|
126
127
|
error: NotifyError,
|
|
127
|
-
|
|
128
|
-
screen: Screen()
|
|
128
|
+
logger: Logger(),
|
|
129
|
+
screen: Screen(),
|
|
130
|
+
success: NotifySuccess
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
app.directive(Test.name, Test)
|
|
@@ -186,6 +188,7 @@ export {
|
|
|
186
188
|
|
|
187
189
|
// plugins
|
|
188
190
|
Dialog,
|
|
191
|
+
Logger,
|
|
189
192
|
NotifyError,
|
|
190
193
|
NotifySuccess,
|
|
191
194
|
Screen,
|