@bagelink/vue 0.0.398 → 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 +2802 -108
- package/dist/index.mjs +2802 -108
- package/dist/plugins/modal.d.ts +14 -2
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +121 -21
- package/package.json +5 -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 +133 -19
- 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
|
@@ -120,12 +120,14 @@ const selectedLabel = $computed(() => {
|
|
|
120
120
|
const emit = defineEmits(['update:modelValue']);
|
|
121
121
|
|
|
122
122
|
const getLabel = (option: Option) => {
|
|
123
|
+
if (!option) return '';
|
|
123
124
|
if (typeof option === 'string') return option;
|
|
124
125
|
if (typeof option === 'number') return `${option}`;
|
|
125
126
|
return option.label;
|
|
126
127
|
};
|
|
127
128
|
|
|
128
129
|
const getValue = (option: Option) => {
|
|
130
|
+
if (!option) return '';
|
|
129
131
|
if (typeof option === 'string') return option;
|
|
130
132
|
if (typeof option === 'number') return option;
|
|
131
133
|
return option.value;
|
|
@@ -182,7 +184,6 @@ function compareArrays(arr1: Option[], arr2: Option[]) {
|
|
|
182
184
|
watch(
|
|
183
185
|
() => props.modelValue,
|
|
184
186
|
(newVal: Option | Option[]) => {
|
|
185
|
-
if (!newVal) return;
|
|
186
187
|
if (!props.multiselect) {
|
|
187
188
|
const newOption =
|
|
188
189
|
props.options.find((o) => getValue(o) === newVal) || newVal;
|
|
@@ -202,7 +203,6 @@ watch(
|
|
|
202
203
|
watch(
|
|
203
204
|
() => props.options,
|
|
204
205
|
() => {
|
|
205
|
-
const original = JSON.stringify(props.options.map(getValue));
|
|
206
206
|
[...selectedItems].forEach((option, i) => {
|
|
207
207
|
const exists = props.options.find(
|
|
208
208
|
(o) => getValue(o) === getValue(option)
|
|
@@ -210,8 +210,9 @@ watch(
|
|
|
210
210
|
if (!exists) selectedItems.splice(i, 1);
|
|
211
211
|
else selectedItems.splice(i, 1, exists);
|
|
212
212
|
});
|
|
213
|
-
const
|
|
214
|
-
|
|
213
|
+
// const original = JSON.stringify(props.options.map(getValue));
|
|
214
|
+
// const newSelection = JSON.stringify(selectedItems.map(getValue));
|
|
215
|
+
// if (original !== newSelection) emitUpdate();
|
|
215
216
|
},
|
|
216
217
|
{ deep: true }
|
|
217
218
|
);
|
package/src/components/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { default as Alert } from './Alert.vue';
|
|
|
20
20
|
export { default as Badge } from './Badge.vue';
|
|
21
21
|
export { default as BglVideo } from './BglVideo.vue';
|
|
22
22
|
export { default as Carousel } from './Carousel.vue';
|
|
23
|
+
export { default as ModalConfirm } from './ModalConfirm.vue';
|
|
23
24
|
|
|
24
25
|
export * from './form';
|
|
25
26
|
export * from './dashboard';
|
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