UNPKG

ano-ui

Version:

<p align="center"> <img src="https://github.com/ano-ui/ano-ui/raw/main/public/logo.svg" style="width:100px;" /> <h1 align="center">Ano-UI (WIP)</h1> <p align="center">An UniApp UI components with UnoCSS.</p> </p> <p align="center"> <a href="https://www.np

31 lines (26 loc) 783 B
import type { SetupContext } from 'vue' import { computed, ref } from 'vue' import { CANCEL_EVENT, CLOSE_EVENT, OPEN_EVENT, UPDATE_SHOW_EVENT } from '../constants' import type { ActionSheetEmits, ActionSheetProps } from './action-sheet' export function useActionSheet(props: ActionSheetProps, emit: SetupContext<ActionSheetEmits>['emit']) { const show = ref(props.show || false) const showValue = computed<ActionSheetProps['show']>({ get: () => props.show || show.value, set(val) { if (val) emit(OPEN_EVENT) else emit(CLOSE_EVENT) show.value = val emit(UPDATE_SHOW_EVENT, val) }, }) const cancelHandler = () => { showValue.value = false emit(CANCEL_EVENT) } return { showValue, cancelHandler, } }