@mythpe/quasar-ui-qui 0.0.17-dev → 0.0.18-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythpe/quasar-ui-qui",
3
- "version": "0.0.17-dev",
3
+ "version": "0.0.18-dev",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -1,3 +1,11 @@
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
+
1
9
  import { boot } from 'quasar/wrappers'
2
10
  import Plugin from '../utils/vue-plugin'
3
11
 
@@ -1,9 +1,20 @@
1
- <script lang="ts" setup>
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
+ >
2
13
  import type { MBtnProps } from '../../types'
3
14
  import { useI18n } from 'vue-i18n'
4
15
  import { computed } from 'vue'
5
16
  import { extend } from 'quasar'
6
- import { myth } from '../../utils/myth'
17
+ import { myth } from '../../utils'
7
18
 
8
19
  const props = defineProps<MBtnProps>()
9
20
  const options = computed(() => myth.options.value.btn ?? {})
@@ -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, ref, toValue } from 'vue'
16
+ import type { MInputProps as Props } from '../../types'
17
+ import { QField, QInput, type QInputSlots } from 'quasar'
18
+ import { useInputHelper, useMyth } from '../../composable'
19
+ import { myth } from '../../utils'
20
+
21
+ type 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
+ autocomplete?: Props['autocomplete'];
40
+ topLabel?: Props['topLabel'];
41
+ fieldOptions?: Props['fieldOptions'];
42
+ clearable?: Props['clearable'];
43
+ }
44
+
45
+ // const props = withDefaults(defineProps<P>(), {
46
+ // name: () => '',
47
+ // auto: undefined,
48
+ // col: undefined,
49
+ // xs: undefined,
50
+ // sm: undefined,
51
+ // md: undefined,
52
+ // lg: undefined,
53
+ // xl: undefined,
54
+ // label: undefined,
55
+ // caption: undefined,
56
+ // hint: undefined,
57
+ // placeholder: undefined,
58
+ // help: undefined,
59
+ // required: undefined,
60
+ // rules: undefined,
61
+ // viewMode: () => !1,
62
+ // viewModeValue: undefined,
63
+ // autocomplete: undefined,
64
+ // topLabel: undefined,
65
+ // fieldOptions: undefined,
66
+ // clearable: undefined
67
+ // })
68
+ const props = defineProps<Props>()
69
+ defineModel<Props['modelValue']>({ required: !1, default: undefined })
70
+ const { __ } = useMyth()
71
+ const options = computed(() => myth.options.value)
72
+ const helper = useInputHelper<P>(() => props, 'input')
73
+ const { hasTopLabel, getLabel, getPlaceholder, getAutocompleteAttribute, getRules } = helper
74
+ const inputScope = useField<Props['modelValue']>(() => props.name, getRules, {
75
+ syncVModel: !0,
76
+ label: getLabel,
77
+ ...toValue<any>(props.fieldOptions)
78
+ })
79
+ const { value, errorMessage, handleChange, handleBlur } = inputScope
80
+ const listeners = {
81
+ blur: (v: any) => handleBlur(v, !0),
82
+ 'update:modelValue': (v: Props['modelValue']) => handleChange(v, !!errorMessage.value)
83
+ }
84
+ const input = ref<InstanceType<typeof QInput | typeof QField> | null>(null)
85
+ const scopes = reactive(inputScope)
86
+ defineExpose<typeof scopes & { input: typeof input }>({ input, ...scopes })
87
+ defineOptions({ name: 'MInput', inheritAttrs: !1 })
88
+ </script>
89
+
90
+ <template>
91
+ <MCol
92
+ :auto="auto"
93
+ :class="[$attrs.class,{'m--input__required':getRules?.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
+ :error="!!errorMessage"
131
+ :error-message="errorMessage"
132
+ :hint="hint ? __(hint) : hint"
133
+ :label="hasTopLabel ? undefined : getLabel"
134
+ :model-value="value"
135
+ :placeholder="getPlaceholder"
136
+ v-bind="{
137
+ ...options.input as any,
138
+ ...( viewMode ? options.field : {} ),
139
+ ...$attrs,
140
+ ...( viewMode ? { stackLabel: !0 } : {} ),
141
+ autocomplete:getAutocompleteAttribute,
142
+ clearable: viewMode ? !1 : clearable
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,24 @@
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({ name: 'MInputFieldControl', inheritAttrs: !1 })
14
+ </script>
15
+
16
+ <template>
17
+ <div
18
+ class="self-center full-width no-outline ellipsis"
19
+ tabindex="0"
20
+ v-bind="$attrs"
21
+ >
22
+ <slot />
23
+ </div>
24
+ </template>
@@ -0,0 +1,31 @@
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
+
11
+ import { MInputLabelProps as Props } from '../../types'
12
+ import { useMyth } from '../../composable'
13
+
14
+ const { __ } = useMyth()
15
+ defineProps<Props>()
16
+ defineOptions({ name: 'MInputLabel' })
17
+ </script>
18
+
19
+ <template>
20
+ <div
21
+ :class="{
22
+ 'row items-center m--input__top-label' : !0,
23
+ 'm--input__top-label__invalid' : !field?.meta?.valid && field?.meta?.dirty
24
+ }"
25
+ >
26
+ <div class="m--input__top-label__content">
27
+ {{ label !== undefined ? __(label) : field?.label }}
28
+ </div>
29
+ <slot />
30
+ </div>
31
+ </template>
@@ -0,0 +1,14 @@
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
+ import MBtn from './MBtn.vue'
10
+ import MInput from './MInput.vue'
11
+ import MInputFieldControl from './MInputFieldControl.vue'
12
+ import MInputLabel from './MInputLabel.vue'
13
+
14
+ export { MBtn, MInput, MInputFieldControl, MInputLabel }
@@ -1,7 +1,15 @@
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
+
1
9
  <script lang="ts" setup>
2
10
  import type { MBlockProps } from '../../types'
3
11
  import { computed } from 'vue'
4
- import MythOptions from '../../utils/myth'
12
+ import { myth } from '../../utils'
5
13
  import { extend } from 'quasar'
6
14
 
7
15
  interface Props {
@@ -15,7 +23,7 @@ const props = withDefaults(defineProps<Props>(), {
15
23
  rounded: !1,
16
24
  shadow: 'none'
17
25
  })
18
- const block = computed(() => MythOptions.options.value.block ?? {})
26
+ const block = computed(() => myth.options.value.block ?? {})
19
27
  const options = computed<Props>(() => extend(!0, { ...props }, block.value))
20
28
  defineOptions({
21
29
  name: 'MBlock',
@@ -1,9 +1,17 @@
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
+
1
9
  <script
2
10
  lang="ts"
3
11
  setup
4
12
  >
5
13
  import { computed } from 'vue'
6
- // import { uniq } from 'lodash'
14
+ import { uniq } from 'lodash'
7
15
  import type { MColProps } from '../../types'
8
16
 
9
17
  interface Props {
@@ -44,9 +52,9 @@ const classes = computed(() => {
44
52
  if (list.length === 1 && props.col !== !1) {
45
53
  list.push('col')
46
54
  }
47
- // return uniq(list)
48
- return list
55
+ return uniq(list)
49
56
  })
57
+
50
58
  defineOptions({
51
59
  name: 'MCol',
52
60
  inheritAttrs: !1
@@ -1,3 +1,11 @@
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
+
1
9
  <script lang="ts" setup>
2
10
  defineOptions({
3
11
  name: 'MColumn',
@@ -8,7 +8,7 @@
8
8
 
9
9
  <script lang="ts" setup>
10
10
  import type { MContainerProps } from '../../types'
11
- import MythOptions from '../../utils/myth'
11
+ import { myth } from '../../utils'
12
12
  import { computed } from 'vue'
13
13
 
14
14
  interface Props {
@@ -18,7 +18,7 @@ interface Props {
18
18
  }
19
19
 
20
20
  const props = defineProps<Props>()
21
- const styles = computed(() => MythOptions.options.value?.style ?? {})
21
+ const styles = computed(() => myth.options.value?.style ?? {})
22
22
  const sizeProp = computed(() => {
23
23
  if (props.size !== undefined) {
24
24
  return props.size
@@ -10,7 +10,7 @@
10
10
  lang="ts"
11
11
  setup
12
12
  >
13
- import { useI18n } from 'vue-i18n'
13
+ import { useMyth } from '../../composable'
14
14
 
15
15
  interface Props {
16
16
  text?: string | undefined;
@@ -19,8 +19,7 @@ interface Props {
19
19
  }
20
20
 
21
21
  defineProps<Props>()
22
- const { t, te } = useI18n({ useScope: 'global' })
23
- const __ = (s: any) => !s ? '' : te(`attributes.${s}`) ? t(`attributes.${s}`) : te(s) ? t(s) : s
22
+ const { __ } = useMyth()
24
23
  defineOptions({
25
24
  name: 'MHelpRow',
26
25
  inheritAttrs: !1
@@ -1,10 +1,18 @@
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
+
1
9
  <script
2
10
  lang="ts"
3
11
  setup
4
12
  >
5
13
  import type { MRowProps } from '../../types'
6
14
  import { computed } from 'vue'
7
- import MythOptions from '../../utils/myth'
15
+ import { myth } from '../../utils'
8
16
 
9
17
  interface Props {
10
18
  gutter?: MRowProps['gutter'];
@@ -12,7 +20,7 @@ interface Props {
12
20
  }
13
21
 
14
22
  const props = defineProps<Props>()
15
- const defSize = computed<string>(() => MythOptions.options.value.style?.gutters || '')
23
+ const defSize = computed<string>(() => myth.options.value.style?.gutters || '')
16
24
  const gutterSize = computed<string>(() => props.gutter === !0 ? defSize.value : (props.gutter || defSize.value))
17
25
  const colSize = computed<string>(() => props.gutter === !0 ? defSize.value : (props.gutter || defSize.value))
18
26
  defineOptions({
@@ -0,0 +1,16 @@
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
+ import MBlock from './MBlock.vue'
10
+ import MCol from './MCol.vue'
11
+ import MColumn from './MColumn.vue'
12
+ import MContainer from './MContainer.vue'
13
+ import MHelpRow from './MHelpRow.vue'
14
+ import MRow from './MRow.vue'
15
+
16
+ export { MBlock, MCol, MColumn, MContainer, MHelpRow, MRow }
@@ -0,0 +1,11 @@
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
+ export * from './form'
10
+ export * from './grid'
11
+ export * from './typography'
@@ -1,3 +1,11 @@
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
+
1
9
  <script
2
10
  lang="ts"
3
11
  setup
@@ -0,0 +1,10 @@
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
+ import MTypingString from './MTypingString.vue'
10
+ export { MTypingString }
@@ -0,0 +1,10 @@
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
+ export * from './useHelpersMyth'
10
+ export * from './useMyth'
@@ -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
+ import { camelCase, kebabCase, snakeCase, uniq } from 'lodash'
10
+ import { computed, type MaybeRefOrGetter, toValue } from 'vue'
11
+ import { extend, useSplitAttrs } from 'quasar'
12
+ import { useI18n } from 'vue-i18n'
13
+ import { useFieldError, useFieldValue, useSetFieldError, useSetFieldValue } from 'vee-validate'
14
+ import { myth } from '../utils'
15
+ import { useMyth } from './useMyth'
16
+ import type { UiOptionsContext as UiOpt } from '../types'
17
+
18
+ type G = { name: string; } & Record<string, any>;
19
+ type OptsContext = { choose?: boolean; };
20
+ export const useInputHelper = <P extends G = G> (Props: MaybeRefOrGetter<P>, key: keyof UiOpt, Opts: MaybeRefOrGetter<OptsContext> = {}) => {
21
+ const { messages, locale } = useI18n({ useScope: 'global' })
22
+ const { __ } = useMyth()
23
+ const { attributes: attrs } = useSplitAttrs()
24
+ const props = toValue<P>(Props)
25
+ const opts = toValue<OptsContext>(Opts)
26
+ // @ts-ignore
27
+ const inputOptions = computed(() => (k: keyof UiOpt) => myth.options.value[k] || {})
28
+ const inputProps = computed<UiOpt[typeof key] & P>(() => extend(!0, {}, inputOptions.value(key), props))
29
+ const hasTopLabel = computed(() => inputProps.value?.topLabel === !0)
30
+
31
+ const getLabel = computed<string | undefined>(() => {
32
+ const k = props.label === undefined ? props.name : props.label
33
+ return k ? (__(k) || undefined) : undefined
34
+ })
35
+ const getPlaceholder = computed<string | undefined>(() => {
36
+ if (props.placeholder === undefined) {
37
+ const k = props.label !== undefined ? props.label : props.name
38
+ return __(`replace.${opts?.choose ? 'choose' : 'enter'}`, { name: __(k) })
39
+ }
40
+ return __(props.placeholder) || undefined
41
+ // if (inputProps.value.hidePlaceholder === !0) {
42
+ // return props.placeholder !== undefined ? (__(props.placeholder) || undefined) : undefined
43
+ // }
44
+ })
45
+ const getAutocompleteAttribute = computed<string | null | undefined>(() => {
46
+ const opt = inputOptions.value(key)
47
+ const autocomplete = 'autocomplete' in opt && opt?.autocomplete !== undefined ? opt?.autocomplete : props.autocomplete
48
+ if (autocomplete !== undefined) {
49
+ if (autocomplete === !0 || autocomplete === '') {
50
+ return kebabCase(props.name)
51
+ } else if (autocomplete === !1) {
52
+ return 'off'
53
+ } else if (autocomplete?.length > 0) {
54
+ return autocomplete
55
+ }
56
+ }
57
+ return undefined
58
+ })
59
+ const accepts = computed(() => {
60
+ const l: any[] = []
61
+ if (props.accept) {
62
+ l.push(props.accept)
63
+ }
64
+ if (props.images) {
65
+ l.push('image/png,image/jpg,image/jpeg')
66
+ }
67
+ if (props.svg) {
68
+ l.push('image/svg+xml')
69
+ }
70
+ if (props.video) {
71
+ l.push('video/mp4,video/x-m4v,video/*')
72
+ }
73
+ if (props.pdf) {
74
+ l.push('application/pdf')
75
+ }
76
+ if (props.excel) {
77
+ l.push('.csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
78
+ }
79
+ return l
80
+ })
81
+
82
+ const isNumeric = (str: any) => !isNaN(str) && !isNaN(parseFloat(str))
83
+ const convertRules = (rules: any) => {
84
+ if (!rules) {
85
+ return {}
86
+ }
87
+ let values: Record<string, any> = {}
88
+ const list: any[] = typeof rules === 'string' ? rules.split('|') : (Array.isArray(rules) ? rules : [rules])
89
+
90
+ for (const rule of list) {
91
+ // console.log(rule)
92
+ if (!rule) {
93
+ continue
94
+ }
95
+ if (typeof rule === 'object' && !Array.isArray(rule)) {
96
+ values = { ...values, ...rule }
97
+ continue
98
+ }
99
+ if (Array.isArray(rule)) {
100
+ values = { ...values, ...rule }
101
+ }
102
+ const [name, value] = rule.split(':')
103
+ if (!name) {
104
+ continue
105
+ }
106
+ values[name] = !value ? !0
107
+ : /,/g.test(value) ? value.split(',').map((e: any) => isNumeric(e) ? parseInt(e) : e) : (isNumeric(value) ? parseInt(value) : value)
108
+ }
109
+ if (values.color && props.required) {
110
+ values.requiredColor = values.color
111
+ delete values.color
112
+ }
113
+ return values
114
+ }
115
+ const publicRules = ['required', 'email', 'numeric', 'integer', 'float', 'color']
116
+ const validations = (messages.value as any)?.[locale.value]?.validation?.messages || {}
117
+ const getRules = computed<Record<string, any>>(() => {
118
+ if (props.viewMode) {
119
+ return {}
120
+ }
121
+ const rules: any = { ...convertRules(toValue(props.rules)) }
122
+ // const attrs = toValue(opts.attrs) || {}
123
+ const keys = uniq<string>([...publicRules, ...(myth.options.value.inputRules ?? []), ...Object.keys(validations)])
124
+ for (const k of keys) {
125
+ if (['mobile', '_default', 'default'].includes(k)) {
126
+ continue
127
+ }
128
+ const cases = [k, snakeCase(k), camelCase(k), kebabCase(k)]
129
+
130
+ // eslint-disable-next-line no-labels
131
+ mainFor: for (const c of cases) {
132
+ for (const b of [attrs.value, props]) {
133
+ if (c in b && (b[c] === !0 || b[c] === '')) {
134
+ rules[snakeCase(k)] = b[c] === !0 || b[c] === '' ? !0 : b[c]
135
+ // eslint-disable-next-line no-labels
136
+ break mainFor
137
+ }
138
+ }
139
+ }
140
+ }
141
+
142
+ const mobile = attrs.value?.mobile !== undefined ? attrs.value.mobile : props.mobile
143
+ if (mobile !== undefined && mobile !== false) {
144
+ const defLen = 10
145
+ rules.digits = typeof mobile === 'boolean' ? defLen : (mobile || defLen)
146
+ }
147
+ return Object.values(rules).filter(e => !!e).length > 0 ? rules : undefined
148
+ })
149
+
150
+ return {
151
+ getRules,
152
+ accepts,
153
+ hasTopLabel,
154
+ getLabel,
155
+ getPlaceholder,
156
+ getAutocompleteAttribute,
157
+ inputOptions,
158
+ inputProps
159
+ }
160
+ }
161
+
162
+ export const useValue = <T = any> (name: MaybeRefOrGetter<string>) => {
163
+ const [value, setValue] = [useFieldValue<T>(name), useSetFieldValue<T>(name)]
164
+ const field = computed<T>({
165
+ get: () => value.value,
166
+ set: (v: T) => setValue(v)
167
+ })
168
+
169
+ return { field, value, setValue }
170
+ }
171
+ export const useError = (name: MaybeRefOrGetter<string>) => {
172
+ const [error, setErrors] = [useFieldError(name), useSetFieldError(name)]
173
+ const errors = computed<string | string[] | undefined>({
174
+ get: () => error.value,
175
+ set: (v: string | string[] | undefined) => setErrors(v)
176
+ })
177
+ return { errors, error, setErrors }
178
+ }
@@ -0,0 +1,17 @@
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
+ import { useI18n } from 'vue-i18n'
10
+
11
+ export const useMyth = () => {
12
+ const { t, te } = useI18n({ useScope: 'global' })
13
+ // const __ = (key: string, ...rest: unknown[]) => !key ? '' : te(`attributes.${key}`) ? t(`attributes.${key}`, ...rest) : te(key) ? t(key, ...rest) : key
14
+ const __ = (key: any, args?: Record<string, unknown>) => !key ? '' : te(`attributes.${key}`) ? t(`attributes.${key}`) : te(key) ? t(key) : key
15
+
16
+ return { __ }
17
+ }
@@ -1 +1,19 @@
1
- export * from './utils/vue-plugin'
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
+ import * as composable from './composable'
10
+ import * as utils from './utils'
11
+
12
+ export default {
13
+ ...composable,
14
+ ...utils
15
+ }
16
+
17
+ export * from './components'
18
+ export * from './composable'
19
+ export * from './utils'
package/src/index.d.ts ADDED
@@ -0,0 +1,9 @@
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
+ export * from './types'
package/src/index.esm.js CHANGED
@@ -1,4 +1,19 @@
1
- export * from './utils/vue-plugin'
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
+ */
2
8
 
3
- import * as Plugin from './utils/vue-plugin'
4
- export default Plugin
9
+ import * as composable from './composable'
10
+ import * as utils from './utils'
11
+
12
+ export default {
13
+ ...composable,
14
+ ...utils
15
+ }
16
+
17
+ export * from './components'
18
+ export * from './composable'
19
+ export * from './utils'
package/src/index.js ADDED
@@ -0,0 +1,19 @@
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
+ import * as composable from './composable'
10
+ import * as utils from './utils'
11
+
12
+ export default {
13
+ ...composable,
14
+ ...utils
15
+ }
16
+
17
+ export * from './components'
18
+ export * from './composable'
19
+ export * from './utils'
package/src/index.sass CHANGED
@@ -1,3 +1,11 @@
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
+
1
9
  @import 'quasar/src/css/variables.sass'
2
10
  $m--container-padding: $space-base !default
3
11
  $m--container-fluid-width: 1440px !default
package/src/index.umd.js CHANGED
@@ -1,2 +1,17 @@
1
- import * as Plugin from './utils/vue-plugin'
2
- export default Plugin
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
+ import * as components from './components'
10
+ import * as composable from './composable'
11
+ import * as utils from './utils'
12
+
13
+ export default {
14
+ ...components,
15
+ ...composable,
16
+ ...utils
17
+ }
@@ -1,6 +1,15 @@
1
- import type { GlobalComponentConstructor, QBtnProps, QBtnSlots, QItemProps } from 'quasar'
2
- import type { VNode } from 'vue'
3
- import { TypedOptions } from 'typed.js'
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
+ import type { GlobalComponentConstructor, QBtnProps, QBtnSlots, QFieldSlots, QInputProps, QInputSlots, QItemProps } from 'quasar'
10
+ import type { MaybeRefOrGetter, UnwrapNestedRefs, VNode } from 'vue'
11
+ import type { TypedOptions } from 'typed.js'
12
+ import type { FieldContext, FieldOptions } from 'vee-validate'
4
13
 
5
14
  export type StyleSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'none';
6
15
 
@@ -12,7 +21,7 @@ export interface MBtnSlots extends QBtnSlots {
12
21
  /**
13
22
  * Use for custom content, instead of relying on 'icon' and 'label' props
14
23
  */
15
- default: () => VNode[];
24
+ default?: () => VNode[];
16
25
  /**
17
26
  * Override the default QSpinner when in 'loading' state
18
27
  */
@@ -36,7 +45,7 @@ export interface MBlockProps {
36
45
  }
37
46
 
38
47
  export interface MBlockSlots {
39
- default: () => VNode[];
48
+ default?: () => VNode[];
40
49
  }
41
50
 
42
51
  export type ColStyleType =
@@ -84,7 +93,7 @@ export interface MColProps {
84
93
  }
85
94
 
86
95
  export interface MColSlots {
87
- default: () => VNode[];
96
+ default?: () => VNode[];
88
97
  }
89
98
 
90
99
  export interface MColumnProps {
@@ -92,7 +101,7 @@ export interface MColumnProps {
92
101
  }
93
102
 
94
103
  export interface MColumnSlots {
95
- default: () => VNode[];
104
+ default?: () => VNode[];
96
105
  }
97
106
 
98
107
  export interface MContainerProps {
@@ -102,7 +111,7 @@ export interface MContainerProps {
102
111
  }
103
112
 
104
113
  export interface MContainerSlots {
105
- default: () => VNode[];
114
+ default?: () => VNode[];
106
115
  }
107
116
 
108
117
  export interface MRowProps {
@@ -117,7 +126,7 @@ export interface MRowProps {
117
126
  }
118
127
 
119
128
  export interface MRowSlots {
120
- default: () => VNode[];
129
+ default?: () => VNode[];
121
130
  }
122
131
 
123
132
  export interface MHelpRowProps extends Partial<QItemProps> {
@@ -127,7 +136,7 @@ export interface MHelpRowProps extends Partial<QItemProps> {
127
136
  }
128
137
 
129
138
  export interface MHelpRowSlots {
130
- default: () => VNode[];
139
+ default?: () => VNode[];
131
140
  }
132
141
 
133
142
  export interface MTypingStringProps {
@@ -142,13 +151,160 @@ export interface MTypingStringProps {
142
151
  }
143
152
 
144
153
  export interface MTypingStringSlots {
154
+ default?: () => VNode[];
155
+ }
156
+
157
+ export type BaseInputFieldPropContext = FieldContext<any>;
158
+ export type BaseInputFieldProps = {
159
+ /**
160
+ * Context of field input.
161
+ */
162
+ field: UnwrapNestedRefs<BaseInputFieldPropContext>;
163
+ readonly label?: string | undefined;
164
+ }
165
+
166
+ export type MInputFieldControlProps = Record<string, unknown>;
167
+ export type MInputFieldControlSlots = {
168
+ default: () => VNode[];
169
+ }
170
+
171
+ export type MInputLabelProps = BaseInputFieldProps;
172
+ export type MInputLabelSlots = {
173
+ default?: () => VNode[];
174
+ }
175
+
176
+ export type ViewModeProps = {
177
+ /**
178
+ * Set input to vie mode use q-field
179
+ */
180
+ readonly viewMode?: boolean;
181
+ /**
182
+ * View Mode value for input or modelValue.
183
+ */
184
+ readonly viewModeValue?: any;
185
+ }
186
+ export type InputHelpProps = {
187
+ /**
188
+ * Information text with Icon.
189
+ */
190
+ readonly help?: string;
191
+ }
192
+ export type InputHelpSlots = {
193
+ /**
194
+ * VNode bottom of input & before 'bottom-input slot'.
195
+ */
196
+ help: () => VNode[];
197
+ }
198
+ export type InputRulesContext = string | string[] | Record<string, any> | undefined;
199
+ export type InputErrorsContext = string[];
200
+ export type InputFormErrorsContext = Record<string, InputErrorsContext> | undefined;
201
+ export type BaseInputFormProps = {
202
+ /**
203
+ * Input name.
204
+ */
205
+ readonly name: string;
206
+ /**
207
+ * Input model value.
208
+ * can be used instead of initialValue.
209
+ */
210
+ modelValue?: any;
211
+ /**
212
+ * Input Label.
213
+ */
214
+ readonly label?: string | undefined;
215
+ /**
216
+ * Caption under label.
217
+ */
218
+ readonly caption?: string | undefined;
219
+ /**
220
+ * Input Hint.
221
+ */
222
+ readonly hint?: string | undefined;
223
+ /**
224
+ * Input Placeholder.
225
+ */
226
+ readonly placeholder?: string | undefined;
227
+ /**
228
+ * Input Required validation.
229
+ */
230
+ readonly required?: boolean;
231
+ /**
232
+ * Input Validation Rules.
233
+ */
234
+ readonly rules?: InputRulesContext;
235
+ /**
236
+ * Input Error Messages.
237
+ */
238
+ // errors?: InputErrorsContext;
239
+ /**
240
+ * Form Error Messages.
241
+ */
242
+ // formErrors?: InputFormErrorsContext;
243
+ /**
244
+ * Input autocomplete attribute.
245
+ * if true, will set from input name.
246
+ * if false, will set 'off'.
247
+ * else, will set the attribute value.
248
+ * Default: undefined.
249
+ */
250
+ readonly autocomplete?: boolean | string | undefined;
251
+ /**
252
+ * Inputs Top Label.
253
+ */
254
+ readonly topLabel?: boolean;
255
+ /**
256
+ * Mobile Rule.
257
+ */
258
+ readonly mobile?: boolean | string | number | undefined;
259
+ /**
260
+ * Email Rule.
261
+ */
262
+ readonly email?: boolean;
263
+ /**
264
+ * Number Rule.
265
+ */
266
+ readonly float?: boolean;
267
+ /**
268
+ * vee-validate Field Options.
269
+ */
270
+ readonly fieldOptions?: Partial<FieldOptions> | MaybeRefOrGetter<Partial<FieldOptions>>;
271
+ }
272
+ export type BaseInputsProps = ViewModeProps & InputHelpProps & Omit<MColProps, 'name'> & BaseInputFormProps;
273
+ export type BaseInputsSlots = InputHelpSlots & {
274
+ /**
275
+ * VNode top of input & top of 'top label slot'.
276
+ */
277
+ 'top-input': () => VNode[];
278
+ /**
279
+ * The label top on input
280
+ */
281
+ 'top-label': () => VNode[];
282
+ /**
283
+ * VNode top of input & after top label.
284
+ */
285
+ caption: () => VNode[];
286
+ /**
287
+ * Field main content
288
+ */
145
289
  default: () => VNode[];
290
+ /**
291
+ * VNode bottom of input.
292
+ */
293
+ 'bottom-input': () => VNode[];
294
+ }
295
+
296
+ export interface MInputProps extends Omit<QInputProps, 'rules' | 'name' | 'modelValue' | 'label' | 'hint'>, BaseInputsProps {
297
+ //
146
298
  }
299
+ export type MInputSlots = QInputSlots & QFieldSlots & BaseInputsSlots
147
300
 
148
301
  declare module '@vue/runtime-core' {
149
302
  interface GlobalComponents {
150
303
  // Form.
151
304
  MBtn: GlobalComponentConstructor<MBtnProps, MBtnSlots>;
305
+ MInput: GlobalComponentConstructor<MInputProps, MInputSlots>;
306
+ MInputFieldControl: GlobalComponentConstructor<MInputFieldControlProps, MInputFieldControlSlots>;
307
+ MInputLabel: GlobalComponentConstructor<MInputLabelProps, MInputLabelSlots>;
152
308
 
153
309
  // Grid.
154
310
  MBlock: GlobalComponentConstructor<MBlockProps, MBlockSlots>;
@@ -1,2 +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
+ import type { QBtnProps, QFieldProps } from 'quasar'
10
+ import type { Ref } from 'vue'
11
+ import type { MBlockProps, MInputProps, StyleSize } from './components'
12
+
13
+ export interface UiOptionsContext {
14
+ /**
15
+ * Rules keys that can be added to Input Rules as Vue Attr
16
+ */
17
+ inputRules?: string[];
18
+ /**
19
+ * Style of the components.
20
+ */
21
+ style?: {
22
+ /**
23
+ * Apply Padding on all sides of components.
24
+ */
25
+ gutters?: StyleSize | undefined;
26
+ /**
27
+ * Apply Fluid on all sides of containers.
28
+ */
29
+ fluid?: boolean | undefined;
30
+ /**
31
+ * Apply style of all inputs.
32
+ */
33
+ // inputs?: {
34
+ // dense?: boolean;
35
+ // rounded?: boolean;
36
+ // outlined?: boolean;
37
+ // standout?: boolean;
38
+ // }
39
+ };
40
+ /**
41
+ * MBtn component.
42
+ */
43
+ btn?: {
44
+ props?: Partial<QBtnProps>;
45
+ loading?: {
46
+ type: 'audio' | 'ball' | 'bars' | 'box' | 'clock' | 'comment' | 'cube' | 'dots' | 'facebook' | 'gears' | 'grid' | 'hearts' | 'hourglass' | 'infinity' | 'ios' | 'orbit' | 'oval' | 'pie' | 'puff' | 'radio' | 'rings' | 'tail';
47
+ color?: string | undefined;
48
+ size?: string | undefined;
49
+ label?: boolean | undefined;
50
+ }
51
+ };
52
+ /**
53
+ * MBlock component.
54
+ */
55
+ block?: Partial<MBlockProps>;
56
+ /**
57
+ * MInput component.
58
+ */
59
+ input?: Partial<MInputProps>;
60
+ /**
61
+ * MInput view mode props.
62
+ */
63
+ field?: Partial<QFieldProps>;
64
+ }
65
+
66
+ export interface MythContext {
67
+ options: Ref<UiOptionsContext>;
68
+ setOptions: (values: Partial<UiOptionsContext>) => void;
69
+ withOptions: (values: Partial<UiOptionsContext>) => void;
70
+ withBtnOptions: (values: Partial<QBtnProps>) => void;
71
+ }
72
+
1
73
  export * from './components'
2
- export * from './myth'
@@ -0,0 +1,10 @@
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
+ export * from './myth'
10
+ export * from './vue-plugin'
package/src/utils/myth.ts CHANGED
@@ -1,7 +1,15 @@
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
+
1
9
  import { ref } from 'vue'
2
10
  import type { QBtnProps } from 'quasar'
3
11
  import { extend } from 'quasar'
4
- import type { MythContext, UiOptionsContext } from '../types'
12
+ import type { UiOptionsContext } from '../types'
5
13
 
6
14
  const defGutters = 'md'
7
15
  const defaultOptions: UiOptionsContext = {
@@ -11,7 +19,7 @@ const defaultOptions: UiOptionsContext = {
11
19
  }
12
20
  const optionsRef = ref<UiOptionsContext>({ ...defaultOptions })
13
21
 
14
- export const myth : MythContext = {
22
+ export const myth = {
15
23
  options: optionsRef,
16
24
  setOptions (values: Partial<UiOptionsContext>) {
17
25
  optionsRef.value = extend(!0, defaultOptions, values)
@@ -27,4 +35,3 @@ export const myth : MythContext = {
27
35
  })
28
36
  }
29
37
  }
30
- export default myth
@@ -1,20 +1,24 @@
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
+
1
9
  import type { App } from 'vue'
2
10
  import { name, version } from '../../package.json'
3
11
  import { myth } from './myth'
4
- import MBtn from '../components/form/MBtn.vue'
5
- import MBlock from '../components/grid/MBlock.vue'
6
- import MCol from '../components/grid/MCol.vue'
7
- import MColumn from '../components/grid/MColumn.vue'
8
- import MContainer from '../components/grid/MContainer.vue'
9
- import MHelpRow from '../components/grid/MHelpRow.vue'
10
- import MRow from '../components/grid/MRow.vue'
11
- import MTypingString from '../components/typography/MTypingString.vue'
12
+ import { MBlock, MBtn, MCol, MColumn, MContainer, MHelpRow, MInput, MInputFieldControl, MInputLabel, MRow, MTypingString } from '../components'
12
13
 
13
14
  function install (app: App, options = {}) {
14
15
  myth.withOptions(options)
15
16
 
16
17
  // Form.
17
18
  app.component('MBtn', MBtn)
19
+ app.component('MInput', MInput)
20
+ app.component('MInputFieldControl', MInputFieldControl)
21
+ app.component('MInputLabel', MInputLabel)
18
22
 
19
23
  // Grid.
20
24
  app.component('MBlock', MBlock)
@@ -31,13 +35,11 @@ function install (app: App, options = {}) {
31
35
  export {
32
36
  name,
33
37
  version,
34
- install,
35
- myth
38
+ install
36
39
  }
37
40
 
38
41
  export default {
39
42
  name,
40
43
  version,
41
- install,
42
- myth
44
+ install
43
45
  }
package/tsconfig.json CHANGED
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": "./",
4
- "rootDir": ".",
5
- "outDir": "./dist",
6
3
  "esModuleInterop": true,
7
4
  "skipLibCheck": true,
8
5
  "target": "esnext",
@@ -10,7 +7,6 @@
10
7
  "resolveJsonModule": true,
11
8
  "moduleDetection": "force",
12
9
  "isolatedModules": true,
13
- "verbatimModuleSyntax": true,
14
10
  "module": "preserve",
15
11
  "noEmit": true,
16
12
  "lib": [
@@ -22,13 +18,16 @@
22
18
  "allowUnreachableCode": false,
23
19
  "allowUnusedLabels": false,
24
20
  "noImplicitOverride": true,
25
- "exactOptionalPropertyTypes": true,
21
+ "exactOptionalPropertyTypes": false,
26
22
  "noUncheckedIndexedAccess": true
27
23
  },
28
- "exclude": [
29
- "./build"
30
- ],
31
24
  "include": [
32
- "src/**/*"
25
+ "./**/*.d.ts",
26
+ "./**/*"
27
+ ],
28
+ "exclude": [
29
+ "./build",
30
+ "./dist",
31
+ "./node_modules",
33
32
  ]
34
33
  }
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './src/utils/vue-plugin'
2
- export * from './src/types'
3
-
4
- import * as Plugin from './src/utils/vue-plugin'
5
- export default Plugin
package/src/types/myth.ts DELETED
@@ -1,42 +0,0 @@
1
- import type { QBtnProps } from 'quasar'
2
- import type { Ref } from 'vue'
3
- import type { MBlockProps, StyleSize } from './components'
4
-
5
- export interface UiOptionsContext {
6
- /**
7
- * Style of the components.
8
- */
9
- style?: {
10
- /**
11
- * Apply Padding on all sides of components.
12
- */
13
- gutters?: StyleSize | undefined;
14
- /**
15
- * Apply Fluid on all sides of containers.
16
- */
17
- fluid?: boolean | undefined;
18
- };
19
- /**
20
- * MBtn component.
21
- */
22
- btn?: {
23
- props?: Partial<QBtnProps>;
24
- loading?: {
25
- type: 'audio' | 'ball' | 'bars' | 'box' | 'clock' | 'comment' | 'cube' | 'dots' | 'facebook' | 'gears' | 'grid' | 'hearts' | 'hourglass' | 'infinity' | 'ios' | 'orbit' | 'oval' | 'pie' | 'puff' | 'radio' | 'rings' | 'tail';
26
- color?: string | undefined;
27
- size?: string | undefined;
28
- label?: boolean | undefined;
29
- }
30
- };
31
- /**
32
- * MBlock component.
33
- */
34
- block?: Partial<MBlockProps>;
35
- }
36
-
37
- export interface MythContext {
38
- options: Ref<UiOptionsContext>;
39
- setOptions: (values: Partial<UiOptionsContext>) => void;
40
- withOptions: (values: Partial<UiOptionsContext>) => void;
41
- withBtnOptions: (values: Partial<QBtnProps>) => void;
42
- }