All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.components.progress.use-progress.js Maven / Gradle / Ivy

'use client';
import * as progress from '@zag-js/progress';
import { useMachine, normalizeProps } from '@zag-js/react';
import { useId } from 'react';
import { useEnvironmentContext } from '../../providers/environment/use-environment-context.js';
import { useLocaleContext } from '../../providers/locale/use-locale-context.js';

const useProgress = (props = {}) => {
  const { getRootNode } = useEnvironmentContext();
  const { dir } = useLocaleContext();
  const initialContext = {
    id: useId(),
    dir,
    getRootNode,
    ...props
  };
  const context = {
    ...initialContext,
    value: props.value
  };
  const [state, send] = useMachine(progress.machine(initialContext), { context });
  return progress.connect(state, send, normalizeProps);
};

export { useProgress };




© 2015 - 2025 Weber Informatics LLC | Privacy Policy