import { use } from '../utils'; import { PopupMixin } from '../mixins/popup'; import Icon from '../icon'; import Loading from '../loading'; import Popup from '../popup'; const [sfc, bem] = use('actionsheet'); export default sfc({ props: { ...PopupMixin.props, title: String, actions: Array, cancelText: String, overlay: { type: Boolean, default: true }, closeOnClickOverlay: { type: Boolean, default: true } }, methods: { onSelect(event, item) { event.stopPropagation(); if (!item.disabled && !item.loading) { if (item.callback) { item.callback(item); } this.$emit('select', item); } }, onCancel() { this.$emit('input', false); this.$emit('cancel'); } }, render(h) { const { title, cancelText, onCancel } = this; const Header = () => (
{title}
); const Option = item => (
{ this.onSelect(event, item); }} > {item.loading ? ( ) : ( [ {item.name}, item.subname && {item.subname} ] )}
); const Footer = cancelText ? (
{cancelText}
) : (
{this.slots()}
); return ( { this.$emit('input', value); }} > {title ? Header() : this.actions.map(Option)} {Footer} ); } });