/** * EGroupware eTemplate2 - Box 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 {classMap, css, html, LitElement} from "@lion/core"; import {Et2Widget} from "../../Et2Widget/Et2Widget"; import {et2_IDetachedDOM} from "../../et2_core_interfaces"; export class Et2Box extends Et2Widget(LitElement) implements et2_IDetachedDOM { static get styles() { return [ ...super.styles, css` :host { display: block; } :host > div { display: flex; flex-wrap: nowrap; justify-content: flex-start; align-items: stretch; gap: 5px; height: 100%; } :host([align="right"]) > div { justify-content: flex-end; } :host([align="left"]) > div { justify-content: flex-start; } :host([align="center"]) > div { justify-content: center; } /* CSS for child elements */ ::slotted(*) { flex: 1 1 auto; } ::slotted(img),::slotted(et2-image) { /* Stop images from growing. In general we want them to stay */ flex-grow: 0; } ::slotted([align="left"]) { margin-right: auto; order: -1; } ::slotted([align="right"]) { margin-left: auto; order: 1; } /* work around for chromium print bug, see render() */ :host > .no-print-gap { gap: 0px; } `, ]; } render() { /** * Work around Chromium bug * https://bugs.chromium.org/p/chromium/issues/detail?id=1161709 * * Printing with gap on empty element gives huge print output */ let noGap = false; if(this.querySelectorAll(":scope > :not([disabled])").length == 0) { noGap = true; } return html`