UNPKG

view-ui-plus

Version:

A high quality UI components Library with Vue.js 3

1,578 lines 1.25 MB
import { nextTick, openBlock, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, renderSlot, withDirectives, vShow, resolveComponent, createBlock, Transition, withCtx, createVNode, createCommentVNode, resolveDynamicComponent, inject, withModifiers, toDisplayString, h, Teleport, mergeProps, getCurrentInstance, Fragment, renderList, createTextVNode, withKeys, vModelText, resolveDirective, vModelCheckbox, TransitionGroup, createApp, normalizeProps, guardReactiveProps, defineComponent, toHandlers, Comment, Text, setBlockTracking, createSlots } from "vue"; const isClient = typeof window !== "undefined"; const on = function() { if (isClient && document.addEventListener) { return function(element, event, handler, useCapture = false) { if (element && event && handler) { element.addEventListener(event, handler, useCapture); } }; } else { return function(element, event, handler) { if (element && event && handler) { element.attachEvent("on" + event, handler); } }; } }(); const off = function() { if (isClient && document.removeEventListener) { return function(element, event, handler, useCapture = false) { if (element && event) { element.removeEventListener(event, handler, useCapture); } }; } else { return function(element, event, handler) { if (element && event) { element.detachEvent("on" + event, handler); } }; } }(); var _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key2, val] of props) { target[key2] = val; } return target; }; const prefixCls$1m = "ivu-affix"; function getScroll(target, top2) { const prop2 = top2 ? "pageYOffset" : "pageXOffset"; const method3 = top2 ? "scrollTop" : "scrollLeft"; let ret = target[prop2]; if (isClient && typeof ret !== "number") { ret = window.document.documentElement[method3]; } return ret; } function getOffset(element) { if (!isClient) return; const rect = element.getBoundingClientRect(); const scrollTop2 = getScroll(window, true); const scrollLeft = getScroll(window); const docEl = window.document.body; const clientTop = docEl.clientTop || 0; const clientLeft = docEl.clientLeft || 0; return { top: rect.top + scrollTop2 - clientTop, left: rect.left + scrollLeft - clientLeft }; } const _sfc_main$2v = { name: "Affix", emits: ["on-change"], props: { offsetTop: { type: Number, default: 0 }, offsetBottom: { type: Number }, useCapture: { type: Boolean, default: false } }, data() { return { affix: false, styles: {}, slot: false, slotStyle: {} }; }, computed: { offsetType() { let type2 = "top"; if (this.offsetBottom >= 0) { type2 = "bottom"; } return type2; }, classes() { return [ { [`${prefixCls$1m}`]: this.affix } ]; } }, mounted() { on(window, "scroll", this.handleScroll, this.useCapture); on(window, "resize", this.handleScroll, this.useCapture); nextTick(() => { this.handleScroll(); }); }, beforeUnmount() { off(window, "scroll", this.handleScroll, this.useCapture); off(window, "resize", this.handleScroll, this.useCapture); }, methods: { handleScroll() { if (!isClient) return; const affix = this.affix; const scrollTop2 = getScroll(window, true); const elOffset = getOffset(this.$el); const windowHeight = window.innerHeight; const elHeight = this.$el.getElementsByTagName("div")[0].offsetHeight; if (elOffset.top - this.offsetTop < scrollTop2 && this.offsetType == "top" && !affix) { this.affix = true; this.slotStyle = { width: this.$refs.point.clientWidth + "px", height: this.$refs.point.clientHeight + "px" }; this.slot = true; this.styles = { top: `${this.offsetTop}px`, left: `${elOffset.left}px`, width: `${this.$el.offsetWidth}px` }; this.$emit("on-change", true); } else if (elOffset.top - this.offsetTop > scrollTop2 && this.offsetType == "top" && affix) { this.slot = false; this.slotStyle = {}; this.affix = false; this.styles = null; this.$emit("on-change", false); } if (elOffset.top + this.offsetBottom + elHeight > scrollTop2 + windowHeight && this.offsetType == "bottom" && !affix) { this.affix = true; this.styles = { bottom: `${this.offsetBottom}px`, left: `${elOffset.left}px`, width: `${this.$el.offsetWidth}px` }; this.$emit("on-change", true); } else if (elOffset.top + this.offsetBottom + elHeight < scrollTop2 + windowHeight && this.offsetType == "bottom" && affix) { this.affix = false; this.styles = null; this.$emit("on-change", false); } } } }; function _sfc_render$2e(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", null, [ createElementVNode("div", { ref: "point", class: normalizeClass($options.classes), style: normalizeStyle($data.styles) }, [ renderSlot(_ctx.$slots, "default") ], 6), withDirectives(createElementVNode("div", { style: normalizeStyle($data.slotStyle) }, null, 4), [ [vShow, $data.slot] ]) ]); } var Affix = /* @__PURE__ */ _export_sfc(_sfc_main$2v, [["render", _sfc_render$2e]]); const prefixCls$1l = "ivu-icon"; const _sfc_main$2u = { name: "Icon", props: { type: { type: String, default: "" }, size: [Number, String], color: String, custom: { type: String, default: "" } }, computed: { classes() { return [ `${prefixCls$1l}`, { [`${prefixCls$1l}-${this.type}`]: this.type !== "", [`${this.custom}`]: this.custom !== "" } ]; }, styles() { let style2 = {}; if (this.size) style2["font-size"] = `${this.size}px`; if (this.color) style2.color = this.color; return style2; } } }; function _sfc_render$2d(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("i", { class: normalizeClass($options.classes), style: normalizeStyle($options.styles) }, null, 6); } var Icon = /* @__PURE__ */ _export_sfc(_sfc_main$2u, [["render", _sfc_render$2d]]); function oneOf(value, validList) { for (let i = 0; i < validList.length; i++) { if (value === validList[i]) { return true; } } return false; } let cached; function getScrollBarSize(fresh) { if (isClient && (fresh || cached === void 0)) { const inner = document.createElement("div"); inner.style.width = "100%"; inner.style.height = "200px"; const outer = document.createElement("div"); const outerStyle = outer.style; outerStyle.position = "absolute"; outerStyle.top = 0; outerStyle.left = 0; outerStyle.pointerEvents = "none"; outerStyle.visibility = "hidden"; outerStyle.width = "200px"; outerStyle.height = "150px"; outerStyle.overflow = "hidden"; outer.appendChild(inner); document.body.appendChild(outer); const widthContained = inner.offsetWidth; outer.style.overflow = "scroll"; let widthScroll = inner.offsetWidth; if (widthContained === widthScroll) { widthScroll = outer.clientWidth; } document.body.removeChild(outer); cached = widthContained - widthScroll; } return cached; } const MutationObserver = isClient ? window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver || false : false; const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; const MOZ_HACK_REGEXP = /^moz([A-Z])/; function camelCase(name2) { return name2.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) { return offset ? letter.toUpperCase() : letter; }).replace(MOZ_HACK_REGEXP, "Moz$1"); } function getStyle(element, styleName) { if (!isClient) return; if (!element || !styleName) return null; styleName = camelCase(styleName); if (styleName === "float") { styleName = "cssFloat"; } try { const computed = document.defaultView.getComputedStyle(element, ""); return element.style[styleName] || computed ? computed[styleName] : null; } catch (e) { return element.style[styleName]; } } function firstUpperCase(str) { return str.toString()[0].toUpperCase() + str.toString().slice(1); } function typeOf(obj) { const toString2 = Object.prototype.toString; const map = { "[object Boolean]": "boolean", "[object Number]": "number", "[object String]": "string", "[object Function]": "function", "[object Array]": "array", "[object Date]": "date", "[object RegExp]": "regExp", "[object Undefined]": "undefined", "[object Null]": "null", "[object Object]": "object" }; return map[toString2.call(obj)]; } function deepCopy(data) { const t2 = typeOf(data); let o; if (t2 === "array") { o = []; } else if (t2 === "object") { o = {}; } else { return data; } if (t2 === "array") { for (let i = 0; i < data.length; i++) { o.push(deepCopy(data[i])); } } else if (t2 === "object") { for (let i in data) { o[i] = deepCopy(data[i]); } } return o; } function scrollTop(el, from = 0, to, duration2 = 500, endCallback) { if (!isClient) return; if (!window.requestAnimationFrame) { window.requestAnimationFrame = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) { return window.setTimeout(callback, 1e3 / 60); }; } const difference = Math.abs(from - to); const step = Math.ceil(difference / duration2 * 50); function scroll2(start, end, step2) { if (start === end) { endCallback && endCallback(); return; } let d = start + step2 > end ? end : start + step2; if (start > end) { d = start - step2 < end ? end : start - step2; } if (el === window) { window.scrollTo(d, d); } else { el.scrollTop = d; } window.requestAnimationFrame(() => scroll2(d, end, step2)); } scroll2(from, to, step); } function findComponentUpward(context, componentName, componentNames) { if (typeof componentName === "string") { componentNames = [componentName]; } else { componentNames = componentName; } let parent = context.$parent; let name2 = parent.$options.name; while (parent && (!name2 || componentNames.indexOf(name2) < 0)) { parent = parent.$parent; if (parent) name2 = parent.$options.name; } return parent; } function findComponentsUpward(context, componentName) { let parents = []; const parent = context.$parent; if (parent) { if (parent.$options.name === componentName) parents.push(parent); return parents.concat(findComponentsUpward(parent, componentName)); } else { return []; } } const trim = function(string2) { return (string2 || "").replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, ""); }; function hasClass(el, cls) { if (!el || !cls) return false; if (cls.indexOf(" ") !== -1) throw new Error("className should not contain space."); if (el.classList) { return el.classList.contains(cls); } else { return (" " + el.className + " ").indexOf(" " + cls + " ") > -1; } } function addClass(el, cls) { if (!el) return; let curClass = el.className; const classes = (cls || "").split(" "); for (let i = 0, j = classes.length; i < j; i++) { const clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.add(clsName); } else { if (!hasClass(el, clsName)) { curClass += " " + clsName; } } } if (!el.classList) { el.className = curClass; } } function removeClass(el, cls) { if (!el || !cls) return; const classes = cls.split(" "); let curClass = " " + el.className + " "; for (let i = 0, j = classes.length; i < j; i++) { const clsName = classes[i]; if (!clsName) continue; if (el.classList) { el.classList.remove(clsName); } else { if (hasClass(el, clsName)) { curClass = curClass.replace(" " + clsName + " ", " "); } } } if (!el.classList) { el.className = trim(curClass); } } const dimensionMap = { xs: "480px", sm: "576px", md: "768px", lg: "992px", xl: "1200px", xxl: "1600px" }; function setMatchMedia() { if (!isClient) return; const matchMediaPolyfill = (mediaQuery) => { return { media: mediaQuery, matches: false, on() { }, off() { } }; }; window.matchMedia = window.matchMedia || matchMediaPolyfill; } const sharpMatcherRegx = /#([^#]+)$/; async function downloadFile(url2, name2 = "unnamed") { if (!isClient) return Promise.reject(); try { const res = await fetch(url2); const blob = await res.blob(); if (!blob) return Promise.reject(); const localUrl = URL.createObjectURL(blob); const a = document.createElement("a"); a.setAttribute("href", localUrl); a.setAttribute("download", name2); a.click(); URL.revokeObjectURL(localUrl); return Promise.resolve(); } catch (e) { return Promise.reject(e); } } const prefixCls$1k = "ivu-alert"; const _sfc_main$2t = { name: "Alert", components: { Icon }, props: { type: { validator(value) { return oneOf(value, ["success", "info", "warning", "error"]); }, default: "info" }, closable: { type: Boolean, default: false }, showIcon: { type: Boolean, default: false }, banner: { type: Boolean, default: false }, fade: { type: Boolean, default: true } }, data() { return { closed: false, desc: false }; }, computed: { wrapClasses() { return [ `${prefixCls$1k}`, `${prefixCls$1k}-${this.type}`, { [`${prefixCls$1k}-with-icon`]: this.showIcon, [`${prefixCls$1k}-with-desc`]: this.desc, [`${prefixCls$1k}-with-banner`]: this.banner } ]; }, messageClasses() { return `${prefixCls$1k}-message`; }, descClasses() { return `${prefixCls$1k}-desc`; }, closeClasses() { return `${prefixCls$1k}-close`; }, iconClasses() { return `${prefixCls$1k}-icon`; }, iconType() { let type2 = ""; switch (this.type) { case "success": type2 = "ios-checkmark-circle"; break; case "info": type2 = "ios-information-circle"; break; case "warning": type2 = "ios-alert"; break; case "error": type2 = "ios-close-circle"; break; } if (this.desc) type2 += "-outline"; return type2; } }, methods: { close(e) { this.closed = true; this.$emit("on-close", e); } }, mounted() { this.desc = this.$slots.desc !== void 0; } }; function _sfc_render$2c(_ctx, _cache, $props, $setup, $data, $options) { const _component_Icon = resolveComponent("Icon"); return openBlock(), createBlock(Transition, { name: $props.fade ? "fade" : "" }, { default: withCtx(() => [ !$data.closed ? (openBlock(), createElementBlock("div", { key: 0, class: normalizeClass($options.wrapClasses) }, [ $props.showIcon ? (openBlock(), createElementBlock("span", { key: 0, class: normalizeClass($options.iconClasses) }, [ renderSlot(_ctx.$slots, "icon", {}, () => [ createVNode(_component_Icon, { type: $options.iconType }, null, 8, ["type"]) ]) ], 2)) : createCommentVNode("", true), createElementVNode("span", { class: normalizeClass($options.messageClasses) }, [ renderSlot(_ctx.$slots, "default") ], 2), createElementVNode("span", { class: normalizeClass($options.descClasses) }, [ renderSlot(_ctx.$slots, "desc") ], 2), $props.closable ? (openBlock(), createElementBlock("a", { key: 1, class: normalizeClass($options.closeClasses), onClick: _cache[0] || (_cache[0] = (...args) => $options.close && $options.close(...args)) }, [ renderSlot(_ctx.$slots, "close", {}, () => [ createVNode(_component_Icon, { type: "ios-close" }) ]) ], 2)) : createCommentVNode("", true) ], 2)) : createCommentVNode("", true) ]), _: 3 }, 8, ["name"]); } var Alert = /* @__PURE__ */ _export_sfc(_sfc_main$2t, [["render", _sfc_render$2c]]); const _sfc_main$2s = { name: "Anchor", provide() { return { AnchorInstance: this }; }, emits: ["on-change", "on-select"], props: { affix: { type: Boolean, default: true }, offsetTop: { type: Number, default: 0 }, offsetBottom: Number, bounds: { type: Number, default: 5 }, container: null, showInk: { type: Boolean, default: false }, scrollOffset: { type: Number, default: 0 } }, data() { return { prefix: "ivu-anchor", isAffixed: false, inkTop: 0, animating: false, currentLink: "", currentId: "", scrollContainer: null, scrollElement: null, wrapperTop: 0, upperFirstTitle: true, links: [] }; }, computed: { wrapperComponent() { return this.affix ? "Affix" : "div"; }, wrapperStyle() { return { maxHeight: this.offsetTop ? `calc(100vh - ${this.offsetTop}px)` : "100vh" }; }, containerIsWindow() { return this.scrollContainer === window; }, titlesOffsetArr() { const links = this.links.map((item) => { return item.link.href; }); const idArr = links.map((link) => { return link.split("#")[1]; }); let offsetArr = []; isClient && idArr.forEach((id) => { const titleEle = document.getElementById(id); if (titleEle) offsetArr.push({ link: `#${id}`, offset: titleEle.offsetTop - this.scrollElement.offsetTop }); }); return offsetArr; } }, methods: { handleAffixStateChange(state) { this.isAffixed = this.affix && state; }, handleScroll(e) { this.upperFirstTitle = !!this.titlesOffsetArr[0] && e.target.scrollTop < this.titlesOffsetArr[0].offset; if (this.animating) return; const scrollTop2 = isClient ? document.documentElement.scrollTop || document.body.scrollTop || e.target.scrollTop : 0; this.getCurrentScrollAtTitleId(scrollTop2); }, handleHashChange() { if (!isClient) return; const url2 = window.location.href; const sharpLinkMatch = sharpMatcherRegx.exec(url2); if (!sharpLinkMatch) return; this.currentLink = sharpLinkMatch[0]; this.currentId = sharpLinkMatch[1]; }, handleScrollTo() { if (!isClient) return; const anchor = document.getElementById(this.currentId); const currentLinkElementA = document.querySelector(`a[data-href="${this.currentLink}"]`); let offset = this.scrollOffset; if (currentLinkElementA) { offset = parseFloat(currentLinkElementA.getAttribute("data-scroll-offset")); } if (!anchor) return; const offsetTop = anchor.offsetTop - this.wrapperTop - offset; this.animating = true; scrollTop(this.scrollContainer, this.scrollElement.scrollTop, offsetTop, 600, () => { this.animating = false; }); this.handleSetInkTop(); }, handleSetInkTop() { if (!isClient) return; const currentLinkElementA = document.querySelector(`a[data-href="${this.currentLink}"]`); if (!currentLinkElementA) return; const elementATop = currentLinkElementA.offsetTop; const top2 = elementATop < 0 ? this.offsetTop : elementATop; this.inkTop = top2; }, getCurrentScrollAtTitleId(scrollTop2) { let i = -1; let len = this.titlesOffsetArr.length; let titleItem = { link: "#", offset: 0 }; scrollTop2 += this.bounds; while (++i < len) { let currentEle = this.titlesOffsetArr[i]; let nextEle = this.titlesOffsetArr[i + 1]; if (scrollTop2 >= currentEle.offset && scrollTop2 < (nextEle && nextEle.offset || Infinity)) { titleItem = this.titlesOffsetArr[i]; break; } } this.currentLink = titleItem.link; this.handleSetInkTop(); }, getContainer() { if (!isClient) return; this.scrollContainer = this.container ? typeof this.container === "string" ? document.querySelector(this.container) : this.container : window; this.scrollElement = this.container ? this.scrollContainer : document.documentElement || document.body; }, removeListener() { off(this.scrollContainer, "scroll", this.handleScroll); off(window, "hashchange", this.handleHashChange); }, init() { this.handleHashChange(); nextTick(() => { this.removeListener(); this.getContainer(); this.wrapperTop = this.containerIsWindow ? 0 : this.scrollElement.offsetTop; this.handleScrollTo(); this.handleSetInkTop(); if (this.titlesOffsetArr[0]) { this.upperFirstTitle = this.scrollElement.scrollTop < this.titlesOffsetArr[0].offset; } on(this.scrollContainer, "scroll", this.handleScroll); on(window, "hashchange", this.handleHashChange); }); }, addLink(id, link) { this.links.push({ id, link }); }, removeLink(id) { const linkIndex = this.links.findIndex((item) => item.id === id); this.links.splice(linkIndex, 1); } }, watch: { "$route"() { this.currentLink = ""; this.currentId = ""; this.handleHashChange(); nextTick(() => { this.handleScrollTo(); }); }, container() { this.init(); }, currentLink(newHref, oldHref) { this.$emit("on-change", newHref, oldHref); } }, mounted() { this.init(); }, beforeUnmount() { this.removeListener(); } }; function _sfc_render$2b(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createBlock(resolveDynamicComponent($options.wrapperComponent), { "offset-top": $props.offsetTop, "offset-bottom": $props.offsetBottom, onOnChange: $options.handleAffixStateChange }, { default: withCtx(() => [ createElementVNode("div", { class: normalizeClass(`${$data.prefix}-wrapper`), style: normalizeStyle($options.wrapperStyle) }, [ createElementVNode("div", { class: normalizeClass(`${$data.prefix}`) }, [ createElementVNode("div", { class: normalizeClass(`${$data.prefix}-ink`) }, [ withDirectives(createElementVNode("span", { class: normalizeClass(`${$data.prefix}-ink-ball`), style: normalizeStyle({ top: `${$data.inkTop}px` }) }, null, 6), [ [vShow, $props.showInk] ]) ], 2), renderSlot(_ctx.$slots, "default") ], 2) ], 6) ]), _: 3 }, 40, ["offset-top", "offset-bottom", "onOnChange"]); } var Anchor = /* @__PURE__ */ _export_sfc(_sfc_main$2s, [["render", _sfc_render$2b]]); function random(len = 32) { const $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; const maxPos = $chars.length; let str = ""; for (let i = 0; i < len; i++) { str += $chars.charAt(Math.floor(Math.random() * maxPos)); } return str; } const _sfc_main$2r = { name: "AnchorLink", inject: ["AnchorInstance"], props: { href: String, title: String, scrollOffset: { type: Number, default() { return inject("AnchorInstance").scrollOffset; } } }, data() { return { prefix: "ivu-anchor-link", id: random(6) }; }, computed: { anchorLinkClasses() { return [ this.prefix, this.AnchorInstance.currentLink === this.href ? `${this.prefix}-active` : "" ]; }, linkTitleClasses() { return [ `${this.prefix}-title` ]; } }, methods: { goAnchor() { this.currentLink = this.href; this.AnchorInstance.handleHashChange(); this.AnchorInstance.handleScrollTo(); this.AnchorInstance.$emit("on-select", this.href); const isRoute = this.$router; if (isRoute) { this.$router.push(this.href, () => { }); } else { isClient && (window.location.href = this.href); } } }, mounted() { this.AnchorInstance.addLink(this.id, this); nextTick(() => { this.AnchorInstance.init(); }); }, beforeUnmount() { this.AnchorInstance.removeLink(this.id); } }; const _hoisted_1$1h = ["href", "data-scroll-offset", "data-href", "title"]; function _sfc_render$2a(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", { class: normalizeClass($options.anchorLinkClasses) }, [ createElementVNode("a", { class: normalizeClass($options.linkTitleClasses), href: $props.href, "data-scroll-offset": $props.scrollOffset, "data-href": $props.href, onClick: _cache[0] || (_cache[0] = withModifiers((...args) => $options.goAnchor && $options.goAnchor(...args), ["prevent"])), title: $props.title }, toDisplayString($props.title), 11, _hoisted_1$1h), renderSlot(_ctx.$slots, "default") ], 2); } var AnchorLink = /* @__PURE__ */ _export_sfc(_sfc_main$2r, [["render", _sfc_render$2a]]); var mixinsLink = { props: { to: { type: [Object, String] }, replace: { type: Boolean, default: false }, target: { type: String, validator(value) { return oneOf(value, ["_blank", "_self", "_parent", "_top"]); }, default: "_self" }, append: { type: Boolean, required: false, default: false } }, computed: { linkUrl() { const type2 = typeof this.to; if (type2 !== "string") { return null; } if (this.to.includes("//")) { return this.to; } const router = this.$router; if (router) { const current = this.$route; const route = router.resolve(this.to, current, this.append); return route ? route.href : this.to; } return this.to; } }, methods: { handleOpenTo() { if (!isClient) return; const router = this.$router; let to = this.to; if (router) { const current = this.$route; const route = router.resolve(this.to, current, this.append); to = route ? route.href : this.to; } if (typeof this.to === "string") return; window.open(to); }, handleClick(new_window = false) { const router = this.$router; if (!isClient) return; if (new_window) { this.handleOpenTo(); } else { if (router) { if (typeof this.to === "string" && this.to.includes("//")) { window.location.href = this.to; } else { this.replace ? this.$router.replace(this.to, () => { }) : this.$router.push(this.to, () => { }); } } else { window.location.href = this.to; } } }, handleCheckClick(event, new_window = false) { if (this.to) { if (this.target === "_blank") { this.handleOpenTo(); return false; } else { event.preventDefault(); this.handleClick(new_window); } } } } }; function includeArray(list1, list2) { let status = false; list2.forEach((item) => { if (list1.includes(item)) status = true; }); return status; } const _sfc_main$2q = { name: "Auth", mixins: [mixinsLink], emits: ["click"], props: { authority: { type: [String, Array, Function, Boolean], default: true }, access: { type: [String, Array] }, prevent: { type: Boolean, default: false }, message: { type: String, default: "\u60A8\u6CA1\u6709\u6743\u9650\u8FDB\u884C\u6B64\u64CD\u4F5C" }, customTip: { type: Boolean, default: false }, display: { type: String } }, computed: { isPermission() { let state; if (typeof this.authority === "boolean") { state = this.authority; } else if (this.authority instanceof Function) { state = this.authority(); } else { const authority = typeof this.authority === "string" ? [this.authority] : this.authority; const access = typeof this.access === "string" ? [this.access] : this.access; state = includeArray(authority, access); } return state; }, options() { let style2 = {}; if (this.display) style2.display = this.display; return { class: { "ivu-auth": true, "ivu-auth-permission": this.isPermission, "ivu-auth-no-math": !this.isPermission, "ivu-auth-redirect": !this.isPermission && this.to, "ivu-auth-prevent": this.prevent }, style: style2 }; } }, render() { if (this.isPermission) { return h("div", this.options, this.$slots.default()); } else { if (this.to) { return h("div", this.options); } else { if (this.prevent) { return h("div", Object.assign({}, this.options, { onClick: this.handlePreventClick }), [ h("div", { class: "ivu-auth-prevent-no-match" }, this.$slots.default()) ]); } else { return h("div", this.options, this.$slots.noMatch()); } } } }, methods: { handlePreventClick(event) { if (!this.isPermission) { if (!this.customTip) { this.$Message.info({ content: this.message, duration: 3 }); } this.$emit("click", event); } } }, created() { if (!this.isPermission && this.to) { this.handleClick(false); } } }; var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function commonjsRequire(path) { throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var popper = { exports: {} }; /**! * @fileOverview Kickass library to create and place poppers near their reference elements. * @version 1.16.1 * @license * Copyright (c) 2016 Federico Zivolo and contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ (function(module, exports) { (function(global2, factory) { module.exports = factory(); })(commonjsGlobal, function() { var isBrowser = typeof window !== "undefined" && typeof document !== "undefined" && typeof navigator !== "undefined"; var timeoutDuration = function() { var longerTimeoutBrowsers = ["Edge", "Trident", "Firefox"]; for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) { return 1; } } return 0; }(); function microtaskDebounce(fn) { var called = false; return function() { if (called) { return; } called = true; window.Promise.resolve().then(function() { called = false; fn(); }); }; } function taskDebounce(fn) { var scheduled = false; return function() { if (!scheduled) { scheduled = true; setTimeout(function() { scheduled = false; fn(); }, timeoutDuration); } }; } var supportsMicroTasks = isBrowser && window.Promise; var debounce2 = supportsMicroTasks ? microtaskDebounce : taskDebounce; function isFunction2(functionToCheck) { var getType2 = {}; return functionToCheck && getType2.toString.call(functionToCheck) === "[object Function]"; } function getStyleComputedProperty(element, property) { if (element.nodeType !== 1) { return []; } var window2 = element.ownerDocument.defaultView; var css = window2.getComputedStyle(element, null); return property ? css[property] : css; } function getParentNode(element) { if (element.nodeName === "HTML") { return element; } return element.parentNode || element.host; } function getScrollParent(element) { if (!element) { return document.body; } switch (element.nodeName) { case "HTML": case "BODY": return element.ownerDocument.body; case "#document": return element.body; } var _getStyleComputedProp = getStyleComputedProperty(element), overflow = _getStyleComputedProp.overflow, overflowX = _getStyleComputedProp.overflowX, overflowY = _getStyleComputedProp.overflowY; if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) { return element; } return getScrollParent(getParentNode(element)); } function getReferenceNode(reference) { return reference && reference.referenceNode ? reference.referenceNode : reference; } var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode); var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent); function isIE(version2) { if (version2 === 11) { return isIE11; } if (version2 === 10) { return isIE10; } return isIE11 || isIE10; } function getOffsetParent(element) { if (!element) { return document.documentElement; } var noOffsetParent = isIE(10) ? document.body : null; var offsetParent = element.offsetParent || null; while (offsetParent === noOffsetParent && element.nextElementSibling) { offsetParent = (element = element.nextElementSibling).offsetParent; } var nodeName = offsetParent && offsetParent.nodeName; if (!nodeName || nodeName === "BODY" || nodeName === "HTML") { return element ? element.ownerDocument.documentElement : document.documentElement; } if (["TH", "TD", "TABLE"].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, "position") === "static") { return getOffsetParent(offsetParent); } return offsetParent; } function isOffsetContainer(element) { var nodeName = element.nodeName; if (nodeName === "BODY") { return false; } return nodeName === "HTML" || getOffsetParent(element.firstElementChild) === element; } function getRoot(node) { if (node.parentNode !== null) { return getRoot(node.parentNode); } return node; } function findCommonOffsetParent(element1, element2) { if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) { return document.documentElement; } var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING; var start = order ? element1 : element2; var end = order ? element2 : element1; var range2 = document.createRange(); range2.setStart(start, 0); range2.setEnd(end, 0); var commonAncestorContainer = range2.commonAncestorContainer; if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) { if (isOffsetContainer(commonAncestorContainer)) { return commonAncestorContainer; } return getOffsetParent(commonAncestorContainer); } var element1root = getRoot(element1); if (element1root.host) { return findCommonOffsetParent(element1root.host, element2); } else { return findCommonOffsetParent(element1, getRoot(element2).host); } } function getScroll2(element) { var side = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "top"; var upperSide = side === "top" ? "scrollTop" : "scrollLeft"; var nodeName = element.nodeName; if (nodeName === "BODY" || nodeName === "HTML") { var html = element.ownerDocument.documentElement; var scrollingElement = element.ownerDocument.scrollingElement || html; return scrollingElement[upperSide]; } return element[upperSide]; } function includeScroll(rect, element) { var subtract = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false; var scrollTop2 = getScroll2(element, "top"); var scrollLeft = getScroll2(element, "left"); var modifier = subtract ? -1 : 1; rect.top += scrollTop2 * modifier; rect.bottom += scrollTop2 * modifier; rect.left += scrollLeft * modifier; rect.right += scrollLeft * modifier; return rect; } function getBordersSize(styles, axis) { var sideA = axis === "x" ? "Left" : "Top"; var sideB = sideA === "Left" ? "Right" : "Bottom"; return parseFloat(styles["border" + sideA + "Width"]) + parseFloat(styles["border" + sideB + "Width"]); } function getSize(axis, body, html, computedStyle) { return Math.max(body["offset" + axis], body["scroll" + axis], html["client" + axis], html["offset" + axis], html["scroll" + axis], isIE(10) ? parseInt(html["offset" + axis]) + parseInt(computedStyle["margin" + (axis === "Height" ? "Top" : "Left")]) + parseInt(computedStyle["margin" + (axis === "Height" ? "Bottom" : "Right")]) : 0); } function getWindowSizes(document2) { var body = document2.body; var html = document2.documentElement; var computedStyle = isIE(10) && getComputedStyle(html); return { height: getSize("Height", body, html, computedStyle), width: getSize("Width", body, html, computedStyle) }; } var classCallCheck = function(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; var createClass = function() { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function(Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var defineProperty = function(obj, key2, value) { if (key2 in obj) { Object.defineProperty(obj, key2, { value, enumerable: true, configurable: true, writable: true }); } else { obj[key2] = value; } return obj; }; var _extends2 = Object.assign || function(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key2 in source) { if (Object.prototype.hasOwnProperty.call(source, key2)) { target[key2] = source[key2]; } } } return target; }; function getClientRect(offsets) { return _extends2({}, offsets, { right: offsets.left + offsets.width, bottom: offsets.top + offsets.height }); } function getBoundingClientRect(element) { var rect = {}; try { if (isIE(10)) { rect = element.getBoundingClientRect(); var scrollTop2 = getScroll2(element, "top"); var scrollLeft = getScroll2(element, "left"); rect.top += scrollTop2; rect.left += scrollLeft; rect.bottom += scrollTop2; rect.right += scrollLeft; } else { rect = element.getBoundingClientRect(); } } catch (e) { } var result = { left: rect.left, top: rect.top, width: rect.right - rect.left, height: rect.bottom - rect.top }; var sizes = element.nodeName === "HTML" ? getWindowSizes(element.ownerDocument) : {}; var width = sizes.width || element.clientWidth || result.width; var height2 = sizes.height || element.clientHeight || result.height; var horizScrollbar = element.offsetWidth - width; var vertScrollbar = element.offsetHeight - height2; if (horizScrollbar || vertScrollbar) { var styles = getStyleComputedProperty(element); horizScrollbar -= getBordersSize(styles, "x"); vertScrollbar -= getBordersSize(styles, "y"); result.width -= horizScrollbar; result.height -= vertScrollbar; } return getClientRect(result); } function getOffsetRectRelativeToArbitraryNode(children, parent) { var fixedPosition = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false; var isIE102 = isIE(10); var isHTML = parent.nodeName === "HTML"; var childrenRect = getBoundingClientRect(children); var parentRect = getBoundingClientRect(parent); var scrollParent = getScrollParent(children); var styles = getStyleComputedProperty(parent); var borderTopWidth = parseFloat(styles.borderTopWidth); var borderLeftWidth = parseFloat(styles.borderLeftWidth); if (fixedPosition && isHTML) { parentRect.top = Math.max(parentRect.top, 0); parentRect.left = Math.max(parentRect.left, 0); } var offsets = getClientRect({ top: childrenRect.top - parentRect.top - borderTopWidth, left: childrenRect.left - parentRect.left - borderLeftWidth, width: childrenRect.width, height: childrenRect.height }); offsets.marginTop = 0; offsets.marginLeft = 0; if (!isIE102 && isHTML) { var marginTop = parseFloat(styles.marginTop); var marginLeft = parseFloat(styles.marginLeft); offsets.top -= borderTopWidth - marginTop; offsets.bottom -= borderTopWidth - marginTop; offsets.left -= borderLeftWidth - marginLeft; offsets.right -= borderLeftWidth - marginLeft; offsets.marginTop = marginTop; offsets.marginLeft = marginLeft; } if (isIE102 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== "BODY") { offsets = includeScroll(offsets, parent); } return offsets; } function getViewportOffsetRectRelativeToArtbitraryNode(element) { var excludeScroll = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; var html = element.ownerDocument.documentElement; var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html); var width = Math.max(html.clientWidth, window.innerWidth || 0); var height2 = Math.max(html.clientHeight, window.innerHeight || 0); var scrollTop2 = !excludeScroll ? getScroll2(html) : 0; var scrollLeft = !excludeScroll ? getScroll2(html, "left") : 0; var offset2 = { top: scrollTop2 - relativeOffset.top + relativeOffset.marginTop, left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft, width, height: height2 }; return getClientRect(offset2); } function isFixed(element) { var nodeName = element.nodeName; if (nodeName === "BODY" || nodeName === "HTML") { return false; } if (getStyleComputedProperty(element, "position") === "fixed") { return true; } var parentNode = getParentNode(element); if (!parentNode) { return false; } return isFixed(parentNode); } function getFixedPositionOffsetParent(element) { if (!element || !element.parentElement || isIE()) { return document.documentElement; } var el = element.parentElement; while (el && getStyleComputedProperty(el, "transform") === "none") { el = el.parentElement; } return el || document.documentElement; } function getBoundaries(popper2, reference, padding, boundariesElement) { var fixedPosition = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false; var boundaries = { top: 0, left: 0 }; var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper2) : findCommonOffsetParent(popper2, getReferenceNode(reference)); if (boundariesElement === "viewport") { boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition); } else { var boundariesNode = void 0; if (boundariesElement === "scrollParent") { boundariesNode = getScrollParent(getParentNode(reference)); if (boundariesNode.nodeName === "BODY") { boundariesNode = popper2.ownerDocument.documentElement; } } else if (boundariesElement === "window") { boundariesNode = popper2.ownerDocument.documentElement; } else { boundariesNode = boundariesElement; } var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition); if (boundariesNode.nodeName === "HTML" && !isFixed(offsetParent)) { var _getWindowSizes = getWindowSizes(popper2.ownerDocument), height2 = _getWindowSizes.height, width = _getWindowSizes.width; boundaries.top += offsets.top - offsets.marginTop; boundaries.bottom = height2 + offsets.top; boundaries.left += offsets.left - offsets.marginLeft; boundaries.right = width + offsets.left; } else { boundaries = offsets; } } padding = padding || 0; var isPaddingNumber = typeof padding === "number"; boundaries.left += isPaddingNumber ? padding : padding.left || 0; boundaries.top += isPaddingNumber ? padding : padding.top || 0; boundaries.right -= isPaddingNumber ? padding : padding.right || 0; boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0; return boundaries; } function getArea(_ref) { var width = _ref.width, height2 = _ref.height; return width * height2; } function computeAutoPlacement(placement, refRect, popper2, reference, boundariesElement) { var padding = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 0; if (placement.indexOf("auto") === -1) { return placement; } var boundaries = getBoundaries(popper2, reference, padding, boundariesElement); var rects = { top: { width: boundaries.width, height: refRect.top - boundaries.top }, right: { width: boundaries.right - refRect.right, height: boundaries.height }, bottom: { width: boundaries.width, height: boundaries.bottom - refRect.bottom }, left: { width: refRect.left - boundaries.left, height: boundaries.height } }; var sortedAreas = Object.keys(rects).map(function(key2) { return _extends2({ key: key2 }, rects[key2], { area: getArea(rects[key2]) }); }).sort(function(a, b) { return b.area - a.area; }); var filteredAreas = sortedAreas.filter(function(_ref2) { var width = _ref2.width, height2 = _ref2.height; return width >= popper2.clientWidth && height2 >= popper2.clientHeight; }); var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key; var variation = placement.split("-")[1]; return computedPlacement + (variation ? "-" + variation : ""); } fu