@nanahoshi/mona-ui 0.37.0 → 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 (83) 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/i18n.md +33 -4
  6. package/docs/api/list.md +1 -1
  7. package/docs/api/locales.md +14 -14
  8. package/docs/api/multi-select-tree.md +75 -0
  9. package/docs/api/multi-select.md +3 -1
  10. package/docs/api/popup.md +1 -1
  11. package/docs/api/tree-view.md +2 -2
  12. package/docs/auto-complete.md +2 -0
  13. package/docs/combo-box.md +2 -0
  14. package/docs/dropdown-list.md +52 -0
  15. package/docs/dropdown-tree.md +427 -0
  16. package/docs/multi-select-tree.md +353 -0
  17. package/docs/multi-select.md +6 -0
  18. package/dropdown-tree/package.json +4 -0
  19. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +40 -5
  20. package/fesm2022/nanahoshi-mona-ui-dropdown-tree.mjs +1061 -0
  21. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -60
  22. package/fesm2022/nanahoshi-mona-ui-editor.mjs +8 -2
  23. package/fesm2022/nanahoshi-mona-ui-filter.mjs +2 -0
  24. package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
  25. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +13 -0
  26. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +80 -37
  27. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +7 -0
  28. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +7 -0
  29. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +7 -0
  30. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +7 -0
  31. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +7 -0
  32. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +7 -0
  33. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +7 -0
  34. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +7 -0
  35. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +17 -0
  36. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +7 -0
  37. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +17 -0
  38. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +7 -0
  39. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +7 -0
  40. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +7 -0
  41. package/fesm2022/nanahoshi-mona-ui-multi-select-tree.mjs +1179 -0
  42. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +42 -7
  43. package/fesm2022/nanahoshi-mona-ui-pager.mjs +3 -1
  44. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +2 -1
  45. package/i18n/catalogs/en-US.messages.json +9 -0
  46. package/llms.txt +6 -2
  47. package/locales/ar-sa/ar-sa.messages.json +9 -0
  48. package/locales/de-de/de-de.messages.json +9 -0
  49. package/locales/es-es/es-es.messages.json +9 -0
  50. package/locales/fr-fr/fr-fr.messages.json +9 -0
  51. package/locales/id-id/id-id.messages.json +9 -0
  52. package/locales/it-it/it-it.messages.json +9 -0
  53. package/locales/ja-jp/ja-jp.messages.json +9 -0
  54. package/locales/ko-kr/ko-kr.messages.json +9 -0
  55. package/locales/pl-pl/pl-pl.messages.json +9 -0
  56. package/locales/pt-br/pt-br.messages.json +9 -0
  57. package/locales/ru-ru/ru-ru.messages.json +9 -0
  58. package/locales/tr-tr/tr-tr.messages.json +9 -0
  59. package/locales/zh-cn/zh-cn.messages.json +9 -0
  60. package/locales/zh-tw/zh-tw.messages.json +9 -0
  61. package/multi-select-tree/package.json +4 -0
  62. package/package.json +9 -1
  63. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +33 -5
  64. package/types/nanahoshi-mona-ui-dropdown-tree.d.ts +414 -0
  65. package/types/nanahoshi-mona-ui-dropdowns.d.ts +198 -8
  66. package/types/nanahoshi-mona-ui-i18n.d.ts +12 -0
  67. package/types/nanahoshi-mona-ui-internal-tree.d.ts +36 -0
  68. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +9 -0
  69. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +9 -0
  70. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +9 -0
  71. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +9 -0
  72. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +9 -0
  73. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +9 -0
  74. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +9 -0
  75. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +9 -0
  76. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +9 -0
  77. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +9 -0
  78. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +9 -0
  79. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +9 -0
  80. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +9 -0
  81. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +9 -0
  82. package/types/nanahoshi-mona-ui-multi-select-tree.d.ts +456 -0
  83. package/types/nanahoshi-mona-ui-multi-select.d.ts +43 -7
@@ -0,0 +1,353 @@
1
+ # Multi Select Tree
2
+
3
+ > A control that opens a tree with checkboxes and shows the checked items as removable tags.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/multi-select-tree`
6
+
7
+ **Selector:** `mona-multi-select-tree`
8
+
9
+ `MultiSelectTreeComponent` is a combobox that opens a tree with checkboxes and shows the checked items as removable tags. Checking an item checks its children too, and an item whose children are all checked is checked itself, so a whole branch can be chosen at once.
10
+
11
+ ## Overview
12
+
13
+ Multi Select Tree renders a combobox whose popup is a tree with checkboxes. The checked items show as removable tags in the field, and the value lists them. The popup opens on click, `Enter`, `Space`, `ArrowDown` or `Alt+ArrowDown`, and stays open while items are checked.
14
+
15
+ Checking follows the tree:
16
+
17
+ - **`checkChildren`** (on by default): checking an item checks its children, and unchecking it unchecks them.
18
+ - **`checkParents`** (on by default): an item is checked when all its children are, and unchecked when one isn't. An item with some of its children checked shows a mixed checkbox.
19
+
20
+ The data takes the shapes of the [dropdown tree](dropdown-tree.md): hierarchical, with `children`, or flat, with `mode="flat"`, `idField` and `parentIdField`.
21
+
22
+ **Use Multi Select Tree when:**
23
+
24
+ - More than one item can be chosen from a hierarchy, such as permissions, regions or folders.
25
+
26
+ **Use `DropdownTree` instead when:**
27
+
28
+ - Exactly one item is chosen.
29
+
30
+ **Use `MultiSelect` instead when:**
31
+
32
+ - The options are a flat list.
33
+
34
+ ## Import & Quick Start
35
+
36
+ ```typescript
37
+ import { MultiSelectTreeComponent } from "@nanahoshi/mona-ui/multi-select-tree";
38
+ ```
39
+
40
+ ```typescript
41
+ protected readonly regions = [
42
+ {
43
+ code: "EU",
44
+ name: "Europe",
45
+ countries: [
46
+ { code: "DE", name: "Germany" },
47
+ { code: "FR", name: "France" }
48
+ ]
49
+ }
50
+ ];
51
+
52
+ protected readonly countries = signal<string[]>([]);
53
+ ```
54
+
55
+ ```html
56
+ <mona-form-field label="Ships to">
57
+ <mona-multi-select-tree
58
+ children="countries"
59
+ textField="name"
60
+ valueField="code"
61
+ [data]="regions"
62
+ [valuePrimitive]="true"
63
+ [(value)]="countries" />
64
+ </mona-form-field>
65
+ ```
66
+
67
+ ## Anatomy
68
+
69
+ Each template below is an `ng-template` placed inside `<mona-multi-select-tree>`.
70
+
71
+ | Directive | Selector | Template context | Replaces |
72
+ |------------------------------------------|--------------------------------------------------|------------------------------------------|-------------------------------------------------|
73
+ | `DropdownItemTemplateDirective` | `ng-template[monaMultiSelectTreeItemTemplate]` | `{ $implicit: TData }` (the node's item) | Each node's text in the popup |
74
+ | `MultiSelectTagTemplateDirective` | `ng-template[monaMultiSelectTagTemplate]` | `{ $implicit: TData }` (the tag's item) | Each tag's text |
75
+ | `MultiSelectSummaryTagTemplateDirective` | `ng-template[monaMultiSelectSummaryTagTemplate]` | `{ $implicit: value, tagCount: number }` | The summary tag's "+ n items" |
76
+ | `DropdownHeaderTemplateDirective` | `ng-template[monaMultiSelectTreeHeaderTemplate]` | None | No default; renders above the tree |
77
+ | `DropdownFooterTemplateDirective` | `ng-template[monaMultiSelectTreeFooterTemplate]` | None | No default; renders below the tree |
78
+ | `DropdownNoDataTemplateDirective` | `ng-template[monaMultiSelectTreeNoDataTemplate]` | None | "No data", or "No matching items" when filtered |
79
+ | `DropdownPrefixTemplateDirective` | `ng-template[monaDropdownPrefixTemplate]` | None | No default; renders before the tags |
80
+
81
+ The tag and summary tag directives, and `MultiSelectSummaryTagDirective`, come from `@nanahoshi/mona-ui/multi-select`, and the others from `@nanahoshi/mona-ui/dropdowns`. With a value whose items aren't loaded (and `valuePrimitive`), the tag template gets the value itself.
82
+
83
+ ## Examples
84
+
85
+ ### Granting permissions
86
+
87
+ Checking a group grants every permission in it, and a group whose permissions are all granted is checked itself. `monaMultiSelectSummaryTag` shows three tags and sums up the rest, and the filter box finds a permission by name. With `adaptiveMode="auto"`, the popup opens as a bottom sheet on a phone.
88
+
89
+ `permissions-example.component.ts`
90
+
91
+ ```typescript
92
+ import { Component, signal } from "@angular/core";
93
+ import { DropdownFilterableDirective } from "@nanahoshi/mona-ui/dropdowns";
94
+ import { FormFieldComponent } from "@nanahoshi/mona-ui/form-field";
95
+ import { MultiSelectSummaryTagDirective } from "@nanahoshi/mona-ui/multi-select";
96
+ import { MultiSelectTreeComponent } from "@nanahoshi/mona-ui/multi-select-tree";
97
+
98
+ interface Permission {
99
+ readonly id: string;
100
+ readonly label: string;
101
+ readonly permissions?: readonly Permission[];
102
+ }
103
+
104
+ @Component({
105
+ selector: "app-multi-select-tree-permissions-example",
106
+ imports: [
107
+ DropdownFilterableDirective,
108
+ FormFieldComponent,
109
+ MultiSelectSummaryTagDirective,
110
+ MultiSelectTreeComponent
111
+ ],
112
+ templateUrl: "./permissions-example.component.html"
113
+ })
114
+ export class MultiSelectTreePermissionsExampleComponent {
115
+ protected readonly granted = signal<string[]>(["orders.view", "orders.refund"]);
116
+ protected readonly permissions: readonly Permission[] = [
117
+ {
118
+ id: "orders",
119
+ label: "Orders",
120
+ permissions: [
121
+ { id: "orders.view", label: "View orders" },
122
+ { id: "orders.edit", label: "Edit orders" },
123
+ { id: "orders.refund", label: "Issue refunds" }
124
+ ]
125
+ },
126
+ {
127
+ id: "products",
128
+ label: "Products",
129
+ permissions: [
130
+ { id: "products.view", label: "View products" },
131
+ { id: "products.edit", label: "Edit products" },
132
+ { id: "products.prices", label: "Change prices" }
133
+ ]
134
+ },
135
+ {
136
+ id: "team",
137
+ label: "Team",
138
+ permissions: [
139
+ { id: "team.invite", label: "Invite members" },
140
+ { id: "team.roles", label: "Change roles" }
141
+ ]
142
+ }
143
+ ];
144
+ }
145
+ ```
146
+
147
+ `permissions-example.component.html`
148
+
149
+ ```html
150
+ <div class="flex max-w-md flex-col gap-2">
151
+ <mona-form-field label="Permissions" hint="Checking a group grants everything in it.">
152
+ <mona-multi-select-tree
153
+ adaptiveMode="auto"
154
+ children="permissions"
155
+ monaDropDownFilterable
156
+ placeholder="Grant permissions"
157
+ textField="label"
158
+ valueField="id"
159
+ [data]="permissions"
160
+ [monaMultiSelectSummaryTag]="3"
161
+ [showClearButton]="true"
162
+ [valuePrimitive]="true"
163
+ [(value)]="granted" />
164
+ </mona-form-field>
165
+ <span class="text-sm">Granted: {{ granted().join(", ") || "nothing" }}</span>
166
+ </div>
167
+ ```
168
+
169
+ ### Signal Forms integration
170
+
171
+ A `minLength` rule on the field asks for at least one country, and the form field shows its message once the field is touched. With `checkParents` off, checking every country of a region leaves the region itself unchecked. Checking the region still checks its countries, and adds the region to the value too.
172
+
173
+ `forms-example.component.ts`
174
+
175
+ ```typescript
176
+ import { Component, signal } from "@angular/core";
177
+ import { form, FormField, minLength } from "@angular/forms/signals";
178
+ import { FormFieldComponent } from "@nanahoshi/mona-ui/form-field";
179
+ import { MultiSelectTreeComponent } from "@nanahoshi/mona-ui/multi-select-tree";
180
+
181
+ interface Region {
182
+ readonly code: string;
183
+ readonly countries?: readonly Region[];
184
+ readonly name: string;
185
+ }
186
+
187
+ interface ShippingModel {
188
+ countries: string[];
189
+ }
190
+
191
+ @Component({
192
+ selector: "app-multi-select-tree-forms-example",
193
+ imports: [FormField, FormFieldComponent, MultiSelectTreeComponent],
194
+ templateUrl: "./forms-example.component.html"
195
+ })
196
+ export class MultiSelectTreeFormsExampleComponent {
197
+ readonly #model = signal<ShippingModel>({ countries: [] });
198
+ protected readonly regions: readonly Region[] = [
199
+ {
200
+ code: "EU",
201
+ name: "Europe",
202
+ countries: [
203
+ { code: "DE", name: "Germany" },
204
+ { code: "FR", name: "France" },
205
+ { code: "IT", name: "Italy" },
206
+ { code: "PL", name: "Poland" }
207
+ ]
208
+ },
209
+ {
210
+ code: "AS",
211
+ name: "Asia",
212
+ countries: [
213
+ { code: "JP", name: "Japan" },
214
+ { code: "KR", name: "South Korea" },
215
+ { code: "TR", name: "Türkiye" }
216
+ ]
217
+ }
218
+ ];
219
+ protected readonly shipping = form(this.#model, path => {
220
+ minLength(path.countries, 1, { message: "Choose at least one country." });
221
+ });
222
+ }
223
+ ```
224
+
225
+ `forms-example.component.html`
226
+
227
+ ```html
228
+ <mona-form-field class="max-w-md" label="Ships to" hint="Choose a region to ship to all its countries.">
229
+ <mona-multi-select-tree
230
+ children="countries"
231
+ textField="name"
232
+ valueField="code"
233
+ [checkParents]="false"
234
+ [data]="regions"
235
+ [formField]="shipping.countries"
236
+ [valuePrimitive]="true" />
237
+ </mona-form-field>
238
+ ```
239
+
240
+ ## Appearance & Styling
241
+
242
+ The multi-select tree has the sizes, corner roundings and states of the [multi-select](multi-select.md): `size` is `small`, `medium` (default) or `large`, and `rounded` is `none`, `small`, `medium` (default), `large` or `full`. The tags wrap onto more lines as items are checked, and the popup moves with the field's bottom edge.
243
+
244
+ | Input | What it does |
245
+ |-------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
246
+ | `popupHeight` | The popup's maximum height; 200 pixels when unset. Shorter trees shrink to fit. |
247
+ | `popupWidth` | The popup's width; the field's width when unset. |
248
+ | `popupClass` | Classes added to the popup. |
249
+ | `showClearButton` | A button in the field that unchecks every item. |
250
+ | `adaptiveMode` | `"auto"` opens the popup as a bottom sheet on a small screen, as described for the [dropdown tree](dropdown-tree.md#on-a-phone). |
251
+
252
+ ## Behavior
253
+
254
+ ### The value's order
255
+
256
+ A change the user makes lists the checked items in the tree's order. A value set from code keeps its own order until the next change, and a value item whose node isn't loaded yet stays in the value, after the loaded ones.
257
+
258
+ ### Tags
259
+
260
+ Each checked item has a tag. A tag's remove button unchecks its item as the tree does, so removing a group's tag unchecks the group's items with `checkChildren`. The summary tag's remove button unchecks only the items it stands for. `Backspace` in the field unchecks the item of the last tag.
261
+
262
+ ### Clicking a node checks it
263
+
264
+ A click anywhere on a node's row checks or unchecks it, as a click on its checkbox does, and the popup stays open. The arrow on a node opens and closes it. A disabled item (`itemDisabled`) can't be checked or opened, and checking its parent leaves it as it is.
265
+
266
+ ### Derived parents
267
+
268
+ With `checkParents`, an item whose children are all in a value set from code shows checked in the tree, but it joins the value only with the user's next change.
269
+
270
+ ### `open` and `close` are cancelable
271
+
272
+ `open` and `close` emit a `PreventableEvent`; calling `preventDefault()` keeps the popup as it is. `opened` and `closed` follow once it has opened or closed.
273
+
274
+ ## Forms Integration
275
+
276
+ The multi-select tree implements `FormValueControl<Iterable<TValue>>`, so `[formField]` binds it to a signal form field, which then sets `disabled`, `readonly`, `required`, `invalid` and `touched`. With `required`, it's invalid while nothing is checked. It also works with `[(ngModel)]` and reactive forms; a `null` value means nothing is checked.
277
+
278
+ ## Accessibility
279
+
280
+ ### Keyboard
281
+
282
+ | Key | When | Action |
283
+ |-----------------------------------------------------------|--------|---------------------------------------------------------------------------------|
284
+ | `Enter`, `Space`, `ArrowDown`, `ArrowUp`, `Alt+ArrowDown` | Closed | Opens the popup |
285
+ | `ArrowDown` / `ArrowUp` | Open | Moves to the next or previous visible node |
286
+ | `ArrowRight` | Open | Opens a closed node, or moves to its first child (`ArrowLeft` in right-to-left) |
287
+ | `ArrowLeft` | Open | Closes an open node, or moves to its parent (`ArrowRight` in right-to-left) |
288
+ | `Home` / `End` | Open | Moves to the first or last visible node |
289
+ | `*` | Open | Opens the active node's siblings |
290
+ | Letters and digits | Open | Moves to the next node whose text starts with them |
291
+ | `Enter` / `Space` | Open | Checks or unchecks the active node |
292
+ | `Backspace` | Any | Unchecks the item of the last tag |
293
+ | `Escape`, `Alt+ArrowUp` | Open | Closes the popup |
294
+ | `Tab` | Open | Closes the popup and moves focus on |
295
+
296
+ In the filter box, `ArrowDown`, `ArrowUp` and `Enter` work as above, and the other keys edit the text.
297
+
298
+ ### Focus
299
+
300
+ Focus stays on the field while the popup is open; the active node is shown with a focus ring and announced through `aria-activedescendant`. With a filter box, focus moves into it when the popup opens, and returns to the field when the popup closes. Tags and their remove buttons aren't Tab stops: `Backspace` removes tags from the keyboard.
301
+
302
+ ### ARIA
303
+
304
+ - The field has `role="combobox"`, `aria-haspopup="tree"`, `aria-expanded`, and `aria-controls` pointing at the tree. It's named by `aria-label`, `aria-labelledby`, a form field's label or, failing those, the placeholder.
305
+ - The popup's tree has `role="tree"` and the field's name. Its nodes are `treeitem`s with `aria-checked` (`mixed` for a partly checked parent), `aria-level`, `aria-setsize`, `aria-posinset` and `aria-expanded` on nodes with children. A disabled node has `aria-disabled`.
306
+ - Each tag's remove button is named "Remove" and the item's text, and the summary tag's "Remove n more items".
307
+ - The filter box is a combobox too, named "Filter" and the field's name. How many items match is announced as the filter changes.
308
+
309
+ ## API
310
+
311
+ Everything below is imported from `@nanahoshi/mona-ui/multi-select-tree`, unless a table names another entry point. Each name links to its reference page, with every input, output, property and method.
312
+
313
+ | Name | Kind |
314
+ | --- | --- |
315
+ | [`MultiSelectTreeComponent`](api/multi-select-tree.md#multiselecttreecomponent) | Component |
316
+
317
+ From `@nanahoshi/mona-ui/dropdowns`:
318
+
319
+ | Name | Kind |
320
+ | --- | --- |
321
+ | [`DropdownFilterableDirective`](api/dropdowns.md#dropdownfilterabledirective) | Directive |
322
+ | [`DropdownGroupableDirective`](api/dropdowns.md#dropdowngroupabledirective) | Directive |
323
+ | [`DropdownVirtualScrollDirective`](api/dropdowns.md#dropdownvirtualscrolldirective) | Directive |
324
+ | [`DropdownDataHandlerDirective`](api/dropdowns.md#dropdowndatahandlerdirective) | Directive |
325
+ | [`DropdownFooterTemplateDirective`](api/dropdowns.md#dropdownfootertemplatedirective) | Directive |
326
+ | [`DropdownGroupHeaderTemplateDirective`](api/dropdowns.md#dropdowngroupheadertemplatedirective) | Directive |
327
+ | [`DropdownHeaderTemplateDirective`](api/dropdowns.md#dropdownheadertemplatedirective) | Directive |
328
+ | [`DropdownItemTemplateDirective`](api/dropdowns.md#dropdownitemtemplatedirective) | Directive |
329
+ | [`DropdownListPopupHandlerDirective`](api/dropdowns.md#dropdownlistpopuphandlerdirective) | Directive |
330
+ | [`DropdownNoDataTemplateDirective`](api/dropdowns.md#dropdownnodatatemplatedirective) | Directive |
331
+ | [`DropdownPrefixTemplateDirective`](api/dropdowns.md#dropdownprefixtemplatedirective) | Directive |
332
+ | [`DropdownSuffixTemplateDirective`](api/dropdowns.md#dropdownsuffixtemplatedirective) | Directive |
333
+ | [`DropdownListService`](api/dropdowns.md#dropdownlistservice) | Service |
334
+
335
+ ### Types
336
+
337
+ | Type | Kind |
338
+ | --- | --- |
339
+ | [`MULTI_SELECT_TREE_DEFAULT_MESSAGES`](api/multi-select-tree.md#multi-select-tree-default-messages) | Constant |
340
+
341
+ From `@nanahoshi/mona-ui/dropdowns`:
342
+
343
+ | Type | Kind | Description |
344
+ | --- | --- | --- |
345
+ | [`DropdownDataInputToken`](api/dropdowns.md#dropdowndatainputtoken) | Constant | **Deprecated.** Use `DROPDOWN_DATA_INPUT_TOKEN`. |
346
+ | [`DROPDOWNS_DEFAULT_MESSAGES`](api/dropdowns.md#dropdowns-default-messages) | Constant | |
347
+ | [`DropdownDataInput`](api/dropdowns.md#dropdowndatainput) | Interface | |
348
+ | [`DropdownSheetData`](api/dropdowns.md#dropdownsheetdata) | Interface | What a dropdown passes to the bottom sheet its popup opens as. |
349
+ | [`AdaptiveMode`](api/dropdowns.md#adaptivemode) | Type alias | How a dropdown's popup adapts to a small screen: `"auto"` opens it as a sheet along the bottom of the screen when the screen is narrower than 640 pixels, and `"none"` always opens it under the field. |
350
+ | [`DropdownFieldPredicateType`](api/dropdowns.md#dropdownfieldpredicatetype) | Type alias | |
351
+ | [`DropdownFieldSelectorType`](api/dropdowns.md#dropdownfieldselectortype) | Type alias | |
352
+
353
+ **Related types:** [`ChildrenSelector`](api/tree-view.md#childrenselector), [`DataStructure`](api/tree-view.md#datastructure), [`FilterableOptions`](api/common.md#filterableoptions), [`FilterChangeEvent`](api/common.md#filterchangeevent), [`GroupableOptions`](api/grid.md#groupableoptions), [`ListItem`](api/list.md#listitem), [`ListSizeInputType`](api/list.md#listsizeinputtype), [`ListSizeType`](api/list.md#listsizetype), [`MonaDropdownsMessages`](api/i18n.md#monadropdownsmessages), [`MonaMultiSelectTreeMessages`](api/i18n.md#monamultiselecttreemessages), [`PopupCloseEvent`](api/popup.md#popupcloseevent), [`PreventableEvent`](api/common.md#preventableevent), [`VirtualScrollOptions`](api/common.md#virtualscrolloptions)
@@ -459,6 +459,10 @@ With nothing highlighted, such as when the filter matches no option, Enter in th
459
459
  - It's left out while the filter leaves no enabled option, and with `autoClose` the popup closes after it as after any option.
460
460
  - It counts among the options, in the position screen readers announce. Its text is the multi-select's `selectAll` message.
461
461
 
462
+ ### On a phone
463
+
464
+ With `adaptiveMode="auto"`, on a screen narrower than 640 pixels, the popup opens as a bottom sheet with the field's name (or `adaptiveTitle`) and a close button, as described for the [dropdown list](dropdown-list.md#the-bottom-sheet). The popup stays open while options are chosen, so the sheet does too.
465
+
462
466
  ### `showClearButton` clears every selection
463
467
 
464
468
  `showClearButton` renders a single clear button that removes all selected items at once, not one at a time.
@@ -560,6 +564,8 @@ From `@nanahoshi/mona-ui/dropdowns`:
560
564
  | [`DropdownDataInputToken`](api/dropdowns.md#dropdowndatainputtoken) | Constant | **Deprecated.** Use `DROPDOWN_DATA_INPUT_TOKEN`. |
561
565
  | [`DROPDOWNS_DEFAULT_MESSAGES`](api/dropdowns.md#dropdowns-default-messages) | Constant | |
562
566
  | [`DropdownDataInput`](api/dropdowns.md#dropdowndatainput) | Interface | |
567
+ | [`DropdownSheetData`](api/dropdowns.md#dropdownsheetdata) | Interface | What a dropdown passes to the bottom sheet its popup opens as. |
568
+ | [`AdaptiveMode`](api/dropdowns.md#adaptivemode) | Type alias | How a dropdown's popup adapts to a small screen: `"auto"` opens it as a sheet along the bottom of the screen when the screen is narrower than 640 pixels, and `"none"` always opens it under the field. |
563
569
  | [`DropdownFieldPredicateType`](api/dropdowns.md#dropdownfieldpredicatetype) | Type alias | |
564
570
  | [`DropdownFieldSelectorType`](api/dropdowns.md#dropdownfieldselectortype) | Type alias | |
565
571
 
@@ -0,0 +1,4 @@
1
+ {
2
+ "module": "../fesm2022/nanahoshi-mona-ui-dropdown-tree.mjs",
3
+ "typings": "../types/nanahoshi-mona-ui-dropdown-tree.d.ts"
4
+ }
@@ -3,7 +3,7 @@ import * as i0 from "@angular/core";
3
3
  import { Component, DestroyRef, Directive, ElementRef, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, forwardRef, inject, input, linkedSignal, model, output, untracked, viewChild } from "@angular/core";
4
4
  import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
5
5
  import * as i1 from "@nanahoshi/mona-ui/dropdowns";
6
- import { DROPDOWN_DATA_INPUT_TOKEN, DROPDOWN_POPUP_INPUT_TOKEN, DropdownDataHandlerDirective, DropdownFooterTemplateDirective, DropdownGroupHeaderTemplateDirective, DropdownHeaderTemplateDirective, DropdownItemTemplateDirective, DropdownListPopupHandlerDirective, DropdownListService, DropdownLiveRegionDirective, DropdownNoDataTemplateDirective, DropdownPrefixTemplateDirective, DropdownService, dropdownPopupThemeVariants } from "@nanahoshi/mona-ui/dropdowns";
6
+ import { DROPDOWN_DATA_INPUT_TOKEN, DROPDOWN_POPUP_INPUT_TOKEN, DropdownDataHandlerDirective, DropdownFooterTemplateDirective, DropdownGroupHeaderTemplateDirective, DropdownHeaderTemplateDirective, DropdownItemTemplateDirective, DropdownListPopupHandlerDirective, DropdownListService, DropdownLiveRegionDirective, DropdownNoDataTemplateDirective, DropdownPrefixTemplateDirective, DropdownService, dropdownPopupThemeVariants, dropdownSheetSurfaceClasses } from "@nanahoshi/mona-ui/dropdowns";
7
7
  import { FIELD_ASSOCIATION_BOUNDARY, TYPEAHEAD_RESET_DELAY, createElementControlId, injectEffectiveDisabled, injectLabelAssociation, isTypeaheadKey, setupTypeahead, themeControlSurfaceClasses } from "@nanahoshi/mona-ui/internal";
8
8
  import { IndicatorIconComponent } from "@nanahoshi/mona-ui/internal/indicator-icon";
9
9
  import { ListComponent, ListFooterTemplateDirective, ListGroupHeaderTemplateDirective, ListHeaderTemplateDirective, ListItemTemplateDirective, ListNoDataTemplateDirective, ListService } from "@nanahoshi/mona-ui/internal/list";
@@ -187,8 +187,10 @@ var DropdownListComponent = class DropdownListComponent {
187
187
  size
188
188
  });
189
189
  const heightClass = this.popupHeight() ? "max-h-none" : "";
190
- return twMerge(variantClass, heightClass, userClass);
190
+ const sheetClass = this.sheet() ? dropdownSheetSurfaceClasses : "";
191
+ return twMerge(variantClass, heightClass, sheetClass, userClass);
191
192
  }, ...ngDevMode ? [{ debugName: "listPopupClass" }] : /* istanbul ignore next */ []);
193
+ this.listSize = computed(() => this.sheet() ? "large" : this.size(), ...ngDevMode ? [{ debugName: "listSize" }] : /* istanbul ignore next */ []);
192
194
  this.messages = this.#i18n.componentMessages("dropdownList", DROPDOWN_LIST_DEFAULT_MESSAGES);
193
195
  this.noDataTemplate = contentChild(DropdownNoDataTemplateDirective, {
194
196
  ...ngDevMode ? { debugName: "noDataTemplate" } : /* istanbul ignore next */ {},
@@ -210,6 +212,7 @@ var DropdownListComponent = class DropdownListComponent {
210
212
  this.selectedListItem = computed(() => {
211
213
  return this.#listService.selectedListItems().firstOrDefault();
212
214
  }, ...ngDevMode ? [{ debugName: "selectedListItem" }] : /* istanbul ignore next */ []);
215
+ this.sheet = this.#dropdownService.sheet.asReadonly();
213
216
  this.valueContainerClass = computed(() => {
214
217
  const hasTemplate = this.valueTemplate() != null;
215
218
  return dropdownListValueContainerThemeVariants({ hasTemplate });
@@ -223,6 +226,8 @@ var DropdownListComponent = class DropdownListComponent {
223
226
  if (!listItem) return "";
224
227
  return this.#listService.getItemText(listItem);
225
228
  }, ...ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []);
229
+ this.adaptiveMode = input("none", ...ngDevMode ? [{ debugName: "adaptiveMode" }] : /* istanbul ignore next */ []);
230
+ this.adaptiveTitle = input("", ...ngDevMode ? [{ debugName: "adaptiveTitle" }] : /* istanbul ignore next */ []);
226
231
  this.ariaDescribedBy = input("", {
227
232
  ...ngDevMode ? { debugName: "ariaDescribedBy" } : /* istanbul ignore next */ {},
228
233
  alias: "aria-describedby"
@@ -480,6 +485,20 @@ var DropdownListComponent = class DropdownListComponent {
480
485
  isStandalone: true,
481
486
  selector: "mona-dropdown-list",
482
487
  inputs: {
488
+ adaptiveMode: {
489
+ classPropertyName: "adaptiveMode",
490
+ publicName: "adaptiveMode",
491
+ isSignal: true,
492
+ isRequired: false,
493
+ transformFunction: null
494
+ },
495
+ adaptiveTitle: {
496
+ classPropertyName: "adaptiveTitle",
497
+ publicName: "adaptiveTitle",
498
+ isSignal: true,
499
+ isRequired: false,
500
+ transformFunction: null
501
+ },
483
502
  ariaDescribedBy: {
484
503
  classPropertyName: "ariaDescribedBy",
485
504
  publicName: "aria-describedby",
@@ -759,7 +778,7 @@ var DropdownListComponent = class DropdownListComponent {
759
778
  { directive: i1.DropdownLiveRegionDirective }
760
779
  ],
761
780
  ngImport: i0,
762
- template: "@if (prefixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"prefixTemplate()\"></ng-container>\n </span>\n}\n\n<span [class]=\"valueContainerClass()\">\n @if (!valueTemplate()) {\n <span>\n @if (selectedListItem()) {\n <span>{{ valueText() }}</span>\n } @else {\n <span>{{ placeholder() }}</span>\n }\n </span>\n } @else {\n <ng-container\n [ngTemplateOutlet]=\"valueTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: selectedDataItem() }\"></ng-container>\n }\n</span>\n\n@if (clearButtonVisible()) {\n <mona-indicator-icon\n preset=\"clear\"\n [interactive]=\"true\"\n [label]=\"messages().clear\"\n (activate)=\"onValueClear($event)\"></mona-indicator-icon>\n}\n\n@if (loading()) {\n <mona-indicator-icon preset=\"loading\" [size]=\"12\"></mona-indicator-icon>\n}\n\n<mona-indicator-icon preset=\"dropdown\" [size]=\"18\"></mona-indicator-icon>\n\n<ng-template #popupTemplate>\n <div [class]=\"listPopupClass()\" (pointerdown)=\"onPopupPointerDown($event)\">\n <mona-list [listId]=\"listId\" [focusOnMount]=\"false\" [size]=\"size()\" (itemSelect)=\"onItemSelect($event)\">\n @if (footerTemplate()) {\n <ng-template monaListFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (groupHeaderTemplate()) {\n <ng-template monaListGroupHeaderTemplate let-group>\n <ng-container\n [ngTemplateOutlet]=\"groupHeaderTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: group }\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n </mona-list>\n </div>\n</ng-template>\n",
781
+ template: "@if (prefixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"prefixTemplate()\"></ng-container>\n </span>\n}\n\n<span [class]=\"valueContainerClass()\">\n @if (!valueTemplate()) {\n <span>\n @if (selectedListItem()) {\n <span>{{ valueText() }}</span>\n } @else {\n <span>{{ placeholder() }}</span>\n }\n </span>\n } @else {\n <ng-container\n [ngTemplateOutlet]=\"valueTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: selectedDataItem() }\"></ng-container>\n }\n</span>\n\n@if (clearButtonVisible()) {\n <mona-indicator-icon\n preset=\"clear\"\n [interactive]=\"true\"\n [label]=\"messages().clear\"\n (activate)=\"onValueClear($event)\"></mona-indicator-icon>\n}\n\n@if (loading()) {\n <mona-indicator-icon preset=\"loading\" [size]=\"12\"></mona-indicator-icon>\n}\n\n<mona-indicator-icon preset=\"dropdown\" [size]=\"18\"></mona-indicator-icon>\n\n<ng-template #popupTemplate>\n <div [class]=\"listPopupClass()\" (pointerdown)=\"onPopupPointerDown($event)\">\n <mona-list [listId]=\"listId\" [focusOnMount]=\"false\" [size]=\"listSize()\" (itemSelect)=\"onItemSelect($event)\">\n @if (footerTemplate()) {\n <ng-template monaListFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (groupHeaderTemplate()) {\n <ng-template monaListGroupHeaderTemplate let-group>\n <ng-container\n [ngTemplateOutlet]=\"groupHeaderTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: group }\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n </mona-list>\n </div>\n</ng-template>\n",
763
782
  dependencies: [
764
783
  {
765
784
  kind: "directive",
@@ -901,7 +920,7 @@ i0.ɵɵngDeclareClassMetadata({
901
920
  "[class]": "baseClass()",
902
921
  "(focusout)": "onFocusOut($event)"
903
922
  },
904
- template: "@if (prefixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"prefixTemplate()\"></ng-container>\n </span>\n}\n\n<span [class]=\"valueContainerClass()\">\n @if (!valueTemplate()) {\n <span>\n @if (selectedListItem()) {\n <span>{{ valueText() }}</span>\n } @else {\n <span>{{ placeholder() }}</span>\n }\n </span>\n } @else {\n <ng-container\n [ngTemplateOutlet]=\"valueTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: selectedDataItem() }\"></ng-container>\n }\n</span>\n\n@if (clearButtonVisible()) {\n <mona-indicator-icon\n preset=\"clear\"\n [interactive]=\"true\"\n [label]=\"messages().clear\"\n (activate)=\"onValueClear($event)\"></mona-indicator-icon>\n}\n\n@if (loading()) {\n <mona-indicator-icon preset=\"loading\" [size]=\"12\"></mona-indicator-icon>\n}\n\n<mona-indicator-icon preset=\"dropdown\" [size]=\"18\"></mona-indicator-icon>\n\n<ng-template #popupTemplate>\n <div [class]=\"listPopupClass()\" (pointerdown)=\"onPopupPointerDown($event)\">\n <mona-list [listId]=\"listId\" [focusOnMount]=\"false\" [size]=\"size()\" (itemSelect)=\"onItemSelect($event)\">\n @if (footerTemplate()) {\n <ng-template monaListFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (groupHeaderTemplate()) {\n <ng-template monaListGroupHeaderTemplate let-group>\n <ng-container\n [ngTemplateOutlet]=\"groupHeaderTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: group }\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n </mona-list>\n </div>\n</ng-template>\n"
923
+ template: "@if (prefixTemplate()) {\n <span [class]=\"affixClass()\">\n <ng-container [ngTemplateOutlet]=\"prefixTemplate()\"></ng-container>\n </span>\n}\n\n<span [class]=\"valueContainerClass()\">\n @if (!valueTemplate()) {\n <span>\n @if (selectedListItem()) {\n <span>{{ valueText() }}</span>\n } @else {\n <span>{{ placeholder() }}</span>\n }\n </span>\n } @else {\n <ng-container\n [ngTemplateOutlet]=\"valueTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: selectedDataItem() }\"></ng-container>\n }\n</span>\n\n@if (clearButtonVisible()) {\n <mona-indicator-icon\n preset=\"clear\"\n [interactive]=\"true\"\n [label]=\"messages().clear\"\n (activate)=\"onValueClear($event)\"></mona-indicator-icon>\n}\n\n@if (loading()) {\n <mona-indicator-icon preset=\"loading\" [size]=\"12\"></mona-indicator-icon>\n}\n\n<mona-indicator-icon preset=\"dropdown\" [size]=\"18\"></mona-indicator-icon>\n\n<ng-template #popupTemplate>\n <div [class]=\"listPopupClass()\" (pointerdown)=\"onPopupPointerDown($event)\">\n <mona-list [listId]=\"listId\" [focusOnMount]=\"false\" [size]=\"listSize()\" (itemSelect)=\"onItemSelect($event)\">\n @if (footerTemplate()) {\n <ng-template monaListFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (groupHeaderTemplate()) {\n <ng-template monaListGroupHeaderTemplate let-group>\n <ng-container\n [ngTemplateOutlet]=\"groupHeaderTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: group }\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n </mona-list>\n </div>\n</ng-template>\n"
905
924
  }]
906
925
  }],
907
926
  ctorParameters: () => [],
@@ -959,6 +978,22 @@ i0.ɵɵngDeclareClassMetadata({
959
978
  isSignal: true
960
979
  }]
961
980
  }],
981
+ adaptiveMode: [{
982
+ type: i0.Input,
983
+ args: [{
984
+ isSignal: true,
985
+ alias: "adaptiveMode",
986
+ required: false
987
+ }]
988
+ }],
989
+ adaptiveTitle: [{
990
+ type: i0.Input,
991
+ args: [{
992
+ isSignal: true,
993
+ alias: "adaptiveTitle",
994
+ required: false
995
+ }]
996
+ }],
962
997
  ariaDescribedBy: [{
963
998
  type: i0.Input,
964
999
  args: [{
@@ -1168,6 +1203,6 @@ i0.ɵɵngDeclareClassMetadata({
1168
1203
  }]
1169
1204
  }
1170
1205
  });
1171
- export { DROPDOWN_LIST_DEFAULT_MESSAGES, DropdownListComponent, DropdownListValueTemplateDirective };
1206
+ export { DROPDOWN_LIST_DEFAULT_MESSAGES, DropdownListComponent, DropdownListValueTemplateDirective, dropdownListAffixContainerThemeVariants, dropdownListInputThemeVariants, dropdownListValueContainerThemeVariants };
1172
1207
 
1173
1208
  //# sourceMappingURL=nanahoshi-mona-ui-dropdown-list.mjs.map