nutui-taro-upgrade
Version:
@nutui/nutui-taro 对京东风格组件库的taro4 版本支持
1,537 lines (1,536 loc) • 712 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 __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __pow = Math.pow;
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));
var __restKey = (key) => typeof key === "symbol" ? key : key + "";
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
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, "calendarcard", {
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: "加载中...",
complete: "刷新成功"
});
}
};
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, "calendarcard", {
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...",
complete: "Refresh successfully"
});
}
}
const funInterceptor = (interceptor, {
args = [],
done,
canceled
}) => {
if (interceptor) {
const returnVal = interceptor(...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 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) => {
const mergeFormat = Object.assign({}, format);
const mergeMapOps = Object.assign({}, mapOps);
if (Object.keys(dataOp).length > 0) {
Object.keys(mergeFormat).forEach((keys) => {
if (Object.prototype.hasOwnProperty.call(mergeMapOps, 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) => {
const targetValue = target[key];
const 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"));
const _hoisted_1$1j = ["type", "formType"];
const _hoisted_2$11 = { class: "nut-button__wrap" };
const _sfc_main$1L = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutButton"
}), {
__name: "button.taro",
props: {
color: { default: "" },
shape: { default: "round" },
plain: { type: Boolean, default: false },
loading: { type: Boolean, default: false },
disabled: { type: Boolean, default: false },
type: { default: "default" },
size: { default: "normal" },
block: { type: Boolean, default: false },
formType: { default: "button" }
},
emits: ["click"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const handleClick = (event) => {
if (!props.loading && !props.disabled) {
emit("click", event);
}
};
const classes = vue.computed(() => {
const prefixCls2 = "nut-button";
return {
[prefixCls2]: true,
[`${prefixCls2}--${props.type}`]: props.type,
[`${prefixCls2}--${props.size}`]: props.size,
[`${prefixCls2}--${props.shape}`]: props.shape,
[`${prefixCls2}--plain`]: props.plain,
[`${prefixCls2}--block`]: props.block,
[`${prefixCls2}--disabled`]: props.disabled,
[`${prefixCls2}--loading`]: props.loading
};
});
const getStyle = vue.computed(() => {
let style = {};
if (props.color) {
style = {
color: props.plain ? props.color : "#fff",
background: props.plain ? "#fff" : `border-box ${props.color}`
};
if (props.color.includes("gradient")) {
style.borderColor = "transparent";
} else {
style.borderColor = props.color;
}
}
return style;
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("button", {
class: vue.normalizeClass(classes.value),
style: vue.normalizeStyle(getStyle.value),
type: vue.unref(Taro).getEnv() === vue.unref(Taro).ENV_TYPE.WEB ? _ctx.formType : void 0,
formType: _ctx.formType === "button" ? void 0 : _ctx.formType,
onClick: handleClick
}, [
vue.createElementVNode("view", _hoisted_2$11, [
_ctx.loading ? (vue.openBlock(), vue.createBlock(vue.unref(iconsVueTaro.Loading), {
key: 0,
class: "nut-icon-loading"
})) : vue.createCommentVNode("", true),
_cache[0] || (_cache[0] = vue.createTextVNode()),
_ctx.$slots.icon && !_ctx.loading ? vue.renderSlot(_ctx.$slots, "icon", { key: 1 }) : vue.createCommentVNode("", true),
_cache[1] || (_cache[1] = 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$1j);
};
}
}));
const useChildren = (key) => {
const publicChildren = vue.reactive([]);
const internalChildren = vue.reactive([]);
const linkChildren = (value) => {
const link = (child) => {
if (child.proxy) {
internalChildren.push(child);
publicChildren.push(child.proxy);
}
};
const unlink = (child) => {
if (child.proxy) {
const internalIndex = internalChildren.indexOf(child);
if (internalIndex > -1) {
internalChildren.splice(internalIndex, 1);
}
const publicIndex = publicChildren.indexOf(child.proxy);
if (internalIndex > -1) {
publicChildren.splice(publicIndex, 1);
}
}
};
vue.provide(key, __spreadValues({
unlink,
link,
children: publicChildren,
internalChildren
}, value));
};
return {
children: publicChildren,
linkChildren
};
};
const useParent = (key) => {
const parent = vue.inject(key, null);
if (parent) {
const instance = vue.getCurrentInstance();
const { link, unlink, internalChildren } = parent;
link(instance);
vue.onUnmounted(() => {
unlink(instance);
});
const index = vue.computed(() => internalChildren.indexOf(instance));
return { parent, index };
}
return {
parent,
index: vue.computed(() => -1)
};
};
const withInstall = (comp) => {
const _comp = comp;
_comp.install = (vue2) => {
if (_comp.name) {
vue2.component(_comp.name, _comp);
}
};
return _comp;
};
const pxCheck = (value) => {
if (value !== void 0) {
return isNaN(Number(value)) ? String(value) : `${value}px`;
}
};
function useRouter() {
const proxy = vue.getCurrentInstance().proxy;
return proxy.$router || null;
}
withInstall(_sfc_main$1L);
const _hoisted_1$1i = {
key: 0,
class: "nut-cell__icon"
};
const _hoisted_2$10 = {
key: 1,
class: "nut-cell__title"
};
const _hoisted_3$P = { class: "title" };
const _hoisted_4$G = { class: "nut-cell__title-desc" };
const _sfc_main$1K = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutCell"
}), {
__name: "cell.taro",
props: {
title: { default: "" },
subTitle: { default: "" },
desc: { default: "" },
descTextAlign: { default: "right" },
isLink: { type: Boolean, default: false },
roundRadius: { default: "" },
center: { type: Boolean, default: false },
size: { default: "normal" }
},
emits: ["click"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const classes = vue.computed(() => {
const prefixCls2 = "nut-cell";
return {
[prefixCls2]: true,
[`${prefixCls2}--clickable`]: props.isLink,
[`${prefixCls2}--center`]: props.center,
[`${prefixCls2}--large`]: props.size === "large"
};
});
const baseStyle = vue.computed(() => {
return {
borderRadius: pxCheck(props.roundRadius)
};
});
const descStyle = vue.computed(() => {
return {
textAlign: props.descTextAlign
};
});
const handleClick = (event) => {
emit("click", event);
};
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(classes.value),
style: vue.normalizeStyle(baseStyle.value),
onClick: handleClick
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
_ctx.$slots.icon ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_1$1i, [
vue.renderSlot(_ctx.$slots, "icon")
])) : vue.createCommentVNode("", true),
_cache[1] || (_cache[1] = vue.createTextVNode()),
_ctx.title || _ctx.subTitle || _ctx.$slots.title ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_2$10, [
_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)
]),
_cache[0] || (_cache[0] = vue.createTextVNode()),
vue.createElementVNode("view", _hoisted_4$G, vue.toDisplayString(_ctx.subTitle), 1)
], 64)) : vue.renderSlot(_ctx.$slots, "title", { key: 1 }, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.title), 1)
])
])) : vue.createCommentVNode("", true),
_cache[2] || (_cache[2] = vue.createTextVNode()),
_ctx.desc || _ctx.$slots.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(descStyle.value)
}, [
vue.renderSlot(_ctx.$slots, "desc", {}, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.desc), 1)
])
], 6)) : vue.createCommentVNode("", true),
_cache[3] || (_cache[3] = vue.createTextVNode()),
vue.renderSlot(_ctx.$slots, "link", {}, () => [
_ctx.isLink ? (vue.openBlock(), vue.createBlock(vue.unref(iconsVueTaro.Right), {
key: 0,
class: "nut-cell__link"
})) : vue.createCommentVNode("", true)
])
])
], 6);
};
}
}));
withInstall(_sfc_main$1K);
const _hoisted_1$1h = { class: "nut-cell-group" };
const _hoisted_2$$ = {
key: 1,
class: "nut-cell-group__title"
};
const _hoisted_3$O = {
key: 3,
class: "nut-cell-group__desc"
};
const _hoisted_4$F = { class: "nut-cell-group__wrap" };
const _sfc_main$1J = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutCellGroup"
}), {
__name: "cell-group.taro",
props: {
title: { default: "" },
desc: { default: "" }
},
setup(__props) {
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("view", _hoisted_1$1h, [
_ctx.$slots.title ? vue.renderSlot(_ctx.$slots, "title", { key: 0 }) : _ctx.title ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_2$$, vue.toDisplayString(_ctx.title), 1)) : vue.createCommentVNode("", true),
_cache[0] || (_cache[0] = vue.createTextVNode()),
_ctx.$slots.desc ? vue.renderSlot(_ctx.$slots, "desc", { key: 2 }) : _ctx.desc ? (vue.openBlock(), vue.createElementBlock("view", _hoisted_3$O, vue.toDisplayString(_ctx.desc), 1)) : vue.createCommentVNode("", true),
_cache[1] || (_cache[1] = vue.createTextVNode()),
vue.createElementVNode("view", _hoisted_4$F, [
vue.renderSlot(_ctx.$slots, "default")
])
]);
};
}
}));
withInstall(_sfc_main$1J);
const _hoisted_1$1g = ["catch-move"];
const _sfc_main$1I = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutOverlay"
}), {
__name: "overlay.taro",
props: {
visible: { type: Boolean, default: false },
zIndex: { default: 2e3 },
duration: { default: 0.3 },
lockScroll: { type: Boolean, default: true },
overlayClass: { default: "" },
overlayStyle: {},
closeOnClickOverlay: { type: Boolean, default: true }
},
emits: ["click", "update:visible"],
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
const classes = vue.computed(() => {
const prefixCls2 = "nut-overlay";
return {
[prefixCls2]: true,
[props.overlayClass]: true
};
});
const style = vue.computed(() => {
return __spreadValues({
transitionDuration: `${props.duration}s`,
zIndex: props.zIndex
}, props.overlayStyle);
});
const onClick = (e) => {
emit("click", e);
if (props.closeOnClickOverlay) {
emit("update:visible", false);
}
};
return (_ctx, _cache) => {
return vue.openBlock(), vue.createBlock(vue.Transition, { name: "overlay-fade" }, {
default: vue.withCtx(() => [
vue.withDirectives(vue.createElementVNode("view", {
class: vue.normalizeClass(classes.value),
style: vue.normalizeStyle(style.value),
"catch-move": _ctx.lockScroll,
onClick
}, [
vue.renderSlot(_ctx.$slots, "default")
], 14, _hoisted_1$1g), [
[vue.vShow, _ctx.visible]
])
]),
_: 3
});
};
}
}));
withInstall(_sfc_main$1I);
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"
},
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 camelize = (s) => s.replace(/-./g, (x) => x[1].toUpperCase());
function createComponent(name) {
const componentName2 = "nut-" + name;
return {
componentName: componentName2,
create: function(_component) {
_component.name = "Nut" + camelize("-" + name);
_component.install = (vue2) => {
vue2.component(_component.name, _component);
};
return vue.defineComponent(_component);
}
};
}
const renderIcon = (icon, props) => {
if (icon)
return vue.h(icon, props);
return "";
};
const { componentName: componentName$8, create: create$14 } = createComponent("popup");
const initIndex = 2e3;
let _zIndex = initIndex;
const _sfc_main$1H = create$14({
components: {
NutOverlay: _sfc_main$1I,
Close: iconsVueTaro.Close
},
props: popupProps,
emits: ["clickPop", "clickCloseIcon", "open", "close", "opened", "closed", "clickOverlay", "update:visible"],
setup(props, { emit }) {
let opened;
const state = vue.reactive({
zIndex: props.zIndex,
showSlot: true,
closed: props.closeable
});
const classes = vue.computed(() => {
const prefixCls2 = componentName$8;
return {
[prefixCls2]: 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 __spreadValues({
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 (!opened) {
opened = true;
if (props.zIndex !== initIndex) {
_zIndex = Number(props.zIndex);
}
emit("update:visible", true);
state.zIndex = ++_zIndex;
if (props.destroyOnClose) {
state.showSlot = true;
}
emit("open");
}
};
const close = () => {
if (opened) {
opened = false;
emit("update:visible", false);
emit("close");
if (props.destroyOnClose) {
setTimeout(() => {
state.showSlot = false;
}, +props.duration * 1e3);
}
}
};
const onClick = (e) => {
emit("clickPop", e);
};
const onClickCloseIcon = (e) => {
e.stopPropagation();
emit("clickCloseIcon", e);
close();
};
const onClickOverlay = (e) => {
emit("clickOverlay", e);
if (props.closeOnClickOverlay) {
close();
}
};
const onOpened = (el) => {
emit("opened", el);
};
const onClosed = (el) => {
emit("closed", el);
};
vue.watch(
() => props.visible,
() => {
if (props.visible && !opened) {
open();
}
if (!props.visible && opened) {
close();
}
}
);
vue.watchEffect(() => {
state.closed = props.closeable;
});
return __spreadProps(__spreadValues({}, vue.toRefs(state)), {
popStyle,
transitionName,
classes,
onClick,
onClickCloseIcon,
onClickOverlay,
onOpened,
onClosed
});
}
});
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
function _sfc_render$$(_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("view", 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
}, _ctx.$attrs, { onClick: _ctx.onClickOverlay }), null, 16, ["visible", "close-on-click-overlay", "z-index", "lock-scroll", "duration", "overlay-class", "overlay-style", "onClick"])) : vue.createCommentVNode("", true),
_cache[3] || (_cache[3] = 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),
_cache[2] || (_cache[2] = vue.createTextVNode()),
_ctx.closed ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: vue.normalizeClass(["nut-popup__close-icon", "nut-popup__close-icon--" + _ctx.closeIconPosition]),
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.onClickCloseIcon && _ctx.onClickCloseIcon(...args))
}, [
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$1H, [["render", _sfc_render$$]]);
const component = (tag) => {
return {
props: {
theme: { type: String, default: "" },
themeVars: { type: Object, default: {} },
tag: { type: String, default: tag }
},
setup(props, { slots }) {
const hexToRgb = (color) => {
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
if (!reg.test(color))
return "";
color = color.toLowerCase();
if (color.length === 4) {
color = "#" + color.slice(1).split("").map((char) => char + char).join("");
}
const colors = [];
for (let i = 1; i < 7; i += 2) {
colors.push(parseInt("0x" + color.slice(i, i + 2)));
}
return colors.join(",");
};
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 mapThemeVarsToCSSVars = (themeVars) => {
if (!themeVars)
return;
const cssVars = {};
const primaryColor = themeVars == null ? void 0 : themeVars.primaryColor;
if (primaryColor) {
const primaryColorRgb = hexToRgb(primaryColor);
cssVars["--nut-address-region-tab-line"] = `linear-gradient(90deg, ${primaryColor} 0%, rgba(${primaryColorRgb}, 0.15) 100%)`;
cssVars["--nut-tabs-horizontal-tab-line-color"] = `linear-gradient(90deg, ${primaryColor} 0%, rgba(${primaryColorRgb}, 0.15) 100%)`;
cssVars["--nut-tabs-vertical-tab-line-color"] = `linear-gradient(180deg, ${primaryColor} 0%, rgba(${primaryColorRgb}, 0.15) 100%)`;
}
Object.keys(themeVars).forEach((key) => {
cssVars[`--nut-${kebabCase(key)}`] = themeVars[key];
});
return cssVars;
};
const themeStyle = vue.computed(() => mapThemeVarsToCSSVars(props.themeVars));
return () => {
var _a;
return vue.h(
props.tag,
{
class: `nut-theme-${props.theme}`,
style: themeStyle.value
},
(_a = slots.default) == null ? void 0 : _a.call(slots)
);
};
}
};
};
const { create: create$13 } = createComponent("config-provider");
const _sfc_main$1G = create$13(component("view"));
const { create: create$12 } = createComponent("layout");
const _sfc_main$1F = create$12({});
withInstall(_sfc_main$1F);
const LAYOUT_KEY = Symbol("nut-layout");
const prefixCls$1 = "nut-col";
const _sfc_main$1E = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutCol"
}), {
__name: "col.taro",
props: {
span: { default: 24 },
offset: { default: 0 }
},
setup(__props) {
const props = __props;
const gutter = vue.inject(LAYOUT_KEY);
const classes = vue.computed(() => {
return {
[prefixCls$1]: true,
[prefixCls$1 + "-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 (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(classes.value),
style: vue.normalizeStyle(style.value)
}, [
vue.renderSlot(_ctx.$slots, "default")
], 6);
};
}
}));
withInstall(_sfc_main$1E);
const prefixCls = "nut-row";
const _sfc_main$1D = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutRow"
}), {
__name: "row.taro",
props: {
type: { default: "" },
gutter: { default: "" },
justify: { default: "start" },
align: { default: "flex-start" },
flexWrap: { default: "nowrap" }
},
setup(__props) {
const props = __props;
vue.provide(LAYOUT_KEY, props.gutter);
const getClass = (prefix2, type) => {
return prefix2 ? type ? `nut-row-${prefix2}-${type}` : "" : `nut-row-${type}`;
};
const classes = vue.computed(() => {
return [
prefixCls,
getClass("", props.type),
getClass("justify", props.justify),
getClass("align", props.align),
getClass("flex", props.flexWrap)
];
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(classes.value)
}, [
vue.renderSlot(_ctx.$slots, "default")
], 2);
};
}
}));
withInstall(_sfc_main$1D);
function isWindow(val) {
return typeof window !== "undefined" && val === window;
}
const useTaroRectById = (id) => {
return new Promise((resolve, reject) => {
if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
const t = document ? document.querySelector(`#${id}`) : "";
if (t) {
resolve(t == null ? void 0 : t.getBoundingClientRect());
}
reject();
} else {
const query = Taro.createSelectorQuery();
query.select(`#${id}`).boundingClientRect().exec(function(rect) {
if (rect[0]) {
resolve(rect[0]);
} else {
reject();
}
});
}
});
};
const useTaroRect = (elementRef) => {
let element = vue.unref(elementRef);
return new Promise((resolve, reject) => {
if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
if (element && element.$el) {
element = element.$el;
}
if (isWindow(element)) {
const width = element.innerWidth;
const height = element.innerHeight;
resolve({
top: 0,
left: 0,
right: width,
bottom: height,
width,
height
});
}
if (element && element.getBoundingClientRect) {
resolve(element.getBoundingClientRect());
}
reject();
} else {
const query = Taro.createSelectorQuery();
const id = element == null ? void 0 : element.id;
if (id) {
query.select(`#${id}`).boundingClientRect().exec(function(rect) {
if (rect[0]) {
resolve(rect[0]);
} else {
reject();
}
});
} else {
reject();
}
}
});
};
const { create: create$11 } = createComponent("sticky");
const _sfc_main$1C = create$11({
props: {
top: {
type: [Number, String],
default: 0
},
zIndex: {
type: [Number, String],
default: 99
},
scrollTop: {
type: [Number, String],
default: -1
}
},
emits: ["change"],
setup(props, { emit }) {
const refRandomId = Math.random().toString(36).slice(-8);
const rootRef = vue.ref();
const state = vue.reactive({
fixed: false,
height: 0,
width: 0
});
const rootStyle = vue.computed(() => {
if (state.fixed)
return { height: `${state.height}px` };
return {};
});
const stickyStyle = vue.computed(() => {
if (!state.fixed)
return {};
return {
top: `${props.top}px`,
height: `${state.height}px`,
width: `${state.width}px`,
position: state.fixed ? "fixed" : void 0,
zIndex: Number(props.zIndex)
};
});
const handleScroll = () => {
useTaroRect(rootRef).then(
(rootRect) => {
state.height = rootRect.height;
state.width = rootRect.width;
state.fixed = Number(props.top) >= rootRect.top;
},
() => {
}
);
};
vue.watch(
() => state.fixed,
(val) => {
emit("change", val);
}
);
if (props.scrollTop === -1) {
Taro.usePageScroll(handleScroll);
} else {
vue.watch(() => props.scrollTop, handleScroll);
}
vue.onMounted(handleScroll);
return { rootRef, rootStyle, stickyStyle, refRandomId };
}
});
const _hoisted_1$1f = ["id"];
function _sfc_render$_(_ctx, _cache, $props, $setup, $data, $options) {
return vue.openBlock(), vue.createElementBlock("view", {
id: "rootRef-" + _ctx.refRandomId,
ref: "rootRef",
class: "nut-sticky",
style: vue.normalizeStyle(_ctx.rootStyle)
}, [
vue.createElementVNode("view", {
class: "nut-sticky__box",
style: vue.normalizeStyle(_ctx.stickyStyle)
}, [
vue.renderSlot(_ctx.$slots, "default")
], 4)
], 12, _hoisted_1$1f);
}
const Sticky = /* @__PURE__ */ _export_sfc(_sfc_main$1C, [["render", _sfc_render$_]]);
const _sfc_main$1B = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutDivider"
}), {
__name: "divider.taro",
props: {
contentPosition: { default: "center" },
dashed: { type: Boolean, default: false },
hairline: { type: Boolean, default: true },
direction: { default: "horizontal" }
},
setup(__props) {
const props = __props;
const slots = vue.useSlots();
const classes = vue.computed(() => {
const prefixCls2 = "nut-divider";
if (props.direction === "horizontal") {
return {
[prefixCls2]: true,
[`${prefixCls2}-center`]: slots.default,
[`${prefixCls2}-left`]: props.contentPosition === "left",
[`${prefixCls2}-right`]: props.contentPosition === "right",
[`${prefixCls2}-dashed`]: props.dashed,
[`${prefixCls2}-hairline`]: props.hairline
};
} else {
return {
[prefixCls2]: true,
[`${prefixCls2}-vertical`]: props.direction === "vertical"
};
}
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(classes.value)
}, [
_ctx.direction === "horizontal" ? vue.renderSlot(_ctx.$slots, "default", { key: 0 }) : vue.createCommentVNode("", true)
], 2);
};
}
}));
withInstall(_sfc_main$1B);
const GRID_KEY = Symbol("grid");
const _sfc_main$1A = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutGrid"
}), {
__name: "grid.taro",
props: {
columnNum: { default: 4 },
border: { type: Boolean, default: true },
gutter: { default: 0 },
center: { type: Boolean, default: true },
square: { type: Boolean, default: false },
reverse: { type: Boolean, default: false },
direction: {},
clickable: { type: Boolean, default: false }
},
setup(__props) {
const props = __props;
const { linkChildren } = useChildren(GRID_KEY);
linkChildren({ props });
const rootClass = vue.computed(() => {
const prefixCls2 = "nut-grid";
return {
[prefixCls2]: true,
[`${prefixCls2}--border`]: props.border && !props.gutter
};
});
const rootStyle = vue.computed(() => {
const style = {};
if (props.gutter) {
style.paddingLeft = pxCheck(props.gutter);
}
return style;
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("view", {
class: vue.normalizeClass(rootClass.value),
style: vue.normalizeStyle(rootStyle.value)
}, [
vue.renderSlot(_ctx.$slots, "default")
], 6);
};
}
}));
withInstall(_sfc_main$1A);
const _hoisted_1$1e = { class: "nut-grid-item__text" };
const _sfc_main$1z = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadValues({}, {
name: "NutGridItem"
}), {
__name: "grid-item.taro",
props: {
text: {}
},
emits: ["click"],
setup(__props, { emit: __emit }) {
const emit = __emit;
const { parent: parentObj, index } = useParent(GRID_KEY);
const parent = (parentObj == null ? void 0 : parentObj.props) || {};
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 prefixCls2 = `nut-grid-item__content`;
return {
[`${prefixCls2}`]: true,
[`${prefixCls2}--border`]: parent.border,
[`${prefixCls2}--surround`]: parent.border && parent.gutter,
[`${prefixCls2}--center`]: parent.center,
[`${prefixCls2}--square`]: parent.square,
[`${prefixCls2}--reverse`]: parent.reverse,
[`${prefixCls2}--${parent.direction}`]: !!parent.direction,
[`${prefixCls2}--clickable`]: parent.clickable
};
});
const handleClick = (event) => {
emit("click", event);
};
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("view", {
class: "nut-grid-item",
style: vue.normalizeStyle(rootStyle.value),
onClick: handleClick
}, [
vue.createElementVNode("view", {
class: vue.normalizeClass(contentClass.value)
}, [
vue.renderSlot(_ctx.$slots, "default"),
_cache[0] || (_cache[0] = vue.createTextVNode()),
vue.createElementVNode("view", _hoisted_1$1e, [
_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)
], 4);
};
}
}));
withInstall(_sfc_main$1z);
const { create: create$10, componentName: componentName$7 } = createComponent("space");
const _sfc_main$1y = create$10({
props: {
align: String,
direction: {
type: String,
default: "horizontal"
},
justify: String,
wrap: Boolean,
gutter: [Number, String, Array],
fill: Boolean
},
setup(props, { slots }) {
const getMargin = (gutter) => {
if (typeof gutter === "number") {
return gutter + "px";
}
return gutter;
};
const getMarginStyle = (isLast) => {
const style = {};
if (!props.gutter)
return style;
const marginRight = `${getMargin(Array.isArray(props.gutter) ? props.gutter[0] : props.gutter)}`;
const marginBottom = `${getMargin(Array.isArray(props.gutter) ? props.gutter[1] : props.gutter)}`;
if (isLast) {
return props.wrap ? { marginBottom } : {};
}
if (props.direction === "horizontal") {
style.marginRight = marginRight;
}
if (props.direction === "vertical" || props.wrap) {
style.marginBottom = marginBottom;
}
return style;
};
const filterEmpty = (children = []) => {
const nodes = [];
children.forEach((child) => {
if (Array.isArray(child)) {
nodes.push(...child);
} else if (child.type === vue.Fragment) {
nodes.push(...filterEmpty(child.children));
} else {
nodes.push(child);
}
});
return nodes.filter(
(c) => {
var _a;
return !(c && (c.type === vue.Comment || c.type === vue.Fragment && ((_a = c.children) == null ? void 0 : _a.lengt