UNPKG

@ntohq/buefy-next

Version:

Lightweight UI components for Vue.js (v3) based on Bulma

122 lines (113 loc) 3.41 kB
/*! Buefy v0.2.0 | MIT License | github.com/buefy/buefy */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) : typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Collapse = {}, global.Vue)); })(this, (function (exports, vue) { 'use strict'; const COLLAPSE_POSITIONS = ["is-top", "is-bottom"]; var _sfc_main = vue.defineComponent({ name: "BCollapse", props: { modelValue: { type: Boolean, default: true }, animation: { type: String, default: "fade" }, ariaId: { type: String, default: "" }, position: { type: String, default: "is-top", validator(value) { return COLLAPSE_POSITIONS.indexOf(value) > -1; } } }, emits: { close: () => true, open: () => true, // eslint-disable-next-line @typescript-eslint/no-unused-vars "update:modelValue": (_value) => true }, data() { return { isOpen: this.modelValue }; }, watch: { modelValue(value) { this.isOpen = value; } }, methods: { /* * Toggle and emit events */ toggle() { this.isOpen = !this.isOpen; this.$emit("update:modelValue", this.isOpen); this.isOpen ? this.$emit("open") : this.$emit("close"); } }, render() { const trigger = vue.h( "div", { class: "collapse-trigger", onClick: this.toggle }, this.$slots.trigger ? this.$slots.trigger({ open: this.isOpen }) : void 0 ); const content = vue.withDirectives( vue.h( vue.Transition, { name: this.animation }, () => [ vue.h( "div", { class: "collapse-content", id: this.ariaId }, this.$slots ) ] ), [[vue.vShow, this.isOpen]] ); return vue.h( "div", { class: "collapse" }, this.position === "is-top" ? [trigger, content] : [content, trigger] ); } }); var _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; var Collapse = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/collapse/Collapse.vue"]]); const registerComponent = (Vue, component, name) => { const componentName = name || component.name; if (componentName == null) { throw new Error("Buefy.registerComponent: missing component name"); } Vue.component(componentName, component); }; const Plugin = { install(Vue) { registerComponent(Vue, Collapse); } }; exports.BCollapse = Collapse; exports.default = Plugin; Object.defineProperty(exports, '__esModule', { value: true }); }));