"use client";
import { useRef } from "react";
import { useTextField } from "../form/useTextField.js";
/**
 * @since 6.3.0
 * @see {@link https://react-md.dev/components/native-date-field | NativeTimeField Demos}
 * @see {@link https://react-md.dev/hooks/use-date-field | useTimeField Demos}
 */ export function useDateField(options) {
    const { min, max, step, ...fieldOptions } = options;
    const { fieldProps, ...impl } = useTextField(fieldOptions);
    // NOTE: Unlike the other text field components, the `value` should **not**
    // be provided since the time input behaves a bit weirdly with the `onChange`
    // event and it is better to rely on default browser behavior instead of
    // controlling the value. The flow is:
    // - user types `12:30`
    //   - `onChange` is fired with `12:30`
    // - user selects `30` and hits backspace
    //   - `onChange` is fired with `""`
    // If the `value` is set, the other time values would be lost
    const { value, ...allowedFieldProps } = fieldProps;
    const initial = useRef(value);
    return {
        ...impl,
        fieldProps: {
            ...allowedFieldProps,
            defaultValue: initial.current,
            min,
            max,
            step,
            type: "date"
        }
    };
}

//# sourceMappingURL=useDateField.js.map