UNPKG

@ark-ui/vue

Version:

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

31 lines (30 loc) 999 B
import { DEFAULT_ENVIRONMENT, useEnvironmentContext } from "../../providers/environment/use-environment-context.js"; import { cleanProps } from "../../utils/clean-props.js"; import * as timer from "@zag-js/timer"; import { computed, toValue, useId } from "vue"; import { normalizeProps as normalizeProps$1, useMachine } from "@zag-js/vue"; //#region src/components/timer/use-timer.ts var useTimer = (props, emit) => { const id = useId(); const env = useEnvironmentContext(DEFAULT_ENVIRONMENT); const context = computed(() => { const localProps = toValue(props); return { id, getRootNode: env?.value.getRootNode, ...cleanProps(localProps), onComplete: () => { emit?.("complete"); localProps.onComplete?.(); }, onTick: (details) => { emit?.("tick", details); localProps.onTick?.(details); } }; }); const service = useMachine(timer.machine, context); return computed(() => timer.connect(service, normalizeProps$1)); }; //#endregion export { useTimer };