UNPKG

plus-pro-components

Version:

Page level components developed based on Element Plus.

167 lines (164 loc) 6.47 kB
import { defineComponent, reactive, watchEffect, openBlock, createElementBlock, normalizeClass, createElementVNode, unref, createBlock, resolveDynamicComponent, renderSlot, mergeProps, createCommentVNode, Fragment, createTextVNode, toDisplayString, withModifiers } from 'vue'; import { ElAvatar } from 'element-plus'; import '../../utils/index.mjs'; import { isFunction, isString } from '../../utils/is.mjs'; const _hoisted_1 = { class: "plus-check-card__avatar-wrapper" }; const _hoisted_2 = { class: "plus-check-card__right-content" }; const _hoisted_3 = { key: 0, class: "plus-check-card__title" }; const _hoisted_4 = { class: "plus-check-card__title-left" }; const _hoisted_5 = { key: 1, class: "plus-check-card__description" }; var _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "PlusCheckCard" }, __name: "index", props: { modelValue: { type: Boolean, default: false }, size: { default: "default" }, avatar: { type: [String, Function], default: void 0 }, avatarProps: { default: () => ({}) }, title: { type: [String, Function], default: void 0 }, description: { type: [String, Function], default: void 0 }, disabled: { type: Boolean, default: false }, extra: { type: Function, default: void 0 } }, emits: ["update:modelValue", "change", "extra"], setup(__props, { emit: __emit }) { const classDataEnum = { large: "plus-check-card--large", default: "plus-check-card--default", small: "plus-check-card--small" }; const props = __props; const emit = __emit; const state = reactive({ checked: false }); watchEffect(() => { state.checked = props.modelValue; }); const getClass = () => { return props.size ? classDataEnum[props.size] : "plus-check-card--default"; }; const handleClick = () => { if (props.disabled) return; state.checked = !state.checked; emit("update:modelValue", state.checked); emit("change", state.checked); }; const handelExtra = () => { if (props.disabled) return; emit("extra"); }; return (_ctx, _cache) => { return openBlock(), createElementBlock( "div", { class: normalizeClass(["plus-check-card", [ getClass(), state.checked ? "plus-check-card--checked" : "", _ctx.disabled ? "plus-check-card--disabled" : "" ]]), onClick: handleClick }, [ createElementVNode("div", _hoisted_1, [ unref(isFunction)(_ctx.avatar) ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.avatar), { key: 0, avatar: _ctx.avatar, title: _ctx.title, description: _ctx.description }, null, 8, ["avatar", "title", "description"])) : _ctx.$slots.avatar ? renderSlot(_ctx.$slots, "avatar", { key: 1, avatar: _ctx.avatar, title: _ctx.title, description: _ctx.description }) : unref(isString)(_ctx.avatar) ? (openBlock(), createBlock(unref(ElAvatar), mergeProps({ key: 2, src: _ctx.avatar }, _ctx.avatarProps), null, 16, ["src"])) : createCommentVNode("v-if", true) ]), createElementVNode("div", _hoisted_2, [ _ctx.title || _ctx.$slots.title ? (openBlock(), createElementBlock("div", _hoisted_3, [ createElementVNode("div", _hoisted_4, [ unref(isFunction)(_ctx.title) ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.title), { key: 0, avatar: _ctx.avatar, title: _ctx.title, description: _ctx.description }, null, 8, ["avatar", "title", "description"])) : _ctx.$slots.title ? renderSlot(_ctx.$slots, "title", { key: 1, title: _ctx.title, avatar: _ctx.avatar, description: _ctx.description }) : (openBlock(), createElementBlock( Fragment, { key: 2 }, [ createTextVNode( toDisplayString(_ctx.title), 1 /* TEXT */ ) ], 64 /* STABLE_FRAGMENT */ )) ]), createElementVNode("div", { class: "plus-check-card__title-right", onClick: withModifiers(handelExtra, ["stop"]) }, [ unref(isFunction)(_ctx.extra) ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.extra), { key: 0, avatar: _ctx.avatar, title: _ctx.title, description: _ctx.description }, null, 8, ["avatar", "title", "description"])) : _ctx.$slots.extra ? renderSlot(_ctx.$slots, "extra", { key: 1, title: _ctx.title, avatar: _ctx.avatar, description: _ctx.description }) : createCommentVNode("v-if", true) ]) ])) : createCommentVNode("v-if", true), _ctx.description || _ctx.$slots.description ? (openBlock(), createElementBlock("div", _hoisted_5, [ unref(isFunction)(_ctx.description) ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.description), { key: 0, title: _ctx.title, avatar: _ctx.avatar, description: _ctx.description }, null, 8, ["title", "avatar", "description"])) : _ctx.$slots.description ? renderSlot(_ctx.$slots, "description", { key: 1, title: _ctx.title, description: _ctx.description, avatar: _ctx.avatar }) : (openBlock(), createElementBlock( Fragment, { key: 2 }, [ createTextVNode( toDisplayString(_ctx.description), 1 /* TEXT */ ) ], 64 /* STABLE_FRAGMENT */ )) ])) : createCommentVNode("v-if", true) ]) ], 2 /* CLASS */ ); }; } }); export { _sfc_main as default };