import { tag, WeElement, h, extractClass, classNames } from 'omi' import * as css from './index.scss' import { MDCList } from '@material/list'; import { MDCRipple } from '@material/ripple'; import { domReady } from '../util/dom-ready' import { extract } from '../util/extract' //@ts-ignore import '../theme.ts' interface Props { items: object, singleSelection?: boolean checkbox?: boolean radio?: boolean checkboxLeft?: boolean radioLeft?: boolean width?: number height?: number onItemClick?: (evt: CustomEvent) => void } interface Data { } @tag('m-list') export default class List extends WeElement{ static css = css static propTypes = { items: Object, singleSelection: Boolean, checkbox: Boolean, radio: Boolean, checkboxLeft: Boolean, radioLeft: Boolean, width: Number, height: Number } static defaultProps = { } installed() { domReady(() => { //init mdc list const lists = this.shadowRoot.querySelectorAll('.mdc-list') lists.forEach((list, index) => { const listControl = new MDCList(list) listControl.listElements.map((listItemEl) => new MDCRipple(listItemEl)) listControl.singleSelection = this.props.singleSelection listControl.listen('MDCList:action', (evt: any) => { this.fire('itemclick', { item: this.props.items[evt.detail.index], index: evt.detail.index }) // if(this.listAll[index][evt.detail.index]) { // this.fire('change', this.listAll[index][evt.detail.index]) // } else { // this.fire('change', this.listAll[index+1][evt.detail.index]) // } }) }) }) } _renderCheckbox(props, item){ if(props.checkbox){ return
} } _renderRadio(props, item){ if(props.radio){ return
} } render(props) { const style:any = {} let hasStyle = false if(props.width){ hasStyle = true style.width = props.width + 'px' } if(props.height){ hasStyle = true style.height = props.height + 'px' } return } }