@gyenno/nutui-taro
Version:
京东风格的轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)
214 lines (213 loc) • 7.29 kB
JavaScript
import { toRefs, computed, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, createBlock, createCommentVNode, createTextVNode, renderSlot, inject, reactive, ref, useSlots, withCtx, toDisplayString } from "vue";
import { c as createComponent } from "./component-25dcca32.js";
import "./style_icon-468bee1d.js";
import { C } from "./Loading-e3a231de.js";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
import "../locale/lang";
const { componentName: componentName$1, create: create$1 } = createComponent("button");
const _sfc_main$1 = create$1({
components: { Loading: C },
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"
},
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 } = toRefs(props);
const handleClick = (event) => {
if (!loading.value && !disabled.value) {
emit("click", event);
}
};
const classes = computed(() => {
const prefixCls = componentName$1;
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 = 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
};
}
});
const _hoisted_1$1 = { class: "nut-button__wrap" };
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_Loading = resolveComponent("Loading");
return openBlock(), createElementBlock("view", {
class: normalizeClass(_ctx.classes),
style: normalizeStyle(_ctx.getStyle),
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
}, [
createElementVNode("view", _hoisted_1$1, [
_ctx.loading ? (openBlock(), createBlock(_component_Loading, {
key: 0,
class: "nut-icon-loading"
})) : createCommentVNode("", true),
createTextVNode(),
_ctx.$slots.icon && !_ctx.loading ? renderSlot(_ctx.$slots, "icon", { key: 1 }) : createCommentVNode("", true),
createTextVNode(),
_ctx.$slots.default ? (openBlock(), createElementBlock("view", {
key: 2,
class: normalizeClass({ "nut-button__text": _ctx.$slots.icon || _ctx.loading })
}, [
renderSlot(_ctx.$slots, "default")
], 2)) : createCommentVNode("", true)
])
], 6);
}
const Button = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
const { componentName, create, translate } = createComponent("audio-operate");
const _sfc_main = create({
props: {
// 展示的形式 back 倒退 play 开始 or 暂停 forward 快进 mute 静音
type: {
type: String,
default: () => "play"
}
},
components: {
[Button.name]: Button
},
emits: ["click"],
setup(props, { emit }) {
const audio = inject("audioParent");
const parent = reactive(audio);
const customSlot = ref(useSlots().default);
return { ...toRefs(props), ...toRefs(parent), customSlot, translate };
}
});
const _hoisted_1 = { class: "nut-audio-operate" };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_nut_button = resolveComponent("nut-button");
return openBlock(), createElementBlock("div", _hoisted_1, [
_ctx.type == "back" ? (openBlock(), createElementBlock("div", {
key: 0,
class: "nut-audio-operate-item",
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.fastBack && _ctx.fastBack(...args))
}, [
!_ctx.customSlot ? (openBlock(), createBlock(_component_nut_button, {
key: 0,
type: "primary",
size: "small"
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(_ctx.translate("back")), 1)
]),
_: 1
})) : createCommentVNode("", true),
renderSlot(_ctx.$slots, "default")
])) : createCommentVNode("", true),
createTextVNode(),
_ctx.type == "play" ? (openBlock(), createElementBlock("div", {
key: 1,
class: "nut-audio-operate-item",
onClick: _cache[1] || (_cache[1] = (...args) => _ctx.changeStatus && _ctx.changeStatus(...args))
}, [
!_ctx.customSlot ? (openBlock(), createBlock(_component_nut_button, {
key: 0,
type: "primary",
size: "small"
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(!_ctx.audioData.playing ? `${_ctx.translate("start")}` : `${_ctx.translate("pause")}`), 1)
]),
_: 1
})) : createCommentVNode("", true),
createTextVNode(),
renderSlot(_ctx.$slots, "default")
])) : createCommentVNode("", true),
createTextVNode(),
_ctx.type == "forward" ? (openBlock(), createElementBlock("div", {
key: 2,
class: "nut-audio-operate-item",
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.forward && _ctx.forward(...args))
}, [
!_ctx.customSlot ? (openBlock(), createBlock(_component_nut_button, {
key: 0,
type: "primary",
size: "small"
}, {
default: withCtx(() => [
createTextVNode("快进")
]),
_: 1
})) : createCommentVNode("", true),
renderSlot(_ctx.$slots, "default")
])) : createCommentVNode("", true),
createTextVNode(),
_ctx.type == "mute" ? (openBlock(), createElementBlock("div", {
key: 3,
class: "nut-audio-operate-item",
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.handleMute && _ctx.handleMute(...args))
}, [
!_ctx.customSlot ? (openBlock(), createBlock(_component_nut_button, {
key: 0,
type: !_ctx.audioData.hanMuted ? "primary" : "default",
size: "small"
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(_ctx.translate("mute")), 1)
]),
_: 1
}, 8, ["type"])) : createCommentVNode("", true),
renderSlot(_ctx.$slots, "default")
])) : createCommentVNode("", true)
]);
}
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
index as default
};