UNPKG

@ark-ui/vue

Version:

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

46 lines (45 loc) 1.67 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 imageCropper from "@zag-js/image-cropper"; import { computed, toValue, useId } from "vue"; import { normalizeProps as normalizeProps$1, useMachine } from "@zag-js/vue"; //#region src/components/image-cropper/use-image-cropper.ts var useImageCropper = (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), onZoomChange(details) { emit?.("zoomChange", details); emit?.("update:zoom", details.zoom); localProps.onZoomChange?.(details); }, onRotationChange(details) { emit?.("rotationChange", details); emit?.("update:rotation", details.rotation); localProps.onRotationChange?.(details); }, onFlipChange(details) { emit?.("flipChange", details); emit?.("update:flip", details.flip); localProps.onFlipChange?.(details); }, onCropChange(details) { emit?.("cropChange", details); emit?.("update:crop", details.crop); localProps.onCropChange?.(details); } }; }); const service = useMachine(imageCropper.machine, context); return computed(() => imageCropper.connect(service, normalizeProps$1)); }; //#endregion export { useImageCropper };