UNPKG

tdesign-vue-next

Version:
163 lines (155 loc) 6.73 kB
/** * tdesign v1.19.2 * (c) 2026 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _defineProperty = require('@babel/runtime/helpers/defineProperty'); var Vue = require('vue'); var notification_notificationList = require('./notification-list.js'); var dom = require('../_chunks/dep-8d990e66.js'); require('./notification.js'); require('tdesign-icons-vue-next'); require('@babel/runtime/helpers/toConsumableArray'); require('@babel/runtime/helpers/typeof'); require('../_chunks/dep-35e23c2b.js'); require('../_chunks/dep-4a7162e7.js'); require('../_chunks/dep-1862d466.js'); require('../_chunks/dep-a6551cc4.js'); require('../_chunks/dep-bf76dead.js'); require('../_chunks/dep-631750cd.js'); require('../_chunks/dep-22dc294c.js'); require('../_chunks/dep-4cb26289.js'); require('../_chunks/dep-7d9abefd.js'); require('../_chunks/dep-2fb8d44f.js'); require('../_chunks/dep-80a41429.js'); require('../_chunks/dep-91305690.js'); require('../_chunks/dep-0b92e695.js'); require('../_chunks/dep-b2024592.js'); require('../_chunks/dep-9f98bf9b.js'); require('../_chunks/dep-2dcf9237.js'); require('../_chunks/dep-0238ed9a.js'); require('../config-provider/hooks/useConfig.js'); require('../_chunks/dep-be1af85d.js'); require('../_chunks/dep-db9c85b1.js'); require('dayjs'); require('../_chunks/dep-82fe2026.js'); require('../_chunks/dep-33b46a52.js'); require('../_chunks/dep-930a2de5.js'); require('../_chunks/dep-c3bbd06c.js'); require('../_chunks/dep-6d87f74d.js'); require('../_chunks/dep-281f7eb2.js'); require('../_chunks/dep-f8f7b1af.js'); require('../_chunks/dep-66d3f30f.js'); require('../_chunks/dep-e1d22111.js'); require('../_chunks/dep-754c0523.js'); require('../_chunks/dep-7076a08a.js'); require('@babel/runtime/helpers/slicedToArray'); require('../_chunks/dep-2fc884aa.js'); require('../_chunks/dep-75d6da05.js'); require('../_chunks/dep-274369eb.js'); require('../_chunks/dep-df6e14a0.js'); require('../_chunks/dep-c26a7d50.js'); require('../_chunks/dep-0989c3be.js'); require('@babel/runtime/helpers/createClass'); require('@babel/runtime/helpers/classCallCheck'); require('./props.js'); require('./utils/animate.js'); require('./constants/index.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var seed = 0; var instanceMap = /* @__PURE__ */new Map(); var NotificationFunction = function NotificationFunction(options, context) { seed += 1; var hackOptions = _objectSpread({ placement: "top-right", zIndex: 6e3, attach: "body", id: seed }, options); hackOptions.content = options.content ? options.content : ""; var attachEl = dom.getAttach(hackOptions.attach); if (!instanceMap.get(attachEl)) { instanceMap.set(attachEl, {}); } var tmpInstance = instanceMap.get(attachEl)[hackOptions.placement]; if (!tmpInstance) { var wrapper = document.createElement("div"); var instance = Vue.createVNode(notification_notificationList["default"], { placement: hackOptions.placement, offset: hackOptions.offset }); if (context !== null && context !== void 0 ? context : NotificationPlugin._context) { instance.appContext = context !== null && context !== void 0 ? context : NotificationPlugin._context; } attachEl.appendChild(wrapper); Vue.render(instance, wrapper); instance.component.exposed.add(hackOptions); instanceMap.get(attachEl)[hackOptions.placement] = instance; tmpInstance = instance; } else { tmpInstance.component.exposed.add(hackOptions); } return new Promise(function (resolve) { var ins = instanceMap.get(attachEl)[hackOptions.placement]; Vue.nextTick(function () { var _ins$component$expose; var notificationList = (_ins$component$expose = ins.component.exposed.notificationList.value) !== null && _ins$component$expose !== void 0 ? _ins$component$expose : []; resolve(notificationList === null || notificationList === void 0 ? void 0 : notificationList.find(function (notify) { var _notify$$; return ((_notify$$ = notify.$) === null || _notify$$ === void 0 || (_notify$$ = _notify$$.vnode) === null || _notify$$ === void 0 ? void 0 : _notify$$.key) === hackOptions.id; })); }); }); }; var showThemeNotification = function showThemeNotification(theme, options, context) { var hackOptions = _objectSpread(_objectSpread({}, options), {}, { theme: theme }); return NotificationFunction(hackOptions, context); }; var extraApi = { info: function info(options, context) { return showThemeNotification("info", options, context); }, success: function success(options, context) { return showThemeNotification("success", options, context); }, warning: function warning(options, context) { return showThemeNotification("warning", options, context); }, error: function error(options, context) { return showThemeNotification("error", options, context); }, close: function close(promise) { promise.then(function (instance) { return instance.close(); }); }, closeAll: function closeAll() { instanceMap.forEach(function (attach) { Object.keys(attach).forEach(function (placement) { attach[placement].component.exposed.removeAll(); }); }); } }; var NotificationPlugin = showThemeNotification; NotificationPlugin.install = function (app) { app.config.globalProperties.$notify = showThemeNotification; Object.keys(extraApi).forEach(function (funcName) { app.config.globalProperties.$notify[funcName] = extraApi[funcName]; }); NotificationPlugin._context = app._context; }; Object.keys(extraApi).forEach(function (funcName) { NotificationPlugin[funcName] = extraApi[funcName]; }); var NotifyPlugin = NotificationPlugin; exports.NotifyPlugin = NotifyPlugin; exports["default"] = NotificationPlugin; //# sourceMappingURL=plugin.js.map