@bagelink/vue 0.0.400 → 0.0.402
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/dist/components/BglVideo.vue.d.ts.map +1 -1
- package/dist/components/ModalConfirm.vue.d.ts +24 -0
- package/dist/components/ModalConfirm.vue.d.ts.map +1 -0
- package/dist/components/ModalForm.vue.d.ts +10 -6
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RichText.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +145 -91
- package/dist/index.mjs +145 -91
- package/dist/plugins/modal.d.ts +14 -2
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +69 -26
- package/package.json +1 -1
- package/src/components/BglVideo.vue +8 -4
- package/src/components/ModalConfirm.vue +26 -0
- package/src/components/ModalForm.vue +15 -12
- package/src/components/form/inputs/RichText.vue +59 -33
- package/src/components/form/inputs/SelectInput.vue +5 -4
- package/src/components/index.ts +1 -0
- package/src/plugins/modal.ts +26 -4
- package/src/styles/layout.css +9 -0
- package/src/styles/mobilLayout.css +11 -0
package/src/plugins/modal.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from 'vue';
|
|
4
4
|
import type { Plugin } from 'vue';
|
|
5
5
|
import type { BglFormSchemaT, BtnOptions } from '@bagelink/vue';
|
|
6
|
-
import { Modal, ModalForm } from '@bagelink/vue';
|
|
6
|
+
import { Modal, ModalForm, ModalConfirm } from '@bagelink/vue';
|
|
7
7
|
|
|
8
8
|
export interface ModalOptions {
|
|
9
9
|
title?: string;
|
|
@@ -29,10 +29,20 @@ export interface ModalFormOptions {
|
|
|
29
29
|
'onUpdate:modelValue'?: (val: any) => void;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export type ModalConfirmOptions = {
|
|
33
|
+
title?: string;
|
|
34
|
+
message?: string;
|
|
35
|
+
resolve: (val: boolean) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type ModalType = 'modal' | 'modalForm' | 'confirm'
|
|
39
|
+
|
|
40
|
+
type ConfirmModalUserOptions = string | { title: string, message: string }
|
|
41
|
+
|
|
32
42
|
export interface ModalComponentProps {
|
|
33
43
|
componentSlots: Record<string, any>,
|
|
34
|
-
modalType:
|
|
35
|
-
modalOptions: ModalOptions | ModalFormOptions
|
|
44
|
+
modalType: ModalType,
|
|
45
|
+
modalOptions: ModalOptions | ModalFormOptions | ModalConfirmOptions
|
|
36
46
|
}
|
|
37
47
|
export interface ModalFormComponentProps {
|
|
38
48
|
componentSlots: Record<string, any>,
|
|
@@ -43,6 +53,7 @@ export interface ModalApi {
|
|
|
43
53
|
showModal: (options: ModalOptions, slots?: Record<string, any>) => void;
|
|
44
54
|
showModalForm: (options: ModalFormOptions, slots?: Record<string, any>) => ModalFormComponentProps | undefined;
|
|
45
55
|
hideModal: (index?: number) => void;
|
|
56
|
+
confirm: (options: ConfirmModalUserOptions) => Promise<boolean>;
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
export const ModalSymbol: InjectionKey<ModalApi> = Symbol('modal');
|
|
@@ -61,8 +72,17 @@ export const ModalPlugin: Plugin = {
|
|
|
61
72
|
modalStack.splice(index, 1);
|
|
62
73
|
};
|
|
63
74
|
|
|
75
|
+
const modalConfirm = (options: ConfirmModalUserOptions) => new Promise<boolean>((resolve) => {
|
|
76
|
+
if (typeof options === 'string') options = { title: options, message: '' };
|
|
77
|
+
modalStack.push({
|
|
78
|
+
modalOptions: { ...options, resolve },
|
|
79
|
+
modalType: 'confirm',
|
|
80
|
+
componentSlots: {},
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
64
84
|
const showModal = (
|
|
65
|
-
modalType:
|
|
85
|
+
modalType: ModalType,
|
|
66
86
|
options: ModalOptions | ModalFormOptions,
|
|
67
87
|
slots: Record<string, any> = {},
|
|
68
88
|
) => {
|
|
@@ -78,6 +98,7 @@ export const ModalPlugin: Plugin = {
|
|
|
78
98
|
app.provide(ModalSymbol, {
|
|
79
99
|
showModal: (options: ModalOptions, slots?: Record<string, any>) => showModal('modal', options, slots),
|
|
80
100
|
showModalForm: (options: ModalFormOptions, slots?: Record<string, any>) => showModal('modalForm', options, slots) as ModalFormComponentProps,
|
|
101
|
+
confirm: (userOptions: ConfirmModalUserOptions) => modalConfirm(userOptions),
|
|
81
102
|
hideModal: (index = modalStack.length - 1) => hideModal(index),
|
|
82
103
|
// modalOptions,
|
|
83
104
|
});
|
|
@@ -88,6 +109,7 @@ export const ModalPlugin: Plugin = {
|
|
|
88
109
|
return modalStack.map((modal, index) => {
|
|
89
110
|
const props = { ...modal.modalOptions, visible: true, 'onUpdate:visible': () => hideModal(index) };
|
|
90
111
|
if (modal.modalType === 'modalForm') return h(ModalForm, props as ModalFormOptions, modal.componentSlots);
|
|
112
|
+
if (modal.modalType === 'confirm') return h(ModalConfirm, props as any, {});
|
|
91
113
|
return h(Modal, props, modal.componentSlots);
|
|
92
114
|
});
|
|
93
115
|
},
|
package/src/styles/layout.css
CHANGED