@logosphere-ui/core 0.0.0-alpha.43 → 0.0.0-alpha.45
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/AGENTS.md +147 -66
- package/dist/AGENTS.md +147 -66
- package/dist/accordion-CYuCj7nB.cjs +21 -0
- package/dist/accordion-cDabqwu6.js +96 -0
- package/dist/accordion.cjs +1 -0
- package/dist/accordion.js +4 -0
- package/dist/atoms/Checkbox/checkbox.d.ts +11 -2
- package/dist/atoms/FormField/formfield.d.ts +2 -0
- package/dist/{badge-DsDxWEHx.js → badge-BhINg1p5.js} +20 -20
- package/dist/{badge-DvaKpUHe.cjs → badge-CKSG_MyA.cjs} +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/breadcrumb-BOuCLUJh.cjs +12 -0
- package/dist/breadcrumb-BeJqq-5C.js +41 -0
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button-CVkIa7M0.js +58 -0
- package/dist/button-vdNReBMi.cjs +10 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/{calendar-CZ_IN2TF.js → calendar-C71sj3Ki.js} +1 -1
- package/dist/{calendar-CIgyrv3U.cjs → calendar-DZJM5Tyu.cjs} +1 -1
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/{card-MDwFGplY.js → card-C7xXMV3h.js} +3 -3
- package/dist/card-DmQRNKtk.cjs +43 -0
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/chatbot-BAou4THb.cjs +183 -0
- package/dist/{chatbot-CHgiUY4h.js → chatbot-BRfqXYYt.js} +13 -13
- package/dist/chatbot.cjs +1 -1
- package/dist/chatbot.js +1 -1
- package/dist/checkbox-BAbPDN6x.cjs +53 -0
- package/dist/checkbox-CTfbav6M.js +152 -0
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{chip-group-CpcjGoRm.cjs → chip-group-D4DwnC37.cjs} +1 -1
- package/dist/{chip-group-BUL2H8rr.js → chip-group-DzfOd6Vw.js} +1 -1
- package/dist/chip-group.cjs +1 -1
- package/dist/chip-group.js +1 -1
- package/dist/collapse-CbRE8ABx.cjs +47 -0
- package/dist/collapse-DY6SJ9jS.js +141 -0
- package/dist/collapse.cjs +1 -0
- package/dist/collapse.js +4 -0
- package/dist/combobox-BAa3UAQs.cjs +113 -0
- package/dist/{combobox-jak7Ac1m.js → combobox-BR05Tgfd.js} +31 -8
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +1 -1
- package/dist/{datepicker-BgysIOZI.js → datepicker-BFYWQRrJ.js} +58 -51
- package/dist/datepicker-BWE4qDJM.cjs +85 -0
- package/dist/datepicker.cjs +1 -1
- package/dist/datepicker.js +1 -1
- package/dist/{drawer-3nyjAkcS.cjs → drawer-CRu4G2zu.cjs} +2 -2
- package/dist/{drawer-CE9zzllI.js → drawer-DhuBPWHP.js} +3 -3
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.js +1 -1
- package/dist/formfield-JXiv9mvJ.cjs +33 -0
- package/dist/{formfield-O327HYt0.js → formfield-ss2mFweu.js} +59 -52
- package/dist/formfield.cjs +1 -1
- package/dist/formfield.js +1 -1
- package/dist/icon.cjs +1 -0
- package/dist/icon.js +4 -0
- package/dist/index.cjs +1 -291
- package/dist/index.d.ts +1 -0
- package/dist/index.js +65 -908
- package/dist/index.umd.js +284 -215
- package/dist/input-DyLKo7h6.cjs +60 -0
- package/dist/input-N3Z8D7q1.js +278 -0
- package/dist/input-group-C6sA1lzj.cjs +5 -0
- package/dist/input-group-DUPlrpug.js +66 -0
- package/dist/input-group.cjs +1 -0
- package/dist/input-group.js +4 -0
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/left-menu.cjs +1 -1
- package/dist/left-menu.js +3 -3
- package/dist/leftmenu-BcUNnvly.cjs +120 -0
- package/dist/leftmenu-Cg57EaSY.js +361 -0
- package/dist/modal-g3KbWncV.cjs +84 -0
- package/dist/{modal-DUIv_yoo.js → modal-vSjEpYrG.js} +4 -4
- package/dist/modal.cjs +1 -1
- package/dist/modal.js +1 -1
- package/dist/molecules/Input/input.d.ts +17 -0
- package/dist/molecules/Popover/popover.d.ts +4 -0
- package/dist/organisms/Combobox/combobox.d.ts +9 -0
- package/dist/organisms/DatePicker/datepicker.d.ts +2 -0
- package/dist/organisms/LeftMenu/index.d.ts +1 -1
- package/dist/organisms/LeftMenu/leftmenu-types.d.ts +24 -0
- package/dist/organisms/LeftMenu/leftmenu.d.ts +24 -9
- package/dist/organisms/TreeMenu/tree-menu.d.ts +20 -2
- package/dist/{pagination-B7jknoOz.js → pagination-CjXvpE2j.js} +61 -61
- package/dist/pagination-Nnzacqdo.cjs +169 -0
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.js +1 -1
- package/dist/popover-CrXUbUR-.cjs +30 -0
- package/dist/popover-M5ZcS5rj.js +161 -0
- package/dist/popover.cjs +1 -1
- package/dist/popover.js +1 -1
- package/dist/shared/icons/index.d.ts +1 -0
- package/dist/slider-DSRs5uhl.cjs +108 -0
- package/dist/slider-ntLRajQa.js +280 -0
- package/dist/slider.cjs +1 -0
- package/dist/slider.js +4 -0
- package/dist/split-button-BdBweoip.js +177 -0
- package/dist/split-button-BpffPlVg.cjs +63 -0
- package/dist/split-button.cjs +1 -0
- package/dist/split-button.js +4 -0
- package/dist/stepper-CZhwgLNp.js +122 -0
- package/dist/stepper-ZOMaU6aZ.cjs +52 -0
- package/dist/stepper.cjs +1 -0
- package/dist/stepper.js +4 -0
- package/dist/{switch-8RGGesy5.cjs → switch-Do6SCkPJ.cjs} +2 -2
- package/dist/{switch-DNqPqH-R.js → switch-uYVuohJ-.js} +25 -21
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +1 -1
- package/dist/tab-BvRVHpWs.cjs +41 -0
- package/dist/{tab-CuBCFGoO.js → tab-Byh4UgFB.js} +1 -1
- package/dist/tab.cjs +1 -1
- package/dist/tab.js +1 -1
- package/dist/{text-area-C73JxnqH.js → text-area-1rALZ0iy.js} +16 -12
- package/dist/text-area-D_TYL4_q.cjs +51 -0
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/{timepicker-DMzGYd0p.js → timepicker-B9l6HN-d.js} +6 -2
- package/dist/{timepicker-CLJKWWGm.cjs → timepicker-Bpf2d4Nn.cjs} +1 -1
- package/dist/timepicker.cjs +1 -1
- package/dist/timepicker.js +1 -1
- package/dist/{toast-container-B5v74b_5.js → toast-container-C5qYjInG.js} +4 -4
- package/dist/toast-container-D2dyP20J.cjs +64 -0
- package/dist/toast.cjs +1 -1
- package/dist/toast.js +1 -1
- package/dist/tree-menu-BZ7aBC7R.js +237 -0
- package/dist/tree-menu-DDQ_DYl7.cjs +78 -0
- package/dist/tree-menu.cjs +1 -1
- package/dist/tree-menu.js +1 -1
- package/dist/{ui-icon-BMJNdIOq.js → ui-icon-BeR-PaPg.js} +11 -7
- package/dist/{ui-icon-DIucAQC_.cjs → ui-icon-DWl7I5BQ.cjs} +2 -2
- package/package.json +6 -1
- package/dist/breadcrumb-BB61Xt0s.js +0 -41
- package/dist/breadcrumb-Cop-B1J7.cjs +0 -12
- package/dist/button-DRZ4sG4T.cjs +0 -10
- package/dist/button-Uu9oaieg.js +0 -58
- package/dist/card-BOCW7gad.cjs +0 -43
- package/dist/chatbot-B-NiZIYK.cjs +0 -183
- package/dist/checkbox-CX0LgsWP.js +0 -148
- package/dist/checkbox-DpbKHANK.cjs +0 -53
- package/dist/combobox-BmIFPk8X.cjs +0 -113
- package/dist/datepicker-DOBmbxlo.cjs +0 -85
- package/dist/formfield-CRcyUMvQ.cjs +0 -33
- package/dist/input-CQS0LzF-.cjs +0 -59
- package/dist/input-CeF3YJk-.js +0 -257
- package/dist/leftmenu-CmWvnA6L.js +0 -301
- package/dist/leftmenu-p9aR2QTy.cjs +0 -83
- package/dist/modal-dUnnHe8u.cjs +0 -84
- package/dist/organisms/LeftMenu/leftmenu-item.d.ts +0 -14
- package/dist/pagination-BkqbWBOn.cjs +0 -169
- package/dist/popover-CYDoeLKp.cjs +0 -30
- package/dist/popover-DDaG8MSj.js +0 -143
- package/dist/tab-CDMcFHvP.cjs +0 -41
- package/dist/text-area-Cprb-azV.cjs +0 -51
- package/dist/toast-container-6t6yEP9Y.cjs +0 -64
- package/dist/tree-menu-CkOPxr-W.js +0 -154
- package/dist/tree-menu-WNwZMreD.cjs +0 -47
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { unsafeCSS as p, css as _, LitElement as u, html as a, nothing as c } from "lit";
|
|
2
|
-
import { property as d, state as v, customElement as g } from "lit/decorators.js";
|
|
3
|
-
import { unsafeHTML as b } from "lit/directives/unsafe-html.js";
|
|
4
|
-
import "./ui-icon-BMJNdIOq.js";
|
|
5
|
-
const f = ".tree{width:100%;font-family:var(--font-family-base)}.tree__list,.tree__children{list-style:none;margin:0;padding:0}.tree__item{margin:0;padding:0}.tree__row{display:flex;align-items:center;gap:var(--spacing-1);padding:var(--spacing-2) var(--spacing-3);padding-left:calc(var(--spacing-3) + (var(--tree-level, 0) * 14px));border-radius:var(--radius-sm);color:var(--color-body-color);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.tree--icons .tree__row{justify-content:center;padding:0;width:44px;height:44px;min-height:44px;margin:0 auto}.tree__row:hover{background-color:var(--color-light)}.tree__row:focus-visible{outline:2px solid var(--color-secondary);outline-offset:1px}.tree__row--disabled{opacity:.5;cursor:not-allowed}.tree__row--active .tree__label,.tree__row--active .tree__icon{color:var(--color-primary)}.tree:not(.tree--icons) .tree__row--active{background-color:var(--color-light)}.tree__icon{width:20px;min-width:20px;display:inline-flex;align-items:center;justify-content:center;color:inherit}.tree--icons .tree__icon{width:20px;min-width:20px;height:20px}.tree--icons .tree__row--active{background-color:var(--color-primary)}.tree--icons .tree__row--active .tree__icon{color:#fff}.tree--icons .tree__row--active:hover{background-color:var(--color-primary-hover)}.tree__chevron-btn{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border:none;background:transparent;color:var(--color-tertiary);cursor:pointer;padding:0;flex-shrink:0}.tree__chevron-btn--right{margin-left:auto}.tree__chevron{transform:rotate(-90deg);transition:transform var(--transition-speed-fast) var(--transition-timing)}.tree__chevron--open{transform:rotate(0)}.tree__chevron-spacer{width:20px;height:20px;flex-shrink:0}.tree__label{display:inline-flex;align-items:center;font-size:var(--font-size-sm);color:inherit}";
|
|
6
|
-
var w = Object.defineProperty, x = Object.getOwnPropertyDescriptor, l = (e, t, r, n) => {
|
|
7
|
-
for (var o = n > 1 ? void 0 : n ? x(t, r) : t, s = e.length - 1, h; s >= 0; s--)
|
|
8
|
-
(h = e[s]) && (o = (n ? h(t, r, o) : h(o)) || o);
|
|
9
|
-
return n && o && w(t, r, o), o;
|
|
10
|
-
};
|
|
11
|
-
let i = class extends u {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments), this.items = [], this.expandedIds = [], this.expandOnLabelClick = !0, this.chevronPosition = "left", this.showLabels = !0, this.iconSize = 16, this._expandedSet = /* @__PURE__ */ new Set();
|
|
14
|
-
}
|
|
15
|
-
willUpdate(e) {
|
|
16
|
-
e.has("expandedIds") && (this._expandedSet = new Set(this.expandedIds ?? []));
|
|
17
|
-
}
|
|
18
|
-
_isExpanded(e) {
|
|
19
|
-
return this._expandedSet.has(e);
|
|
20
|
-
}
|
|
21
|
-
_emitToggle(e, t) {
|
|
22
|
-
this.dispatchEvent(
|
|
23
|
-
new CustomEvent("toggle", {
|
|
24
|
-
detail: { item: e, expanded: t },
|
|
25
|
-
bubbles: !0,
|
|
26
|
-
composed: !0
|
|
27
|
-
})
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
_emitItemClick(e) {
|
|
31
|
-
this.dispatchEvent(
|
|
32
|
-
new CustomEvent("item-click", {
|
|
33
|
-
detail: { item: e },
|
|
34
|
-
bubbles: !0,
|
|
35
|
-
composed: !0
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
_emitNodeClick(e, t) {
|
|
40
|
-
this.dispatchEvent(
|
|
41
|
-
new CustomEvent("node-click", {
|
|
42
|
-
detail: { item: e, hasChildren: t },
|
|
43
|
-
bubbles: !0,
|
|
44
|
-
composed: !0
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
_setExpanded(e, t) {
|
|
49
|
-
t ? this._expandedSet.add(e.id) : this._expandedSet.delete(e.id), this.expandedIds = Array.from(this._expandedSet), this._emitToggle(e, t);
|
|
50
|
-
}
|
|
51
|
-
_toggle(e, t) {
|
|
52
|
-
t.stopPropagation(), !(e.disabled || !e.children?.length) && this._setExpanded(e, !this._isExpanded(e.id));
|
|
53
|
-
}
|
|
54
|
-
_handleItemClick(e, t) {
|
|
55
|
-
if (t.stopPropagation(), e.disabled) return;
|
|
56
|
-
const r = !!e.children?.length;
|
|
57
|
-
if (this._emitNodeClick(e, r), r && this.expandOnLabelClick) {
|
|
58
|
-
this._setExpanded(e, !this._isExpanded(e.id));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
r || (e.onClick?.(e), this._emitItemClick(e));
|
|
62
|
-
}
|
|
63
|
-
_handleRowKeydown(e, t) {
|
|
64
|
-
t.key !== "Enter" && t.key !== " " || (t.preventDefault(), this._handleItemClick(e, t));
|
|
65
|
-
}
|
|
66
|
-
_renderIcon(e) {
|
|
67
|
-
return e.iconName ? a`
|
|
68
|
-
<span class="tree__icon">
|
|
69
|
-
<ui-icon name=${e.iconName} .size=${this.iconSize}></ui-icon>
|
|
70
|
-
</span>
|
|
71
|
-
` : e.iconHtml ? a`<span class="tree__icon">${b(e.iconHtml)}</span>` : c;
|
|
72
|
-
}
|
|
73
|
-
_renderChevron(e, t) {
|
|
74
|
-
const r = !!e.children?.length;
|
|
75
|
-
return this.showLabels ? r ? a`
|
|
76
|
-
<button
|
|
77
|
-
type="button"
|
|
78
|
-
class="tree__chevron-btn ${this.chevronPosition === "right" ? "tree__chevron-btn--right" : ""}"
|
|
79
|
-
aria-label=${t ? "Collapse" : "Expand"}
|
|
80
|
-
@click=${(n) => this._toggle(e, n)}
|
|
81
|
-
>
|
|
82
|
-
<ui-icon
|
|
83
|
-
class="tree__chevron ${t ? "tree__chevron--open" : ""}"
|
|
84
|
-
name="uil-angle-down"
|
|
85
|
-
size="20"
|
|
86
|
-
></ui-icon>
|
|
87
|
-
</button>
|
|
88
|
-
` : a`<span class="tree__chevron-spacer"></span>` : c;
|
|
89
|
-
}
|
|
90
|
-
_renderNode(e, t) {
|
|
91
|
-
const r = !!e.children?.length, n = r ? this._isExpanded(e.id) : !1, o = this.showLabels ? `--tree-level:${t};` : "--tree-level:0;";
|
|
92
|
-
return a`
|
|
93
|
-
<li class="tree__item">
|
|
94
|
-
<div
|
|
95
|
-
class="tree__row ${e.disabled ? "tree__row--disabled" : ""} ${e.active ? "tree__row--active" : ""}"
|
|
96
|
-
style=${o}
|
|
97
|
-
role="button"
|
|
98
|
-
tabindex=${e.disabled ? -1 : 0}
|
|
99
|
-
@click=${(s) => this._handleItemClick(e, s)}
|
|
100
|
-
@keydown=${(s) => this._handleRowKeydown(e, s)}
|
|
101
|
-
title=${this.showLabels ? "" : e.label}
|
|
102
|
-
>
|
|
103
|
-
${this.chevronPosition === "left" ? this._renderChevron(e, n) : c}
|
|
104
|
-
${this._renderIcon(e)}
|
|
105
|
-
${this.showLabels ? a`<span class="tree__label">${e.label}</span>` : c}
|
|
106
|
-
${this.chevronPosition === "right" ? this._renderChevron(e, n) : c}
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
${this.showLabels && r && n ? a`
|
|
110
|
-
<ul class="tree__children">
|
|
111
|
-
${e.children.map((s) => this._renderNode(s, t + 1))}
|
|
112
|
-
</ul>
|
|
113
|
-
` : c}
|
|
114
|
-
</li>
|
|
115
|
-
`;
|
|
116
|
-
}
|
|
117
|
-
render() {
|
|
118
|
-
return a`
|
|
119
|
-
<nav class="tree ${this.showLabels ? "" : "tree--icons"}" aria-label="Tree Menu">
|
|
120
|
-
<ul class="tree__list">
|
|
121
|
-
${this.items.map((e) => this._renderNode(e, 0))}
|
|
122
|
-
</ul>
|
|
123
|
-
</nav>
|
|
124
|
-
`;
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
i.styles = [_`${p(f)}`];
|
|
128
|
-
l([
|
|
129
|
-
d({ attribute: !1 })
|
|
130
|
-
], i.prototype, "items", 2);
|
|
131
|
-
l([
|
|
132
|
-
d({ type: Array })
|
|
133
|
-
], i.prototype, "expandedIds", 2);
|
|
134
|
-
l([
|
|
135
|
-
d({ type: Boolean })
|
|
136
|
-
], i.prototype, "expandOnLabelClick", 2);
|
|
137
|
-
l([
|
|
138
|
-
d({ type: String })
|
|
139
|
-
], i.prototype, "chevronPosition", 2);
|
|
140
|
-
l([
|
|
141
|
-
d({ type: Boolean })
|
|
142
|
-
], i.prototype, "showLabels", 2);
|
|
143
|
-
l([
|
|
144
|
-
d({ type: Number })
|
|
145
|
-
], i.prototype, "iconSize", 2);
|
|
146
|
-
l([
|
|
147
|
-
v()
|
|
148
|
-
], i.prototype, "_expandedSet", 2);
|
|
149
|
-
i = l([
|
|
150
|
-
g("logosphere-tree-menu")
|
|
151
|
-
], i);
|
|
152
|
-
export {
|
|
153
|
-
i as T
|
|
154
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("lit"),s=require("lit/decorators.js"),d=require("lit/directives/unsafe-html.js");require("./ui-icon-DIucAQC_.cjs");const h=".tree{width:100%;font-family:var(--font-family-base)}.tree__list,.tree__children{list-style:none;margin:0;padding:0}.tree__item{margin:0;padding:0}.tree__row{display:flex;align-items:center;gap:var(--spacing-1);padding:var(--spacing-2) var(--spacing-3);padding-left:calc(var(--spacing-3) + (var(--tree-level, 0) * 14px));border-radius:var(--radius-sm);color:var(--color-body-color);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background-color var(--transition-speed-fast) var(--transition-timing)}.tree--icons .tree__row{justify-content:center;padding:0;width:44px;height:44px;min-height:44px;margin:0 auto}.tree__row:hover{background-color:var(--color-light)}.tree__row:focus-visible{outline:2px solid var(--color-secondary);outline-offset:1px}.tree__row--disabled{opacity:.5;cursor:not-allowed}.tree__row--active .tree__label,.tree__row--active .tree__icon{color:var(--color-primary)}.tree:not(.tree--icons) .tree__row--active{background-color:var(--color-light)}.tree__icon{width:20px;min-width:20px;display:inline-flex;align-items:center;justify-content:center;color:inherit}.tree--icons .tree__icon{width:20px;min-width:20px;height:20px}.tree--icons .tree__row--active{background-color:var(--color-primary)}.tree--icons .tree__row--active .tree__icon{color:#fff}.tree--icons .tree__row--active:hover{background-color:var(--color-primary-hover)}.tree__chevron-btn{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border:none;background:transparent;color:var(--color-tertiary);cursor:pointer;padding:0;flex-shrink:0}.tree__chevron-btn--right{margin-left:auto}.tree__chevron{transform:rotate(-90deg);transition:transform var(--transition-speed-fast) var(--transition-timing)}.tree__chevron--open{transform:rotate(0)}.tree__chevron-spacer{width:20px;height:20px;flex-shrink:0}.tree__label{display:inline-flex;align-items:center;font-size:var(--font-size-sm);color:inherit}";var p=Object.defineProperty,_=Object.getOwnPropertyDescriptor,a=(c,e,t,n)=>{for(var i=n>1?void 0:n?_(e,t):e,l=c.length-1,o;l>=0;l--)(o=c[l])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&p(e,t,i),i};exports.TreeMenu=class extends r.LitElement{constructor(){super(...arguments),this.items=[],this.expandedIds=[],this.expandOnLabelClick=!0,this.chevronPosition="left",this.showLabels=!0,this.iconSize=16,this._expandedSet=new Set}willUpdate(e){e.has("expandedIds")&&(this._expandedSet=new Set(this.expandedIds??[]))}_isExpanded(e){return this._expandedSet.has(e)}_emitToggle(e,t){this.dispatchEvent(new CustomEvent("toggle",{detail:{item:e,expanded:t},bubbles:!0,composed:!0}))}_emitItemClick(e){this.dispatchEvent(new CustomEvent("item-click",{detail:{item:e},bubbles:!0,composed:!0}))}_emitNodeClick(e,t){this.dispatchEvent(new CustomEvent("node-click",{detail:{item:e,hasChildren:t},bubbles:!0,composed:!0}))}_setExpanded(e,t){t?this._expandedSet.add(e.id):this._expandedSet.delete(e.id),this.expandedIds=Array.from(this._expandedSet),this._emitToggle(e,t)}_toggle(e,t){t.stopPropagation(),!(e.disabled||!e.children?.length)&&this._setExpanded(e,!this._isExpanded(e.id))}_handleItemClick(e,t){if(t.stopPropagation(),e.disabled)return;const n=!!e.children?.length;if(this._emitNodeClick(e,n),n&&this.expandOnLabelClick){this._setExpanded(e,!this._isExpanded(e.id));return}n||(e.onClick?.(e),this._emitItemClick(e))}_handleRowKeydown(e,t){t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this._handleItemClick(e,t))}_renderIcon(e){return e.iconName?r.html`
|
|
2
|
-
<span class="tree__icon">
|
|
3
|
-
<ui-icon name=${e.iconName} .size=${this.iconSize}></ui-icon>
|
|
4
|
-
</span>
|
|
5
|
-
`:e.iconHtml?r.html`<span class="tree__icon">${d.unsafeHTML(e.iconHtml)}</span>`:r.nothing}_renderChevron(e,t){const n=!!e.children?.length;return this.showLabels?n?r.html`
|
|
6
|
-
<button
|
|
7
|
-
type="button"
|
|
8
|
-
class="tree__chevron-btn ${this.chevronPosition==="right"?"tree__chevron-btn--right":""}"
|
|
9
|
-
aria-label=${t?"Collapse":"Expand"}
|
|
10
|
-
@click=${i=>this._toggle(e,i)}
|
|
11
|
-
>
|
|
12
|
-
<ui-icon
|
|
13
|
-
class="tree__chevron ${t?"tree__chevron--open":""}"
|
|
14
|
-
name="uil-angle-down"
|
|
15
|
-
size="20"
|
|
16
|
-
></ui-icon>
|
|
17
|
-
</button>
|
|
18
|
-
`:r.html`<span class="tree__chevron-spacer"></span>`:r.nothing}_renderNode(e,t){const n=!!e.children?.length,i=n?this._isExpanded(e.id):!1,l=this.showLabels?`--tree-level:${t};`:"--tree-level:0;";return r.html`
|
|
19
|
-
<li class="tree__item">
|
|
20
|
-
<div
|
|
21
|
-
class="tree__row ${e.disabled?"tree__row--disabled":""} ${e.active?"tree__row--active":""}"
|
|
22
|
-
style=${l}
|
|
23
|
-
role="button"
|
|
24
|
-
tabindex=${e.disabled?-1:0}
|
|
25
|
-
@click=${o=>this._handleItemClick(e,o)}
|
|
26
|
-
@keydown=${o=>this._handleRowKeydown(e,o)}
|
|
27
|
-
title=${this.showLabels?"":e.label}
|
|
28
|
-
>
|
|
29
|
-
${this.chevronPosition==="left"?this._renderChevron(e,i):r.nothing}
|
|
30
|
-
${this._renderIcon(e)}
|
|
31
|
-
${this.showLabels?r.html`<span class="tree__label">${e.label}</span>`:r.nothing}
|
|
32
|
-
${this.chevronPosition==="right"?this._renderChevron(e,i):r.nothing}
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
${this.showLabels&&n&&i?r.html`
|
|
36
|
-
<ul class="tree__children">
|
|
37
|
-
${e.children.map(o=>this._renderNode(o,t+1))}
|
|
38
|
-
</ul>
|
|
39
|
-
`:r.nothing}
|
|
40
|
-
</li>
|
|
41
|
-
`}render(){return r.html`
|
|
42
|
-
<nav class="tree ${this.showLabels?"":"tree--icons"}" aria-label="Tree Menu">
|
|
43
|
-
<ul class="tree__list">
|
|
44
|
-
${this.items.map(e=>this._renderNode(e,0))}
|
|
45
|
-
</ul>
|
|
46
|
-
</nav>
|
|
47
|
-
`}};exports.TreeMenu.styles=[r.css`${r.unsafeCSS(h)}`];a([s.property({attribute:!1})],exports.TreeMenu.prototype,"items",2);a([s.property({type:Array})],exports.TreeMenu.prototype,"expandedIds",2);a([s.property({type:Boolean})],exports.TreeMenu.prototype,"expandOnLabelClick",2);a([s.property({type:String})],exports.TreeMenu.prototype,"chevronPosition",2);a([s.property({type:Boolean})],exports.TreeMenu.prototype,"showLabels",2);a([s.property({type:Number})],exports.TreeMenu.prototype,"iconSize",2);a([s.state()],exports.TreeMenu.prototype,"_expandedSet",2);exports.TreeMenu=a([s.customElement("logosphere-tree-menu")],exports.TreeMenu);
|