import { tag, WeElement, h, extractClass, classNames } from 'omi' import * as css from './index.scss' import { MDCSelect } from '@material/select'; import * as globalCss from './global.scss' import { domReady } from '../util/dom-ready' // @ts-ignore import { extract, htmlToVdom } from '../util.ts' //@ts-ignore import '../theme.ts' interface Props { label?: string, menu?: object } interface Data { } @tag('m-select') export default class Select extends WeElement{ static css = css static propTypes = { label: String, menu: Object } installed() { if (this.props.menu) { const style = document.createElement('style') style.textContent = globalCss document.querySelector('head').appendChild(style) } const select = new MDCSelect(this.shadowRoot.querySelector('.mdc-select')); select.listen('MDCSelect:change', () => { this.fire('change', { selectedIndex: select.selectedIndex, value: select.value }) }); domReady(() => { this.update() }) } render(props) { if (props.menu) { return (
    {props.menu.map(item=>
  • {item.text}
  • )}
) } return (
) } }