@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythpe/quasar-ui-qui",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -10,18 +10,40 @@
10
10
  lang="ts"
11
11
  setup
12
12
  >
13
- import type { ButtonLoadingOptions, MBtnProps as Props } from '../../types'
13
+ import type { ButtonLoadingOptions, MBtnProps } from '../../types'
14
14
  import { computed } from 'vue'
15
- import { useBindInput, useMyth } from '../../composable'
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 btnLoading = computed(() => theme.value.buttonLoading as ButtonLoadingOptions)
21
- const getLabel = computed<string | undefined>(() => props.label ? (__(props.label) ?? undefined) : undefined)
22
- const getSize = computed<string | undefined>(() => btnLoading.value.size)
23
- const getColor = computed<string | undefined>(() => btnLoading.value.color)
24
- const { attrs } = useBindInput<QBtnProps & { name: string }>(() => props, 'btn')
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
- ariaLabel: getLabel,
56
+ ...pluginOptions.btn,
57
+ ariaLabel: getAriaLabel,
35
58
  ...$attrs,
36
- ...attrs,
37
- label: loading ? `${getLabel} ...` : getLabel,
59
+ label: loading && getLabel ? `${getLabel} ...` : getLabel,
38
60
  }"
39
61
  >
40
62
  <template
41
- v-if="!!btnLoading && !$slots.loading"
63
+ v-if="!!loadingOptions && !$slots.loading"
42
64
  #loading
43
65
  >
44
66
  <q-spinner-audio
45
- v-if="btnLoading.type === 'audio'"
46
- :class="{'on-left': !!getLabel}"
47
- :color="getColor"
48
- :size="getSize"
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="btnLoading.type === 'ball'"
52
- :class="{'on-left': !!getLabel}"
53
- :color="getColor"
54
- :size="getSize"
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="btnLoading.type === 'bars'"
58
- :class="{'on-left': !!getLabel}"
59
- :color="getColor"
60
- :size="getSize"
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="btnLoading.type === 'box'"
64
- :class="{'on-left': !!getLabel}"
65
- :color="getColor"
66
- :size="getSize"
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="btnLoading.type === 'clock'"
70
- :class="{'on-left': !!getLabel}"
71
- :color="getColor"
72
- :size="getSize"
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="btnLoading.type === 'comment'"
76
- :class="{'on-left': !!getLabel}"
77
- :color="getColor"
78
- :size="getSize"
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="btnLoading.type === 'cube'"
82
- :class="{'on-left': !!getLabel}"
83
- :color="getColor"
84
- :size="getSize"
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="btnLoading.type === 'dots'"
88
- :class="{'on-left': !!getLabel}"
89
- :color="getColor"
90
- :size="getSize"
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="btnLoading.type === 'facebook'"
94
- :class="{'on-left': !!getLabel}"
95
- :color="getColor"
96
- :size="getSize"
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="btnLoading.type === 'gears'"
100
- :class="{'on-left': !!getLabel}"
101
- :color="getColor"
102
- :size="getSize"
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="btnLoading.type === 'grid'"
106
- :class="{'on-left': !!getLabel}"
107
- :color="getColor"
108
- :size="getSize"
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="btnLoading.type === 'hearts'"
112
- :class="{'on-left': !!getLabel}"
113
- :color="getColor"
114
- :size="getSize"
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="btnLoading.type === 'hearts'"
118
- :class="{'on-left': !!getLabel}"
119
- :color="getColor"
120
- :size="getSize"
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="btnLoading.type === 'hourglass'"
124
- :class="{'on-left': !!getLabel}"
125
- :color="getColor"
126
- :size="getSize"
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="btnLoading.type === 'infinity'"
130
- :class="{'on-left': !!getLabel}"
131
- :color="getColor"
132
- :size="getSize"
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="btnLoading.type === 'ios'"
136
- :class="{'on-left': !!getLabel}"
137
- :color="getColor"
138
- :size="getSize"
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="btnLoading.type === 'orbit'"
142
- :class="{'on-left': !!getLabel}"
143
- :color="getColor"
144
- :size="getSize"
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="btnLoading.type === 'oval'"
148
- :class="{'on-left': !!getLabel}"
149
- :color="getColor"
150
- :size="getSize"
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="btnLoading.type === 'pie'"
154
- :class="{'on-left': !!getLabel}"
155
- :color="getColor"
156
- :size="getSize"
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="btnLoading.type === 'puff'"
160
- :class="{'on-left': !!getLabel}"
161
- :color="getColor"
162
- :size="getSize"
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="btnLoading.type === 'radio'"
166
- :class="{'on-left': !!getLabel}"
167
- :color="getColor"
168
- :size="getSize"
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="btnLoading.type === 'rings'"
172
- :class="{'on-left': !!getLabel}"
173
- :color="getColor"
174
- :size="getSize"
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="btnLoading.type === 'tail'"
178
- :class="{'on-left': !!getLabel}"
179
- :color="getColor"
180
- :size="getSize"
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="btnLoading.type === 'spinner'"
184
- :class="{'on-left': !!getLabel}"
185
- :color="getColor"
186
- :size="getSize"
205
+ v-if="loadingOptions.type === 'spinner'"
206
+ :class="{'on-left': hasLabel}"
207
+ :color="loadingColor"
208
+ :size="loadingSize"
187
209
  />
188
- <template v-if="btnLoading.noLabel !== !1 && getLabel">
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<Props>(), {
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 { attrs, hasTopLabel, getLabel, getPlaceholder, getAutocompleteAttribute, inputRules } = helper
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
- ...attrs as any,
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
- theme.value[k] = props[k] !== undefined ? props[k] : themeStyle.value[k]
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
- native?: boolean;
79
+ ariaLabel?: boolean | string | null | undefined;
80
+ nativeLabel?: boolean | undefined;
80
81
  }
81
82
 
82
83
  export interface MBtnSlots extends QBtnSlots {