stream-chat-react
Version:
React components to create chat conversations or livestream style chat
25 lines (24 loc) • 1.06 kB
TypeScript
import type { ComponentProps } from 'react';
import React from 'react';
type FormElements = 'input' | 'textarea';
type FieldId = string;
type Validator = (value: string | readonly string[] | number | boolean | undefined) => Error | undefined;
export type FieldConfig = {
element: FormElements;
props: ComponentProps<FormElements>;
label?: React.ReactNode;
validator?: Validator;
};
type TextInputFormProps<F extends FormValue<Record<FieldId, FieldConfig>>> = {
close: () => void;
fields: Record<FieldId, FieldConfig>;
onSubmit: (formValue: F) => Promise<void>;
className?: string;
shouldDisableSubmitButton?: (formValue: F) => boolean;
title?: string;
};
type FormValue<F extends Record<FieldId, FieldConfig>> = {
[K in keyof F]: F[K]['props']['value'];
};
export declare const FormDialog: <F extends FormValue<Record<string, FieldConfig>> = FormValue<Record<string, FieldConfig>>>({ className, close, fields, onSubmit, shouldDisableSubmitButton, title, }: TextInputFormProps<F>) => React.JSX.Element;
export {};