From e17176838bd2b70b4c3a10f850e5ff5d274a509b Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 14 Feb 2023 13:36:32 +0000 Subject: [PATCH] fd4cd412a2c321607a90c2beaf0c9b5302e93c80 Fix: Allow other extensions to extend Typescript definitations for buttons 30575e1db8a1d327908215f9952ce8ab35e3101a Merge branch 'master' of github.com:DataTables/Buttons Sync to source repo @30575e1db8a1d327908215f9952ce8ab35e3101a --- datatables.json | 2 +- types/types.d.ts | 878 +++++++++++++++++++++++------------------------ 2 files changed, 440 insertions(+), 440 deletions(-) diff --git a/datatables.json b/datatables.json index 6dbe344..0bba178 100644 --- a/datatables.json +++ b/datatables.json @@ -15,5 +15,5 @@ ], "src-repo": "http://github.com/DataTables/Buttons", "last-tag": "2.3.4", - "last-sync": "19ac016a5d8afb9fd25572e61085ebe99ae1c757" + "last-sync": "30575e1db8a1d327908215f9952ce8ab35e3101a" } \ No newline at end of file diff --git a/types/types.d.ts b/types/types.d.ts index 0e2805a..5b9668c 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -69,544 +69,544 @@ declare module 'datatables.net' { interface ApiStaticExt { buttons: ExtButtons; } -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Options - */ -interface ConfigButtons { - name?: string; - tabIndex?: number; - buttons: Array; - dom?: ConfigButtonDom; -} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Options + */ -interface ConfigButtonsLanguage { - [key: string]: string | ConfigButtonsLanguage; -} + interface ConfigButtons { + name?: string; + tabIndex?: number; + buttons: Array; + dom?: ConfigButtonDom; + } + interface ConfigButtonsLanguage { + [key: string]: string | ConfigButtonsLanguage; + } -interface ApiButton { - (groupSelector?: number | string | Array, buttonSelector?: null | number | string | Node | JQuery | Array>): ApiButtonMethods; -} -interface ApiButtonMethods extends Api { - /** - * Get the action function for the selected button. - * - * @returns The action function for the selected button. - */ - action(): FunctionButtonAction; + interface ApiButton { + (groupSelector?: number | string | Array, buttonSelector?: null | number | string | Node | JQuery | Array>): ApiButtonMethods; + } - /** - * Set the action function for the selected button. - * - * @param set the function that is to be triggered on an action. - * @returns DataTables Api for chaining - */ - action(set: FunctionButtonAction): Api; + interface ApiButtonMethods extends Api { + /** + * Get the action function for the selected button. + * + * @returns The action function for the selected button. + */ + action(): FunctionButtonAction; - /** - * Get the active state for the selected button. - * - * @returns true if currently active, otherwise false. - */ - active(): boolean; + /** + * Set the action function for the selected button. + * + * @param set the function that is to be triggered on an action. + * @returns DataTables Api for chaining + */ + action(set: FunctionButtonAction): Api; - /** - * Set the active state for the selected button. - * - * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. - */ - active(state: boolean): Api; + /** + * Get the active state for the selected button. + * + * @returns true if currently active, otherwise false. + */ + active(): boolean; - /** - * Create a new button, adding it to the selected button instance and inserting immediately into the document. - * - * @returns New DataTables API instance with the result set containing the newly created button. This means it is possible to immediately using the chaining API to manipulate the button. - */ - add(index: number | string, config: string|FunctionButton|ButtonConfig): Api; + /** + * Set the active state for the selected button. + * + * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. + */ + active(state: boolean): Api; - /** - * Disable the selected buttons. - * - * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. - */ - disable(): Api; + /** + * Create a new button, adding it to the selected button instance and inserting immediately into the document. + * + * @returns New DataTables API instance with the result set containing the newly created button. This means it is possible to immediately using the chaining API to manipulate the button. + */ + add(index: number | string, config: string|FunctionButton|ButtonConfig): Api; - /** - * Set the enabled state for the selected button. - * - * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. - */ - enable(state?: boolean): Api; + /** + * Disable the selected buttons. + * + * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. + */ + disable(): Api; - /** - * Get a jQuery object that contains a reference to the node for the selected button. - * - * @returns A jQuery object that contains the node of the selected button - */ - node(): JQuery; + /** + * Set the enabled state for the selected button. + * + * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. + */ + enable(state?: boolean): Api; - /** - * Determine if a button is currently in the processing state or not. - * - * @returns true if the button is currently in its processing state, false otherwise. - */ - processing(): boolean; + /** + * Get a jQuery object that contains a reference to the node for the selected button. + * + * @returns A jQuery object that contains the node of the selected button + */ + node(): JQuery; - /** - * Set the processing state for the selected button. - * - * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons. - */ - processing(set: boolean): Api; + /** + * Determine if a button is currently in the processing state or not. + * + * @returns true if the button is currently in its processing state, false otherwise. + */ + processing(): boolean; - /** - * Remove the selected button from the display. The button is destroyed and can no longer be used once removed. - * - * @returns DataTables API instance. - */ - remove(): Api; + /** + * Set the processing state for the selected button. + * + * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons. + */ + processing(set: boolean): Api; - /** - * Get the display text for the selected button - * - * @returns The current display string from the button. - */ - text(): string; + /** + * Remove the selected button from the display. The button is destroyed and can no longer be used once removed. + * + * @returns DataTables API instance. + */ + remove(): Api; - /** - * Set the display text for the selected button - * - * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons. - */ - text(title: string | FunctionButtonText): Api; + /** + * Get the display text for the selected button + * + * @returns The current display string from the button. + */ + text(): string; - /** - * Programmatically trigger the action of the selected button. - * - * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. - */ - trigger(): Api; -} + /** + * Set the display text for the selected button + * + * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons. + */ + text(title: string | FunctionButtonText): Api; + /** + * Programmatically trigger the action of the selected button. + * + * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. + */ + trigger(): Api; + } -interface ApiButtons { - (groupSelector?: any, buttonSelector?: any): ApiButtonsMethods; - /** - * Display / hide an information message to the end user to indicate that something has happened. - * - * @returns DataTables API instance for chaining. - */ - info(title: string, message?: string, time?: number): Api; + interface ApiButtons { + (groupSelector?: any, buttonSelector?: any): ApiButtonsMethods; - /** - * Get meta information that is common to many different button types. - * - * @returns An object with properties which contain the filename, messageTop, messageBottom and title. - */ - exportInfo(options?: ButtonsApiExportInfoParameter): ButtonsApiExportInfoReturn; + /** + * Display / hide an information message to the end user to indicate that something has happened. + * + * @returns DataTables API instance for chaining. + */ + info(title: string, message?: string, time?: number): Api; - /** - * Obtain data from a DataTable that is suitable for exporting by saving into a file or copying to clipboard. - * - * @returns An object with 3 properties, one each for the data in the header, body and footer. - */ - exportData(options?: ButtonsApiExportDataParameter): ButtonsApiExportDataReturn; -} + /** + * Get meta information that is common to many different button types. + * + * @returns An object with properties which contain the filename, messageTop, messageBottom and title. + */ + exportInfo(options?: ButtonsApiExportInfoParameter): ButtonsApiExportInfoReturn; -interface ApiButtonsMethods extends Api { - /** - * Get the action function for the selected button. - * - * @returns DataTables API instance which contains the action functions for the selected buttons - */ - action(): Api>; + /** + * Obtain data from a DataTable that is suitable for exporting by saving into a file or copying to clipboard. + * + * @returns An object with 3 properties, one each for the data in the header, body and footer. + */ + exportData(options?: ButtonsApiExportDataParameter): ButtonsApiExportDataReturn; + } - /** - * Set the action function for the selected button. - * - * @param set the function that is to be triggered on an action. - * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. - */ - action(set: FunctionButtonAction): Api>; + interface ApiButtonsMethods extends Api { + /** + * Get the action function for the selected button. + * + * @returns DataTables API instance which contains the action functions for the selected buttons + */ + action(): Api>; - /** - * Get the active state for the selected button. - * - * @returns API instance which contains true if currently active, otherwise false for each selected button in the result set. - */ - active(): Api>; + /** + * Set the action function for the selected button. + * + * @param set the function that is to be triggered on an action. + * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. + */ + action(set: FunctionButtonAction): Api>; - /** - * Set the active state for the selected button. - * - * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. - */ - active(state: boolean): Api>; + /** + * Get the active state for the selected button. + * + * @returns API instance which contains true if currently active, otherwise false for each selected button in the result set. + */ + active(): Api>; - /** - * Get a jQuery instance that contains a reference to the button container instance. - */ - container(): JQuery; + /** + * Set the active state for the selected button. + * + * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. + */ + active(state: boolean): Api>; - /** - * Get a jQuery instance that contains a reference to the button container instances. - * - * @returns jQuery instance that contains the container elements for the selected button instances. - */ - containers(): JQuery; + /** + * Get a jQuery instance that contains a reference to the button container instance. + */ + container(): JQuery; - /** - * Destroy the selected button instances, removing the container and all button elements from the document. - * - * @returns DataTables API instance. - */ - destroy(): Api; + /** + * Get a jQuery instance that contains a reference to the button container instances. + * + * @returns jQuery instance that contains the container elements for the selected button instances. + */ + containers(): JQuery; - /** - * Disable the selected buttons. - * - * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. - */ - disable(): Api>; + /** + * Destroy the selected button instances, removing the container and all button elements from the document. + * + * @returns DataTables API instance. + */ + destroy(): Api; - /** - * Set the enabled state for the selected button. - * - * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. - */ - enable(state?: boolean): Api>; + /** + * Disable the selected buttons. + * + * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. + */ + disable(): Api>; - /** - * Get a jQuery object that contains a reference to the node for the selected button. - * - * @returns A jQuery object that contains the node of the selected button - */ - nodes(): JQuery; + /** + * Set the enabled state for the selected button. + * + * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. + */ + enable(state?: boolean): Api>; - /** - * Set the processing state for the selected button. - * - * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. - */ - processing(set: boolean): Api; + /** + * Get a jQuery object that contains a reference to the node for the selected button. + * + * @returns A jQuery object that contains the node of the selected button + */ + nodes(): JQuery; - /** - * Remove the selected button from the display. The button is destroyed and can no longer be used once removed. - * - * @returns DataTables API instance. - */ - remove(): Api; + /** + * Set the processing state for the selected button. + * + * @returns DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons. + */ + processing(set: boolean): Api; - /** - * Get the display text for the selected button - * - * @returns The current display string from the button. - */ - text(): string; + /** + * Remove the selected button from the display. The button is destroyed and can no longer be used once removed. + * + * @returns DataTables API instance. + */ + remove(): Api; - /** - * Set the display text for the selected button - * - * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons. - */ - text(title: string | FunctionButtonText): Api>; + /** + * Get the display text for the selected button + * + * @returns The current display string from the button. + */ + text(): string; - /** - * Programmatically trigger the action of the selected button. - * - * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. - */ - trigger(): Api>; -} + /** + * Set the display text for the selected button + * + * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the buttons. + */ + text(title: string | FunctionButtonText): Api>; + /** + * Programmatically trigger the action of the selected button. + * + * @returns DataTables API instance with the selected button in the result set, available for chaining further operations on the button. + */ + trigger(): Api>; + } -interface ButtonsApiExportInfoParameter { - extension?: string | (() => string); - filename?: string | (() => string); - messageBottom?: null | string | (() => string); - messageTop?: null | string | (() => string); - title?: null | string | (() => string); -} -interface ButtonsApiExportInfoReturn { - filename: string; - messageTop: string; - messageBottom: string; - title: string; -} + interface ButtonsApiExportInfoParameter { + extension?: string | (() => string); + filename?: string | (() => string); + messageBottom?: null | string | (() => string); + messageTop?: null | string | (() => string); + title?: null | string | (() => string); + } -interface ButtonsApiExportDataParameter { - rows?: any; - columns?: any; - modifier?: any; - orthogonal?: string; - stripHtml?: boolean; - stripNewlines?: boolean; - decodeEntities?: boolean; - trim?: boolean; - format?: any; -} + interface ButtonsApiExportInfoReturn { + filename: string; + messageTop: string; + messageBottom: string; + title: string; + } -interface ButtonsApiExportDataReturn { - header: string[]; - footer: string[]; - body: string[]; -} + interface ButtonsApiExportDataParameter { + rows?: any; + columns?: any; + modifier?: any; + orthogonal?: string; + stripHtml?: boolean; + stripNewlines?: boolean; + decodeEntities?: boolean; + trim?: boolean; + format?: any; + } -interface ConfigButtonDom { - button?: ButtonDomButton; - buttonContainer?: ButtonDomButtonEl; - buttonLiner?: ButtonDomButtonEl; - collection?: ButtonDomButtonEl; - container?: ButtonDomButtonEl; -} + interface ButtonsApiExportDataReturn { + header: string[]; + footer: string[]; + body: string[]; + } -interface ButtonDomButtonEl { - className?: string; - tag?: string; -} + interface ConfigButtonDom { + button?: ButtonDomButton; + buttonContainer?: ButtonDomButtonEl; + buttonLiner?: ButtonDomButtonEl; + collection?: ButtonDomButtonEl; + container?: ButtonDomButtonEl; + } -interface ButtonDomButton extends ButtonDomButtonEl { - active?: string; - disabled?: string; -} + interface ButtonDomButtonEl { + className?: string; + tag?: string; + } -interface ButtonConfigCommon { - /** - * Action to take when the button is activated - */ - action?: FunctionButtonAction; + interface ButtonDomButton extends ButtonDomButtonEl { + active?: string; + disabled?: string; + } - /** - * Ensure that any requirements have been satisfied before initialising a button - */ - available?: FunctionButtonAvailable; + interface ButtonConfigCommon { + /** + * Action to take when the button is activated + */ + action?: FunctionButtonAction; - /** - * Set the class name for the button - */ - className?: string; + /** + * Ensure that any requirements have been satisfied before initialising a button + */ + available?: FunctionButtonAvailable; - /** - * Function that is called when the button is destroyed - */ - destroy?: FunctionButtonInit; + /** + * Set the class name for the button + */ + className?: string; - /** - * Set a button's initial enabled state - */ - enabled?: boolean; + /** + * Function that is called when the button is destroyed + */ + destroy?: FunctionButtonInit; - /** - * Define which button type the button should be based on - */ - extend?: string; + /** + * Set a button's initial enabled state + */ + enabled?: boolean; - /** - * Initialisation function that can be used to add events specific to this button - */ - init?: FunctionButtonInit; + /** + * Define which button type the button should be based on + */ + extend?: string; - /** - * Define an activation key for a button - */ - key?: string | ButtonKey; + /** + * Initialisation function that can be used to add events specific to this button + */ + init?: FunctionButtonInit; - /** - * Set a name for each selection - */ - name?: string; + /** + * Define an activation key for a button + */ + key?: string | ButtonKey; - /** - * Unique namespace for every button - */ - namespace?: string; + /** + * Set a name for each selection + */ + name?: string; - /** - * The text to show in the button - */ - text?: string | FunctionButtonText; + /** + * Unique namespace for every button + */ + namespace?: string; - /** - * Button 'title' attribute text - */ - titleAttr?: string; -} + /** + * The text to show in the button + */ + text?: string | FunctionButtonText; -interface ButtonKey { - key?: string; - shiftKey?: boolean; - altKey?: boolean; - ctrlKey?: boolean; - metaKey?: boolean; -} + /** + * Button 'title' attribute text + */ + titleAttr?: string; + } -/** - * A function that will be executed upon creation of the buttons. - */ -type FunctionButton = (dt: Api) => ButtonConfigCommon; + interface ButtonKey { + key?: string; + shiftKey?: boolean; + altKey?: boolean; + ctrlKey?: boolean; + metaKey?: boolean; + } -type FunctionButtonText = (dt: Api, node: JQuery, config: any) => string; + /** + * A function that will be executed upon creation of the buttons. + */ + type FunctionButton = (dt: Api) => ButtonConfigCommon; -type FunctionButtonAvailable = (dt: Api, config: any) => boolean; + type FunctionButtonText = (dt: Api, node: JQuery, config: any) => string; -type FunctionButtonInit = (dt: Api, node: JQuery, config: any) => void; + type FunctionButtonAvailable = (dt: Api, config: any) => boolean; -type FunctionButtonAction = (e: any, dt: Api, node: JQuery, config: ButtonConfig) => void; + type FunctionButtonInit = (dt: Api, node: JQuery, config: any) => void; -type FunctionButtonCustomize = (win: Window|string) => void; + type FunctionButtonAction = (e: any, dt: Api, node: JQuery, config: ButtonConfig) => void; -type FunctionExtButtonsCollectionText = (a: any) => string; + type FunctionButtonCustomize = (win: Window|string) => void; -interface ExtButtons { - [name: string]: ButtonConfigCommon; + type FunctionExtButtonsCollectionText = (a: any) => string; - collection: ButtonCollection; -} + interface ExtButtons { + [name: string]: ButtonConfigCommon; -/** - * Collection button - */ -interface ButtonCollection { - action: FunctionButtonAction; - autoClose: boolean; - background: boolean; - backgroundClassName: string; - className: string; - collectionLayout: string; - fade: number; - text: FunctionExtButtonsCollectionText; -} + collection: ButtonCollection; + } -/** - * Buttons extension options - */ -interface ButtonConfig extends ButtonConfigCommon { /** - * CSV / EXCEL: Define what the exported filename should be + * Collection button */ - filename?: string; + interface ButtonCollection { + action: FunctionButtonAction; + autoClose: boolean; + background: boolean; + backgroundClassName: string; + className: string; + collectionLayout: string; + fade: number; + text: FunctionExtButtonsCollectionText; + } /** - * COPY / CSV: field separator + * Buttons extension options */ - fieldSeparator?: string; + interface ButtonConfig extends ButtonConfigCommon { + /** + * CSV / EXCEL: Define what the exported filename should be + */ + filename?: string; - /** - * COPY / CSV: field boundary - */ - fieldBoundary?: string; + /** + * COPY / CSV: field separator + */ + fieldSeparator?: string; - /** - * COPY / CSV: field separator - */ - newLine?: string; + /** + * COPY / CSV: field boundary + */ + fieldBoundary?: string; - /** - * CSV / EXCEL / PDF: file extension - */ - extension?: string; + /** + * COPY / CSV: field separator + */ + newLine?: string; - /** - * CSV: UTF-8 boom - */ - bom?: boolean; + /** + * CSV / EXCEL / PDF: file extension + */ + extension?: string; - /** - * CSV: charset - */ - charset?: string|boolean; + /** + * CSV: UTF-8 boom + */ + bom?: boolean; - /** - * CSV: escape char - */ - escapeChar?: string; + /** + * CSV: charset + */ + charset?: string|boolean; - /** - * EXCEL - */ - customizeData?: FunctionButtonCustomizeData; + /** + * CSV: escape char + */ + escapeChar?: string; - /** - * PDF: portrait / landscape - */ - orientation?: string; + /** + * EXCEL + */ + customizeData?: FunctionButtonCustomizeData; - /** - * PDF: A3 / A4 / A5 / LEGAL / LETTER / TABLOID - */ - pageSize?: string; + /** + * PDF: portrait / landscape + */ + orientation?: string; - /** - * COPY / CSV / EXCEL / PDF / PRINT: show header - */ - exportOptions?: ButtonExportOptions | object; + /** + * PDF: A3 / A4 / A5 / LEGAL / LETTER / TABLOID + */ + pageSize?: string; - /** - * COPY / CSV / EXCEL / PDF / PRINT: show header - */ - customize?: FunctionButtonCustomize; + /** + * COPY / CSV / EXCEL / PDF / PRINT: show header + */ + exportOptions?: ButtonExportOptions | object; - /** - * COPY / CSV / EXCEL / PDF / PRINT: show header - */ - header?: boolean; + /** + * COPY / CSV / EXCEL / PDF / PRINT: show header + */ + customize?: FunctionButtonCustomize; - /** - * COPY / CSV / EXCEL / PDF / PRINT: show footer - */ - footer?: boolean; + /** + * COPY / CSV / EXCEL / PDF / PRINT: show header + */ + header?: boolean; - /** - * COPY / PRINT: title - */ - title?: string; + /** + * COPY / CSV / EXCEL / PDF / PRINT: show footer + */ + footer?: boolean; - /** - * COPY / EXCEL / PDF / PRINT: field separator - */ - messageTop?: string; + /** + * COPY / PRINT: title + */ + title?: string; - /** - * COPY / EXCEL / PDF / PRINT: field separator - */ - messageBottom?: string; + /** + * COPY / EXCEL / PDF / PRINT: field separator + */ + messageTop?: string; - /** - * PDF / PRINT: Extra message - */ - message?: string|Api|JQuery|object; + /** + * COPY / EXCEL / PDF / PRINT: field separator + */ + messageBottom?: string; - /** - * PRINT: Show print dialoge on click - */ - autoPrint?: boolean; + /** + * PDF / PRINT: Extra message + */ + message?: string|Api|JQuery|object; - /** - * COLVIS: Column selector - */ - columns?: any; + /** + * PRINT: Show print dialoge on click + */ + autoPrint?: boolean; - /** - * COLVIS: - */ - columnText?: FunctionButtonColvisColumnText; -} + /** + * COLVIS: Column selector + */ + columns?: any; -type ButtonSelectorTypes = string | number | JQuery; -interface ButtonExportOptions { - columns?: ButtonSelectorTypes | ButtonSelectorTypes[]; -} + /** + * COLVIS: + */ + columnText?: FunctionButtonColvisColumnText; + } -type FunctionButtonCustomizeData = (content: any) => void; + type ButtonSelectorTypes = string | number | JQuery; + interface ButtonExportOptions { + columns?: ButtonSelectorTypes | ButtonSelectorTypes[]; + } -type FunctionButtonColvisColumnText = (dt: Api, i: number, title: string) => string; + type FunctionButtonCustomizeData = (content: any) => void; + + type FunctionButtonColvisColumnText = (dt: Api, i: number, title: string) => string; +}