@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
@@ -4,11 +4,17 @@ import { Predicate, Selector } from "@mirei/ts-collections";
4
4
  import { GroupableOptions, ListItem, ListSizeInputType } from "@nanahoshi/mona-ui/internal/list";
5
5
  import { PopupCloseEvent, PopupRef, PopupSettings } from "@nanahoshi/mona-ui/popup";
6
6
  import { FilterChangeEvent, FilterableOptions, PreventableEvent, VirtualScrollOptions } from "@nanahoshi/mona-ui/common";
7
+ import { TreeService } from "@nanahoshi/mona-ui/internal/tree";
7
8
  import { ConnectionPositionPair } from "@angular/cdk/overlay";
8
9
  import { Subject } from "rxjs";
9
10
  import { VariantInputs } from "@nanahoshi/mona-ui/internal";
10
11
  import { VariantProps } from "class-variance-authority";
11
12
  import { MonaDropdownsMessages } from "@nanahoshi/mona-ui/i18n";
13
+ /**
14
+ * How a dropdown's popup adapts to a small screen: `"auto"` opens it as a sheet along the bottom of the screen when
15
+ * the screen is narrower than 640 pixels, and `"none"` always opens it under the field.
16
+ */
17
+ type AdaptiveMode = "auto" | "none";
12
18
  export type DropdownFieldSelectorType<TData, TResult = unknown> = string | Selector<TData, TResult> | null | undefined;
13
19
  export type DropdownFieldPredicateType<TData> = string | Predicate<TData> | null | undefined;
14
20
  export interface DropdownDataInput<TData> {
@@ -25,6 +31,10 @@ export declare const DROPDOWN_DATA_INPUT_TOKEN: InjectionToken<DropdownDataInput
25
31
  export declare const DropdownDataInputToken: InjectionToken<DropdownDataInput<unknown>>;
26
32
  /** @hidden Exported for Mona UI's other entry points; applications don't need it. */
27
33
  export interface DropdownPopupInput {
34
+ /** Whether the popup opens as a bottom sheet on a small screen. Dropdowns without the input never do. */
35
+ readonly adaptiveMode?: InputSignal<AdaptiveMode>;
36
+ /** The bottom sheet's title; the field's name when empty. */
37
+ readonly adaptiveTitle?: InputSignal<string>;
28
38
  readonly close: OutputEmitterRef<PopupCloseEvent>;
29
39
  readonly closed: OutputEmitterRef<void>;
30
40
  readonly disabled: Signal<boolean>;
@@ -37,6 +47,113 @@ export interface DropdownPopupInput {
37
47
  }
38
48
  /** @hidden Exported for Mona UI's other entry points; applications don't need it. */
39
49
  export declare const DROPDOWN_POPUP_INPUT_TOKEN: InjectionToken<DropdownPopupInput>;
50
+ /** What a dropdown passes to the bottom sheet its popup opens as. */
51
+ export interface DropdownSheetData {
52
+ /** The dropdown's popup template, shown below the sheet's header. */
53
+ readonly content: TemplateRef<unknown>;
54
+ /** The sheet's title: the dropdown's `adaptiveTitle`, or else its name. */
55
+ readonly title: Signal<string>;
56
+ }
57
+ /**
58
+ * The bottom sheet a dropdown's popup opens as on a small screen (`adaptiveMode="auto"`): a header with the field's
59
+ * name and a close button, over the dropdown's own popup.
60
+ *
61
+ * Focus stays on the field, or in the popup's filter box, as it does in the popup under the field. So the sheet isn't a
62
+ * dialog, and its close button is for pointers; the keyboard closes it with Escape or Tab.
63
+ * @hidden Exported for Mona UI's other entry points; applications don't need it.
64
+ */
65
+ export declare class DropdownSheetComponent {
66
+ #private;
67
+ protected readonly data: DropdownSheetData;
68
+ protected readonly messages: Signal<import("@nanahoshi/mona-ui/i18n").MonaDropdownsMessages>;
69
+ protected readonly sheetClass: string;
70
+ protected closeSheet(): void;
71
+ /** Keeps focus on the field (or in the filter box) when the sheet is pressed. */
72
+ protected onPointerDown(event: PointerEvent): void;
73
+ static ɵfac: i0.ɵɵFactoryDeclaration<DropdownSheetComponent, never>;
74
+ static ɵcmp: i0.ɵɵComponentDeclaration<DropdownSheetComponent, "mona-dropdown-sheet", never, {}, {}, never, never, true, never>;
75
+ }
76
+ /**
77
+ * The popup of a dropdown tree and a multi-select tree: an optional filter box, the tree, and the header, footer and
78
+ * "no data" templates. The tree doesn't take focus. Its field keeps it (or the filter box does), and points
79
+ * `aria-activedescendant` at the active node.
80
+ * @hidden Exported for Mona UI's other entry points; applications don't need it.
81
+ */
82
+ export declare class DropdownTreePopupComponent<T> {
83
+ #private;
84
+ protected readonly activeDescendant: import("@angular/core").Signal<string | null>;
85
+ protected readonly empty: import("@angular/core").Signal<boolean>;
86
+ protected readonly emptyText: import("@angular/core").Signal<string>;
87
+ protected readonly filterAriaLabel: import("@angular/core").Signal<string>;
88
+ protected readonly messages: import("@angular/core").Signal<import("@nanahoshi/mona-ui/i18n").MonaTreeViewMessages>;
89
+ protected readonly noDataId: import("@angular/core").Signal<string>;
90
+ protected readonly treeService: TreeService<T>;
91
+ /** The field's accessible name, which names the tree and its filter box. */
92
+ readonly ariaLabel: import("@angular/core").InputSignal<string>;
93
+ /** Ids of the elements that name the field, which name the tree too. */
94
+ readonly ariaLabelledBy: import("@angular/core").InputSignal<string>;
95
+ readonly footerTemplate: import("@angular/core").InputSignal<TemplateRef<unknown> | null | undefined>;
96
+ readonly headerTemplate: import("@angular/core").InputSignal<TemplateRef<unknown> | null | undefined>;
97
+ readonly itemTemplate: import("@angular/core").InputSignal<TemplateRef<unknown> | null | undefined>;
98
+ readonly noDataTemplate: import("@angular/core").InputSignal<TemplateRef<unknown> | null | undefined>;
99
+ /** Classes of the popup's surface. */
100
+ readonly popupClass: import("@angular/core").InputSignal<string>;
101
+ readonly size: import("@angular/core").InputSignal<"large" | "medium" | "small">;
102
+ /** The id of the tree, which the field's `aria-controls` points at. */
103
+ readonly treeId: import("@angular/core").InputSignal<string>;
104
+ constructor();
105
+ protected onFilterChange(event: FilterChangeEvent): void;
106
+ /** Keeps focus where it is (the field or the filter box) when a node or the popup's padding is pressed. */
107
+ protected onPointerDown(event: PointerEvent): void;
108
+ static ɵfac: i0.ɵɵFactoryDeclaration<DropdownTreePopupComponent<any>, never>;
109
+ static ɵcmp: i0.ɵɵComponentDeclaration<DropdownTreePopupComponent<any>, "mona-dropdown-tree-popup", never, {
110
+ "ariaLabel": {
111
+ "alias": "ariaLabel";
112
+ "required": false;
113
+ "isSignal": true;
114
+ };
115
+ "ariaLabelledBy": {
116
+ "alias": "ariaLabelledBy";
117
+ "required": false;
118
+ "isSignal": true;
119
+ };
120
+ "footerTemplate": {
121
+ "alias": "footerTemplate";
122
+ "required": false;
123
+ "isSignal": true;
124
+ };
125
+ "headerTemplate": {
126
+ "alias": "headerTemplate";
127
+ "required": false;
128
+ "isSignal": true;
129
+ };
130
+ "itemTemplate": {
131
+ "alias": "itemTemplate";
132
+ "required": false;
133
+ "isSignal": true;
134
+ };
135
+ "noDataTemplate": {
136
+ "alias": "noDataTemplate";
137
+ "required": false;
138
+ "isSignal": true;
139
+ };
140
+ "popupClass": {
141
+ "alias": "popupClass";
142
+ "required": false;
143
+ "isSignal": true;
144
+ };
145
+ "size": {
146
+ "alias": "size";
147
+ "required": false;
148
+ "isSignal": true;
149
+ };
150
+ "treeId": {
151
+ "alias": "treeId";
152
+ "required": true;
153
+ "isSignal": true;
154
+ };
155
+ }, {}, never, never, true, never>;
156
+ }
40
157
  export declare class DropdownFilterableDirective {
41
158
  #private;
42
159
  /** @description Current filter text used to narrow the visible options. */
@@ -57,7 +174,7 @@ export declare class DropdownFilterableDirective {
57
174
  readonly options: import("@angular/core").InputSignal<"" | Partial<FilterableOptions>>;
58
175
  constructor();
59
176
  static ɵfac: i0.ɵɵFactoryDeclaration<DropdownFilterableDirective, never>;
60
- static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownFilterableDirective, " mona-auto-complete[monaDropDownFilterable], mona-dropdown-list[monaDropDownFilterable], mona-combo-box[monaDropDownFilterable], mona-multi-select[monaDropDownFilterable] ", never, {
177
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownFilterableDirective, " mona-auto-complete[monaDropDownFilterable], mona-dropdown-list[monaDropDownFilterable], mona-combo-box[monaDropDownFilterable], mona-dropdown-tree[monaDropDownFilterable], mona-multi-select[monaDropDownFilterable], mona-multi-select-tree[monaDropDownFilterable] ", never, {
61
178
  "filter": {
62
179
  "alias": "filter";
63
180
  "required": false;
@@ -79,7 +196,7 @@ export declare class DropdownFilterableDirective {
79
196
  }
80
197
  export declare class DropdownFooterTemplateDirective {
81
198
  static ɵfac: i0.ɵɵFactoryDeclaration<DropdownFooterTemplateDirective, never>;
82
- static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownFooterTemplateDirective, " ng-template[monaDropDownFooterTemplate], ng-template[monaAutoCompleteFooterTemplate], ng-template[monaDropDownListFooterTemplate], ng-template[monaDropDownTreeFooterTemplate], ng-template[monaComboBoxFooterTemplate], ng-template[monaMultiSelectFooterTemplate] ", never, {}, {}, never, never, true, never>;
199
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownFooterTemplateDirective, " ng-template[monaDropDownFooterTemplate], ng-template[monaAutoCompleteFooterTemplate], ng-template[monaDropDownListFooterTemplate], ng-template[monaDropDownTreeFooterTemplate], ng-template[monaComboBoxFooterTemplate], ng-template[monaMultiSelectFooterTemplate], ng-template[monaMultiSelectTreeFooterTemplate] ", never, {}, {}, never, never, true, never>;
83
200
  }
84
201
  export declare class DropdownGroupHeaderTemplateDirective {
85
202
  static ɵfac: i0.ɵɵFactoryDeclaration<DropdownGroupHeaderTemplateDirective, never>;
@@ -111,15 +228,15 @@ export declare class DropdownGroupableDirective<TData> {
111
228
  }
112
229
  export declare class DropdownHeaderTemplateDirective {
113
230
  static ɵfac: i0.ɵɵFactoryDeclaration<DropdownHeaderTemplateDirective, never>;
114
- static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownHeaderTemplateDirective, " ng-template[monaDropDownHeaderTemplate], ng-template[monaAutoCompleteHeaderTemplate], ng-template[monaDropDownListHeaderTemplate], ng-template[monaDropDownTreeHeaderTemplate], ng-template[monaComboBoxHeaderTemplate], ng-template[monaMultiSelectHeaderTemplate] ", never, {}, {}, never, never, true, never>;
231
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownHeaderTemplateDirective, " ng-template[monaDropDownHeaderTemplate], ng-template[monaAutoCompleteHeaderTemplate], ng-template[monaDropDownListHeaderTemplate], ng-template[monaDropDownTreeHeaderTemplate], ng-template[monaComboBoxHeaderTemplate], ng-template[monaMultiSelectHeaderTemplate], ng-template[monaMultiSelectTreeHeaderTemplate] ", never, {}, {}, never, never, true, never>;
115
232
  }
116
233
  export declare class DropdownItemTemplateDirective {
117
234
  static ɵfac: i0.ɵɵFactoryDeclaration<DropdownItemTemplateDirective, never>;
118
- static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownItemTemplateDirective, " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate] ", never, {}, {}, never, never, true, never>;
235
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownItemTemplateDirective, " ng-template[monaDropDownItemTemplate], ng-template[monaAutoCompleteItemTemplate], ng-template[monaDropDownListItemTemplate], ng-template[monaDropDownTreeItemTemplate], ng-template[monaComboBoxItemTemplate], ng-template[monaMultiSelectItemTemplate], ng-template[monaMultiSelectTreeItemTemplate] ", never, {}, {}, never, never, true, never>;
119
236
  }
120
237
  export declare class DropdownNoDataTemplateDirective {
121
238
  static ɵfac: i0.ɵɵFactoryDeclaration<DropdownNoDataTemplateDirective, never>;
122
- static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownNoDataTemplateDirective, " ng-template[monaDropDownNoDataTemplate], ng-template[monaAutoCompleteNoDataTemplate], ng-template[monaDropDownListNoDataTemplate], ng-template[monaDropDownTreeNoDataTemplate], ng-template[monaComboBoxNoDataTemplate], ng-template[monaMultiSelectNoDataTemplate] ", never, {}, {}, never, never, true, never>;
239
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownNoDataTemplateDirective, " ng-template[monaDropDownNoDataTemplate], ng-template[monaAutoCompleteNoDataTemplate], ng-template[monaDropDownListNoDataTemplate], ng-template[monaDropDownTreeNoDataTemplate], ng-template[monaComboBoxNoDataTemplate], ng-template[monaMultiSelectNoDataTemplate], ng-template[monaMultiSelectTreeNoDataTemplate] ", never, {}, {}, never, never, true, never>;
123
240
  }
124
241
  export declare class DropdownVirtualScrollDirective {
125
242
  #private;
@@ -149,10 +266,28 @@ export declare class DropdownPopupHandlerDirective {
149
266
  #private;
150
267
  constructor();
151
268
  private closePopup;
269
+ private createPopup;
270
+ /**
271
+ * Opens the popup as a sheet along the bottom of the screen, with the field's name and a close button above the
272
+ * dropdown's popup content. Focus stays where it is, as with the popup under the field.
273
+ */
274
+ private createSheet;
275
+ /**
276
+ * Keeps the sheet on the bottom edge of what is visible. An on-screen keyboard (opened by the filter box) shrinks
277
+ * the visual viewport but not the layout viewport the overlay is placed in, so the sheet is lifted above it.
278
+ */
279
+ private followVisualViewport;
152
280
  private getMaxHeight;
153
281
  private getMinWidth;
154
282
  private openPopup;
283
+ /** Whether the popup opens as a bottom sheet: with `adaptiveMode="auto"`, on a small screen. */
284
+ private opensAsSheet;
155
285
  private setPopupCloseSubscriptions;
286
+ /**
287
+ * The bottom sheet's title: the host's `adaptiveTitle`, or else its accessible name (`aria-labelledby` first, as
288
+ * assistive technology reads it, then `aria-label`).
289
+ */
290
+ private sheetTitle;
156
291
  private togglePopup;
157
292
  static ɵfac: i0.ɵɵFactoryDeclaration<DropdownPopupHandlerDirective, never>;
158
293
  static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownPopupHandlerDirective, "[monaDropdownPopupHandler]", never, {}, {}, never, never, true, never>;
@@ -198,6 +333,36 @@ export declare class DropdownSuffixTemplateDirective {
198
333
  static ɵfac: i0.ɵɵFactoryDeclaration<DropdownSuffixTemplateDirective, never>;
199
334
  static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownSuffixTemplateDirective, "ng-template[monaDropdownSuffixTemplate]", never, {}, {}, never, never, true, never>;
200
335
  }
336
+ /**
337
+ * Opens and closes the popup of a dropdown tree or a multi-select tree, and moves through its tree.
338
+ *
339
+ * The field keeps focus, or the popup's filter box does, and the tree follows: the arrow keys, Home, End, `*` and
340
+ * typeahead move its active node the way they move a focused tree's. Enter and Space go to the component through
341
+ * `DropdownService.keydown$`, to select or check the active node.
342
+ *
343
+ * When the popup opens, the selected node (or the first checked one) becomes the active node, with its ancestors
344
+ * opened; without one, the first node does. As the filter changes, its first match does. Closing the popup clears
345
+ * the filter.
346
+ * @hidden Exported for Mona UI's other entry points; applications don't need it.
347
+ */
348
+ export declare class DropdownTreePopupHandlerDirective<T> {
349
+ #private;
350
+ constructor();
351
+ /** Makes the selected node, or else the first checked one, the active node, opening its ancestors to show it. */
352
+ private activateCurrentNode;
353
+ private closePopup;
354
+ /** Arrow keys and Enter pressed in the popup's filter box. */
355
+ private handleFilterKeydown;
356
+ private handleHostKeydown;
357
+ private navigate;
358
+ private setHostEvents;
359
+ static ɵfac: i0.ɵɵFactoryDeclaration<DropdownTreePopupHandlerDirective<any>, never>;
360
+ static ɵdir: i0.ɵɵDirectiveDeclaration<DropdownTreePopupHandlerDirective<any>, "[monaDropdownTreePopupHandler]", never, {}, {}, never, never, true, [{
361
+ directive: typeof DropdownPopupHandlerDirective;
362
+ inputs: {};
363
+ outputs: {};
364
+ }]>;
365
+ }
201
366
  /**
202
367
  * @hidden
203
368
  * The state one dropdown shares with its popup handlers and live region. Each dropdown provides its own; the date and
@@ -243,6 +408,11 @@ export declare class DropdownService {
243
408
  * The auto-complete sets it to `false`.
244
409
  */
245
410
  readonly restoreFocus: import("@angular/core").WritableSignal<boolean | "auto">;
411
+ /**
412
+ * Whether the open popup is a bottom sheet (`adaptiveMode="auto"` on a small screen). The dropdowns style their
413
+ * popup content for it. `false` while the popup is closed.
414
+ */
415
+ readonly sheet: import("@angular/core").WritableSignal<boolean>;
246
416
  /**
247
417
  * Opens the popup with the given settings when it is closed. Does nothing while the host is disabled or read-only,
248
418
  * or when the `open` event is prevented.
@@ -263,9 +433,29 @@ export declare class DropdownListService<TData = unknown> {
263
433
  }
264
434
  /** @hidden Exported for Mona UI's other entry points; applications don't need it. */
265
435
  export declare const dropdownPopupThemeVariants: (props?: ({
266
- rounded?: "none" | "small" | "medium" | "large" | "full" | null | undefined;
267
- size?: "small" | "medium" | "large" | null | undefined;
436
+ rounded?: "none" | "large" | "medium" | "small" | "full" | null | undefined;
437
+ size?: "large" | "medium" | "small" | null | undefined;
268
438
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
269
439
  export type DropdownPopupVariantProps = VariantProps<typeof dropdownPopupThemeVariants>;
270
440
  export type DropdownPopupVariantInput = VariantInputs<DropdownPopupVariantProps>;
271
- export declare const DROPDOWNS_DEFAULT_MESSAGES: MonaDropdownsMessages;
441
+ /**
442
+ * The bottom sheet a dropdown's popup opens as on a small screen. Its rounded top edge faces the page; the bottom
443
+ * padding keeps the content above the home indicator. `overflow-clip`, not `hidden`, so content that takes focus
444
+ * during the slide-in can't scroll the sheet and cancel the animation.
445
+ * @hidden Exported for Mona UI's other entry points; applications don't need it.
446
+ */
447
+ export declare const dropdownSheetThemeVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
448
+ /**
449
+ * A dropdown's popup surface inside the bottom sheet: the sheet draws the border, corners and shadow, and sets the
450
+ * height, so the surface only fills it. Options and nodes are 44 pixels tall there, to be easy to tap.
451
+ * @hidden Exported for Mona UI's other entry points; applications don't need it.
452
+ */
453
+ export declare const dropdownSheetSurfaceClasses = "\n h-full max-h-none flex-1 rounded-none border-0 shadow-none text-base\n [&_[role=option]]:min-h-11 [&_mona-tree-node>div]:py-2.5\n";
454
+ /**
455
+ * Reads a dropdown field from an item: a property of it when the field is a name, or what the field returns when it
456
+ * is an accessor. Without a field, the item itself.
457
+ * @hidden Exported for Mona UI's other entry points; applications don't need it.
458
+ */
459
+ export declare function readDropdownField<TData>(item: TData, field: DropdownFieldPredicateType<TData> | DropdownFieldSelectorType<TData>): unknown;
460
+ export declare const DROPDOWNS_DEFAULT_MESSAGES: MonaDropdownsMessages;
461
+ export type { AdaptiveMode };
@@ -1,11 +1,13 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { ElementRef } from "@angular/core";
3
3
  import { FormValueControl } from "@angular/forms/signals";
4
+ import { FileUploadHandler } from "@nanahoshi/mona-ui/file-upload";
4
5
  import { Editor, JSONContent } from "@tiptap/core";
6
+ import { Observable, Subject } from "rxjs";
5
7
  import { ImmutableSet } from "@mirei/ts-collections";
6
8
  import { EditorState } from "@tiptap/pm/state";
7
- import { Subject } from "rxjs";
8
9
  import { MonaEditorMessages } from "@nanahoshi/mona-ui/i18n";
10
+ import "@tiptap/pm/model";
9
11
  /** The content of the editor after a user change, emitted by `EditorComponent.update`. */
10
12
  interface ContentChangeEvent {
11
13
  /** The content as HTML, the same as the editor's `html` property. */
@@ -13,6 +15,22 @@ interface ContentChangeEvent {
13
15
  /** The content as a `JSONContent` document, the same as the editor's `json` property. */
14
16
  json: JSONContent;
15
17
  }
18
+ /**
19
+ * Someone, or something, the content can mention. A mention keeps both: the content shows `@label`, and the HTML
20
+ * keeps the id in `data-id` for the page to read, such as to notify the person.
21
+ */
22
+ interface EditorMention {
23
+ /** What the mention refers to, such as a user id. */
24
+ readonly id: string;
25
+ /** What the mention shows after the `@`, such as a name. */
26
+ readonly label: string;
27
+ }
28
+ /**
29
+ * Finds the mentions to offer for the text typed after `@`, which is empty right after the `@`. It returns them, or a
30
+ * promise or an observable of them; a new search replaces one still running, so an observable can be HttpClient's
31
+ * request. Return a few, such as the first ten matches: the list doesn't page.
32
+ */
33
+ type EditorMentionSearch = (query: string) => Iterable<EditorMention> | Observable<Iterable<EditorMention>> | Promise<Iterable<EditorMention>>;
16
34
  /**
17
35
  * The features of an editor. Every feature is on unless it is set to `false`. Turning one off removes its toolbar
18
36
  * control, and the editor no longer keeps that kind of content.
@@ -57,6 +75,11 @@ interface EditorSettings {
57
75
  link: boolean;
58
76
  /** Whether the toolbar shows the numbered and bulleted list buttons and the editor keeps those lists. */
59
77
  list: boolean;
78
+ /**
79
+ * Whether the editor keeps mentions, and offers them as `@` is typed when it has a `mentionSearch`. It has no
80
+ * toolbar control. Optional, unlike the others, so settings written before it still compile.
81
+ */
82
+ mention?: boolean;
60
83
  /** Whether the toolbar shows the strikethrough button and the editor keeps struck-through text. */
61
84
  strikethrough: boolean;
62
85
  /** Whether the toolbar shows the subscript button and the editor keeps subscript text. */
@@ -93,6 +116,10 @@ declare class EditorService {
93
116
  readonly settings: import("@angular/core").WritableSignal<Partial<EditorSettings>>;
94
117
  readonly state: import("@angular/core").Signal<EditorState | null>;
95
118
  readonly update$: Subject<void>;
119
+ /** Set by the image upload service, which uploads pasted and dropped images. */
120
+ imageUploader: EditorImageUploader | null;
121
+ /** Set by the mention service, which offers mentions as `@` is typed. */
122
+ mentionController: EditorMentionController | null;
96
123
  destroy(): void;
97
124
  /**
98
125
  * Replaces the document without emitting an update, as for a value set from outside.
@@ -115,11 +142,24 @@ export declare class EditorComponent implements FormValueControl<string> {
115
142
  #private;
116
143
  protected readonly baseClass: import("@angular/core").Signal<string>;
117
144
  protected readonly containerClass: import("@angular/core").Signal<string>;
145
+ /** The counts under the content: the words, then the characters or the characters left. */
146
+ protected readonly countParts: import("@angular/core").Signal<{
147
+ readonly class: string;
148
+ readonly text: string;
149
+ }[]>;
118
150
  protected readonly editorContainer: import("@angular/core").Signal<ElementRef<HTMLDivElement>>;
119
151
  protected readonly editorService: EditorService;
120
152
  protected readonly effectiveDisabled: import("@angular/core").Signal<boolean>;
153
+ protected readonly footerClass = "not-prose flex flex-wrap justify-end gap-x-3 border-t border-border-subtle px-2 py-1 text-xs text-muted-foreground";
121
154
  protected readonly invalidState: import("@angular/core").Signal<boolean>;
155
+ /** Says how many characters the content can have, for assistive technology. */
156
+ protected readonly limitHint: import("@angular/core").Signal<string>;
157
+ protected readonly limitHintId: string;
158
+ /** How many characters are left, or how many are over the limit. Null without a limit. */
159
+ protected readonly limitMessage: import("@angular/core").Signal<string | null>;
122
160
  protected readonly messages: import("@angular/core").Signal<import("@nanahoshi/mona-ui/i18n").MonaEditorMessages>;
161
+ /** Whether the content has more characters than its limit. */
162
+ protected readonly overLimit: import("@angular/core").Signal<boolean>;
123
163
  protected readonly placeholderClass: import("@angular/core").Signal<string>;
124
164
  protected readonly toolbarClass: import("@angular/core").Signal<string>;
125
165
  protected readonly toolbarElement: import("@angular/core").Signal<ElementRef<HTMLDivElement> | undefined>;
@@ -141,6 +181,13 @@ export declare class EditorComponent implements FormValueControl<string> {
141
181
  * @deprecated Use `editorBlur`.
142
182
  */
143
183
  readonly blur: import("@angular/core").OutputEmitterRef<void>;
184
+ /**
185
+ * @description How many characters the content should fit, counted as people see them: the text without the
186
+ * markup, where an emoji or a letter with an accent counts once. Under the content, a count says how many are
187
+ * left. Typing past the limit isn't blocked, so nothing pasted is lost: the count turns into how many are over,
188
+ * and the editor shows as invalid. For a form, validate the value with `countEditorText`.
189
+ */
190
+ readonly characterLimit: import("@angular/core").InputSignal<number | null>;
144
191
  /**
145
192
  * @description The initial content of the editor, as HTML or a {@link JSONContent} document. A later change
146
193
  * replaces the document, unless it is the content the editor already has.
@@ -166,11 +213,30 @@ export declare class EditorComponent implements FormValueControl<string> {
166
213
  * @description Emits when the editor gains focus.
167
214
  */
168
215
  readonly editorFocus: import("@angular/core").OutputEmitterRef<void>;
216
+ /**
217
+ * @description The image files `imageUpload` takes, as an `accept` attribute: MIME types such as `image/png`,
218
+ * `image/*` for any image, and extensions such as `.png`.
219
+ */
220
+ readonly imageAccept: import("@angular/core").InputSignal<string>;
221
+ /** @description The largest image file, in bytes, that `imageUpload` takes. Null takes any size. */
222
+ readonly imageMaxFileSize: import("@angular/core").InputSignal<number | null>;
223
+ /**
224
+ * @description Uploads image files, and returns the image's address: as a promise or an observable, the same
225
+ * way as the file upload's `upload`. With it, the image form takes a file, and images pasted or dropped into the
226
+ * content upload in place, with a placeholder while they do. Without it, images are added by their address.
227
+ */
228
+ readonly imageUpload: import("@angular/core").InputSignal<FileUploadHandler | null>;
169
229
  /**
170
230
  * @description Marks the editor as invalid once it has been touched. When bound to a signal form field via
171
231
  * `[formField]`, the form sets it.
172
232
  */
173
233
  readonly invalid: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
234
+ /**
235
+ * @description Finds the mentions to offer as `@` and a query are typed. With it, a list of suggestions opens at
236
+ * the `@`: the arrow keys move through it, Enter or Tab puts the highlighted one in the content, and Escape closes
237
+ * it. A mention is kept in the HTML as `<span data-type="mention" data-id="…">`.
238
+ */
239
+ readonly mentionSearch: import("@angular/core").InputSignal<EditorMentionSearch | null>;
174
240
  /**
175
241
  * @description Text shown in the empty editor, and given to assistive technology as `aria-placeholder`. It is not
176
242
  * a name: use a label or `aria-label` too.
@@ -193,6 +259,10 @@ export declare class EditorComponent implements FormValueControl<string> {
193
259
  * @description The settings of the editor. Changing them rebuilds the editor and keeps its document.
194
260
  */
195
261
  readonly settings: import("@angular/core").InputSignal<Partial<EditorSettings>>;
262
+ /** @description Shows how many characters the content has, under it. A `characterLimit` shows the count anyway. */
263
+ readonly showCharacterCount: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
264
+ /** @description Shows how many words the content has, under it. */
265
+ readonly showWordCount: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
196
266
  /**
197
267
  * @description Emits when the editor loses focus.
198
268
  * Form directives (`[formField]`, `ngModel`, `formControl`) listen to this to mark the field as touched.
@@ -249,6 +319,11 @@ export declare class EditorComponent implements FormValueControl<string> {
249
319
  "required": false;
250
320
  "isSignal": true;
251
321
  };
322
+ "characterLimit": {
323
+ "alias": "characterLimit";
324
+ "required": false;
325
+ "isSignal": true;
326
+ };
252
327
  "content": {
253
328
  "alias": "content";
254
329
  "required": false;
@@ -259,11 +334,31 @@ export declare class EditorComponent implements FormValueControl<string> {
259
334
  "required": false;
260
335
  "isSignal": true;
261
336
  };
337
+ "imageAccept": {
338
+ "alias": "imageAccept";
339
+ "required": false;
340
+ "isSignal": true;
341
+ };
342
+ "imageMaxFileSize": {
343
+ "alias": "imageMaxFileSize";
344
+ "required": false;
345
+ "isSignal": true;
346
+ };
347
+ "imageUpload": {
348
+ "alias": "imageUpload";
349
+ "required": false;
350
+ "isSignal": true;
351
+ };
262
352
  "invalid": {
263
353
  "alias": "invalid";
264
354
  "required": false;
265
355
  "isSignal": true;
266
356
  };
357
+ "mentionSearch": {
358
+ "alias": "mentionSearch";
359
+ "required": false;
360
+ "isSignal": true;
361
+ };
267
362
  "placeholder": {
268
363
  "alias": "placeholder";
269
364
  "required": false;
@@ -284,6 +379,16 @@ export declare class EditorComponent implements FormValueControl<string> {
284
379
  "required": false;
285
380
  "isSignal": true;
286
381
  };
382
+ "showCharacterCount": {
383
+ "alias": "showCharacterCount";
384
+ "required": false;
385
+ "isSignal": true;
386
+ };
387
+ "showWordCount": {
388
+ "alias": "showWordCount";
389
+ "required": false;
390
+ "isSignal": true;
391
+ };
287
392
  "touched": {
288
393
  "alias": "touched";
289
394
  "required": false;
@@ -311,4 +416,21 @@ export declare class EditorComponent implements FormValueControl<string> {
311
416
  }, never, never, true, never>;
312
417
  }
313
418
  export declare const EDITOR_DEFAULT_MESSAGES: MonaEditorMessages;
314
- export type { ContentChangeEvent, EditorSettings };
419
+ /** What {@link countEditorText} counts: characters as people see them, or words. */
420
+ type EditorTextUnit = "characters" | "words";
421
+ /**
422
+ * Counts the characters or words of the editor's HTML value, as the editor's own count does: the text people see,
423
+ * without the markup. Use it in a validator for a limit:
424
+ *
425
+ * ```ts
426
+ * validate(path.body, ({ value }) =>
427
+ * countEditorText(value(), "characters") > 500 ? { kind: "tooLong", message: "Keep it to 500 characters." } : undefined
428
+ * );
429
+ * ```
430
+ *
431
+ * @param html The editor's value.
432
+ * @param unit Characters, as people see them, or words.
433
+ * @param locale The locale whose rules find the words, such as `"ja-JP"`. Defaults to the browser's.
434
+ */
435
+ export declare function countEditorText(html: string, unit: EditorTextUnit, locale?: string): number;
436
+ export type { ContentChangeEvent, EditorMention, EditorMentionSearch, EditorSettings, EditorTextUnit };
@@ -3,6 +3,7 @@ import { ElementRef } from "@angular/core";
3
3
  import { FormValueControl } from "@angular/forms/signals";
4
4
  import { Observable } from "rxjs";
5
5
  import { MonaFileUploadMessages } from "@nanahoshi/mona-ui/i18n";
6
+ import "@nanahoshi/mona-ui/internal";
6
7
  /**
7
8
  * What the upload function gets with each file.
8
9
  */
@@ -323,7 +323,12 @@ export type DialogMessages = MonaDialogMessages;
323
323
  export interface MonaDropdownListMessages {
324
324
  readonly clear: string;
325
325
  }
326
+ export interface MonaDropdownTreeMessages {
327
+ readonly clear: string;
328
+ }
326
329
  export interface MonaDropdownsMessages {
330
+ /** The button that closes a dropdown's popup when it opens as a bottom sheet on a small screen. */
331
+ readonly close: string;
327
332
  readonly itemPosition: (text: string, position: number, total: number) => string;
328
333
  readonly noResultsFound: string;
329
334
  readonly resultsAvailable: (count: number) => string;
@@ -361,6 +366,14 @@ export interface MonaEditorMessages {
361
366
  readonly bold: string;
362
367
  /** The label of the Cancel button in the link dialog and the insert image form. */
363
368
  readonly cancel: string;
369
+ /** The count under the content when `showCharacterCount` is set and there's no `characterLimit`. */
370
+ readonly characterCount: (count: number) => string;
371
+ /** Describes the content when it has a `characterLimit`, given the limit. Not shown, only read with the content. */
372
+ readonly characterLimitHint: (limit: number) => string;
373
+ /** The count under the content while it is within its `characterLimit`, given the characters left. */
374
+ readonly charactersLeft: (count: number) => string;
375
+ /** The count under the content once it is over its `characterLimit`, given the characters over it. */
376
+ readonly charactersOver: (count: number) => string;
364
377
  /** The label of the toolbar button that toggles a code block. */
365
378
  readonly codeBlock: string;
366
379
  /** The label of the toolbar color picker that sets the text color. */
@@ -375,6 +388,8 @@ export interface MonaEditorMessages {
375
388
  readonly deleteRow: string;
376
389
  /** The label of the toolbar button that deletes the table. */
377
390
  readonly deleteTable: string;
391
+ /** The title of the image form's window, and the label of the image button, when an image is selected. */
392
+ readonly editImage: string;
378
393
  /** The title of the link dialog when the selection is already in a link. */
379
394
  readonly editLink: string;
380
395
  /** The label of the URL field in the link dialog. */
@@ -389,6 +404,16 @@ export interface MonaEditorMessages {
389
404
  readonly heightPx: string;
390
405
  /** The accessible name of the toolbar's undo and redo button group. */
391
406
  readonly historyGroup: string;
407
+ /** The accessible name of the file drop zone in the image form, shown when the editor has `imageUpload`. */
408
+ readonly imageFile: string;
409
+ /** Announced when a pasted or dropped image has uploaded and is in the content, given the file's name. */
410
+ readonly imageInserted: (name: string) => string;
411
+ /** Announced when a pasted or dropped image is larger than `imageMaxFileSize`, given its name and the size. */
412
+ readonly imageTooLarge: (name: string, size: string) => string;
413
+ /** Announced when a pasted or dropped image fails to upload, given the file's name. */
414
+ readonly imageUploadFailed: (name: string) => string;
415
+ /** Announced when a pasted or dropped image starts uploading, and names its placeholder, given the file's name. */
416
+ readonly imageUploading: (name: string) => string;
392
417
  /** The label of the image URL field in the insert image form. */
393
418
  readonly imageUrl: string;
394
419
  /** The label of the toolbar button that increases the indentation. */
@@ -419,6 +444,14 @@ export interface MonaEditorMessages {
419
444
  readonly linkGroup: string;
420
445
  /** The accessible name of the toolbar's list button group. */
421
446
  readonly listGroup: string;
447
+ /** Shown in the mention suggestions when the search finds no one. */
448
+ readonly mentionNoResults: string;
449
+ /** Announced when the mention suggestions change, given how many there are. */
450
+ readonly mentionResults: (count: number) => string;
451
+ /** Shown in the mention suggestions while the search runs. */
452
+ readonly mentionSearching: string;
453
+ /** The accessible name of the mention suggestions list. */
454
+ readonly mentionSuggestions: string;
422
455
  /** The label of the toolbar button that merges the selected cells. */
423
456
  readonly mergeCells: string;
424
457
  /** The label of the toolbar button that decreases the indentation. */
@@ -431,6 +464,8 @@ export interface MonaEditorMessages {
431
464
  readonly redo: string;
432
465
  /** The label of the toolbar button and the link dialog button that remove the link. */
433
466
  readonly removeLink: string;
467
+ /** The label of the image form's button that applies the changes to a selected image. */
468
+ readonly save: string;
434
469
  /** The label of the toolbar's font family dropdown. */
435
470
  readonly selectFontFamily: string;
436
471
  /** The label of the toolbar's font size dropdown. */
@@ -462,6 +497,8 @@ export interface MonaEditorMessages {
462
497
  readonly undo: string;
463
498
  /** The label of the width field in the insert image form. */
464
499
  readonly widthPx: string;
500
+ /** The count under the content when `showWordCount` is set, given the number of words. */
501
+ readonly wordCount: (count: number) => string;
465
502
  }
466
503
  /**
467
504
  * The file upload's drop zone, its list of files, and what it announces as files are added, uploaded and removed.
@@ -726,6 +763,11 @@ export interface MonaMultiSelectMessages {
726
763
  /** The option at the top of the list that selects every item shown, or clears them when they're all selected. */
727
764
  readonly selectAll: string;
728
765
  }
766
+ export interface MonaMultiSelectTreeMessages {
767
+ readonly clear: string;
768
+ readonly itemsCount: (count: number) => string;
769
+ readonly removeMoreItems: (count: number) => string;
770
+ }
729
771
  export interface MonaNotificationMessages {
730
772
  readonly close: string;
731
773
  readonly error: string;
@@ -958,6 +1000,7 @@ export interface MonaLocaleMessages {
958
1000
  dateTimePicker: MonaDateTimePickerMessages;
959
1001
  dialog: MonaDialogMessages;
960
1002
  dropdownList: MonaDropdownListMessages;
1003
+ dropdownTree: MonaDropdownTreeMessages;
961
1004
  dropdowns: MonaDropdownsMessages;
962
1005
  editor: MonaEditorMessages;
963
1006
  fileUpload: MonaFileUploadMessages;
@@ -969,6 +1012,7 @@ export interface MonaLocaleMessages {
969
1012
  listBox: MonaListBoxMessages;
970
1013
  maskedTextBox: MonaMaskedTextBoxMessages;
971
1014
  multiSelect: MonaMultiSelectMessages;
1015
+ multiSelectTree: MonaMultiSelectTreeMessages;
972
1016
  notification: MonaNotificationMessages;
973
1017
  numericTextBox: MonaNumericTextBoxMessages;
974
1018
  otpInput: MonaOtpInputMessages;