@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.
@@ -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: 'modal' | 'modalForm',
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: 'modal' | 'modalForm',
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
  },
@@ -1620,6 +1620,15 @@
1620
1620
  width: 100%;
1621
1621
  }
1622
1622
 
1623
+ .ltr,
1624
+ .direction-ltr {
1625
+ direction: ltr;
1626
+ }
1627
+
1628
+ .rtl,
1629
+ .direction-rtl {
1630
+ direction: rtl;
1631
+ }
1623
1632
 
1624
1633
  @media screen and (max-width: 910px) {
1625
1634
  .grid-wrap-2 {
@@ -1520,4 +1520,15 @@
1520
1520
  .m_overflow-y-hidden {
1521
1521
  overflow-y: hidden;
1522
1522
  }
1523
+
1524
+ .m_ltr,
1525
+ .m_direction-ltr {
1526
+ direction: ltr;
1527
+ }
1528
+
1529
+ .m_rtl,
1530
+ .m_direction-rtl {
1531
+ direction: rtl;
1532
+ }
1533
+
1523
1534
  }