import { Component, ComponentInterface, Listen, Prop, h } from '@stencil/core'; import { getIonMode } from '../../global/ionic-global'; import { SelectPopoverOption } from '../../interface'; import { safeCall } from '../../utils/overlays'; /** * @internal */ @Component({ tag: 'ion-select-popover', styleUrl: 'select-popover.scss', scoped: true }) export class SelectPopover implements ComponentInterface { /** Header text for the popover */ @Prop() header?: string; /** Subheader text for the popover */ @Prop() subHeader?: string; /** Text for popover body */ @Prop() message?: string; /** Array of options for the popover */ @Prop() options: SelectPopoverOption[] = []; @Listen('ionSelect') onSelect(ev: any) { const option = this.options.find(o => o.value === ev.target.value); if (option) { safeCall(option.handler); } } hostData() { const mode = getIonMode(this); return { class: { [mode]: true, } }; } render() { return ( {this.header !== undefined && {this.header}} { (this.subHeader !== undefined || this.message !== undefined) && {this.subHeader !== undefined &&

{this.subHeader}

} {this.message !== undefined &&

{this.message}

}
} {this.options.map(option => {option.text} )}
); } }