@mythpe/quasar-ui-qui 0.0.18 → 0.0.19-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/index.d.ts +13 -0
- package/package.json +11 -9
- package/src/boot/register.ts +14 -0
- package/src/components/form/MBtn.vue +13 -2
- package/src/components/form/MInput.vue +178 -0
- package/src/components/form/MInputFieldControl.vue +24 -0
- package/src/components/form/MInputLabel.vue +31 -0
- package/src/components/form/index.ts +14 -0
- package/src/components/grid/MBlock.vue +10 -2
- package/src/components/grid/MCol.vue +9 -1
- package/src/components/grid/MColumn.vue +8 -0
- package/src/components/grid/MContainer.vue +2 -2
- package/src/components/grid/MHelpRow.vue +2 -3
- package/src/components/grid/MRow.vue +10 -2
- package/src/components/grid/index.ts +16 -0
- package/src/components/index.ts +11 -0
- package/src/components/typography/MTypingString.vue +8 -0
- package/src/components/typography/index.ts +10 -0
- package/src/composable/index.ts +10 -0
- package/src/composable/useHelpersMyth.ts +179 -0
- package/src/composable/useMyth.ts +17 -0
- package/src/index.common.js +19 -0
- package/src/index.esm.js +19 -0
- package/src/index.js +19 -0
- package/src/index.sass +8 -0
- package/src/index.umd.js +17 -0
- package/src/types/components.d.ts +166 -10
- package/src/types/index.d.ts +72 -1
- package/src/utils/index.ts +10 -0
- package/src/{myth.ts → utils/myth.ts} +10 -3
- package/src/utils/vue-plugin.ts +45 -0
- package/tsconfig.json +8 -9
- package/src/index.ts +0 -5
- package/src/types/myth.ts +0 -42
- package/src/vue-plugin.ts +0 -41
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
const inputOptions = computed(() => (k: keyof UiOpt) => myth.options.value[k] || {})
|
|
29
|
+
const inputProps = computed<UiOpt[typeof key] & P>(() => extend(!0, {}, inputOptions.value(key), props))
|
|
30
|
+
const hasTopLabel = computed(() => inputProps.value?.topLabel === !0)
|
|
31
|
+
|
|
32
|
+
const getLabel = computed<string | undefined>(() => {
|
|
33
|
+
const k = props.label === undefined ? props.name : props.label
|
|
34
|
+
return k ? (__(k) || undefined) : undefined
|
|
35
|
+
})
|
|
36
|
+
const getPlaceholder = computed<string | undefined>(() => {
|
|
37
|
+
if (props.placeholder === undefined) {
|
|
38
|
+
const k = props.label !== undefined ? props.label : props.name
|
|
39
|
+
return __(`replace.${opts?.choose ? 'choose' : 'enter'}`, { name: __(k) })
|
|
40
|
+
}
|
|
41
|
+
return __(props.placeholder) || undefined
|
|
42
|
+
// if (inputProps.value.hidePlaceholder === !0) {
|
|
43
|
+
// return props.placeholder !== undefined ? (__(props.placeholder) || undefined) : undefined
|
|
44
|
+
// }
|
|
45
|
+
})
|
|
46
|
+
const getAutocompleteAttribute = computed<string | null | undefined>(() => {
|
|
47
|
+
const opt = inputOptions.value(key)
|
|
48
|
+
const autocomplete = 'autocomplete' in opt && opt?.autocomplete !== undefined ? opt?.autocomplete : props.autocomplete
|
|
49
|
+
if (autocomplete !== undefined) {
|
|
50
|
+
if (autocomplete === !0 || autocomplete === '') {
|
|
51
|
+
return kebabCase(props.name)
|
|
52
|
+
} else if (autocomplete === !1) {
|
|
53
|
+
return 'off'
|
|
54
|
+
} else if (autocomplete?.length > 0) {
|
|
55
|
+
return autocomplete
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return undefined
|
|
59
|
+
})
|
|
60
|
+
const accepts = computed(() => {
|
|
61
|
+
const l: any[] = []
|
|
62
|
+
if (props.accept) {
|
|
63
|
+
l.push(props.accept)
|
|
64
|
+
}
|
|
65
|
+
if (props.images) {
|
|
66
|
+
l.push('image/png,image/jpg,image/jpeg')
|
|
67
|
+
}
|
|
68
|
+
if (props.svg) {
|
|
69
|
+
l.push('image/svg+xml')
|
|
70
|
+
}
|
|
71
|
+
if (props.video) {
|
|
72
|
+
l.push('video/mp4,video/x-m4v,video/*')
|
|
73
|
+
}
|
|
74
|
+
if (props.pdf) {
|
|
75
|
+
l.push('application/pdf')
|
|
76
|
+
}
|
|
77
|
+
if (props.excel) {
|
|
78
|
+
l.push('.csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
|
79
|
+
}
|
|
80
|
+
return l
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const isNumeric = (str: any) => !isNaN(str) && !isNaN(parseFloat(str))
|
|
84
|
+
const convertRules = (rules: any) => {
|
|
85
|
+
if (!rules) {
|
|
86
|
+
return {}
|
|
87
|
+
}
|
|
88
|
+
let values: Record<string, any> = {}
|
|
89
|
+
const list: any[] = typeof rules === 'string' ? rules.split('|') : (Array.isArray(rules) ? rules : [rules])
|
|
90
|
+
|
|
91
|
+
for (const rule of list) {
|
|
92
|
+
// console.log(rule)
|
|
93
|
+
if (!rule) {
|
|
94
|
+
continue
|
|
95
|
+
}
|
|
96
|
+
if (typeof rule === 'object' && !Array.isArray(rule)) {
|
|
97
|
+
values = { ...values, ...rule }
|
|
98
|
+
continue
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(rule)) {
|
|
101
|
+
values = { ...values, ...rule }
|
|
102
|
+
}
|
|
103
|
+
const [name, value] = rule.split(':')
|
|
104
|
+
if (!name) {
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
values[name] = !value ? !0
|
|
108
|
+
: /,/g.test(value) ? value.split(',').map((e: any) => isNumeric(e) ? parseInt(e) : e) : (isNumeric(value) ? parseInt(value) : value)
|
|
109
|
+
}
|
|
110
|
+
if (values.color && props.required) {
|
|
111
|
+
values.requiredColor = values.color
|
|
112
|
+
delete values.color
|
|
113
|
+
}
|
|
114
|
+
return values
|
|
115
|
+
}
|
|
116
|
+
const publicRules = ['required', 'email', 'numeric', 'integer', 'float', 'color']
|
|
117
|
+
const validations = (messages.value as any)?.[locale.value]?.validation?.messages || {}
|
|
118
|
+
const getRules = computed<Record<string, any>>(() => {
|
|
119
|
+
if (props.viewMode) {
|
|
120
|
+
return {}
|
|
121
|
+
}
|
|
122
|
+
const rules: any = { ...convertRules(toValue(props.rules)) }
|
|
123
|
+
// const attrs = toValue(opts.attrs) || {}
|
|
124
|
+
const keys = uniq<string>([...publicRules, ...(myth.options.value.inputRules ?? []), ...Object.keys(validations)])
|
|
125
|
+
for (const k of keys) {
|
|
126
|
+
if (['mobile', '_default', 'default'].includes(k)) {
|
|
127
|
+
continue
|
|
128
|
+
}
|
|
129
|
+
const cases = [k, snakeCase(k), camelCase(k), kebabCase(k)]
|
|
130
|
+
|
|
131
|
+
// eslint-disable-next-line no-labels
|
|
132
|
+
mainFor: for (const c of cases) {
|
|
133
|
+
for (const b of [attrs.value, props]) {
|
|
134
|
+
if (c in b && (b[c] === !0 || b[c] === '')) {
|
|
135
|
+
rules[snakeCase(k)] = b[c] === !0 || b[c] === '' ? !0 : b[c]
|
|
136
|
+
// eslint-disable-next-line no-labels
|
|
137
|
+
break mainFor
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const mobile = attrs.value?.mobile !== undefined ? attrs.value.mobile : props.mobile
|
|
144
|
+
if (mobile !== undefined && mobile !== false) {
|
|
145
|
+
const defLen = 10
|
|
146
|
+
rules.digits = typeof mobile === 'boolean' ? defLen : (mobile || defLen)
|
|
147
|
+
}
|
|
148
|
+
return Object.values(rules).filter(e => !!e).length > 0 ? rules : undefined
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
getRules,
|
|
153
|
+
accepts,
|
|
154
|
+
hasTopLabel,
|
|
155
|
+
getLabel,
|
|
156
|
+
getPlaceholder,
|
|
157
|
+
getAutocompleteAttribute,
|
|
158
|
+
inputOptions,
|
|
159
|
+
inputProps
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const useValue = <T = any> (name: MaybeRefOrGetter<string>) => {
|
|
164
|
+
const [value, setValue] = [useFieldValue<T>(name), useSetFieldValue<T>(name)]
|
|
165
|
+
const field = computed<T>({
|
|
166
|
+
get: () => value.value,
|
|
167
|
+
set: (v: T) => setValue(v)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
return { field, value, setValue }
|
|
171
|
+
}
|
|
172
|
+
export const useError = (name: MaybeRefOrGetter<string>) => {
|
|
173
|
+
const [error, setErrors] = [useFieldError(name), useSetFieldError(name)]
|
|
174
|
+
const errors = computed<string | string[] | undefined>({
|
|
175
|
+
get: () => error.value,
|
|
176
|
+
set: (v: string | string[] | undefined) => setErrors(v)
|
|
177
|
+
})
|
|
178
|
+
return { errors, error, setErrors }
|
|
179
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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.esm.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.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
ADDED
|
@@ -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 * 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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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>;
|
package/src/types/index.d.ts
CHANGED
|
@@ -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'
|
|
@@ -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 {
|
|
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
|
|
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
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { App } from 'vue'
|
|
10
|
+
import { name, version } from '../../package.json'
|
|
11
|
+
import { myth } from './myth'
|
|
12
|
+
import { MBlock, MBtn, MCol, MColumn, MContainer, MHelpRow, MInput, MInputFieldControl, MInputLabel, MRow, MTypingString } from '../components'
|
|
13
|
+
|
|
14
|
+
function install (app: App, options = {}) {
|
|
15
|
+
myth.withOptions(options)
|
|
16
|
+
|
|
17
|
+
// Form.
|
|
18
|
+
app.component('MBtn', MBtn)
|
|
19
|
+
app.component('MInput', MInput)
|
|
20
|
+
app.component('MInputFieldControl', MInputFieldControl)
|
|
21
|
+
app.component('MInputLabel', MInputLabel)
|
|
22
|
+
|
|
23
|
+
// Grid.
|
|
24
|
+
app.component('MBlock', MBlock)
|
|
25
|
+
app.component('MCol', MCol)
|
|
26
|
+
app.component('MColumn', MColumn)
|
|
27
|
+
app.component('MContainer', MContainer)
|
|
28
|
+
app.component('MHelpRow', MHelpRow)
|
|
29
|
+
app.component('MRow', MRow)
|
|
30
|
+
|
|
31
|
+
// Typography.
|
|
32
|
+
app.component('MTypingString', MTypingString)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
name,
|
|
37
|
+
version,
|
|
38
|
+
install
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
name,
|
|
43
|
+
version,
|
|
44
|
+
install
|
|
45
|
+
}
|