From 21e117df88ad9bae25d171c489d0deed607a3630 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 26 Mar 2024 15:07:35 +0000 Subject: [PATCH] Typescript: Add `DataTable.Responsive.bootstrap()` function to register bootstrap Typescript: Correct modal type for display rendering --- types/types.d.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/types/types.d.ts b/types/types.d.ts index 72b697c..0b430a5 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -73,9 +73,14 @@ declare module 'datatables.net' { breakpoints: ResponsiveBreakpoint[]; display: { - childRow: ResponsiveDisplay, - childRowImmediate: ResponsiveDisplay, - modal: ResponsiveDisplay, + /** Display details as a child row, when requested (click) */ + childRow: ResponsiveDisplay; + + /** Display details as a child row, immediately (no-click) */ + childRowImmediate: ResponsiveDisplay; + + /** Display details as a modal */ + modal: (options?: ResponsiveModalOptions) => ResponsiveDisplay; }; /** @@ -91,6 +96,13 @@ declare module 'datatables.net' { * Responsive version */ version: string; + + /** + * Set the Bootstrap library to use + * + * @param bs Bootstrap - from `import * as bootstrap from 'bootstrap';` + */ + bootstrap: (bs: any) => void; } } } @@ -159,7 +171,7 @@ interface ConfigResponsiveDetails { * @param render The data to be shown - this is given as a function so it will be executed only when required (i.e. there is no point in gather data to display if the display function is simply going to hide it). The string returned by this function is that given by the responsive.details.renderer function. It accepts no input parameters. * @returns boolean true if the display function has shown the hidden data, false */ - display?(row: ApiRow, update: boolean, render: () => string): boolean; + display?: ResponsiveDisplay; /** * Define the renderer used to display the child rows. @@ -219,6 +231,10 @@ interface ResponsiveDisplay { (row: Api, update: boolean, render: () => Node): boolean; } +interface ResponsiveModalOptions { + header?(row: any): string; +} + interface ResponsiveColumn { className: string; columnIndex: number;