UNPKG

@ctsy/layui-vue

Version:

a component library for Vue 3 base on layui-vue

89 lines (88 loc) 3.55 kB
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 __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)); import { defineComponent, inject, computed, openBlock, createElementBlock, createElementVNode, normalizeClass, renderSlot, createTextVNode, toDisplayString, unref, createVNode, withCtx, createCommentVNode } from "vue"; import { _ as _sfc_main$1 } from "../index2.js"; import "../plugin-vue_export-helper.js"; var index = ""; const _hoisted_1 = { class: "layui-colla-item" }; const _hoisted_2 = { class: "layui-icon layui-colla-icon" }; const _hoisted_3 = { key: 0 }; const _hoisted_4 = { class: "layui-colla-content" }; const __default__ = { name: "LayCollapseItem" }; const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, __default__), { props: { id: null, title: null, disabled: { type: Boolean, default: false } }, setup(__props) { const props = __props; const { accordion, activeValues, emit, collapseTransition } = inject("layCollapse"); let isShow = computed(() => { return activeValues.value.includes(props.id); }); const showHandle = function() { if (props.disabled) { return; } const _isShow = isShow.value; if (accordion) { activeValues.value = !_isShow ? [props.id] : []; } else if (_isShow) { activeValues.value.splice(activeValues.value.indexOf(props.id), 1); } else { activeValues.value.push(props.id); } emit("update:modelValue", accordion ? activeValues.value[0] || null : activeValues.value); emit("change", props.id, !_isShow, activeValues.value); }; return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("h2", { class: normalizeClass(["layui-colla-title", { "layui-disabled": __props.disabled }]), onClick: showHandle }, [ renderSlot(_ctx.$slots, "title", { props }, () => [ createTextVNode(toDisplayString(__props.title), 1) ]), createElementVNode("i", _hoisted_2, toDisplayString(unref(isShow) ? "\uE61A" : "\uE602"), 1) ], 2), createVNode(_sfc_main$1, { enable: unref(collapseTransition) }, { default: withCtx(() => [ unref(isShow) ? (openBlock(), createElementBlock("div", _hoisted_3, [ createElementVNode("div", _hoisted_4, [ createElementVNode("p", null, [ renderSlot(_ctx.$slots, "default", { props }) ]) ]) ])) : createCommentVNode("", true) ]), _: 3 }, 8, ["enable"]) ]); }; } })); _sfc_main.install = (app) => { app.component(_sfc_main.name, _sfc_main); }; export { _sfc_main as default };