From b4af31496ad1d482bc11dcc1c846862b5ac74c30 Mon Sep 17 00:00:00 2001 From: Igor Danchenko <64441155+igordanchenko@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:28:26 -0400 Subject: [PATCH] feat: improve types usability --- src/types.ts | 124 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 97 insertions(+), 27 deletions(-) diff --git a/src/types.ts b/src/types.ts index 0a96578..aba3d74 100644 --- a/src/types.ts +++ b/src/types.ts @@ -44,7 +44,7 @@ export interface CommonPhotoAlbumProps { /** Default container width in SSR. */ defaultContainerWidth?: number; /** Photo click callback. */ - onClick?: (props: ClickHandlerProps) => void; + onClick?: ClickHandler; /** Custom render functions. */ render?: ResponsiveParameter>; /** Additional HTML attributes to be passed to the rendered elements. */ @@ -129,42 +129,55 @@ export type LayoutVariables = { [key: string]: string | number | undefined }; /** Responsive parameter */ export type ResponsiveParameter = Value | ((containerWidth: number) => Value); -/** Custom render functions */ -export type Render = { - /** Custom container render function. */ - container?: RenderFunction; - /** Custom track render function. */ - track?: RenderFunction; - /** Custom wrapper render function. */ - wrapper?: RenderFunction>; - /** Custom link render function. */ - link?: RenderFunction>; - /** Custom button render function. */ - button?: RenderFunction>; - /** Custom image render function. */ - image?: RenderFunction>; - /** Custom photo render function. */ - photo?: RenderFunction>; - /** Custom extra markup render function. */ - extras?: RenderFunction<{}, RenderPhotoContext>; -}; - /** Components props */ export type ComponentsProps = { /** Additional HTML attributes for the outer `
` container. */ - container?: React.ComponentPropsWithoutRef<"div">; + container?: ContainerComponentProps; /** Additional HTML attributes for the row / column `
` container. */ - track?: React.ComponentPropsWithoutRef<"div">; + track?: TrackComponentProps; /** Additional HTML attributes for the image `
` wrapper. */ - wrapper?: ContextAware, RenderWrapperContext>; + wrapper?: WrapperComponentProps; /** Additional HTML attributes for the photo `` link. */ - link?: ContextAware, RenderLinkContext>; + link?: LinkComponentProps; /** Additional HTML attributes for the photo `