@nanahoshi/mona-ui 0.36.1 → 0.38.0

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 (91) hide show
  1. package/docs/api/common.md +1 -1
  2. package/docs/api/dropdown-list.md +2 -0
  3. package/docs/api/dropdown-tree.md +81 -0
  4. package/docs/api/dropdowns.md +34 -8
  5. package/docs/api/editor.md +67 -0
  6. package/docs/api/file-upload.md +1 -1
  7. package/docs/api/i18n.md +49 -4
  8. package/docs/api/list.md +1 -1
  9. package/docs/api/locales.md +14 -14
  10. package/docs/api/multi-select-tree.md +75 -0
  11. package/docs/api/multi-select.md +3 -1
  12. package/docs/api/popup.md +1 -1
  13. package/docs/api/tree-view.md +2 -2
  14. package/docs/auto-complete.md +2 -0
  15. package/docs/combo-box.md +2 -0
  16. package/docs/dropdown-list.md +52 -0
  17. package/docs/dropdown-tree.md +427 -0
  18. package/docs/editor.md +238 -9
  19. package/docs/multi-select-tree.md +353 -0
  20. package/docs/multi-select.md +6 -0
  21. package/dropdown-tree/package.json +4 -0
  22. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +40 -5
  23. package/fesm2022/nanahoshi-mona-ui-dropdown-tree.mjs +1061 -0
  24. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -60
  25. package/fesm2022/nanahoshi-mona-ui-editor.mjs +1356 -192
  26. package/fesm2022/nanahoshi-mona-ui-file-upload.mjs +28 -94
  27. package/fesm2022/nanahoshi-mona-ui-filter.mjs +2 -0
  28. package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
  29. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +63 -1
  30. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +80 -37
  31. package/fesm2022/nanahoshi-mona-ui-internal.mjs +83 -2
  32. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +66 -1
  33. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +30 -1
  34. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +42 -1
  35. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +42 -1
  36. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +24 -1
  37. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +42 -1
  38. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +24 -1
  39. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +24 -1
  40. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +64 -1
  41. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +42 -1
  42. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +64 -1
  43. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +24 -1
  44. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +24 -1
  45. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +24 -1
  46. package/fesm2022/nanahoshi-mona-ui-multi-select-tree.mjs +1179 -0
  47. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +42 -7
  48. package/fesm2022/nanahoshi-mona-ui-pager.mjs +3 -1
  49. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +2 -1
  50. package/i18n/catalogs/en-US.messages.json +26 -1
  51. package/llms.txt +7 -3
  52. package/locales/ar-sa/ar-sa.messages.json +26 -1
  53. package/locales/de-de/de-de.messages.json +26 -1
  54. package/locales/es-es/es-es.messages.json +26 -1
  55. package/locales/fr-fr/fr-fr.messages.json +26 -1
  56. package/locales/id-id/id-id.messages.json +26 -1
  57. package/locales/it-it/it-it.messages.json +26 -1
  58. package/locales/ja-jp/ja-jp.messages.json +26 -1
  59. package/locales/ko-kr/ko-kr.messages.json +26 -1
  60. package/locales/pl-pl/pl-pl.messages.json +26 -1
  61. package/locales/pt-br/pt-br.messages.json +26 -1
  62. package/locales/ru-ru/ru-ru.messages.json +26 -1
  63. package/locales/tr-tr/tr-tr.messages.json +26 -1
  64. package/locales/zh-cn/zh-cn.messages.json +26 -1
  65. package/locales/zh-tw/zh-tw.messages.json +26 -1
  66. package/multi-select-tree/package.json +4 -0
  67. package/package.json +9 -1
  68. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +33 -5
  69. package/types/nanahoshi-mona-ui-dropdown-tree.d.ts +414 -0
  70. package/types/nanahoshi-mona-ui-dropdowns.d.ts +198 -8
  71. package/types/nanahoshi-mona-ui-editor.d.ts +124 -2
  72. package/types/nanahoshi-mona-ui-file-upload.d.ts +1 -0
  73. package/types/nanahoshi-mona-ui-i18n.d.ts +44 -0
  74. package/types/nanahoshi-mona-ui-internal-tree.d.ts +36 -0
  75. package/types/nanahoshi-mona-ui-internal.d.ts +37 -0
  76. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +25 -0
  77. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +25 -0
  78. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +25 -0
  79. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +25 -0
  80. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +25 -0
  81. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +25 -0
  82. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +25 -0
  83. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +25 -0
  84. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +25 -0
  85. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +25 -0
  86. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +25 -0
  87. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +25 -0
  88. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +25 -0
  89. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +25 -0
  90. package/types/nanahoshi-mona-ui-multi-select-tree.d.ts +456 -0
  91. package/types/nanahoshi-mona-ui-multi-select.d.ts +43 -7
@@ -1,13 +1,11 @@
1
1
  import { DOCUMENT } from "@angular/common";
2
- import { HttpEventType, HttpResponse, HttpResponseBase } from "@angular/common/http";
3
2
  import * as i0 from "@angular/core";
4
3
  import { Component, DestroyRef, ElementRef, Injector, afterNextRender, booleanAttribute, computed, effect, inject, input, model, numberAttribute, output, signal, untracked, viewChild } from "@angular/core";
5
4
  import { LucideCircleAlert, LucideCircleCheck, LucideCloudUpload, LucideFile, LucideRotateCw, LucideX } from "@lucide/angular";
6
5
  import { ButtonDirective } from "@nanahoshi/mona-ui/button";
7
6
  import { MonaI18nService, formatNumber } from "@nanahoshi/mona-ui/i18n";
8
- import { createElementControlId, injectEffectiveDisabled, injectLabelAssociation, themeControlSurfaceClasses } from "@nanahoshi/mona-ui/internal";
7
+ import { createElementControlId, injectEffectiveDisabled, injectLabelAssociation, matchesAccept, parseAccept, runUpload, themeControlSurfaceClasses } from "@nanahoshi/mona-ui/internal";
9
8
  import { ProgressBarComponent } from "@nanahoshi/mona-ui/progress-bar";
10
- import { isObservable } from "rxjs";
11
9
  import { twMerge } from "tailwind-merge";
12
10
  import { cva } from "class-variance-authority";
13
11
  function localizeNumber(value, options) {
@@ -117,19 +115,6 @@ const FILE_SIZE_UNITS = [
117
115
  "gigabyte",
118
116
  "terabyte"
119
117
  ];
120
- function parseAccept(accept) {
121
- return (accept ?? "").split(",").map((token) => token.trim().toLowerCase()).filter((token) => token.length > 0);
122
- }
123
- function matchesAccept(file, accept) {
124
- if (accept.length === 0) return true;
125
- const name = file.name.toLowerCase();
126
- const type = file.type.toLowerCase();
127
- return accept.some((token) => {
128
- if (token.startsWith(".")) return name.endsWith(token);
129
- if (token.endsWith("/*")) return type.startsWith(token.slice(0, -1));
130
- return type === token;
131
- });
132
- }
133
118
  function checkFile(file, rules) {
134
119
  if (!matchesAccept(file, rules.accept)) return "type";
135
120
  if (rules.maxFileSize != null && file.size > rules.maxFileSize) return "maxFileSize";
@@ -165,22 +150,6 @@ function describeAccept(accept, localeId) {
165
150
  }
166
151
  }
167
152
  const ANNOUNCEMENT_REPEAT_DELAY = 100;
168
- function isHttpEventWithoutResult(value) {
169
- if (value instanceof HttpResponseBase) return !(value instanceof HttpResponse);
170
- if (value == null || typeof value !== "object") return false;
171
- const type = value.type;
172
- if (type === HttpEventType.Sent) return Object.keys(value).length === 1;
173
- return (type === HttpEventType.UploadProgress || type === HttpEventType.DownloadProgress) && typeof value.loaded === "number";
174
- }
175
- function httpUploadProgress(value) {
176
- if (value == null || typeof value !== "object") return null;
177
- const event = value;
178
- if (event.type !== HttpEventType.UploadProgress || typeof event.loaded !== "number") return null;
179
- return {
180
- loaded: event.loaded,
181
- total: typeof event.total === "number" ? event.total : void 0
182
- };
183
- }
184
153
  var FileUploadComponent = class FileUploadComponent {
185
154
  #destroyRef;
186
155
  #document;
@@ -596,74 +565,39 @@ var FileUploadComponent = class FileUploadComponent {
596
565
  const entry = this.#entries().find((other) => other.key === key);
597
566
  if (handler == null || entry == null || entry.item.status === "uploading" || entry.item.status === "rejected") return;
598
567
  const file = entry.item.file;
599
- const controller = new AbortController();
600
- let finished = false;
601
- let subscription = null;
602
- const abort = () => {
603
- finished = true;
604
- controller.abort();
605
- subscription?.unsubscribe();
606
- };
607
- const context = {
608
- progress: (loaded, total = file.size) => {
609
- if (!finished && Number.isFinite(loaded) && total > 0) this.#patchEntry(key, { progress: Math.min(1, Math.max(0, loaded / total)) });
610
- },
611
- signal: controller.signal
612
- };
613
- const succeed = (response) => {
614
- if (finished) return;
615
- finished = true;
616
- const item = this.#patchEntry(key, {
617
- progress: 1,
618
- response,
619
- status: "uploaded"
620
- }, null);
621
- this.#writeValue();
622
- if (item) {
623
- this.uploadSuccess.emit(item);
624
- this.#announce(this.messages().fileUploaded(file.name));
625
- }
626
- };
627
- const fail = (error) => {
628
- if (finished) return;
629
- finished = true;
630
- const item = this.#patchEntry(key, {
631
- error,
632
- progress: null,
633
- status: "failed"
634
- }, null);
635
- if (item) {
636
- this.uploadError.emit(item);
637
- this.#announce(this.messages().fileFailed(file.name));
638
- }
639
- };
568
+ let abort = null;
640
569
  this.#patchEntry(key, {
641
570
  error: null,
642
571
  progress: null,
643
572
  response: null,
644
573
  status: "uploading"
645
- }, abort);
646
- let result;
647
- try {
648
- result = handler(file, context);
649
- } catch (error) {
650
- fail(error);
651
- return;
652
- }
653
- if (isObservable(result)) {
654
- let response = void 0;
655
- subscription = result.subscribe({
656
- complete: () => succeed(response),
657
- error: (error) => fail(error),
658
- next: (value) => {
659
- const progress = httpUploadProgress(value);
660
- if (progress) context.progress(progress.loaded, progress.total);
661
- else if (value instanceof HttpResponse) response = value.body;
662
- else if (!isHttpEventWithoutResult(value)) response = value;
574
+ }, () => abort?.());
575
+ abort = runUpload(handler, file, {
576
+ failure: (error) => {
577
+ const item = this.#patchEntry(key, {
578
+ error,
579
+ progress: null,
580
+ status: "failed"
581
+ }, null);
582
+ if (item) {
583
+ this.uploadError.emit(item);
584
+ this.#announce(this.messages().fileFailed(file.name));
663
585
  }
664
- });
665
- if (finished) subscription.unsubscribe();
666
- } else Promise.resolve(result).then(succeed, fail);
586
+ },
587
+ progress: (fraction) => this.#patchEntry(key, { progress: fraction }),
588
+ success: (response) => {
589
+ const item = this.#patchEntry(key, {
590
+ progress: 1,
591
+ response,
592
+ status: "uploaded"
593
+ }, null);
594
+ this.#writeValue();
595
+ if (item) {
596
+ this.uploadSuccess.emit(item);
597
+ this.#announce(this.messages().fileUploaded(file.name));
598
+ }
599
+ }
600
+ });
667
601
  }
668
602
  #valueFiles(entries) {
669
603
  const status = this.upload() != null ? "uploaded" : "selected";
@@ -811,6 +811,8 @@ var FilterMenuComponent = class FilterMenuComponent {
811
811
  type: DropdownListComponent,
812
812
  selector: "mona-dropdown-list",
813
813
  inputs: [
814
+ "adaptiveMode",
815
+ "adaptiveTitle",
814
816
  "aria-describedby",
815
817
  "aria-label",
816
818
  "aria-labelledby",
@@ -4067,6 +4067,8 @@ var GridFilterRowCellComponent = class GridFilterRowCellComponent {
4067
4067
  type: DropdownListComponent,
4068
4068
  selector: "mona-dropdown-list",
4069
4069
  inputs: [
4070
+ "adaptiveMode",
4071
+ "adaptiveTitle",
4070
4072
  "aria-describedby",
4071
4073
  "aria-label",
4072
4074
  "aria-labelledby",
@@ -476,7 +476,9 @@ const MONA_MESSAGE_PARAMETERS = {
476
476
  ok: null
477
477
  },
478
478
  dropdownList: { clear: null },
479
+ dropdownTree: { clear: null },
479
480
  dropdowns: {
481
+ close: null,
480
482
  itemPosition: [
481
483
  {
482
484
  name: "text",
@@ -514,6 +516,22 @@ const MONA_MESSAGE_PARAMETERS = {
514
516
  backgroundColor: null,
515
517
  bold: null,
516
518
  cancel: null,
519
+ characterCount: [{
520
+ name: "count",
521
+ type: "number"
522
+ }],
523
+ characterLimitHint: [{
524
+ name: "limit",
525
+ type: "number"
526
+ }],
527
+ charactersLeft: [{
528
+ name: "count",
529
+ type: "number"
530
+ }],
531
+ charactersOver: [{
532
+ name: "count",
533
+ type: "number"
534
+ }],
517
535
  codeBlock: null,
518
536
  color: null,
519
537
  contentLabel: null,
@@ -521,6 +539,7 @@ const MONA_MESSAGE_PARAMETERS = {
521
539
  deleteColumn: null,
522
540
  deleteRow: null,
523
541
  deleteTable: null,
542
+ editImage: null,
524
543
  editLink: null,
525
544
  enterUrl: null,
526
545
  fontSize: null,
@@ -531,6 +550,26 @@ const MONA_MESSAGE_PARAMETERS = {
531
550
  }],
532
551
  heightPx: null,
533
552
  historyGroup: null,
553
+ imageFile: null,
554
+ imageInserted: [{
555
+ name: "name",
556
+ type: "string"
557
+ }],
558
+ imageTooLarge: [{
559
+ name: "name",
560
+ type: "string"
561
+ }, {
562
+ name: "size",
563
+ type: "string"
564
+ }],
565
+ imageUploadFailed: [{
566
+ name: "name",
567
+ type: "string"
568
+ }],
569
+ imageUploading: [{
570
+ name: "name",
571
+ type: "string"
572
+ }],
534
573
  imageUrl: null,
535
574
  indent: null,
536
575
  indentGroup: null,
@@ -546,12 +585,20 @@ const MONA_MESSAGE_PARAMETERS = {
546
585
  justify: null,
547
586
  linkGroup: null,
548
587
  listGroup: null,
588
+ mentionNoResults: null,
589
+ mentionResults: [{
590
+ name: "count",
591
+ type: "number"
592
+ }],
593
+ mentionSearching: null,
594
+ mentionSuggestions: null,
549
595
  mergeCells: null,
550
596
  outdent: null,
551
597
  paragraph: null,
552
598
  quotation: null,
553
599
  redo: null,
554
600
  removeLink: null,
601
+ save: null,
555
602
  selectFontFamily: null,
556
603
  selectFontSize: null,
557
604
  splitCell: null,
@@ -571,7 +618,11 @@ const MONA_MESSAGE_PARAMETERS = {
571
618
  toolbar: null,
572
619
  underline: null,
573
620
  undo: null,
574
- widthPx: null
621
+ widthPx: null,
622
+ wordCount: [{
623
+ name: "count",
624
+ type: "number"
625
+ }]
575
626
  },
576
627
  fileUpload: {
577
628
  browse: null,
@@ -936,6 +987,17 @@ const MONA_MESSAGE_PARAMETERS = {
936
987
  }],
937
988
  selectAll: null
938
989
  },
990
+ multiSelectTree: {
991
+ clear: null,
992
+ itemsCount: [{
993
+ name: "count",
994
+ type: "number"
995
+ }],
996
+ removeMoreItems: [{
997
+ name: "count",
998
+ type: "number"
999
+ }]
1000
+ },
939
1001
  notification: {
940
1002
  close: null,
941
1003
  error: null,
@@ -245,6 +245,7 @@ var TreeService = class TreeService {
245
245
  enabled: false,
246
246
  mode: "multiple"
247
247
  }, ...ngDevMode ? [{ debugName: "checkableOptions" }] : /* istanbul ignore next */ []);
248
+ this.checkedKeys = this.#checkedKeys.asReadonly();
248
249
  this.checkedKeysChange$ = new Subject();
249
250
  this.children = signal("", ...ngDevMode ? [{ debugName: "children" }] : /* istanbul ignore next */ []);
250
251
  this.childrenLoadError$ = new Subject();
@@ -382,6 +383,11 @@ var TreeService = class TreeService {
382
383
  const identity = this.getNodeIdentity(node);
383
384
  return _a.flatten(this.nodeSet()).firstOrDefault((candidate) => candidate.data === node.data || this.getNodeIdentity(candidate) === identity) ?? null;
384
385
  }
386
+ findFirstMatch() {
387
+ const filterText = this.filterText();
388
+ if (!filterText) return null;
389
+ return _a.flatten(this.nodeSet()).firstOrDefault((node) => this.isFiltered(this.getNodeText(node), filterText)) ?? null;
390
+ }
385
391
  findNodeByText(prefix) {
386
392
  const normalizedPrefix = prefix.toLowerCase();
387
393
  const nodes = this.#navigableNodes().toArray();
@@ -1229,6 +1235,43 @@ const treeNodeExpanderThemeVariants = cva(`
1229
1235
  -ms-6 flex h-full min-w-6 items-center justify-center
1230
1236
  cursor-pointer text-sm text-foreground
1231
1237
  `);
1238
+ function handleTreeNavigationKey(event, context) {
1239
+ if (event.ctrlKey || event.metaKey || event.altKey) return false;
1240
+ const { rtl, treeService } = context;
1241
+ const navigatedNode = treeService.navigatedNode();
1242
+ const collapseKey = rtl ? "ArrowRight" : "ArrowLeft";
1243
+ const expandKey = rtl ? "ArrowLeft" : "ArrowRight";
1244
+ switch (event.key) {
1245
+ case "ArrowUp":
1246
+ treeService.navigate("previous");
1247
+ break;
1248
+ case "ArrowDown":
1249
+ treeService.navigate("next");
1250
+ break;
1251
+ case collapseKey:
1252
+ if (navigatedNode && !treeService.toggleNodeExpand(navigatedNode, false) && navigatedNode.parent) treeService.navigatedNode.set(navigatedNode.parent);
1253
+ break;
1254
+ case expandKey:
1255
+ if (!navigatedNode || !treeService.hasChildren(navigatedNode)) break;
1256
+ if (!treeService.isExpanded(navigatedNode)) treeService.toggleNodeExpand(navigatedNode, true);
1257
+ else if (!navigatedNode.children().isEmpty()) treeService.navigate("next");
1258
+ break;
1259
+ case "*":
1260
+ if (navigatedNode) treeService.expandSiblings(navigatedNode);
1261
+ break;
1262
+ case "Home":
1263
+ treeService.navigate("first");
1264
+ break;
1265
+ case "End":
1266
+ treeService.navigate("last");
1267
+ break;
1268
+ default:
1269
+ if (event.key === " " || !isTypeaheadKey(event.key, event)) return false;
1270
+ context.typeahead(event.key);
1271
+ }
1272
+ event.preventDefault();
1273
+ return true;
1274
+ }
1232
1275
  var NodeDragEndEvent = class extends NodeEvent {
1233
1276
  constructor(node, event) {
1234
1277
  super("nodeDragEnd", node, event);
@@ -2055,6 +2098,7 @@ var TreeComponent = class TreeComponent {
2055
2098
  this.ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
2056
2099
  this.ariaLabelledBy = input("", ...ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []);
2057
2100
  this.data = input(...ngDevMode ? [void 0, { debugName: "data" }] : /* istanbul ignore next */ []);
2101
+ this.focusable = input(true, ...ngDevMode ? [{ debugName: "focusable" }] : /* istanbul ignore next */ []);
2058
2102
  this.nodeTemplate = contentChild(TreeNodeTemplateDirective, {
2059
2103
  ...ngDevMode ? { debugName: "nodeTemplate" } : /* istanbul ignore next */ {},
2060
2104
  read: TemplateRef
@@ -2066,6 +2110,11 @@ var TreeComponent = class TreeComponent {
2066
2110
  if (node !== null) this.#lastNavigatedNode = node;
2067
2111
  });
2068
2112
  });
2113
+ effect(() => {
2114
+ const node = this.treeService.navigatedNode();
2115
+ if (node === null) return;
2116
+ untracked(() => afterNextRender({ read: () => this.scrollNodeIntoView(node) }, { injector: this.#injector }));
2117
+ });
2069
2118
  effect(() => {
2070
2119
  const nodeTemplate = this.nodeTemplate() ?? null;
2071
2120
  untracked(() => {
@@ -2183,6 +2232,11 @@ var TreeComponent = class TreeComponent {
2183
2232
  position: "inside"
2184
2233
  });
2185
2234
  }
2235
+ scrollNodeIntoView(node) {
2236
+ if (this.#destroyRef.destroyed) return;
2237
+ const id = this.treeService.getNodeElementId(node.uid);
2238
+ (this.#document.getElementById(id)?.firstElementChild)?.scrollIntoView({ block: "nearest" });
2239
+ }
2186
2240
  setFocusSubscription() {
2187
2241
  this.#focusMonitor.monitor(this.#hostElementRef.nativeElement, true).pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((origin) => {
2188
2242
  if (origin) {
@@ -2205,33 +2259,13 @@ var TreeComponent = class TreeComponent {
2205
2259
  fromEvent(this.#hostElementRef.nativeElement, "keydown").pipe(filter((event) => !event.isComposing && this.isTreeKeyTarget(event)), takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
2206
2260
  if (this.handleMoveKey(event)) return;
2207
2261
  if (event.ctrlKey || event.metaKey || event.altKey) return;
2262
+ if (handleTreeNavigationKey(event, {
2263
+ rtl: this.isRtl(),
2264
+ treeService: this.treeService,
2265
+ typeahead: (key) => this.#typeaheadKey$.next(key)
2266
+ })) return;
2208
2267
  const navigatedNode = this.treeService.navigatedNode();
2209
- const isRtl = this.isRtl();
2210
- const collapseKey = isRtl ? "ArrowRight" : "ArrowLeft";
2211
- const expandKey = isRtl ? "ArrowLeft" : "ArrowRight";
2212
- if (event.key === "ArrowUp") {
2213
- event.preventDefault();
2214
- this.treeService.navigate("previous");
2215
- } else if (event.key === "ArrowDown") {
2216
- event.preventDefault();
2217
- this.treeService.navigate("next");
2218
- } else if (event.key === collapseKey) {
2219
- event.preventDefault();
2220
- if (!navigatedNode) return;
2221
- if (this.treeService.toggleNodeExpand(navigatedNode, false)) return;
2222
- if (navigatedNode.parent) this.treeService.navigatedNode.set(navigatedNode.parent);
2223
- } else if (event.key === expandKey) {
2224
- event.preventDefault();
2225
- if (!navigatedNode || !this.treeService.hasChildren(navigatedNode)) return;
2226
- if (!this.treeService.isExpanded(navigatedNode)) this.treeService.toggleNodeExpand(navigatedNode, true);
2227
- else if (!navigatedNode.children().isEmpty()) this.treeService.navigate("next");
2228
- } else if (event.key === "*") {
2229
- event.preventDefault();
2230
- if (navigatedNode) this.treeService.expandSiblings(navigatedNode);
2231
- } else if (event.key !== " " && isTypeaheadKey(event.key, event)) {
2232
- event.preventDefault();
2233
- this.#typeaheadKey$.next(event.key);
2234
- } else if (event.key === " ") {
2268
+ if (event.key === " ") {
2235
2269
  event.preventDefault();
2236
2270
  if (!navigatedNode || this.treeService.isDisabled(navigatedNode)) return;
2237
2271
  if (!this.treeService.isCheckable(navigatedNode)) return;
@@ -2245,12 +2279,6 @@ var TreeComponent = class TreeComponent {
2245
2279
  checked: newCheckState
2246
2280
  });
2247
2281
  }
2248
- } else if (event.key === "Home") {
2249
- event.preventDefault();
2250
- this.treeService.navigate("first");
2251
- } else if (event.key === "End") {
2252
- event.preventDefault();
2253
- this.treeService.navigate("last");
2254
2282
  } else if (event.key === "Enter") {
2255
2283
  event.preventDefault();
2256
2284
  if (!navigatedNode || this.treeService.isDisabled(navigatedNode)) return;
@@ -2333,17 +2361,24 @@ var TreeComponent = class TreeComponent {
2333
2361
  isSignal: true,
2334
2362
  isRequired: false,
2335
2363
  transformFunction: null
2364
+ },
2365
+ focusable: {
2366
+ classPropertyName: "focusable",
2367
+ publicName: "focusable",
2368
+ isSignal: true,
2369
+ isRequired: false,
2370
+ transformFunction: null
2336
2371
  }
2337
2372
  },
2338
2373
  host: { properties: {
2339
2374
  "class": "baseClass()",
2340
2375
  "attr.role": "'tree'",
2341
- "attr.tabindex": "0",
2376
+ "attr.tabindex": "focusable() ? 0 : null",
2342
2377
  "attr.aria-label": "ariaLabel() || null",
2343
2378
  "attr.aria-labelledby": "ariaLabelledBy() || null",
2344
2379
  "attr.aria-describedby": "ariaDescribedBy() || null",
2345
2380
  "attr.aria-multiselectable": "multiselectable()",
2346
- "attr.aria-activedescendant": "activeDescendantId()",
2381
+ "attr.aria-activedescendant": "focusable() ? activeDescendantId() : null",
2347
2382
  "attr.aria-keyshortcuts": "keyShortcuts()"
2348
2383
  } },
2349
2384
  queries: [{
@@ -2386,12 +2421,12 @@ i0.ɵɵngDeclareClassMetadata({
2386
2421
  host: {
2387
2422
  "[class]": "baseClass()",
2388
2423
  "[attr.role]": "'tree'",
2389
- "[attr.tabindex]": "0",
2424
+ "[attr.tabindex]": "focusable() ? 0 : null",
2390
2425
  "[attr.aria-label]": "ariaLabel() || null",
2391
2426
  "[attr.aria-labelledby]": "ariaLabelledBy() || null",
2392
2427
  "[attr.aria-describedby]": "ariaDescribedBy() || null",
2393
2428
  "[attr.aria-multiselectable]": "multiselectable()",
2394
- "[attr.aria-activedescendant]": "activeDescendantId()",
2429
+ "[attr.aria-activedescendant]": "focusable() ? activeDescendantId() : null",
2395
2430
  "[attr.aria-keyshortcuts]": "keyShortcuts()"
2396
2431
  },
2397
2432
  template: "<mona-sub-tree [nodes]=\"treeService.viewNodeSet()\" [parent]=\"null\" [depth]=\"0\"></mona-sub-tree>\n@if (treeService.dragging() && treeService.dropAllowed()) {\n <mona-tree-drop-hint></mona-tree-drop-hint>\n}\n"
@@ -2431,6 +2466,14 @@ i0.ɵɵngDeclareClassMetadata({
2431
2466
  required: false
2432
2467
  }]
2433
2468
  }],
2469
+ focusable: [{
2470
+ type: i0.Input,
2471
+ args: [{
2472
+ isSignal: true,
2473
+ alias: "focusable",
2474
+ required: false
2475
+ }]
2476
+ }],
2434
2477
  nodeTemplate: [{
2435
2478
  type: i0.ContentChild,
2436
2479
  args: [i0.forwardRef(() => TreeNodeTemplateDirective), {
@@ -2545,6 +2588,6 @@ function moveTreeNode(treeData, event, idKey, childrenKey) {
2545
2588
  if (draggedNode) insertNode(updatedTree);
2546
2589
  return updatedTree;
2547
2590
  }
2548
- export { InternalNodeDragEvent, NodeCheckEvent, NodeClickEvent, NodeDragEndEvent, NodeDragEvent, NodeDragStartEvent, NodeDropEvent, NodeDropEventSansTree, NodeEvent, NodeSelectEvent, TREE_DEFAULT_MESSAGES, TreeComponent, TreeNode, TreeNodeTemplateDirective, TreeService, moveFlatTreeNode, moveTreeNode };
2591
+ export { InternalNodeDragEvent, NodeCheckEvent, NodeClickEvent, NodeDragEndEvent, NodeDragEvent, NodeDragStartEvent, NodeDropEvent, NodeDropEventSansTree, NodeEvent, NodeSelectEvent, TREE_DEFAULT_MESSAGES, TreeComponent, TreeNode, TreeNodeTemplateDirective, TreeService, getTreeNodeElementId, handleTreeNavigationKey, moveFlatTreeNode, moveTreeNode };
2549
2592
 
2550
2593
  //# sourceMappingURL=nanahoshi-mona-ui-internal-tree.mjs.map
@@ -1,6 +1,7 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { DOCUMENT, DestroyRef, Directive, ElementRef, InjectionToken, Renderer2, afterEveryRender, computed, effect, inject, input, signal, untracked } from "@angular/core";
3
- import { Observable, debounceTime, filter, map, merge, scan, take, timer } from "rxjs";
3
+ import { Observable, debounceTime, filter, isObservable, map, merge, scan, take, timer } from "rxjs";
4
+ import { HttpEventType, HttpResponse, HttpResponseBase } from "@angular/common/http";
4
5
  import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
5
6
  var AttributeBinderDirective = class AttributeBinderDirective {
6
7
  #element;
@@ -302,6 +303,19 @@ function injectEffectiveDisabled(disabled) {
302
303
  const fieldsetDisabled = inject(MONA_FIELDSET_DISABLED, { optional: true });
303
304
  return computed(() => disabled() || (fieldsetDisabled?.() ?? false));
304
305
  }
306
+ function parseAccept(accept) {
307
+ return (accept ?? "").split(",").map((token) => token.trim().toLowerCase()).filter((token) => token.length > 0);
308
+ }
309
+ function matchesAccept(file, accept) {
310
+ if (accept.length === 0) return true;
311
+ const name = file.name.toLowerCase();
312
+ const type = file.type.toLowerCase();
313
+ return accept.some((token) => {
314
+ if (token.startsWith(".")) return name.endsWith(token);
315
+ if (token.endsWith("/*")) return type.startsWith(token.slice(0, -1));
316
+ return type === token;
317
+ });
318
+ }
305
319
  const MONA_LABEL = new InjectionToken("MONA_LABEL");
306
320
  const MONA_FORM_FIELD = new InjectionToken("MONA_FORM_FIELD");
307
321
  const FIELD_ASSOCIATION_BOUNDARY = [{
@@ -532,6 +546,73 @@ var RovingToolbar = class {
532
546
  return candidates.filter((candidate) => !candidates.some((other) => other !== candidate && other.contains(candidate)));
533
547
  }
534
548
  };
549
+ function isHttpEventWithoutResult(value) {
550
+ if (value instanceof HttpResponseBase) return !(value instanceof HttpResponse);
551
+ if (value == null || typeof value !== "object") return false;
552
+ const type = value.type;
553
+ if (type === HttpEventType.Sent) return Object.keys(value).length === 1;
554
+ return (type === HttpEventType.UploadProgress || type === HttpEventType.DownloadProgress) && typeof value.loaded === "number";
555
+ }
556
+ function httpUploadProgress(value) {
557
+ if (value == null || typeof value !== "object") return null;
558
+ const event = value;
559
+ if (event.type !== HttpEventType.UploadProgress || typeof event.loaded !== "number") return null;
560
+ return {
561
+ loaded: event.loaded,
562
+ total: typeof event.total === "number" ? event.total : void 0
563
+ };
564
+ }
565
+ function runUpload(handler, file, callbacks) {
566
+ const controller = new AbortController();
567
+ let finished = false;
568
+ let subscription = null;
569
+ const abort = () => {
570
+ if (finished) return;
571
+ finished = true;
572
+ controller.abort();
573
+ subscription?.unsubscribe();
574
+ };
575
+ const succeed = (response) => {
576
+ if (!finished) {
577
+ finished = true;
578
+ callbacks.success(response);
579
+ }
580
+ };
581
+ const fail = (error) => {
582
+ if (!finished) {
583
+ finished = true;
584
+ callbacks.failure(error);
585
+ }
586
+ };
587
+ const context = {
588
+ progress: (loaded, total = file.size) => {
589
+ if (!finished && Number.isFinite(loaded) && total > 0) callbacks.progress(Math.min(1, Math.max(0, loaded / total)));
590
+ },
591
+ signal: controller.signal
592
+ };
593
+ let result;
594
+ try {
595
+ result = handler(file, context);
596
+ } catch (error) {
597
+ fail(error);
598
+ return abort;
599
+ }
600
+ if (isObservable(result)) {
601
+ let response = void 0;
602
+ subscription = result.subscribe({
603
+ complete: () => succeed(response),
604
+ error: (error) => fail(error),
605
+ next: (value) => {
606
+ const progress = httpUploadProgress(value);
607
+ if (progress) context.progress(progress.loaded, progress.total);
608
+ else if (value instanceof HttpResponse) response = value.body;
609
+ else if (!isHttpEventWithoutResult(value)) response = value;
610
+ }
611
+ });
612
+ if (finished) subscription.unsubscribe();
613
+ } else Promise.resolve(result).then(succeed, fail);
614
+ return abort;
615
+ }
535
616
  const rxTimeout = (destroyRef, fn, delay = 0) => {
536
617
  timer(delay).pipe(takeUntilDestroyed(destroyRef), take(1)).subscribe(() => fn());
537
618
  };
@@ -874,6 +955,6 @@ const setupTypeahead = (typeaheadKey$) => {
874
955
  })));
875
956
  return merge(keypress$, resetTrigger$).pipe(scan((buffer, action) => action.type === "reset" ? "" : buffer + action.value.toLowerCase(), ""), filter((buffer) => buffer.length > 0));
876
957
  };
877
- export { AttributeBinderDirective, FIELD_ASSOCIATION_BOUNDARY, HOVER_GRACE, HoverIntent, MONA_FIELDSET_DISABLED, MONA_FORM_FIELD, MONA_LABEL, NavigationKeys, RovingToolbar, TYPEAHEAD_RESET_DELAY, addAriaReference, colorKey, createElementControlId, createPageScrollBlockStrategy, focusCanReturn, focusElement, formatAlpha, hex2rgba, hsla2hsva, hsva2rgba, inertOutside, injectEffectiveDisabled, injectLabelAssociation, injectLabelledByText, isNavigationKey, isTypeaheadKey, isValidHex, listenForHover, navigationKeysList, onDisconnect, overlaySidePositions, parseColor, positionGlobalOverlay, removeAriaReference, resolveOverlaySide, restoreOverlayScroll, rgba2hex, rgba2hsla, rgba2hsva, rxFromResize, rxTimeout, setupTypeahead, sideOfPosition, themeControlBackdropClasses, themeControlSurfaceClasses, themeOverlayBackdropClasses, themeOverlaySurfaceClasses, themeRaisedBackdropClasses, themeRaisedSurfaceClasses, themeSelectionBarClasses, themeSelectionBorderClasses, toCssValue };
958
+ export { AttributeBinderDirective, FIELD_ASSOCIATION_BOUNDARY, HOVER_GRACE, HoverIntent, MONA_FIELDSET_DISABLED, MONA_FORM_FIELD, MONA_LABEL, NavigationKeys, RovingToolbar, TYPEAHEAD_RESET_DELAY, addAriaReference, colorKey, createElementControlId, createPageScrollBlockStrategy, focusCanReturn, focusElement, formatAlpha, hex2rgba, hsla2hsva, hsva2rgba, inertOutside, injectEffectiveDisabled, injectLabelAssociation, injectLabelledByText, isNavigationKey, isTypeaheadKey, isValidHex, listenForHover, matchesAccept, navigationKeysList, onDisconnect, overlaySidePositions, parseAccept, parseColor, positionGlobalOverlay, removeAriaReference, resolveOverlaySide, restoreOverlayScroll, rgba2hex, rgba2hsla, rgba2hsva, runUpload, rxFromResize, rxTimeout, setupTypeahead, sideOfPosition, themeControlBackdropClasses, themeControlSurfaceClasses, themeOverlayBackdropClasses, themeOverlaySurfaceClasses, themeRaisedBackdropClasses, themeRaisedSurfaceClasses, themeSelectionBarClasses, themeSelectionBorderClasses, toCssValue };
878
959
 
879
960
  //# sourceMappingURL=nanahoshi-mona-ui-internal.mjs.map