@su-labs/select 19.0.0 → 22.0.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.
@@ -1,306 +1,511 @@
1
- import { DOCUMENT } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { input, model, booleanAttribute, output, computed, signal, inject, ElementRef, viewChild, DestroyRef, effect, untracked, afterRenderEffect, ChangeDetectionStrategy, Component } from '@angular/core';
4
- import { SU_SELECT_LABELS, SuSelectController, suSelectGroups } from '@su-labs/core/select';
5
- import { suTooltipPosition } from '@su-labs/core/tooltip';
6
-
1
+ import { DOCUMENT } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, afterRenderEffect, booleanAttribute, computed, effect, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
4
+ import { SU_SELECT_LABELS, SuSelectController, suSelectGroups } from "@su-labs/core/select";
5
+ import { suTooltipPosition } from "@su-labs/core/tooltip";
7
6
  let nextSelectId = 0;
8
7
  const MOVES = {
9
- ArrowDown: 'next',
10
- ArrowUp: 'previous',
11
- Home: 'first',
12
- End: 'last',
13
- PageDown: 'last',
14
- PageUp: 'first',
8
+ ArrowDown: "next",
9
+ ArrowUp: "previous",
10
+ Home: "first",
11
+ End: "last",
12
+ PageDown: "last",
13
+ PageUp: "first"
15
14
  };
16
- /**
17
- * A select over `SuSelectController` from `@su-labs/core/select`, with its own styled list instead of the browser's
18
- * popup: `<su-lib-select [options]="sizes" [(value)]="size" />`. The trigger is a `combobox` button and the list a
19
- * `listbox` in the top layer (`popover`), placed below the trigger or above it when there's no room. It follows the
20
- * WAI-ARIA select-only combobox pattern: arrows, Home and End, type-ahead, Enter or Space to choose, Escape to close
21
- * and Tab to choose and move on. With `searchable`, a search field at the top of the list filters the options.
22
- */
23
- class SuSelectComponent {
24
- /** The choices: `{ value, label, disabled?, group? }`; options sharing a `group` should follow one another */
25
- options = input([]);
26
- /** The chosen value, or `null` while nothing is chosen */
27
- value = model(null);
28
- /** Whether the list is open; setting it opens or closes it */
29
- open = model(false);
30
- /** Set once focus has left the select, for forms that show errors after the user moved on */
31
- touched = model(false);
32
- /** A search field at the top of the list that filters the options @default false */
33
- searchable = input(false, { transform: booleanAttribute });
34
- /** Can't be opened or focused @default false */
35
- disabled = input(false, { transform: booleanAttribute });
36
- /** Opens with a short fade and slide; off when the user prefers less motion @default true */
37
- animated = input(true, { transform: booleanAttribute });
38
- /** Shown while nothing is chosen @default labels.placeholder */
39
- placeholder = input();
40
- /** The select's name for screen readers, when no `<label>` wraps it and no `ariaLabelledby` names it */
41
- ariaLabel = input();
42
- /** The id of the element that names the select */
43
- ariaLabelledby = input();
44
- /** Texts to replace, e.g. in the page's language */
45
- labels = input({});
46
- /** The user chose an option (never emitted for a value set from outside): its value */
47
- chosen = output();
48
- id = `su-select-${nextSelectId++}`;
49
- listId = `${this.id}-list`;
50
- texts = computed(() => ({
51
- ...SU_SELECT_LABELS,
52
- ...this.labels(),
53
- }));
54
- controller = new SuSelectController();
55
- state = signal(this.controller.state.get());
56
- groups = computed(() => suSelectGroups(this.state().visible));
57
- selected = computed(() => {
58
- this.state();
59
- return this.controller.selected;
60
- });
61
- activeId = computed(() => {
62
- const { open, active } = this.state();
63
- return open && active >= 0 ? this.optionId(active) : null;
64
- });
65
- host = inject(ElementRef);
66
- document = inject(DOCUMENT);
67
- trigger = viewChild.required('trigger');
68
- panel = viewChild.required('panel');
69
- search = viewChild('search');
70
- constructor() {
71
- let previous = this.controller.state.get();
72
- const unsubscribe = this.controller.state.subscribe(state => {
73
- this.state.set(state);
74
- if (state.value !== previous.value) {
75
- this.value.set(state.value);
76
- }
77
- if (state.open !== previous.open) {
78
- this.open.set(state.open);
79
- }
80
- previous = state;
81
- });
82
- inject(DestroyRef).onDestroy(unsubscribe);
83
- effect(() => {
84
- const options = this.options();
85
- untracked(() => this.controller.setOptions(options));
86
- });
87
- effect(() => {
88
- const value = this.value();
89
- untracked(() => this.controller.setValue(value));
90
- });
91
- effect(() => {
92
- const open = this.open() && !this.disabled();
93
- untracked(() => open ? this.controller.open() : this.controller.close());
94
- });
95
- effect(onCleanup => {
96
- if (!this.state().open) {
97
- return;
98
- }
99
- const onPointerDown = (event) => this.onDocumentPointerDown(event);
100
- const onMove = () => this.follow();
101
- const view = this.document.defaultView;
102
- this.document.addEventListener('pointerdown', onPointerDown);
103
- view?.addEventListener('scroll', onMove, true);
104
- view?.addEventListener('resize', onMove);
105
- onCleanup(() => {
106
- this.document.removeEventListener('pointerdown', onPointerDown);
107
- view?.removeEventListener('scroll', onMove, true);
108
- view?.removeEventListener('resize', onMove);
109
- });
110
- });
111
- afterRenderEffect(() => {
112
- const open = this.state().open;
113
- untracked(() => (open ? this.reveal() : this.conceal()));
114
- });
115
- afterRenderEffect(() => {
116
- const id = this.activeId();
117
- const option = id ? this.document.getElementById(id) : null;
118
- if (option && typeof option.scrollIntoView === 'function') {
119
- option.scrollIntoView({ block: 'nearest' });
120
- }
121
- });
122
- }
123
- /** Moves focus to the trigger */
124
- focus() {
125
- this.trigger().nativeElement.focus();
126
- }
127
- optionId(index) {
128
- return `${this.id}-option-${index}`;
129
- }
130
- isSelected(option) {
131
- return option === this.selected();
132
- }
133
- toggle() {
134
- if (!this.disabled()) {
135
- this.controller.toggle();
136
- }
137
- }
138
- choose(index) {
139
- this.byUser(() => this.pick(index));
140
- }
141
- activate(index) {
142
- if (index !== this.state().active) {
143
- this.controller.activate(index);
144
- }
145
- }
146
- onSearch(event) {
147
- if (event.target instanceof HTMLInputElement) {
148
- this.controller.search(event.target.value);
149
- }
150
- }
151
- onKeydown(event) {
152
- if (this.disabled() || event.ctrlKey || event.metaKey) {
153
- return;
154
- }
155
- this.byUser(() => this.state().open
156
- ? this.onOpenKeydown(event)
157
- : this.onClosedKeydown(event));
158
- }
159
- onFocusOut(event) {
160
- const next = event.relatedTarget;
161
- if (next instanceof Node && this.host.nativeElement.contains(next)) {
162
- return;
163
- }
164
- this.controller.close();
165
- this.touched.set(true);
166
- }
167
- onClosedKeydown(event) {
168
- const move = MOVES[event.key];
169
- if (move || event.key === 'Enter' || event.key === ' ') {
170
- event.preventDefault();
171
- this.controller.open();
172
- if (move === 'first' || move === 'last') {
173
- this.controller.move(move);
174
- }
175
- return;
176
- }
177
- if (isPrintable(event)) {
178
- event.preventDefault();
179
- this.controller.typeAhead(event.key);
180
- }
181
- }
182
- onOpenKeydown(event) {
183
- const searching = this.searchable();
184
- const move = MOVES[event.key];
185
- if (event.key === 'ArrowUp' && event.altKey) {
186
- event.preventDefault();
187
- this.pick(this.state().active);
188
- }
189
- else if (move &&
190
- !(searching && (event.key === 'Home' || event.key === 'End'))) {
191
- event.preventDefault();
192
- this.controller.move(move);
193
- }
194
- else if (event.key === 'Enter' || (event.key === ' ' && !searching)) {
195
- event.preventDefault();
196
- this.pick(this.state().active);
197
- }
198
- else if (event.key === 'Escape') {
199
- event.preventDefault();
200
- event.stopPropagation();
201
- this.controller.close();
202
- this.focus();
203
- }
204
- else if (event.key === 'Tab') {
205
- this.controller.choose();
206
- this.controller.close();
207
- }
208
- else if (!searching && isPrintable(event)) {
209
- event.preventDefault();
210
- this.controller.typeAhead(event.key);
211
- }
212
- }
213
- pick(index) {
214
- if (this.controller.choose(index)) {
215
- this.focus();
216
- }
217
- }
218
- byUser(action) {
219
- const before = this.controller.state.get().value;
220
- action();
221
- const after = this.controller.state.get().value;
222
- if (after !== null && after !== before) {
223
- this.chosen.emit(after);
224
- }
225
- }
226
- onDocumentPointerDown(event) {
227
- const target = event.target;
228
- if (!(target instanceof Node) ||
229
- !this.host.nativeElement.contains(target)) {
230
- this.controller.close();
231
- }
232
- }
233
- reveal() {
234
- const panel = this.panel().nativeElement;
235
- panel.classList.add('su-select-shown');
236
- if (typeof panel.showPopover === 'function' &&
237
- !panel.matches(':popover-open')) {
238
- panel.showPopover();
239
- }
240
- this.place();
241
- const search = this.search()?.nativeElement;
242
- if (search) {
243
- search.value = '';
244
- search.focus();
245
- }
246
- }
247
- conceal() {
248
- const panel = this.panel().nativeElement;
249
- panel.classList.remove('su-select-shown');
250
- if (typeof panel.hidePopover === 'function' &&
251
- panel.matches(':popover-open')) {
252
- panel.hidePopover();
253
- }
254
- }
255
- follow() {
256
- const trigger = this.trigger().nativeElement.getBoundingClientRect();
257
- const height = this.document.defaultView?.innerHeight ?? 0;
258
- if (trigger.bottom <= 0 || trigger.top >= height) {
259
- this.controller.close();
260
- return;
261
- }
262
- this.place();
263
- }
264
- place() {
265
- if (!this.state().open) {
266
- return;
267
- }
268
- const panel = this.panel().nativeElement;
269
- const trigger = this.trigger().nativeElement.getBoundingClientRect();
270
- const view = this.document.defaultView;
271
- panel.style.minWidth = `${trigger.width}px`;
272
- const position = suTooltipPosition(trigger, { width: panel.offsetWidth, height: panel.offsetHeight }, {
273
- placement: 'bottom-start',
274
- offset: 4,
275
- viewport: {
276
- width: this.document.documentElement.clientWidth,
277
- height: view?.innerHeight ?? 0,
278
- },
279
- rtl: view?.getComputedStyle(this.host.nativeElement).direction === 'rtl',
280
- });
281
- panel.dataset['side'] = position.side;
282
- panel.style.left = `${position.x}px`;
283
- panel.style.top = `${position.y}px`;
284
- }
285
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SuSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
286
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: SuSelectComponent, isStandalone: true, selector: "su-lib-select", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, animated: { classPropertyName: "animated", publicName: "animated", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledby: { classPropertyName: "ariaLabelledby", publicName: "ariaLabelledby", isSignal: true, isRequired: false, transformFunction: null }, labels: { classPropertyName: "labels", publicName: "labels", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", open: "openChange", touched: "touchedChange", chosen: "chosen" }, host: { listeners: { "focusout": "onFocusOut($event)" }, properties: { "class.su-select-open": "open()", "class.su-select-disabled": "disabled()" }, classAttribute: "su-select" }, viewQueries: [{ propertyName: "trigger", first: true, predicate: ["trigger"], descendants: true, isSignal: true }, { propertyName: "panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }, { propertyName: "search", first: true, predicate: ["search"], descendants: true, isSignal: true }], ngImport: i0, template: "<button\n #trigger\n type=\"button\"\n class=\"su-select-trigger\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n [id]=\"id\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"state().open\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"searchable() ? null : activeId()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"ariaLabelledby() ?? null\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\">\n <span class=\"su-select-value\" [class.su-select-placeholder]=\"!selected()\">{{ selected()?.label ?? placeholder() ?? texts().placeholder }}</span>\n <svg class=\"su-select-chevron\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m6 9 6 6 6-6\" /></svg>\n</button>\n<div #panel popover=\"manual\" class=\"su-select-panel\" [class.su-select-animated]=\"animated()\">\n @if (searchable()) {\n <input\n #search\n type=\"text\"\n class=\"su-select-search\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"activeId()\"\n [attr.aria-label]=\"texts().search\"\n [placeholder]=\"texts().search\"\n (input)=\"onSearch($event)\"\n (keydown)=\"onKeydown($event)\" />\n }\n <ul class=\"su-select-list\" role=\"listbox\" tabindex=\"-1\" [id]=\"listId\" [attr.aria-label]=\"ariaLabel() ?? null\" [attr.aria-labelledby]=\"ariaLabel() ? null : (ariaLabelledby() ?? id)\" (mousedown)=\"$event.preventDefault()\">\n @for (group of groups(); track $index) {\n <li role=\"presentation\">\n <ul class=\"su-select-group\" [attr.role]=\"group.label ? 'group' : 'presentation'\" [attr.aria-labelledby]=\"group.label ? id + '-group-' + $index : null\">\n @if (group.label) {\n <li role=\"presentation\" class=\"su-select-group-label\" [id]=\"id + '-group-' + $index\">{{ group.label }}</li>\n }\n @for (item of group.options; track item.index) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -- the combobox handles the keyboard through aria-activedescendant -->\n <li\n role=\"option\"\n class=\"su-select-option\"\n [id]=\"optionId(item.index)\"\n [class.su-select-active]=\"item.index === state().active\"\n [attr.aria-selected]=\"isSelected(item.option)\"\n [attr.aria-disabled]=\"item.option.disabled ? true : null\"\n (click)=\"choose(item.index)\"\n (pointermove)=\"activate(item.index)\">\n <span class=\"su-select-option-label\">{{ item.option.label }}</span>\n <svg class=\"su-select-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n </li>\n }\n </ul>\n </li>\n } @empty {\n <li role=\"presentation\" class=\"su-select-empty\">{{ texts().empty }}</li>\n }\n </ul>\n</div>\n", styles: [":host{display:inline-block;max-width:100%;vertical-align:middle}.su-select-trigger{align-items:center;background:var(--su-select-background, #fff);border:var(--su-select-border, 1px solid #d1d5db);border-radius:var(--su-select-radius, .375rem);box-sizing:border-box;color:var(--su-select-color, #111827);cursor:pointer;display:inline-flex;font:inherit;font-size:var(--su-select-font-size, .875rem);gap:.5rem;justify-content:space-between;line-height:1.4;max-width:100%;min-height:var(--su-select-height, 2.25rem);min-width:var(--su-select-min-width, 8rem);padding:var(--su-select-padding, .375rem .625rem);text-align:start;transition:border-color .15s,box-shadow .15s;width:100%}.su-select-trigger:hover:not(:disabled){border-color:var(--su-select-hover-border-color, #9ca3af)}.su-select-trigger:focus-visible{box-shadow:var(--su-select-focus-ring, 0 0 0 3px rgba(37, 99, 235, .35));outline:none}.su-select-trigger:disabled{cursor:not-allowed;opacity:var(--su-select-disabled-opacity, .5)}.su-select-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.su-select-placeholder{color:var(--su-select-muted-color, #6b7280)}.su-select-chevron,.su-select-check{fill:none;flex:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2}.su-select-chevron{block-size:1rem;color:var(--su-select-muted-color, #6b7280);inline-size:1rem;transition:transform .2s}:host(.su-select-open) .su-select-chevron{transform:rotate(180deg)}.su-select-panel{background:var(--su-select-list-background, var(--su-select-background, #fff));border:var(--su-select-list-border, var(--su-select-border, 1px solid #d1d5db));border-radius:var(--su-select-list-radius, .5rem);box-shadow:var(--su-select-list-shadow, 0 10px 30px rgba(0, 0, 0, .12));box-sizing:border-box;color:var(--su-select-color, #111827);display:none;flex-direction:column;font-family:inherit;font-size:var(--su-select-font-size, .875rem);inset:auto;margin:0;max-height:min(var(--su-select-list-max-height, 18rem),100vh - 16px);max-width:calc(100vw - 16px);overflow:hidden;padding:var(--su-select-list-padding, .25rem);position:fixed;z-index:var(--su-select-z-index, 1000)}.su-select-panel.su-select-shown{display:flex}.su-select-panel.su-select-animated.su-select-shown{animation:su-select-in var(--su-select-duration, .16s) cubic-bezier(.16,1,.3,1);transform-origin:top}.su-select-panel.su-select-animated.su-select-shown[data-side=top]{animation-name:su-select-in-above;transform-origin:bottom}.su-select-search{background:transparent;border:0;border-bottom:var(--su-select-search-border, 1px solid #e5e7eb);box-sizing:border-box;color:inherit;flex:none;font:inherit;margin-bottom:.25rem;outline:none;padding:.4rem .5rem;width:100%}.su-select-search::placeholder{color:var(--su-select-muted-color, #6b7280)}.su-select-list,.su-select-group{list-style:none;margin:0;padding:0}.su-select-list{outline:none;overflow-y:auto;overscroll-behavior:contain}.su-select-group-label{color:var(--su-select-muted-color, #6b7280);font-size:.75em;letter-spacing:.04em;padding:.5rem .5rem .2rem;text-transform:uppercase}.su-select-option{align-items:center;border-radius:var(--su-select-option-radius, .3125rem);cursor:pointer;display:flex;gap:1rem;justify-content:space-between;padding:var(--su-select-option-padding, .4rem .5rem);white-space:nowrap}.su-select-option.su-select-active{background:var(--su-select-option-active-background, #f3f4f6)}.su-select-option[aria-selected=true]{color:var(--su-select-option-selected-color, inherit);font-weight:var(--su-select-option-selected-weight, 600)}.su-select-option[aria-disabled=true]{cursor:not-allowed;opacity:var(--su-select-disabled-opacity, .5)}.su-select-check{block-size:1rem;inline-size:1rem;visibility:hidden}[aria-selected=true]>.su-select-check{visibility:visible}.su-select-empty{color:var(--su-select-muted-color, #6b7280);padding:var(--su-select-option-padding, .4rem .5rem)}@keyframes su-select-in{0%{opacity:0;transform:translateY(-4px) scaleY(.96)}}@keyframes su-select-in-above{0%{opacity:0;transform:translateY(4px) scaleY(.96)}}@media(prefers-reduced-motion:reduce){.su-select-panel.su-select-shown,.su-select-panel.su-select-shown[data-side=top]{animation:none}.su-select-chevron{transition:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
287
- }
288
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SuSelectComponent, decorators: [{
289
- type: Component,
290
- args: [{ selector: 'su-lib-select', changeDetection: ChangeDetectionStrategy.OnPush, host: {
291
- class: 'su-select',
292
- '[class.su-select-open]': 'open()',
293
- '[class.su-select-disabled]': 'disabled()',
294
- '(focusout)': 'onFocusOut($event)',
295
- }, template: "<button\n #trigger\n type=\"button\"\n class=\"su-select-trigger\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n [id]=\"id\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"state().open\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"searchable() ? null : activeId()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"ariaLabelledby() ?? null\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\">\n <span class=\"su-select-value\" [class.su-select-placeholder]=\"!selected()\">{{ selected()?.label ?? placeholder() ?? texts().placeholder }}</span>\n <svg class=\"su-select-chevron\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m6 9 6 6 6-6\" /></svg>\n</button>\n<div #panel popover=\"manual\" class=\"su-select-panel\" [class.su-select-animated]=\"animated()\">\n @if (searchable()) {\n <input\n #search\n type=\"text\"\n class=\"su-select-search\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"activeId()\"\n [attr.aria-label]=\"texts().search\"\n [placeholder]=\"texts().search\"\n (input)=\"onSearch($event)\"\n (keydown)=\"onKeydown($event)\" />\n }\n <ul class=\"su-select-list\" role=\"listbox\" tabindex=\"-1\" [id]=\"listId\" [attr.aria-label]=\"ariaLabel() ?? null\" [attr.aria-labelledby]=\"ariaLabel() ? null : (ariaLabelledby() ?? id)\" (mousedown)=\"$event.preventDefault()\">\n @for (group of groups(); track $index) {\n <li role=\"presentation\">\n <ul class=\"su-select-group\" [attr.role]=\"group.label ? 'group' : 'presentation'\" [attr.aria-labelledby]=\"group.label ? id + '-group-' + $index : null\">\n @if (group.label) {\n <li role=\"presentation\" class=\"su-select-group-label\" [id]=\"id + '-group-' + $index\">{{ group.label }}</li>\n }\n @for (item of group.options; track item.index) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -- the combobox handles the keyboard through aria-activedescendant -->\n <li\n role=\"option\"\n class=\"su-select-option\"\n [id]=\"optionId(item.index)\"\n [class.su-select-active]=\"item.index === state().active\"\n [attr.aria-selected]=\"isSelected(item.option)\"\n [attr.aria-disabled]=\"item.option.disabled ? true : null\"\n (click)=\"choose(item.index)\"\n (pointermove)=\"activate(item.index)\">\n <span class=\"su-select-option-label\">{{ item.option.label }}</span>\n <svg class=\"su-select-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n </li>\n }\n </ul>\n </li>\n } @empty {\n <li role=\"presentation\" class=\"su-select-empty\">{{ texts().empty }}</li>\n }\n </ul>\n</div>\n", styles: [":host{display:inline-block;max-width:100%;vertical-align:middle}.su-select-trigger{align-items:center;background:var(--su-select-background, #fff);border:var(--su-select-border, 1px solid #d1d5db);border-radius:var(--su-select-radius, .375rem);box-sizing:border-box;color:var(--su-select-color, #111827);cursor:pointer;display:inline-flex;font:inherit;font-size:var(--su-select-font-size, .875rem);gap:.5rem;justify-content:space-between;line-height:1.4;max-width:100%;min-height:var(--su-select-height, 2.25rem);min-width:var(--su-select-min-width, 8rem);padding:var(--su-select-padding, .375rem .625rem);text-align:start;transition:border-color .15s,box-shadow .15s;width:100%}.su-select-trigger:hover:not(:disabled){border-color:var(--su-select-hover-border-color, #9ca3af)}.su-select-trigger:focus-visible{box-shadow:var(--su-select-focus-ring, 0 0 0 3px rgba(37, 99, 235, .35));outline:none}.su-select-trigger:disabled{cursor:not-allowed;opacity:var(--su-select-disabled-opacity, .5)}.su-select-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.su-select-placeholder{color:var(--su-select-muted-color, #6b7280)}.su-select-chevron,.su-select-check{fill:none;flex:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2}.su-select-chevron{block-size:1rem;color:var(--su-select-muted-color, #6b7280);inline-size:1rem;transition:transform .2s}:host(.su-select-open) .su-select-chevron{transform:rotate(180deg)}.su-select-panel{background:var(--su-select-list-background, var(--su-select-background, #fff));border:var(--su-select-list-border, var(--su-select-border, 1px solid #d1d5db));border-radius:var(--su-select-list-radius, .5rem);box-shadow:var(--su-select-list-shadow, 0 10px 30px rgba(0, 0, 0, .12));box-sizing:border-box;color:var(--su-select-color, #111827);display:none;flex-direction:column;font-family:inherit;font-size:var(--su-select-font-size, .875rem);inset:auto;margin:0;max-height:min(var(--su-select-list-max-height, 18rem),100vh - 16px);max-width:calc(100vw - 16px);overflow:hidden;padding:var(--su-select-list-padding, .25rem);position:fixed;z-index:var(--su-select-z-index, 1000)}.su-select-panel.su-select-shown{display:flex}.su-select-panel.su-select-animated.su-select-shown{animation:su-select-in var(--su-select-duration, .16s) cubic-bezier(.16,1,.3,1);transform-origin:top}.su-select-panel.su-select-animated.su-select-shown[data-side=top]{animation-name:su-select-in-above;transform-origin:bottom}.su-select-search{background:transparent;border:0;border-bottom:var(--su-select-search-border, 1px solid #e5e7eb);box-sizing:border-box;color:inherit;flex:none;font:inherit;margin-bottom:.25rem;outline:none;padding:.4rem .5rem;width:100%}.su-select-search::placeholder{color:var(--su-select-muted-color, #6b7280)}.su-select-list,.su-select-group{list-style:none;margin:0;padding:0}.su-select-list{outline:none;overflow-y:auto;overscroll-behavior:contain}.su-select-group-label{color:var(--su-select-muted-color, #6b7280);font-size:.75em;letter-spacing:.04em;padding:.5rem .5rem .2rem;text-transform:uppercase}.su-select-option{align-items:center;border-radius:var(--su-select-option-radius, .3125rem);cursor:pointer;display:flex;gap:1rem;justify-content:space-between;padding:var(--su-select-option-padding, .4rem .5rem);white-space:nowrap}.su-select-option.su-select-active{background:var(--su-select-option-active-background, #f3f4f6)}.su-select-option[aria-selected=true]{color:var(--su-select-option-selected-color, inherit);font-weight:var(--su-select-option-selected-weight, 600)}.su-select-option[aria-disabled=true]{cursor:not-allowed;opacity:var(--su-select-disabled-opacity, .5)}.su-select-check{block-size:1rem;inline-size:1rem;visibility:hidden}[aria-selected=true]>.su-select-check{visibility:visible}.su-select-empty{color:var(--su-select-muted-color, #6b7280);padding:var(--su-select-option-padding, .4rem .5rem)}@keyframes su-select-in{0%{opacity:0;transform:translateY(-4px) scaleY(.96)}}@keyframes su-select-in-above{0%{opacity:0;transform:translateY(4px) scaleY(.96)}}@media(prefers-reduced-motion:reduce){.su-select-panel.su-select-shown,.su-select-panel.su-select-shown[data-side=top]{animation:none}.su-select-chevron{transition:none}}\n"] }]
296
- }], ctorParameters: () => [] });
15
+ var SuSelectComponent = class SuSelectComponent {
16
+ options = input([], ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
17
+ value = model(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
18
+ open = model(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
19
+ touched = model(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
20
+ searchable = input(false, {
21
+ ...ngDevMode ? { debugName: "searchable" } : /* istanbul ignore next */ {},
22
+ transform: booleanAttribute
23
+ });
24
+ disabled = input(false, {
25
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
26
+ transform: booleanAttribute
27
+ });
28
+ animated = input(true, {
29
+ ...ngDevMode ? { debugName: "animated" } : /* istanbul ignore next */ {},
30
+ transform: booleanAttribute
31
+ });
32
+ placeholder = input(...ngDevMode ? [void 0, { debugName: "placeholder" }] : /* istanbul ignore next */ []);
33
+ ariaLabel = input(...ngDevMode ? [void 0, { debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
34
+ ariaLabelledby = input(...ngDevMode ? [void 0, { debugName: "ariaLabelledby" }] : /* istanbul ignore next */ []);
35
+ labels = input({}, ...ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []);
36
+ chosen = output();
37
+ id = `su-select-${nextSelectId++}`;
38
+ listId = `${this.id}-list`;
39
+ texts = computed(() => ({
40
+ ...SU_SELECT_LABELS,
41
+ ...this.labels()
42
+ }), ...ngDevMode ? [{ debugName: "texts" }] : /* istanbul ignore next */ []);
43
+ controller = new SuSelectController();
44
+ state = signal(this.controller.state.get(), ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
45
+ groups = computed(() => suSelectGroups(this.state().visible), ...ngDevMode ? [{ debugName: "groups" }] : /* istanbul ignore next */ []);
46
+ selected = computed(() => {
47
+ this.state();
48
+ return this.controller.selected;
49
+ }, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
50
+ activeId = computed(() => {
51
+ const { open, active } = this.state();
52
+ return open && active >= 0 ? this.optionId(active) : null;
53
+ }, ...ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []);
54
+ host = inject(ElementRef);
55
+ document = inject(DOCUMENT);
56
+ trigger = viewChild.required("trigger", ...ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []);
57
+ panel = viewChild.required("panel", ...ngDevMode ? [{ debugName: "panel" }] : /* istanbul ignore next */ []);
58
+ search = viewChild("search", ...ngDevMode ? [{ debugName: "search" }] : /* istanbul ignore next */ []);
59
+ constructor() {
60
+ let previous = this.controller.state.get();
61
+ const unsubscribe = this.controller.state.subscribe((state) => {
62
+ this.state.set(state);
63
+ if (state.value !== previous.value) this.value.set(state.value);
64
+ if (state.open !== previous.open) this.open.set(state.open);
65
+ previous = state;
66
+ });
67
+ inject(DestroyRef).onDestroy(unsubscribe);
68
+ effect(() => {
69
+ const options = this.options();
70
+ untracked(() => this.controller.setOptions(options));
71
+ });
72
+ effect(() => {
73
+ const value = this.value();
74
+ untracked(() => this.controller.setValue(value));
75
+ });
76
+ effect(() => {
77
+ const open = this.open() && !this.disabled();
78
+ untracked(() => open ? this.controller.open() : this.controller.close());
79
+ });
80
+ effect((onCleanup) => {
81
+ if (!this.state().open) return;
82
+ const onPointerDown = (event) => this.onDocumentPointerDown(event);
83
+ const onMove = () => this.follow();
84
+ const view = this.document.defaultView;
85
+ this.document.addEventListener("pointerdown", onPointerDown);
86
+ view?.addEventListener("scroll", onMove, true);
87
+ view?.addEventListener("resize", onMove);
88
+ onCleanup(() => {
89
+ this.document.removeEventListener("pointerdown", onPointerDown);
90
+ view?.removeEventListener("scroll", onMove, true);
91
+ view?.removeEventListener("resize", onMove);
92
+ });
93
+ });
94
+ afterRenderEffect(() => {
95
+ const open = this.state().open;
96
+ untracked(() => open ? this.reveal() : this.conceal());
97
+ });
98
+ afterRenderEffect(() => {
99
+ const id = this.activeId();
100
+ const option = id ? this.document.getElementById(id) : null;
101
+ if (option && typeof option.scrollIntoView === "function") option.scrollIntoView({ block: "nearest" });
102
+ });
103
+ }
104
+ focus() {
105
+ this.trigger().nativeElement.focus();
106
+ }
107
+ optionId(index) {
108
+ return `${this.id}-option-${index}`;
109
+ }
110
+ isSelected(option) {
111
+ return option === this.selected();
112
+ }
113
+ toggle() {
114
+ if (!this.disabled()) this.controller.toggle();
115
+ }
116
+ choose(index) {
117
+ this.byUser(() => this.pick(index));
118
+ }
119
+ activate(index) {
120
+ if (index !== this.state().active) this.controller.activate(index);
121
+ }
122
+ onSearch(event) {
123
+ if (event.target instanceof HTMLInputElement) this.controller.search(event.target.value);
124
+ }
125
+ onKeydown(event) {
126
+ if (this.disabled() || event.ctrlKey || event.metaKey) return;
127
+ this.byUser(() => this.state().open ? this.onOpenKeydown(event) : this.onClosedKeydown(event));
128
+ }
129
+ onFocusOut(event) {
130
+ const next = event.relatedTarget;
131
+ if (next instanceof Node && this.host.nativeElement.contains(next)) return;
132
+ this.controller.close();
133
+ this.touched.set(true);
134
+ }
135
+ onClosedKeydown(event) {
136
+ const move = MOVES[event.key];
137
+ if (move || event.key === "Enter" || event.key === " ") {
138
+ event.preventDefault();
139
+ this.controller.open();
140
+ if (move === "first" || move === "last") this.controller.move(move);
141
+ return;
142
+ }
143
+ if (isPrintable(event)) {
144
+ event.preventDefault();
145
+ this.controller.typeAhead(event.key);
146
+ }
147
+ }
148
+ onOpenKeydown(event) {
149
+ const searching = this.searchable();
150
+ const move = MOVES[event.key];
151
+ if (event.key === "ArrowUp" && event.altKey) {
152
+ event.preventDefault();
153
+ this.pick(this.state().active);
154
+ } else if (move && !(searching && (event.key === "Home" || event.key === "End"))) {
155
+ event.preventDefault();
156
+ this.controller.move(move);
157
+ } else if (event.key === "Enter" || event.key === " " && !searching) {
158
+ event.preventDefault();
159
+ this.pick(this.state().active);
160
+ } else if (event.key === "Escape") {
161
+ event.preventDefault();
162
+ event.stopPropagation();
163
+ this.controller.close();
164
+ this.focus();
165
+ } else if (event.key === "Tab") {
166
+ this.controller.choose();
167
+ this.controller.close();
168
+ } else if (!searching && isPrintable(event)) {
169
+ event.preventDefault();
170
+ this.controller.typeAhead(event.key);
171
+ }
172
+ }
173
+ pick(index) {
174
+ if (this.controller.choose(index)) this.focus();
175
+ }
176
+ byUser(action) {
177
+ const before = this.controller.state.get().value;
178
+ action();
179
+ const after = this.controller.state.get().value;
180
+ if (after !== null && after !== before) this.chosen.emit(after);
181
+ }
182
+ onDocumentPointerDown(event) {
183
+ const target = event.target;
184
+ if (!(target instanceof Node) || !this.host.nativeElement.contains(target)) this.controller.close();
185
+ }
186
+ reveal() {
187
+ const panel = this.panel().nativeElement;
188
+ panel.classList.add("su-select-shown");
189
+ if (typeof panel.showPopover === "function" && !panel.matches(":popover-open")) panel.showPopover();
190
+ this.place();
191
+ const search = this.search()?.nativeElement;
192
+ if (search) {
193
+ search.value = "";
194
+ search.focus();
195
+ }
196
+ }
197
+ conceal() {
198
+ const panel = this.panel().nativeElement;
199
+ panel.classList.remove("su-select-shown");
200
+ if (typeof panel.hidePopover === "function" && panel.matches(":popover-open")) panel.hidePopover();
201
+ }
202
+ follow() {
203
+ const trigger = this.trigger().nativeElement.getBoundingClientRect();
204
+ const height = this.document.defaultView?.innerHeight ?? 0;
205
+ if (trigger.bottom <= 0 || trigger.top >= height) {
206
+ this.controller.close();
207
+ return;
208
+ }
209
+ this.place();
210
+ }
211
+ place() {
212
+ if (!this.state().open) return;
213
+ const panel = this.panel().nativeElement;
214
+ const trigger = this.trigger().nativeElement.getBoundingClientRect();
215
+ const view = this.document.defaultView;
216
+ panel.style.minWidth = `${trigger.width}px`;
217
+ const position = suTooltipPosition(trigger, {
218
+ width: panel.offsetWidth,
219
+ height: panel.offsetHeight
220
+ }, {
221
+ placement: "bottom-start",
222
+ offset: 4,
223
+ viewport: {
224
+ width: this.document.documentElement.clientWidth,
225
+ height: view?.innerHeight ?? 0
226
+ },
227
+ rtl: view?.getComputedStyle(this.host.nativeElement).direction === "rtl"
228
+ });
229
+ panel.dataset["side"] = position.side;
230
+ panel.style.left = `${position.x}px`;
231
+ panel.style.top = `${position.y}px`;
232
+ }
233
+ static ɵfac = i0.ɵɵngDeclareFactory({
234
+ minVersion: "12.0.0",
235
+ version: "22.2.4",
236
+ ngImport: i0,
237
+ type: SuSelectComponent,
238
+ deps: [],
239
+ target: i0.ɵɵFactoryTarget.Component
240
+ });
241
+ static ɵcmp = i0.ɵɵngDeclareComponent({
242
+ minVersion: "17.0.0",
243
+ version: "22.2.4",
244
+ type: SuSelectComponent,
245
+ isStandalone: true,
246
+ selector: "su-lib-select",
247
+ inputs: {
248
+ options: {
249
+ classPropertyName: "options",
250
+ publicName: "options",
251
+ isSignal: true,
252
+ isRequired: false,
253
+ transformFunction: null
254
+ },
255
+ value: {
256
+ classPropertyName: "value",
257
+ publicName: "value",
258
+ isSignal: true,
259
+ isRequired: false,
260
+ transformFunction: null
261
+ },
262
+ open: {
263
+ classPropertyName: "open",
264
+ publicName: "open",
265
+ isSignal: true,
266
+ isRequired: false,
267
+ transformFunction: null
268
+ },
269
+ touched: {
270
+ classPropertyName: "touched",
271
+ publicName: "touched",
272
+ isSignal: true,
273
+ isRequired: false,
274
+ transformFunction: null
275
+ },
276
+ searchable: {
277
+ classPropertyName: "searchable",
278
+ publicName: "searchable",
279
+ isSignal: true,
280
+ isRequired: false,
281
+ transformFunction: null
282
+ },
283
+ disabled: {
284
+ classPropertyName: "disabled",
285
+ publicName: "disabled",
286
+ isSignal: true,
287
+ isRequired: false,
288
+ transformFunction: null
289
+ },
290
+ animated: {
291
+ classPropertyName: "animated",
292
+ publicName: "animated",
293
+ isSignal: true,
294
+ isRequired: false,
295
+ transformFunction: null
296
+ },
297
+ placeholder: {
298
+ classPropertyName: "placeholder",
299
+ publicName: "placeholder",
300
+ isSignal: true,
301
+ isRequired: false,
302
+ transformFunction: null
303
+ },
304
+ ariaLabel: {
305
+ classPropertyName: "ariaLabel",
306
+ publicName: "ariaLabel",
307
+ isSignal: true,
308
+ isRequired: false,
309
+ transformFunction: null
310
+ },
311
+ ariaLabelledby: {
312
+ classPropertyName: "ariaLabelledby",
313
+ publicName: "ariaLabelledby",
314
+ isSignal: true,
315
+ isRequired: false,
316
+ transformFunction: null
317
+ },
318
+ labels: {
319
+ classPropertyName: "labels",
320
+ publicName: "labels",
321
+ isSignal: true,
322
+ isRequired: false,
323
+ transformFunction: null
324
+ }
325
+ },
326
+ outputs: {
327
+ value: "valueChange",
328
+ open: "openChange",
329
+ touched: "touchedChange",
330
+ chosen: "chosen"
331
+ },
332
+ host: {
333
+ listeners: { "focusout": "onFocusOut($event)" },
334
+ properties: {
335
+ "class.su-select-open": "open()",
336
+ "class.su-select-disabled": "disabled()"
337
+ },
338
+ classAttribute: "su-select"
339
+ },
340
+ viewQueries: [
341
+ {
342
+ propertyName: "trigger",
343
+ first: true,
344
+ predicate: ["trigger"],
345
+ descendants: true,
346
+ isSignal: true
347
+ },
348
+ {
349
+ propertyName: "panel",
350
+ first: true,
351
+ predicate: ["panel"],
352
+ descendants: true,
353
+ isSignal: true
354
+ },
355
+ {
356
+ propertyName: "search",
357
+ first: true,
358
+ predicate: ["search"],
359
+ descendants: true,
360
+ isSignal: true
361
+ }
362
+ ],
363
+ ngImport: i0,
364
+ template: "<button\n #trigger\n type=\"button\"\n class=\"su-select-trigger\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n [id]=\"id\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"state().open\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"searchable() ? null : activeId()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"ariaLabelledby() ?? null\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\">\n <span class=\"su-select-value\" [class.su-select-placeholder]=\"!selected()\">{{ selected()?.label ?? placeholder() ?? texts().placeholder }}</span>\n <svg class=\"su-select-chevron\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m6 9 6 6 6-6\" /></svg>\n</button>\n<div #panel popover=\"manual\" class=\"su-select-panel\" [class.su-select-animated]=\"animated()\">\n @if (searchable()) {\n <input\n #search\n type=\"text\"\n class=\"su-select-search\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"activeId()\"\n [attr.aria-label]=\"texts().search\"\n [placeholder]=\"texts().search\"\n (input)=\"onSearch($event)\"\n (keydown)=\"onKeydown($event)\" />\n }\n <ul class=\"su-select-list\" role=\"listbox\" tabindex=\"-1\" [id]=\"listId\" [attr.aria-label]=\"ariaLabel() ?? null\" [attr.aria-labelledby]=\"ariaLabel() ? null : (ariaLabelledby() ?? id)\" (mousedown)=\"$event.preventDefault()\">\n @for (group of groups(); track $index) {\n <li role=\"presentation\">\n <ul class=\"su-select-group\" [attr.role]=\"group.label ? 'group' : 'presentation'\" [attr.aria-labelledby]=\"group.label ? id + '-group-' + $index : null\">\n @if (group.label) {\n <li role=\"presentation\" class=\"su-select-group-label\" [id]=\"id + '-group-' + $index\">{{ group.label }}</li>\n }\n @for (item of group.options; track item.index) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -- the combobox handles the keyboard through aria-activedescendant -->\n <li\n role=\"option\"\n class=\"su-select-option\"\n [id]=\"optionId(item.index)\"\n [class.su-select-active]=\"item.index === state().active\"\n [attr.aria-selected]=\"isSelected(item.option)\"\n [attr.aria-disabled]=\"item.option.disabled ? true : null\"\n (click)=\"choose(item.index)\"\n (pointermove)=\"activate(item.index)\">\n <span class=\"su-select-option-label\">{{ item.option.label }}</span>\n <svg class=\"su-select-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n </li>\n }\n </ul>\n </li>\n } @empty {\n <li role=\"presentation\" class=\"su-select-empty\">{{ texts().empty }}</li>\n }\n </ul>\n</div>\n",
365
+ styles: [":host{display:inline-block;max-width:100%;vertical-align:middle}.su-select-trigger{align-items:center;background:var(--su-select-background, #fff);border:var(--su-select-border, 1px solid #d1d5db);border-radius:var(--su-select-radius, .375rem);box-sizing:border-box;color:var(--su-select-color, #111827);cursor:pointer;display:inline-flex;font:inherit;font-size:var(--su-select-font-size, .875rem);gap:.5rem;justify-content:space-between;line-height:1.4;max-width:100%;min-height:var(--su-select-height, 2.25rem);min-width:var(--su-select-min-width, 8rem);padding:var(--su-select-padding, .375rem .625rem);text-align:start;transition:border-color .15s,box-shadow .15s;width:100%}.su-select-trigger:hover:not(:disabled){border-color:var(--su-select-hover-border-color, #9ca3af)}.su-select-trigger:focus-visible{box-shadow:var(--su-select-focus-ring, 0 0 0 3px rgba(37, 99, 235, .35));outline:none}.su-select-trigger:disabled{cursor:not-allowed;opacity:var(--su-select-disabled-opacity, .5)}.su-select-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.su-select-placeholder{color:var(--su-select-muted-color, #6b7280)}.su-select-chevron,.su-select-check{fill:none;flex:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2}.su-select-chevron{block-size:1rem;color:var(--su-select-muted-color, #6b7280);inline-size:1rem;transition:transform .2s}:host(.su-select-open) .su-select-chevron{transform:rotate(180deg)}.su-select-panel{background:var(--su-select-list-background, var(--su-select-background, #fff));border:var(--su-select-list-border, var(--su-select-border, 1px solid #d1d5db));border-radius:var(--su-select-list-radius, .5rem);box-shadow:var(--su-select-list-shadow, 0 10px 30px rgba(0, 0, 0, .12));box-sizing:border-box;color:var(--su-select-color, #111827);display:none;flex-direction:column;font-family:inherit;font-size:var(--su-select-font-size, .875rem);inset:auto;margin:0;max-height:min(var(--su-select-list-max-height, 18rem),100vh - 16px);max-width:calc(100vw - 16px);overflow:hidden;padding:var(--su-select-list-padding, .25rem);position:fixed;z-index:var(--su-select-z-index, 1000)}.su-select-panel.su-select-shown{display:flex}.su-select-panel.su-select-animated.su-select-shown{animation:su-select-in var(--su-select-duration, .16s) cubic-bezier(.16,1,.3,1);transform-origin:top}.su-select-panel.su-select-animated.su-select-shown[data-side=top]{animation-name:su-select-in-above;transform-origin:bottom}.su-select-search{background:transparent;border:0;border-bottom:var(--su-select-search-border, 1px solid #e5e7eb);box-sizing:border-box;color:inherit;flex:none;font:inherit;margin-bottom:.25rem;outline:none;padding:.4rem .5rem;width:100%}.su-select-search::placeholder{color:var(--su-select-muted-color, #6b7280)}.su-select-list,.su-select-group{list-style:none;margin:0;padding:0}.su-select-list{outline:none;overflow-y:auto;overscroll-behavior:contain}.su-select-group-label{color:var(--su-select-muted-color, #6b7280);font-size:.75em;letter-spacing:.04em;padding:.5rem .5rem .2rem;text-transform:uppercase}.su-select-option{align-items:center;border-radius:var(--su-select-option-radius, .3125rem);cursor:pointer;display:flex;gap:1rem;justify-content:space-between;padding:var(--su-select-option-padding, .4rem .5rem);white-space:nowrap}.su-select-option.su-select-active{background:var(--su-select-option-active-background, #f3f4f6)}.su-select-option[aria-selected=true]{color:var(--su-select-option-selected-color, inherit);font-weight:var(--su-select-option-selected-weight, 600)}.su-select-option[aria-disabled=true]{cursor:not-allowed;opacity:var(--su-select-disabled-opacity, .5)}.su-select-check{block-size:1rem;inline-size:1rem;visibility:hidden}[aria-selected=true]>.su-select-check{visibility:visible}.su-select-empty{color:var(--su-select-muted-color, #6b7280);padding:var(--su-select-option-padding, .4rem .5rem)}@keyframes su-select-in{0%{opacity:0;transform:translateY(-4px) scaleY(.96)}}@keyframes su-select-in-above{0%{opacity:0;transform:translateY(4px) scaleY(.96)}}@media(prefers-reduced-motion:reduce){.su-select-panel.su-select-shown,.su-select-panel.su-select-shown[data-side=top]{animation:none}.su-select-chevron{transition:none}}\n"],
366
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
367
+ });
368
+ };
369
+ i0.ɵɵngDeclareClassMetadata({
370
+ minVersion: "12.0.0",
371
+ version: "22.2.4",
372
+ ngImport: i0,
373
+ type: SuSelectComponent,
374
+ decorators: [{
375
+ type: Component,
376
+ args: [{
377
+ selector: "su-lib-select",
378
+ changeDetection: ChangeDetectionStrategy.OnPush,
379
+ host: {
380
+ class: "su-select",
381
+ "[class.su-select-open]": "open()",
382
+ "[class.su-select-disabled]": "disabled()",
383
+ "(focusout)": "onFocusOut($event)"
384
+ },
385
+ template: "<button\n #trigger\n type=\"button\"\n class=\"su-select-trigger\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n [id]=\"id\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"state().open\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"searchable() ? null : activeId()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"ariaLabelledby() ?? null\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\">\n <span class=\"su-select-value\" [class.su-select-placeholder]=\"!selected()\">{{ selected()?.label ?? placeholder() ?? texts().placeholder }}</span>\n <svg class=\"su-select-chevron\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m6 9 6 6 6-6\" /></svg>\n</button>\n<div #panel popover=\"manual\" class=\"su-select-panel\" [class.su-select-animated]=\"animated()\">\n @if (searchable()) {\n <input\n #search\n type=\"text\"\n class=\"su-select-search\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n aria-expanded=\"true\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"activeId()\"\n [attr.aria-label]=\"texts().search\"\n [placeholder]=\"texts().search\"\n (input)=\"onSearch($event)\"\n (keydown)=\"onKeydown($event)\" />\n }\n <ul class=\"su-select-list\" role=\"listbox\" tabindex=\"-1\" [id]=\"listId\" [attr.aria-label]=\"ariaLabel() ?? null\" [attr.aria-labelledby]=\"ariaLabel() ? null : (ariaLabelledby() ?? id)\" (mousedown)=\"$event.preventDefault()\">\n @for (group of groups(); track $index) {\n <li role=\"presentation\">\n <ul class=\"su-select-group\" [attr.role]=\"group.label ? 'group' : 'presentation'\" [attr.aria-labelledby]=\"group.label ? id + '-group-' + $index : null\">\n @if (group.label) {\n <li role=\"presentation\" class=\"su-select-group-label\" [id]=\"id + '-group-' + $index\">{{ group.label }}</li>\n }\n @for (item of group.options; track item.index) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -- the combobox handles the keyboard through aria-activedescendant -->\n <li\n role=\"option\"\n class=\"su-select-option\"\n [id]=\"optionId(item.index)\"\n [class.su-select-active]=\"item.index === state().active\"\n [attr.aria-selected]=\"isSelected(item.option)\"\n [attr.aria-disabled]=\"item.option.disabled ? true : null\"\n (click)=\"choose(item.index)\"\n (pointermove)=\"activate(item.index)\">\n <span class=\"su-select-option-label\">{{ item.option.label }}</span>\n <svg class=\"su-select-check\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n </li>\n }\n </ul>\n </li>\n } @empty {\n <li role=\"presentation\" class=\"su-select-empty\">{{ texts().empty }}</li>\n }\n </ul>\n</div>\n",
386
+ styles: [":host{display:inline-block;max-width:100%;vertical-align:middle}.su-select-trigger{align-items:center;background:var(--su-select-background, #fff);border:var(--su-select-border, 1px solid #d1d5db);border-radius:var(--su-select-radius, .375rem);box-sizing:border-box;color:var(--su-select-color, #111827);cursor:pointer;display:inline-flex;font:inherit;font-size:var(--su-select-font-size, .875rem);gap:.5rem;justify-content:space-between;line-height:1.4;max-width:100%;min-height:var(--su-select-height, 2.25rem);min-width:var(--su-select-min-width, 8rem);padding:var(--su-select-padding, .375rem .625rem);text-align:start;transition:border-color .15s,box-shadow .15s;width:100%}.su-select-trigger:hover:not(:disabled){border-color:var(--su-select-hover-border-color, #9ca3af)}.su-select-trigger:focus-visible{box-shadow:var(--su-select-focus-ring, 0 0 0 3px rgba(37, 99, 235, .35));outline:none}.su-select-trigger:disabled{cursor:not-allowed;opacity:var(--su-select-disabled-opacity, .5)}.su-select-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.su-select-placeholder{color:var(--su-select-muted-color, #6b7280)}.su-select-chevron,.su-select-check{fill:none;flex:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2}.su-select-chevron{block-size:1rem;color:var(--su-select-muted-color, #6b7280);inline-size:1rem;transition:transform .2s}:host(.su-select-open) .su-select-chevron{transform:rotate(180deg)}.su-select-panel{background:var(--su-select-list-background, var(--su-select-background, #fff));border:var(--su-select-list-border, var(--su-select-border, 1px solid #d1d5db));border-radius:var(--su-select-list-radius, .5rem);box-shadow:var(--su-select-list-shadow, 0 10px 30px rgba(0, 0, 0, .12));box-sizing:border-box;color:var(--su-select-color, #111827);display:none;flex-direction:column;font-family:inherit;font-size:var(--su-select-font-size, .875rem);inset:auto;margin:0;max-height:min(var(--su-select-list-max-height, 18rem),100vh - 16px);max-width:calc(100vw - 16px);overflow:hidden;padding:var(--su-select-list-padding, .25rem);position:fixed;z-index:var(--su-select-z-index, 1000)}.su-select-panel.su-select-shown{display:flex}.su-select-panel.su-select-animated.su-select-shown{animation:su-select-in var(--su-select-duration, .16s) cubic-bezier(.16,1,.3,1);transform-origin:top}.su-select-panel.su-select-animated.su-select-shown[data-side=top]{animation-name:su-select-in-above;transform-origin:bottom}.su-select-search{background:transparent;border:0;border-bottom:var(--su-select-search-border, 1px solid #e5e7eb);box-sizing:border-box;color:inherit;flex:none;font:inherit;margin-bottom:.25rem;outline:none;padding:.4rem .5rem;width:100%}.su-select-search::placeholder{color:var(--su-select-muted-color, #6b7280)}.su-select-list,.su-select-group{list-style:none;margin:0;padding:0}.su-select-list{outline:none;overflow-y:auto;overscroll-behavior:contain}.su-select-group-label{color:var(--su-select-muted-color, #6b7280);font-size:.75em;letter-spacing:.04em;padding:.5rem .5rem .2rem;text-transform:uppercase}.su-select-option{align-items:center;border-radius:var(--su-select-option-radius, .3125rem);cursor:pointer;display:flex;gap:1rem;justify-content:space-between;padding:var(--su-select-option-padding, .4rem .5rem);white-space:nowrap}.su-select-option.su-select-active{background:var(--su-select-option-active-background, #f3f4f6)}.su-select-option[aria-selected=true]{color:var(--su-select-option-selected-color, inherit);font-weight:var(--su-select-option-selected-weight, 600)}.su-select-option[aria-disabled=true]{cursor:not-allowed;opacity:var(--su-select-disabled-opacity, .5)}.su-select-check{block-size:1rem;inline-size:1rem;visibility:hidden}[aria-selected=true]>.su-select-check{visibility:visible}.su-select-empty{color:var(--su-select-muted-color, #6b7280);padding:var(--su-select-option-padding, .4rem .5rem)}@keyframes su-select-in{0%{opacity:0;transform:translateY(-4px) scaleY(.96)}}@keyframes su-select-in-above{0%{opacity:0;transform:translateY(4px) scaleY(.96)}}@media(prefers-reduced-motion:reduce){.su-select-panel.su-select-shown,.su-select-panel.su-select-shown[data-side=top]{animation:none}.su-select-chevron{transition:none}}\n"]
387
+ }]
388
+ }],
389
+ ctorParameters: () => [],
390
+ propDecorators: {
391
+ options: [{
392
+ type: i0.Input,
393
+ args: [{
394
+ isSignal: true,
395
+ alias: "options",
396
+ required: false
397
+ }]
398
+ }],
399
+ value: [{
400
+ type: i0.Input,
401
+ args: [{
402
+ isSignal: true,
403
+ alias: "value",
404
+ required: false
405
+ }]
406
+ }, {
407
+ type: i0.Output,
408
+ args: ["valueChange"]
409
+ }],
410
+ open: [{
411
+ type: i0.Input,
412
+ args: [{
413
+ isSignal: true,
414
+ alias: "open",
415
+ required: false
416
+ }]
417
+ }, {
418
+ type: i0.Output,
419
+ args: ["openChange"]
420
+ }],
421
+ touched: [{
422
+ type: i0.Input,
423
+ args: [{
424
+ isSignal: true,
425
+ alias: "touched",
426
+ required: false
427
+ }]
428
+ }, {
429
+ type: i0.Output,
430
+ args: ["touchedChange"]
431
+ }],
432
+ searchable: [{
433
+ type: i0.Input,
434
+ args: [{
435
+ isSignal: true,
436
+ alias: "searchable",
437
+ required: false
438
+ }]
439
+ }],
440
+ disabled: [{
441
+ type: i0.Input,
442
+ args: [{
443
+ isSignal: true,
444
+ alias: "disabled",
445
+ required: false
446
+ }]
447
+ }],
448
+ animated: [{
449
+ type: i0.Input,
450
+ args: [{
451
+ isSignal: true,
452
+ alias: "animated",
453
+ required: false
454
+ }]
455
+ }],
456
+ placeholder: [{
457
+ type: i0.Input,
458
+ args: [{
459
+ isSignal: true,
460
+ alias: "placeholder",
461
+ required: false
462
+ }]
463
+ }],
464
+ ariaLabel: [{
465
+ type: i0.Input,
466
+ args: [{
467
+ isSignal: true,
468
+ alias: "ariaLabel",
469
+ required: false
470
+ }]
471
+ }],
472
+ ariaLabelledby: [{
473
+ type: i0.Input,
474
+ args: [{
475
+ isSignal: true,
476
+ alias: "ariaLabelledby",
477
+ required: false
478
+ }]
479
+ }],
480
+ labels: [{
481
+ type: i0.Input,
482
+ args: [{
483
+ isSignal: true,
484
+ alias: "labels",
485
+ required: false
486
+ }]
487
+ }],
488
+ chosen: [{
489
+ type: i0.Output,
490
+ args: ["chosen"]
491
+ }],
492
+ trigger: [{
493
+ type: i0.ViewChild,
494
+ args: ["trigger", { isSignal: true }]
495
+ }],
496
+ panel: [{
497
+ type: i0.ViewChild,
498
+ args: ["panel", { isSignal: true }]
499
+ }],
500
+ search: [{
501
+ type: i0.ViewChild,
502
+ args: ["search", { isSignal: true }]
503
+ }]
504
+ }
505
+ });
297
506
  function isPrintable(event) {
298
- return event.key.length === 1 && event.key !== ' ' && !event.altKey;
507
+ return event.key.length === 1 && event.key !== " " && !event.altKey;
299
508
  }
300
-
301
- /**
302
- * Generated bundle index. Do not edit.
303
- */
304
-
305
509
  export { SuSelectComponent };
306
- //# sourceMappingURL=su-labs-select.mjs.map
510
+
511
+ //# sourceMappingURL=su-labs-select.mjs.map