@mythpe/quasar-ui-qui 0.0.25 → 0.0.26-dev

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.
Files changed (71) hide show
  1. package/index.d.ts +17 -0
  2. package/package.json +14 -8
  3. package/src/boot/register.ts +14 -0
  4. package/src/components/form/MAvatarViewer.vue +324 -0
  5. package/src/components/form/MAxios.vue +141 -0
  6. package/src/components/form/MBtn.vue +271 -93
  7. package/src/components/form/MCheckbox.vue +126 -0
  8. package/src/components/form/MColor.vue +122 -0
  9. package/src/components/form/MDate.vue +47 -0
  10. package/src/components/form/MEditor.vue +285 -0
  11. package/src/components/form/MEmail.vue +40 -0
  12. package/src/components/form/MField.vue +145 -0
  13. package/src/components/form/MFile.vue +212 -0
  14. package/src/components/form/MForm.vue +86 -0
  15. package/src/components/form/MHidden.vue +86 -0
  16. package/src/components/form/MHiddenInput.vue +55 -0
  17. package/src/components/form/MInput.vue +178 -0
  18. package/src/components/form/MInputFieldControl.vue +27 -0
  19. package/src/components/form/MInputLabel.vue +35 -0
  20. package/src/components/form/MMobile.vue +40 -0
  21. package/src/components/form/MPassword.vue +73 -0
  22. package/src/components/form/MPicker.vue +313 -0
  23. package/src/components/form/MRadio.vue +178 -0
  24. package/src/components/form/MSelect.vue +349 -0
  25. package/src/components/form/MTime.vue +45 -0
  26. package/src/components/form/index.ts +55 -0
  27. package/src/components/grid/MBlock.vue +39 -18
  28. package/src/components/grid/MCol.vue +11 -15
  29. package/src/components/grid/MColumn.vue +8 -0
  30. package/src/components/grid/MContainer.vue +22 -13
  31. package/src/components/grid/MHelpRow.vue +9 -12
  32. package/src/components/grid/MRow.vue +31 -10
  33. package/src/components/grid/index.ts +16 -0
  34. package/src/components/index.ts +12 -0
  35. package/src/components/transition/MFadeTransition.vue +27 -0
  36. package/src/components/transition/MFadeXTransition.vue +26 -0
  37. package/src/components/transition/MTransition.vue +41 -0
  38. package/src/components/transition/index.ts +13 -0
  39. package/src/components/typography/MTypingString.vue +8 -0
  40. package/src/components/typography/index.ts +11 -0
  41. package/src/composable/index.ts +12 -0
  42. package/src/composable/useBindInput.ts +209 -0
  43. package/src/composable/useError.ts +11 -0
  44. package/src/composable/useMyth.ts +302 -0
  45. package/src/composable/useValue.ts +12 -0
  46. package/src/index.common.js +19 -1
  47. package/src/index.esm.js +18 -3
  48. package/src/index.js +19 -0
  49. package/src/index.sass +8 -26
  50. package/src/index.ts +18 -4
  51. package/src/index.umd.js +17 -2
  52. package/src/style/m-container.sass +13 -0
  53. package/src/style/main.sass +42 -0
  54. package/src/types/api-helpers.d.ts +123 -0
  55. package/src/types/components.d.ts +769 -27
  56. package/src/types/dt.d.ts +144 -0
  57. package/src/types/index.d.ts +155 -1
  58. package/src/types/lodash.d.ts +26 -0
  59. package/src/types/quasar-helpers.d.ts +7 -0
  60. package/src/types/theme.d.ts +12 -0
  61. package/src/utils/Helpers.ts +293 -0
  62. package/src/utils/Str.ts +211 -0
  63. package/src/utils/index.ts +13 -0
  64. package/src/utils/myth.ts +95 -0
  65. package/src/utils/vee-rules.ts +32 -0
  66. package/src/utils/vue-plugin.ts +129 -0
  67. package/tsconfig.json +9 -13
  68. package/src/myth.ts +0 -30
  69. package/src/types/myth.ts +0 -42
  70. package/src/vue-plugin.ts +0 -41
  71. package/types.d.ts +0 -1
@@ -0,0 +1,40 @@
1
+ <!--
2
+ - MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ - Email: mythpe@gmail.com
4
+ - Mobile: +966590470092
5
+ - Website: https://www.4myth.com
6
+ - Github: https://github.com/mythpe
7
+ -->
8
+
9
+ <script lang="ts" setup>
10
+ import type { MInputProps as Props, MInputSlots } from '../../types'
11
+ import { useTemplateRef } from 'vue'
12
+ import MInput from './MInput.vue'
13
+ import { myth } from '../../utils'
14
+
15
+ const modelValue = defineModel<Props['modelValue']>({ required: !1, default: undefined })
16
+ const input = useTemplateRef<InstanceType<typeof MInput>>('input')
17
+ const { props: options } = myth
18
+ defineExpose<{ input: typeof input }>({ input })
19
+ defineOptions({
20
+ name: 'MMobile',
21
+ inheritAttrs: !1
22
+ })
23
+ </script>
24
+
25
+ <template>
26
+ <MInput
27
+ ref="input"
28
+ v-model="modelValue"
29
+ type="tel"
30
+ v-bind="{...options.mobile as any,...$attrs}"
31
+ >
32
+ <template
33
+ v-for="(_,slot) in $slots as Readonly<MInputSlots>"
34
+ :key="slot"
35
+ #[slot]
36
+ >
37
+ <slot :name="slot" />
38
+ </template>
39
+ </MInput>
40
+ </template>
@@ -0,0 +1,73 @@
1
+ <!--
2
+ - MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ - Email: mythpe@gmail.com
4
+ - Mobile: +966590470092
5
+ - Website: https://www.4myth.com
6
+ - Github: https://github.com/mythpe
7
+ -->
8
+
9
+ <script
10
+ lang="ts"
11
+ setup
12
+ >
13
+ import type { MInputSlots, MPasswordProps as Props } from '../../types'
14
+ import MInput from './MInput.vue'
15
+ import { ref, useTemplateRef } from 'vue'
16
+
17
+ type P = {
18
+ name?: Props['name'];
19
+ icon?: Props['icon'];
20
+ noToggle?: Props['noToggle'];
21
+ }
22
+
23
+ withDefaults(defineProps<P>(), {
24
+ name: () => '',
25
+ icon: () => !1,
26
+ noToggle: () => !1
27
+ })
28
+ const modelValue = defineModel<Props['modelValue']>({ required: !1, default: undefined })
29
+ const inputType = ref<'text' | 'password'>('password')
30
+ const togglePassword = () => {
31
+ inputType.value = inputType.value === 'text' ? 'password' : 'text'
32
+ }
33
+ const input = useTemplateRef<InstanceType<typeof MInput>>('input')
34
+ defineExpose<{ input: typeof input }>({ input })
35
+ defineOptions({
36
+ name: 'MPassword',
37
+ inheritAttrs: !1
38
+ })
39
+ </script>
40
+
41
+ <template>
42
+ <MInput
43
+ ref="input"
44
+ v-model="modelValue"
45
+ :name="name"
46
+ v-bind="{...$attrs,type:inputType}"
47
+ >
48
+ <template
49
+ v-if="icon && !Boolean($slots.prepend)"
50
+ #prepend
51
+ >
52
+ <q-icon name="password" />
53
+ </template>
54
+ <template
55
+ v-if="!noToggle && !Boolean($slots.prepend)"
56
+ #append
57
+ >
58
+ <q-btn
59
+ :icon="'ion-ios-eye' + (inputType !== 'password' ? '-off' : '')"
60
+ flat
61
+ round
62
+ @click="togglePassword()"
63
+ />
64
+ </template>
65
+ <template
66
+ v-for="(_,slot) in $slots as Readonly<MInputSlots>"
67
+ :key="slot"
68
+ #[slot]
69
+ >
70
+ <slot :name="slot" />
71
+ </template>
72
+ </MInput>
73
+ </template>
@@ -0,0 +1,313 @@
1
+ <!--
2
+ - MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ - Email: mythpe@gmail.com
4
+ - Mobile: +966590470092
5
+ - Website: https://www.4myth.com
6
+ - Github: https://github.com/mythpe
7
+ -->
8
+
9
+ <script
10
+ lang="ts"
11
+ setup
12
+ >
13
+ import { computed, reactive, ref, toValue, useTemplateRef } from 'vue'
14
+ import type { MPickerProps as Props } from '../../types'
15
+ import { useBindInput, useMyth } from '../../composable'
16
+ import { useField } from 'vee-validate'
17
+ import { QDate, QField, QFieldSlots, QTime } from 'quasar'
18
+ import { myth } from '../../utils'
19
+
20
+ const defSeparator = ' - '
21
+ const props = withDefaults(defineProps<Omit<Props, 'prefix'>>(), {
22
+ name: '',
23
+ type: undefined,
24
+ fillMask: undefined,
25
+ reverseFillMask: undefined,
26
+ unmaskedValue: undefined,
27
+ error: undefined,
28
+ noErrorIcon: undefined,
29
+ reactiveRules: undefined,
30
+ lazyRules: undefined,
31
+ stackLabel: undefined,
32
+ hideHint: undefined,
33
+ dark: undefined,
34
+ loading: undefined,
35
+ clearable: undefined,
36
+ filled: undefined,
37
+ outlined: undefined,
38
+ borderless: undefined,
39
+ standout: undefined,
40
+ labelSlot: undefined,
41
+ bottomSlots: undefined,
42
+ hideBottomSpace: undefined,
43
+ counter: undefined,
44
+ rounded: undefined,
45
+ square: undefined,
46
+ dense: undefined,
47
+ itemAligned: undefined,
48
+ disable: undefined,
49
+ readonly: undefined,
50
+ autofocus: undefined,
51
+ autogrow: undefined,
52
+ viewMode: undefined,
53
+ auto: undefined,
54
+ col: undefined,
55
+ xs: undefined,
56
+ sm: undefined,
57
+ md: undefined,
58
+ lg: undefined,
59
+ xl: undefined,
60
+ required: undefined,
61
+ autocomplete: undefined,
62
+ topLabel: undefined,
63
+ mobile: undefined,
64
+ email: undefined,
65
+ float: undefined,
66
+ landscape: undefined,
67
+ flat: undefined,
68
+ bordered: undefined,
69
+ yearsInMonthView: undefined,
70
+ noUnset: undefined,
71
+ todayBtn: undefined,
72
+ minimal: undefined,
73
+ multiple: undefined,
74
+ range: undefined,
75
+ emitImmediately: undefined,
76
+ format24h: undefined,
77
+ withSeconds: undefined,
78
+ nowBtn: undefined,
79
+ useChoice: undefined
80
+ })
81
+
82
+ defineModel<Props['modelValue']>({ required: !1, default: undefined })
83
+ const helper = useBindInput<Props>(() => props, 'picker', () => ({ choose: !0 }))
84
+ const { hasTopLabel, getLabel, getPlaceholder, inputRules, getAutocompleteAttribute, getProp } = helper
85
+ const { __ } = useMyth()
86
+ const options = computed(() => myth.props.value)
87
+ const theme = computed(() => myth.themeInput)
88
+ const inputScope = useField<Props['modelValue']>(() => props.name, inputRules, {
89
+ syncVModel: !0,
90
+ label: getLabel,
91
+ ...toValue<any>(props.fieldOptions)
92
+ })
93
+ const scopes = reactive(inputScope)
94
+ const { value, errorMessage, handleChange } = inputScope
95
+
96
+ const isDate = computed(() => props.type !== 'time')
97
+ // const mask = computed(() => {
98
+ // if (props.range || props.multiple) {
99
+ // return undefined
100
+ // // return isDate.value ? '####/##/## - ####-##-##' : '##:## - ##:##'
101
+ // }
102
+ // return isDate.value ? '####/##/##' : '##:##'
103
+ // })
104
+ const format = computed(() => isDate.value ? 'YYYY/MM/DD' : 'HH:mm')
105
+ const dateRef = ref<string | null>(null)
106
+ const onBeforeShow = () => {
107
+ dateRef.value = value.value || null
108
+ }
109
+ const onBeforeHide = () => {
110
+ dateRef.value = null
111
+ }
112
+ const saveDialog = () => {
113
+ let newVal: any = dateRef.value
114
+ if (typeof newVal === 'object' && isDate.value) {
115
+ const values: any[] = Object.values(newVal)
116
+ for (const aKey in values) {
117
+ if (typeof values[aKey] === 'object') {
118
+ values[aKey] = Object.values(values[aKey])
119
+ }
120
+ }
121
+ newVal = values
122
+ }
123
+ handleChange(newVal, !!errorMessage.value)
124
+ }
125
+
126
+ const dateElm = useTemplateRef<InstanceType<typeof QDate>>('dateElm')
127
+ const timeElm = useTemplateRef<InstanceType<typeof QTime>>('timeElm')
128
+ defineExpose<{ input: typeof dateElm | typeof timeElm }>({ input: isDate.value ? dateElm : timeElm })
129
+ defineOptions({
130
+ name: 'MPicker',
131
+ inheritAttrs: !1
132
+ })
133
+ </script>
134
+
135
+ <template>
136
+ <MCol
137
+ :auto="auto"
138
+ :class="[$attrs.class,{'m--input__required':inputRules?.required!==undefined,'m--input__error':!!errorMessage,'m--input__view':viewMode}]"
139
+ :col="col"
140
+ :lg="lg"
141
+ :md="md"
142
+ :name="name"
143
+ :sm="sm"
144
+ :xs="xs"
145
+ >
146
+ <slot
147
+ name="top-input"
148
+ v-bind="scopes"
149
+ />
150
+ <slot name="top-label">
151
+ <MInputLabel
152
+ v-if="hasTopLabel"
153
+ :field="scopes"
154
+ >
155
+ <MHelpRow
156
+ :text="help"
157
+ tooltip
158
+ />
159
+ </MInputLabel>
160
+ </slot>
161
+ <slot name="caption">
162
+ <div
163
+ v-if="!!caption"
164
+ class="m--input__caption"
165
+ >
166
+ {{ __(caption) }}
167
+ </div>
168
+ </slot>
169
+ <q-field
170
+ ref="input"
171
+ v-model="value"
172
+ :error="!!errorMessage"
173
+ :error-message="errorMessage"
174
+ :hint="__(hint)"
175
+ :label="hasTopLabel ? undefined : getLabel"
176
+ v-bind="{
177
+ ...options.input as any,
178
+ ...options.field as any,
179
+ ...theme,
180
+ ...$attrs,
181
+ autocomplete:getAutocompleteAttribute,
182
+ stackLabel: !0
183
+ }"
184
+ >
185
+ <template #control>
186
+ <slot name="control">
187
+ <div
188
+ v-if="!disable && !readonly && !viewMode && !!getPlaceholder && !value"
189
+ class="q-placeholder"
190
+ >
191
+ {{ getPlaceholder }}
192
+ </div>
193
+ <template v-else-if="viewMode && viewModeValue">
194
+ <div>{{ viewModeValue?.toString() }}</div>
195
+ </template>
196
+ <template v-else>
197
+ <div>
198
+ <template v-if="value && Array.isArray(value)">
199
+ {{ value.join(rangeSeparator || options.picker?.rangeSeparator || defSeparator) }}
200
+ </template>
201
+ <template v-else>
202
+ {{ value?.toString() }}
203
+ </template>
204
+ </div>
205
+ </template>
206
+ </slot>
207
+ </template>
208
+ <template #append>
209
+ <q-btn
210
+ v-if="!disable && !readonly && !viewMode"
211
+ :icon="isDate ? 'ion-ios-calendar' : 'ion-ios-clock'"
212
+ flat
213
+ round
214
+ v-bind="{...options?.pickerBtn, ...btnProps}"
215
+ >
216
+ <q-popup-proxy
217
+ cover
218
+ no-shake
219
+ persistent
220
+ transition-hide="jump-down"
221
+ transition-show="jump-up"
222
+ @before-show="onBeforeShow()"
223
+ @before-hide="onBeforeHide()"
224
+ >
225
+ <q-card>
226
+ <q-date
227
+ v-if="isDate"
228
+ ref="dateElm"
229
+ v-bind="{
230
+ ...options.date as any,
231
+ ...props,
232
+ ...$attrs,
233
+ todayBtn: getProp('todayBtn') === undefined ? !0 : getProp('todayBtn'),
234
+ mask:format,
235
+ multiple,
236
+ range,
237
+ modelValue: dateRef ?? null
238
+ }"
239
+ @update:model-value="dateRef = $event ?? null"
240
+ >
241
+ <template #default>
242
+ <div class="row items-center justify-end">
243
+ <MBtn
244
+ v-close-popup
245
+ :label="__('close')"
246
+ color="negative"
247
+ flat
248
+ />
249
+ <MBtn
250
+ v-close-popup
251
+ :label="__('save')"
252
+ flat
253
+ @click="saveDialog()"
254
+ />
255
+ </div>
256
+ </template>
257
+ </q-date>
258
+ <q-time
259
+ v-else
260
+ ref="timeElm"
261
+ v-bind="{
262
+ ...$props,
263
+ ...options.time,
264
+ ...$attrs,
265
+ mask:format,
266
+ nowBtn: getProp('nowBtn') === undefined? !0 : getProp('nowBtn'),
267
+ modelValue: dateRef ?? null
268
+ }"
269
+ @update:model-value="dateRef = $event ?? null"
270
+ >
271
+ <div class="row items-center justify-end">
272
+ <MBtn
273
+ v-close-popup
274
+ :label="__('close')"
275
+ color="negative"
276
+ flat
277
+ />
278
+ <MBtn
279
+ v-close-popup
280
+ :label="__('save')"
281
+ flat
282
+ @click="saveDialog()"
283
+ />
284
+ </div>
285
+ </q-time>
286
+ </q-card>
287
+ </q-popup-proxy>
288
+ </q-btn>
289
+ </template>
290
+
291
+ <template
292
+ v-for="(_,slot) in $slots as Readonly<QFieldSlots>"
293
+ :key="slot"
294
+ #[slot]
295
+ >
296
+ <slot :name="slot" />
297
+ </template>
298
+ </q-field>
299
+ <slot
300
+ name="help"
301
+ v-bind="scopes"
302
+ >
303
+ <MHelpRow
304
+ v-if="!hasTopLabel"
305
+ :text="help"
306
+ />
307
+ </slot>
308
+ <slot
309
+ name="bottom-input"
310
+ v-bind="scopes"
311
+ />
312
+ </MCol>
313
+ </template>
@@ -0,0 +1,178 @@
1
+ <!--
2
+ - MyTh Ahmed Faiz Copyright © 2016-2024 All rights reserved.
3
+ - Email: mythpe@gmail.com
4
+ - Mobile: +966590470092
5
+ - Website: https://www.4myth.com
6
+ - Github: https://github.com/mythpe
7
+ -->
8
+
9
+ <script lang="ts" setup>
10
+ import { useField } from 'vee-validate'
11
+ import { defineProps, reactive, toValue, useTemplateRef } from 'vue'
12
+ import { useBindInput, useMyth } from '../../composable'
13
+ import type { MRadioProps as Props } from '../../types'
14
+ import { QField, QRadio } from 'quasar'
15
+ import { myth } from '../../utils'
16
+
17
+ type P = {
18
+ auto?: Props['auto'];
19
+ col?: Props['col'];
20
+ xs?: Props['xs'];
21
+ sm?: Props['sm'];
22
+ md?: Props['md'];
23
+ lg?: Props['lg'];
24
+ xl?: Props['xl'];
25
+ name: Props['name'];
26
+ label?: Props['label'];
27
+ caption?: Props['caption'];
28
+ hint?: Props['hint'];
29
+ help?: Props['help'];
30
+ val: Props['val'];
31
+ required?: Props['required'];
32
+ rules?: Props['rules'];
33
+ dense?: Props['dense'];
34
+ checkedIcon?: Props['checkedIcon'];
35
+ rowProps?: Props['rowProps'];
36
+ colProps?: Props['colProps'];
37
+ viewMode?: Props['viewMode'];
38
+ fieldOptions?: Props['fieldOptions'];
39
+ }
40
+
41
+ const props = withDefaults(defineProps<P>(), {
42
+ auto: undefined,
43
+ col: undefined,
44
+ xs: undefined,
45
+ sm: undefined,
46
+ md: undefined,
47
+ lg: undefined,
48
+ xl: undefined,
49
+ name: () => '',
50
+ label: undefined,
51
+ caption: undefined,
52
+ hint: undefined,
53
+ help: undefined,
54
+ val: undefined,
55
+ required: undefined,
56
+ rules: undefined,
57
+ dense: undefined,
58
+ checkedIcon: undefined,
59
+ rowProps: undefined,
60
+ colProps: undefined,
61
+ viewMode: () => !1,
62
+ fieldOptions: undefined
63
+ })
64
+ defineModel<Props['modelValue']>({ required: !1, default: undefined })
65
+ const helper = useBindInput<P>(() => props, 'radio')
66
+ const { getLabel, inputRules, attrs, getProp } = helper
67
+ const inputScope = useField<Props['modelValue']>(() => props.name, inputRules, {
68
+ syncVModel: !0,
69
+ label: getLabel,
70
+ type: 'radio',
71
+ checkedValue: () => props.val,
72
+ ...toValue<any>(props.fieldOptions)
73
+ })
74
+ const { value, errorMessage, handleChange } = inputScope
75
+ const { __ } = useMyth()
76
+ const { props: options } = myth
77
+ const listeners = {
78
+ 'update:modelValue': (v: Props['modelValue']) => handleChange(v, !!errorMessage.value)
79
+ }
80
+ const input = useTemplateRef<InstanceType<typeof QRadio>>('input')
81
+ const scopes = reactive(inputScope)
82
+ defineExpose<typeof scopes & { input: typeof input }>({ input, ...scopes })
83
+ defineOptions({
84
+ name: 'MRadio',
85
+ inheritAttrs: !1
86
+ })
87
+ </script>
88
+
89
+ <template>
90
+ <MCol
91
+ :auto="auto"
92
+ :class="[$attrs.class,{'m--input__required':inputRules?.required!==undefined,'m--input__error':!!errorMessage,'m--input__view':viewMode}]"
93
+ :col="col"
94
+ :lg="lg"
95
+ :md="md"
96
+ :name="name"
97
+ :sm="sm"
98
+ :xs="xs"
99
+ >
100
+ <slot
101
+ name="top-input"
102
+ v-bind="scopes"
103
+ />
104
+ <slot name="caption">
105
+ <div
106
+ v-if="!!caption"
107
+ class="m--input__caption text-caption"
108
+ >
109
+ {{ __(caption) }}
110
+ </div>
111
+ </slot>
112
+ <MRow v-bind="rowProps">
113
+ <slot
114
+ name="before"
115
+ v-bind="scopes"
116
+ />
117
+ <MCol v-bind="colProps">
118
+ <q-field
119
+ :error="!!errorMessage"
120
+ :error-message="errorMessage"
121
+ :hint="__(hint)"
122
+ v-bind="{
123
+ ...options.input as any,
124
+ ...options.field,
125
+ ...$attrs,
126
+ ...myth.themeInput,
127
+ borderless: !0,
128
+ outlined: !1,
129
+ stackLabel: !0
130
+ }"
131
+ >
132
+ <template #control>
133
+ <q-radio
134
+ ref="input"
135
+ :disable="viewMode"
136
+ :model-value="value"
137
+ :val="val"
138
+ v-bind="{
139
+ ...options.radio,
140
+ ...$attrs,
141
+ dense: attrs.dense,
142
+ checkedIcon: getProp('checkedIcon'),
143
+ label: undefined
144
+ }"
145
+ v-on="listeners"
146
+ >
147
+ <template #default>
148
+ <MRow class="items-center">
149
+ <div
150
+ v-if="!!getLabel"
151
+ class="text-color"
152
+ >
153
+ {{ getLabel }}
154
+ </div>
155
+ <MHelpRow
156
+ v-if="!!help"
157
+ :right="!!getLabel"
158
+ :text="help"
159
+ tooltip
160
+ />
161
+ </MRow>
162
+ </template>
163
+ </q-radio>
164
+ </template>
165
+ </q-field>
166
+ <slot v-bind="scopes" />
167
+ </MCol>
168
+ <slot
169
+ name="after"
170
+ v-bind="scopes"
171
+ />
172
+ </MRow>
173
+ <slot
174
+ name="bottom-input"
175
+ v-bind="scopes"
176
+ />
177
+ </MCol>
178
+ </template>