@sixbell-telco/sdk 4.8.0 → 4.10.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/CHANGELOG.md +53 -0
- package/components/accordion/README.md +1 -1
- package/components/accordion/src/accordion.component.d.ts +4 -0
- package/components/alert/src/alert.component.d.ts +8 -1
- package/components/data-table/README.md +1 -0
- package/components/data-table/src/data-table.component.d.ts +2 -24
- package/components/dialog/README.md +4 -3
- package/components/dialog/dialog-actions/dialog-actions.component.d.ts +2 -1
- package/components/dialog/src/dialog.component.d.ts +10 -5
- package/components/dropdown-menu/bar/dropdown-menu-bar-item/dropdown-menu-bar-item.component.d.ts +1 -1
- package/components/dropdown-menu/src/dropdown-menu-item/dropdown-menu-item.component.d.ts +3 -2
- package/components/file-upload/file-dropzone/file-dropzone.component.d.ts +12 -0
- package/components/file-upload/file-uploader/file-uploader.component.d.ts +6 -0
- package/components/forms/combobox/README.md +49 -0
- package/components/forms/combobox/src/combobox.component.d.ts +178 -3
- package/components/forms/date-picker/README.md +3 -1
- package/components/forms/date-picker/src/date-picker.component.d.ts +8 -1
- package/components/forms/form-error/README.md +2 -0
- package/components/forms/form-error/src/form-error.component.d.ts +17 -0
- package/components/forms/form-hint/README.md +2 -2
- package/components/forms/form-item/README.md +1 -0
- package/components/forms/form-item/src/form-item.component.d.ts +38 -6
- package/components/forms/input/README.md +7 -0
- package/components/forms/input/src/input.component.d.ts +11 -1
- package/components/forms/select/README.md +48 -0
- package/components/forms/select/src/select.component.d.ts +157 -2
- package/components/forms/textarea/README.md +1 -0
- package/components/forms/textarea/src/textarea.component.d.ts +6 -1
- package/components/paginator/README.md +3 -0
- package/components/paginator/components/pagination-item/pagination-item.component.d.ts +8 -3
- package/components/paginator/src/paginator.component.d.ts +2 -1
- package/components/progress/src/progress.component.d.ts +17 -3
- package/components/table/README.md +2 -0
- package/components/table/src/table.component.d.ts +16 -23
- package/directives/only-numbers/src/only-numbers.directive.d.ts +27 -1
- package/fesm2022/sixbell-telco-sdk-components-accordion.mjs +6 -1
- package/fesm2022/sixbell-telco-sdk-components-accordion.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-alert.mjs +12 -5
- package/fesm2022/sixbell-telco-sdk-components-alert.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs +5 -2
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs +30 -13
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs +2 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +10 -4
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs +32 -6
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +272 -23
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs +17 -4
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs +32 -4
- package/fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-form-item.mjs +74 -10
- package/fesm2022/sixbell-telco-sdk-components-forms-form-item.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs +13 -3
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +258 -18
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-switch.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-switch.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs +11 -3
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-paginator.mjs +15 -11
- package/fesm2022/sixbell-telco-sdk-components-paginator.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-progress.mjs +22 -4
- package/fesm2022/sixbell-telco-sdk-components-progress.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-table.mjs +42 -5
- package/fesm2022/sixbell-telco-sdk-components-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-only-numbers.mjs +49 -4
- package/fesm2022/sixbell-telco-sdk-directives-only-numbers.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-layouts.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-layouts.mjs.map +1 -1
- package/i18n/sdk/en.json +14 -4
- package/i18n/sdk/es.json +14 -4
- package/i18n/sdk/pt.json +14 -4
- package/manifest.json +185 -19
- package/package.json +1 -1
- package/src/_index.css +19 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
3
|
import { inject, input, booleanAttribute, computed, model, output, signal, viewChild, afterRenderEffect, effect, untracked, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
4
|
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
|
|
@@ -65,6 +66,11 @@ const selectComponent = cva([
|
|
|
65
66
|
size: 'md',
|
|
66
67
|
},
|
|
67
68
|
});
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
* Classes of an option row; the option sizer uses them too, so it measures what the panel shows
|
|
72
|
+
*/
|
|
73
|
+
const OPTION_ROW_CLASS = 'group-[.cdk-option-active]:bg-base-300 font-body flex w-full items-center justify-between rounded-none px-4 py-2 text-left leading-normal font-normal text-pretty transition-colors duration-150 ease-in-out group-data-disabled:cursor-not-allowed group-data-disabled:bg-transparent group-data-disabled:text-(--color-disabled-content) group-data-disabled:hover:bg-transparent';
|
|
68
74
|
// ==============================================================================
|
|
69
75
|
// COMPONENT
|
|
70
76
|
// ==============================================================================
|
|
@@ -157,6 +163,10 @@ class SelectComponent {
|
|
|
157
163
|
generatedId = `st-select-${nextSelectId++}`;
|
|
158
164
|
/** @internal Id applied to the focusable control and referenced by its label */
|
|
159
165
|
resolvedId = computed(() => this.inputId() || this.generatedId);
|
|
166
|
+
/** @internal Id of the options listbox, referenced by the trigger's `aria-controls` */
|
|
167
|
+
listboxId = `${this.generatedId}-listbox`;
|
|
168
|
+
/** @internal Id of the visually hidden label, which names the listbox */
|
|
169
|
+
labelId = `${this.generatedId}-label`;
|
|
160
170
|
/**
|
|
161
171
|
* Placeholder text when no option is selected
|
|
162
172
|
*/
|
|
@@ -183,11 +193,56 @@ class SelectComponent {
|
|
|
183
193
|
* Uses the entire object if not specified
|
|
184
194
|
*/
|
|
185
195
|
valueKey = input('');
|
|
196
|
+
/**
|
|
197
|
+
* The object property that marks an option as disabled when truthy.
|
|
198
|
+
* A disabled option stays in the list (and in search results), is dimmed,
|
|
199
|
+
* carries `aria-disabled="true"` and cannot be chosen by click or keyboard.
|
|
200
|
+
* Leave empty to keep every option enabled.
|
|
201
|
+
*/
|
|
202
|
+
disabledKey = input('');
|
|
203
|
+
/**
|
|
204
|
+
* The object property holding a secondary text shown right-aligned on the option row
|
|
205
|
+
* (for example why it is disabled: "Already added"). It is part of the
|
|
206
|
+
* option's accessible name.
|
|
207
|
+
*/
|
|
208
|
+
descriptionKey = input('');
|
|
209
|
+
/**
|
|
210
|
+
* The object property naming the group an option belongs to. Options that share a value are listed
|
|
211
|
+
* together under one header showing that value, groups in the order they first appear, each group
|
|
212
|
+
* named by its header for assistive technology. Options without the property are listed first,
|
|
213
|
+
* ungrouped. Headers cannot be chosen and the arrow keys skip them. Leave empty for a flat list.
|
|
214
|
+
*/
|
|
215
|
+
groupKey = input('');
|
|
216
|
+
/**
|
|
217
|
+
* The object property that marks an option as already taken outside this field when truthy (for
|
|
218
|
+
* example a country added earlier). The option shows the check icon, in the option's own color, but
|
|
219
|
+
* it is not part of the value and never appears in the trigger. Pair it with `disabledKey` so it is
|
|
220
|
+
* dimmed, check included, and cannot be chosen again.
|
|
221
|
+
*/
|
|
222
|
+
checkedKey = input('');
|
|
186
223
|
/**
|
|
187
224
|
* Whether to show a clear button next to the selected value
|
|
188
225
|
* @default true
|
|
189
226
|
*/
|
|
190
227
|
allowClear = input(true, { transform: booleanAttribute });
|
|
228
|
+
/**
|
|
229
|
+
* Width of the options panel.
|
|
230
|
+
* - `'trigger'`: as wide as the control; a long option wraps onto more lines.
|
|
231
|
+
* - `'content'`: at least as wide as the control and wider when an option needs it, up to
|
|
232
|
+
* `min(28rem, 100vw - 2rem)`. Options stay on one line; past that cap the description, then the label,
|
|
233
|
+
* end in an ellipsis and the row shows its full text as a tooltip. Near the viewport edge the panel
|
|
234
|
+
* aligns to the control's end instead of overflowing.
|
|
235
|
+
* @defaultValue 'trigger'
|
|
236
|
+
*/
|
|
237
|
+
panelWidth = input('trigger');
|
|
238
|
+
/**
|
|
239
|
+
* Size the closed control to its widest option or the placeholder, measured with the option row's own
|
|
240
|
+
* font, padding and check icon for the current `size`. A selected value never truncates and the control
|
|
241
|
+
* keeps its width between selections. The panel then follows its options as with `panelWidth="content"`.
|
|
242
|
+
* The control does not shrink in a flex row (`shrink-0`); `min-w-*` and `w-*` classes on the element still apply.
|
|
243
|
+
* @defaultValue false
|
|
244
|
+
*/
|
|
245
|
+
fitOptions = input(false, { transform: booleanAttribute });
|
|
191
246
|
/**
|
|
192
247
|
* Parent form group for reactive forms
|
|
193
248
|
*/
|
|
@@ -242,6 +297,8 @@ class SelectComponent {
|
|
|
242
297
|
translateLabel = injectLabelTranslator();
|
|
243
298
|
/** @internal Name of the icon-only clear button. */
|
|
244
299
|
clearSelectionLabel = computed(() => this.translateLabel({ key: 'sdk.select.clearSelection', fallback: 'Clear selection' }));
|
|
300
|
+
/** @internal Text of the empty listbox */
|
|
301
|
+
noOptionsLabel = computed(() => this.translateLabel({ key: 'sdk.select.noOptions', fallback: 'No options available' }));
|
|
245
302
|
// ==============================================================================
|
|
246
303
|
// PRIVATE PROPERTIES
|
|
247
304
|
// ==============================================================================
|
|
@@ -276,6 +333,35 @@ class SelectComponent {
|
|
|
276
333
|
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 4 },
|
|
277
334
|
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -4 },
|
|
278
335
|
];
|
|
336
|
+
/** @internal Content-width panel positions: a panel wider than the control aligns to its end near the viewport edge */
|
|
337
|
+
contentOverlayPositions = [
|
|
338
|
+
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 4 },
|
|
339
|
+
{ originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top', offsetY: 4 },
|
|
340
|
+
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -4 },
|
|
341
|
+
{ originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom', offsetY: -4 },
|
|
342
|
+
];
|
|
343
|
+
/** @internal Whether the panel sizes to its options (`panelWidth="content"` or `fitOptions`) */
|
|
344
|
+
contentPanel = computed(() => this.fitOptions() || this.panelWidth() === 'content');
|
|
345
|
+
/** @internal Positions bound to the overlay */
|
|
346
|
+
activeOverlayPositions = computed(() => (this.contentPanel() ? this.contentOverlayPositions : this.overlayPositions));
|
|
347
|
+
/** @internal Fixed overlay width: the trigger width, or none when the panel sizes to its options */
|
|
348
|
+
overlayWidth = computed(() => (this.contentPanel() ? '' : this.triggerWidth()));
|
|
349
|
+
/** @internal Classes of the panel box */
|
|
350
|
+
panelClass = computed(() => cn('rounded-box shadow-overlay', this.contentPanel() ? 'w-max max-w-[min(28rem,calc(100vw-2rem))] min-w-full' : 'w-full', this.animationClasses()));
|
|
351
|
+
/**
|
|
352
|
+
* @internal
|
|
353
|
+
* Classes of the hidden option sizer: the panel's menu size, so rows measure alike, plus a reserved scrollbar
|
|
354
|
+
* gutter, so a list that scrolls keeps the width of one that does not; capped like the panel, so a long
|
|
355
|
+
* option cannot widen the control past the panel
|
|
356
|
+
*/
|
|
357
|
+
optionSizerClass = computed(() => cn('menu pointer-events-none invisible h-0 max-w-[min(28rem,calc(100vw-2rem))] scrollbar-gutter-stable flex-nowrap overflow-hidden p-0', this.menuSizeClass()));
|
|
358
|
+
/** @internal Classes of an option row */
|
|
359
|
+
optionRowClass = OPTION_ROW_CLASS;
|
|
360
|
+
/** @internal Texts the closed control must fit with `fitOptions`: the placeholder and every option label */
|
|
361
|
+
valueSizerLabels = computed(() => [
|
|
362
|
+
this.translatedPlaceholder(),
|
|
363
|
+
...this.options().map((option) => this.getDisplayValue(option)),
|
|
364
|
+
]);
|
|
279
365
|
/** Real placement of the open panel, bound to `data-side` / `data-align`; null until the CDK places it */
|
|
280
366
|
placement = computed(() => {
|
|
281
367
|
const position = this.currentPosition();
|
|
@@ -445,18 +531,27 @@ class SelectComponent {
|
|
|
445
531
|
}
|
|
446
532
|
return this.componentClass();
|
|
447
533
|
});
|
|
534
|
+
/**
|
|
535
|
+
* @internal
|
|
536
|
+
* Options in the order they are listed: ungrouped first, then each `groupKey` group
|
|
537
|
+
*/
|
|
538
|
+
optionSections = computed(() => this.groupOptions(this.options()));
|
|
539
|
+
/**
|
|
540
|
+
* @internal
|
|
541
|
+
* Options in the order they are listed, which keyboard navigation and `data-option-index` follow
|
|
542
|
+
*/
|
|
543
|
+
orderedOptions = computed(() => this.groupKey() ? this.optionSections().flatMap((section) => section.options.map((entry) => entry.option)) : this.options());
|
|
448
544
|
/**
|
|
449
545
|
* CSS classes for the options menu
|
|
450
546
|
* @internal
|
|
451
547
|
*/
|
|
452
548
|
menuClass = computed(() => {
|
|
453
|
-
return cn('menu max-h-72 w-full flex-nowrap overflow-y-auto overscroll-contain p-0 focus-within:outline-hidden focus:outline-hidden focus-visible:outline-hidden',
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
});
|
|
549
|
+
return cn('menu scroll-fade-y max-h-72 w-full flex-nowrap overflow-y-auto overscroll-contain p-0 focus-within:outline-hidden focus:outline-hidden focus-visible:outline-hidden', this.menuSizeClass());
|
|
550
|
+
});
|
|
551
|
+
/** @internal Menu size modifier shared by the options list and the option sizer */
|
|
552
|
+
menuSizeClass = computed(() => {
|
|
553
|
+
const size = this.size();
|
|
554
|
+
return size ? `menu-${size}` : '';
|
|
460
555
|
});
|
|
461
556
|
// ==============================================================================
|
|
462
557
|
// LIFECYCLE METHODS
|
|
@@ -651,6 +746,8 @@ class SelectComponent {
|
|
|
651
746
|
* @param option - The selected option
|
|
652
747
|
*/
|
|
653
748
|
handleOptionSelect(option) {
|
|
749
|
+
if (this.isOptionDisabled(option))
|
|
750
|
+
return;
|
|
654
751
|
this.pendingValue = null;
|
|
655
752
|
this.value.set(option);
|
|
656
753
|
this.onChange(option);
|
|
@@ -672,7 +769,7 @@ class SelectComponent {
|
|
|
672
769
|
* @param event - The keyboard event
|
|
673
770
|
*/
|
|
674
771
|
handleListboxKeydown(event) {
|
|
675
|
-
const options = this.
|
|
772
|
+
const options = this.orderedOptions();
|
|
676
773
|
const currentIndex = this.activeOptionIndex();
|
|
677
774
|
switch (event.key) {
|
|
678
775
|
case 'ArrowDown': {
|
|
@@ -680,7 +777,7 @@ class SelectComponent {
|
|
|
680
777
|
if (this.stopPropagation()) {
|
|
681
778
|
event.stopPropagation();
|
|
682
779
|
}
|
|
683
|
-
const nextIndex = currentIndex < options.length - 1 ? currentIndex
|
|
780
|
+
const nextIndex = this.findEnabledIndex(options, currentIndex < options.length - 1 ? currentIndex : -1, 1);
|
|
684
781
|
this.setActiveOption(nextIndex);
|
|
685
782
|
break;
|
|
686
783
|
}
|
|
@@ -689,10 +786,20 @@ class SelectComponent {
|
|
|
689
786
|
if (this.stopPropagation()) {
|
|
690
787
|
event.stopPropagation();
|
|
691
788
|
}
|
|
692
|
-
const prevIndex = currentIndex > 0 ? currentIndex
|
|
789
|
+
const prevIndex = this.findEnabledIndex(options, currentIndex > 0 ? currentIndex : options.length, -1);
|
|
693
790
|
this.setActiveOption(prevIndex);
|
|
694
791
|
break;
|
|
695
792
|
}
|
|
793
|
+
case 'Home':
|
|
794
|
+
case 'End': {
|
|
795
|
+
event.preventDefault();
|
|
796
|
+
if (this.stopPropagation()) {
|
|
797
|
+
event.stopPropagation();
|
|
798
|
+
}
|
|
799
|
+
const edgeIndex = event.key === 'Home' ? this.findEnabledIndex(options, -1, 1) : this.findEnabledIndex(options, options.length, -1);
|
|
800
|
+
this.setActiveOption(edgeIndex);
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
696
803
|
case 'Enter':
|
|
697
804
|
case ' ':
|
|
698
805
|
event.preventDefault();
|
|
@@ -806,6 +913,36 @@ class SelectComponent {
|
|
|
806
913
|
isActiveOption(index) {
|
|
807
914
|
return this.activeOptionIndex() === index;
|
|
808
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* Whether an option is disabled through `disabledKey`
|
|
918
|
+
* @param option - The option to check
|
|
919
|
+
* @returns True if the option cannot be chosen
|
|
920
|
+
*/
|
|
921
|
+
isOptionDisabled(option) {
|
|
922
|
+
const disabledKey = this.disabledKey();
|
|
923
|
+
return !!disabledKey && !!option && typeof option === 'object' && !!option[disabledKey];
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Whether an option is marked as already taken through `checkedKey`
|
|
927
|
+
* @param option - The option to check
|
|
928
|
+
* @returns True if the option shows the check without being part of the value
|
|
929
|
+
*/
|
|
930
|
+
isOptionChecked(option) {
|
|
931
|
+
const checkedKey = this.checkedKey();
|
|
932
|
+
return !!checkedKey && !!option && typeof option === 'object' && !!option[checkedKey];
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Gets the secondary text for an option through `descriptionKey`
|
|
936
|
+
* @param option - The option to read
|
|
937
|
+
* @returns The secondary text, or an empty string
|
|
938
|
+
*/
|
|
939
|
+
getOptionDescription(option) {
|
|
940
|
+
const descriptionKey = this.descriptionKey();
|
|
941
|
+
if (!descriptionKey || !option || typeof option !== 'object')
|
|
942
|
+
return '';
|
|
943
|
+
const description = option[descriptionKey];
|
|
944
|
+
return description === undefined || description === null ? '' : String(description);
|
|
945
|
+
}
|
|
809
946
|
/**
|
|
810
947
|
* Gets the display value for an option
|
|
811
948
|
* @param option - The option to get display value for
|
|
@@ -843,11 +980,47 @@ class SelectComponent {
|
|
|
843
980
|
* Updates the trigger button width for overlay positioning
|
|
844
981
|
*/
|
|
845
982
|
updateTriggerWidth() {
|
|
846
|
-
|
|
983
|
+
// Fractional widths round up: rounding down would make an option that exactly fills the control wrap
|
|
984
|
+
const width = Math.ceil(this.fieldRef()?.nativeElement.getBoundingClientRect().width ?? 0);
|
|
847
985
|
if (!width)
|
|
848
986
|
return;
|
|
849
987
|
this.triggerWidth.set(width);
|
|
850
988
|
}
|
|
989
|
+
/**
|
|
990
|
+
* @internal
|
|
991
|
+
* On hover of a single-line option, shows its full text as a tooltip when its label or description is cut off
|
|
992
|
+
* @param event - The pointer event on the option row
|
|
993
|
+
* @param option - The option the row shows
|
|
994
|
+
*/
|
|
995
|
+
syncOptionTitle(event, option) {
|
|
996
|
+
this.syncRowTitle(event.currentTarget, option);
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Sets the full-text tooltip of an option row when its label or description is cut off, or removes it;
|
|
1000
|
+
* runs on hover and when the row becomes the keyboard-active one
|
|
1001
|
+
* @param row - The option row
|
|
1002
|
+
* @param option - The option the row shows
|
|
1003
|
+
*/
|
|
1004
|
+
syncRowTitle(row, option) {
|
|
1005
|
+
const parts = row.querySelectorAll('[data-st-option-label], [data-st-option-description]');
|
|
1006
|
+
const truncated = Array.from(parts).some((part) => part.scrollWidth > part.clientWidth);
|
|
1007
|
+
if (truncated) {
|
|
1008
|
+
row.setAttribute('title', this.getOptionFullText(option));
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
row.removeAttribute('title');
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Gets the full text of an option: its label, then its description when it has one
|
|
1016
|
+
* @param option - The option to read
|
|
1017
|
+
* @returns The text shown as the tooltip of a truncated option
|
|
1018
|
+
*/
|
|
1019
|
+
getOptionFullText(option) {
|
|
1020
|
+
const description = this.getOptionDescription(option);
|
|
1021
|
+
const label = this.getDisplayValue(option);
|
|
1022
|
+
return description ? `${label}, ${description}` : label;
|
|
1023
|
+
}
|
|
851
1024
|
/**
|
|
852
1025
|
* Gets the value property from an option
|
|
853
1026
|
* @param option - The option to get value from
|
|
@@ -859,6 +1032,48 @@ class SelectComponent {
|
|
|
859
1032
|
const valueKey = this.valueKey();
|
|
860
1033
|
return valueKey && typeof option === 'object' ? option[valueKey] : option;
|
|
861
1034
|
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Gets the group an option belongs to through `groupKey`
|
|
1037
|
+
* @param option - The option to read
|
|
1038
|
+
* @returns The group name, or null when the option is ungrouped
|
|
1039
|
+
*/
|
|
1040
|
+
getOptionGroup(option) {
|
|
1041
|
+
const groupKey = this.groupKey();
|
|
1042
|
+
if (!groupKey || !option || typeof option !== 'object')
|
|
1043
|
+
return null;
|
|
1044
|
+
const group = option[groupKey];
|
|
1045
|
+
return group === undefined || group === null || group === '' ? null : String(group);
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Splits options into the ungrouped run, listed first, and one section per group in first-appearance order.
|
|
1049
|
+
* `index` is the option's position in the listed order; `headerId` is unique per instance.
|
|
1050
|
+
* @param options - The options to list
|
|
1051
|
+
* @returns The sections to render
|
|
1052
|
+
*/
|
|
1053
|
+
groupOptions(options) {
|
|
1054
|
+
const ungrouped = [];
|
|
1055
|
+
const groups = new Map();
|
|
1056
|
+
for (const option of options) {
|
|
1057
|
+
const group = this.getOptionGroup(option);
|
|
1058
|
+
if (group === null) {
|
|
1059
|
+
ungrouped.push(option);
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
groups.set(group, [...(groups.get(group) ?? []), option]);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
let index = 0;
|
|
1066
|
+
const entries = (list) => list.map((option) => ({ option, index: index++ }));
|
|
1067
|
+
const sections = [];
|
|
1068
|
+
if (ungrouped.length > 0) {
|
|
1069
|
+
sections.push({ label: null, headerId: null, options: entries(ungrouped) });
|
|
1070
|
+
}
|
|
1071
|
+
let groupIndex = 0;
|
|
1072
|
+
for (const [label, list] of groups) {
|
|
1073
|
+
sections.push({ label, headerId: `${this.listboxId}-group-${groupIndex++}`, options: entries(list) });
|
|
1074
|
+
}
|
|
1075
|
+
return sections;
|
|
1076
|
+
}
|
|
862
1077
|
/**
|
|
863
1078
|
* Triggers blur event for form validation
|
|
864
1079
|
*/
|
|
@@ -867,6 +1082,22 @@ class SelectComponent {
|
|
|
867
1082
|
this.onTouched();
|
|
868
1083
|
this.blurred.emit(this.value());
|
|
869
1084
|
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Finds the next enabled option index, wrapping around the list
|
|
1087
|
+
* @param options - The options being navigated
|
|
1088
|
+
* @param from - The index to start from (exclusive)
|
|
1089
|
+
* @param step - 1 to move down, -1 to move up
|
|
1090
|
+
* @returns The index of the next enabled option, or -1 if every option is disabled
|
|
1091
|
+
*/
|
|
1092
|
+
findEnabledIndex(options, from, step) {
|
|
1093
|
+
const count = options.length;
|
|
1094
|
+
for (let offset = 1; offset <= count; offset++) {
|
|
1095
|
+
const index = (((from + step * offset) % count) + count) % count;
|
|
1096
|
+
if (!this.isOptionDisabled(options[index]))
|
|
1097
|
+
return index;
|
|
1098
|
+
}
|
|
1099
|
+
return -1;
|
|
1100
|
+
}
|
|
870
1101
|
/**
|
|
871
1102
|
* Sets the active option for keyboard navigation
|
|
872
1103
|
* @param index - The index of the option to make active
|
|
@@ -876,12 +1107,14 @@ class SelectComponent {
|
|
|
876
1107
|
this.updateActiveOptionVisually();
|
|
877
1108
|
}
|
|
878
1109
|
/**
|
|
879
|
-
*
|
|
1110
|
+
* Makes the selected option active when the panel opens, so the highlight and the check sit on the same row;
|
|
1111
|
+
* without an enabled selected option, the first enabled one
|
|
880
1112
|
*/
|
|
881
1113
|
setDefaultActiveOption() {
|
|
882
|
-
const options = this.
|
|
1114
|
+
const options = this.orderedOptions();
|
|
883
1115
|
if (options.length > 0) {
|
|
884
|
-
this.
|
|
1116
|
+
const selectedIndex = options.findIndex((option) => this.isOptionSelected(option) && !this.isOptionDisabled(option));
|
|
1117
|
+
this.setActiveOption(selectedIndex >= 0 ? selectedIndex : this.findEnabledIndex(options, -1, 1));
|
|
885
1118
|
}
|
|
886
1119
|
}
|
|
887
1120
|
/**
|
|
@@ -903,29 +1136,36 @@ class SelectComponent {
|
|
|
903
1136
|
const activeOption = this.optionsList()?.nativeElement.querySelector(`[data-option-index="${currentIndex}"]`);
|
|
904
1137
|
if (activeOption) {
|
|
905
1138
|
activeOption.classList.add('cdk-option-active');
|
|
1139
|
+
const row = activeOption.querySelector(':scope > button');
|
|
1140
|
+
if (row && this.contentPanel())
|
|
1141
|
+
this.syncRowTitle(row, this.orderedOptions()[currentIndex]);
|
|
906
1142
|
// Scroll into view if needed
|
|
907
1143
|
activeOption.scrollIntoView({ block: 'nearest' });
|
|
908
1144
|
}
|
|
909
1145
|
}
|
|
910
1146
|
}
|
|
911
1147
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
912
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: SelectComponent, isStandalone: true, selector: "st-select", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, showOptional: { classPropertyName: "showOptional", publicName: "showOptional", isSignal: true, isRequired: false, transformFunction: null }, optionalText: { classPropertyName: "optionalText", publicName: "optionalText", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, ghost: { classPropertyName: "ghost", publicName: "ghost", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, displayKey: { classPropertyName: "displayKey", publicName: "displayKey", isSignal: true, isRequired: false, transformFunction: null }, valueKey: { classPropertyName: "valueKey", publicName: "valueKey", isSignal: true, isRequired: false, transformFunction: null }, allowClear: { classPropertyName: "allowClear", publicName: "allowClear", isSignal: true, isRequired: false, transformFunction: null }, parentForm: { classPropertyName: "parentForm", publicName: "parentForm", isSignal: true, isRequired: false, transformFunction: null }, formControlName: { classPropertyName: "formControlName", publicName: "formControlName", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, stopPropagation: { classPropertyName: "stopPropagation", publicName: "stopPropagation", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", blurred: "blurred", valueUpdated: "valueUpdated", clicked: "clicked", keyDownEnter: "keyDownEnter", keyDownSpace: "keyDownSpace", triggered: "triggered" }, providers: [
|
|
1148
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: SelectComponent, isStandalone: true, selector: "st-select", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, showOptional: { classPropertyName: "showOptional", publicName: "showOptional", isSignal: true, isRequired: false, transformFunction: null }, optionalText: { classPropertyName: "optionalText", publicName: "optionalText", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, ghost: { classPropertyName: "ghost", publicName: "ghost", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, displayKey: { classPropertyName: "displayKey", publicName: "displayKey", isSignal: true, isRequired: false, transformFunction: null }, valueKey: { classPropertyName: "valueKey", publicName: "valueKey", isSignal: true, isRequired: false, transformFunction: null }, disabledKey: { classPropertyName: "disabledKey", publicName: "disabledKey", isSignal: true, isRequired: false, transformFunction: null }, descriptionKey: { classPropertyName: "descriptionKey", publicName: "descriptionKey", isSignal: true, isRequired: false, transformFunction: null }, groupKey: { classPropertyName: "groupKey", publicName: "groupKey", isSignal: true, isRequired: false, transformFunction: null }, checkedKey: { classPropertyName: "checkedKey", publicName: "checkedKey", isSignal: true, isRequired: false, transformFunction: null }, allowClear: { classPropertyName: "allowClear", publicName: "allowClear", isSignal: true, isRequired: false, transformFunction: null }, panelWidth: { classPropertyName: "panelWidth", publicName: "panelWidth", isSignal: true, isRequired: false, transformFunction: null }, fitOptions: { classPropertyName: "fitOptions", publicName: "fitOptions", isSignal: true, isRequired: false, transformFunction: null }, parentForm: { classPropertyName: "parentForm", publicName: "parentForm", isSignal: true, isRequired: false, transformFunction: null }, formControlName: { classPropertyName: "formControlName", publicName: "formControlName", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, stopPropagation: { classPropertyName: "stopPropagation", publicName: "stopPropagation", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", blurred: "blurred", valueUpdated: "valueUpdated", clicked: "clicked", keyDownEnter: "keyDownEnter", keyDownSpace: "keyDownSpace", triggered: "triggered" }, host: { properties: { "class.inline-block": "fitOptions()", "class.align-top": "fitOptions()", "class.shrink-0": "fitOptions()" } }, providers: [
|
|
913
1149
|
{
|
|
914
1150
|
provide: NG_VALUE_ACCESSOR,
|
|
915
1151
|
useExisting: SelectComponent,
|
|
916
1152
|
multi: true,
|
|
917
1153
|
},
|
|
918
|
-
], viewQueries: [{ propertyName: "fieldRef", first: true, predicate: ["field"], descendants: true, isSignal: true }, { propertyName: "triggerRef", first: true, predicate: ["trigger"], descendants: true, isSignal: true }, { propertyName: "optionsList", first: true, predicate: ["optionsList"], descendants: true, isSignal: true }, { propertyName: "listbox", first: true, predicate: ["listbox"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->\n<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->\n<!-- Field chrome click is pointer-only sugar; keyboard access is the focusable trigger button inside. -->\n@let isOpen = this.isOpen(); @let triggerWidth = this.triggerWidth(); @let dataState = this.dataState(); @let options = this.options();\n@let displayValue = this.displayValue();\n@let label = this.label();\n\n<fieldset class=\"fieldset p-0\">\n\t@if (label) {\n\t\t<legend class=\"fieldset-legend font-body w-full items-center justify-between gap-2 pt-0 font-normal text-pretty\">\n\t\t\t<span\n\t\t\t\t>{{ label }}\n\t\t\t\t@if (fieldA11y.required()) {\n\t\t\t\t\t<span aria-hidden=\"true\" data-st-required-marker class=\"text-error-strong ms-0.5\">*</span>\n\t\t\t\t}\n\t\t\t</span>\n\t\t\t@if (showOptional()) {\n\t\t\t\t<span class=\"label font-body text-xs font-normal\">{{ optionalText() | translate }}</span>\n\t\t\t}\n\t\t</legend>\n\t}\n\n\t<div\n\t\t#field\n\t\tcdkOverlayOrigin\n\t\t#overlayOrigin=\"cdkOverlayOrigin\"\n\t\t[class]=\"validationClass()\"\n\t\t[attr.data-open]=\"isOpen ? '' : null\"\n\t\t(click)=\"handleFieldChromeClick($event)\"\n\t>\n\t\t<button\n\t\t\t#trigger\n\t\t\t[id]=\"resolvedId()\"\n\t\t\t[attr.aria-required]=\"fieldA11y.required() || null\"\n\t\t\t[attr.aria-describedby]=\"fieldA11y.describedBy()\"\n\t\t\tclass=\"min-w-0 flex-1 grow cursor-pointer bg-transparent p-0 text-left outline-hidden\"\n\t\t\t(click)=\"handleClick($event)\"\n\t\t\t(keydown)=\"handleTriggerKeydown($event)\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"true\"\n\t\t\trole=\"combobox\"\n\t\t\t[attr.aria-controls]=\"'select-list'\"\n\t\t\t[attr.aria-expanded]=\"isOpen\"\n\t\t\t[disabled]=\"disabled()\"\n\t\t>\n\t\t\t<span class=\"block min-w-0 truncate text-left\">\n\t\t\t\t{{ displayValue }}\n\t\t\t</span>\n\t\t</button>\n\t\t@if (showClearButton()) {\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\tdata-st-clear\n\t\t\t\tclass=\"btn btn-ghost btn-square shrink-0 cursor-pointer [--fontsize:1em] [--size:1.25em]\"\n\t\t\t\t(click)=\"handleClearSelection($event)\"\n\t\t\t\t(keydown.enter)=\"handleClearSelection($event)\"\n\t\t\t\t(keydown.space)=\"handleClearSelection($event)\"\n\t\t\t\t[attr.aria-label]=\"clearSelectionLabel()\"\n\t\t\t>\n\t\t\t\t<st-icon [icon]=\"iconClose\"></st-icon>\n\t\t\t</button>\n\t\t}\n\t\t<span data-st-chevron class=\"pointer-events-none inline-flex size-[1em] shrink-0 items-center justify-center\" aria-hidden=\"true\">\n\t\t\t<st-icon [icon]=\"iconChevronDown\"></st-icon>\n\t\t</span>\n\t</div>\n\n\t<ng-template\n\t\tcdkConnectedOverlay\n\t\t[cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n\t\t[cdkConnectedOverlayOpen]=\"isOpen\"\n\t\t[cdkConnectedOverlayPositions]=\"overlayPositions\"\n\t\t[cdkConnectedOverlayDisableClose]=\"true\"\n\t\t[cdkConnectedOverlayWidth]=\"triggerWidth\"\n\t\t[cdkConnectedOverlayMinWidth]=\"triggerWidth\"\n\t\t(detach)=\"handleDetach()\"\n\t\t(overlayOutsideClick)=\"handleClickOutside($event)\"\n\t\t(positionChange)=\"onPositionChange($event)\"\n\t>\n\t\t<div class=\"contents\" [attr.data-theme]=\"themeDomService.themeOf(field)\">\n\t\t\t<div\n\t\t\t\t[class]=\"'rounded-box shadow-overlay w-full ' + animationClasses()\"\n\t\t\t\t(animationend)=\"onAnimationEnd($event)\"\n\t\t\t\t[attr.data-state]=\"dataState\"\n\t\t\t\t[attr.data-side]=\"placement()?.side\"\n\t\t\t\t[attr.data-align]=\"placement()?.align\"\n\t\t\t>\n\t\t\t\t<div class=\"bg-base-200 rounded-box border-neutral overflow-hidden border border-solid\">\n\t\t\t\t\t<!-- Options List -->\n\t\t\t\t\t@let menuClass = this.menuClass();\n\t\t\t\t\t<ul\n\t\t\t\t\t\t[class]=\"menuClass\"\n\t\t\t\t\t\tcdkListbox\n\t\t\t\t\t\tcdkListboxUseActiveDescendant\n\t\t\t\t\t\taria-labelledby=\"Select options\"\n\t\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\t\t#optionsList\n\t\t\t\t\t\t[tabindex]=\"0\"\n\t\t\t\t\t\t(keydown)=\"handleListboxKeydown($event)\"\n\t\t\t\t\t\t(selectionChange)=\"handleSelectionChange($event)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t@for (option of options; track $index) {\n\t\t\t\t\t\t\t<li [cdkOption]=\"option\" class=\"group\" [attr.data-option-index]=\"$index\" [class.cdk-option-active]=\"isActiveOption($index)\">\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\tclass=\"group-[.cdk-option-active]:bg-base-300 font-body flex w-full items-center justify-between rounded-none px-4 py-2 text-left leading-normal font-normal text-pretty transition-colors duration-150 ease-in-out\"\n\t\t\t\t\t\t\t\t\t(click)=\"handleOptionSelect(option)\"\n\t\t\t\t\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span class=\"min-w-0 flex-1 wrap-break-word whitespace-normal\">{{ getDisplayValue(option) }}</span>\n\n\t\t\t\t\t\t\t\t\t@if (isOptionSelected(option)) {\n\t\t\t\t\t\t\t\t\t\t<st-icon class=\"h-4 w-4 shrink-0\" [icon]=\"iconCheck\"></st-icon>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t<!-- Empty state -->\n\t\t\t\t\t\t@if (options.length === 0) {\n\t\t\t\t\t\t\t<li class=\"text-base-content-muted px-4 py-2 text-center\">\n\t\t\t\t\t\t\t\t<span>No options available</span>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t}\n\t\t\t\t\t</ul>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</ng-template>\n\n\t@if (label) {\n\t\t<label class=\"sr-only\" [for]=\"resolvedId()\">{{ label }}</label>\n\t}\n\n\t<!-- Additional content -->\n\t<ng-content></ng-content>\n</fieldset>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i1.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: i1.CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }, { kind: "ngmodule", type: PortalModule }, { kind: "directive", type: CdkListbox, selector: "[cdkListbox]", inputs: ["id", "tabindex", "cdkListboxValue", "cdkListboxMultiple", "cdkListboxDisabled", "cdkListboxUseActiveDescendant", "cdkListboxOrientation", "cdkListboxCompareWith", "cdkListboxNavigationWrapDisabled", "cdkListboxNavigatesDisabledOptions"], outputs: ["cdkListboxValueChange"], exportAs: ["cdkListbox"] }, { kind: "directive", type: CdkOption, selector: "[cdkOption]", inputs: ["id", "cdkOption", "cdkOptionTypeaheadLabel", "cdkOptionDisabled", "tabindex"], exportAs: ["cdkOption"] }, { kind: "component", type: IconComponent, selector: "st-icon", inputs: ["color", "size", "icon", "ariaLabel"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1154
|
+
], viewQueries: [{ propertyName: "fieldRef", first: true, predicate: ["field"], descendants: true, isSignal: true }, { propertyName: "triggerRef", first: true, predicate: ["trigger"], descendants: true, isSignal: true }, { propertyName: "optionsList", first: true, predicate: ["optionsList"], descendants: true, isSignal: true }, { propertyName: "listbox", first: true, predicate: ["listbox"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->\n<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->\n<!-- Field chrome click is pointer-only sugar; keyboard access is the focusable trigger button inside. -->\n@let isOpen = this.isOpen(); @let triggerWidth = this.triggerWidth(); @let dataState = this.dataState(); @let options = this.options();\n@let displayValue = this.displayValue();\n@let label = this.label();\n@let fitOptions = this.fitOptions(); @let contentPanel = this.contentPanel();\n\n<!-- One option on a single line (content-width panel and option sizer): label, description, check slot (always 16px in the sizer) -->\n<ng-template #optionLine let-option let-sizer=\"sizer\">\n\t@let lineDescription = getOptionDescription(option);\n\t<span class=\"flex min-w-0 grow items-center\">\n\t\t<span data-st-option-label [class]=\"lineDescription ? 'max-w-[calc(100%-1.25rem)] shrink-0 truncate' : 'max-w-full shrink-0 truncate'\">{{\n\t\t\tgetDisplayValue(option)\n\t\t}}</span>\n\t\t@if (lineDescription) {\n\t\t\t<span class=\"sr-only\">, </span>\n\t\t\t<span\n\t\t\t\tdata-st-option-description\n\t\t\t\tclass=\"text-base-content-muted ms-3 me-2 min-w-0 grow truncate text-end text-sm group-data-disabled:text-(--color-disabled-content)\"\n\t\t\t\t>{{ lineDescription }}</span\n\t\t\t>\n\t\t}\n\t</span>\n\t@if (sizer) {\n\t\t<span class=\"size-4 shrink-0\"></span>\n\t} @else if (isOptionSelected(option)) {\n\t\t<st-icon class=\"h-4 w-4 shrink-0\" [icon]=\"iconCheck\"></st-icon>\n\t} @else if (isOptionChecked(option)) {\n\t\t<st-icon data-st-option-checked class=\"h-4 w-4 shrink-0 group-data-disabled:text-(--color-disabled-content)\" [icon]=\"iconCheck\"></st-icon>\n\t} @else {\n\t\t<span aria-hidden=\"true\" class=\"size-4 shrink-0\"></span>\n\t}\n</ng-template>\n\n<!-- Hidden stack of every option row, so CSS takes the widest as the width -->\n<ng-template #optionSizer let-placement>\n\t<ul aria-hidden=\"true\" data-st-option-sizer [class]=\"optionSizerClass() + ' ' + placement\">\n\t\t@for (section of optionSections(); track section.label) {\n\t\t\t@if (section.label) {\n\t\t\t\t<li class=\"menu-title px-4 font-semibold whitespace-nowrap\">{{ section.label }}</li>\n\t\t\t}\n\t\t\t@for (entry of section.options; track entry.index) {\n\t\t\t\t<li>\n\t\t\t\t\t<div [class]=\"optionRowClass + ' whitespace-nowrap'\">\n\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"optionLine; context: { $implicit: entry.option, sizer: true }\" />\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t}\n\t\t}\n\t</ul>\n</ng-template>\n\n<fieldset class=\"fieldset p-0\">\n\t@if (label) {\n\t\t<legend class=\"fieldset-legend font-body w-full items-center justify-between gap-2 pt-0 font-normal text-pretty\">\n\t\t\t<span\n\t\t\t\t>{{ label }}\n\t\t\t\t@if (fieldA11y.required()) {\n\t\t\t\t\t<span aria-hidden=\"true\" data-st-required-marker class=\"text-error-strong ms-0.5\">*</span>\n\t\t\t\t}\n\t\t\t</span>\n\t\t\t@if (showOptional()) {\n\t\t\t\t<span class=\"label font-body text-xs font-normal\">{{ optionalText() | translate }}</span>\n\t\t\t}\n\t\t</legend>\n\t}\n\n\t<div [class]=\"fitOptions ? 'grid' : 'contents'\">\n\t\t@if (fitOptions) {\n\t\t\t<ng-container *ngTemplateOutlet=\"optionSizer; context: { $implicit: 'col-start-1 row-start-1 border-x border-solid border-transparent' }\" />\n\t\t}\n\t\t<div\n\t\t\t#field\n\t\t\tcdkOverlayOrigin\n\t\t\t#overlayOrigin=\"cdkOverlayOrigin\"\n\t\t\t[class]=\"validationClass()\"\n\t\t\t[class.col-start-1]=\"fitOptions\"\n\t\t\t[class.row-start-1]=\"fitOptions\"\n\t\t\t[attr.data-open]=\"isOpen ? '' : null\"\n\t\t\t(click)=\"handleFieldChromeClick($event)\"\n\t\t>\n\t\t\t<button\n\t\t\t\t#trigger\n\t\t\t\t[id]=\"resolvedId()\"\n\t\t\t\t[attr.aria-required]=\"fieldA11y.required() || null\"\n\t\t\t\t[attr.aria-invalid]=\"fieldA11y.invalid() || null\"\n\t\t\t\t[attr.aria-describedby]=\"fieldA11y.describedBy()\"\n\t\t\t\tclass=\"min-w-0 flex-1 grow cursor-pointer bg-transparent p-0 text-left outline-hidden\"\n\t\t\t\t(click)=\"handleClick($event)\"\n\t\t\t\t(keydown)=\"handleTriggerKeydown($event)\"\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-haspopup=\"listbox\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\t[attr.aria-controls]=\"listboxId\"\n\t\t\t\t[attr.aria-expanded]=\"isOpen\"\n\t\t\t\t[disabled]=\"disabled()\"\n\t\t\t>\n\t\t\t\t@if (fitOptions) {\n\t\t\t\t\t<span class=\"grid min-w-0\">\n\t\t\t\t\t\t<span class=\"col-start-1 row-start-1 block min-w-0 truncate text-left\">{{ displayValue }}</span>\n\t\t\t\t\t\t<span aria-hidden=\"true\" data-st-value-sizer class=\"invisible col-start-1 row-start-1 h-0 overflow-hidden\">\n\t\t\t\t\t\t\t@for (text of valueSizerLabels(); track $index) {\n\t\t\t\t\t\t\t\t<span class=\"block whitespace-nowrap\">{{ text }}</span>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t} @else {\n\t\t\t\t\t<span class=\"block min-w-0 truncate text-left\">\n\t\t\t\t\t\t{{ displayValue }}\n\t\t\t\t\t</span>\n\t\t\t\t}\n\t\t\t</button>\n\t\t\t@if (showClearButton()) {\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-st-clear\n\t\t\t\t\tclass=\"btn btn-ghost btn-square shrink-0 cursor-pointer [--fontsize:1em] [--size:1.25em]\"\n\t\t\t\t\t(click)=\"handleClearSelection($event)\"\n\t\t\t\t\t(keydown.enter)=\"handleClearSelection($event)\"\n\t\t\t\t\t(keydown.space)=\"handleClearSelection($event)\"\n\t\t\t\t\t[attr.aria-label]=\"clearSelectionLabel()\"\n\t\t\t\t>\n\t\t\t\t\t<st-icon [icon]=\"iconClose\"></st-icon>\n\t\t\t\t</button>\n\t\t\t} @else if (fitOptions && allowClear()) {\n\t\t\t\t<!-- Keeps the clear button's room so the fitted control does not change width when a value is chosen -->\n\t\t\t\t<span aria-hidden=\"true\" data-st-clear-spacer class=\"w-[1.25em] shrink-0\"></span>\n\t\t\t}\n\t\t\t<span data-st-chevron class=\"pointer-events-none inline-flex size-[1em] shrink-0 items-center justify-center\" aria-hidden=\"true\">\n\t\t\t\t<st-icon [icon]=\"iconChevronDown\"></st-icon>\n\t\t\t</span>\n\t\t</div>\n\t</div>\n\n\t<ng-template\n\t\tcdkConnectedOverlay\n\t\t[cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n\t\t[cdkConnectedOverlayOpen]=\"isOpen\"\n\t\t[cdkConnectedOverlayPositions]=\"activeOverlayPositions()\"\n\t\t[cdkConnectedOverlayDisableClose]=\"true\"\n\t\t[cdkConnectedOverlayWidth]=\"overlayWidth()\"\n\t\t[cdkConnectedOverlayMinWidth]=\"triggerWidth\"\n\t\t(detach)=\"handleDetach()\"\n\t\t(overlayOutsideClick)=\"handleClickOutside($event)\"\n\t\t(positionChange)=\"onPositionChange($event)\"\n\t>\n\t\t<div class=\"contents\" [attr.data-theme]=\"themeDomService.themeOf(field)\">\n\t\t\t<div\n\t\t\t\t[class]=\"panelClass()\"\n\t\t\t\t(animationend)=\"onAnimationEnd($event)\"\n\t\t\t\t[attr.data-state]=\"dataState\"\n\t\t\t\t[attr.data-side]=\"placement()?.side\"\n\t\t\t\t[attr.data-align]=\"placement()?.align\"\n\t\t\t>\n\t\t\t\t<div class=\"bg-base-200 rounded-box border-neutral overflow-hidden border border-solid\">\n\t\t\t\t\t<!-- Options List -->\n\t\t\t\t\t@let menuClass = this.menuClass();\n\t\t\t\t\t<ul\n\t\t\t\t\t\t[class]=\"menuClass\"\n\t\t\t\t\t\tcdkListbox\n\t\t\t\t\t\tcdkListboxUseActiveDescendant\n\t\t\t\t\t\t[id]=\"listboxId\"\n\t\t\t\t\t\t[attr.aria-labelledby]=\"label ? labelId : resolvedId()\"\n\t\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\t\t#optionsList\n\t\t\t\t\t\t[tabindex]=\"0\"\n\t\t\t\t\t\t(keydown)=\"handleListboxKeydown($event)\"\n\t\t\t\t\t\t(selectionChange)=\"handleSelectionChange($event)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ng-template #optionTemplate let-option let-index=\"index\">\n\t\t\t\t\t\t\t@let optionDisabled = isOptionDisabled(option);\n\t\t\t\t\t\t\t@let optionDescription = getOptionDescription(option);\n\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\t[cdkOption]=\"option\"\n\t\t\t\t\t\t\t\t[cdkOptionDisabled]=\"optionDisabled\"\n\t\t\t\t\t\t\t\tclass=\"group\"\n\t\t\t\t\t\t\t\t[attr.data-option-index]=\"index\"\n\t\t\t\t\t\t\t\t[attr.data-disabled]=\"optionDisabled ? '' : null\"\n\t\t\t\t\t\t\t\t[class.cdk-option-active]=\"isActiveOption(index)\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t@if (contentPanel) {\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t[class]=\"optionRowClass + ' whitespace-nowrap'\"\n\t\t\t\t\t\t\t\t\t\t(click)=\"handleOptionSelect(option)\"\n\t\t\t\t\t\t\t\t\t\t(mouseenter)=\"syncOptionTitle($event, option)\"\n\t\t\t\t\t\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"optionLine; context: { $implicit: option }\" />\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t\t\t<button type=\"button\" [class]=\"optionRowClass\" (click)=\"handleOptionSelect(option)\" tabindex=\"-1\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"min-w-min flex-1 wrap-break-word whitespace-normal\">\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"block\">{{ getDisplayValue(option) }}</span>\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t@if (optionDescription) {\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"sr-only\">, </span>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tdata-st-option-description\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"text-base-content-muted ms-3 min-w-0 truncate text-end text-sm not-last:me-2 group-data-disabled:text-(--color-disabled-content)\"\n\t\t\t\t\t\t\t\t\t\t\t\t>{{ optionDescription }}</span\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t@if (isOptionSelected(option)) {\n\t\t\t\t\t\t\t\t\t\t\t<st-icon class=\"h-4 w-4 shrink-0\" [icon]=\"iconCheck\"></st-icon>\n\t\t\t\t\t\t\t\t\t\t} @else if (isOptionChecked(option)) {\n\t\t\t\t\t\t\t\t\t\t\t<st-icon\n\t\t\t\t\t\t\t\t\t\t\t\tdata-st-option-checked\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"h-4 w-4 shrink-0 group-data-disabled:text-(--color-disabled-content)\"\n\t\t\t\t\t\t\t\t\t\t\t\t[icon]=\"iconCheck\"\n\t\t\t\t\t\t\t\t\t\t\t></st-icon>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ng-template>\n\n\t\t\t\t\t\t@for (section of optionSections(); track section.label; let firstSection = $first) {\n\t\t\t\t\t\t\t@if (section.headerId) {\n\t\t\t\t\t\t\t\t@if (!firstSection) {\n\t\t\t\t\t\t\t\t\t<li role=\"none\" data-st-option-group-separator class=\"pointer-events-none top-0 left-0 mx-0 my-1 w-full p-0\"></li>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t<li role=\"none\" data-st-option-group>\n\t\t\t\t\t\t\t\t\t<ul role=\"group\" class=\"ms-0 ps-0 whitespace-normal before:hidden\" [attr.aria-labelledby]=\"section.headerId\">\n\t\t\t\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\t\t\t\t\tdata-st-option-group-header\n\t\t\t\t\t\t\t\t\t\t\tclass=\"menu-title text-base-content-secondary px-4 font-semibold\"\n\t\t\t\t\t\t\t\t\t\t\t[id]=\"section.headerId\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{{ section.label }}\n\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t@for (entry of section.options; track entry.index) {\n\t\t\t\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"optionTemplate; context: { $implicit: entry.option, index: entry.index }\" />\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t\t@for (entry of section.options; track entry.index) {\n\t\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"optionTemplate; context: { $implicit: entry.option, index: entry.index }\" />\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t<!-- Empty state -->\n\t\t\t\t\t\t@if (options.length === 0) {\n\t\t\t\t\t\t\t<li class=\"text-base-content-muted px-4 py-2 text-center\">\n\t\t\t\t\t\t\t\t<span>{{ noOptionsLabel() }}</span>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t}\n\t\t\t\t\t</ul>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</ng-template>\n\n\t@if (label) {\n\t\t<label class=\"sr-only\" [id]=\"labelId\" [for]=\"resolvedId()\">{{ label }}</label>\n\t}\n\n\t<!-- Additional content -->\n\t<ng-content></ng-content>\n</fieldset>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i1.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: i1.CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }, { kind: "ngmodule", type: PortalModule }, { kind: "directive", type: CdkListbox, selector: "[cdkListbox]", inputs: ["id", "tabindex", "cdkListboxValue", "cdkListboxMultiple", "cdkListboxDisabled", "cdkListboxUseActiveDescendant", "cdkListboxOrientation", "cdkListboxCompareWith", "cdkListboxNavigationWrapDisabled", "cdkListboxNavigatesDisabledOptions"], outputs: ["cdkListboxValueChange"], exportAs: ["cdkListbox"] }, { kind: "directive", type: CdkOption, selector: "[cdkOption]", inputs: ["id", "cdkOption", "cdkOptionTypeaheadLabel", "cdkOptionDisabled", "tabindex"], exportAs: ["cdkOption"] }, { kind: "component", type: IconComponent, selector: "st-icon", inputs: ["color", "size", "icon", "ariaLabel"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
919
1155
|
}
|
|
920
1156
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SelectComponent, decorators: [{
|
|
921
1157
|
type: Component,
|
|
922
|
-
args: [{ selector: 'st-select', imports: [FormsModule, OverlayModule, PortalModule, CdkListbox, CdkOption, IconComponent, TranslatePipe], providers: [
|
|
1158
|
+
args: [{ selector: 'st-select', imports: [FormsModule, NgTemplateOutlet, OverlayModule, PortalModule, CdkListbox, CdkOption, IconComponent, TranslatePipe], providers: [
|
|
923
1159
|
{
|
|
924
1160
|
provide: NG_VALUE_ACCESSOR,
|
|
925
1161
|
useExisting: SelectComponent,
|
|
926
1162
|
multi: true,
|
|
927
1163
|
},
|
|
928
|
-
], changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1164
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
1165
|
+
'[class.inline-block]': 'fitOptions()',
|
|
1166
|
+
'[class.align-top]': 'fitOptions()',
|
|
1167
|
+
'[class.shrink-0]': 'fitOptions()',
|
|
1168
|
+
}, template: "<!-- eslint-disable @angular-eslint/template/interactive-supports-focus -->\n<!-- eslint-disable @angular-eslint/template/click-events-have-key-events -->\n<!-- Field chrome click is pointer-only sugar; keyboard access is the focusable trigger button inside. -->\n@let isOpen = this.isOpen(); @let triggerWidth = this.triggerWidth(); @let dataState = this.dataState(); @let options = this.options();\n@let displayValue = this.displayValue();\n@let label = this.label();\n@let fitOptions = this.fitOptions(); @let contentPanel = this.contentPanel();\n\n<!-- One option on a single line (content-width panel and option sizer): label, description, check slot (always 16px in the sizer) -->\n<ng-template #optionLine let-option let-sizer=\"sizer\">\n\t@let lineDescription = getOptionDescription(option);\n\t<span class=\"flex min-w-0 grow items-center\">\n\t\t<span data-st-option-label [class]=\"lineDescription ? 'max-w-[calc(100%-1.25rem)] shrink-0 truncate' : 'max-w-full shrink-0 truncate'\">{{\n\t\t\tgetDisplayValue(option)\n\t\t}}</span>\n\t\t@if (lineDescription) {\n\t\t\t<span class=\"sr-only\">, </span>\n\t\t\t<span\n\t\t\t\tdata-st-option-description\n\t\t\t\tclass=\"text-base-content-muted ms-3 me-2 min-w-0 grow truncate text-end text-sm group-data-disabled:text-(--color-disabled-content)\"\n\t\t\t\t>{{ lineDescription }}</span\n\t\t\t>\n\t\t}\n\t</span>\n\t@if (sizer) {\n\t\t<span class=\"size-4 shrink-0\"></span>\n\t} @else if (isOptionSelected(option)) {\n\t\t<st-icon class=\"h-4 w-4 shrink-0\" [icon]=\"iconCheck\"></st-icon>\n\t} @else if (isOptionChecked(option)) {\n\t\t<st-icon data-st-option-checked class=\"h-4 w-4 shrink-0 group-data-disabled:text-(--color-disabled-content)\" [icon]=\"iconCheck\"></st-icon>\n\t} @else {\n\t\t<span aria-hidden=\"true\" class=\"size-4 shrink-0\"></span>\n\t}\n</ng-template>\n\n<!-- Hidden stack of every option row, so CSS takes the widest as the width -->\n<ng-template #optionSizer let-placement>\n\t<ul aria-hidden=\"true\" data-st-option-sizer [class]=\"optionSizerClass() + ' ' + placement\">\n\t\t@for (section of optionSections(); track section.label) {\n\t\t\t@if (section.label) {\n\t\t\t\t<li class=\"menu-title px-4 font-semibold whitespace-nowrap\">{{ section.label }}</li>\n\t\t\t}\n\t\t\t@for (entry of section.options; track entry.index) {\n\t\t\t\t<li>\n\t\t\t\t\t<div [class]=\"optionRowClass + ' whitespace-nowrap'\">\n\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"optionLine; context: { $implicit: entry.option, sizer: true }\" />\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t}\n\t\t}\n\t</ul>\n</ng-template>\n\n<fieldset class=\"fieldset p-0\">\n\t@if (label) {\n\t\t<legend class=\"fieldset-legend font-body w-full items-center justify-between gap-2 pt-0 font-normal text-pretty\">\n\t\t\t<span\n\t\t\t\t>{{ label }}\n\t\t\t\t@if (fieldA11y.required()) {\n\t\t\t\t\t<span aria-hidden=\"true\" data-st-required-marker class=\"text-error-strong ms-0.5\">*</span>\n\t\t\t\t}\n\t\t\t</span>\n\t\t\t@if (showOptional()) {\n\t\t\t\t<span class=\"label font-body text-xs font-normal\">{{ optionalText() | translate }}</span>\n\t\t\t}\n\t\t</legend>\n\t}\n\n\t<div [class]=\"fitOptions ? 'grid' : 'contents'\">\n\t\t@if (fitOptions) {\n\t\t\t<ng-container *ngTemplateOutlet=\"optionSizer; context: { $implicit: 'col-start-1 row-start-1 border-x border-solid border-transparent' }\" />\n\t\t}\n\t\t<div\n\t\t\t#field\n\t\t\tcdkOverlayOrigin\n\t\t\t#overlayOrigin=\"cdkOverlayOrigin\"\n\t\t\t[class]=\"validationClass()\"\n\t\t\t[class.col-start-1]=\"fitOptions\"\n\t\t\t[class.row-start-1]=\"fitOptions\"\n\t\t\t[attr.data-open]=\"isOpen ? '' : null\"\n\t\t\t(click)=\"handleFieldChromeClick($event)\"\n\t\t>\n\t\t\t<button\n\t\t\t\t#trigger\n\t\t\t\t[id]=\"resolvedId()\"\n\t\t\t\t[attr.aria-required]=\"fieldA11y.required() || null\"\n\t\t\t\t[attr.aria-invalid]=\"fieldA11y.invalid() || null\"\n\t\t\t\t[attr.aria-describedby]=\"fieldA11y.describedBy()\"\n\t\t\t\tclass=\"min-w-0 flex-1 grow cursor-pointer bg-transparent p-0 text-left outline-hidden\"\n\t\t\t\t(click)=\"handleClick($event)\"\n\t\t\t\t(keydown)=\"handleTriggerKeydown($event)\"\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-haspopup=\"listbox\"\n\t\t\t\trole=\"combobox\"\n\t\t\t\t[attr.aria-controls]=\"listboxId\"\n\t\t\t\t[attr.aria-expanded]=\"isOpen\"\n\t\t\t\t[disabled]=\"disabled()\"\n\t\t\t>\n\t\t\t\t@if (fitOptions) {\n\t\t\t\t\t<span class=\"grid min-w-0\">\n\t\t\t\t\t\t<span class=\"col-start-1 row-start-1 block min-w-0 truncate text-left\">{{ displayValue }}</span>\n\t\t\t\t\t\t<span aria-hidden=\"true\" data-st-value-sizer class=\"invisible col-start-1 row-start-1 h-0 overflow-hidden\">\n\t\t\t\t\t\t\t@for (text of valueSizerLabels(); track $index) {\n\t\t\t\t\t\t\t\t<span class=\"block whitespace-nowrap\">{{ text }}</span>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</span>\n\t\t\t\t} @else {\n\t\t\t\t\t<span class=\"block min-w-0 truncate text-left\">\n\t\t\t\t\t\t{{ displayValue }}\n\t\t\t\t\t</span>\n\t\t\t\t}\n\t\t\t</button>\n\t\t\t@if (showClearButton()) {\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-st-clear\n\t\t\t\t\tclass=\"btn btn-ghost btn-square shrink-0 cursor-pointer [--fontsize:1em] [--size:1.25em]\"\n\t\t\t\t\t(click)=\"handleClearSelection($event)\"\n\t\t\t\t\t(keydown.enter)=\"handleClearSelection($event)\"\n\t\t\t\t\t(keydown.space)=\"handleClearSelection($event)\"\n\t\t\t\t\t[attr.aria-label]=\"clearSelectionLabel()\"\n\t\t\t\t>\n\t\t\t\t\t<st-icon [icon]=\"iconClose\"></st-icon>\n\t\t\t\t</button>\n\t\t\t} @else if (fitOptions && allowClear()) {\n\t\t\t\t<!-- Keeps the clear button's room so the fitted control does not change width when a value is chosen -->\n\t\t\t\t<span aria-hidden=\"true\" data-st-clear-spacer class=\"w-[1.25em] shrink-0\"></span>\n\t\t\t}\n\t\t\t<span data-st-chevron class=\"pointer-events-none inline-flex size-[1em] shrink-0 items-center justify-center\" aria-hidden=\"true\">\n\t\t\t\t<st-icon [icon]=\"iconChevronDown\"></st-icon>\n\t\t\t</span>\n\t\t</div>\n\t</div>\n\n\t<ng-template\n\t\tcdkConnectedOverlay\n\t\t[cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n\t\t[cdkConnectedOverlayOpen]=\"isOpen\"\n\t\t[cdkConnectedOverlayPositions]=\"activeOverlayPositions()\"\n\t\t[cdkConnectedOverlayDisableClose]=\"true\"\n\t\t[cdkConnectedOverlayWidth]=\"overlayWidth()\"\n\t\t[cdkConnectedOverlayMinWidth]=\"triggerWidth\"\n\t\t(detach)=\"handleDetach()\"\n\t\t(overlayOutsideClick)=\"handleClickOutside($event)\"\n\t\t(positionChange)=\"onPositionChange($event)\"\n\t>\n\t\t<div class=\"contents\" [attr.data-theme]=\"themeDomService.themeOf(field)\">\n\t\t\t<div\n\t\t\t\t[class]=\"panelClass()\"\n\t\t\t\t(animationend)=\"onAnimationEnd($event)\"\n\t\t\t\t[attr.data-state]=\"dataState\"\n\t\t\t\t[attr.data-side]=\"placement()?.side\"\n\t\t\t\t[attr.data-align]=\"placement()?.align\"\n\t\t\t>\n\t\t\t\t<div class=\"bg-base-200 rounded-box border-neutral overflow-hidden border border-solid\">\n\t\t\t\t\t<!-- Options List -->\n\t\t\t\t\t@let menuClass = this.menuClass();\n\t\t\t\t\t<ul\n\t\t\t\t\t\t[class]=\"menuClass\"\n\t\t\t\t\t\tcdkListbox\n\t\t\t\t\t\tcdkListboxUseActiveDescendant\n\t\t\t\t\t\t[id]=\"listboxId\"\n\t\t\t\t\t\t[attr.aria-labelledby]=\"label ? labelId : resolvedId()\"\n\t\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\t\t#optionsList\n\t\t\t\t\t\t[tabindex]=\"0\"\n\t\t\t\t\t\t(keydown)=\"handleListboxKeydown($event)\"\n\t\t\t\t\t\t(selectionChange)=\"handleSelectionChange($event)\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ng-template #optionTemplate let-option let-index=\"index\">\n\t\t\t\t\t\t\t@let optionDisabled = isOptionDisabled(option);\n\t\t\t\t\t\t\t@let optionDescription = getOptionDescription(option);\n\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\t[cdkOption]=\"option\"\n\t\t\t\t\t\t\t\t[cdkOptionDisabled]=\"optionDisabled\"\n\t\t\t\t\t\t\t\tclass=\"group\"\n\t\t\t\t\t\t\t\t[attr.data-option-index]=\"index\"\n\t\t\t\t\t\t\t\t[attr.data-disabled]=\"optionDisabled ? '' : null\"\n\t\t\t\t\t\t\t\t[class.cdk-option-active]=\"isActiveOption(index)\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t@if (contentPanel) {\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t[class]=\"optionRowClass + ' whitespace-nowrap'\"\n\t\t\t\t\t\t\t\t\t\t(click)=\"handleOptionSelect(option)\"\n\t\t\t\t\t\t\t\t\t\t(mouseenter)=\"syncOptionTitle($event, option)\"\n\t\t\t\t\t\t\t\t\t\ttabindex=\"-1\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"optionLine; context: { $implicit: option }\" />\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t\t\t<button type=\"button\" [class]=\"optionRowClass\" (click)=\"handleOptionSelect(option)\" tabindex=\"-1\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"min-w-min flex-1 wrap-break-word whitespace-normal\">\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"block\">{{ getDisplayValue(option) }}</span>\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t@if (optionDescription) {\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"sr-only\">, </span>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tdata-st-option-description\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"text-base-content-muted ms-3 min-w-0 truncate text-end text-sm not-last:me-2 group-data-disabled:text-(--color-disabled-content)\"\n\t\t\t\t\t\t\t\t\t\t\t\t>{{ optionDescription }}</span\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t@if (isOptionSelected(option)) {\n\t\t\t\t\t\t\t\t\t\t\t<st-icon class=\"h-4 w-4 shrink-0\" [icon]=\"iconCheck\"></st-icon>\n\t\t\t\t\t\t\t\t\t\t} @else if (isOptionChecked(option)) {\n\t\t\t\t\t\t\t\t\t\t\t<st-icon\n\t\t\t\t\t\t\t\t\t\t\t\tdata-st-option-checked\n\t\t\t\t\t\t\t\t\t\t\t\tclass=\"h-4 w-4 shrink-0 group-data-disabled:text-(--color-disabled-content)\"\n\t\t\t\t\t\t\t\t\t\t\t\t[icon]=\"iconCheck\"\n\t\t\t\t\t\t\t\t\t\t\t></st-icon>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t</ng-template>\n\n\t\t\t\t\t\t@for (section of optionSections(); track section.label; let firstSection = $first) {\n\t\t\t\t\t\t\t@if (section.headerId) {\n\t\t\t\t\t\t\t\t@if (!firstSection) {\n\t\t\t\t\t\t\t\t\t<li role=\"none\" data-st-option-group-separator class=\"pointer-events-none top-0 left-0 mx-0 my-1 w-full p-0\"></li>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t<li role=\"none\" data-st-option-group>\n\t\t\t\t\t\t\t\t\t<ul role=\"group\" class=\"ms-0 ps-0 whitespace-normal before:hidden\" [attr.aria-labelledby]=\"section.headerId\">\n\t\t\t\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\t\t\t\t\tdata-st-option-group-header\n\t\t\t\t\t\t\t\t\t\t\tclass=\"menu-title text-base-content-secondary px-4 font-semibold\"\n\t\t\t\t\t\t\t\t\t\t\t[id]=\"section.headerId\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{{ section.label }}\n\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t\t@for (entry of section.options; track entry.index) {\n\t\t\t\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"optionTemplate; context: { $implicit: entry.option, index: entry.index }\" />\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t} @else {\n\t\t\t\t\t\t\t\t@for (entry of section.options; track entry.index) {\n\t\t\t\t\t\t\t\t\t<ng-container *ngTemplateOutlet=\"optionTemplate; context: { $implicit: entry.option, index: entry.index }\" />\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t<!-- Empty state -->\n\t\t\t\t\t\t@if (options.length === 0) {\n\t\t\t\t\t\t\t<li class=\"text-base-content-muted px-4 py-2 text-center\">\n\t\t\t\t\t\t\t\t<span>{{ noOptionsLabel() }}</span>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t}\n\t\t\t\t\t</ul>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</ng-template>\n\n\t@if (label) {\n\t\t<label class=\"sr-only\" [id]=\"labelId\" [for]=\"resolvedId()\">{{ label }}</label>\n\t}\n\n\t<!-- Additional content -->\n\t<ng-content></ng-content>\n</fieldset>\n" }]
|
|
929
1169
|
}] });
|
|
930
1170
|
|
|
931
1171
|
/**
|