@nanahoshi/mona-ui 0.51.0 → 0.52.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.
- package/docs/api/grid.json +1 -1
- package/docs/api/grid.md +1 -1
- package/docs/api/index.json +1 -1
- package/docs/api/tile-view.json +1 -0
- package/docs/api/tile-view.md +131 -0
- package/docs/grid-columns.md +3 -1
- package/docs/grid.md +1 -1
- package/docs/manifest.json +1 -1
- package/docs/tile-view.md +272 -0
- package/fesm2022/{grid-colgroup.component-BFbiAvkG.mjs → grid-colgroup.component-Ccz4jNGD.mjs} +2 -2
- package/fesm2022/{grid-footer-row.component-DpSu7jvG.mjs → grid-footer-row.component-3i2wvQ6a.mjs} +2 -2
- package/fesm2022/{grid-list.component-B-F4bvFL.mjs → grid-list.component-BaI4IOC6.mjs} +5 -5
- package/fesm2022/{grid-row.component-CuCQ_Z5F.mjs → grid-row.component-CK8q0Ecr.mjs} +3 -3
- package/fesm2022/{grid-virtual-list.component-rIz5AUOU.mjs → grid-virtual-list.component-BPLi0OaO.mjs} +5 -5
- package/fesm2022/{grid.styles-D6jP3vwD.mjs → grid.styles-DBLUtq2X.mjs} +18 -10
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +42 -39
- package/fesm2022/nanahoshi-mona-ui-tile-view.mjs +948 -0
- package/llms.txt +2 -0
- package/package.json +5 -1
- package/tile-view/package.json +5 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +12 -4
- package/types/nanahoshi-mona-ui-tile-view.d.ts +314 -0
|
@@ -0,0 +1,948 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Component, DestroyRef, Directive, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
|
|
4
|
+
import { MonaI18nService, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
|
|
5
|
+
import { twMerge } from "tailwind-merge";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
8
|
+
import { TYPEAHEAD_RESET_DELAY, createElementControlId, isTypeaheadKey, setupTypeahead } from "@nanahoshi/mona-ui/internal";
|
|
9
|
+
import { LIST_DEFAULT_MESSAGES } from "@nanahoshi/mona-ui/internal/list";
|
|
10
|
+
import { Subject } from "rxjs";
|
|
11
|
+
import { ImmutableSet } from "@mirei/ts-collections";
|
|
12
|
+
import { PlaceholderComponent } from "@nanahoshi/mona-ui/placeholder";
|
|
13
|
+
import { CdkFixedSizeVirtualScroll, CdkVirtualForOf, CdkVirtualScrollViewport } from "@angular/cdk/scrolling";
|
|
14
|
+
var TileViewItemTemplateDirective = class TileViewItemTemplateDirective {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.monaTileViewItemTemplateOf = input(null, ...ngDevMode ? [{ debugName: "monaTileViewItemTemplateOf" }] : /* istanbul ignore next */ []);
|
|
17
|
+
}
|
|
18
|
+
static ngTemplateContextGuard(_directive, _context) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
static {
|
|
22
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
23
|
+
minVersion: "12.0.0",
|
|
24
|
+
version: "22.3.0",
|
|
25
|
+
ngImport: i0,
|
|
26
|
+
type: TileViewItemTemplateDirective,
|
|
27
|
+
deps: [],
|
|
28
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
static {
|
|
32
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
33
|
+
minVersion: "17.1.0",
|
|
34
|
+
version: "22.3.0",
|
|
35
|
+
type: TileViewItemTemplateDirective,
|
|
36
|
+
isStandalone: true,
|
|
37
|
+
selector: "ng-template[monaTileViewItemTemplate]",
|
|
38
|
+
inputs: { monaTileViewItemTemplateOf: {
|
|
39
|
+
classPropertyName: "monaTileViewItemTemplateOf",
|
|
40
|
+
publicName: "monaTileViewItemTemplateOf",
|
|
41
|
+
isSignal: true,
|
|
42
|
+
isRequired: false,
|
|
43
|
+
transformFunction: null
|
|
44
|
+
} },
|
|
45
|
+
ngImport: i0
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
50
|
+
minVersion: "12.0.0",
|
|
51
|
+
version: "22.3.0",
|
|
52
|
+
ngImport: i0,
|
|
53
|
+
type: TileViewItemTemplateDirective,
|
|
54
|
+
decorators: [{
|
|
55
|
+
type: Directive,
|
|
56
|
+
args: [{ selector: "ng-template[monaTileViewItemTemplate]" }]
|
|
57
|
+
}],
|
|
58
|
+
propDecorators: { monaTileViewItemTemplateOf: [{
|
|
59
|
+
type: i0.Input,
|
|
60
|
+
args: [{
|
|
61
|
+
isSignal: true,
|
|
62
|
+
alias: "monaTileViewItemTemplateOf",
|
|
63
|
+
required: false
|
|
64
|
+
}]
|
|
65
|
+
}] }
|
|
66
|
+
});
|
|
67
|
+
var TileViewNoDataTemplateDirective = class TileViewNoDataTemplateDirective {
|
|
68
|
+
static {
|
|
69
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
70
|
+
minVersion: "12.0.0",
|
|
71
|
+
version: "22.3.0",
|
|
72
|
+
ngImport: i0,
|
|
73
|
+
type: TileViewNoDataTemplateDirective,
|
|
74
|
+
deps: [],
|
|
75
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
static {
|
|
79
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
80
|
+
minVersion: "14.0.0",
|
|
81
|
+
version: "22.3.0",
|
|
82
|
+
type: TileViewNoDataTemplateDirective,
|
|
83
|
+
isStandalone: true,
|
|
84
|
+
selector: "ng-template[monaTileViewNoDataTemplate]",
|
|
85
|
+
ngImport: i0
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
90
|
+
minVersion: "12.0.0",
|
|
91
|
+
version: "22.3.0",
|
|
92
|
+
ngImport: i0,
|
|
93
|
+
type: TileViewNoDataTemplateDirective,
|
|
94
|
+
decorators: [{
|
|
95
|
+
type: Directive,
|
|
96
|
+
args: [{ selector: "ng-template[monaTileViewNoDataTemplate]" }]
|
|
97
|
+
}]
|
|
98
|
+
});
|
|
99
|
+
const tileViewBaseThemeVariants = cva(`
|
|
100
|
+
relative flex h-full w-full flex-col overflow-hidden
|
|
101
|
+
bg-surface text-foreground
|
|
102
|
+
border border-border
|
|
103
|
+
`, { variants: {
|
|
104
|
+
rounded: {
|
|
105
|
+
small: "rounded-sm",
|
|
106
|
+
medium: "rounded-md",
|
|
107
|
+
large: "rounded-lg",
|
|
108
|
+
none: "rounded-none"
|
|
109
|
+
},
|
|
110
|
+
size: {
|
|
111
|
+
small: "text-sm",
|
|
112
|
+
medium: "text-base",
|
|
113
|
+
large: "text-lg"
|
|
114
|
+
}
|
|
115
|
+
} });
|
|
116
|
+
const tileViewViewportThemeVariants = cva(`h-full w-full outline-none focus-visible:outline-hidden [scrollbar-color:var(--color-scrollbar-thumb)_var(--color-scrollbar-track)] [scrollbar-width:thin]`, { variants: { empty: {
|
|
117
|
+
true: "focus-visible:inset-ring-2 focus-visible:inset-ring-focus-indicator focus-visible:-outline-offset-2",
|
|
118
|
+
false: ""
|
|
119
|
+
} } });
|
|
120
|
+
const tileViewTileThemeVariants = cva(`
|
|
121
|
+
relative flex shrink-0 cursor-default select-none flex-col overflow-hidden rounded-md text-foreground
|
|
122
|
+
after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:border-2
|
|
123
|
+
after:border-transparent after:forced-color-adjust-none
|
|
124
|
+
`, {
|
|
125
|
+
variants: {
|
|
126
|
+
selectable: {
|
|
127
|
+
true: "",
|
|
128
|
+
false: ""
|
|
129
|
+
},
|
|
130
|
+
selected: {
|
|
131
|
+
true: `
|
|
132
|
+
bg-(--color-selected) text-(--color-selected-foreground)
|
|
133
|
+
hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground)
|
|
134
|
+
forced-colors:after:border-[Highlight]
|
|
135
|
+
`,
|
|
136
|
+
false: ""
|
|
137
|
+
},
|
|
138
|
+
focused: {
|
|
139
|
+
true: `
|
|
140
|
+
inset-ring-2 inset-ring-focus-indicator
|
|
141
|
+
forced-colors:outline-2 forced-colors:-outline-offset-4 forced-colors:outline-dashed
|
|
142
|
+
forced-colors:outline-[CanvasText]
|
|
143
|
+
`,
|
|
144
|
+
false: ""
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
compoundVariants: [{
|
|
148
|
+
selectable: true,
|
|
149
|
+
selected: false,
|
|
150
|
+
class: "hover:bg-hover"
|
|
151
|
+
}]
|
|
152
|
+
});
|
|
153
|
+
const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
154
|
+
"ArrowDown",
|
|
155
|
+
"ArrowLeft",
|
|
156
|
+
"ArrowRight",
|
|
157
|
+
"ArrowUp",
|
|
158
|
+
"End",
|
|
159
|
+
"Home",
|
|
160
|
+
"PageDown",
|
|
161
|
+
"PageUp"
|
|
162
|
+
]);
|
|
163
|
+
function isTileNavigationKey(key) {
|
|
164
|
+
return NAVIGATION_KEYS.has(key);
|
|
165
|
+
}
|
|
166
|
+
function navigateTiles(from, key, layout) {
|
|
167
|
+
const { columns, count, pageRows, rtl } = layout;
|
|
168
|
+
if (count === 0) return -1;
|
|
169
|
+
const last = count - 1;
|
|
170
|
+
if (from < 0 || from > last) return key === "End" ? last : 0;
|
|
171
|
+
const column = from % columns;
|
|
172
|
+
switch (key) {
|
|
173
|
+
case "ArrowLeft":
|
|
174
|
+
case "ArrowRight":
|
|
175
|
+
if (key === "ArrowRight" !== rtl) return column < columns - 1 ? Math.min(from + 1, last) : from;
|
|
176
|
+
return column > 0 ? from - 1 : from;
|
|
177
|
+
case "ArrowDown": return byRows(from, 1, columns, last);
|
|
178
|
+
case "ArrowUp": return byRows(from, -1, columns, last);
|
|
179
|
+
case "PageDown": return byRows(from, Math.max(1, pageRows), columns, last);
|
|
180
|
+
case "PageUp": return byRows(from, -Math.max(1, pageRows), columns, last);
|
|
181
|
+
case "Home": return 0;
|
|
182
|
+
case "End": return last;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function byRows(from, rows, columns, last) {
|
|
186
|
+
const row = Math.floor(from / columns);
|
|
187
|
+
const target = Math.min(Math.max(row + rows, 0), Math.floor(last / columns));
|
|
188
|
+
return target === row ? from : Math.min(target * columns + from % columns, last);
|
|
189
|
+
}
|
|
190
|
+
function tileColumns(width, tileWidth, gap) {
|
|
191
|
+
if (width <= 0 || tileWidth <= 0) return 1;
|
|
192
|
+
return Math.max(1, Math.floor((width - gap) / (tileWidth + gap)));
|
|
193
|
+
}
|
|
194
|
+
const NONE = Symbol("none");
|
|
195
|
+
const NO_MODIFIERS = {
|
|
196
|
+
ctrlKey: false,
|
|
197
|
+
metaKey: false,
|
|
198
|
+
shiftKey: false
|
|
199
|
+
};
|
|
200
|
+
var TileViewComponent = class TileViewComponent {
|
|
201
|
+
#activeKey;
|
|
202
|
+
#destroyRef;
|
|
203
|
+
#direction;
|
|
204
|
+
#focused;
|
|
205
|
+
#id;
|
|
206
|
+
#indexOf;
|
|
207
|
+
#items;
|
|
208
|
+
#keyboard;
|
|
209
|
+
#keys;
|
|
210
|
+
#renderedRange;
|
|
211
|
+
#selected;
|
|
212
|
+
#typeaheadKey$;
|
|
213
|
+
#viewportHeight;
|
|
214
|
+
#viewportWidth;
|
|
215
|
+
#anchorKey;
|
|
216
|
+
#lastActiveIndex;
|
|
217
|
+
#ownSelection;
|
|
218
|
+
#typeaheadUntil;
|
|
219
|
+
constructor() {
|
|
220
|
+
this.#activeKey = signal(NONE, ...ngDevMode ? [{ debugName: "#activeKey" }] : /* istanbul ignore next */ []);
|
|
221
|
+
this.#destroyRef = inject(DestroyRef);
|
|
222
|
+
this.#direction = injectComponentDirection();
|
|
223
|
+
this.#focused = signal(false, ...ngDevMode ? [{ debugName: "#focused" }] : /* istanbul ignore next */ []);
|
|
224
|
+
this.#id = createElementControlId();
|
|
225
|
+
this.#indexOf = computed(() => {
|
|
226
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
227
|
+
this.#keys().forEach((key, index) => {
|
|
228
|
+
if (!indexOf.has(key)) indexOf.set(key, index);
|
|
229
|
+
});
|
|
230
|
+
return indexOf;
|
|
231
|
+
}, ...ngDevMode ? [{ debugName: "#indexOf" }] : /* istanbul ignore next */ []);
|
|
232
|
+
this.#items = computed(() => Array.from(this.items()), ...ngDevMode ? [{ debugName: "#items" }] : /* istanbul ignore next */ []);
|
|
233
|
+
this.#keyboard = signal(false, ...ngDevMode ? [{ debugName: "#keyboard" }] : /* istanbul ignore next */ []);
|
|
234
|
+
this.#keys = computed(() => {
|
|
235
|
+
const key = this.itemKey();
|
|
236
|
+
const keyOf = typeof key === "function" ? key : key === "" ? (item) => item : (item) => item?.[key];
|
|
237
|
+
return this.#items().map((item) => keyOf(item));
|
|
238
|
+
}, ...ngDevMode ? [{ debugName: "#keys" }] : /* istanbul ignore next */ []);
|
|
239
|
+
this.#renderedRange = signal({
|
|
240
|
+
start: 0,
|
|
241
|
+
end: 0
|
|
242
|
+
}, ...ngDevMode ? [{ debugName: "#renderedRange" }] : /* istanbul ignore next */ []);
|
|
243
|
+
this.#selected = computed(() => ImmutableSet.create(this.selectedKeys()), ...ngDevMode ? [{ debugName: "#selected" }] : /* istanbul ignore next */ []);
|
|
244
|
+
this.#typeaheadKey$ = new Subject();
|
|
245
|
+
this.#viewportHeight = signal(0, ...ngDevMode ? [{ debugName: "#viewportHeight" }] : /* istanbul ignore next */ []);
|
|
246
|
+
this.#viewportWidth = signal(0, ...ngDevMode ? [{ debugName: "#viewportWidth" }] : /* istanbul ignore next */ []);
|
|
247
|
+
this.#anchorKey = NONE;
|
|
248
|
+
this.#lastActiveIndex = -1;
|
|
249
|
+
this.#ownSelection = null;
|
|
250
|
+
this.#typeaheadUntil = 0;
|
|
251
|
+
this.activeDescendant = computed(() => {
|
|
252
|
+
const index = this.activeIndex();
|
|
253
|
+
const { start, end } = this.#renderedRange();
|
|
254
|
+
const columns = this.columnCount();
|
|
255
|
+
const row = Math.floor(index / columns);
|
|
256
|
+
return this.#focused() && index >= 0 && row >= start && row < end ? this.tileId(index) : null;
|
|
257
|
+
}, ...ngDevMode ? [{ debugName: "activeDescendant" }] : /* istanbul ignore next */ []);
|
|
258
|
+
this.activeIndex = computed(() => {
|
|
259
|
+
const key = this.#activeKey();
|
|
260
|
+
const count = this.count();
|
|
261
|
+
if (key === NONE || count === 0) return -1;
|
|
262
|
+
return this.#indexOf().get(key) ?? Math.min(this.#lastActiveIndex, count - 1);
|
|
263
|
+
}, ...ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []);
|
|
264
|
+
this.baseClasses = computed(() => twMerge(tileViewBaseThemeVariants({
|
|
265
|
+
rounded: this.rounded(),
|
|
266
|
+
size: this.size()
|
|
267
|
+
}), this.userClass()), ...ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []);
|
|
268
|
+
this.columnCount = computed(() => {
|
|
269
|
+
const columns = this.columns();
|
|
270
|
+
return columns === "auto" ? tileColumns(this.#viewportWidth(), this.tileWidth(), this.gap()) : Math.max(1, Math.floor(columns));
|
|
271
|
+
}, ...ngDevMode ? [{ debugName: "columnCount" }] : /* istanbul ignore next */ []);
|
|
272
|
+
this.count = computed(() => this.#items().length, ...ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []);
|
|
273
|
+
this.itemTemplate = contentChild(TileViewItemTemplateDirective, {
|
|
274
|
+
...ngDevMode ? { debugName: "itemTemplate" } : /* istanbul ignore next */ {},
|
|
275
|
+
read: TemplateRef
|
|
276
|
+
});
|
|
277
|
+
this.maxBufferPx = computed(() => this.rowHeight() * 2, ...ngDevMode ? [{ debugName: "maxBufferPx" }] : /* istanbul ignore next */ []);
|
|
278
|
+
this.messages = inject(MonaI18nService).componentMessages("list", LIST_DEFAULT_MESSAGES);
|
|
279
|
+
this.minBufferPx = computed(() => this.rowHeight(), ...ngDevMode ? [{ debugName: "minBufferPx" }] : /* istanbul ignore next */ []);
|
|
280
|
+
this.noDataId = `${this.#id}-no-data`;
|
|
281
|
+
this.noDataTemplate = contentChild(TileViewNoDataTemplateDirective, {
|
|
282
|
+
...ngDevMode ? { debugName: "noDataTemplate" } : /* istanbul ignore next */ {},
|
|
283
|
+
read: TemplateRef
|
|
284
|
+
});
|
|
285
|
+
this.role = computed(() => this.selectionMode() === "none" ? "list" : "listbox", ...ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []);
|
|
286
|
+
this.rowHeight = computed(() => this.tileHeight() + this.gap(), ...ngDevMode ? [{ debugName: "rowHeight" }] : /* istanbul ignore next */ []);
|
|
287
|
+
this.rows = computed(() => {
|
|
288
|
+
const items = this.#items();
|
|
289
|
+
const keys = this.#keys();
|
|
290
|
+
const columns = this.columnCount();
|
|
291
|
+
const rows = [];
|
|
292
|
+
for (let start = 0; start < items.length; start += columns) {
|
|
293
|
+
const end = Math.min(start + columns, items.length);
|
|
294
|
+
const row = [];
|
|
295
|
+
for (let index = start; index < end; index++) row.push({
|
|
296
|
+
index,
|
|
297
|
+
item: items[index],
|
|
298
|
+
key: keys[index]
|
|
299
|
+
});
|
|
300
|
+
rows.push(row);
|
|
301
|
+
}
|
|
302
|
+
return rows;
|
|
303
|
+
}, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
|
|
304
|
+
this.slotCount = computed(() => {
|
|
305
|
+
const rowHeight = Math.max(1, this.rowHeight());
|
|
306
|
+
return (Math.ceil((this.#viewportHeight() + this.minBufferPx() + this.maxBufferPx()) / rowHeight) + 3) * this.columnCount();
|
|
307
|
+
}, ...ngDevMode ? [{ debugName: "slotCount" }] : /* istanbul ignore next */ []);
|
|
308
|
+
this.statusText = computed(() => {
|
|
309
|
+
if (this.loading()) return this.messages().loading;
|
|
310
|
+
return this.count() === 0 && !this.noDataTemplate() ? this.messages().noData : "";
|
|
311
|
+
}, ...ngDevMode ? [{ debugName: "statusText" }] : /* istanbul ignore next */ []);
|
|
312
|
+
this.tileRole = computed(() => this.selectionMode() === "none" ? "listitem" : "option", ...ngDevMode ? [{ debugName: "tileRole" }] : /* istanbul ignore next */ []);
|
|
313
|
+
this.viewport = viewChild.required(CdkVirtualScrollViewport, ...ngDevMode ? [{ debugName: "viewport" }] : /* istanbul ignore next */ []);
|
|
314
|
+
this.viewportClasses = computed(() => tileViewViewportThemeVariants({ empty: this.count() === 0 }), ...ngDevMode ? [{ debugName: "viewportClasses" }] : /* istanbul ignore next */ []);
|
|
315
|
+
this.ariaLabel = input("", {
|
|
316
|
+
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
317
|
+
alias: "aria-label"
|
|
318
|
+
});
|
|
319
|
+
this.ariaLabelledBy = input("", {
|
|
320
|
+
...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
|
|
321
|
+
alias: "aria-labelledby"
|
|
322
|
+
});
|
|
323
|
+
this.columns = input("auto", ...ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []);
|
|
324
|
+
this.gap = input(4, ...ngDevMode ? [{ debugName: "gap" }] : /* istanbul ignore next */ []);
|
|
325
|
+
this.itemActivate = output();
|
|
326
|
+
this.itemKey = input("", ...ngDevMode ? [{ debugName: "itemKey" }] : /* istanbul ignore next */ []);
|
|
327
|
+
this.items = input([], ...ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []);
|
|
328
|
+
this.loading = input(false, {
|
|
329
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
330
|
+
transform: booleanAttribute
|
|
331
|
+
});
|
|
332
|
+
this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
|
|
333
|
+
this.selectedKeys = model([], ...ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []);
|
|
334
|
+
this.selectionMode = input("single", ...ngDevMode ? [{ debugName: "selectionMode" }] : /* istanbul ignore next */ []);
|
|
335
|
+
this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
336
|
+
this.textField = input("", ...ngDevMode ? [{ debugName: "textField" }] : /* istanbul ignore next */ []);
|
|
337
|
+
this.tileHeight = input(112, ...ngDevMode ? [{ debugName: "tileHeight" }] : /* istanbul ignore next */ []);
|
|
338
|
+
this.tileWidth = input(112, ...ngDevMode ? [{ debugName: "tileWidth" }] : /* istanbul ignore next */ []);
|
|
339
|
+
this.userClass = input("", {
|
|
340
|
+
...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
|
|
341
|
+
alias: "class"
|
|
342
|
+
});
|
|
343
|
+
afterNextRender(() => this.observeViewport());
|
|
344
|
+
setupTypeahead(this.#typeaheadKey$).pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((buffer) => this.findByText(buffer));
|
|
345
|
+
effect(() => {
|
|
346
|
+
const selected = this.selectedKeys();
|
|
347
|
+
untracked(() => {
|
|
348
|
+
if (selected === this.#ownSelection) return;
|
|
349
|
+
const set = this.#selected();
|
|
350
|
+
if (set.size() === 0 || set.contains(this.#activeKey())) return;
|
|
351
|
+
const indexOf = this.#indexOf();
|
|
352
|
+
const first = Math.min(...selected.map((key) => indexOf.get(key) ?? Infinity));
|
|
353
|
+
if (Number.isFinite(first)) {
|
|
354
|
+
this.setActive(first);
|
|
355
|
+
this.#anchorKey = this.#keys()[first];
|
|
356
|
+
this.scrollToIndex(first);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
scrollToItem(key) {
|
|
362
|
+
const index = this.#indexOf().get(key);
|
|
363
|
+
if (index !== void 0) this.scrollToIndex(index);
|
|
364
|
+
}
|
|
365
|
+
contextOf(cell) {
|
|
366
|
+
return {
|
|
367
|
+
$implicit: cell.item,
|
|
368
|
+
active: cell.index === this.activeIndex(),
|
|
369
|
+
index: cell.index,
|
|
370
|
+
selected: this.isSelected(cell),
|
|
371
|
+
slot: cell.index % this.slotCount()
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
isSelected(cell) {
|
|
375
|
+
return this.#selected().contains(cell.key);
|
|
376
|
+
}
|
|
377
|
+
onBlur() {
|
|
378
|
+
this.#focused.set(false);
|
|
379
|
+
}
|
|
380
|
+
onFocus() {
|
|
381
|
+
this.#focused.set(true);
|
|
382
|
+
this.#keyboard.set(this.matchesFocusVisible());
|
|
383
|
+
if (this.activeIndex() < 0 && this.count() > 0) {
|
|
384
|
+
const indexOf = this.#indexOf();
|
|
385
|
+
const first = Math.min(...this.selectedKeys().map((key) => indexOf.get(key) ?? Infinity));
|
|
386
|
+
this.setActive(Number.isFinite(first) ? first : 0);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
onKeydown(event) {
|
|
390
|
+
this.#keyboard.set(true);
|
|
391
|
+
if (isTileNavigationKey(event.key)) {
|
|
392
|
+
if (event.altKey) return;
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
const target = navigateTiles(this.activeIndex(), event.key, {
|
|
395
|
+
columns: this.columnCount(),
|
|
396
|
+
count: this.count(),
|
|
397
|
+
pageRows: Math.max(1, Math.floor(this.#viewportHeight() / this.rowHeight())),
|
|
398
|
+
rtl: this.#direction() === "rtl"
|
|
399
|
+
});
|
|
400
|
+
if (target >= 0) this.moveTo(target, event);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const index = this.activeIndex();
|
|
404
|
+
if (event.key === "Enter") {
|
|
405
|
+
if (index >= 0) {
|
|
406
|
+
event.preventDefault();
|
|
407
|
+
this.itemActivate.emit({
|
|
408
|
+
item: this.#items()[index],
|
|
409
|
+
originalEvent: event
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (event.key === " " && Date.now() >= this.#typeaheadUntil && !event.altKey) {
|
|
415
|
+
event.preventDefault();
|
|
416
|
+
if (index >= 0) this.selectWithSpace(index, event.ctrlKey || event.metaKey);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
if ((event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey && event.key.toLowerCase() === "a") {
|
|
420
|
+
if (this.selectionMode() === "multiple") {
|
|
421
|
+
event.preventDefault();
|
|
422
|
+
this.report([...this.#keys()]);
|
|
423
|
+
}
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (isTypeaheadKey(event.key, event)) {
|
|
427
|
+
event.preventDefault();
|
|
428
|
+
this.#typeaheadUntil = Date.now() + TYPEAHEAD_RESET_DELAY;
|
|
429
|
+
this.#typeaheadKey$.next(event.key);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
onPointerDown() {
|
|
433
|
+
this.#keyboard.set(false);
|
|
434
|
+
}
|
|
435
|
+
onTileClick(event, index) {
|
|
436
|
+
this.setActive(index);
|
|
437
|
+
this.select(index, event, "click");
|
|
438
|
+
this.focusViewport();
|
|
439
|
+
}
|
|
440
|
+
onTileDoubleClick(event, index) {
|
|
441
|
+
this.itemActivate.emit({
|
|
442
|
+
item: this.#items()[index],
|
|
443
|
+
originalEvent: event
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
onViewportClick(event) {
|
|
447
|
+
if (event.target?.closest("[data-mona-tile]") || event.ctrlKey || event.metaKey || event.shiftKey) return;
|
|
448
|
+
if (this.selectionMode() !== "none" && this.selectedKeys().length > 0) this.report([]);
|
|
449
|
+
this.focusViewport();
|
|
450
|
+
}
|
|
451
|
+
textOf(item) {
|
|
452
|
+
const field = this.textField();
|
|
453
|
+
if (typeof field === "function") return field(item);
|
|
454
|
+
const value = field === "" ? item : item?.[field];
|
|
455
|
+
return value == null ? "" : String(value);
|
|
456
|
+
}
|
|
457
|
+
tileClasses(cell) {
|
|
458
|
+
return tileViewTileThemeVariants({
|
|
459
|
+
focused: cell.index === this.activeIndex() && this.#focused() && this.#keyboard(),
|
|
460
|
+
selectable: this.selectionMode() !== "none",
|
|
461
|
+
selected: this.isSelected(cell)
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
tileId(index) {
|
|
465
|
+
return `${this.#id}-${index}`;
|
|
466
|
+
}
|
|
467
|
+
trackRow(index) {
|
|
468
|
+
return index;
|
|
469
|
+
}
|
|
470
|
+
findByText(buffer) {
|
|
471
|
+
const count = this.count();
|
|
472
|
+
if (count === 0) return;
|
|
473
|
+
const items = this.#items();
|
|
474
|
+
const start = this.activeIndex() + (buffer.length === 1 ? 1 : 0);
|
|
475
|
+
for (let step = 0; step < count; step++) {
|
|
476
|
+
const index = (Math.max(start, 0) + step) % count;
|
|
477
|
+
if (this.textOf(items[index]).toLowerCase().startsWith(buffer)) {
|
|
478
|
+
this.moveTo(index, NO_MODIFIERS);
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
focusViewport() {
|
|
484
|
+
const element = this.viewport().elementRef.nativeElement;
|
|
485
|
+
if (element.ownerDocument.activeElement !== element) element.focus({ preventScroll: true });
|
|
486
|
+
}
|
|
487
|
+
matchesFocusVisible() {
|
|
488
|
+
try {
|
|
489
|
+
return this.viewport().elementRef.nativeElement.matches(":focus-visible");
|
|
490
|
+
} catch {
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
moveTo(index, modifiers) {
|
|
495
|
+
this.setActive(index);
|
|
496
|
+
this.scrollToIndex(index);
|
|
497
|
+
if (!(modifiers.ctrlKey || modifiers.metaKey) || modifiers.shiftKey) this.select(index, modifiers, "keyboard");
|
|
498
|
+
}
|
|
499
|
+
observeViewport() {
|
|
500
|
+
const viewport = this.viewport();
|
|
501
|
+
this.#renderedRange.set(viewport.getRenderedRange());
|
|
502
|
+
viewport.renderedRangeStream.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((range) => this.#renderedRange.set(range));
|
|
503
|
+
const element = viewport.elementRef.nativeElement;
|
|
504
|
+
const measure = () => {
|
|
505
|
+
this.#viewportWidth.set(element.clientWidth);
|
|
506
|
+
this.#viewportHeight.set(element.clientHeight);
|
|
507
|
+
};
|
|
508
|
+
measure();
|
|
509
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
510
|
+
const observer = new ResizeObserver(measure);
|
|
511
|
+
observer.observe(element);
|
|
512
|
+
this.#destroyRef.onDestroy(() => observer.disconnect());
|
|
513
|
+
}
|
|
514
|
+
report(keys) {
|
|
515
|
+
const current = this.#selected();
|
|
516
|
+
if (keys.length === current.size() && keys.every((key) => current.contains(key))) return;
|
|
517
|
+
this.#ownSelection = keys;
|
|
518
|
+
this.selectedKeys.set(keys);
|
|
519
|
+
}
|
|
520
|
+
scrollToIndex(index) {
|
|
521
|
+
const viewport = this.viewport();
|
|
522
|
+
const rowHeight = this.rowHeight();
|
|
523
|
+
const top = Math.floor(index / this.columnCount()) * rowHeight;
|
|
524
|
+
const bottom = top + rowHeight + this.gap();
|
|
525
|
+
const scrollTop = viewport.measureScrollOffset("top");
|
|
526
|
+
const height = viewport.getViewportSize();
|
|
527
|
+
if (top < scrollTop) viewport.scrollToOffset(top);
|
|
528
|
+
else if (height > 0 && bottom > scrollTop + height) viewport.scrollToOffset(bottom - height);
|
|
529
|
+
}
|
|
530
|
+
select(index, modifiers, source) {
|
|
531
|
+
const mode = this.selectionMode();
|
|
532
|
+
if (mode === "none") return;
|
|
533
|
+
const keys = this.#keys();
|
|
534
|
+
const key = keys[index];
|
|
535
|
+
const ctrl = modifiers.ctrlKey || modifiers.metaKey;
|
|
536
|
+
if (mode === "single") {
|
|
537
|
+
this.report(ctrl && source === "click" && this.#selected().contains(key) ? [] : [key]);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (modifiers.shiftKey) {
|
|
541
|
+
const anchor = this.#indexOf().get(this.#anchorKey) ?? index;
|
|
542
|
+
const range = keys.slice(Math.min(anchor, index), Math.max(anchor, index) + 1);
|
|
543
|
+
this.report(ctrl ? [...this.#selected().union(range)] : range);
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
this.#anchorKey = key;
|
|
547
|
+
if (ctrl) {
|
|
548
|
+
const selected = this.#selected();
|
|
549
|
+
this.report(selected.contains(key) ? [...selected.where((k) => k !== key)] : [...selected, key]);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
this.report([key]);
|
|
553
|
+
}
|
|
554
|
+
selectWithSpace(index, ctrl) {
|
|
555
|
+
const mode = this.selectionMode();
|
|
556
|
+
if (mode === "none") return;
|
|
557
|
+
const key = this.#keys()[index];
|
|
558
|
+
const selected = this.#selected();
|
|
559
|
+
this.#anchorKey = key;
|
|
560
|
+
if (ctrl && selected.contains(key)) this.report([...selected.where((k) => k !== key)]);
|
|
561
|
+
else if (!selected.contains(key)) this.report(mode === "single" ? [key] : [...selected, key]);
|
|
562
|
+
}
|
|
563
|
+
setActive(index) {
|
|
564
|
+
this.#lastActiveIndex = index;
|
|
565
|
+
this.#activeKey.set(this.#keys()[index]);
|
|
566
|
+
}
|
|
567
|
+
static {
|
|
568
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
569
|
+
minVersion: "12.0.0",
|
|
570
|
+
version: "22.3.0",
|
|
571
|
+
ngImport: i0,
|
|
572
|
+
type: TileViewComponent,
|
|
573
|
+
deps: [],
|
|
574
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
static {
|
|
578
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
579
|
+
minVersion: "17.0.0",
|
|
580
|
+
version: "22.3.0",
|
|
581
|
+
type: TileViewComponent,
|
|
582
|
+
isStandalone: true,
|
|
583
|
+
selector: "mona-tile-view",
|
|
584
|
+
inputs: {
|
|
585
|
+
ariaLabel: {
|
|
586
|
+
classPropertyName: "ariaLabel",
|
|
587
|
+
publicName: "aria-label",
|
|
588
|
+
isSignal: true,
|
|
589
|
+
isRequired: false,
|
|
590
|
+
transformFunction: null
|
|
591
|
+
},
|
|
592
|
+
ariaLabelledBy: {
|
|
593
|
+
classPropertyName: "ariaLabelledBy",
|
|
594
|
+
publicName: "aria-labelledby",
|
|
595
|
+
isSignal: true,
|
|
596
|
+
isRequired: false,
|
|
597
|
+
transformFunction: null
|
|
598
|
+
},
|
|
599
|
+
columns: {
|
|
600
|
+
classPropertyName: "columns",
|
|
601
|
+
publicName: "columns",
|
|
602
|
+
isSignal: true,
|
|
603
|
+
isRequired: false,
|
|
604
|
+
transformFunction: null
|
|
605
|
+
},
|
|
606
|
+
gap: {
|
|
607
|
+
classPropertyName: "gap",
|
|
608
|
+
publicName: "gap",
|
|
609
|
+
isSignal: true,
|
|
610
|
+
isRequired: false,
|
|
611
|
+
transformFunction: null
|
|
612
|
+
},
|
|
613
|
+
itemKey: {
|
|
614
|
+
classPropertyName: "itemKey",
|
|
615
|
+
publicName: "itemKey",
|
|
616
|
+
isSignal: true,
|
|
617
|
+
isRequired: false,
|
|
618
|
+
transformFunction: null
|
|
619
|
+
},
|
|
620
|
+
items: {
|
|
621
|
+
classPropertyName: "items",
|
|
622
|
+
publicName: "items",
|
|
623
|
+
isSignal: true,
|
|
624
|
+
isRequired: false,
|
|
625
|
+
transformFunction: null
|
|
626
|
+
},
|
|
627
|
+
loading: {
|
|
628
|
+
classPropertyName: "loading",
|
|
629
|
+
publicName: "loading",
|
|
630
|
+
isSignal: true,
|
|
631
|
+
isRequired: false,
|
|
632
|
+
transformFunction: null
|
|
633
|
+
},
|
|
634
|
+
rounded: {
|
|
635
|
+
classPropertyName: "rounded",
|
|
636
|
+
publicName: "rounded",
|
|
637
|
+
isSignal: true,
|
|
638
|
+
isRequired: false,
|
|
639
|
+
transformFunction: null
|
|
640
|
+
},
|
|
641
|
+
selectedKeys: {
|
|
642
|
+
classPropertyName: "selectedKeys",
|
|
643
|
+
publicName: "selectedKeys",
|
|
644
|
+
isSignal: true,
|
|
645
|
+
isRequired: false,
|
|
646
|
+
transformFunction: null
|
|
647
|
+
},
|
|
648
|
+
selectionMode: {
|
|
649
|
+
classPropertyName: "selectionMode",
|
|
650
|
+
publicName: "selectionMode",
|
|
651
|
+
isSignal: true,
|
|
652
|
+
isRequired: false,
|
|
653
|
+
transformFunction: null
|
|
654
|
+
},
|
|
655
|
+
size: {
|
|
656
|
+
classPropertyName: "size",
|
|
657
|
+
publicName: "size",
|
|
658
|
+
isSignal: true,
|
|
659
|
+
isRequired: false,
|
|
660
|
+
transformFunction: null
|
|
661
|
+
},
|
|
662
|
+
textField: {
|
|
663
|
+
classPropertyName: "textField",
|
|
664
|
+
publicName: "textField",
|
|
665
|
+
isSignal: true,
|
|
666
|
+
isRequired: false,
|
|
667
|
+
transformFunction: null
|
|
668
|
+
},
|
|
669
|
+
tileHeight: {
|
|
670
|
+
classPropertyName: "tileHeight",
|
|
671
|
+
publicName: "tileHeight",
|
|
672
|
+
isSignal: true,
|
|
673
|
+
isRequired: false,
|
|
674
|
+
transformFunction: null
|
|
675
|
+
},
|
|
676
|
+
tileWidth: {
|
|
677
|
+
classPropertyName: "tileWidth",
|
|
678
|
+
publicName: "tileWidth",
|
|
679
|
+
isSignal: true,
|
|
680
|
+
isRequired: false,
|
|
681
|
+
transformFunction: null
|
|
682
|
+
},
|
|
683
|
+
userClass: {
|
|
684
|
+
classPropertyName: "userClass",
|
|
685
|
+
publicName: "class",
|
|
686
|
+
isSignal: true,
|
|
687
|
+
isRequired: false,
|
|
688
|
+
transformFunction: null
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
outputs: {
|
|
692
|
+
itemActivate: "itemActivate",
|
|
693
|
+
selectedKeys: "selectedKeysChange"
|
|
694
|
+
},
|
|
695
|
+
host: { properties: {
|
|
696
|
+
"class": "baseClasses()",
|
|
697
|
+
"attr.aria-label": "null",
|
|
698
|
+
"attr.aria-labelledby": "null"
|
|
699
|
+
} },
|
|
700
|
+
queries: [{
|
|
701
|
+
propertyName: "itemTemplate",
|
|
702
|
+
first: true,
|
|
703
|
+
predicate: TileViewItemTemplateDirective,
|
|
704
|
+
descendants: true,
|
|
705
|
+
read: TemplateRef,
|
|
706
|
+
isSignal: true
|
|
707
|
+
}, {
|
|
708
|
+
propertyName: "noDataTemplate",
|
|
709
|
+
first: true,
|
|
710
|
+
predicate: TileViewNoDataTemplateDirective,
|
|
711
|
+
descendants: true,
|
|
712
|
+
read: TemplateRef,
|
|
713
|
+
isSignal: true
|
|
714
|
+
}],
|
|
715
|
+
viewQueries: [{
|
|
716
|
+
propertyName: "viewport",
|
|
717
|
+
first: true,
|
|
718
|
+
predicate: CdkVirtualScrollViewport,
|
|
719
|
+
descendants: true,
|
|
720
|
+
isSignal: true
|
|
721
|
+
}],
|
|
722
|
+
ngImport: i0,
|
|
723
|
+
template: "@let showNoData = count() === 0 && !loading();\n@if (showNoData) {\n <!-- The listbox lies over the \"No data\" content, so that content keeps its place and the ring frames it. -->\n <div [id]=\"noDataId\" class=\"absolute inset-0\">\n @if (noDataTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\"></ng-container>\n } @else {\n <mona-placeholder\n [text]=\"messages().noData\"\n class=\"flex h-full w-full items-center justify-center\"></mona-placeholder>\n }\n </div>\n}\n<cdk-virtual-scroll-viewport\n [itemSize]=\"rowHeight()\"\n [minBufferPx]=\"minBufferPx()\"\n [maxBufferPx]=\"maxBufferPx()\"\n [class]=\"viewportClasses()\"\n [tabIndex]=\"0\"\n [attr.role]=\"role()\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-activedescendant]=\"activeDescendant()\"\n [attr.aria-multiselectable]=\"(role() === 'listbox' && selectionMode() === 'multiple') || null\"\n [attr.aria-busy]=\"loading() || null\"\n [attr.aria-describedby]=\"showNoData ? noDataId : null\"\n (blur)=\"onBlur()\"\n (click)=\"onViewportClick($event)\"\n (focus)=\"onFocus()\"\n (keydown)=\"onKeydown($event)\"\n (pointerdown)=\"onPointerDown()\">\n <div\n *cdkVirtualFor=\"let row of rows(); trackBy: trackRow\"\n role=\"none\"\n class=\"flex\"\n [style.height.px]=\"rowHeight()\"\n [style.gap.px]=\"gap()\"\n [style.padding-top.px]=\"gap()\"\n [style.padding-inline.px]=\"gap()\">\n <!-- By place: a row scrolled away is reused for one scrolled in, with its tiles, which only change items. -->\n @for (cell of row; track $index) {\n <div\n data-mona-tile\n [id]=\"tileId(cell.index)\"\n [class]=\"tileClasses(cell)\"\n [style.width.px]=\"tileWidth()\"\n [style.height.px]=\"tileHeight()\"\n [attr.role]=\"tileRole()\"\n [attr.aria-selected]=\"tileRole() === 'option' ? isSelected(cell) : null\"\n [attr.aria-posinset]=\"cell.index + 1\"\n [attr.aria-setsize]=\"count()\"\n (click)=\"onTileClick($event, cell.index)\"\n (dblclick)=\"onTileDoubleClick($event, cell.index)\">\n @if (itemTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"contextOf(cell)\"></ng-container>\n } @else {\n <span class=\"m-auto line-clamp-2 px-1 text-center wrap-break-word\">{{ textOf(cell.item) }}</span>\n }\n </div>\n }\n </div>\n</cdk-virtual-scroll-viewport>\n<div role=\"status\" class=\"sr-only\">{{ statusText() }}</div>\n",
|
|
724
|
+
dependencies: [
|
|
725
|
+
{
|
|
726
|
+
kind: "directive",
|
|
727
|
+
type: CdkFixedSizeVirtualScroll,
|
|
728
|
+
selector: "cdk-virtual-scroll-viewport[itemSize]",
|
|
729
|
+
inputs: [
|
|
730
|
+
"itemSize",
|
|
731
|
+
"minBufferPx",
|
|
732
|
+
"maxBufferPx"
|
|
733
|
+
]
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
kind: "directive",
|
|
737
|
+
type: CdkVirtualForOf,
|
|
738
|
+
selector: "[cdkVirtualFor][cdkVirtualForOf]",
|
|
739
|
+
inputs: [
|
|
740
|
+
"cdkVirtualForOf",
|
|
741
|
+
"cdkVirtualForTrackBy",
|
|
742
|
+
"cdkVirtualForTemplate",
|
|
743
|
+
"cdkVirtualForTemplateCacheSize"
|
|
744
|
+
]
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
kind: "component",
|
|
748
|
+
type: CdkVirtualScrollViewport,
|
|
749
|
+
selector: "cdk-virtual-scroll-viewport",
|
|
750
|
+
inputs: ["orientation", "appendOnly"],
|
|
751
|
+
outputs: ["scrolledIndexChange"]
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
kind: "directive",
|
|
755
|
+
type: NgTemplateOutlet,
|
|
756
|
+
selector: "[ngTemplateOutlet]",
|
|
757
|
+
inputs: [
|
|
758
|
+
"ngTemplateOutletContext",
|
|
759
|
+
"ngTemplateOutlet",
|
|
760
|
+
"ngTemplateOutletInjector"
|
|
761
|
+
]
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
kind: "component",
|
|
765
|
+
type: PlaceholderComponent,
|
|
766
|
+
selector: "mona-placeholder",
|
|
767
|
+
inputs: ["text", "class"]
|
|
768
|
+
}
|
|
769
|
+
]
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
774
|
+
minVersion: "12.0.0",
|
|
775
|
+
version: "22.3.0",
|
|
776
|
+
ngImport: i0,
|
|
777
|
+
type: TileViewComponent,
|
|
778
|
+
decorators: [{
|
|
779
|
+
type: Component,
|
|
780
|
+
args: [{
|
|
781
|
+
selector: "mona-tile-view",
|
|
782
|
+
imports: [
|
|
783
|
+
CdkFixedSizeVirtualScroll,
|
|
784
|
+
CdkVirtualForOf,
|
|
785
|
+
CdkVirtualScrollViewport,
|
|
786
|
+
NgTemplateOutlet,
|
|
787
|
+
PlaceholderComponent
|
|
788
|
+
],
|
|
789
|
+
host: {
|
|
790
|
+
"[class]": "baseClasses()",
|
|
791
|
+
"[attr.aria-label]": "null",
|
|
792
|
+
"[attr.aria-labelledby]": "null"
|
|
793
|
+
},
|
|
794
|
+
template: "@let showNoData = count() === 0 && !loading();\n@if (showNoData) {\n <!-- The listbox lies over the \"No data\" content, so that content keeps its place and the ring frames it. -->\n <div [id]=\"noDataId\" class=\"absolute inset-0\">\n @if (noDataTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\"></ng-container>\n } @else {\n <mona-placeholder\n [text]=\"messages().noData\"\n class=\"flex h-full w-full items-center justify-center\"></mona-placeholder>\n }\n </div>\n}\n<cdk-virtual-scroll-viewport\n [itemSize]=\"rowHeight()\"\n [minBufferPx]=\"minBufferPx()\"\n [maxBufferPx]=\"maxBufferPx()\"\n [class]=\"viewportClasses()\"\n [tabIndex]=\"0\"\n [attr.role]=\"role()\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-activedescendant]=\"activeDescendant()\"\n [attr.aria-multiselectable]=\"(role() === 'listbox' && selectionMode() === 'multiple') || null\"\n [attr.aria-busy]=\"loading() || null\"\n [attr.aria-describedby]=\"showNoData ? noDataId : null\"\n (blur)=\"onBlur()\"\n (click)=\"onViewportClick($event)\"\n (focus)=\"onFocus()\"\n (keydown)=\"onKeydown($event)\"\n (pointerdown)=\"onPointerDown()\">\n <div\n *cdkVirtualFor=\"let row of rows(); trackBy: trackRow\"\n role=\"none\"\n class=\"flex\"\n [style.height.px]=\"rowHeight()\"\n [style.gap.px]=\"gap()\"\n [style.padding-top.px]=\"gap()\"\n [style.padding-inline.px]=\"gap()\">\n <!-- By place: a row scrolled away is reused for one scrolled in, with its tiles, which only change items. -->\n @for (cell of row; track $index) {\n <div\n data-mona-tile\n [id]=\"tileId(cell.index)\"\n [class]=\"tileClasses(cell)\"\n [style.width.px]=\"tileWidth()\"\n [style.height.px]=\"tileHeight()\"\n [attr.role]=\"tileRole()\"\n [attr.aria-selected]=\"tileRole() === 'option' ? isSelected(cell) : null\"\n [attr.aria-posinset]=\"cell.index + 1\"\n [attr.aria-setsize]=\"count()\"\n (click)=\"onTileClick($event, cell.index)\"\n (dblclick)=\"onTileDoubleClick($event, cell.index)\">\n @if (itemTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"contextOf(cell)\"></ng-container>\n } @else {\n <span class=\"m-auto line-clamp-2 px-1 text-center wrap-break-word\">{{ textOf(cell.item) }}</span>\n }\n </div>\n }\n </div>\n</cdk-virtual-scroll-viewport>\n<div role=\"status\" class=\"sr-only\">{{ statusText() }}</div>\n"
|
|
795
|
+
}]
|
|
796
|
+
}],
|
|
797
|
+
ctorParameters: () => [],
|
|
798
|
+
propDecorators: {
|
|
799
|
+
itemTemplate: [{
|
|
800
|
+
type: i0.ContentChild,
|
|
801
|
+
args: [i0.forwardRef(() => TileViewItemTemplateDirective), {
|
|
802
|
+
read: TemplateRef,
|
|
803
|
+
isSignal: true
|
|
804
|
+
}]
|
|
805
|
+
}],
|
|
806
|
+
noDataTemplate: [{
|
|
807
|
+
type: i0.ContentChild,
|
|
808
|
+
args: [i0.forwardRef(() => TileViewNoDataTemplateDirective), {
|
|
809
|
+
read: TemplateRef,
|
|
810
|
+
isSignal: true
|
|
811
|
+
}]
|
|
812
|
+
}],
|
|
813
|
+
viewport: [{
|
|
814
|
+
type: i0.ViewChild,
|
|
815
|
+
args: [i0.forwardRef(() => CdkVirtualScrollViewport), { isSignal: true }]
|
|
816
|
+
}],
|
|
817
|
+
ariaLabel: [{
|
|
818
|
+
type: i0.Input,
|
|
819
|
+
args: [{
|
|
820
|
+
isSignal: true,
|
|
821
|
+
alias: "aria-label",
|
|
822
|
+
required: false
|
|
823
|
+
}]
|
|
824
|
+
}],
|
|
825
|
+
ariaLabelledBy: [{
|
|
826
|
+
type: i0.Input,
|
|
827
|
+
args: [{
|
|
828
|
+
isSignal: true,
|
|
829
|
+
alias: "aria-labelledby",
|
|
830
|
+
required: false
|
|
831
|
+
}]
|
|
832
|
+
}],
|
|
833
|
+
columns: [{
|
|
834
|
+
type: i0.Input,
|
|
835
|
+
args: [{
|
|
836
|
+
isSignal: true,
|
|
837
|
+
alias: "columns",
|
|
838
|
+
required: false
|
|
839
|
+
}]
|
|
840
|
+
}],
|
|
841
|
+
gap: [{
|
|
842
|
+
type: i0.Input,
|
|
843
|
+
args: [{
|
|
844
|
+
isSignal: true,
|
|
845
|
+
alias: "gap",
|
|
846
|
+
required: false
|
|
847
|
+
}]
|
|
848
|
+
}],
|
|
849
|
+
itemActivate: [{
|
|
850
|
+
type: i0.Output,
|
|
851
|
+
args: ["itemActivate"]
|
|
852
|
+
}],
|
|
853
|
+
itemKey: [{
|
|
854
|
+
type: i0.Input,
|
|
855
|
+
args: [{
|
|
856
|
+
isSignal: true,
|
|
857
|
+
alias: "itemKey",
|
|
858
|
+
required: false
|
|
859
|
+
}]
|
|
860
|
+
}],
|
|
861
|
+
items: [{
|
|
862
|
+
type: i0.Input,
|
|
863
|
+
args: [{
|
|
864
|
+
isSignal: true,
|
|
865
|
+
alias: "items",
|
|
866
|
+
required: false
|
|
867
|
+
}]
|
|
868
|
+
}],
|
|
869
|
+
loading: [{
|
|
870
|
+
type: i0.Input,
|
|
871
|
+
args: [{
|
|
872
|
+
isSignal: true,
|
|
873
|
+
alias: "loading",
|
|
874
|
+
required: false
|
|
875
|
+
}]
|
|
876
|
+
}],
|
|
877
|
+
rounded: [{
|
|
878
|
+
type: i0.Input,
|
|
879
|
+
args: [{
|
|
880
|
+
isSignal: true,
|
|
881
|
+
alias: "rounded",
|
|
882
|
+
required: false
|
|
883
|
+
}]
|
|
884
|
+
}],
|
|
885
|
+
selectedKeys: [{
|
|
886
|
+
type: i0.Input,
|
|
887
|
+
args: [{
|
|
888
|
+
isSignal: true,
|
|
889
|
+
alias: "selectedKeys",
|
|
890
|
+
required: false
|
|
891
|
+
}]
|
|
892
|
+
}, {
|
|
893
|
+
type: i0.Output,
|
|
894
|
+
args: ["selectedKeysChange"]
|
|
895
|
+
}],
|
|
896
|
+
selectionMode: [{
|
|
897
|
+
type: i0.Input,
|
|
898
|
+
args: [{
|
|
899
|
+
isSignal: true,
|
|
900
|
+
alias: "selectionMode",
|
|
901
|
+
required: false
|
|
902
|
+
}]
|
|
903
|
+
}],
|
|
904
|
+
size: [{
|
|
905
|
+
type: i0.Input,
|
|
906
|
+
args: [{
|
|
907
|
+
isSignal: true,
|
|
908
|
+
alias: "size",
|
|
909
|
+
required: false
|
|
910
|
+
}]
|
|
911
|
+
}],
|
|
912
|
+
textField: [{
|
|
913
|
+
type: i0.Input,
|
|
914
|
+
args: [{
|
|
915
|
+
isSignal: true,
|
|
916
|
+
alias: "textField",
|
|
917
|
+
required: false
|
|
918
|
+
}]
|
|
919
|
+
}],
|
|
920
|
+
tileHeight: [{
|
|
921
|
+
type: i0.Input,
|
|
922
|
+
args: [{
|
|
923
|
+
isSignal: true,
|
|
924
|
+
alias: "tileHeight",
|
|
925
|
+
required: false
|
|
926
|
+
}]
|
|
927
|
+
}],
|
|
928
|
+
tileWidth: [{
|
|
929
|
+
type: i0.Input,
|
|
930
|
+
args: [{
|
|
931
|
+
isSignal: true,
|
|
932
|
+
alias: "tileWidth",
|
|
933
|
+
required: false
|
|
934
|
+
}]
|
|
935
|
+
}],
|
|
936
|
+
userClass: [{
|
|
937
|
+
type: i0.Input,
|
|
938
|
+
args: [{
|
|
939
|
+
isSignal: true,
|
|
940
|
+
alias: "class",
|
|
941
|
+
required: false
|
|
942
|
+
}]
|
|
943
|
+
}]
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
export { TileViewComponent, TileViewItemTemplateDirective, TileViewNoDataTemplateDirective };
|
|
947
|
+
|
|
948
|
+
//# sourceMappingURL=nanahoshi-mona-ui-tile-view.mjs.map
|