UNPKG

tdesign-vue

Version:
116 lines (112 loc) 3.97 kB
/** * tdesign v1.14.1 * (c) 2025 tdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import _Notification from './notification.js'; import { PLACEMENT_OFFSET, DEFAULT_Z_INDEX, DISTANCE } from './const.js'; import { getClassPrefixMixins } from '../config-provider/config-receiver.js'; import mixins from '../utils/mixins.js'; import 'lodash-es'; import 'tdesign-icons-vue'; import '../utils/render-tnode.js'; import '@babel/runtime/helpers/readOnlyError'; import '@babel/runtime/helpers/typeof'; import 'vue'; import '@vue/composition-api'; import './props.js'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-ba613a02.js'; import '../_chunks/dep-fdb1b253.js'; import 'dayjs'; import '../_common/js/global-config/t.js'; import '@babel/runtime/helpers/slicedToArray'; 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(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 classPrefixMixins = getClassPrefixMixins("notification"); var NotificationList = mixins(classPrefixMixins).extend({ components: { Notification: _Notification }, props: { placement: { type: String, "default": "top-right", validator: function validator(v) { return ["top-left", "top-right", "bottom-left", "bottom-right"].indexOf(v) > -1; } } }, data: function data() { return { list: [] }; }, computed: { styles: function styles() { return _objectSpread({ zIndex: DEFAULT_Z_INDEX }, PLACEMENT_OFFSET[this.placement]); } }, methods: { add: function add(options) { this.list.push(options); return this.list.length - 1; }, remove: function remove(index) { this.list.splice(index, 1); }, removeAll: function removeAll() { this.list = []; }, getOffset: function getOffset(val) { if (!val) return; return isNaN(Number(val)) ? val : "".concat(val, "px"); }, notificationStyles: function notificationStyles(item) { var styles = { marginBottom: DISTANCE }; if (item.offset) { styles.position = "relative"; styles.left = this.getOffset(item.offset[0]); styles.top = this.getOffset(item.offset[1]); } if (item.zIndex) styles["z-index"] = item.zIndex; return styles; }, getListeners: function getListeners(index) { var _this = this; return { "close-btn-click": function closeBtnClick() { return _this.remove(index); }, "duration-end": function durationEnd() { return _this.remove(index); } }; } }, render: function render() { var _this2 = this; var h = arguments[0]; if (!this.list.length) return; return h("div", { "class": "".concat(this.componentName, "__show--").concat(this.placement), "style": this.styles }, [this.list.map(function (item, index) { return h("t-notification", { "key": item.id, "style": _this2.notificationStyles(item), "props": _objectSpread({}, item), "on": _objectSpread({}, _this2.getListeners(index)) }); })]); } }); export { NotificationList as default }; //# sourceMappingURL=notificationList.js.map