
package.dist.components.time-picker.use-time-picker.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of react Show documentation
Show all versions of react Show documentation
A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.
The newest version!
'use client';
import { useMachine, normalizeProps } from '@zag-js/react';
import * as timePicker from '@zag-js/time-picker';
import { useId } from 'react';
import { useEnvironmentContext } from '../../providers/environment/use-environment-context.js';
import { useLocaleContext } from '../../providers/locale/use-locale-context.js';
import { useEvent } from '../../utils/use-event.js';
const useTimePicker = (props = {}) => {
const { getRootNode } = useEnvironmentContext();
const { dir } = useLocaleContext();
const initialContext = {
id: useId(),
dir,
getRootNode,
open: props.defaultOpen,
"open.controlled": props.open !== void 0,
value: props.defaultValue,
...props
};
const context = {
...initialContext,
value: props.value,
onValueChange: useEvent(props.onValueChange),
onFocusChange: useEvent(props.onFocusChange),
onOpenChange: useEvent(props.onOpenChange)
};
const [state, send] = useMachine(timePicker.machine(initialContext), { context });
return timePicker.connect(state, send, normalizeProps);
};
export { useTimePicker };
© 2015 - 2025 Weber Informatics LLC | Privacy Policy