@ctsy/layui-vue
Version:
a component library for Vue 3 base on layui-vue
1,522 lines • 136 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
import { defineComponent, computed, openBlock, createElementBlock, normalizeStyle, unref, createCommentVNode, toDisplayString, useSlots, ref, watch, createVNode, Transition, withCtx, normalizeClass, createBlock, createElementVNode, Fragment, renderSlot, createTextVNode, renderList, h, render as render$1, nextTick, isVNode, getCurrentInstance, resolveComponent, withModifiers } from "vue";
import { t as templateRef } from "./index4.js";
var index$1 = "";
function ownKeys$1(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2$1(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
i % 2 ? ownKeys$1(Object(source), true).forEach(function(key) {
_defineProperty$1(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty$1(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _toConsumableArray$1(arr) {
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
}
function _arrayWithoutHoles$1(arr) {
if (Array.isArray(arr))
return _arrayLikeToArray$1(arr);
}
function _iterableToArray$1(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
return Array.from(iter);
}
function _unsupportedIterableToArray$1(o, minLen) {
if (!o)
return;
if (typeof o === "string")
return _arrayLikeToArray$1(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor)
n = o.constructor.name;
if (n === "Map" || n === "Set")
return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
return _arrayLikeToArray$1(o, minLen);
}
function _arrayLikeToArray$1(arr, len) {
if (len == null || len > arr.length)
len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++)
arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread$1() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var __default__$4 = {
name: "Shade"
};
var _sfc_main$5 = /* @__PURE__ */ defineComponent(_objectSpread2$1(_objectSpread2$1({}, __default__$4), {}, {
props: {
index: null,
opacity: null,
visible: {
type: Boolean
}
},
emits: ["shadeClick"],
setup: function setup(__props, _ref) {
var emit = _ref.emit;
var props = __props;
var styles = computed(function() {
return {
opacity: props.opacity,
zIndex: props.index
};
});
var shadeClick = function shadeClick2() {
emit("shadeClick");
};
return function(_ctx, _cache) {
return __props.visible ? (openBlock(), createElementBlock("div", {
key: 0,
class: "layui-layer-shade",
style: normalizeStyle(unref(styles)),
onClick: shadeClick
}, null, 4)) : createCommentVNode("", true);
};
}
}));
var _hoisted_1$3 = ["src"];
var __default__$3 = {
name: "Iframe"
};
var _sfc_main$4 = /* @__PURE__ */ defineComponent(_objectSpread2$1(_objectSpread2$1({}, __default__$3), {}, {
props: {
src: null
},
setup: function setup2(__props) {
return function(_ctx, _cache) {
return openBlock(), createElementBlock("iframe", {
scrolling: "auto",
class: "layui-layer-iframe",
allowtransparency: "true",
frameborder: "0",
src: __props.src
}, null, 8, _hoisted_1$3);
};
}
}));
var _hoisted_1$2 = {
class: "layui-layer-title",
style: {
"cursor": "move"
}
};
var __default__$2 = {
name: "Title"
};
var _sfc_main$3 = /* @__PURE__ */ defineComponent(_objectSpread2$1(_objectSpread2$1({}, __default__$2), {}, {
props: {
title: null
},
setup: function setup3(__props) {
var renderContent = function renderContent2(content) {
if (typeof content === "function") {
return content();
}
return content;
};
return function(_ctx, _cache) {
return openBlock(), createElementBlock("div", _hoisted_1$2, toDisplayString(renderContent(__props.title)), 1);
};
}
}));
var __default__$1 = {
name: "CloseBtn"
};
var _sfc_main$2 = /* @__PURE__ */ defineComponent(_objectSpread2$1(_objectSpread2$1({}, __default__$1), {}, {
emits: ["closeHandle"],
setup: function setup4(__props, _ref) {
var emit = _ref.emit;
var closeHandle = function closeHandle2() {
emit("closeHandle");
};
return function(_ctx, _cache) {
return openBlock(), createElementBlock("a", {
class: "layui-layer-ico layui-layer-close layui-layer-close1",
href: "javascript:;",
onClick: closeHandle
});
};
}
}));
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
var _sfc_main$1 = {
name: "Resize"
};
var _hoisted_1$1 = {
class: "layui-layer-resize"
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("span", _hoisted_1$1);
}
var Resize = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
function nextId() {
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 16), 1);
}
s[14] = "4";
s[19] = hexDigits.substr(s[19] & 3 | 8, 1);
s[8] = s[13] = s[18] = s[23] = "-";
var uuid = s.join("");
return uuid;
}
function calculateArea(type, area, offset) {
return type != "drawer" ? calculateBaseArea(area) : calculateDrawerArea(offset, area);
}
function calculateBaseArea(area) {
if (area === "auto") {
return [];
}
if (typeof area == "string") {
return [area];
}
return _toConsumableArray$1(area);
}
function calculateDrawerArea(offset) {
var drawerArea = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "30%";
if (drawerArea instanceof Array) {
return drawerArea;
}
if (drawerArea === "auto") {
drawerArea = "30%";
}
if (offset === "l" || offset === "r") {
return [drawerArea, "100%"];
} else if (offset === "t" || offset === "b") {
return ["100%", drawerArea];
}
return [drawerArea, "100%"];
}
function calculateOffset(offset, area, type) {
var arr = ["t", "r", "b", "l", "lt", "lb", "rt", "rb"];
var t = offset[0];
var l = offset[1];
if (offset instanceof Array && type === "drawer") {
offset = "r";
}
if (arr.indexOf(offset) > -1) {
t = "50%";
l = "50%";
}
if (arr.indexOf(offset) != -1 || t.indexOf("%") > -1)
t = "calc(" + t + " - (" + (area === "auto" ? "100px" : area[1]) + "/2 ))";
if (arr.indexOf(offset) != -1 || l.indexOf("%") > -1)
l = "calc(" + l + " - (" + (area === "auto" ? "100px" : area[0]) + "/2 ))";
if (offset === "t")
t = "0px";
else if (offset === "r")
l = "calc(100% - " + area[0] + ")";
else if (offset === "b")
t = "calc(100% - " + area[1] + ")";
else if (offset === "l")
l = "0px";
else if (offset === "lt") {
t = "0px";
l = "0px";
} else if (offset === "lb") {
t = "calc(100% - " + area[1] + ")";
l = "0px";
} else if (offset === "rt") {
t = "0px";
l = "calc(100% - " + area[0] + ")";
} else if (offset === "rb") {
t = "calc(100% - " + area[1] + ")";
l = "calc(100% - " + area[0] + ")";
}
return [t, l];
}
function calculateType(modalType) {
if (modalType === "dialog" || modalType === 0 || modalType === "0") {
return 0;
} else if (modalType === "page" || modalType === "drawer" || modalType === 1 || modalType === "1") {
return 1;
} else if (modalType === "iframe" || modalType === 2 || modalType === "2") {
return 2;
} else if (modalType === "loading" || modalType === 3 || modalType === "3") {
return 3;
}
return 0;
}
function calculateContent(height, btn, type, isMessage) {
if (height && height.indexOf("%") != -1) {
height = "100%";
}
if (btn && btn.length > 0) {
if (type === 0) {
return "calc(" + height + " - 137px)";
}
if (type === 1) {
return "calc(" + height + " - 102px)";
}
if (type === 2) {
return "calc(" + height + " - 102px)";
}
} else {
if (type === 0) {
return isMessage ? height : "calc(" + height + " - 137px)";
}
if (type === 1) {
return "calc(" + height + " - 51px)";
}
if (type === 2) {
return "calc(" + height + " - 51px)";
}
}
}
function maxArea() {
return {
w: "100%",
h: "100%"
};
}
function maxOffset() {
return {
t: "0px",
l: "0px"
};
}
function minArea() {
return {
w: "180px",
h: "51px"
};
}
function minOffset(left) {
return {
t: "calc(100% - 51px)",
l: left + "px"
};
}
function getArea(dom) {
var width = getComputedStyle(dom, null).width;
var height = getComputedStyle(dom, null).height;
return [width, height];
}
var minArrays = [];
function updateMinArrays(id, state) {
var i = 0;
if (state) {
var index2 = minArrays.findIndex(function(v) {
return v === void 0;
});
if (index2 === -1) {
minArrays.push(id);
i = minArrays.length - 1;
} else {
minArrays[index2] = id;
i = index2;
}
} else {
delete minArrays[minArrays.findIndex(function(v) {
return v == id;
})];
i = -1;
}
return i;
}
function getDrawerAnimationClass(offset) {
var isClose = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
var prefix = "layer-drawer-anim layer-anim";
var suffix = "rl";
if (offset === "l") {
suffix = "lr";
} else if (offset === "r") {
suffix = "rl";
} else if (offset === "t") {
suffix = "tb";
} else if (offset === "b") {
suffix = "bt";
}
return isClose ? "".concat(prefix, "-").concat(suffix, "-close") : "".concat(prefix, "-").concat(suffix);
}
var useMove$1 = function useMove(el, callback) {
el.style.position = "fixed";
var offsetX;
var offsetY;
if (el != null) {
el.addEventListener("mousedown", function(event) {
if (event.path[0].className === "layui-layer-title") {
if (event.button == 0 && el != null) {
var lexObj = getComputedStyle(el);
offsetX = event.pageX - el.offsetLeft + parseInt(lexObj["margin-left"]);
offsetY = event.pageY - el.offsetTop + parseInt(lexObj["margin-right"]);
var move2 = function move22(event2) {
if (el != null) {
var x = event2.pageX - offsetX;
var y = event2.pageY - offsetY;
if (x < 0) {
x = 0;
} else if (x > document.documentElement.clientWidth - el.offsetWidth) {
x = document.documentElement.clientWidth - el.offsetWidth;
}
if (y < 0) {
y = 0;
} else if (y > document.documentElement.clientHeight - el.offsetHeight) {
y = document.documentElement.clientHeight - el.offsetHeight;
}
el.style.left = "".concat(x, "px");
el.style.top = "".concat(y, "px");
callback(el.style.left, el.style.top);
}
return false;
};
document.addEventListener("mousemove", move2);
var stop = function stop2() {
document.removeEventListener("mousemove", move2);
document.removeEventListener("mouseup", stop2);
};
document.addEventListener("mouseup", stop);
}
}
return false;
});
}
};
var useMove2 = function useMove3(el, callback) {
if (el != null) {
el.addEventListener("mousedown", function(event) {
if (event.path[0].className === "layui-layer-resize") {
if (event.button == 0 && el != null) {
var x = el.offsetLeft;
var y = el.offsetTop;
var move2 = function move22(moveEvent) {
if (el != null) {
var offsetX = moveEvent.clientX;
var offsetY = moveEvent.clientY;
var w = offsetX - x;
var h2 = offsetY - y;
w < 260 && (w = 260);
h2 < 115 && (h2 = 115);
el.style.width = "".concat(w, "px");
el.style.height = "".concat(h2, "px");
callback(el.style.width, el.style.height);
}
return false;
};
document.addEventListener("mousemove", move2);
var stop = function stop2() {
document.removeEventListener("mousemove", move2);
document.removeEventListener("mouseup", stop2);
};
document.addEventListener("mouseup", stop);
}
}
return false;
});
}
};
var _hoisted_1$4 = ["innerHTML"];
var _hoisted_2$1 = {
key: 1,
class: "layui-layer-setwin"
};
var _hoisted_3$1 = {
key: 0
};
var _hoisted_4$1 = ["onClick"];
var __default__$5 = {
name: "LayLayer"
};
var _sfc_main$6 = /* @__PURE__ */ defineComponent(_objectSpread2$1(_objectSpread2$1({}, __default__$5), {}, {
props: {
title: {
type: [String, Boolean, Function],
default: "\u4FE1\u606F"
},
icon: null,
skin: null,
zIndex: {
type: [Number, Function],
default: 99999
},
setTop: {
type: Boolean,
default: false
},
offset: {
default: function _default() {
return ["50%", "50%"];
}
},
area: {
default: "auto"
},
modelValue: {
type: Boolean,
default: false
},
maxmin: {
type: [Boolean, String],
default: false
},
btn: {
type: [Array, Boolean]
},
move: {
type: [Boolean, String],
default: true
},
resize: {
type: [Boolean, String],
default: false
},
type: {
default: 1
},
content: null,
isHtmlFragment: {
type: Boolean,
default: false
},
shade: {
type: [Boolean, String],
default: true
},
shadeClose: {
type: [Boolean, String],
default: true
},
shadeOpacity: {
default: "0.1"
},
closeBtn: {
type: [Boolean, String],
default: true
},
btnAlign: {
default: "r"
},
time: {
default: 0
},
load: {
default: 0
},
anim: {
default: 0
},
isOutAnim: {
type: Boolean,
default: true
},
destroy: {
type: Function,
default: function _default2() {
}
},
success: {
type: Function,
default: function _default3() {
}
},
end: {
type: Function,
default: function _default4() {
}
},
yes: null,
yesText: {
default: "\u786E\u5B9A"
},
isFunction: {
type: Boolean,
default: false
},
isMessage: {
type: Boolean,
default: false
},
appContext: null
},
emits: ["close", "update:modelValue"],
setup: function setup5(__props, _ref) {
var expose = _ref.expose, emit = _ref.emit;
var props = __props;
var slots = useSlots();
var layero = ref(null);
var id = ref(nextId());
var max = ref(false);
var min = ref(false);
var type = calculateType(props.type);
var area = ref(calculateArea(props.type, props.area, props.offset));
var offset = ref(calculateOffset(props.offset, area.value, props.type));
var contentHeight = ref(calculateContent(area.value[1], props.btn, type, props.isMessage));
var index2 = ref(props.zIndex);
var visible = ref(false);
var first = ref(true);
var w = ref(area.value[0]);
var h2 = ref(area.value[1]);
var t = ref(offset.value[0]);
var l = ref(offset.value[1]);
var _w = ref(area.value[0]);
var _h = ref(area.value[0]);
var _t = ref(offset.value[0]);
var _l = ref(offset.value[1]);
var firstOpenDelayCalculation = function firstOpenDelayCalculation2() {
nextTick(function() {
area.value = getArea(layero.value);
if (props.type === "drawer") {
area.value = calculateDrawerArea(props.offset, props.area);
}
offset.value = calculateOffset(props.offset, area.value, props.type);
w.value = area.value[0];
h2.value = area.value[1];
t.value = offset.value[0];
l.value = offset.value[1];
_w.value = area.value[0];
_l.value = area.value[1];
_t.value = offset.value[0];
_l.value = offset.value[1];
supportMove();
});
};
var notFirstOpenLayerInit = function notFirstOpenLayerInit2() {
w.value = _w.value;
h2.value = _h.value;
t.value = _t.value;
l.value = _l.value;
supportMove();
};
var beforeCloseSaveData = function beforeCloseSaveData2() {
if (min.value)
minHandle();
if (max.value)
maxHandle();
_w.value = w.value;
_h.value = h2.value;
_t.value = t.value;
_l.value = l.value;
};
var maxHandle = function maxHandle2() {
if (max.value) {
w.value = _w.value;
h2.value = _h.value;
t.value = _t.value;
l.value = _l.value;
} else {
_t.value = t.value;
_l.value = l.value;
_w.value = w.value;
_h.value = h2.value;
w.value = maxArea().w;
h2.value = maxArea().h;
t.value = maxOffset().t;
l.value = maxOffset().l;
}
max.value = !max.value;
};
var minHandle = function minHandle2() {
var left = 180 * updateMinArrays(id.value, !min.value);
if (left > document.documentElement.clientWidth - 180) {
left = document.documentElement.clientWidth - 180;
}
if (min.value) {
w.value = _w.value;
h2.value = _h.value;
t.value = _t.value;
l.value = _l.value;
} else {
_w.value = w.value;
_h.value = h2.value;
_t.value = t.value;
_l.value = l.value;
h2.value = minArea().h;
w.value = minArea().w;
t.value = minOffset(left).t;
l.value = minOffset(left).l;
}
min.value = !min.value;
};
var reset22 = function reset3() {
if (!first.value) {
min.value = false;
max.value = false;
w.value = area.value[0];
h2.value = area.value[1];
t.value = offset.value[0];
l.value = offset.value[1];
_w.value = area.value[0];
_h.value = area.value[1];
_t.value = offset.value[0];
_l.value = offset.value[1];
}
if (!props.modelValue) {
emit("update:modelValue", true);
}
};
watch(function() {
return props.modelValue;
}, function() {
visible.value = props.modelValue;
if (visible.value) {
if (first.value) {
first.value = false;
firstOpenDelayCalculation();
} else {
notFirstOpenLayerInit();
}
} else {
beforeCloseSaveData();
}
}, {
deep: true
});
watch(function() {
return visible.value;
}, function() {
if (visible.value) {
if (props.isFunction) {
firstOpenDelayCalculation();
}
props.success();
} else {
props.end();
}
});
watch(function() {
return h2.value;
}, function() {
contentHeight.value = calculateContent(h2.value, props.btn, type, props.isMessage);
});
var boxClasses = computed(function() {
return [type === 0 ? "layui-layer-dialog" : "", type === 1 ? "layui-layer-page" : "", type === 2 ? "layui-layer-iframe" : "", type === 3 ? "layui-layer-loading" : "", props.isMessage ? "layui-layer-msg" : "", props.isMessage && !props.icon ? "layui-layer-hui" : "", props.skin];
});
var supportMove = function supportMove2() {
if (props.move && props.type != "drawer") {
nextTick(function() {
useMove$1(layero.value, function(left, top) {
l.value = left;
t.value = top;
});
useMove2(layero.value, function(width, height) {
h2.value = height;
w.value = width;
});
});
}
};
var styles = computed(function() {
return {
top: t.value,
left: l.value,
width: w.value,
height: h2.value,
zIndex: index2.value
};
});
var contentClasses = computed(function() {
return [type === 3 ? "layui-layer-loading".concat(props.load) : "", props.icon ? "layui-layer-padding" : ""];
});
var closeHandle = function closeHandle2() {
emit("close");
emit("update:modelValue", false);
props.destroy();
};
var yesHandle = function yesHandle2() {
if (props.yes != void 0)
props.yes();
else
closeHandle();
};
var shadeHandle = function shadeHandle2() {
if (props.shadeClose)
closeHandle();
};
var renderContent = function renderContent2(content) {
if (content instanceof Function) {
return content();
}
return content;
};
var iconClass = computed(function() {
return ["layui-layer-ico", "layui-layer-ico".concat(props.icon)];
});
var enterActiveClass = computed(function() {
if (props.type === "drawer") {
return getDrawerAnimationClass(props.offset);
}
return "layer-anim layer-anim-0".concat(props.anim);
});
var leaveActiveClass = computed(function() {
if (props.type === "drawer") {
return getDrawerAnimationClass(props.offset, true);
}
return props.isOutAnim ? "layer-anim-close" : "";
});
var open2 = function open3() {
visible.value = true;
};
var close2 = function close3() {
visible.value = false;
};
var shadeVisible = computed(function() {
return visible.value && props.shade && !min.value;
});
var showResize = computed(function() {
return props.resize && !max.value && !min.value;
});
var showTitle = computed(function() {
return props.title && props.type != 3;
});
expose({
reset: reset22,
open: open2,
close: close2
});
return function(_ctx, _cache) {
return openBlock(), createElementBlock("div", null, [createVNode(_sfc_main$5, {
index: index2.value,
visible: unref(shadeVisible),
opacity: __props.shadeOpacity,
onShadeClick: shadeHandle
}, null, 8, ["index", "visible", "opacity"]), createVNode(Transition, {
"enter-active-class": unref(enterActiveClass),
"leave-active-class": unref(leaveActiveClass)
}, {
default: withCtx(function() {
return [visible.value ? (openBlock(), createElementBlock("div", {
key: 0,
ref_key: "layero",
ref: layero,
class: normalizeClass(["layui-layer layui-layer-border", unref(boxClasses)]),
style: normalizeStyle(unref(styles))
}, [unref(showTitle) ? (openBlock(), createBlock(_sfc_main$3, {
key: 0,
title: __props.title
}, null, 8, ["title"])) : createCommentVNode("", true), createElementVNode("div", {
class: normalizeClass(["layui-layer-content", unref(contentClasses)]),
style: normalizeStyle({
height: contentHeight.value
})
}, [unref(type) === 0 || unref(type) === 1 ? (openBlock(), createElementBlock(Fragment, {
key: 0
}, [__props.icon ? (openBlock(), createElementBlock("i", {
key: 0,
class: normalizeClass(unref(iconClass))
}, null, 2)) : createCommentVNode("", true), unref(slots).default ? renderSlot(_ctx.$slots, "default", {
key: 1
}) : (openBlock(), createElementBlock(Fragment, {
key: 2
}, [__props.isHtmlFragment ? (openBlock(), createElementBlock("span", {
key: 0,
innerHTML: renderContent(props.content)
}, null, 8, _hoisted_1$4)) : (openBlock(), createElementBlock(Fragment, {
key: 1
}, [createTextVNode(toDisplayString(renderContent(props.content)), 1)], 64))], 64))], 64)) : createCommentVNode("", true), unref(type) === 2 ? (openBlock(), createBlock(_sfc_main$4, {
key: 1,
src: props.content
}, null, 8, ["src"])) : createCommentVNode("", true)], 6), unref(type) != 3 ? (openBlock(), createElementBlock("span", _hoisted_2$1, [__props.maxmin && !max.value ? (openBlock(), createElementBlock("a", {
key: 0,
class: normalizeClass(["layui-layer-min", [min.value ? "layui-layer-ico layui-layer-maxmin" : ""]]),
href: "javascript:;",
onClick: minHandle
}, [!min.value ? (openBlock(), createElementBlock("cite", _hoisted_3$1)) : createCommentVNode("", true)], 2)) : createCommentVNode("", true), __props.maxmin && !min.value ? (openBlock(), createElementBlock("a", {
key: 1,
class: normalizeClass(["layui-layer-ico layui-layer-max", [max.value ? "layui-layer-maxmin" : ""]]),
href: "javascript:;",
onClick: maxHandle
}, null, 2)) : createCommentVNode("", true), __props.closeBtn ? (openBlock(), createBlock(_sfc_main$2, {
key: 2,
onCloseHandle: closeHandle
})) : createCommentVNode("", true)])) : createCommentVNode("", true), (__props.btn && __props.btn.length > 0 || unref(type) === 0) && !__props.isMessage ? (openBlock(), createElementBlock("div", {
key: 2,
class: normalizeClass(["layui-layer-btn", ["layui-layer-btn-".concat(__props.btnAlign)]])
}, [__props.btn && __props.btn.length > 0 ? (openBlock(true), createElementBlock(Fragment, {
key: 0
}, renderList(__props.btn, function(b, index22) {
return openBlock(), createElementBlock("a", {
key: index22,
class: normalizeClass(["layui-layer-btn".concat(index22)]),
onClick: function onClick($event) {
return b.callback(props.domId);
}
}, toDisplayString(b.text), 11, _hoisted_4$1);
}), 128)) : (openBlock(), createElementBlock(Fragment, {
key: 1
}, [unref(type) === 0 ? (openBlock(), createElementBlock("a", {
key: 0,
class: "layui-layer-btn0",
onClick: _cache[0] || (_cache[0] = function($event) {
return yesHandle();
})
}, toDisplayString(__props.yesText), 1)) : createCommentVNode("", true)], 64))], 2)) : createCommentVNode("", true), unref(showResize) ? (openBlock(), createBlock(Resize, {
key: 3
})) : createCommentVNode("", true)], 6)) : createCommentVNode("", true)];
}),
_: 3
}, 8, ["enter-active-class", "leave-active-class"])]);
};
}
}));
var layerInstance = [];
var addInstance = function addInstance2(instance) {
layerInstance.push(instance);
};
var delInstance = function delInstance2(id) {
layerInstance.forEach(function(item, index2) {
if (item.modalContainer.id === id) {
layerInstance.splice(index2, 1);
}
});
};
var cleanInstance = function cleanInstance2() {
layerInstance.splice(0, layerInstance.length);
};
var isExist = function isExist2(id) {
var b = false;
layerInstance.forEach(function(item, index2) {
if (item.modalContainer.id === id) {
b = true;
}
});
return b;
};
var mergeOption = function mergeOption2(option, defaultOption) {
if (option)
defaultOption = Object.assign(defaultOption, option);
return defaultOption;
};
var createContainer = function createContainer2() {
var modalContainer = document.createElement("div");
modalContainer.id = nextId();
document.body.appendChild(modalContainer);
return modalContainer;
};
var modalChildrenVNode = function modalChildrenVNode2(content) {
if (typeof content === "function") {
return isVNode(content()) ? {
default: function _default5() {
return content();
}
} : void 0;
}
return isVNode(content) ? {
default: function _default5() {
return content;
}
} : void 0;
};
var layer = {
_context: null,
open: function open(option, callback) {
var defaultOption = {};
return layer.create(option, defaultOption, callback);
},
drawer: function drawer(option, callback) {
var defaultOption = {
type: "drawer"
};
return layer.create(option, defaultOption, callback);
},
msg: function msg(message, option, callback) {
var defaultOption = {
type: 0,
title: false,
content: message,
closeBtn: false,
shadeClose: false,
isMessage: true,
shade: false,
time: 1e3,
btn: false
};
return layer.create(option, defaultOption, callback);
},
load: function load(_load, option, callback) {
var defaultOption = {
type: 3,
load: _load,
anim: 5,
isOutAnim: false,
shadeClose: false
};
return layer.create(option, defaultOption, callback);
},
confirm: function confirm(msg2, option, callback) {
var defaultOption = {
type: 0,
content: msg2,
shadeClose: false
};
return layer.create(option, defaultOption, callback);
},
create: function create(option, defaultOption, callback) {
var _modalInstance$compon3, _modalInstance$compon4;
var timer;
var options = mergeOption(option, defaultOption);
var modalContainer = createContainer();
options.id = modalContainer;
var modalInstance = h(_sfc_main$6, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
isFunction: true,
destroy: function destroy2() {
var _modalInstance$compon, _modalInstance$compon2;
clearTimeout(timer);
(_modalInstance$compon = modalInstance.component) === null || _modalInstance$compon === void 0 ? void 0 : (_modalInstance$compon2 = _modalInstance$compon.exposed) === null || _modalInstance$compon2 === void 0 ? void 0 : _modalInstance$compon2.close();
setTimeout(function() {
render$1(null, modalContainer);
if (document.body.contains(modalContainer)) {
document.body.removeChild(modalContainer);
}
}, 2e3);
delInstance(modalContainer.id);
}
}), modalChildrenVNode(options.content));
modalInstance.appContext = options.appContext || layer._context;
render$1(modalInstance, modalContainer);
(_modalInstance$compon3 = modalInstance.component) === null || _modalInstance$compon3 === void 0 ? void 0 : (_modalInstance$compon4 = _modalInstance$compon3.exposed) === null || _modalInstance$compon4 === void 0 ? void 0 : _modalInstance$compon4.open();
if (defaultOption && defaultOption.time != void 0) {
timer = setTimeout(function() {
var _modalInstance$compon5, _modalInstance$compon6;
(_modalInstance$compon5 = modalInstance.component) === null || _modalInstance$compon5 === void 0 ? void 0 : (_modalInstance$compon6 = _modalInstance$compon5.exposed) === null || _modalInstance$compon6 === void 0 ? void 0 : _modalInstance$compon6.close();
if (callback)
callback(modalContainer.id);
setTimeout(function() {
render$1(null, modalContainer);
if (document.body.contains(modalContainer)) {
document.body.removeChild(modalContainer);
}
}, 2e3);
delInstance(modalContainer.id);
}, defaultOption.time);
}
addInstance({
modalContainer,
modalInstance
});
return {
modalContainer,
modalInstance
};
},
close: function close(instance) {
if (instance != null && isExist(instance.modalContainer.id)) {
var _instance$modalInstan, _instance$modalInstan2;
(_instance$modalInstan = instance.modalInstance.component) === null || _instance$modalInstan === void 0 ? void 0 : (_instance$modalInstan2 = _instance$modalInstan.exposed) === null || _instance$modalInstan2 === void 0 ? void 0 : _instance$modalInstan2.close();
setTimeout(function() {
render$1(null, instance.modalContainer);
if (document.body.contains(instance.modalContainer))
document.body.removeChild(instance.modalContainer);
}, 2e3);
}
delInstance(instance.modalContainer.id);
},
closeAll: function closeAll() {
layerInstance.forEach(function(item) {
var _item$modalInstance$c, _item$modalInstance$c2;
(_item$modalInstance$c = item.modalInstance.component) === null || _item$modalInstance$c === void 0 ? void 0 : (_item$modalInstance$c2 = _item$modalInstance$c.exposed) === null || _item$modalInstance$c2 === void 0 ? void 0 : _item$modalInstance$c2.close();
setTimeout(function() {
render$1(null, item.modalContainer);
if (document.body.contains(item.modalContainer))
document.body.removeChild(item.modalContainer);
}, 2e3);
});
cleanInstance();
},
reset: function reset(instance) {
var _instance$modalInstan3, _instance$modalInstan4;
(_instance$modalInstan3 = instance.modalInstance.component) === null || _instance$modalInstan3 === void 0 ? void 0 : (_instance$modalInstan4 = _instance$modalInstan3.exposed) === null || _instance$modalInstan4 === void 0 ? void 0 : _instance$modalInstan4.reset();
}
};
var install = function install2(app, options) {
layer._context = app._context;
app.component(_sfc_main$6.name, _sfc_main$6);
app.config.globalProperties.$layer = layer;
};
var index = {
install
};
/*!
* Cropper.js v1.5.12
* https://fengyuanchen.github.io/cropperjs
*
* Copyright 2015-present Chen Fengyuan
* Released under the MIT license
*
* Date: 2021-06-12T08:00:17.411Z
*/
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function(key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function(obj2) {
return typeof obj2;
};
} else {
_typeof = function(obj2) {
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a 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);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps)
_defineProperties(Constructor.prototype, protoProps);
if (staticProps)
_defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr))
return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o)
return;
if (typeof o === "string")
return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor)
n = o.constructor.name;
if (n === "Map" || n === "Set")
return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length)
len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++)
arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var IS_BROWSER = typeof window !== "undefined" && typeof window.document !== "undefined";
var WINDOW = IS_BROWSER ? window : {};
var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? "ontouchstart" in WINDOW.document.documentElement : false;
var HAS_POINTER_EVENT = IS_BROWSER ? "PointerEvent" in WINDOW : false;
var NAMESPACE = "cropper";
var ACTION_ALL = "all";
var ACTION_CROP = "crop";
var ACTION_MOVE = "move";
var ACTION_ZOOM = "zoom";
var ACTION_EAST = "e";
var ACTION_WEST = "w";
var ACTION_SOUTH = "s";
var ACTION_NORTH = "n";
var ACTION_NORTH_EAST = "ne";
var ACTION_NORTH_WEST = "nw";
var ACTION_SOUTH_EAST = "se";
var ACTION_SOUTH_WEST = "sw";
var CLASS_CROP = "".concat(NAMESPACE, "-crop");
var CLASS_DISABLED = "".concat(NAMESPACE, "-disabled");
var CLASS_HIDDEN = "".concat(NAMESPACE, "-hidden");
var CLASS_HIDE = "".concat(NAMESPACE, "-hide");
var CLASS_INVISIBLE = "".concat(NAMESPACE, "-invisible");
var CLASS_MODAL = "".concat(NAMESPACE, "-modal");
var CLASS_MOVE = "".concat(NAMESPACE, "-move");
var DATA_ACTION = "".concat(NAMESPACE, "Action");
var DATA_PREVIEW = "".concat(NAMESPACE, "Preview");
var DRAG_MODE_CROP = "crop";
var DRAG_MODE_MOVE = "move";
var DRAG_MODE_NONE = "none";
var EVENT_CROP = "crop";
var EVENT_CROP_END = "cropend";
var EVENT_CROP_MOVE = "cropmove";
var EVENT_CROP_START = "cropstart";
var EVENT_DBLCLICK = "dblclick";
var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? "touchstart" : "mousedown";
var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? "touchmove" : "mousemove";
var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? "touchend touchcancel" : "mouseup";
var EVENT_POINTER_DOWN = HAS_POINTER_EVENT ? "pointerdown" : EVENT_TOUCH_START;
var EVENT_POINTER_MOVE = HAS_POINTER_EVENT ? "pointermove" : EVENT_TOUCH_MOVE;
var EVENT_POINTER_UP = HAS_POINTER_EVENT ? "pointerup pointercancel" : EVENT_TOUCH_END;
var EVENT_READY = "ready";
var EVENT_RESIZE = "resize";
var EVENT_WHEEL = "wheel";
var EVENT_ZOOM = "zoom";
var MIME_TYPE_JPEG = "image/jpeg";
var REGEXP_ACTIONS = /^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/;
var REGEXP_DATA_URL = /^data:/;
var REGEXP_DATA_URL_JPEG = /^data:image\/jpeg;base64,/;
var REGEXP_TAG_NAME = /^img|canvas$/i;
var MIN_CONTAINER_WIDTH = 200;
var MIN_CONTAINER_HEIGHT = 100;
var DEFAULTS = {
viewMode: 0,
dragMode: DRAG_MODE_CROP,
initialAspectRatio: NaN,
aspectRatio: NaN,
data: null,
preview: "",
responsive: true,
restore: true,
checkCrossOrigin: true,
checkOrientation: true,
modal: true,
guides: true,
center: true,
highlight: true,
background: true,
autoCrop: true,
autoCropArea: 0.8,
movable: true,
rotatable: true,
scalable: true,
zoomable: true,
zoomOnTouch: true,
zoomOnWheel: true,
wheelZoomRatio: 0.1,
cropBoxMovable: true,
cropBoxResizable: true,
toggleDragModeOnDblclick: true,
minCanvasWidth: 0,
minCanvasHeight: 0,
minCropBoxWidth: 0,
minCropBoxHeight: 0,
minContainerWidth: MIN_CONTAINER_WIDTH,
minContainerHeight: MIN_CONTAINER_HEIGHT,
ready: null,
cropstart: null,
cropmove: null,
cropend: null,
crop: null,
zoom: null
};
var TEMPLATE = '<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>';
var isNaN = Number.isNaN || WINDOW.isNaN;
function isNumber(value) {
return typeof value === "number" && !isNaN(value);
}
var isPositiveNumber = function isPositiveNumber2(value) {
return value > 0 && value < Infinity;
};
function isUndefined(value) {
return typeof value === "undefined";
}
function isObject(value) {
return _typeof(value) === "object" && value !== null;
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function isPlainObject(value) {
if (!isObject(value)) {
return false;
}
try {
var _constructor = value.constructor;
var prototype = _constructor.prototype;
return _constructor && prototype && hasOwnProperty.call(prototype, "isPrototypeOf");
} catch (error) {
return false;
}
}
function isFunction(value) {
return typeof value === "function";
}
var slice = Array.prototype.slice;
function toArray(value) {
return Array.from ? Array.from(value) : slice.call(value);
}
function forEach(data, callback) {
if (data && isFunction(callback)) {
if (Array.isArray(data) || isNumber(data.length)) {
toArray(data).forEach(function(value, key) {
callback.call(data, value, key, data);
});
} else if (isObject(data)) {
Object.keys(data).forEach(function(key) {
callback.call(data, data[key], key, data);
});
}
}
return data;
}
var assign = Object.assign || function assign2(target) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
if (isObject(target) && args.length > 0) {
args.forEach(function(arg) {
if (isObject(arg)) {
Object.keys(arg).forEach(function(key) {
target[key] = arg[key];
});
}
});
}
return target;
};
var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/;
function normalizeDecimalNumber(value) {
var times = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1e11;
return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value;
}
var REGEXP_SUFFIX = /^width|height|left|top|marginLeft|marginTop$/;
function setStyle(element, styles) {
var style = element.style;
forEach(styles, function(value, property) {
if (REGEXP_SUFFIX.test(property) && isNumber(value)) {
value = "".concat(value, "px");
}
style[property] = value;
});
}
function hasClass(element, value) {
return element.classList ? element.classList.contains(value) : element.className.indexOf(value) > -1;
}
function addClass(element, value) {
if (!value) {
return;
}
if (isNumber(element.length)) {
forEach(element, function(elem) {
addClass(elem, value);
});
return;
}
if (element.classList) {
element.classList.add(value);
return;
}
var className = element.className.trim();
if (!className) {
element.className = value;
} else if (className.indexOf(value) < 0) {
element.className = "".concat(className, " ").concat(value);
}
}
function removeClass(element, value) {
if (!value) {
return;
}
if (isNumber(element.length)) {
forEach(element, function(elem) {
removeClass(elem, value);
});
return;
}
if (element.classList) {
element.classList.remove(value);
return;
}
if (element.className.indexOf(value) >= 0) {
element.className = element.className.replace(value, "");
}
}
function toggleClass(element, value, added) {
if (!value) {
return;
}
if (isNumber(element.length)) {
forEach(element, function(elem) {
toggleClass(elem, value, added);
});
return;
}
if (added) {
addClass(element, value);
} else {
removeClass(element, value);
}
}
var REGEXP_CAMEL_CASE = /([a-z\d])([A-Z])/g;
function toParamCase(value) {
return value.replace(REGEXP_CAMEL_CASE, "$1-$2").toLowerCase();
}
function getData(element, name) {
if (isObject(element[name])) {
return element[name];
}
if (element.dataset) {
return element.dataset[name];
}
return element.getAttribute("data-".concat(toParamCase(name)));
}
function setData(element, name, data) {
if (isObject(data)) {
element[name] = data;
} else if (element.dataset) {
element.dataset[name] = data;
} else {
element.setAttribute("data-".concat(toParamCase(name)), data);
}
}
function removeData(element, name) {
if (isObject(element[name])) {
try {
delete element[name];
} catch (error) {
element[name] = void 0;
}
} else if (element.dataset) {
try {
delete element.dataset[name];
} catch (error) {
element.dataset[name] = void 0;
}
} else {
element.removeAttribute("data-".concat(toParamCase(name)));
}
}
var REGEXP_SPACES = /\s\s*/;
var onceSupported = function() {
var supported = false;
if (IS_BROWSER) {
var once = false;
var listener = function listener2() {
};
var options = Object.defineProperty({}, "once", {
get: function get() {
supported = true;
return once;
},
set: function set(value) {
once = value;
}
});
WINDOW.addEventListener("test", listener, options);
WINDOW.removeEventListener("test", listener, options);
}
return supported;
}();
function removeListener(element, type, listener) {
var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
var handler = listener;
type.trim().split(REGEXP_SPACES).forEach(function(event) {
if (!onceSupported) {
var listeners = element.listeners;
if (listeners && listeners[event] && listeners[event][listener]) {
handler = listeners[event][listener];
delete listeners[event][listener];
if (Object.keys(listeners[event]).length === 0) {
delete listeners[event];
}
if (Object.keys(listeners).length === 0) {
delete element.listeners;
}
}
}
element.removeEventListener(event, handler, options);
});
}
function addListener(element, type, listener) {
var options = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
var _handler = listener;
type.trim().split(REGEXP_SPACES).forEach(function(event) {
if (options.once && !onceSupported) {
var _element$listeners = element.listeners, listeners = _element$listeners === void 0 ? {} : _element$listeners;
_handler = function handler() {
delete listeners[event][listener];
element.removeEventListener(event, _handler, options);
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = argume