@mythpe/quasar-ui-qui 0.0.73 → 0.0.74
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 +1 -1
- package/src/components/datatable/MDatatable.vue +44 -44
- package/src/components/form/MMobile.vue +2 -3
- package/src/components/form/MPicker.vue +5 -1
- package/src/components/form/MSelect.vue +2 -0
- package/src/components/grid/MCol.vue +1 -1
- package/src/composable/useBindInput.ts +3 -0
- package/src/style/main.sass +1 -1
- package/src/types/components.d.ts +2 -1
- package/src/types/myth-api.ts +5 -0
- package/src/utils/createMyth.ts +9 -4
package/package.json
CHANGED
|
@@ -201,9 +201,9 @@ const getTableTitle = computed(() => {
|
|
|
201
201
|
}
|
|
202
202
|
return undefined
|
|
203
203
|
})
|
|
204
|
-
const
|
|
205
|
-
const formScope = reactive(
|
|
206
|
-
const { resetForm: resetDialogForm, setValues, handleSubmit } =
|
|
204
|
+
const useFormContext = useForm<any, any>()
|
|
205
|
+
// const formScope = reactive(useFormContext)
|
|
206
|
+
const { resetForm: resetDialogForm, setValues, handleSubmit } = useFormContext
|
|
207
207
|
watch(() => props.defaultItem, (v) => {
|
|
208
208
|
resetDialogForm({ values: { ...v || {} } }, { force: !0 })
|
|
209
209
|
}, { immediate: !0, deep: !0 })
|
|
@@ -267,6 +267,7 @@ const dialogs = reactive<MDatatableDialogsOptions>({
|
|
|
267
267
|
errors: dialogErrors
|
|
268
268
|
})
|
|
269
269
|
const resetDialogs = () => {
|
|
270
|
+
console.log('resetDialogs')
|
|
270
271
|
dialogs.filter = !1
|
|
271
272
|
dialogs.show = !1
|
|
272
273
|
dialogs.form = !1
|
|
@@ -769,13 +770,14 @@ const openUpdateDialog = (i: MDtItem, index: MDtItemIndex) => {
|
|
|
769
770
|
getRows.value[index] = { ..._data } as any
|
|
770
771
|
nextTick(() => setTimeout(() => (selected.value = [getRows.value[index] as any]), openDialogTimeout))
|
|
771
772
|
}
|
|
772
|
-
setTimeout(
|
|
773
|
+
setTimeout(() => {
|
|
773
774
|
resetVeeForm(_data)
|
|
774
|
-
nextTick()
|
|
775
|
-
|
|
775
|
+
nextTick(() => {
|
|
776
|
+
dialogs.form = !0
|
|
777
|
+
})
|
|
776
778
|
}, openDialogTimeout)
|
|
777
779
|
})
|
|
778
|
-
.catch((e) => {
|
|
780
|
+
.catch((e: any) => {
|
|
779
781
|
const message = e?._message || e?.message
|
|
780
782
|
message && alertError(message)
|
|
781
783
|
})
|
|
@@ -897,7 +899,7 @@ const onSuccess: SubmissionHandler = async (form) => {
|
|
|
897
899
|
scrollToElementFromErrors(_errors, undefined, '.m--datatable__dialog-form-container')
|
|
898
900
|
_message && alertError(_message)
|
|
899
901
|
if (_errors) {
|
|
900
|
-
|
|
902
|
+
useFormContext.setErrors(_errors)
|
|
901
903
|
}
|
|
902
904
|
} finally {
|
|
903
905
|
loading.value = !1
|
|
@@ -981,7 +983,7 @@ const deleteSelectionItem = () => {
|
|
|
981
983
|
})
|
|
982
984
|
}
|
|
983
985
|
const logoutDatatable = () => {
|
|
984
|
-
//
|
|
986
|
+
//
|
|
985
987
|
}
|
|
986
988
|
/**
|
|
987
989
|
* ---
|
|
@@ -993,23 +995,22 @@ const logoutDatatable = () => {
|
|
|
993
995
|
const contextmenu = ref(!1)
|
|
994
996
|
const onRowContextmenu = (e: MouseEvent | Event, row: MDtItem, index: number | undefined) => {
|
|
995
997
|
e.preventDefault?.()
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
}
|
|
1004
|
-
return
|
|
998
|
+
row = toValue(row)
|
|
999
|
+
if (index === dialogs.index) {
|
|
1000
|
+
selected.value = []
|
|
1001
|
+
dialogs.item = undefined
|
|
1002
|
+
dialogs.index = undefined
|
|
1003
|
+
if (contextmenu.value) {
|
|
1004
|
+
contextmenu.value = !1
|
|
1005
1005
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1006
|
+
return
|
|
1007
|
+
}
|
|
1008
|
+
selected.value = [row]
|
|
1009
|
+
dialogs.item = row
|
|
1010
|
+
dialogs.index = index
|
|
1011
|
+
if (isGrid.value) {
|
|
1012
|
+
contextmenu.value = !0
|
|
1013
|
+
}
|
|
1013
1014
|
}
|
|
1014
1015
|
const contextmenuItemsProp = computed(() => props.contextItems)
|
|
1015
1016
|
const contextmenuItems = computed<any>(() => ([
|
|
@@ -1086,7 +1087,7 @@ watch(loading, v => {
|
|
|
1086
1087
|
$q.loading.hide()
|
|
1087
1088
|
}
|
|
1088
1089
|
}
|
|
1089
|
-
tableOptions.hasAction =
|
|
1090
|
+
tableOptions.hasAction = v
|
|
1090
1091
|
})
|
|
1091
1092
|
watch([filterForm, () => $q.lang.nativeName], () => refreshNoUpdate(), { deep: !0 })
|
|
1092
1093
|
watch(formDialogModel, (v) => {
|
|
@@ -1193,13 +1194,13 @@ defineOptions({
|
|
|
1193
1194
|
>
|
|
1194
1195
|
<!-- Context Menu -->
|
|
1195
1196
|
<MModalMenu
|
|
1197
|
+
v-if="false"
|
|
1196
1198
|
v-model="contextmenu"
|
|
1197
1199
|
class="shadow-6 relative-position"
|
|
1198
1200
|
context-menu
|
|
1199
1201
|
position="standard"
|
|
1200
1202
|
touch-position
|
|
1201
1203
|
v-bind="pluginOptions.dt?.contextmenu?.menu"
|
|
1202
|
-
@hide="resetDialogs()"
|
|
1203
1204
|
>
|
|
1204
1205
|
<q-list
|
|
1205
1206
|
v-if="dialogs.item"
|
|
@@ -1259,7 +1260,6 @@ defineOptions({
|
|
|
1259
1260
|
@request="fetchDatatableItems"
|
|
1260
1261
|
@update:selected="onUpdateSelectedItems"
|
|
1261
1262
|
@virtual-scroll="endReach ? onScroll : undefined"
|
|
1262
|
-
@row-contextmenu="onRowContextmenu"
|
|
1263
1263
|
>
|
|
1264
1264
|
<template
|
|
1265
1265
|
v-for="slotName in getSlots"
|
|
@@ -1268,7 +1268,7 @@ defineOptions({
|
|
|
1268
1268
|
>
|
|
1269
1269
|
<slot
|
|
1270
1270
|
:dt="datatableItemsScope"
|
|
1271
|
-
:form="
|
|
1271
|
+
:form="useFormContext"
|
|
1272
1272
|
:index="dialogItemIndex"
|
|
1273
1273
|
:item="dialogItem"
|
|
1274
1274
|
:name="slotName"
|
|
@@ -1279,7 +1279,7 @@ defineOptions({
|
|
|
1279
1279
|
<template #item="iTempProps">
|
|
1280
1280
|
<slot
|
|
1281
1281
|
:dt="datatableItemsScope"
|
|
1282
|
-
:form="
|
|
1282
|
+
:form="useFormContext"
|
|
1283
1283
|
name="item"
|
|
1284
1284
|
v-bind="iTempProps"
|
|
1285
1285
|
>
|
|
@@ -1402,7 +1402,7 @@ defineOptions({
|
|
|
1402
1402
|
>
|
|
1403
1403
|
<slot
|
|
1404
1404
|
:dt="datatableItemsScope"
|
|
1405
|
-
:form="
|
|
1405
|
+
:form="useFormContext"
|
|
1406
1406
|
:index="dialogItemIndex"
|
|
1407
1407
|
:item="dialogItem"
|
|
1408
1408
|
name="top"
|
|
@@ -1411,7 +1411,7 @@ defineOptions({
|
|
|
1411
1411
|
<MRow col>
|
|
1412
1412
|
<slot
|
|
1413
1413
|
:dt="datatableItemsScope"
|
|
1414
|
-
:form="
|
|
1414
|
+
:form="useFormContext"
|
|
1415
1415
|
:index="dialogItemIndex"
|
|
1416
1416
|
:item="dialogItem"
|
|
1417
1417
|
name="title"
|
|
@@ -1444,7 +1444,7 @@ defineOptions({
|
|
|
1444
1444
|
</slot>
|
|
1445
1445
|
<slot
|
|
1446
1446
|
:dt="datatableItemsScope"
|
|
1447
|
-
:form="
|
|
1447
|
+
:form="useFormContext"
|
|
1448
1448
|
:index="dialogItemIndex"
|
|
1449
1449
|
:item="dialogItem"
|
|
1450
1450
|
name="top-search"
|
|
@@ -1543,7 +1543,7 @@ defineOptions({
|
|
|
1543
1543
|
</MInput>
|
|
1544
1544
|
<slot
|
|
1545
1545
|
:dt="datatableItemsScope"
|
|
1546
|
-
:form="
|
|
1546
|
+
:form="useFormContext"
|
|
1547
1547
|
:index="dialogItemIndex"
|
|
1548
1548
|
:item="dialogItem"
|
|
1549
1549
|
name="bottom-search"
|
|
@@ -1708,7 +1708,7 @@ defineOptions({
|
|
|
1708
1708
|
<slot
|
|
1709
1709
|
:dt="datatableItemsScope"
|
|
1710
1710
|
:filter="tableOptions.tempFilter"
|
|
1711
|
-
:form="
|
|
1711
|
+
:form="useFormContext"
|
|
1712
1712
|
:index="dialogItemIndex"
|
|
1713
1713
|
:item="dialogItem"
|
|
1714
1714
|
name="filter"
|
|
@@ -1892,7 +1892,7 @@ defineOptions({
|
|
|
1892
1892
|
>
|
|
1893
1893
|
<slot
|
|
1894
1894
|
:dt="datatableItemsScope"
|
|
1895
|
-
:form="
|
|
1895
|
+
:form="useFormContext"
|
|
1896
1896
|
:index="dialogItemIndex"
|
|
1897
1897
|
:item="dialogItem"
|
|
1898
1898
|
name="selection"
|
|
@@ -1916,7 +1916,7 @@ defineOptions({
|
|
|
1916
1916
|
>
|
|
1917
1917
|
<slot
|
|
1918
1918
|
:dt="datatableItemsScope"
|
|
1919
|
-
:form="
|
|
1919
|
+
:form="useFormContext"
|
|
1920
1920
|
:index="dialogItemIndex"
|
|
1921
1921
|
:item="dialogItem"
|
|
1922
1922
|
:name="`body-cell-${controlKey}`"
|
|
@@ -2010,7 +2010,7 @@ defineOptions({
|
|
|
2010
2010
|
</q-table>
|
|
2011
2011
|
<slot
|
|
2012
2012
|
:dt="datatableItemsScope"
|
|
2013
|
-
:form="
|
|
2013
|
+
:form="useFormContext"
|
|
2014
2014
|
:index="dialogItemIndex"
|
|
2015
2015
|
:item="dialogItem"
|
|
2016
2016
|
name="default"
|
|
@@ -2047,7 +2047,7 @@ defineOptions({
|
|
|
2047
2047
|
>
|
|
2048
2048
|
<slot
|
|
2049
2049
|
:dt="datatableItemsScope"
|
|
2050
|
-
:form="
|
|
2050
|
+
:form="useFormContext"
|
|
2051
2051
|
:index="dialogItemIndex"
|
|
2052
2052
|
:item="dialogItem"
|
|
2053
2053
|
name="show"
|
|
@@ -2084,14 +2084,14 @@ defineOptions({
|
|
|
2084
2084
|
<q-toolbar :class="{'q-pa-none': $q.screen.lt.md}">
|
|
2085
2085
|
<slot
|
|
2086
2086
|
:dt="datatableItemsScope"
|
|
2087
|
-
:form="
|
|
2087
|
+
:form="useFormContext"
|
|
2088
2088
|
:index="dialogItemIndex"
|
|
2089
2089
|
:item="dialogItem"
|
|
2090
2090
|
name="form-title-left"
|
|
2091
2091
|
/>
|
|
2092
2092
|
<slot
|
|
2093
2093
|
:dt="datatableItemsScope"
|
|
2094
|
-
:form="
|
|
2094
|
+
:form="useFormContext"
|
|
2095
2095
|
:index="dialogItemIndex"
|
|
2096
2096
|
:item="dialogItem"
|
|
2097
2097
|
name="form-title"
|
|
@@ -2117,7 +2117,7 @@ defineOptions({
|
|
|
2117
2117
|
</slot>
|
|
2118
2118
|
<slot
|
|
2119
2119
|
:dt="datatableItemsScope"
|
|
2120
|
-
:form="
|
|
2120
|
+
:form="useFormContext"
|
|
2121
2121
|
:index="dialogItemIndex"
|
|
2122
2122
|
:item="dialogItem"
|
|
2123
2123
|
name="form-title-right"
|
|
@@ -2154,7 +2154,7 @@ defineOptions({
|
|
|
2154
2154
|
<slot
|
|
2155
2155
|
v-else
|
|
2156
2156
|
:dt="datatableItemsScope"
|
|
2157
|
-
:form="
|
|
2157
|
+
:form="useFormContext"
|
|
2158
2158
|
:index="dialogItemIndex"
|
|
2159
2159
|
:item="dialogItem"
|
|
2160
2160
|
name="form"
|
|
@@ -2167,7 +2167,7 @@ defineOptions({
|
|
|
2167
2167
|
>
|
|
2168
2168
|
<slot
|
|
2169
2169
|
:dt="datatableItemsScope"
|
|
2170
|
-
:form="
|
|
2170
|
+
:form="useFormContext"
|
|
2171
2171
|
:index="dialogItemIndex"
|
|
2172
2172
|
:item="dialogItem"
|
|
2173
2173
|
name="form-actions"
|
|
@@ -15,7 +15,7 @@ import { useTemplateRef } from 'vue'
|
|
|
15
15
|
import MInput from './MInput.vue'
|
|
16
16
|
import { useMyth } from '../../composable'
|
|
17
17
|
|
|
18
|
-
const { props: pluginOptions } = useMyth()
|
|
18
|
+
const { props: pluginOptions, mobileRule: mobile } = useMyth()
|
|
19
19
|
const modelValue = defineModel<Props['modelValue']>({ required: !1, default: undefined })
|
|
20
20
|
const input = useTemplateRef<InstanceType<typeof MInput>>('input')
|
|
21
21
|
defineExpose<{ input: typeof input }>({ input })
|
|
@@ -29,8 +29,7 @@ defineOptions({
|
|
|
29
29
|
<MInput
|
|
30
30
|
ref="input"
|
|
31
31
|
v-model="modelValue"
|
|
32
|
-
|
|
33
|
-
v-bind="{...pluginOptions.mobile as any,...$attrs}"
|
|
32
|
+
v-bind="{ type: 'tel', mobile, maxlength:mobile === !0 ? 10 : (mobile ?? 10), ...pluginOptions.mobile as any, ...$attrs }"
|
|
34
33
|
>
|
|
35
34
|
<template
|
|
36
35
|
v-for="(_,slot) in $slots as Readonly<MInputSlots>"
|
|
@@ -108,7 +108,10 @@ const onBeforeHide = () => {
|
|
|
108
108
|
dateRef.value = null
|
|
109
109
|
}
|
|
110
110
|
const saveDialog = () => {
|
|
111
|
-
let newVal: any = dateRef.value
|
|
111
|
+
let newVal: any = dateRef.value ?? null
|
|
112
|
+
if (!newVal) {
|
|
113
|
+
return
|
|
114
|
+
}
|
|
112
115
|
if (typeof newVal === 'object' && isDate.value) {
|
|
113
116
|
const values: any[] = Object.values(newVal)
|
|
114
117
|
for (const aKey in values) {
|
|
@@ -208,6 +211,7 @@ defineOptions({
|
|
|
208
211
|
<q-btn
|
|
209
212
|
v-if="!disable && !readonly && !viewMode"
|
|
210
213
|
:icon="isDate ? 'ion-ios-calendar' : 'ion-ios-clock'"
|
|
214
|
+
:color="!!errorMessage ? 'negative' : undefined"
|
|
211
215
|
flat
|
|
212
216
|
round
|
|
213
217
|
v-bind="{...pluginOptions?.pickerBtn, ...btnProps}"
|
|
@@ -64,6 +64,9 @@ export const useBindInput = <P extends G = G> (Props: MaybeRefOrGetter<P>, key:
|
|
|
64
64
|
if (typeof val === 'string' && val?.length > 0) {
|
|
65
65
|
return val
|
|
66
66
|
}
|
|
67
|
+
if (val === !0) {
|
|
68
|
+
return 'choose'
|
|
69
|
+
}
|
|
67
70
|
return 'enter'
|
|
68
71
|
})
|
|
69
72
|
if (props.placeholder === undefined) {
|
package/src/style/main.sass
CHANGED
|
@@ -678,7 +678,7 @@ export interface MHiddenSlots {
|
|
|
678
678
|
default: () => VNode[];
|
|
679
679
|
}
|
|
680
680
|
|
|
681
|
-
export type MFormScope = FormContext<Record<string, any>>;
|
|
681
|
+
export type MFormScope = FormContext<Record<string, any>, Record<string, any>>;
|
|
682
682
|
|
|
683
683
|
export interface MFormProps {
|
|
684
684
|
/**
|
|
@@ -1208,6 +1208,7 @@ declare module '@vue/runtime-core' {
|
|
|
1208
1208
|
MForm: GlobalComponentConstructor<MFormProps, MFormSlots>;
|
|
1209
1209
|
MHidden: GlobalComponentConstructor<MHiddenProps, MHiddenSlots>;
|
|
1210
1210
|
MHiddenInput: GlobalComponentConstructor<MHiddenInputProps, MHiddenInputSlots>;
|
|
1211
|
+
MInput: GlobalComponentConstructor<MInputProps, MInputSlots>;
|
|
1211
1212
|
MInputFieldControl: GlobalComponentConstructor<MInputFieldControlProps, MInputFieldControlSlots>;
|
|
1212
1213
|
MInputLabel: GlobalComponentConstructor<MInputLabelProps, MInputLabelSlots>;
|
|
1213
1214
|
MMobile: GlobalComponentConstructor<MInputProps, MInputSlots>;
|
package/src/types/myth-api.ts
CHANGED
package/src/utils/createMyth.ts
CHANGED
|
@@ -11,21 +11,26 @@ export const createMyth = (options: InstallOptions) => {
|
|
|
11
11
|
services: {},
|
|
12
12
|
axios: {} as AxiosInstance
|
|
13
13
|
},
|
|
14
|
-
props: {},
|
|
15
|
-
rules: [],
|
|
16
14
|
theme: {
|
|
17
15
|
size: 'md',
|
|
18
16
|
rounded: !0,
|
|
19
17
|
shadow: 2,
|
|
20
18
|
fluid: !0,
|
|
21
19
|
buttons: {},
|
|
22
|
-
inputs: {
|
|
20
|
+
inputs: {
|
|
21
|
+
hideBottomSpace: !0,
|
|
22
|
+
noErrorIcon: !0,
|
|
23
|
+
clearIcon: 'clear'
|
|
24
|
+
},
|
|
23
25
|
buttonLoading: {
|
|
24
26
|
type: 'spinner',
|
|
25
27
|
color: undefined,
|
|
26
28
|
size: undefined
|
|
27
29
|
} as MythApi['theme']['buttonLoading']
|
|
28
|
-
}
|
|
30
|
+
},
|
|
31
|
+
props: {},
|
|
32
|
+
rules: [],
|
|
33
|
+
mobileRule: !0
|
|
29
34
|
} as MythApi
|
|
30
35
|
const opts = reactive<MythApi>(extend<MythApi>(!0, { ...defaultOptions }, options))
|
|
31
36
|
const functions = {
|