234 lines
6.1 KiB
JavaScript
234 lines
6.1 KiB
JavaScript
import { ref, reactive } from 'vue';
|
|
|
|
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 makeNumericProp = (defaultVal) => ({
|
|
type: numericProp,
|
|
default: defaultVal
|
|
});
|
|
const makeStringProp = (defaultVal) => ({
|
|
type: String,
|
|
default: defaultVal
|
|
});
|
|
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$1 = {
|
|
name: "\u59D3\u540D",
|
|
tel: "\u7535\u8BDD",
|
|
save: "\u4FDD\u5B58",
|
|
clear: "\u6E05\u7A7A",
|
|
cancel: "\u53D6\u6D88",
|
|
confirm: "\u786E\u8BA4",
|
|
delete: "\u5220\u9664",
|
|
loading: "\u52A0\u8F7D\u4E2D...",
|
|
noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
|
|
nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
|
|
addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
|
|
telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
|
|
vanCalendar: {
|
|
end: "\u7ED3\u675F",
|
|
start: "\u5F00\u59CB",
|
|
title: "\u65E5\u671F\u9009\u62E9",
|
|
weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
|
|
monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
|
|
rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
|
|
},
|
|
vanCascader: {
|
|
select: "\u8BF7\u9009\u62E9"
|
|
},
|
|
vanPagination: {
|
|
prev: "\u4E0A\u4E00\u9875",
|
|
next: "\u4E0B\u4E00\u9875"
|
|
},
|
|
vanPullRefresh: {
|
|
pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
|
|
loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
|
|
},
|
|
vanSubmitBar: {
|
|
label: "\u5408\u8BA1:"
|
|
},
|
|
vanCoupon: {
|
|
unlimited: "\u65E0\u95E8\u69DB",
|
|
discount: (discount) => `${discount}\u6298`,
|
|
condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
|
|
},
|
|
vanCouponCell: {
|
|
title: "\u4F18\u60E0\u5238",
|
|
count: (count) => `${count}\u5F20\u53EF\u7528`
|
|
},
|
|
vanCouponList: {
|
|
exchange: "\u5151\u6362",
|
|
close: "\u4E0D\u4F7F\u7528",
|
|
enable: "\u53EF\u7528",
|
|
disabled: "\u4E0D\u53EF\u7528",
|
|
placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
|
|
},
|
|
vanAddressEdit: {
|
|
area: "\u5730\u533A",
|
|
areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
|
|
addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
|
|
addressDetail: "\u8BE6\u7EC6\u5730\u5740",
|
|
defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
|
|
},
|
|
vanAddressList: {
|
|
add: "\u65B0\u589E\u5730\u5740"
|
|
}
|
|
};
|
|
const lang = ref("zh-CN");
|
|
const messages = reactive({
|
|
"zh-CN": stdin_default$1
|
|
});
|
|
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 = Locale;
|
|
function createTranslate(name) {
|
|
const prefix = camelize(name) + ".";
|
|
return (path, ...args) => {
|
|
const messages2 = stdin_default.messages();
|
|
const message = get(messages2, prefix + path) || get(messages2, path);
|
|
return isFunction(message) ? message(...args) : message;
|
|
};
|
|
}
|
|
function genBem(name, mods) {
|
|
if (!mods) {
|
|
return "";
|
|
}
|
|
if (typeof mods === "string") {
|
|
return ` ${name}--${mods}`;
|
|
}
|
|
if (Array.isArray(mods)) {
|
|
return mods.reduce(
|
|
(ret, item) => ret + genBem(name, item),
|
|
""
|
|
);
|
|
}
|
|
return Object.keys(mods).reduce(
|
|
(ret, key) => ret + (mods[key] ? genBem(name, key) : ""),
|
|
""
|
|
);
|
|
}
|
|
function createBEM(name) {
|
|
return (el, mods) => {
|
|
if (el && typeof el !== "string") {
|
|
mods = el;
|
|
el = "";
|
|
}
|
|
el = el ? `${name}__${el}` : name;
|
|
return `${el}${genBem(el, mods)}`;
|
|
};
|
|
}
|
|
function createNamespace(name) {
|
|
const prefixedName = `van-${name}`;
|
|
return [
|
|
prefixedName,
|
|
createBEM(prefixedName),
|
|
createTranslate(prefixedName)
|
|
];
|
|
}
|
|
function withInstall(options) {
|
|
options.install = (app) => {
|
|
const { name } = options;
|
|
if (name) {
|
|
app.component(name, options);
|
|
app.component(camelize(`-${name}`), options);
|
|
}
|
|
};
|
|
return options;
|
|
}
|
|
|
|
export { makeNumericProp as a, addUnit as b, createNamespace as c, makeArrayProp as d, extend as e, isNumeric as f, getSizeStyle as g, getZIndexStyle as h, isDef as i, isPromise as j, kebabCase as k, noop as l, makeStringProp as m, numericProp as n, pick as p, truthProp as t, unknownProp as u, withInstall as w };
|
|
//# sourceMappingURL=base-C_z4ndMf.mjs.map
|