@mythpe/quasar-ui-qui 0.0.58 → 0.0.60
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
|
@@ -10,18 +10,40 @@
|
|
|
10
10
|
lang="ts"
|
|
11
11
|
setup
|
|
12
12
|
>
|
|
13
|
-
import type { ButtonLoadingOptions, MBtnProps
|
|
13
|
+
import type { ButtonLoadingOptions, MBtnProps } from '../../types'
|
|
14
14
|
import { computed } from 'vue'
|
|
15
|
-
import {
|
|
16
|
-
import type { QBtnProps } from 'quasar'
|
|
15
|
+
import { useMyth } from '../../composable'
|
|
17
16
|
|
|
17
|
+
type Props = {
|
|
18
|
+
label?: MBtnProps['label'];
|
|
19
|
+
ariaLabel?: MBtnProps['ariaLabel'];
|
|
20
|
+
loading?: MBtnProps['loading'];
|
|
21
|
+
nativeLabel?: MBtnProps['nativeLabel'];
|
|
22
|
+
}
|
|
18
23
|
const props = defineProps<Props>()
|
|
19
|
-
const { __, theme } = useMyth()
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const { __, theme, props: pluginOptions } = useMyth()
|
|
25
|
+
const getLabel = computed<string | undefined>(() => {
|
|
26
|
+
if (props.nativeLabel === !0) {
|
|
27
|
+
return props.label
|
|
28
|
+
}
|
|
29
|
+
return props.label ? (__(props.label) ?? undefined) : undefined
|
|
30
|
+
})
|
|
31
|
+
const getAriaLabel = computed<string | undefined>(() => {
|
|
32
|
+
if (props.ariaLabel === !0 || (typeof props.ariaLabel === 'string' && !props.ariaLabel?.length)) {
|
|
33
|
+
if (props.label !== undefined) {
|
|
34
|
+
return __(props.label) || undefined
|
|
35
|
+
}
|
|
36
|
+
} else if (typeof props.ariaLabel === 'string' && props.ariaLabel?.length > 0) {
|
|
37
|
+
return __(props.ariaLabel) || undefined
|
|
38
|
+
}
|
|
39
|
+
return props.ariaLabel ? __(props.ariaLabel) : undefined
|
|
40
|
+
})
|
|
41
|
+
const hasLabel = computed<boolean>(() => !!getLabel.value)
|
|
42
|
+
|
|
43
|
+
const loadingOptions = computed(() => theme.value.buttonLoading as ButtonLoadingOptions)
|
|
44
|
+
const loadingSize = computed<string | undefined>(() => loadingOptions.value.size)
|
|
45
|
+
const loadingColor = computed<string | undefined>(() => loadingOptions.value.color)
|
|
46
|
+
|
|
25
47
|
defineOptions({
|
|
26
48
|
name: 'MBtn',
|
|
27
49
|
inheritAttrs: !1
|
|
@@ -31,161 +53,161 @@ defineOptions({
|
|
|
31
53
|
<template>
|
|
32
54
|
<q-btn
|
|
33
55
|
v-bind="{
|
|
34
|
-
|
|
56
|
+
...pluginOptions.btn,
|
|
57
|
+
ariaLabel: getAriaLabel,
|
|
35
58
|
...$attrs,
|
|
36
|
-
|
|
37
|
-
label: loading ? `${getLabel} ...` : getLabel,
|
|
59
|
+
label: loading && getLabel ? `${getLabel} ...` : getLabel,
|
|
38
60
|
}"
|
|
39
61
|
>
|
|
40
62
|
<template
|
|
41
|
-
v-if="!!
|
|
63
|
+
v-if="!!loadingOptions && !$slots.loading"
|
|
42
64
|
#loading
|
|
43
65
|
>
|
|
44
66
|
<q-spinner-audio
|
|
45
|
-
v-if="
|
|
46
|
-
:class="{'on-left':
|
|
47
|
-
:color="
|
|
48
|
-
:size="
|
|
67
|
+
v-if="loadingOptions.type === 'audio'"
|
|
68
|
+
:class="{'on-left': hasLabel}"
|
|
69
|
+
:color="loadingColor"
|
|
70
|
+
:size="loadingSize"
|
|
49
71
|
/>
|
|
50
72
|
<q-spinner-ball
|
|
51
|
-
v-if="
|
|
52
|
-
:class="{'on-left':
|
|
53
|
-
:color="
|
|
54
|
-
:size="
|
|
73
|
+
v-if="loadingOptions.type === 'ball'"
|
|
74
|
+
:class="{'on-left': hasLabel}"
|
|
75
|
+
:color="loadingColor"
|
|
76
|
+
:size="loadingSize"
|
|
55
77
|
/>
|
|
56
78
|
<q-spinner-bars
|
|
57
|
-
v-if="
|
|
58
|
-
:class="{'on-left':
|
|
59
|
-
:color="
|
|
60
|
-
:size="
|
|
79
|
+
v-if="loadingOptions.type === 'bars'"
|
|
80
|
+
:class="{'on-left': hasLabel}"
|
|
81
|
+
:color="loadingColor"
|
|
82
|
+
:size="loadingSize"
|
|
61
83
|
/>
|
|
62
84
|
<q-spinner-box
|
|
63
|
-
v-if="
|
|
64
|
-
:class="{'on-left':
|
|
65
|
-
:color="
|
|
66
|
-
:size="
|
|
85
|
+
v-if="loadingOptions.type === 'box'"
|
|
86
|
+
:class="{'on-left': hasLabel}"
|
|
87
|
+
:color="loadingColor"
|
|
88
|
+
:size="loadingSize"
|
|
67
89
|
/>
|
|
68
90
|
<q-spinner-clock
|
|
69
|
-
v-if="
|
|
70
|
-
:class="{'on-left':
|
|
71
|
-
:color="
|
|
72
|
-
:size="
|
|
91
|
+
v-if="loadingOptions.type === 'clock'"
|
|
92
|
+
:class="{'on-left': hasLabel}"
|
|
93
|
+
:color="loadingColor"
|
|
94
|
+
:size="loadingSize"
|
|
73
95
|
/>
|
|
74
96
|
<q-spinner-comment
|
|
75
|
-
v-if="
|
|
76
|
-
:class="{'on-left':
|
|
77
|
-
:color="
|
|
78
|
-
:size="
|
|
97
|
+
v-if="loadingOptions.type === 'comment'"
|
|
98
|
+
:class="{'on-left': hasLabel}"
|
|
99
|
+
:color="loadingColor"
|
|
100
|
+
:size="loadingSize"
|
|
79
101
|
/>
|
|
80
102
|
<q-spinner-cube
|
|
81
|
-
v-if="
|
|
82
|
-
:class="{'on-left':
|
|
83
|
-
:color="
|
|
84
|
-
:size="
|
|
103
|
+
v-if="loadingOptions.type === 'cube'"
|
|
104
|
+
:class="{'on-left': hasLabel}"
|
|
105
|
+
:color="loadingColor"
|
|
106
|
+
:size="loadingSize"
|
|
85
107
|
/>
|
|
86
108
|
<q-spinner-dots
|
|
87
|
-
v-if="
|
|
88
|
-
:class="{'on-left':
|
|
89
|
-
:color="
|
|
90
|
-
:size="
|
|
109
|
+
v-if="loadingOptions.type === 'dots'"
|
|
110
|
+
:class="{'on-left': hasLabel}"
|
|
111
|
+
:color="loadingColor"
|
|
112
|
+
:size="loadingSize"
|
|
91
113
|
/>
|
|
92
114
|
<q-spinner-facebook
|
|
93
|
-
v-if="
|
|
94
|
-
:class="{'on-left':
|
|
95
|
-
:color="
|
|
96
|
-
:size="
|
|
115
|
+
v-if="loadingOptions.type === 'facebook'"
|
|
116
|
+
:class="{'on-left': hasLabel}"
|
|
117
|
+
:color="loadingColor"
|
|
118
|
+
:size="loadingSize"
|
|
97
119
|
/>
|
|
98
120
|
<q-spinner-gears
|
|
99
|
-
v-if="
|
|
100
|
-
:class="{'on-left':
|
|
101
|
-
:color="
|
|
102
|
-
:size="
|
|
121
|
+
v-if="loadingOptions.type === 'gears'"
|
|
122
|
+
:class="{'on-left': hasLabel}"
|
|
123
|
+
:color="loadingColor"
|
|
124
|
+
:size="loadingSize"
|
|
103
125
|
/>
|
|
104
126
|
<q-spinner-grid
|
|
105
|
-
v-if="
|
|
106
|
-
:class="{'on-left':
|
|
107
|
-
:color="
|
|
108
|
-
:size="
|
|
127
|
+
v-if="loadingOptions.type === 'grid'"
|
|
128
|
+
:class="{'on-left': hasLabel}"
|
|
129
|
+
:color="loadingColor"
|
|
130
|
+
:size="loadingSize"
|
|
109
131
|
/>
|
|
110
132
|
<q-spinner-hearts
|
|
111
|
-
v-if="
|
|
112
|
-
:class="{'on-left':
|
|
113
|
-
:color="
|
|
114
|
-
:size="
|
|
133
|
+
v-if="loadingOptions.type === 'hearts'"
|
|
134
|
+
:class="{'on-left': hasLabel}"
|
|
135
|
+
:color="loadingColor"
|
|
136
|
+
:size="loadingSize"
|
|
115
137
|
/>
|
|
116
138
|
<q-spinner-hearts
|
|
117
|
-
v-if="
|
|
118
|
-
:class="{'on-left':
|
|
119
|
-
:color="
|
|
120
|
-
:size="
|
|
139
|
+
v-if="loadingOptions.type === 'hearts'"
|
|
140
|
+
:class="{'on-left': hasLabel}"
|
|
141
|
+
:color="loadingColor"
|
|
142
|
+
:size="loadingSize"
|
|
121
143
|
/>
|
|
122
144
|
<q-spinner-hourglass
|
|
123
|
-
v-if="
|
|
124
|
-
:class="{'on-left':
|
|
125
|
-
:color="
|
|
126
|
-
:size="
|
|
145
|
+
v-if="loadingOptions.type === 'hourglass'"
|
|
146
|
+
:class="{'on-left': hasLabel}"
|
|
147
|
+
:color="loadingColor"
|
|
148
|
+
:size="loadingSize"
|
|
127
149
|
/>
|
|
128
150
|
<q-spinner-infinity
|
|
129
|
-
v-if="
|
|
130
|
-
:class="{'on-left':
|
|
131
|
-
:color="
|
|
132
|
-
:size="
|
|
151
|
+
v-if="loadingOptions.type === 'infinity'"
|
|
152
|
+
:class="{'on-left': hasLabel}"
|
|
153
|
+
:color="loadingColor"
|
|
154
|
+
:size="loadingSize"
|
|
133
155
|
/>
|
|
134
156
|
<q-spinner-ios
|
|
135
|
-
v-if="
|
|
136
|
-
:class="{'on-left':
|
|
137
|
-
:color="
|
|
138
|
-
:size="
|
|
157
|
+
v-if="loadingOptions.type === 'ios'"
|
|
158
|
+
:class="{'on-left': hasLabel}"
|
|
159
|
+
:color="loadingColor"
|
|
160
|
+
:size="loadingSize"
|
|
139
161
|
/>
|
|
140
162
|
<q-spinner-orbit
|
|
141
|
-
v-if="
|
|
142
|
-
:class="{'on-left':
|
|
143
|
-
:color="
|
|
144
|
-
:size="
|
|
163
|
+
v-if="loadingOptions.type === 'orbit'"
|
|
164
|
+
:class="{'on-left': hasLabel}"
|
|
165
|
+
:color="loadingColor"
|
|
166
|
+
:size="loadingSize"
|
|
145
167
|
/>
|
|
146
168
|
<q-spinner-oval
|
|
147
|
-
v-if="
|
|
148
|
-
:class="{'on-left':
|
|
149
|
-
:color="
|
|
150
|
-
:size="
|
|
169
|
+
v-if="loadingOptions.type === 'oval'"
|
|
170
|
+
:class="{'on-left': hasLabel}"
|
|
171
|
+
:color="loadingColor"
|
|
172
|
+
:size="loadingSize"
|
|
151
173
|
/>
|
|
152
174
|
<q-spinner-pie
|
|
153
|
-
v-if="
|
|
154
|
-
:class="{'on-left':
|
|
155
|
-
:color="
|
|
156
|
-
:size="
|
|
175
|
+
v-if="loadingOptions.type === 'pie'"
|
|
176
|
+
:class="{'on-left': hasLabel}"
|
|
177
|
+
:color="loadingColor"
|
|
178
|
+
:size="loadingSize"
|
|
157
179
|
/>
|
|
158
180
|
<q-spinner-puff
|
|
159
|
-
v-if="
|
|
160
|
-
:class="{'on-left':
|
|
161
|
-
:color="
|
|
162
|
-
:size="
|
|
181
|
+
v-if="loadingOptions.type === 'puff'"
|
|
182
|
+
:class="{'on-left': hasLabel}"
|
|
183
|
+
:color="loadingColor"
|
|
184
|
+
:size="loadingSize"
|
|
163
185
|
/>
|
|
164
186
|
<q-spinner-radio
|
|
165
|
-
v-if="
|
|
166
|
-
:class="{'on-left':
|
|
167
|
-
:color="
|
|
168
|
-
:size="
|
|
187
|
+
v-if="loadingOptions.type === 'radio'"
|
|
188
|
+
:class="{'on-left': hasLabel}"
|
|
189
|
+
:color="loadingColor"
|
|
190
|
+
:size="loadingSize"
|
|
169
191
|
/>
|
|
170
192
|
<q-spinner-rings
|
|
171
|
-
v-if="
|
|
172
|
-
:class="{'on-left':
|
|
173
|
-
:color="
|
|
174
|
-
:size="
|
|
193
|
+
v-if="loadingOptions.type === 'rings'"
|
|
194
|
+
:class="{'on-left': hasLabel}"
|
|
195
|
+
:color="loadingColor"
|
|
196
|
+
:size="loadingSize"
|
|
175
197
|
/>
|
|
176
198
|
<q-spinner-tail
|
|
177
|
-
v-if="
|
|
178
|
-
:class="{'on-left':
|
|
179
|
-
:color="
|
|
180
|
-
:size="
|
|
199
|
+
v-if="loadingOptions.type === 'tail'"
|
|
200
|
+
:class="{'on-left': hasLabel}"
|
|
201
|
+
:color="loadingColor"
|
|
202
|
+
:size="loadingSize"
|
|
181
203
|
/>
|
|
182
204
|
<q-spinner
|
|
183
|
-
v-if="
|
|
184
|
-
:class="{'on-left':
|
|
185
|
-
:color="
|
|
186
|
-
:size="
|
|
205
|
+
v-if="loadingOptions.type === 'spinner'"
|
|
206
|
+
:class="{'on-left': hasLabel}"
|
|
207
|
+
:color="loadingColor"
|
|
208
|
+
:size="loadingSize"
|
|
187
209
|
/>
|
|
188
|
-
<template v-if="
|
|
210
|
+
<template v-if="loadingOptions.noLabel !== !1 && getLabel">
|
|
189
211
|
<span>{{ getLabel }}</span>
|
|
190
212
|
</template>
|
|
191
213
|
</template>
|
|
@@ -12,41 +12,39 @@
|
|
|
12
12
|
>
|
|
13
13
|
import { useField } from 'vee-validate'
|
|
14
14
|
import { reactive, toValue, useTemplateRef } from 'vue'
|
|
15
|
-
import type { MInputProps as Props } from '../../types'
|
|
16
15
|
import { QField, QInput, type QInputSlots } from 'quasar'
|
|
17
16
|
import { useBindInput, useMyth } from '../../composable'
|
|
17
|
+
import type { MInputProps as Props } from '../../types'
|
|
18
|
+
|
|
19
|
+
type P = {
|
|
20
|
+
name: Props['name'];
|
|
21
|
+
auto?: Props['auto'];
|
|
22
|
+
col?: Props['col'];
|
|
23
|
+
xs?: Props['xs'];
|
|
24
|
+
sm?: Props['sm'];
|
|
25
|
+
md?: Props['md'];
|
|
26
|
+
lg?: Props['lg'];
|
|
27
|
+
xl?: Props['xl'];
|
|
28
|
+
label?: Props['label'];
|
|
29
|
+
caption?: Props['caption'];
|
|
30
|
+
hint?: Props['hint'];
|
|
31
|
+
placeholder?: Props['placeholder'];
|
|
32
|
+
help?: Props['help'];
|
|
33
|
+
required?: Props['required'];
|
|
34
|
+
rules?: Props['rules'];
|
|
35
|
+
viewMode?: Props['viewMode'];
|
|
36
|
+
viewModeValue?: Props['viewModeValue'];
|
|
37
|
+
autocomplete?: Props['autocomplete'];
|
|
38
|
+
topLabel?: Props['topLabel'];
|
|
39
|
+
fieldOptions?: Props['fieldOptions'];
|
|
40
|
+
clearable?: Props['clearable'];
|
|
41
|
+
mobile?: Props['mobile'];
|
|
42
|
+
email?: Props['email'];
|
|
43
|
+
float?: Props['float'];
|
|
44
|
+
}
|
|
18
45
|
|
|
19
|
-
const props = withDefaults(defineProps<
|
|
46
|
+
const props = withDefaults(defineProps<P>(), {
|
|
20
47
|
name: () => '',
|
|
21
|
-
fillMask: undefined,
|
|
22
|
-
reverseFillMask: undefined,
|
|
23
|
-
unmaskedValue: undefined,
|
|
24
|
-
error: undefined,
|
|
25
|
-
noErrorIcon: undefined,
|
|
26
|
-
reactiveRules: undefined,
|
|
27
|
-
lazyRules: undefined,
|
|
28
|
-
stackLabel: undefined,
|
|
29
|
-
hideHint: undefined,
|
|
30
|
-
dark: undefined,
|
|
31
|
-
loading: undefined,
|
|
32
|
-
clearable: undefined,
|
|
33
|
-
filled: undefined,
|
|
34
|
-
outlined: undefined,
|
|
35
|
-
borderless: undefined,
|
|
36
|
-
standout: undefined,
|
|
37
|
-
labelSlot: undefined,
|
|
38
|
-
bottomSlots: undefined,
|
|
39
|
-
hideBottomSpace: undefined,
|
|
40
|
-
counter: undefined,
|
|
41
|
-
rounded: undefined,
|
|
42
|
-
square: undefined,
|
|
43
|
-
dense: undefined,
|
|
44
|
-
itemAligned: undefined,
|
|
45
|
-
disable: undefined,
|
|
46
|
-
readonly: undefined,
|
|
47
|
-
autofocus: undefined,
|
|
48
|
-
autogrow: undefined,
|
|
49
|
-
viewMode: undefined,
|
|
50
48
|
auto: undefined,
|
|
51
49
|
col: undefined,
|
|
52
50
|
xs: undefined,
|
|
@@ -54,9 +52,19 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
54
52
|
md: undefined,
|
|
55
53
|
lg: undefined,
|
|
56
54
|
xl: undefined,
|
|
55
|
+
label: undefined,
|
|
56
|
+
caption: undefined,
|
|
57
|
+
hint: undefined,
|
|
58
|
+
placeholder: undefined,
|
|
59
|
+
help: undefined,
|
|
57
60
|
required: undefined,
|
|
61
|
+
rules: undefined,
|
|
62
|
+
viewMode: () => !1,
|
|
63
|
+
viewModeValue: undefined,
|
|
58
64
|
autocomplete: undefined,
|
|
59
65
|
topLabel: undefined,
|
|
66
|
+
fieldOptions: undefined,
|
|
67
|
+
clearable: undefined,
|
|
60
68
|
mobile: undefined,
|
|
61
69
|
email: undefined,
|
|
62
70
|
float: undefined
|
|
@@ -64,7 +72,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
64
72
|
defineModel<Props['modelValue']>({ required: !1, default: undefined })
|
|
65
73
|
const { __ } = useMyth()
|
|
66
74
|
const helper = useBindInput<Props>(() => props, 'input')
|
|
67
|
-
const {
|
|
75
|
+
const { theme, hasTopLabel, getLabel, getPlaceholder, getAutocompleteAttribute, inputRules } = helper
|
|
68
76
|
const inputScope = useField<Props['modelValue']>(() => props.name, inputRules, {
|
|
69
77
|
syncVModel: !0,
|
|
70
78
|
label: getLabel,
|
|
@@ -126,17 +134,17 @@ defineOptions({
|
|
|
126
134
|
:is="viewMode ? QField : QInput"
|
|
127
135
|
ref="input"
|
|
128
136
|
v-bind="{
|
|
129
|
-
|
|
137
|
+
...$attrs,
|
|
138
|
+
...theme,
|
|
130
139
|
...( viewMode ? { stackLabel: !0 } : {} ),
|
|
131
140
|
autocomplete: getAutocompleteAttribute,
|
|
132
141
|
clearable: viewMode ? !1 : clearable,
|
|
133
142
|
error: !!errorMessage,
|
|
134
|
-
required,
|
|
135
143
|
errorMessage,
|
|
136
144
|
hint: __(hint),
|
|
137
|
-
label: hasTopLabel?undefined:getLabel,
|
|
145
|
+
label: hasTopLabel ? undefined : getLabel,
|
|
138
146
|
modelValue: value,
|
|
139
|
-
placeholder:getPlaceholder
|
|
147
|
+
placeholder: getPlaceholder
|
|
140
148
|
}"
|
|
141
149
|
v-on="listeners"
|
|
142
150
|
>
|
|
@@ -27,7 +27,15 @@ export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key:
|
|
|
27
27
|
const themeStyle = computed(() => (key === 'btn' ? mTheme.value.buttons : mTheme.value.inputs) ?? {})
|
|
28
28
|
const theme = ref({})
|
|
29
29
|
for (const k in themeStyle.value) {
|
|
30
|
-
|
|
30
|
+
if (props[k] !== undefined) {
|
|
31
|
+
theme.value[k] = props[k]
|
|
32
|
+
continue
|
|
33
|
+
}
|
|
34
|
+
if (attributes[k] !== undefined) {
|
|
35
|
+
theme.value[k] = attributes[k]
|
|
36
|
+
continue
|
|
37
|
+
}
|
|
38
|
+
theme.value[k] = themeStyle.value[k]
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
const hasTopLabel = computed(() => {
|
|
@@ -195,7 +203,6 @@ export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key:
|
|
|
195
203
|
return Object.values(rules).filter(e => !!e).length > 0 ? rules : undefined
|
|
196
204
|
})
|
|
197
205
|
const attrs = computed(() => ({
|
|
198
|
-
...props,
|
|
199
206
|
...attributes,
|
|
200
207
|
...theme.value
|
|
201
208
|
}))
|
|
@@ -76,7 +76,8 @@ export interface MTransitionsSlots {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export interface MBtnProps extends QBtnProps {
|
|
79
|
-
|
|
79
|
+
ariaLabel?: boolean | string | null | undefined;
|
|
80
|
+
nativeLabel?: boolean | undefined;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
export interface MBtnSlots extends QBtnSlots {
|