@thalassic/ui 22.19.1 → 22.19.2
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.
|
@@ -5515,10 +5515,11 @@ class Autocomplete extends AbstractSelect {
|
|
|
5515
5515
|
virtualScrollItemSize = input(this._config.virtualScrollItemSize, { ...(ngDevMode ? { debugName: "virtualScrollItemSize" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
5516
5516
|
/**
|
|
5517
5517
|
* The field's text, emitted as it is typed — the hook for answering a query from a source the
|
|
5518
|
-
* control does not hold.
|
|
5519
|
-
*
|
|
5520
|
-
*
|
|
5521
|
-
*
|
|
5518
|
+
* control does not hold. A typed term is emitted once it reaches {@link minQueryLength}, and an
|
|
5519
|
+
* empty field is emitted however it was emptied (typing, the clear button, a search abandoned by
|
|
5520
|
+
* closing the panel), so a listener is never left holding results for a term the field no longer
|
|
5521
|
+
* shows. Restoring a committed selection's label emits nothing: the item is already chosen, and
|
|
5522
|
+
* searching for it again is noise. Any debouncing belongs to the listener.
|
|
5522
5523
|
*/
|
|
5523
5524
|
queryChange = output();
|
|
5524
5525
|
hasValue = computed(() => {
|
|
@@ -5578,12 +5579,13 @@ class Autocomplete extends AbstractSelect {
|
|
|
5578
5579
|
}
|
|
5579
5580
|
onInput(event) {
|
|
5580
5581
|
const target = event.target;
|
|
5581
|
-
this.
|
|
5582
|
+
this._setQuery(target.value);
|
|
5582
5583
|
this.open();
|
|
5583
5584
|
this.activeIndex.set(this.getInitialActiveIndex());
|
|
5584
|
-
// Typing is the only thing that emits; every other write of `query` re-derives it from
|
|
5585
|
-
// committed selection, and a listener must not be sent a query nobody typed.
|
|
5586
|
-
|
|
5585
|
+
// Typing is the only thing that emits a term; every other write of `query` re-derives it from
|
|
5586
|
+
// the committed selection, and a listener must not be sent a query nobody typed. An emptied
|
|
5587
|
+
// field is announced by the write itself, whatever emptied it.
|
|
5588
|
+
if (target.value !== '' && !this.belowMinQueryLength())
|
|
5587
5589
|
this.queryChange.emit(target.value);
|
|
5588
5590
|
}
|
|
5589
5591
|
onKeydown(event) {
|
|
@@ -5651,11 +5653,13 @@ class Autocomplete extends AbstractSelect {
|
|
|
5651
5653
|
}
|
|
5652
5654
|
onClosed() {
|
|
5653
5655
|
// Discard an unmatched free-text query, restoring the committed selection's label (or empty).
|
|
5654
|
-
this.
|
|
5656
|
+
this._setQuery(this.selectedLabel());
|
|
5655
5657
|
}
|
|
5656
5658
|
clear() {
|
|
5659
|
+
// The text goes first: dropping the value re-derives the field from the (now absent)
|
|
5660
|
+
// selection, which would erase the outgoing text before it can be seen as emptied.
|
|
5661
|
+
this._setQuery('');
|
|
5657
5662
|
this.value.set(null);
|
|
5658
|
-
this.query.set('');
|
|
5659
5663
|
}
|
|
5660
5664
|
getInitialActiveIndex() {
|
|
5661
5665
|
const options = this.visibleOptions();
|
|
@@ -5669,6 +5673,19 @@ class Autocomplete extends AbstractSelect {
|
|
|
5669
5673
|
commitActiveOption(option) {
|
|
5670
5674
|
this.select(option);
|
|
5671
5675
|
}
|
|
5676
|
+
// Private methods
|
|
5677
|
+
/**
|
|
5678
|
+
* Writes the field's text, announcing it whenever the write leaves the field empty. An empty
|
|
5679
|
+
* field is the one state a listener cannot infer from silence — its last results answer a term
|
|
5680
|
+
* that is gone — so it is reported no matter which route emptied the field. A write that lands
|
|
5681
|
+
* on text, including a committed selection's restored label, says nothing on its own.
|
|
5682
|
+
*/
|
|
5683
|
+
_setQuery(text) {
|
|
5684
|
+
const emptied = text === '' && this.query() !== '';
|
|
5685
|
+
this.query.set(text);
|
|
5686
|
+
if (emptied)
|
|
5687
|
+
this.queryChange.emit('');
|
|
5688
|
+
}
|
|
5672
5689
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: Autocomplete, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
5673
5690
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: Autocomplete, isStandalone: true, selector: "tls-autocomplete", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null }, clearable: { classPropertyName: "clearable", publicName: "clearable", isSignal: true, isRequired: false, transformFunction: null }, filterMode: { classPropertyName: "filterMode", publicName: "filterMode", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, minQueryLength: { classPropertyName: "minQueryLength", publicName: "minQueryLength", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, loadingMessage: { classPropertyName: "loadingMessage", publicName: "loadingMessage", isSignal: true, isRequired: false, transformFunction: null }, clearLabel: { classPropertyName: "clearLabel", publicName: "clearLabel", isSignal: true, isRequired: false, transformFunction: null }, virtualScroll: { classPropertyName: "virtualScroll", publicName: "virtualScroll", isSignal: true, isRequired: false, transformFunction: null }, virtualScrollItemSize: { classPropertyName: "virtualScrollItemSize", publicName: "virtualScrollItemSize", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", queryChange: "queryChange" }, host: { properties: { "class": "hostClasses()" } }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => Autocomplete) }], usesInheritance: true, ngImport: i0, template: "<input\n #trigger\n type=\"text\"\n class=\"tls-autocomplete__trigger\"\n role=\"combobox\"\n autocomplete=\"off\"\n [attr.id]=\"effectiveInputId()\"\n [attr.name]=\"name()\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-invalid]=\"invalid() ? 'true' : null\"\n [attr.aria-required]=\"required() ? 'true' : null\"\n [attr.aria-busy]=\"busy() ? 'true' : null\"\n [attr.aria-describedby]=\"describedBy()\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n [attr.aria-controls]=\"isOpen() ? listboxId : null\"\n [attr.aria-activedescendant]=\"activeDescendantId()\"\n [attr.aria-expanded]=\"isOpen()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [tabindex]=\"disabled() ? -1 : tabindex()\"\n [value]=\"query()\"\n (input)=\"onInput($event)\"\n (click)=\"open()\"\n (blur)=\"touched.set(true)\"\n (keydown)=\"onKeydown($event)\"\n/>\n@if (clearable() && hasValue()) {\n <button\n type=\"button\"\n class=\"tls-autocomplete__clear\"\n tabindex=\"-1\"\n [attr.aria-label]=\"clearLabel()\"\n (click)=\"clear()\"\n >\n <tls-icon class=\"tls-autocomplete__clear-icon\" name=\"close\" aria-hidden=\"true\" />\n </button>\n}\n@if (pending()) {\n <tls-loader class=\"tls-autocomplete__spinner\" size=\"xs\" aria-hidden=\"true\" />\n}\n\n<!--\n A live region is only announced reliably when it is already in the DOM before its text\n changes, so the region is permanent and the loading state writes into it. The panel's own\n notice is hidden from assistive technology to keep it from being read twice. Only a search\n behind an open panel is announced: a list nobody is looking at has nothing to report.\n-->\n<div class=\"tls-autocomplete__status\" role=\"status\">\n {{ loading() && isOpen() ? loadingMessage() : '' }}\n</div>\n\n<ng-template #panel>\n <ng-template #optionButton let-option let-index=\"index\" let-setsize=\"setsize\">\n <button\n class=\"tls-autocomplete__option-button\"\n role=\"option\"\n [id]=\"optionId(index)\"\n [disabled]=\"option.disabled\"\n [attr.aria-selected]=\"option.value === value()\"\n [attr.aria-disabled]=\"option.disabled\"\n [attr.aria-posinset]=\"setsize !== null ? index + 1 : null\"\n [attr.aria-setsize]=\"setsize\"\n (click)=\"select(option)\"\n (pointerenter)=\"onOptionHover($event, index, option.disabled)\"\n >\n @if (optionTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"optionContext(option, index)\" />\n } @else {\n {{ option.label }}\n }\n </button>\n </ng-template>\n\n @if (virtualScroll()) {\n <div\n class=\"tls-autocomplete__panel tls-autocomplete__panel--virtual\"\n [class.tls-autocomplete__panel--hidden]=\"!hasPanelContent()\"\n animate.enter=\"tls-autocomplete__panel--enter\"\n animate.leave=\"tls-autocomplete__panel--leave\"\n >\n <tls-virtual-scroll\n [items]=\"visibleOptions()\"\n [itemSize]=\"virtualScrollItemSize()\"\n trackBy=\"value\"\n viewportRole=\"listbox\"\n [viewportId]=\"listboxId\"\n [focusable]=\"false\"\n [style.--tls-virtual-scroll-height]=\"virtualPanelHeight()\"\n >\n <ng-template #item let-option let-index=\"index\" let-count=\"count\">\n <div\n class=\"tls-autocomplete__option\"\n role=\"presentation\"\n [class.tls-autocomplete__option--selected]=\"option.value === value()\"\n [class.tls-autocomplete__option--active]=\"index === activeIndex()\"\n [class.tls-autocomplete__option--disabled]=\"option.disabled\"\n >\n <ng-container\n [ngTemplateOutlet]=\"optionButton\"\n [ngTemplateOutletContext]=\"{ $implicit: option, index: index, setsize: count }\"\n />\n </div>\n </ng-template>\n </tls-virtual-scroll>\n @if (visibleOptions().length === 0) {\n @if (loading()) {\n <div class=\"tls-autocomplete__loading\" role=\"presentation\" aria-hidden=\"true\">\n <tls-loader size=\"xs\" />\n {{ loadingMessage() }}\n </div>\n } @else if (!belowMinQueryLength()) {\n <div class=\"tls-autocomplete__empty\" role=\"presentation\">{{ emptyMessage() }}</div>\n }\n }\n </div>\n } @else {\n <ul\n class=\"tls-autocomplete__panel\"\n [class.tls-autocomplete__panel--hidden]=\"!hasPanelContent()\"\n animate.enter=\"tls-autocomplete__panel--enter\"\n animate.leave=\"tls-autocomplete__panel--leave\"\n role=\"listbox\"\n [id]=\"listboxId\"\n >\n @for (option of visibleOptions(); track option.value; let index = $index) {\n <li\n class=\"tls-autocomplete__option\"\n [class.tls-autocomplete__option--selected]=\"option.value === value()\"\n [class.tls-autocomplete__option--active]=\"index === activeIndex()\"\n [class.tls-autocomplete__option--disabled]=\"option.disabled\"\n >\n <ng-container\n [ngTemplateOutlet]=\"optionButton\"\n [ngTemplateOutletContext]=\"{ $implicit: option, index: index, setsize: null }\"\n />\n </li>\n } @empty {\n @if (loading()) {\n <li class=\"tls-autocomplete__loading\" role=\"presentation\" aria-hidden=\"true\">\n <tls-loader size=\"xs\" />\n {{ loadingMessage() }}\n </li>\n } @else if (!belowMinQueryLength()) {\n <li class=\"tls-autocomplete__empty\" role=\"presentation\">{{ emptyMessage() }}</li>\n }\n }\n </ul>\n }\n</ng-template>\n", dependencies: [{ kind: "component", type: Loader, selector: "tls-loader", inputs: ["size", "width", "widthRatio", "ariaLabel"] }, { kind: "component", type: Icon, selector: "tls-icon", inputs: ["name", "iconSrc", "alt", "allowedSources"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: VirtualScroll, selector: "tls-virtual-scroll", inputs: ["items", "itemSize", "minBufferPx", "maxBufferPx", "orientation", "appendOnly", "templateCacheSize", "trackBy", "viewportRole", "viewportId", "ariaMultiselectable", "focusable", "ariaLabel", "ariaLabelledby", "ariaDescribedby"], outputs: ["scrolledIndexChange"] }] });
|
|
5674
5691
|
}
|