import Icon from "./Icon.js"; import Button from "./Button.js"; import List from "./List.js"; import Input from "./Input.js"; import Title from "./Title.js"; import PopoverHorizontalAlign from "./types/PopoverHorizontalAlign.js"; import Popover from "./Popover.js"; import ResponsivePopover from "./ResponsivePopover.js"; import BusyIndicator from "./BusyIndicator.js"; import SuggestionItem from "./SuggestionItem.js"; import type ComboBox from "./ComboBox.js"; import { LOADING_DELAY } from "./features/ComboBoxLazyLoading.js"; export default function ComboBoxPopoverTemplate(this: ComboBox) { return ( <> {this._isPhone && dialogHeader.call(this)} {valueStateHeader.call(this)} {content.call(this)} {this._isPhone && dialogFooter.call(this)} {this.shouldOpenValueStateMessagePopover &&
{valueStateMessage.call(this)}
} ); } function valueStateMessage(this: ComboBox) { return ( <> {this.shouldDisplayDefaultValueStateMessage ? this.valueStateDefaultText : } ); } function valueStateHeader(this: ComboBox) { if (!this.hasValueStateText) { return; } if (this._isPhone) { return (
{this.open && valueStateMessage.call(this)}
); } return (
{this.open && valueStateMessage.call(this)}
); } function content(this: ComboBox) { if (this.loading && (this._isPhone || !this.hasValueState)) { return ; } const loadingOnDesktopWithValueState = this.loading && !this._isPhone && this.hasValueState; const hasFilteredItems = !this.loading && !!this._filteredItems?.length; if (!loadingOnDesktopWithValueState && !hasFilteredItems) { return; } return ( <> {loadingOnDesktopWithValueState &&
} {hasFilteredItems && {this._filteredItems.map(item => )} } ); } function dialogFooter(this: ComboBox) { return ( ); } function dialogHeader(this: ComboBox) { return <>
{this._headerTitleText}
{!this.loading && this._filteredItems.flatMap(item => { if (item.isGroupItem && item.items) { // For group items, return all nested items return item.items .filter(nestedItem => !!nestedItem) .map(nestedItem => ); } // For regular items return ; })}
; }