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