@mythpe/quasar-ui-qui 0.0.27 → 0.0.29-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 (93) hide show
  1. package/index.d.ts +13 -0
  2. package/package.json +17 -8
  3. package/src/boot/register.ts +14 -0
  4. package/src/components/datatable/MDatatable.vue +2305 -0
  5. package/src/components/datatable/MDtAvatar.vue +49 -0
  6. package/src/components/datatable/MDtBtn.vue +153 -0
  7. package/src/components/datatable/MDtContextmenuItems.vue +54 -0
  8. package/src/components/datatable/index.ts +6 -0
  9. package/src/components/form/MAvatarViewer.vue +327 -0
  10. package/src/components/form/MAxios.vue +144 -0
  11. package/src/components/form/MBtn.vue +271 -93
  12. package/src/components/form/MCheckbox.vue +150 -0
  13. package/src/components/form/MCkeditor.vue +403 -0
  14. package/src/components/form/MColor.vue +122 -0
  15. package/src/components/form/MDate.vue +50 -0
  16. package/src/components/form/MEditor.vue +285 -0
  17. package/src/components/form/MEmail.vue +43 -0
  18. package/src/components/form/MField.vue +148 -0
  19. package/src/components/form/MFile.vue +215 -0
  20. package/src/components/form/MForm.vue +89 -0
  21. package/src/components/form/MHidden.vue +86 -0
  22. package/src/components/form/MHiddenInput.vue +58 -0
  23. package/src/components/form/MInput.vue +178 -0
  24. package/src/components/form/MInputFieldControl.vue +27 -0
  25. package/src/components/form/MInputLabel.vue +38 -0
  26. package/src/components/form/MMobile.vue +43 -0
  27. package/src/components/form/MOptions.vue +255 -0
  28. package/src/components/form/MOtp.vue +292 -0
  29. package/src/components/form/MPassword.vue +73 -0
  30. package/src/components/form/MPicker.vue +313 -0
  31. package/src/components/form/MRadio.vue +181 -0
  32. package/src/components/form/MSelect.vue +352 -0
  33. package/src/components/form/MTime.vue +48 -0
  34. package/src/components/form/MToggle.vue +211 -0
  35. package/src/components/form/MUploader.vue +511 -0
  36. package/src/components/form/index.ts +65 -0
  37. package/src/components/grid/MBlock.vue +39 -18
  38. package/src/components/grid/MCol.vue +11 -15
  39. package/src/components/grid/MColumn.vue +12 -1
  40. package/src/components/grid/MContainer.vue +22 -13
  41. package/src/components/grid/MHelpRow.vue +13 -12
  42. package/src/components/grid/MRow.vue +31 -10
  43. package/src/components/grid/index.ts +16 -0
  44. package/src/components/index.ts +15 -0
  45. package/src/components/modal/MDialog.vue +58 -0
  46. package/src/components/modal/MModalMenu.vue +62 -0
  47. package/src/components/modal/MTooltip.vue +39 -0
  48. package/src/components/modal/index.ts +5 -0
  49. package/src/components/parials/UploaderItem.vue +298 -0
  50. package/src/components/parials/index.ts +3 -0
  51. package/src/components/transition/MFadeTransition.vue +27 -0
  52. package/src/components/transition/MFadeXTransition.vue +26 -0
  53. package/src/components/transition/MTransition.vue +44 -0
  54. package/src/components/transition/index.ts +13 -0
  55. package/src/components/typography/MTypingString.vue +8 -0
  56. package/src/components/typography/index.ts +11 -0
  57. package/src/composable/index.ts +12 -0
  58. package/src/composable/useBindInput.ts +209 -0
  59. package/src/composable/useError.ts +11 -0
  60. package/src/composable/useMyth.ts +311 -0
  61. package/src/composable/useValue.ts +12 -0
  62. package/src/index.common.js +19 -1
  63. package/src/index.esm.js +18 -3
  64. package/src/index.js +19 -0
  65. package/src/index.sass +9 -26
  66. package/src/index.ts +18 -4
  67. package/src/index.umd.js +17 -2
  68. package/src/style/m-container.sass +13 -0
  69. package/src/style/main.sass +146 -0
  70. package/src/style/print.sass +14 -0
  71. package/src/style/transition.sass +40 -0
  72. package/src/types/api-helpers.d.ts +62 -0
  73. package/src/types/components.d.ts +1108 -27
  74. package/src/types/index.d.ts +21 -1
  75. package/src/types/install-options.d.ts +19 -0
  76. package/src/types/lodash.d.ts +26 -0
  77. package/src/types/m-datatable.d.ts +316 -0
  78. package/src/types/m-geolocation.d.ts +16 -0
  79. package/src/types/m-helpers.d.ts +97 -0
  80. package/src/types/plugin-props-option.d.ts +305 -0
  81. package/src/types/quasar-helpers.d.ts +7 -0
  82. package/src/types/theme.d.ts +12 -0
  83. package/src/utils/Helpers.ts +293 -0
  84. package/src/utils/Str.ts +211 -0
  85. package/src/utils/index.ts +13 -0
  86. package/src/utils/myth.ts +109 -0
  87. package/src/utils/vee-rules.ts +32 -0
  88. package/src/utils/vue-plugin.ts +163 -0
  89. package/tsconfig.json +9 -13
  90. package/src/myth.ts +0 -30
  91. package/src/types/myth.ts +0 -42
  92. package/src/vue-plugin.ts +0 -41
  93. package/types.d.ts +0 -1
@@ -0,0 +1,215 @@
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
+
14
+ import { QField, QFile, QFileSlots } from 'quasar'
15
+ import { useBindInput, useMyth } from '../../composable'
16
+ import { useField } from 'vee-validate'
17
+ import { reactive, toValue, useTemplateRef } from 'vue'
18
+ import type { MFileProps as Props } from '../../types'
19
+ import { myth } from '../../utils'
20
+
21
+ interface P {
22
+ name: Props['name'];
23
+ auto?: Props['auto'];
24
+ col?: Props['col'];
25
+ xs?: Props['xs'];
26
+ sm?: Props['sm'];
27
+ md?: Props['md'];
28
+ lg?: Props['lg'];
29
+ xl?: Props['xl'];
30
+ label?: Props['label'];
31
+ caption?: Props['caption'];
32
+ hint?: Props['hint'];
33
+ placeholder?: Props['placeholder'];
34
+ help?: Props['help'];
35
+ required?: Props['required'];
36
+ rules?: Props['rules'];
37
+ viewMode?: Props['viewMode'];
38
+ viewModeValue?: Props['viewModeValue'];
39
+ topLabel?: Props['topLabel'];
40
+ accept?: Props['accept'];
41
+ images?: Props['images'];
42
+ svg?: Props['svg'];
43
+ video?: Props['video'];
44
+ pdf?: Props['pdf'];
45
+ excel?: Props['excel'];
46
+ fieldOptions?: Props['fieldOptions'];
47
+ }
48
+
49
+ const props = withDefaults(defineProps<P>(), {
50
+ name: () => '',
51
+ auto: undefined,
52
+ col: undefined,
53
+ xs: undefined,
54
+ sm: undefined,
55
+ md: undefined,
56
+ lg: undefined,
57
+ xl: undefined,
58
+ label: undefined,
59
+ caption: undefined,
60
+ hint: undefined,
61
+ placeholder: undefined,
62
+ help: undefined,
63
+ required: undefined,
64
+ rules: undefined,
65
+ viewMode: () => !1,
66
+ viewModeValue: undefined,
67
+ topLabel: undefined,
68
+ accept: undefined,
69
+ images: () => !1,
70
+ svg: () => !1,
71
+ video: () => !1,
72
+ pdf: () => !1,
73
+ excel: () => !1,
74
+ fieldOptions: undefined
75
+ })
76
+ defineModel<Props['modelValue']>({ required: !1, default: undefined })
77
+ const { __ } = useMyth()
78
+ const { props: options } = myth
79
+ const helper = useBindInput<P>(() => props, 'file', () => ({ choose: !0 }))
80
+ const { hasTopLabel, getLabel, getPlaceholder, accepts, inputRules } = helper
81
+ const inputScope = useField<Props['modelValue']>(() => props.name, inputRules, {
82
+ syncVModel: !0,
83
+ label: getLabel,
84
+ ...toValue<any>(props.fieldOptions)
85
+ })
86
+ const { value, errorMessage, handleChange, handleBlur } = inputScope
87
+
88
+ const listeners = {
89
+ focus: (v: Event) => handleBlur(v, !1),
90
+ blur: (v: Event) => handleBlur(v, !1),
91
+ clear: (v: Event) => handleBlur(v, !0),
92
+ 'update:modelValue': (v: Props['modelValue']) => handleChange(v, !!errorMessage.value)
93
+ }
94
+ const input = useTemplateRef<InstanceType<typeof QFile> | InstanceType<typeof QField>>('input')
95
+ const scopes = reactive(inputScope)
96
+
97
+ const pickFiles = (evt?: Event) => (input.value as QFile)?.pickFiles(evt)
98
+ const addFiles = (files: readonly any[] | FileList) => (input.value as QFile)?.addFiles(files)
99
+ const resetValidation = () => (input.value as QFile)?.resetValidation()
100
+ const validate = (value?: any) => (input.value as QFile)?.validate(value)
101
+ const focus = () => (input.value as QFile)?.focus()
102
+ const blur = () => (input.value as QFile)?.blur()
103
+ const removeAtIndex = (index: number) => (input.value as QFile)?.removeAtIndex(index)
104
+ const removeFile = (index: number) => (input.value as QFile)?.removeAtIndex(index)
105
+ const methods = {
106
+ pickFiles,
107
+ addFiles,
108
+ resetValidation,
109
+ validate,
110
+ focus,
111
+ blur,
112
+ removeAtIndex,
113
+ removeFile
114
+ }
115
+
116
+ defineExpose({ input, ...scopes, ...methods })
117
+ defineOptions({
118
+ name: 'MFile',
119
+ inheritAttrs: !1
120
+ })
121
+ </script>
122
+
123
+ <template>
124
+ <MCol
125
+ :auto="auto"
126
+ :class="[$attrs.class,{'m--input__required':inputRules?.required!==undefined,'m--input__error':!!errorMessage,'m--input__view':viewMode}]"
127
+ :col="col"
128
+ :lg="lg"
129
+ :md="md"
130
+ :name="name"
131
+ :sm="sm"
132
+ :xs="xs"
133
+ >
134
+ <slot
135
+ name="top-input"
136
+ v-bind="scopes"
137
+ />
138
+ <slot name="top-label">
139
+ <MInputLabel
140
+ v-if="hasTopLabel"
141
+ :field="scopes"
142
+ >
143
+ <MHelpRow
144
+ :text="help"
145
+ tooltip
146
+ />
147
+ </MInputLabel>
148
+ </slot>
149
+ <slot name="caption">
150
+ <div
151
+ v-if="!!caption"
152
+ class="m--input__caption"
153
+ >
154
+ {{ __(caption) }}
155
+ </div>
156
+ </slot>
157
+ <component
158
+ :is="viewMode ? QField : QFile"
159
+ ref="input"
160
+ :accept="accepts.join(',')"
161
+ :error="!!errorMessage"
162
+ :error-message="errorMessage"
163
+ :hint="__(hint)"
164
+ :label="hasTopLabel ? (viewMode ? undefined : getPlaceholder) : getLabel"
165
+ :model-value="value"
166
+ v-bind="{ ...options.file as any,...( viewMode ? options.field : {} ), ...$attrs, ...( viewMode ? { stackLabel: !0 } : {} ) }"
167
+ v-on="listeners"
168
+ >
169
+ <template #prepend>
170
+ <slot name="prepend">
171
+ <q-icon
172
+ class="cursor-pointer"
173
+ name="ion-ios-attach"
174
+ @click="pickFiles($event)"
175
+ />
176
+ </slot>
177
+ </template>
178
+
179
+ <template
180
+ v-for="(_,slot) in $slots as Readonly<QFileSlots>"
181
+ :key="slot"
182
+ #[slot]
183
+ >
184
+ <slot :name="slot" />
185
+ </template>
186
+ <template
187
+ v-if="viewMode"
188
+ #control
189
+ >
190
+ <slot name="control">
191
+ <MInputFieldControl>
192
+ {{ viewModeValue ?? value }}
193
+ </MInputFieldControl>
194
+ </slot>
195
+ </template>
196
+ </component>
197
+ <slot
198
+ name="help"
199
+ v-bind="scopes"
200
+ >
201
+ <MHelpRow
202
+ v-if="!hasTopLabel"
203
+ :text="help"
204
+ />
205
+ </slot>
206
+ <slot
207
+ name="bottom-input"
208
+ v-bind="scopes"
209
+ />
210
+ </MCol>
211
+ <slot
212
+ name="hidden"
213
+ v-bind="scopes"
214
+ />
215
+ </template>
@@ -0,0 +1,89 @@
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 { InvalidSubmissionHandler, SubmissionContext, SubmissionHandler } from 'vee-validate'
14
+ import { useForm } from 'vee-validate'
15
+ import type { MFormProps as Props } from '../../types'
16
+ import { computed, reactive, toValue, watch } from 'vue'
17
+ import { useMyth } from '../../composable'
18
+
19
+ interface P {
20
+ formProps?: Props['formProps'];
21
+ opts?: Props['opts'];
22
+ target?: Props['target'];
23
+ emitValues?: Props['emitValues'];
24
+ state?: Props['state'];
25
+ form?: Props['form'];
26
+ values?: Props['values'];
27
+ errors?: Props['errors'];
28
+ padding?: Props['padding'];
29
+ }
30
+
31
+ const props = withDefaults(defineProps<P>(), {
32
+ formProps: undefined,
33
+ opts: undefined,
34
+ target: undefined,
35
+ emitValues: () => !1,
36
+ state: () => () => ({}),
37
+ form: () => () => ({}),
38
+ values: () => () => ({}),
39
+ errors: () => () => ({}),
40
+ padding: undefined
41
+ })
42
+ const formScope = useForm<Record<string, any>>(props.opts)
43
+ const { __, scrollToElementFromErrors } = useMyth()
44
+ const scope = reactive(formScope)
45
+ const { handleSubmit, resetForm, setErrors, setValues } = scope
46
+ type Emits = {
47
+ (e: 'submit', values: Record<string, any>, ctx: SubmissionContext, scope: typeof formScope): void;
48
+ }
49
+ const emit = defineEmits<Emits>()
50
+ const onSuccessSubmission: SubmissionHandler = async (values, ctx) => emit('submit', values, ctx, formScope)
51
+ const onErrorSubmission: InvalidSubmissionHandler = ({ errors }) => {
52
+ const keys: any[] = Object.keys(errors)
53
+ if (keys.length) {
54
+ const message = errors[keys[0]] as string || __('messages.the_given_data_was_invalid')
55
+ scrollToElementFromErrors({ [keys[0]]: [message] }, undefined, props.target)
56
+ }
57
+ }
58
+ const defaultSubmit = props.emitValues ? handleSubmit(onSuccessSubmission, onErrorSubmission) : handleSubmit.withControlled(onSuccessSubmission,
59
+ onErrorSubmission)
60
+ defineExpose({ ...scope, defaultSubmit })
61
+ defineOptions({
62
+ name: 'MForm',
63
+ inheritAttrs: !1
64
+ })
65
+ const options = { deep: !0, immediate: !0 }
66
+ const stateComputed = computed(() => props.state ? toValue(props.state) : {})
67
+ watch(stateComputed, v => v && resetForm(v), options)
68
+ const formComputed = computed(() => props.form ? toValue(props.form) : {})
69
+ watch(formComputed, values => values && resetForm({ values, errors: {}, touched: {} }), options)
70
+ const valuesComputed = computed(() => props.values ? toValue(props.values) : {})
71
+ watch(valuesComputed, v => v && setValues(v), options)
72
+ const errorsComputed = computed(() => props.errors ? toValue(props.errors) : {})
73
+ watch(errorsComputed, v => v && setErrors(v), options)
74
+ </script>
75
+
76
+ <template>
77
+ <div
78
+ class="m--form__container"
79
+ v-bind="$attrs"
80
+ >
81
+ <form
82
+ :class="{'m--form': !0, 'm--container': padding}"
83
+ v-bind="formProps"
84
+ @submit="defaultSubmit"
85
+ >
86
+ <slot v-bind="scope" />
87
+ </form>
88
+ </div>
89
+ </template>
@@ -0,0 +1,86 @@
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
+
14
+ import { useField } from 'vee-validate'
15
+ import type { MHiddenProps as Props } from '../../types'
16
+ import { reactive, toValue } from 'vue'
17
+ import { useBindInput } from '../../composable'
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
+ rules?: Props['rules'];
29
+ required?: Props['required'];
30
+ fieldOptions?: Props['modelValue'];
31
+ viewMode?: Props['viewMode'];
32
+ }
33
+
34
+ const props = withDefaults(defineProps<P>(), {
35
+ name: () => '',
36
+ auto: undefined,
37
+ col: undefined,
38
+ xs: undefined,
39
+ sm: undefined,
40
+ md: undefined,
41
+ lg: undefined,
42
+ xl: undefined,
43
+ rules: undefined,
44
+ required: () => !1,
45
+ fieldOptions: undefined,
46
+ viewMode: () => !1
47
+ })
48
+ defineModel<Props['modelValue']>({ required: !1, default: undefined })
49
+ const helper = useBindInput<P>(() => props, 'input')
50
+ const { inputRules, getLabel } = helper
51
+ const inputScope = useField<Props['modelValue']>(() => props.name, inputRules, {
52
+ syncVModel: !0,
53
+ label: getLabel,
54
+ validateOnValueUpdate: !1,
55
+ validateOnMount: !1,
56
+ controlled: !0,
57
+ ...toValue<any>(props.fieldOptions)
58
+ })
59
+ const { value, errorMessage } = inputScope
60
+
61
+ const scopes = reactive(inputScope)
62
+ defineExpose<typeof scopes>({ ...scopes })
63
+ defineOptions({
64
+ name: 'MHidden',
65
+ inheritAttrs: !1
66
+ })
67
+ </script>
68
+
69
+ <template>
70
+ <MCol
71
+ :auto="auto"
72
+ :class="[$attrs.class,{'m--input__required':inputRules?.required!==undefined,'m--input__error':!!errorMessage,'m--input__view':viewMode}]"
73
+ :col="col"
74
+ :lg="lg"
75
+ :md="md"
76
+ :name="name"
77
+ :sm="sm"
78
+ :xs="xs"
79
+ >
80
+ <input
81
+ v-model="value"
82
+ v-bind="{...$attrs,type: 'hidden' }"
83
+ >
84
+ <slot />
85
+ </MCol>
86
+ </template>
@@ -0,0 +1,58 @@
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
+
14
+ import { useField } from 'vee-validate'
15
+ import type { MHiddenInputProps as Props } from '../../types'
16
+ import { reactive, toValue } from 'vue'
17
+ import { useBindInput } from '../../composable'
18
+
19
+ type P = {
20
+ name: Props['name'];
21
+ rules?: Props['rules'];
22
+ required?: Props['required'];
23
+ fieldOptions?: Props['modelValue'];
24
+ }
25
+
26
+ const props = withDefaults(defineProps<P>(), {
27
+ name: () => '',
28
+ rules: undefined,
29
+ required: () => !1,
30
+ fieldOptions: undefined
31
+ })
32
+ defineModel<Props['modelValue']>({ required: !1, default: undefined })
33
+ const helper = useBindInput<P>(() => props, 'input')
34
+ const { inputRules, getLabel } = helper
35
+ const inputScope = useField<Props['modelValue']>(() => props.name, inputRules, {
36
+ syncVModel: !0,
37
+ label: getLabel,
38
+ validateOnValueUpdate: !1,
39
+ validateOnMount: !1,
40
+ controlled: !0,
41
+ ...toValue<any>(props.fieldOptions)
42
+ })
43
+ const { value } = inputScope
44
+
45
+ const scopes = reactive(inputScope)
46
+ defineExpose<typeof scopes>({ ...scopes })
47
+ defineOptions({
48
+ name: 'MHiddenInput',
49
+ inheritAttrs: !1
50
+ })
51
+ </script>
52
+
53
+ <template>
54
+ <input
55
+ v-model="value"
56
+ v-bind="{...$attrs,type: 'hidden' }"
57
+ >
58
+ </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
10
+ lang="ts"
11
+ setup
12
+ >
13
+
14
+ import { useField } from 'vee-validate'
15
+ import { computed, reactive, toValue, useTemplateRef } from 'vue'
16
+ import type { MInputProps as Props } from '../../types'
17
+ import { QField, QInput, type QInputSlots } from 'quasar'
18
+ import { useBindInput, useMyth } from '../../composable'
19
+ import { myth } from '../../utils'
20
+
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ name: () => '',
23
+ fillMask: undefined,
24
+ reverseFillMask: undefined,
25
+ unmaskedValue: undefined,
26
+ error: undefined,
27
+ noErrorIcon: undefined,
28
+ reactiveRules: undefined,
29
+ lazyRules: undefined,
30
+ stackLabel: undefined,
31
+ hideHint: undefined,
32
+ dark: undefined,
33
+ loading: undefined,
34
+ clearable: undefined,
35
+ filled: undefined,
36
+ outlined: undefined,
37
+ borderless: undefined,
38
+ standout: undefined,
39
+ labelSlot: undefined,
40
+ bottomSlots: undefined,
41
+ hideBottomSpace: undefined,
42
+ counter: undefined,
43
+ rounded: undefined,
44
+ square: undefined,
45
+ dense: undefined,
46
+ itemAligned: undefined,
47
+ disable: undefined,
48
+ readonly: undefined,
49
+ autofocus: undefined,
50
+ autogrow: undefined,
51
+ viewMode: undefined,
52
+ auto: undefined,
53
+ col: undefined,
54
+ xs: undefined,
55
+ sm: undefined,
56
+ md: undefined,
57
+ lg: undefined,
58
+ xl: undefined,
59
+ required: undefined,
60
+ autocomplete: undefined,
61
+ topLabel: undefined,
62
+ mobile: undefined,
63
+ email: undefined,
64
+ float: undefined
65
+ })
66
+ defineModel<Props['modelValue']>({ required: !1, default: undefined })
67
+ const { __ } = useMyth()
68
+ const options = computed(() => myth.props.value)
69
+ const helper = useBindInput<Props>(() => props, 'input')
70
+ const { attrs, hasTopLabel, getLabel, getPlaceholder, getAutocompleteAttribute, inputRules } = helper
71
+ const inputScope = useField<Props['modelValue']>(() => props.name, inputRules, {
72
+ syncVModel: !0,
73
+ label: getLabel,
74
+ ...toValue<any>(props.fieldOptions)
75
+ })
76
+ const { value, errorMessage, handleChange, handleBlur } = inputScope
77
+ const listeners = {
78
+ blur: (v: any) => handleBlur(v, !0),
79
+ 'update:modelValue': (v: Props['modelValue']) => handleChange(v, !!errorMessage.value)
80
+ }
81
+ const input = useTemplateRef<InstanceType<typeof QInput> | InstanceType<typeof QField>>('input')
82
+ const scopes = reactive(inputScope)
83
+ defineExpose<typeof scopes & { input: typeof input }>({ input, ...scopes })
84
+ defineOptions({
85
+ name: 'MInput',
86
+ inheritAttrs: !1
87
+ })
88
+ </script>
89
+
90
+ <template>
91
+ <MCol
92
+ :auto="auto"
93
+ :class="[$attrs.class,{'m--input__required':inputRules?.required!==undefined,'m--input__error':!!errorMessage,'m--input__view':viewMode}]"
94
+ :col="col"
95
+ :lg="lg"
96
+ :md="md"
97
+ :name="name"
98
+ :sm="sm"
99
+ :xs="xs"
100
+ >
101
+ <slot
102
+ name="top-input"
103
+ v-bind="scopes"
104
+ />
105
+ <slot
106
+ name="top-label"
107
+ v-bind="scopes"
108
+ >
109
+ <MInputLabel
110
+ v-if="hasTopLabel"
111
+ :field="scopes"
112
+ >
113
+ <MHelpRow
114
+ :text="help"
115
+ tooltip
116
+ />
117
+ </MInputLabel>
118
+ </slot>
119
+ <slot name="caption">
120
+ <div
121
+ v-if="!!caption"
122
+ class="m--input__caption"
123
+ >
124
+ {{ __(caption) }}
125
+ </div>
126
+ </slot>
127
+ <component
128
+ :is="viewMode ? QField : QInput"
129
+ ref="input"
130
+ v-bind="{
131
+ ...( viewMode ? options.field : {} ),
132
+ ...$props,
133
+ ...attrs as any,
134
+ ...( viewMode ? { stackLabel: !0 } : {} ),
135
+ autocomplete:getAutocompleteAttribute,
136
+ clearable:viewMode?!1:clearable,
137
+ error:!!errorMessage,
138
+ errorMessage,
139
+ hint:__(hint),
140
+ label:hasTopLabel?undefined:getLabel,
141
+ modelValue:value,
142
+ placeholder:getPlaceholder
143
+ }"
144
+ v-on="listeners"
145
+ >
146
+ <template
147
+ v-for="(_,slot) in $slots as Readonly<QInputSlots>"
148
+ :key="slot"
149
+ #[slot]
150
+ >
151
+ <slot :name="slot" />
152
+ </template>
153
+ <template
154
+ v-if="viewMode"
155
+ #control
156
+ >
157
+ <slot name="control">
158
+ <MInputFieldControl>
159
+ {{ viewModeValue ?? value }}
160
+ </MInputFieldControl>
161
+ </slot>
162
+ </template>
163
+ </component>
164
+ <slot
165
+ name="help"
166
+ v-bind="scopes"
167
+ >
168
+ <MHelpRow
169
+ v-if="!hasTopLabel"
170
+ :text="help"
171
+ />
172
+ </slot>
173
+ <slot
174
+ name="bottom-input"
175
+ v-bind="scopes"
176
+ />
177
+ </MCol>
178
+ </template>
@@ -0,0 +1,27 @@
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
+ defineOptions({
14
+ name: 'MInputFieldControl',
15
+ inheritAttrs: !1
16
+ })
17
+ </script>
18
+
19
+ <template>
20
+ <div
21
+ class="self-center full-width no-outline ellipsis"
22
+ tabindex="0"
23
+ v-bind="$attrs"
24
+ >
25
+ <slot />
26
+ </div>
27
+ </template>
@@ -0,0 +1,38 @@
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
+
14
+ import type { MInputLabelProps as Props } from '../../types'
15
+ import { useMyth } from '../../composable'
16
+
17
+ const { __ } = useMyth()
18
+ defineProps<Props>()
19
+ defineOptions({
20
+ name: 'MInputLabel',
21
+ inheritAttrs: !1
22
+ })
23
+ </script>
24
+
25
+ <template>
26
+ <div
27
+ :class="{
28
+ 'row items-center m--input__top-label' : !0,
29
+ 'm--input__top-label__invalid' : !field?.meta?.valid && field?.meta?.dirty
30
+ }"
31
+ v-bind="$attrs"
32
+ >
33
+ <div class="m--input__top-label__content">
34
+ {{ label !== undefined ? __(label) : field?.label }}
35
+ </div>
36
+ <slot />
37
+ </div>
38
+ </template>