'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import React, { useEffect } from 'react';
import { useField } from '../../forms/useField/index.js';
import { withCondition } from '../../forms/withCondition/index.js';
/**
 * Renders an input with `type="hidden"`.
 * 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 HiddenFieldComponent = (props)=>{
    const { disableModifyingForm = true, path: pathFromProps, value: valueFromProps } = props;
    const { formInitializing, path, setValue, value } = useField({
        potentiallyStalePath: pathFromProps
    });
    useEffect(()=>{
        if (valueFromProps !== undefined && !formInitializing) {
            setValue(valueFromProps, disableModifyingForm);
        }
    }, [
        valueFromProps,
        setValue,
        disableModifyingForm,
        formInitializing
    ]);
    return /*#__PURE__*/ _jsxDEV("input", {
        id: `field-${path?.replace(/\./g, '__')}`,
        name: path,
        onChange: setValue,
        type: "hidden",
        value: value || ''
    }, void 0, false, {
        fileName: "src/fields/Hidden/index.tsx",
        lineNumber: 29,
        columnNumber: 5
    }, this);
};
export const HiddenField = withCondition(HiddenFieldComponent);

//# sourceMappingURL=index.js.map