@teammodlr/ui-kit 2.3.16 → 2.3.18
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/lib/components/confirm/Confirm.vue.d.ts +11 -0
- package/lib/components/confirm/props.d.ts +4 -0
- package/lib/components/dialogprovider/types.d.ts +3 -0
- package/lib/index.cjs.js +5 -5
- package/lib/index.es.js +743 -726
- package/package.json +1 -1
- package/src/components/confirm/Confirm.vue +18 -9
- package/src/components/confirm/props.ts +4 -0
- package/src/components/dialogprovider/DialogProvider.vue +18 -1
- package/src/components/dialogprovider/types.ts +3 -0
package/package.json
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
<template #footer>
|
|
13
13
|
<div style="display: flex; flex-grow: 1; justify-content: end">
|
|
14
|
-
<MButton :variant="okVariant" @click="handleOk">
|
|
14
|
+
<MButton ref="actionButton" :variant="okVariant" @click="handleOk">
|
|
15
15
|
{{ okText ?? 'Okay' }}
|
|
16
16
|
</MButton>
|
|
17
|
-
<MButton style="margin-left: 8px" @click="handleCancel">
|
|
17
|
+
<MButton ref="cancelButton" style="margin-left: 8px" @click="handleCancel">
|
|
18
18
|
{{ cancelText ?? 'Cancel' }}
|
|
19
19
|
</MButton>
|
|
20
20
|
</div>
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script lang="ts">
|
|
27
|
-
import { defineComponent, onMounted, ref } from 'vue';
|
|
28
|
-
import { useZIndex } from '../../composables/useZIndex';
|
|
27
|
+
import { defineComponent, onMounted, ref, nextTick } from 'vue';
|
|
29
28
|
import { confirmProps } from './props';
|
|
30
29
|
import MModal from '../modal/Modal.vue';
|
|
31
30
|
import MButton from '../button/Button.vue';
|
|
@@ -33,10 +32,10 @@ import MButton from '../button/Button.vue';
|
|
|
33
32
|
export default defineComponent({
|
|
34
33
|
name: 'Confirm',
|
|
35
34
|
props: confirmProps,
|
|
36
|
-
setup(props
|
|
35
|
+
setup(props) {
|
|
37
36
|
const modal = ref();
|
|
38
|
-
|
|
39
|
-
const
|
|
37
|
+
const actionButton = ref();
|
|
38
|
+
const cancelButton = ref();
|
|
40
39
|
|
|
41
40
|
async function handleCancel(event: MouseEvent) {
|
|
42
41
|
modal.value?.close();
|
|
@@ -48,14 +47,24 @@ export default defineComponent({
|
|
|
48
47
|
async function handleOk(event: MouseEvent) {
|
|
49
48
|
modal.value?.close();
|
|
50
49
|
if (props.onOk) {
|
|
51
|
-
props.onOk(event);
|
|
50
|
+
await props.onOk(event);
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
onMounted(() => {
|
|
53
|
+
onMounted(async () => {
|
|
55
54
|
modal.value?.open(null);
|
|
55
|
+
await nextTick();
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
if (props.focusAction) {
|
|
58
|
+
actionButton.value.$el.focus();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
cancelButton.value.$el.focus();
|
|
62
|
+
}, 100);
|
|
56
63
|
});
|
|
57
64
|
return {
|
|
58
65
|
modal,
|
|
66
|
+
actionButton,
|
|
67
|
+
cancelButton,
|
|
59
68
|
handleOk,
|
|
60
69
|
handleCancel
|
|
61
70
|
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</template>
|
|
14
14
|
</template>
|
|
15
15
|
<script lang="ts">
|
|
16
|
-
import { defineComponent, reactive, provide, ref, nextTick } from 'vue';
|
|
16
|
+
import { defineComponent, reactive, provide, ref, nextTick, computed } from 'vue';
|
|
17
17
|
import type { DialogApiInjection, DialogOptions, DialogReactive } from './types';
|
|
18
18
|
import MDialog from '../dialog/Dialog.vue';
|
|
19
19
|
import MRenderer from '../renderer/renderer';
|
|
@@ -103,9 +103,26 @@ export default defineComponent({
|
|
|
103
103
|
remove(key);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
const hasOpenDialog = computed(() => {
|
|
107
|
+
return Object.values(dialogMap).some(dialog => dialog.options.open === true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const openDialogCount = computed(() => {
|
|
111
|
+
return Object.values(dialogMap).filter(dialog => dialog.options.open === true).length;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const openDialogKeys = computed(() => {
|
|
115
|
+
return Object.values(dialogMap)
|
|
116
|
+
.filter(dialog => dialog.options.open === true)
|
|
117
|
+
.map(dialog => dialog.key);
|
|
118
|
+
});
|
|
119
|
+
|
|
106
120
|
const api: DialogApiInjection = {
|
|
107
121
|
create,
|
|
108
122
|
remove,
|
|
123
|
+
hasOpenDialog: () => hasOpenDialog.value,
|
|
124
|
+
openDialogCount: () => openDialogCount.value,
|
|
125
|
+
openDialogKeys: () => openDialogKeys.value
|
|
109
126
|
};
|
|
110
127
|
|
|
111
128
|
provide('m-dialog', api);
|
|
@@ -23,4 +23,7 @@ export interface DialogReactive {
|
|
|
23
23
|
export interface DialogApiInjection {
|
|
24
24
|
create: (key: string, options?: DialogOptions) => DialogReactive;
|
|
25
25
|
remove: (key: string) => void;
|
|
26
|
+
hasOpenDialog: () => boolean;
|
|
27
|
+
openDialogCount: () => number;
|
|
28
|
+
openDialogKeys: () => string[];
|
|
26
29
|
}
|