UNPKG

@codeperate/cdp-ui-library

Version:

Codeperate UI Library

37 lines (32 loc) 1.34 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-189a024f.js'); const deepAssign = require('./deep-assign-b6a043d3.js'); const CdpAccordion = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.props = { display: false }; this.defaultConfig = { classList: { content: 'transition-all duration-500 overflow-hidden', expanded: 'expanded', }, maxHeight: '100vh', toggle: true, }; } toggle() { this.props = Object.assign(Object.assign({}, this.props), { display: !this.props.display }); } componentWillLoad() { this._config = deepAssign.deepAssign(this.config, this.defaultConfig); } render() { const { classList, maxHeight, toggle } = this._config; const { display } = this.props; const hostClass = display ? classList.expanded : ''; return (index.h(index.Host, { class: hostClass }, index.h("div", { onClick: () => (toggle ? this.toggle() : null) }, index.h("slot", { name: "accordion" })), index.h("div", { ref: el => (this.contentEl = el), class: classList.content, style: { maxHeight: display ? maxHeight : '0' } }, index.h("slot", null)))); } get rootEl() { return index.getElement(this); } }; exports.cdp_accordion = CdpAccordion;