@truenas/ui-components 0.3.24 → 0.3.25

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.
@@ -13,7 +13,7 @@ import { mdiCheckCircle, mdiAlertCircle, mdiAlert, mdiInformation, mdiOpenInNew,
13
13
  import * as i1$1 from '@angular/platform-browser';
14
14
  import { DomSanitizer } from '@angular/platform-browser';
15
15
  import { HttpClient } from '@angular/common/http';
16
- import { firstValueFrom, BehaviorSubject, Subject, merge, animationFrameScheduler, asapScheduler, take } from 'rxjs';
16
+ import { firstValueFrom, BehaviorSubject, merge, animationFrameScheduler, asapScheduler, Subject, take } from 'rxjs';
17
17
  import { RouterLink } from '@angular/router';
18
18
  import { filesize } from 'filesize';
19
19
  import { CdkMenu, CdkMenuItem, CdkMenuTrigger } from '@angular/cdk/menu';
@@ -25,7 +25,7 @@ import { SelectionModel, DataSource } from '@angular/cdk/collections';
25
25
  import * as i2 from '@angular/cdk/tree';
26
26
  import { CdkTree, CdkTreeModule, CdkTreeNode, CDK_TREE_NODE_OUTLET_NODE, CdkNestedTreeNode, CdkTreeNodeOutlet, FlatTreeControl, NestedTreeControl, CdkTreeNodeOutletContext } from '@angular/cdk/tree';
27
27
  export { FlatTreeControl } from '@angular/cdk/tree';
28
- import { map, filter, debounceTime, distinctUntilChanged, takeUntil, auditTime } from 'rxjs/operators';
28
+ import { map, filter, debounceTime, distinctUntilChanged, auditTime } from 'rxjs/operators';
29
29
  import { CdkVirtualScrollViewport, CdkVirtualScrollableWindow, CdkFixedSizeVirtualScroll, CdkVirtualForOf, ScrollingModule } from '@angular/cdk/scrolling';
30
30
  import { DialogRef, DIALOG_DATA, Dialog } from '@angular/cdk/dialog';
31
31
 
@@ -11694,7 +11694,6 @@ class TnTreeFlatDataSource extends DataSource {
11694
11694
  _filteredData = new BehaviorSubject([]);
11695
11695
  filterValue = '';
11696
11696
  filterChanged$ = new BehaviorSubject('');
11697
- disconnect$ = new Subject();
11698
11697
  constructor(_treeControl, _treeFlattener) {
11699
11698
  super();
11700
11699
  this._treeControl = _treeControl;
@@ -11709,9 +11708,9 @@ class TnTreeFlatDataSource extends DataSource {
11709
11708
  }
11710
11709
  this.flattenData();
11711
11710
  }
11712
- /** The currently filtered (unflattened) data; equals `data` until `filter()` is used. */
11711
+ /** The currently filtered (unflattened) data; equals `data` while no filter query is active. */
11713
11712
  get filteredData() {
11714
- return this._filteredData.value;
11713
+ return this.filterValue ? this._filteredData.value : this.data;
11715
11714
  }
11716
11715
  connect() {
11717
11716
  return merge(this._treeControl.expansionModel.changed, this._flattenedData).pipe(map(() => {
@@ -11719,10 +11718,7 @@ class TnTreeFlatDataSource extends DataSource {
11719
11718
  return this._expandedData.value;
11720
11719
  }));
11721
11720
  }
11722
- disconnect() {
11723
- this.disconnect$.next();
11724
- this.disconnect$.complete();
11725
- }
11721
+ disconnect() { }
11726
11722
  /** Filters the tree using `filterPredicate` (debounced). No-op until `filterPredicate` is set. */
11727
11723
  filter(query) {
11728
11724
  this.filterChanged$.next(query);
@@ -11731,8 +11727,15 @@ class TnTreeFlatDataSource extends DataSource {
11731
11727
  this._flattenedData.next(this._treeFlattener.flattenNodes(this.filterValue ? this._filteredData.value : this.data));
11732
11728
  this._treeControl.dataNodes = this._flattenedData.value;
11733
11729
  }
11730
+ /**
11731
+ * Deliberately NOT torn down in `disconnect()`: CdkTree disconnects the
11732
+ * datasource when the tree is destroyed, but the same instance may be
11733
+ * reconnected (e.g. a tree behind an `@if`), and filtering must survive that.
11734
+ * The pipeline only references the datasource's own subjects, so it holds no
11735
+ * external resources and is collected with the instance.
11736
+ */
11734
11737
  detectFilterChanges() {
11735
- this.filterChanged$.pipe(filter(() => !!this.filterPredicate), debounceTime(200), distinctUntilChanged(), takeUntil(this.disconnect$)).subscribe((changedValue) => {
11738
+ this.filterChanged$.pipe(filter(() => !!this.filterPredicate), debounceTime(200), distinctUntilChanged()).subscribe((changedValue) => {
11736
11739
  if (this.filterValue === changedValue || !this.filterPredicate) {
11737
11740
  return;
11738
11741
  }
@@ -11823,6 +11826,10 @@ class TnNestedTreeNodeComponent extends CdkNestedTreeNode {
11823
11826
  /**
11824
11827
  * Suppresses the built-in toggle button (and its alignment spacer) so the
11825
11828
  * consumer can render a fully custom toggle in the projected content.
11829
+ *
11830
+ * The built-in button is the only keyboard/AT-operable expand control this
11831
+ * component guarantees — when hiding it, the projected replacement must be
11832
+ * an accessible control (a real button with an aria-label, not a bare icon).
11826
11833
  */
11827
11834
  hideToggle = input(false, { ...(ngDevMode ? { debugName: "hideToggle" } : {}), transform: booleanAttribute });
11828
11835
  changeDetectorRef = inject(ChangeDetectorRef);
@@ -11911,6 +11918,9 @@ class TnNestedTreeNodeComponent extends CdkNestedTreeNode {
11911
11918
  else {
11912
11919
  this._tree.toggle(this.data);
11913
11920
  }
11921
+ // Mirrors CdkTreeNodeToggle's focus handling. `_keyManager` is a CDK
11922
+ // underscore member, so a CDK upgrade may rename it — the optional call
11923
+ // degrades to "focus not moved" rather than breaking the toggle.
11914
11924
  this._tree._keyManager?.focusItem(this);
11915
11925
  }
11916
11926
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: TnNestedTreeNodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
@@ -11959,13 +11969,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
11959
11969
  class TnNestedTreeDataSource extends DataSource {
11960
11970
  /** When set, `filter(query)` re-renders the tree from `filterPredicate(data, query)`. */
11961
11971
  filterPredicate;
11962
- /** When set, incoming `data` is sorted recursively before rendering. */
11972
+ /**
11973
+ * When set, incoming `data` is sorted recursively before rendering.
11974
+ *
11975
+ * Note: sorting REWRITES `children` arrays on the caller's node objects
11976
+ * (a new sorted array is assigned per node). Node object identity is
11977
+ * preserved — deliberately, since tree controls track expansion state by
11978
+ * node identity — but don't pass an object graph that is shared with code
11979
+ * relying on the original child order.
11980
+ */
11963
11981
  sortComparer;
11964
11982
  filterValue = '';
11965
11983
  filterChanged$ = new BehaviorSubject('');
11966
11984
  _data = new BehaviorSubject([]);
11967
11985
  _filteredData = new BehaviorSubject([]);
11968
- disconnect$ = new Subject();
11969
11986
  get data() {
11970
11987
  return this._data.value;
11971
11988
  }
@@ -11982,16 +11999,20 @@ class TnNestedTreeDataSource extends DataSource {
11982
11999
  connect(collectionViewer) {
11983
12000
  return merge(collectionViewer.viewChange, this._data, this._filteredData).pipe(map(() => (this.filterValue ? this._filteredData.value : this.data)));
11984
12001
  }
11985
- disconnect() {
11986
- this.disconnect$.next();
11987
- this.disconnect$.complete();
11988
- }
12002
+ disconnect() { }
11989
12003
  /** Filters the tree using `filterPredicate` (debounced). No-op until `filterPredicate` is set. */
11990
12004
  filter(query) {
11991
12005
  this.filterChanged$.next(query);
11992
12006
  }
12007
+ /**
12008
+ * Deliberately NOT torn down in `disconnect()`: CdkTree disconnects the
12009
+ * datasource when the tree is destroyed, but the same instance may be
12010
+ * reconnected (e.g. a tree behind an `@if`), and filtering must survive that.
12011
+ * The pipeline only references the datasource's own subjects, so it holds no
12012
+ * external resources and is collected with the instance.
12013
+ */
11993
12014
  detectFilterChanges() {
11994
- this.filterChanged$.pipe(filter(() => !!this.filterPredicate), debounceTime(200), distinctUntilChanged(), takeUntil(this.disconnect$)).subscribe((changedValue) => {
12015
+ this.filterChanged$.pipe(filter(() => !!this.filterPredicate), debounceTime(200), distinctUntilChanged()).subscribe((changedValue) => {
11995
12016
  if (this.filterValue === changedValue || !this.filterPredicate) {
11996
12017
  return;
11997
12018
  }
@@ -12128,6 +12149,10 @@ class TnTreeNodeHarness extends ComponentHarness {
12128
12149
  /**
12129
12150
  * Toggles the node together with all of its descendants (Alt+click on the
12130
12151
  * built-in nested-node toggle).
12152
+ *
12153
+ * Only nested nodes honor the Alt modifier — on a flat node the row's
12154
+ * `cdkTreeNodeToggle` is not Alt-aware, so this degrades to a plain
12155
+ * single-level toggle.
12131
12156
  */
12132
12157
  async toggleWithDescendants() {
12133
12158
  await (await this.getToggle()).click({ alt: true });