UNPKG

winbox-ui-next

Version:

We Design Vue 2.0: A Vue.js 3 UI Library

67 lines (66 loc) 2.22 kB
"use strict"; var vue = require("vue"); var globalConfig = require("../_utils/global-config.js"); var convertCase = require("../_utils/convert-case.js"); var notification = require("./notification.js"); var is = require("../_utils/is.js"); var _interface = require("./interface.js"); var usePopupManager = require("../_hooks/use-popup-manager.js"); function _isSlot(s) { return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s); } var NotificationList = vue.defineComponent({ name: "NotificationList", props: { notifications: { type: Array, default: () => [] }, position: { type: String, default: "topRight", validator: (value) => { return _interface.NOTIFICATION_POSITION.includes(value); } } }, emits: ["close", "afterClose"], setup(props, context) { const prefixCls = globalConfig.getPrefixCls("notification-list"); const kebabPosition = convertCase.toKebabCase(props.position); const { zIndex } = usePopupManager("message", { runOnMounted: true }); const isRight = props.position.includes("Right"); return () => { let _slot; return vue.createVNode(vue.TransitionGroup, { "class": [prefixCls, `${prefixCls}-${kebabPosition}`], "style": { zIndex: zIndex.value }, "name": `slide-${isRight ? "right" : "left"}-notification`, "onAfterLeave": () => context.emit("afterClose"), "tag": "ul" }, _isSlot(_slot = props.notifications.map((item) => { const slots = { default: () => is.isFunction(item.title) ? item.title() : item.title, content: () => is.isFunction(item.content) ? item.content() : item.content, icon: () => is.isFunction(item.icon) ? item.icon() : item.icon }; return vue.createVNode(notification, { "key": item.id, "type": item.type, "duration": item.duration, "closable": item.closable, "onClose": () => context.emit("close", item.id) }, slots); })) ? _slot : { default: () => [_slot] }); }; } }); module.exports = NotificationList;