UNPKG

@wordpress/components

Version:
32 lines (31 loc) • 1.36 kB
import { forwardRef, useRef } from "@wordpress/element"; import { useMergeRefs } from "@wordpress/compose"; import deprecated from "@wordpress/deprecated"; import { ControlWithError } from "@wordpress/ui"; import InputControl from "../../input-control/index.mjs"; import { jsx } from "react/jsx-runtime"; // packages/components/src/validated-form-controls/components/input-control.tsx const UnforwardedValidatedInputControl = ({ required, customValidity, markWhenOptional, ...restProps }, forwardedRef) => { deprecated("wp.components.privateApis.ValidatedInputControl", { since: "7.2", alternative: "ValidatedInputControl from @wordpress/ui", hint: "This private API will be completely removed within a few Gutenberg plugin releases." }); const validityTargetRef = useRef(null); const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]); return /* @__PURE__ */ jsx(ControlWithError, { className: "components-validated-control", required, markWhenOptional, customValidity, getValidityTarget: () => validityTargetRef.current, children: /* @__PURE__ */ jsx(InputControl, { ref: mergedRefs, ...restProps }) }); }; const ValidatedInputControl = forwardRef(UnforwardedValidatedInputControl); ValidatedInputControl.displayName = "ValidatedInputControl"; export { ValidatedInputControl }; //# sourceMappingURL=input-control.mjs.map