@nanahoshi/mona-ui 0.24.6 → 0.24.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +14 -4
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +233 -231
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-CD_ODHpU.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-DdyHnUIr.mjs} +24 -12
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-B6gq7Hu3.mjs +208 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DdUY3I7P.mjs +1100 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-Sa1aAtJ-.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-DG8Bu4Dy.mjs} +34 -21
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BvUM9nPt.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CVqpbMcb.mjs} +2565 -928
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +79 -11
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +20 -4
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +335 -45
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +565 -197
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +28 -2
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +598 -208
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +193 -74
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +58 -11
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +62 -11
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +62 -11
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +69 -11
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +58 -11
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +62 -11
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +58 -11
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +58 -11
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +62 -11
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +78 -11
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +58 -11
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +58 -11
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +58 -11
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +367 -463
- package/fesm2022/nanahoshi-mona-ui-query.mjs +317 -122
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +205 -140
- package/i18n/catalogs/en-US.messages.json +64 -17
- package/locales/ar-sa/ar-sa.messages.json +58 -11
- package/locales/de-de/de-de.messages.json +58 -11
- package/locales/es-es/es-es.messages.json +58 -11
- package/locales/fr-fr/fr-fr.messages.json +58 -11
- package/locales/id-id/id-id.messages.json +58 -11
- package/locales/it-it/it-it.messages.json +58 -11
- package/locales/ja-jp/ja-jp.messages.json +58 -11
- package/locales/ko-kr/ko-kr.messages.json +58 -11
- package/locales/pt-br/pt-br.messages.json +58 -11
- package/locales/ru-ru/ru-ru.messages.json +58 -11
- package/locales/tr-tr/tr-tr.messages.json +58 -11
- package/locales/zh-cn/zh-cn.messages.json +58 -11
- package/locales/zh-tw/zh-tw.messages.json +58 -11
- package/package.json +1 -1
- package/types/nanahoshi-mona-ui-check-box.d.ts +11 -1
- package/types/nanahoshi-mona-ui-filter.d.ts +54 -32
- package/types/nanahoshi-mona-ui-grid.d.ts +359 -110
- package/types/nanahoshi-mona-ui-i18n.d.ts +97 -6
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +14 -2
- package/types/nanahoshi-mona-ui-internal-list.d.ts +89 -10
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +155 -40
- package/types/nanahoshi-mona-ui-internal.d.ts +10 -2
- package/types/nanahoshi-mona-ui-list-box.d.ts +148 -47
- package/types/nanahoshi-mona-ui-list-view.d.ts +111 -21
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +53 -6
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +53 -6
- package/types/nanahoshi-mona-ui-pager.d.ts +159 -76
- package/types/nanahoshi-mona-ui-query.d.ts +45 -14
- package/types/nanahoshi-mona-ui-tree-view.d.ts +84 -40
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-0jN7I1jo.mjs +0 -176
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BI_iE7pl.mjs +0 -946
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Directive, inject, DestroyRef, ElementRef, computed, contentChild, TemplateRef,
|
|
3
|
+
import { Directive, input, inject, DestroyRef, ElementRef, computed, contentChild, TemplateRef, output, booleanAttribute, effect, untracked, Component, model } from '@angular/core';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
-
import {
|
|
5
|
+
import { ImmutableList } from '@mirei/ts-collections';
|
|
6
|
+
import { MonaI18nService } from '@nanahoshi/mona-ui/i18n';
|
|
7
|
+
import { ListService, LIST_DEFAULT_MESSAGES, ListComponent, ListHeaderTemplateDirective, ListFooterTemplateDirective, ListGroupHeaderTemplateDirective, ListItemTemplateDirective, ListNoDataTemplateDirective, LIST_VIEW_HOST_LIST_SERVICE } from '@nanahoshi/mona-ui/internal/list';
|
|
6
8
|
import { PagerComponent } from '@nanahoshi/mona-ui/pager';
|
|
7
|
-
import {
|
|
8
|
-
import { fromEvent, filter } from 'rxjs';
|
|
9
|
+
import { Subject, fromEvent, filter } from 'rxjs';
|
|
9
10
|
import { twMerge } from 'tailwind-merge';
|
|
10
11
|
import { cva } from 'class-variance-authority';
|
|
11
12
|
|
|
@@ -20,6 +21,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
20
21
|
}]
|
|
21
22
|
}] });
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Template for the header of each group. The group's value is the template's implicit value (`let-group`); see
|
|
26
|
+
* `ListViewGroupHeaderTemplateContext`. The context isn't type-checked, so templates written against the value's own
|
|
27
|
+
* type keep compiling.
|
|
28
|
+
*/
|
|
23
29
|
class ListViewGroupHeaderTemplateDirective {
|
|
24
30
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewGroupHeaderTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
25
31
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListViewGroupHeaderTemplateDirective, isStandalone: true, selector: "ng-template[monaListViewGroupHeaderTemplate]", ngImport: i0 }); }
|
|
@@ -42,16 +48,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
42
48
|
}]
|
|
43
49
|
}] });
|
|
44
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Template for each item of a list view. The data item is the template's implicit value (`let-item`). Bind the list
|
|
53
|
+
* view's items to `monaListViewItemTemplateOf` to type it; without it, the item is `any` in templates.
|
|
54
|
+
*/
|
|
55
|
+
// `any` by default: a template without `monaListViewItemTemplateOf` keeps an untyped item, as before the guard existed.
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
57
|
class ListViewItemTemplateDirective {
|
|
58
|
+
constructor() {
|
|
59
|
+
/**
|
|
60
|
+
* @description The list view's items, used only to type the template's item. Optional.
|
|
61
|
+
* @default null
|
|
62
|
+
*/
|
|
63
|
+
this.monaListViewItemTemplateOf = input(null, /* @ts-ignore */
|
|
64
|
+
...(ngDevMode ? [{ debugName: "monaListViewItemTemplateOf" }] : /* istanbul ignore next */ []));
|
|
65
|
+
}
|
|
66
|
+
static ngTemplateContextGuard(_directive, _context) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
46
69
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewItemTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
47
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "
|
|
70
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ListViewItemTemplateDirective, isStandalone: true, selector: "ng-template[monaListViewItemTemplate]", inputs: { monaListViewItemTemplateOf: { classPropertyName: "monaListViewItemTemplateOf", publicName: "monaListViewItemTemplateOf", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
48
71
|
}
|
|
49
72
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewItemTemplateDirective, decorators: [{
|
|
50
73
|
type: Directive,
|
|
51
74
|
args: [{
|
|
52
75
|
selector: "ng-template[monaListViewItemTemplate]"
|
|
53
76
|
}]
|
|
54
|
-
}] });
|
|
77
|
+
}], propDecorators: { monaListViewItemTemplateOf: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaListViewItemTemplateOf", required: false }] }] } });
|
|
55
78
|
|
|
56
79
|
class ListViewNoDataTemplateDirective {
|
|
57
80
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewNoDataTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
@@ -85,20 +108,16 @@ const listViewBaseThemeVariants = cva(`
|
|
|
85
108
|
}
|
|
86
109
|
});
|
|
87
110
|
|
|
111
|
+
/** How close to the end (in pixels) counts as scrolled to the bottom. */
|
|
112
|
+
const SCROLL_BOTTOM_THRESHOLD = 3;
|
|
88
113
|
class ListViewComponent {
|
|
89
114
|
#destroyRef;
|
|
90
115
|
#hostElementRef;
|
|
91
|
-
#
|
|
92
|
-
#scrollSubscription;
|
|
116
|
+
#atBottom;
|
|
93
117
|
constructor() {
|
|
94
118
|
this.#destroyRef = inject(DestroyRef);
|
|
95
|
-
this.#hostElementRef = inject(
|
|
96
|
-
this.#
|
|
97
|
-
const pageableOptions = this.listService.pageableOptions();
|
|
98
|
-
return !pageableOptions.enabled;
|
|
99
|
-
}, /* @ts-ignore */
|
|
100
|
-
...(ngDevMode ? [{ debugName: "#scrollBottomEnabled" }] : /* istanbul ignore next */ []));
|
|
101
|
-
this.#scrollSubscription = null;
|
|
119
|
+
this.#hostElementRef = inject(ElementRef);
|
|
120
|
+
this.#atBottom = false;
|
|
102
121
|
this.baseClasses = computed(() => {
|
|
103
122
|
const rounded = this.rounded();
|
|
104
123
|
const size = this.size();
|
|
@@ -110,7 +129,7 @@ class ListViewComponent {
|
|
|
110
129
|
this.footerTemplate = contentChild(ListViewFooterTemplateDirective, { ...(ngDevMode ? { debugName: "footerTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
111
130
|
this.groupHeaderTemplate = contentChild(ListViewGroupHeaderTemplateDirective, { ...(ngDevMode ? { debugName: "groupHeaderTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
112
131
|
this.headerTemplate = contentChild(ListViewHeaderTemplateDirective, { ...(ngDevMode ? { debugName: "headerTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
113
|
-
this.itemCount = computed(() => this.listItems().
|
|
132
|
+
this.itemCount = computed(() => this.listItems().length, /* @ts-ignore */
|
|
114
133
|
...(ngDevMode ? [{ debugName: "itemCount" }] : /* istanbul ignore next */ []));
|
|
115
134
|
this.itemTemplate = contentChild(ListViewItemTemplateDirective, { ...(ngDevMode ? { debugName: "itemTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
116
135
|
this.listHeight = computed(() => {
|
|
@@ -118,10 +137,8 @@ class ListViewComponent {
|
|
|
118
137
|
return typeof height === "number" ? `${height}px` : height;
|
|
119
138
|
}, /* @ts-ignore */
|
|
120
139
|
...(ngDevMode ? [{ debugName: "listHeight" }] : /* istanbul ignore next */ []));
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return ImmutableSet.create(items);
|
|
124
|
-
}, /* @ts-ignore */
|
|
140
|
+
/** The items as given: a list, so equal items (two `"a"` strings) are both shown. */
|
|
141
|
+
this.listItems = computed(() => ImmutableList.create(this.items()), /* @ts-ignore */
|
|
125
142
|
...(ngDevMode ? [{ debugName: "listItems" }] : /* istanbul ignore next */ []));
|
|
126
143
|
this.listMaxHeight = computed(() => {
|
|
127
144
|
const maxHeight = this.maxHeight();
|
|
@@ -133,26 +150,66 @@ class ListViewComponent {
|
|
|
133
150
|
return typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
134
151
|
}, /* @ts-ignore */
|
|
135
152
|
...(ngDevMode ? [{ debugName: "listMaxWidth" }] : /* istanbul ignore next */ []));
|
|
153
|
+
/**
|
|
154
|
+
* A list you can select from is a `listbox`; one that only shows items is a `list`.
|
|
155
|
+
*/
|
|
156
|
+
this.listRole = computed(() => this.listService.selectableOptions().enabled ? "listbox" : "list", /* @ts-ignore */
|
|
157
|
+
...(ngDevMode ? [{ debugName: "listRole" }] : /* istanbul ignore next */ []));
|
|
136
158
|
this.listService = inject(ListService);
|
|
137
159
|
this.listWidth = computed(() => {
|
|
138
160
|
const width = this.width();
|
|
139
161
|
return typeof width === "number" ? `${width}px` : width;
|
|
140
162
|
}, /* @ts-ignore */
|
|
141
163
|
...(ngDevMode ? [{ debugName: "listWidth" }] : /* istanbul ignore next */ []));
|
|
164
|
+
this.messages = inject(MonaI18nService).componentMessages("list", LIST_DEFAULT_MESSAGES);
|
|
142
165
|
this.noDataTemplate = contentChild(ListViewNoDataTemplateDirective, { ...(ngDevMode ? { debugName: "noDataTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
143
|
-
|
|
144
|
-
|
|
166
|
+
/** The pager's name: the given one, else one built from the list's name, else the pager's own default. */
|
|
167
|
+
this.pagerLabel = computed(() => {
|
|
168
|
+
const pagerAriaLabel = this.pagerAriaLabel();
|
|
169
|
+
if (pagerAriaLabel) {
|
|
170
|
+
return pagerAriaLabel;
|
|
171
|
+
}
|
|
172
|
+
const ariaLabel = this.ariaLabel();
|
|
173
|
+
return ariaLabel ? this.messages().pagerLabel(ariaLabel) : null;
|
|
174
|
+
}, /* @ts-ignore */
|
|
175
|
+
...(ngDevMode ? [{ debugName: "pagerLabel" }] : /* istanbul ignore next */ []));
|
|
176
|
+
/** Polite status text: loading, or the empty state. */
|
|
177
|
+
this.statusText = computed(() => {
|
|
178
|
+
if (this.loading()) {
|
|
179
|
+
return this.messages().loading;
|
|
180
|
+
}
|
|
181
|
+
return this.itemCount() === 0 ? this.messages().noData : "";
|
|
182
|
+
}, /* @ts-ignore */
|
|
183
|
+
...(ngDevMode ? [{ debugName: "statusText" }] : /* istanbul ignore next */ []));
|
|
145
184
|
/**
|
|
146
185
|
* @description Accessible name for the list view's `listbox` element. Describe what the list represents.
|
|
147
186
|
* @default ""
|
|
148
187
|
*/
|
|
149
188
|
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
150
189
|
/**
|
|
151
|
-
* @description
|
|
190
|
+
* @description Id of the element that names the list view's list, as an alternative to `aria-label`.
|
|
191
|
+
* @default ""
|
|
192
|
+
*/
|
|
193
|
+
this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
194
|
+
/**
|
|
195
|
+
* @description Property name or predicate that marks an item as disabled. Disabled items can't be selected,
|
|
196
|
+
* activated or reached by typeahead.
|
|
197
|
+
* @default ""
|
|
198
|
+
*/
|
|
199
|
+
this.disabledBy = input("", /* @ts-ignore */
|
|
200
|
+
...(ngDevMode ? [{ debugName: "disabledBy" }] : /* istanbul ignore next */ []));
|
|
201
|
+
/**
|
|
202
|
+
* @description Sets the height of the list view. With virtual scrolling, the viewport takes this height, so a
|
|
203
|
+
* percentage needs a parent with a height; `""` sizes the viewport to its items instead.
|
|
152
204
|
* @default 100%
|
|
153
205
|
*/
|
|
154
206
|
this.height = input("100%", /* @ts-ignore */
|
|
155
207
|
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
208
|
+
/**
|
|
209
|
+
* @description Emitted with the data item when the user activates an enabled item by clicking it or pressing
|
|
210
|
+
* Enter on it. Fires whether or not the list view is selectable.
|
|
211
|
+
*/
|
|
212
|
+
this.itemActivate = output();
|
|
156
213
|
/**
|
|
157
214
|
* @description Collection of items to render.
|
|
158
215
|
* @default []
|
|
@@ -183,6 +240,11 @@ class ListViewComponent {
|
|
|
183
240
|
*/
|
|
184
241
|
this.listStyle = input({}, /* @ts-ignore */
|
|
185
242
|
...(ngDevMode ? [{ debugName: "listStyle" }] : /* istanbul ignore next */ []));
|
|
243
|
+
/**
|
|
244
|
+
* @description Marks the list as loading: it gets `aria-busy` and a polite "Loading" status.
|
|
245
|
+
* @default false
|
|
246
|
+
*/
|
|
247
|
+
this.loading = input(false, { ...(ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
186
248
|
/**
|
|
187
249
|
* @description Sets the maximum height of the list.
|
|
188
250
|
* @default ""
|
|
@@ -195,6 +257,18 @@ class ListViewComponent {
|
|
|
195
257
|
*/
|
|
196
258
|
this.maxWidth = input("", /* @ts-ignore */
|
|
197
259
|
...(ngDevMode ? [{ debugName: "maxWidth" }] : /* istanbul ignore next */ []));
|
|
260
|
+
/**
|
|
261
|
+
* Page-size picks from the pager, forwarded to `ListViewPageableDirective`.
|
|
262
|
+
* @internal
|
|
263
|
+
*/
|
|
264
|
+
this.pageSizeSelect$ = new Subject();
|
|
265
|
+
/**
|
|
266
|
+
* @description Accessible name of the pager. Defaults to "{name} pagination" from the list view's `aria-label`,
|
|
267
|
+
* so two paged list views on a page have different landmarks.
|
|
268
|
+
* @default ""
|
|
269
|
+
*/
|
|
270
|
+
this.pagerAriaLabel = input("", /* @ts-ignore */
|
|
271
|
+
...(ngDevMode ? [{ debugName: "pagerAriaLabel" }] : /* istanbul ignore next */ []));
|
|
198
272
|
/**
|
|
199
273
|
* @description Border-radius preset applied to the component.
|
|
200
274
|
* @default medium
|
|
@@ -202,7 +276,8 @@ class ListViewComponent {
|
|
|
202
276
|
this.rounded = input("medium", /* @ts-ignore */
|
|
203
277
|
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
204
278
|
/**
|
|
205
|
-
* @description Emitted
|
|
279
|
+
* @description Emitted once each time the list is scrolled to its end, when the list view isn't paged. Scrolling
|
|
280
|
+
* away and back emits again, as does reaching the new end after more items are added.
|
|
206
281
|
*/
|
|
207
282
|
this.scrollBottom = output();
|
|
208
283
|
/**
|
|
@@ -228,63 +303,68 @@ class ListViewComponent {
|
|
|
228
303
|
*/
|
|
229
304
|
this.width = input("100%", /* @ts-ignore */
|
|
230
305
|
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
306
|
+
// Arrow keys, Home/End and typeahead work without the navigable directive, which can still change or turn
|
|
307
|
+
// them off. Without them only one item could be reached from the keyboard.
|
|
308
|
+
this.listService.setNavigableOptions({ enabled: true, mode: "select", wrap: false });
|
|
231
309
|
effect(() => {
|
|
232
310
|
const textField = this.textField();
|
|
233
311
|
untracked(() => this.listService.setTextField(textField ?? ""));
|
|
234
312
|
});
|
|
235
|
-
|
|
236
|
-
|
|
313
|
+
effect(() => {
|
|
314
|
+
const disabledBy = this.disabledBy();
|
|
315
|
+
untracked(() => this.listService.setDisabledBy(disabledBy ?? ""));
|
|
237
316
|
});
|
|
317
|
+
this.setScrollBottomEvent();
|
|
318
|
+
}
|
|
319
|
+
onItemActivate(item) {
|
|
320
|
+
this.itemActivate.emit(item.data);
|
|
238
321
|
}
|
|
239
322
|
onPageChange(event) {
|
|
240
|
-
this.listService.pageState.update(s => ({ ...s, page: event.page, skip: event.skip }));
|
|
323
|
+
this.listService.pageState.update(s => ({ ...s, page: event.page, skip: event.skip, take: event.take }));
|
|
241
324
|
}
|
|
242
|
-
|
|
243
|
-
this.
|
|
325
|
+
onPageSizeSelect(event) {
|
|
326
|
+
this.pageSizeSelect$.next(event);
|
|
244
327
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
element = this.#hostElementRef.nativeElement.querySelector("mona-list > ul");
|
|
253
|
-
}
|
|
254
|
-
this.#scrollSubscription?.unsubscribe();
|
|
255
|
-
if (!element) {
|
|
256
|
-
return;
|
|
328
|
+
/** Whether the scrolled element is this list view's own list or viewport, not a nested list view or template. */
|
|
329
|
+
isListScroll(target) {
|
|
330
|
+
if (!(target instanceof HTMLElement) ||
|
|
331
|
+
target.closest("mona-list-view") !== this.#hostElementRef.nativeElement) {
|
|
332
|
+
return false;
|
|
257
333
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
334
|
+
return target.matches("cdk-virtual-scroll-viewport") || target.matches("mona-list > ul");
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Scroll events don't bubble, so the host listens in the capture phase. That covers the list and the virtual
|
|
338
|
+
* viewport whenever they are rendered, including ones created after the first render.
|
|
339
|
+
*/
|
|
340
|
+
setScrollBottomEvent() {
|
|
341
|
+
const host = this.#hostElementRef.nativeElement;
|
|
342
|
+
fromEvent(host, "scroll", { capture: true })
|
|
343
|
+
.pipe(takeUntilDestroyed(this.#destroyRef), filter(event => this.isListScroll(event.target)), filter(event => {
|
|
263
344
|
const target = event.target;
|
|
264
|
-
|
|
345
|
+
const atBottom = target.scrollHeight - target.scrollTop - target.clientHeight < SCROLL_BOTTOM_THRESHOLD;
|
|
346
|
+
const arrived = atBottom && !this.#atBottom;
|
|
347
|
+
this.#atBottom = atBottom;
|
|
348
|
+
return arrived && !this.listService.pageableOptions().enabled;
|
|
265
349
|
}))
|
|
266
350
|
.subscribe(event => this.scrollBottom.emit(event));
|
|
267
351
|
}
|
|
268
352
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
269
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: ListViewComponent, isStandalone: true, selector: "mona-list-view", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, listClass: { classPropertyName: "listClass", publicName: "listClass", isSignal: true, isRequired: false, transformFunction: null }, listItemClass: { classPropertyName: "listItemClass", publicName: "listItemClass", isSignal: true, isRequired: false, transformFunction: null }, listItemStyle: { classPropertyName: "listItemStyle", publicName: "listItemStyle", isSignal: true, isRequired: false, transformFunction: null }, listStyle: { classPropertyName: "listStyle", publicName: "listStyle", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, textField: { classPropertyName: "textField", publicName: "textField", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { scrollBottom: "scrollBottom" }, host: { properties: { "class": "baseClasses()", "attr.tabindex": "-1" } }, providers: [
|
|
353
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: ListViewComponent, isStandalone: true, selector: "mona-list-view", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, disabledBy: { classPropertyName: "disabledBy", publicName: "disabledBy", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, listClass: { classPropertyName: "listClass", publicName: "listClass", isSignal: true, isRequired: false, transformFunction: null }, listItemClass: { classPropertyName: "listItemClass", publicName: "listItemClass", isSignal: true, isRequired: false, transformFunction: null }, listItemStyle: { classPropertyName: "listItemStyle", publicName: "listItemStyle", isSignal: true, isRequired: false, transformFunction: null }, listStyle: { classPropertyName: "listStyle", publicName: "listStyle", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, pagerAriaLabel: { classPropertyName: "pagerAriaLabel", publicName: "pagerAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, textField: { classPropertyName: "textField", publicName: "textField", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemActivate: "itemActivate", scrollBottom: "scrollBottom" }, host: { properties: { "class": "baseClasses()", "attr.tabindex": "-1", "attr.aria-label": "null", "attr.aria-labelledby": "null" } }, providers: [
|
|
270
354
|
{
|
|
355
|
+
// Each list view has its own service, unless the component whose template it is in shares one on purpose.
|
|
271
356
|
provide: ListService,
|
|
272
|
-
useFactory: (
|
|
273
|
-
return parentListService ?? new ListService();
|
|
274
|
-
},
|
|
275
|
-
deps: [[new Optional(), new SkipSelf(), ListService]]
|
|
357
|
+
useFactory: () => inject(LIST_VIEW_HOST_LIST_SERVICE, { optional: true, skipSelf: true }) ?? new ListService()
|
|
276
358
|
}
|
|
277
|
-
], queries: [{ propertyName: "footerTemplate", first: true, predicate: ListViewFooterTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ListViewGroupHeaderTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "headerTemplate", first: true, predicate: ListViewHeaderTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "itemTemplate", first: true, predicate: ListViewItemTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "noDataTemplate", first: true, predicate: ListViewNoDataTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "<mona-list\n [ariaLabel]=\"ariaLabel()\"\n [data]=\"
|
|
359
|
+
], queries: [{ propertyName: "footerTemplate", first: true, predicate: ListViewFooterTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ListViewGroupHeaderTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "headerTemplate", first: true, predicate: ListViewHeaderTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "itemTemplate", first: true, predicate: ListViewItemTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "noDataTemplate", first: true, predicate: ListViewNoDataTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "<mona-list\n [ariaLabel]=\"ariaLabel()\"\n [ariaLabelledBy]=\"ariaLabelledBy()\"\n [busy]=\"loading()\"\n [listRole]=\"listRole()\"\n [data]=\"listItems()\"\n [height]=\"listHeight()\"\n [focusOnMount]=\"false\"\n [width]=\"listWidth()\"\n [maxHeight]=\"listMaxHeight()\"\n [maxWidth]=\"listMaxWidth()\"\n [listItemClass]=\"listItemClass()\"\n [listItemStyle]=\"listItemStyle()\"\n [listClass]=\"listClass()\"\n [listStyle]=\"listStyle()\"\n (itemActivate)=\"onItemActivate($event)\">\n @if (footerTemplate()) {\n <ng-template monaListFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate() ?? null\"></ng-container>\n </ng-template>\n }\n @if (groupHeaderTemplate()) {\n <ng-template monaListGroupHeaderTemplate let-groupHeader>\n <ng-container\n [ngTemplateOutlet]=\"groupHeaderTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: groupHeader }\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate() ?? null\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate() ?? null\"></ng-container>\n </ng-template>\n }\n</mona-list>\n\n@let pageableOptions = listService.pageableOptions();\n@if (pageableOptions.enabled && !listService.virtualScrollOptions().enabled && itemCount() > 0) {\n @let pageState = listService.pageState();\n <mona-pager\n [firstLast]=\"pageableOptions.firstLast\"\n [pageSizeValues]=\"pageableOptions.pageSizeValues\"\n [visiblePages]=\"pageableOptions.visiblePages\"\n [total]=\"itemCount()\"\n [skip]=\"pageState.skip\"\n [responsive]=\"false\"\n [rounded]=\"rounded()\"\n [pageSize]=\"pageState.take\"\n [previousNext]=\"pageableOptions.previousNext\"\n [showInfo]=\"pageableOptions.showInfo\"\n [type]=\"pageableOptions.type\"\n [size]=\"size()\"\n [aria-label]=\"pagerLabel()\"\n (pageChange)=\"onPageChange($event)\"\n (pageSizeSelect)=\"onPageSizeSelect($event)\"\n class=\"border-b-0 border-x-0 rounded-t-none\"></mona-pager>\n}\n<div role=\"status\" class=\"sr-only\">{{ statusText() }}</div>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: PagerComponent, selector: "mona-pager", inputs: ["aria-label", "aria-labelledby", "firstLast", "navigable", "pageInput", "pageSize", "pageSizeValues", "previousNext", "responsive", "rounded", "showInfo", "size", "skip", "total", "type", "class", "visiblePages"], outputs: ["pageChange", "pageSizeChange", "pageSizeSelect", "skipChange"] }, { kind: "component", type: ListComponent, selector: "mona-list", inputs: ["ariaLabel", "ariaLabelledBy", "busy", "data", "focusOnMount", "height", "listClass", "listId", "listItemClass", "listItemStyle", "listRole", "listStyle", "maxHeight", "maxWidth", "size", "textField", "width"], outputs: ["itemActivate", "itemSelect"] }, { kind: "directive", type: ListHeaderTemplateDirective, selector: "ng-template[monaListHeaderTemplate]" }, { kind: "directive", type: ListFooterTemplateDirective, selector: "ng-template[monaListFooterTemplate]" }, { kind: "directive", type: ListGroupHeaderTemplateDirective, selector: "ng-template[monaListGroupHeaderTemplate]" }, { kind: "directive", type: ListItemTemplateDirective, selector: "ng-template[monaListItemTemplate]" }, { kind: "directive", type: ListNoDataTemplateDirective, selector: "ng-template[monaListNoDataTemplate]" }] }); }
|
|
278
360
|
}
|
|
279
361
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewComponent, decorators: [{
|
|
280
362
|
type: Component,
|
|
281
363
|
args: [{ selector: "mona-list-view", providers: [
|
|
282
364
|
{
|
|
365
|
+
// Each list view has its own service, unless the component whose template it is in shares one on purpose.
|
|
283
366
|
provide: ListService,
|
|
284
|
-
useFactory: (
|
|
285
|
-
return parentListService ?? new ListService();
|
|
286
|
-
},
|
|
287
|
-
deps: [[new Optional(), new SkipSelf(), ListService]]
|
|
367
|
+
useFactory: () => inject(LIST_VIEW_HOST_LIST_SERVICE, { optional: true, skipSelf: true }) ?? new ListService()
|
|
288
368
|
}
|
|
289
369
|
], imports: [
|
|
290
370
|
NgTemplateOutlet,
|
|
@@ -297,9 +377,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
297
377
|
ListNoDataTemplateDirective
|
|
298
378
|
], host: {
|
|
299
379
|
"[class]": "baseClasses()",
|
|
300
|
-
"[attr.tabindex]": "-1"
|
|
301
|
-
|
|
302
|
-
|
|
380
|
+
"[attr.tabindex]": "-1",
|
|
381
|
+
// The name belongs to the list inside; the host has no role to carry it.
|
|
382
|
+
"[attr.aria-label]": "null",
|
|
383
|
+
"[attr.aria-labelledby]": "null"
|
|
384
|
+
}, template: "<mona-list\n [ariaLabel]=\"ariaLabel()\"\n [ariaLabelledBy]=\"ariaLabelledBy()\"\n [busy]=\"loading()\"\n [listRole]=\"listRole()\"\n [data]=\"listItems()\"\n [height]=\"listHeight()\"\n [focusOnMount]=\"false\"\n [width]=\"listWidth()\"\n [maxHeight]=\"listMaxHeight()\"\n [maxWidth]=\"listMaxWidth()\"\n [listItemClass]=\"listItemClass()\"\n [listItemStyle]=\"listItemStyle()\"\n [listClass]=\"listClass()\"\n [listStyle]=\"listStyle()\"\n (itemActivate)=\"onItemActivate($event)\">\n @if (footerTemplate()) {\n <ng-template monaListFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate() ?? null\"></ng-container>\n </ng-template>\n }\n @if (groupHeaderTemplate()) {\n <ng-template monaListGroupHeaderTemplate let-groupHeader>\n <ng-container\n [ngTemplateOutlet]=\"groupHeaderTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: groupHeader }\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate() ?? null\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate() ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate() ?? null\"></ng-container>\n </ng-template>\n }\n</mona-list>\n\n@let pageableOptions = listService.pageableOptions();\n@if (pageableOptions.enabled && !listService.virtualScrollOptions().enabled && itemCount() > 0) {\n @let pageState = listService.pageState();\n <mona-pager\n [firstLast]=\"pageableOptions.firstLast\"\n [pageSizeValues]=\"pageableOptions.pageSizeValues\"\n [visiblePages]=\"pageableOptions.visiblePages\"\n [total]=\"itemCount()\"\n [skip]=\"pageState.skip\"\n [responsive]=\"false\"\n [rounded]=\"rounded()\"\n [pageSize]=\"pageState.take\"\n [previousNext]=\"pageableOptions.previousNext\"\n [showInfo]=\"pageableOptions.showInfo\"\n [type]=\"pageableOptions.type\"\n [size]=\"size()\"\n [aria-label]=\"pagerLabel()\"\n (pageChange)=\"onPageChange($event)\"\n (pageSizeSelect)=\"onPageSizeSelect($event)\"\n class=\"border-b-0 border-x-0 rounded-t-none\"></mona-pager>\n}\n<div role=\"status\" class=\"sr-only\">{{ statusText() }}</div>\n" }]
|
|
385
|
+
}], ctorParameters: () => [], propDecorators: { footerTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListViewFooterTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], groupHeaderTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListViewGroupHeaderTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], headerTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListViewHeaderTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], itemTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListViewItemTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], noDataTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListViewNoDataTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], disabledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledBy", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], itemActivate: [{ type: i0.Output, args: ["itemActivate"] }], items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], listClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "listClass", required: false }] }], listItemClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "listItemClass", required: false }] }], listItemStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "listItemStyle", required: false }] }], listStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "listStyle", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], pagerAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "pagerAriaLabel", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], scrollBottom: [{ type: i0.Output, args: ["scrollBottom"] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], textField: [{ type: i0.Input, args: [{ isSignal: true, alias: "textField", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }] } });
|
|
303
386
|
|
|
304
387
|
class ListViewGroupableDirective {
|
|
305
388
|
#defaultOptions;
|
|
@@ -402,12 +485,33 @@ class ListViewPageableDirective {
|
|
|
402
485
|
*/
|
|
403
486
|
this.page = model(1, /* @ts-ignore */
|
|
404
487
|
...(ngDevMode ? [{ debugName: "page" }] : /* istanbul ignore next */ []));
|
|
488
|
+
/**
|
|
489
|
+
* @description Items per page. Supports two-way binding via `[(pageSize)]`: it updates when the user picks a size
|
|
490
|
+
* in the pager. While unset, the options' `pageSize` applies. A new size keeps the first item of the current
|
|
491
|
+
* page in view.
|
|
492
|
+
* @default undefined
|
|
493
|
+
*/
|
|
494
|
+
this.pageSize = model(undefined, /* @ts-ignore */
|
|
495
|
+
...(ngDevMode ? [{ debugName: "pageSize" }] : /* istanbul ignore next */ []));
|
|
496
|
+
/**
|
|
497
|
+
* @description Emitted when the user picks a page size, before it is applied. Call `preventDefault()` on the
|
|
498
|
+
* event to keep the current size.
|
|
499
|
+
*/
|
|
500
|
+
this.pageSizeSelect = output();
|
|
405
501
|
effect(() => {
|
|
406
502
|
const options = this.options();
|
|
407
503
|
untracked(() => {
|
|
408
504
|
const mergedOptions = options === "" ? this.#defaultOptions : { ...this.#defaultOptions, ...options };
|
|
409
505
|
this.#listService.setPageableOptions(mergedOptions);
|
|
410
|
-
this
|
|
506
|
+
this.setTake(this.pageSize() ?? mergedOptions.pageSize);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
effect(() => {
|
|
510
|
+
const pageSize = this.pageSize();
|
|
511
|
+
untracked(() => {
|
|
512
|
+
if (pageSize != null) {
|
|
513
|
+
this.setTake(pageSize);
|
|
514
|
+
}
|
|
411
515
|
});
|
|
412
516
|
});
|
|
413
517
|
effect(() => {
|
|
@@ -426,22 +530,42 @@ class ListViewPageableDirective {
|
|
|
426
530
|
if (this.page() !== pageState.page) {
|
|
427
531
|
this.page.set(pageState.page);
|
|
428
532
|
}
|
|
533
|
+
// Report sizes the user picked; an unset size stays unset while the options' size applies.
|
|
534
|
+
const pageSize = this.pageSize();
|
|
535
|
+
const optionsSize = this.#listService.pageableOptions().pageSize;
|
|
536
|
+
if (pageSize !== pageState.take && (pageSize != null || pageState.take !== optionsSize)) {
|
|
537
|
+
this.pageSize.set(pageState.take);
|
|
538
|
+
}
|
|
429
539
|
});
|
|
430
540
|
});
|
|
541
|
+
inject(ListViewComponent)
|
|
542
|
+
.pageSizeSelect$.pipe(takeUntilDestroyed(inject(DestroyRef)))
|
|
543
|
+
.subscribe(event => {
|
|
544
|
+
this.pageSizeSelect.emit(event);
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
/** Applies a page size, keeping the first item of the current page in view. */
|
|
548
|
+
setTake(take) {
|
|
549
|
+
const size = Math.max(1, Math.floor(take) || 1);
|
|
550
|
+
const pageState = this.#listService.pageState();
|
|
551
|
+
if (pageState.take === size) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
const page = Math.floor(pageState.skip / size) + 1;
|
|
555
|
+
this.#listService.pageState.set({ page, skip: (page - 1) * size, take: size });
|
|
431
556
|
}
|
|
432
557
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewPageableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
433
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ListViewPageableDirective, isStandalone: true, selector: "mona-list-view[monaListViewPageable]", inputs: { options: { classPropertyName: "options", publicName: "monaListViewPageable", isSignal: true, isRequired: false, transformFunction: null }, page: { classPropertyName: "page", publicName: "page", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { page: "pageChange" }, ngImport: i0 }); }
|
|
558
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ListViewPageableDirective, isStandalone: true, selector: "mona-list-view[monaListViewPageable]", inputs: { options: { classPropertyName: "options", publicName: "monaListViewPageable", isSignal: true, isRequired: false, transformFunction: null }, page: { classPropertyName: "page", publicName: "page", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { page: "pageChange", pageSize: "pageSizeChange", pageSizeSelect: "pageSizeSelect" }, ngImport: i0 }); }
|
|
434
559
|
}
|
|
435
560
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewPageableDirective, decorators: [{
|
|
436
561
|
type: Directive,
|
|
437
562
|
args: [{
|
|
438
563
|
selector: "mona-list-view[monaListViewPageable]"
|
|
439
564
|
}]
|
|
440
|
-
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaListViewPageable", required: false }] }], page: [{ type: i0.Input, args: [{ isSignal: true, alias: "page", required: false }] }, { type: i0.Output, args: ["pageChange"] }] } });
|
|
565
|
+
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaListViewPageable", required: false }] }], page: [{ type: i0.Input, args: [{ isSignal: true, alias: "page", required: false }] }, { type: i0.Output, args: ["pageChange"] }], pageSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageSize", required: false }] }, { type: i0.Output, args: ["pageSizeChange"] }], pageSizeSelect: [{ type: i0.Output, args: ["pageSizeSelect"] }] } });
|
|
441
566
|
|
|
442
567
|
class ListViewSelectableDirective {
|
|
443
568
|
#defaultOptions;
|
|
444
|
-
#destroyRef;
|
|
445
569
|
#listService;
|
|
446
570
|
constructor() {
|
|
447
571
|
this.#defaultOptions = {
|
|
@@ -449,14 +573,13 @@ class ListViewSelectableDirective {
|
|
|
449
573
|
enabled: true,
|
|
450
574
|
toggleable: false
|
|
451
575
|
};
|
|
452
|
-
this.#destroyRef = inject(DestroyRef);
|
|
453
576
|
this.#listService = inject(ListService);
|
|
454
|
-
this.selectedKeysChange = output();
|
|
455
577
|
this.options = input("", { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), alias: "monaListViewSelectable" });
|
|
456
578
|
this.selectBy = input("", /* @ts-ignore */
|
|
457
579
|
...(ngDevMode ? [{ debugName: "selectBy" }] : /* istanbul ignore next */ []));
|
|
458
580
|
this.selectedKeys = input([], /* @ts-ignore */
|
|
459
581
|
...(ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []));
|
|
582
|
+
this.selectedKeysChange = output();
|
|
460
583
|
effect(() => {
|
|
461
584
|
const selectBy = this.selectBy();
|
|
462
585
|
untracked(() => {
|
|
@@ -483,13 +606,9 @@ class ListViewSelectableDirective {
|
|
|
483
606
|
}
|
|
484
607
|
});
|
|
485
608
|
});
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
this.selectedKeysChange.emit(keys);
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
});
|
|
609
|
+
this.#listService.selectedKeysChange$
|
|
610
|
+
.pipe(takeUntilDestroyed())
|
|
611
|
+
.subscribe(keys => this.selectedKeysChange.emit(keys));
|
|
493
612
|
}
|
|
494
613
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListViewSelectableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
495
614
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ListViewSelectableDirective, isStandalone: true, selector: "mona-list-view[monaListViewSelectable]", inputs: { options: { classPropertyName: "options", publicName: "monaListViewSelectable", isSignal: true, isRequired: false, transformFunction: null }, selectBy: { classPropertyName: "selectBy", publicName: "selectBy", isSignal: true, isRequired: false, transformFunction: null }, selectedKeys: { classPropertyName: "selectedKeys", publicName: "selectedKeys", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedKeysChange: "selectedKeysChange" }, ngImport: i0 }); }
|
|
@@ -499,7 +618,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
499
618
|
args: [{
|
|
500
619
|
selector: "mona-list-view[monaListViewSelectable]"
|
|
501
620
|
}]
|
|
502
|
-
}], ctorParameters: () => [], propDecorators: {
|
|
621
|
+
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaListViewSelectable", required: false }] }], selectBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectBy", required: false }] }], selectedKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedKeys", required: false }] }], selectedKeysChange: [{ type: i0.Output, args: ["selectedKeysChange"] }] } });
|
|
503
622
|
|
|
504
623
|
class ListViewVirtualScrollDirective {
|
|
505
624
|
#listService;
|