@star-ng/ui 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +162 -2
- package/fesm2022/star-ng-ui-accordion.mjs +376 -0
- package/fesm2022/star-ng-ui-accordion.mjs.map +1 -0
- package/fesm2022/star-ng-ui-autocomplete.mjs +786 -0
- package/fesm2022/star-ng-ui-autocomplete.mjs.map +1 -0
- package/fesm2022/star-ng-ui-avatar.mjs +154 -0
- package/fesm2022/star-ng-ui-avatar.mjs.map +1 -0
- package/fesm2022/star-ng-ui-badge.mjs +153 -0
- package/fesm2022/star-ng-ui-badge.mjs.map +1 -0
- package/fesm2022/star-ng-ui-breadcrumb.mjs +199 -0
- package/fesm2022/star-ng-ui-breadcrumb.mjs.map +1 -0
- package/fesm2022/star-ng-ui-button.mjs +282 -0
- package/fesm2022/star-ng-ui-button.mjs.map +1 -0
- package/fesm2022/star-ng-ui-card.mjs +112 -0
- package/fesm2022/star-ng-ui-card.mjs.map +1 -0
- package/fesm2022/star-ng-ui-chart.mjs +1904 -0
- package/fesm2022/star-ng-ui-chart.mjs.map +1 -0
- package/fesm2022/star-ng-ui-checkbox.mjs +345 -0
- package/fesm2022/star-ng-ui-checkbox.mjs.map +1 -0
- package/fesm2022/star-ng-ui-core.mjs +484 -0
- package/fesm2022/star-ng-ui-core.mjs.map +1 -0
- package/fesm2022/star-ng-ui-data-display.mjs +1870 -0
- package/fesm2022/star-ng-ui-data-display.mjs.map +1 -0
- package/fesm2022/star-ng-ui-date-picker.mjs +2786 -0
- package/fesm2022/star-ng-ui-date-picker.mjs.map +1 -0
- package/fesm2022/star-ng-ui-dialog.mjs +948 -0
- package/fesm2022/star-ng-ui-dialog.mjs.map +1 -0
- package/fesm2022/star-ng-ui-drawer.mjs +158 -0
- package/fesm2022/star-ng-ui-drawer.mjs.map +1 -0
- package/fesm2022/star-ng-ui-editor.mjs +416 -0
- package/fesm2022/star-ng-ui-editor.mjs.map +1 -0
- package/fesm2022/star-ng-ui-field.mjs +378 -0
- package/fesm2022/star-ng-ui-field.mjs.map +1 -0
- package/fesm2022/star-ng-ui-file-upload.mjs +762 -0
- package/fesm2022/star-ng-ui-file-upload.mjs.map +1 -0
- package/fesm2022/star-ng-ui-i18n-de.mjs +179 -0
- package/fesm2022/star-ng-ui-i18n-de.mjs.map +1 -0
- package/fesm2022/star-ng-ui-i18n-es.mjs +179 -0
- package/fesm2022/star-ng-ui-i18n-es.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-group.mjs +188 -0
- package/fesm2022/star-ng-ui-input-group.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-mask.mjs +434 -0
- package/fesm2022/star-ng-ui-input-mask.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-number.mjs +691 -0
- package/fesm2022/star-ng-ui-input-number.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-otp.mjs +343 -0
- package/fesm2022/star-ng-ui-input-otp.mjs.map +1 -0
- package/fesm2022/star-ng-ui-input-tags.mjs +616 -0
- package/fesm2022/star-ng-ui-input-tags.mjs.map +1 -0
- package/fesm2022/star-ng-ui-knob.mjs +514 -0
- package/fesm2022/star-ng-ui-knob.mjs.map +1 -0
- package/fesm2022/star-ng-ui-layout.mjs +608 -0
- package/fesm2022/star-ng-ui-layout.mjs.map +1 -0
- package/fesm2022/star-ng-ui-listbox.mjs +886 -0
- package/fesm2022/star-ng-ui-listbox.mjs.map +1 -0
- package/fesm2022/star-ng-ui-media.mjs +833 -0
- package/fesm2022/star-ng-ui-media.mjs.map +1 -0
- package/fesm2022/star-ng-ui-menu.mjs +1840 -0
- package/fesm2022/star-ng-ui-menu.mjs.map +1 -0
- package/fesm2022/star-ng-ui-message.mjs +191 -0
- package/fesm2022/star-ng-ui-message.mjs.map +1 -0
- package/fesm2022/star-ng-ui-paginator.mjs +387 -0
- package/fesm2022/star-ng-ui-paginator.mjs.map +1 -0
- package/fesm2022/star-ng-ui-panel.mjs +324 -0
- package/fesm2022/star-ng-ui-panel.mjs.map +1 -0
- package/fesm2022/star-ng-ui-password.mjs +517 -0
- package/fesm2022/star-ng-ui-password.mjs.map +1 -0
- package/fesm2022/star-ng-ui-popover.mjs +241 -0
- package/fesm2022/star-ng-ui-popover.mjs.map +1 -0
- package/fesm2022/star-ng-ui-progress-bar.mjs +183 -0
- package/fesm2022/star-ng-ui-progress-bar.mjs.map +1 -0
- package/fesm2022/star-ng-ui-radio.mjs +411 -0
- package/fesm2022/star-ng-ui-radio.mjs.map +1 -0
- package/fesm2022/star-ng-ui-rating.mjs +211 -0
- package/fesm2022/star-ng-ui-rating.mjs.map +1 -0
- package/fesm2022/star-ng-ui-select-button.mjs +613 -0
- package/fesm2022/star-ng-ui-select-button.mjs.map +1 -0
- package/fesm2022/star-ng-ui-select.mjs +2547 -0
- package/fesm2022/star-ng-ui-select.mjs.map +1 -0
- package/fesm2022/star-ng-ui-skeleton.mjs +160 -0
- package/fesm2022/star-ng-ui-skeleton.mjs.map +1 -0
- package/fesm2022/star-ng-ui-slider.mjs +552 -0
- package/fesm2022/star-ng-ui-slider.mjs.map +1 -0
- package/fesm2022/star-ng-ui-spinner.mjs +148 -0
- package/fesm2022/star-ng-ui-spinner.mjs.map +1 -0
- package/fesm2022/star-ng-ui-stepper.mjs +360 -0
- package/fesm2022/star-ng-ui-stepper.mjs.map +1 -0
- package/fesm2022/star-ng-ui-table.mjs +3531 -0
- package/fesm2022/star-ng-ui-table.mjs.map +1 -0
- package/fesm2022/star-ng-ui-tabs.mjs +464 -0
- package/fesm2022/star-ng-ui-tabs.mjs.map +1 -0
- package/fesm2022/star-ng-ui-tag.mjs +129 -0
- package/fesm2022/star-ng-ui-tag.mjs.map +1 -0
- package/fesm2022/star-ng-ui-theme-switch.mjs +105 -0
- package/fesm2022/star-ng-ui-theme-switch.mjs.map +1 -0
- package/fesm2022/star-ng-ui-theme.mjs +98 -0
- package/fesm2022/star-ng-ui-theme.mjs.map +1 -0
- package/fesm2022/star-ng-ui-toast.mjs +298 -0
- package/fesm2022/star-ng-ui-toast.mjs.map +1 -0
- package/fesm2022/star-ng-ui-toggle-switch.mjs +316 -0
- package/fesm2022/star-ng-ui-toggle-switch.mjs.map +1 -0
- package/fesm2022/star-ng-ui-tooltip.mjs +297 -0
- package/fesm2022/star-ng-ui-tooltip.mjs.map +1 -0
- package/fesm2022/star-ng-ui-transloco.mjs +40 -0
- package/fesm2022/star-ng-ui-transloco.mjs.map +1 -0
- package/fesm2022/star-ng-ui-tree.mjs +1446 -0
- package/fesm2022/star-ng-ui-tree.mjs.map +1 -0
- package/fesm2022/star-ng-ui-utility.mjs +2134 -0
- package/fesm2022/star-ng-ui-utility.mjs.map +1 -0
- package/fesm2022/star-ng-ui.mjs +51 -0
- package/package.json +285 -3
- package/styles/_base.scss +70 -0
- package/styles/_shared.scss +2 -0
- package/styles/_tokens.scss +190 -0
- package/styles/controls/_accordion.scss +75 -0
- package/styles/controls/_autocomplete.scss +44 -0
- package/styles/controls/_avatar.scss +39 -0
- package/styles/controls/_breadcrumb.scss +45 -0
- package/styles/controls/_button.scss +137 -0
- package/styles/controls/_card.scss +38 -0
- package/styles/controls/_chart.scss +214 -0
- package/styles/controls/_chip.scss +51 -0
- package/styles/controls/_choice.scss +153 -0
- package/styles/controls/_data-display.scss +124 -0
- package/styles/controls/_date-picker.scss +300 -0
- package/styles/controls/_dialog.scss +123 -0
- package/styles/controls/_drawer.scss +118 -0
- package/styles/controls/_editor.scss +74 -0
- package/styles/controls/_field.scss +92 -0
- package/styles/controls/_file-upload.scss +136 -0
- package/styles/controls/_input-group.scss +104 -0
- package/styles/controls/_input-mask.scss +46 -0
- package/styles/controls/_input-number.scss +125 -0
- package/styles/controls/_knob.scss +76 -0
- package/styles/controls/_layout.scss +182 -0
- package/styles/controls/_listbox.scss +38 -0
- package/styles/controls/_media.scss +222 -0
- package/styles/controls/_menu.scss +254 -0
- package/styles/controls/_message.scss +48 -0
- package/styles/controls/_org-chart.scss +128 -0
- package/styles/controls/_paginator.scss +59 -0
- package/styles/controls/_panel.scss +83 -0
- package/styles/controls/_popover.scss +40 -0
- package/styles/controls/_progress-bar.scss +74 -0
- package/styles/controls/_select-button.scss +61 -0
- package/styles/controls/_select.scss +216 -0
- package/styles/controls/_skeleton.scss +43 -0
- package/styles/controls/_slider.scss +163 -0
- package/styles/controls/_spinner.scss +34 -0
- package/styles/controls/_stepper.scss +109 -0
- package/styles/controls/_table.scss +523 -0
- package/styles/controls/_tabs.scss +93 -0
- package/styles/controls/_tag.scss +84 -0
- package/styles/controls/_toast.scss +141 -0
- package/styles/controls/_tooltip.scss +14 -0
- package/styles/controls/_tree.scss +113 -0
- package/styles/controls/_utility.scss +654 -0
- package/styles/star-ng.css +5807 -0
- package/styles/star-ng.min.css +1 -0
- package/styles/star-ng.scss +50 -0
- package/theme/star-theme-first-paint.js +1 -0
- package/types/star-ng-ui-accordion.d.ts +82 -0
- package/types/star-ng-ui-autocomplete.d.ts +171 -0
- package/types/star-ng-ui-avatar.d.ts +43 -0
- package/types/star-ng-ui-badge.d.ts +46 -0
- package/types/star-ng-ui-breadcrumb.d.ts +39 -0
- package/types/star-ng-ui-button.d.ts +79 -0
- package/types/star-ng-ui-card.d.ts +29 -0
- package/types/star-ng-ui-chart.d.ts +337 -0
- package/types/star-ng-ui-checkbox.d.ts +92 -0
- package/types/star-ng-ui-core.d.ts +373 -0
- package/types/star-ng-ui-data-display.d.ts +438 -0
- package/types/star-ng-ui-date-picker.d.ts +701 -0
- package/types/star-ng-ui-dialog.d.ts +254 -0
- package/types/star-ng-ui-drawer.d.ts +29 -0
- package/types/star-ng-ui-editor.d.ts +96 -0
- package/types/star-ng-ui-field.d.ts +146 -0
- package/types/star-ng-ui-file-upload.d.ts +192 -0
- package/types/star-ng-ui-i18n-de.d.ts +7 -0
- package/types/star-ng-ui-i18n-es.d.ts +7 -0
- package/types/star-ng-ui-input-group.d.ts +58 -0
- package/types/star-ng-ui-input-mask.d.ts +126 -0
- package/types/star-ng-ui-input-number.d.ts +193 -0
- package/types/star-ng-ui-input-otp.d.ts +86 -0
- package/types/star-ng-ui-input-tags.d.ts +159 -0
- package/types/star-ng-ui-knob.d.ts +121 -0
- package/types/star-ng-ui-layout.d.ts +154 -0
- package/types/star-ng-ui-listbox.d.ts +170 -0
- package/types/star-ng-ui-media.d.ts +161 -0
- package/types/star-ng-ui-menu.d.ts +332 -0
- package/types/star-ng-ui-message.d.ts +52 -0
- package/types/star-ng-ui-paginator.d.ts +85 -0
- package/types/star-ng-ui-panel.d.ts +65 -0
- package/types/star-ng-ui-password.d.ts +129 -0
- package/types/star-ng-ui-popover.d.ts +57 -0
- package/types/star-ng-ui-progress-bar.d.ts +49 -0
- package/types/star-ng-ui-radio.d.ts +116 -0
- package/types/star-ng-ui-rating.d.ts +52 -0
- package/types/star-ng-ui-select-button.d.ts +169 -0
- package/types/star-ng-ui-select.d.ts +563 -0
- package/types/star-ng-ui-skeleton.d.ts +47 -0
- package/types/star-ng-ui-slider.d.ts +145 -0
- package/types/star-ng-ui-spinner.d.ts +29 -0
- package/types/star-ng-ui-stepper.d.ts +89 -0
- package/types/star-ng-ui-table.d.ts +885 -0
- package/types/star-ng-ui-tabs.d.ts +109 -0
- package/types/star-ng-ui-tag.d.ts +35 -0
- package/types/star-ng-ui-theme-switch.d.ts +36 -0
- package/types/star-ng-ui-theme.d.ts +95 -0
- package/types/star-ng-ui-toast.d.ts +84 -0
- package/types/star-ng-ui-toggle-switch.d.ts +81 -0
- package/types/star-ng-ui-tooltip.d.ts +66 -0
- package/types/star-ng-ui-transloco.d.ts +14 -0
- package/types/star-ng-ui-tree.d.ts +343 -0
- package/types/star-ng-ui-utility.d.ts +533 -0
- package/types/star-ng-ui.d.ts +51 -0
|
@@ -0,0 +1,886 @@
|
|
|
1
|
+
import { _IdGenerator } from "@angular/cdk/a11y";
|
|
2
|
+
import { CdkFixedSizeVirtualScroll, CdkVirtualForOf, CdkVirtualScrollViewport } from "@angular/cdk/scrolling";
|
|
3
|
+
import { NgTemplateOutlet } from "@angular/common";
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import { ChangeDetectionStrategy, Component, ElementRef, Injector, afterNextRender, booleanAttribute, computed, contentChild, effect, inject, input, model, output, signal, viewChild } from "@angular/core";
|
|
6
|
+
import { STAR_UI_TEXT, matchesFilter, optionText, readOption, starListAriaPosition, starListHeight, starListKeyboardTarget, starListLayout, starListPageSize, starListRevealOffset, starListRevealRows, starListRowRendered, starListTypeaheadIndex } from "@star-ng/ui/core";
|
|
7
|
+
import { StarOptionTemplate } from "@star-ng/ui/select";
|
|
8
|
+
var StarListbox = class StarListbox {
|
|
9
|
+
text = inject(STAR_UI_TEXT);
|
|
10
|
+
listId = inject(_IdGenerator).getId("star-listbox-");
|
|
11
|
+
value = model(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
12
|
+
options = input([], ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
|
|
13
|
+
optionLabel = input(null, ...ngDevMode ? [{ debugName: "optionLabel" }] : /* istanbul ignore next */ []);
|
|
14
|
+
optionValue = input(null, ...ngDevMode ? [{ debugName: "optionValue" }] : /* istanbul ignore next */ []);
|
|
15
|
+
optionDisabled = input(null, ...ngDevMode ? [{ debugName: "optionDisabled" }] : /* istanbul ignore next */ []);
|
|
16
|
+
optionGroup = input(null, ...ngDevMode ? [{ debugName: "optionGroup" }] : /* istanbul ignore next */ []);
|
|
17
|
+
multiple = input(false, {
|
|
18
|
+
...ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {},
|
|
19
|
+
transform: booleanAttribute
|
|
20
|
+
});
|
|
21
|
+
filter = input(false, {
|
|
22
|
+
...ngDevMode ? { debugName: "filter" } : /* istanbul ignore next */ {},
|
|
23
|
+
transform: booleanAttribute
|
|
24
|
+
});
|
|
25
|
+
scrollHeight = input("16rem", ...ngDevMode ? [{ debugName: "scrollHeight" }] : /* istanbul ignore next */ []);
|
|
26
|
+
virtualScroll = input(false, {
|
|
27
|
+
...ngDevMode ? { debugName: "virtualScroll" } : /* istanbul ignore next */ {},
|
|
28
|
+
transform: booleanAttribute
|
|
29
|
+
});
|
|
30
|
+
virtualItemSize = input(40, ...ngDevMode ? [{ debugName: "virtualItemSize" }] : /* istanbul ignore next */ []);
|
|
31
|
+
ariaLabel = input(null, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
32
|
+
disabled = input(false, {
|
|
33
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
34
|
+
transform: booleanAttribute
|
|
35
|
+
});
|
|
36
|
+
invalid = input(false, {
|
|
37
|
+
...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
|
|
38
|
+
transform: booleanAttribute
|
|
39
|
+
});
|
|
40
|
+
touched = input(false, {
|
|
41
|
+
...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
|
|
42
|
+
transform: booleanAttribute
|
|
43
|
+
});
|
|
44
|
+
touch = output();
|
|
45
|
+
optionTemplate = contentChild(StarOptionTemplate, ...ngDevMode ? [{ debugName: "optionTemplate" }] : /* istanbul ignore next */ []);
|
|
46
|
+
list = viewChild("list", {
|
|
47
|
+
...ngDevMode ? { debugName: "list" } : /* istanbul ignore next */ {},
|
|
48
|
+
read: ElementRef
|
|
49
|
+
});
|
|
50
|
+
viewport = viewChild(CdkVirtualScrollViewport, ...ngDevMode ? [{ debugName: "viewport" }] : /* istanbul ignore next */ []);
|
|
51
|
+
injector = inject(Injector);
|
|
52
|
+
query = signal("", ...ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []);
|
|
53
|
+
active = signal(-1, ...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
|
|
54
|
+
typeahead = "";
|
|
55
|
+
typeaheadAt = 0;
|
|
56
|
+
visible = computed(() => {
|
|
57
|
+
const options = this.options().filter((option) => matchesFilter(this.labelOf(option), this.query()));
|
|
58
|
+
if (!this.optionGroup()) return options;
|
|
59
|
+
const order = /* @__PURE__ */ new Map();
|
|
60
|
+
for (const option of options) {
|
|
61
|
+
const group = this.groupOf(option);
|
|
62
|
+
if (!order.has(group)) order.set(group, order.size);
|
|
63
|
+
}
|
|
64
|
+
return options.map((option, index) => ({
|
|
65
|
+
option,
|
|
66
|
+
index,
|
|
67
|
+
rank: order.get(this.groupOf(option)) ?? 0
|
|
68
|
+
})).sort((a, b) => a.rank - b.rank || a.index - b.index).map(({ option }) => option);
|
|
69
|
+
}, ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
|
|
70
|
+
groupOf(option) {
|
|
71
|
+
const key = this.optionGroup();
|
|
72
|
+
const group = key ? readOption(option, key) : null;
|
|
73
|
+
return group === null || group === void 0 ? "" : String(group);
|
|
74
|
+
}
|
|
75
|
+
groupHeading(index) {
|
|
76
|
+
if (!this.optionGroup()) return null;
|
|
77
|
+
const options = this.visible();
|
|
78
|
+
const group = this.groupOf(options[index]);
|
|
79
|
+
return index === 0 || this.groupOf(options[index - 1]) !== group ? group : null;
|
|
80
|
+
}
|
|
81
|
+
groupId(index) {
|
|
82
|
+
if (!this.optionGroup()) return null;
|
|
83
|
+
const options = this.visible();
|
|
84
|
+
let first = index;
|
|
85
|
+
while (first > 0 && this.groupOf(options[first - 1]) === this.groupOf(options[index])) first--;
|
|
86
|
+
return `${this.listId}-group-${first}`;
|
|
87
|
+
}
|
|
88
|
+
itemSize = computed(() => Math.max(1, this.virtualItemSize()), ...ngDevMode ? [{ debugName: "itemSize" }] : /* istanbul ignore next */ []);
|
|
89
|
+
layout = computed(() => starListLayout(this.visible(), this.optionGroup() ? (option) => this.groupOf(option) : null, this.listId), ...ngDevMode ? [{ debugName: "layout" }] : /* istanbul ignore next */ []);
|
|
90
|
+
viewportHeight = computed(() => starListHeight(this.scrollHeight(), this.layout().rows.length, this.itemSize()), ...ngDevMode ? [{ debugName: "viewportHeight" }] : /* istanbul ignore next */ []);
|
|
91
|
+
renderedRange = signal({
|
|
92
|
+
start: 0,
|
|
93
|
+
end: 0
|
|
94
|
+
}, ...ngDevMode ? [{ debugName: "renderedRange" }] : /* istanbul ignore next */ []);
|
|
95
|
+
trackRow = (_index, row) => row.key;
|
|
96
|
+
positionOf(index) {
|
|
97
|
+
return starListAriaPosition(index, this.visible().length);
|
|
98
|
+
}
|
|
99
|
+
describedBy(row) {
|
|
100
|
+
return row.groupId !== null && starListRowRendered(row.groupRow, this.renderedRange()) ? row.groupId : null;
|
|
101
|
+
}
|
|
102
|
+
activeId = computed(() => {
|
|
103
|
+
const index = this.active();
|
|
104
|
+
if (index < 0 || index >= this.visible().length) return null;
|
|
105
|
+
if (this.virtualScroll()) {
|
|
106
|
+
const row = this.layout().rowOfOption[index];
|
|
107
|
+
if (row === void 0 || !starListRowRendered(row, this.renderedRange())) return null;
|
|
108
|
+
}
|
|
109
|
+
return `${this.listId}-${index}`;
|
|
110
|
+
}, ...ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []);
|
|
111
|
+
constructor() {
|
|
112
|
+
effect((onCleanup) => {
|
|
113
|
+
const viewport = this.viewport();
|
|
114
|
+
if (!viewport) return;
|
|
115
|
+
const element = viewport.getElementRef().nativeElement;
|
|
116
|
+
this.renderedRange.set(viewport.getRenderedRange());
|
|
117
|
+
const range = viewport.renderedRangeStream.subscribe((next) => afterNextRender(() => this.renderedRange.set({ ...next }), { injector: this.injector }));
|
|
118
|
+
afterNextRender(() => element.querySelector(".cdk-virtual-scroll-content-wrapper")?.setAttribute("role", "presentation"), { injector: this.injector });
|
|
119
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => viewport.checkViewportSize());
|
|
120
|
+
observer?.observe(element);
|
|
121
|
+
onCleanup(() => {
|
|
122
|
+
range.unsubscribe();
|
|
123
|
+
observer?.disconnect();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
labelOf(option) {
|
|
128
|
+
return optionText(option, this.optionLabel());
|
|
129
|
+
}
|
|
130
|
+
isDisabled(option) {
|
|
131
|
+
const key = this.optionDisabled();
|
|
132
|
+
return key ? !!readOption(option, key) : false;
|
|
133
|
+
}
|
|
134
|
+
valueOf(option) {
|
|
135
|
+
return readOption(option, this.optionValue());
|
|
136
|
+
}
|
|
137
|
+
isSelected(option) {
|
|
138
|
+
const value = this.value();
|
|
139
|
+
const optionValue = this.valueOf(option);
|
|
140
|
+
return Array.isArray(value) ? value.some((v) => Object.is(v, optionValue)) : Object.is(value, optionValue);
|
|
141
|
+
}
|
|
142
|
+
firstSelectedOrZero() {
|
|
143
|
+
return Math.max(0, this.visible().findIndex((option) => this.isSelected(option)));
|
|
144
|
+
}
|
|
145
|
+
choose(option) {
|
|
146
|
+
if (this.disabled() || this.isDisabled(option)) return;
|
|
147
|
+
const optionValue = this.valueOf(option);
|
|
148
|
+
if (this.multiple()) {
|
|
149
|
+
const current = Array.isArray(this.value()) ? this.value() : [];
|
|
150
|
+
this.value.set(this.isSelected(option) ? current.filter((v) => !Object.is(v, optionValue)) : [...current, optionValue]);
|
|
151
|
+
} else this.value.set(optionValue);
|
|
152
|
+
}
|
|
153
|
+
onFilterInput(text) {
|
|
154
|
+
this.query.set(text);
|
|
155
|
+
this.active.set(0);
|
|
156
|
+
this.viewport()?.scrollToOffset(0);
|
|
157
|
+
}
|
|
158
|
+
onFocus() {
|
|
159
|
+
if (this.active() >= 0) return;
|
|
160
|
+
this.active.set(this.firstSelectedOrZero());
|
|
161
|
+
if (this.virtualScroll()) this.reveal(this.active());
|
|
162
|
+
}
|
|
163
|
+
reveal(index) {
|
|
164
|
+
if (!this.virtualScroll()) {
|
|
165
|
+
queueMicrotask(() => this.list()?.nativeElement.querySelector(`#${CSS.escape(this.activeId() ?? "")}`)?.scrollIntoView?.({ block: "nearest" }));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const viewport = this.viewport();
|
|
169
|
+
if (!viewport) return;
|
|
170
|
+
const [first, last] = starListRevealRows(this.layout(), index);
|
|
171
|
+
const offset = starListRevealOffset(first, last, this.itemSize(), viewport.measureScrollOffset(), viewport.getViewportSize());
|
|
172
|
+
if (offset !== null) viewport.scrollToOffset(offset);
|
|
173
|
+
}
|
|
174
|
+
onKeydown(event) {
|
|
175
|
+
const options = this.visible();
|
|
176
|
+
if (!options.length || this.disabled()) return;
|
|
177
|
+
const fromInput = event.target instanceof HTMLInputElement;
|
|
178
|
+
const page = starListPageSize(this.viewport()?.getViewportSize() || 256, this.itemSize());
|
|
179
|
+
const move = (key) => {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
this.active.set(typeof key === "number" ? key : starListKeyboardTarget(key, this.active(), options.length, page));
|
|
182
|
+
this.reveal(this.active());
|
|
183
|
+
if (!this.multiple() && !fromInput) {
|
|
184
|
+
const option = options[this.active()];
|
|
185
|
+
if (!this.isDisabled(option)) this.value.set(this.valueOf(option));
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
switch (event.key) {
|
|
189
|
+
case "ArrowDown":
|
|
190
|
+
case "ArrowUp": return move(event.key);
|
|
191
|
+
case "Home":
|
|
192
|
+
case "End":
|
|
193
|
+
if (fromInput) return;
|
|
194
|
+
return move(event.key);
|
|
195
|
+
case "PageDown":
|
|
196
|
+
case "PageUp":
|
|
197
|
+
if (fromInput || !this.virtualScroll()) return;
|
|
198
|
+
return move(event.key);
|
|
199
|
+
case " ":
|
|
200
|
+
case "Enter":
|
|
201
|
+
if (event.key === " " && fromInput) return;
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
if (options[this.active()] !== void 0) this.choose(options[this.active()]);
|
|
204
|
+
return;
|
|
205
|
+
default: if (event.key.length === 1 && !fromInput) {
|
|
206
|
+
const now = Date.now();
|
|
207
|
+
this.typeahead = (now - this.typeaheadAt > 500 ? "" : this.typeahead) + event.key.toLowerCase();
|
|
208
|
+
this.typeaheadAt = now;
|
|
209
|
+
const index = starListTypeaheadIndex(options.length, (i) => this.labelOf(options[i]), this.typeahead);
|
|
210
|
+
if (index >= 0) move(index);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
focus() {
|
|
215
|
+
this.list()?.nativeElement.focus();
|
|
216
|
+
}
|
|
217
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
218
|
+
minVersion: "12.0.0",
|
|
219
|
+
version: "22.2.6",
|
|
220
|
+
ngImport: i0,
|
|
221
|
+
type: StarListbox,
|
|
222
|
+
deps: [],
|
|
223
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
224
|
+
});
|
|
225
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
226
|
+
minVersion: "17.0.0",
|
|
227
|
+
version: "22.2.6",
|
|
228
|
+
type: StarListbox,
|
|
229
|
+
isStandalone: true,
|
|
230
|
+
selector: "star-listbox",
|
|
231
|
+
inputs: {
|
|
232
|
+
value: {
|
|
233
|
+
classPropertyName: "value",
|
|
234
|
+
publicName: "value",
|
|
235
|
+
isSignal: true,
|
|
236
|
+
isRequired: false,
|
|
237
|
+
transformFunction: null
|
|
238
|
+
},
|
|
239
|
+
options: {
|
|
240
|
+
classPropertyName: "options",
|
|
241
|
+
publicName: "options",
|
|
242
|
+
isSignal: true,
|
|
243
|
+
isRequired: false,
|
|
244
|
+
transformFunction: null
|
|
245
|
+
},
|
|
246
|
+
optionLabel: {
|
|
247
|
+
classPropertyName: "optionLabel",
|
|
248
|
+
publicName: "optionLabel",
|
|
249
|
+
isSignal: true,
|
|
250
|
+
isRequired: false,
|
|
251
|
+
transformFunction: null
|
|
252
|
+
},
|
|
253
|
+
optionValue: {
|
|
254
|
+
classPropertyName: "optionValue",
|
|
255
|
+
publicName: "optionValue",
|
|
256
|
+
isSignal: true,
|
|
257
|
+
isRequired: false,
|
|
258
|
+
transformFunction: null
|
|
259
|
+
},
|
|
260
|
+
optionDisabled: {
|
|
261
|
+
classPropertyName: "optionDisabled",
|
|
262
|
+
publicName: "optionDisabled",
|
|
263
|
+
isSignal: true,
|
|
264
|
+
isRequired: false,
|
|
265
|
+
transformFunction: null
|
|
266
|
+
},
|
|
267
|
+
optionGroup: {
|
|
268
|
+
classPropertyName: "optionGroup",
|
|
269
|
+
publicName: "optionGroup",
|
|
270
|
+
isSignal: true,
|
|
271
|
+
isRequired: false,
|
|
272
|
+
transformFunction: null
|
|
273
|
+
},
|
|
274
|
+
multiple: {
|
|
275
|
+
classPropertyName: "multiple",
|
|
276
|
+
publicName: "multiple",
|
|
277
|
+
isSignal: true,
|
|
278
|
+
isRequired: false,
|
|
279
|
+
transformFunction: null
|
|
280
|
+
},
|
|
281
|
+
filter: {
|
|
282
|
+
classPropertyName: "filter",
|
|
283
|
+
publicName: "filter",
|
|
284
|
+
isSignal: true,
|
|
285
|
+
isRequired: false,
|
|
286
|
+
transformFunction: null
|
|
287
|
+
},
|
|
288
|
+
scrollHeight: {
|
|
289
|
+
classPropertyName: "scrollHeight",
|
|
290
|
+
publicName: "scrollHeight",
|
|
291
|
+
isSignal: true,
|
|
292
|
+
isRequired: false,
|
|
293
|
+
transformFunction: null
|
|
294
|
+
},
|
|
295
|
+
virtualScroll: {
|
|
296
|
+
classPropertyName: "virtualScroll",
|
|
297
|
+
publicName: "virtualScroll",
|
|
298
|
+
isSignal: true,
|
|
299
|
+
isRequired: false,
|
|
300
|
+
transformFunction: null
|
|
301
|
+
},
|
|
302
|
+
virtualItemSize: {
|
|
303
|
+
classPropertyName: "virtualItemSize",
|
|
304
|
+
publicName: "virtualItemSize",
|
|
305
|
+
isSignal: true,
|
|
306
|
+
isRequired: false,
|
|
307
|
+
transformFunction: null
|
|
308
|
+
},
|
|
309
|
+
ariaLabel: {
|
|
310
|
+
classPropertyName: "ariaLabel",
|
|
311
|
+
publicName: "ariaLabel",
|
|
312
|
+
isSignal: true,
|
|
313
|
+
isRequired: false,
|
|
314
|
+
transformFunction: null
|
|
315
|
+
},
|
|
316
|
+
disabled: {
|
|
317
|
+
classPropertyName: "disabled",
|
|
318
|
+
publicName: "disabled",
|
|
319
|
+
isSignal: true,
|
|
320
|
+
isRequired: false,
|
|
321
|
+
transformFunction: null
|
|
322
|
+
},
|
|
323
|
+
invalid: {
|
|
324
|
+
classPropertyName: "invalid",
|
|
325
|
+
publicName: "invalid",
|
|
326
|
+
isSignal: true,
|
|
327
|
+
isRequired: false,
|
|
328
|
+
transformFunction: null
|
|
329
|
+
},
|
|
330
|
+
touched: {
|
|
331
|
+
classPropertyName: "touched",
|
|
332
|
+
publicName: "touched",
|
|
333
|
+
isSignal: true,
|
|
334
|
+
isRequired: false,
|
|
335
|
+
transformFunction: null
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
outputs: {
|
|
339
|
+
value: "valueChange",
|
|
340
|
+
touch: "touch"
|
|
341
|
+
},
|
|
342
|
+
host: {
|
|
343
|
+
properties: {
|
|
344
|
+
"class.star-listbox-box--disabled": "disabled()",
|
|
345
|
+
"class.star-listbox-box--invalid": "invalid() && touched()"
|
|
346
|
+
},
|
|
347
|
+
classAttribute: "star-listbox-box"
|
|
348
|
+
},
|
|
349
|
+
queries: [{
|
|
350
|
+
propertyName: "optionTemplate",
|
|
351
|
+
first: true,
|
|
352
|
+
predicate: StarOptionTemplate,
|
|
353
|
+
descendants: true,
|
|
354
|
+
isSignal: true
|
|
355
|
+
}],
|
|
356
|
+
viewQueries: [{
|
|
357
|
+
propertyName: "list",
|
|
358
|
+
first: true,
|
|
359
|
+
predicate: ["list"],
|
|
360
|
+
descendants: true,
|
|
361
|
+
read: ElementRef,
|
|
362
|
+
isSignal: true
|
|
363
|
+
}, {
|
|
364
|
+
propertyName: "viewport",
|
|
365
|
+
first: true,
|
|
366
|
+
predicate: CdkVirtualScrollViewport,
|
|
367
|
+
descendants: true,
|
|
368
|
+
isSignal: true
|
|
369
|
+
}],
|
|
370
|
+
ngImport: i0,
|
|
371
|
+
template: `
|
|
372
|
+
@if (filter()) {
|
|
373
|
+
<div class="star-panel__filter">
|
|
374
|
+
<i class="ph-bold ph-magnifying-glass" aria-hidden="true"></i>
|
|
375
|
+
<input
|
|
376
|
+
#filterInput
|
|
377
|
+
type="search"
|
|
378
|
+
class="star-input star-input--sm"
|
|
379
|
+
autocomplete="off"
|
|
380
|
+
[attr.aria-label]="text.filterPlaceholder"
|
|
381
|
+
[attr.aria-controls]="listId"
|
|
382
|
+
[placeholder]="text.filterPlaceholder"
|
|
383
|
+
[value]="query()"
|
|
384
|
+
(input)="onFilterInput(filterInput.value)"
|
|
385
|
+
(keydown)="onKeydown($event)"
|
|
386
|
+
/>
|
|
387
|
+
</div>
|
|
388
|
+
}
|
|
389
|
+
@if (virtualScroll()) {
|
|
390
|
+
<!-- Virtual scroll: the CDK viewport is the listbox. Group headings and options are rows of one height. -->
|
|
391
|
+
<cdk-virtual-scroll-viewport
|
|
392
|
+
#list
|
|
393
|
+
class="star-listbox star-listbox--virtual star-listbox--viewport"
|
|
394
|
+
role="listbox"
|
|
395
|
+
[id]="listId"
|
|
396
|
+
[itemSize]="itemSize()"
|
|
397
|
+
[minBufferPx]="itemSize() * 4"
|
|
398
|
+
[maxBufferPx]="itemSize() * 8"
|
|
399
|
+
[attr.tabindex]="disabled() ? -1 : 0"
|
|
400
|
+
[attr.aria-label]="ariaLabel()"
|
|
401
|
+
[attr.aria-multiselectable]="multiple() || null"
|
|
402
|
+
[attr.aria-activedescendant]="activeId()"
|
|
403
|
+
[attr.aria-disabled]="disabled() || null"
|
|
404
|
+
[style.--star-item-size.px]="itemSize()"
|
|
405
|
+
[style.height]="viewportHeight()"
|
|
406
|
+
(keydown)="onKeydown($event)"
|
|
407
|
+
(focus)="onFocus()"
|
|
408
|
+
(blur)="touch.emit()"
|
|
409
|
+
>
|
|
410
|
+
<ng-container *cdkVirtualFor="let row of layout().rows; trackBy: trackRow">
|
|
411
|
+
@if (row.kind === 'group') {
|
|
412
|
+
<div class="star-listbox__group" role="presentation" [id]="row.id">
|
|
413
|
+
{{ row.label }}
|
|
414
|
+
</div>
|
|
415
|
+
} @else {
|
|
416
|
+
@let option = row.option;
|
|
417
|
+
@let i = row.index;
|
|
418
|
+
@let position = positionOf(i);
|
|
419
|
+
<!-- Keyboard is handled on the listbox via aria-activedescendant. -->
|
|
420
|
+
<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->
|
|
421
|
+
<div
|
|
422
|
+
class="star-listbox__option"
|
|
423
|
+
role="option"
|
|
424
|
+
[id]="listId + '-' + i"
|
|
425
|
+
[class.star-listbox__option--active]="active() === i"
|
|
426
|
+
[class.star-listbox__option--selected]="isSelected(option)"
|
|
427
|
+
[attr.aria-selected]="isSelected(option)"
|
|
428
|
+
[attr.aria-disabled]="isDisabled(option) || null"
|
|
429
|
+
[attr.aria-describedby]="describedBy(row)"
|
|
430
|
+
[attr.aria-setsize]="position.setsize"
|
|
431
|
+
[attr.aria-posinset]="position.posinset"
|
|
432
|
+
(click)="active.set(i); choose(option)"
|
|
433
|
+
>
|
|
434
|
+
@if (multiple()) {
|
|
435
|
+
<span class="star-check__box" aria-hidden="true">
|
|
436
|
+
@if (isSelected(option)) {
|
|
437
|
+
<i class="ph-bold ph-check"></i>
|
|
438
|
+
}
|
|
439
|
+
</span>
|
|
440
|
+
}
|
|
441
|
+
<span class="star-listbox__label">
|
|
442
|
+
@if (optionTemplate(); as custom) {
|
|
443
|
+
<ng-container
|
|
444
|
+
*ngTemplateOutlet="
|
|
445
|
+
custom.template;
|
|
446
|
+
context: { $implicit: option, selected: isSelected(option), index: i }
|
|
447
|
+
"
|
|
448
|
+
/>
|
|
449
|
+
} @else {
|
|
450
|
+
{{ labelOf(option) }}
|
|
451
|
+
}
|
|
452
|
+
</span>
|
|
453
|
+
</div>
|
|
454
|
+
}
|
|
455
|
+
</ng-container>
|
|
456
|
+
</cdk-virtual-scroll-viewport>
|
|
457
|
+
@if (!visible().length) {
|
|
458
|
+
<div class="star-listbox__empty" role="presentation">{{ text.emptyFilterMessage }}</div>
|
|
459
|
+
}
|
|
460
|
+
} @else {
|
|
461
|
+
<ul
|
|
462
|
+
#list
|
|
463
|
+
class="star-listbox"
|
|
464
|
+
role="listbox"
|
|
465
|
+
[id]="listId"
|
|
466
|
+
[attr.tabindex]="disabled() ? -1 : 0"
|
|
467
|
+
[attr.aria-label]="ariaLabel()"
|
|
468
|
+
[attr.aria-multiselectable]="multiple() || null"
|
|
469
|
+
[attr.aria-activedescendant]="activeId()"
|
|
470
|
+
[attr.aria-disabled]="disabled() || null"
|
|
471
|
+
[style.max-height]="scrollHeight()"
|
|
472
|
+
(keydown)="onKeydown($event)"
|
|
473
|
+
(focus)="onFocus()"
|
|
474
|
+
(blur)="touch.emit()"
|
|
475
|
+
>
|
|
476
|
+
@for (option of visible(); track $index; let i = $index) {
|
|
477
|
+
@if (groupHeading(i); as heading) {
|
|
478
|
+
<li class="star-listbox__group" role="presentation" [id]="groupId(i)">{{ heading }}</li>
|
|
479
|
+
}
|
|
480
|
+
<!-- Keyboard is handled on the listbox via aria-activedescendant. -->
|
|
481
|
+
<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->
|
|
482
|
+
<li
|
|
483
|
+
class="star-listbox__option"
|
|
484
|
+
role="option"
|
|
485
|
+
[id]="listId + '-' + i"
|
|
486
|
+
[class.star-listbox__option--active]="active() === i"
|
|
487
|
+
[class.star-listbox__option--selected]="isSelected(option)"
|
|
488
|
+
[attr.aria-selected]="isSelected(option)"
|
|
489
|
+
[attr.aria-disabled]="isDisabled(option) || null"
|
|
490
|
+
[attr.aria-describedby]="groupId(i)"
|
|
491
|
+
(click)="active.set(i); choose(option)"
|
|
492
|
+
>
|
|
493
|
+
@if (multiple()) {
|
|
494
|
+
<span class="star-check__box" aria-hidden="true">
|
|
495
|
+
@if (isSelected(option)) {
|
|
496
|
+
<i class="ph-bold ph-check"></i>
|
|
497
|
+
}
|
|
498
|
+
</span>
|
|
499
|
+
}
|
|
500
|
+
<span class="star-listbox__label">
|
|
501
|
+
@if (optionTemplate(); as custom) {
|
|
502
|
+
<ng-container
|
|
503
|
+
*ngTemplateOutlet="
|
|
504
|
+
custom.template;
|
|
505
|
+
context: { $implicit: option, selected: isSelected(option), index: i }
|
|
506
|
+
"
|
|
507
|
+
/>
|
|
508
|
+
} @else {
|
|
509
|
+
{{ labelOf(option) }}
|
|
510
|
+
}
|
|
511
|
+
</span>
|
|
512
|
+
</li>
|
|
513
|
+
}
|
|
514
|
+
</ul>
|
|
515
|
+
<!-- Outside the listbox: a listbox may contain options and groups only. -->
|
|
516
|
+
@if (!visible().length) {
|
|
517
|
+
<div class="star-listbox__empty" role="presentation">{{ text.emptyFilterMessage }}</div>
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
`,
|
|
521
|
+
isInline: true,
|
|
522
|
+
dependencies: [
|
|
523
|
+
{
|
|
524
|
+
kind: "directive",
|
|
525
|
+
type: NgTemplateOutlet,
|
|
526
|
+
selector: "[ngTemplateOutlet]",
|
|
527
|
+
inputs: [
|
|
528
|
+
"ngTemplateOutletContext",
|
|
529
|
+
"ngTemplateOutlet",
|
|
530
|
+
"ngTemplateOutletInjector"
|
|
531
|
+
]
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
kind: "component",
|
|
535
|
+
type: CdkVirtualScrollViewport,
|
|
536
|
+
selector: "cdk-virtual-scroll-viewport",
|
|
537
|
+
inputs: ["orientation", "appendOnly"],
|
|
538
|
+
outputs: ["scrolledIndexChange"]
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
kind: "directive",
|
|
542
|
+
type: CdkFixedSizeVirtualScroll,
|
|
543
|
+
selector: "cdk-virtual-scroll-viewport[itemSize]",
|
|
544
|
+
inputs: [
|
|
545
|
+
"itemSize",
|
|
546
|
+
"minBufferPx",
|
|
547
|
+
"maxBufferPx"
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
kind: "directive",
|
|
552
|
+
type: CdkVirtualForOf,
|
|
553
|
+
selector: "[cdkVirtualFor][cdkVirtualForOf]",
|
|
554
|
+
inputs: [
|
|
555
|
+
"cdkVirtualForOf",
|
|
556
|
+
"cdkVirtualForTrackBy",
|
|
557
|
+
"cdkVirtualForTemplate",
|
|
558
|
+
"cdkVirtualForTemplateCacheSize"
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
],
|
|
562
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
563
|
+
});
|
|
564
|
+
};
|
|
565
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
566
|
+
minVersion: "12.0.0",
|
|
567
|
+
version: "22.2.6",
|
|
568
|
+
ngImport: i0,
|
|
569
|
+
type: StarListbox,
|
|
570
|
+
decorators: [{
|
|
571
|
+
type: Component,
|
|
572
|
+
args: [{
|
|
573
|
+
selector: "star-listbox",
|
|
574
|
+
imports: [
|
|
575
|
+
NgTemplateOutlet,
|
|
576
|
+
CdkVirtualScrollViewport,
|
|
577
|
+
CdkFixedSizeVirtualScroll,
|
|
578
|
+
CdkVirtualForOf
|
|
579
|
+
],
|
|
580
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
581
|
+
host: {
|
|
582
|
+
class: "star-listbox-box",
|
|
583
|
+
"[class.star-listbox-box--disabled]": "disabled()",
|
|
584
|
+
"[class.star-listbox-box--invalid]": "invalid() && touched()"
|
|
585
|
+
},
|
|
586
|
+
template: `
|
|
587
|
+
@if (filter()) {
|
|
588
|
+
<div class="star-panel__filter">
|
|
589
|
+
<i class="ph-bold ph-magnifying-glass" aria-hidden="true"></i>
|
|
590
|
+
<input
|
|
591
|
+
#filterInput
|
|
592
|
+
type="search"
|
|
593
|
+
class="star-input star-input--sm"
|
|
594
|
+
autocomplete="off"
|
|
595
|
+
[attr.aria-label]="text.filterPlaceholder"
|
|
596
|
+
[attr.aria-controls]="listId"
|
|
597
|
+
[placeholder]="text.filterPlaceholder"
|
|
598
|
+
[value]="query()"
|
|
599
|
+
(input)="onFilterInput(filterInput.value)"
|
|
600
|
+
(keydown)="onKeydown($event)"
|
|
601
|
+
/>
|
|
602
|
+
</div>
|
|
603
|
+
}
|
|
604
|
+
@if (virtualScroll()) {
|
|
605
|
+
<!-- Virtual scroll: the CDK viewport is the listbox. Group headings and options are rows of one height. -->
|
|
606
|
+
<cdk-virtual-scroll-viewport
|
|
607
|
+
#list
|
|
608
|
+
class="star-listbox star-listbox--virtual star-listbox--viewport"
|
|
609
|
+
role="listbox"
|
|
610
|
+
[id]="listId"
|
|
611
|
+
[itemSize]="itemSize()"
|
|
612
|
+
[minBufferPx]="itemSize() * 4"
|
|
613
|
+
[maxBufferPx]="itemSize() * 8"
|
|
614
|
+
[attr.tabindex]="disabled() ? -1 : 0"
|
|
615
|
+
[attr.aria-label]="ariaLabel()"
|
|
616
|
+
[attr.aria-multiselectable]="multiple() || null"
|
|
617
|
+
[attr.aria-activedescendant]="activeId()"
|
|
618
|
+
[attr.aria-disabled]="disabled() || null"
|
|
619
|
+
[style.--star-item-size.px]="itemSize()"
|
|
620
|
+
[style.height]="viewportHeight()"
|
|
621
|
+
(keydown)="onKeydown($event)"
|
|
622
|
+
(focus)="onFocus()"
|
|
623
|
+
(blur)="touch.emit()"
|
|
624
|
+
>
|
|
625
|
+
<ng-container *cdkVirtualFor="let row of layout().rows; trackBy: trackRow">
|
|
626
|
+
@if (row.kind === 'group') {
|
|
627
|
+
<div class="star-listbox__group" role="presentation" [id]="row.id">
|
|
628
|
+
{{ row.label }}
|
|
629
|
+
</div>
|
|
630
|
+
} @else {
|
|
631
|
+
@let option = row.option;
|
|
632
|
+
@let i = row.index;
|
|
633
|
+
@let position = positionOf(i);
|
|
634
|
+
<!-- Keyboard is handled on the listbox via aria-activedescendant. -->
|
|
635
|
+
<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->
|
|
636
|
+
<div
|
|
637
|
+
class="star-listbox__option"
|
|
638
|
+
role="option"
|
|
639
|
+
[id]="listId + '-' + i"
|
|
640
|
+
[class.star-listbox__option--active]="active() === i"
|
|
641
|
+
[class.star-listbox__option--selected]="isSelected(option)"
|
|
642
|
+
[attr.aria-selected]="isSelected(option)"
|
|
643
|
+
[attr.aria-disabled]="isDisabled(option) || null"
|
|
644
|
+
[attr.aria-describedby]="describedBy(row)"
|
|
645
|
+
[attr.aria-setsize]="position.setsize"
|
|
646
|
+
[attr.aria-posinset]="position.posinset"
|
|
647
|
+
(click)="active.set(i); choose(option)"
|
|
648
|
+
>
|
|
649
|
+
@if (multiple()) {
|
|
650
|
+
<span class="star-check__box" aria-hidden="true">
|
|
651
|
+
@if (isSelected(option)) {
|
|
652
|
+
<i class="ph-bold ph-check"></i>
|
|
653
|
+
}
|
|
654
|
+
</span>
|
|
655
|
+
}
|
|
656
|
+
<span class="star-listbox__label">
|
|
657
|
+
@if (optionTemplate(); as custom) {
|
|
658
|
+
<ng-container
|
|
659
|
+
*ngTemplateOutlet="
|
|
660
|
+
custom.template;
|
|
661
|
+
context: { $implicit: option, selected: isSelected(option), index: i }
|
|
662
|
+
"
|
|
663
|
+
/>
|
|
664
|
+
} @else {
|
|
665
|
+
{{ labelOf(option) }}
|
|
666
|
+
}
|
|
667
|
+
</span>
|
|
668
|
+
</div>
|
|
669
|
+
}
|
|
670
|
+
</ng-container>
|
|
671
|
+
</cdk-virtual-scroll-viewport>
|
|
672
|
+
@if (!visible().length) {
|
|
673
|
+
<div class="star-listbox__empty" role="presentation">{{ text.emptyFilterMessage }}</div>
|
|
674
|
+
}
|
|
675
|
+
} @else {
|
|
676
|
+
<ul
|
|
677
|
+
#list
|
|
678
|
+
class="star-listbox"
|
|
679
|
+
role="listbox"
|
|
680
|
+
[id]="listId"
|
|
681
|
+
[attr.tabindex]="disabled() ? -1 : 0"
|
|
682
|
+
[attr.aria-label]="ariaLabel()"
|
|
683
|
+
[attr.aria-multiselectable]="multiple() || null"
|
|
684
|
+
[attr.aria-activedescendant]="activeId()"
|
|
685
|
+
[attr.aria-disabled]="disabled() || null"
|
|
686
|
+
[style.max-height]="scrollHeight()"
|
|
687
|
+
(keydown)="onKeydown($event)"
|
|
688
|
+
(focus)="onFocus()"
|
|
689
|
+
(blur)="touch.emit()"
|
|
690
|
+
>
|
|
691
|
+
@for (option of visible(); track $index; let i = $index) {
|
|
692
|
+
@if (groupHeading(i); as heading) {
|
|
693
|
+
<li class="star-listbox__group" role="presentation" [id]="groupId(i)">{{ heading }}</li>
|
|
694
|
+
}
|
|
695
|
+
<!-- Keyboard is handled on the listbox via aria-activedescendant. -->
|
|
696
|
+
<!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->
|
|
697
|
+
<li
|
|
698
|
+
class="star-listbox__option"
|
|
699
|
+
role="option"
|
|
700
|
+
[id]="listId + '-' + i"
|
|
701
|
+
[class.star-listbox__option--active]="active() === i"
|
|
702
|
+
[class.star-listbox__option--selected]="isSelected(option)"
|
|
703
|
+
[attr.aria-selected]="isSelected(option)"
|
|
704
|
+
[attr.aria-disabled]="isDisabled(option) || null"
|
|
705
|
+
[attr.aria-describedby]="groupId(i)"
|
|
706
|
+
(click)="active.set(i); choose(option)"
|
|
707
|
+
>
|
|
708
|
+
@if (multiple()) {
|
|
709
|
+
<span class="star-check__box" aria-hidden="true">
|
|
710
|
+
@if (isSelected(option)) {
|
|
711
|
+
<i class="ph-bold ph-check"></i>
|
|
712
|
+
}
|
|
713
|
+
</span>
|
|
714
|
+
}
|
|
715
|
+
<span class="star-listbox__label">
|
|
716
|
+
@if (optionTemplate(); as custom) {
|
|
717
|
+
<ng-container
|
|
718
|
+
*ngTemplateOutlet="
|
|
719
|
+
custom.template;
|
|
720
|
+
context: { $implicit: option, selected: isSelected(option), index: i }
|
|
721
|
+
"
|
|
722
|
+
/>
|
|
723
|
+
} @else {
|
|
724
|
+
{{ labelOf(option) }}
|
|
725
|
+
}
|
|
726
|
+
</span>
|
|
727
|
+
</li>
|
|
728
|
+
}
|
|
729
|
+
</ul>
|
|
730
|
+
<!-- Outside the listbox: a listbox may contain options and groups only. -->
|
|
731
|
+
@if (!visible().length) {
|
|
732
|
+
<div class="star-listbox__empty" role="presentation">{{ text.emptyFilterMessage }}</div>
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
`
|
|
736
|
+
}]
|
|
737
|
+
}],
|
|
738
|
+
ctorParameters: () => [],
|
|
739
|
+
propDecorators: {
|
|
740
|
+
value: [{
|
|
741
|
+
type: i0.Input,
|
|
742
|
+
args: [{
|
|
743
|
+
isSignal: true,
|
|
744
|
+
alias: "value",
|
|
745
|
+
required: false
|
|
746
|
+
}]
|
|
747
|
+
}, {
|
|
748
|
+
type: i0.Output,
|
|
749
|
+
args: ["valueChange"]
|
|
750
|
+
}],
|
|
751
|
+
options: [{
|
|
752
|
+
type: i0.Input,
|
|
753
|
+
args: [{
|
|
754
|
+
isSignal: true,
|
|
755
|
+
alias: "options",
|
|
756
|
+
required: false
|
|
757
|
+
}]
|
|
758
|
+
}],
|
|
759
|
+
optionLabel: [{
|
|
760
|
+
type: i0.Input,
|
|
761
|
+
args: [{
|
|
762
|
+
isSignal: true,
|
|
763
|
+
alias: "optionLabel",
|
|
764
|
+
required: false
|
|
765
|
+
}]
|
|
766
|
+
}],
|
|
767
|
+
optionValue: [{
|
|
768
|
+
type: i0.Input,
|
|
769
|
+
args: [{
|
|
770
|
+
isSignal: true,
|
|
771
|
+
alias: "optionValue",
|
|
772
|
+
required: false
|
|
773
|
+
}]
|
|
774
|
+
}],
|
|
775
|
+
optionDisabled: [{
|
|
776
|
+
type: i0.Input,
|
|
777
|
+
args: [{
|
|
778
|
+
isSignal: true,
|
|
779
|
+
alias: "optionDisabled",
|
|
780
|
+
required: false
|
|
781
|
+
}]
|
|
782
|
+
}],
|
|
783
|
+
optionGroup: [{
|
|
784
|
+
type: i0.Input,
|
|
785
|
+
args: [{
|
|
786
|
+
isSignal: true,
|
|
787
|
+
alias: "optionGroup",
|
|
788
|
+
required: false
|
|
789
|
+
}]
|
|
790
|
+
}],
|
|
791
|
+
multiple: [{
|
|
792
|
+
type: i0.Input,
|
|
793
|
+
args: [{
|
|
794
|
+
isSignal: true,
|
|
795
|
+
alias: "multiple",
|
|
796
|
+
required: false
|
|
797
|
+
}]
|
|
798
|
+
}],
|
|
799
|
+
filter: [{
|
|
800
|
+
type: i0.Input,
|
|
801
|
+
args: [{
|
|
802
|
+
isSignal: true,
|
|
803
|
+
alias: "filter",
|
|
804
|
+
required: false
|
|
805
|
+
}]
|
|
806
|
+
}],
|
|
807
|
+
scrollHeight: [{
|
|
808
|
+
type: i0.Input,
|
|
809
|
+
args: [{
|
|
810
|
+
isSignal: true,
|
|
811
|
+
alias: "scrollHeight",
|
|
812
|
+
required: false
|
|
813
|
+
}]
|
|
814
|
+
}],
|
|
815
|
+
virtualScroll: [{
|
|
816
|
+
type: i0.Input,
|
|
817
|
+
args: [{
|
|
818
|
+
isSignal: true,
|
|
819
|
+
alias: "virtualScroll",
|
|
820
|
+
required: false
|
|
821
|
+
}]
|
|
822
|
+
}],
|
|
823
|
+
virtualItemSize: [{
|
|
824
|
+
type: i0.Input,
|
|
825
|
+
args: [{
|
|
826
|
+
isSignal: true,
|
|
827
|
+
alias: "virtualItemSize",
|
|
828
|
+
required: false
|
|
829
|
+
}]
|
|
830
|
+
}],
|
|
831
|
+
ariaLabel: [{
|
|
832
|
+
type: i0.Input,
|
|
833
|
+
args: [{
|
|
834
|
+
isSignal: true,
|
|
835
|
+
alias: "ariaLabel",
|
|
836
|
+
required: false
|
|
837
|
+
}]
|
|
838
|
+
}],
|
|
839
|
+
disabled: [{
|
|
840
|
+
type: i0.Input,
|
|
841
|
+
args: [{
|
|
842
|
+
isSignal: true,
|
|
843
|
+
alias: "disabled",
|
|
844
|
+
required: false
|
|
845
|
+
}]
|
|
846
|
+
}],
|
|
847
|
+
invalid: [{
|
|
848
|
+
type: i0.Input,
|
|
849
|
+
args: [{
|
|
850
|
+
isSignal: true,
|
|
851
|
+
alias: "invalid",
|
|
852
|
+
required: false
|
|
853
|
+
}]
|
|
854
|
+
}],
|
|
855
|
+
touched: [{
|
|
856
|
+
type: i0.Input,
|
|
857
|
+
args: [{
|
|
858
|
+
isSignal: true,
|
|
859
|
+
alias: "touched",
|
|
860
|
+
required: false
|
|
861
|
+
}]
|
|
862
|
+
}],
|
|
863
|
+
touch: [{
|
|
864
|
+
type: i0.Output,
|
|
865
|
+
args: ["touch"]
|
|
866
|
+
}],
|
|
867
|
+
optionTemplate: [{
|
|
868
|
+
type: i0.ContentChild,
|
|
869
|
+
args: [i0.forwardRef(() => StarOptionTemplate), { isSignal: true }]
|
|
870
|
+
}],
|
|
871
|
+
list: [{
|
|
872
|
+
type: i0.ViewChild,
|
|
873
|
+
args: ["list", {
|
|
874
|
+
read: ElementRef,
|
|
875
|
+
isSignal: true
|
|
876
|
+
}]
|
|
877
|
+
}],
|
|
878
|
+
viewport: [{
|
|
879
|
+
type: i0.ViewChild,
|
|
880
|
+
args: [i0.forwardRef(() => CdkVirtualScrollViewport), { isSignal: true }]
|
|
881
|
+
}]
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
export { StarListbox };
|
|
885
|
+
|
|
886
|
+
//# sourceMappingURL=star-ng-ui-listbox.mjs.map
|