mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-15 12:34:57 +01:00
40278c8827
Made a lot of "failed to construct htmlelement" errors go away, avoid a bunch of egwIsMobile is undefined errors
67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
/**
|
|
* EGroupware eTemplate2 - Button widget
|
|
*
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
* @package etemplate
|
|
* @subpackage api
|
|
* @link https://www.egroupware.org
|
|
* @author Nathan Gray
|
|
*/
|
|
|
|
|
|
import {Et2InputWidget} from "../Et2InputWidget/Et2InputWidget";
|
|
import '../Et2Image/Et2Image';
|
|
import {SlButton} from "@shoelace-style/shoelace";
|
|
|
|
|
|
export class Et2Button extends ButtonMixin(Et2InputWidget(SlButton))
|
|
{
|
|
static get properties()
|
|
{
|
|
return {
|
|
...super.properties,
|
|
label: {type: String}
|
|
}
|
|
}
|
|
|
|
protected firstUpdated(_changedProperties : PropertyValues)
|
|
{
|
|
super.firstUpdated(_changedProperties);
|
|
|
|
if(!this.label && this.__image)
|
|
{
|
|
/*
|
|
Label / no label should get special classes set, but they're missing without this extra requestUpdate()
|
|
This is a work-around for button--has-prefix & button--has-label not being set, something to do
|
|
with how we're setting them.
|
|
*/
|
|
this.updateComplete.then(() =>
|
|
{
|
|
this.requestUpdate();
|
|
});
|
|
}
|
|
}
|
|
|
|
set label(new_label : string)
|
|
{
|
|
this.updateComplete.then(() =>
|
|
{
|
|
if(!this._labelNode)
|
|
{
|
|
const textNode = document.createTextNode(new_label);
|
|
this.appendChild(textNode);
|
|
}
|
|
else
|
|
{
|
|
this._labelNode.textContent = new_label;
|
|
}
|
|
});
|
|
}
|
|
|
|
get label()
|
|
{
|
|
return this._labelNode?.textContent?.trim();
|
|
}
|
|
}
|
|
|
|
customElements.define("et2-button", Et2Button); |