UNPKG

holakit

Version:

Yet another design-driven UI component set.

69 lines (68 loc) 2.19 kB
/*! Built with http://stenciljs.com */ import { h } from '../holakitcore.core.js'; var HolaButton = /** @class */ (function () { function HolaButton() { this.href = '#'; this.type = 'button'; this.submit = false; } HolaButton.prototype.onClick = function (event) { var form = this.el.closest('form'); if (form) { event.preventDefault(); if (this.submit) return form.submit(); var fakeButton = document.createElement('button'); fakeButton.type = this.type; fakeButton.style.display = 'none'; form.appendChild(fakeButton); fakeButton.click(); fakeButton.remove(); } }; HolaButton.prototype.render = function () { if (this.href) h("a", { href: this.href, class: "button" }, h("slot", null)); return h("button", { onClick: this.onClick, type: this.type, class: "button" }, h("slot", null)); }; Object.defineProperty(HolaButton, "is", { get: function () { return "hola-button"; }, enumerable: true, configurable: true }); Object.defineProperty(HolaButton, "encapsulation", { get: function () { return "shadow"; }, enumerable: true, configurable: true }); Object.defineProperty(HolaButton, "properties", { get: function () { return { "el": { "elementRef": true }, "href": { "type": String, "attr": "href" }, "submit": { "type": Boolean, "attr": "submit" }, "type": { "type": String, "attr": "type" } }; }, enumerable: true, configurable: true }); Object.defineProperty(HolaButton, "style", { get: function () { return "/**style-placeholder:hola-button:**/"; }, enumerable: true, configurable: true }); return HolaButton; }()); export { HolaButton };