@g1cloud/open-bluesea-core 1.0.0-alpha.7 → 1.0.0-alpha.8
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/index.d.ts +5 -5
- package/dist/open-bluesea-core.css +1 -0
- package/dist/open-bluesea-core.es.js +108 -106
- package/dist/open-bluesea-core.umd.js +107 -105
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -703,9 +703,9 @@ export declare const BSDateInput: DefineComponent<__VLS_Props_11, {}, {}, {}, {}
|
|
|
703
703
|
}, string, PublicProps, Readonly<__VLS_Props_11> & Readonly<{
|
|
704
704
|
"onUpdate:modelValue"?: ((value?: string | undefined) => any) | undefined;
|
|
705
705
|
}>, {
|
|
706
|
+
width: string;
|
|
706
707
|
tabindex: number;
|
|
707
708
|
resolution: DateResolution;
|
|
708
|
-
width: string;
|
|
709
709
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
710
710
|
root: HTMLDivElement;
|
|
711
711
|
field: HTMLInputElement;
|
|
@@ -729,9 +729,9 @@ export declare const BSDateRange: DefineComponent<__VLS_Props_13, {}, {}, {}, {}
|
|
|
729
729
|
"onUpdate:fromValue"?: ((value?: string | undefined) => any) | undefined;
|
|
730
730
|
"onUpdate:toValue"?: ((value?: string | undefined) => any) | undefined;
|
|
731
731
|
}>, {
|
|
732
|
+
width: string;
|
|
732
733
|
tabindex: number;
|
|
733
734
|
resolution: DateResolution;
|
|
734
|
-
width: string;
|
|
735
735
|
validateDateOrder: boolean;
|
|
736
736
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
737
737
|
root: HTMLDivElement;
|
|
@@ -832,8 +832,8 @@ export declare const BSNumberInput: DefineComponent<__VLS_Props_8, {}, {}, {}, {
|
|
|
832
832
|
}, string, PublicProps, Readonly<__VLS_Props_8> & Readonly<{
|
|
833
833
|
"onUpdate:modelValue"?: ((value?: number | undefined) => any) | undefined;
|
|
834
834
|
}>, {
|
|
835
|
-
tabindex: number;
|
|
836
835
|
width: string;
|
|
836
|
+
tabindex: number;
|
|
837
837
|
format: boolean;
|
|
838
838
|
formatInViewMode: boolean;
|
|
839
839
|
formatOnBlur: boolean;
|
|
@@ -951,8 +951,8 @@ export declare const BSTextArea: DefineComponent<__VLS_Props_9, {}, {}, {}, {},
|
|
|
951
951
|
}, string, PublicProps, Readonly<__VLS_Props_9> & Readonly<{
|
|
952
952
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
953
953
|
}>, {
|
|
954
|
-
tabindex: number;
|
|
955
954
|
width: string;
|
|
955
|
+
tabindex: number;
|
|
956
956
|
trimValue: boolean;
|
|
957
957
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
958
958
|
field: HTMLTextAreaElement;
|
|
@@ -964,8 +964,8 @@ export declare const BSTextInput: DefineComponent<__VLS_Props_7, {}, {}, {}, {},
|
|
|
964
964
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
965
965
|
}>, {
|
|
966
966
|
name: string;
|
|
967
|
-
tabindex: number;
|
|
968
967
|
width: string;
|
|
968
|
+
tabindex: number;
|
|
969
969
|
inputType: "text" | "password";
|
|
970
970
|
trimValue: boolean;
|
|
971
971
|
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
@@ -1676,6 +1676,7 @@
|
|
|
1676
1676
|
.bs-date-range .input-area input {
|
|
1677
1677
|
width: calc(var(--spacing) * 16);
|
|
1678
1678
|
border-style: var(--tw-border-style);
|
|
1679
|
+
padding-inline: calc(var(--spacing) * 1.5);
|
|
1679
1680
|
padding-right: calc(var(--spacing) * 0);
|
|
1680
1681
|
--tw-outline-style: none;
|
|
1681
1682
|
color: var(--body-text);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, ref, markRaw, reactive, defineComponent, withDirectives, createBlock, openBlock, resolveDynamicComponent, normalizeClass, withCtx, createElementBlock, createCommentVNode, createElementVNode, toDisplayString, unref, computed, withModifiers, Fragment, renderList, onMounted, onBeforeUnmount, Teleport, createVNode, Transition, normalizeStyle, renderSlot, watch, nextTick, withKeys,
|
|
1
|
+
import { inject, ref, markRaw, provide, reactive, defineAsyncComponent, defineComponent, withDirectives, createBlock, openBlock, resolveDynamicComponent, normalizeClass, withCtx, createElementBlock, createCommentVNode, createElementVNode, toDisplayString, unref, computed, withModifiers, Fragment, renderList, onMounted, onBeforeUnmount, Teleport, createVNode, Transition, normalizeStyle, renderSlot, watch, nextTick, withKeys, shallowRef, useTemplateRef, mergeProps, isRef, toHandlers, vModelDynamic, vModelText, useSlots, vShow, TransitionGroup, resolveComponent } from "vue";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
const ContextMenuPluginKey = Symbol("BlueseaContextMenuPlugin");
|
|
4
4
|
class BSContextMenuPlugin {
|
|
@@ -40,6 +40,110 @@ const useContextMenuOptional = () => {
|
|
|
40
40
|
const createContextMenuPlugin = () => {
|
|
41
41
|
return new BSContextMenuPlugin();
|
|
42
42
|
};
|
|
43
|
+
const modalPluginKey = "BlueseaModalPlugin";
|
|
44
|
+
const modalHandleKey = "BlueseaModalHandle";
|
|
45
|
+
class ModalHandleImpl {
|
|
46
|
+
constructor(modal, modalId) {
|
|
47
|
+
this.modal = modal;
|
|
48
|
+
this.modalId = modalId;
|
|
49
|
+
}
|
|
50
|
+
maximized = false;
|
|
51
|
+
defaultStyleListener;
|
|
52
|
+
defaultPositionListener;
|
|
53
|
+
close() {
|
|
54
|
+
this.modal.closeModal(this.modalId);
|
|
55
|
+
}
|
|
56
|
+
setDefaultStyle(modalStyle) {
|
|
57
|
+
this.defaultStyleListener?.(modalStyle);
|
|
58
|
+
}
|
|
59
|
+
setDefaultPosition(modalPosition) {
|
|
60
|
+
this.defaultPositionListener?.(modalPosition);
|
|
61
|
+
}
|
|
62
|
+
setDefaultStyleListener(listener) {
|
|
63
|
+
this.defaultStyleListener = listener;
|
|
64
|
+
}
|
|
65
|
+
setDefaultPositionListener(listener) {
|
|
66
|
+
this.defaultPositionListener = listener;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class BSModal {
|
|
70
|
+
modalItems = reactive([]);
|
|
71
|
+
openModal(modalItem) {
|
|
72
|
+
const modalId = Math.random().toString(36);
|
|
73
|
+
const handle = new ModalHandleImpl(this, modalId);
|
|
74
|
+
const registered = {
|
|
75
|
+
modalId,
|
|
76
|
+
pageId: modalItem.pageId,
|
|
77
|
+
component: markRaw(modalItem.component),
|
|
78
|
+
style: modalItem.style,
|
|
79
|
+
position: modalItem.position,
|
|
80
|
+
bind: modalItem.bind,
|
|
81
|
+
on: modalItem.on,
|
|
82
|
+
slots: modalItem.slots,
|
|
83
|
+
modalHandle: handle
|
|
84
|
+
};
|
|
85
|
+
this.modalItems.push(registered);
|
|
86
|
+
return registered;
|
|
87
|
+
}
|
|
88
|
+
closeModal(modalItem) {
|
|
89
|
+
let index = -1;
|
|
90
|
+
if (typeof modalItem === "string") {
|
|
91
|
+
index = this.modalItems.findIndex((item) => item.modalId === modalItem);
|
|
92
|
+
} else {
|
|
93
|
+
index = this.modalItems.findIndex((item) => item === modalItem);
|
|
94
|
+
}
|
|
95
|
+
if (index >= 0) this.modalItems.splice(index, 1);
|
|
96
|
+
}
|
|
97
|
+
closeAllModals() {
|
|
98
|
+
this.modalItems.splice(0, this.modalItems.length);
|
|
99
|
+
}
|
|
100
|
+
openAlert(title, message, clickHandler) {
|
|
101
|
+
const option = {
|
|
102
|
+
component: defineAsyncComponent(() => import("./BSAlertModal-ZEIUM0ut.js")),
|
|
103
|
+
bind: {
|
|
104
|
+
title,
|
|
105
|
+
message
|
|
106
|
+
},
|
|
107
|
+
on: {
|
|
108
|
+
click: async () => await clickHandler?.()
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return this.openModal(option);
|
|
112
|
+
}
|
|
113
|
+
openYesNo(title, message, yesHandler, noHandler) {
|
|
114
|
+
const option = {
|
|
115
|
+
component: defineAsyncComponent(() => import("./BSYesNoModal-Cs6mgXcP.js")),
|
|
116
|
+
bind: {
|
|
117
|
+
title,
|
|
118
|
+
message
|
|
119
|
+
},
|
|
120
|
+
on: {
|
|
121
|
+
clickYes: async () => await yesHandler?.(),
|
|
122
|
+
clickNo: async () => await noHandler?.()
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return this.openModal(option);
|
|
126
|
+
}
|
|
127
|
+
install(app) {
|
|
128
|
+
app.provide(modalPluginKey, this);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const useModal = () => {
|
|
132
|
+
const modal = inject(modalPluginKey);
|
|
133
|
+
if (!modal) throw new Error("BSModal is not initialized.");
|
|
134
|
+
return modal;
|
|
135
|
+
};
|
|
136
|
+
const provideModalHandle = (modalHandle) => {
|
|
137
|
+
provide(modalHandleKey, modalHandle);
|
|
138
|
+
};
|
|
139
|
+
const useModalHandle = () => {
|
|
140
|
+
const modalHandle = inject(modalHandleKey);
|
|
141
|
+
if (!modalHandle) throw new Error("ModalHandle not found. Maybe not inside modal component.");
|
|
142
|
+
return modalHandle;
|
|
143
|
+
};
|
|
144
|
+
const createModalPlugin = () => {
|
|
145
|
+
return new BSModal();
|
|
146
|
+
};
|
|
43
147
|
class BlueseaConfig {
|
|
44
148
|
dateFormat = "YYYY-MM-DD HH:mm";
|
|
45
149
|
dateFormatDay = "YYYY-MM-DD";
|
|
@@ -78,8 +182,10 @@ const BlueseaPlugin = {
|
|
|
78
182
|
install(app, options) {
|
|
79
183
|
const config = new BlueseaConfig(options);
|
|
80
184
|
app.provide(BlueseaConfigKey, config);
|
|
81
|
-
const contextMenu =
|
|
185
|
+
const contextMenu = createContextMenuPlugin();
|
|
82
186
|
app.provide(ContextMenuPluginKey, contextMenu);
|
|
187
|
+
const modal = createModalPlugin();
|
|
188
|
+
app.use(modal);
|
|
83
189
|
}
|
|
84
190
|
};
|
|
85
191
|
const notificationEntries = reactive([]);
|
|
@@ -4352,110 +4458,6 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
4352
4458
|
};
|
|
4353
4459
|
}
|
|
4354
4460
|
});
|
|
4355
|
-
const modalPluginKey = "BlueseaModalPlugin";
|
|
4356
|
-
const modalHandleKey = "BlueseaModalHandle";
|
|
4357
|
-
class ModalHandleImpl {
|
|
4358
|
-
constructor(modal, modalId) {
|
|
4359
|
-
this.modal = modal;
|
|
4360
|
-
this.modalId = modalId;
|
|
4361
|
-
}
|
|
4362
|
-
maximized = false;
|
|
4363
|
-
defaultStyleListener;
|
|
4364
|
-
defaultPositionListener;
|
|
4365
|
-
close() {
|
|
4366
|
-
this.modal.closeModal(this.modalId);
|
|
4367
|
-
}
|
|
4368
|
-
setDefaultStyle(modalStyle) {
|
|
4369
|
-
this.defaultStyleListener?.(modalStyle);
|
|
4370
|
-
}
|
|
4371
|
-
setDefaultPosition(modalPosition) {
|
|
4372
|
-
this.defaultPositionListener?.(modalPosition);
|
|
4373
|
-
}
|
|
4374
|
-
setDefaultStyleListener(listener) {
|
|
4375
|
-
this.defaultStyleListener = listener;
|
|
4376
|
-
}
|
|
4377
|
-
setDefaultPositionListener(listener) {
|
|
4378
|
-
this.defaultPositionListener = listener;
|
|
4379
|
-
}
|
|
4380
|
-
}
|
|
4381
|
-
class BSModal {
|
|
4382
|
-
modalItems = reactive([]);
|
|
4383
|
-
openModal(modalItem) {
|
|
4384
|
-
const modalId = Math.random().toString(36);
|
|
4385
|
-
const handle = new ModalHandleImpl(this, modalId);
|
|
4386
|
-
const registered = {
|
|
4387
|
-
modalId,
|
|
4388
|
-
pageId: modalItem.pageId,
|
|
4389
|
-
component: markRaw(modalItem.component),
|
|
4390
|
-
style: modalItem.style,
|
|
4391
|
-
position: modalItem.position,
|
|
4392
|
-
bind: modalItem.bind,
|
|
4393
|
-
on: modalItem.on,
|
|
4394
|
-
slots: modalItem.slots,
|
|
4395
|
-
modalHandle: handle
|
|
4396
|
-
};
|
|
4397
|
-
this.modalItems.push(registered);
|
|
4398
|
-
return registered;
|
|
4399
|
-
}
|
|
4400
|
-
closeModal(modalItem) {
|
|
4401
|
-
let index = -1;
|
|
4402
|
-
if (typeof modalItem === "string") {
|
|
4403
|
-
index = this.modalItems.findIndex((item) => item.modalId === modalItem);
|
|
4404
|
-
} else {
|
|
4405
|
-
index = this.modalItems.findIndex((item) => item === modalItem);
|
|
4406
|
-
}
|
|
4407
|
-
if (index >= 0) this.modalItems.splice(index, 1);
|
|
4408
|
-
}
|
|
4409
|
-
closeAllModals() {
|
|
4410
|
-
this.modalItems.splice(0, this.modalItems.length);
|
|
4411
|
-
}
|
|
4412
|
-
openAlert(title, message, clickHandler) {
|
|
4413
|
-
const option = {
|
|
4414
|
-
component: defineAsyncComponent(() => import("./BSAlertModal-ZEIUM0ut.js")),
|
|
4415
|
-
bind: {
|
|
4416
|
-
title,
|
|
4417
|
-
message
|
|
4418
|
-
},
|
|
4419
|
-
on: {
|
|
4420
|
-
click: async () => await clickHandler?.()
|
|
4421
|
-
}
|
|
4422
|
-
};
|
|
4423
|
-
return this.openModal(option);
|
|
4424
|
-
}
|
|
4425
|
-
openYesNo(title, message, yesHandler, noHandler) {
|
|
4426
|
-
const option = {
|
|
4427
|
-
component: defineAsyncComponent(() => import("./BSYesNoModal-Cs6mgXcP.js")),
|
|
4428
|
-
bind: {
|
|
4429
|
-
title,
|
|
4430
|
-
message
|
|
4431
|
-
},
|
|
4432
|
-
on: {
|
|
4433
|
-
clickYes: async () => await yesHandler?.(),
|
|
4434
|
-
clickNo: async () => await noHandler?.()
|
|
4435
|
-
}
|
|
4436
|
-
};
|
|
4437
|
-
return this.openModal(option);
|
|
4438
|
-
}
|
|
4439
|
-
install(app) {
|
|
4440
|
-
app.provide(modalPluginKey, this);
|
|
4441
|
-
}
|
|
4442
|
-
}
|
|
4443
|
-
const useModal = () => {
|
|
4444
|
-
const modal = inject(modalPluginKey);
|
|
4445
|
-
if (!modal) throw new Error("BSModal is not initialized.");
|
|
4446
|
-
return modal;
|
|
4447
|
-
};
|
|
4448
|
-
const provideModalHandle = (modalHandle) => {
|
|
4449
|
-
provide(modalHandleKey, modalHandle);
|
|
4450
|
-
};
|
|
4451
|
-
const useModalHandle = () => {
|
|
4452
|
-
const modalHandle = inject(modalHandleKey);
|
|
4453
|
-
if (!modalHandle) throw new Error("ModalHandle not found. Maybe not inside modal component.");
|
|
4454
|
-
return modalHandle;
|
|
4455
|
-
};
|
|
4456
|
-
const createModalPlugin = () => {
|
|
4457
|
-
return new BSModal();
|
|
4458
|
-
};
|
|
4459
4461
|
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
4460
4462
|
__name: "BSModalWrapper",
|
|
4461
4463
|
props: {
|
|
@@ -42,6 +42,110 @@
|
|
|
42
42
|
const createContextMenuPlugin = () => {
|
|
43
43
|
return new BSContextMenuPlugin();
|
|
44
44
|
};
|
|
45
|
+
const modalPluginKey = "BlueseaModalPlugin";
|
|
46
|
+
const modalHandleKey = "BlueseaModalHandle";
|
|
47
|
+
class ModalHandleImpl {
|
|
48
|
+
constructor(modal, modalId) {
|
|
49
|
+
this.modal = modal;
|
|
50
|
+
this.modalId = modalId;
|
|
51
|
+
}
|
|
52
|
+
maximized = false;
|
|
53
|
+
defaultStyleListener;
|
|
54
|
+
defaultPositionListener;
|
|
55
|
+
close() {
|
|
56
|
+
this.modal.closeModal(this.modalId);
|
|
57
|
+
}
|
|
58
|
+
setDefaultStyle(modalStyle) {
|
|
59
|
+
this.defaultStyleListener?.(modalStyle);
|
|
60
|
+
}
|
|
61
|
+
setDefaultPosition(modalPosition) {
|
|
62
|
+
this.defaultPositionListener?.(modalPosition);
|
|
63
|
+
}
|
|
64
|
+
setDefaultStyleListener(listener) {
|
|
65
|
+
this.defaultStyleListener = listener;
|
|
66
|
+
}
|
|
67
|
+
setDefaultPositionListener(listener) {
|
|
68
|
+
this.defaultPositionListener = listener;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
class BSModal {
|
|
72
|
+
modalItems = vue.reactive([]);
|
|
73
|
+
openModal(modalItem) {
|
|
74
|
+
const modalId = Math.random().toString(36);
|
|
75
|
+
const handle = new ModalHandleImpl(this, modalId);
|
|
76
|
+
const registered = {
|
|
77
|
+
modalId,
|
|
78
|
+
pageId: modalItem.pageId,
|
|
79
|
+
component: vue.markRaw(modalItem.component),
|
|
80
|
+
style: modalItem.style,
|
|
81
|
+
position: modalItem.position,
|
|
82
|
+
bind: modalItem.bind,
|
|
83
|
+
on: modalItem.on,
|
|
84
|
+
slots: modalItem.slots,
|
|
85
|
+
modalHandle: handle
|
|
86
|
+
};
|
|
87
|
+
this.modalItems.push(registered);
|
|
88
|
+
return registered;
|
|
89
|
+
}
|
|
90
|
+
closeModal(modalItem) {
|
|
91
|
+
let index = -1;
|
|
92
|
+
if (typeof modalItem === "string") {
|
|
93
|
+
index = this.modalItems.findIndex((item) => item.modalId === modalItem);
|
|
94
|
+
} else {
|
|
95
|
+
index = this.modalItems.findIndex((item) => item === modalItem);
|
|
96
|
+
}
|
|
97
|
+
if (index >= 0) this.modalItems.splice(index, 1);
|
|
98
|
+
}
|
|
99
|
+
closeAllModals() {
|
|
100
|
+
this.modalItems.splice(0, this.modalItems.length);
|
|
101
|
+
}
|
|
102
|
+
openAlert(title, message, clickHandler) {
|
|
103
|
+
const option = {
|
|
104
|
+
component: vue.defineAsyncComponent(() => Promise.resolve().then(() => BSAlertModal)),
|
|
105
|
+
bind: {
|
|
106
|
+
title,
|
|
107
|
+
message
|
|
108
|
+
},
|
|
109
|
+
on: {
|
|
110
|
+
click: async () => await clickHandler?.()
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return this.openModal(option);
|
|
114
|
+
}
|
|
115
|
+
openYesNo(title, message, yesHandler, noHandler) {
|
|
116
|
+
const option = {
|
|
117
|
+
component: vue.defineAsyncComponent(() => Promise.resolve().then(() => BSYesNoModal)),
|
|
118
|
+
bind: {
|
|
119
|
+
title,
|
|
120
|
+
message
|
|
121
|
+
},
|
|
122
|
+
on: {
|
|
123
|
+
clickYes: async () => await yesHandler?.(),
|
|
124
|
+
clickNo: async () => await noHandler?.()
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
return this.openModal(option);
|
|
128
|
+
}
|
|
129
|
+
install(app) {
|
|
130
|
+
app.provide(modalPluginKey, this);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const useModal = () => {
|
|
134
|
+
const modal = vue.inject(modalPluginKey);
|
|
135
|
+
if (!modal) throw new Error("BSModal is not initialized.");
|
|
136
|
+
return modal;
|
|
137
|
+
};
|
|
138
|
+
const provideModalHandle = (modalHandle) => {
|
|
139
|
+
vue.provide(modalHandleKey, modalHandle);
|
|
140
|
+
};
|
|
141
|
+
const useModalHandle = () => {
|
|
142
|
+
const modalHandle = vue.inject(modalHandleKey);
|
|
143
|
+
if (!modalHandle) throw new Error("ModalHandle not found. Maybe not inside modal component.");
|
|
144
|
+
return modalHandle;
|
|
145
|
+
};
|
|
146
|
+
const createModalPlugin = () => {
|
|
147
|
+
return new BSModal();
|
|
148
|
+
};
|
|
45
149
|
class BlueseaConfig {
|
|
46
150
|
dateFormat = "YYYY-MM-DD HH:mm";
|
|
47
151
|
dateFormatDay = "YYYY-MM-DD";
|
|
@@ -80,8 +184,10 @@
|
|
|
80
184
|
install(app, options) {
|
|
81
185
|
const config = new BlueseaConfig(options);
|
|
82
186
|
app.provide(BlueseaConfigKey, config);
|
|
83
|
-
const contextMenu =
|
|
187
|
+
const contextMenu = createContextMenuPlugin();
|
|
84
188
|
app.provide(ContextMenuPluginKey, contextMenu);
|
|
189
|
+
const modal = createModalPlugin();
|
|
190
|
+
app.use(modal);
|
|
85
191
|
}
|
|
86
192
|
};
|
|
87
193
|
const notificationEntries = vue.reactive([]);
|
|
@@ -4354,110 +4460,6 @@
|
|
|
4354
4460
|
};
|
|
4355
4461
|
}
|
|
4356
4462
|
});
|
|
4357
|
-
const modalPluginKey = "BlueseaModalPlugin";
|
|
4358
|
-
const modalHandleKey = "BlueseaModalHandle";
|
|
4359
|
-
class ModalHandleImpl {
|
|
4360
|
-
constructor(modal, modalId) {
|
|
4361
|
-
this.modal = modal;
|
|
4362
|
-
this.modalId = modalId;
|
|
4363
|
-
}
|
|
4364
|
-
maximized = false;
|
|
4365
|
-
defaultStyleListener;
|
|
4366
|
-
defaultPositionListener;
|
|
4367
|
-
close() {
|
|
4368
|
-
this.modal.closeModal(this.modalId);
|
|
4369
|
-
}
|
|
4370
|
-
setDefaultStyle(modalStyle) {
|
|
4371
|
-
this.defaultStyleListener?.(modalStyle);
|
|
4372
|
-
}
|
|
4373
|
-
setDefaultPosition(modalPosition) {
|
|
4374
|
-
this.defaultPositionListener?.(modalPosition);
|
|
4375
|
-
}
|
|
4376
|
-
setDefaultStyleListener(listener) {
|
|
4377
|
-
this.defaultStyleListener = listener;
|
|
4378
|
-
}
|
|
4379
|
-
setDefaultPositionListener(listener) {
|
|
4380
|
-
this.defaultPositionListener = listener;
|
|
4381
|
-
}
|
|
4382
|
-
}
|
|
4383
|
-
class BSModal {
|
|
4384
|
-
modalItems = vue.reactive([]);
|
|
4385
|
-
openModal(modalItem) {
|
|
4386
|
-
const modalId = Math.random().toString(36);
|
|
4387
|
-
const handle = new ModalHandleImpl(this, modalId);
|
|
4388
|
-
const registered = {
|
|
4389
|
-
modalId,
|
|
4390
|
-
pageId: modalItem.pageId,
|
|
4391
|
-
component: vue.markRaw(modalItem.component),
|
|
4392
|
-
style: modalItem.style,
|
|
4393
|
-
position: modalItem.position,
|
|
4394
|
-
bind: modalItem.bind,
|
|
4395
|
-
on: modalItem.on,
|
|
4396
|
-
slots: modalItem.slots,
|
|
4397
|
-
modalHandle: handle
|
|
4398
|
-
};
|
|
4399
|
-
this.modalItems.push(registered);
|
|
4400
|
-
return registered;
|
|
4401
|
-
}
|
|
4402
|
-
closeModal(modalItem) {
|
|
4403
|
-
let index = -1;
|
|
4404
|
-
if (typeof modalItem === "string") {
|
|
4405
|
-
index = this.modalItems.findIndex((item) => item.modalId === modalItem);
|
|
4406
|
-
} else {
|
|
4407
|
-
index = this.modalItems.findIndex((item) => item === modalItem);
|
|
4408
|
-
}
|
|
4409
|
-
if (index >= 0) this.modalItems.splice(index, 1);
|
|
4410
|
-
}
|
|
4411
|
-
closeAllModals() {
|
|
4412
|
-
this.modalItems.splice(0, this.modalItems.length);
|
|
4413
|
-
}
|
|
4414
|
-
openAlert(title, message, clickHandler) {
|
|
4415
|
-
const option = {
|
|
4416
|
-
component: vue.defineAsyncComponent(() => Promise.resolve().then(() => BSAlertModal)),
|
|
4417
|
-
bind: {
|
|
4418
|
-
title,
|
|
4419
|
-
message
|
|
4420
|
-
},
|
|
4421
|
-
on: {
|
|
4422
|
-
click: async () => await clickHandler?.()
|
|
4423
|
-
}
|
|
4424
|
-
};
|
|
4425
|
-
return this.openModal(option);
|
|
4426
|
-
}
|
|
4427
|
-
openYesNo(title, message, yesHandler, noHandler) {
|
|
4428
|
-
const option = {
|
|
4429
|
-
component: vue.defineAsyncComponent(() => Promise.resolve().then(() => BSYesNoModal)),
|
|
4430
|
-
bind: {
|
|
4431
|
-
title,
|
|
4432
|
-
message
|
|
4433
|
-
},
|
|
4434
|
-
on: {
|
|
4435
|
-
clickYes: async () => await yesHandler?.(),
|
|
4436
|
-
clickNo: async () => await noHandler?.()
|
|
4437
|
-
}
|
|
4438
|
-
};
|
|
4439
|
-
return this.openModal(option);
|
|
4440
|
-
}
|
|
4441
|
-
install(app) {
|
|
4442
|
-
app.provide(modalPluginKey, this);
|
|
4443
|
-
}
|
|
4444
|
-
}
|
|
4445
|
-
const useModal = () => {
|
|
4446
|
-
const modal = vue.inject(modalPluginKey);
|
|
4447
|
-
if (!modal) throw new Error("BSModal is not initialized.");
|
|
4448
|
-
return modal;
|
|
4449
|
-
};
|
|
4450
|
-
const provideModalHandle = (modalHandle) => {
|
|
4451
|
-
vue.provide(modalHandleKey, modalHandle);
|
|
4452
|
-
};
|
|
4453
|
-
const useModalHandle = () => {
|
|
4454
|
-
const modalHandle = vue.inject(modalHandleKey);
|
|
4455
|
-
if (!modalHandle) throw new Error("ModalHandle not found. Maybe not inside modal component.");
|
|
4456
|
-
return modalHandle;
|
|
4457
|
-
};
|
|
4458
|
-
const createModalPlugin = () => {
|
|
4459
|
-
return new BSModal();
|
|
4460
|
-
};
|
|
4461
4463
|
const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
4462
4464
|
__name: "BSModalWrapper",
|
|
4463
4465
|
props: {
|