@openremote/or-tree-menu 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/umd/index.bundle.js +732 -0
- package/dist/umd/index.bundle.js.LICENSE.txt +136 -0
- package/dist/umd/index.js +732 -0
- package/dist/umd/index.js.LICENSE.txt +136 -0
- package/dist/umd/index.orbundle.js +790 -0
- package/dist/umd/index.orbundle.js.LICENSE.txt +166 -0
- package/lib/index.d.ts +215 -0
- package/lib/index.js +103 -0
- package/lib/index.js.map +1 -0
- package/lib/model.d.ts +58 -0
- package/lib/model.js +1 -0
- package/lib/model.js.map +1 -0
- package/lib/or-tree-group.d.ts +66 -0
- package/lib/or-tree-group.js +49 -0
- package/lib/or-tree-group.js.map +1 -0
- package/lib/or-tree-node.d.ts +27 -0
- package/lib/or-tree-node.js +43 -0
- package/lib/or-tree-node.js.map +1 -0
- package/lib/util.d.ts +10 -0
- package/lib/util.js +1 -0
- package/lib/util.js.map +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from "lit";
|
|
2
|
+
import { OrTreeNode } from "./or-tree-node";
|
|
3
|
+
/**
|
|
4
|
+
* @slot - Default slot for child nodes within the group
|
|
5
|
+
* @slot parent - Slot for inserting a parent node
|
|
6
|
+
* @csspart chevron - The chevron icon element for expanding/collapsing the group.
|
|
7
|
+
*/
|
|
8
|
+
export declare class OrTreeGroup extends LitElement {
|
|
9
|
+
/**
|
|
10
|
+
* Determines the visibility of child nodes.
|
|
11
|
+
* Setting this to `false` hides them, and acts as a 'collapsed' state.
|
|
12
|
+
*/
|
|
13
|
+
expanded: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Only allows child nodes to be selected, making the expander (parent node) readonly.
|
|
16
|
+
* If this is set to false, only the chevron icon can be used to collapse/expand the list.
|
|
17
|
+
*/
|
|
18
|
+
readonly leaf = false;
|
|
19
|
+
/**
|
|
20
|
+
* Makes the group readonly
|
|
21
|
+
*/
|
|
22
|
+
readonly readonly = false;
|
|
23
|
+
protected _childNodes?: Array<HTMLLIElement>;
|
|
24
|
+
protected _parentNodes?: Array<OrTreeNode>;
|
|
25
|
+
/** A click event listener on the component, used for selecting, expanding, and collapsing the group */
|
|
26
|
+
protected _slotClickListener: (e: MouseEvent) => void | null;
|
|
27
|
+
/** A click event listener on the chevron, used for expanding/collapsing the group */
|
|
28
|
+
protected _chevronClickListener: (e: MouseEvent) => void;
|
|
29
|
+
static get styles(): import("lit").CSSResult[];
|
|
30
|
+
/** Selects the group (parent) node. */
|
|
31
|
+
select(): void;
|
|
32
|
+
/** Selects the group node itself, and all children nodes within that group. */
|
|
33
|
+
selectAll(): void;
|
|
34
|
+
/** Deselects the group (parent) node. */
|
|
35
|
+
deselect(): void;
|
|
36
|
+
/** Deselects the group node itself, and all children nodes within that group. */
|
|
37
|
+
deselectAll(): void;
|
|
38
|
+
/** Returns the group (parent) node ({@link OrTreeNode}) using a query selector. */
|
|
39
|
+
getGroupNode(): OrTreeNode | undefined;
|
|
40
|
+
/** Returns a list of all children nodes ({@link OrTreeNode}) within the group, using a query selector. */
|
|
41
|
+
getChildNodes(): OrTreeNode[];
|
|
42
|
+
firstUpdated(changedProps: PropertyValues): void;
|
|
43
|
+
disconnectedCallback(): void;
|
|
44
|
+
render(): TemplateResult;
|
|
45
|
+
/**
|
|
46
|
+
* Returns an HTML template that represents the icon for this group.
|
|
47
|
+
* @param expanded State of the group
|
|
48
|
+
*/
|
|
49
|
+
protected _getIconTemplate(expanded?: boolean): TemplateResult;
|
|
50
|
+
/**
|
|
51
|
+
* Function that expands/collapses the group, changing the visibility of the child nodes.
|
|
52
|
+
*/
|
|
53
|
+
protected _onExpandToggle(_ev: MouseEvent): void;
|
|
54
|
+
/**
|
|
55
|
+
* Event listener for 'slotchange' of the default slot.
|
|
56
|
+
* Normally triggers when <or-tree-node> elements are added or removed.
|
|
57
|
+
*/
|
|
58
|
+
protected _onSlotChange(_ev: Event): void;
|
|
59
|
+
/**
|
|
60
|
+
* Function that applies CSS to TreeNode based on the group indentation.
|
|
61
|
+
* It loops through all parent elements, and detects the amount of or-tree-group elements it is in.
|
|
62
|
+
* The more nested in the tree, the more left handed padding is applied.
|
|
63
|
+
* @param children Node elements to apply padding to.
|
|
64
|
+
*/
|
|
65
|
+
protected _applyIndentToChildren(children?: OrTreeNode[]): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,r){var n,s=arguments.length,l=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,o,r);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(l=(s<3?n(l):s>3?n(t,o,l):n(t,o))||l);return s>3&&l&&Object.defineProperty(t,o,l),l};import{css,html,LitElement}from"lit";import{customElement,property,queryAssignedElements}from"lit/decorators.js";import{when}from"lit/directives/when.js";const getStyles=()=>css`
|
|
2
|
+
* {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host {
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
ol {
|
|
11
|
+
list-style: none;
|
|
12
|
+
padding: 0;
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
::slotted(*[slot="parent"]) {
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#chevron {
|
|
21
|
+
position: absolute;
|
|
22
|
+
height: 44px;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
aspect-ratio: 1/1.25;
|
|
26
|
+
padding-left: 4px;
|
|
27
|
+
font-size: 18px;
|
|
28
|
+
color: #cccccc;
|
|
29
|
+
z-index: 10;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#chevron:hover {
|
|
33
|
+
color: unset;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host(:not([readonly])) > #chevron {
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
}
|
|
39
|
+
`;let OrTreeGroup=class extends LitElement{constructor(){super(...arguments),this.expanded=!1,this.leaf=!1,this.readonly=!1,this._slotClickListener=e=>this.leaf?this._onExpandToggle(e):null,this._chevronClickListener=e=>this._onExpandToggle(e)}static get styles(){return[getStyles()]}select(){const e=this.getGroupNode();!this.leaf&&e&&(e.selected=!0)}selectAll(){this.select(),this.getChildNodes().forEach((e=>e.selected=!0))}deselect(){const e=this.getGroupNode();e&&(e.selected=!1)}deselectAll(){this.deselect(),this.getChildNodes().forEach((e=>e.selected=!1))}getGroupNode(){var e;return null===(e=this._parentNodes)||void 0===e?void 0:e[0]}getChildNodes(){return Array.from(this._childNodes||[]).map((e=>e.querySelector("or-tree-node"))).filter((e=>null!=e))}firstUpdated(e){var t;return null===(t=this._parentNodes)||void 0===t||t.forEach((e=>{e.addEventListener("click",this._slotClickListener)})),super.firstUpdated(e)}disconnectedCallback(){var e;null===(e=this._parentNodes)||void 0===e||e.forEach((e=>{e.removeEventListener("click",this._slotClickListener)})),super.disconnectedCallback()}render(){return html`
|
|
40
|
+
${when(!this.readonly,(()=>this._getIconTemplate(this.expanded)))}
|
|
41
|
+
<slot name="parent"></slot>
|
|
42
|
+
<ol ?hidden=${!this.expanded}>
|
|
43
|
+
<slot @slotchange=${this._onSlotChange}></slot>
|
|
44
|
+
</ol>
|
|
45
|
+
`}_getIconTemplate(e=!1){return html`
|
|
46
|
+
<or-icon id="chevron" part="chevron" icon="${e?"chevron-down":"chevron-right"}"
|
|
47
|
+
@click="${this._chevronClickListener}"
|
|
48
|
+
></or-icon>
|
|
49
|
+
`}_onExpandToggle(e){this.expanded=!this.expanded}_onSlotChange(e){this._applyIndentToChildren()}_applyIndentToChildren(e=this.getChildNodes()){e.forEach((e=>{let t=(e=>{let t=0;for(;e;)"or-tree-group"===e.tagName.toLowerCase()&&t++,e=e.parentElement;return t})(e);"parent"===e.slot&&t--,e.style.setProperty("--or-tree-node-indent",24+12*t+"px")}))}};__decorate([property({type:Boolean,reflect:!0})],OrTreeGroup.prototype,"expanded",void 0),__decorate([property({type:Boolean})],OrTreeGroup.prototype,"leaf",void 0),__decorate([property({type:Boolean})],OrTreeGroup.prototype,"readonly",void 0),__decorate([queryAssignedElements({slot:void 0})],OrTreeGroup.prototype,"_childNodes",void 0),__decorate([queryAssignedElements({slot:"parent"})],OrTreeGroup.prototype,"_parentNodes",void 0),OrTreeGroup=__decorate([customElement("or-tree-group")],OrTreeGroup);export{OrTreeGroup};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"or-tree-group.js","sourceRoot":"","sources":["../src/or-tree-group.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAiC,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAS,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAG9C,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsC1B,CAAC;AAEF;;;;GAIG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAEH;;;WAGG;QAEI,aAAQ,GAAG,KAAK,CAAC;QAExB;;;WAGG;QAEa,SAAI,GAAG,KAAK,CAAC;QAE7B;;WAEG;QAEa,aAAQ,GAAG,KAAK,CAAC;QAQjC,uGAAuG;QAC7F,uBAAkB,GAAG,CAAC,CAAa,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAA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ClB,WAAW,CA2JvB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* @slot prefix - Appends elements to the left hand side of the node, commonly used for icons.
|
|
4
|
+
* @slot - Default slot for the main content, commonly used for text.
|
|
5
|
+
* @slot suffix - Appends elements to the right hand side of the node.
|
|
6
|
+
*
|
|
7
|
+
* @cssprop --or-tree-node-height - Controls the height of the node
|
|
8
|
+
* @cssprop --or-tree-node-indent - Controls the left padding of the node
|
|
9
|
+
*
|
|
10
|
+
* @cssprop --or-tree-node-background - Sets the default background
|
|
11
|
+
* @cssprop --or-tree-node-background--hovered - Sets the background while hovering
|
|
12
|
+
* @cssprop --or-tree-node-background--selected - Sets the background when selected
|
|
13
|
+
*
|
|
14
|
+
* @cssprop --or-tree-node-color--selected - Sets the primary color of the node when selected
|
|
15
|
+
*/
|
|
16
|
+
export declare class OrTreeNode extends LitElement {
|
|
17
|
+
/**
|
|
18
|
+
* HTML attribute that only applies CSS, showing this node cannot be interacted with.
|
|
19
|
+
*/
|
|
20
|
+
readonly: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* HTML attribute that only applies CSS, marking the node as 'selected'.
|
|
23
|
+
*/
|
|
24
|
+
selected: boolean;
|
|
25
|
+
static get styles(): import("lit").CSSResult[];
|
|
26
|
+
protected render(): TemplateResult;
|
|
27
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,r,o,t){var n,d=arguments.length,l=d<3?r:null===t?t=Object.getOwnPropertyDescriptor(r,o):t;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,r,o,t);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(l=(d<3?n(l):d>3?n(r,o,l):n(r,o))||l);return d>3&&l&&Object.defineProperty(r,o,l),l};import{css,html,LitElement}from"lit";import{customElement,property}from"lit/decorators.js";const styles=css`
|
|
2
|
+
* {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
}
|
|
5
|
+
:host {
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: var(--or-tree-node-height, 44px);
|
|
8
|
+
padding: 6px 12px 6px var(--or-tree-node-indent, 24px);
|
|
9
|
+
background: var(--or-tree-node-background, transparent);
|
|
10
|
+
border-left: 4px solid transparent;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: var(--or-tree-node-gap, 8px);
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
user-select: none;
|
|
16
|
+
--or-icon-width: 20px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host(:not([readonly])) {
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host([readonly]) {
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host(:not([readonly]):hover) {
|
|
28
|
+
background: var(--or-tree-node-backgrond--hovered, #f8f9fa);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([selected]) {
|
|
32
|
+
background: var(--or-tree-node-background--selected, #f1f3f5);
|
|
33
|
+
border-left: 4px solid var(--or-tree-node-color--selected, var(--or-app-color4, #4d9d2a));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
::slotted(*:not([slot])) {
|
|
37
|
+
flex: 1;
|
|
38
|
+
}
|
|
39
|
+
`;let OrTreeNode=class extends LitElement{constructor(){super(...arguments),this.readonly=!1,this.selected=!1}static get styles(){return[styles]}render(){return html`
|
|
40
|
+
<slot name="prefix"></slot>
|
|
41
|
+
<slot></slot>
|
|
42
|
+
<slot name="suffix"></slot>
|
|
43
|
+
`}};__decorate([property({type:Boolean,reflect:!0})],OrTreeNode.prototype,"readonly",void 0),__decorate([property({type:Boolean,reflect:!0})],OrTreeNode.prototype,"selected",void 0),OrTreeNode=__decorate([customElement("or-tree-node")],OrTreeNode);export{OrTreeNode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"or-tree-node.js","sourceRoot":"","sources":["../src/or-tree-node.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE1D,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCjB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAEH;;WAEG;QAEI,aAAQ,GAAG,KAAK,CAAC;QAExB;;WAEG;QAEI,aAAQ,GAAG,KAAK,CAAC;IAa5B,CAAC;IAXG,MAAM,KAAK,MAAM;QACb,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;IAES,MAAM;QACZ,OAAO,IAAI,CAAA;;;;SAIV,CAAC;IACN,CAAC;CACJ,CAAA;AAnBU;IADN,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;4CACjB;AAMjB;IADN,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;4CACjB;AAZf,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CAyBtB"}
|
package/lib/util.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TreeNode } from "./model";
|
|
2
|
+
/**
|
|
3
|
+
* Utility function that moves an array of {@link TreeNode} into another {@link TreeNode}, by adding them to their children.
|
|
4
|
+
* The function takes care of removing the nodes from the former group, and makes sure no duplicates end up in the list.
|
|
5
|
+
*
|
|
6
|
+
* @param nodesToMove - The array of nodes that are moved into a group.
|
|
7
|
+
* @param groupNode - The group node to insert nodesToMove in.
|
|
8
|
+
* @param treeNodes - Full list of nodes in the tree menu.
|
|
9
|
+
*/
|
|
10
|
+
export declare function moveNodesToGroupNode(nodesToMove: TreeNode[], groupNode?: TreeNode, treeNodes?: TreeNode[]): TreeNode[];
|
package/lib/util.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function moveNodesToGroupNode(e,n,o=[]){console.debug(`Moving nodes '${e.map((e=>e.label)).join(", ")}' into group '${null==n?void 0:n.label}'. Tree nodes are`,n);const i=function o(i){return i.map((i=>{if(e.some((e=>i.id===e.id)))return console.debug("Removed the node from original position."),null;const l=Object.assign({},i);return l.children&&(l.children=o(l.children).filter((e=>null!==e))),n&&i.id===(null==n?void 0:n.id)&&e.forEach((e=>{l.children=l.children?[...l.children,e]:[e]})),l})).filter((e=>null!==e))}(o);return n||i.push(...e),i}
|
package/lib/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAqBA;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAAuB,EAAE,SAAoB,EAAE,YAAwB,EAAE;IAC1G,OAAO,CAAC,KAAK,CAAC,iBAAiB,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,mBAAmB,EAAE,SAAS,CAAC,CAAC;IAE9I,SAAS,YAAY,CAAC,KAAiB;QACnC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAEpB,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC5D,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAA;gBACzD,OAAO,IAAI,CAAC,CAAC,8CAA8C;YAC/D,CAAC;YAED,MAAM,OAAO,qBAAkB,IAAI,CAAE,CAAC;YAEtC,oCAAoC;YACpC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACnB,OAAO,CAAC,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;YACtF,CAAC;YAED,uFAAuF;YACvF,IAAI,SAAS,IAAI,IAAI,CAAC,EAAE,MAAK,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,EAAE,CAAA,EAAE,CAAC;gBACzC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;oBAC7B,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;gBAC3F,CAAC,CAAC,CAAC;YACP,CAAC;YACD,OAAO,OAAO,CAAC;QAEnB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,IAAI,CAAe,CAAC;IACnD,CAAC;IAED,+BAA+B;IAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAEzC,oEAAoE;IACpE,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,QAAQ,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openremote/or-tree-menu",
|
|
3
|
+
"version": "1.3.4",
|
|
4
|
+
"description": "Web Component for displaying a tree menu of items with a predefined hierarchy",
|
|
5
|
+
"main": "dist/umd/index.bundle.js",
|
|
6
|
+
"module": "lib/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/index.js",
|
|
9
|
+
"./*": "./lib/*.js"
|
|
10
|
+
},
|
|
11
|
+
"types": "lib/index.d.ts",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"No tests\" && exit 0",
|
|
14
|
+
"prepack": "npx webpack"
|
|
15
|
+
},
|
|
16
|
+
"author": "OpenRemote",
|
|
17
|
+
"license": "AGPL-3.0-or-later",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@mdi/js": "^5.9.55",
|
|
20
|
+
"@openremote/core": "1.3.4",
|
|
21
|
+
"@openremote/or-mwc-components": "1.3.4",
|
|
22
|
+
"@openremote/or-translate": "1.3.4",
|
|
23
|
+
"lit": "^3.2.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@openremote/util": "1.3.4"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
}
|
|
31
|
+
}
|