206 lines
7.3 KiB
JavaScript
206 lines
7.3 KiB
JavaScript
"use strict";
|
|
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));
|
|
const common_vendor = require("../../../../common/vendor.js");
|
|
if (!Array) {
|
|
const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
|
|
const _easycom_wd_transition2 = common_vendor.resolveComponent("wd-transition");
|
|
(_easycom_wd_icon2 + _easycom_wd_transition2)();
|
|
}
|
|
const _easycom_wd_icon = () => "../wd-icon/wd-icon.js";
|
|
const _easycom_wd_transition = () => "../wd-transition/wd-transition.js";
|
|
if (!Math) {
|
|
(_easycom_wd_icon + _easycom_wd_transition)();
|
|
}
|
|
const __default__ = {
|
|
name: "wd-popover",
|
|
options: {
|
|
virtualHost: true,
|
|
addGlobalClass: true,
|
|
styleIsolation: "shared"
|
|
}
|
|
};
|
|
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent(__spreadProps(__spreadValues({}, __default__), {
|
|
props: common_vendor.popoverProps,
|
|
emits: ["update:modelValue", "menuclick", "change", "open", "close"],
|
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
const props = __props;
|
|
const emit = __emit;
|
|
const queue = common_vendor.inject(common_vendor.queueKey, null);
|
|
const selector = "popover";
|
|
const { proxy } = common_vendor.getCurrentInstance();
|
|
common_vendor.watch(
|
|
() => props.content,
|
|
(newVal) => {
|
|
const { mode } = props;
|
|
if (mode === "normal" && typeof newVal !== "string") {
|
|
console.error("The value type must be a string type in normal mode");
|
|
} else if (mode === "menu" && !common_vendor.isArray(newVal)) {
|
|
console.error("The value type must be a Array type in menu mode");
|
|
}
|
|
}
|
|
);
|
|
common_vendor.watch(
|
|
() => props.placement,
|
|
() => {
|
|
popover.init(props.placement, props.visibleArrow, selector);
|
|
}
|
|
);
|
|
common_vendor.watch(
|
|
() => props.modelValue,
|
|
(newValue) => {
|
|
if (newValue) {
|
|
popover.control(props.placement, props.offset);
|
|
if (queue && queue.closeOther) {
|
|
queue.closeOther(proxy);
|
|
} else {
|
|
common_vendor.closeOther(proxy);
|
|
}
|
|
}
|
|
popover.showStyle.value = newValue ? "display: inline-block;" : "display: none;";
|
|
emit("change", { show: newValue });
|
|
emit(`${newValue ? "open" : "close"}`);
|
|
}
|
|
);
|
|
common_vendor.onMounted(() => {
|
|
popover.init(props.placement, props.visibleArrow, selector);
|
|
});
|
|
common_vendor.onBeforeMount(() => {
|
|
if (queue && queue.pushToQueue) {
|
|
queue.pushToQueue(proxy);
|
|
} else {
|
|
common_vendor.pushToQueue(proxy);
|
|
}
|
|
popover.showStyle.value = props.modelValue ? "opacity: 1;" : "opacity: 0;";
|
|
});
|
|
common_vendor.onBeforeUnmount(() => {
|
|
if (queue && queue.removeFromQueue) {
|
|
queue.removeFromQueue(proxy);
|
|
} else {
|
|
common_vendor.removeFromQueue(proxy);
|
|
}
|
|
});
|
|
const popover = common_vendor.usePopover();
|
|
function menuClick(index) {
|
|
emit("update:modelValue", false);
|
|
emit("menuclick", {
|
|
item: props.content[index],
|
|
index
|
|
});
|
|
}
|
|
function toggle() {
|
|
if (props.disabled)
|
|
return;
|
|
emit("update:modelValue", !props.modelValue);
|
|
}
|
|
function open() {
|
|
emit("update:modelValue", true);
|
|
}
|
|
function close() {
|
|
emit("update:modelValue", false);
|
|
}
|
|
__expose({
|
|
open,
|
|
close
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: !_ctx.useContentSlot && _ctx.mode === "normal"
|
|
}, !_ctx.useContentSlot && _ctx.mode === "normal" ? {
|
|
b: common_vendor.t(_ctx.content)
|
|
} : {}, {
|
|
c: !_ctx.useContentSlot && _ctx.mode === "menu" && typeof _ctx.content === "object"
|
|
}, !_ctx.useContentSlot && _ctx.mode === "menu" && typeof _ctx.content === "object" ? {
|
|
d: common_vendor.f(_ctx.content, (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: item.iconClass
|
|
}, item.iconClass ? {
|
|
b: "89ac049a-0-" + i0,
|
|
c: common_vendor.p({
|
|
name: item.iconClass,
|
|
["custom-class"]: "wd-popover__icon"
|
|
})
|
|
} : {}, {
|
|
d: common_vendor.t(item.content),
|
|
e: index,
|
|
f: common_vendor.o(($event) => menuClick(index), index)
|
|
});
|
|
})
|
|
} : {}, {
|
|
e: common_vendor.n(`wd-popover__container ${_ctx.customPop}`),
|
|
f: props.visibleArrow
|
|
}, props.visibleArrow ? {
|
|
g: common_vendor.n(`wd-popover__arrow ${common_vendor.unref(popover).arrowClass.value} ${_ctx.customArrow}`),
|
|
h: common_vendor.s(common_vendor.unref(popover).arrowStyle.value)
|
|
} : {}, {
|
|
i: !_ctx.useContentSlot && _ctx.mode === "normal"
|
|
}, !_ctx.useContentSlot && _ctx.mode === "normal" ? {
|
|
j: common_vendor.t(_ctx.content)
|
|
} : {}, {
|
|
k: !_ctx.useContentSlot && _ctx.mode === "menu"
|
|
}, !_ctx.useContentSlot && _ctx.mode === "menu" ? {
|
|
l: common_vendor.f(_ctx.content, (item, index, i0) => {
|
|
return common_vendor.e({
|
|
a: typeof item === "object" && item.iconClass
|
|
}, typeof item === "object" && item.iconClass ? {
|
|
b: "89ac049a-2-" + i0 + ",89ac049a-1",
|
|
c: common_vendor.p({
|
|
name: item.iconClass,
|
|
["custom-class"]: "wd-popover__icon"
|
|
})
|
|
} : {}, {
|
|
d: common_vendor.t(typeof item === "object" && item.content ? item.content : ""),
|
|
e: index,
|
|
f: common_vendor.o(($event) => menuClick(index), index),
|
|
g: common_vendor.s(index === 0 ? "border-top: none" : "")
|
|
});
|
|
})
|
|
} : {}, {
|
|
m: common_vendor.n(`wd-popover__container ${_ctx.customPop}`),
|
|
n: _ctx.showClose
|
|
}, _ctx.showClose ? {
|
|
o: common_vendor.o(toggle),
|
|
p: common_vendor.p({
|
|
name: "close",
|
|
["custom-class"]: "wd-popover__close-icon"
|
|
})
|
|
} : {}, {
|
|
q: common_vendor.p({
|
|
["custom-class"]: "wd-popover__pos",
|
|
["custom-style"]: common_vendor.unref(popover).popStyle.value,
|
|
show: _ctx.modelValue,
|
|
name: "fade",
|
|
duration: 200
|
|
}),
|
|
r: common_vendor.o(toggle),
|
|
s: common_vendor.n(`wd-popover ${_ctx.customClass}`),
|
|
t: common_vendor.s(_ctx.customStyle),
|
|
v: common_vendor.o(
|
|
//@ts-ignore
|
|
(...args) => common_vendor.unref(popover).noop && common_vendor.unref(popover).noop(...args)
|
|
)
|
|
});
|
|
};
|
|
}
|
|
}));
|
|
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-89ac049a"]]);
|
|
wx.createComponent(Component);
|
|
//# sourceMappingURL=wd-popover.js.map
|