2021-08-10 23:02:52 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-08-27 08:13:36 +02:00
|
|
|
import {css, html, LitElement} from "@lion/core";
|
2021-08-25 23:35:06 +02:00
|
|
|
import {Et2Widget} from "../Et2Widget/Et2Widget";
|
2021-09-03 19:20:53 +02:00
|
|
|
import {et2_IDetachedDOM} from "../et2_core_interfaces";
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-09-03 19:20:53 +02:00
|
|
|
export class Et2Box extends Et2Widget(LitElement) implements et2_IDetachedDOM
|
2021-08-10 23:02:52 +02:00
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
static get styles()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
css`
|
2021-08-10 23:02:52 +02:00
|
|
|
:host {
|
2021-08-13 23:26:18 +02:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
|
|
|
:host > div {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: nowrap;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: stretch;
|
2021-09-02 17:39:17 +02:00
|
|
|
}
|
|
|
|
/* CSS for child elements */
|
2021-08-10 23:02:52 +02:00
|
|
|
::slotted(*) {
|
2021-09-02 17:39:17 +02:00
|
|
|
margin: 0px 2px;
|
|
|
|
flex: 1 0 auto;
|
|
|
|
}
|
|
|
|
::slotted([align="left"]) {
|
|
|
|
margin-right: auto;
|
|
|
|
}
|
|
|
|
::slotted([align="right"]) {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
`,
|
2021-08-13 23:26:18 +02:00
|
|
|
];
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-13 23:26:18 +02:00
|
|
|
render()
|
|
|
|
{
|
|
|
|
return html`
|
2021-09-03 22:44:52 +02:00
|
|
|
<div ${this.id ? html`id="${this.id}"` : ''}>
|
2021-09-02 17:39:17 +02:00
|
|
|
<slot></slot>
|
2021-08-10 23:02:52 +02:00
|
|
|
</div> `;
|
2021-08-13 23:26:18 +02:00
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
|
2021-08-19 01:41:23 +02:00
|
|
|
set_label(new_label)
|
|
|
|
{
|
|
|
|
// Boxes don't have labels
|
|
|
|
}
|
|
|
|
|
|
|
|
_createNamespace() : boolean
|
2021-08-13 23:26:18 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2021-09-03 19:20:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Code for implementing et2_IDetachedDOM
|
|
|
|
*
|
|
|
|
* Individual widgets are detected and handled by the grid, but the interface is needed for this to happen
|
|
|
|
*
|
|
|
|
* @param {array} _attrs array to add further attributes to
|
|
|
|
*/
|
|
|
|
getDetachedAttributes(_attrs)
|
|
|
|
{
|
|
|
|
_attrs.push('data');
|
|
|
|
}
|
|
|
|
|
|
|
|
getDetachedNodes()
|
|
|
|
{
|
|
|
|
return [this.getDOMNode()];
|
|
|
|
}
|
|
|
|
|
|
|
|
setDetachedAttributes(_nodes, _values)
|
|
|
|
{
|
|
|
|
if(_values.data)
|
|
|
|
{
|
|
|
|
var pairs = _values.data.split(/,/g);
|
|
|
|
for(var i = 0; i < pairs.length; ++i)
|
|
|
|
{
|
|
|
|
var name_value = pairs[i].split(':');
|
|
|
|
jQuery(_nodes[0]).attr('data-' + name_value[0], name_value[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define("et2-box", Et2Box);
|
|
|
|
|
|
|
|
export class Et2HBox extends Et2Box
|
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
static get styles()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
...super.styles,
|
|
|
|
css`
|
2021-08-10 23:02:52 +02:00
|
|
|
:host > div {
|
|
|
|
flex-direction: row;
|
2021-09-03 22:44:52 +02:00
|
|
|
}`
|
2021-08-13 23:26:18 +02:00
|
|
|
];
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define("et2-hbox", Et2HBox);
|
|
|
|
|
|
|
|
export class Et2VBox extends Et2Box
|
|
|
|
{
|
2021-08-13 23:26:18 +02:00
|
|
|
static get styles()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
...super.styles,
|
|
|
|
css`
|
2021-08-10 23:02:52 +02:00
|
|
|
:host > div {
|
|
|
|
flex-direction: column;
|
|
|
|
}`
|
2021-08-13 23:26:18 +02:00
|
|
|
];
|
|
|
|
}
|
2021-08-10 23:02:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define("et2-vbox", Et2VBox);
|