@cmk/fe_utils
Version:
frontend utility library
47 lines (45 loc) • 2.3 kB
TypeScript
import { CAutoCompleteProps } from './AutoComplete';
import { MultiSelectProps } from './MultiSelect';
import { CNumberFieldProps } from './NumberField';
import { CSelectProps } from './Select';
import { CTextFieldProps } from './TextField';
import { DatePickerProps } from './DatePicker';
import { TextAreaProps } from './_archiv/TextArea';
import { CheckboxProps } from './Checkbox';
import { InputFieldType, GenericInputFieldProps } from './types';
import { KeyboardEvent } from 'react';
import { JsonFieldProps } from './JsonField';
export type GenericInputFieldOption = {
label: string;
value: number | string | boolean;
};
export type StringValueOption = {
label: string;
value: string;
textLabel?: string;
};
export type SpecificInputProps<T extends InputFieldType> = T extends 'text' ? CTextFieldProps : T extends 'number' ? CNumberFieldProps : T extends 'int' ? CNumberFieldProps : T extends 'date' ? DatePickerProps : T extends 'select' ? CSelectProps : T extends 'multiselect' ? MultiSelectProps : T extends 'autocomplete' ? CAutoCompleteProps : T extends 'textarea' ? TextAreaProps : T extends 'bool' ? CheckboxProps : T extends 'json' ? JsonFieldProps : never;
export type GGenericInputFieldProps<T extends InputFieldType> = GenericInputFieldProps<T> & Omit<SpecificInputProps<T>, 'value' | 'onChange'> & {
type: T;
hidden?: boolean;
invisible?: boolean;
disableHelperTextTheming?: boolean;
files?: T extends 'file' ? {
[key: string]: {
file: File;
filename: string;
}[];
} : never;
onFileChange?: (name: string, files: File[]) => void;
onKeyDown?: (e: KeyboardEvent<HTMLInputElement>) => void;
onKeyUp?: (e: KeyboardEvent<HTMLInputElement>) => void;
};
/**
* Generic Input Field Component - provides a unified prop interface for different input types.
* The type property {@link InputFieldType} determines the rendered input type
* Prefer using the GenericForm Component directly
* @param props: {@link GenericInputFieldProps}
* @returns JSX.Element | null
* @todo implement Multiselect Component
*/
export declare const GenericInputField: <FieldType extends InputFieldType = InputFieldType>(props: GGenericInputFieldProps<FieldType>) => import("react/jsx-runtime").JSX.Element | null;