UNPKG

tass-ui

Version:

A high quality UI Toolkit built on Vue.js3+.

67 lines (66 loc) 2.54 kB
import { defineComponent, reactive, resolveComponent, openBlock, createElementBlock, createElementVNode, Fragment, renderList, createTextVNode, toDisplayString, createVNode, normalizeClass, Transition, withCtx, withDirectives, vShow } from "vue"; import "../../../theme-chalk/src/collapse.scss.mjs"; const _hoisted_1 = { class: "tas-collapse" }; const _hoisted_2 = { class: "tas-collapse-ul" }; const _hoisted_3 = ["onClick"]; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "collapse", props: { posts: null, types: { type: Boolean, default: false } }, setup(__props) { const props = __props; const arr = reactive([]); function toggle(index) { if (!arr.includes(index)) { if (props.types == true) { arr.push(index); } else { arr.length = 0; arr.push(index); } } else { arr.splice(arr.indexOf(index), 1); } } return (_ctx, _cache) => { const _component_tass_icon = resolveComponent("tass-icon"); return openBlock(), createElementBlock("div", _hoisted_1, [ createElementVNode("ul", _hoisted_2, [ createElementVNode("li", null, [ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.posts, (item) => { return openBlock(), createElementBlock("div", { key: item.id, class: "tas-collapse-panel" }, [ createElementVNode("div", { class: "tas-collapse-title", onClick: ($event) => toggle(item.id) }, [ createTextVNode(toDisplayString(item.title) + " ", 1), createVNode(_component_tass_icon, { name: "chevronright", class: normalizeClass([arr.includes(item.id) === true ? "icon-select" : "icon-unselect"]), style: { "float": "right" } }, null, 8, ["class"]) ], 8, _hoisted_3), createVNode(Transition, { name: "tas-collapse" }, { default: withCtx(() => [ withDirectives(createElementVNode("div", { class: "tas-collapse-content" }, toDisplayString(item.body), 513), [ [vShow, arr.includes(item.id) === true] ]) ]), _: 2 }, 1024) ]); }), 128)) ]) ]) ]); }; } }); export { _sfc_main as default };