UNPKG

@ark-ui/vue

Version:

A collection of unstyled, accessible UI components for Vue, utilizing state machines for seamless interaction.

23 lines (22 loc) 740 B
import { cleanProps } from "../../utils/clean-props.js"; import { computed, toValue } from "vue"; import { normalizeProps as normalizeProps$1, useMachine } from "@zag-js/vue"; import * as toggle from "@zag-js/toggle"; //#region src/components/toggle/use-toggle.ts function useToggle(props, emit) { const machineProps = computed(() => { const localProps = toValue(props); return { ...cleanProps(localProps), onPressedChange: (value) => { emit?.("pressedChange", value); emit?.("update:pressed", value); localProps.onPressedChange?.(value); } }; }); const service = useMachine(toggle.machine, machineProps); return computed(() => toggle.connect(service, normalizeProps$1)); } //#endregion export { useToggle };