@larva.io/webcomponents
Version:
Fentrica SmartUnits WebComponents package
106 lines (101 loc) • 4.15 kB
JavaScript
/*!
* (C) Fentrica http://fentrica.com - Seee LICENSE.md
*/
'use strict';
var index = require('./index-B0SElCD3.js');
const doorCss = "slot-fb[hidden],slot[hidden]{display:initial !important}";
const Door = 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 = 'door';
/**
* 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;
/**
* Allow node indication color automatic change based on feedback/node value. Defaults to false
*/
this.allowIndicationAutoColoring = 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.doorType = 'buzz';
this.loading = true;
// state for indicating buzzer door open state
this.buzzingState = false;
}
/**
* Larva input message
*/
async input(data) {
this.isOpen = data.state || false;
if (this.buzzingState && !this.isOpen) {
this.buzzingState = false;
}
if (data.doorType) {
this.doorType = data.doorType;
}
this.loading = false;
}
/**
* Larva error input
*/
async error(data) {
if (this.node) {
this.node.error(data);
}
this.loading = false;
}
componentDidLoad() {
const el = this.el.shadowRoot || this.el;
this.node = el.querySelector('lar-node');
this.loading = true;
this.output.emit({ command: 'fullstate' });
}
handleChange() {
if (this.loading || this.buzzingState) {
return this.node.error('invalid door state');
}
this.loading = true;
const cmd = {
command: this.doorType === 'buzz' ? 'buzz' : this.isOpen ? 'lock' : 'unlock'
};
if (this.doorType === 'buzz') {
this.buzzingState = true;
}
return this.output.emit(cmd);
}
render() {
const componentProps = {
onClick: () => this.handleChange(),
value: this.doorType === 'buzz' ? 'door.buzzOpen' : this.isOpen ? 'door.lock' : 'door.unlock',
disabled: this.loading || this.buzzingState === true,
color: this.colorInputs || this.color
};
return [
index.h("lar-node", { key: 'a907470c8d97f1493f682d8f0a96ae2b4a598526', value: this.isOpen ? 'door.unlocked' : 'door.locked', colorIconSmall: this.allowIndicationAutoColoring && !this.loading ? (this.isOpen ? 'danger' : 'success') : this.colorIconSmall, hideTitles: this.hideTitles, iconSmall: this.isOpen ? 'unlock' : 'lock', icon: this.icon, color: this.color, supTitle: this.supTitle, mainTitle: this.mainTitle, subTitle: this.subTitle, colorModal: this.colorModal, colorInputs: this.colorInputs, nodeSize: this.nodeSize, log: this.log, loading: this.loading, component: "lar-door-content", componentProps: componentProps }, this.disableQuickActions === false &&
index.h("lar-button-push", { key: '25441a3caad4de63b15922b2ac169a72ccba6828', size: "small", slot: "titles", color: this.colorInputs || this.color, disabled: this.loading || this.buzzingState === true, onClick: () => this.handleChange() }), index.h("slot", { key: 'aba75ec2e0b898ca72f0870e0614e80f7c72fad3' }))
];
}
get el() { return index.getElement(this); }
};
Door.style = doorCss;
exports.lar_door = Door;
//# sourceMappingURL=lar-door.entry.cjs.js.map