@gyenno/nutui-taro
Version:
京东风格的轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)
1,633 lines (1,632 loc) • 679 kB
JavaScript
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("@nutui/icons-vue-taro"), require("@tarojs/taro")) : typeof define === "function" && define.amd ? define(["exports", "vue", "@nutui/icons-vue-taro", "@tarojs/taro"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.nutui = {}, global.Vue, global.iconsVueTaro, global.Taro));
})(this, function(exports2, vue, iconsVueTaro, Taro) {
"use strict";var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
class BaseLang {
}
let Lang$1 = class Lang extends BaseLang {
constructor() {
super(...arguments);
__publicField(this, "save", "保存");
__publicField(this, "confirm", "确认");
__publicField(this, "cancel", "取消");
__publicField(this, "done", "完成");
__publicField(this, "noData", "暂无数据");
__publicField(this, "placeholder", "请输入");
__publicField(this, "select", "请选择");
__publicField(this, "video", {
errorTip: "视频加载失败",
clickRetry: "点击重试"
});
__publicField(this, "fixednav", {
activeText: "收起导航",
unActiveText: "快速导航"
});
__publicField(this, "pagination", {
prev: "上一页",
next: "下一页"
});
__publicField(this, "calendaritem", {
weekdays: ["日", "一", "二", "三", "四", "五", "六"],
end: "结束",
start: "开始",
title: "日期选择",
monthTitle: (year, month) => `${year}年${month}月`,
today: "今天"
});
__publicField(this, "shortpassword", {
title: "请输入密码",
desc: "您使用了虚拟资产,请进行验证",
tips: "忘记密码"
});
__publicField(this, "uploader", {
ready: "准备完成",
readyUpload: "准备上传",
waitingUpload: "等待上传",
uploading: "上传中",
success: "上传成功",
error: "上传失败"
});
__publicField(this, "countdown", {
day: "天",
hour: "时",
minute: "分",
second: "秒"
});
__publicField(this, "address", {
selectRegion: "请选择所在地区",
deliveryTo: "配送至",
chooseAnotherAddress: "选择其他地址"
});
__publicField(this, "signature", {
reSign: "重签",
unSupportTpl: "对不起,当前浏览器不支持Canvas,无法使用本控件!"
});
__publicField(this, "ecard", {
chooseText: "请选择电子卡面值",
otherValueText: "其他面值",
placeholder: "请输入1-5000整数"
});
__publicField(this, "timeselect", {
pickupTime: "取件时间"
});
__publicField(this, "sku", {
buyNow: "立即购买",
buyNumber: "购买数量",
addToCart: "加入购物车"
});
__publicField(this, "skuheader", {
skuId: "商品编号"
});
__publicField(this, "addresslist", {
addAddress: "新建地址",
default: "默认"
});
__publicField(this, "comment", {
complaintsText: "我要投诉",
additionalReview: (day) => `购买${day}天后追评`,
additionalImages: (length) => `${length}张追评图片`
});
__publicField(this, "infiniteloading", {
loading: "加载中...",
pullTxt: "松开刷新",
loadMoreTxt: "哎呀,这里是底部了啦"
});
__publicField(this, "datepicker", {
year: "年",
month: "月",
day: "日",
hour: "时",
min: "分",
seconds: "秒"
});
__publicField(this, "audiooperate", {
back: "倒退",
start: "开始",
pause: "暂停",
forward: "快进",
mute: "静音"
});
__publicField(this, "pullrefresh", {
pulling: "下拉刷新",
loosing: "释放刷新",
loading: "加载中..."
});
}
};
class Lang extends BaseLang {
constructor() {
super(...arguments);
__publicField(this, "save", "Save");
__publicField(this, "confirm", "Confirm");
__publicField(this, "cancel", "Cancel");
__publicField(this, "done", "Done");
__publicField(this, "noData", "No Data");
__publicField(this, "placeholder", "Placeholder");
__publicField(this, "select", "Select");
__publicField(this, "video", {
errorTip: "Error Tip",
clickRetry: "Click Retry"
});
__publicField(this, "fixednav", {
activeText: "Close Nav",
unActiveText: "Open Nav"
});
__publicField(this, "pagination", {
prev: "Previous",
next: "Next"
});
__publicField(this, "calendaritem", {
weekdays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
end: "End",
start: "Start",
title: "Calendar",
monthTitle: (year, month) => `${year}/${month}`,
today: "Today"
});
__publicField(this, "shortpassword", {
title: "Please input a password",
desc: "Verify",
tips: "Forget password"
});
__publicField(this, "uploader", {
ready: "Ready",
readyUpload: "Ready to upload",
waitingUpload: "Waiting for upload",
uploading: "Uploading",
success: "Upload successful",
error: "Upload failed"
});
__publicField(this, "countdown", {
day: " Day ",
hour: " Hour ",
minute: " Minute ",
second: " Second "
});
__publicField(this, "address", {
selectRegion: "Select Region",
deliveryTo: "Delivery To",
chooseAnotherAddress: "Choose Another Address"
});
__publicField(this, "signature", {
reSign: "Re Sign",
unSupportTpl: `Sorry, the current browser doesn't support canvas, so we can't use this control!`
});
__publicField(this, "ecard", {
chooseText: "Select",
otherValueText: "Other Value",
placeholder: "Placeholder"
});
__publicField(this, "timeselect", {
pickupTime: "Pickup Time"
});
__publicField(this, "sku", {
buyNow: "Buy Now",
buyNumber: "Buy Number",
addToCart: "Add to Cart"
});
__publicField(this, "skuheader", {
skuId: "Sku Number"
});
__publicField(this, "addresslist", {
addAddress: "Add New Address",
default: "default"
});
__publicField(this, "comment", {
complaintsText: "I have a complaint",
additionalReview: (day) => `Review after ${day} days of purchase`,
additionalImages: (length) => `There are ${length} follow-up comments`
});
__publicField(this, "infiniteloading", {
loading: "Loading...",
pullTxt: "Loose to refresh",
loadMoreTxt: "Oops, this is the bottom"
});
__publicField(this, "datepicker", {
year: "Year",
month: "Month",
day: "Day",
hour: "Hour",
min: "Minute",
seconds: "Second"
});
__publicField(this, "audiooperate", {
back: "Back",
start: "Start",
pause: "Pause",
forward: "Forward",
mute: "Mute"
});
__publicField(this, "pullrefresh", {
pulling: "Pull to refresh...",
loosing: "Loose to refresh...",
loading: "Loading..."
});
}
}
const funInterceptor = (interceptor, {
args = [],
done,
canceled
}) => {
if (interceptor) {
const returnVal = interceptor.apply(null, args);
if (isPromise(returnVal)) {
returnVal.then((value) => {
if (value) {
done(value);
} else if (canceled) {
canceled();
}
}).catch(() => {
});
} else if (returnVal) {
done();
} else if (canceled) {
canceled();
}
} else {
done();
}
};
const TypeOfFun = (value) => {
if (null === value) {
return "null";
}
const type = typeof value;
if ("undefined" === type || "string" === type) {
return type;
}
const typeString = toString.call(value);
switch (typeString) {
case "[object Array]":
return "array";
case "[object Date]":
return "date";
case "[object Boolean]":
return "boolean";
case "[object Number]":
return "number";
case "[object Function]":
return "function";
case "[object RegExp]":
return "regexp";
case "[object Object]":
if (void 0 !== value.nodeType) {
if (3 == value.nodeType) {
return /\S/.test(value.nodeValue) ? "textnode" : "whitespace";
} else {
return "element";
}
} else {
return "object";
}
default:
return "unknow";
}
};
const isArray = Array.isArray;
const isDate$1 = (val) => val instanceof Date;
const isFunction = (val) => typeof val === "function";
const isObject = (val) => val !== null && typeof val === "object";
const isPromise = (val) => {
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
};
const getPropByPath = (obj, keyPath) => {
try {
return keyPath.split(".").reduce((prev, curr) => prev[curr], obj);
} catch (error) {
return "";
}
};
const floatData = (format, dataOp, mapOps) => {
let mergeFormat = Object.assign({}, format);
let mergeMapOps = Object.assign({}, mapOps);
if (Object.keys(dataOp).length > 0) {
Object.keys(mergeFormat).forEach((keys) => {
if (mergeMapOps.hasOwnProperty(keys)) {
const tof = TypeOfFun(mergeMapOps[keys]);
if (tof == "function") {
mergeFormat[keys] = mergeMapOps[keys](dataOp);
}
if (tof == "string") {
mergeFormat[keys] = dataOp[mergeMapOps[keys]];
}
} else {
if (dataOp[keys])
mergeFormat[keys] = dataOp[keys];
}
});
return mergeFormat;
}
return format;
};
const deepMerge = (target, newObj) => {
Object.keys(newObj).forEach((key) => {
let targetValue = target[key];
let newObjValue = newObj[key];
if (isObject(targetValue) && isObject(newObjValue)) {
deepMerge(targetValue, newObjValue);
} else {
target[key] = newObjValue;
}
});
return target;
};
function myFixed(num, digit = 2) {
if (Object.is(parseFloat(num), NaN)) {
return console.log(`传入的值:${num}不是一个数字`);
}
num = parseFloat(num);
return (Math.round((num + Number.EPSILON) * Math.pow(10, digit)) / Math.pow(10, digit)).toFixed(digit);
}
function preventDefault(event, isStopPropagation) {
if (typeof event.cancelable !== "boolean" || event.cancelable) {
event.preventDefault();
}
if (isStopPropagation) {
event.stopPropagation();
}
}
const padZero = (num, length = 2) => {
num += "";
while (num.length < length) {
num = "0" + num;
}
return num.toString();
};
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
const langs = vue.reactive({
"zh-CN": new Lang$1(),
"en-US": new Lang()
});
class Locale {
static languages() {
return langs[this.currentLang.value];
}
static use(lang, newLanguages) {
if (newLanguages) {
langs[lang] = new newLanguages();
}
this.currentLang.value = lang;
}
static merge(lang, newLanguages) {
if (newLanguages) {
if (langs[lang]) {
deepMerge(langs[lang], newLanguages);
} else {
this.use(lang, newLanguages);
}
}
}
}
__publicField(Locale, "currentLang", vue.ref("zh-CN"));
function createComponent(name) {
const componentName2 = "nut-" + name;
return {
componentName: componentName2,
translate(keyPath, ...args) {
const languages = Locale.languages();
const text = getPropByPath(languages, `${name.replace("-", "")}.${keyPath}`) || getPropByPath(languages, keyPath);
return isFunction(text) ? text(...args) : text;
},
create: function(_component) {
_component.baseName = name;
_component.name = componentName2;
_component.install = (vue2) => {
vue2.component(_component.name, _component);
};
return vue.defineComponent(_component);
},
createDemo: function(_component) {
_component.baseName = name;
_component.name = "demo-" + name;
return vue.defineComponent(_component);
}
};
}
const renderIcon = (icon, props) => {
if (icon)
return vue.h(icon, props);
return "";
};
const { componentName: componentName$1f, create: create$1G } = createComponent("button");
const _sfc_main$1G = create$1G({
components: { Loading: iconsVueTaro.Loading },
props: {
color: String,
shape: {
type: String,
default: "round"
},
plain: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
type: {
type: String,
default: "default"
},
formType: {
type: String,
default: "button"
},
size: {
type: String,
default: "normal"
},
block: {
type: Boolean,
default: false
}
},
emits: ["click"],
setup(props, { emit, slots }) {
const { type, size, shape, disabled, loading, color, plain, block } = vue.toRefs(props);
const handleClick = (event) => {
if (!loading.value && !disabled.value) {
emit("click", event);
}
};
const classes = vue.computed(() => {
const prefixCls = componentName$1f;
return {
[prefixCls]: true,
[`${prefixCls}--${type.value}`]: type.value,
[`${prefixCls}--${size.value}`]: size.value,
[`${prefixCls}--${shape.value}`]: shape.value,
[`${prefixCls}--plain`]: plain.value,
[`${prefixCls}--block`]: block.value,
[`${prefixCls}--disabled`]: disabled.value,
[`${prefixCls}--loading`]: loading.value
};
});
const getStyle = vue.computed(() => {
var _a;
const style = {};
if (color == null ? void 0 : color.value) {
if (plain.value) {
style.color = color.value;
style.background = "#fff";
if (!((_a = color.value) == null ? void 0 : _a.includes("gradient"))) {
style.borderColor = color.value;
}
} else {
style.color = "#fff";
style.background = color.value;
}
}
return style;
});
return {
handleClick,
classes,
getStyle,
Taro
};
}
});
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _hoisted_1$1c = ["type", "formType"];
const _hoisted_2$10 = { class: "nut-button__wrap" };
function _sfc_render$1u(_ctx, _cache, $props, $setup, $data, $options) {
const _component_Loading = vue.resolveComponent("Loading");
return vue.openBlock(), vue.createElementBlock("button", {
class: vue.normalizeClass(_ctx.classes),
style: vue.normalizeStyle(_ctx.getStyle),
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
type: _ctx.Taro.getEnv() === _ctx.Taro.ENV_TYPE.WEB ? _ctx.formType : void 0,
formType: _ctx.formType === "button" ? void 0 : _ctx.formType
}, [
vue.createElementVNode("view", _hoisted_2$10, [
_ctx.loading ? (vue.openBlock(), vue.createBlock(_component_Loading, {
key: 0,
class: "nut-icon-loading"
})) : vue.createCommentVNode("", true),
vue.createTextVNode(),
_ctx.$slots.icon && !_ctx.loading ? vue.renderSlot(_ctx.$slots, "icon", { key: 1 }) : vue.createCommentVNode("", true),
vue.createTextVNode(),
_ctx.$slots.default ? (vue.openBlock(), vue.createElementBlock("view", {
key: 2,
class: vue.normalizeClass({ "nut-button__text": _ctx.$slots.icon || _ctx.loading })
}, [
vue.renderSlot(_ctx.$slots, "default")
], 2)) : vue.createCommentVNode("", true)
])
], 14, _hoisted_1$1c);
}
const Button = /* @__PURE__ */ _export_sfc(_sfc_main$1G, [["render", _sfc_render$1u]]);
const pxCheck = (value) => {
return isNaN(Number(value)) ? String(value) : `${value}px`;
};
const { componentName: componentName$1e, create: create$1F } = createComponent("cell");
const _sfc_main$1F = create$1F({
components: { Right: iconsVueTaro.Right },
props: {
title: { type: String, default: "" },
subTitle: { type: String, default: "" },
desc: { type: String, default: "" },
descTextAlign: { type: String, default: "right" },
isLink: { type: Boolean, default: false },
to: { type: String, default: "" },
replace: { type: Boolean, default: false },
roundRadius: { type: [String, Number], default: "" },
url: { type: String, default: "" },
center: { type: Boolean, default: false },
size: { type: String, default: "" }
// large
},
emits: ["click"],
setup(props, { emit }) {
const classes = vue.computed(() => {
const prefixCls = componentName$1e;
return {
[prefixCls]: true,
[`${prefixCls}--clickable`]: props.isLink || props.to,
[`${prefixCls}--center`]: props.center,
[`${prefixCls}--large`]: props.size == "large"
};
});
const baseStyle = vue.computed(() => {
return {
borderRadius: pxCheck(props.roundRadius)
};
});
const handleClick = (event) => {
emit("click", event);
};
return {
handleClick,
classes,
baseStyle
};
}
});
const _hoisted_1$1b = {
key: 0,
class: "nut-cell__icon"
};
const _hoisted_2$$ = {
key: 1,
class: "nut-cell__title"
};
const _hoisted_3$P = { class: "title" };
const _hoisted_4$F = { class: "nut-cell__title-desc" };
function render$2(_ctx, _cache, $props, $setup, $data, $options) {
const _component_Right = vue.resolveComponent("Right");
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(_ctx.classes),
style: vue.normalizeStyle(_ctx.baseStyle),
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
_ctx.$slots.icon ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_1$1b, [
vue.renderSlot(_ctx.$slots, "icon")
])) : vue.createCommentVNode("", true),
vue.createTextVNode(),
_ctx.title || _ctx.subTitle || _ctx.$slots.title ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_2$$, [
_ctx.subTitle ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
vue.renderSlot(_ctx.$slots, "title", {}, () => [
vue.createElementVNode("view", _hoisted_3$P, vue.toDisplayString(_ctx.title), 1)
]),
vue.createTextVNode(),
vue.createElementVNode("view", _hoisted_4$F, vue.toDisplayString(_ctx.subTitle), 1)
], 64)) : vue.renderSlot(_ctx.$slots, "title", { key: 1 }, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.title), 1)
])
])) : vue.createCommentVNode("", true),
vue.createTextVNode(),
_ctx.desc ? (vue.openBlock(), vue.createElementBlock("view", {
key: 2,
class: vue.normalizeClass(["nut-cell__value", { "nut-cell__value--alone": !_ctx.title && !_ctx.subTitle && !_ctx.$slots.title }]),
style: vue.normalizeStyle({ "text-align": _ctx.descTextAlign })
}, vue.toDisplayString(_ctx.desc), 7)) : vue.createCommentVNode("", true),
vue.createTextVNode(),
vue.renderSlot(_ctx.$slots, "link", {}, () => [
_ctx.isLink || _ctx.to ? (vue.openBlock(), vue.createBlock(_component_Right, {
key: 0,
class: "nut-cell__link"
})) : vue.createCommentVNode("", true)
])
])
], 6);
}
const Cell = /* @__PURE__ */ _export_sfc(_sfc_main$1F, [["render", render$2]]);
const { componentName: componentName$1d, create: create$1E } = createComponent("cell-group");
const _sfc_main$1E = create$1E({
props: {
title: { type: String, default: "" },
desc: { type: String, default: "" }
},
setup() {
const classes = vue.computed(() => {
const prefixCls = componentName$1d;
return {
[prefixCls]: true
};
});
return {
classes
};
}
});
const _hoisted_1$1a = {
key: 1,
class: "nut-cell-group__title"
};
const _hoisted_2$_ = {
key: 3,
class: "nut-cell-group__desc"
};
const _hoisted_3$O = { class: "nut-cell-group__wrap" };
function _sfc_render$1t(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(_ctx.classes)
}, [
_ctx.$slots.title ? vue.renderSlot(_ctx.$slots, "title", { key: 0 }) : _ctx.title ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_1$1a, vue.toDisplayString(_ctx.title), 1)) : vue.createCommentVNode("", true),
vue.createTextVNode(),
_ctx.$slots.desc ? vue.renderSlot(_ctx.$slots, "desc", { key: 2 }) : _ctx.desc ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_2$_, vue.toDisplayString(_ctx.desc), 1)) : vue.createCommentVNode("", true),
vue.createTextVNode(),
vue.createElementVNode("view", _hoisted_3$O, [
vue.renderSlot(_ctx.$slots, "default")
])
], 2);
}
const CellGroup = /* @__PURE__ */ _export_sfc(_sfc_main$1E, [["render", _sfc_render$1t]]);
const { componentName: componentName$1c, create: create$1D } = createComponent("overlay");
const _sfc_main$1D = create$1D({
props: {
visible: {
type: Boolean,
default: false
},
zIndex: {
type: [Number, String],
default: 2e3
},
duration: {
type: [Number, String],
default: 0.3
},
overlayClass: {
type: String,
default: ""
},
lockScroll: {
type: Boolean,
default: true
},
overlayStyle: {
type: Object
},
closeOnClickOverlay: {
type: Boolean,
default: true
}
},
emits: ["click", "update:visible"],
setup(props, { emit }) {
const classes = vue.computed(() => {
const prefixCls = componentName$1c;
return {
[prefixCls]: true,
[props.overlayClass]: true
};
});
const style = vue.computed(() => {
return {
transitionDuration: `${props.duration}s`,
zIndex: props.zIndex,
...props.overlayStyle
};
});
const onClick = (e) => {
emit("click", e);
if (props.closeOnClickOverlay) {
emit("update:visible", false);
}
};
return { classes, style, onClick };
}
});
const _hoisted_1$19 = ["catch-move"];
function _sfc_render$1s(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createBlock(vue.Transition, { name: "overlay-fade" }, {
default: vue.withCtx(() => [
vue.withDirectives(vue.createElementVNode("view", {
class: vue.normalizeClass(_ctx.classes),
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClick && _ctx.onClick(...args)),
style: vue.normalizeStyle(_ctx.style),
"catch-move": _ctx.lockScroll
}, [
vue.renderSlot(_ctx.$slots, "default")
], 14, _hoisted_1$19), [
[vue.vShow, _ctx.visible]
])
]),
_: 3
});
}
const Overlay = /* @__PURE__ */ _export_sfc(_sfc_main$1D, [["render", _sfc_render$1s]]);
const popupProps = {
visible: {
type: Boolean,
default: false
},
zIndex: {
type: [Number, String],
default: 2e3
},
duration: {
type: [Number, String],
default: 0.3
},
lockScroll: {
type: Boolean,
default: true
},
closeOnClickOverlay: {
type: Boolean,
default: true
},
position: {
type: String,
default: "center"
},
transition: {
type: String,
default: ""
},
style: {
type: Object,
default: {}
},
popClass: {
type: String,
default: ""
},
closeable: {
type: Boolean,
default: false
},
closeIconPosition: {
type: String,
default: "top-right"
},
closeIcon: {
type: String,
default: "close"
},
destroyOnClose: {
type: Boolean,
default: true
},
teleport: {
type: [String, Element],
default: "body"
},
overlay: {
type: Boolean,
default: true
},
round: {
type: Boolean,
default: false
},
teleportDisable: {
type: Boolean,
default: false
},
safeAreaInsetBottom: {
type: Boolean,
default: false
},
overlayClass: {
type: String,
default: ""
},
overlayStyle: {
type: Object,
default: {}
}
};
const initIndex = 2e3;
let _zIndex$1 = initIndex;
const component$6 = (componentName2, components) => {
return {
components,
props: {
...popupProps
},
emits: ["click-pop", "click-close-icon", "open", "close", "opend", "closed", "click-overlay", "update:visible"],
setup(props, { emit }) {
const state = vue.reactive({
zIndex: props.zIndex,
showSlot: true,
closed: props.closeable
});
const classes = vue.computed(() => {
const prefixCls = componentName2;
return {
[prefixCls]: true,
["round"]: props.round,
[`nut-popup--${props.position}`]: true,
[`nut-popup--${props.position}--safebottom`]: props.position === "bottom" && props.safeAreaInsetBottom,
[props.popClass]: true
};
});
const popStyle = vue.computed(() => {
return {
zIndex: state.zIndex,
transitionDuration: `${props.duration}s`,
...props.style
};
});
const transitionName = vue.computed(() => {
return props.transition ? props.transition : `nut-popup-slide-${props.position}`;
});
const open = () => {
if (props.zIndex !== initIndex) {
_zIndex$1 = Number(props.zIndex);
}
emit("update:visible", true);
state.zIndex = ++_zIndex$1;
if (props.destroyOnClose) {
state.showSlot = true;
}
emit("open");
};
const close = () => {
emit("update:visible", false);
emit("close");
if (props.destroyOnClose) {
setTimeout(() => {
state.showSlot = false;
}, +props.duration * 1e3);
}
};
const onClick = (e) => {
emit("click-pop", e);
};
const onClickCloseIcon = (e) => {
e.stopPropagation();
emit("click-close-icon", e);
emit("update:visible", false);
};
const onClickOverlay = (e) => {
emit("click-overlay", e);
if (props.closeOnClickOverlay) {
emit("update:visible", false);
}
};
const onOpened = (e) => {
emit("opend", e);
};
const onClosed = (e) => {
emit("closed", e);
};
vue.watch(
() => props.visible,
(val) => {
props.visible ? open() : close();
}
);
vue.watchEffect(() => {
state.closed = props.closeable;
});
return {
...vue.toRefs(state),
popStyle,
transitionName,
classes,
onClick,
onClickCloseIcon,
onClickOverlay,
onOpened,
onClosed
};
}
};
};
const { componentName: componentName$1b, create: create$1C } = createComponent("popup");
const _sfc_main$1C = create$1C(
component$6(componentName$1b, {
[Overlay.name]: Overlay,
Close: iconsVueTaro.Close
})
);
function _sfc_render$1r(_ctx, _cache, $props, $setup, $data, $options) {
const _component_nut_overlay = vue.resolveComponent("nut-overlay");
const _component_Close = vue.resolveComponent("Close");
return vue.openBlock(), vue.createElementBlock("div", null, [
_ctx.overlay ? (vue.openBlock(), vue.createBlock(_component_nut_overlay, vue.mergeProps({
key: 0,
visible: _ctx.visible,
"close-on-click-overlay": _ctx.closeOnClickOverlay,
"z-index": _ctx.zIndex,
"lock-scroll": _ctx.lockScroll,
duration: _ctx.duration,
"overlay-class": _ctx.overlayClass,
"overlay-style": _ctx.overlayStyle,
onClick: _ctx.onClickOverlay
}, _ctx.$attrs), null, 16, ["visible", "close-on-click-overlay", "z-index", "lock-scroll", "duration", "overlay-class", "overlay-style", "onClick"])) : vue.createCommentVNode("", true),
vue.createTextVNode(),
vue.createVNode(vue.Transition, {
name: _ctx.transitionName,
onAfterEnter: _ctx.onOpened,
onAfterLeave: _ctx.onClosed
}, {
default: vue.withCtx(() => [
vue.withDirectives(vue.createElementVNode("view", {
class: vue.normalizeClass(_ctx.classes),
style: vue.normalizeStyle(_ctx.popStyle),
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.onClick && _ctx.onClick(...args))
}, [
_ctx.showSlot ? vue.renderSlot(_ctx.$slots, "default", { key: 0 }) : vue.createCommentVNode("", true),
vue.createTextVNode(),
_ctx.closed ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClickCloseIcon && _ctx.onClickCloseIcon(...args)),
class: vue.normalizeClass(["nut-popup__close-icon", "nut-popup__close-icon--" + _ctx.closeIconPosition])
}, [
vue.renderSlot(_ctx.$slots, "close-icon", {}, () => [
vue.createVNode(_component_Close, { height: "12px" })
])
], 2)) : vue.createCommentVNode("", true)
], 6), [
[vue.vShow, _ctx.visible]
])
]),
_: 3
}, 8, ["name", "onAfterEnter", "onAfterLeave"])
]);
}
const Popup = /* @__PURE__ */ _export_sfc(_sfc_main$1C, [["render", _sfc_render$1r]]);
const { componentName: componentName$1a, create: create$1B } = createComponent("config-provider");
const _sfc_main$1B = create$1B({
props: {
theme: { type: String, default: "" },
themeVars: { type: Object, default: {} },
tag: { type: String, default: "view" }
},
setup(props, { slots }) {
const kebabCase = (str) => {
str = str.replace(str.charAt(0), str.charAt(0).toLocaleLowerCase());
return str.replace(/([a-z])([A-Z])/g, (_, p1, p2) => p1 + "-" + p2.toLowerCase());
};
const colorRgb = (str) => {
if (!str)
return;
var sColor = str.toLowerCase();
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
if (sColor && reg.test(sColor)) {
if (sColor.length === 4) {
var sColorNew = "#";
for (var i = 1; i < 4; i += 1) {
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
}
sColor = sColorNew;
}
var sColorChange = [];
for (var i = 1; i < 7; i += 2) {
sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
}
return sColorChange.join(",");
}
return null;
};
const mapThemeVarsToCSSVars = (themeVars) => {
var _a;
if (!themeVars)
return;
const cssVars = {};
const primaryColor = (_a = props == null ? void 0 : props.themeVars) == null ? void 0 : _a.primaryColor;
if (primaryColor) {
cssVars[`--nut-address-region-tab-line`] = `linear-gradient(90deg, ${primaryColor} 0%, rgba(${colorRgb(
primaryColor
)},0.15) 100%) `;
cssVars[`--nut-tabs-horizontal-tab-line-color`] = `linear-gradient(90deg, ${primaryColor} 0%, rgba(${colorRgb(
primaryColor
)},0.15)100%)`;
cssVars[`--nut-tabs-vertical-tab-line-color`] = `linear-gradient(180deg, ${primaryColor} 0%, rgba(${colorRgb(
primaryColor
)},0.15) 100%) `;
}
Object.keys(themeVars).forEach((key) => {
cssVars[`--nut-${kebabCase(key)}`] = themeVars[key];
});
return cssVars;
};
return () => {
var _a;
const defaultSlots = (_a = slots.default) == null ? void 0 : _a.call(slots);
return vue.h(
props.tag,
{
class: `nut-theme-${props.theme}`,
style: mapThemeVarsToCSSVars(props.themeVars)
},
defaultSlots
);
};
}
});
const { create: create$1A } = createComponent("layout");
const _sfc_main$1A = create$1A({});
const { componentName: componentName$19, create: create$1z } = createComponent("col");
const _sfc_main$1z = create$1z({
props: {
span: {
type: [String, Number],
default: "24"
},
offset: {
type: [String, Number],
default: "0"
}
},
emits: [],
setup(props) {
const prefixCls = componentName$19;
const gutter = vue.inject("gutter");
const classes = vue.computed(() => {
return {
[prefixCls]: true,
[prefixCls + "-gutter"]: gutter,
["nut-col-" + props.span]: true,
["nut-col-offset-" + props.offset]: true
};
});
const style = vue.computed(() => {
return {
paddingLeft: gutter / 2 + "px",
paddingRight: gutter / 2 + "px"
};
});
return {
classes,
style
};
}
});
function _sfc_render$1q(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(_ctx.classes),
style: vue.normalizeStyle(_ctx.style)
}, [
vue.renderSlot(_ctx.$slots, "default")
], 6);
}
const Col = /* @__PURE__ */ _export_sfc(_sfc_main$1z, [["render", _sfc_render$1q]]);
const { componentName: componentName$18, create: create$1y } = createComponent("row");
const _sfc_main$1y = create$1y({
props: {
type: {
type: String,
default: ""
},
gutter: {
type: [String, Number],
default: ""
},
justify: {
type: String,
default: "start"
},
align: {
type: String,
default: "flex-start"
},
flexWrap: {
type: String,
default: "nowrap"
}
},
emits: [],
setup(props) {
const prefixCls = componentName$18;
vue.provide("gutter", props.gutter);
const getClass = (prefix, type) => {
return prefix ? type ? `nut-row-${prefix}-${type}` : "" : `nut-row-${type}`;
};
const getClasses = () => {
return `
${getClass("", props.type)}
${getClass("justify", props.justify)}
${getClass("align", props.align)}
${getClass("flex", props.flexWrap)}
${prefixCls}
`;
};
return {
getClasses
};
}
});
function _sfc_render$1p(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(_ctx.getClasses())
}, [
vue.renderSlot(_ctx.$slots, "default")
], 2);
}
const Row = /* @__PURE__ */ _export_sfc(_sfc_main$1y, [["render", _sfc_render$1p]]);
const { componentName: componentName$17, create: create$1x } = createComponent("sticky");
const _sfc_main$1x = create$1x({
props: {
top: {
type: [Number, String],
default: 0
},
zIndex: {
type: [Number, String],
default: 2e3
},
parentHeight: {
type: [Number],
default: 667
}
},
emits: ["change", "scroll"],
setup(props, { emit, slots }) {
const root = vue.ref();
const rootStyle = vue.computed(() => {
return {
height: `${props.parentHeight}px`
};
});
const stickyStyle = vue.computed(() => {
const style = {
top: `${props.top}px`,
zIndex: +props.zIndex
};
return style;
});
const renderFixed = () => {
var _a;
return vue.h(
"view",
{
style: stickyStyle.value,
class: `${componentName$17} nut-sticky--stickyed`
},
(_a = slots.default) == null ? void 0 : _a.call(slots)
);
};
return () => {
return vue.h(
"view",
{
style: rootStyle.value,
ref: root
},
[renderFixed()]
);
};
}
});
const { componentName: componentName$16, create: create$1w } = createComponent("divider");
const _sfc_main$1w = create$1w({
props: {
contentPosition: {
type: String,
default: "center"
},
dashed: {
type: Boolean,
default: false
},
hairline: {
type: Boolean,
default: true
},
direction: {
type: String,
default: "horizontal"
}
},
components: {},
setup(props, context) {
const classes = vue.computed(() => {
const prefixCls = componentName$16;
let defaultClassesObj = {
[prefixCls]: true
};
let classesObj = {};
if (props.direction === "horizontal") {
classesObj = {
...defaultClassesObj,
[`${prefixCls}-center`]: context.slots.default,
[`${prefixCls}-left`]: props.contentPosition === "left",
[`${prefixCls}-right`]: props.contentPosition === "right",
[`${prefixCls}-dashed`]: props.dashed,
[`${prefixCls}-hairline`]: props.hairline
};
} else {
classesObj = {
...defaultClassesObj,
[`${prefixCls}-vertical`]: props.direction === "vertical"
};
}
return classesObj;
});
return { classes };
}
});
function _sfc_render$1o(_ctx, _cache, $props, $setup, $data, $options) {
return _ctx.direction === "horizontal" ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: vue.normalizeClass(_ctx.classes)
}, [
vue.renderSlot(_ctx.$slots, "default")
], 2)) : (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: vue.normalizeClass(_ctx.classes)
}, null, 2));
}
const Divider = /* @__PURE__ */ _export_sfc(_sfc_main$1w, [["render", _sfc_render$1o]]);
function flattenVNodes(children, childName) {
const result = [];
const traverse = (children2) => {
if (!Array.isArray(children2))
return;
children2.forEach((child) => {
var _a;
if (!vue.isVNode(child))
return;
if (childName) {
if (child.type && child.type.name === childName) {
result.push(child);
return;
}
} else {
result.push(child);
}
if ((_a = child.component) == null ? void 0 : _a.subTree) {
traverse(child.component.subTree.children);
}
if (child.children) {
traverse(child.children);
}
});
};
traverse(children);
return result;
}
function sortChildren(parent, internalChildren, childName) {
const vnodes = flattenVNodes(parent.subTree.children, childName);
internalChildren.sort((a, b) => {
return vnodes.indexOf(a.vnode) - vnodes.indexOf(b.vnode);
});
}
function useProvide(key, childName) {
const internalChildren = vue.shallowReactive([]);
const parent = vue.getCurrentInstance();
const add = (child) => {
if (!child.proxy)
return;
internalChildren.push(vue.markRaw(child));
sortChildren(parent, internalChildren, childName);
};
const remove = (child) => {
internalChildren.splice(internalChildren.indexOf(vue.markRaw(child)), 1);
};
const extend = Object.assign;
return (value) => {
vue.provide(
key,
extend(
{
add,
remove,
internalChildren
},
value
)
);
return {
internalChildren
};
};
}
const { componentName: componentName$15 } = createComponent("grid");
const GRID_KEY = Symbol("grid");
const gridProps = {
// 列数
columnNum: {
type: [Number, String],
default: 4
},
// 是否显示边框
border: {
type: Boolean,
default: true
},
// 格子之间间隔距离
gutter: {
type: [Number, String],
default: 0
},
// 是否内容居中
center: {
type: Boolean,
default: true
},
// 是否固定正方形
square: {
type: Boolean,
default: false
},
// 内容与文字翻转
reverse: {
type: Boolean,
default: false
},
// 内容排列方向
direction: {
type: String
},
// 是否开启点击反馈
clickable: {
type: Boolean,
default: false
}
};
const component$5 = {
props: gridProps,
setup(props, { slots }) {
useProvide(GRID_KEY, `${componentName$15}-item`)({ props });
const rootClass = vue.computed(() => {
const prefixCls = componentName$15;
return {
[prefixCls]: true,
[`${prefixCls}--border`]: props.border && !props.gutter
};
});
const rootStyle = vue.computed(() => {
const style = {};
if (props.gutter) {
style.paddingLeft = pxCheck(props.gutter);
}
return style;
});
return () => {
var _a;
return vue.h(
"view",
{
class: rootClass.value,
style: rootStyle.value
},
(_a = slots.default) == null ? void 0 : _a.call(slots)
);
};
}
};
const { create: create$1v } = createComponent("grid");
const _sfc_main$1v = create$1v(component$5);
function useInject(key) {
const parent = vue.inject(key, null);
if (parent) {
const instance = vue.getCurrentInstance();
const { add, remove, internalChildren } = parent;
add(instance);
vue.onUnmounted(() => remove(instance));
const index = vue.computed(() => internalChildren.indexOf(instance));
return {
parent,
index
};
}
return {
parent: null,
index: vue.ref(-1)
};
}
const { create: create$1u, componentName: componentName$14 } = createComponent("grid-item");
const _sfc_main$1u = create$1u({
props: {
text: {
type: String
}
// router
// to: {
// type: [String, Object]
// },
// url: {
// type: String,
// default: ''
// },
// replace: {
// type: Boolean,
// default: false
// }
},
emits: ["click"],
setup(props, { emit }) {
const Parent = useInject(GRID_KEY);
if (!Parent.parent)
return {};
const index = Parent.index;
const parent = Parent.parent.props;
const rootClass = vue.computed(() => {
const prefixCls = componentName$14;
return {
[prefixCls]: true
};
});
const rootStyle = vue.computed(() => {
const style = {
flexBasis: `${100 / +parent.columnNum}%`
};
if (parent.square) {
style.paddingTop = `${100 / +parent.columnNum}%`;
} else if (parent.gutter) {
style.paddingRight = pxCheck(parent.gutter);
if (index.value >= parent.columnNum) {
style.marginTop = pxCheck(parent.gutter);
}
}
return style;
});
const contentClass = vue.computed(() => {
const prefixCls = `${componentName$14}__content`;
return {
[`${prefixCls}`]: true,
[`${prefixCls}--border`]: parent.border,
[`${prefixCls}--surround`]: parent.border && parent.gutter,
[`${prefixCls}--center`]: parent.center,
[`${prefixCls}--square`]: parent.square,
[`${prefixCls}--reverse`]: parent.reverse,
[`${prefixCls}--${parent.direction}`]: !!parent.direction,
[`${prefixCls}--clickable`]: parent.clickable
};
});
const handleClick = (event) => {
emit("click", event);
};
return {
rootClass,
rootStyle,
contentClass,
handleClick
};
}
});
const _hoisted_1$18 = { class: "nut-grid-item__text" };
function _sfc_render$1n(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(_ctx.rootClass),
style: vue.normalizeStyle(_ctx.rootStyle),
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
}, [
vue.createElementVNode("view", {
class: vue.normalizeClass(_ctx.contentClass)
}, [
vue.renderSlot(_ctx.$slots, "default"),
vue.createTextVNode(),
vue.createElementVNode("view", _hoisted_1$18, [
_ctx.text ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
vue.createTextVNode(vue.toDisplayString(_ctx.text), 1)
], 64)) : vue.renderSlot(_ctx.$slots, "text", { key: 1 })
])
], 2)
], 6);
}
const GridItem = /* @__PURE__ */ _export_sfc(_sfc_main$1u, [["render", _sfc_render$1n]]);
const { componentName: componentName$13, create: create$1t } = createComponent("navbar");
const _sfc_main$1t = create$1t({
components: { Left: iconsVueTaro.Left },
props: {
leftShow: { type: Boolean, default: false },
//左侧 是否显示返回icon
title: { type: String, default: "" },
//中间 文字标题
titleIcon: { type: Boolean, default: false },
//中间 标题icon
leftText: { type: String, default: "" },
//左侧文字
desc: { type: String, default: "" },
//右侧 按钮文字
fixed: {
type: Boolean,
default: false
},
safeAreaInsetTop: {
type: Boolean,
default: false
},
border: {
type: Boolean,
default: false
},
placeholder: {
// 生成一个等高的占位元素
type: Boolean,
default: true
},
zIndex: {
type: [Number, String],
default: 10
}
},
emits: ["on-click-back", "on-click-title", "on-click-icon", "on-click-right"],
setup(props, { emit }) {
const { border, fixed, safeAreaInsetTop, placeholder, zIndex } = vue.toRefs(props);
let navHeight = vue.ref(0);
const classes = vue.computed(() => {
const prefixCls = componentName$13;
return {
[prefixCls]: true,
[`${prefixCls}--border`]: border.value,
[`${prefixCls}--fixed`]: fixed.value,
[`${prefixCls}--safe-area-inset-top`]: safeAreaInsetTop.value
};
});
const styles = vue.computed(() => {
return {
zIndex: zIndex.value
};
});
vue.onMounted(() => {
if (fixed.value && placeholder.value) {
setTimeout(() => {
const query = Taro.createSelectorQuery();
query.select(".navBarHtml").boundingClientRect();
query.exec((res) => {
navHeight.value = res[0].height;
});
}, 500);
}
});
function handleLeft() {
emit("on-click-back");
}
function handleCenter() {
emit("on-click-title");
}
function handleCenterIcon() {
emit("on-click-icon");
}
function handleRight() {
emit("on-click-right");
}
return {
navHeight,
classes,
styles,
handleLeft,
handleCenter,
handleCenterIcon,
handleRight
};
}
});
const _hoisted_1$17 = {
key: 1,
class: "nut-navbar__text"
};
const _hoisted_2$Z = { class: "nut-navbar__title" };
const _hoisted_3$N = {
key: 0,
class: "nut-navbar__text"
};
const _hoisted_4$E = {
key: 1,
class: "nut-navbar__text"
};
const _hoisted_5$r = { class: "nut-navbar__title" };
const _hoisted_6$m = {
key: 0,
class: "nut-navbar__text"
};
function _sfc_render$1m(_ctx, _cache, $props, $setup, $data, $options) {
const _component_Left = vue.resolveComponent("Left");
return _ctx.fixed && _ctx.placeholder ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "nut-navbar--placeholder",
style: vue.normalizeStyle({ height: _ctx.navHeight + "px" })
}, [
vue.createElementVNode("view", {
class: vue.normalizeClass([_ctx.classes, "navBarHtml"]),
style: vue.normalizeStyle(_ctx.styles)
},