import m from 'mithril'; import { PopoverPosition, ISelectAttrs, Select } from '../../'; export interface IPopoverPositionSelectAttrs extends ISelectAttrs { onSelect: (e: PopoverPosition) => void; } export class PopoverPositionSelect implements m.Component { public view({ attrs: { onSelect, ...otherAttrs } }: m.Vnode) { return m(Select, { ...otherAttrs, fluid: true, options: Object.keys(PopoverPosition).map(key => PopoverPosition[key]), onchange: (e: Event) => { const target = (e.target as HTMLSelectElement); const position = target.options[target.options.selectedIndex].value as PopoverPosition; onSelect(position); }, size: 'xs' }); } }