@nanahoshi/mona-ui 0.24.7 → 0.24.8

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.
Files changed (67) hide show
  1. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
  2. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
  3. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1 -1
  4. package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-vXXNWmEN.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DdyHnUIr.mjs} +2 -2
  5. package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-DDgNmgE0.mjs → nanahoshi-mona-ui-grid-grid-list.component-B6gq7Hu3.mjs} +4 -4
  6. package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-Dzf6Vbs_.mjs → nanahoshi-mona-ui-grid-grid-row.component-DdUY3I7P.mjs} +2 -2
  7. package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-DAPNqnWV.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-DG8Bu4Dy.mjs} +4 -4
  8. package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-B9rmDLq8.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CVqpbMcb.mjs} +8 -8
  9. package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
  10. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +40 -3
  11. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +20 -4
  12. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +335 -45
  13. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +565 -197
  14. package/fesm2022/nanahoshi-mona-ui-internal.mjs +28 -2
  15. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +598 -208
  16. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +193 -71
  17. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +25 -3
  18. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +29 -3
  19. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +29 -3
  20. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +36 -3
  21. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +25 -3
  22. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +29 -3
  23. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +25 -3
  24. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +25 -3
  25. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +29 -3
  26. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +45 -3
  27. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +25 -3
  28. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +25 -3
  29. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +25 -3
  30. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1 -1
  31. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +205 -140
  32. package/i18n/catalogs/en-US.messages.json +28 -6
  33. package/locales/ar-sa/ar-sa.messages.json +25 -3
  34. package/locales/de-de/de-de.messages.json +25 -3
  35. package/locales/es-es/es-es.messages.json +25 -3
  36. package/locales/fr-fr/fr-fr.messages.json +25 -3
  37. package/locales/id-id/id-id.messages.json +25 -3
  38. package/locales/it-it/it-it.messages.json +25 -3
  39. package/locales/ja-jp/ja-jp.messages.json +25 -3
  40. package/locales/ko-kr/ko-kr.messages.json +25 -3
  41. package/locales/pt-br/pt-br.messages.json +25 -3
  42. package/locales/ru-ru/ru-ru.messages.json +25 -3
  43. package/locales/tr-tr/tr-tr.messages.json +25 -3
  44. package/locales/zh-cn/zh-cn.messages.json +25 -3
  45. package/locales/zh-tw/zh-tw.messages.json +25 -3
  46. package/package.json +1 -1
  47. package/types/nanahoshi-mona-ui-i18n.d.ts +50 -0
  48. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +14 -2
  49. package/types/nanahoshi-mona-ui-internal-list.d.ts +89 -10
  50. package/types/nanahoshi-mona-ui-internal-tree.d.ts +155 -40
  51. package/types/nanahoshi-mona-ui-internal.d.ts +10 -2
  52. package/types/nanahoshi-mona-ui-list-box.d.ts +148 -47
  53. package/types/nanahoshi-mona-ui-list-view.d.ts +112 -21
  54. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +22 -0
  55. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +22 -0
  56. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +22 -0
  57. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +22 -0
  58. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +22 -0
  59. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +22 -0
  60. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +22 -0
  61. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +22 -0
  62. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +22 -0
  63. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +22 -0
  64. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +22 -0
  65. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +22 -0
  66. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +22 -0
  67. package/types/nanahoshi-mona-ui-tree-view.d.ts +84 -40
@@ -1,53 +1,101 @@
1
+ import { LiveAnnouncer } from '@angular/cdk/a11y';
1
2
  import { NgTemplateOutlet } from '@angular/common';
2
3
  import * as i0 from '@angular/core';
3
- import { Directive, inject, DestroyRef, computed, contentChild, TemplateRef, input, output, effect, untracked, afterNextRender, Component } from '@angular/core';
4
+ import { input, Directive, inject, ElementRef, NgZone, computed, contentChild, TemplateRef, booleanAttribute, output, effect, untracked, DestroyRef, isDevMode, afterNextRender, Component, model } from '@angular/core';
4
5
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
+ import { MonaI18nService } from '@nanahoshi/mona-ui/i18n';
7
+ import { injectLabelledByText, createElementControlId } from '@nanahoshi/mona-ui/internal';
5
8
  import { FilterInputComponent } from '@nanahoshi/mona-ui/internal/filter-input';
6
9
  import { TREE_DEFAULT_MESSAGES, TreeService, TreeComponent, TreeNodeTemplateDirective, NodeDropEvent } from '@nanahoshi/mona-ui/internal/tree';
7
- export { NodeCheckEvent, NodeClickEvent, NodeDragEndEvent, NodeDragEvent, NodeDragStartEvent, NodeDropEvent, moveFlatTreeNode, moveTreeNode } from '@nanahoshi/mona-ui/internal/tree';
8
- import { MonaI18nService } from '@nanahoshi/mona-ui/i18n';
9
- import { sequenceEqual } from '@mirei/ts-collections';
10
- import { pairwise } from 'rxjs';
10
+ export { NodeCheckEvent, NodeClickEvent, NodeDragEndEvent, NodeDragEvent, NodeDragStartEvent, NodeDropEvent, NodeSelectEvent, moveFlatTreeNode, moveTreeNode } from '@nanahoshi/mona-ui/internal/tree';
11
+ import { PlaceholderComponent } from '@nanahoshi/mona-ui/placeholder';
11
12
 
13
+ /**
14
+ * Template for each node's content. The data item is the template's implicit value (`let-dataItem`) and the node's
15
+ * element is `element`. Bind the tree view's data to `monaTreeViewNodeTemplateOf` to type the data item; without it,
16
+ * the data item is `any` in templates.
17
+ */
18
+ // `any` by default: a template without `monaTreeViewNodeTemplateOf` keeps an untyped data item, as before the guard.
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
20
  class TreeViewNodeTemplateDirective {
21
+ constructor() {
22
+ /**
23
+ * @description The tree view's data, used only to type the template's data item. Optional.
24
+ * @default null
25
+ */
26
+ this.monaTreeViewNodeTemplateOf = input(null, /* @ts-ignore */
27
+ ...(ngDevMode ? [{ debugName: "monaTreeViewNodeTemplateOf" }] : /* istanbul ignore next */ []));
28
+ }
29
+ static ngTemplateContextGuard(_directive, _context) {
30
+ return true;
31
+ }
13
32
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewNodeTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
14
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: TreeViewNodeTemplateDirective, isStandalone: true, selector: "ng-template[monaTreeViewNodeTemplate]", ngImport: i0 }); }
33
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TreeViewNodeTemplateDirective, isStandalone: true, selector: "ng-template[monaTreeViewNodeTemplate]", inputs: { monaTreeViewNodeTemplateOf: { classPropertyName: "monaTreeViewNodeTemplateOf", publicName: "monaTreeViewNodeTemplateOf", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
15
34
  }
16
35
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewNodeTemplateDirective, decorators: [{
17
36
  type: Directive,
18
37
  args: [{
19
38
  selector: "ng-template[monaTreeViewNodeTemplate]"
20
39
  }]
21
- }] });
40
+ }], propDecorators: { monaTreeViewNodeTemplateOf: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaTreeViewNodeTemplateOf", required: false }] }] } });
22
41
 
23
42
  const TREE_VIEW_DEFAULT_MESSAGES = TREE_DEFAULT_MESSAGES;
24
43
 
44
+ /** A load that finishes within this time isn't announced; the children just appear. */
45
+ const LOADING_ANNOUNCEMENT_DELAY = 400;
25
46
  class TreeViewComponent {
26
- #destroyRef;
47
+ #announcer;
48
+ #hostElementRef;
27
49
  #i18n;
50
+ #labelledByText;
51
+ #loadingTimers;
52
+ #zone;
53
+ /** The filter text the user typed, announced with its result count once the tree applies it. */
54
+ #pendingFilterAnnouncement;
28
55
  constructor() {
29
- this.#destroyRef = inject(DestroyRef);
56
+ this.#announcer = inject(LiveAnnouncer);
57
+ this.#hostElementRef = inject(ElementRef);
30
58
  this.#i18n = inject(MonaI18nService);
59
+ this.#labelledByText = injectLabelledByText(() => this.ariaLabelledBy());
60
+ this.#loadingTimers = new Set();
61
+ this.#zone = inject(NgZone);
62
+ /** The filter text the user typed, announced with its result count once the tree applies it. */
63
+ this.#pendingFilterAnnouncement = null;
64
+ this.empty = computed(() => this.treeService.viewNodeSet().isEmpty(), /* @ts-ignore */
65
+ ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
66
+ this.emptyText = computed(() => this.treeService.isTreeFiltered() ? this.messages().noMatches : this.messages().noData, /* @ts-ignore */
67
+ ...(ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []));
68
+ /** "Filter {name}", from the tree's `ariaLabel` or else the text of its `ariaLabelledBy` elements. */
31
69
  this.filterAriaLabel = computed(() => {
32
- const ariaLabel = this.ariaLabel();
33
- return ariaLabel ? `${this.messages().filter} ${ariaLabel}` : this.messages().filterTree;
70
+ const name = this.ariaLabel().trim() || this.#labelledByText();
71
+ return name ? this.messages().filterLabel(name) : this.messages().filterTree;
34
72
  }, /* @ts-ignore */
35
73
  ...(ngDevMode ? [{ debugName: "filterAriaLabel" }] : /* istanbul ignore next */ []));
36
74
  this.messages = this.#i18n.componentMessages("treeView", TREE_VIEW_DEFAULT_MESSAGES);
37
75
  this.nodeTemplate = contentChild(TreeViewNodeTemplateDirective, { ...(ngDevMode ? { debugName: "nodeTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
76
+ this.statusId = `${createElementControlId()}-status`;
77
+ this.treeId = createElementControlId();
38
78
  this.treeService = inject((TreeService));
39
79
  /**
40
- * @description Enables CSS transitions when nodes expand or collapse.
80
+ * @description Enables CSS transitions when nodes expand or collapse. Accepts the attribute form
81
+ * (`animate="false"`).
41
82
  * @default true
42
83
  */
43
- this.animate = input(true, /* @ts-ignore */
44
- ...(ngDevMode ? [{ debugName: "animate" }] : /* istanbul ignore next */ []));
84
+ this.animate = input(true, { ...(ngDevMode ? { debugName: "animate" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
45
85
  /**
46
- * @description Accessible name for the tree. Describe what the tree represents. When empty, assistive technology announces the role without a label.
86
+ * @description Accessible name of the tree. Describe what the tree represents; it also names the filter input
87
+ * ("Filter {name}"). Set this or `ariaLabelledBy`: an unnamed tree logs a warning in development. A plain
88
+ * `aria-label` attribute on `mona-tree-view` doesn't name the tree.
47
89
  * @default ""
48
90
  */
49
91
  this.ariaLabel = input("", /* @ts-ignore */
50
92
  ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
93
+ /**
94
+ * @description Id of the element that names the tree, as an alternative to `ariaLabel`.
95
+ * @default ""
96
+ */
97
+ this.ariaLabelledBy = input("", /* @ts-ignore */
98
+ ...(ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
51
99
  /**
52
100
  * @description Emitted when the tree-view loses focus.
53
101
  */
@@ -59,6 +107,12 @@ class TreeViewComponent {
59
107
  */
60
108
  this.children = input("", /* @ts-ignore */
61
109
  ...(ngDevMode ? [{ debugName: "children" }] : /* istanbul ignore next */ []));
110
+ /**
111
+ * @description Emitted when the children observable of a node errors. The node is collapsed again and marked
112
+ * as failed (its expander reads "Retry loading {node}"), the failure is announced, and expanding the node
113
+ * retries the load.
114
+ */
115
+ this.childrenLoadError = output();
62
116
  /**
63
117
  * @description Collection of items to render.
64
118
  * @default []
@@ -104,6 +158,12 @@ class TreeViewComponent {
104
158
  */
105
159
  this.textField = input("", /* @ts-ignore */
106
160
  ...(ngDevMode ? [{ debugName: "textField" }] : /* istanbul ignore next */ []));
161
+ // The text is read when nodes render, so changing it doesn't rebuild the nodes (which would undo moves).
162
+ effect(() => {
163
+ const textField = this.textField();
164
+ untracked(() => this.treeService.setTextField(textField));
165
+ });
166
+ // Only the data and its structure rebuild the nodes.
107
167
  effect(() => {
108
168
  const mode = this.mode();
109
169
  if (mode === "flat") {
@@ -112,7 +172,11 @@ class TreeViewComponent {
112
172
  else if (mode === "hierarchical") {
113
173
  this.#setHierarchicalDataStructureFields();
114
174
  }
115
- this.#setGenericDataStructureFields(mode);
175
+ const data = this.data();
176
+ untracked(() => {
177
+ this.treeService.setDataStructure(mode);
178
+ this.treeService.setData(data);
179
+ });
116
180
  });
117
181
  effect(() => {
118
182
  const animate = this.animate();
@@ -120,10 +184,32 @@ class TreeViewComponent {
120
184
  this.treeService.setAnimationEnabled(animate);
121
185
  });
122
186
  });
123
- afterNextRender({
124
- read: () => this.#setSubscriptions()
125
- });
187
+ effect(() => {
188
+ const filterText = this.treeService.filterText();
189
+ const matchCount = this.treeService.matchCount();
190
+ untracked(() => this.#announceFilterResults(filterText, matchCount));
191
+ });
192
+ this.treeService.nodeClick$.pipe(takeUntilDestroyed()).subscribe(event => this.nodeClick.emit(event));
193
+ this.treeService.focus$.pipe(takeUntilDestroyed()).subscribe(event => this.focus.emit(event));
194
+ this.treeService.blur$.pipe(takeUntilDestroyed()).subscribe(event => this.blur.emit(event));
195
+ this.treeService.childrenLoadStart$
196
+ .pipe(takeUntilDestroyed())
197
+ .subscribe(node => this.#announceLoadingAfterDelay(node));
198
+ inject(DestroyRef).onDestroy(() => this.#loadingTimers.forEach(timer => clearTimeout(timer)));
199
+ this.treeService.childrenLoadError$.pipe(takeUntilDestroyed()).subscribe(({ error, node }) => {
200
+ this.#announcer.announce(this.messages().loadError(this.treeService.getNodeText(node)), "polite");
201
+ this.childrenLoadError.emit({ error, node: node.nodeItem });
202
+ });
203
+ if (isDevMode()) {
204
+ afterNextRender({ read: () => this.#warnIfUnnamed() });
205
+ }
126
206
  }
207
+ /**
208
+ * Moves a node in the tree's internal structure, without going through `data`.
209
+ * @returns a snapshot for `undoMoveNode`, or `null` when nothing moved: `position` is `"outside"`, a node isn't
210
+ * in the tree, or the move isn't possible (onto the node itself or into its own subtree, inside its own parent or
211
+ * a disabled node).
212
+ */
127
213
  moveNode(source, target, position) {
128
214
  if (position === "outside") {
129
215
  return null;
@@ -140,7 +226,9 @@ class TreeViewComponent {
140
226
  const originalIndex = sourceNode.parent !== null
141
227
  ? sourceNode.parent.children().toList().indexOf(sourceNode)
142
228
  : this.treeService.nodeSet().toList().indexOf(sourceNode);
143
- this.treeService.moveNode(sourceNode, targetNode, position);
229
+ if (!this.treeService.moveNode(sourceNode, targetNode, position)) {
230
+ return null;
231
+ }
144
232
  return { originalParentUid, originalIndex, sourceNodeUid: sourceNode.uid };
145
233
  }
146
234
  undoMoveNode(snapshot) {
@@ -160,9 +248,37 @@ class TreeViewComponent {
160
248
  onFilterChange(event) {
161
249
  this.treeService.filterChange$.next(event);
162
250
  if (!event.isDefaultPrevented()) {
251
+ this.#pendingFilterAnnouncement = event.filter;
163
252
  this.treeService.filter$.next(event.filter);
164
253
  }
165
254
  }
255
+ /**
256
+ * Announces a load that is still running after a moment; quicker loads just show their children. The timer runs
257
+ * outside Angular, so it doesn't hold up the app's stability.
258
+ */
259
+ #announceLoadingAfterDelay(node) {
260
+ this.#zone.runOutsideAngular(() => {
261
+ const timer = setTimeout(() => {
262
+ this.#loadingTimers.delete(timer);
263
+ if (node.loading()) {
264
+ this.#announcer.announce(this.messages().loadingNode(this.treeService.getNodeText(node)), "polite");
265
+ }
266
+ }, LOADING_ANNOUNCEMENT_DELAY);
267
+ this.#loadingTimers.add(timer);
268
+ });
269
+ }
270
+ /** Announces how many nodes match once the filter the user typed applies. Filters set from code aren't announced. */
271
+ #announceFilterResults(filterText, matchCount) {
272
+ if (this.#pendingFilterAnnouncement === null || this.#pendingFilterAnnouncement !== filterText) {
273
+ return;
274
+ }
275
+ this.#pendingFilterAnnouncement = null;
276
+ if (!filterText) {
277
+ return;
278
+ }
279
+ const messages = this.messages();
280
+ this.#announcer.announce(matchCount === 0 ? messages.noMatches : messages.results(matchCount), "polite");
281
+ }
166
282
  #setFlatDataStructureFields() {
167
283
  const idField = this.idField();
168
284
  const parentIdField = this.parentIdField();
@@ -171,15 +287,6 @@ class TreeViewComponent {
171
287
  this.treeService.setFlatParentIdField(parentIdField);
172
288
  });
173
289
  }
174
- #setGenericDataStructureFields(mode) {
175
- const textField = this.textField();
176
- const data = this.data();
177
- untracked(() => {
178
- this.treeService.setTextField(textField);
179
- this.treeService.setDataStructure(mode);
180
- this.treeService.setData(data);
181
- });
182
- }
183
290
  #setHierarchicalDataStructureFields() {
184
291
  const childrenSelector = this.children();
185
292
  const hasChildren = this.hasChildren();
@@ -188,33 +295,32 @@ class TreeViewComponent {
188
295
  this.treeService.setHasChildrenPredicate(hasChildren);
189
296
  });
190
297
  }
191
- #setSubscriptions() {
192
- this.treeService.nodeClick$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
193
- this.nodeClick.emit(event);
194
- });
195
- this.treeService.focus$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(e => this.focus.emit(e));
196
- this.treeService.blur$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(e => this.blur.emit(e));
298
+ #warnIfUnnamed() {
299
+ if (this.ariaLabel().trim() || this.ariaLabelledBy().trim()) {
300
+ return;
301
+ }
302
+ console.warn("[Mona TreeView] A tree view needs an accessible name. Set ariaLabel or ariaLabelledBy.", this.#hostElementRef.nativeElement);
197
303
  }
198
304
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
199
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: TreeViewComponent, isStandalone: true, selector: "mona-tree-view", inputs: { animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, children: { classPropertyName: "children", publicName: "children", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, hasChildren: { classPropertyName: "hasChildren", publicName: "hasChildren", isSignal: true, isRequired: false, transformFunction: null }, idField: { classPropertyName: "idField", publicName: "idField", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, parentIdField: { classPropertyName: "parentIdField", publicName: "parentIdField", isSignal: true, isRequired: false, transformFunction: null }, textField: { classPropertyName: "textField", publicName: "textField", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { blur: "blur", focus: "focus", nodeClick: "nodeClick" }, providers: [TreeService], queries: [{ propertyName: "nodeTemplate", first: true, predicate: TreeViewNodeTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "@if (treeService.filterableOptions().enabled) {\n <div role=\"search\" [attr.aria-label]=\"filterAriaLabel()\">\n <mona-filter-input\n [filter]=\"treeService.filterText()\"\n [debounce]=\"treeService.filterableOptions().debounce\"\n [placeholder]=\"treeService.filterPlaceholder()\"\n (filterChange)=\"onFilterChange($event)\"></mona-filter-input>\n </div>\n}\n<div class=\"flex-1 overflow-auto\">\n <mona-tree [ariaLabel]=\"ariaLabel()\">\n @if (nodeTemplate()) {\n <ng-template monaTreeNodeTemplate let-dataItem let-element=\"element\">\n <ng-container\n [ngTemplateOutlet]=\"nodeTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem, element }\"></ng-container>\n </ng-template>\n }\n </mona-tree>\n</div>\n", dependencies: [{ kind: "component", type: FilterInputComponent, selector: "mona-filter-input", inputs: ["activeDescendant", "ariaLabel", "controls", "debounce", "filter", "placeholder", "size"], outputs: ["filterChange", "inputBlur", "inputFocus"] }, { kind: "component", type: TreeComponent, selector: "mona-tree", inputs: ["ariaLabel", "data"] }, { kind: "directive", type: TreeNodeTemplateDirective, selector: "ng-template[monaTreeNodeTemplate]" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
305
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: TreeViewComponent, isStandalone: true, selector: "mona-tree-view", inputs: { animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "ariaLabelledBy", isSignal: true, isRequired: false, transformFunction: null }, children: { classPropertyName: "children", publicName: "children", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, hasChildren: { classPropertyName: "hasChildren", publicName: "hasChildren", isSignal: true, isRequired: false, transformFunction: null }, idField: { classPropertyName: "idField", publicName: "idField", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, parentIdField: { classPropertyName: "parentIdField", publicName: "parentIdField", isSignal: true, isRequired: false, transformFunction: null }, textField: { classPropertyName: "textField", publicName: "textField", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { blur: "blur", childrenLoadError: "childrenLoadError", focus: "focus", nodeClick: "nodeClick" }, providers: [TreeService], queries: [{ propertyName: "nodeTemplate", first: true, predicate: TreeViewNodeTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "@if (treeService.filterableOptions().enabled) {\n <div role=\"search\" [attr.aria-label]=\"filterAriaLabel()\">\n <mona-filter-input\n [filter]=\"treeService.filterText()\"\n [debounce]=\"treeService.filterableOptions().debounce\"\n [placeholder]=\"treeService.filterPlaceholder()\"\n [ariaLabel]=\"filterAriaLabel()\"\n [ariaControls]=\"treeId\"\n [autoFocus]=\"false\"\n (filterChange)=\"onFilterChange($event)\"></mona-filter-input>\n </div>\n}\n<!-- An empty tree stays a named Tab stop, lying over the \"No data\" or \"No matching items\" text that describes it. -->\n<div class=\"relative flex-1 overflow-auto\">\n @if (empty()) {\n <mona-placeholder\n [id]=\"statusId\"\n [text]=\"emptyText()\"\n class=\"flex h-full w-full items-center justify-center\"></mona-placeholder>\n }\n <mona-tree\n [id]=\"treeId\"\n [class.absolute]=\"empty()\"\n [class.inset-0]=\"empty()\"\n [ariaLabel]=\"ariaLabel()\"\n [ariaLabelledBy]=\"ariaLabelledBy()\"\n [ariaDescribedBy]=\"empty() ? statusId : ''\">\n @if (nodeTemplate()) {\n <ng-template monaTreeNodeTemplate let-dataItem let-element=\"element\">\n <ng-container\n [ngTemplateOutlet]=\"nodeTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem, element }\"></ng-container>\n </ng-template>\n }\n </mona-tree>\n</div>\n", dependencies: [{ kind: "component", type: FilterInputComponent, selector: "mona-filter-input", inputs: ["activeDescendant", "ariaControls", "ariaLabel", "autoFocus", "controls", "debounce", "filter", "placeholder", "size"], outputs: ["filterChange", "inputBlur", "inputFocus"] }, { kind: "component", type: PlaceholderComponent, selector: "mona-placeholder", inputs: ["text", "class"] }, { kind: "component", type: TreeComponent, selector: "mona-tree", inputs: ["ariaDescribedBy", "ariaLabel", "ariaLabelledBy", "data"] }, { kind: "directive", type: TreeNodeTemplateDirective, selector: "ng-template[monaTreeNodeTemplate]" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
200
306
  }
201
307
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewComponent, decorators: [{
202
308
  type: Component,
203
- args: [{ selector: "mona-tree-view", imports: [FilterInputComponent, TreeComponent, TreeNodeTemplateDirective, NgTemplateOutlet], providers: [TreeService], template: "@if (treeService.filterableOptions().enabled) {\n <div role=\"search\" [attr.aria-label]=\"filterAriaLabel()\">\n <mona-filter-input\n [filter]=\"treeService.filterText()\"\n [debounce]=\"treeService.filterableOptions().debounce\"\n [placeholder]=\"treeService.filterPlaceholder()\"\n (filterChange)=\"onFilterChange($event)\"></mona-filter-input>\n </div>\n}\n<div class=\"flex-1 overflow-auto\">\n <mona-tree [ariaLabel]=\"ariaLabel()\">\n @if (nodeTemplate()) {\n <ng-template monaTreeNodeTemplate let-dataItem let-element=\"element\">\n <ng-container\n [ngTemplateOutlet]=\"nodeTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem, element }\"></ng-container>\n </ng-template>\n }\n </mona-tree>\n</div>\n" }]
204
- }], ctorParameters: () => [], propDecorators: { nodeTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TreeViewNodeTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], animate: [{ type: i0.Input, args: [{ isSignal: true, alias: "animate", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], blur: [{ type: i0.Output, args: ["blur"] }], children: [{ type: i0.Input, args: [{ isSignal: true, alias: "children", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], focus: [{ type: i0.Output, args: ["focus"] }], hasChildren: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasChildren", required: false }] }], idField: [{ type: i0.Input, args: [{ isSignal: true, alias: "idField", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], nodeClick: [{ type: i0.Output, args: ["nodeClick"] }], parentIdField: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentIdField", required: false }] }], textField: [{ type: i0.Input, args: [{ isSignal: true, alias: "textField", required: false }] }] } });
309
+ args: [{ selector: "mona-tree-view", imports: [FilterInputComponent, PlaceholderComponent, TreeComponent, TreeNodeTemplateDirective, NgTemplateOutlet], providers: [TreeService], template: "@if (treeService.filterableOptions().enabled) {\n <div role=\"search\" [attr.aria-label]=\"filterAriaLabel()\">\n <mona-filter-input\n [filter]=\"treeService.filterText()\"\n [debounce]=\"treeService.filterableOptions().debounce\"\n [placeholder]=\"treeService.filterPlaceholder()\"\n [ariaLabel]=\"filterAriaLabel()\"\n [ariaControls]=\"treeId\"\n [autoFocus]=\"false\"\n (filterChange)=\"onFilterChange($event)\"></mona-filter-input>\n </div>\n}\n<!-- An empty tree stays a named Tab stop, lying over the \"No data\" or \"No matching items\" text that describes it. -->\n<div class=\"relative flex-1 overflow-auto\">\n @if (empty()) {\n <mona-placeholder\n [id]=\"statusId\"\n [text]=\"emptyText()\"\n class=\"flex h-full w-full items-center justify-center\"></mona-placeholder>\n }\n <mona-tree\n [id]=\"treeId\"\n [class.absolute]=\"empty()\"\n [class.inset-0]=\"empty()\"\n [ariaLabel]=\"ariaLabel()\"\n [ariaLabelledBy]=\"ariaLabelledBy()\"\n [ariaDescribedBy]=\"empty() ? statusId : ''\">\n @if (nodeTemplate()) {\n <ng-template monaTreeNodeTemplate let-dataItem let-element=\"element\">\n <ng-container\n [ngTemplateOutlet]=\"nodeTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem, element }\"></ng-container>\n </ng-template>\n }\n </mona-tree>\n</div>\n" }]
310
+ }], ctorParameters: () => [], propDecorators: { nodeTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TreeViewNodeTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], animate: [{ type: i0.Input, args: [{ isSignal: true, alias: "animate", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledBy", required: false }] }], blur: [{ type: i0.Output, args: ["blur"] }], children: [{ type: i0.Input, args: [{ isSignal: true, alias: "children", required: false }] }], childrenLoadError: [{ type: i0.Output, args: ["childrenLoadError"] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], focus: [{ type: i0.Output, args: ["focus"] }], hasChildren: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasChildren", required: false }] }], idField: [{ type: i0.Input, args: [{ isSignal: true, alias: "idField", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], nodeClick: [{ type: i0.Output, args: ["nodeClick"] }], parentIdField: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentIdField", required: false }] }], textField: [{ type: i0.Input, args: [{ isSignal: true, alias: "textField", required: false }] }] } });
205
311
 
206
312
  class TreeViewCheckableDirective {
207
313
  #defaultOptions;
208
- #destroyRef;
209
314
  #treeService;
210
315
  constructor() {
211
316
  this.#defaultOptions = {
212
317
  checkChildren: true,
318
+ checkDisabledChildren: false,
213
319
  checkParents: true,
320
+ childrenOnly: false,
214
321
  enabled: true,
215
322
  mode: "multiple"
216
323
  };
217
- this.#destroyRef = inject(DestroyRef);
218
324
  this.#treeService = inject(TreeService);
219
325
  /**
220
326
  * @description Property name or accessor used to derive a node's check key from its data. Falls back to the node's data when unset.
@@ -229,7 +335,10 @@ class TreeViewCheckableDirective {
229
335
  this.checkedKeys = input([], /* @ts-ignore */
230
336
  ...(ngDevMode ? [{ debugName: "checkedKeys" }] : /* istanbul ignore next */ []));
231
337
  /**
232
- * @description Emitted when the checked keys change.
338
+ * @description Emitted with the checked keys when the user checks or unchecks a node, including the children and
339
+ * parents that check follows (`checkChildren`, `checkParents`). Not emitted for keys set through `checkedKeys`,
340
+ * nor for keys the tree derives on its own: checked parents of checked children set from code, lazily loaded
341
+ * children of a checked node, and ancestors after a drop. Those are reported with the next user change.
233
342
  */
234
343
  this.checkedKeysChange = output();
235
344
  /**
@@ -243,7 +352,7 @@ class TreeViewCheckableDirective {
243
352
  */
244
353
  this.nodeCheck = output();
245
354
  /**
246
- * @description Configures check mode and whether checking a node also checks its children or parents. Merged over `{ checkChildren: true, checkParents: true, enabled: true, mode: "multiple" }` when applied bare.
355
+ * @description Configures check mode and whether checking a node also checks its children or parents. Merged over `{ checkChildren: true, checkDisabledChildren: false, checkParents: true, childrenOnly: false, enabled: true, mode: "multiple" }` when applied bare.
247
356
  * @default ""
248
357
  */
249
358
  this.options = input("", { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), alias: "monaTreeViewCheckable" });
@@ -279,24 +388,10 @@ class TreeViewCheckableDirective {
279
388
  this.#treeService.setHasCheckboxPredicate(hasCheckbox);
280
389
  });
281
390
  });
282
- }
283
- ngOnInit() {
284
- this.setNodeCheckSubscription();
285
- }
286
- setNodeCheckSubscription() {
287
- this.#treeService.checkedKeys$
288
- .pipe(pairwise(), takeUntilDestroyed(this.#destroyRef))
289
- .subscribe(([oldKeys, keys]) => {
290
- const orderedOldKeys = oldKeys.orderBy(k => k);
291
- const orderedKeys = keys.orderBy(k => k);
292
- if (sequenceEqual(orderedOldKeys, orderedKeys)) {
293
- return;
294
- }
295
- this.checkedKeysChange.emit(keys.toArray());
296
- });
297
- this.#treeService.nodeCheck$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
298
- this.nodeCheck.emit(event);
299
- });
391
+ this.#treeService.checkedKeysChange$
392
+ .pipe(takeUntilDestroyed())
393
+ .subscribe(keys => this.checkedKeysChange.emit(keys.toArray()));
394
+ this.#treeService.nodeCheck$.pipe(takeUntilDestroyed()).subscribe(event => this.nodeCheck.emit(event));
300
395
  }
301
396
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewCheckableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
302
397
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TreeViewCheckableDirective, isStandalone: true, selector: "mona-tree-view[monaTreeViewCheckable]", inputs: { checkBy: { classPropertyName: "checkBy", publicName: "checkBy", isSignal: true, isRequired: false, transformFunction: null }, checkedKeys: { classPropertyName: "checkedKeys", publicName: "checkedKeys", isSignal: true, isRequired: false, transformFunction: null }, hasCheckbox: { classPropertyName: "hasCheckbox", publicName: "hasCheckbox", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "monaTreeViewCheckable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checkedKeysChange: "checkedKeysChange", nodeCheck: "nodeCheck" }, exportAs: ["monaTreeViewCheckable"], ngImport: i0 }); }
@@ -375,14 +470,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
375
470
 
376
471
  class TreeViewDragAndDropDirective {
377
472
  #defaultOptions;
378
- #destroyRef;
379
473
  #treeService;
380
474
  #treeView;
381
475
  constructor() {
382
476
  this.#defaultOptions = {
383
477
  enabled: true
384
478
  };
385
- this.#destroyRef = inject(DestroyRef);
386
479
  this.#treeService = inject(TreeService);
387
480
  this.#treeView = inject((TreeViewComponent));
388
481
  /**
@@ -390,7 +483,7 @@ class TreeViewDragAndDropDirective {
390
483
  */
391
484
  this.nodeDrag = output();
392
485
  /**
393
- * @description Emitted when a node drag ends.
486
+ * @description Emitted when a node drag ends, dropped or not. Not cancelable: the drag is over either way.
394
487
  */
395
488
  this.nodeDragEnd = output();
396
489
  /**
@@ -398,7 +491,9 @@ class TreeViewDragAndDropDirective {
398
491
  */
399
492
  this.nodeDragStart = output();
400
493
  /**
401
- * @description Emitted when a node is dropped.
494
+ * @description Emitted when a node is dropped on another node, or moved with Ctrl+Shift+Arrow (Cmd+Shift+Arrow on
495
+ * macOS). The tree doesn't move the node: the handler applies the move (with `moveTreeNode`,
496
+ * `moveFlatTreeNode` or `event.treeView.moveNode`). Call `preventDefault()` when the move isn't applied.
402
497
  */
403
498
  this.nodeDrop = output();
404
499
  /**
@@ -420,21 +515,16 @@ class TreeViewDragAndDropDirective {
420
515
  }
421
516
  });
422
517
  });
423
- afterNextRender({
424
- read: () => this.setSubscriptions()
425
- });
426
- }
427
- setSubscriptions() {
428
- this.#treeService.nodeDrag$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(e => {
518
+ this.#treeService.nodeDrag$.pipe(takeUntilDestroyed()).subscribe(e => {
429
519
  this.nodeDrag.emit(e.dragEvent);
430
520
  });
431
- this.#treeService.nodeDragEnd$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(e => {
521
+ this.#treeService.nodeDragEnd$.pipe(takeUntilDestroyed()).subscribe(e => {
432
522
  this.nodeDragEnd.emit(e);
433
523
  });
434
- this.#treeService.nodeDragStart$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(e => {
524
+ this.#treeService.nodeDragStart$.pipe(takeUntilDestroyed()).subscribe(e => {
435
525
  this.nodeDragStart.emit(e);
436
526
  });
437
- this.#treeService.nodeDrop$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(e => {
527
+ this.#treeService.nodeDrop$.pipe(takeUntilDestroyed()).subscribe(e => {
438
528
  const event = new NodeDropEvent({
439
529
  event: e.event,
440
530
  position: e.position,
@@ -443,6 +533,9 @@ class TreeViewDragAndDropDirective {
443
533
  treeView: this.#treeView
444
534
  });
445
535
  this.nodeDrop.emit(event);
536
+ if (event.isDefaultPrevented()) {
537
+ e.preventDefault();
538
+ }
446
539
  });
447
540
  }
448
541
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewDragAndDropDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
@@ -458,13 +551,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
458
551
 
459
552
  class TreeViewExpandableDirective {
460
553
  #defaultOptions;
461
- #destroyRef;
462
554
  #treeService;
463
555
  constructor() {
464
556
  this.#defaultOptions = {
465
557
  enabled: true
466
558
  };
467
- this.#destroyRef = inject(DestroyRef);
468
559
  this.#treeService = inject(TreeService);
469
560
  /**
470
561
  * @description Emitted when a node is collapsed.
@@ -487,7 +578,8 @@ class TreeViewExpandableDirective {
487
578
  this.expandedKeys = input([], /* @ts-ignore */
488
579
  ...(ngDevMode ? [{ debugName: "expandedKeys" }] : /* istanbul ignore next */ []));
489
580
  /**
490
- * @description Emitted when the expanded keys change.
581
+ * @description Emitted with the expanded keys when the user expands or collapses a node. Not emitted for keys set
582
+ * through `expandedKeys`, nor for the expansion a filter applies (which is undone when the filter is cleared).
491
583
  */
492
584
  this.expandedKeysChange = output();
493
585
  /**
@@ -521,22 +613,10 @@ class TreeViewExpandableDirective {
521
613
  }
522
614
  });
523
615
  });
524
- afterNextRender({
525
- read: () => this.setSubscriptions()
526
- });
527
- }
528
- setSubscriptions() {
529
- this.#treeService.expandedKeys$
530
- .pipe(pairwise(), takeUntilDestroyed(this.#destroyRef))
531
- .subscribe(([oldKeys, keys]) => {
532
- const orderedOldKeys = oldKeys.orderBy(k => k);
533
- const orderedKeys = keys.orderBy(k => k);
534
- if (sequenceEqual(orderedOldKeys, orderedKeys)) {
535
- return;
536
- }
537
- this.expandedKeysChange.emit(keys.toArray());
538
- });
539
- this.#treeService.nodeExpand$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
616
+ this.#treeService.expandedKeysChange$
617
+ .pipe(takeUntilDestroyed())
618
+ .subscribe(keys => this.expandedKeysChange.emit(keys.toArray()));
619
+ this.#treeService.nodeExpand$.pipe(takeUntilDestroyed()).subscribe(event => {
540
620
  if (event.expanded) {
541
621
  this.expand.emit(event.node.nodeItem);
542
622
  }
@@ -558,7 +638,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
558
638
 
559
639
  class TreeViewFilterableDirective {
560
640
  #defaultOptions;
561
- #destroyRef;
562
641
  #treeService;
563
642
  constructor() {
564
643
  this.#defaultOptions = {
@@ -567,18 +646,19 @@ class TreeViewFilterableDirective {
567
646
  caseSensitive: false,
568
647
  debounce: 0
569
648
  };
570
- this.#destroyRef = inject(DestroyRef);
571
649
  this.#treeService = inject(TreeService);
572
650
  /**
573
- * @description Current filter text used to narrow the visible nodes.
651
+ * @description Current filter text used to narrow the visible nodes. Two-way bindable (`[(filter)]`); the user's
652
+ * typing updates it, so setting it from code (including back to `""`) always applies.
574
653
  * @default ""
575
654
  */
576
- this.filter = input("", /* @ts-ignore */
655
+ this.filter = model("", /* @ts-ignore */
577
656
  ...(ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []));
578
657
  /**
579
- * @description Emitted when the filter value changes.
658
+ * @description Emitted when the user types in the filter input, before the filter applies. Call
659
+ * `preventDefault()` to keep the current filter; otherwise `filterChange` reports the new text.
580
660
  */
581
- this.filterChange = output();
661
+ this.filterInput = output();
582
662
  /**
583
663
  * @description Placeholder text shown in the filter input.
584
664
  * @default ""
@@ -612,17 +692,15 @@ class TreeViewFilterableDirective {
612
692
  }
613
693
  });
614
694
  });
615
- afterNextRender({
616
- read: () => this.setSubscription()
617
- });
618
- }
619
- setSubscription() {
620
- this.#treeService.filterChange$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
621
- this.filterChange.emit(event);
695
+ this.#treeService.filterChange$.pipe(takeUntilDestroyed()).subscribe(event => {
696
+ this.filterInput.emit(event);
697
+ if (!event.isDefaultPrevented()) {
698
+ this.filter.set(event.filter);
699
+ }
622
700
  });
623
701
  }
624
702
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewFilterableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
625
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TreeViewFilterableDirective, isStandalone: true, selector: "mona-tree-view[monaTreeViewFilterable]", inputs: { filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, filterPlaceholder: { classPropertyName: "filterPlaceholder", publicName: "filterPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "monaTreeViewFilterable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filterChange: "filterChange" }, exportAs: ["monaTreeViewFilterable"], ngImport: i0 }); }
703
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TreeViewFilterableDirective, isStandalone: true, selector: "mona-tree-view[monaTreeViewFilterable]", inputs: { filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, filterPlaceholder: { classPropertyName: "filterPlaceholder", publicName: "filterPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "monaTreeViewFilterable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filter: "filterChange", filterInput: "filterInput" }, exportAs: ["monaTreeViewFilterable"], ngImport: i0 }); }
626
704
  }
627
705
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewFilterableDirective, decorators: [{
628
706
  type: Directive,
@@ -630,11 +708,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
630
708
  selector: "mona-tree-view[monaTreeViewFilterable]",
631
709
  exportAs: "monaTreeViewFilterable"
632
710
  }]
633
- }], ctorParameters: () => [], propDecorators: { filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], filterChange: [{ type: i0.Output, args: ["filterChange"] }], filterPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterPlaceholder", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaTreeViewFilterable", required: false }] }] } });
711
+ }], ctorParameters: () => [], propDecorators: { filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }, { type: i0.Output, args: ["filterChange"] }], filterInput: [{ type: i0.Output, args: ["filterInput"] }], filterPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterPlaceholder", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaTreeViewFilterable", required: false }] }] } });
634
712
 
635
713
  class TreeViewSelectableDirective {
636
714
  #defaultOptions;
637
- #destroyRef;
638
715
  #treeService;
639
716
  constructor() {
640
717
  this.#defaultOptions = {
@@ -643,12 +720,17 @@ class TreeViewSelectableDirective {
643
720
  mode: "single",
644
721
  toggleable: false
645
722
  };
646
- this.#destroyRef = inject(DestroyRef);
647
723
  this.#treeService = inject(TreeService);
648
724
  /**
649
- * @description Emitted when a node is selected or deselected.
725
+ * @description Emitted before the user selects or deselects a node, by click or Enter. Call `preventDefault()`
726
+ * to keep the selection as it is; `selectionChange` follows when it isn't prevented.
650
727
  */
651
728
  this.nodeSelect = output();
729
+ /**
730
+ * @description Configures selection mode, toggleability, and whether only child nodes are selectable. Merged over `{ childrenOnly: false, enabled: true, mode: "single", toggleable: false }` when applied bare.
731
+ * @default ""
732
+ */
733
+ this.options = input("", { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), alias: "monaTreeViewSelectable" });
652
734
  /**
653
735
  * @description Property name or accessor used to derive a node's selection key from its data. Falls back to the node's data when unset.
654
736
  * @default ""
@@ -662,18 +744,15 @@ class TreeViewSelectableDirective {
662
744
  this.selectedKeys = input([], /* @ts-ignore */
663
745
  ...(ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []));
664
746
  /**
665
- * @description Emitted when the selected keys change.
747
+ * @description Emitted with the selected keys when the user selects or deselects a node. Not emitted for keys set
748
+ * through `selectedKeys`.
666
749
  */
667
750
  this.selectedKeysChange = output();
668
751
  /**
669
- * @description Emitted when the selection changes.
752
+ * @description Emitted with the node after the user selects or deselects it (after a `nodeSelect` that wasn't
753
+ * prevented).
670
754
  */
671
755
  this.selectionChange = output();
672
- /**
673
- * @description Configures selection mode, toggleability, and whether only child nodes are selectable. Merged over `{ childrenOnly: false, enabled: true, mode: "single", toggleable: false }` when applied bare.
674
- * @default ""
675
- */
676
- this.options = input("", { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), alias: "monaTreeViewSelectable" });
677
756
  effect(() => {
678
757
  const selectBy = this.selectBy();
679
758
  untracked(() => this.#treeService.setSelectBy(selectBy ?? ""));
@@ -696,30 +775,16 @@ class TreeViewSelectableDirective {
696
775
  }
697
776
  });
698
777
  });
699
- }
700
- ngOnInit() {
701
- this.setNodeSelectSubscription();
702
- }
703
- setNodeSelectSubscription() {
704
- this.#treeService.nodeSelect$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
705
- this.nodeSelect.emit(event);
706
- });
707
- this.#treeService.selectedKeys$
708
- .pipe(pairwise(), takeUntilDestroyed(this.#destroyRef))
709
- .subscribe(([oldKeys, keys]) => {
710
- const orderedOldKeys = oldKeys.orderBy(k => k);
711
- const orderedKeys = keys.orderBy(k => k);
712
- if (sequenceEqual(orderedOldKeys, orderedKeys)) {
713
- return;
714
- }
715
- this.selectedKeysChange.emit(keys.toArray());
716
- });
717
- this.#treeService.selectionChange$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(nodeItem => {
718
- this.selectionChange.emit(nodeItem);
719
- });
778
+ this.#treeService.nodeSelect$.pipe(takeUntilDestroyed()).subscribe(event => this.nodeSelect.emit(event));
779
+ this.#treeService.selectedKeysChange$
780
+ .pipe(takeUntilDestroyed())
781
+ .subscribe(keys => this.selectedKeysChange.emit(keys.toArray()));
782
+ this.#treeService.selectionChange$
783
+ .pipe(takeUntilDestroyed())
784
+ .subscribe(nodeItem => this.selectionChange.emit(nodeItem));
720
785
  }
721
786
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewSelectableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
722
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TreeViewSelectableDirective, isStandalone: true, selector: "mona-tree-view[monaTreeViewSelectable]", inputs: { selectBy: { classPropertyName: "selectBy", publicName: "selectBy", isSignal: true, isRequired: false, transformFunction: null }, selectedKeys: { classPropertyName: "selectedKeys", publicName: "selectedKeys", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "monaTreeViewSelectable", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nodeSelect: "nodeSelect", selectedKeysChange: "selectedKeysChange", selectionChange: "selectionChange" }, exportAs: ["monaTreeViewSelectable"], ngImport: i0 }); }
787
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TreeViewSelectableDirective, isStandalone: true, selector: "mona-tree-view[monaTreeViewSelectable]", inputs: { options: { classPropertyName: "options", publicName: "monaTreeViewSelectable", isSignal: true, isRequired: false, transformFunction: null }, selectBy: { classPropertyName: "selectBy", publicName: "selectBy", isSignal: true, isRequired: false, transformFunction: null }, selectedKeys: { classPropertyName: "selectedKeys", publicName: "selectedKeys", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { nodeSelect: "nodeSelect", selectedKeysChange: "selectedKeysChange", selectionChange: "selectionChange" }, exportAs: ["monaTreeViewSelectable"], ngImport: i0 }); }
723
788
  }
724
789
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TreeViewSelectableDirective, decorators: [{
725
790
  type: Directive,
@@ -727,7 +792,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
727
792
  selector: "mona-tree-view[monaTreeViewSelectable]",
728
793
  exportAs: "monaTreeViewSelectable"
729
794
  }]
730
- }], ctorParameters: () => [], propDecorators: { nodeSelect: [{ type: i0.Output, args: ["nodeSelect"] }], selectBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectBy", required: false }] }], selectedKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedKeys", required: false }] }], selectedKeysChange: [{ type: i0.Output, args: ["selectedKeysChange"] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaTreeViewSelectable", required: false }] }] } });
795
+ }], ctorParameters: () => [], propDecorators: { nodeSelect: [{ type: i0.Output, args: ["nodeSelect"] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaTreeViewSelectable", required: false }] }], selectBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectBy", required: false }] }], selectedKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedKeys", required: false }] }], selectedKeysChange: [{ type: i0.Output, args: ["selectedKeysChange"] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }] } });
731
796
 
732
797
  /*
733
798
  * Public API Surface of @nanahoshi/mona-ui/tree-view