UNPKG

@cqmcui/cqmcui

Version:

轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)

106 lines (105 loc) 4.14 kB
import { computed, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createCommentVNode, Fragment, createElementVNode, toDisplayString, createTextVNode, createBlock } from "vue"; import { c as createComponent } from "./component-81a4c1d0.js"; import { u as useRouter } from "./index-54d03fc1.js"; import { p as pxCheck } from "./pxCheck-c6b9f6b7.js"; import { Right } from "@cqmcui/icons-vue"; import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js"; import "../locale/lang"; const { componentName, create } = createComponent("cell"); const _sfc_main = create({ components: { 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: [String, Object], 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 = computed(() => { const prefixCls = componentName; return { [prefixCls]: true, [`${prefixCls}--clickable`]: props.isLink || props.to, [`${prefixCls}--center`]: props.center, [`${prefixCls}--large`]: props.size == "large" }; }); const router = useRouter(); const baseStyle = computed(() => { return { borderRadius: pxCheck(props.roundRadius) }; }); const handleClick = (event) => { emit("click", event); if (props.to && router) { router[props.replace ? "replace" : "push"](props.to); } else if (props.url) { props.replace ? location.replace(props.url) : location.href = props.url; } }; return { handleClick, classes, baseStyle }; } }); const _hoisted_1 = { key: 0, class: "cqmc-cell__icon" }; const _hoisted_2 = { key: 1, class: "cqmc-cell__title" }; const _hoisted_3 = { class: "title" }; const _hoisted_4 = { class: "cqmc-cell__title-desc" }; function render(_ctx, _cache, $props, $setup, $data, $options) { const _component_Right = resolveComponent("Right"); return openBlock(), createElementBlock("view", { class: normalizeClass(_ctx.classes), style: normalizeStyle(_ctx.baseStyle), onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)) }, [ renderSlot(_ctx.$slots, "default", {}, () => [ _ctx.$slots.icon ? (openBlock(), createElementBlock("view", _hoisted_1, [ renderSlot(_ctx.$slots, "icon") ])) : createCommentVNode("", true), _ctx.title || _ctx.subTitle || _ctx.$slots.title ? (openBlock(), createElementBlock("view", _hoisted_2, [ _ctx.subTitle ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [ renderSlot(_ctx.$slots, "title", {}, () => [ createElementVNode("view", _hoisted_3, toDisplayString(_ctx.title), 1) ]), createElementVNode("view", _hoisted_4, toDisplayString(_ctx.subTitle), 1) ], 64)) : renderSlot(_ctx.$slots, "title", { key: 1 }, () => [ createTextVNode(toDisplayString(_ctx.title), 1) ]) ])) : createCommentVNode("", true), _ctx.desc ? (openBlock(), createElementBlock("view", { key: 2, class: normalizeClass(["cqmc-cell__value", { "cqmc-cell__value--alone": !_ctx.title && !_ctx.subTitle && !_ctx.$slots.title }]), style: normalizeStyle({ "text-align": _ctx.descTextAlign }) }, toDisplayString(_ctx.desc), 7)) : createCommentVNode("", true), renderSlot(_ctx.$slots, "link", {}, () => [ _ctx.isLink || _ctx.to ? (openBlock(), createBlock(_component_Right, { key: 0, class: "cqmc-cell__link" })) : createCommentVNode("", true) ]) ]) ], 6); } const Cell = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", render]]); export { Cell as default };