@nyx-ds/treeview 0.1.0 → 0.1.1

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/dist/treeview.js CHANGED
@@ -1,644 +1,1327 @@
1
- import { LitElement as k, html as l, unsafeCSS as m, nothing as y } from "lit";
2
- import { property as a, state as f, queryAssignedElements as M } from "lit/decorators.js";
3
- import { repeat as U } from "lit/directives/repeat.js";
4
- import { classMap as O } from "lit/directives/class-map.js";
5
- import { eyeSlash as W, eye as V, xmark as G, check as j, minus as J, spinnerThird as K, magnifyingGlass as Q, chevronRightRegular as X } from "@nyx-ds/core";
6
- import { classMap as $ } from "lit-html/directives/class-map.js";
1
+ import { LitElement as Z, nothing as w, html as h, unsafeCSS as G } from "lit";
2
+ import { property as K, state as f } from "lit/decorators.js";
3
+ import { repeat as Y } from "lit/directives/repeat.js";
4
+ import { classMap as b } from "lit/directives/class-map.js";
5
+ import { chevronRightRegular as X, magnifyingGlass as J } from "@nyx-ds/core";
6
+ import "@lit-labs/virtualizer";
7
+ import "@nyx-ds/input";
8
+ import "@nyx-ds/checkbox";
7
9
  import "@nyx-ds/icon";
8
- import { unsafeHTML as B } from "lit-html/directives/unsafe-html.js";
9
- function Y(c, o) {
10
- return function(e, n) {
11
- const { native: t = !1, ...r } = n || {}, i = t ? new Event(o, r) : new CustomEvent(o, { detail: e, ...r });
12
- c.dispatchEvent(i);
10
+ import "@nyx-ds/button";
11
+ function Q(n, e) {
12
+ return function(t, i) {
13
+ const { native: s = !1, ...r } = i || {}, o = s ? new Event(e, r) : new CustomEvent(e, { detail: t, ...r });
14
+ n.dispatchEvent(o);
13
15
  };
14
16
  }
15
- function q(c) {
16
- return (o, e) => {
17
- Object.defineProperty(o, e, {
17
+ function ee(n) {
18
+ return (e, t) => {
19
+ Object.defineProperty(e, t, {
18
20
  get() {
19
- return Y(this, c || e);
21
+ return Q(this, n);
20
22
  },
21
23
  enumerable: !0,
22
24
  configurable: !0
23
25
  });
24
26
  };
25
27
  }
26
- const Z = ":host{display:flex;flex-direction:column;width:100%;--treeview-radius: var(--nyx-radii-s);--treeview-search-padding: var(--nyx-sizing-1-25) var(--nyx-sizing-1-75) 0 var(--nyx-sizing-1-75);--treeview-header-padding: var(--nyx-sizing-2) var(--nyx-sizing-2) var(--nyx-sizing-1-75) var(--nyx-sizing-2);--treeview-row-padding: var(--nyx-sizing-1-5, 12px) var(--nyx-sizing-2);--treeview-row-gap: var(--nyx-sizing-2);--treeview-col-gap: var(--nyx-sizing-1);--treeview-node-gap: var(--nyx-sizing-1);--treeview-row-min-height: 56px;--treeview-expander-wrapper-size: var(--nyx-sizing-4);--treeview-expander-padding: var(--nyx-sizing-1-25);--treeview-col-width: var(--treeview-header-icon-size);--treeview-background: var(--nyx-color-neutral-background-primary);--treeview-border-color: var(--nyx-color-neutral-border-tertiary);--treeview-content-color: var(--nyx-color-neutral-content-primary);--treeview-focus-border-color: var(--nyx-color-brand-border-default);--treeview-row-selected-background: var(--nyx-color-brand-background-softer);--treeview-row-selected-hover-background: var( --nyx-color-brand-background-softer-hover );--treeview-row-selected-color: var(--nyx-color-neutral-content-primary);--treeview-font-family: var(--nyx-font-family-font-family);--treeview-title-font-size: var(--nyx-label-medium-font-size);--treeview-title-line-height: var(--nyx-label-medium-line-height);--treeview-text-font-size: var(--nyx-label-medium-font-size);--treeview-text-line-height: var(--nyx-label-medium-line-height);--treeview-header-icon-size: var(--nyx-label-large-font-size);--treeview-node-icon-size: var(--nyx-label-medium-font-size);--treeview-expander-icon-size: var(--nyx-label-large-font-size);--treeview-row-hover-background: var(--nyx-color-brand-background-hover);--treeview-row-hover-color: var(--nyx-color-neutral-content-primary-inverse)}.nyx-treeview{display:flex;flex-direction:column;width:100%;font-family:var(--treeview-font-family);align-items:flex-start;border-radius:var(--treeview-radius);border:1px solid var(--treeview-border-color);background:var(--treeview-background);box-sizing:border-box}.component-subtitle{color:var(--nyx-color-neutral-content-tertiary);font-family:var(--nyx-font-family-font-family);font-size:var(--nyx-paragraph-large-font-size);line-height:var(--nyx-paragraph-large-line-height);display:block;margin-top:-8px;margin-bottom:16px}.search-container{display:flex;padding:var(--treeview-search-padding);flex-direction:column;align-items:flex-start;align-self:stretch}.tree-scroll{width:100%}.tree-header{display:flex;justify-content:space-between;align-items:center;align-self:stretch;padding:var(--treeview-header-padding);border-bottom:.5px solid var(--treeview-border-color);box-sizing:border-box}.tree-title{color:var(--treeview-content-color);font-size:var(--treeview-title-font-size);line-height:var(--treeview-title-line-height);font-weight:600}.header-columns,.node-columns{display:flex;align-items:center;justify-content:flex-end;gap:var(--treeview-col-gap);flex-shrink:0}.col-cell{min-width:var(--treeview-col-width);width:var(--treeview-col-width);flex:0 0 auto}.col-cell,.header-columns ::slotted(*){display:flex;justify-content:center;align-items:center;box-sizing:border-box}.header-columns ::slotted(nyx-icon){--nyx-icon-size: var(--treeview-header-icon-size);color:var(--treeview-content-color)}.tree-body{width:100%;display:flex;flex-direction:column}.node-wrapper{display:flex;flex-direction:column;width:100%}.node-row{display:flex;align-items:center;justify-content:space-between;min-height:var(--treeview-row-min-height);border-bottom:.5px solid var(--treeview-border-color);gap:var(--treeview-row-gap);padding:var(--treeview-row-padding);box-sizing:border-box;background:transparent;color:var(--treeview-content-color);outline:none;cursor:default}.node-row:hover{background:var(--treeview-row-hover-background);color:var(--treeview-row-hover-color)}.node-row:focus-within{background:var(--treeview-row-hover-background)!important;color:var(--treeview-row-hover-color)!important}.node-row:hover .expander nyx-icon,.node-row:hover .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-hover-color)}.node-row:focus-within .expander nyx-icon,.node-row:focus-within .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-hover-color)}.node-row.selectable.selected{background-color:var(--treeview-row-selected-background);color:var(--treeview-row-selected-color)}.node-row.selectable.selected .expander nyx-icon,.node-row.selectable.selected .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-selected-color)}.node-row.selectable.selected:hover{background-color:var(--treeview-row-selected-hover-background);color:var(--treeview-row-selected-color)}.node-row:focus-visible{position:relative;z-index:2;outline:2px solid var(--treeview-content-color);outline-offset:-4px;background:var(--treeview-row-hover-background)!important;color:var(--treeview-row-hover-color)}.row-checkbox{display:flex;align-items:center;margin-right:4px}.node-info{display:flex;align-items:center;gap:var(--treeview-node-gap);flex:1 0 0;overflow:hidden;min-height:32px;padding-left:4px}.expander{--button-icon-color: inherit}.expander nyx-icon{--nyx-icon-size: var(--treeview-expander-icon-size);transition:transform .2s ease;transform-origin:center}.expander nyx-icon.expanded{transform:rotate(90deg)}.expander:hover,.expander:focus-within{--button-icon-color: var(--treeview-content-color) !important}.expander:hover nyx-icon,.expander:focus-within nyx-icon{color:var(--treeview-content-color)!important;--nyx-icon-color: var(--treeview-content-color) !important}.node-type-icon-wrapper{display:flex;align-items:center;justify-content:center;flex-shrink:0}.node-type-icon-wrapper ::slotted(nyx-icon){--nyx-icon-size: var(--treeview-node-icon-size)}.node-text{font-size:var(--treeview-text-font-size);line-height:var(--treeview-text-line-height);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-children{width:100%}@media (max-width: 768px){.tree-scroll{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}.tree-header,.tree-body{min-width:calc(250px + ((var(--treeview-col-width) + var(--treeview-col-gap)) * 4))}.node-text{white-space:normal;display:-webkit-box;line-clamp:2;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}}", oo = ':host{--field-padding: var(--nyx-sizing-1-5);--field-padding-small: var(--nyx-sizing-1) var(--nyx-sizing-1-5);--field-border-radius-sharp: var(--nyx-radii-xs);--field-border-radius-rounded: var(--nyx-radii-100);--field-border: var(--nyx-stroke-number-2) solid var(--nyx-color-neutral-border-tertiary);--field-text-color: var(--nyx-color-neutral-content-primary);--field-font-family: var(--nyx-font-family-font-family);--field-font-size: var(--nyx-label-medium-font-size);--field-line-height: var(--nyx-label-medium-line-height);--placeholder-color: var(--nyx-color-neutral-content-tertiary);--field-hover-border: var(--nyx-stroke-number-3) solid var(--nyx-color-neutral-border-active);--field-focus-outline: var(--nyx-stroke-number-3) solid var(--nyx-color-neutral-border-active);--field-invalid-border: var(--nyx-stroke-number-3) solid var(--nyx-color-danger-border-default);--field-disabled-border: var(--nyx-stroke-number-2) solid var(--nyx-color-neutral-border-disable);--field-disabled-text-color: var(--nyx-color-neutral-content-disabled);--icon-color: var(--nyx-color-neutral-content-tertiary);--icon-disabled-color: var(--nyx-color-neutral-content-disabled);box-sizing:border-box;display:inline-flex;width:100%}*{box-sizing:inherit}.component-subtitle{color:var(--nyx-color-neutral-content-tertiary);font-family:var(--nyx-font-family-font-family);font-size:var(--nyx-paragraph-large-font-size);line-height:var(--nyx-paragraph-large-line-height);display:block;margin-top:-8px;margin-bottom:16px}.container{width:100%;position:relative}.container.small ::slotted([slot="field"]){padding:var(--field-padding-small)}.container.iconLeft ::slotted([slot="field"]){padding-left:36px}.container.iconLeft ::slotted([slot="field"]){padding-right:36px}.password,.clear{display:none;position:absolute;top:0;bottom:0;right:12px;font-size:var(--field-font-size)}::slotted([slot="field"]){width:100%;margin:0;box-sizing:inherit;padding:var(--field-padding);border-radius:var(--field-border-radius-sharp);border:var(--field-border);color:var(--field-text-color);background-color:transparent;font-family:var(--field-font-family);font-size:var(--field-font-size);font-style:normal;font-weight:400;line-height:var(--field-line-height);resize:none}.container.rounded ::slotted([slot="field"]){border-radius:var(--field-border-radius-rounded)}::slotted([slot="field"])::placeholder{color:var(--placeholder-color)}::slotted([slot="field"]:hover:not([disabled])){border:var(--field-hover-border)}::slotted([slot="field"]:focus){outline:var(--field-focus-outline)}::slotted([slot="field"][invalid]){border:var(--field-invalid-border)}::slotted([slot="field"][disabled]){border:var(--field-disabled-border);color:var(--field-disabled-text-color)}::slotted([slot="field"][disabled])::placeholder{color:var(--field-disabled-text-color)}::slotted([slot="iconLeft"]),::slotted([slot="iconRight"]){position:absolute;top:12px;font-size:var(--field-font-size)}.container.small ::slotted([slot="iconLeft"]),.container.small ::slotted([slot="iconRight"]){top:8px}::slotted([slot="iconLeft"]){left:12px}::slotted([slot="iconRight"]){right:12px}::slotted([slot="iconLeft"]:not([action])),::slotted([slot="iconRight"]:not([action])){color:var(--icon-color)}::slotted([slot="iconLeft"][clickable]:not([disabled])),::slotted([slot="iconRight"][clickable]:not([disabled])){cursor:pointer}:host(.disabled) ::slotted([slot="iconLeft"]),:host(.disabled) ::slotted([slot="iconRight"]){color:var(--icon-disabled-color)}.container.passwordToggle ::slotted([slot="iconRight"]),.container.clearable ::slotted([slot="iconRight"]){display:none}.container.passwordToggle .password,.container.clearable .clear{display:flex;cursor:pointer}';
27
- var to = Object.defineProperty, w = (c, o, e, n) => {
28
- for (var t = void 0, r = c.length - 1, i; r >= 0; r--)
29
- (i = c[r]) && (t = i(o, e, t) || t);
30
- return t && to(o, e, t), t;
31
- };
32
- const C = class C extends k {
33
- constructor() {
34
- super(...arguments), this.size = "medium", this.border = "sharp", this.passwordToggle = !1, this.clearable = !1, this.showPassword = !1;
28
+ const te = ":host{display:flex;flex-direction:column;width:100%;--treeview-radius: var(--nyx-radii-s);--treeview-search-padding: var(--nyx-sizing-1-25) var(--nyx-sizing-1-75) 0 var(--nyx-sizing-1-75);--treeview-header-padding: var(--nyx-sizing-2) var(--nyx-sizing-2) var(--nyx-sizing-1-75) var(--nyx-sizing-2);--treeview-row-padding: var(--nyx-sizing-1) var(--nyx-sizing-2);--treeview-row-gap: var(--nyx-sizing-2);--treeview-col-gap: var(--nyx-sizing-1);--treeview-node-gap: var(--nyx-sizing-1);--treeview-row-min-height: 48px;--treeview-indent-base: 16px;--treeview-indent-step: 24px;--treeview-expander-wrapper-size: var(--nyx-sizing-4);--treeview-expander-padding: var(--nyx-sizing-1-25);--treeview-col-width: var(--treeview-header-icon-size);--treeview-column-count: 0;--treeview-scrollbar-gutter: 15px;--treeview-background: var(--nyx-color-neutral-background-primary);--treeview-border-color: var(--nyx-color-neutral-border-tertiary);--treeview-content-color: var(--nyx-color-neutral-content-primary);--treeview-focus-border-color: var(--nyx-color-brand-border-default);--treeview-row-selected-background: var(--nyx-color-brand-background-softer);--treeview-row-selected-hover-background: var( --nyx-color-brand-background-softer-hover );--treeview-row-selected-color: var(--nyx-color-neutral-content-primary);--treeview-font-family: var(--nyx-font-family-font-family);--treeview-title-font-size: var(--nyx-label-medium-font-size);--treeview-title-line-height: var(--nyx-label-medium-line-height);--treeview-text-font-size: var(--nyx-label-medium-font-size);--treeview-text-line-height: var(--nyx-label-medium-line-height);--treeview-header-icon-size: var(--nyx-label-large-font-size);--treeview-node-icon-size: var(--nyx-label-medium-font-size);--treeview-expander-icon-size: var(--nyx-label-large-font-size);--treeview-row-hover-background: var(--nyx-color-neutral-background-secondary);--treeview-row-hover-color: var(--nyx-color-brand-content-hover)}.nyx-treeview{display:flex;flex-direction:column;width:100%;font-family:var(--treeview-font-family);align-items:flex-start;border-radius:var(--treeview-radius);border:1px solid var(--treeview-border-color);background:var(--treeview-background);box-sizing:border-box}.search-container{display:flex;padding:var(--treeview-search-padding);flex-direction:column;align-items:flex-start;align-self:stretch}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.tree-scroll{width:100%;display:flex;flex-direction:column;min-height:0}.tree-body--virtual{display:flex;flex-direction:column;flex:1 1 auto;min-height:280px;max-height:var(--treeview-max-height, 480px);overflow:hidden}.tree-virtualizer{flex:1 1 auto;width:100%;min-height:280px;scrollbar-gutter:stable}.node-wrapper--flat{width:100%}.tree-header{display:flex;justify-content:space-between;align-items:center;align-self:stretch;padding:var(--treeview-header-padding);border-bottom:.5px solid var(--treeview-border-color);box-sizing:border-box}.tree-title{color:var(--treeview-content-color);font-size:var(--treeview-title-font-size);line-height:var(--treeview-title-line-height);font-weight:600;flex:1 1 auto;min-width:0}.tree-header--no-columns .tree-title{flex:1 1 auto}.nyx-treeview--no-columns .header-columns,.nyx-treeview--no-columns .node-columns{display:none}.nyx-treeview--no-columns .tree-header{padding-inline-end:var(--nyx-sizing-2, 16px)}.header-columns,.node-columns{display:flex;align-items:center;justify-content:flex-end;gap:var(--treeview-col-gap);flex-shrink:0}.header-columns{padding-inline-end:0}.nyx-treeview--virtual .header-columns{padding-inline-end:var(--treeview-scrollbar-gutter)}.col-cell{min-width:var(--treeview-col-width);width:var(--treeview-col-width);flex:0 0 auto;display:flex;justify-content:center;align-items:center;box-sizing:border-box}.header-columns ::slotted(nyx-icon){display:flex;justify-content:center;align-items:center;--nyx-icon-size: var(--treeview-header-icon-size);color:var(--treeview-content-color)}.tree-body{width:100%;display:flex;flex-direction:column}.node-wrapper{display:flex;flex-direction:column;width:100%}.node-row{--treeview-row-level: 0;display:flex;align-items:center;justify-content:space-between;min-height:var(--treeview-row-min-height);border-bottom:.5px solid var(--treeview-border-color);gap:var(--treeview-row-gap);padding:var(--treeview-row-padding);padding-left:calc(var(--treeview-indent-base) + var(--treeview-row-level) * var(--treeview-indent-step));box-sizing:border-box;background:transparent;color:var(--treeview-content-color);outline:none;cursor:default}.node-row:hover{background:var(--treeview-row-hover-background);color:var(--treeview-row-hover-color)}.node-row:focus-within{background:var(--treeview-row-hover-background)!important;color:var(--treeview-row-hover-color)!important}.node-row:hover .expander nyx-icon,.node-row:hover .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-hover-color)}.node-row:focus-within .expander nyx-icon,.node-row:focus-within .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-hover-color)}.node-row.selectable.selected{background-color:var(--treeview-row-selected-background);color:var(--treeview-row-selected-color)}.node-row.selectable.selected .expander nyx-icon,.node-row.selectable.selected .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-selected-color)}.node-row.selectable.selected:hover{background-color:var(--treeview-row-selected-hover-background);color:var(--treeview-row-selected-color)}.node-row.selectable.selected:focus-within{background-color:var(--treeview-row-selected-background)!important;color:var(--treeview-row-selected-color)!important}.node-row.selectable.selected:focus-within .expander nyx-icon,.node-row.selectable.selected:focus-within .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-selected-color)}.node-row.selectable.selected:hover:focus-within{background-color:var(--treeview-row-selected-hover-background)!important}.node-row:focus-visible{position:relative;z-index:2;outline:2px solid var(--treeview-focus-border-color);outline-offset:-3px;background:var(--treeview-row-hover-background)!important;color:var(--treeview-row-hover-color)}.row-checkbox{display:flex;align-items:center;margin-right:4px}.node-info{display:flex;align-items:center;gap:var(--treeview-node-gap);flex:1 0 0;overflow:hidden;min-height:32px;padding-left:4px}.expander{--button-icon-color: inherit;flex-shrink:0;width:var(--treeview-expander-wrapper-size);min-width:var(--treeview-expander-wrapper-size)}.expander-placeholder{display:block;flex-shrink:0;width:var(--treeview-expander-wrapper-size);min-width:var(--treeview-expander-wrapper-size);height:var(--treeview-expander-wrapper-size)}.expander nyx-icon{--nyx-icon-size: var(--treeview-expander-icon-size);transition:transform .2s ease;transform-origin:center}.expander nyx-icon.expanded{transform:rotate(90deg)}.expander:hover,.expander:focus-within{--button-icon-color: var(--treeview-content-color) !important}.expander:hover nyx-icon,.expander:focus-within nyx-icon{color:var(--treeview-content-color)!important;--nyx-icon-color: var(--treeview-content-color) !important}.node-row:hover .expander:hover,.node-row:hover .expander:focus-within{--button-icon-color: var(--treeview-row-hover-color) !important}.node-row:hover .expander:hover nyx-icon,.node-row:hover .expander:focus-within nyx-icon{color:var(--treeview-row-hover-color)!important;--nyx-icon-color: var(--treeview-row-hover-color) !important}.node-type-icon-wrapper{display:flex;align-items:center;justify-content:center;flex-shrink:0}.node-type-icon-wrapper ::slotted(nyx-icon){--nyx-icon-size: var(--treeview-node-icon-size)}.node-text{font-size:var(--treeview-text-font-size);line-height:var(--treeview-text-line-height);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-children{width:100%}@media(max-width:768px){.tree-scroll{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}.tree-header,.tree-body{min-width:calc(250px + ((var(--treeview-col-width) + var(--treeview-col-gap)) * var(--treeview-column-count)))}.node-text{white-space:normal;display:-webkit-box;line-clamp:2;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}}", ie = 200;
29
+ function I(n, e) {
30
+ const t = e.trim().toLowerCase();
31
+ return t ? n.toLowerCase().includes(t) : !1;
32
+ }
33
+ function R(n, e) {
34
+ return n.includes(e);
35
+ }
36
+ function k(n) {
37
+ var s;
38
+ const e = /* @__PURE__ */ new Map(), t = [], i = [];
39
+ for (let r = n.length - 1; r >= 0; r--)
40
+ i.push({ node: n[r], parentId: null });
41
+ for (; i.length > 0; ) {
42
+ const { node: r, parentId: o } = i.pop(), a = ((s = r.children) == null ? void 0 : s.map((d) => d.id)) ?? [];
43
+ if (e.set(r.id, {
44
+ id: r.id,
45
+ parentId: o,
46
+ normalizedLabel: r.label.toLowerCase(),
47
+ childIds: a,
48
+ hasChildren: a.length > 0
49
+ }), o === null && t.push(r.id), r.children)
50
+ for (let d = r.children.length - 1; d >= 0; d--)
51
+ i.push({ node: r.children[d], parentId: r.id });
35
52
  }
36
- updated(o) {
37
- const e = this.querySelector('[slot="field"]'), n = e instanceof HTMLInputElement && e.disabled;
38
- this.classList.toggle("disabled", n);
53
+ return { roots: t, byId: e, size: e.size };
54
+ }
55
+ function se(n) {
56
+ const e = [], t = [];
57
+ for (let i = n.roots.length - 1; i >= 0; i--)
58
+ t.push({ id: n.roots[i], visited: !1 });
59
+ for (; t.length > 0; ) {
60
+ const i = t[t.length - 1];
61
+ if (i.visited)
62
+ t.pop(), e.push(i.id);
63
+ else {
64
+ i.visited = !0;
65
+ const s = n.byId.get(i.id);
66
+ if (!s) continue;
67
+ for (let r = s.childIds.length - 1; r >= 0; r--)
68
+ t.push({ id: s.childIds[r], visited: !1 });
69
+ }
39
70
  }
40
- /** @internal */
41
- handleClick() {
42
- this.showPassword = !this.showPassword;
43
- const e = this.shadowRoot.querySelector("slot[name='field']").assignedElements({ flatten: !0 })[0];
44
- e && (e.type = this.showPassword ? "text" : "password");
71
+ return e;
72
+ }
73
+ function re(n, e, t) {
74
+ const i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
75
+ for (const o of se(n)) {
76
+ const a = n.byId.get(o);
77
+ if (!a) continue;
78
+ const d = R(
79
+ a.normalizedLabel,
80
+ e
81
+ );
82
+ let l = !1;
83
+ for (const p of a.childIds)
84
+ if (r.get(p)) {
85
+ l = !0;
86
+ break;
87
+ }
88
+ const c = d || l;
89
+ if (r.set(o, c), !c || (i.add(o), !a.hasChildren || !l)) continue;
90
+ let m = !1;
91
+ for (const p of a.childIds) {
92
+ const v = n.byId.get(p);
93
+ if (v && R(v.normalizedLabel, e)) {
94
+ m = !0;
95
+ break;
96
+ }
97
+ }
98
+ !t.has(o) && (!d || m) && s.add(o);
45
99
  }
46
- /** @internal */
47
- handleClear() {
48
- const e = this.shadowRoot.querySelector("slot[name='field']").assignedElements({ flatten: !0 })[0];
49
- e && (e.value = "");
100
+ return { visibleIds: i, expandIds: s };
101
+ }
102
+ function ne(n, e) {
103
+ const t = e.trim().toLowerCase();
104
+ if (!t) return 0;
105
+ const i = Array.isArray(n) ? k(n) : n;
106
+ let s = 0;
107
+ for (const r of i.byId.values())
108
+ R(r.normalizedLabel, t) && s++;
109
+ return s;
110
+ }
111
+ function oe(n, e, t = /* @__PURE__ */ new Set()) {
112
+ const i = e.trim().toLowerCase();
113
+ if (!i)
114
+ return { visibleIds: /* @__PURE__ */ new Set(), expandIds: /* @__PURE__ */ new Set() };
115
+ const s = Array.isArray(n) ? k(n) : n;
116
+ return re(s, i, t);
117
+ }
118
+ function U(n, e, t = "") {
119
+ const i = n.children ?? [], s = t.trim().toLowerCase();
120
+ return s ? i.filter(
121
+ (r) => e.has(r.id) || I(r.label, s)
122
+ ) : i.filter((r) => e.has(r.id));
123
+ }
124
+ function ae(n, e, t) {
125
+ const i = e.trim().toLowerCase();
126
+ if (!i) return !1;
127
+ const s = [n];
128
+ for (; s.length > 0; ) {
129
+ const r = s.pop();
130
+ for (const o of t(r) ?? []) {
131
+ if (I(o.label, i)) return !0;
132
+ s.push(o.id);
133
+ }
50
134
  }
51
- render() {
52
- const o = !!this.querySelector('[slot="iconLeft"]'), e = !!this.querySelector('[slot="iconRight"]'), n = {
53
- container: !0,
54
- small: this.size === "small",
55
- iconLeft: o,
56
- iconRight: e,
57
- passwordToggle: this.passwordToggle,
58
- clearable: this.clearable,
59
- rounded: this.border === "rounded"
60
- };
61
- return l`
62
- <div class=${$(n)}>
63
- <slot name="field"></slot>
64
- <slot name="iconLeft"></slot>
65
- <slot name="iconRight"></slot>
66
- <div class="password">
67
- <nyx-icon @click=${this.handleClick} svg=${this.showPassword ? W : V}></nyx-icon>
68
- </div>
69
- <div class="clear">
70
- <nyx-icon @click=${this.handleClear} svg=${G}></nyx-icon>
71
- </div>
72
- </div>
73
- `;
135
+ return !1;
136
+ }
137
+ function le(n, e, t) {
138
+ const i = [n];
139
+ for (; i.length > 0; ) {
140
+ const s = i.pop();
141
+ for (const r of t(s) ?? []) {
142
+ if (e.has(r.id)) return !0;
143
+ i.push(r.id);
144
+ }
74
145
  }
75
- };
76
- C.styles = m(oo);
77
- let h = C;
78
- w([
79
- a({ type: String, reflect: !0 })
80
- ], h.prototype, "size");
81
- w([
82
- a({ type: String, reflect: !0 })
83
- ], h.prototype, "border");
84
- w([
85
- a({ type: Boolean, reflect: !0 })
86
- ], h.prototype, "passwordToggle");
87
- w([
88
- a({ type: Boolean, reflect: !0 })
89
- ], h.prototype, "clearable");
90
- w([
91
- f()
92
- ], h.prototype, "showPassword");
93
- customElements.get("nyx-input") || customElements.define("nyx-input", h);
94
- const eo = ':host{--checkbox-container-gap: var(--nyx-sizing-1);--checkbox-container-color: var(--nyx-color-neutral-content-primary);--checkbox-container-font-family: var(--nyx-font-family-font-family);--checkbox-container-font-size: var(--nyx-label-medium-font-size);--checkbox-container-line-height: var(--nyx-label-medium-line-height);--checkbox-container-disabled-color: var(--nyx-color-neutral-content-disabled);--checkbox-background: var(--nyx-color-neutral-background-primary);--checkbox-border: 1px solid var(--nyx-color-neutral-border-primary);--checkbox-disabled-border: 1px solid var(--nyx-color-neutral-border-disable);--checkbox-hover-border: 1px solid var(--nyx-color-brand-border-hover);--checkbox-checked-background: var(--nyx-color-brand-background-default);--checkbox-background-hover: var(--nyx-color-neutral-content-primary-inverse);--checkbox-checked-color: var(--nyx-color-neutral-content-primary-inverse);--checkbox-checked-disabled-background: var(--nyx-color-neutral-background-disable);--checkbox-checked-disabled-color: var(--nyx-color-neutral-content-disabled);--checkbox-checked-hover-background: var(--nyx-color-brand-background-hover);box-sizing:border-box;display:inline-flex}*{box-sizing:inherit}::slotted(input[type="checkbox"]){position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.container{display:inline-flex;justify-content:center;align-items:center;gap:var(--checkbox-container-gap);color:var(--checkbox-container-color);font-family:var(--checkbox-container-font-family);font-size:var(--checkbox-container-font-size);font-style:normal;font-weight:400;line-height:var(--checkbox-container-line-height);cursor:pointer}.component-subtitle{color:var(--nyx-color-neutral-content-tertiary);font-family:var(--nyx-font-family-font-family);font-size:var(--nyx-paragraph-large-font-size);line-height:var(--nyx-paragraph-large-line-height);display:block;margin-top:-8px;margin-bottom:16px}.container[disabled]{color:var(--checkbox-container-disabled-color)}.container:focus-visible:not([disabled]),.container:focus-within:not([disabled]){outline:2px solid var(--checkbox-container-color);outline-offset:2px;border-radius:1px}.container:focus-visible .checkbox:not([disabled]),.container:focus-within .checkbox:not([disabled]){border:var(--checkbox-hover-border);background-color:var(--checkbox-background-hover)}.container:focus-visible .checkbox.checked:not([disabled]),.container:focus-visible .checkbox.indeterminate:not([disabled]),.container:focus-within .checkbox.checked:not([disabled]),.container:focus-within .checkbox.indeterminate:not([disabled]){background-color:var(--checkbox-checked-hover-background);border-color:transparent}.checkbox{display:inline-flex;gap:var(--checkbox-container-gap);padding:1px;justify-content:center;align-items:center;cursor:pointer;border-radius:4px;background-color:var(--checkbox-background);border:var(--checkbox-border)}.checkbox nyx-icon{opacity:0;--nyx-icon-size: var(--checkbox-container-font-size)}.checkbox.checked nyx-icon,.checkbox.indeterminate nyx-icon{opacity:1}.checkbox[disabled]{border:var(--checkbox-disabled-border);background-color:var(--checkbox-checked-disabled-background);color:var(--checkbox-checked-disabled-color);cursor:default}.container:hover .checkbox:not([disabled]){border:var(--checkbox-hover-border);background-color:var(--checkbox-background-hover)}.checkbox.checked,.checkbox.indeterminate{background-color:var(--checkbox-checked-background);color:var(--checkbox-checked-color);border:1px solid transparent}.checkbox[disabled].checked,.checkbox[disabled].indeterminate{border:var(--checkbox-disabled-border);background-color:var(--checkbox-checked-disabled-background);color:var(--checkbox-checked-disabled-color)}.container:hover .checkbox.checked:not([disabled]),.container:hover .checkbox.indeterminate:not([disabled]){background-color:var(--checkbox-checked-hover-background);border-color:transparent}';
95
- var no = Object.defineProperty, S = (c, o, e, n) => {
96
- for (var t = void 0, r = c.length - 1, i; r >= 0; r--)
97
- (i = c[r]) && (t = i(o, e, t) || t);
98
- return t && no(o, e, t), t;
99
- };
100
- const A = class A extends k {
101
- constructor() {
102
- super(...arguments), this.checked = !1, this.indeterminate = !1, this.disabled = !1;
146
+ return !1;
147
+ }
148
+ function z(n, e, t, i, s, r) {
149
+ return q(n, e, t) && !le(i, s, r) && !ae(i, e, r);
150
+ }
151
+ function q(n, e, t) {
152
+ return I(n, e) && !t;
153
+ }
154
+ function H(n, e, t, i) {
155
+ return t || q(n, e, i);
156
+ }
157
+ function E(n, e) {
158
+ var t, i;
159
+ if (e) {
160
+ if (n.selected) return !0;
161
+ } else if ((((t = n.selectedColumns) == null ? void 0 : t.length) ?? 0) > 0)
162
+ return !0;
163
+ return ((i = n.children) == null ? void 0 : i.some(
164
+ (s) => E(s, e)
165
+ )) ?? !1;
166
+ }
167
+ function O(n, e) {
168
+ const t = n.map((i, s) => ({ node: i, index: s }));
169
+ return t.sort((i, s) => {
170
+ const r = E(i.node, e), o = E(s.node, e);
171
+ return r !== o ? r ? -1 : 1 : i.index - s.index;
172
+ }), t.map(({ node: i }) => {
173
+ var s;
174
+ return (s = i.children) != null && s.length ? {
175
+ ...i,
176
+ children: O(i.children, e)
177
+ } : i;
178
+ });
179
+ }
180
+ const x = 50, de = 2;
181
+ function ce(n) {
182
+ const e = [], t = n.map((s) => ({ node: s, depth: 0, parentId: null }));
183
+ let i = 0;
184
+ for (; i < t.length; ) {
185
+ const s = t[i++], { node: r, depth: o, parentId: a } = s, d = !!(r.children && r.children.length > 0);
186
+ if (e.push({
187
+ id: r.id,
188
+ depth: o,
189
+ parentId: a,
190
+ hasChildrenInSource: d
191
+ }), d)
192
+ for (const l of r.children)
193
+ t.push({ node: l, depth: o + 1, parentId: r.id });
103
194
  }
104
- updated(o) {
105
- super.updated(o);
106
- const e = this._slottedInputs[0];
107
- e && (o.has("checked") && e.checked !== this.checked && (e.checked = this.checked), o.has("disabled") && (e.disabled = this.disabled, this.disabled ? e.setAttribute("tabindex", "-1") : e.removeAttribute("tabindex")));
195
+ return e;
196
+ }
197
+ function he(n, e = x, t = de) {
198
+ const i = /* @__PURE__ */ new Set();
199
+ for (const s of n)
200
+ if (!(s.depth > t) && (i.add(s.id), i.size >= e))
201
+ break;
202
+ return i;
203
+ }
204
+ function ue(n, e = x) {
205
+ const t = /* @__PURE__ */ new Set();
206
+ for (const i of n)
207
+ if (i.depth === 0 && (t.add(i.id), t.size >= e))
208
+ break;
209
+ return t;
210
+ }
211
+ function _e(n, e, t) {
212
+ const i = [];
213
+ for (const s of n)
214
+ if (s.depth === 0 && !e.has(s.id) && (i.push(s.id), i.length >= t))
215
+ break;
216
+ return i;
217
+ }
218
+ function fe(n, e) {
219
+ return n.some((t) => t.depth === 0 && !e.has(t.id));
220
+ }
221
+ function L(n, e, t) {
222
+ return T(e, n).some((i) => !t.has(i));
223
+ }
224
+ function V(n, e) {
225
+ if (!n) return;
226
+ let t = n.node.id, i = e.get(t);
227
+ for (; (i == null ? void 0 : i.parentId) != null; )
228
+ t = i.parentId, i = e.get(t);
229
+ return t;
230
+ }
231
+ function pe(n, e, t, i, s, r) {
232
+ const o = Math.min(
233
+ Math.max(0, e),
234
+ Math.max(0, n.length - 1)
235
+ );
236
+ for (let a = o; a >= 0; a--) {
237
+ const d = n[a];
238
+ if (t.has(d.node.id) && L(d.node.id, i, s))
239
+ return V(d, r);
108
240
  }
109
- _toggleCheck() {
110
- if (this.disabled) return;
111
- this.checked = !this.checked, this.indeterminate = !1;
112
- const o = this._slottedInputs[0];
113
- o && (o.checked = this.checked, o.dispatchEvent(new Event("change", { bubbles: !0 })));
241
+ return V(n[o], r);
242
+ }
243
+ function we(n, e) {
244
+ const t = [];
245
+ let i = e.get(n);
246
+ for (; (i == null ? void 0 : i.parentId) != null; )
247
+ t.push(i.parentId), i = e.get(i.parentId);
248
+ return t;
249
+ }
250
+ function P(n, e, t, i) {
251
+ const s = [], r = (o) => {
252
+ s.length >= t || !e.has(o) && !s.includes(o) && s.push(o);
253
+ };
254
+ if (i != null) {
255
+ const o = T(n, i);
256
+ for (const a of o) r(a);
114
257
  }
115
- render() {
116
- const o = {
117
- checkbox: !0,
118
- checked: this.checked,
119
- indeterminate: this.indeterminate,
120
- disabled: this.disabled
121
- };
122
- return l`
123
- <div class="container" ?disabled=${this.disabled} @click=${this._toggleCheck}>
124
- <div class=${$(o)} ?disabled=${this.disabled}>
125
- <nyx-icon svg=${this.checked ? j : this.indeterminate ? J : j}></nyx-icon>
126
- </div>
127
- <slot name="input"></slot>
128
- <slot></slot>
129
- </div>
130
- `;
258
+ for (const o of n)
259
+ if (r(o.id), s.length >= t) break;
260
+ return s;
261
+ }
262
+ function T(n, e) {
263
+ const t = /* @__PURE__ */ new Map();
264
+ for (const r of n) {
265
+ const o = r.parentId;
266
+ t.has(o) || t.set(o, []), t.get(o).push(r.id);
131
267
  }
268
+ const i = [], s = [e];
269
+ for (; s.length > 0; ) {
270
+ const r = s.pop();
271
+ i.push(r);
272
+ const o = t.get(r);
273
+ if (o != null && o.length)
274
+ for (let a = o.length - 1; a >= 0; a--)
275
+ s.push(o[a]);
276
+ }
277
+ return i;
278
+ }
279
+ function me(n, e, t) {
280
+ return T(n, e).filter((i) => !t.has(i));
281
+ }
282
+ function ve(n, e, t, i = x) {
283
+ return me(n, e, t).slice(0, i);
284
+ }
285
+ function A(n) {
286
+ var e;
287
+ return {
288
+ ...n,
289
+ selectedColumns: n.selectedColumns ? [...n.selectedColumns] : void 0,
290
+ disabledColumns: n.disabledColumns ? [...n.disabledColumns] : void 0,
291
+ children: (e = n.children) == null ? void 0 : e.map((t) => A(t)),
292
+ data: n.data
293
+ };
294
+ }
295
+ function xe(n) {
296
+ const e = /* @__PURE__ */ new Map(), t = (i) => {
297
+ var s;
298
+ e.set(i.id, i), (s = i.children) == null || s.forEach(t);
299
+ };
300
+ return n.forEach(t), e;
301
+ }
302
+ function be(n, e, t) {
303
+ const i = (s) => {
304
+ if (!e.has(s.id)) return null;
305
+ const r = t.get(s.id) ?? s, o = (r.children ?? []).map((d) => i(d)).filter((d) => d !== null), a = A(r);
306
+ return a.children = o.length > 0 ? o : void 0, a;
307
+ };
308
+ return n.map((s) => i(s)).filter((s) => s !== null);
309
+ }
310
+ function F(n) {
311
+ const e = [], t = n.searchTerm.trim().toLowerCase(), i = (s, r, o, a, d = !1) => {
312
+ const l = n.hasSearch && !d ? s.filter((c) => n.searchVisibleIds.has(c.id)) : s;
313
+ for (const c of l) {
314
+ const m = n.hasSearch && !!t && c.label.toLowerCase().includes(t), p = H(
315
+ c.label,
316
+ t,
317
+ o,
318
+ a
319
+ ), v = a || !!m;
320
+ if (e.push({
321
+ node: c,
322
+ level: r,
323
+ revealSubtree: p,
324
+ parentLabelMatched: v,
325
+ hasChildrenInSource: n.sourceHasChildren(c.id)
326
+ }), !n.expandedIds.has(c.id)) continue;
327
+ const M = n.getSourceChildren ?? ((C) => {
328
+ var D;
329
+ return (D = n.items.find((W) => W.id === C)) == null ? void 0 : D.children;
330
+ }), g = !n.hasSearch || p && z(
331
+ c.label,
332
+ t,
333
+ a,
334
+ c.id,
335
+ n.searchVisibleIds,
336
+ M
337
+ ) ? c.children ?? [] : U(
338
+ c,
339
+ n.searchVisibleIds,
340
+ n.searchTerm
341
+ );
342
+ g.length > 0 && i(g, r + 1, p, v, !0);
343
+ }
344
+ };
345
+ return i(n.items, 0, !1, !1), e;
346
+ }
347
+ function y(n, e) {
348
+ for (const t of n)
349
+ if (!e.has(t)) return !0;
350
+ return !1;
351
+ }
352
+ function j(n, e, t, i = x) {
353
+ const s = [], r = (o) => {
354
+ s.length >= i || !e.has(o) && !s.includes(o) && s.push(o);
355
+ };
356
+ for (const o of n)
357
+ if (!e.has(o)) {
358
+ r(o);
359
+ for (const a of we(o, t))
360
+ r(a);
361
+ if (s.length >= i) break;
362
+ }
363
+ return s;
364
+ }
365
+ function B(n, e, t, i = x) {
366
+ const s = j(
367
+ n,
368
+ e,
369
+ t,
370
+ i
371
+ );
372
+ return s.length === 0 ? !1 : (s.forEach((r) => e.add(r)), !0);
373
+ }
374
+ function ge(n, e) {
375
+ return e ? `Collapse ${n}` : `Expand ${n}`;
376
+ }
377
+ function ye(n) {
378
+ return `Select ${n}`;
379
+ }
380
+ function Ie(n, e) {
381
+ return `${n}, ${e}`;
382
+ }
383
+ function Se(n) {
384
+ return n === 0 ? "No results found" : n === 1 ? "1 result found" : `${n} results found`;
385
+ }
386
+ var Ce = Object.defineProperty, Re = Object.getOwnPropertyDescriptor, _ = (n, e, t, i) => {
387
+ for (var s = i > 1 ? void 0 : i ? Re(e, t) : e, r = n.length - 1, o; r >= 0; r--)
388
+ (o = n[r]) && (s = (i ? o(e, t, s) : o(s)) || s);
389
+ return i && s && Ce(e, t, s), s;
132
390
  };
133
- A.styles = m(eo);
134
- let x = A;
135
- S([
136
- a({ type: Boolean, reflect: !0 })
137
- ], x.prototype, "checked");
138
- S([
139
- a({ type: Boolean, reflect: !0 })
140
- ], x.prototype, "indeterminate");
141
- S([
142
- a({ type: Boolean, reflect: !0 })
143
- ], x.prototype, "disabled");
144
- S([
145
- M({ slot: "input" })
146
- ], x.prototype, "_slottedInputs");
147
- customElements.get("nyx-checkbox") || customElements.define("nyx-checkbox", x);
148
- const ro = ":host{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;font-size:var(--nyx-icon-size, 1rem);color:var(--nyx-icon-color, currentColor)}*{box-sizing:inherit}.component-subtitle{color:var(--nyx-color-neutral-content-tertiary);font-family:var(--nyx-font-family-font-family);font-size:var(--nyx-paragraph-large-font-size);line-height:var(--nyx-paragraph-large-line-height);display:block;margin-top:-8px;margin-bottom:16px}::slotted(svg),svg{width:var(--nyx-icon-size, 1rem);height:var(--nyx-icon-size, 1rem);fill:currentColor}i{font-size:inherit;color:inherit}";
149
- var io = Object.defineProperty, _ = (c, o, e, n) => {
150
- for (var t = void 0, r = c.length - 1, i; r >= 0; r--)
151
- (i = c[r]) && (t = i(o, e, t) || t);
152
- return t && io(o, e, t), t;
153
- };
154
- const E = class E extends k {
391
+ const $ = class $ extends Z {
155
392
  constructor() {
156
- super(...arguments), this.variant = "solid";
393
+ super(...arguments), this._items = [], this._expandedIds = /* @__PURE__ */ new Set(), this._searchTerm = "", this._searchStatusMessage = "", this._searchVisibleIds = /* @__PURE__ */ new Set(), this._searchUserCollapsedIds = /* @__PURE__ */ new Set(), this._searchManualExpandedIds = /* @__PURE__ */ new Set(), this._expandedIdsBeforeSearch = null, this._flatRows = [], this._loadedIds = /* @__PURE__ */ new Set(), this._activeRowId = null, this._sourceItems = [], this._lazyItemsSourceRef = null, this._treeIndex = [], this._indexById = /* @__PURE__ */ new Map(), this._sourceById = /* @__PURE__ */ new Map(), this._lazyScrollLoading = !1, this._searchIndex = null, this._searchIndexSourceRef = null, this._searchDebounceTimer = null;
157
394
  }
158
- /**
159
- * Watches for property changes and loads the SVG if `src` changes.
160
- * @param changedProperties Properties that have been changed.
161
- */
162
- async updated(o) {
163
- o.has("src") && this.src && await this.loadSvg();
395
+ get options() {
396
+ return this._options;
397
+ }
398
+ set options(e) {
399
+ const t = this._options;
400
+ t !== e && (this._options = e, e && (this._applyOptionsChange(), this._generateLightDomIcons()), this.requestUpdate("options", t));
401
+ }
402
+ _isLazyEnabled() {
403
+ var e;
404
+ return !!((e = this.options) != null && e.lazyLoad);
405
+ }
406
+ _getLazyPageSize() {
407
+ var t;
408
+ const e = (t = this.options) == null ? void 0 : t.lazyLoadPageSize;
409
+ return e == null || !Number.isFinite(e) ? x : Math.max(1, Math.floor(e));
410
+ }
411
+ _hasColumnPermissions() {
412
+ var e, t, i;
413
+ return ((e = this.options) == null ? void 0 : e.showColumnPermissions) === !1 ? !1 : (((i = (t = this.options) == null ? void 0 : t.columns) == null ? void 0 : i.length) ?? 0) > 0;
414
+ }
415
+ _showRowSelection() {
416
+ var e;
417
+ return !!((e = this.options) != null && e.showRowSelection);
418
+ }
419
+ _showNodeIcons() {
420
+ var e;
421
+ return ((e = this.options) == null ? void 0 : e.showNodeIcons) !== !1;
422
+ }
423
+ _usesSimpleRowSelection() {
424
+ return this._showRowSelection() && !this._hasColumnPermissions();
425
+ }
426
+ _applyItemsFromOptions(e) {
427
+ var i;
428
+ let t = e.map((s) => A(s));
429
+ return (i = this.options) != null && i.sortSelectedFirst && (t = O(t, this._usesSimpleRowSelection())), t;
430
+ }
431
+ _applyOptionsChange() {
432
+ if (this.options) {
433
+ if (this._isLazyEnabled()) {
434
+ this.options.items !== this._lazyItemsSourceRef && (this._initLazyState(), this._resetSearchDerivedState(), this._searchTerm.trim() && this._recomputeSearchFilter());
435
+ return;
436
+ }
437
+ if (this._items = this._applyItemsFromOptions(this.options.items), this._invalidateSearchIndex(), this._activeRowId = null, this._resetSearchDerivedState(), this._searchTerm.trim()) {
438
+ this._recomputeSearchFilter();
439
+ return;
440
+ }
441
+ this.options.defaultExpandedLevel !== void 0 && this._expandedIds.size === 0 && this._expandToLevel(
442
+ this._items,
443
+ 0,
444
+ this.options.defaultExpandedLevel
445
+ ), this._syncActiveRowWithVisibleRows();
446
+ }
447
+ }
448
+ _initLazyState() {
449
+ var i;
450
+ this._lazyItemsSourceRef = this.options.items, this._sourceItems = this._applyItemsFromOptions(this.options.items), this._invalidateSearchIndex(), this._treeIndex = ce(this._sourceItems), this._indexById = new Map(this._treeIndex.map((s) => [s.id, s])), this._sourceById = xe(this._sourceItems);
451
+ const e = (i = this.options) == null ? void 0 : i.defaultExpandedLevel, t = this._getLazyPageSize();
452
+ this._loadedIds = e !== void 0 && e > 0 ? he(this._treeIndex, t) : ue(this._treeIndex, t), this._expandedIds = /* @__PURE__ */ new Set(), this._activeRowId = null, this._rebuildMaterializedItems(), e !== void 0 && e > 0 && this._applyLazyInitialExpansion(e), this._commitLazyRows();
164
453
  }
165
454
  /**
166
- * @private
167
- * Loads an external SVG file and stores its contents.
455
+ * Expands only nodes already present in the materialized tree.
456
+ * Further rows appear as lazy load + scroll bring more ids into `_items`.
168
457
  */
169
- async loadSvg() {
170
- if (this.src)
171
- try {
172
- const o = await fetch(this.src);
173
- if (!o.ok)
174
- throw new Error("Error on load SVG.");
175
- this._svgContentImported = await o.text();
176
- } catch (o) {
177
- this.dispatchEvent(new CustomEvent("nyx-icon-load-error", {
178
- detail: {
179
- src: this.src,
180
- message: o instanceof Error ? o.message : String(o)
181
- },
182
- bubbles: !0,
183
- composed: !0
184
- }));
185
- }
458
+ _applyLazyInitialExpansion(e) {
459
+ this._expandToLevel(this._items, 0, e), this._expandedIds = new Set(this._expandedIds);
186
460
  }
187
- render() {
188
- if (this.svg)
189
- return l`${B(this.svg)}`;
190
- if (this.src)
191
- return l`${B(this._svgContentImported)}`;
192
- const o = [`fa-${this.name}`];
193
- this.variant && o.push(...this.variant.split(" ").map((n) => `fa-${n}`));
194
- const e = document.createElement("i");
195
- return e.className = o.join(" "), this.shadowRoot.host.innerHTML = "", this.shadowRoot.host.appendChild(e), l`<slot></slot>`;
461
+ _rebuildMaterializedItems() {
462
+ this._items = be(
463
+ this._sourceItems,
464
+ this._loadedIds,
465
+ this._sourceById
466
+ );
196
467
  }
197
- };
198
- E.styles = m(ro);
199
- let v = E;
200
- _([
201
- a({ type: String })
202
- ], v.prototype, "name");
203
- _([
204
- a({ type: String })
205
- ], v.prototype, "variant");
206
- _([
207
- a({ type: String })
208
- ], v.prototype, "src");
209
- _([
210
- a({ type: String })
211
- ], v.prototype, "svg");
212
- _([
213
- f()
214
- ], v.prototype, "_svgContentImported");
215
- customElements.get("nyx-icon") || customElements.define("nyx-icon", v);
216
- const ao = ":host{--button-padding: var(--nyx-sizing-2);--button-gap: var(--nyx-sizing-1);--button-border-radius: var(--nyx-radii-2xs);--button-color: var(--nyx-color-neutral-content-always-white);--button-font-family: var(--nyx-font-family-font-family);--button-font-size: var(--nyx-label-medium-font-size);--button-line-height: var(--nyx-label-medium-line-height);--button-small-padding: var(--nyx-sizing-1-25);--button-small-font-size: var(--nyx-label-medium-font-size);--button-small-line-height: var(--nyx-label-medium-line-height);--button-medium-padding: var(--nyx-sizing-1-5);--button-brand-background: var(--nyx-color-brand-background-default);--button-warning-background: var(--nyx-color-warning-background-default);--button-danger-background: var(--nyx-color-danger-background-default);--button-info-background: var(--nyx-color-info-background-default);--button-success-background: var(--nyx-color-success-background-default);--button-brand-background-hover: var(--nyx-color-brand-background-hover);--button-warning-background-hover: var(--nyx-color-warning-background-hover);--button-danger-background-hover: var(--nyx-color-danger-background-hover);--button-info-background-hover: var(--nyx-color-info-background-hover);--button-success-background-hover: var(--nyx-color-success-background-hover);--button-neutral-background-hover: var(--nyx-color-neutral-background-hover);--button-brand-background-active: var(--nyx-color-brand-background-strong);--button-warning-background-active: var(--nyx-color-warning-background-strong);--button-danger-background-active: var(--nyx-color-danger-background-strong);--button-info-background-active: var(--nyx-color-info-background-strong);--button-success-background-active: var(--nyx-color-success-background-strong);--button-color-inverse: var(--nyx-color-neutral-content-primary-inverse);--button-disabled-background: var(--nyx-color-neutral-background-disable);--button-disabled-color: var(--nyx-color-neutral-content-disabled);--button-outline-border: 1px solid var(--nyx-color-neutral-border-primary);--button-outline-color: var(--nyx-color-neutral-content-primary);--button-outline-background: var(--nyx-color-neutral-background-primary);--button-outline-danger-border: 1px solid var(--nyx-color-danger-border-default);--button-outline-danger-color: var(--nyx-color-danger-content-default);--button-outline-warning-border: 1px solid var(--nyx-color-warning-border-default);--button-outline-warning-color: var(--nyx-color-warning-content-default);--button-outline-info-border: 1px solid var(--nyx-color-info-border-default);--button-outline-info-color: var(--nyx-color-info-content-default);--button-outline-success-border: 1px solid var(--nyx-color-success-border-default);--button-outline-success-color: var(--nyx-color-success-content-default);--button-outline-background-hover: var(--nyx-color-neutral-background-hover);--button-outline-border-hover: 1px solid var(--nyx-color-neutral-border-primary);--button-outline-color-hover: var(--nyx-color-neutral-content-primary);--button-outline-danger-background-hover: var(--nyx-color-danger-background-softer-hover);--button-outline-danger-border-hover: 1px solid var(--nyx-color-danger-border-softer);--button-outline-danger-color-hover: var(--nyx-color-danger-content-strong);--button-outline-warning-background-hover: var(--nyx-color-warning-background-softer-hover);--button-outline-warning-border-hover: 1px solid var(--nyx-color-warning-border-softer);--button-outline-warning-color-hover: var(--nyx-color-warning-content-strong);--button-outline-info-background-hover: var(--nyx-color-info-background-softer-hover);--button-outline-info-border-hover: 1px solid var(--nyx-color-info-border-softer);--button-outline-info-color-hover: var(--nyx-color-info-content-default);--button-outline-success-background-hover: var(--nyx-color-success-background-softer-hover);--button-outline-success-border-hover: 1px solid var(--nyx-color-success-border-softer);--button-outline-success-color-hover: var(--nyx-color-success-content-strong);--button-outline-background-active: var(--nyx-color-neutral-background-active);--button-outline-color-active: var(--nyx-color-neutral-content-primary);--button-outline-warning-background-active: var(--nyx-color-warning-background-strong);--button-outline-warning-color-active: var(--nyx-color-neutral-content-always-white);--button-outline-danger-background-active: var(--nyx-color-danger-background-strong);--button-outline-danger-color-active: var(--nyx-color-neutral-content-always-white);--button-outline-info-background-active: var(--nyx-color-info-background-strong);--button-outline-info-color-active: var(--nyx-color-neutral-content-always-white);--button-outline-success-background-active: var(--nyx-color-success-background-strong);--button-outline-success-color-active: var(--nyx-color-neutral-content-always-white);--button-outline-disabled-color: var(--nyx-color-neutral-content-disabled);--button-outline-disabled-border: 1px solid var(--nyx-color-neutral-border-disable);--button-ghost-color: var(--nyx-color-neutral-content-primary);--button-ghost-warning-color: var(--nyx-color-warning-content-default);--button-ghost-danger-color: var(--nyx-color-danger-content-default);--button-ghost-info-color: var(--nyx-color-info-content-default);--button-ghost-success-color: var(--nyx-color-success-content-default);--button-ghost-background: transparent;--button-ghost-neutral-color-hover: var(--nyx-color-neutral-content-tertiary);--button-ghost-warning-color-hover: var(--nyx-color-warning-content-hover);--button-ghost-danger-color-hover: var(--nyx-color-danger-content-hover);--button-ghost-info-color-hover: var(--nyx-color-info-content-hover);--button-ghost-success-color-hover: var(--nyx-color-success-content-hover);--button-ghost-neutral-color-active: var(--nyx-color-neutral-content-secondary);--button-ghost-warning-color-active: var(--nyx-color-warning-content-strong);--button-ghost-danger-color-active: var(--nyx-color-danger-content-strong);--button-ghost-info-color-active: var(--nyx-color-info-content-strong);--button-ghost-success-color-active: var(--nyx-color-success-content-strong);--button-loading-line-height: calc(var(--nyx-label-medium-line-height) - 4px);--button-icon-background-hover: var(--nyx-color-brand-background-softer-hover);--button-icon-border-hover: 1px solid var(--nyx-color-brand-border-hover);--button-icon-color-disabled: var(--nyx-color-neutral-content-disabled);--button-icon-border-disabled: 1px solid var(--nyx-color-neutral-border-disable);--button-icon-border-with-border: 1px solid var(--nyx-color-neutral-border-active);--button-icon-border-radius-with-border: var(--nyx-radii-2xs);--button-icon-color: var(--nyx-color-neutral-content-primary);--button-icon-border-radius: var(--nyx-radii-100);--button-icon-small-icon-font-size: var(--nyx-label-small-font-size);--button-icon-medium-icon-font-size: var(--nyx-label-medium-font-size);--button-icon-large-icon-font-size: var(--nyx-heading-h6-font-size);--button-icon-xlarge-icon-font-size: var(--nyx-heading-h4-font-size);box-sizing:border-box;display:inline-flex}:host([block]){width:100%}*{box-sizing:inherit}button.brand:not([disabled]):not(.loading):hover,button.brand:not([disabled]):not(.loading):active,button.warning:not([disabled]):not(.loading):hover,button.warning:not([disabled]):not(.loading):active,button.danger:not([disabled]):not(.loading):hover,button.danger:not([disabled]):not(.loading):active,button.info:not([disabled]):not(.loading):hover,button.info:not([disabled]):not(.loading):active,button.success:not([disabled]):not(.loading):hover,button.success:not([disabled]):not(.loading):active{color:var(--button-color-inverse)}button{display:inline-flex;padding:var(--button-padding);align-items:center;justify-content:center;gap:var(--button-gap);border-radius:var(--button-border-radius);color:var(--button-color);cursor:pointer;border:none;text-align:center;font-family:var(--button-font-family);font-size:var(--button-font-size);font-style:normal;font-weight:600;line-height:var(--button-line-height)}.component-subtitle{color:var(--nyx-color-neutral-content-tertiary);font-family:var(--nyx-font-family-font-family);font-size:var(--nyx-paragraph-large-font-size);line-height:var(--nyx-paragraph-large-line-height);display:block;margin-top:-8px;margin-bottom:16px}button.icon-right{flex-direction:row-reverse}button.small{padding:var(--button-small-padding);font-size:var(--button-small-font-size);line-height:var(--button-small-line-height)}button.medium{padding:var(--button-medium-padding)}button.block{width:100%}button.brand{background-color:var(--button-brand-background)}button.warning{background-color:var(--button-warning-background)}button.danger{background-color:var(--button-danger-background)}button.info{background-color:var(--button-info-background)}button.success{background-color:var(--button-success-background)}button.ghost{color:var(--button-ghost-color);background-color:var(--button-ghost-background)}button.ghost.danger{color:var(--button-ghost-danger-color);background-color:var(--button-ghost-background)}button.ghost.warning{color:var(--button-ghost-warning-color);background-color:var(--button-ghost-background)}button.ghost.info{color:var(--button-ghost-info-color);background-color:var(--button-ghost-background)}button.ghost.success{color:var(--button-ghost-success-color);background-color:var(--button-ghost-background)}button.brand:not([disabled]):not(.loading):hover{background-color:var(--button-brand-background-hover);color:var(--button-color-inverse)}button.warning:not([disabled]):not(.loading):hover{background-color:var(--button-warning-background-hover);color:var(--button-color-inverse)}button.danger:not([disabled]):not(.loading):hover{background-color:var(--button-danger-background-hover);color:var(--button-color-inverse)}button.info:not([disabled]):not(.loading):hover{background-color:var(--button-info-background-hover);color:var(--button-color-inverse)}button.outline:not([disabled]):not(.loading):hover{background-color:var(--button-success-background-hover);color:var(--button-color-inverse)}button.brand:not([disabled]):not(.loading):active{background-color:var(--button-brand-background-active)}button.warning:not([disabled]):not(.loading):active{background-color:var(--button-warning-background-active)}button.danger:not([disabled]):not(.loading):active{background-color:var(--button-danger-background-active)}button.info:not([disabled]):not(.loading):active{background-color:var(--button-info-background-active)}button.success:not([disabled]):not(.loading):active{background-color:var(--button-success-background-active)}button.outline:not([disabled]):not(.loading):active{background-color:var(--button-outline-background-active);color:var(--button-outline-color-active)}button.outline.warning:not([disabled]):not(.loading):active{background-color:var(--button-outline-warning-background-active);color:var(--button-outline-warning-background-active)}button.outline.danger:not([disabled]):not(.loading):active{background-color:var(--button-outline-danger-background-active);color:var(--button-outline-danger-background-active)}button.outline.info:not([disabled]):not(.loading):active{background-color:var(--button-outline-info-background-active);color:var(--button-outline-info-background-active)}button.outline.success:not([disabled]):not(.loading):active{background-color:var(--button-outline-success-background-active);color:var(--button-outline-success-background-active)}button.ghost:not([disabled]):not(.loading):active{background-color:var(--button-ghost-background-active);color:var(--button-ghost-neutral-color-active)}button.ghost.warning:not([disabled]):not(.loading):active{background-color:var(--button-warning-background-active);color:var(--button-ghost-warning-color-active)}button.ghost.danger:not([disabled]):not(.loading):active{background-color:var(--button-danger-background-active);color:var(--button-ghost-danger-color-active)}button.ghost.info:not([disabled]):not(.loading):active{background-color:var(--button-info-background-active);color:var(--button-ghost-info-color-active)}button.ghost.success:not([disabled]):not(.loading):active{background-color:var(--button-success-background-active);color:var(--button-ghost-success-color-active)}button:disabled{background:var(--button-disabled-background);color:var(--button-disabled-color);cursor:default}button.outline{background-color:transparent;border:var(--button-outline-border);color:var(--button-outline-color)}button.outline.danger{color:var(--button-outline-danger-color)}button.outline.warning{color:var(--button-outline-warning-color)}button.outline.info{color:var(--button-outline-info-color)}button.outline.success{color:var(--button-outline-success-color)}button.outline:not([disabled]):not(.loading):hover{background-color:var(--button-outline-background-hover);border:var(--button-outline-border-hover);color:var(--button-outline-color)}button.outline.danger:not([disabled]):not(.loading):hover{background-color:var(--button-outline-danger-background-hover);border:var(--button-outline-danger-border-hover);color:var(--button-outline-danger-color-hover)}button.outline.warning:not([disabled]):not(.loading):hover{background-color:var(--button-outline-warning-background-hover);border:var(--button-outline-warning-border-hover);color:var(--button-outline-warning-color-hover)}button.outline.info:not([disabled]):not(.loading):hover{background-color:var(--button-outline-info-background-hover);border:var(--button-outline-info-border-hover);color:var(--button-outline-info-color-hover)}button.outline.success:not([disabled]):not(.loading):hover{background-color:var(--button-outline-success-background-hover);border:var(--button-outline-success-border-hover);color:var(--button-outline-success-color-hover)}button.outline:disabled{border:1px solid var(--nyx-color-neutral-border-disable);background:var(--nyx-color-neutral-background-primary)}button.ghost{background-color:transparent;border:none;color:var(--button-ghost-color)}button.ghost.info{color:var(--button-ghost-info-color);background-color:transparent}button.ghost.danger{color:var(--button-ghost-danger-color);background-color:transparent}button.ghost.warning{color:var(--button-ghost-warning-color);background-color:transparent}button.ghost.success{color:var(--button-ghost-success-color);background-color:transparent}button.ghost:not([disabled]):not(.loading):hover{background-color:var(--button-ghost-background);color:var(--button-ghost-color)}button.ghost.danger:not([disabled]):not(.loading):hover{background-color:var(--button-ghost-background);color:var(--button-ghost-danger-color-hover)}button.ghost.warning:not([disabled]):not(.loading):hover{background-color:var(--button-ghost-background);color:var(--button-ghost-warning-color-hover)}button.ghost.info:not([disabled]):not(.loading):hover{background-color:var(--button-ghost-background);color:var(--button-ghost-info-color-hover)}button.ghost.success:not([disabled]):not(.loading):hover{background-color:var(--button-ghost-background);color:var(--button-ghost-success-color-hover)}button.ghost:disabled{background-color:var(--button-ghost-background);color:var(--button-disabled-color)}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.loading nyx-icon{animation:spin 1s linear infinite}button.loading{cursor:default;line-height:var(--button-loading-line-height)}button.button-icon{display:flex;justify-content:center;align-items:center;flex-shrink:0;border-radius:var(--button-icon-border-radius);align-self:stretch;border:none;cursor:pointer;background-color:transparent;color:var(--button-icon-color);text-align:center}button.button-icon:not([disabled]):hover{background-color:var(--button-icon-background-hover)!important}button.button-icon.neutral:not([disabled]):hover{background-color:var(--button-neutral-background-hover)!important}button.button-icon[disabled]{color:var(--button-icon-color-disabled);cursor:default}button:focus-visible,button:focus-within{outline:2px solid var(--button-outline-color);outline-offset:2px}button.brand:focus-visible,button.brand:focus-within{background-color:var(--button-brand-background-hover)}button.warning:focus-visible,button.warning:focus-within{background-color:var(--button-warning-background-hover)}button.danger:focus-visible,button.danger:focus-within{background-color:var(--button-danger-background-hover)}button.info:focus-visible,button.info:focus-within{background-color:var(--button-info-background-hover)}button.success:focus-visible,button.success:focus-within{background-color:var(--button-success-background-hover)}button.ghost:focus-visible,button.ghost:focus-within{background-color:var(--button-ghost-background-hover);color:var(--button-ghost-color)}button.ghost.danger:focus-visible,button.ghost.danger:focus-within{background-color:var(--button-ghost-background-hover);color:var(--button-ghost-danger-color-hover)}button.ghost.info:focus-visible,button.ghost.info:focus-within{background-color:var(--button-ghost-background-hover);color:var(--button-ghost-info-color-hover)}button.ghost.success:focus-visible,button.ghost.success:focus-within{background-color:var(--button-ghost-background-hover);color:var(--button-ghost-success-color-hover)}button.ghost.warning:focus-visible,button.ghost.warning:focus-within{background-color:var(--button-ghost-background-hover);color:var(--button-ghost-warning-color-hover)}button.outline:focus-visible,button.outline:focus-within{background-color:var(--button-outline-background-hover)}button.outline.danger:focus-visible,button.outline.danger:focus-within{background-color:var(--button-outline-danger-background-hover)}button.outline.warning:focus-visible,button.outline.warning:focus-within{background-color:var(--button-outline-warning-background-hover)}button.outline.info:focus-visible,button.outline.info:focus-within{background-color:var(--button-outline-info-background-hover)}button.outline.success:focus-visible,button.outline.success:focus-within{background-color:var(--button-outline-success-background-hover)}button.button-icon:focus-visible,button.button-icon:focus-within{background-color:var( --button-icon-background-focus, var(--button-icon-background-hover) )!important}button.button-icon.neutral:focus-visible,button.button-icon.neutral:focus-within{background-color:var( --button-icon-background-focus, var(--button-neutral-background-hover) )!important}:host(.active) button.button-icon:not([disabled]){background-color:var( --button-icon-background-focus, var(--button-icon-background-hover) )!important}button.button-icon.button-icon-with-border{border:var(--button-icon-border-with-border);border-radius:var(--button-icon-border-radius-with-border)}button.button-icon.button-icon-with-border:not([disabled]):hover{border:var(--button-icon-border-hover)}button.button-icon.button-icon-with-border[disabled]{border:var(--button-icon-border-disabled)}button.button-icon nyx-icon{font-style:normal;font-weight:400;line-height:normal}button.button-icon.small{width:var(--button-icon-override-width, 24px);height:var(--button-icon-override-height, 24px)}button.button-icon.small nyx-icon{font-size:var(--button-icon-small-icon-font-size)}button.button-icon.medium{width:var(--button-icon-override-width, 30px);height:var(--button-icon-override-height, 30px)}button.button-icon.medium nyx-icon{font-size:var(--button-icon-medium-icon-font-size)}button.button-icon.large{width:var(--button-icon-override-width, 34px);height:var(--button-icon-override-height, 34px)}button.button-icon.large nyx-icon{font-size:var(--button-icon-large-icon-font-size)}button.button-icon.xlarge{width:var(--button-icon-override-width, 40px);height:var(--button-icon-override-height, 40px)}button.button-icon.xlarge nyx-icon{font-size:var(--button-icon-xlarge-icon-font-size)}";
217
- var co = Object.defineProperty, u = (c, o, e, n) => {
218
- for (var t = void 0, r = c.length - 1, i; r >= 0; r--)
219
- (i = c[r]) && (t = i(o, e, t) || t);
220
- return t && co(o, e, t), t;
221
- }, b;
222
- const d = (b = class extends k {
223
- constructor() {
224
- super(...arguments), this.variant = "brand", this.size = "large", this.hierarchy = "solid", this.iconPosition = "left", this.disabled = !1, this.loading = !1, this.block = !1, this.buttonIcon = !1, this.buttonIconWithBorder = !1;
225
- }
226
- connectedCallback() {
227
- super.connectedCallback(), this._hostAriaObserver = new MutationObserver(() => {
228
- this.requestUpdate();
229
- }), this._hostAriaObserver.observe(this, {
230
- attributes: !0,
231
- attributeFilter: [...b._HOST_ARIA_ATTRS]
232
- });
468
+ _selectionRoots() {
469
+ return this._isLazyEnabled() ? this._sourceItems : this._items;
233
470
  }
234
- willUpdate(o) {
235
- this._pullHostAriaIntoShadowButton(), super.willUpdate(o);
471
+ /** Full source node for selection UI/state (lazy materialized nodes may omit children). */
472
+ _selectionNode(e) {
473
+ return this._isLazyEnabled() ? this._sourceById.get(e.id) ?? e : e;
474
+ }
475
+ _invalidateSearchIndex() {
476
+ this._searchIndex = null, this._searchIndexSourceRef = null;
477
+ }
478
+ /** Clears search-derived sets so a data source swap cannot reuse stale ids. */
479
+ _resetSearchDerivedState() {
480
+ this._searchVisibleIds = /* @__PURE__ */ new Set(), this._searchUserCollapsedIds = /* @__PURE__ */ new Set(), this._searchManualExpandedIds = /* @__PURE__ */ new Set(), this._searchStatusMessage = "";
481
+ }
482
+ _ensureSearchIndex() {
483
+ const e = this._selectionRoots();
484
+ return this._searchIndex && this._searchIndexSourceRef === e ? this._searchIndex : (this._searchIndexSourceRef = e, this._searchIndex = k(e), this._searchIndex);
236
485
  }
237
486
  disconnectedCallback() {
238
- var o;
239
- (o = this._hostAriaObserver) == null || o.disconnect(), this._hostAriaObserver = void 0, super.disconnectedCallback();
487
+ super.disconnectedCallback(), this._searchDebounceTimer !== null && (clearTimeout(this._searchDebounceTimer), this._searchDebounceTimer = null);
240
488
  }
241
- _pullHostAriaIntoShadowButton() {
242
- var o, e;
243
- if (this.hasAttribute("aria-label")) {
244
- const n = this.getAttribute("aria-label") ?? "", t = n.trim() === "" ? void 0 : n;
245
- t !== this._innerAriaLabel && (this._innerAriaLabel = t), this.removeAttribute("aria-label");
489
+ _findNodeById(e, t) {
490
+ for (const i of e) {
491
+ if (i.id === t) return i;
492
+ if (i.children) {
493
+ const s = this._findNodeById(i.children, t);
494
+ if (s) return s;
495
+ }
246
496
  }
247
- if (this.hasAttribute("aria-labelledby")) {
248
- const n = (o = this.getAttribute("aria-labelledby")) == null ? void 0 : o.trim(), t = n === "" ? void 0 : n;
249
- t !== this._innerAriaLabelledby && (this._innerAriaLabelledby = t), this.removeAttribute("aria-labelledby");
497
+ }
498
+ _forEachInSubtree(e, t, i) {
499
+ const s = this._findNodeById(e, t);
500
+ if (!s) return;
501
+ const r = (o) => {
502
+ var a;
503
+ i(o), (a = o.children) == null || a.forEach(r);
504
+ };
505
+ r(s);
506
+ }
507
+ _getSourceChildren(e) {
508
+ const t = this._isLazyEnabled() ? this._sourceById.get(e) : this._findNodeById(this._items, e);
509
+ return t == null ? void 0 : t.children;
510
+ }
511
+ _loadMoreNodes(e) {
512
+ if (!this._isLazyEnabled()) return;
513
+ const t = this._getLazyPageSize();
514
+ let i;
515
+ if (this._isSearchActive())
516
+ if (y(this._searchVisibleIds, this._loadedIds))
517
+ i = j(
518
+ this._searchVisibleIds,
519
+ this._loadedIds,
520
+ this._indexById,
521
+ t
522
+ );
523
+ else if (e != null && this._hasExclusiveSearchFolderWithUnloadedChildren())
524
+ i = P(
525
+ this._treeIndex,
526
+ this._loadedIds,
527
+ t,
528
+ e
529
+ );
530
+ else
531
+ return;
532
+ else e != null ? i = P(
533
+ this._treeIndex,
534
+ this._loadedIds,
535
+ t,
536
+ e
537
+ ) : i = _e(this._treeIndex, this._loadedIds, t);
538
+ i.length !== 0 && (i.forEach((s) => this._loadedIds.add(s)), this._loadedIds = new Set(this._loadedIds), this._rebuildMaterializedItems(), this._commitLazyRows());
539
+ }
540
+ _loadSubtreeForExpand(e) {
541
+ const t = ve(
542
+ this._treeIndex,
543
+ e,
544
+ this._loadedIds,
545
+ this._getLazyPageSize()
546
+ );
547
+ t.length !== 0 && (t.forEach((i) => this._loadedIds.add(i)), this._loadedIds = new Set(this._loadedIds), this._rebuildMaterializedItems());
548
+ }
549
+ _sourceHasChildren(e) {
550
+ var t, i;
551
+ return !!((i = (t = this._sourceById.get(e)) == null ? void 0 : t.children) != null && i.length);
552
+ }
553
+ /** Refresh lazy flat rows after intentional lazy state mutations. */
554
+ _commitLazyRows() {
555
+ this._isLazyEnabled() && this._syncFlatRows();
556
+ }
557
+ _syncFlatRows() {
558
+ this._flatRows = F({
559
+ items: this._items,
560
+ expandedIds: this._expandedIds,
561
+ hasSearch: !!this._searchTerm.trim(),
562
+ searchTerm: this._searchTerm,
563
+ searchVisibleIds: this._searchVisibleIds,
564
+ sourceHasChildren: (e) => this._sourceHasChildren(e),
565
+ getSourceChildren: (e) => this._getSourceChildren(e)
566
+ }), this._syncActiveRowWithVisibleRows();
567
+ }
568
+ _setActiveRow(e) {
569
+ this._activeRowId !== e && (this._activeRowId = e);
570
+ }
571
+ _syncActiveRowWithVisibleRows() {
572
+ const e = this._getVisibleTreeRows();
573
+ if (e.length === 0) {
574
+ this._activeRowId !== null && (this._activeRowId = null);
575
+ return;
250
576
  }
251
- if (this.hasAttribute("aria-describedby")) {
252
- const n = (e = this.getAttribute("aria-describedby")) == null ? void 0 : e.trim(), t = n === "" ? void 0 : n;
253
- t !== this._innerAriaDescribedby && (this._innerAriaDescribedby = t), this.removeAttribute("aria-describedby");
577
+ const t = e.some((i) => i.node.id === this._activeRowId);
578
+ (this._activeRowId === null || !t) && (this._activeRowId = e[0].node.id);
579
+ }
580
+ _getRowTabIndex(e) {
581
+ const t = this._getVisibleTreeRows();
582
+ if (t.length === 0) return -1;
583
+ const i = this._activeRowId ?? t[0].node.id;
584
+ return e === i ? 0 : -1;
585
+ }
586
+ _rowDomId(e) {
587
+ return `row-${String(e)}`;
588
+ }
589
+ _rowSelector(e) {
590
+ return `#${CSS.escape(this._rowDomId(e))}`;
591
+ }
592
+ _isSearchActive() {
593
+ return !!this._searchTerm.trim();
594
+ }
595
+ /** Index to scroll to after search — deepest hit, or first homonymous child. */
596
+ _getSearchScrollTargetIndex() {
597
+ const e = this._searchTerm.trim().toLowerCase();
598
+ if (!e || this._flatRows.length === 0) return 0;
599
+ const t = this._flatRows.map((r, o) => ({ row: r, index: o })).filter(({ row: r }) => I(r.node.label, e));
600
+ if (t.length === 0) return 0;
601
+ const i = t.reduce(
602
+ (r, o) => o.row.level >= r.row.level ? o : r
603
+ ), [s] = t;
604
+ if (t.length > 1 && s.row.hasChildrenInSource && this._expandedIds.has(s.row.node.id)) {
605
+ const r = t.find(
606
+ ({ row: o }) => o.level === s.row.level + 1 && o.node.label.toLowerCase() === s.row.node.label.toLowerCase()
607
+ );
608
+ if (r) return r.index;
254
609
  }
610
+ return i.index;
255
611
  }
256
- /**
257
- * @private
258
- * Handles the click action performed on the button.
259
- */
260
- _handleClick(o) {
261
- if (this.disabled || this.loading) {
262
- o.preventDefault(), o.stopPropagation();
263
- return;
612
+ _loadUntilSearchTargetVisible() {
613
+ let e = 0;
614
+ for (; e++ < 100 && !(this._getSearchScrollTargetIndex() < this._flatRows.length || !y(this._searchVisibleIds, this._loadedIds) && !this._hasExpandedUnloadedSubtree()); ) {
615
+ if (y(this._searchVisibleIds, this._loadedIds)) {
616
+ if (!B(
617
+ this._searchVisibleIds,
618
+ this._loadedIds,
619
+ this._indexById,
620
+ this._getLazyPageSize()
621
+ ))
622
+ break;
623
+ } else
624
+ break;
625
+ this._loadedIds = new Set(this._loadedIds), this._rebuildMaterializedItems(), this._commitLazyRows();
264
626
  }
265
- o.stopPropagation(), this.click(void 0, { native: !0, bubbles: !0, composed: !0 });
266
627
  }
267
- render() {
268
- const o = this.buttonIcon || this.buttonIconWithBorder, e = {
269
- brand: this.variant === "brand",
270
- info: this.variant === "info",
271
- warning: this.variant === "warning",
272
- danger: this.variant === "danger",
273
- neutral: this.variant === "neutral",
274
- success: this.variant === "success",
275
- small: this.size === "small",
276
- medium: this.size === "medium",
277
- large: this.size === "large",
278
- xlarge: this.size === "xlarge",
279
- outline: this.hierarchy === "outline",
280
- ghost: this.hierarchy === "ghost",
281
- "icon-right": this.iconPosition === "right",
282
- loading: this.loading,
283
- block: this.block,
284
- "button-icon": o,
285
- "button-icon-with-border": this.buttonIconWithBorder
286
- };
287
- return l`
288
- <button
289
- type="button"
290
- ?disabled=${this.disabled}
291
- class=${$(e)}
292
- aria-label=${this._innerAriaLabel ?? y}
293
- aria-labelledby=${this._innerAriaLabelledby ?? y}
294
- aria-describedby=${this._innerAriaDescribedby ?? y}
295
- @click=${this._handleClick}
628
+ _scrollToSearchTarget() {
629
+ !this._isLazyEnabled() || !this._isSearchActive() || this.updateComplete.then(() => {
630
+ var i;
631
+ const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector("lit-virtualizer"), t = this._getSearchScrollTargetIndex();
632
+ !(e != null && e.scrollToIndex) || t < 0 || e.scrollToIndex(t, "start");
633
+ });
634
+ }
635
+ _hasExpandedUnloadedSubtree() {
636
+ for (const e of this._expandedIds)
637
+ if (L(e, this._treeIndex, this._loadedIds))
638
+ return !0;
639
+ return !1;
640
+ }
641
+ /** Expanded folder hit with no deeper visible match — may lazy-load all children. */
642
+ _hasExclusiveSearchFolderWithUnloadedChildren() {
643
+ if (!this._isSearchActive()) return !1;
644
+ const e = this._searchTerm.trim();
645
+ if (!e) return !1;
646
+ for (const t of this._expandedIds) {
647
+ const i = this._sourceById.get(t);
648
+ if (i && L(t, this._treeIndex, this._loadedIds) && z(
649
+ i.label,
650
+ e,
651
+ !1,
652
+ t,
653
+ this._searchVisibleIds,
654
+ (s) => this._getSourceChildren(s)
655
+ ))
656
+ return !0;
657
+ }
658
+ return !1;
659
+ }
660
+ _shouldLoadMoreOnScroll() {
661
+ return this._isLazyEnabled() ? this._isSearchActive() ? y(
662
+ this._searchVisibleIds,
663
+ this._loadedIds
664
+ ) || this._hasExclusiveSearchFolderWithUnloadedChildren() : this._hasExpandedUnloadedSubtree() ? this._treeIndex.some(
665
+ (e) => !this._loadedIds.has(e.id)
666
+ ) : fe(this._treeIndex, this._loadedIds) : !1;
667
+ }
668
+ _getLazyLoadPriorityRootId(e) {
669
+ if (!(!this._isSearchActive() && !this._hasExpandedUnloadedSubtree()))
670
+ return pe(
671
+ this._flatRows,
672
+ e,
673
+ this._expandedIds,
674
+ this._treeIndex,
675
+ this._loadedIds,
676
+ this._indexById
677
+ );
678
+ }
679
+ _getScrollPrefetchMargin() {
680
+ return Math.min(20, Math.max(5, Math.floor(this._getLazyPageSize() / 4)));
681
+ }
682
+ _onVirtualizerVisibilityChanged(e) {
683
+ const i = e.last;
684
+ if (i == null || !this._shouldLoadMoreOnScroll() || this._lazyScrollLoading)
685
+ return;
686
+ const s = Math.max(
687
+ 0,
688
+ this._flatRows.length - this._getScrollPrefetchMargin()
689
+ );
690
+ i < s || (this._lazyScrollLoading = !0, this._loadMoreNodes(this._getLazyLoadPriorityRootId(i)), this.updateComplete.then(() => {
691
+ this._lazyScrollLoading = !1;
692
+ }));
693
+ }
694
+ _getTreeAriaLabel() {
695
+ var e, t;
696
+ return ((t = (e = this.options) == null ? void 0 : e.title) == null ? void 0 : t.trim()) || "Treeview";
697
+ }
698
+ _renderTreeRow(e, t, i) {
699
+ const { isExpanded: s, hasChildren: r, isRowHighlighted: o, isSelectable: a } = i;
700
+ return h`
701
+ <div
702
+ id=${this._rowDomId(e.id)}
703
+ role="treeitem"
704
+ aria-level=${t + 1}
705
+ aria-expanded=${r ? s ? "true" : "false" : w}
706
+ class=${b({
707
+ "node-row": !0,
708
+ selectable: a,
709
+ selected: o
710
+ })}
711
+ style="--treeview-row-level: ${t}"
712
+ tabindex=${this._getRowTabIndex(e.id)}
713
+ @mousedown=${(d) => d.preventDefault()}
714
+ @focus=${() => this._setActiveRow(e.id)}
715
+ @keydown=${(d) => this._handleRowKeyDown(d, e)}
716
+ @focusout=${this._handleRowFocusOut}
296
717
  >
297
- ${this.loading ? "" : l`<slot name="icon"></slot>`}
298
- ${this.loading ? l`<div class="loading"><nyx-icon svg=${K}></nyx-icon></div>` : ""}
299
- ${o ? "" : l`<slot></slot>`}
300
- </button>
718
+ <div class="node-info">
719
+ ${this._renderRowSelectionCheckbox(e)}
720
+ ${this._renderExpanderCell(e, s, r)}
721
+ ${this._renderNodeIconCell(e)}
722
+ <span class="node-text" title="${e.label}">${e.label}</span>
723
+ </div>
724
+ ${this._renderColumnCheckboxes(e)}
725
+ </div>
301
726
  `;
302
727
  }
303
- }, b._HOST_ARIA_ATTRS = [
304
- "aria-label",
305
- "aria-labelledby",
306
- "aria-describedby"
307
- ], b.styles = m(ao), b);
308
- u([
309
- a({ type: String, reflect: !0 })
310
- ], d.prototype, "variant");
311
- u([
312
- a({ type: String, reflect: !0 })
313
- ], d.prototype, "size");
314
- u([
315
- a({ type: String, reflect: !0 })
316
- ], d.prototype, "hierarchy");
317
- u([
318
- a()
319
- ], d.prototype, "iconPosition");
320
- u([
321
- a({ type: Boolean, reflect: !0 })
322
- ], d.prototype, "disabled");
323
- u([
324
- a({ type: Boolean, reflect: !0 })
325
- ], d.prototype, "loading");
326
- u([
327
- a({ type: Boolean, reflect: !0 })
328
- ], d.prototype, "block");
329
- u([
330
- a({ attribute: "button-icon", type: Boolean, reflect: !0 })
331
- ], d.prototype, "buttonIcon");
332
- u([
333
- a({ attribute: "button-icon-with-border", type: Boolean, reflect: !0 })
334
- ], d.prototype, "buttonIconWithBorder");
335
- u([
336
- q()
337
- ], d.prototype, "click");
338
- u([
339
- f()
340
- ], d.prototype, "_innerAriaLabel");
341
- u([
342
- f()
343
- ], d.prototype, "_innerAriaLabelledby");
344
- u([
345
- f()
346
- ], d.prototype, "_innerAriaDescribedby");
347
- let lo = d;
348
- customElements.get("nyx-button") || customElements.define("nyx-button", lo);
349
- var so = Object.defineProperty, z = (c, o, e, n) => {
350
- for (var t = void 0, r = c.length - 1, i; r >= 0; r--)
351
- (i = c[r]) && (t = i(o, e, t) || t);
352
- return t && so(o, e, t), t;
353
- };
354
- const R = class R extends k {
355
- constructor() {
356
- super(...arguments), this._items = [], this._expandedIds = /* @__PURE__ */ new Set(), this._searchTerm = "";
728
+ _renderExpanderCell(e, t, i) {
729
+ return i ? h`
730
+ <nyx-button
731
+ class="expander"
732
+ size="small"
733
+ button-icon
734
+ tabindex="-1"
735
+ hierarchy="ghost"
736
+ aria-label=${ge(e.label, t)}
737
+ @click=${() => this._toggleExpand(e, !1)}
738
+ @keydown=${(s) => {
739
+ (s.key === "Enter" || s.key === " ") && (s.preventDefault(), s.stopPropagation(), this._toggleExpand(e, !0));
740
+ }}
741
+ >
742
+ <nyx-icon
743
+ slot="icon"
744
+ class=${b({ expanded: t })}
745
+ .svg=${X}
746
+ ></nyx-icon>
747
+ </nyx-button>
748
+ ` : h`<span class="expander-placeholder" aria-hidden="true"></span>`;
357
749
  }
358
- updated(o) {
359
- o.has("options") && this.options && (this._items = JSON.parse(JSON.stringify(this.options.items)), this.options.defaultExpandedLevel !== void 0 && this._expandedIds.size === 0 && this._expandToLevel(
360
- this._items,
361
- 0,
362
- this.options.defaultExpandedLevel
363
- ), this._generateLightDomIcons());
750
+ _renderNodeTypeIcon(e) {
751
+ const t = e.icon;
752
+ return t ? typeof t == "string" ? h`<nyx-icon name=${t} variant="regular"></nyx-icon>` : h`
753
+ <nyx-icon
754
+ name=${t.name ?? w}
755
+ variant=${t.variant ?? "regular"}
756
+ src=${t.src ?? w}
757
+ .svg=${t.svg}
758
+ ></nyx-icon>
759
+ ` : w;
364
760
  }
365
761
  _generateLightDomIcons() {
366
- var n;
367
- if (this.querySelectorAll("[data-auto-generated]").forEach((t) => t.remove()), !this.options) return;
368
- (n = this.options.columns) == null || n.forEach((t, r) => {
369
- t.icon && this._createIconElement(t.icon, `generated-header-icon-${r}`);
370
- });
371
- const e = (t) => {
372
- t.icon && this._createIconElement(
373
- t.icon,
374
- `generated-tree-icon-${t.id}`
375
- ), t.children && t.children.forEach(e);
762
+ var i;
763
+ if (this.querySelectorAll("[data-auto-generated]").forEach((s) => s.remove()), !this.options || (this._hasColumnPermissions() && ((i = this.options.columns) == null || i.forEach((s, r) => {
764
+ s.icon && this._createIconElement(s.icon, `generated-header-icon-${r}`);
765
+ })), this._isLazyEnabled() || !this._showNodeIcons())) return;
766
+ const t = (s) => {
767
+ var r;
768
+ s.icon && this._createIconElement(
769
+ s.icon,
770
+ `generated-tree-icon-${s.id}`
771
+ ), (r = s.children) == null || r.forEach(t);
376
772
  };
377
- this._items.forEach(e);
773
+ this._items.forEach(t);
378
774
  }
379
- _createIconElement(o, e) {
380
- const n = document.createElement("nyx-icon");
381
- let t = "regular";
382
- typeof o == "string" ? n.setAttribute("name", o) : (o.name && n.setAttribute("name", o.name), o.variant && (t = o.variant), o.src && n.setAttribute("src", o.src), o.svg && (n.svg = o.svg)), n.setAttribute("variant", t), n.setAttribute("slot", e), n.setAttribute("data-auto-generated", ""), this.appendChild(n);
775
+ _createIconElement(e, t) {
776
+ const i = document.createElement("nyx-icon");
777
+ let s = "regular";
778
+ typeof e == "string" ? i.setAttribute("name", e) : (e.name && i.setAttribute("name", e.name), e.variant && (s = e.variant), e.src && i.setAttribute("src", e.src), e.svg && (i.svg = e.svg)), i.setAttribute("variant", s), i.setAttribute("slot", t), i.setAttribute("data-auto-generated", ""), this.appendChild(i);
383
779
  }
384
- _expandToLevel(o, e, n) {
385
- o.forEach((t) => {
386
- e < n && (this._expandedIds.add(t.id), t.children && this._expandToLevel(t.children, e + 1, n));
780
+ _expandToLevel(e, t, i) {
781
+ e.forEach((s) => {
782
+ t < i && (this._expandedIds.add(s.id), s.children && this._expandToLevel(s.children, t + 1, i));
387
783
  });
388
784
  }
389
- _isColumnDisabled(o, e) {
390
- return !!o.disabledColumns && o.disabledColumns.includes(e);
785
+ _isColumnDisabled(e, t) {
786
+ return !!e.disabledColumns && e.disabledColumns.includes(t);
391
787
  }
392
- _isNodeSelected(o, e) {
393
- return this._isColumnDisabled(o, e) ? !1 : (o.selectedColumns || []).includes(e);
788
+ _isNodeSelected(e, t) {
789
+ return this._isColumnDisabled(e, t) ? !1 : (e.selectedColumns || []).includes(t);
394
790
  }
395
- _isIndeterminate(o, e) {
396
- if (!o.children || o.children.length === 0) return !1;
397
- const n = this._getFlatDescendants(o), t = n.filter(
398
- (r) => this._isNodeSelected(r, e)
791
+ _isIndeterminate(e, t) {
792
+ if (e = this._selectionNode(e), !e.children || e.children.length === 0) return !1;
793
+ const i = this._getFlatDescendants(e), s = i.filter(
794
+ (r) => this._isNodeSelected(r, t)
399
795
  ).length;
400
- return t > 0 && t < n.length;
401
- }
402
- _allDescendantsSelected(o, e) {
403
- return !o.children || o.children.length === 0 ? this._isNodeSelected(o, e) : this._getFlatDescendants(o).every((t) => this._isNodeSelected(t, e));
404
- }
405
- _getFlatDescendants(o) {
406
- let e = [];
407
- return o.children && o.children.forEach((n) => {
408
- e.push(n), e = e.concat(this._getFlatDescendants(n));
409
- }), e;
410
- }
411
- _handleCheck(o, e) {
412
- const t = !this._isNodeSelected(o, e);
413
- this._toggleNodeState(o, e, t), o.children && this._getFlatDescendants(o).forEach((r) => {
414
- this._toggleNodeState(r, e, t);
415
- }), this._updateParents(this._items, o.id, e), this._triggerChange();
416
- }
417
- _toggleNodeState(o, e, n) {
418
- if (this._isColumnDisabled(o, e)) return;
419
- o.selectedColumns || (o.selectedColumns = []);
420
- const t = o.selectedColumns.indexOf(e);
421
- n && t === -1 ? o.selectedColumns.push(e) : !n && t > -1 && o.selectedColumns.splice(t, 1);
422
- }
423
- _updateParents(o, e, n) {
424
- for (const t of o)
425
- if (t.children && t.children.some(
426
- (r) => r.id === e || this._updateParents(t.children, e, n)
796
+ return s > 0 && s < i.length;
797
+ }
798
+ _allDescendantsSelected(e, t) {
799
+ return e = this._selectionNode(e), !e.children || e.children.length === 0 ? this._isNodeSelected(e, t) : this._getFlatDescendants(e).every((s) => this._isNodeSelected(s, t));
800
+ }
801
+ _getFlatDescendants(e) {
802
+ e = this._selectionNode(e);
803
+ let t = [];
804
+ return e.children && e.children.forEach((i) => {
805
+ const s = this._selectionNode(i);
806
+ t.push(s), t = t.concat(this._getFlatDescendants(s));
807
+ }), t;
808
+ }
809
+ /** Transitive set of prerequisite column ids for `columnId` (excludes itself). */
810
+ _requiredClosure(e) {
811
+ var a, d, l;
812
+ const t = ((a = this.options) == null ? void 0 : a.columns) ?? [], i = new Map(t.map((c) => [c.id, c])), s = [], r = /* @__PURE__ */ new Set([e]), o = [...((d = i.get(e)) == null ? void 0 : d.requires) ?? []];
813
+ for (; o.length; ) {
814
+ const c = o.pop();
815
+ r.has(c) || (r.add(c), s.push(c), o.push(...((l = i.get(c)) == null ? void 0 : l.requires) ?? []));
816
+ }
817
+ return s;
818
+ }
819
+ /** Transitive set of column ids that depend on `columnId` (excludes itself). */
820
+ _dependentsClosure(e) {
821
+ var o;
822
+ const t = ((o = this.options) == null ? void 0 : o.columns) ?? [], i = [], s = /* @__PURE__ */ new Set([e]), r = [e];
823
+ for (; r.length; ) {
824
+ const a = r.pop();
825
+ for (const d of t)
826
+ (d.requires ?? []).includes(a) && !s.has(d.id) && (s.add(d.id), i.push(d.id), r.push(d.id));
827
+ }
828
+ return i;
829
+ }
830
+ _canEnableColumn(e, t) {
831
+ return this._isColumnDisabled(e, t) ? !1 : this._requiredClosure(t).every(
832
+ (i) => !this._isColumnDisabled(e, i)
833
+ );
834
+ }
835
+ _handleCheck(e, t) {
836
+ const i = this._selectionNode(e);
837
+ if (this._isColumnDisabled(i, t)) return;
838
+ const r = !this._isNodeSelected(i, t), o = this._requiredClosure(t), a = r ? [t, ...o] : [t, ...this._dependentsClosure(t)];
839
+ this._forEachInSubtree(this._selectionRoots(), e.id, (d) => {
840
+ r && o.some(
841
+ (c) => this._isColumnDisabled(d, c)
842
+ ) || a.forEach(
843
+ (l) => this._toggleNodeState(d, l, r)
844
+ );
845
+ }), a.forEach(
846
+ (d) => this._updateParents(this._selectionRoots(), e.id, d)
847
+ ), this._triggerChange();
848
+ }
849
+ _toggleNodeState(e, t, i) {
850
+ if (this._isColumnDisabled(e, t)) return;
851
+ e.selectedColumns || (e.selectedColumns = []);
852
+ const s = e.selectedColumns.indexOf(t);
853
+ i && s === -1 ? e.selectedColumns.push(t) : !i && s > -1 && e.selectedColumns.splice(s, 1);
854
+ }
855
+ _updateParents(e, t, i) {
856
+ for (const s of e)
857
+ if (s.children && s.children.some(
858
+ (r) => r.id === t || this._updateParents(s.children, t, i)
427
859
  )) {
428
- const r = t.children.every(
429
- (i) => this._allDescendantsSelected(i, n)
860
+ const r = s.children.every(
861
+ (o) => this._allDescendantsSelected(o, i)
430
862
  );
431
- return this._toggleNodeState(t, n, r), !0;
863
+ return this._toggleNodeState(
864
+ s,
865
+ i,
866
+ r && this._canEnableColumn(s, i)
867
+ ), !0;
432
868
  }
433
869
  return !1;
434
870
  }
435
- _isRowAllSelected(o) {
436
- var n;
437
- if (!((n = this.options) != null && n.columns)) return !1;
438
- const e = this.options.columns.every((t) => this._isColumnDisabled(o, t.id) ? !0 : this._isNodeSelected(o, t.id));
439
- return o.children && o.children.length > 0 ? e && o.children.every((t) => this._isRowAllSelected(t)) : e;
871
+ _isRowAllSelected(e) {
872
+ var i;
873
+ if (e = this._selectionNode(e), !((i = this.options) != null && i.columns)) return !1;
874
+ const t = this.options.columns.every((s) => this._isColumnDisabled(e, s.id) ? !0 : this._isNodeSelected(e, s.id));
875
+ return e.children && e.children.length > 0 ? t && e.children.every((s) => this._isRowAllSelected(s)) : t;
440
876
  }
441
- _isRowIndeterminate(o) {
442
- var t;
443
- if (this._isRowAllSelected(o) || !((t = this.options) != null && t.columns)) return !1;
444
- const e = this.options.columns.some(
445
- (r) => this._isNodeSelected(o, r.id)
446
- ), n = o.children ? o.children.some(
877
+ _isRowIndeterminate(e) {
878
+ var s;
879
+ if (e = this._selectionNode(e), this._isRowAllSelected(e) || !((s = this.options) != null && s.columns)) return !1;
880
+ const t = this.options.columns.some(
881
+ (r) => this._isNodeSelected(e, r.id)
882
+ ), i = e.children ? e.children.some(
447
883
  (r) => this._isRowAllSelected(r) || this._isRowIndeterminate(r)
448
884
  ) : !1;
449
- return e || n;
885
+ return t || i;
450
886
  }
451
- _handleRowCheck(o) {
887
+ _isSimpleRowAllSelected(e) {
452
888
  var t;
453
- const n = !this._isRowAllSelected(o);
454
- this._toggleRowRecursively(o, n), (t = this.options) != null && t.columns && this.options.columns.forEach((r) => {
455
- this._updateParents(this._items, o.id, r.id);
456
- }), this._triggerChange();
889
+ return e = this._selectionNode(e), (t = e.children) != null && t.length ? e.children.every((i) => this._isSimpleRowAllSelected(i)) : !!e.selected;
890
+ }
891
+ _isSimpleRowIndeterminate(e) {
892
+ var s;
893
+ return e = this._selectionNode(e), this._isSimpleRowAllSelected(e) || !((s = e.children) != null && s.length) ? !1 : this._getFlatDescendants(e).filter((r) => r.selected).length > 0;
894
+ }
895
+ _setSimpleRowSelected(e, t) {
896
+ this._forEachInSubtree(this._selectionRoots(), e, (i) => {
897
+ i.selected = t;
898
+ });
899
+ }
900
+ _updateSimpleRowParents(e, t) {
901
+ var i;
902
+ for (const s of e)
903
+ if ((i = s.children) != null && i.some(
904
+ (r) => r.id === t || this._updateSimpleRowParents(s.children, t)
905
+ ))
906
+ return s.selected = s.children.every(
907
+ (r) => this._isSimpleRowAllSelected(r)
908
+ ), !0;
909
+ return !1;
910
+ }
911
+ _isRowCheckboxChecked(e) {
912
+ const t = this._selectionNode(e);
913
+ return this._usesSimpleRowSelection() ? this._isSimpleRowAllSelected(t) : this._isRowAllSelected(t);
914
+ }
915
+ _isRowCheckboxIndeterminate(e) {
916
+ const t = this._selectionNode(e);
917
+ return this._usesSimpleRowSelection() ? this._isSimpleRowIndeterminate(t) : this._isRowIndeterminate(t);
457
918
  }
458
- _toggleRowRecursively(o, e) {
459
- var n;
460
- (n = this.options) != null && n.columns && (e ? this.options.columns.forEach((t) => {
461
- this._isColumnDisabled(o, t.id) || (o.selectedColumns || (o.selectedColumns = []), o.selectedColumns.includes(t.id) || o.selectedColumns.push(t.id));
462
- }) : o.selectedColumns = [], o.children && o.children.forEach((t) => this._toggleRowRecursively(t, e)));
919
+ _handleRowCheck(e) {
920
+ var s;
921
+ const i = !this._isRowCheckboxChecked(e);
922
+ this._usesSimpleRowSelection() ? (this._setSimpleRowSelected(e.id, i), this._updateSimpleRowParents(this._selectionRoots(), e.id)) : (this._toggleRowRecursively(e.id, i), (s = this.options) != null && s.columns && this.options.columns.forEach((r) => {
923
+ this._updateParents(this._selectionRoots(), e.id, r.id);
924
+ })), this._triggerChange();
925
+ }
926
+ _applyRowColumnsToNode(e, t) {
927
+ var i;
928
+ (i = this.options) != null && i.columns && (t ? this.options.columns.forEach((s) => {
929
+ this._canEnableColumn(e, s.id) && (e.selectedColumns || (e.selectedColumns = []), e.selectedColumns.includes(s.id) || e.selectedColumns.push(s.id));
930
+ }) : e.selectedColumns = (e.selectedColumns ?? []).filter(
931
+ (s) => this._isColumnDisabled(e, s)
932
+ ));
933
+ }
934
+ _toggleRowRecursively(e, t) {
935
+ this._forEachInSubtree(this._selectionRoots(), e, (i) => {
936
+ this._applyRowColumnsToNode(i, t);
937
+ });
463
938
  }
464
939
  _triggerChange() {
465
- this._items = [...this._items], this.onChange({ items: this._items }, { bubbles: !0, composed: !0 });
466
- }
467
- async _toggleExpand(o, e = !1) {
468
- var r;
469
- if (!(o.children && o.children.length > 0)) return;
470
- const t = this._expandedIds.has(o.id);
471
- if (t ? this._expandedIds.delete(o.id) : this._expandedIds.add(o.id), this._expandedIds = new Set(this._expandedIds), !t && e && o.children && o.children[0]) {
472
- await this.updateComplete;
473
- const i = o.children[0].id, p = (r = this.shadowRoot) == null ? void 0 : r.querySelector(
474
- `#row-${i}`
940
+ if (this._isLazyEnabled()) {
941
+ this._rebuildMaterializedItems(), this._commitLazyRows(), this.onChange(
942
+ { items: this._sourceItems },
943
+ { bubbles: !0, composed: !0 }
475
944
  );
476
- p && p.focus();
945
+ return;
477
946
  }
947
+ this._items = [...this._items], this._invalidateSearchIndex(), this._searchTerm.trim() && this._recomputeSearchFilter(), this.onChange({ items: this._items }, { bubbles: !0, composed: !0 });
478
948
  }
479
- _handleRowKeyDown(o, e) {
480
- var t;
481
- const n = o.currentTarget;
482
- if ((o.key === "Enter" || o.key === " ") && o.target === n) {
483
- o.preventDefault(), this._enableChildren(n);
484
- const r = n.querySelector(
949
+ _handleSearchInput(e) {
950
+ const t = e.target.value, i = this._searchTerm, s = t.trim();
951
+ if (this._searchDebounceTimer !== null && (clearTimeout(this._searchDebounceTimer), this._searchDebounceTimer = null), !s && i.trim()) {
952
+ this._applySearchTerm(t, i);
953
+ return;
954
+ }
955
+ this._searchDebounceTimer = setTimeout(() => {
956
+ this._searchDebounceTimer = null, this._applySearchTerm(t, i);
957
+ }, ie);
958
+ }
959
+ _applySearchTerm(e, t) {
960
+ const i = t.trim(), s = e.trim();
961
+ !i && s ? (this._expandedIdsBeforeSearch = new Set(this._expandedIds), this._searchManualExpandedIds = /* @__PURE__ */ new Set(), this._searchUserCollapsedIds = /* @__PURE__ */ new Set()) : i && !s ? (this._searchUserCollapsedIds = /* @__PURE__ */ new Set(), this._searchManualExpandedIds = /* @__PURE__ */ new Set()) : i && s && i.toLowerCase() !== s.toLowerCase() && (this._searchUserCollapsedIds = /* @__PURE__ */ new Set(), this._searchManualExpandedIds = /* @__PURE__ */ new Set()), this._searchTerm = e, this._recomputeSearchFilter();
962
+ }
963
+ _recomputeSearchFilter() {
964
+ const e = this._searchTerm.trim();
965
+ if (!e) {
966
+ this._searchVisibleIds = /* @__PURE__ */ new Set(), this._expandedIdsBeforeSearch && (this._expandedIds = new Set(this._expandedIdsBeforeSearch), this._expandedIdsBeforeSearch = null), this._isLazyEnabled() ? this._commitLazyRows() : this._syncActiveRowWithVisibleRows(), this._updateSearchStatusMessage();
967
+ return;
968
+ }
969
+ const t = this._ensureSearchIndex(), { visibleIds: i, expandIds: s } = oe(
970
+ t,
971
+ e,
972
+ this._searchUserCollapsedIds
973
+ ), r = new Set(s);
974
+ this._searchManualExpandedIds.forEach((o) => {
975
+ this._searchUserCollapsedIds.has(o) || r.add(o);
976
+ }), this._searchVisibleIds = i, this._expandedIds = r, this._isLazyEnabled() ? (B(
977
+ i,
978
+ this._loadedIds,
979
+ this._indexById,
980
+ this._getLazyPageSize()
981
+ ) && (this._loadedIds = new Set(this._loadedIds), this._rebuildMaterializedItems()), this._commitLazyRows(), this._loadUntilSearchTargetVisible(), this._scrollToSearchTarget()) : this._syncActiveRowWithVisibleRows(), this._updateSearchStatusMessage();
982
+ }
983
+ _updateSearchStatusMessage() {
984
+ const e = this._searchTerm.trim();
985
+ if (!e) {
986
+ this._searchStatusMessage = "";
987
+ return;
988
+ }
989
+ const t = this._ensureSearchIndex();
990
+ this._searchStatusMessage = Se(
991
+ ne(t, e)
992
+ );
993
+ }
994
+ async _toggleExpand(e, t = !1) {
995
+ if (!(this._isLazyEnabled() ? this._sourceHasChildren(e.id) : !!(e.children && e.children.length > 0))) return;
996
+ const s = this._expandedIds.has(e.id);
997
+ s ? (this._expandedIds.delete(e.id), this._searchTerm.trim() && (this._searchUserCollapsedIds.add(e.id), this._searchUserCollapsedIds = new Set(this._searchUserCollapsedIds), this._searchManualExpandedIds.delete(e.id), this._searchManualExpandedIds = new Set(this._searchManualExpandedIds))) : (this._expandedIds.add(e.id), this._searchTerm.trim() && (this._searchManualExpandedIds.add(e.id), this._searchManualExpandedIds = new Set(this._searchManualExpandedIds), this._searchUserCollapsedIds.delete(e.id), this._searchUserCollapsedIds = new Set(this._searchUserCollapsedIds)), this._isLazyEnabled() && this._loadSubtreeForExpand(e.id)), this._expandedIds = new Set(this._expandedIds), this._isLazyEnabled() ? this._commitLazyRows() : this._syncActiveRowWithVisibleRows(), !s && t && (await this.updateComplete, this._focusFirstVisibleChild(e.id));
998
+ }
999
+ _nodeHasChildren(e) {
1000
+ return this._isLazyEnabled() ? this._sourceHasChildren(e.id) : !!(e.children && e.children.length > 0);
1001
+ }
1002
+ _getVisibleTreeRows() {
1003
+ return this._isLazyEnabled() ? this._flatRows : F({
1004
+ items: this._items,
1005
+ expandedIds: this._expandedIds,
1006
+ hasSearch: this._isSearchActive(),
1007
+ searchTerm: this._searchTerm,
1008
+ searchVisibleIds: this._searchVisibleIds,
1009
+ sourceHasChildren: (e) => {
1010
+ var t;
1011
+ return !!((t = this._getSourceChildren(e)) != null && t.length);
1012
+ },
1013
+ getSourceChildren: (e) => this._getSourceChildren(e)
1014
+ });
1015
+ }
1016
+ _getParentId(e) {
1017
+ var s;
1018
+ if (this._isLazyEnabled()) {
1019
+ const r = (s = this._indexById.get(e)) == null ? void 0 : s.parentId;
1020
+ return r ?? void 0;
1021
+ }
1022
+ let t;
1023
+ const i = (r, o) => {
1024
+ for (const a of r) {
1025
+ if (a.id === e)
1026
+ return t = o ?? void 0, !0;
1027
+ if (a.children && i(a.children, a.id))
1028
+ return !0;
1029
+ }
1030
+ return !1;
1031
+ };
1032
+ return i(this._items, null), t;
1033
+ }
1034
+ _focusRowById(e) {
1035
+ this._setActiveRow(e), this.updateComplete.then(() => {
1036
+ var i, s, r;
1037
+ if (this._isLazyEnabled()) {
1038
+ const o = this._flatRows.findIndex((a) => a.node.id === e);
1039
+ if (o >= 0) {
1040
+ const a = (i = this.shadowRoot) == null ? void 0 : i.querySelector(
1041
+ "lit-virtualizer"
1042
+ );
1043
+ (s = a == null ? void 0 : a.scrollToIndex) == null || s.call(a, o, "nearest");
1044
+ }
1045
+ }
1046
+ const t = (r = this.shadowRoot) == null ? void 0 : r.querySelector(
1047
+ this._rowSelector(e)
1048
+ );
1049
+ t == null || t.focus();
1050
+ });
1051
+ }
1052
+ _focusFirstVisibleChild(e) {
1053
+ const t = this._getVisibleTreeRows(), i = t.findIndex((r) => r.node.id === e);
1054
+ if (i < 0) return;
1055
+ const s = t[i].level;
1056
+ for (let r = i + 1; r < t.length && !(t[r].level <= s); r++)
1057
+ if (t[r].level === s + 1) {
1058
+ this._focusRowById(t[r].node.id);
1059
+ return;
1060
+ }
1061
+ }
1062
+ async _handleRowKeyDown(e, t) {
1063
+ var d;
1064
+ const i = e.currentTarget;
1065
+ if (e.target !== i)
1066
+ return;
1067
+ const s = this._getVisibleTreeRows(), r = s.findIndex((l) => l.node.id === t.id), o = this._nodeHasChildren(t), a = this._expandedIds.has(t.id);
1068
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1069
+ const l = e.key === "ArrowDown" ? r + 1 : r - 1;
1070
+ l >= 0 && l < s.length && (e.preventDefault(), this._focusRowById(s[l].node.id));
1071
+ return;
1072
+ }
1073
+ if (e.key === "Home" || e.key === "End") {
1074
+ if (s.length === 0) return;
1075
+ e.preventDefault();
1076
+ const l = e.key === "Home" ? s[0] : s[s.length - 1];
1077
+ this._focusRowById(l.node.id);
1078
+ return;
1079
+ }
1080
+ if (e.key === "ArrowRight") {
1081
+ if (!o) return;
1082
+ if (e.preventDefault(), !a) {
1083
+ await this._toggleExpand(t, !0);
1084
+ return;
1085
+ }
1086
+ this._focusFirstVisibleChild(t.id);
1087
+ return;
1088
+ }
1089
+ if (e.key === "ArrowLeft") {
1090
+ if (e.preventDefault(), o && a) {
1091
+ await this._toggleExpand(t, !1), i.focus();
1092
+ return;
1093
+ }
1094
+ const l = this._getParentId(t.id);
1095
+ l !== void 0 && this._focusRowById(l);
1096
+ return;
1097
+ }
1098
+ if (e.key === "Enter" || e.key === " ") {
1099
+ e.preventDefault(), this._enableChildren(i);
1100
+ const l = i.querySelector(
485
1101
  "nyx-checkbox input, nyx-button:not([disabled])"
486
1102
  );
487
- if (r)
488
- if (r instanceof HTMLInputElement)
489
- r.focus();
1103
+ if (l)
1104
+ if (l instanceof HTMLInputElement)
1105
+ l.focus();
490
1106
  else {
491
- const i = (t = r.shadowRoot) == null ? void 0 : t.querySelector("button");
492
- i == null || i.focus();
1107
+ const c = (d = l.shadowRoot) == null ? void 0 : d.querySelector("button");
1108
+ c == null || c.focus();
493
1109
  }
494
1110
  return;
495
1111
  }
496
- o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), this._disableChildren(n), n.focus());
1112
+ e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this._disableChildren(i), i.focus());
497
1113
  }
498
- _handleRowFocusOut(o) {
499
- const e = o.currentTarget;
500
- e.contains(o.relatedTarget) || this._disableChildren(e);
1114
+ _handleRowFocusOut(e) {
1115
+ const t = e.currentTarget;
1116
+ t.contains(e.relatedTarget) || this._disableChildren(t);
501
1117
  }
502
- _enableChildren(o) {
503
- const e = o.querySelectorAll('input[slot="input"]'), n = o.querySelectorAll("nyx-button");
504
- e.forEach((t) => t.setAttribute("tabindex", "0")), n.forEach((t) => t.removeAttribute("tabindex"));
1118
+ _enableChildren(e) {
1119
+ const t = e.querySelectorAll('input[slot="input"]'), i = e.querySelectorAll("nyx-button");
1120
+ t.forEach((s) => s.setAttribute("tabindex", "0")), i.forEach((s) => s.removeAttribute("tabindex"));
505
1121
  }
506
- _disableChildren(o) {
507
- const e = o.querySelectorAll('input[slot="input"]'), n = o.querySelectorAll("nyx-button");
508
- e.forEach((t) => t.setAttribute("tabindex", "-1")), n.forEach((t) => t.setAttribute("tabindex", "-1"));
1122
+ _disableChildren(e) {
1123
+ const t = e.querySelectorAll('input[slot="input"]'), i = e.querySelectorAll("nyx-button");
1124
+ t.forEach((s) => s.setAttribute("tabindex", "-1")), i.forEach((s) => s.setAttribute("tabindex", "-1"));
509
1125
  }
510
1126
  _clearAllFocus() {
511
- var n, t;
512
- const o = (n = this.shadowRoot) == null ? void 0 : n.activeElement;
513
- o == null || o.blur();
514
- const e = (t = this.shadowRoot) == null ? void 0 : t.querySelectorAll(".node-row");
515
- e == null || e.forEach((r) => {
1127
+ var i, s;
1128
+ const e = (i = this.shadowRoot) == null ? void 0 : i.activeElement;
1129
+ e == null || e.blur();
1130
+ const t = (s = this.shadowRoot) == null ? void 0 : s.querySelectorAll(".node-row");
1131
+ t == null || t.forEach((r) => {
516
1132
  this._disableChildren(r);
517
1133
  });
518
1134
  }
1135
+ _renderRowSelectionCheckbox(e) {
1136
+ return this._showRowSelection() ? h`
1137
+ <div class="row-checkbox">
1138
+ <nyx-checkbox
1139
+ aria-label=${ye(e.label)}
1140
+ ?checked=${this._isRowCheckboxChecked(e)}
1141
+ ?indeterminate=${this._isRowCheckboxIndeterminate(e)}
1142
+ @click=${(t) => {
1143
+ t.stopPropagation(), this._handleRowCheck(e);
1144
+ }}
1145
+ >
1146
+ <input type="checkbox" slot="input" tabindex="-1" />
1147
+ </nyx-checkbox>
1148
+ </div>
1149
+ ` : w;
1150
+ }
1151
+ _renderNodeIconCell(e) {
1152
+ return this._showNodeIcons() ? h`
1153
+ <div class="node-type-icon-wrapper">
1154
+ ${this._isLazyEnabled() ? this._renderNodeTypeIcon(e) : h`<slot name="generated-tree-icon-${e.id}"></slot>`}
1155
+ </div>
1156
+ ` : w;
1157
+ }
1158
+ _renderColumnCheckboxes(e) {
1159
+ return this._hasColumnPermissions() ? h`
1160
+ <div class="node-columns">
1161
+ ${this.options.columns.map(
1162
+ (t) => h`
1163
+ <div class="col-cell">
1164
+ <nyx-checkbox
1165
+ aria-label=${Ie(
1166
+ t.title || `Column ${t.id}`,
1167
+ e.label
1168
+ )}
1169
+ ?checked=${this._allDescendantsSelected(
1170
+ this._selectionNode(e),
1171
+ t.id
1172
+ )}
1173
+ ?indeterminate=${this._isIndeterminate(
1174
+ this._selectionNode(e),
1175
+ t.id
1176
+ )}
1177
+ ?disabled=${this._isColumnDisabled(
1178
+ this._selectionNode(e),
1179
+ t.id
1180
+ )}
1181
+ @click=${(i) => {
1182
+ if (i.stopPropagation(), this._isColumnDisabled(this._selectionNode(e), t.id)) {
1183
+ i.preventDefault();
1184
+ return;
1185
+ }
1186
+ this._handleCheck(this._selectionNode(e), t.id);
1187
+ }}
1188
+ >
1189
+ <input type="checkbox" slot="input" tabindex="-1" />
1190
+ </nyx-checkbox>
1191
+ </div>
1192
+ `
1193
+ )}
1194
+ </div>
1195
+ ` : w;
1196
+ }
519
1197
  render() {
520
- var o, e, n;
521
- return l`
522
- <div class="nyx-treeview" @mousedown=${() => this._clearAllFocus()}>
1198
+ var i, s, r;
1199
+ const e = this._hasColumnPermissions(), t = e ? ((s = (i = this.options) == null ? void 0 : i.columns) == null ? void 0 : s.length) ?? 0 : 0;
1200
+ return h`
1201
+ <div
1202
+ class=${b({
1203
+ "nyx-treeview": !0,
1204
+ "nyx-treeview--no-columns": !e,
1205
+ "nyx-treeview--row-selection": this._showRowSelection(),
1206
+ "nyx-treeview--virtual": this._isLazyEnabled()
1207
+ })}
1208
+ style=${`--treeview-column-count: ${t};`}
1209
+ @mousedown=${() => this._clearAllFocus()}
1210
+ >
523
1211
  <div class="search-container">
524
1212
  <nyx-input>
525
- <nyx-icon .svg=${Q} slot="iconLeft"></nyx-icon>
1213
+ <nyx-icon .svg=${J} slot="iconLeft"></nyx-icon>
526
1214
  <input
527
1215
  class="search-input"
528
1216
  type="text"
529
1217
  slot="field"
530
- placeholder="Search..."
531
- @input=${(t) => this._searchTerm = t.target.value}
1218
+ placeholder="Search"
1219
+ aria-label="Search"
1220
+ @input=${this._handleSearchInput}
532
1221
  />
533
1222
  </nyx-input>
1223
+ <div
1224
+ class="search-status visually-hidden"
1225
+ role="status"
1226
+ aria-live="polite"
1227
+ aria-atomic="true"
1228
+ >
1229
+ ${this._searchStatusMessage}
1230
+ </div>
534
1231
  </div>
535
1232
 
536
1233
  <div class="tree-scroll">
537
- <div class="tree-header">
538
- <div class="tree-title">${(o = this.options) == null ? void 0 : o.title}</div>
539
- <div class="header-columns">
540
- ${(n = (e = this.options) == null ? void 0 : e.columns) == null ? void 0 : n.map(
541
- (t, r) => l`
542
- <div class="col-cell" title="${t.title || ""}">
543
- <slot name="generated-header-icon-${r}"></slot>
544
- </div>
545
- `
1234
+ <div
1235
+ class=${b({
1236
+ "tree-header": !0,
1237
+ "tree-header--no-columns": !e
1238
+ })}
1239
+ >
1240
+ <div class="tree-title">${(r = this.options) == null ? void 0 : r.title}</div>
1241
+ ${e ? h`
1242
+ <div class="header-columns">
1243
+ ${this.options.columns.map(
1244
+ (o, a) => h`
1245
+ <div class="col-cell" title="${o.title || ""}">
1246
+ <slot name="generated-header-icon-${a}"></slot>
1247
+ </div>
1248
+ `
546
1249
  )}
547
- </div>
1250
+ </div>
1251
+ ` : w}
548
1252
  </div>
549
1253
 
550
- <div class="tree-body">${this._renderNodes(this._items, 0)}</div>
1254
+ <div
1255
+ class=${b({
1256
+ "tree-body": !0,
1257
+ "tree-body--virtual": this._isLazyEnabled()
1258
+ })}
1259
+ role="tree"
1260
+ aria-label=${this._getTreeAriaLabel()}
1261
+ >
1262
+ ${this._isLazyEnabled() ? h`
1263
+ <lit-virtualizer
1264
+ scroller
1265
+ class="tree-virtualizer"
1266
+ .items=${this._flatRows}
1267
+ .estimateSize=${48}
1268
+ .renderItem=${(o) => this._renderFlatRow(o)}
1269
+ @visibilityChanged=${this._onVirtualizerVisibilityChanged}
1270
+ ></lit-virtualizer>
1271
+ ` : this._renderNodes(this._items, 0)}
1272
+ </div>
551
1273
  </div>
552
1274
  </div>
553
1275
  `;
554
1276
  }
555
- _renderNodes(o, e) {
556
- var r;
557
- const n = o.filter(
558
- (i) => !this._searchTerm || i.label.toLowerCase().includes(this._searchTerm.toLowerCase()) || i.children && i.children.some(
559
- (p) => p.label.toLowerCase().includes(this._searchTerm.toLowerCase())
560
- )
561
- ), t = 16 + e * 24 - ((r = this.options) != null && r.showRowSelection ? 4 : 0);
562
- return U(
563
- n,
564
- (i) => i.id,
565
- (i) => {
566
- var I, D, P, T;
567
- const p = this._expandedIds.has(i.id), L = i.children && i.children.length > 0, N = this._isRowAllSelected(i), F = this._isRowIndeterminate(i), H = !!((I = this.options) != null && I.showRowSelection);
568
- return l`
1277
+ _renderFlatRow(e) {
1278
+ const { node: t, level: i, revealSubtree: s, parentLabelMatched: r } = e, o = this._expandedIds.has(t.id), a = e.hasChildrenInSource, d = this._showRowSelection(), l = this._isRowCheckboxChecked(t) || this._isRowCheckboxIndeterminate(t);
1279
+ return h`
1280
+ <div class="node-wrapper node-wrapper--flat">
1281
+ ${this._renderTreeRow(t, i, {
1282
+ isExpanded: o,
1283
+ hasChildren: a,
1284
+ isRowHighlighted: l,
1285
+ isSelectable: d
1286
+ })}
1287
+ </div>
1288
+ `;
1289
+ }
1290
+ _renderNodes(e, t, i = !1, s = !1, r = !1) {
1291
+ const o = !!this._searchTerm.trim(), a = this._searchTerm.trim().toLowerCase(), d = o && !r ? e.filter((l) => this._searchVisibleIds.has(l.id)) : e;
1292
+ return Y(
1293
+ d,
1294
+ (l) => l.id,
1295
+ (l) => {
1296
+ const c = this._expandedIds.has(l.id), m = this._isLazyEnabled() ? this._sourceHasChildren(l.id) : !!(l.children && l.children.length > 0), p = this._isRowCheckboxChecked(l) || this._isRowCheckboxIndeterminate(l), v = this._showRowSelection(), S = H(
1297
+ l.label,
1298
+ a,
1299
+ i,
1300
+ s
1301
+ ), N = !o || S && z(
1302
+ l.label,
1303
+ a,
1304
+ s,
1305
+ l.id,
1306
+ this._searchVisibleIds,
1307
+ (C) => this._getSourceChildren(C)
1308
+ ) ? l.children : U(l, this._searchVisibleIds, a), g = s || o && !!a && l.label.toLowerCase().includes(a);
1309
+ return h`
569
1310
  <div class="node-wrapper">
570
- <div
571
- id="row-${i.id}"
572
- class=${O({
573
- "node-row": !0,
574
- selectable: H,
575
- selected: N || F
1311
+ ${this._renderTreeRow(l, t, {
1312
+ isExpanded: c,
1313
+ hasChildren: m,
1314
+ isRowHighlighted: p,
1315
+ isSelectable: v
576
1316
  })}
577
- style="padding-left: ${t}px;"
578
- tabindex="0"
579
- @mousedown=${(s) => s.preventDefault()}
580
- @keydown=${(s) => this._handleRowKeyDown(s, i)}
581
- @focusout=${this._handleRowFocusOut}
582
- >
583
- <div class="node-info">
584
- ${(D = this.options) != null && D.showRowSelection ? l`
585
- <div class="row-checkbox">
586
- <nyx-checkbox
587
- ?checked=${this._isRowAllSelected(i)}
588
- ?indeterminate=${this._isRowIndeterminate(i)}
589
- @click=${(s) => {
590
- s.stopPropagation(), this._handleRowCheck(i);
591
- }}
592
- >
593
- <input type="checkbox" slot="input" tabindex="-1" />
594
- </nyx-checkbox>
595
- </div>
596
- ` : y}
597
- ${L ? l`
598
- <nyx-button
599
- class="expander"
600
- size="small"
601
- button-icon
602
- tabindex="-1"
603
- hierarchy="ghost"
604
- @click=${() => this._toggleExpand(i, !1)}
605
- @keydown=${(s) => {
606
- (s.key === "Enter" || s.key === " ") && (s.preventDefault(), s.stopPropagation(), this._toggleExpand(i, !0));
607
- }}
608
- >
609
- <nyx-icon
610
- slot="icon"
611
- class=${O({ expanded: p })}
612
- .svg=${X}
613
- ></nyx-icon>
614
- </nyx-button>
615
- ` : y}
616
- <div class="node-type-icon-wrapper">
617
- <slot name="generated-tree-icon-${i.id}"></slot>
618
- </div>
619
- <span class="node-text" title="${i.label}"
620
- >${i.label}</span
621
- >
622
- </div>
623
- <div class="node-columns">
624
- ${(T = (P = this.options) == null ? void 0 : P.columns) == null ? void 0 : T.map(
625
- (s) => l`
626
- <div class="col-cell">
627
- <nyx-checkbox
628
- ?checked=${this._allDescendantsSelected(i, s.id)}
629
- ?indeterminate=${this._isIndeterminate(i, s.id)}
630
- ?disabled=${this._isColumnDisabled(i, s.id)}
631
- @click=${() => this._handleCheck(i, s.id)}
632
- >
633
- <input type="checkbox" slot="input" tabindex="-1" />
634
- </nyx-checkbox>
635
- </div>
636
- `
1317
+ ${c && m ? h`<div class="node-children" role="group">
1318
+ ${this._renderNodes(
1319
+ N,
1320
+ t + 1,
1321
+ S,
1322
+ g,
1323
+ !0
637
1324
  )}
638
- </div>
639
- </div>
640
- ${p && L ? l`<div class="node-children">
641
- ${this._renderNodes(i.children, e + 1)}
642
1325
  </div>` : ""}
643
1326
  </div>
644
1327
  `;
@@ -646,24 +1329,45 @@ const R = class R extends k {
646
1329
  );
647
1330
  }
648
1331
  };
649
- R.styles = m(Z);
650
- let g = R;
651
- z([
652
- a({ type: Object })
653
- ], g.prototype, "options");
654
- z([
1332
+ $.styles = G(te);
1333
+ let u = $;
1334
+ _([
1335
+ K({ type: Object, noAccessor: !0 })
1336
+ ], u.prototype, "options", 1);
1337
+ _([
1338
+ f()
1339
+ ], u.prototype, "_items", 2);
1340
+ _([
1341
+ f()
1342
+ ], u.prototype, "_expandedIds", 2);
1343
+ _([
1344
+ f()
1345
+ ], u.prototype, "_searchTerm", 2);
1346
+ _([
1347
+ f()
1348
+ ], u.prototype, "_searchStatusMessage", 2);
1349
+ _([
1350
+ f()
1351
+ ], u.prototype, "_searchVisibleIds", 2);
1352
+ _([
1353
+ f()
1354
+ ], u.prototype, "_searchUserCollapsedIds", 2);
1355
+ _([
1356
+ f()
1357
+ ], u.prototype, "_searchManualExpandedIds", 2);
1358
+ _([
655
1359
  f()
656
- ], g.prototype, "_items");
657
- z([
1360
+ ], u.prototype, "_flatRows", 2);
1361
+ _([
658
1362
  f()
659
- ], g.prototype, "_expandedIds");
660
- z([
1363
+ ], u.prototype, "_loadedIds", 2);
1364
+ _([
661
1365
  f()
662
- ], g.prototype, "_searchTerm");
663
- z([
664
- q("nyx-change")
665
- ], g.prototype, "onChange");
666
- customElements.get("nyx-treeview") || customElements.define("nyx-treeview", g);
1366
+ ], u.prototype, "_activeRowId", 2);
1367
+ _([
1368
+ ee("nyx-change")
1369
+ ], u.prototype, "onChange", 2);
1370
+ customElements.get("nyx-treeview") || customElements.define("nyx-treeview", u);
667
1371
  export {
668
- g as NyxTreeview
1372
+ u as NyxTreeview
669
1373
  };