@bagelink/vue 1.9.88 → 1.9.92
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/Dropdown.vue.d.ts.map +1 -1
- package/dist/index.cjs +36 -36
- package/dist/index.mjs +3637 -3590
- package/dist/plugins/useToast.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Dropdown.vue +9 -3
- package/src/plugins/useToast.ts +25 -8
- package/src/styles/toast-overrides.css +10 -3
- package/src/utils/index.ts +28 -0
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { Attributes, BglFormSchemaT, Path } from '../types/BagelForm';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a singleton popover container that lives in the browser's top layer.
|
|
4
|
+
* Popovers rendered inside it will appear above showModal() dialogs.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getTopLayerContainer(): HTMLElement | string;
|
|
7
|
+
/**
|
|
8
|
+
* Re-stacks the top-layer container above any currently open dialogs.
|
|
9
|
+
* Call this just before showing a popper/dropdown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function restackTopLayerContainer(): void;
|
|
2
12
|
export declare function debounce(fn: () => void, wait?: number): void;
|
|
3
13
|
export declare function slugify(str: string): string;
|
|
4
14
|
export declare function keyToLabel(key?: string): string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,MA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AC,GAAG,SAAS,CAQzF;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,QA6BpE;AAED,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { IconType, ThemeType } from '@bagelink/vue'
|
|
3
3
|
import type { TriggerEvent } from 'floating-vue'
|
|
4
4
|
import type { ComponentExposed } from 'vue-component-type-helpers'
|
|
5
|
-
import { Btn, useDevice } from '@bagelink/vue'
|
|
5
|
+
import { Btn, useDevice, getTopLayerContainer, restackTopLayerContainer } from '@bagelink/vue'
|
|
6
6
|
import { Dropdown as DDown } from 'floating-vue'
|
|
7
7
|
import { computed, ref } from 'vue'
|
|
8
8
|
|
|
@@ -191,7 +191,13 @@ const computedPopperHideTriggers = computed((): TriggerEvent[] => {
|
|
|
191
191
|
|
|
192
192
|
const computedAutoHide = computed(() => autoHide)
|
|
193
193
|
|
|
194
|
-
const container = computed(() =>
|
|
194
|
+
const container = computed(() => getTopLayerContainer())
|
|
195
|
+
|
|
196
|
+
function onShow() {
|
|
197
|
+
// Re-stack the container above any dialog that opened after it
|
|
198
|
+
restackTopLayerContainer()
|
|
199
|
+
emit('show')
|
|
200
|
+
}
|
|
195
201
|
|
|
196
202
|
const computedDelay = computed((): number | { show: number, hide: number } | undefined => {
|
|
197
203
|
if (delay !== undefined) { return delay }
|
|
@@ -213,7 +219,7 @@ defineExpose({ show, hide, shown })
|
|
|
213
219
|
:showTriggers="computedShowTriggers" :hideTriggers="computedHideTriggers"
|
|
214
220
|
:popperTriggers="computedPopperTriggers" :popperShowTriggers="computedPopperShowTriggers"
|
|
215
221
|
:popperHideTriggers="computedPopperHideTriggers" :showGroup="showGroup" :container="container"
|
|
216
|
-
@hide="emit('hide')" @show="
|
|
222
|
+
@hide="emit('hide')" @show="onShow"
|
|
217
223
|
>
|
|
218
224
|
<div ref="triggerRef" />
|
|
219
225
|
<slot name="trigger" :show :hide :shown>
|
package/src/plugins/useToast.ts
CHANGED
|
@@ -38,20 +38,24 @@ export function useToast(): ToastApi {
|
|
|
38
38
|
|
|
39
39
|
export type BagelToastOptions = Partial<ToastOptions>
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
function getToastContainer(): HTMLElement | undefined {
|
|
42
42
|
if (typeof document === 'undefined') return undefined
|
|
43
|
-
|
|
44
|
-
el
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
let el = document.getElementById('bgl-toast-container')
|
|
44
|
+
if (!el) {
|
|
45
|
+
el = document.createElement('div')
|
|
46
|
+
el.setAttribute('popover', 'manual')
|
|
47
|
+
el.setAttribute('id', 'bgl-toast-container')
|
|
48
|
+
document.body.appendChild(el)
|
|
49
|
+
}
|
|
50
|
+
// Re-stack on top of any open dialogs
|
|
51
|
+
try { (el as any).hidePopover() } catch {}
|
|
52
|
+
try { (el as any).showPopover() } catch {}
|
|
49
53
|
return el
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
export const ToastPlugin: Plugin<BagelToastOptions[]> = {
|
|
53
57
|
install: (app: App, options: BagelToastOptions = {}) => {
|
|
54
|
-
const container =
|
|
58
|
+
const container = getToastContainer()
|
|
55
59
|
|
|
56
60
|
const defaultOptions: ToastOptions = {
|
|
57
61
|
position: POSITION.TOP_RIGHT,
|
|
@@ -78,9 +82,18 @@ export const ToastPlugin: Plugin<BagelToastOptions[]> = {
|
|
|
78
82
|
// Install vue-toastification
|
|
79
83
|
app.use(Toast, defaultOptions)
|
|
80
84
|
|
|
85
|
+
function restackToastContainer() {
|
|
86
|
+
const el = typeof document !== 'undefined' ? document.getElementById('bgl-toast-container') : null
|
|
87
|
+
if (el) {
|
|
88
|
+
try { (el as any).hidePopover() } catch {}
|
|
89
|
+
try { (el as any).showPopover() } catch {}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
81
93
|
// Create the API wrapper using lazy evaluation
|
|
82
94
|
const api: ToastApi = {
|
|
83
95
|
success: (message: string, opts?: any) => {
|
|
96
|
+
restackToastContainer()
|
|
84
97
|
const toast = useVueToast()
|
|
85
98
|
return toast({
|
|
86
99
|
component: CustomToast,
|
|
@@ -91,6 +104,7 @@ export const ToastPlugin: Plugin<BagelToastOptions[]> = {
|
|
|
91
104
|
}, opts)
|
|
92
105
|
},
|
|
93
106
|
error: (message: string, opts?: any) => {
|
|
107
|
+
restackToastContainer()
|
|
94
108
|
const toast = useVueToast()
|
|
95
109
|
return toast({
|
|
96
110
|
component: CustomToast,
|
|
@@ -101,6 +115,7 @@ export const ToastPlugin: Plugin<BagelToastOptions[]> = {
|
|
|
101
115
|
}, opts)
|
|
102
116
|
},
|
|
103
117
|
info: (message: string, opts?: any) => {
|
|
118
|
+
restackToastContainer()
|
|
104
119
|
const toast = useVueToast()
|
|
105
120
|
return toast({
|
|
106
121
|
component: CustomToast,
|
|
@@ -111,6 +126,7 @@ export const ToastPlugin: Plugin<BagelToastOptions[]> = {
|
|
|
111
126
|
}, opts)
|
|
112
127
|
},
|
|
113
128
|
warning: (message: string, opts?: any) => {
|
|
129
|
+
restackToastContainer()
|
|
114
130
|
const toast = useVueToast()
|
|
115
131
|
return toast({
|
|
116
132
|
component: CustomToast,
|
|
@@ -121,6 +137,7 @@ export const ToastPlugin: Plugin<BagelToastOptions[]> = {
|
|
|
121
137
|
}, opts)
|
|
122
138
|
},
|
|
123
139
|
show: (message: string, opts?: any) => {
|
|
140
|
+
restackToastContainer()
|
|
124
141
|
const toast = useVueToast()
|
|
125
142
|
return toast({
|
|
126
143
|
component: CustomToast,
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
/* Reset popover
|
|
2
|
-
#bgl-toast-container
|
|
1
|
+
/* Reset popover containers used to promote elements above showModal() dialogs */
|
|
2
|
+
#bgl-toast-container,
|
|
3
|
+
#bgl-toplayer-container {
|
|
3
4
|
all: unset;
|
|
5
|
+
position: fixed;
|
|
6
|
+
inset: 0;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
4
9
|
pointer-events: none;
|
|
10
|
+
overflow: visible;
|
|
5
11
|
}
|
|
6
12
|
|
|
7
|
-
#bgl-toast-container >
|
|
13
|
+
#bgl-toast-container > *,
|
|
14
|
+
#bgl-toplayer-container > * {
|
|
8
15
|
pointer-events: auto;
|
|
9
16
|
}
|
|
10
17
|
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
import type { Attributes, BglFormSchemaT, Path } from '../types/BagelForm'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Returns a singleton popover container that lives in the browser's top layer.
|
|
5
|
+
* Popovers rendered inside it will appear above showModal() dialogs.
|
|
6
|
+
*/
|
|
7
|
+
export function getTopLayerContainer(): HTMLElement | string {
|
|
8
|
+
if (typeof document === 'undefined') return 'body'
|
|
9
|
+
let el = document.getElementById('bgl-toplayer-container')
|
|
10
|
+
if (!el) {
|
|
11
|
+
el = document.createElement('div')
|
|
12
|
+
el.id = 'bgl-toplayer-container'
|
|
13
|
+
el.setAttribute('popover', 'manual')
|
|
14
|
+
document.body.appendChild(el)
|
|
15
|
+
}
|
|
16
|
+
return el
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Re-stacks the top-layer container above any currently open dialogs.
|
|
21
|
+
* Call this just before showing a popper/dropdown.
|
|
22
|
+
*/
|
|
23
|
+
export function restackTopLayerContainer(): void {
|
|
24
|
+
if (typeof document === 'undefined') return
|
|
25
|
+
const el = document.getElementById('bgl-toplayer-container')
|
|
26
|
+
if (!el) return
|
|
27
|
+
try { (el as any).hidePopover() } catch {}
|
|
28
|
+
try { (el as any).showPopover() } catch {}
|
|
29
|
+
}
|
|
30
|
+
|
|
3
31
|
const debouncers = new Map<() => void, ReturnType<typeof setTimeout>>()
|
|
4
32
|
|
|
5
33
|
export function debounce(fn: () => void, wait: number = 500) {
|