tdesign-vue-next
Version:
TDesign Component for vue-next
163 lines (155 loc) • 6.74 kB
JavaScript
/**
* tdesign v1.15.2
* (c) 2025 tdesign
* @license MIT
*/
;
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-0a9c2d75.js');
require('./notification.js');
require('tdesign-icons-vue-next');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-040b3cbb.js');
require('../_chunks/dep-0f5dd876.js');
require('../_chunks/dep-9b6bbd57.js');
require('../_chunks/dep-eada02ce.js');
require('../_chunks/dep-63ff6e12.js');
require('../_chunks/dep-c6c5ec69.js');
require('../_chunks/dep-79f734cc.js');
require('../_chunks/dep-ce0157af.js');
require('../_chunks/dep-41b6fe49.js');
require('../_chunks/dep-d388e00e.js');
require('../_chunks/dep-15ce91d8.js');
require('../_chunks/dep-baaf07d6.js');
require('../_chunks/dep-27e5c925.js');
require('../_chunks/dep-13d731e3.js');
require('../_chunks/dep-7cb54b29.js');
require('../_chunks/dep-2544aa61.js');
require('../_chunks/dep-3e1aa2e0.js');
require('../_chunks/dep-ac087407.js');
require('../config-provider/hooks/useConfig.js');
require('../_chunks/dep-ee4f84a5.js');
require('../_chunks/dep-66f974a3.js');
require('dayjs');
require('../_chunks/dep-5e94db90.js');
require('../_chunks/dep-2f309208.js');
require('../_chunks/dep-7154c044.js');
require('../_chunks/dep-020c2a7e.js');
require('../_chunks/dep-79cd6be1.js');
require('../_chunks/dep-06f7d92f.js');
require('../_chunks/dep-0c415789.js');
require('../_chunks/dep-57045e93.js');
require('../_chunks/dep-c66679ef.js');
require('../_chunks/dep-3df90229.js');
require('../_chunks/dep-93426c60.js');
require('@babel/runtime/helpers/slicedToArray');
require('../_chunks/dep-1ec17e27.js');
require('../_chunks/dep-15b276e6.js');
require('../_chunks/dep-4d3ddec0.js');
require('../_chunks/dep-d0f125b5.js');
require('../_chunks/dep-4c12d7dc.js');
require('../_chunks/dep-682444b3.js');
require('@babel/runtime/helpers/createClass');
require('@babel/runtime/helpers/classCallCheck');
require('./props.js');
require('./utils/animate.js');
require('./consts/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
});
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