@mythpe/quasar-ui-qui 0.0.23 → 0.0.24-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 +17 -0
- package/package.json +14 -9
- package/src/boot/register.ts +14 -0
- package/src/components/form/MAvatarViewer.vue +324 -0
- package/src/components/form/MBtn.vue +271 -93
- package/src/components/form/MCheckbox.vue +123 -0
- package/src/components/form/MColor.vue +122 -0
- package/src/components/form/MDate.vue +47 -0
- package/src/components/form/MEditor.vue +285 -0
- package/src/components/form/MEmail.vue +40 -0
- package/src/components/form/MField.vue +142 -0
- package/src/components/form/MFile.vue +209 -0
- package/src/components/form/MForm.vue +83 -0
- package/src/components/form/MHidden.vue +83 -0
- package/src/components/form/MHiddenInput.vue +55 -0
- package/src/components/form/MInput.vue +178 -0
- package/src/components/form/MInputFieldControl.vue +27 -0
- package/src/components/form/MInputLabel.vue +35 -0
- package/src/components/form/MMobile.vue +37 -0
- package/src/components/form/MPicker.vue +310 -0
- package/src/components/form/MRadio.vue +175 -0
- package/src/components/form/MSelect.vue +343 -0
- package/src/components/form/MTime.vue +45 -0
- package/src/components/form/index.ts +51 -0
- package/src/components/grid/MBlock.vue +40 -18
- package/src/components/grid/MCol.vue +11 -15
- package/src/components/grid/MColumn.vue +8 -0
- package/src/components/grid/MContainer.vue +22 -13
- package/src/components/grid/MHelpRow.vue +9 -12
- package/src/components/grid/MRow.vue +31 -10
- package/src/components/grid/index.ts +16 -0
- package/src/components/index.ts +12 -0
- package/src/components/transition/MFadeTransition.vue +27 -0
- package/src/components/transition/MFadeXTransition.vue +26 -0
- package/src/components/transition/MTransition.vue +41 -0
- package/src/components/transition/index.ts +13 -0
- package/src/components/typography/MTypingString.vue +8 -0
- package/src/components/typography/index.ts +11 -0
- package/src/composable/index.ts +12 -0
- package/src/composable/useBindInput.ts +209 -0
- package/src/composable/useError.ts +11 -0
- package/src/composable/useMyth.ts +294 -0
- package/src/composable/useValue.ts +12 -0
- package/src/index.common.js +19 -1
- package/src/index.esm.js +18 -3
- package/src/index.js +19 -0
- package/src/index.sass +8 -26
- package/src/index.ts +18 -4
- package/src/index.umd.js +16 -2
- package/src/style/m-container.sass +13 -0
- package/src/style/main.sass +42 -0
- package/src/types/api-helpers.d.ts +120 -0
- package/src/types/components.d.ts +682 -28
- package/src/types/dt.d.ts +142 -0
- package/src/types/index.d.ts +153 -1
- package/src/types/lodash.d.ts +26 -0
- package/src/types/quasar-helpers.d.ts +7 -0
- package/src/types/theme.d.ts +12 -0
- package/src/utils/Helpers.ts +321 -0
- package/src/utils/Str.ts +210 -0
- package/src/utils/index.ts +13 -0
- package/src/utils/myth.ts +90 -0
- package/src/utils/vee-rules.ts +32 -0
- package/src/utils/vue-plugin.ts +122 -0
- package/tsconfig.json +9 -13
- package/src/myth.ts +0 -30
- package/src/types/myth.ts +0 -42
- package/src/vue-plugin.ts +0 -41
- package/types.d.ts +0 -1
|
@@ -1,20 +1,41 @@
|
|
|
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
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
gutter?: MRowProps['gutter'];
|
|
11
|
-
col?: MRowProps['col'];
|
|
12
|
-
}
|
|
15
|
+
import { myth } from '../../utils'
|
|
13
16
|
|
|
14
|
-
const props = defineProps<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
const props = withDefaults(defineProps<MRowProps>(), {
|
|
18
|
+
gutter: undefined,
|
|
19
|
+
col: undefined
|
|
20
|
+
})
|
|
21
|
+
const defSize = 'md'
|
|
22
|
+
const gutterSize = computed<string>(() => {
|
|
23
|
+
if (props.gutter !== undefined) {
|
|
24
|
+
if (typeof props.gutter === 'string' && props.gutter?.length > 0) {
|
|
25
|
+
return props.gutter
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return myth.size.value || defSize
|
|
29
|
+
})
|
|
30
|
+
const colSize = computed<string>(() => {
|
|
31
|
+
if (props.col !== undefined) {
|
|
32
|
+
if (typeof props.col === 'string' && props.col?.length > 0) {
|
|
33
|
+
return props.col
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return myth.size.value || defSize
|
|
37
|
+
})
|
|
38
|
+
// const colSize = computed<string>(() => props.gutter === !0 ? defSize.value : (props.gutter || defSize.value))
|
|
18
39
|
defineOptions({
|
|
19
40
|
name: 'MRow',
|
|
20
41
|
inheritAttrs: !1
|
|
@@ -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,12 @@
|
|
|
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'
|
|
12
|
+
export * from './transition'
|
|
@@ -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: 'MFadeTransition',
|
|
15
|
+
inheritAttrs: !1
|
|
16
|
+
})
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<Transition
|
|
21
|
+
appear
|
|
22
|
+
name="myth-transition__fade"
|
|
23
|
+
v-bind="$attrs"
|
|
24
|
+
>
|
|
25
|
+
<slot />
|
|
26
|
+
</Transition>
|
|
27
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
<script
|
|
9
|
+
lang="ts"
|
|
10
|
+
setup
|
|
11
|
+
>
|
|
12
|
+
defineOptions({
|
|
13
|
+
name: 'MFadeXTransition',
|
|
14
|
+
inheritAttrs: !1
|
|
15
|
+
})
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<Transition
|
|
20
|
+
appear
|
|
21
|
+
name="myth-transition__fade-x"
|
|
22
|
+
v-bind="$attrs"
|
|
23
|
+
>
|
|
24
|
+
<slot />
|
|
25
|
+
</Transition>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { MTransitionProps as Props } from '../../types'
|
|
11
|
+
|
|
12
|
+
interface P {
|
|
13
|
+
enterIn?: Props['enterIn'];
|
|
14
|
+
enterOut?: Props['enterOut'];
|
|
15
|
+
slowIn?: Props['slowIn'];
|
|
16
|
+
slowOut?: Props['slowIn'];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
withDefaults(defineProps<P>(), {
|
|
20
|
+
enterIn: () => 'fadeIn',
|
|
21
|
+
enterOut: () => 'fadeOut',
|
|
22
|
+
slowIn: () => !1,
|
|
23
|
+
slowOut: () => !1
|
|
24
|
+
})
|
|
25
|
+
defineOptions({
|
|
26
|
+
name: 'MTransition',
|
|
27
|
+
inheritAttrs: !1
|
|
28
|
+
})
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<TransitionGroup
|
|
33
|
+
:enter-active-class="`animated ${enterIn} ${slowIn ? 'slow' : ''}`"
|
|
34
|
+
:leave-active-class="`animated ${enterOut} ${slowOut ? 'slow' : ''}`"
|
|
35
|
+
appear
|
|
36
|
+
name="m__transition__fade"
|
|
37
|
+
v-bind="$attrs"
|
|
38
|
+
>
|
|
39
|
+
<slot />
|
|
40
|
+
</TransitionGroup>
|
|
41
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
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 MFadeTransition from './MFadeTransition.vue'
|
|
10
|
+
import MFadeXTransition from './MFadeXTransition.vue'
|
|
11
|
+
import MTransition from './MTransition.vue'
|
|
12
|
+
|
|
13
|
+
export { MFadeTransition, MFadeXTransition, MTransition }
|
|
@@ -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
|
+
import MTypingString from './MTypingString.vue'
|
|
10
|
+
|
|
11
|
+
export { MTypingString }
|
|
@@ -0,0 +1,12 @@
|
|
|
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 './useBindInput'
|
|
10
|
+
export * from './useMyth'
|
|
11
|
+
export * from './useValue'
|
|
12
|
+
export * from './useError'
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { PropsContext as UiOpt } from '../types'
|
|
2
|
+
import { computed, MaybeRefOrGetter, ref, toValue } from 'vue'
|
|
3
|
+
import { useI18n } from 'vue-i18n'
|
|
4
|
+
import { useMyth } from './useMyth'
|
|
5
|
+
import { useSplitAttrs } from 'quasar'
|
|
6
|
+
import { myth } from '../utils'
|
|
7
|
+
import { camelCase, kebabCase, snakeCase, uniq } from 'lodash'
|
|
8
|
+
|
|
9
|
+
type G = { name: string; [k: string]: any };
|
|
10
|
+
type OptsContext = { choose?: boolean; };
|
|
11
|
+
export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key: keyof UiOpt, Opts: MaybeRefOrGetter<OptsContext> = {}) => {
|
|
12
|
+
const { messages, locale } = useI18n({ useScope: 'global' })
|
|
13
|
+
const { __ } = useMyth()
|
|
14
|
+
const { attributes } = useSplitAttrs()
|
|
15
|
+
const props = toValue<P>(Props)
|
|
16
|
+
const opts = toValue<OptsContext>(Opts)
|
|
17
|
+
const getProp = computed(() => (k: string) => {
|
|
18
|
+
if (props[k] !== undefined) {
|
|
19
|
+
return props[k]
|
|
20
|
+
}
|
|
21
|
+
return pluginProps.value[key]?.[k]
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const { themeBtn, themeInput, props: pluginProps } = myth
|
|
25
|
+
const theme = computed(() => (key === 'btn' ? themeBtn.value : themeInput.value) ?? {})
|
|
26
|
+
const mergedTheme = ref({})
|
|
27
|
+
for (const k in theme.value) {
|
|
28
|
+
mergedTheme.value[k] = props[k] !== undefined ? theme.value[k] : props[k]
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Top Label Style.
|
|
32
|
+
*/
|
|
33
|
+
const hasTopLabel = computed(() => {
|
|
34
|
+
if (props.topLabel !== undefined) {
|
|
35
|
+
return props.topLabel !== !1
|
|
36
|
+
}
|
|
37
|
+
if ('topLabel' in theme.value && theme.value.topLabel !== undefined) {
|
|
38
|
+
return theme.value.topLabel !== !1
|
|
39
|
+
}
|
|
40
|
+
if (pluginProps.value[key] && 'topLabel' in pluginProps.value[key]) {
|
|
41
|
+
return pluginProps.value[key]?.topLabel !== !1
|
|
42
|
+
}
|
|
43
|
+
return !1
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const getLabel = computed<string | undefined>(() => {
|
|
47
|
+
const k = props.label === undefined ? props.name : props.label
|
|
48
|
+
return k ? (__(k) || undefined) : undefined
|
|
49
|
+
})
|
|
50
|
+
const getPlaceholder = computed<string | undefined>(() => {
|
|
51
|
+
const replace = computed(() => {
|
|
52
|
+
const val = props.useChoice !== undefined ? props.useChoice : (attributes.value.useChoice !== undefined ? attributes.value.useChoice : opts?.choose)
|
|
53
|
+
if (typeof val === 'string' && val?.length > 0) {
|
|
54
|
+
return val
|
|
55
|
+
}
|
|
56
|
+
return 'enter'
|
|
57
|
+
})
|
|
58
|
+
if (props.placeholder === undefined) {
|
|
59
|
+
const k = props.label !== undefined ? props.label : props.name
|
|
60
|
+
return __(`replace.${replace.value}`, { name: __(k) })
|
|
61
|
+
}
|
|
62
|
+
return __(props.placeholder) || undefined
|
|
63
|
+
})
|
|
64
|
+
const getAutocompleteAttribute = computed<string | null | undefined>(() => {
|
|
65
|
+
const autocomplete = props.autocomplete !== undefined ? props.autocomplete : (pluginProps.value[key] && 'autocomplete' in pluginProps.value[key] ? pluginProps.value[key]?.autocomplete : undefined)
|
|
66
|
+
// const autocomplete = 'autocomplete' in opt && opt?.autocomplete !== undefined ? opt?.autocomplete : props.autocomplete
|
|
67
|
+
if (autocomplete !== undefined) {
|
|
68
|
+
if (autocomplete === !0 || autocomplete === '') {
|
|
69
|
+
return kebabCase(props.name)
|
|
70
|
+
} else if (autocomplete === !1) {
|
|
71
|
+
return 'off'
|
|
72
|
+
} else if (autocomplete?.length > 0) {
|
|
73
|
+
return autocomplete
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return undefined
|
|
77
|
+
})
|
|
78
|
+
const accepts = computed(() => {
|
|
79
|
+
const l: string[] = []
|
|
80
|
+
if (props.accept) {
|
|
81
|
+
if (typeof props.accept === 'string') {
|
|
82
|
+
l.push(props.accept)
|
|
83
|
+
} else if (Array.isArray(props.accept)) {
|
|
84
|
+
l.push(...props.accept)
|
|
85
|
+
} else if (typeof props.accept === 'object') {
|
|
86
|
+
const v = toValue(props.accept)
|
|
87
|
+
l.push(...Object.values<string>(v))
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (props.images) {
|
|
91
|
+
if (typeof props.images === 'string' && props.images?.length > 0) {
|
|
92
|
+
l.push(props.images)
|
|
93
|
+
} else {
|
|
94
|
+
l.push('image/png,image/jpg,image/jpeg')
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (props.svg) {
|
|
98
|
+
if (typeof props.svg === 'string' && props.svg?.length > 0) {
|
|
99
|
+
l.push(props.svg)
|
|
100
|
+
} else {
|
|
101
|
+
l.push('image/svg+xml')
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (props.video) {
|
|
105
|
+
if (typeof props.video === 'string' && props.video?.length > 0) {
|
|
106
|
+
l.push(props.video)
|
|
107
|
+
} else {
|
|
108
|
+
l.push('video/mp4')
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (props.pdf) {
|
|
112
|
+
if (typeof props.pdf === 'string' && props.pdf?.length > 0) {
|
|
113
|
+
l.push(props.pdf)
|
|
114
|
+
} else {
|
|
115
|
+
l.push('application/pdf')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (props.excel) {
|
|
119
|
+
if (typeof props.excel === 'string' && props.excel?.length > 0) {
|
|
120
|
+
l.push(props.excel)
|
|
121
|
+
} else {
|
|
122
|
+
l.push('application/vnd.ms-excel')
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return l
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const isNumeric = (str: any) => !isNaN(str) && !isNaN(parseFloat(str))
|
|
129
|
+
const convertRules = (rules: any) => {
|
|
130
|
+
if (!rules) {
|
|
131
|
+
return {}
|
|
132
|
+
}
|
|
133
|
+
let values: Record<string, any> = {}
|
|
134
|
+
const list: any[] = typeof rules === 'string' ? rules.split('|') : (Array.isArray(rules) ? rules : [rules])
|
|
135
|
+
|
|
136
|
+
for (const rule of list) {
|
|
137
|
+
// console.log(rule)
|
|
138
|
+
if (!rule) {
|
|
139
|
+
continue
|
|
140
|
+
}
|
|
141
|
+
if (typeof rule === 'object' && !Array.isArray(rule)) {
|
|
142
|
+
values = { ...values, ...rule }
|
|
143
|
+
continue
|
|
144
|
+
}
|
|
145
|
+
if (Array.isArray(rule)) {
|
|
146
|
+
values = { ...values, ...rule }
|
|
147
|
+
}
|
|
148
|
+
const [name, value] = rule.split(':')
|
|
149
|
+
if (!name) {
|
|
150
|
+
continue
|
|
151
|
+
}
|
|
152
|
+
values[name] = !value ? !0
|
|
153
|
+
: /,/g.test(value) ? value.split(',').map((e: any) => isNumeric(e) ? parseInt(e) : e) : (isNumeric(value) ? parseInt(value) : value)
|
|
154
|
+
}
|
|
155
|
+
if (values.color && props.required) {
|
|
156
|
+
values.requiredColor = values.color
|
|
157
|
+
delete values.color
|
|
158
|
+
}
|
|
159
|
+
return values
|
|
160
|
+
}
|
|
161
|
+
const publicRules = ['required', 'email', 'numeric', 'integer', 'float', 'color']
|
|
162
|
+
const validations = (messages.value as any)?.[locale.value]?.validation?.messages || {}
|
|
163
|
+
const inputRules = computed<Record<string, any>>(() => {
|
|
164
|
+
if (props.viewMode) {
|
|
165
|
+
return {}
|
|
166
|
+
}
|
|
167
|
+
const rules: any = { ...convertRules(toValue(props.rules)) }
|
|
168
|
+
const keys = uniq<string>([...publicRules, ...(myth.rules.value ?? []), ...Object.keys(validations)])
|
|
169
|
+
for (const k of keys) {
|
|
170
|
+
if (['mobile', '_default', 'default'].includes(k)) {
|
|
171
|
+
continue
|
|
172
|
+
}
|
|
173
|
+
const cases = [k, snakeCase(k), camelCase(k), kebabCase(k)]
|
|
174
|
+
|
|
175
|
+
// eslint-disable-next-line no-labels
|
|
176
|
+
mainFor: for (const c of cases) {
|
|
177
|
+
for (const b of [attributes.value, props]) {
|
|
178
|
+
if (c in b && (b[c] === !0 || b[c] === '')) {
|
|
179
|
+
rules[snakeCase(k)] = b[c] === !0 || b[c] === '' ? !0 : b[c]
|
|
180
|
+
// eslint-disable-next-line no-labels
|
|
181
|
+
break mainFor
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const mobile = attributes.value?.mobile !== undefined ? attributes.value.mobile : props.mobile
|
|
188
|
+
if (mobile !== undefined && mobile !== false) {
|
|
189
|
+
const defLen = 10
|
|
190
|
+
rules.digits = typeof mobile === 'boolean' ? defLen : (mobile || defLen)
|
|
191
|
+
}
|
|
192
|
+
return Object.values(rules).filter(e => !!e).length > 0 ? rules : undefined
|
|
193
|
+
})
|
|
194
|
+
const attrs = computed(() => ({
|
|
195
|
+
...props,
|
|
196
|
+
...attributes.value,
|
|
197
|
+
...mergedTheme.value
|
|
198
|
+
}))
|
|
199
|
+
return {
|
|
200
|
+
inputRules,
|
|
201
|
+
accepts,
|
|
202
|
+
hasTopLabel,
|
|
203
|
+
getLabel,
|
|
204
|
+
getPlaceholder,
|
|
205
|
+
getAutocompleteAttribute,
|
|
206
|
+
getProp,
|
|
207
|
+
attrs
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { computed, MaybeRefOrGetter } from 'vue'
|
|
2
|
+
import { useFieldError, useSetFieldError } from 'vee-validate'
|
|
3
|
+
|
|
4
|
+
export const useError = (name: MaybeRefOrGetter<string>) => {
|
|
5
|
+
const [error, setErrors] = [useFieldError(name), useSetFieldError(name)]
|
|
6
|
+
const errors = computed<string | string[] | undefined>({
|
|
7
|
+
get: () => error.value,
|
|
8
|
+
set: (v: string | string[] | undefined) => setErrors(v)
|
|
9
|
+
})
|
|
10
|
+
return { errors, error, setErrors }
|
|
11
|
+
}
|