UNPKG

@larva.io/webcomponents

Version:

Fentrica SmartUnits WebComponents package

94 lines (89 loc) 3.43 kB
/*! * (C) Fentrica http://fentrica.com - Seee LICENSE.md */ 'use strict'; var index = require('./index-B0SElCD3.js'); const onoffCss = "slot-fb[hidden],slot[hidden]{display:initial !important}"; const LarvaOnOffNode = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.output = index.createEvent(this, "output"); this.request = index.createEvent(this, "request"); /////// LarvaNode base properties /** * Component main icon */ this.icon = 'security'; /** * The color to use from your application's color palette. * Detrouble options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. */ this.color = 'primary'; /** * Disable quck actions */ this.disableQuickActions = false; /** * Is logging for this component enabled (lar-log subcomponent loaded) */ this.log = false; /** * Node size */ this.nodeSize = 'default'; /////// LarvaNode base properties and events - end this.checked = false; this.loading = true; } componentDidLoad() { const el = this.el.shadowRoot || this.el; this.node = el.querySelector('lar-node'); this.output.emit(); } /** * Larva error input */ async error(data) { if (this.node) { this.node.error(data); } this.loading = false; // revert last switch back if error response this.checked = !this.checked; } /** * Larva input message */ async input(data) { this.loading = false; this.checked = Boolean(data); } handleChange(checked) { if (this.checked === checked) { return; } this.checked = !!checked; this.loading = true; this.output.emit(!!this.checked); } render() { let value = ' '; if (!this.loading) { value = this.checked ? 'onoff.on' : 'onoff.off'; } const componentProps = { onButtonclick: () => this.handleChange(!this.checked), value: this.checked ? 'onoff.on' : 'onoff.off', disabled: this.loading, color: this.colorInputs || this.color }; return [ index.h("lar-node", { key: '73a04c8759056dbe42661c2a637cf8f900bf5c4a', value: value, hideTitles: this.hideTitles, icon: this.icon, color: this.color, supTitle: this.supTitle, mainTitle: this.mainTitle, subTitle: this.subTitle, colorModal: this.colorModal, colorInputs: this.colorInputs, colorIconSmall: this.colorIconSmall, loading: this.loading, log: this.log, nodeSize: this.nodeSize, component: "lar-onoff-content", componentProps: componentProps }, this.disableQuickActions === false && index.h("lar-toggle", { key: '8f5f977d14fddd4d87f6321d9a3b283447ea9940', slot: "titles", onLarchange: ev => this.handleChange(ev.detail.checked), checked: this.checked, color: this.colorInputs || this.color }), index.h("slot", { key: 'b54da5ee34f71ae578f9d501cbb6b44edce4418e' })) ]; } get el() { return index.getElement(this); } }; LarvaOnOffNode.style = onoffCss; exports.lar_onoff = LarvaOnOffNode; //# sourceMappingURL=lar-onoff.entry.cjs.js.map