Add AnyComponentTypeWithChildren

This commit is contained in:
Nuckyz 2024-09-18 14:26:50 -03:00
parent 4722851172
commit a493d56487
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
2 changed files with 14 additions and 15 deletions

3
src/globals.d.ts vendored
View file

@ -20,7 +20,8 @@ import { LoDashStatic } from "lodash";
declare global {
type AnyRecord = Record<PropertyKey, any>;
type AnyComponentType<P extends AnyRecord> = React.ComponentType<P> & AnyRecord;
type AnyComponentType<P extends AnyRecord> = React.ComponentType<P & AnyRecord> & AnyRecord;
type AnyComponentTypeWithChildren<P extends AnyRecord> = React.ComponentType<React.PropsWithChildren<P> & AnyRecord> & AnyRecord;
/**
* This exists only at build time, so references to it in patches should insert it

View file

@ -16,12 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import type { ComponentType, CSSProperties, MouseEvent, PropsWithChildren, ReactNode, UIEvent } from "react";
type RC<C> = ComponentType<PropsWithChildren<C & AnyRecord>>;
import type { CSSProperties, MouseEvent, ReactNode, UIEvent } from "react";
export interface Menu {
Menu: RC<{
Menu: AnyComponentTypeWithChildren<{
navId: string;
onClose(): void;
className?: string;
@ -29,31 +27,31 @@ export interface Menu {
hideScroller?: boolean;
onSelect?(): void;
}>;
MenuSeparator: ComponentType;
MenuGroup: RC<{
MenuSeparator: AnyComponentType;
MenuGroup: AnyComponentTypeWithChildren<{
label?: string;
}>;
MenuItem: RC<{
MenuItem: AnyComponentTypeWithChildren<{
id: string;
label: ReactNode;
action?(e: MouseEvent): void;
icon?: ComponentType<any>;
icon?: AnyComponentType<any>;
color?: string;
render?: ComponentType<any>;
render?: AnyComponentType<any>;
onChildrenScroll?: Function;
childRowHeight?: number;
listClassName?: string;
disabled?: boolean;
}>;
MenuCheckboxItem: RC<{
MenuCheckboxItem: AnyComponentTypeWithChildren<{
id: string;
label: string;
checked: boolean;
action?(e: MouseEvent): void;
disabled?: boolean;
}>;
MenuRadioItem: RC<{
MenuRadioItem: AnyComponentTypeWithChildren<{
id: string;
group: string;
label: string;
@ -61,18 +59,18 @@ export interface Menu {
action?(e: MouseEvent): void;
disabled?: boolean;
}>;
MenuControlItem: RC<{
MenuControlItem: AnyComponentTypeWithChildren<{
id: string;
interactive?: boolean;
}>;
MenuSliderControl: RC<{
MenuSliderControl: AnyComponentTypeWithChildren<{
minValue: number,
maxValue: number,
value: number,
onChange(value: number): void,
renderValue?(value: number): string,
}>;
MenuSearchControl: RC<{
MenuSearchControl: AnyComponentTypeWithChildren<{
query: string;
onChange(query: string): void;
placeholder?: string;