From f2eb09526bad49362dc64417bf32f77591a26833 Mon Sep 17 00:00:00 2001 From: DerDorius <77979816+DerDorius@users.noreply.github.com> Date: Sun, 28 Aug 2022 12:09:08 +0200 Subject: [PATCH] DataTable/TreeTable: stricter generically typed API #2523 Added Generics for Dropdown. Generics have to be also added in: cascadeselect.d.ts listbox.d.ts multiselect.d.ts selectbutton.d.ts because of the SelectItemOptionsType --- components/lib/dropdown/dropdown.d.ts | 40 +++++++++++------------ components/lib/selectitem/selectitem.d.ts | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/components/lib/dropdown/dropdown.d.ts b/components/lib/dropdown/dropdown.d.ts index 42f72c1e37..6b28d76501 100755 --- a/components/lib/dropdown/dropdown.d.ts +++ b/components/lib/dropdown/dropdown.d.ts @@ -4,34 +4,34 @@ import { CSSTransitionProps } from '../csstransition'; import { VirtualScrollerProps } from '../virtualscroller'; import { SelectItemOptionsType } from '../selectitem/selectitem'; -type DropdownOptionGroupTemplateType = React.ReactNode | ((option: any, index: number) => React.ReactNode); +type DropdownOptionGroupTemplateType = React.ReactNode | ((option: TOption, index: number) => React.ReactNode); -type DropdownValueTemplateType = React.ReactNode | ((option: any, props: DropdownProps) => React.ReactNode); +type DropdownValueTemplateType = React.ReactNode | ((option: TOption, props: DropdownProps) => React.ReactNode); -type DropdownItemTemplateType = React.ReactNode | ((option: any) => React.ReactNode); +type DropdownItemTemplateType = React.ReactNode | ((option: TOption) => React.ReactNode); type DropdownFilterTemplateType = React.ReactNode | ((options: DropdownFilterOptions) => React.ReactNode); -type DropdownEmptyMessageType = React.ReactNode | ((props: DropdownProps) => React.ReactNode); +type DropdownEmptyMessageType = React.ReactNode | ((props: DropdownProps) => React.ReactNode); -type DropdownEmptyFilterMessageType = React.ReactNode | ((props: DropdownProps) => React.ReactNode); +type DropdownEmptyFilterMessageType = React.ReactNode | ((props: DropdownProps) => React.ReactNode); -type DropdownOptionDisabledType = string | ((option: any) => boolean); +type DropdownOptionDisabledType = string | ((option: TOption) => boolean); type DropdownAppendToType = 'self' | HTMLElement | undefined | null; -interface DropdownChangeTargetOptions { +interface DropdownChangeTargetOptions { name: string; id: string; - value: any; + value: TOption; } -interface DropdownChangeParams { +interface DropdownChangeParams { originalEvent: React.SyntheticEvent; value: any; stopPropagation(): void; preventDefault(): void; - target: DropdownChangeTargetOptions; + target: DropdownChangeTargetOptions; } interface DropdownFilterParams { @@ -44,21 +44,21 @@ interface DropdownFilterOptions { reset?: () => void; } -export interface DropdownProps extends Omit, HTMLDivElement>, 'onChange' | 'ref'> { +export interface DropdownProps extends Omit, HTMLDivElement>, 'onChange' | 'ref'> { id?: string; inputRef?: React.Ref; name?: string; value?: any; - options?: SelectItemOptionsType; + options?: SelectItemOptionsType; optionLabel?: string; optionValue?: string; - optionDisabled?: DropdownOptionDisabledType; + optionDisabled?: DropdownOptionDisabledType; optionGroupLabel?: string; optionGroupChildren?: string; - optionGroupTemplate?: DropdownOptionGroupTemplateType; - valueTemplate?: DropdownValueTemplateType; + optionGroupTemplate?: DropdownOptionGroupTemplateType; + valueTemplate?: DropdownValueTemplateType; filterTemplate?: DropdownFilterTemplateType; - itemTemplate?: DropdownItemTemplateType; + itemTemplate?: DropdownItemTemplateType; style?: object; className?: string; virtualScrollerOptions?: VirtualScrollerProps; @@ -68,8 +68,8 @@ export interface DropdownProps extends Omit; + emptyFilterMessage?: DropdownEmptyFilterMessageType; editable?: boolean; placeholder?: string; required?: boolean; @@ -93,7 +93,7 @@ export interface DropdownProps extends Omit): void; onFocus?(event: React.FocusEvent): void; onBlur?(event: React.FocusEvent): void; onMouseDown?(event: React.MouseEvent): void; @@ -104,7 +104,7 @@ export interface DropdownProps extends Omit { +export declare class Dropdown extends React.Component, any> { public getElement(): HTMLDivElement; public getInput(): HTMLInputElement; public getFocusInput(): HTMLInputElement; diff --git a/components/lib/selectitem/selectitem.d.ts b/components/lib/selectitem/selectitem.d.ts index 9d15f1de57..a47fe0ce9a 100644 --- a/components/lib/selectitem/selectitem.d.ts +++ b/components/lib/selectitem/selectitem.d.ts @@ -1,6 +1,6 @@ import { IconType } from '../utils'; -export type SelectItemOptionsType = SelectItem[] | any[]; +export type SelectItemOptionsType = SelectItem[] | TOption[]; export interface SelectItem { label?: string;