@mantine-vue/notifications 3.1.0 → 3.3.0
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/cjs/index.cjs +255 -23
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +255 -23
- package/esm/index.mjs.map +1 -1
- package/lib/components/NotificationContainer/NotificationContainer.types.d.ts +20 -1
- package/lib/components/NotificationContainer/NotificationContainer.vue.d.ts +4 -0
- package/lib/components/Notifications/Notifications.types.d.ts +6 -1
- package/lib/notifications.store.d.ts +6 -1
- package/package.json +4 -4
- package/styles.css +16 -8
- package/styles.layer.css +16 -8
package/cjs/index.cjs
CHANGED
|
@@ -105,7 +105,9 @@ function getAutoClose(autoClose, notificationAutoClose) {
|
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region src/components/NotificationContainer/NotificationContainer.vue?vue&type=script&setup=true&lang.ts
|
|
108
|
+
var _hoisted_1 = ["role", "inert"];
|
|
108
109
|
var SCROLL_DISMISS_RESET_TIMEOUT = 120;
|
|
110
|
+
var MAX_VISIBLE_STACK_DEPTH = 4;
|
|
109
111
|
//#endregion
|
|
110
112
|
//#region src/components/NotificationContainer/NotificationContainer.vue
|
|
111
113
|
var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
@@ -118,12 +120,22 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
118
120
|
transitionDuration: {},
|
|
119
121
|
allowDragDismiss: { type: Boolean },
|
|
120
122
|
allowScrollDismiss: { type: Boolean },
|
|
121
|
-
paused: { type: Boolean }
|
|
123
|
+
paused: { type: Boolean },
|
|
124
|
+
renderNotification: { type: [Function, null] },
|
|
125
|
+
layout: {},
|
|
126
|
+
stackIndex: {},
|
|
127
|
+
stackSize: {},
|
|
128
|
+
stackPosition: {},
|
|
129
|
+
stackExpanded: { type: Boolean },
|
|
130
|
+
stackExpandedOffset: {},
|
|
131
|
+
transitionState: {}
|
|
122
132
|
},
|
|
123
133
|
emits: [
|
|
124
134
|
"hide",
|
|
125
135
|
"hoverStart",
|
|
126
|
-
"hoverEnd"
|
|
136
|
+
"hoverEnd",
|
|
137
|
+
"expandRequest",
|
|
138
|
+
"heightChange"
|
|
127
139
|
],
|
|
128
140
|
setup(__props, { emit: __emit }) {
|
|
129
141
|
const props = __props;
|
|
@@ -136,11 +148,14 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
136
148
|
const active = (0, vue.ref)(false);
|
|
137
149
|
const scrollDismissActive = (0, vue.ref)(false);
|
|
138
150
|
const hovered = (0, vue.ref)(false);
|
|
151
|
+
const focused = (0, vue.ref)(false);
|
|
152
|
+
const contributedActive = (0, vue.ref)(false);
|
|
139
153
|
const startX = (0, vue.ref)(0);
|
|
140
154
|
const startTime = (0, vue.ref)(0);
|
|
141
155
|
let autoCloseTimeout = -1;
|
|
142
156
|
let hideTimeout = -1;
|
|
143
157
|
let scrollDismissTimeout = -1;
|
|
158
|
+
let resizeObserver;
|
|
144
159
|
const autoCloseDuration = (0, vue.computed)(() => getAutoClose(props.autoClose, props.data.autoClose));
|
|
145
160
|
const isCloseDisabled = (0, vue.computed)(() => props.data.allowClose === false);
|
|
146
161
|
function normalizeStyle(style) {
|
|
@@ -158,7 +173,10 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
158
173
|
"withCloseButton",
|
|
159
174
|
"onOpen",
|
|
160
175
|
"onClose",
|
|
161
|
-
"id"
|
|
176
|
+
"id",
|
|
177
|
+
"renderNotification",
|
|
178
|
+
"priority",
|
|
179
|
+
"__sequence"
|
|
162
180
|
]);
|
|
163
181
|
return Object.fromEntries(Object.entries(props.data).filter(([key]) => !omittedKeys.has(key)).map(([key, value]) => [key, cloneRenderable(value)]));
|
|
164
182
|
}
|
|
@@ -168,6 +186,7 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
168
186
|
return value;
|
|
169
187
|
}
|
|
170
188
|
const renderMessage = () => cloneRenderable(typeof props.data.message === "function" ? props.data.message() : props.data.message);
|
|
189
|
+
const renderCustomNotification = () => cloneRenderable(props.renderNotification?.(props.data));
|
|
171
190
|
const notificationStyle = (0, vue.computed)(() => {
|
|
172
191
|
const baseStyle = {
|
|
173
192
|
...normalizeStyle(attrs.style),
|
|
@@ -176,19 +195,44 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
176
195
|
const baseOpacity = typeof baseStyle.opacity === "number" ? baseStyle.opacity : 1;
|
|
177
196
|
const swipeOpacity = dismissed.value ? 0 : 1 - Math.min(Math.abs(offset.value) / 200, 1) * .6;
|
|
178
197
|
const transitionDuration = baseStyle.transitionDuration ?? `${props.transitionDuration}ms, ${props.transitionDuration}ms, ${props.transitionDuration}ms`;
|
|
198
|
+
const isStackedLayout = props.layout === "stacked";
|
|
199
|
+
const isStacked = isStackedLayout && (props.stackIndex ?? 0) > 0;
|
|
200
|
+
const isCollapsed = isStacked && !props.stackExpanded;
|
|
201
|
+
const isExiting = props.transitionState === "exiting" || props.transitionState === "exited";
|
|
202
|
+
const stackDirection = props.stackPosition?.startsWith("top") ? 1 : -1;
|
|
203
|
+
const stackDepth = Math.min(props.stackIndex ?? 0, MAX_VISIBLE_STACK_DEPTH);
|
|
204
|
+
const collapsedOffset = isCollapsed ? stackDepth * 10 * stackDirection : 0;
|
|
205
|
+
const staggerDelay = isStackedLayout ? (props.stackIndex ?? 0) * 30 : 0;
|
|
206
|
+
const isDragging = active.value || scrollDismissActive.value;
|
|
207
|
+
let transform = "var(--notifications-state-transform) translate3d(var(--notifications-swipe-offset), 0, 0)";
|
|
208
|
+
if (isStackedLayout) {
|
|
209
|
+
if (isExiting) transform = `translateY(${props.stackExpanded ? props.stackExpandedOffset ?? 0 : collapsedOffset}px) ${transform}`;
|
|
210
|
+
else if (props.stackExpanded) transform = `translateY(${props.stackExpandedOffset ?? 0}px) translate3d(var(--notifications-swipe-offset), 0, 0)`;
|
|
211
|
+
else if (isStacked) transform = `scale(${1 - stackDepth * .03}) translateY(${collapsedOffset}px)`;
|
|
212
|
+
}
|
|
179
213
|
return {
|
|
180
214
|
...baseStyle,
|
|
215
|
+
...isStackedLayout ? { maxHeight: void 0 } : {},
|
|
181
216
|
"--notifications-state-transform": typeof baseStyle.transform === "string" ? baseStyle.transform : "translateX(0)",
|
|
182
217
|
"--notifications-state-opacity": String(baseOpacity),
|
|
183
218
|
"--notifications-swipe-offset": `${offset.value}px`,
|
|
184
219
|
"--notifications-swipe-opacity": String(swipeOpacity),
|
|
185
|
-
transform
|
|
220
|
+
transform,
|
|
186
221
|
opacity: "calc(var(--notifications-state-opacity) * var(--notifications-swipe-opacity))",
|
|
187
|
-
transitionDuration:
|
|
222
|
+
transitionDuration: isDragging ? "0ms, 0ms, 0ms" : transitionDuration,
|
|
188
223
|
cursor: "default",
|
|
189
|
-
touchAction: "pan-y"
|
|
224
|
+
touchAction: "pan-y",
|
|
225
|
+
...isStackedLayout ? {
|
|
226
|
+
gridArea: "1 / 1",
|
|
227
|
+
zIndex: (props.stackSize ?? 5) - (props.stackIndex ?? 0),
|
|
228
|
+
pointerEvents: isCollapsed ? "none" : void 0,
|
|
229
|
+
alignSelf: stackDirection === 1 ? "start" : "end",
|
|
230
|
+
transition: isDragging ? "none" : `transform ${props.transitionDuration}ms cubic-bezier(.51,.3,0,1.21), opacity ${props.transitionDuration}ms ease`,
|
|
231
|
+
transitionDelay: isDragging || isExiting ? "0ms" : `${staggerDelay}ms`
|
|
232
|
+
} : {}
|
|
190
233
|
};
|
|
191
234
|
});
|
|
235
|
+
const isCollapsed = (0, vue.computed)(() => props.layout === "stacked" && (props.stackIndex ?? 0) > 0 && !props.stackExpanded);
|
|
192
236
|
const cancelAutoClose = () => window.clearTimeout(autoCloseTimeout);
|
|
193
237
|
const cancelHide = () => window.clearTimeout(hideTimeout);
|
|
194
238
|
const cancelScrollDismissReset = () => window.clearTimeout(scrollDismissTimeout);
|
|
@@ -199,7 +243,7 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
199
243
|
cancelScrollDismissReset();
|
|
200
244
|
}
|
|
201
245
|
function handleAutoClose() {
|
|
202
|
-
if (typeof window === "undefined" || dismissed.value || active.value || props.paused || hovered.value || typeof autoCloseDuration.value !== "number") return;
|
|
246
|
+
if (typeof window === "undefined" || dismissed.value || active.value || props.paused || hovered.value || focused.value || typeof autoCloseDuration.value !== "number") return;
|
|
203
247
|
cancelAutoClose();
|
|
204
248
|
autoCloseTimeout = window.setTimeout(handleHide, autoCloseDuration.value);
|
|
205
249
|
}
|
|
@@ -289,7 +333,34 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
289
333
|
function handleMouseEnter() {
|
|
290
334
|
hovered.value = true;
|
|
291
335
|
cancelAutoClose();
|
|
292
|
-
|
|
336
|
+
syncActiveContribution();
|
|
337
|
+
}
|
|
338
|
+
function syncActiveContribution() {
|
|
339
|
+
const isActive = hovered.value || focused.value;
|
|
340
|
+
if (isActive && !contributedActive.value) {
|
|
341
|
+
contributedActive.value = true;
|
|
342
|
+
emit("hoverStart");
|
|
343
|
+
} else if (!isActive && contributedActive.value) {
|
|
344
|
+
contributedActive.value = false;
|
|
345
|
+
emit("hoverEnd");
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function handleFocusIn() {
|
|
349
|
+
if (props.layout !== "stacked") return;
|
|
350
|
+
focused.value = true;
|
|
351
|
+
cancelAutoClose();
|
|
352
|
+
syncActiveContribution();
|
|
353
|
+
}
|
|
354
|
+
function handleFocusOut(event) {
|
|
355
|
+
if (props.layout !== "stacked") return;
|
|
356
|
+
const next = event.relatedTarget;
|
|
357
|
+
if (next && notificationRef.value?.contains(next)) return;
|
|
358
|
+
focused.value = false;
|
|
359
|
+
if (!scrollDismissActive.value) handleAutoClose();
|
|
360
|
+
syncActiveContribution();
|
|
361
|
+
}
|
|
362
|
+
function handlePointerDownCapture(event) {
|
|
363
|
+
if (props.layout === "stacked" && (event.pointerType === "touch" || event.pointerType === "pen")) emit("expandRequest");
|
|
293
364
|
}
|
|
294
365
|
function handleMouseLeave() {
|
|
295
366
|
hovered.value = false;
|
|
@@ -297,7 +368,7 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
297
368
|
resetSwipe();
|
|
298
369
|
handleAutoClose();
|
|
299
370
|
}
|
|
300
|
-
|
|
371
|
+
syncActiveContribution();
|
|
301
372
|
}
|
|
302
373
|
(0, vue.watch)(scrollDismissActive, (enabled, _, onCleanup) => {
|
|
303
374
|
if (!enabled) return;
|
|
@@ -317,35 +388,69 @@ var NotificationContainer_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
317
388
|
props.data.onOpen?.(props.data);
|
|
318
389
|
notificationRef.value?.addEventListener("wheel", handleWheel, { passive: false });
|
|
319
390
|
window.addEventListener("resize", handleResize);
|
|
391
|
+
if (notificationRef.value) {
|
|
392
|
+
emit("heightChange", notificationRef.value.offsetHeight);
|
|
393
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
394
|
+
resizeObserver = new ResizeObserver(() => {
|
|
395
|
+
if (notificationRef.value) emit("heightChange", notificationRef.value.offsetHeight);
|
|
396
|
+
});
|
|
397
|
+
resizeObserver.observe(notificationRef.value);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
320
400
|
});
|
|
321
401
|
function handleResize() {
|
|
322
402
|
if (dismissed.value) offset.value = getExitOffset(dismissDirection.value);
|
|
323
403
|
}
|
|
324
404
|
(0, vue.onBeforeUnmount)(() => {
|
|
325
|
-
|
|
405
|
+
hovered.value = false;
|
|
406
|
+
focused.value = false;
|
|
407
|
+
syncActiveContribution();
|
|
326
408
|
cancelAutoClose();
|
|
327
409
|
cancelHide();
|
|
328
410
|
cancelScrollDismissReset();
|
|
329
411
|
cancelPointerDrag(false);
|
|
330
412
|
notificationRef.value?.removeEventListener("wheel", handleWheel);
|
|
331
413
|
window.removeEventListener("resize", handleResize);
|
|
414
|
+
resizeObserver?.disconnect();
|
|
332
415
|
});
|
|
416
|
+
function setNotificationRef(node) {
|
|
417
|
+
notificationRef.value = node?.$el ?? node ?? null;
|
|
418
|
+
}
|
|
333
419
|
return (_ctx, _cache) => {
|
|
334
|
-
return (0, vue.openBlock)(), (0, vue.
|
|
420
|
+
return props.renderNotification ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", (0, vue.mergeProps)({ key: 0 }, (0, vue.unref)(attrs), {
|
|
421
|
+
ref: setNotificationRef,
|
|
422
|
+
style: notificationStyle.value,
|
|
423
|
+
role: (0, vue.unref)(attrs).role || "alert",
|
|
424
|
+
inert: isCollapsed.value || void 0,
|
|
425
|
+
onMouseenter: handleMouseEnter,
|
|
426
|
+
onMouseleave: handleMouseLeave,
|
|
427
|
+
onFocusin: handleFocusIn,
|
|
428
|
+
onFocusout: handleFocusOut,
|
|
429
|
+
onPointerdownCapture: handlePointerDownCapture,
|
|
430
|
+
onPointerdown: handlePointerDown
|
|
431
|
+
}), [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(renderCustomNotification)))], 16, _hoisted_1)) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.Notification), (0, vue.mergeProps)({ key: 1 }, {
|
|
335
432
|
...(0, vue.unref)(attrs),
|
|
336
433
|
...getNotificationProps()
|
|
337
434
|
}, {
|
|
338
|
-
ref:
|
|
435
|
+
ref: setNotificationRef,
|
|
339
436
|
style: notificationStyle.value,
|
|
437
|
+
inert: isCollapsed.value || void 0,
|
|
340
438
|
"with-close-button": isCloseDisabled.value ? false : props.data.withCloseButton,
|
|
341
439
|
onClose: handleHide,
|
|
342
440
|
onMouseenter: handleMouseEnter,
|
|
343
441
|
onMouseleave: handleMouseLeave,
|
|
442
|
+
onFocusin: handleFocusIn,
|
|
443
|
+
onFocusout: handleFocusOut,
|
|
444
|
+
onPointerdownCapture: handlePointerDownCapture,
|
|
344
445
|
onPointerdown: handlePointerDown
|
|
345
446
|
}), {
|
|
346
447
|
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)(renderMessage)))]),
|
|
347
448
|
_: 1
|
|
348
|
-
}, 16, [
|
|
449
|
+
}, 16, [
|
|
450
|
+
"style",
|
|
451
|
+
"inert",
|
|
452
|
+
"with-close-button"
|
|
453
|
+
]));
|
|
349
454
|
};
|
|
350
455
|
}
|
|
351
456
|
});
|
|
@@ -417,8 +522,8 @@ function getNotificationStateStyles({ state, maxHeight, position, transitionDura
|
|
|
417
522
|
};
|
|
418
523
|
}
|
|
419
524
|
var Notifications_module_default = {
|
|
420
|
-
root: "
|
|
421
|
-
notification: "
|
|
525
|
+
root: "_root_1hrsl_1",
|
|
526
|
+
notification: "_notification_1hrsl_40"
|
|
422
527
|
};
|
|
423
528
|
//#endregion
|
|
424
529
|
//#region src/components/Notifications/Notifications.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -458,6 +563,8 @@ var Notifications = Object.assign(/* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
458
563
|
default: true
|
|
459
564
|
},
|
|
460
565
|
pauseResetOnHover: { default: "all" },
|
|
566
|
+
renderNotification: {},
|
|
567
|
+
layout: { default: "default" },
|
|
461
568
|
classNames: {},
|
|
462
569
|
styles: {},
|
|
463
570
|
vars: {},
|
|
@@ -469,10 +576,18 @@ var Notifications = Object.assign(/* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
469
576
|
const props = (0, _mantine_vue_core.useProps)("Notifications", null, rawProps);
|
|
470
577
|
const theme = (0, _mantine_vue_core.useMantineTheme)();
|
|
471
578
|
const shouldReduceMotion = (0, _mantine_vue_hooks.useReducedMotion)();
|
|
472
|
-
const
|
|
579
|
+
const STACK_EXPANDED_GAP = 16;
|
|
580
|
+
const FALLBACK_NOTIFICATION_HEIGHT = 80;
|
|
581
|
+
const hoveredCounts = (0, vue.ref)({});
|
|
582
|
+
const hoveredGroups = (0, vue.ref)({});
|
|
583
|
+
const expandedPositions = (0, vue.ref)({});
|
|
584
|
+
const pinnedPosition = (0, vue.ref)(null);
|
|
585
|
+
const notificationHeights = (0, vue.ref)({});
|
|
586
|
+
const collapseTimeouts = {};
|
|
473
587
|
const data = useNotifications(props.store);
|
|
474
588
|
const duration = (0, vue.computed)(() => theme.value.respectReducedMotion && shouldReduceMotion.value ? 1 : props.transitionDuration);
|
|
475
589
|
const grouped = (0, vue.computed)(() => getGroupedNotifications(data.value.notifications, props.position));
|
|
590
|
+
const hoveredCount = (0, vue.computed)(() => Object.values(hoveredCounts.value).reduce((sum, value) => sum + (value ?? 0), 0) + Object.values(hoveredGroups.value).filter(Boolean).length);
|
|
476
591
|
const getStyles = (0, _mantine_vue_core.useStyles)({
|
|
477
592
|
name: "Notifications",
|
|
478
593
|
classes: Notifications_module_default,
|
|
@@ -518,47 +633,164 @@ var Notifications = Object.assign(/* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
518
633
|
delete data.style;
|
|
519
634
|
return data;
|
|
520
635
|
}
|
|
636
|
+
function isStackExpanded(position) {
|
|
637
|
+
return props.layout === "stacked" && Boolean(expandedPositions.value[position]);
|
|
638
|
+
}
|
|
639
|
+
function orderedGroup(position) {
|
|
640
|
+
const items = grouped.value[position];
|
|
641
|
+
if (props.layout !== "stacked") return items;
|
|
642
|
+
return [...items].sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0) || (b.__sequence ?? 0) - (a.__sequence ?? 0));
|
|
643
|
+
}
|
|
644
|
+
function expandedOffset(position, index) {
|
|
645
|
+
if (!isStackExpanded(position)) return 0;
|
|
646
|
+
const direction = position.startsWith("top") ? 1 : -1;
|
|
647
|
+
return orderedGroup(position).slice(0, index).reduce((sum, item) => sum + (notificationHeights.value[item.id] ?? FALLBACK_NOTIFICATION_HEIGHT) + STACK_EXPANDED_GAP, 0) * direction;
|
|
648
|
+
}
|
|
649
|
+
function setExpanded(position, expanded) {
|
|
650
|
+
expandedPositions.value = {
|
|
651
|
+
...expandedPositions.value,
|
|
652
|
+
[position]: expanded
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function scheduleCollapse(position) {
|
|
656
|
+
window.clearTimeout(collapseTimeouts[position]);
|
|
657
|
+
if ((hoveredCounts.value[position] ?? 0) > 0 || hoveredGroups.value[position] || pinnedPosition.value === position) return;
|
|
658
|
+
collapseTimeouts[position] = window.setTimeout(() => setExpanded(position, false), 200);
|
|
659
|
+
}
|
|
660
|
+
function handleHoverStart(position) {
|
|
661
|
+
hoveredCounts.value = {
|
|
662
|
+
...hoveredCounts.value,
|
|
663
|
+
[position]: (hoveredCounts.value[position] ?? 0) + 1
|
|
664
|
+
};
|
|
665
|
+
if (props.layout === "stacked") setExpanded(position, true);
|
|
666
|
+
}
|
|
667
|
+
function handleHoverEnd(position) {
|
|
668
|
+
hoveredCounts.value = {
|
|
669
|
+
...hoveredCounts.value,
|
|
670
|
+
[position]: Math.max(0, (hoveredCounts.value[position] ?? 0) - 1)
|
|
671
|
+
};
|
|
672
|
+
if (props.layout === "stacked") scheduleCollapse(position);
|
|
673
|
+
}
|
|
674
|
+
function handleGroupHover(position, hovered) {
|
|
675
|
+
if (props.layout !== "stacked") return;
|
|
676
|
+
hoveredGroups.value = {
|
|
677
|
+
...hoveredGroups.value,
|
|
678
|
+
[position]: hovered
|
|
679
|
+
};
|
|
680
|
+
if (hovered) {
|
|
681
|
+
window.clearTimeout(collapseTimeouts[position]);
|
|
682
|
+
setExpanded(position, true);
|
|
683
|
+
} else scheduleCollapse(position);
|
|
684
|
+
}
|
|
685
|
+
function handleExpandRequest(position) {
|
|
686
|
+
pinnedPosition.value = position;
|
|
687
|
+
setExpanded(position, true);
|
|
688
|
+
}
|
|
689
|
+
function handleDocumentPointerDown(event) {
|
|
690
|
+
if (!pinnedPosition.value) return;
|
|
691
|
+
if (!event.target?.closest(`[data-notifications-position="${pinnedPosition.value}"]`)) {
|
|
692
|
+
const previous = pinnedPosition.value;
|
|
693
|
+
pinnedPosition.value = null;
|
|
694
|
+
scheduleCollapse(previous);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
(0, vue.watch)(() => props.layout, (layout) => {
|
|
698
|
+
if (layout !== "stacked") {
|
|
699
|
+
pinnedPosition.value = null;
|
|
700
|
+
hoveredGroups.value = {};
|
|
701
|
+
expandedPositions.value = {};
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
(0, vue.watch)(grouped, (groups) => {
|
|
705
|
+
if (pinnedPosition.value && groups[pinnedPosition.value].length === 0) pinnedPosition.value = null;
|
|
706
|
+
});
|
|
707
|
+
(0, vue.onMounted)(() => document.addEventListener("pointerdown", handleDocumentPointerDown));
|
|
708
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
709
|
+
document.removeEventListener("pointerdown", handleDocumentPointerDown);
|
|
710
|
+
positions.forEach((position) => window.clearTimeout(collapseTimeouts[position]));
|
|
711
|
+
});
|
|
521
712
|
return (_ctx, _cache) => {
|
|
522
713
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.OptionalPortal), (0, vue.mergeProps)((0, vue.unref)(props).portalProps, { "within-portal": (0, vue.unref)(props).withinPortal }), {
|
|
523
714
|
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)((0, vue.unref)(positions), (position) => {
|
|
524
715
|
return (0, vue.openBlock)(), (0, vue.createBlock)((0, vue.unref)(_mantine_vue_core.Box), (0, vue.mergeProps)({ key: position }, { ref_for: true }, {
|
|
525
716
|
...(0, vue.unref)(attrs),
|
|
526
717
|
...(0, vue.unref)(getStyles)("root")
|
|
527
|
-
}, {
|
|
718
|
+
}, {
|
|
719
|
+
"data-position": position,
|
|
720
|
+
"data-notifications-position": position,
|
|
721
|
+
"data-layout": (0, vue.unref)(props).layout
|
|
722
|
+
}), {
|
|
528
723
|
default: (0, vue.withCtx)(() => [(0, vue.createVNode)(vue.TransitionGroup, {
|
|
724
|
+
tag: "div",
|
|
529
725
|
css: false,
|
|
726
|
+
onMouseenter: ($event) => handleGroupHover(position, true),
|
|
727
|
+
onMouseleave: ($event) => handleGroupHover(position, false),
|
|
728
|
+
onFocusin: ($event) => handleGroupHover(position, true),
|
|
729
|
+
onFocusout: ($event) => handleGroupHover(position, false),
|
|
530
730
|
onBeforeEnter: (element) => applyTransitionStyles(element, "exited", position),
|
|
531
731
|
onEnter: (element, done) => enter(element, done, position),
|
|
532
732
|
onLeave: (element, done) => leave(element, done, position)
|
|
533
733
|
}, {
|
|
534
|
-
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(
|
|
734
|
+
default: (0, vue.withCtx)(() => [((0, vue.openBlock)(true), (0, vue.createElementBlock)(vue.Fragment, null, (0, vue.renderList)(orderedGroup(position), (notification, stackIndex) => {
|
|
535
735
|
return (0, vue.openBlock)(), (0, vue.createBlock)(NotificationContainer_default, (0, vue.mergeProps)({ key: notification.id }, { ref_for: true }, (0, vue.unref)(getStyles)("notification", { style: notification.style }), {
|
|
536
736
|
data: notificationData(notification),
|
|
537
737
|
"auto-close": (0, vue.unref)(props).autoClose,
|
|
538
738
|
"transition-duration": duration.value,
|
|
539
739
|
"allow-drag-dismiss": (0, vue.unref)(props).allowDragDismiss,
|
|
540
740
|
"allow-scroll-dismiss": (0, vue.unref)(props).allowScrollDismiss,
|
|
541
|
-
paused: (0, vue.unref)(props).pauseResetOnHover === "all" && hoveredCount.value > 0,
|
|
741
|
+
paused: (0, vue.unref)(props).pauseResetOnHover === "all" && hoveredCount.value > 0 || (0, vue.unref)(props).layout === "stacked" && !isStackExpanded(position) && stackIndex > 0,
|
|
742
|
+
"render-notification": "renderNotification" in notification ? notification.renderNotification : (0, vue.unref)(props).renderNotification,
|
|
743
|
+
layout: (0, vue.unref)(props).layout,
|
|
744
|
+
"stack-index": stackIndex,
|
|
745
|
+
"stack-size": orderedGroup(position).length,
|
|
746
|
+
"stack-position": position,
|
|
747
|
+
"stack-expanded": isStackExpanded(position),
|
|
748
|
+
"stack-expanded-offset": expandedOffset(position, stackIndex),
|
|
749
|
+
"transition-state": "entered",
|
|
542
750
|
onHide: _cache[0] || (_cache[0] = (id) => (0, vue.unref)(hideNotification)(id, (0, vue.unref)(props).store)),
|
|
543
|
-
onHoverStart:
|
|
544
|
-
onHoverEnd:
|
|
751
|
+
onHoverStart: ($event) => handleHoverStart(position),
|
|
752
|
+
onHoverEnd: ($event) => handleHoverEnd(position),
|
|
753
|
+
onExpandRequest: ($event) => handleExpandRequest(position),
|
|
754
|
+
onHeightChange: (height) => notificationHeights.value = {
|
|
755
|
+
...notificationHeights.value,
|
|
756
|
+
[notification.id]: height
|
|
757
|
+
}
|
|
545
758
|
}), null, 16, [
|
|
546
759
|
"data",
|
|
547
760
|
"auto-close",
|
|
548
761
|
"transition-duration",
|
|
549
762
|
"allow-drag-dismiss",
|
|
550
763
|
"allow-scroll-dismiss",
|
|
551
|
-
"paused"
|
|
764
|
+
"paused",
|
|
765
|
+
"render-notification",
|
|
766
|
+
"layout",
|
|
767
|
+
"stack-index",
|
|
768
|
+
"stack-size",
|
|
769
|
+
"stack-position",
|
|
770
|
+
"stack-expanded",
|
|
771
|
+
"stack-expanded-offset",
|
|
772
|
+
"onHoverStart",
|
|
773
|
+
"onHoverEnd",
|
|
774
|
+
"onExpandRequest",
|
|
775
|
+
"onHeightChange"
|
|
552
776
|
]);
|
|
553
777
|
}), 128))]),
|
|
554
778
|
_: 2
|
|
555
779
|
}, 1032, [
|
|
780
|
+
"onMouseenter",
|
|
781
|
+
"onMouseleave",
|
|
782
|
+
"onFocusin",
|
|
783
|
+
"onFocusout",
|
|
556
784
|
"onBeforeEnter",
|
|
557
785
|
"onEnter",
|
|
558
786
|
"onLeave"
|
|
559
787
|
])]),
|
|
560
788
|
_: 2
|
|
561
|
-
}, 1040, [
|
|
789
|
+
}, 1040, [
|
|
790
|
+
"data-position",
|
|
791
|
+
"data-notifications-position",
|
|
792
|
+
"data-layout"
|
|
793
|
+
]);
|
|
562
794
|
}), 128))]),
|
|
563
795
|
_: 1
|
|
564
796
|
}, 16, ["within-portal"]);
|