'use client';
import React, { useEffect } from 'react';
import useField from '../../useField/index.js';
import { withCondition } from '../../withCondition/index.js';
/**
 * This is mainly used to save a value on the form that is not visible to the user.
 * For example, this sets the `ìd` property of a block in the Blocks field.
 */ const HiddenInput = (props)=>{
    const { name, disableModifyingForm = true, path: pathFromProps, value: valueFromProps } = props;
    const { path, setValue, value } = useField({
        path: pathFromProps || name
    });
    useEffect(()=>{
        if (valueFromProps !== undefined) {
            setValue(valueFromProps, disableModifyingForm);
        }
    }, [
        valueFromProps,
        setValue,
        disableModifyingForm
    ]);
    return /*#__PURE__*/ React.createElement("input", {
        id: `field-${path?.replace(/\./g, '__')}`,
        name: path,
        onChange: setValue,
        type: "hidden",
        value: value || ''
    });
};
export default withCondition(HiddenInput);

//# sourceMappingURL=index.js.map