/* * Copyright (c) 2020 - present Cloudogu GmbH * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ import React, { ChangeEvent, FC, FocusEvent } from "react"; /** * @deprecated */ export type MinimumBaseProps = { name?: string; }; /** * @deprecated */ export type LegacyProps = Base & { onChange?: (value: ValueType, name?: string) => void; onBlur?: (value: ValueType, name?: string) => void; innerRef?: never; }; /** * @deprecated */ export type RefProps = Base & { onChange?: (event: ChangeEvent) => void; onBlur?: (event: FocusEvent) => void; }; /** * @deprecated */ export type InnerRefProps = RefProps< Base, ElementType > & { innerRef: React.ForwardedRef; }; /** * @deprecated */ export const isUsingRef = ( props: Partial>, ): props is InnerRefProps => { return (props as Partial>).innerRef !== undefined; }; /** * @deprecated */ export const isLegacy = ( props: FieldProps, ): props is LegacyProps => { return (props as Partial>).innerRef === undefined; }; /** * @deprecated */ export type FieldProps = | LegacyProps | InnerRefProps; /** * @deprecated */ export type OuterProps = RefProps & { ref: React.Ref; }; /** * @deprecated */ export type FieldType = { (props: OuterProps): React.ReactElement> | null; (props: LegacyProps): React.ReactElement> | null; }; /** * @deprecated */ export const createFormFieldWrapper = ( InnerType: FC>, ) => (props: LegacyProps | OuterProps) => { if ("ref" in props) { const { ref, ...rest } = props as OuterProps; return )} />; } return )} />; };