import { ComponentType } from "react"; import PropTypes from "prop-types"; import IElementConfig from "../../Models/IElementConfig"; interface WithControlledVisibilityProps { elementConfig?: IElementConfig; } /** * Higher-order component that hides element, depending on whether * element is available inside either "hidden" or "shown" lists passed * as prop */ export default
(WrappedComponent: ComponentType
) => {
function WithControlledVisibility({
elementConfig,
...props
}: P & WithControlledVisibilityProps) {
const isVisible = elementConfig ? elementConfig.visible : true;
return isVisible ?