UNPKG

@ark-ui/vue

Version:

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

50 lines (49 loc) 1.72 kB
import { DEFAULT_ENVIRONMENT, useEnvironmentContext } from "../../providers/environment/use-environment-context.js"; import { DEFAULT_LOCALE, useLocaleContext } from "../../providers/locale/use-locale-context.js"; import { cleanProps } from "../../utils/clean-props.js"; import * as tour from "@zag-js/tour"; import { computed, toValue, useId } from "vue"; import { normalizeProps as normalizeProps$1, useMachine } from "@zag-js/vue"; //#region src/components/tour/use-tour.ts var useTour = (props = {}, emit) => { const id = useId(); const env = useEnvironmentContext(DEFAULT_ENVIRONMENT); const locale = useLocaleContext(DEFAULT_LOCALE); const context = computed(() => { const localProps = toValue(props); return { id, dir: locale.value.dir, getRootNode: env?.value.getRootNode, ...cleanProps(localProps), onFocusOutside: (details) => { emit?.("focusOutside", details); localProps.onFocusOutside?.(details); }, onInteractOutside: (details) => { emit?.("interactOutside", details); localProps.onInteractOutside?.(details); }, onPointerDownOutside: (details) => { emit?.("pointerDownOutside", details); localProps.onPointerDownOutside?.(details); }, onStatusChange: (details) => { emit?.("statusChange", details); localProps.onStatusChange?.(details); }, onStepChange: (details) => { emit?.("stepChange", details); localProps.onStepChange?.(details); }, onStepsChange(details) { emit?.("stepsChange", details); localProps.onStepsChange?.(details); } }; }); const service = useMachine(tour.machine, context); return computed(() => tour.connect(service, normalizeProps$1)); }; //#endregion export { useTour };