1224 lines
34 KiB
JavaScript
1224 lines
34 KiB
JavaScript
import { defineComponent, mergeProps, withCtx, createTextVNode, toDisplayString, createVNode, renderSlot, openBlock, createBlock, createCommentVNode, nextTick, inject, computed, ref, reactive, provide, watchEffect, Transition, Teleport, watch, Fragment, useSSRContext, withDirectives, vShow, getCurrentInstance } from 'vue';
|
|
import { ssrRenderComponent, ssrRenderSlot, ssrRenderClass, ssrInterpolate } from 'vue/server-renderer';
|
|
import { M as Button } from './server.mjs';
|
|
|
|
function noop() {
|
|
}
|
|
const extend = Object.assign;
|
|
const isObject = (val) => val !== null && typeof val === "object";
|
|
const isDef = (val) => val !== void 0 && val !== null;
|
|
const isFunction = (val) => typeof val === "function";
|
|
const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
|
|
function get(object, path) {
|
|
const keys = path.split(".");
|
|
let result = object;
|
|
keys.forEach((key) => {
|
|
var _a;
|
|
result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
|
|
});
|
|
return result;
|
|
}
|
|
function pick(obj, keys, ignoreUndefined) {
|
|
return keys.reduce(
|
|
(ret, key) => {
|
|
{
|
|
ret[key] = obj[key];
|
|
}
|
|
return ret;
|
|
},
|
|
{}
|
|
);
|
|
}
|
|
const unknownProp = null;
|
|
const numericProp = [Number, String];
|
|
const truthProp = {
|
|
type: Boolean,
|
|
default: true
|
|
};
|
|
const makeArrayProp = () => ({
|
|
type: Array,
|
|
default: () => []
|
|
});
|
|
const makeStringProp = (defaultVal) => ({
|
|
type: String,
|
|
default: defaultVal
|
|
});
|
|
var width;
|
|
var height;
|
|
function useWindowSize() {
|
|
if (!width) {
|
|
width = ref(0);
|
|
height = ref(0);
|
|
}
|
|
return { width, height };
|
|
}
|
|
var overflowScrollReg = /scroll|auto|overlay/i;
|
|
var defaultRoot = void 0;
|
|
function isElement(node) {
|
|
const ELEMENT_NODE_TYPE = 1;
|
|
return node.tagName !== "HTML" && node.tagName !== "BODY" && node.nodeType === ELEMENT_NODE_TYPE;
|
|
}
|
|
function getScrollParent(el, root = defaultRoot) {
|
|
let node = el;
|
|
while (node && node !== root && isElement(node)) {
|
|
const { overflowY } = (void 0).getComputedStyle(node);
|
|
if (overflowScrollReg.test(overflowY)) {
|
|
return node;
|
|
}
|
|
node = node.parentNode;
|
|
}
|
|
return root;
|
|
}
|
|
const stopPropagation = (event) => event.stopPropagation();
|
|
function preventDefault(event, isStopPropagation) {
|
|
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
event.preventDefault();
|
|
}
|
|
{
|
|
stopPropagation(event);
|
|
}
|
|
}
|
|
useWindowSize();
|
|
function addUnit(value) {
|
|
if (isDef(value)) {
|
|
return isNumeric(value) ? `${value}px` : String(value);
|
|
}
|
|
return void 0;
|
|
}
|
|
function getSizeStyle(originSize) {
|
|
if (isDef(originSize)) {
|
|
if (Array.isArray(originSize)) {
|
|
return {
|
|
width: addUnit(originSize[0]),
|
|
height: addUnit(originSize[1])
|
|
};
|
|
}
|
|
const size = addUnit(originSize);
|
|
return {
|
|
width: size,
|
|
height: size
|
|
};
|
|
}
|
|
}
|
|
function getZIndexStyle(zIndex) {
|
|
const style = {};
|
|
if (zIndex !== void 0) {
|
|
style.zIndex = +zIndex;
|
|
}
|
|
return style;
|
|
}
|
|
const camelizeRE = /-(\w)/g;
|
|
const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
|
|
const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
|
const { hasOwnProperty } = Object.prototype;
|
|
function assignKey(to, from, key) {
|
|
const val = from[key];
|
|
if (!isDef(val)) {
|
|
return;
|
|
}
|
|
if (!hasOwnProperty.call(to, key) || !isObject(val)) {
|
|
to[key] = val;
|
|
} else {
|
|
to[key] = deepAssign(Object(to[key]), val);
|
|
}
|
|
}
|
|
function deepAssign(to, from) {
|
|
Object.keys(from).forEach((key) => {
|
|
assignKey(to, from, key);
|
|
});
|
|
return to;
|
|
}
|
|
var stdin_default$7 = {
|
|
name: "姓名",
|
|
tel: "电话",
|
|
save: "保存",
|
|
clear: "清空",
|
|
cancel: "取消",
|
|
confirm: "确认",
|
|
delete: "删除",
|
|
loading: "加载中...",
|
|
noCoupon: "暂无优惠券",
|
|
nameEmpty: "请填写姓名",
|
|
addContact: "添加联系人",
|
|
telInvalid: "请填写正确的电话",
|
|
vanCalendar: {
|
|
end: "结束",
|
|
start: "开始",
|
|
title: "日期选择",
|
|
weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
|
monthTitle: (year, month) => `${year}年${month}月`,
|
|
rangePrompt: (maxRange) => `最多选择 ${maxRange} 天`
|
|
},
|
|
vanCascader: {
|
|
select: "请选择"
|
|
},
|
|
vanPagination: {
|
|
prev: "上一页",
|
|
next: "下一页"
|
|
},
|
|
vanPullRefresh: {
|
|
pulling: "下拉即可刷新...",
|
|
loosing: "释放即可刷新..."
|
|
},
|
|
vanSubmitBar: {
|
|
label: "合计:"
|
|
},
|
|
vanCoupon: {
|
|
unlimited: "无门槛",
|
|
discount: (discount) => `${discount}折`,
|
|
condition: (condition) => `满${condition}元可用`
|
|
},
|
|
vanCouponCell: {
|
|
title: "优惠券",
|
|
count: (count) => `${count}张可用`
|
|
},
|
|
vanCouponList: {
|
|
exchange: "兑换",
|
|
close: "不使用",
|
|
enable: "可用",
|
|
disabled: "不可用",
|
|
placeholder: "输入优惠码"
|
|
},
|
|
vanAddressEdit: {
|
|
area: "地区",
|
|
areaEmpty: "请选择地区",
|
|
addressEmpty: "请填写详细地址",
|
|
addressDetail: "详细地址",
|
|
defaultAddress: "设为默认收货地址"
|
|
},
|
|
vanAddressList: {
|
|
add: "新增地址"
|
|
}
|
|
};
|
|
const lang = ref("zh-CN");
|
|
const messages = reactive({
|
|
"zh-CN": stdin_default$7
|
|
});
|
|
const Locale = {
|
|
messages() {
|
|
return messages[lang.value];
|
|
},
|
|
use(newLang, newMessages) {
|
|
lang.value = newLang;
|
|
this.add({ [newLang]: newMessages });
|
|
},
|
|
add(newMessages = {}) {
|
|
deepAssign(messages, newMessages);
|
|
}
|
|
};
|
|
var stdin_default$6 = Locale;
|
|
function createTranslate(name2) {
|
|
const prefix = camelize(name2) + ".";
|
|
return (path, ...args) => {
|
|
const messages2 = stdin_default$6.messages();
|
|
const message = get(messages2, prefix + path) || get(messages2, path);
|
|
return isFunction(message) ? message(...args) : message;
|
|
};
|
|
}
|
|
function genBem(name2, mods) {
|
|
if (!mods) {
|
|
return "";
|
|
}
|
|
if (typeof mods === "string") {
|
|
return ` ${name2}--${mods}`;
|
|
}
|
|
if (Array.isArray(mods)) {
|
|
return mods.reduce(
|
|
(ret, item) => ret + genBem(name2, item),
|
|
""
|
|
);
|
|
}
|
|
return Object.keys(mods).reduce(
|
|
(ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
|
|
""
|
|
);
|
|
}
|
|
function createBEM(name2) {
|
|
return (el, mods) => {
|
|
if (el && typeof el !== "string") {
|
|
mods = el;
|
|
el = "";
|
|
}
|
|
el = el ? `${name2}__${el}` : name2;
|
|
return `${el}${genBem(el, mods)}`;
|
|
};
|
|
}
|
|
function createNamespace(name2) {
|
|
const prefixedName = `van-${name2}`;
|
|
return [
|
|
prefixedName,
|
|
createBEM(prefixedName),
|
|
createTranslate(prefixedName)
|
|
];
|
|
}
|
|
const HAPTICS_FEEDBACK = "van-haptics-feedback";
|
|
const TAP_OFFSET = 5;
|
|
function callInterceptor(interceptor, {
|
|
args = [],
|
|
done,
|
|
canceled,
|
|
error
|
|
}) {
|
|
if (interceptor) {
|
|
const returnVal = interceptor.apply(null, args);
|
|
if (isPromise(returnVal)) {
|
|
returnVal.then((value) => {
|
|
if (value) {
|
|
done();
|
|
} else if (canceled) {
|
|
canceled();
|
|
}
|
|
}).catch(error || noop);
|
|
} else if (returnVal) {
|
|
done();
|
|
} else if (canceled) {
|
|
canceled();
|
|
}
|
|
} else {
|
|
done();
|
|
}
|
|
}
|
|
function withInstall(options) {
|
|
options.install = (app) => {
|
|
const { name: name2 } = options;
|
|
if (name2) {
|
|
app.component(name2, options);
|
|
app.component(camelize(`-${name2}`), options);
|
|
}
|
|
};
|
|
return options;
|
|
}
|
|
const [name$6, bem$6] = createNamespace("badge");
|
|
const badgeProps = {
|
|
dot: Boolean,
|
|
max: numericProp,
|
|
tag: makeStringProp("div"),
|
|
color: String,
|
|
offset: Array,
|
|
content: numericProp,
|
|
showZero: truthProp,
|
|
position: makeStringProp("top-right")
|
|
};
|
|
var stdin_default$5 = defineComponent({
|
|
name: name$6,
|
|
props: badgeProps,
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
const hasContent = () => {
|
|
if (slots.content) {
|
|
return true;
|
|
}
|
|
const {
|
|
content,
|
|
showZero
|
|
} = props;
|
|
return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
|
|
};
|
|
const renderContent = () => {
|
|
const {
|
|
dot,
|
|
max,
|
|
content
|
|
} = props;
|
|
if (!dot && hasContent()) {
|
|
if (slots.content) {
|
|
return slots.content();
|
|
}
|
|
if (isDef(max) && isNumeric(content) && +content > +max) {
|
|
return `${max}+`;
|
|
}
|
|
return content;
|
|
}
|
|
};
|
|
const getOffsetWithMinusString = (val) => val.startsWith("-") ? val.replace("-", "") : `-${val}`;
|
|
const style = computed(() => {
|
|
const style2 = {
|
|
background: props.color
|
|
};
|
|
if (props.offset) {
|
|
const [x, y] = props.offset;
|
|
const {
|
|
position
|
|
} = props;
|
|
const [offsetY, offsetX] = position.split("-");
|
|
if (slots.default) {
|
|
if (typeof y === "number") {
|
|
style2[offsetY] = addUnit(offsetY === "top" ? y : -y);
|
|
} else {
|
|
style2[offsetY] = offsetY === "top" ? addUnit(y) : getOffsetWithMinusString(y);
|
|
}
|
|
if (typeof x === "number") {
|
|
style2[offsetX] = addUnit(offsetX === "left" ? x : -x);
|
|
} else {
|
|
style2[offsetX] = offsetX === "left" ? addUnit(x) : getOffsetWithMinusString(x);
|
|
}
|
|
} else {
|
|
style2.marginTop = addUnit(y);
|
|
style2.marginLeft = addUnit(x);
|
|
}
|
|
}
|
|
return style2;
|
|
});
|
|
const renderBadge = () => {
|
|
if (hasContent() || props.dot) {
|
|
return createVNode("div", {
|
|
"class": bem$6([props.position, {
|
|
dot: props.dot,
|
|
fixed: !!slots.default
|
|
}]),
|
|
"style": style.value
|
|
}, [renderContent()]);
|
|
}
|
|
};
|
|
return () => {
|
|
if (slots.default) {
|
|
const {
|
|
tag
|
|
} = props;
|
|
return createVNode(tag, {
|
|
"class": bem$6("wrapper")
|
|
}, {
|
|
default: () => [slots.default(), renderBadge()]
|
|
});
|
|
}
|
|
return renderBadge();
|
|
};
|
|
}
|
|
});
|
|
const Badge = withInstall(stdin_default$5);
|
|
let globalZIndex = 2e3;
|
|
const useGlobalZIndex = () => ++globalZIndex;
|
|
const setGlobalZIndex = (val) => {
|
|
globalZIndex = val;
|
|
};
|
|
const [name$5, bem$5] = createNamespace("config-provider");
|
|
const CONFIG_PROVIDER_KEY = Symbol(name$5);
|
|
const configProviderProps = {
|
|
tag: makeStringProp("div"),
|
|
theme: makeStringProp("light"),
|
|
zIndex: Number,
|
|
themeVars: Object,
|
|
themeVarsDark: Object,
|
|
themeVarsLight: Object,
|
|
themeVarsScope: makeStringProp("local"),
|
|
iconPrefix: String
|
|
};
|
|
function insertDash(str) {
|
|
return str.replace(/([a-zA-Z])(\d)/g, "$1-$2");
|
|
}
|
|
function mapThemeVarsToCSSVars(themeVars) {
|
|
const cssVars = {};
|
|
Object.keys(themeVars).forEach((key) => {
|
|
const formattedKey = insertDash(kebabCase(key));
|
|
cssVars[`--van-${formattedKey}`] = themeVars[key];
|
|
});
|
|
return cssVars;
|
|
}
|
|
defineComponent({
|
|
name: name$5,
|
|
props: configProviderProps,
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
const style = computed(() => mapThemeVarsToCSSVars(extend({}, props.themeVars, props.theme === "dark" ? props.themeVarsDark : props.themeVarsLight)));
|
|
provide(CONFIG_PROVIDER_KEY, props);
|
|
watchEffect(() => {
|
|
if (props.zIndex !== void 0) {
|
|
setGlobalZIndex(props.zIndex);
|
|
}
|
|
});
|
|
return () => createVNode(props.tag, {
|
|
"class": bem$5(),
|
|
"style": props.themeVarsScope === "local" ? style.value : void 0
|
|
}, {
|
|
default: () => {
|
|
var _a;
|
|
return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
|
}
|
|
});
|
|
}
|
|
});
|
|
const [name$4, bem$4] = createNamespace("icon");
|
|
const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
|
|
const iconProps = {
|
|
dot: Boolean,
|
|
tag: makeStringProp("i"),
|
|
name: String,
|
|
size: numericProp,
|
|
badge: numericProp,
|
|
color: String,
|
|
badgeProps: Object,
|
|
classPrefix: String
|
|
};
|
|
var stdin_default$4 = defineComponent({
|
|
name: name$4,
|
|
props: iconProps,
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
const config = inject(CONFIG_PROVIDER_KEY, null);
|
|
const classPrefix = computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$4());
|
|
return () => {
|
|
const {
|
|
tag,
|
|
dot,
|
|
name: name2,
|
|
size,
|
|
badge,
|
|
color
|
|
} = props;
|
|
const isImageIcon = isImage(name2);
|
|
return createVNode(Badge, mergeProps({
|
|
"dot": dot,
|
|
"tag": tag,
|
|
"class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
|
|
"style": {
|
|
color,
|
|
fontSize: addUnit(size)
|
|
},
|
|
"content": badge
|
|
}, props.badgeProps), {
|
|
default: () => {
|
|
var _a;
|
|
return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && createVNode("img", {
|
|
"class": bem$4("image"),
|
|
"src": name2
|
|
}, null)];
|
|
}
|
|
});
|
|
};
|
|
}
|
|
});
|
|
const Icon = withInstall(stdin_default$4);
|
|
const popupSharedProps = {
|
|
// whether to show popup
|
|
show: Boolean,
|
|
// z-index
|
|
zIndex: numericProp,
|
|
// whether to show overlay
|
|
overlay: truthProp,
|
|
// transition duration
|
|
duration: numericProp,
|
|
// teleport
|
|
teleport: [String, Object],
|
|
// prevent body scroll
|
|
lockScroll: truthProp,
|
|
// whether to lazy render
|
|
lazyRender: truthProp,
|
|
// callback function before close
|
|
beforeClose: Function,
|
|
// overlay props
|
|
overlayProps: Object,
|
|
// overlay custom style
|
|
overlayStyle: Object,
|
|
// overlay custom class name
|
|
overlayClass: unknownProp,
|
|
// Initial rendering animation
|
|
transitionAppear: Boolean,
|
|
// whether to close popup when overlay is clicked
|
|
closeOnClickOverlay: truthProp
|
|
};
|
|
const popupSharedPropKeys = Object.keys(
|
|
popupSharedProps
|
|
);
|
|
function useExpose(apis) {
|
|
const instance = getCurrentInstance();
|
|
if (instance) {
|
|
extend(instance.proxy, apis);
|
|
}
|
|
}
|
|
function getDirection(x, y) {
|
|
if (x > y) {
|
|
return "horizontal";
|
|
}
|
|
if (y > x) {
|
|
return "vertical";
|
|
}
|
|
return "";
|
|
}
|
|
function useTouch() {
|
|
const startX = ref(0);
|
|
const startY = ref(0);
|
|
const deltaX = ref(0);
|
|
const deltaY = ref(0);
|
|
const offsetX = ref(0);
|
|
const offsetY = ref(0);
|
|
const direction = ref("");
|
|
const isTap = ref(true);
|
|
const isVertical = () => direction.value === "vertical";
|
|
const isHorizontal = () => direction.value === "horizontal";
|
|
const reset = () => {
|
|
deltaX.value = 0;
|
|
deltaY.value = 0;
|
|
offsetX.value = 0;
|
|
offsetY.value = 0;
|
|
direction.value = "";
|
|
isTap.value = true;
|
|
};
|
|
const start = ((event) => {
|
|
reset();
|
|
startX.value = event.touches[0].clientX;
|
|
startY.value = event.touches[0].clientY;
|
|
});
|
|
const move = ((event) => {
|
|
const touch = event.touches[0];
|
|
deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
|
|
deltaY.value = touch.clientY - startY.value;
|
|
offsetX.value = Math.abs(deltaX.value);
|
|
offsetY.value = Math.abs(deltaY.value);
|
|
const LOCK_DIRECTION_DISTANCE = 10;
|
|
if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
|
|
direction.value = getDirection(offsetX.value, offsetY.value);
|
|
}
|
|
if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
|
|
isTap.value = false;
|
|
}
|
|
});
|
|
return {
|
|
move,
|
|
start,
|
|
reset,
|
|
startX,
|
|
startY,
|
|
deltaX,
|
|
deltaY,
|
|
offsetX,
|
|
offsetY,
|
|
direction,
|
|
isVertical,
|
|
isHorizontal,
|
|
isTap
|
|
};
|
|
}
|
|
let totalLockCount = 0;
|
|
const BODY_LOCK_CLASS = "van-overflow-hidden";
|
|
function useLockScroll(rootRef, shouldLock) {
|
|
const touch = useTouch();
|
|
const DIRECTION_UP = "01";
|
|
const DIRECTION_DOWN = "10";
|
|
const onTouchMove = (event) => {
|
|
touch.move(event);
|
|
const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
|
|
const el = getScrollParent(
|
|
event.target,
|
|
rootRef.value
|
|
);
|
|
const { scrollHeight, offsetHeight, scrollTop } = el;
|
|
let status = "11";
|
|
if (scrollTop === 0) {
|
|
status = offsetHeight >= scrollHeight ? "00" : "01";
|
|
} else if (scrollTop + offsetHeight >= scrollHeight) {
|
|
status = "10";
|
|
}
|
|
if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
|
|
preventDefault(event);
|
|
}
|
|
};
|
|
const lock = () => {
|
|
(void 0).addEventListener("touchstart", touch.start);
|
|
(void 0).addEventListener("touchmove", onTouchMove, { passive: false });
|
|
if (!totalLockCount) {
|
|
(void 0).body.classList.add(BODY_LOCK_CLASS);
|
|
}
|
|
totalLockCount++;
|
|
};
|
|
const unlock = () => {
|
|
if (totalLockCount) {
|
|
(void 0).removeEventListener("touchstart", touch.start);
|
|
(void 0).removeEventListener("touchmove", onTouchMove);
|
|
totalLockCount--;
|
|
if (!totalLockCount) {
|
|
(void 0).body.classList.remove(BODY_LOCK_CLASS);
|
|
}
|
|
}
|
|
};
|
|
watch(shouldLock, (value) => {
|
|
value ? lock() : unlock();
|
|
});
|
|
}
|
|
function useLazyRender(show) {
|
|
const inited = ref(false);
|
|
watch(
|
|
show,
|
|
(value) => {
|
|
if (value) {
|
|
inited.value = value;
|
|
}
|
|
},
|
|
{ immediate: true }
|
|
);
|
|
return (render) => () => inited.value ? render() : null;
|
|
}
|
|
const POPUP_TOGGLE_KEY = /* @__PURE__ */ Symbol();
|
|
const useScopeId = () => {
|
|
var _a;
|
|
const { scopeId } = ((_a = getCurrentInstance()) == null ? void 0 : _a.vnode) || {};
|
|
return scopeId ? { [scopeId]: "" } : null;
|
|
};
|
|
const [name$3, bem$3] = createNamespace("overlay");
|
|
const overlayProps = {
|
|
show: Boolean,
|
|
zIndex: numericProp,
|
|
duration: numericProp,
|
|
className: unknownProp,
|
|
lockScroll: truthProp,
|
|
lazyRender: truthProp,
|
|
customStyle: Object,
|
|
teleport: [String, Object]
|
|
};
|
|
var stdin_default$3 = defineComponent({
|
|
name: name$3,
|
|
inheritAttrs: false,
|
|
props: overlayProps,
|
|
setup(props, {
|
|
attrs,
|
|
slots
|
|
}) {
|
|
const root = ref();
|
|
const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
|
|
const renderOverlay = lazyRender(() => {
|
|
var _a;
|
|
const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
|
|
if (isDef(props.duration)) {
|
|
style.animationDuration = `${props.duration}s`;
|
|
}
|
|
return withDirectives(createVNode("div", mergeProps({
|
|
"ref": root,
|
|
"style": style,
|
|
"class": [bem$3(), props.className]
|
|
}, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, props.show]]);
|
|
});
|
|
return () => {
|
|
const Content = createVNode(Transition, {
|
|
"name": "van-fade",
|
|
"appear": true
|
|
}, {
|
|
default: renderOverlay
|
|
});
|
|
if (props.teleport) {
|
|
return createVNode(Teleport, {
|
|
"to": props.teleport
|
|
}, {
|
|
default: () => [Content]
|
|
});
|
|
}
|
|
return Content;
|
|
};
|
|
}
|
|
});
|
|
const Overlay = withInstall(stdin_default$3);
|
|
const popupProps = extend({}, popupSharedProps, {
|
|
round: Boolean,
|
|
position: makeStringProp("center"),
|
|
closeIcon: makeStringProp("cross"),
|
|
closeable: Boolean,
|
|
transition: String,
|
|
iconPrefix: String,
|
|
closeOnPopstate: Boolean,
|
|
closeIconPosition: makeStringProp("top-right"),
|
|
destroyOnClose: Boolean,
|
|
safeAreaInsetTop: Boolean,
|
|
safeAreaInsetBottom: Boolean
|
|
});
|
|
const [name$2, bem$2] = createNamespace("popup");
|
|
var stdin_default$2 = defineComponent({
|
|
name: name$2,
|
|
inheritAttrs: false,
|
|
props: popupProps,
|
|
emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
|
|
setup(props, {
|
|
emit,
|
|
attrs,
|
|
slots
|
|
}) {
|
|
let opened;
|
|
const zIndex = ref();
|
|
const popupRef = ref();
|
|
const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
|
|
const style = computed(() => {
|
|
const style2 = {
|
|
zIndex: zIndex.value
|
|
};
|
|
if (isDef(props.duration)) {
|
|
const key = props.position === "center" ? "animationDuration" : "transitionDuration";
|
|
style2[key] = `${props.duration}s`;
|
|
}
|
|
return style2;
|
|
});
|
|
const open = () => {
|
|
if (!opened) {
|
|
opened = true;
|
|
zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
|
|
emit("open");
|
|
}
|
|
};
|
|
const close = () => {
|
|
if (opened) {
|
|
callInterceptor(props.beforeClose, {
|
|
done() {
|
|
opened = false;
|
|
emit("close");
|
|
emit("update:show", false);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
const onClickOverlay = (event) => {
|
|
emit("clickOverlay", event);
|
|
if (props.closeOnClickOverlay) {
|
|
close();
|
|
}
|
|
};
|
|
const renderOverlay = () => {
|
|
if (props.overlay) {
|
|
const overlayProps2 = extend({
|
|
show: props.show,
|
|
class: props.overlayClass,
|
|
zIndex: zIndex.value,
|
|
duration: props.duration,
|
|
customStyle: props.overlayStyle,
|
|
role: props.closeOnClickOverlay ? "button" : void 0,
|
|
tabindex: props.closeOnClickOverlay ? 0 : void 0
|
|
}, props.overlayProps);
|
|
return createVNode(Overlay, mergeProps(overlayProps2, useScopeId(), {
|
|
"onClick": onClickOverlay
|
|
}), {
|
|
default: slots["overlay-content"]
|
|
});
|
|
}
|
|
};
|
|
const onClickCloseIcon = (event) => {
|
|
emit("clickCloseIcon", event);
|
|
close();
|
|
};
|
|
const renderCloseIcon = () => {
|
|
if (props.closeable) {
|
|
return createVNode(Icon, {
|
|
"role": "button",
|
|
"tabindex": 0,
|
|
"name": props.closeIcon,
|
|
"class": [bem$2("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
|
|
"classPrefix": props.iconPrefix,
|
|
"onClick": onClickCloseIcon
|
|
}, null);
|
|
}
|
|
};
|
|
let timer;
|
|
const onOpened = () => {
|
|
if (timer) clearTimeout(timer);
|
|
timer = setTimeout(() => {
|
|
emit("opened");
|
|
});
|
|
};
|
|
const onClosed = () => emit("closed");
|
|
const onKeydown = (event) => emit("keydown", event);
|
|
const renderPopup = lazyRender(() => {
|
|
var _a;
|
|
const {
|
|
destroyOnClose,
|
|
round,
|
|
position,
|
|
safeAreaInsetTop,
|
|
safeAreaInsetBottom,
|
|
show
|
|
} = props;
|
|
if (!show && destroyOnClose) {
|
|
return;
|
|
}
|
|
return withDirectives(createVNode("div", mergeProps({
|
|
"ref": popupRef,
|
|
"style": style.value,
|
|
"role": "dialog",
|
|
"tabindex": 0,
|
|
"class": [bem$2({
|
|
round,
|
|
[position]: position
|
|
}), {
|
|
"van-safe-area-top": safeAreaInsetTop,
|
|
"van-safe-area-bottom": safeAreaInsetBottom
|
|
}],
|
|
"onKeydown": onKeydown
|
|
}, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vShow, show]]);
|
|
});
|
|
const renderTransition = () => {
|
|
const {
|
|
position,
|
|
transition,
|
|
transitionAppear
|
|
} = props;
|
|
const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
|
|
return createVNode(Transition, {
|
|
"name": transition || name2,
|
|
"appear": transitionAppear,
|
|
"onAfterEnter": onOpened,
|
|
"onAfterLeave": onClosed
|
|
}, {
|
|
default: renderPopup
|
|
});
|
|
};
|
|
watch(() => props.show, (show) => {
|
|
if (show && !opened) {
|
|
open();
|
|
if (attrs.tabindex === 0) {
|
|
nextTick(() => {
|
|
var _a;
|
|
(_a = popupRef.value) == null ? void 0 : _a.focus();
|
|
});
|
|
}
|
|
}
|
|
if (!show && opened) {
|
|
opened = false;
|
|
emit("close");
|
|
}
|
|
});
|
|
useExpose({
|
|
popupRef
|
|
});
|
|
useLockScroll(popupRef, () => props.show && props.lockScroll);
|
|
provide(POPUP_TOGGLE_KEY, () => props.show);
|
|
return () => {
|
|
if (props.teleport) {
|
|
return createVNode(Teleport, {
|
|
"to": props.teleport
|
|
}, {
|
|
default: () => [renderOverlay(), renderTransition()]
|
|
});
|
|
}
|
|
return createVNode(Fragment, null, [renderOverlay(), renderTransition()]);
|
|
};
|
|
}
|
|
});
|
|
const Popup = withInstall(stdin_default$2);
|
|
const [name$1, bem$1] = createNamespace("loading");
|
|
const SpinIcon = Array(12).fill(null).map((_, index) => createVNode("i", {
|
|
"class": bem$1("line", String(index + 1))
|
|
}, null));
|
|
const CircularIcon = createVNode("svg", {
|
|
"class": bem$1("circular"),
|
|
"viewBox": "25 25 50 50"
|
|
}, [createVNode("circle", {
|
|
"cx": "50",
|
|
"cy": "50",
|
|
"r": "20",
|
|
"fill": "none"
|
|
}, null)]);
|
|
const loadingProps = {
|
|
size: numericProp,
|
|
type: makeStringProp("circular"),
|
|
color: String,
|
|
vertical: Boolean,
|
|
textSize: numericProp,
|
|
textColor: String
|
|
};
|
|
var stdin_default$1 = defineComponent({
|
|
name: name$1,
|
|
props: loadingProps,
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
const spinnerStyle = computed(() => extend({
|
|
color: props.color
|
|
}, getSizeStyle(props.size)));
|
|
const renderIcon = () => {
|
|
const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
|
|
return createVNode("span", {
|
|
"class": bem$1("spinner", props.type),
|
|
"style": spinnerStyle.value
|
|
}, [slots.icon ? slots.icon() : DefaultIcon]);
|
|
};
|
|
const renderText = () => {
|
|
var _a;
|
|
if (slots.default) {
|
|
return createVNode("span", {
|
|
"class": bem$1("text"),
|
|
"style": {
|
|
fontSize: addUnit(props.textSize),
|
|
color: (_a = props.textColor) != null ? _a : props.color
|
|
}
|
|
}, [slots.default()]);
|
|
}
|
|
};
|
|
return () => {
|
|
const {
|
|
type,
|
|
vertical
|
|
} = props;
|
|
return createVNode("div", {
|
|
"class": bem$1([type, {
|
|
vertical
|
|
}]),
|
|
"aria-live": "polite",
|
|
"aria-busy": true
|
|
}, [renderIcon(), renderText()]);
|
|
};
|
|
}
|
|
});
|
|
const Loading = withInstall(stdin_default$1);
|
|
const [name, bem] = createNamespace("action-sheet");
|
|
const actionSheetProps = extend({}, popupSharedProps, {
|
|
title: String,
|
|
round: truthProp,
|
|
actions: makeArrayProp(),
|
|
closeIcon: makeStringProp("cross"),
|
|
closeable: truthProp,
|
|
cancelText: String,
|
|
description: String,
|
|
closeOnPopstate: truthProp,
|
|
closeOnClickAction: Boolean,
|
|
safeAreaInsetBottom: truthProp
|
|
});
|
|
const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
|
|
var stdin_default = defineComponent({
|
|
name,
|
|
props: actionSheetProps,
|
|
emits: ["select", "cancel", "update:show"],
|
|
setup(props, {
|
|
slots,
|
|
emit
|
|
}) {
|
|
const updateShow = (show) => emit("update:show", show);
|
|
const onCancel = () => {
|
|
updateShow(false);
|
|
emit("cancel");
|
|
};
|
|
const renderHeader = () => {
|
|
if (props.title) {
|
|
return createVNode("div", {
|
|
"class": bem("header")
|
|
}, [props.title, props.closeable && createVNode(Icon, {
|
|
"name": props.closeIcon,
|
|
"class": [bem("close"), HAPTICS_FEEDBACK],
|
|
"onClick": onCancel
|
|
}, null)]);
|
|
}
|
|
};
|
|
const renderCancel = () => {
|
|
if (slots.cancel || props.cancelText) {
|
|
return [createVNode("div", {
|
|
"class": bem("gap")
|
|
}, null), createVNode("button", {
|
|
"type": "button",
|
|
"class": bem("cancel"),
|
|
"onClick": onCancel
|
|
}, [slots.cancel ? slots.cancel() : props.cancelText])];
|
|
}
|
|
};
|
|
const renderIcon = (action) => {
|
|
if (action.icon) {
|
|
return createVNode(Icon, {
|
|
"class": bem("item-icon"),
|
|
"name": action.icon
|
|
}, null);
|
|
}
|
|
};
|
|
const renderActionContent = (action, index) => {
|
|
if (action.loading) {
|
|
return createVNode(Loading, {
|
|
"class": bem("loading-icon")
|
|
}, null);
|
|
}
|
|
if (slots.action) {
|
|
return slots.action({
|
|
action,
|
|
index
|
|
});
|
|
}
|
|
return [createVNode("span", {
|
|
"class": bem("name")
|
|
}, [action.name]), action.subname && createVNode("div", {
|
|
"class": bem("subname")
|
|
}, [action.subname])];
|
|
};
|
|
const renderAction = (action, index) => {
|
|
const {
|
|
color,
|
|
loading,
|
|
callback,
|
|
disabled,
|
|
className
|
|
} = action;
|
|
const onClick = () => {
|
|
if (disabled || loading) {
|
|
return;
|
|
}
|
|
if (callback) {
|
|
callback(action);
|
|
}
|
|
if (props.closeOnClickAction) {
|
|
updateShow(false);
|
|
}
|
|
nextTick(() => emit("select", action, index));
|
|
};
|
|
return createVNode("button", {
|
|
"type": "button",
|
|
"style": {
|
|
color
|
|
},
|
|
"class": [bem("item", {
|
|
loading,
|
|
disabled
|
|
}), className],
|
|
"onClick": onClick
|
|
}, [renderIcon(action), renderActionContent(action, index)]);
|
|
};
|
|
const renderDescription = () => {
|
|
if (props.description || slots.description) {
|
|
const content = slots.description ? slots.description() : props.description;
|
|
return createVNode("div", {
|
|
"class": bem("description")
|
|
}, [content]);
|
|
}
|
|
};
|
|
return () => createVNode(Popup, mergeProps({
|
|
"class": bem(),
|
|
"position": "bottom",
|
|
"onUpdate:show": updateShow
|
|
}, pick(props, popupInheritKeys)), {
|
|
default: () => {
|
|
var _a;
|
|
return [renderHeader(), renderDescription(), createVNode("div", {
|
|
"class": bem("content")
|
|
}, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
|
|
}
|
|
});
|
|
}
|
|
});
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "BasicActionSheet",
|
|
__ssrInlineRender: true,
|
|
props: {
|
|
cancelText: { default: "بازگشت" },
|
|
showButton: { type: Boolean, default: false },
|
|
showCancel: { type: Boolean, default: true },
|
|
showOk: { type: Boolean, default: true },
|
|
okText: { default: "ثبت" }
|
|
},
|
|
setup(__props) {
|
|
const props = __props;
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
const _component_VanActionSheet = stdin_default;
|
|
const _component_AButton = Button;
|
|
_push(ssrRenderComponent(_component_VanActionSheet, mergeProps({
|
|
teleport: "body",
|
|
dir: "ltr",
|
|
"close-on-click-overlay": true
|
|
}, _attrs), {
|
|
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
if (_push2) {
|
|
_push2(`<div class="justify-center cursor-pointer flex mt-1"${_scopeId}><span class="rounded-sm w-12 border-t-2 border-t-solid border-t-gray-500 mt-2"${_scopeId}></span></div><div class="mx-4 mb-5 mt-3 max-h-90% overflow-y-auto"${_scopeId}>`);
|
|
ssrRenderSlot(_ctx.$slots, "default", {}, null, _push2, _parent2, _scopeId);
|
|
if (props.showButton && (props.showCancel || props.showOk)) {
|
|
_push2(`<div class="${ssrRenderClass([[!props.showOk || !props.showCancel ? "grid-cols-1" : "grid-cols-12"], "grid gap-3 mb-5 mt-2"])}"${_scopeId}>`);
|
|
if (props.showCancel) {
|
|
_push2(ssrRenderComponent(_component_AButton, {
|
|
onClick: ($event) => _ctx.$emit("cancel"),
|
|
type: "primary",
|
|
class: [{ "col-span-4": props.showOk }],
|
|
size: "large",
|
|
ghost: "",
|
|
block: ""
|
|
}, {
|
|
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
|
|
if (_push3) {
|
|
_push3(`${ssrInterpolate(props.cancelText)}`);
|
|
} else {
|
|
return [
|
|
createTextVNode(toDisplayString(props.cancelText), 1)
|
|
];
|
|
}
|
|
}),
|
|
_: 1
|
|
}, _parent2, _scopeId));
|
|
} else {
|
|
_push2(`<!---->`);
|
|
}
|
|
if (props.showOk) {
|
|
_push2(ssrRenderComponent(_component_AButton, {
|
|
onClick: ($event) => _ctx.$emit("ok"),
|
|
type: "primary",
|
|
class: [{ "col-span-8": props.showCancel }],
|
|
size: "large",
|
|
block: ""
|
|
}, {
|
|
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
|
|
if (_push3) {
|
|
_push3(`${ssrInterpolate(props.okText)}`);
|
|
} else {
|
|
return [
|
|
createTextVNode(toDisplayString(props.okText), 1)
|
|
];
|
|
}
|
|
}),
|
|
_: 1
|
|
}, _parent2, _scopeId));
|
|
} else {
|
|
_push2(`<!---->`);
|
|
}
|
|
_push2(`</div>`);
|
|
} else {
|
|
_push2(`<!---->`);
|
|
}
|
|
_push2(`</div>`);
|
|
} else {
|
|
return [
|
|
createVNode("div", {
|
|
class: "justify-center cursor-pointer flex mt-1",
|
|
onClick: ($event) => _ctx.$emit("update:show", false)
|
|
}, [
|
|
createVNode("span", { class: "rounded-sm w-12 border-t-2 border-t-solid border-t-gray-500 mt-2" })
|
|
], 8, ["onClick"]),
|
|
createVNode("div", { class: "mx-4 mb-5 mt-3 max-h-90% overflow-y-auto" }, [
|
|
renderSlot(_ctx.$slots, "default"),
|
|
props.showButton && (props.showCancel || props.showOk) ? (openBlock(), createBlock("div", {
|
|
key: 0,
|
|
class: ["grid gap-3 mb-5 mt-2", [!props.showOk || !props.showCancel ? "grid-cols-1" : "grid-cols-12"]]
|
|
}, [
|
|
props.showCancel ? (openBlock(), createBlock(_component_AButton, {
|
|
key: 0,
|
|
onClick: ($event) => _ctx.$emit("cancel"),
|
|
type: "primary",
|
|
class: [{ "col-span-4": props.showOk }],
|
|
size: "large",
|
|
ghost: "",
|
|
block: ""
|
|
}, {
|
|
default: withCtx(() => [
|
|
createTextVNode(toDisplayString(props.cancelText), 1)
|
|
]),
|
|
_: 1
|
|
}, 8, ["onClick", "class"])) : createCommentVNode("", true),
|
|
props.showOk ? (openBlock(), createBlock(_component_AButton, {
|
|
key: 1,
|
|
onClick: ($event) => _ctx.$emit("ok"),
|
|
type: "primary",
|
|
class: [{ "col-span-8": props.showCancel }],
|
|
size: "large",
|
|
block: ""
|
|
}, {
|
|
default: withCtx(() => [
|
|
createTextVNode(toDisplayString(props.okText), 1)
|
|
]),
|
|
_: 1
|
|
}, 8, ["onClick", "class"])) : createCommentVNode("", true)
|
|
], 2)) : createCommentVNode("", true)
|
|
])
|
|
];
|
|
}
|
|
}),
|
|
_: 3
|
|
}, _parent));
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup = _sfc_main.setup;
|
|
_sfc_main.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/BasicPacks/BasicActionSheet.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
const BasicActionSheet = Object.assign(_sfc_main, { __name: "BasicPacksBasicActionSheet" });
|
|
|
|
export { BasicActionSheet as B };
|